@rpcbase/ui 0.237.0 → 0.238.0

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.
Files changed (98) hide show
  1. package/dist/components/Notifications/NotificationsDrawer.d.ts.map +1 -1
  2. package/dist/index121.js +10 -10
  3. package/dist/index123.js +2 -2
  4. package/dist/index124.js +3 -3
  5. package/dist/index16.js +228 -196
  6. package/dist/index16.js.map +1 -1
  7. package/dist/index185.js +1 -1
  8. package/dist/index189.js +3 -3
  9. package/dist/index190.js +4 -4
  10. package/dist/index237.js +27 -14
  11. package/dist/index237.js.map +1 -1
  12. package/dist/index238.js +12 -7
  13. package/dist/index238.js.map +1 -1
  14. package/dist/index239.js +24 -9
  15. package/dist/index239.js.map +1 -1
  16. package/dist/index240.js +5 -10
  17. package/dist/index240.js.map +1 -1
  18. package/dist/index241.js +15 -20
  19. package/dist/index241.js.map +1 -1
  20. package/dist/index242.js +7 -10
  21. package/dist/index242.js.map +1 -1
  22. package/dist/index243.js +10 -9
  23. package/dist/index243.js.map +1 -1
  24. package/dist/index244.js +10 -9
  25. package/dist/index244.js.map +1 -1
  26. package/dist/index245.js +21 -4
  27. package/dist/index245.js.map +1 -1
  28. package/dist/index246.js +10 -5
  29. package/dist/index246.js.map +1 -1
  30. package/dist/index247.js +9 -16
  31. package/dist/index247.js.map +1 -1
  32. package/dist/index248.js +8 -8
  33. package/dist/index248.js.map +1 -1
  34. package/dist/index249.js +4 -18
  35. package/dist/index249.js.map +1 -1
  36. package/dist/index250.js +5 -15
  37. package/dist/index250.js.map +1 -1
  38. package/dist/index251.js +16 -12
  39. package/dist/index251.js.map +1 -1
  40. package/dist/index252.js +9 -29
  41. package/dist/index252.js.map +1 -1
  42. package/dist/index253.js +18 -12
  43. package/dist/index253.js.map +1 -1
  44. package/dist/index254.js +15 -25
  45. package/dist/index254.js.map +1 -1
  46. package/dist/index255.js +12 -5
  47. package/dist/index255.js.map +1 -1
  48. package/dist/index270.js +1 -1
  49. package/dist/index272.js +1 -1
  50. package/dist/index275.js +1 -1
  51. package/dist/index277.js +1 -1
  52. package/dist/index278.js +1 -1
  53. package/dist/index285.js +1 -1
  54. package/dist/index287.js +1 -1
  55. package/dist/index298.js +1 -1
  56. package/dist/index302.js +1 -1
  57. package/dist/index339.js +1 -1
  58. package/dist/index347.js +122 -5
  59. package/dist/index347.js.map +1 -1
  60. package/dist/index348.js +31 -121
  61. package/dist/index348.js.map +1 -1
  62. package/dist/index349.js +72 -31
  63. package/dist/index349.js.map +1 -1
  64. package/dist/index350.js +139 -70
  65. package/dist/index350.js.map +1 -1
  66. package/dist/index351.js +35 -116
  67. package/dist/index351.js.map +1 -1
  68. package/dist/index352.js +44 -56
  69. package/dist/index352.js.map +1 -1
  70. package/dist/index353.js +14 -49
  71. package/dist/index353.js.map +1 -1
  72. package/dist/index354.js +6 -15
  73. package/dist/index354.js.map +1 -1
  74. package/dist/index362.js +12 -4
  75. package/dist/index362.js.map +1 -1
  76. package/dist/index363.js +16 -11
  77. package/dist/index363.js.map +1 -1
  78. package/dist/index364.js +5 -16
  79. package/dist/index364.js.map +1 -1
  80. package/dist/index365.js +4 -6
  81. package/dist/index365.js.map +1 -1
  82. package/dist/index384.js +2 -2
  83. package/dist/index386.js +1 -1
  84. package/dist/index44.js +1 -1
  85. package/dist/index45.js +2 -2
  86. package/dist/index70.js +1 -1
  87. package/dist/index71.js +1 -1
  88. package/dist/index74.js +2 -6
  89. package/dist/index74.js.map +1 -1
  90. package/dist/index75.js +2 -8
  91. package/dist/index75.js.map +1 -1
  92. package/dist/index76.js +5 -5
  93. package/dist/index76.js.map +1 -1
  94. package/dist/index77.js +8 -2
  95. package/dist/index77.js.map +1 -1
  96. package/dist/index78.js +6 -2
  97. package/dist/index78.js.map +1 -1
  98. package/package.json +1 -1
package/dist/index16.js CHANGED
@@ -1,30 +1,30 @@
1
1
  import { j as t } from "./index30.js";
