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