@krak-stack/registry 0.1.6 → 0.1.9
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.
- package/README.md +24 -0
- package/dist/components/ui/data-table.js +78 -28
- package/dist/components/ui/editing-locale-switcher.js +8 -0
- package/dist/components/ui/effect-form.js +71 -21
- package/dist/components/ui/file-picker.js +8 -0
- package/dist/components/ui/form.d.ts +5 -5
- package/dist/components/ui/form.js +71 -21
- package/dist/components/ui/google-map.js +8 -0
- package/dist/components/ui/icon-input.js +71 -21
- package/dist/components/ui/loading.js +8 -0
- package/dist/components/ui/locale-switcher.js +8 -0
- package/dist/components/ui/pagination.js +8 -0
- package/dist/components/ui/search-menu.js +8 -0
- package/dist/components/ui/tabs.d.ts +10 -0
- package/dist/components/ui/theme-switcher.js +8 -0
- package/dist/components/ui/virtualized-combobox.d.ts +3 -0
- package/dist/components/ui/virtualized-combobox.js +71 -21
- package/dist/lib/docs-ai.d.ts +3 -3
- package/dist/lib/docs-ai.js +2 -1
- package/dist/lib/docs-core.d.ts +32 -27
- package/dist/lib/docs-core.js +134 -35
- package/dist/lib/seo.d.ts +88 -0
- package/dist/lib/seo.js +104 -0
- package/dist/services/agent/client/index.js +8 -0
- package/dist/services/notification/client/index.d.ts +1 -0
- package/dist/services/notification/client/index.js +1123 -0
- package/dist/services/notification/client/notification-menu.d.ts +82 -0
- package/dist/services/notification/public.d.ts +2 -0
- package/dist/services/notification/public.js +1194 -0
- package/package.json +13 -13
- package/dist/services/embedding.d.ts +0 -2
- package/dist/services/embedding.js +0 -23
- package/dist/services/opentelemetry.d.ts +0 -8
- package/dist/services/opentelemetry.js +0 -23
|
@@ -0,0 +1,1123 @@
|
|
|
1
|
+
// ../../src/services/notification/client/notification-menu.tsx
|
|
2
|
+
import {
|
|
3
|
+
Archive,
|
|
4
|
+
ArchiveRestore,
|
|
5
|
+
Bell,
|
|
6
|
+
BellDot,
|
|
7
|
+
Inbox,
|
|
8
|
+
TriangleAlert
|
|
9
|
+
} from "lucide-react";
|
|
10
|
+
import { useState } from "react";
|
|
11
|
+
|
|
12
|
+
// ../../src/components/ui/badge.tsx
|
|
13
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
14
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
15
|
+
import { cva } from "class-variance-authority";
|
|
16
|
+
|
|
17
|
+
// ../../src/lib/utils.ts
|
|
18
|
+
import { clsx } from "clsx";
|
|
19
|
+
import { twMerge } from "tailwind-merge";
|
|
20
|
+
function cn(...inputs) {
|
|
21
|
+
return twMerge(clsx(inputs));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// ../../src/components/ui/badge.tsx
|
|
25
|
+
var badgeVariants = cva("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!", {
|
|
26
|
+
variants: {
|
|
27
|
+
variant: {
|
|
28
|
+
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
|
29
|
+
secondary: "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
|
|
30
|
+
destructive: "bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",
|
|
31
|
+
outline: "border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",
|
|
32
|
+
ghost: "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
|
|
33
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
defaultVariants: {
|
|
37
|
+
variant: "default"
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
function Badge({
|
|
41
|
+
className,
|
|
42
|
+
variant = "default",
|
|
43
|
+
render,
|
|
44
|
+
...props
|
|
45
|
+
}) {
|
|
46
|
+
return useRender({
|
|
47
|
+
defaultTagName: "span",
|
|
48
|
+
props: mergeProps({
|
|
49
|
+
className: cn(badgeVariants({ variant }), className)
|
|
50
|
+
}, props),
|
|
51
|
+
render,
|
|
52
|
+
state: {
|
|
53
|
+
slot: "badge",
|
|
54
|
+
variant
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ../../src/components/ui/button.tsx
|
|
60
|
+
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
61
|
+
import { cva as cva2 } from "class-variance-authority";
|
|
62
|
+
import { jsx } from "react/jsx-runtime";
|
|
63
|
+
var buttonVariants = cva2("group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
|
|
64
|
+
variants: {
|
|
65
|
+
variant: {
|
|
66
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/80",
|
|
67
|
+
outline: "border-border bg-background shadow-xs hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
|
68
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
|
|
69
|
+
ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
70
|
+
destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
|
|
71
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
72
|
+
},
|
|
73
|
+
size: {
|
|
74
|
+
default: "h-9 gap-1.5 px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
75
|
+
xs: "h-6 gap-1 rounded-[min(var(--radius-md),8px)] px-2 text-xs in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
76
|
+
sm: "h-8 gap-1 rounded-[min(var(--radius-md),10px)] px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5",
|
|
77
|
+
lg: "h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
78
|
+
icon: "size-9",
|
|
79
|
+
"icon-xs": "size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3",
|
|
80
|
+
"icon-sm": "size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md",
|
|
81
|
+
"icon-lg": "size-10"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
defaultVariants: {
|
|
85
|
+
variant: "default",
|
|
86
|
+
size: "default"
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
function Button({
|
|
90
|
+
className,
|
|
91
|
+
variant = "default",
|
|
92
|
+
size = "default",
|
|
93
|
+
...props
|
|
94
|
+
}) {
|
|
95
|
+
return /* @__PURE__ */ jsx(ButtonPrimitive, {
|
|
96
|
+
"data-slot": "button",
|
|
97
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
98
|
+
...props
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// ../../src/components/ui/empty.tsx
|
|
103
|
+
import { cva as cva3 } from "class-variance-authority";
|
|
104
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
105
|
+
function Empty({ className, ...props }) {
|
|
106
|
+
return /* @__PURE__ */ jsx2("div", {
|
|
107
|
+
"data-slot": "empty",
|
|
108
|
+
className: cn("flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-lg border-dashed p-12 text-center text-balance", className),
|
|
109
|
+
...props
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
function EmptyHeader({ className, ...props }) {
|
|
113
|
+
return /* @__PURE__ */ jsx2("div", {
|
|
114
|
+
"data-slot": "empty-header",
|
|
115
|
+
className: cn("flex max-w-sm flex-col items-center gap-2", className),
|
|
116
|
+
...props
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
var emptyMediaVariants = cva3("mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0", {
|
|
120
|
+
variants: {
|
|
121
|
+
variant: {
|
|
122
|
+
default: "bg-transparent",
|
|
123
|
+
icon: "flex size-10 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground [&_svg:not([class*='size-'])]:size-6"
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
defaultVariants: {
|
|
127
|
+
variant: "default"
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
function EmptyMedia({
|
|
131
|
+
className,
|
|
132
|
+
variant = "default",
|
|
133
|
+
...props
|
|
134
|
+
}) {
|
|
135
|
+
return /* @__PURE__ */ jsx2("div", {
|
|
136
|
+
"data-slot": "empty-icon",
|
|
137
|
+
"data-variant": variant,
|
|
138
|
+
className: cn(emptyMediaVariants({ variant, className })),
|
|
139
|
+
...props
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function EmptyTitle({ className, ...props }) {
|
|
143
|
+
return /* @__PURE__ */ jsx2("div", {
|
|
144
|
+
"data-slot": "empty-title",
|
|
145
|
+
className: cn("text-lg font-medium tracking-tight", className),
|
|
146
|
+
...props
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
function EmptyDescription({ className, ...props }) {
|
|
150
|
+
return /* @__PURE__ */ jsx2("div", {
|
|
151
|
+
"data-slot": "empty-description",
|
|
152
|
+
className: cn("text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary", className),
|
|
153
|
+
...props
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// ../../src/components/ui/popover.tsx
|
|
158
|
+
import { Popover as PopoverPrimitive } from "@base-ui/react/popover";
|
|
159
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
160
|
+
function Popover({ ...props }) {
|
|
161
|
+
return /* @__PURE__ */ jsx3(PopoverPrimitive.Root, {
|
|
162
|
+
"data-slot": "popover",
|
|
163
|
+
...props
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function PopoverTrigger({ ...props }) {
|
|
167
|
+
return /* @__PURE__ */ jsx3(PopoverPrimitive.Trigger, {
|
|
168
|
+
"data-slot": "popover-trigger",
|
|
169
|
+
...props
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
function PopoverContent({
|
|
173
|
+
className,
|
|
174
|
+
align = "center",
|
|
175
|
+
alignOffset = 0,
|
|
176
|
+
side = "bottom",
|
|
177
|
+
sideOffset = 4,
|
|
178
|
+
...props
|
|
179
|
+
}) {
|
|
180
|
+
return /* @__PURE__ */ jsx3(PopoverPrimitive.Portal, {
|
|
181
|
+
children: /* @__PURE__ */ jsx3(PopoverPrimitive.Positioner, {
|
|
182
|
+
align,
|
|
183
|
+
alignOffset,
|
|
184
|
+
side,
|
|
185
|
+
sideOffset,
|
|
186
|
+
className: "isolate z-50",
|
|
187
|
+
children: /* @__PURE__ */ jsx3(PopoverPrimitive.Popup, {
|
|
188
|
+
"data-slot": "popover-content",
|
|
189
|
+
className: cn("z-50 flex w-72 origin-(--transform-origin) flex-col gap-4 rounded-md bg-popover p-4 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className),
|
|
190
|
+
...props
|
|
191
|
+
})
|
|
192
|
+
})
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
function PopoverHeader({ className, ...props }) {
|
|
196
|
+
return /* @__PURE__ */ jsx3("div", {
|
|
197
|
+
"data-slot": "popover-header",
|
|
198
|
+
className: cn("flex flex-col gap-1 text-sm", className),
|
|
199
|
+
...props
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
function PopoverTitle({ className, ...props }) {
|
|
203
|
+
return /* @__PURE__ */ jsx3(PopoverPrimitive.Title, {
|
|
204
|
+
"data-slot": "popover-title",
|
|
205
|
+
className: cn("font-medium", className),
|
|
206
|
+
...props
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// ../../src/components/ui/scroll-area.tsx
|
|
211
|
+
import { ScrollArea as ScrollAreaPrimitive } from "@base-ui/react/scroll-area";
|
|
212
|
+
import { jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
213
|
+
function ScrollArea({
|
|
214
|
+
className,
|
|
215
|
+
children,
|
|
216
|
+
...props
|
|
217
|
+
}) {
|
|
218
|
+
return /* @__PURE__ */ jsxs(ScrollAreaPrimitive.Root, {
|
|
219
|
+
"data-slot": "scroll-area",
|
|
220
|
+
className: cn("relative", className),
|
|
221
|
+
...props,
|
|
222
|
+
children: [
|
|
223
|
+
/* @__PURE__ */ jsx4(ScrollAreaPrimitive.Viewport, {
|
|
224
|
+
"data-slot": "scroll-area-viewport",
|
|
225
|
+
className: "focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",
|
|
226
|
+
children
|
|
227
|
+
}),
|
|
228
|
+
/* @__PURE__ */ jsx4(ScrollBar, {}),
|
|
229
|
+
/* @__PURE__ */ jsx4(ScrollAreaPrimitive.Corner, {})
|
|
230
|
+
]
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
function ScrollBar({
|
|
234
|
+
className,
|
|
235
|
+
orientation = "vertical",
|
|
236
|
+
...props
|
|
237
|
+
}) {
|
|
238
|
+
return /* @__PURE__ */ jsx4(ScrollAreaPrimitive.Scrollbar, {
|
|
239
|
+
"data-slot": "scroll-area-scrollbar",
|
|
240
|
+
"data-orientation": orientation,
|
|
241
|
+
orientation,
|
|
242
|
+
className: cn("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent", className),
|
|
243
|
+
...props,
|
|
244
|
+
children: /* @__PURE__ */ jsx4(ScrollAreaPrimitive.Thumb, {
|
|
245
|
+
"data-slot": "scroll-area-thumb",
|
|
246
|
+
className: "bg-border relative flex-1 rounded-full"
|
|
247
|
+
})
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// ../../src/components/ui/skeleton.tsx
|
|
252
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
253
|
+
function Skeleton({ className, ...props }) {
|
|
254
|
+
return /* @__PURE__ */ jsx5("div", {
|
|
255
|
+
"data-slot": "skeleton",
|
|
256
|
+
className: cn("animate-pulse rounded-md bg-muted", className),
|
|
257
|
+
...props
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// ../../src/components/ui/tabs.tsx
|
|
262
|
+
import { Tabs as TabsPrimitive } from "@base-ui/react/tabs";
|
|
263
|
+
import { cva as cva4 } from "class-variance-authority";
|
|
264
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
265
|
+
function Tabs({
|
|
266
|
+
className,
|
|
267
|
+
orientation = "horizontal",
|
|
268
|
+
...props
|
|
269
|
+
}) {
|
|
270
|
+
return /* @__PURE__ */ jsx6(TabsPrimitive.Root, {
|
|
271
|
+
"data-slot": "tabs",
|
|
272
|
+
"data-orientation": orientation,
|
|
273
|
+
className: cn("group/tabs flex gap-2 data-horizontal:flex-col", className),
|
|
274
|
+
...props
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
var tabsListVariants = cva4("group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-9 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none", {
|
|
278
|
+
variants: {
|
|
279
|
+
variant: {
|
|
280
|
+
default: "bg-muted",
|
|
281
|
+
line: "gap-1 bg-transparent"
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
defaultVariants: {
|
|
285
|
+
variant: "default"
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
function TabsList({
|
|
289
|
+
className,
|
|
290
|
+
variant = "default",
|
|
291
|
+
...props
|
|
292
|
+
}) {
|
|
293
|
+
return /* @__PURE__ */ jsx6(TabsPrimitive.List, {
|
|
294
|
+
"data-slot": "tabs-list",
|
|
295
|
+
"data-variant": variant,
|
|
296
|
+
className: cn(tabsListVariants({ variant }), className),
|
|
297
|
+
...props
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
function TabsTrigger({ className, ...props }) {
|
|
301
|
+
return /* @__PURE__ */ jsx6(TabsPrimitive.Tab, {
|
|
302
|
+
"data-slot": "tabs-trigger",
|
|
303
|
+
className: cn("relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", "group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent", "data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground", "after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100", className),
|
|
304
|
+
...props
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// ../../src/paraglide/runtime.js
|
|
309
|
+
import"@inlang/paraglide-js/urlpattern-polyfill";
|
|
310
|
+
var baseLocale = "en";
|
|
311
|
+
var locales = ["en", "fr"];
|
|
312
|
+
var cookieName = "locale";
|
|
313
|
+
var cookieMaxAge = 34560000;
|
|
314
|
+
var cookieDomain = "";
|
|
315
|
+
var localStorageKey = "PARAGLIDE_LOCALE";
|
|
316
|
+
var strategy = [
|
|
317
|
+
"url",
|
|
318
|
+
"cookie",
|
|
319
|
+
"preferredLanguage",
|
|
320
|
+
"baseLocale"
|
|
321
|
+
];
|
|
322
|
+
var routeStrategies = [
|
|
323
|
+
{
|
|
324
|
+
match: "/api/:path(.*)?",
|
|
325
|
+
exclude: true
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
match: "/sitemap.xml",
|
|
329
|
+
exclude: true
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
match: "/llms.txt",
|
|
333
|
+
exclude: true
|
|
334
|
+
}
|
|
335
|
+
];
|
|
336
|
+
var urlPatterns = [
|
|
337
|
+
{
|
|
338
|
+
pattern: "/:path(.*)?",
|
|
339
|
+
localized: [
|
|
340
|
+
[
|
|
341
|
+
"en",
|
|
342
|
+
"/en/:path(.*)?"
|
|
343
|
+
],
|
|
344
|
+
[
|
|
345
|
+
"fr",
|
|
346
|
+
"/fr/:path(.*)?"
|
|
347
|
+
]
|
|
348
|
+
]
|
|
349
|
+
}
|
|
350
|
+
];
|
|
351
|
+
var cachedRouteStrategyUrl;
|
|
352
|
+
var cachedRouteStrategy;
|
|
353
|
+
function findMatchingRouteStrategy(url) {
|
|
354
|
+
if (routeStrategies.length === 0) {
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
const urlString = typeof url === "string" ? url : url.href;
|
|
358
|
+
if (cachedRouteStrategyUrl === urlString) {
|
|
359
|
+
return cachedRouteStrategy;
|
|
360
|
+
}
|
|
361
|
+
const urlObject = new URL(urlString, "http://dummy.com");
|
|
362
|
+
let match;
|
|
363
|
+
for (const routeStrategy of routeStrategies) {
|
|
364
|
+
const pattern = new URLPattern(routeStrategy.match, urlObject.href);
|
|
365
|
+
if (pattern.exec(urlObject.href)) {
|
|
366
|
+
match = routeStrategy;
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
cachedRouteStrategyUrl = urlString;
|
|
371
|
+
cachedRouteStrategy = match;
|
|
372
|
+
return match;
|
|
373
|
+
}
|
|
374
|
+
function getStrategyForUrl(url) {
|
|
375
|
+
const routeStrategy = findMatchingRouteStrategy(url);
|
|
376
|
+
if (routeStrategy && routeStrategy.exclude !== true && Array.isArray(routeStrategy.strategy)) {
|
|
377
|
+
return routeStrategy.strategy;
|
|
378
|
+
}
|
|
379
|
+
return strategy;
|
|
380
|
+
}
|
|
381
|
+
var serverAsyncLocalStorage = undefined;
|
|
382
|
+
var isServer = import.meta.env?.SSR ?? typeof window === "undefined";
|
|
383
|
+
var experimentalStaticLocale = undefined;
|
|
384
|
+
var TREE_SHAKE_COOKIE_STRATEGY_USED = true;
|
|
385
|
+
var TREE_SHAKE_URL_STRATEGY_USED = true;
|
|
386
|
+
var TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED = false;
|
|
387
|
+
var TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED = true;
|
|
388
|
+
var TREE_SHAKE_DEFAULT_URL_PATTERN_USED = false;
|
|
389
|
+
var TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED = false;
|
|
390
|
+
globalThis.__paraglide = globalThis.__paraglide ?? {};
|
|
391
|
+
globalThis.__paraglide.ssr = globalThis.__paraglide.ssr ?? {};
|
|
392
|
+
var _locale;
|
|
393
|
+
var localeInitiallySet = false;
|
|
394
|
+
var getLocale = () => {
|
|
395
|
+
if (experimentalStaticLocale !== undefined) {
|
|
396
|
+
return experimentalStaticLocale;
|
|
397
|
+
}
|
|
398
|
+
if (serverAsyncLocalStorage) {
|
|
399
|
+
const locale = serverAsyncLocalStorage?.getStore()?.locale;
|
|
400
|
+
if (locale) {
|
|
401
|
+
return locale;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
let strategyToUse = strategy;
|
|
405
|
+
if (!isServer && typeof window !== "undefined" && window.location?.href) {
|
|
406
|
+
strategyToUse = getStrategyForUrl(window.location.href);
|
|
407
|
+
}
|
|
408
|
+
const resolved = resolveLocaleWithStrategies(strategyToUse, typeof window !== "undefined" ? window.location?.href : undefined);
|
|
409
|
+
if (resolved) {
|
|
410
|
+
if (!localeInitiallySet) {
|
|
411
|
+
_locale = resolved;
|
|
412
|
+
localeInitiallySet = true;
|
|
413
|
+
setLocale(resolved, { reload: false });
|
|
414
|
+
}
|
|
415
|
+
return resolved;
|
|
416
|
+
}
|
|
417
|
+
throw new Error("No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found");
|
|
418
|
+
};
|
|
419
|
+
function resolveLocaleWithStrategies(strategyToUse, urlForUrlStrategy) {
|
|
420
|
+
let locale;
|
|
421
|
+
for (const strat of strategyToUse) {
|
|
422
|
+
if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
|
|
423
|
+
locale = extractLocaleFromCookie();
|
|
424
|
+
} else if (strat === "baseLocale") {
|
|
425
|
+
locale = baseLocale;
|
|
426
|
+
} else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url" && !isServer && typeof urlForUrlStrategy === "string") {
|
|
427
|
+
locale = extractLocaleFromUrl(urlForUrlStrategy);
|
|
428
|
+
} else if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === "globalVariable" && _locale !== undefined) {
|
|
429
|
+
locale = _locale;
|
|
430
|
+
} else if (TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED && strat === "preferredLanguage" && !isServer) {
|
|
431
|
+
locale = extractLocaleFromNavigator();
|
|
432
|
+
} else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === "localStorage" && !isServer) {
|
|
433
|
+
locale = localStorage.getItem(localStorageKey) ?? undefined;
|
|
434
|
+
} else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
|
|
435
|
+
const handler = customClientStrategies.get(strat);
|
|
436
|
+
if (handler) {
|
|
437
|
+
const result = handler.getLocale();
|
|
438
|
+
if (result instanceof Promise) {
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
if (result !== undefined) {
|
|
442
|
+
return assertIsLocale(result);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
const matchedLocale = toLocale(locale);
|
|
447
|
+
if (matchedLocale) {
|
|
448
|
+
return matchedLocale;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
var rtlLanguages = new Set([
|
|
454
|
+
"ar",
|
|
455
|
+
"dv",
|
|
456
|
+
"fa",
|
|
457
|
+
"he",
|
|
458
|
+
"ks",
|
|
459
|
+
"ku",
|
|
460
|
+
"ps",
|
|
461
|
+
"sd",
|
|
462
|
+
"ug",
|
|
463
|
+
"ur",
|
|
464
|
+
"yi"
|
|
465
|
+
]);
|
|
466
|
+
var navigateOrReload = (newLocation) => {
|
|
467
|
+
if (newLocation) {
|
|
468
|
+
window.location.href = newLocation;
|
|
469
|
+
} else {
|
|
470
|
+
window.location.reload();
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
var setLocale = (newLocale, options) => {
|
|
474
|
+
const optionsWithDefaults = {
|
|
475
|
+
reload: true,
|
|
476
|
+
...options
|
|
477
|
+
};
|
|
478
|
+
let currentLocale;
|
|
479
|
+
try {
|
|
480
|
+
currentLocale = getLocale();
|
|
481
|
+
} catch {}
|
|
482
|
+
const customSetLocalePromises = [];
|
|
483
|
+
let newLocation = undefined;
|
|
484
|
+
let strategyToUse = strategy;
|
|
485
|
+
if (!isServer && typeof window !== "undefined" && window.location?.href) {
|
|
486
|
+
strategyToUse = getStrategyForUrl(window.location.href);
|
|
487
|
+
}
|
|
488
|
+
for (const strat of strategyToUse) {
|
|
489
|
+
if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === "globalVariable") {
|
|
490
|
+
_locale = newLocale;
|
|
491
|
+
} else if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
|
|
492
|
+
if (isServer || typeof document === "undefined" || typeof window === "undefined") {
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
const cookieString = `${cookieName}=${newLocale}; path=/; max-age=${cookieMaxAge}`;
|
|
496
|
+
document.cookie = cookieDomain ? `${cookieString}; domain=${cookieDomain}` : cookieString;
|
|
497
|
+
} else if (strat === "baseLocale") {
|
|
498
|
+
continue;
|
|
499
|
+
} else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url" && typeof window !== "undefined") {
|
|
500
|
+
newLocation = localizeUrl(window.location.href, {
|
|
501
|
+
locale: newLocale
|
|
502
|
+
}).href;
|
|
503
|
+
} else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === "localStorage" && typeof window !== "undefined") {
|
|
504
|
+
localStorage.setItem(localStorageKey, newLocale);
|
|
505
|
+
} else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
|
|
506
|
+
const handler = customClientStrategies.get(strat);
|
|
507
|
+
if (handler) {
|
|
508
|
+
let result = handler.setLocale(newLocale);
|
|
509
|
+
if (result instanceof Promise) {
|
|
510
|
+
result = result.catch((error) => {
|
|
511
|
+
throw new Error(`Custom strategy "${strat}" setLocale failed.`, {
|
|
512
|
+
cause: error
|
|
513
|
+
});
|
|
514
|
+
});
|
|
515
|
+
customSetLocalePromises.push(result);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
const runReload = () => {
|
|
521
|
+
if (!isServer && optionsWithDefaults.reload && window.location && newLocale !== currentLocale) {
|
|
522
|
+
navigateOrReload(newLocation);
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
if (customSetLocalePromises.length) {
|
|
526
|
+
return Promise.all(customSetLocalePromises).then(() => {
|
|
527
|
+
runReload();
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
runReload();
|
|
531
|
+
return;
|
|
532
|
+
};
|
|
533
|
+
var getUrlOrigin = () => {
|
|
534
|
+
if (serverAsyncLocalStorage) {
|
|
535
|
+
return serverAsyncLocalStorage.getStore()?.origin ?? "http://fallback.com";
|
|
536
|
+
} else if (typeof window !== "undefined") {
|
|
537
|
+
return window.location.origin;
|
|
538
|
+
}
|
|
539
|
+
return "http://fallback.com";
|
|
540
|
+
};
|
|
541
|
+
function toLocale(value) {
|
|
542
|
+
if (typeof value !== "string") {
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
const lowerValue = value.toLowerCase();
|
|
546
|
+
for (const locale of locales) {
|
|
547
|
+
if (locale.toLowerCase() === lowerValue) {
|
|
548
|
+
return locale;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
function assertIsLocale(input) {
|
|
554
|
+
const locale = toLocale(input);
|
|
555
|
+
if (locale)
|
|
556
|
+
return locale;
|
|
557
|
+
throw new Error(`Invalid locale: ${input}. Expected one of: ${locales.join(", ")}`);
|
|
558
|
+
}
|
|
559
|
+
function extractLocaleFromCookie() {
|
|
560
|
+
if (typeof document === "undefined" || !document.cookie) {
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
const match = document.cookie.match(new RegExp(`(^| )${cookieName}=([^;]+)`));
|
|
564
|
+
const locale = match?.[2];
|
|
565
|
+
return toLocale(locale);
|
|
566
|
+
}
|
|
567
|
+
function extractLocaleFromNavigator() {
|
|
568
|
+
if (!navigator?.languages?.length) {
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
const languages = navigator.languages.map((lang) => ({
|
|
572
|
+
fullTag: lang,
|
|
573
|
+
baseTag: lang.split("-")[0]
|
|
574
|
+
}));
|
|
575
|
+
for (const lang of languages) {
|
|
576
|
+
const fullLocale = toLocale(lang.fullTag);
|
|
577
|
+
if (fullLocale) {
|
|
578
|
+
return fullLocale;
|
|
579
|
+
}
|
|
580
|
+
const baseLocale2 = toLocale(lang.baseTag);
|
|
581
|
+
if (baseLocale2) {
|
|
582
|
+
return baseLocale2;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
var cachedUrl;
|
|
588
|
+
var cachedLocale;
|
|
589
|
+
function extractLocaleFromUrl(url) {
|
|
590
|
+
const urlString = typeof url === "string" ? url : url.href;
|
|
591
|
+
if (cachedUrl === urlString) {
|
|
592
|
+
return cachedLocale;
|
|
593
|
+
}
|
|
594
|
+
let result;
|
|
595
|
+
if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
|
|
596
|
+
result = defaultUrlPatternExtractLocale(url);
|
|
597
|
+
} else {
|
|
598
|
+
const urlObj = typeof url === "string" ? new URL(url) : url;
|
|
599
|
+
for (const element of urlPatterns) {
|
|
600
|
+
for (const [locale, localizedPattern] of element.localized) {
|
|
601
|
+
const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
|
|
602
|
+
if (match) {
|
|
603
|
+
result = locale;
|
|
604
|
+
break;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
if (result)
|
|
608
|
+
break;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
cachedUrl = urlString;
|
|
612
|
+
cachedLocale = result;
|
|
613
|
+
return result;
|
|
614
|
+
}
|
|
615
|
+
function defaultUrlPatternExtractLocale(url) {
|
|
616
|
+
const urlObj = new URL(url, "http://dummy.com");
|
|
617
|
+
const pathSegments = urlObj.pathname.split("/").filter(Boolean);
|
|
618
|
+
return toLocale(pathSegments[0]) || baseLocale;
|
|
619
|
+
}
|
|
620
|
+
function localizeUrl(url, options) {
|
|
621
|
+
const targetLocale = options?.locale ? assertIsLocale(options?.locale) : getLocale();
|
|
622
|
+
if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
|
|
623
|
+
return localizeUrlDefaultPattern(url, targetLocale);
|
|
624
|
+
}
|
|
625
|
+
const urlObj = typeof url === "string" ? new URL(url) : url;
|
|
626
|
+
for (const element of urlPatterns) {
|
|
627
|
+
for (const [, localizedPattern] of element.localized) {
|
|
628
|
+
const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
|
|
629
|
+
if (!match) {
|
|
630
|
+
continue;
|
|
631
|
+
}
|
|
632
|
+
const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
|
|
633
|
+
if (!targetPattern) {
|
|
634
|
+
continue;
|
|
635
|
+
}
|
|
636
|
+
const localizedUrl = fillPattern(targetPattern, aggregateGroups(match), urlObj.origin);
|
|
637
|
+
return fillMissingUrlParts(localizedUrl, match);
|
|
638
|
+
}
|
|
639
|
+
const unlocalizedMatch = new URLPattern(element.pattern, urlObj.href).exec(urlObj.href);
|
|
640
|
+
if (unlocalizedMatch) {
|
|
641
|
+
const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
|
|
642
|
+
if (targetPattern) {
|
|
643
|
+
const localizedUrl = fillPattern(targetPattern, aggregateGroups(unlocalizedMatch), urlObj.origin);
|
|
644
|
+
return fillMissingUrlParts(localizedUrl, unlocalizedMatch);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
return urlObj;
|
|
649
|
+
}
|
|
650
|
+
function localizeUrlDefaultPattern(url, locale) {
|
|
651
|
+
const urlObj = typeof url === "string" ? new URL(url, getUrlOrigin()) : new URL(url);
|
|
652
|
+
const currentLocale = extractLocaleFromUrl(urlObj);
|
|
653
|
+
if (currentLocale === locale) {
|
|
654
|
+
return urlObj;
|
|
655
|
+
}
|
|
656
|
+
const pathSegments = urlObj.pathname.split("/").filter(Boolean);
|
|
657
|
+
if (pathSegments.length > 0 && toLocale(pathSegments[0])) {
|
|
658
|
+
pathSegments.shift();
|
|
659
|
+
}
|
|
660
|
+
if (locale === baseLocale) {
|
|
661
|
+
urlObj.pathname = "/" + pathSegments.join("/");
|
|
662
|
+
} else {
|
|
663
|
+
urlObj.pathname = "/" + locale + "/" + pathSegments.join("/");
|
|
664
|
+
}
|
|
665
|
+
return urlObj;
|
|
666
|
+
}
|
|
667
|
+
function fillMissingUrlParts(url, match) {
|
|
668
|
+
if (match.protocol.groups["0"]) {
|
|
669
|
+
url.protocol = match.protocol.groups["0"] ?? "";
|
|
670
|
+
}
|
|
671
|
+
if (match.hostname.groups["0"]) {
|
|
672
|
+
url.hostname = match.hostname.groups["0"] ?? "";
|
|
673
|
+
}
|
|
674
|
+
if (match.username.groups["0"]) {
|
|
675
|
+
url.username = match.username.groups["0"] ?? "";
|
|
676
|
+
}
|
|
677
|
+
if (match.password.groups["0"]) {
|
|
678
|
+
url.password = match.password.groups["0"] ?? "";
|
|
679
|
+
}
|
|
680
|
+
if (match.port.groups["0"]) {
|
|
681
|
+
url.port = match.port.groups["0"] ?? "";
|
|
682
|
+
}
|
|
683
|
+
if (match.pathname.groups["0"]) {
|
|
684
|
+
url.pathname = match.pathname.groups["0"] ?? "";
|
|
685
|
+
}
|
|
686
|
+
if (match.search.groups["0"]) {
|
|
687
|
+
url.search = match.search.groups["0"] ?? "";
|
|
688
|
+
}
|
|
689
|
+
if (match.hash.groups["0"]) {
|
|
690
|
+
url.hash = match.hash.groups["0"] ?? "";
|
|
691
|
+
}
|
|
692
|
+
return url;
|
|
693
|
+
}
|
|
694
|
+
function fillPattern(pattern, values, origin) {
|
|
695
|
+
let processedPattern = pattern.replace(/(https?:\/\/[^:/]+):(\d+)(\/|$)/g, (_, protocol, port, slash) => {
|
|
696
|
+
return `${protocol}#PORT-${port}#${slash}`;
|
|
697
|
+
});
|
|
698
|
+
let processedGroupDelimiters = processedPattern.replace(/\{([^{}]*)\}([?+*]?)/g, (_, content, modifier) => {
|
|
699
|
+
if (modifier === "?") {
|
|
700
|
+
return content;
|
|
701
|
+
}
|
|
702
|
+
return content;
|
|
703
|
+
});
|
|
704
|
+
let filled = processedGroupDelimiters.replace(/(\/?):([a-zA-Z0-9_]+)(\([^)]*\))?([?+*]?)/g, (_, slash, name, __, modifier) => {
|
|
705
|
+
const value = values[name];
|
|
706
|
+
if (value === null) {
|
|
707
|
+
return "";
|
|
708
|
+
}
|
|
709
|
+
if (modifier === "?") {
|
|
710
|
+
return value !== undefined ? `${slash}${value}` : "";
|
|
711
|
+
}
|
|
712
|
+
if (modifier === "+" || modifier === "*") {
|
|
713
|
+
if (value === undefined && modifier === "+") {
|
|
714
|
+
throw new Error(`Missing value for "${name}" (one or more required)`);
|
|
715
|
+
}
|
|
716
|
+
return value ? `${slash}${value}` : "";
|
|
717
|
+
}
|
|
718
|
+
if (value === undefined) {
|
|
719
|
+
throw new Error(`Missing value for "${name}"`);
|
|
720
|
+
}
|
|
721
|
+
return `${slash}${value}`;
|
|
722
|
+
});
|
|
723
|
+
filled = filled.replace(/#PORT-(\d+)#/g, ":$1");
|
|
724
|
+
return new URL(filled, origin);
|
|
725
|
+
}
|
|
726
|
+
function aggregateGroups(match) {
|
|
727
|
+
return {
|
|
728
|
+
...match.hash.groups,
|
|
729
|
+
...match.hostname.groups,
|
|
730
|
+
...match.password.groups,
|
|
731
|
+
...match.pathname.groups,
|
|
732
|
+
...match.port.groups,
|
|
733
|
+
...match.protocol.groups,
|
|
734
|
+
...match.search.groups,
|
|
735
|
+
...match.username.groups
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
var customServerStrategies = new Map;
|
|
739
|
+
var customClientStrategies = new Map;
|
|
740
|
+
function isCustomStrategy(strategy2) {
|
|
741
|
+
return typeof strategy2 === "string" && /^custom-[A-Za-z0-9_-]+$/.test(strategy2);
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
// ../../src/services/notification/client/notification-menu.tsx
|
|
745
|
+
import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
746
|
+
var defaultMessages = {
|
|
747
|
+
en: {
|
|
748
|
+
archive: "Archive",
|
|
749
|
+
archiveAll: "Archive all",
|
|
750
|
+
archiveItem: (title) => `Archive ${title}`,
|
|
751
|
+
archived: "Archived",
|
|
752
|
+
emptyArchiveDescription: "Notifications you archive will appear here.",
|
|
753
|
+
emptyArchiveTitle: "No archived notifications",
|
|
754
|
+
emptyInboxDescription: "You are all caught up.",
|
|
755
|
+
emptyInboxTitle: "No new notifications",
|
|
756
|
+
errorDescription: "Refresh the page and try again.",
|
|
757
|
+
errorTitle: "Notifications could not be loaded",
|
|
758
|
+
inbox: "Inbox",
|
|
759
|
+
loading: "Loading notifications",
|
|
760
|
+
notifications: "Notifications",
|
|
761
|
+
unread: (count) => `${count} unread ${count === 1 ? "notification" : "notifications"}`
|
|
762
|
+
},
|
|
763
|
+
fr: {
|
|
764
|
+
archive: "Archiver",
|
|
765
|
+
archiveAll: "Tout archiver",
|
|
766
|
+
archiveItem: (title) => `Archiver ${title}`,
|
|
767
|
+
archived: "Archivées",
|
|
768
|
+
emptyArchiveDescription: "Les notifications que vous archivez apparaîtront ici.",
|
|
769
|
+
emptyArchiveTitle: "Aucune notification archivée",
|
|
770
|
+
emptyInboxDescription: "Vous êtes à jour.",
|
|
771
|
+
emptyInboxTitle: "Aucune nouvelle notification",
|
|
772
|
+
errorDescription: "Actualisez la page et réessayez.",
|
|
773
|
+
errorTitle: "Impossible de charger les notifications",
|
|
774
|
+
inbox: "Boîte de réception",
|
|
775
|
+
loading: "Chargement des notifications",
|
|
776
|
+
notifications: "Notifications",
|
|
777
|
+
unread: (count) => `${count} notification${count === 1 ? "" : "s"} non lue${count === 1 ? "" : "s"}`
|
|
778
|
+
}
|
|
779
|
+
};
|
|
780
|
+
var notificationMenuMessages = (locale = getLocale(), overrides) => ({
|
|
781
|
+
...locale.startsWith("fr") ? defaultMessages.fr : defaultMessages.en,
|
|
782
|
+
...overrides
|
|
783
|
+
});
|
|
784
|
+
function NotificationMenu({
|
|
785
|
+
className,
|
|
786
|
+
defaultOpen = false,
|
|
787
|
+
error = false,
|
|
788
|
+
isLoading = false,
|
|
789
|
+
locale = getLocale(),
|
|
790
|
+
markReadOnOpen = true,
|
|
791
|
+
messages: messageOverrides,
|
|
792
|
+
notifications,
|
|
793
|
+
onArchive,
|
|
794
|
+
onMarkRead,
|
|
795
|
+
onNavigate,
|
|
796
|
+
onOpenChange,
|
|
797
|
+
open: controlledOpen,
|
|
798
|
+
renderItem,
|
|
799
|
+
renderTrigger
|
|
800
|
+
}) {
|
|
801
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
|
|
802
|
+
const [tab, setTab] = useState("inbox");
|
|
803
|
+
const open = controlledOpen ?? uncontrolledOpen;
|
|
804
|
+
const labels = notificationMenuMessages(locale, messageOverrides);
|
|
805
|
+
const inbox = notifications.filter((notification) => !notification.archivedAt);
|
|
806
|
+
const archive = notifications.filter((notification) => notification.archivedAt);
|
|
807
|
+
const unreadIds = inbox.filter((notification) => !notification.readAt).map((notification) => notification.id);
|
|
808
|
+
const triggerState = {
|
|
809
|
+
archivedCount: archive.length,
|
|
810
|
+
open,
|
|
811
|
+
unreadCount: unreadIds.length
|
|
812
|
+
};
|
|
813
|
+
const handleOpenChange = (nextOpen) => {
|
|
814
|
+
if (controlledOpen === undefined)
|
|
815
|
+
setUncontrolledOpen(nextOpen);
|
|
816
|
+
onOpenChange?.(nextOpen);
|
|
817
|
+
if (nextOpen && markReadOnOpen && unreadIds.length > 0) {
|
|
818
|
+
onMarkRead?.(unreadIds);
|
|
819
|
+
}
|
|
820
|
+
};
|
|
821
|
+
return /* @__PURE__ */ jsxs2(Popover, {
|
|
822
|
+
open,
|
|
823
|
+
onOpenChange: handleOpenChange,
|
|
824
|
+
children: [
|
|
825
|
+
renderTrigger ? /* @__PURE__ */ jsx7(PopoverTrigger, {
|
|
826
|
+
render: renderTrigger(triggerState)
|
|
827
|
+
}) : /* @__PURE__ */ jsx7(NotificationMenuTrigger, {
|
|
828
|
+
labels,
|
|
829
|
+
unreadCount: unreadIds.length
|
|
830
|
+
}),
|
|
831
|
+
/* @__PURE__ */ jsxs2(PopoverContent, {
|
|
832
|
+
align: "end",
|
|
833
|
+
className: cn("max-h-[min(32rem,80svh)] w-96 max-w-[calc(100vw-1rem)] gap-0 p-0", className),
|
|
834
|
+
children: [
|
|
835
|
+
/* @__PURE__ */ jsx7(PopoverHeader, {
|
|
836
|
+
className: "border-b px-4 py-3",
|
|
837
|
+
children: /* @__PURE__ */ jsx7(PopoverTitle, {
|
|
838
|
+
children: labels.notifications
|
|
839
|
+
})
|
|
840
|
+
}),
|
|
841
|
+
/* @__PURE__ */ jsxs2(Tabs, {
|
|
842
|
+
value: tab,
|
|
843
|
+
onValueChange: (value) => setTab(value === "archive" ? "archive" : "inbox"),
|
|
844
|
+
className: "min-h-0 gap-0",
|
|
845
|
+
children: [
|
|
846
|
+
/* @__PURE__ */ jsxs2("div", {
|
|
847
|
+
className: "flex items-center gap-2 border-b p-2",
|
|
848
|
+
children: [
|
|
849
|
+
/* @__PURE__ */ jsxs2(TabsList, {
|
|
850
|
+
className: "grid flex-1 grid-cols-2",
|
|
851
|
+
children: [
|
|
852
|
+
/* @__PURE__ */ jsxs2(TabsTrigger, {
|
|
853
|
+
value: "inbox",
|
|
854
|
+
children: [
|
|
855
|
+
/* @__PURE__ */ jsx7(Inbox, {
|
|
856
|
+
"data-icon": "inline-start"
|
|
857
|
+
}),
|
|
858
|
+
labels.inbox,
|
|
859
|
+
inbox.length > 0 ? /* @__PURE__ */ jsx7(Badge, {
|
|
860
|
+
variant: "secondary",
|
|
861
|
+
children: inbox.length
|
|
862
|
+
}) : null
|
|
863
|
+
]
|
|
864
|
+
}),
|
|
865
|
+
/* @__PURE__ */ jsxs2(TabsTrigger, {
|
|
866
|
+
value: "archive",
|
|
867
|
+
children: [
|
|
868
|
+
/* @__PURE__ */ jsx7(ArchiveRestore, {
|
|
869
|
+
"data-icon": "inline-start"
|
|
870
|
+
}),
|
|
871
|
+
labels.archived
|
|
872
|
+
]
|
|
873
|
+
})
|
|
874
|
+
]
|
|
875
|
+
}),
|
|
876
|
+
tab === "inbox" && inbox.length > 0 && onArchive ? /* @__PURE__ */ jsx7(ArchiveButton, {
|
|
877
|
+
label: labels.archiveAll,
|
|
878
|
+
notificationIds: inbox.map((notification) => notification.id),
|
|
879
|
+
onArchive
|
|
880
|
+
}) : null
|
|
881
|
+
]
|
|
882
|
+
}),
|
|
883
|
+
/* @__PURE__ */ jsx7(NotificationList, {
|
|
884
|
+
error,
|
|
885
|
+
isLoading,
|
|
886
|
+
labels,
|
|
887
|
+
locale,
|
|
888
|
+
notifications: tab === "inbox" ? inbox : archive,
|
|
889
|
+
onArchive: tab === "inbox" ? onArchive : undefined,
|
|
890
|
+
onNavigate,
|
|
891
|
+
renderItem,
|
|
892
|
+
tab
|
|
893
|
+
}, tab)
|
|
894
|
+
]
|
|
895
|
+
})
|
|
896
|
+
]
|
|
897
|
+
})
|
|
898
|
+
]
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
function NotificationMenuTrigger({
|
|
902
|
+
labels = notificationMenuMessages(),
|
|
903
|
+
unreadCount
|
|
904
|
+
}) {
|
|
905
|
+
return /* @__PURE__ */ jsxs2(PopoverTrigger, {
|
|
906
|
+
"aria-label": unreadCount > 0 ? `${labels.notifications}, ${labels.unread(unreadCount)}` : labels.notifications,
|
|
907
|
+
className: cn(buttonVariants({ variant: "outline", size: "icon" }), "relative rounded-full"),
|
|
908
|
+
type: "button",
|
|
909
|
+
children: [
|
|
910
|
+
/* @__PURE__ */ jsx7(Bell, {}),
|
|
911
|
+
unreadCount > 0 ? /* @__PURE__ */ jsx7(Badge, {
|
|
912
|
+
"aria-hidden": "true",
|
|
913
|
+
className: "absolute -top-1 -right-1 min-w-5 px-1 tabular-nums",
|
|
914
|
+
children: unreadCount > 99 ? "99+" : unreadCount
|
|
915
|
+
}) : null
|
|
916
|
+
]
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
function NotificationList({
|
|
920
|
+
error,
|
|
921
|
+
isLoading,
|
|
922
|
+
labels,
|
|
923
|
+
locale,
|
|
924
|
+
notifications,
|
|
925
|
+
onArchive,
|
|
926
|
+
onNavigate,
|
|
927
|
+
renderItem,
|
|
928
|
+
tab
|
|
929
|
+
}) {
|
|
930
|
+
if (isLoading)
|
|
931
|
+
return /* @__PURE__ */ jsx7(NotificationListLoading, {
|
|
932
|
+
label: labels.loading
|
|
933
|
+
});
|
|
934
|
+
if (error) {
|
|
935
|
+
return /* @__PURE__ */ jsx7(NotificationEmpty, {
|
|
936
|
+
description: labels.errorDescription,
|
|
937
|
+
icon: /* @__PURE__ */ jsx7(TriangleAlert, {}),
|
|
938
|
+
title: labels.errorTitle
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
if (notifications.length === 0) {
|
|
942
|
+
return /* @__PURE__ */ jsx7(NotificationEmpty, {
|
|
943
|
+
description: tab === "inbox" ? labels.emptyInboxDescription : labels.emptyArchiveDescription,
|
|
944
|
+
icon: tab === "inbox" ? /* @__PURE__ */ jsx7(BellDot, {}) : /* @__PURE__ */ jsx7(Archive, {}),
|
|
945
|
+
title: tab === "inbox" ? labels.emptyInboxTitle : labels.emptyArchiveTitle
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
return /* @__PURE__ */ jsx7(ScrollArea, {
|
|
949
|
+
className: "h-[min(24rem,60svh)]",
|
|
950
|
+
children: /* @__PURE__ */ jsx7("div", {
|
|
951
|
+
className: "flex flex-col gap-1 p-2",
|
|
952
|
+
children: notifications.map((notification) => /* @__PURE__ */ jsx7(NotificationListItem, {
|
|
953
|
+
labels,
|
|
954
|
+
locale,
|
|
955
|
+
notification,
|
|
956
|
+
onArchive,
|
|
957
|
+
onNavigate,
|
|
958
|
+
renderItem
|
|
959
|
+
}, notification.id))
|
|
960
|
+
})
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
function NotificationListItem({
|
|
964
|
+
labels,
|
|
965
|
+
locale,
|
|
966
|
+
notification,
|
|
967
|
+
onArchive,
|
|
968
|
+
onNavigate,
|
|
969
|
+
renderItem
|
|
970
|
+
}) {
|
|
971
|
+
const unread = !notification.readAt && !notification.archivedAt;
|
|
972
|
+
const selectNotification = () => {
|
|
973
|
+
if (onNavigate) {
|
|
974
|
+
onNavigate(notification);
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
if (notification.href && typeof window !== "undefined") {
|
|
978
|
+
window.location.assign(notification.href);
|
|
979
|
+
}
|
|
980
|
+
};
|
|
981
|
+
return /* @__PURE__ */ jsxs2("div", {
|
|
982
|
+
className: cn("group flex min-w-0 items-start gap-1 rounded-lg", unread && "bg-muted/70"),
|
|
983
|
+
"data-unread": unread || undefined,
|
|
984
|
+
children: [
|
|
985
|
+
/* @__PURE__ */ jsx7(Button, {
|
|
986
|
+
className: "h-auto min-w-0 flex-1 justify-start px-3 py-2.5 text-left whitespace-normal",
|
|
987
|
+
disabled: !notification.href && !onNavigate,
|
|
988
|
+
onClick: selectNotification,
|
|
989
|
+
type: "button",
|
|
990
|
+
variant: "ghost",
|
|
991
|
+
children: renderItem?.(notification) ?? /* @__PURE__ */ jsxs2("span", {
|
|
992
|
+
className: "flex min-w-0 flex-1 flex-col gap-1",
|
|
993
|
+
children: [
|
|
994
|
+
/* @__PURE__ */ jsxs2("span", {
|
|
995
|
+
className: "flex min-w-0 items-start gap-2",
|
|
996
|
+
children: [
|
|
997
|
+
unread ? /* @__PURE__ */ jsx7("span", {
|
|
998
|
+
"aria-hidden": "true",
|
|
999
|
+
className: "bg-primary mt-1.5 size-2 shrink-0 rounded-full"
|
|
1000
|
+
}) : null,
|
|
1001
|
+
/* @__PURE__ */ jsx7("span", {
|
|
1002
|
+
className: "min-w-0 flex-1 font-medium",
|
|
1003
|
+
children: notification.title
|
|
1004
|
+
})
|
|
1005
|
+
]
|
|
1006
|
+
}),
|
|
1007
|
+
notification.description ? /* @__PURE__ */ jsx7("span", {
|
|
1008
|
+
className: "text-muted-foreground line-clamp-2 text-xs font-normal",
|
|
1009
|
+
children: notification.description
|
|
1010
|
+
}) : null,
|
|
1011
|
+
notification.timestampLabel || notification.createdAt ? /* @__PURE__ */ jsx7("span", {
|
|
1012
|
+
className: "text-muted-foreground text-xs font-normal",
|
|
1013
|
+
children: notification.timestampLabel ?? formatNotificationDate(notification.createdAt, locale)
|
|
1014
|
+
}) : null
|
|
1015
|
+
]
|
|
1016
|
+
})
|
|
1017
|
+
}),
|
|
1018
|
+
!notification.archivedAt && onArchive ? /* @__PURE__ */ jsx7(ArchiveButton, {
|
|
1019
|
+
className: "mt-2 mr-2 shrink-0",
|
|
1020
|
+
label: labels.archiveItem(notificationTitle(notification)),
|
|
1021
|
+
notificationIds: [notification.id],
|
|
1022
|
+
onArchive
|
|
1023
|
+
}) : null
|
|
1024
|
+
]
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
1027
|
+
function NotificationEmpty({
|
|
1028
|
+
description,
|
|
1029
|
+
icon,
|
|
1030
|
+
title
|
|
1031
|
+
}) {
|
|
1032
|
+
return /* @__PURE__ */ jsx7(Empty, {
|
|
1033
|
+
className: "min-h-48 p-6",
|
|
1034
|
+
children: /* @__PURE__ */ jsxs2(EmptyHeader, {
|
|
1035
|
+
children: [
|
|
1036
|
+
/* @__PURE__ */ jsx7(EmptyMedia, {
|
|
1037
|
+
variant: "icon",
|
|
1038
|
+
children: icon
|
|
1039
|
+
}),
|
|
1040
|
+
/* @__PURE__ */ jsx7(EmptyTitle, {
|
|
1041
|
+
className: "text-base",
|
|
1042
|
+
children: title
|
|
1043
|
+
}),
|
|
1044
|
+
/* @__PURE__ */ jsx7(EmptyDescription, {
|
|
1045
|
+
children: description
|
|
1046
|
+
})
|
|
1047
|
+
]
|
|
1048
|
+
})
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
function ArchiveButton({
|
|
1052
|
+
className,
|
|
1053
|
+
label,
|
|
1054
|
+
notificationIds,
|
|
1055
|
+
onArchive
|
|
1056
|
+
}) {
|
|
1057
|
+
const [pending, setPending] = useState(false);
|
|
1058
|
+
const archiveNotifications = async () => {
|
|
1059
|
+
setPending(true);
|
|
1060
|
+
try {
|
|
1061
|
+
await onArchive(notificationIds);
|
|
1062
|
+
} finally {
|
|
1063
|
+
setPending(false);
|
|
1064
|
+
}
|
|
1065
|
+
};
|
|
1066
|
+
return /* @__PURE__ */ jsx7(Button, {
|
|
1067
|
+
"aria-label": label,
|
|
1068
|
+
className,
|
|
1069
|
+
disabled: pending,
|
|
1070
|
+
onClick: () => void archiveNotifications(),
|
|
1071
|
+
size: "icon-sm",
|
|
1072
|
+
title: label,
|
|
1073
|
+
type: "button",
|
|
1074
|
+
variant: "ghost",
|
|
1075
|
+
children: /* @__PURE__ */ jsx7(Archive, {})
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
function NotificationListLoading({ label }) {
|
|
1079
|
+
return /* @__PURE__ */ jsx7("div", {
|
|
1080
|
+
"aria-label": label,
|
|
1081
|
+
className: "flex flex-col gap-2 p-3",
|
|
1082
|
+
role: "status",
|
|
1083
|
+
children: [0, 1, 2].map((item) => /* @__PURE__ */ jsxs2("div", {
|
|
1084
|
+
className: "flex items-center gap-3 p-2",
|
|
1085
|
+
children: [
|
|
1086
|
+
/* @__PURE__ */ jsx7(Skeleton, {
|
|
1087
|
+
className: "size-2 shrink-0 rounded-full"
|
|
1088
|
+
}),
|
|
1089
|
+
/* @__PURE__ */ jsxs2("div", {
|
|
1090
|
+
className: "flex flex-1 flex-col gap-2",
|
|
1091
|
+
children: [
|
|
1092
|
+
/* @__PURE__ */ jsx7(Skeleton, {
|
|
1093
|
+
className: "h-4 w-4/5"
|
|
1094
|
+
}),
|
|
1095
|
+
/* @__PURE__ */ jsx7(Skeleton, {
|
|
1096
|
+
className: "h-3 w-2/5"
|
|
1097
|
+
})
|
|
1098
|
+
]
|
|
1099
|
+
})
|
|
1100
|
+
]
|
|
1101
|
+
}, item))
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
var formatNotificationDate = (value, locale) => {
|
|
1105
|
+
if (!value)
|
|
1106
|
+
return;
|
|
1107
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
1108
|
+
if (Number.isNaN(date.getTime()))
|
|
1109
|
+
return;
|
|
1110
|
+
return new Intl.DateTimeFormat(locale, {
|
|
1111
|
+
dateStyle: "medium",
|
|
1112
|
+
timeStyle: "short"
|
|
1113
|
+
}).format(date);
|
|
1114
|
+
};
|
|
1115
|
+
var notificationTitle = (notification) => typeof notification.title === "string" ? notification.title : defaultMessages.en.notifications;
|
|
1116
|
+
export {
|
|
1117
|
+
notificationMenuMessages,
|
|
1118
|
+
NotificationMenuTrigger,
|
|
1119
|
+
NotificationMenu,
|
|
1120
|
+
NotificationListItem,
|
|
1121
|
+
NotificationList,
|
|
1122
|
+
NotificationEmpty
|
|
1123
|
+
};
|