2
- import { c as _ } from "./index28.js";
3
- import { useContext as te, useState as R, useMemo as Y, useCallback as ne, useEffect as J, createContext as oe, useRef as H } from "react";
4
- import { X as ie, Loader2 as re, MoreVertical as se } from "lucide-react";
5
- import { cn as W } from "./index2.js";
6
- import { DialogRoot as ae } from "./index34.js";
7
- import { DialogPortal as ce } from "./index39.js";
8
- import { DialogBackdrop as le } from "./index38.js";
9
- import { DialogPopup as de } from "./index36.js";
10
- import { DialogTitle as ue } from "./index40.js";
11
- import { DialogClose as me } from "./index35.js";
12
- const ee = (r) => {
13
- const e = Date.parse(r);
2
+ import { c as te } from "./index28.js";
3
+ import { useContext as ie, useState as U, useRef as H, useMemo as G, useCallback as re, useEffect as W, createContext as se } from "react";
4
+ import { X as ae, Loader2 as ce, MoreVertical as le } from "lucide-react";
5
+ import { cn as V } from "./index2.js";
6
+ import { DialogRoot as de } from "./index34.js";
7
+ import { DialogPortal as ue } from "./index39.js";
8
+ import { DialogBackdrop as me } from "./index38.js";
9
+ import { DialogPopup as fe } from "./index36.js";
10
+ import { DialogTitle as xe } from "./index40.js";
11
+ import { DialogClose as he } from "./index35.js";
12
+ const ne = (o) => {
13
+ const e = Date.parse(o);
14
14
  return Number.isFinite(e) ? e : 0;
15
- }, fe = (r) => {
16
- const e = new Date(ee(r));
15
+ }, pe = (o) => {
16
+ const e = new Date(ne(o));
17
17
  if (!Number.isFinite(e.getTime())) return "unknown";
18
- const n = e.getFullYear(), s = String(e.getMonth() + 1).padStart(2, "0"), a = String(e.getDate()).padStart(2, "0");
19
- return `${n}-${s}-${a}`;
20
- }, xe = (r) => {
21
- if (r === "unknown") return "Unknown date";
22
- const [e, n, s] = r.split("-"), a = Number(e), c = Number(n), i = Number(s);
23
- if (!Number.isFinite(a) || !Number.isFinite(c) || !Number.isFinite(i)) return "Unknown date";
24
- const f = new Date(a, c - 1, i);
25
- if (!Number.isFinite(f.getTime())) return "Unknown date";
26
- const l = (/* @__PURE__ */ new Date()).getFullYear() !== a;
27
- return f.toLocaleDateString(void 0, l ? {
18
+ const n = e.getFullYear(), r = String(e.getMonth() + 1).padStart(2, "0"), a = String(e.getDate()).padStart(2, "0");
19
+ return `${n}-${r}-${a}`;
20
+ }, be = (o) => {
21
+ if (o === "unknown") return "Unknown date";
22
+ const [e, n, r] = o.split("-"), a = Number(e), y = Number(n), i = Number(r);
23
+ if (!Number.isFinite(a) || !Number.isFinite(y) || !Number.isFinite(i)) return "Unknown date";
24
+ const c = new Date(a, y - 1, i);
25
+ if (!Number.isFinite(c.getTime())) return "Unknown date";
26
+ const m = (/* @__PURE__ */ new Date()).getFullYear() !== a;
27
+ return c.toLocaleDateString(void 0, m ? {
28
28
  weekday: "short",
29
29
  month: "short",
30
30
  day: "numeric",
@@ -34,37 +34,60 @@ const ee = (r) => {
34
34
  month: "short",
35
35
  day: "numeric"
36
36
  });
37
- }, pe = (r) => {
38
- const e = r.platform?.webpush;
39
- if (!e || typeof e != "object" || Array.isArray(e)) return "";
40
- const n = e.fcmOptions;
41
- return !n || typeof n != "object" || Array.isArray(n) ? "" : typeof n.link == "string" ? n.link : "";
42
- }, Q = (r) => {
37
+ }, ge = (o) => {
38
+ const e = o.data?.link?.trim();
39
+ if (e) return e;
40
+ const n = o.platform?.webpush;
41
+ if (!n || typeof n != "object" || Array.isArray(n)) return "";
42
+ const r = n.fcmOptions;
43
+ if (!r || typeof r != "object" || Array.isArray(r)) return "";
44
+ const a = r.link;
45
+ return typeof a == "string" ? a.trim() : "";
46
+ }, ye = (o) => o.data?.linkMode === "merge_current_search" ? "merge_current_search" : "navigate", we = (o) => {
47
+ const e = ge(o);
48
+ return e ? {
49
+ link: e,
50
+ mode: ye(o)
51
+ } : null;
52
+ }, ve = (o) => {
53
+ window.history.pushState(window.history.state, "", o), window.dispatchEvent(new PopStateEvent("popstate", {
54
+ state: window.history.state
55
+ }));
56
+ }, Ne = (o) => {
57
+ if (o.mode === "merge_current_search") {
58
+ const e = new URL(window.location.href), n = new URL(o.link, e);
59
+ n.searchParams.forEach((r, a) => {
60
+ e.searchParams.set(a, r);
61
+ }), n.hash && (e.hash = n.hash), ve(`${e.pathname}${e.search}${e.hash}`);
62
+ return;
63
+ }
64
+ window.location.href = o.link;
65
+ }, Z = (o) => {
43
66
  const e = [];
44
67
  let n = null;
45
- for (const s of r) {
46
- const a = fe(s.createdAt);
68
+ for (const r of o) {
69
+ const a = pe(r.createdAt);
47
70
  a !== n && (n = a, e.push({
48
71
  key: a,
49
- label: xe(a),
72
+ label: be(a),
50
73
  items: []
51
- })), e[e.length - 1].items.push(s);
74
+ })), e[e.length - 1].items.push(r);
52
75
  }
53
76
  return e;
54
- }, G = () => typeof window > "u" || !("Notification" in window) ? "unsupported" : window.Notification.permission, he = oe(null);
55
- function Re({
56
- open: r,
77
+ }, J = () => typeof window > "u" || !("Notification" in window) ? "unsupported" : window.Notification.permission, je = se(null);
78
+ function Be({
79
+ open: o,
57
80
  onOpenChange: e,
58
81
  className: n,
59
- limit: s = 50,
82
+ limit: r = 50,
60
83
  defaultUnreadOnly: a = !1,
61
- realtimeContext: c
84
+ realtimeContext: y
62
85
  }) {
63
- const i = te(c ?? he), [f, h] = R([]), [l, b] = R(0), [d, x] = R(0), [v, B] = R(!1), [q, T] = R(null), [p, P] = R(a), [M, g] = R(() => G()), [O, k] = R(!1), A = i?.notifications ?? f, C = i?.unreadCount ?? l, F = i?.unseenCount ?? d, z = i?.loading ?? v, S = i?.error ? i.error instanceof Error ? i.error.message : String(i.error) : q, y = Y(() => A.slice(0, s), [s, A]), D = Y(() => y.filter((o) => !o.readAt), [y]), $ = Y(() => y.filter((o) => !!o.readAt), [y]), U = Y(() => Q(D), [D]), I = Y(() => Q($), [$]), L = ne(async ({
64
- unreadOnly: o,
65
- markSeen: m
86
+ const i = ie(y ?? je), [c, w] = U([]), [m, u] = U(0), [x, f] = U(0), [v, M] = U(!1), [q, L] = U(null), [h, K] = U(a), [O, p] = U(() => J()), [$, k] = U(!1), A = H(null), C = i?.notifications ?? c, R = i?.unreadCount ?? m, S = i?.unseenCount ?? x, z = i?.loading ?? v, T = i?.error ? i.error instanceof Error ? i.error.message : String(i.error) : q, b = G(() => C.slice(0, r), [r, C]), E = G(() => b.filter((s) => !s.readAt), [b]), D = G(() => b.filter((s) => !!s.readAt), [b]), F = G(() => Z(E), [E]), B = G(() => Z(D), [D]), I = re(async ({
87
+ unreadOnly: s,
88
+ markSeen: d
66
89
  }) => {
67
- B(!0), T(null);
90
+ M(!0), L(null);
68
91
  try {
69
92
  const j = await fetch("/api/rb/notifications", {
70
93
  method: "POST",
@@ -73,25 +96,25 @@ function Re({
73
96
  },
74
97
  credentials: "include",
75
98
  body: JSON.stringify({
76
- limit: s,
77
- unreadOnly: o,
78
- markSeen: m
99
+ limit: r,
100
+ unreadOnly: s,
101
+ markSeen: d
79
102
  })
80
- }), u = await j.json().catch(() => null);
81
- if (!j.ok || !u?.ok) {
82
- T(u?.error || "Unable to load notifications.");
103
+ }), l = await j.json().catch(() => null);
104
+ if (!j.ok || !l?.ok) {
105
+ L(l?.error || "Unable to load notifications.");
83
106
  return;
84
107
  }
85
- const E = Array.isArray(u.notifications) ? u.notifications : [];
86
- h(E), b(Number.isFinite(u.unreadCount) ? Math.max(0, Math.floor(u.unreadCount ?? 0)) : 0), x(Number.isFinite(u.unseenCount) ? Math.max(0, Math.floor(u.unseenCount ?? 0)) : 0);
108
+ const P = Array.isArray(l.notifications) ? l.notifications : [];
109
+ w(P), u(Number.isFinite(l.unreadCount) ? Math.max(0, Math.floor(l.unreadCount ?? 0)) : 0), f(Number.isFinite(l.unseenCount) ? Math.max(0, Math.floor(l.unseenCount ?? 0)) : 0);
87
110
  } catch {
88
- T("Unable to load notifications.");
111
+ L("Unable to load notifications.");
89
112
  } finally {
90
- B(!1);
113
+ M(!1);
91
114
  }
92
- }, [s]);
93
- J(() => {
94
- if (r) {
115
+ }, [r]);
116
+ W(() => {
117
+ if (o) {
95
118
  if (i) {
96
119
  (async () => {
97
120
  try {
@@ -113,53 +136,53 @@ function Re({
113
136
  })();
114
137
  return;
115
138
  }
116
- L({
117
- unreadOnly: p,
139
+ I({
140
+ unreadOnly: h,
118
141
  markSeen: !0
119
142
  });
120
143
  }
121
- }, [r, i, L, p]), J(() => {
122
- r && (i || L({
123
- unreadOnly: p,
144
+ }, [o, i, I, h]), W(() => {
145
+ o && (i || I({
146
+ unreadOnly: h,
124
147
  markSeen: !1
125
148
  }));
126
- }, [r, i, L, p]), J(() => {
127
- if (!r || (g(G()), typeof navigator > "u" || !navigator.permissions?.query)) return;
128
- let o = null, m = !1;
149
+ }, [o, i, I, h]), W(() => {
150
+ if (!o || (p(J()), typeof navigator > "u" || !navigator.permissions?.query)) return;
151
+ let s = null, d = !1;
129
152
  const j = () => {
130
- g(G());
153
+ p(J());
131
154
  };
132
155
  try {
133
156
  navigator.permissions.query({
134
157
  name: "notifications"
135
- }).then((u) => {
136
- m || (o = u, j(), u.addEventListener("change", j));
158
+ }).then((l) => {
159
+ d || (s = l, j(), l.addEventListener("change", j));
137
160
  }).catch(() => {
138
161
  });
139
162
  } catch {
140
163
  return;
141
164
  }
142
165
  return () => {
143
- m = !0, o?.removeEventListener("change", j);
166
+ d = !0, s?.removeEventListener("change", j);
144
167
  };
145
- }, [r]);
146
- const K = async () => {
168
+ }, [o]);
169
+ const Y = async () => {
147
170
  if (typeof window > "u" || !("Notification" in window)) {
148
- g("unsupported");
171
+ p("unsupported");
149
172
  return;
150
173
  }
151
174
  k(!0);
152
175
  try {
153
- const o = await window.Notification.requestPermission();
154
- g(o);
176
+ const s = await window.Notification.requestPermission();
177
+ p(s);
155
178
  } catch {
156
- g(G());
179
+ p(J());
157
180
  } finally {
158
181
  k(!1);
159
182
  }
160
- }, V = async (o) => {
183
+ }, _ = async (s) => {
161
184
  try {
162
- const m = await fetch(`/api/rb/notifications/${encodeURIComponent(o)}/read`, {
185
+ const d = await fetch(`/api/rb/notifications/${encodeURIComponent(s)}/read`, {
163
186
  method: "POST",
164
187
  headers: {
165
188
  "Content-Type": "application/json"
@@ -167,198 +190,207 @@ function Re({
167
190
  credentials: "include",
168
191
  keepalive: !0,
169
192
  body: "{}"
170
- }), j = await m.json().catch(() => null);
171
- if (!m.ok || !j?.ok) return;
172
- const u = (/* @__PURE__ */ new Date()).toISOString();
193
+ }), j = await d.json().catch(() => null);
194
+ if (!d.ok || !j?.ok) return;
195
+ const l = (/* @__PURE__ */ new Date()).toISOString();
173
196
  if (i) return;
174
- h((E) => {
175
- const w = E.find((N) => N.id === o);
176
- return w && !w.readAt && b((N) => Math.max(0, N - 1)), w && !w.seenAt && x((N) => Math.max(0, N - 1)), E.map((N) => N.id === o && !N.readAt ? {
197
+ w((P) => {
198
+ const g = P.find((N) => N.id === s);
199
+ return g && !g.readAt && u((N) => Math.max(0, N - 1)), g && !g.seenAt && f((N) => Math.max(0, N - 1)), P.map((N) => N.id === s && !N.readAt ? {
177
200
  ...N,
178
- readAt: u,
201
+ readAt: l,
179
202
  ...N.seenAt ? {} : {
180
- seenAt: u
203
+ seenAt: l
181
204
  }
182
205
  } : N);
183
206
  });
184
207
  } catch {
185
208
  return;
186
209
  }
187
- }, X = async (o) => {
210
+ }, Q = async (s) => {
188
211
  try {
189
- const m = await fetch(`/api/rb/notifications/${encodeURIComponent(o)}/archive`, {
212
+ const d = await fetch(`/api/rb/notifications/${encodeURIComponent(s)}/archive`, {
190
213
  method: "POST",
191
214
  headers: {
192
215
  "Content-Type": "application/json"
193
216
  },
194
217
  credentials: "include",
195
218
  body: "{}"
196
- }), j = await m.json().catch(() => null);
197
- if (!m.ok || !j?.ok || i) return;
198
- h((u) => {
199
- const E = u.find((w) => w.id === o);
200
- return E && !E.readAt && b((w) => Math.max(0, w - 1)), E && !E.seenAt && x((w) => Math.max(0, w - 1)), u.filter((w) => w.id !== o);
219
+ }), j = await d.json().catch(() => null);
220
+ if (!d.ok || !j?.ok || i) return;
221
+ w((l) => {
222
+ const P = l.find((g) => g.id === s);
223
+ return P && !P.readAt && u((g) => Math.max(0, g - 1)), P && !P.seenAt && f((g) => Math.max(0, g - 1)), l.filter((g) => g.id !== s);
201
224
  });
202
225
  } catch {
203
226
  return;
204
227
  }
228
+ }, X = () => {
229
+ e(!1), A.current?.unmount();
230
+ }, oe = (s) => {
231
+ if (s) {
232
+ e(!0);
233
+ return;
234
+ }
235
+ X();
205
236
  };
206
- return /* @__PURE__ */ t.jsx(ae, { open: r, onOpenChange: e, children: /* @__PURE__ */ t.jsxs(ce, { children: [
207
- /* @__PURE__ */ t.jsx(le, { className: "fixed inset-0 z-50 bg-black/50" }),
208
- /* @__PURE__ */ t.jsxs(de, { className: W("fixed right-0 top-0 z-50 flex h-full w-full max-w-md flex-col border-l bg-background shadow-xl outline-none", n), children: [
237
+ return /* @__PURE__ */ t.jsx(de, { open: o, onOpenChange: oe, actionsRef: A, children: /* @__PURE__ */ t.jsxs(ue, { children: [
238
+ /* @__PURE__ */ t.jsx(me, { className: "fixed inset-0 z-50 bg-black/50" }),
239
+ /* @__PURE__ */ t.jsxs(fe, { className: V("fixed right-0 top-0 z-50 flex h-full w-full max-w-md flex-col border-l bg-background shadow-xl outline-none", n), children: [
209
240
  /* @__PURE__ */ t.jsxs("header", { className: "flex items-center justify-between gap-2 border-b px-4 py-3", children: [
210
241
  /* @__PURE__ */ t.jsxs("div", { className: "flex min-w-0 flex-col", children: [
211
- /* @__PURE__ */ t.jsx(ue, { className: "text-sm font-semibold", children: "Notifications" }),
212
- /* @__PURE__ */ t.jsx("span", { className: "text-xs text-muted-foreground", children: C > 0 ? `${C} unread` : F > 0 ? `${F} new` : "All caught up" })
242
+ /* @__PURE__ */ t.jsx(xe, { className: "text-sm font-semibold", children: "Notifications" }),
243
+ /* @__PURE__ */ t.jsx("span", { className: "text-xs text-muted-foreground", children: R > 0 ? `${R} unread` : S > 0 ? `${S} new` : "All caught up" })
213
244
  ] }),
214
245
  /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
215
- /* @__PURE__ */ t.jsx("button", { type: "button", onClick: () => P((o) => !o), className: W("rounded-md border px-2 py-1 text-xs", p ? "bg-accent text-foreground" : "bg-background text-muted-foreground hover:bg-accent"), children: p ? "Unread" : "All" }),
216
- /* @__PURE__ */ t.jsx(me, { render: /* @__PURE__ */ t.jsx("button", { type: "button", className: "inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-accent" }), children: /* @__PURE__ */ t.jsx(ie, { className: "h-4 w-4" }) })
246
+ /* @__PURE__ */ t.jsx("button", { type: "button", onClick: () => K((s) => !s), className: V("rounded-md border px-2 py-1 text-xs", h ? "bg-accent text-foreground" : "bg-background text-muted-foreground hover:bg-accent"), children: h ? "Unread" : "All" }),
247
+ /* @__PURE__ */ t.jsx(he, { render: /* @__PURE__ */ t.jsx("button", { type: "button", className: "inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-accent" }), children: /* @__PURE__ */ t.jsx(ae, { className: "h-4 w-4" }) })
217
248
  ] })
218
249
  ] }),
219
250
  /* @__PURE__ */ t.jsxs("div", { className: "flex-1 overflow-y-auto px-4 pb-3", children: [
220
- /* @__PURE__ */ t.jsx(be, { permission: M, requesting: O, onEnable: K }),
221
- z ? /* @__PURE__ */ t.jsx("div", { className: "flex items-center justify-center py-10 text-muted-foreground", children: /* @__PURE__ */ t.jsx(re, { className: "h-4 w-4 animate-spin" }) }) : S ? /* @__PURE__ */ t.jsx("div", { className: "py-10 text-center text-sm text-muted-foreground", children: S }) : y.length === 0 ? /* @__PURE__ */ t.jsx("div", { className: "py-10 text-center text-sm text-muted-foreground", children: "No notifications." }) : /* @__PURE__ */ t.jsxs("div", { className: "flex flex-col gap-4", children: [
251
+ /* @__PURE__ */ t.jsx(ke, { permission: O, requesting: $, onEnable: Y }),
252
+ z ? /* @__PURE__ */ t.jsx("div", { className: "flex items-center justify-center py-10 text-muted-foreground", children: /* @__PURE__ */ t.jsx(ce, { className: "h-4 w-4 animate-spin" }) }) : T ? /* @__PURE__ */ t.jsx("div", { className: "py-10 text-center text-sm text-muted-foreground", children: T }) : b.length === 0 ? /* @__PURE__ */ t.jsx("div", { className: "py-10 text-center text-sm text-muted-foreground", children: "No notifications." }) : /* @__PURE__ */ t.jsxs("div", { className: "flex flex-col gap-4", children: [
222
253
  /* @__PURE__ */ t.jsxs("div", { children: [
223
254
  /* @__PURE__ */ t.jsx("div", { className: "sticky top-0 z-20 -mx-4 flex h-8 items-center border-b bg-background px-4 text-xs font-semibold text-muted-foreground", children: "Unread notifications" }),
224
- U.length === 0 ? /* @__PURE__ */ t.jsx("div", { className: "py-6 text-center text-sm text-muted-foreground", children: "No unread notifications." }) : U.map((o) => /* @__PURE__ */ t.jsxs("div", { children: [
225
- /* @__PURE__ */ t.jsx("div", { className: "sticky top-8 z-10 -mx-4 flex h-7 items-center bg-background px-4 text-[11px] font-semibold text-muted-foreground", children: o.label }),
226
- /* @__PURE__ */ t.jsx("div", { className: "-mx-4 flex flex-col divide-y divide-border", children: o.items.map((m) => /* @__PURE__ */ t.jsx(Z, { notification: m, onMarkRead: V, onArchive: X }, m.id)) })
227
- ] }, `unread:${o.key}`))
255
+ F.length === 0 ? /* @__PURE__ */ t.jsx("div", { className: "py-6 text-center text-sm text-muted-foreground", children: "No unread notifications." }) : F.map((s) => /* @__PURE__ */ t.jsxs("div", { children: [
256
+ /* @__PURE__ */ t.jsx("div", { className: "sticky top-8 z-10 -mx-4 flex h-7 items-center bg-background px-4 text-[11px] font-semibold text-muted-foreground", children: s.label }),
257
+ /* @__PURE__ */ t.jsx("div", { className: "-mx-4 flex flex-col divide-y divide-border", children: s.items.map((d) => /* @__PURE__ */ t.jsx(ee, { notification: d, onMarkRead: _, onArchive: Q, onAction: X }, d.id)) })
258
+ ] }, `unread:${s.key}`))
228
259
  ] }),
229
- p ? null : /* @__PURE__ */ t.jsxs("div", { children: [
260
+ h ? null : /* @__PURE__ */ t.jsxs("div", { children: [
230
261
  /* @__PURE__ */ t.jsx("div", { className: "sticky top-0 z-20 -mx-4 flex h-8 items-center border-b bg-background px-4 text-xs font-semibold text-muted-foreground", children: "Previous notifications" }),
231
- I.length === 0 ? /* @__PURE__ */ t.jsx("div", { className: "py-6 text-center text-sm text-muted-foreground", children: "No previous notifications." }) : I.map((o) => /* @__PURE__ */ t.jsxs("div", { children: [
232
- /* @__PURE__ */ t.jsx("div", { className: "sticky top-8 z-10 -mx-4 flex h-7 items-center bg-background px-4 text-[11px] font-semibold text-muted-foreground", children: o.label }),
233
- /* @__PURE__ */ t.jsx("div", { className: "-mx-4 flex flex-col divide-y divide-border", children: o.items.map((m) => /* @__PURE__ */ t.jsx(Z, { notification: m, onMarkRead: V, onArchive: X }, m.id)) })
234
- ] }, `previous:${o.key}`))
262
+ B.length === 0 ? /* @__PURE__ */ t.jsx("div", { className: "py-6 text-center text-sm text-muted-foreground", children: "No previous notifications." }) : B.map((s) => /* @__PURE__ */ t.jsxs("div", { children: [
263
+ /* @__PURE__ */ t.jsx("div", { className: "sticky top-8 z-10 -mx-4 flex h-7 items-center bg-background px-4 text-[11px] font-semibold text-muted-foreground", children: s.label }),
264
+ /* @__PURE__ */ t.jsx("div", { className: "-mx-4 flex flex-col divide-y divide-border", children: s.items.map((d) => /* @__PURE__ */ t.jsx(ee, { notification: d, onMarkRead: _, onArchive: Q, onAction: X }, d.id)) })
265
+ ] }, `previous:${s.key}`))
235
266
  ] })
236
267
  ] })
237
268
  ] })
238
269
  ] })
239
270
  ] }) });
240
271
  }
241
- function be(r) {
242
- const e = _.c(13), {
272
+ function ke(o) {
273
+ const e = te.c(13), {
243
274
  permission: n,
244
- requesting: s,
275
+ requesting: r,
245
276
  onEnable: a
246
- } = r;
277
+ } = o;
247
278
  if (n === "granted")
248
279
  return null;
249
280
  if (n === "unsupported") {
250
281
  let v;
251
282
  return e[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (v = /* @__PURE__ */ t.jsx("div", { className: "mt-3 rounded-md border bg-muted/40 p-3 text-sm text-muted-foreground", children: "Browser notifications are not supported by this browser." }), e[0] = v) : v = e[0], v;
252
283
  }
253
- const c = n === "denied", i = c ? "Browser notifications are blocked." : "Browser notifications are not enabled.";
254
- let f;
255
- e[1] !== i ? (f = /* @__PURE__ */ t.jsx("div", { className: "text-sm font-medium", children: i }), e[1] = i, e[2] = f) : f = e[2];
256
- const h = c ? "Enable notifications for this site in your browser settings, then click again." : "Enable browser notifications to receive important alerts.";
257
- let l;
258
- e[3] !== h ? (l = /* @__PURE__ */ t.jsx("div", { className: "mt-1 text-xs text-muted-foreground", children: h }), e[3] = h, e[4] = l) : l = e[4];
259
- const b = s ? "Enabling..." : "Enable browser notifications";
260
- let d;
261
- e[5] !== a || e[6] !== s || e[7] !== b ? (d = /* @__PURE__ */ t.jsx("button", { type: "button", className: "mt-3 inline-flex h-8 items-center rounded-md border bg-background px-2.5 text-xs font-medium hover:bg-accent disabled:pointer-events-none disabled:opacity-50", disabled: s, onClick: a, children: b }), e[5] = a, e[6] = s, e[7] = b, e[8] = d) : d = e[8];
284
+ const y = n === "denied", i = y ? "Browser notifications are blocked." : "Browser notifications are not enabled.";
285
+ let c;
286
+ e[1] !== i ? (c = /* @__PURE__ */ t.jsx("div", { className: "text-sm font-medium", children: i }), e[1] = i, e[2] = c) : c = e[2];
287
+ const w = y ? "Enable notifications for this site in your browser settings, then click again." : "Enable browser notifications to receive important alerts.";
288
+ let m;
289
+ e[3] !== w ? (m = /* @__PURE__ */ t.jsx("div", { className: "mt-1 text-xs text-muted-foreground", children: w }), e[3] = w, e[4] = m) : m = e[4];
290
+ const u = r ? "Enabling..." : "Enable browser notifications";
262
291
  let x;
263
- return e[9] !== f || e[10] !== l || e[11] !== d ? (x = /* @__PURE__ */ t.jsxs("div", { className: "mt-3 rounded-md border bg-muted/40 p-3", children: [
264
- f,
265
- l,
266
- d
267
- ] }), e[9] = f, e[10] = l, e[11] = d, e[12] = x) : x = e[12], x;
292
+ e[5] !== a || e[6] !== r || e[7] !== u ? (x = /* @__PURE__ */ t.jsx("button", { type: "button", className: "mt-3 inline-flex h-8 items-center rounded-md border bg-background px-2.5 text-xs font-medium hover:bg-accent disabled:pointer-events-none disabled:opacity-50", disabled: r, onClick: a, children: u }), e[5] = a, e[6] = r, e[7] = u, e[8] = x) : x = e[8];
293
+ let f;
294
+ return e[9] !== c || e[10] !== m || e[11] !== x ? (f = /* @__PURE__ */ t.jsxs("div", { className: "mt-3 rounded-md border bg-muted/40 p-3", children: [
295
+ c,
296
+ m,
297
+ x
298
+ ] }), e[9] = c, e[10] = m, e[11] = x, e[12] = f) : f = e[12], f;
268
299
  }
269
- function Z(r) {
270
- const e = _.c(47), {
300
+ function ee(o) {
301
+ const e = te.c(48), {
271
302
  notification: n,
272
- onMarkRead: s,
273
- onArchive: a
274
- } = r, [c, i] = R(!1), f = H(null), h = H(null), l = !n.readAt;
275
- let b;
276
- e[0] !== n ? (b = pe(n), e[0] = n, e[1] = b) : b = e[1];
277
- const d = b;
303
+ onMarkRead: r,
304
+ onArchive: a,
305
+ onAction: y
306
+ } = o, [i, c] = U(!1), w = H(null), m = H(null), u = !n.readAt;
278
307
  let x;
308
+ e[0] !== n ? (x = we(n), e[0] = n, e[1] = x) : x = e[1];
309
+ const f = x, v = f?.link ?? "";
310
+ let M;
279
311
  if (e[2] !== n.createdAt) {
280
312
  e: {
281
- const U = new Date(ee(n.createdAt));
282
- if (!Number.isFinite(U.getTime())) {
283
- x = "";
313
+ const B = new Date(ne(n.createdAt));
314
+ if (!Number.isFinite(B.getTime())) {
315
+ M = "";
284
316
  break e;
285
317
  }
286
- x = U.toLocaleString();
318
+ M = B.toLocaleString();
287
319
  }
288
- e[2] = n.createdAt, e[3] = x;
320
+ e[2] = n.createdAt, e[3] = M;
289
321
  } else
290
- x = e[3];
291
- const v = x;
292
- let B, q;
293
- e[4] !== c ? (B = () => {
294
- if (!c)
322
+ M = e[3];
323
+ const q = M;
324
+ let L, h;
325
+ e[4] !== i ? (L = () => {
326
+ if (!i)
295
327
  return;
296
- const U = (L) => {
297
- const K = L.target;
298
- K instanceof Node && (f.current?.contains(K) || h.current?.contains(K) || i(!1));
299
- }, I = (L) => {
300
- L.key === "Escape" && (i(!1), h.current?.focus());
328
+ const B = (Y) => {
329
+ const _ = Y.target;
330
+ _ instanceof Node && (w.current?.contains(_) || m.current?.contains(_) || c(!1));
331
+ }, I = (Y) => {
332
+ Y.key === "Escape" && (c(!1), m.current?.focus());
301
333
  };
302
- return document.addEventListener("pointerdown", U), document.addEventListener("keydown", I), () => {
303
- document.removeEventListener("pointerdown", U), document.removeEventListener("keydown", I);
334
+ return document.addEventListener("pointerdown", B), document.addEventListener("keydown", I), () => {
335
+ document.removeEventListener("pointerdown", B), document.removeEventListener("keydown", I);
304
336
  };
305
- }, q = [c], e[4] = c, e[5] = B, e[6] = q) : (B = e[5], q = e[6]), J(B, q);
306
- const T = l ? "bg-primary/5" : "bg-background";
307
- let p;
308
- e[7] !== T ? (p = W("group flex w-full gap-3 px-4 py-3 hover:bg-accent/40", T), e[7] = T, e[8] = p) : p = e[8];
309
- let P;
310
- e[9] !== l || e[10] !== d || e[11] !== n.id || e[12] !== s ? (P = () => {
311
- l && s(n.id), d && (window.location.href = d);
312
- }, e[9] = l, e[10] = d, e[11] = n.id, e[12] = s, e[13] = P) : P = e[13];
313
- let M;
314
- e[14] !== n.title ? (M = /* @__PURE__ */ t.jsx("div", { className: "truncate text-sm font-semibold", children: n.title }), e[14] = n.title, e[15] = M) : M = e[15];
315
- let g;
316
- e[16] !== n.body ? (g = n.body ? /* @__PURE__ */ t.jsx("div", { className: "mt-0.5 line-clamp-2 text-xs text-muted-foreground", children: n.body }) : null, e[16] = n.body, e[17] = g) : g = e[17];
337
+ }, h = [i], e[4] = i, e[5] = L, e[6] = h) : (L = e[5], h = e[6]), W(L, h);
338
+ const K = u ? "bg-primary/5" : "bg-background";
317
339
  let O;
318
- e[18] !== M || e[19] !== g ? (O = /* @__PURE__ */ t.jsxs("div", { className: "min-w-0", children: [
319
- M,
320
- g
321
- ] }), e[18] = M, e[19] = g, e[20] = O) : O = e[20];
340
+ e[7] !== K ? (O = V("group flex w-full gap-3 px-4 py-3 hover:bg-accent/40", K), e[7] = K, e[8] = O) : O = e[8];
341
+ let p;
342
+ e[9] !== f || e[10] !== u || e[11] !== n.id || e[12] !== y || e[13] !== r ? (p = () => {
343
+ u && r(n.id), f && (y(), Ne(f));
344
+ }, e[9] = f, e[10] = u, e[11] = n.id, e[12] = y, e[13] = r, e[14] = p) : p = e[14];
345
+ let $;
346
+ e[15] !== n.title ? ($ = /* @__PURE__ */ t.jsx("div", { className: "truncate text-sm font-semibold", children: n.title }), e[15] = n.title, e[16] = $) : $ = e[16];
322
347
  let k;
323
- e[21] !== d ? (k = d ? /* @__PURE__ */ t.jsx("div", { className: "mt-2 truncate text-xs text-primary", children: d }) : null, e[21] = d, e[22] = k) : k = e[22];
348
+ e[17] !== n.body ? (k = n.body ? /* @__PURE__ */ t.jsx("div", { className: "mt-0.5 line-clamp-2 text-xs text-muted-foreground", children: n.body }) : null, e[17] = n.body, e[18] = k) : k = e[18];
324
349
  let A;
325
- e[23] !== v ? (A = v ? /* @__PURE__ */ t.jsx("div", { className: "mt-2 text-[11px] text-muted-foreground", children: v }) : null, e[23] = v, e[24] = A) : A = e[24];
350
+ e[19] !== $ || e[20] !== k ? (A = /* @__PURE__ */ t.jsxs("div", { className: "min-w-0", children: [
351
+ $,
352
+ k
353
+ ] }), e[19] = $, e[20] = k, e[21] = A) : A = e[21];
326
354
  let C;
327
- e[25] !== O || e[26] !== k || e[27] !== A || e[28] !== P ? (C = /* @__PURE__ */ t.jsxs("button", { type: "button", className: "min-w-0 flex-1 text-left", onClick: P, children: [
328
- O,
329
- k,
330
- A
331
- ] }), e[25] = O, e[26] = k, e[27] = A, e[28] = P, e[29] = C) : C = e[29];
332
- let F, z;
333
- e[30] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (F = () => {
334
- i(ge);
335
- }, z = /* @__PURE__ */ t.jsx(se, { className: "h-4 w-4" }), e[30] = F, e[31] = z) : (F = e[30], z = e[31]);
355
+ e[22] !== v ? (C = v ? /* @__PURE__ */ t.jsx("div", { className: "mt-2 truncate text-xs text-primary", children: v }) : null, e[22] = v, e[23] = C) : C = e[23];
356
+ let R;
357
+ e[24] !== q ? (R = q ? /* @__PURE__ */ t.jsx("div", { className: "mt-2 text-[11px] text-muted-foreground", children: q }) : null, e[24] = q, e[25] = R) : R = e[25];
336
358
  let S;
337
- e[32] !== c ? (S = /* @__PURE__ */ t.jsx("button", { ref: h, type: "button", className: "inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-accent", "aria-label": "Notification options", "aria-haspopup": "menu", "aria-expanded": c, onClick: F, children: z }), e[32] = c, e[33] = S) : S = e[33];
338
- let y;
339
- e[34] !== l || e[35] !== c || e[36] !== n.id || e[37] !== a || e[38] !== s ? (y = c ? /* @__PURE__ */ t.jsxs("div", { ref: f, role: "menu", className: W("absolute right-0 top-full z-50 mt-1 min-w-[10rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md", "animate-in fade-in-0 zoom-in-95"), children: [
359
+ e[26] !== A || e[27] !== C || e[28] !== R || e[29] !== p ? (S = /* @__PURE__ */ t.jsxs("button", { type: "button", className: "min-w-0 flex-1 text-left", onClick: p, children: [
360
+ A,
361
+ C,
362
+ R
363
+ ] }), e[26] = A, e[27] = C, e[28] = R, e[29] = p, e[30] = S) : S = e[30];
364
+ let z, T;
365
+ e[31] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (z = () => {
366
+ c(Ae);
367
+ }, T = /* @__PURE__ */ t.jsx(le, { className: "h-4 w-4" }), e[31] = z, e[32] = T) : (z = e[31], T = e[32]);
368
+ let b;
369
+ e[33] !== i ? (b = /* @__PURE__ */ t.jsx("button", { ref: m, type: "button", className: "inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-accent", "aria-label": "Notification options", "aria-haspopup": "menu", "aria-expanded": i, onClick: z, children: T }), e[33] = i, e[34] = b) : b = e[34];
370
+ let E;
371
+ e[35] !== u || e[36] !== i || e[37] !== n.id || e[38] !== a || e[39] !== r ? (E = i ? /* @__PURE__ */ t.jsxs("div", { ref: w, role: "menu", className: V("absolute right-0 top-full z-50 mt-1 min-w-[10rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md", "animate-in fade-in-0 zoom-in-95"), children: [
340
372
  /* @__PURE__ */ t.jsx("button", { type: "button", role: "menuitem", className: "relative flex w-full cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm outline-none transition-colors hover:bg-accent focus:bg-accent focus:text-accent-foreground", onClick: () => {
341
- i(!1), a(n.id);
373
+ c(!1), a(n.id);
342
374
  }, children: "Archive" }),
343
- /* @__PURE__ */ t.jsx("button", { type: "button", role: "menuitem", className: "relative flex w-full cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm outline-none transition-colors hover:bg-accent focus:bg-accent focus:text-accent-foreground disabled:pointer-events-none disabled:opacity-50", disabled: !l, onClick: () => {
344
- i(!1), s(n.id);
375
+ /* @__PURE__ */ t.jsx("button", { type: "button", role: "menuitem", className: "relative flex w-full cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm outline-none transition-colors hover:bg-accent focus:bg-accent focus:text-accent-foreground disabled:pointer-events-none disabled:opacity-50", disabled: !u, onClick: () => {
376
+ c(!1), r(n.id);
345
377
  }, children: "Mark as read" })
346
- ] }) : null, e[34] = l, e[35] = c, e[36] = n.id, e[37] = a, e[38] = s, e[39] = y) : y = e[39];
378
+ ] }) : null, e[35] = u, e[36] = i, e[37] = n.id, e[38] = a, e[39] = r, e[40] = E) : E = e[40];
347
379
  let D;
348
- e[40] !== S || e[41] !== y ? (D = /* @__PURE__ */ t.jsxs("div", { className: "relative flex items-start", children: [
380
+ e[41] !== b || e[42] !== E ? (D = /* @__PURE__ */ t.jsxs("div", { className: "relative flex items-start", children: [
381
+ b,
382
+ E
383
+ ] }), e[41] = b, e[42] = E, e[43] = D) : D = e[43];
384
+ let F;
385
+ return e[44] !== S || e[45] !== D || e[46] !== O ? (F = /* @__PURE__ */ t.jsxs("div", { className: O, children: [
349
386
  S,
350
- y
351
- ] }), e[40] = S, e[41] = y, e[42] = D) : D = e[42];
352
- let $;
353
- return e[43] !== C || e[44] !== D || e[45] !== p ? ($ = /* @__PURE__ */ t.jsxs("div", { className: p, children: [
354
- C,
355
387
  D
356
- ] }), e[43] = C, e[44] = D, e[45] = p, e[46] = $) : $ = e[46], $;
388
+ ] }), e[44] = S, e[45] = D, e[46] = O, e[47] = F) : F = e[47], F;
357
389
  }
358
- function ge(r) {
359
- return !r;
390
+ function Ae(o) {
391
+ return !o;
360
392
  }
361
393
  export {
362
- Re as NotificationsDrawer
394
+ Be as NotificationsDrawer
363
395
  };
364
396
  //# sourceMappingURL=index16.js.map