@edusight/notification-widget 1.0.35 → 1.0.36

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,1603 @@
1
+ import T, { Component as me, useState as z, useRef as O, useEffect as K, useCallback as I, useMemo as ie } from "react";
2
+ import { jsxs as i, jsx as t, Fragment as B } from "react/jsx-runtime";
3
+ var se = {
4
+ color: void 0,
5
+ size: void 0,
6
+ className: void 0,
7
+ style: void 0,
8
+ attr: void 0
9
+ }, J = T.createContext && /* @__PURE__ */ T.createContext(se), ge = ["attr", "size", "title"];
10
+ function fe(e, r) {
11
+ if (e == null) return {};
12
+ var a = pe(e, r), n, s;
13
+ if (Object.getOwnPropertySymbols) {
14
+ var l = Object.getOwnPropertySymbols(e);
15
+ for (s = 0; s < l.length; s++)
16
+ n = l[s], !(r.indexOf(n) >= 0) && Object.prototype.propertyIsEnumerable.call(e, n) && (a[n] = e[n]);
17
+ }
18
+ return a;
19
+ }
20
+ function pe(e, r) {
21
+ if (e == null) return {};
22
+ var a = {};
23
+ for (var n in e)
24
+ if (Object.prototype.hasOwnProperty.call(e, n)) {
25
+ if (r.indexOf(n) >= 0) continue;
26
+ a[n] = e[n];
27
+ }
28
+ return a;
29
+ }
30
+ function P() {
31
+ return P = Object.assign ? Object.assign.bind() : function(e) {
32
+ for (var r = 1; r < arguments.length; r++) {
33
+ var a = arguments[r];
34
+ for (var n in a)
35
+ Object.prototype.hasOwnProperty.call(a, n) && (e[n] = a[n]);
36
+ }
37
+ return e;
38
+ }, P.apply(this, arguments);
39
+ }
40
+ function Q(e, r) {
41
+ var a = Object.keys(e);
42
+ if (Object.getOwnPropertySymbols) {
43
+ var n = Object.getOwnPropertySymbols(e);
44
+ r && (n = n.filter(function(s) {
45
+ return Object.getOwnPropertyDescriptor(e, s).enumerable;
46
+ })), a.push.apply(a, n);
47
+ }
48
+ return a;
49
+ }
50
+ function R(e) {
51
+ for (var r = 1; r < arguments.length; r++) {
52
+ var a = arguments[r] != null ? arguments[r] : {};
53
+ r % 2 ? Q(Object(a), !0).forEach(function(n) {
54
+ ve(e, n, a[n]);
55
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(a)) : Q(Object(a)).forEach(function(n) {
56
+ Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(a, n));
57
+ });
58
+ }
59
+ return e;
60
+ }
61
+ function ve(e, r, a) {
62
+ return r = be(r), r in e ? Object.defineProperty(e, r, { value: a, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = a, e;
63
+ }
64
+ function be(e) {
65
+ var r = xe(e, "string");
66
+ return typeof r == "symbol" ? r : r + "";
67
+ }
68
+ function xe(e, r) {
69
+ if (typeof e != "object" || !e) return e;
70
+ var a = e[Symbol.toPrimitive];
71
+ if (a !== void 0) {
72
+ var n = a.call(e, r);
73
+ if (typeof n != "object") return n;
74
+ throw new TypeError("@@toPrimitive must return a primitive value.");
75
+ }
76
+ return (r === "string" ? String : Number)(e);
77
+ }
78
+ function le(e) {
79
+ return e && e.map((r, a) => /* @__PURE__ */ T.createElement(r.tag, R({
80
+ key: a
81
+ }, r.attr), le(r.child)));
82
+ }
83
+ function w(e) {
84
+ return (r) => /* @__PURE__ */ T.createElement(we, P({
85
+ attr: R({}, e.attr)
86
+ }, r), le(e.child));
87
+ }
88
+ function we(e) {
89
+ var r = (a) => {
90
+ var {
91
+ attr: n,
92
+ size: s,
93
+ title: l
94
+ } = e, u = fe(e, ge), h = s || a.size || "1em", d;
95
+ return a.className && (d = a.className), e.className && (d = (d ? d + " " : "") + e.className), /* @__PURE__ */ T.createElement("svg", P({
96
+ stroke: "currentColor",
97
+ fill: "currentColor",
98
+ strokeWidth: "0"
99
+ }, a.attr, n, u, {
100
+ className: d,
101
+ style: R(R({
102
+ color: e.color || a.color
103
+ }, a.style), e.style),
104
+ height: h,
105
+ width: h,
106
+ xmlns: "http://www.w3.org/2000/svg"
107
+ }), l && /* @__PURE__ */ T.createElement("title", null, l), e.children);
108
+ };
109
+ return J !== void 0 ? /* @__PURE__ */ T.createElement(J.Consumer, null, (a) => r(a)) : r(se);
110
+ }
111
+ function ye(e) {
112
+ return w({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M257 120.471c7.083 0 23.911 4.479 23.911 4.479 45.589 10.447 77.678 52.439 77.678 99.85V352.412l9.321 9.364 7.788 7.823H136.302l7.788-7.823 9.321-9.364V224.8c0-47.41 32.089-89.403 77.678-99.85 0 0 18.043-4.479 23.911-4.479M256 48c-17.602 0-31.059 13.518-31.059 31.2v14.559c-59.015 13.523-103.53 67.601-103.53 131.041v114.4L80 380.8v20.8h352v-20.8l-41.411-41.6V224.8c0-63.44-44.516-117.518-103.53-131.041V79.2c0-17.682-13.457-31.2-31.059-31.2zm41.411 374.4h-82.823c0 22.881 18.633 41.6 41.412 41.6s41.411-18.719 41.411-41.6z" }, child: [] }] })(e);
113
+ }
114
+ const Ge = ({
115
+ unreadCount: e,
116
+ onClick: r,
117
+ className: a = "",
118
+ disabled: n = !1
119
+ }) => {
120
+ const s = (d) => d === 0 ? "" : d > 99 ? "99+" : d.toString(), l = (d) => {
121
+ n || (d.key === "Enter" || d.key === " ") && (d.preventDefault(), r());
122
+ }, u = s(e), h = e > 0;
123
+ return /* @__PURE__ */ i(
124
+ "button",
125
+ {
126
+ type: "button",
127
+ className: `
128
+ relative inline-flex items-center justify-center
129
+ rounded-full
130
+ text-[var(--widget-text-secondary)] hover:text-[var(--widget-text)]
131
+ bg-transparent hover:bg-[var(--widget-bg-hover)]
132
+ border-0 cursor-pointer
133
+ transition-colors duration-300
134
+ focus:outline-none focus:ring-1 focus:ring-[var(--widget-primary)] focus:ring-offset-1
135
+ disabled:opacity-70 disabled:cursor-not-allowed
136
+ w-10 h-10
137
+ mx-widget-bell
138
+ ${a}
139
+ `,
140
+ onClick: r,
141
+ onKeyDown: l,
142
+ disabled: n,
143
+ "aria-label": h ? `Notifications (${e} unread)` : "Notifications",
144
+ "aria-expanded": !1,
145
+ "aria-haspopup": "dialog",
146
+ "data-testid": "bell-component",
147
+ "data-mx-widget": "bell",
148
+ children: [
149
+ /* @__PURE__ */ i("div", { className: "relative inline-flex items-center justify-center text-align-center", children: [
150
+ /* @__PURE__ */ t(ye, { className: "w-6 h-6" }),
151
+ h && /* @__PURE__ */ t(
152
+ "span",
153
+ {
154
+ className: `
155
+ absolute
156
+ flex items-center justify-center
157
+ w-[16px] h-[16px]
158
+ text-[10px] font-bold leading-none
159
+ text-[var(--widget-text)] bg-red-500
160
+ rounded-full
161
+ border border-white dark:border-gray-900
162
+ shadow-sm
163
+ pointer-events-none
164
+ text-align-center
165
+ `,
166
+ "aria-hidden": "true",
167
+ "data-testid": "unread-badge",
168
+ style: { marginTop: "-25px", marginRight: "-25px" },
169
+ children: u
170
+ }
171
+ )
172
+ ] }),
173
+ /* @__PURE__ */ t("span", { className: "sr-only", children: h ? `${e} unread notifications` : "No unread notifications" })
174
+ ]
175
+ }
176
+ );
177
+ };
178
+ class X extends me {
179
+ constructor(r) {
180
+ super(r), this.state = {
181
+ hasError: !1,
182
+ error: null
183
+ };
184
+ }
185
+ static getDerivedStateFromError(r) {
186
+ return {
187
+ hasError: !0,
188
+ error: r
189
+ };
190
+ }
191
+ componentDidCatch(r, a) {
192
+ const { componentName: n = "Unknown Component", onError: s } = this.props;
193
+ s && s(r, a);
194
+ }
195
+ render() {
196
+ return this.state.hasError ? this.props.fallback ? this.props.fallback : /* @__PURE__ */ t(
197
+ "div",
198
+ {
199
+ className: "p-2 text-sm text-gray-500 bg-gray-50 border border-gray-200 rounded",
200
+ "data-testid": "component-error-fallback",
201
+ children: /* @__PURE__ */ i("span", { children: [
202
+ "Unable to load ",
203
+ this.props.componentName || "component"
204
+ ] })
205
+ }
206
+ ) : this.props.children;
207
+ }
208
+ }
209
+ function q(e) {
210
+ return w({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" }, child: [] }] })(e);
211
+ }
212
+ function Ne(e) {
213
+ return w({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z" }, child: [] }] })(e);
214
+ }
215
+ function ke(e) {
216
+ return w({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z" }, child: [] }, { tag: "path", attr: { d: "M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z" }, child: [] }] })(e);
217
+ }
218
+ function Ce(e) {
219
+ return w({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" }, child: [] }] })(e);
220
+ }
221
+ function oe(e) {
222
+ return w({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0V0z" }, child: [] }, { tag: "path", attr: { d: "M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58a.49.49 0 0 0 .12-.61l-1.92-3.32a.488.488 0 0 0-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54a.484.484 0 0 0-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58a.49.49 0 0 0-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z" }, child: [] }] })(e);
223
+ }
224
+ function Ye(e) {
225
+ return w({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z" }, child: [] }] })(e);
226
+ }
227
+ function Me(e) {
228
+ return w({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z" }, child: [] }] })(e);
229
+ }
230
+ function ze(e) {
231
+ return w({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4-8 5-8-5V6l8 5 8-5v2z" }, child: [] }] })(e);
232
+ }
233
+ function de(e) {
234
+ return w({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "m20.54 5.23-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.48-.17-.93-.46-1.27zM12 17.5 6.5 12H10v-2h4v2h3.5L12 17.5zM5.12 5l.81-1h12l.94 1H5.12z" }, child: [] }] })(e);
235
+ }
236
+ function je(e) {
237
+ return w({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z" }, child: [] }, { tag: "path", attr: { d: "M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z" }, child: [] }] })(e);
238
+ }
239
+ function Se(e) {
240
+ return w({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "M17 1.01 7 1c-1.1 0-2 .9-2 2v18c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V3c0-1.1-.9-1.99-2-1.99zM17 19H7V5h10v14z" }, child: [] }] })(e);
241
+ }
242
+ function He(e) {
243
+ return w({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "m21.41 11.58-9-9C12.05 2.22 11.55 2 11 2H4c-1.1 0-2 .9-2 2v7c0 .55.22 1.05.59 1.42l9 9c.36.36.86.58 1.41.58.55 0 1.05-.22 1.41-.59l7-7c.37-.36.59-.86.59-1.41 0-.55-.23-1.06-.59-1.42zM5.5 7C4.67 7 4 6.33 4 5.5S4.67 4 5.5 4 7 4.67 7 5.5 6.33 7 5.5 7z" }, child: [] }] })(e);
244
+ }
245
+ function Te(e) {
246
+ return w({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" }, child: [] }] })(e);
247
+ }
248
+ function ce(e) {
249
+ return w({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }, child: [] }] })(e);
250
+ }
251
+ function Z(e) {
252
+ return w({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "m12 8-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z" }, child: [] }] })(e);
253
+ }
254
+ function F(e) {
255
+ return w({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z" }, child: [] }] })(e);
256
+ }
257
+ function Je(e) {
258
+ return w({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "M17.65 6.35A7.958 7.958 0 0 0 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08A5.99 5.99 0 0 1 12 18c-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z" }, child: [] }] })(e);
259
+ }
260
+ function Ee(e) {
261
+ return w({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM9 11H7V9h2v2zm4 0h-2V9h2v2zm4 0h-2V9h2v2z" }, child: [] }] })(e);
262
+ }
263
+ function ee(e) {
264
+ return w({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M12 22c1.1 0 2-.9 2-2h-4a2 2 0 0 0 2 2zm6-6v-5c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2z" }, child: [] }] })(e);
265
+ }
266
+ function Ie(e) {
267
+ return w({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z" }, child: [] }, { tag: "path", attr: { d: "M14 17H7v-2h7v2zm3-4H7v-2h10v2zm0-4H7V7h10v2z" }, child: [] }] })(e);
268
+ }
269
+ function ue(e) {
270
+ return w({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0V0z" }, child: [] }, { tag: "path", attr: { d: "M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 14H4V8l8 5 8-5v10zm-8-7L4 6h16l-8 5z" }, child: [] }] })(e);
271
+ }
272
+ const Ae = ({ onRetry: e, error: r }) => /* @__PURE__ */ i("div", { className: "p-3 text-center", "data-testid": "notifications-fallback", children: [
273
+ /* @__PURE__ */ t("div", { className: "text-[var(--widget-text-tertiary)] mb-2", children: /* @__PURE__ */ t(q, { className: "w-12 h-12 mx-auto" }) }),
274
+ /* @__PURE__ */ t("p", { className: "text-sm text-[var(--widget-text-secondary)] mb-3", children: r ? "Failed to load notifications" : "No notifications available" }),
275
+ e && /* @__PURE__ */ t(
276
+ "button",
277
+ {
278
+ type: "button",
279
+ className: "text-sm text-[var(--widget-primary)] hover:text-[var(--widget-primary-hover)] font-medium transition-colors",
280
+ onClick: e,
281
+ children: "Try again"
282
+ }
283
+ )
284
+ ] }), te = ({ onRetry: e, onBack: r }) => /* @__PURE__ */ i("div", { className: "p-3 text-center", "data-testid": "preferences-fallback", children: [
285
+ /* @__PURE__ */ t("div", { className: "text-[var(--widget-text-tertiary)] mb-2", children: /* @__PURE__ */ t(oe, { className: "w-12 h-12 mx-auto" }) }),
286
+ /* @__PURE__ */ t("p", { className: "text-sm text-[var(--widget-text-secondary)] mb-3", children: "Unable to load preferences" }),
287
+ /* @__PURE__ */ i("div", { className: "space-x-2", children: [
288
+ e && /* @__PURE__ */ t(
289
+ "button",
290
+ {
291
+ type: "button",
292
+ className: "text-sm text-[var(--widget-primary)] hover:text-[var(--widget-primary-hover)] font-medium transition-colors",
293
+ onClick: e,
294
+ children: "Try again"
295
+ }
296
+ ),
297
+ r && /* @__PURE__ */ t(
298
+ "button",
299
+ {
300
+ type: "button",
301
+ className: "text-sm text-[var(--widget-text-secondary)] hover:text-[var(--widget-text)] font-medium transition-colors",
302
+ onClick: r,
303
+ children: "Back"
304
+ }
305
+ )
306
+ ] })
307
+ ] }), Qe = ({ onRetry: e, error: r }) => /* @__PURE__ */ i(
308
+ "div",
309
+ {
310
+ className: "p-3 text-center bg-[var(--widget-warning)]/10 border border-[var(--widget-warning)]/20 rounded-lg",
311
+ "data-testid": "sdk-connection-fallback",
312
+ children: [
313
+ /* @__PURE__ */ t("div", { className: "text-[var(--widget-warning)] mb-2", children: /* @__PURE__ */ t(Me, { className: "w-12 h-12 mx-auto" }) }),
314
+ /* @__PURE__ */ t("p", { className: "text-sm text-[var(--widget-warning)] mb-3 font-medium", children: "Connection to notification service failed" }),
315
+ r && process.env.NODE_ENV === "development" && /* @__PURE__ */ t("p", { className: "text-xs text-[var(--widget-warning)] mb-3 font-mono opacity-80", children: r }),
316
+ e && /* @__PURE__ */ t(
317
+ "button",
318
+ {
319
+ type: "button",
320
+ className: "text-sm font-medium bg-[var(--widget-warning)]/20 text-[var(--widget-warning)] hover:bg-[var(--widget-warning)]/30 px-3 py-1 rounded transition-colors",
321
+ onClick: e,
322
+ children: "Retry connection"
323
+ }
324
+ )
325
+ ]
326
+ }
327
+ ), Xe = ({ message: e = "Loading..." }) => /* @__PURE__ */ i("div", { className: "p-3 text-center", "data-testid": "loading-fallback", children: [
328
+ /* @__PURE__ */ t("div", { className: "w-6 h-6 border-2 border-[var(--widget-primary)] border-t-transparent rounded-full animate-spin mx-auto mb-2" }),
329
+ /* @__PURE__ */ t("p", { className: "text-sm text-[var(--widget-text-secondary)]", children: e })
330
+ ] }), $e = (e, r) => {
331
+ switch (r) {
332
+ case "all":
333
+ return e;
334
+ case "unread":
335
+ return e.filter((a) => !a.isRead);
336
+ default:
337
+ if (r.startsWith("tag:")) {
338
+ const a = r.substring(4);
339
+ return e.filter((n) => n.tags.includes(a));
340
+ }
341
+ return e;
342
+ }
343
+ }, Oe = (e, r) => {
344
+ if (!r.trim())
345
+ return e;
346
+ const a = r.toLowerCase().trim();
347
+ return e.filter((n) => {
348
+ const s = n.subject.toLowerCase(), l = n.body.toLowerCase(), u = n.tags.join(" ").toLowerCase();
349
+ return s.includes(a) || l.includes(a) || u.includes(a);
350
+ });
351
+ }, Le = (e, r) => {
352
+ const a = [...e];
353
+ switch (r) {
354
+ case "newest":
355
+ return a.sort((n, s) => s.timestamp.getTime() - n.timestamp.getTime());
356
+ case "oldest":
357
+ return a.sort((n, s) => n.timestamp.getTime() - s.timestamp.getTime());
358
+ case "unread-first":
359
+ return a.sort((n, s) => n.isRead === s.isRead ? s.timestamp.getTime() - n.timestamp.getTime() : n.isRead ? 1 : -1);
360
+ case "read-first":
361
+ return a.sort((n, s) => n.isRead === s.isRead ? s.timestamp.getTime() - n.timestamp.getTime() : n.isRead ? -1 : 1);
362
+ default:
363
+ return a;
364
+ }
365
+ }, Be = (e, r, a, n = "newest") => {
366
+ let s = e;
367
+ return s = $e(s, r), a && (s = Oe(s, a)), s = Le(s, n), s;
368
+ }, Pe = ({
369
+ selectedNotifications: e,
370
+ onMarkAllAsRead: r,
371
+ onMarkAllAsUnread: a,
372
+ onArchiveAll: n,
373
+ onDeleteAll: s,
374
+ onClearSelection: l,
375
+ className: u = ""
376
+ }) => {
377
+ const [h, d] = z(!1), [m, v] = z(null), g = e.length, y = async (x, C) => {
378
+ if (g !== 0) {
379
+ d(!0), v(null);
380
+ try {
381
+ const k = await x(e);
382
+ v(k), k.success && l();
383
+ } catch (k) {
384
+ v({
385
+ success: !1,
386
+ processedCount: 0,
387
+ failedCount: g,
388
+ errors: [{ notificationId: "", error: k }]
389
+ });
390
+ } finally {
391
+ d(!1);
392
+ }
393
+ }
394
+ };
395
+ return g === 0 ? null : /* @__PURE__ */ i("div", { className: `border-t border-border bg-widget-primary-light p-2 ${u}`, children: [
396
+ /* @__PURE__ */ i("div", { className: "flex items-center justify-between", children: [
397
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
398
+ /* @__PURE__ */ i("span", { className: "text-sm font-medium text-widget-primary", children: [
399
+ g,
400
+ " notification",
401
+ g !== 1 ? "s" : "",
402
+ " selected"
403
+ ] }),
404
+ m && !m.success && /* @__PURE__ */ i("span", { className: "text-xs text-[var(--widget-error)]", children: [
405
+ m.failedCount,
406
+ " failed"
407
+ ] })
408
+ ] }),
409
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
410
+ /* @__PURE__ */ i(
411
+ "button",
412
+ {
413
+ type: "button",
414
+ onClick: () => y(r),
415
+ disabled: h,
416
+ className: "inline-flex items-center px-2 py-1 text-xs font-medium text-blue-700 bg-white border border-blue-300 rounded hover:bg-blue-50 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",
417
+ "data-testid": "bulk-mark-read",
418
+ children: [
419
+ /* @__PURE__ */ t(q, { className: "mr-1 w-4 h-4" }),
420
+ "Mark Read"
421
+ ]
422
+ }
423
+ ),
424
+ /* @__PURE__ */ i(
425
+ "button",
426
+ {
427
+ type: "button",
428
+ onClick: () => y(a),
429
+ disabled: h,
430
+ className: "inline-flex items-center px-2 py-1 text-xs font-medium text-blue-700 bg-white border border-blue-300 rounded hover:bg-blue-50 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",
431
+ "data-testid": "bulk-mark-unread",
432
+ children: [
433
+ /* @__PURE__ */ t(ue, { className: "mr-1 w-4 h-4" }),
434
+ "Mark Unread"
435
+ ]
436
+ }
437
+ ),
438
+ /* @__PURE__ */ i(
439
+ "button",
440
+ {
441
+ type: "button",
442
+ onClick: () => y(n),
443
+ disabled: h,
444
+ className: "inline-flex items-center px-2 py-1 text-xs font-medium text-text-secondary bg-white border border-border rounded hover:bg-widget-hover focus:outline-none focus:ring-2 focus:ring-text-secondary disabled:opacity-50 disabled:cursor-not-allowed transition-colors",
445
+ "data-testid": "bulk-archive",
446
+ children: [
447
+ /* @__PURE__ */ t(de, { className: "mr-1 w-4 h-4" }),
448
+ "Archive"
449
+ ]
450
+ }
451
+ ),
452
+ /* @__PURE__ */ i(
453
+ "button",
454
+ {
455
+ type: "button",
456
+ onClick: () => {
457
+ window.confirm(
458
+ `Are you sure you want to delete ${g} notification${g !== 1 ? "s" : ""}? This action cannot be undone.`
459
+ ) && y(s);
460
+ },
461
+ disabled: h,
462
+ className: "inline-flex items-center px-2 py-1 text-xs font-medium text-[var(--widget-error)] bg-white border border-[var(--widget-error)]/30 rounded hover:bg-[var(--widget-error)]/10 focus:outline-none focus:ring-2 focus:ring-[var(--widget-error)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",
463
+ "data-testid": "bulk-delete",
464
+ children: [
465
+ /* @__PURE__ */ t(Ne, { className: "mr-1 w-4 h-4" }),
466
+ "Delete"
467
+ ]
468
+ }
469
+ ),
470
+ /* @__PURE__ */ t(
471
+ "button",
472
+ {
473
+ type: "button",
474
+ onClick: l,
475
+ disabled: h,
476
+ className: "inline-flex items-center px-1 py-1 text-xs font-medium text-text-secondary hover:text-text-primary focus:outline-none focus:ring-2 focus:ring-text-secondary disabled:opacity-50 disabled:cursor-not-allowed transition-colors",
477
+ "data-testid": "clear-selection",
478
+ "aria-label": "Clear selection",
479
+ children: /* @__PURE__ */ t(ce, { className: "w-5 h-5" })
480
+ }
481
+ )
482
+ ] })
483
+ ] }),
484
+ h && /* @__PURE__ */ i("div", { className: "mt-2 flex items-center gap-2", children: [
485
+ /* @__PURE__ */ t("div", { className: "animate-spin rounded-full h-4 w-4 border-b-2 border-[var(--widget-primary)]" }),
486
+ /* @__PURE__ */ t("span", { className: "text-xs text-[var(--widget-primary)]", children: "Processing..." })
487
+ ] }),
488
+ m && /* @__PURE__ */ t("div", { className: "mt-2", children: m.success ? /* @__PURE__ */ i("div", { className: "text-xs text-[var(--widget-success)]", children: [
489
+ "Successfully processed ",
490
+ m.processedCount,
491
+ " notification",
492
+ m.processedCount !== 1 ? "s" : ""
493
+ ] }) : /* @__PURE__ */ i("div", { className: "text-xs text-[var(--widget-error)]", children: [
494
+ m.processedCount > 0 && /* @__PURE__ */ i("span", { children: [
495
+ "Processed ",
496
+ m.processedCount,
497
+ ", "
498
+ ] }),
499
+ "Failed to process ",
500
+ m.failedCount,
501
+ " notification",
502
+ m.failedCount !== 1 ? "s" : ""
503
+ ] }) })
504
+ ] });
505
+ }, re = ({
506
+ title: e = "No Items",
507
+ description: r = "There are no items to display",
508
+ icon: a
509
+ }) => /* @__PURE__ */ i("div", { className: "flex flex-col items-center justify-center py-8 px-4", children: [
510
+ a && /* @__PURE__ */ t("div", { className: "mb-4 text-gray-300", children: a }),
511
+ /* @__PURE__ */ t("h3", { className: "text-lg font-medium text-[var(--widget-text)] mb-2", children: e }),
512
+ /* @__PURE__ */ t("p", { className: "text-sm text-text-gray-300 text-center", children: r })
513
+ ] }), W = ({
514
+ content: e,
515
+ children: r,
516
+ position: a = "top",
517
+ delay: n = 200
518
+ }) => {
519
+ const [s, l] = z(!1), [u, h] = z({ x: 0, y: 0 }), d = O(null), m = O(null), v = () => {
520
+ d.current && clearTimeout(d.current), d.current = setTimeout(() => {
521
+ if (m.current) {
522
+ const x = m.current.getBoundingClientRect();
523
+ let C = 0, k = 0;
524
+ switch (a) {
525
+ case "top":
526
+ C = x.left + x.width / 2, k = x.top - 8;
527
+ break;
528
+ case "bottom":
529
+ C = x.left + x.width / 2, k = x.bottom + 8;
530
+ break;
531
+ case "left":
532
+ C = x.left - 8, k = x.top + x.height / 2;
533
+ break;
534
+ case "right":
535
+ C = x.right + 8, k = x.top + x.height / 2;
536
+ break;
537
+ }
538
+ h({ x: C, y: k }), l(!0);
539
+ }
540
+ }, n);
541
+ }, g = () => {
542
+ d.current && clearTimeout(d.current), l(!1);
543
+ };
544
+ return K(() => () => {
545
+ d.current && clearTimeout(d.current);
546
+ }, []), /* @__PURE__ */ i(B, { children: [
547
+ /* @__PURE__ */ t(
548
+ "div",
549
+ {
550
+ ref: m,
551
+ onMouseEnter: v,
552
+ onMouseLeave: g,
553
+ className: "inline-flex",
554
+ children: r
555
+ }
556
+ ),
557
+ s && /* @__PURE__ */ t(
558
+ "div",
559
+ {
560
+ className: `
561
+ fixed z-50 px-2 py-1 text-xs font-medium text-[var(--widget-text)] rounded-md pointer-events-none
562
+ bg-[var(--widget-text)] shadow-lg
563
+ ${{
564
+ top: "-translate-x-1/2 -translate-y-full",
565
+ bottom: "-translate-x-1/2 translate-y-0",
566
+ left: "-translate-x-full -translate-y-1/2",
567
+ right: "translate-x-0 -translate-y-1/2"
568
+ }[a]}
569
+ animate-in fade-in-0 zoom-in-95 duration-200
570
+ `,
571
+ style: {
572
+ left: `${u.x}px`,
573
+ top: `${u.y}px`
574
+ },
575
+ children: e
576
+ }
577
+ )
578
+ ] });
579
+ }, Re = (e) => {
580
+ if (Number.isNaN(e.getTime())) return "Long ago";
581
+ const n = (/* @__PURE__ */ new Date()).getTime() - e.getTime(), s = Math.floor(n / 6e4), l = Math.floor(n / 36e5), u = Math.floor(n / 864e5);
582
+ return s < 1 ? "Just now" : s < 60 ? `${s}m ago` : l < 24 ? `${l}h ago` : u < 7 ? `${u}d ago` : e.toLocaleDateString();
583
+ }, U = ({ type: e, className: r }) => {
584
+ const a = r || "w-4 h-4";
585
+ switch (e) {
586
+ case "mark_read":
587
+ return /* @__PURE__ */ t(q, { className: a });
588
+ case "snooze":
589
+ return /* @__PURE__ */ t(je, { className: a });
590
+ case "archive":
591
+ return /* @__PURE__ */ t(de, { className: a });
592
+ default:
593
+ return null;
594
+ }
595
+ }, De = ({
596
+ notification: e,
597
+ onActionClick: r,
598
+ onSelectionChange: a,
599
+ isSelected: n = !1
600
+ }) => {
601
+ const [s, l] = z(!1), u = Number.isNaN(e.timestamp.getTime()), h = u ? void 0 : e.timestamp.toISOString(), d = Re(e.timestamp), m = (g) => {
602
+ r && r(e.id, g), l(!1);
603
+ }, v = () => {
604
+ a && a(!n);
605
+ };
606
+ return /* @__PURE__ */ i(
607
+ "div",
608
+ {
609
+ className: `
610
+ mx-widget-item relative group flex items-start gap-3 px-4 py-3 border-b border-border-light
611
+ transition-all duration-200
612
+ bg-widget-background hover:bg-widget-hover
613
+ min-w-[20rem]
614
+ ${n ? "bg-widget-primary-light" : ""}
615
+ `,
616
+ onMouseEnter: () => l(!0),
617
+ onMouseLeave: () => l(!1),
618
+ "data-testid": "notification-item",
619
+ "data-notification-id": e.id,
620
+ "data-mx-widget": "item",
621
+ children: [
622
+ a && /* @__PURE__ */ t("div", { className: "flex-shrink-0 pt-0.5", children: /* @__PURE__ */ t(
623
+ "input",
624
+ {
625
+ type: "checkbox",
626
+ checked: n,
627
+ onChange: v,
628
+ className: "w-4 h-4 text-[var(--widget-primary)] border-[var(--widget-border)] rounded cursor-pointer focus:ring-2 focus:ring-[var(--widget-primary)] focus:ring-offset-0",
629
+ "aria-label": `Select notification: ${e.subject}`
630
+ }
631
+ ) }),
632
+ /* @__PURE__ */ t("div", { className: "flex-shrink-0", children: e.avatar ? /* @__PURE__ */ t(
633
+ "img",
634
+ {
635
+ src: e.avatar,
636
+ alt: "",
637
+ className: "w-10 h-10 rounded-full object-cover border border-border",
638
+ "aria-hidden": "true",
639
+ loading: "lazy"
640
+ }
641
+ ) : /* @__PURE__ */ t("div", { className: "w-10 h-10 rounded-full bg-gradient-to-br from-widget-primary to-widget-primary-hover flex items-center justify-center shadow-sm", children: /* @__PURE__ */ t("span", { className: "text-[var(--widget-text)] font-semibold text-base", children: e.subject.charAt(0).toUpperCase() }) }) }),
642
+ /* @__PURE__ */ i("div", { className: "flex-1 min-w-0", children: [
643
+ /* @__PURE__ */ i("div", { className: "flex items-start justify-between gap-2 mb-0.5", children: [
644
+ /* @__PURE__ */ t(
645
+ "h3",
646
+ {
647
+ className: `text-sm leading-5 text-[var(--widget-text)] ${e.isRead ? "font-medium" : "font-semibold"}`,
648
+ children: e.subject
649
+ }
650
+ ),
651
+ !e.isRead && /* @__PURE__ */ t("div", { className: "flex-shrink-0 mt-1.5 ml-1", children: /* @__PURE__ */ t(
652
+ "div",
653
+ {
654
+ className: "w-2 h-2 rounded-full bg-unread-indicator shadow-sm",
655
+ "aria-label": "Unread",
656
+ role: "img"
657
+ }
658
+ ) })
659
+ ] }),
660
+ /* @__PURE__ */ t("p", { className: "text-sm text-[var(--widget-text-secondary)] line-clamp-2 leading-relaxed mb-2", children: e.body }),
661
+ e.actions && e.actions.length > 0 && /* @__PURE__ */ t("div", { className: "flex items-center gap-2 mb-2", children: e.actions.map((g, y) => /* @__PURE__ */ t(
662
+ "button",
663
+ {
664
+ onClick: (x) => {
665
+ x.stopPropagation(), m(g);
666
+ },
667
+ className: `
668
+ px-3 py-1.5 rounded-md text-sm font-medium transition-colors
669
+ ${y === 0 ? "bg-[var(--widget-primary)] text-[var(--widget-text)] hover:bg-[var(--widget-primary-hover)] shadow-sm" : "bg-transparent text-[var(--widget-text-secondary)] hover:bg-[var(--widget-bg-hover)] border border-[var(--widget-border)]"}
670
+ `,
671
+ "data-mx-widget": "action",
672
+ children: g.label
673
+ },
674
+ y
675
+ )) }),
676
+ /* @__PURE__ */ i("div", { className: "flex items-center justify-between min-h-[20px]", children: [
677
+ /* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ t("time", { className: "text-xs text-[var(--widget-text-tertiary)]", dateTime: h, children: d }) }),
678
+ /* @__PURE__ */ i(
679
+ "div",
680
+ {
681
+ className: `flex items-center gap-1 transition-opacity duration-200 ${s ? "opacity-100" : "opacity-0"}`,
682
+ onClick: (g) => g.stopPropagation(),
683
+ children: [
684
+ /* @__PURE__ */ t(W, { content: "Mark as read", position: "top", children: /* @__PURE__ */ t(
685
+ "button",
686
+ {
687
+ className: "inline-flex items-center justify-center w-7 h-7 rounded-md text-[var(--widget-text-secondary)] hover:text-[var(--widget-text)] hover:bg-[var(--widget-bg-hover)] transition-colors",
688
+ onClick: () => m({
689
+ type: "mark_read",
690
+ label: "Mark as read",
691
+ handler: async () => {
692
+ }
693
+ }),
694
+ "aria-label": "Mark as read",
695
+ children: /* @__PURE__ */ t(U, { type: "mark_read" })
696
+ }
697
+ ) }),
698
+ /* @__PURE__ */ t(W, { content: "Snooze", position: "top", children: /* @__PURE__ */ t(
699
+ "button",
700
+ {
701
+ className: "inline-flex items-center justify-center w-7 h-7 rounded-md text-[var(--widget-text-secondary)] hover:text-[var(--widget-text)] hover:bg-[var(--widget-bg-hover)] transition-colors",
702
+ onClick: () => m({ type: "custom", label: "Snooze", handler: async () => {
703
+ } }),
704
+ "aria-label": "Snooze",
705
+ children: /* @__PURE__ */ t(U, { type: "snooze" })
706
+ }
707
+ ) }),
708
+ /* @__PURE__ */ t(W, { content: "Archive", position: "top", children: /* @__PURE__ */ t(
709
+ "button",
710
+ {
711
+ className: "inline-flex items-center justify-center w-7 h-7 rounded-md text-[var(--widget-text-secondary)] hover:text-[var(--widget-text)] hover:bg-[var(--widget-bg-hover)] transition-colors",
712
+ onClick: () => m({ type: "archive", label: "Archive", handler: async () => {
713
+ } }),
714
+ "aria-label": "Archive",
715
+ children: /* @__PURE__ */ t(U, { type: "archive" })
716
+ }
717
+ ) })
718
+ ]
719
+ }
720
+ )
721
+ ] })
722
+ ] }),
723
+ /* @__PURE__ */ i("div", { className: "sr-only", children: [
724
+ "Notification from",
725
+ " ",
726
+ u ? "Unknown time" : e.timestamp.toLocaleString(),
727
+ ".",
728
+ e.isRead ? "Read" : "Unread",
729
+ ".",
730
+ e.isArchived ? "Archived" : "Active",
731
+ "."
732
+ ] })
733
+ ]
734
+ }
735
+ );
736
+ }, ae = ({ count: e = 3 }) => /* @__PURE__ */ t(B, { children: Array.from({ length: e }).map((r, a) => /* @__PURE__ */ i(
737
+ "div",
738
+ {
739
+ className: "flex items-start gap-3 px-4 py-3 border-b border-border-light animate-pulse",
740
+ children: [
741
+ /* @__PURE__ */ t("div", { className: "flex-shrink-0", children: /* @__PURE__ */ t("div", { className: "w-10 h-10 rounded-full bg-widget-hover" }) }),
742
+ /* @__PURE__ */ i("div", { className: "flex-1 space-y-2", children: [
743
+ /* @__PURE__ */ t("div", { className: "h-4 w-3/4 rounded bg-widget-hover" }),
744
+ /* @__PURE__ */ i("div", { className: "space-y-1", children: [
745
+ /* @__PURE__ */ t("div", { className: "h-3 w-full rounded bg-widget-hover" }),
746
+ /* @__PURE__ */ t("div", { className: "h-3 w-5/6 rounded bg-widget-hover" })
747
+ ] }),
748
+ /* @__PURE__ */ t("div", { className: "h-3 w-16 rounded bg-widget-hover" })
749
+ ] }),
750
+ /* @__PURE__ */ t("div", { className: "flex-shrink-0", children: /* @__PURE__ */ t("div", { className: "w-2 h-2 rounded-full bg-widget-hover" }) })
751
+ ]
752
+ },
753
+ a
754
+ )) }), Ve = ({
755
+ notifications: e,
756
+ isLoading: r = !1,
757
+ error: a,
758
+ onNotificationAction: n,
759
+ selectedNotifications: s = [],
760
+ onSelectionChange: l,
761
+ onSelectAll: u,
762
+ onLoadMore: h,
763
+ hasMore: d = !1,
764
+ className: m = ""
765
+ }) => {
766
+ const v = O(null), g = O(null), [y, x] = z(!1);
767
+ K(() => {
768
+ if (!(!h || !d || y))
769
+ return v.current = new IntersectionObserver(
770
+ (c) => {
771
+ c[0].isIntersecting && d && !y && (x(!0), h(), setTimeout(() => x(!1), 500));
772
+ },
773
+ {
774
+ root: null,
775
+ rootMargin: "100px",
776
+ threshold: 0.1
777
+ }
778
+ ), g.current && v.current.observe(g.current), () => {
779
+ v.current && v.current.disconnect();
780
+ };
781
+ }, [h, d, y]);
782
+ const C = I(
783
+ async (c, f) => {
784
+ try {
785
+ f.handler && await f.handler(c), n && f.type && n(c, f);
786
+ } catch {
787
+ }
788
+ },
789
+ [n]
790
+ ), k = I(
791
+ (c, f) => {
792
+ l && l(c, f);
793
+ },
794
+ [l]
795
+ );
796
+ return r && e.length === 0 ? /* @__PURE__ */ t("div", { className: `flex flex-col h-full bg-widget-background min-w-[20rem] ${m}`, children: /* @__PURE__ */ t(ae, { count: 5 }) }) : a ? /* @__PURE__ */ t("div", { className: `flex flex-col h-full bg-widget-background min-w-[20rem] ${m}`, children: /* @__PURE__ */ t("div", { className: "flex items-center justify-center flex-1 py-12", children: /* @__PURE__ */ t(
797
+ re,
798
+ {
799
+ title: "Error Loading Notifications",
800
+ description: "Failed to load notifications. Please try again.",
801
+ icon: /* @__PURE__ */ t(
802
+ "svg",
803
+ {
804
+ className: "w-12 h-12 text-[var(--widget-error)]",
805
+ fill: "none",
806
+ stroke: "currentColor",
807
+ viewBox: "0 0 24 24",
808
+ children: /* @__PURE__ */ t(
809
+ "path",
810
+ {
811
+ strokeLinecap: "round",
812
+ strokeLinejoin: "round",
813
+ strokeWidth: 2,
814
+ d: "M12 8v4m0 4v.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
815
+ }
816
+ )
817
+ }
818
+ )
819
+ }
820
+ ) }) }) : e.length === 0 ? /* @__PURE__ */ t("div", { className: `flex flex-col h-full bg-widget-background min-w-[20rem] ${m}`, children: /* @__PURE__ */ t("div", { className: "flex items-center justify-center flex-1 py-12", children: /* @__PURE__ */ t(
821
+ re,
822
+ {
823
+ title: "No Notifications",
824
+ description: "You're all caught up! No notifications to display.",
825
+ icon: /* @__PURE__ */ t(
826
+ "svg",
827
+ {
828
+ className: "w-12 h-12 text-[var(--widget-text-tertiary)]",
829
+ fill: "none",
830
+ stroke: "currentColor",
831
+ viewBox: "0 0 24 24",
832
+ children: /* @__PURE__ */ t(
833
+ "path",
834
+ {
835
+ strokeLinecap: "round",
836
+ strokeLinejoin: "round",
837
+ strokeWidth: 2,
838
+ d: "M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4"
839
+ }
840
+ )
841
+ }
842
+ )
843
+ }
844
+ ) }) }) : /* @__PURE__ */ i("div", { className: `flex flex-col h-full min-w-[20rem] ${m}`, children: [
845
+ u && n && /* @__PURE__ */ t(
846
+ Pe,
847
+ {
848
+ selectedNotifications: s,
849
+ onMarkAllAsRead: async (c) => {
850
+ try {
851
+ for (const f of c)
852
+ n(f, {
853
+ type: "mark_read",
854
+ label: "Mark as read",
855
+ handler: async () => {
856
+ }
857
+ });
858
+ return {
859
+ success: !0,
860
+ processedCount: c.length,
861
+ failedCount: 0,
862
+ errors: []
863
+ };
864
+ } catch (f) {
865
+ return {
866
+ success: !1,
867
+ processedCount: 0,
868
+ failedCount: c.length,
869
+ errors: [{ notificationId: "", error: f }]
870
+ };
871
+ }
872
+ },
873
+ onMarkAllAsUnread: async (c) => {
874
+ try {
875
+ for (const f of c)
876
+ n(f, {
877
+ type: "mark_unread",
878
+ label: "Mark as unread",
879
+ handler: async () => {
880
+ }
881
+ });
882
+ return {
883
+ success: !0,
884
+ processedCount: c.length,
885
+ failedCount: 0,
886
+ errors: []
887
+ };
888
+ } catch (f) {
889
+ return {
890
+ success: !1,
891
+ processedCount: 0,
892
+ failedCount: c.length,
893
+ errors: [{ notificationId: "", error: f }]
894
+ };
895
+ }
896
+ },
897
+ onArchiveAll: async (c) => {
898
+ try {
899
+ for (const f of c)
900
+ n(f, {
901
+ type: "archive",
902
+ label: "Archive",
903
+ handler: async () => {
904
+ }
905
+ });
906
+ return {
907
+ success: !0,
908
+ processedCount: c.length,
909
+ failedCount: 0,
910
+ errors: []
911
+ };
912
+ } catch (f) {
913
+ return {
914
+ success: !1,
915
+ processedCount: 0,
916
+ failedCount: c.length,
917
+ errors: [{ notificationId: "", error: f }]
918
+ };
919
+ }
920
+ },
921
+ onDeleteAll: async (c) => {
922
+ try {
923
+ for (const f of c)
924
+ n(f, {
925
+ type: "delete",
926
+ label: "Delete",
927
+ handler: async () => {
928
+ }
929
+ });
930
+ return {
931
+ success: !0,
932
+ processedCount: c.length,
933
+ failedCount: 0,
934
+ errors: []
935
+ };
936
+ } catch (f) {
937
+ return {
938
+ success: !1,
939
+ processedCount: 0,
940
+ failedCount: c.length,
941
+ errors: [{ notificationId: "", error: f }]
942
+ };
943
+ }
944
+ },
945
+ onClearSelection: () => u(!1)
946
+ }
947
+ ),
948
+ /* @__PURE__ */ t("div", { className: "flex-1", children: /* @__PURE__ */ i("div", { children: [
949
+ e.map((c) => /* @__PURE__ */ t(
950
+ De,
951
+ {
952
+ notification: c,
953
+ onActionClick: C,
954
+ isSelected: s.includes(c.id),
955
+ onSelectionChange: l ? (f) => k(c.id, f) : void 0
956
+ },
957
+ c.id
958
+ )),
959
+ d && /* @__PURE__ */ t("div", { ref: g, className: "py-2", children: y && /* @__PURE__ */ t(ae, { count: 3 }) })
960
+ ] }) })
961
+ ] });
962
+ }, H = ({
963
+ id: e,
964
+ label: r,
965
+ checked: a,
966
+ onChange: n,
967
+ disabled: s = !1,
968
+ icon: l
969
+ }) => /* @__PURE__ */ i("div", { className: "flex items-center justify-between py-2.5", children: [
970
+ r && /* @__PURE__ */ i(
971
+ "label",
972
+ {
973
+ htmlFor: e,
974
+ className: "flex items-center gap-2 text-sm font-medium text-text-primary cursor-pointer",
975
+ children: [
976
+ l && /* @__PURE__ */ t("span", { className: "text-widget-primary", children: l }),
977
+ /* @__PURE__ */ t("span", { children: r })
978
+ ]
979
+ }
980
+ ),
981
+ /* @__PURE__ */ t(
982
+ "button",
983
+ {
984
+ type: "button",
985
+ id: e,
986
+ role: "switch",
987
+ "aria-checked": a,
988
+ disabled: s,
989
+ className: `relative inline-flex h-5 w-9 flex-shrink-0 rounded-full border-2 border-transparent
990
+ transition-colors duration-200 ease-in-out
991
+ focus:outline-none focus:ring-2 focus:ring-widget-primary focus:ring-offset-2
992
+ ${a ? "bg-widget-primary" : "bg-gray-300 dark:bg-gray-600"}
993
+ ${s ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}
994
+ `,
995
+ onClick: () => !s && n(!a),
996
+ children: /* @__PURE__ */ t(
997
+ "span",
998
+ {
999
+ className: `pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white shadow-md ring-0
1000
+ transition duration-200 ease-in-out
1001
+ ${a ? "translate-x-4" : "translate-x-0"}
1002
+ `
1003
+ }
1004
+ )
1005
+ }
1006
+ )
1007
+ ] }), _e = {
1008
+ sm: "w-4 h-4",
1009
+ md: "w-8 h-8",
1010
+ lg: "w-12 h-12"
1011
+ }, ne = ({
1012
+ size: e = "md",
1013
+ label: r = "Loading..."
1014
+ }) => /* @__PURE__ */ i("div", { className: "flex flex-col items-center justify-center gap-2", children: [
1015
+ /* @__PURE__ */ t(
1016
+ "div",
1017
+ {
1018
+ className: `${_e[e]} animate-spin rounded-full border-2 border-gray-300 dark:border-gray-600 border-t-blue-500 dark:border-t-blue-400`,
1019
+ role: "status",
1020
+ "aria-label": r
1021
+ }
1022
+ ),
1023
+ r && /* @__PURE__ */ t("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: r })
1024
+ ] }), Fe = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"], We = ({
1025
+ preferences: e,
1026
+ onPreferenceChange: r,
1027
+ isLoading: a,
1028
+ specificPreferences: n,
1029
+ onLoadMoreSpecific: s,
1030
+ hasMoreSpecific: l,
1031
+ isListLoading: u,
1032
+ onMorePreferencesClick: h
1033
+ }) => {
1034
+ const [d, m] = z({
1035
+ global: !0,
1036
+ schedule: !1
1037
+ }), [v, g] = z({}), y = (o) => {
1038
+ m((p) => ({ ...p, [o]: !p[o] }));
1039
+ }, x = (o) => {
1040
+ g((p) => ({ ...p, [o]: !p[o] }));
1041
+ }, C = (o, p) => {
1042
+ r(`channels.${o}`, p);
1043
+ }, k = (o, p) => {
1044
+ r(`subscriptions.${o}.enabled`, p);
1045
+ }, c = (o, p, M) => {
1046
+ r(`subscriptions.${o}.channels.${p}`, M);
1047
+ }, f = (o) => {
1048
+ const p = [...e.deliverySchedule.weekdays];
1049
+ p[o] = !p[o], r("deliverySchedule.weekdays", p);
1050
+ }, A = (o) => {
1051
+ const { scrollTop: p, scrollHeight: M, clientHeight: E } = o.currentTarget;
1052
+ M - p - E < 50 && l && s && !u && s();
1053
+ }, S = (o) => {
1054
+ switch (o) {
1055
+ case "email":
1056
+ return /* @__PURE__ */ t(ze, { className: "w-4 h-4" });
1057
+ case "push":
1058
+ return /* @__PURE__ */ t(ee, { className: "w-4 h-4" });
1059
+ case "sms":
1060
+ return /* @__PURE__ */ t(Ee, { className: "w-4 h-4" });
1061
+ case "inApp":
1062
+ return /* @__PURE__ */ t(Se, { className: "w-4 h-4" });
1063
+ default:
1064
+ return null;
1065
+ }
1066
+ }, $ = n || e.subscriptions;
1067
+ return /* @__PURE__ */ i(
1068
+ "div",
1069
+ {
1070
+ className: "h-full overflow-y-auto widget-scrollbar p-2 bg-[var(--widget-background)]",
1071
+ "data-testid": "preferences-view",
1072
+ onScroll: A,
1073
+ children: [
1074
+ a && /* @__PURE__ */ t("div", { className: "absolute inset-0 bg-[var(--widget-bg)]/75 backdrop-blur-sm flex items-center justify-center z-10 transition-all duration-200", children: /* @__PURE__ */ t(ne, { size: "lg" }) }),
1075
+ /* @__PURE__ */ i("div", { className: "space-y-2", children: [
1076
+ /* @__PURE__ */ i("div", { className: "border border-[var(--widget-border)] rounded-lg overflow-hidden", children: [
1077
+ /* @__PURE__ */ i(
1078
+ "button",
1079
+ {
1080
+ type: "button",
1081
+ onClick: () => y("global"),
1082
+ className: "w-full flex items-center justify-between px-2 py-1.5 bg-[var(--widget-bg-secondary)] hover:bg-[var(--widget-bg-hover)] transition-colors",
1083
+ children: [
1084
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
1085
+ /* @__PURE__ */ t(ee, { className: "w-5 h-5 text-widget-primary" }),
1086
+ /* @__PURE__ */ t("span", { className: "font-semibold text-sm text-text-primary", children: "Global Preferences" })
1087
+ ] }),
1088
+ d.global ? /* @__PURE__ */ t(Z, { className: "w-5 h-5 text-text-secondary" }) : /* @__PURE__ */ t(F, { className: "w-5 h-5 text-text-secondary" })
1089
+ ]
1090
+ }
1091
+ ),
1092
+ d.global && /* @__PURE__ */ i("div", { className: "px-2 pb-1.5 divide-y divide-border-light bg-[var(--widget-background)]", children: [
1093
+ /* @__PURE__ */ t(
1094
+ H,
1095
+ {
1096
+ id: "channel-email",
1097
+ label: "Email",
1098
+ icon: S("email"),
1099
+ checked: e.channels.email,
1100
+ onChange: (o) => C("email", o),
1101
+ disabled: a
1102
+ }
1103
+ ),
1104
+ /* @__PURE__ */ t(
1105
+ H,
1106
+ {
1107
+ id: "channel-inapp",
1108
+ label: "In-App",
1109
+ icon: S("inApp"),
1110
+ checked: e.channels.inApp,
1111
+ onChange: (o) => C("inApp", o),
1112
+ disabled: a
1113
+ }
1114
+ ),
1115
+ /* @__PURE__ */ t(
1116
+ H,
1117
+ {
1118
+ id: "channel-push",
1119
+ label: "Push",
1120
+ icon: S("push"),
1121
+ checked: e.channels.push,
1122
+ onChange: (o) => C("push", o),
1123
+ disabled: a
1124
+ }
1125
+ )
1126
+ ] })
1127
+ ] }),
1128
+ /* @__PURE__ */ i("div", { className: "border border-[var(--widget-border)] rounded-lg overflow-hidden bg-[var(--widget-background)]", children: [
1129
+ /* @__PURE__ */ i(
1130
+ "button",
1131
+ {
1132
+ type: "button",
1133
+ onClick: () => y("schedule"),
1134
+ className: "w-full flex items-center justify-between px-2 py-1.5 bg-[var(--widget-bg-secondary)] hover:bg-[var(--widget-bg-hover)] transition-colors",
1135
+ children: [
1136
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
1137
+ /* @__PURE__ */ t(ke, { className: "w-5 h-5 text-widget-primary" }),
1138
+ /* @__PURE__ */ t("span", { className: "font-semibold text-sm text-text-primary", children: "Schedule" })
1139
+ ] }),
1140
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
1141
+ /* @__PURE__ */ t(
1142
+ H,
1143
+ {
1144
+ id: "schedule-enabled",
1145
+ checked: d.schedule,
1146
+ onChange: () => {
1147
+ },
1148
+ disabled: a
1149
+ }
1150
+ ),
1151
+ /* @__PURE__ */ t(
1152
+ "div",
1153
+ {
1154
+ className: `transition-transform duration-200 ${d.schedule ? "rotate-180" : ""}`,
1155
+ "aria-hidden": "true",
1156
+ children: /* @__PURE__ */ t(F, { className: "w-5 h-5 text-text-secondary" })
1157
+ }
1158
+ )
1159
+ ] })
1160
+ ]
1161
+ }
1162
+ ),
1163
+ d.schedule && /* @__PURE__ */ i("div", { className: "px-2 py-1.5 space-y-2 animate-in slide-in-from-top-2 duration-200 bg-[var(--widget-background)]", children: [
1164
+ /* @__PURE__ */ t("div", { className: "text-sm text-[var(--widget-text-secondary)]", children: "Allow notifications between:" }),
1165
+ /* @__PURE__ */ i("div", { className: "grid grid-cols-[auto_1fr_auto_auto] gap-x-4 gap-y-3 items-center", children: [
1166
+ /* @__PURE__ */ t("div", { className: "col-span-2 text-xs font-semibold text-[var(--widget-text-tertiary)] pl-1", children: "Days" }),
1167
+ /* @__PURE__ */ t("div", { className: "text-xs font-semibold text-[var(--widget-text-tertiary)] w-[88px]", children: "From" }),
1168
+ /* @__PURE__ */ t("div", { className: "text-xs font-semibold text-[var(--widget-text-tertiary)] w-[88px]", children: "To" }),
1169
+ Fe.map((o, p) => {
1170
+ const M = e.deliverySchedule.weekdays[p];
1171
+ return /* @__PURE__ */ i(T.Fragment, { children: [
1172
+ /* @__PURE__ */ t("div", { className: "flex items-center h-8", children: /* @__PURE__ */ t(
1173
+ H,
1174
+ {
1175
+ id: `day-${p}`,
1176
+ checked: M,
1177
+ onChange: () => f(p),
1178
+ disabled: a
1179
+ }
1180
+ ) }),
1181
+ /* @__PURE__ */ t(
1182
+ "div",
1183
+ {
1184
+ className: `text-sm ${M ? "text-text-primary" : "text-text-tertiary"}`,
1185
+ children: o
1186
+ }
1187
+ ),
1188
+ /* @__PURE__ */ t("div", { className: "w-[88px]", children: /* @__PURE__ */ t(
1189
+ "input",
1190
+ {
1191
+ type: "time",
1192
+ className: "w-full px-2 py-1 bg-widget-background border border-border rounded text-sm text-text-primary focus:outline-none focus:ring-1 focus:ring-widget-primary disabled:opacity-50 disabled:bg-widget-hover",
1193
+ value: e.deliverySchedule.quietHours.start,
1194
+ onChange: (E) => r("deliverySchedule.quietHours.start", E.target.value),
1195
+ disabled: a || !M
1196
+ }
1197
+ ) }),
1198
+ /* @__PURE__ */ t("div", { className: "w-[88px]", children: /* @__PURE__ */ t(
1199
+ "input",
1200
+ {
1201
+ type: "time",
1202
+ className: "w-full px-2 py-1 bg-widget-background border border-border rounded text-sm text-text-primary focus:outline-none focus:ring-1 focus:ring-widget-primary disabled:opacity-50 disabled:bg-widget-hover",
1203
+ value: e.deliverySchedule.quietHours.end,
1204
+ onChange: (E) => r("deliverySchedule.quietHours.end", E.target.value),
1205
+ disabled: a || !M
1206
+ }
1207
+ ) })
1208
+ ] }, o);
1209
+ })
1210
+ ] })
1211
+ ] })
1212
+ ] }),
1213
+ $.length > 0 && $.map((o) => /* @__PURE__ */ i(
1214
+ "div",
1215
+ {
1216
+ className: "border border-[var(--widget-border)] rounded-lg overflow-hidden",
1217
+ children: [
1218
+ /* @__PURE__ */ i(
1219
+ "button",
1220
+ {
1221
+ type: "button",
1222
+ onClick: () => x(o.workflowId),
1223
+ className: "w-full flex items-center justify-between px-2 py-1.5 bg-[var(--widget-bg-secondary)] hover:bg-[var(--widget-bg-hover)] transition-colors",
1224
+ children: [
1225
+ /* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ t(
1226
+ "span",
1227
+ {
1228
+ className: "text-sm font-medium text-text-primary truncate max-w-[180px]",
1229
+ title: o.name,
1230
+ children: o.name
1231
+ }
1232
+ ) }),
1233
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
1234
+ /* @__PURE__ */ t(
1235
+ H,
1236
+ {
1237
+ id: `workflow-${o.workflowId}`,
1238
+ checked: o.enabled,
1239
+ onChange: (p) => k(o.workflowId, p),
1240
+ disabled: a
1241
+ }
1242
+ ),
1243
+ v[o.workflowId] ? /* @__PURE__ */ t(Z, { className: "w-5 h-5 text-text-secondary" }) : /* @__PURE__ */ t(F, { className: "w-5 h-5 text-text-secondary" })
1244
+ ] })
1245
+ ]
1246
+ }
1247
+ ),
1248
+ v[o.workflowId] && o.enabled && /* @__PURE__ */ i("div", { className: "px-2 pb-1.5 divide-y divide-border-light bg-[var(--widget-background)]", children: [
1249
+ /* @__PURE__ */ t(
1250
+ H,
1251
+ {
1252
+ id: `sub-${o.workflowId}-inapp`,
1253
+ label: "In-App",
1254
+ icon: S("inApp"),
1255
+ checked: o.channels.inApp,
1256
+ onChange: (p) => c(o.workflowId, "inApp", p),
1257
+ disabled: a
1258
+ }
1259
+ ),
1260
+ /* @__PURE__ */ t(
1261
+ H,
1262
+ {
1263
+ id: `sub-${o.workflowId}-push`,
1264
+ label: "Push",
1265
+ icon: S("push"),
1266
+ checked: o.channels.push,
1267
+ onChange: (p) => c(o.workflowId, "push", p),
1268
+ disabled: a
1269
+ }
1270
+ )
1271
+ ] })
1272
+ ]
1273
+ },
1274
+ o.workflowId
1275
+ )),
1276
+ u && /* @__PURE__ */ t("div", { className: "flex justify-center p-2", children: /* @__PURE__ */ t(ne, { size: "md" }) }),
1277
+ h && /* @__PURE__ */ t("div", { className: "pt-2 pb-1 flex justify-center", children: /* @__PURE__ */ t(
1278
+ "button",
1279
+ {
1280
+ onClick: h,
1281
+ className: "text-sm font-medium text-[var(--widget-primary)] hover:text-[var(--widget-primary-hover)] hover:underline focus:outline-none",
1282
+ children: "More Preferences"
1283
+ }
1284
+ ) })
1285
+ ] })
1286
+ ]
1287
+ }
1288
+ );
1289
+ }, Ue = ({
1290
+ notifications: e,
1291
+ activeTab: r,
1292
+ onTabChange: a,
1293
+ className: n = ""
1294
+ }) => {
1295
+ const s = ie(() => {
1296
+ const l = e.length, u = e.filter((v) => !v.isRead).length, h = /* @__PURE__ */ new Map();
1297
+ e.forEach((v) => {
1298
+ v.tags.forEach((g) => {
1299
+ h.set(g, (h.get(g) || 0) + 1);
1300
+ });
1301
+ });
1302
+ const d = [
1303
+ {
1304
+ id: "all",
1305
+ label: "All",
1306
+ count: l,
1307
+ icon: /* @__PURE__ */ t(Ie, { className: "w-4 h-4" })
1308
+ },
1309
+ {
1310
+ id: "unread",
1311
+ label: "Unread",
1312
+ count: u,
1313
+ icon: /* @__PURE__ */ t(ue, { className: "w-4 h-4" })
1314
+ }
1315
+ ], m = Array.from(h.entries()).sort(([, v], [, g]) => g - v).slice(0, 5).map(([v, g]) => ({
1316
+ id: `tag:${v}`,
1317
+ label: v,
1318
+ count: g,
1319
+ icon: /* @__PURE__ */ t(He, { className: "w-4 h-4" })
1320
+ }));
1321
+ return [...d, ...m];
1322
+ }, [e]);
1323
+ return /* @__PURE__ */ t(
1324
+ "div",
1325
+ {
1326
+ className: `
1327
+ mx-widget-tabs flex items-center gap-1 overflow-x-auto widget-scrollbar border-b border-[var(--widget-border)] px-2 py-1.5 bg-[var(--widget-background)]
1328
+ ${n}
1329
+ `,
1330
+ role: "tablist",
1331
+ "data-mx-widget": "tabs",
1332
+ children: s.map((l) => {
1333
+ const u = r === l.id;
1334
+ return /* @__PURE__ */ i(
1335
+ "button",
1336
+ {
1337
+ onClick: () => a(l.id),
1338
+ className: `
1339
+ flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium transition-all whitespace-nowrap outline-none focus:ring-2 focus:ring-offset-1
1340
+ ${u ? "shadow-sm bg-[var(--widget-primary)] text-[var(--widget-text)]" : "tab-inactive text-[var(--widget-text-secondary)]"}
1341
+ `,
1342
+ role: "tab",
1343
+ "aria-selected": u,
1344
+ "data-testid": `tab-${l.id}`,
1345
+ children: [
1346
+ l.icon && /* @__PURE__ */ t(
1347
+ "span",
1348
+ {
1349
+ className: u ? "text-[var(--widget-text)]" : "text-[var(--widget-text-tertiary)]",
1350
+ children: l.icon
1351
+ }
1352
+ ),
1353
+ /* @__PURE__ */ t("span", { children: l.label }),
1354
+ l.count !== void 0 && l.count > 0 && /* @__PURE__ */ i(
1355
+ "span",
1356
+ {
1357
+ className: `ml-1 text-[10px] font-semibold ${u ? "text-[var(--widget-text)]" : "text-[var(--widget-text-tertiary)]"}`,
1358
+ children: [
1359
+ "(",
1360
+ l.count > 99 ? "99+" : l.count,
1361
+ ")"
1362
+ ]
1363
+ }
1364
+ )
1365
+ ]
1366
+ },
1367
+ l.id
1368
+ );
1369
+ })
1370
+ }
1371
+ );
1372
+ }, Ze = ({
1373
+ isOpen: e,
1374
+ onClose: r,
1375
+ position: a,
1376
+ currentView: n,
1377
+ onViewChange: s,
1378
+ notifications: l,
1379
+ onNotificationAction: u,
1380
+ preferences: h,
1381
+ onPreferenceChange: d,
1382
+ isPreferencesLoading: m = !1,
1383
+ size: v = "medium",
1384
+ onMorePreferencesClick: g,
1385
+ specificPreferences: y,
1386
+ onLoadMoreSpecific: x,
1387
+ hasMoreSpecific: C,
1388
+ isListLoading: k
1389
+ }) => {
1390
+ const c = O(null), f = O(null), [A, S] = z("all"), [$, o] = z(""), p = I(() => {
1391
+ const b = window.__notificationSDK?.config, N = window.__notificationSDK?.client;
1392
+ if (!b || !N) return null;
1393
+ const { tenantId: j, environmentId: L, subscriberId: Y } = b;
1394
+ return !j || !L || !Y ? null : { client: N, tenantId: j, environmentId: L, subscriberId: Y };
1395
+ }, []), M = I(
1396
+ async (b) => {
1397
+ const N = p();
1398
+ if (!N)
1399
+ return { success: !1, processedCount: 0, failedCount: b.length, errors: [] };
1400
+ try {
1401
+ for (const j of b)
1402
+ await N.client.inbox.markAsRead(
1403
+ j,
1404
+ N.tenantId,
1405
+ N.environmentId,
1406
+ N.subscriberId
1407
+ );
1408
+ return { success: !0, processedCount: b.length, failedCount: 0, errors: [] };
1409
+ } catch (j) {
1410
+ return {
1411
+ success: !1,
1412
+ processedCount: 0,
1413
+ failedCount: b.length,
1414
+ errors: [{ notificationId: "", error: j }]
1415
+ };
1416
+ }
1417
+ },
1418
+ [p]
1419
+ ), E = ie(() => Be(l, A, $), [l, A, $]), D = I(
1420
+ (b) => {
1421
+ c.current && !c.current.contains(b.target) && r();
1422
+ },
1423
+ [r]
1424
+ ), V = I(
1425
+ (b) => {
1426
+ b.key === "Escape" && r();
1427
+ },
1428
+ [r]
1429
+ ), _ = I(
1430
+ (b) => {
1431
+ if (!(!e || !c.current) && b.key === "Tab") {
1432
+ const N = c.current.querySelectorAll(
1433
+ 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
1434
+ );
1435
+ if (N.length === 0) return;
1436
+ const j = N[0], L = N[N.length - 1];
1437
+ b.shiftKey ? document.activeElement === j && (L.focus(), b.preventDefault()) : document.activeElement === L && (j.focus(), b.preventDefault());
1438
+ }
1439
+ },
1440
+ [e]
1441
+ );
1442
+ if (K(() => (e ? (f.current = document.activeElement, document.addEventListener("mousedown", D), document.addEventListener("keydown", V), document.addEventListener("keydown", _), setTimeout(() => {
1443
+ c.current?.querySelector(
1444
+ 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
1445
+ )?.focus();
1446
+ }, 0)) : (f.current && f.current.focus(), S("all"), o("")), () => {
1447
+ document.removeEventListener("mousedown", D), document.removeEventListener("keydown", V), document.removeEventListener("keydown", _);
1448
+ }), [e, D, V, _]), !e) return null;
1449
+ const he = {
1450
+ left: "left-0 origin-top-left",
1451
+ right: "right-0 origin-top-right"
1452
+ }, G = l.filter((b) => !b.isRead).length;
1453
+ return /* @__PURE__ */ i(B, { children: [
1454
+ /* @__PURE__ */ t(
1455
+ "div",
1456
+ {
1457
+ className: "fixed inset-0 bg-black/20 backdrop-blur-sm z-40 md:hidden transition-opacity duration-200",
1458
+ "aria-hidden": "true",
1459
+ onClick: r
1460
+ }
1461
+ ),
1462
+ /* @__PURE__ */ i(
1463
+ "div",
1464
+ {
1465
+ ref: c,
1466
+ className: `
1467
+ mx-widget-popover absolute top-full mt-2 ${he[a]}
1468
+ w-[var(--widget-popover-width,400px)] max-h-[var(--widget-popover-max-height,580px)]
1469
+ border border-[var(--widget-border)] rounded-2xl overflow-hidden
1470
+ shadow-[var(--widget-shadow-xl)] bg-[var(--widget-background)]
1471
+ z-50 flex flex-col
1472
+ animate-in fade-in-0 zoom-in-95 duration-200
1473
+ max-sm:fixed max-sm:inset-x-4 max-sm:top-16 max-sm:bottom-4
1474
+ max-sm:w-auto max-sm:max-w-none max-sm:max-h-[calc(100vh-120px)]
1475
+ `,
1476
+ role: "dialog",
1477
+ "aria-modal": "true",
1478
+ "aria-label": "Notifications",
1479
+ "data-testid": "inbox-popover",
1480
+ "data-mx-widget": "popover",
1481
+ children: [
1482
+ /* @__PURE__ */ i("div", { className: "flex-shrink-0 flex items-center justify-between px-4 py-3 border-b border-[var(--widget-border)] bg-[var(--widget-background)]", children: [
1483
+ /* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ t("h2", { className: "text-base font-semibold text-[var(--widget-text)]", children: n === "notifications" ? "Notifications" : "Preferences" }) }),
1484
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-1", children: [
1485
+ n === "notifications" && /* @__PURE__ */ t(
1486
+ "button",
1487
+ {
1488
+ type: "button",
1489
+ className: "inline-flex items-center justify-center w-6 h-6 rounded-lg text-[var(--widget-text-secondary)] hover:text-[var(--widget-text)] hover:bg-[var(--widget-bg-hover)] transition-colors",
1490
+ onClick: () => s("preferences"),
1491
+ "aria-label": "Open preferences",
1492
+ "data-testid": "preferences-button",
1493
+ children: /* @__PURE__ */ t(oe, { className: "w-4 h-4" })
1494
+ }
1495
+ ),
1496
+ n === "preferences" && /* @__PURE__ */ t(
1497
+ "button",
1498
+ {
1499
+ type: "button",
1500
+ className: "inline-flex items-center justify-center w-6 h-6 rounded-lg text-[var(--widget-text-secondary)] hover:text-[var(--widget-text)] hover:bg-[var(--widget-bg-hover)] transition-colors",
1501
+ onClick: () => s("notifications"),
1502
+ "aria-label": "Back to notifications",
1503
+ "data-testid": "back-button",
1504
+ children: /* @__PURE__ */ t(Te, { className: "w-5 h-5" })
1505
+ }
1506
+ ),
1507
+ /* @__PURE__ */ t(
1508
+ "button",
1509
+ {
1510
+ type: "button",
1511
+ className: "inline-flex items-center justify-center w-6 h-6 rounded-lg text-[var(--widget-text-secondary)] hover:text-[var(--widget-text)] hover:bg-[var(--widget-bg-hover)] transition-colors",
1512
+ onClick: r,
1513
+ "aria-label": "Close notifications",
1514
+ "data-testid": "close-button",
1515
+ children: /* @__PURE__ */ t(ce, { className: "w-5 h-5" })
1516
+ }
1517
+ )
1518
+ ] })
1519
+ ] }),
1520
+ n === "notifications" ? /* @__PURE__ */ i(B, { children: [
1521
+ /* @__PURE__ */ t("div", { className: "flex-shrink-0 px-4 py-2.5 border-b border-[var(--widget-border)] bg-[var(--widget-background)]", children: /* @__PURE__ */ i("div", { className: "relative", children: [
1522
+ /* @__PURE__ */ t("div", { className: "absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none", children: /* @__PURE__ */ t(Ce, { className: "w-5 h-5 text-[var(--widget-text-tertiary)]" }) }),
1523
+ /* @__PURE__ */ t(
1524
+ "input",
1525
+ {
1526
+ type: "text",
1527
+ className: `
1528
+ w-full pl-10 pr-3 py-1
1529
+ bg-[var(--widget-bg-secondary)]
1530
+ border border-[var(--widget-border)]
1531
+ rounded-lg
1532
+ text-sm text-[var(--widget-text)]
1533
+ placeholder:text-[var(--widget-text-tertiary)]
1534
+ focus:outline-none focus:ring-2 focus:ring-[var(--widget-primary)] focus:border-transparent
1535
+ transition-colors
1536
+ `,
1537
+ placeholder: "Search notifications...",
1538
+ value: $,
1539
+ onChange: (b) => o(b.target.value),
1540
+ "aria-label": "Search notifications"
1541
+ }
1542
+ )
1543
+ ] }) }),
1544
+ /* @__PURE__ */ t(
1545
+ Ue,
1546
+ {
1547
+ notifications: l,
1548
+ activeTab: A,
1549
+ onTabChange: (b) => S(b),
1550
+ size: v
1551
+ }
1552
+ ),
1553
+ /* @__PURE__ */ t("div", { className: "flex-1 overflow-y-auto widget-scrollbar bg-[var(--widget-background)] max-h-[calc(var(--widget-popover-max-height)-200px)]", children: /* @__PURE__ */ t(X, { fallback: /* @__PURE__ */ t(Ae, {}), children: /* @__PURE__ */ t(
1554
+ Ve,
1555
+ {
1556
+ notifications: E,
1557
+ onNotificationAction: u
1558
+ }
1559
+ ) }) }),
1560
+ G > 0 && /* @__PURE__ */ t("div", { className: "flex-shrink-0 px-4 py-2.5 border-t border-[var(--widget-border)] bg-[var(--widget-bg-hover)]", children: /* @__PURE__ */ t(
1561
+ "button",
1562
+ {
1563
+ type: "button",
1564
+ className: "w-full px-4 py-2 text-sm font-medium text-[var(--widget-primary)] hover:text-[var(--widget-primary-hover)] hover:bg-[var(--widget-primary-light)] rounded-lg transition-colors",
1565
+ onClick: () => {
1566
+ const b = l.filter((N) => !N.isRead).map((N) => N.id);
1567
+ M(b);
1568
+ },
1569
+ "aria-label": `Mark all ${G} notifications as read`,
1570
+ children: "Mark all as read"
1571
+ }
1572
+ ) })
1573
+ ] }) : /* @__PURE__ */ t("div", { className: "flex-1 overflow-y-auto widget-scrollbar", children: /* @__PURE__ */ t(X, { fallback: /* @__PURE__ */ t(te, {}), children: h && d ? /* @__PURE__ */ t(
1574
+ We,
1575
+ {
1576
+ preferences: h,
1577
+ onPreferenceChange: d,
1578
+ isLoading: m,
1579
+ onBack: () => s("notifications"),
1580
+ onMorePreferencesClick: g,
1581
+ specificPreferences: y,
1582
+ onLoadMoreSpecific: x,
1583
+ hasMoreSpecific: C,
1584
+ isListLoading: k
1585
+ }
1586
+ ) : /* @__PURE__ */ t(te, {}) }) })
1587
+ ]
1588
+ }
1589
+ )
1590
+ ] });
1591
+ };
1592
+ export {
1593
+ Ge as B,
1594
+ X as C,
1595
+ Ze as I,
1596
+ Xe as L,
1597
+ Ye as M,
1598
+ De as N,
1599
+ We as P,
1600
+ Qe as S,
1601
+ Je as a
1602
+ };
1603
+ //# sourceMappingURL=components-DqQ0ehzG.js.map