@krak-stack/registry 0.1.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 (84) hide show
  1. package/README.md +29 -0
  2. package/dist/components/ui/alert-dialog.d.ts +18 -0
  3. package/dist/components/ui/app-brand.d.ts +26 -0
  4. package/dist/components/ui/app-brand.js +78 -0
  5. package/dist/components/ui/attachment.d.ts +23 -0
  6. package/dist/components/ui/badge.d.ts +7 -0
  7. package/dist/components/ui/button.d.ts +8 -0
  8. package/dist/components/ui/card.d.ts +11 -0
  9. package/dist/components/ui/checkbox.d.ts +3 -0
  10. package/dist/components/ui/code-block.d.ts +14 -0
  11. package/dist/components/ui/code-block.js +224 -0
  12. package/dist/components/ui/command.d.ts +18 -0
  13. package/dist/components/ui/copy-button.d.ts +18 -0
  14. package/dist/components/ui/copy-button.js +133 -0
  15. package/dist/components/ui/data-table.d.ts +264 -0
  16. package/dist/components/ui/data-table.js +3594 -0
  17. package/dist/components/ui/dialog.d.ts +13 -0
  18. package/dist/components/ui/dropdown-menu.d.ts +29 -0
  19. package/dist/components/ui/editing-locale-switcher.d.ts +7 -0
  20. package/dist/components/ui/editing-locale-switcher.js +626 -0
  21. package/dist/components/ui/effect-form.d.ts +137 -0
  22. package/dist/components/ui/effect-form.js +2330 -0
  23. package/dist/components/ui/field.d.ts +24 -0
  24. package/dist/components/ui/file-picker.d.ts +30 -0
  25. package/dist/components/ui/file-picker.js +811 -0
  26. package/dist/components/ui/form.d.ts +402 -0
  27. package/dist/components/ui/form.js +2245 -0
  28. package/dist/components/ui/google-map.d.ts +103 -0
  29. package/dist/components/ui/google-map.js +754 -0
  30. package/dist/components/ui/icon-input.d.ts +9 -0
  31. package/dist/components/ui/icon-input.js +971 -0
  32. package/dist/components/ui/input-group.d.ts +17 -0
  33. package/dist/components/ui/input.d.ts +3 -0
  34. package/dist/components/ui/label.d.ts +3 -0
  35. package/dist/components/ui/loading.d.ts +7 -0
  36. package/dist/components/ui/loading.js +467 -0
  37. package/dist/components/ui/locale-switcher.d.ts +7 -0
  38. package/dist/components/ui/locale-switcher.js +632 -0
  39. package/dist/components/ui/pagination.d.ts +43 -0
  40. package/dist/components/ui/pagination.js +787 -0
  41. package/dist/components/ui/popover.d.ts +9 -0
  42. package/dist/components/ui/scroll-area.d.ts +4 -0
  43. package/dist/components/ui/search-menu.d.ts +34 -0
  44. package/dist/components/ui/search-menu.js +839 -0
  45. package/dist/components/ui/select.d.ts +15 -0
  46. package/dist/components/ui/separator.d.ts +3 -0
  47. package/dist/components/ui/sheet.d.ts +14 -0
  48. package/dist/components/ui/sidebar-layout.d.ts +29 -0
  49. package/dist/components/ui/sidebar-layout.js +755 -0
  50. package/dist/components/ui/sidebar.d.ts +63 -0
  51. package/dist/components/ui/skeleton.d.ts +2 -0
  52. package/dist/components/ui/stats-card.d.ts +12 -0
  53. package/dist/components/ui/stats-card.js +125 -0
  54. package/dist/components/ui/table.d.ts +10 -0
  55. package/dist/components/ui/textarea.d.ts +3 -0
  56. package/dist/components/ui/theme-switcher.d.ts +29 -0
  57. package/dist/components/ui/theme-switcher.js +775 -0
  58. package/dist/components/ui/tooltip.d.ts +6 -0
  59. package/dist/components/ui/virtualized-combobox.d.ts +54 -0
  60. package/dist/components/ui/virtualized-combobox.js +821 -0
  61. package/dist/hooks/use-mobile.d.ts +1 -0
  62. package/dist/lib/query.d.ts +49 -0
  63. package/dist/lib/utils.d.ts +2 -0
  64. package/dist/paraglide/runtime.d.ts +978 -0
  65. package/dist/services/embedding.d.ts +2 -0
  66. package/dist/services/embedding.js +23 -0
  67. package/dist/services/notification/channels/index.d.ts +22 -0
  68. package/dist/services/notification/channels/index.js +11 -0
  69. package/dist/services/notification/channels/ses/index.d.ts +51 -0
  70. package/dist/services/notification/channels/ses/index.js +145 -0
  71. package/dist/services/notification/channels/ses/schema.d.ts +13 -0
  72. package/dist/services/notification/channels/ses/schema.js +35 -0
  73. package/dist/services/notification/index.d.ts +15 -0
  74. package/dist/services/notification/index.js +67 -0
  75. package/dist/services/notification/schema.d.ts +10 -0
  76. package/dist/services/notification/schema.js +30 -0
  77. package/dist/services/opentelemetry.d.ts +8 -0
  78. package/dist/services/opentelemetry.js +23 -0
  79. package/dist/services/s3/index.d.ts +62 -0
  80. package/dist/services/s3/index.js +208 -0
  81. package/dist/services/s3/schema.d.ts +18 -0
  82. package/dist/services/s3/schema.js +37 -0
  83. package/package.json +218 -0
  84. package/tailwind.css +1 -0
@@ -0,0 +1,811 @@
1
+ // ../../src/components/ui/file-picker.tsx
2
+ import {
3
+ useEffect,
4
+ useMemo,
5
+ useRef,
6
+ useState
7
+ } from "react";
8
+ import { CloudUpload, FileIcon, FileUp, RefreshCw, Trash2 } from "lucide-react";
9
+
10
+ // ../../src/components/ui/attachment.tsx
11
+ import { mergeProps } from "@base-ui/react/merge-props";
12
+ import { useRender } from "@base-ui/react/use-render";
13
+ import { cva as cva2 } from "class-variance-authority";
14
+
15
+ // ../../src/lib/utils.ts
16
+ import { clsx } from "clsx";
17
+ import { twMerge } from "tailwind-merge";
18
+ function cn(...inputs) {
19
+ return twMerge(clsx(inputs));
20
+ }
21
+
22
+ // ../../src/components/ui/button.tsx
23
+ import { Button as ButtonPrimitive } from "@base-ui/react/button";
24
+ import { cva } from "class-variance-authority";
25
+ import { jsxDEV } from "react/jsx-dev-runtime";
26
+ var buttonVariants = cva("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", {
27
+ variants: {
28
+ variant: {
29
+ default: "bg-primary text-primary-foreground hover:bg-primary/80",
30
+ 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",
31
+ 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",
32
+ ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
33
+ 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",
34
+ link: "text-primary underline-offset-4 hover:underline"
35
+ },
36
+ size: {
37
+ 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",
38
+ 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",
39
+ 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",
40
+ lg: "h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
41
+ icon: "size-9",
42
+ "icon-xs": "size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3",
43
+ "icon-sm": "size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md",
44
+ "icon-lg": "size-10"
45
+ }
46
+ },
47
+ defaultVariants: {
48
+ variant: "default",
49
+ size: "default"
50
+ }
51
+ });
52
+ function Button({
53
+ className,
54
+ variant = "default",
55
+ size = "default",
56
+ ...props
57
+ }) {
58
+ return /* @__PURE__ */ jsxDEV(ButtonPrimitive, {
59
+ "data-slot": "button",
60
+ className: cn(buttonVariants({ variant, size, className })),
61
+ ...props
62
+ }, undefined, false, undefined, this);
63
+ }
64
+
65
+ // ../../src/components/ui/attachment.tsx
66
+ import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
67
+ var attachmentVariants = cva2("group/attachment relative flex w-fit max-w-full min-w-0 shrink-0 flex-wrap rounded-xl border bg-card text-card-foreground transition-colors focus-within:ring-1 focus-within:ring-ring/50 has-[>a,>button]:hover:bg-muted/50 data-[state=error]:border-destructive/30 data-[state=idle]:border-dashed", {
68
+ variants: {
69
+ size: {
70
+ default: "gap-2 text-sm has-data-[slot=attachment-content]:px-2.5 has-data-[slot=attachment-content]:py-2 has-data-[slot=attachment-media]:p-2",
71
+ sm: "gap-2.5 text-xs has-data-[slot=attachment-content]:px-2 has-data-[slot=attachment-content]:py-1.5 has-data-[slot=attachment-media]:p-1.5",
72
+ xs: "gap-1.5 rounded-lg text-xs has-data-[slot=attachment-content]:px-1.5 has-data-[slot=attachment-content]:py-1 has-data-[slot=attachment-media]:p-1"
73
+ },
74
+ orientation: {
75
+ horizontal: "min-w-40 items-center",
76
+ vertical: "w-24 flex-col has-data-[slot=attachment-content]:w-30"
77
+ }
78
+ }
79
+ });
80
+ function Attachment({
81
+ className,
82
+ state = "done",
83
+ size = "default",
84
+ orientation = "horizontal",
85
+ ...props
86
+ }) {
87
+ return /* @__PURE__ */ jsxDEV2("div", {
88
+ "data-slot": "attachment",
89
+ "data-state": state,
90
+ "data-size": size,
91
+ "data-orientation": orientation,
92
+ className: cn(attachmentVariants({ size, orientation }), className),
93
+ ...props
94
+ }, undefined, false, undefined, this);
95
+ }
96
+ var attachmentMediaVariants = cva2("relative flex aspect-square w-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted text-foreground group-data-[orientation=vertical]/attachment:w-full group-data-[size=sm]/attachment:w-8 group-data-[size=xs]/attachment:w-7 group-data-[size=xs]/attachment:rounded-md group-data-[state=error]/attachment:bg-destructive/10 group-data-[state=error]/attachment:text-destructive group-data-[orientation=vertical]/attachment:*:data-[slot=spinner]:size-6! [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 group-data-[orientation=vertical]/attachment:[&_svg:not([class*='size-'])]:size-6 group-data-[size=xs]/attachment:[&_svg:not([class*='size-'])]:size-3.5", {
97
+ variants: {
98
+ variant: {
99
+ icon: "",
100
+ image: "opacity-60 group-data-[state=done]/attachment:opacity-100 group-data-[state=idle]/attachment:opacity-100 *:[img]:aspect-square *:[img]:w-full *:[img]:object-cover"
101
+ }
102
+ },
103
+ defaultVariants: {
104
+ variant: "icon"
105
+ }
106
+ });
107
+ function AttachmentMedia({
108
+ className,
109
+ variant = "icon",
110
+ ...props
111
+ }) {
112
+ return /* @__PURE__ */ jsxDEV2("div", {
113
+ "data-slot": "attachment-media",
114
+ "data-variant": variant,
115
+ className: cn(attachmentMediaVariants({ variant }), className),
116
+ ...props
117
+ }, undefined, false, undefined, this);
118
+ }
119
+ function AttachmentContent({
120
+ className,
121
+ ...props
122
+ }) {
123
+ return /* @__PURE__ */ jsxDEV2("div", {
124
+ "data-slot": "attachment-content",
125
+ className: cn("max-w-full min-w-0 flex-1 leading-tight group-data-[orientation=vertical]/attachment:px-1", className),
126
+ ...props
127
+ }, undefined, false, undefined, this);
128
+ }
129
+ function AttachmentTitle({
130
+ className,
131
+ ...props
132
+ }) {
133
+ return /* @__PURE__ */ jsxDEV2("span", {
134
+ "data-slot": "attachment-title",
135
+ className: cn("block max-w-full min-w-0 truncate font-medium group-data-[state=processing]/attachment:shimmer group-data-[state=uploading]/attachment:shimmer", className),
136
+ ...props
137
+ }, undefined, false, undefined, this);
138
+ }
139
+ function AttachmentDescription({
140
+ className,
141
+ ...props
142
+ }) {
143
+ return /* @__PURE__ */ jsxDEV2("span", {
144
+ "data-slot": "attachment-description",
145
+ className: cn("mt-0.5 block min-w-0 truncate text-xs text-muted-foreground group-data-[state=error]/attachment:text-destructive/80", "max-w-full", className),
146
+ ...props
147
+ }, undefined, false, undefined, this);
148
+ }
149
+ function AttachmentActions({
150
+ className,
151
+ ...props
152
+ }) {
153
+ return /* @__PURE__ */ jsxDEV2("div", {
154
+ "data-slot": "attachment-actions",
155
+ className: cn("relative z-20 flex shrink-0 items-center group-data-[orientation=vertical]/attachment:absolute group-data-[orientation=vertical]/attachment:top-3 group-data-[orientation=vertical]/attachment:right-3 group-data-[orientation=vertical]/attachment:gap-1", className),
156
+ ...props
157
+ }, undefined, false, undefined, this);
158
+ }
159
+ function AttachmentAction({
160
+ className,
161
+ variant,
162
+ size = "icon-xs",
163
+ ...props
164
+ }) {
165
+ return /* @__PURE__ */ jsxDEV2(Button, {
166
+ "data-slot": "attachment-action",
167
+ variant: variant ?? "ghost",
168
+ size,
169
+ className: cn(className),
170
+ ...props
171
+ }, undefined, false, undefined, this);
172
+ }
173
+
174
+ // ../../src/components/ui/input.tsx
175
+ import { Input as InputPrimitive } from "@base-ui/react/input";
176
+ import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
177
+ function Input({ className, type, ...props }) {
178
+ return /* @__PURE__ */ jsxDEV3(InputPrimitive, {
179
+ type,
180
+ "data-slot": "input",
181
+ className: cn("h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-2.5 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40", className),
182
+ ...props
183
+ }, undefined, false, undefined, this);
184
+ }
185
+
186
+ // ../../src/paraglide/runtime.js
187
+ import"@inlang/paraglide-js/urlpattern-polyfill";
188
+ var baseLocale = "en";
189
+ var locales = ["en", "fr"];
190
+ var cookieName = "locale";
191
+ var cookieMaxAge = 34560000;
192
+ var cookieDomain = "";
193
+ var localStorageKey = "PARAGLIDE_LOCALE";
194
+ var strategy = [
195
+ "url",
196
+ "cookie",
197
+ "preferredLanguage",
198
+ "baseLocale"
199
+ ];
200
+ var routeStrategies = [
201
+ {
202
+ match: "/api/:path(.*)?",
203
+ exclude: true
204
+ }
205
+ ];
206
+ var urlPatterns = [
207
+ {
208
+ pattern: "/:path(.*)?",
209
+ localized: [
210
+ [
211
+ "en",
212
+ "/en/:path(.*)?"
213
+ ],
214
+ [
215
+ "fr",
216
+ "/fr/:path(.*)?"
217
+ ]
218
+ ]
219
+ }
220
+ ];
221
+ var cachedRouteStrategyUrl;
222
+ var cachedRouteStrategy;
223
+ function findMatchingRouteStrategy(url) {
224
+ if (routeStrategies.length === 0) {
225
+ return;
226
+ }
227
+ const urlString = typeof url === "string" ? url : url.href;
228
+ if (cachedRouteStrategyUrl === urlString) {
229
+ return cachedRouteStrategy;
230
+ }
231
+ const urlObject = new URL(urlString, "http://dummy.com");
232
+ let match;
233
+ for (const routeStrategy of routeStrategies) {
234
+ const pattern = new URLPattern(routeStrategy.match, urlObject.href);
235
+ if (pattern.exec(urlObject.href)) {
236
+ match = routeStrategy;
237
+ break;
238
+ }
239
+ }
240
+ cachedRouteStrategyUrl = urlString;
241
+ cachedRouteStrategy = match;
242
+ return match;
243
+ }
244
+ function getStrategyForUrl(url) {
245
+ const routeStrategy = findMatchingRouteStrategy(url);
246
+ if (routeStrategy && routeStrategy.exclude !== true && Array.isArray(routeStrategy.strategy)) {
247
+ return routeStrategy.strategy;
248
+ }
249
+ return strategy;
250
+ }
251
+ var serverAsyncLocalStorage = undefined;
252
+ var isServer = import.meta.env?.SSR ?? typeof window === "undefined";
253
+ var experimentalStaticLocale = undefined;
254
+ var TREE_SHAKE_COOKIE_STRATEGY_USED = true;
255
+ var TREE_SHAKE_URL_STRATEGY_USED = true;
256
+ var TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED = false;
257
+ var TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED = true;
258
+ var TREE_SHAKE_DEFAULT_URL_PATTERN_USED = false;
259
+ var TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED = false;
260
+ globalThis.__paraglide = globalThis.__paraglide ?? {};
261
+ globalThis.__paraglide.ssr = globalThis.__paraglide.ssr ?? {};
262
+ var _locale;
263
+ var localeInitiallySet = false;
264
+ var getLocale = () => {
265
+ if (experimentalStaticLocale !== undefined) {
266
+ return experimentalStaticLocale;
267
+ }
268
+ if (serverAsyncLocalStorage) {
269
+ const locale = serverAsyncLocalStorage?.getStore()?.locale;
270
+ if (locale) {
271
+ return locale;
272
+ }
273
+ }
274
+ let strategyToUse = strategy;
275
+ if (!isServer && typeof window !== "undefined" && window.location?.href) {
276
+ strategyToUse = getStrategyForUrl(window.location.href);
277
+ }
278
+ const resolved = resolveLocaleWithStrategies(strategyToUse, typeof window !== "undefined" ? window.location?.href : undefined);
279
+ if (resolved) {
280
+ if (!localeInitiallySet) {
281
+ _locale = resolved;
282
+ localeInitiallySet = true;
283
+ setLocale(resolved, { reload: false });
284
+ }
285
+ return resolved;
286
+ }
287
+ throw new Error("No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found");
288
+ };
289
+ function resolveLocaleWithStrategies(strategyToUse, urlForUrlStrategy) {
290
+ let locale;
291
+ for (const strat of strategyToUse) {
292
+ if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
293
+ locale = extractLocaleFromCookie();
294
+ } else if (strat === "baseLocale") {
295
+ locale = baseLocale;
296
+ } else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url" && !isServer && typeof urlForUrlStrategy === "string") {
297
+ locale = extractLocaleFromUrl(urlForUrlStrategy);
298
+ } else if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === "globalVariable" && _locale !== undefined) {
299
+ locale = _locale;
300
+ } else if (TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED && strat === "preferredLanguage" && !isServer) {
301
+ locale = extractLocaleFromNavigator();
302
+ } else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === "localStorage" && !isServer) {
303
+ locale = localStorage.getItem(localStorageKey) ?? undefined;
304
+ } else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
305
+ const handler = customClientStrategies.get(strat);
306
+ if (handler) {
307
+ const result = handler.getLocale();
308
+ if (result instanceof Promise) {
309
+ continue;
310
+ }
311
+ if (result !== undefined) {
312
+ return assertIsLocale(result);
313
+ }
314
+ }
315
+ }
316
+ const matchedLocale = toLocale(locale);
317
+ if (matchedLocale) {
318
+ return matchedLocale;
319
+ }
320
+ }
321
+ return;
322
+ }
323
+ var rtlLanguages = new Set([
324
+ "ar",
325
+ "dv",
326
+ "fa",
327
+ "he",
328
+ "ks",
329
+ "ku",
330
+ "ps",
331
+ "sd",
332
+ "ug",
333
+ "ur",
334
+ "yi"
335
+ ]);
336
+ var navigateOrReload = (newLocation) => {
337
+ if (newLocation) {
338
+ window.location.href = newLocation;
339
+ } else {
340
+ window.location.reload();
341
+ }
342
+ };
343
+ var setLocale = (newLocale, options) => {
344
+ const optionsWithDefaults = {
345
+ reload: true,
346
+ ...options
347
+ };
348
+ let currentLocale;
349
+ try {
350
+ currentLocale = getLocale();
351
+ } catch {}
352
+ const customSetLocalePromises = [];
353
+ let newLocation = undefined;
354
+ let strategyToUse = strategy;
355
+ if (!isServer && typeof window !== "undefined" && window.location?.href) {
356
+ strategyToUse = getStrategyForUrl(window.location.href);
357
+ }
358
+ for (const strat of strategyToUse) {
359
+ if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === "globalVariable") {
360
+ _locale = newLocale;
361
+ } else if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
362
+ if (isServer || typeof document === "undefined" || typeof window === "undefined") {
363
+ continue;
364
+ }
365
+ const cookieString = `${cookieName}=${newLocale}; path=/; max-age=${cookieMaxAge}`;
366
+ document.cookie = cookieDomain ? `${cookieString}; domain=${cookieDomain}` : cookieString;
367
+ } else if (strat === "baseLocale") {
368
+ continue;
369
+ } else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url" && typeof window !== "undefined") {
370
+ newLocation = localizeUrl(window.location.href, {
371
+ locale: newLocale
372
+ }).href;
373
+ } else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === "localStorage" && typeof window !== "undefined") {
374
+ localStorage.setItem(localStorageKey, newLocale);
375
+ } else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
376
+ const handler = customClientStrategies.get(strat);
377
+ if (handler) {
378
+ let result = handler.setLocale(newLocale);
379
+ if (result instanceof Promise) {
380
+ result = result.catch((error) => {
381
+ throw new Error(`Custom strategy "${strat}" setLocale failed.`, {
382
+ cause: error
383
+ });
384
+ });
385
+ customSetLocalePromises.push(result);
386
+ }
387
+ }
388
+ }
389
+ }
390
+ const runReload = () => {
391
+ if (!isServer && optionsWithDefaults.reload && window.location && newLocale !== currentLocale) {
392
+ navigateOrReload(newLocation);
393
+ }
394
+ };
395
+ if (customSetLocalePromises.length) {
396
+ return Promise.all(customSetLocalePromises).then(() => {
397
+ runReload();
398
+ });
399
+ }
400
+ runReload();
401
+ return;
402
+ };
403
+ var getUrlOrigin = () => {
404
+ if (serverAsyncLocalStorage) {
405
+ return serverAsyncLocalStorage.getStore()?.origin ?? "http://fallback.com";
406
+ } else if (typeof window !== "undefined") {
407
+ return window.location.origin;
408
+ }
409
+ return "http://fallback.com";
410
+ };
411
+ function toLocale(value) {
412
+ if (typeof value !== "string") {
413
+ return;
414
+ }
415
+ const lowerValue = value.toLowerCase();
416
+ for (const locale of locales) {
417
+ if (locale.toLowerCase() === lowerValue) {
418
+ return locale;
419
+ }
420
+ }
421
+ return;
422
+ }
423
+ function assertIsLocale(input) {
424
+ const locale = toLocale(input);
425
+ if (locale)
426
+ return locale;
427
+ throw new Error(`Invalid locale: ${input}. Expected one of: ${locales.join(", ")}`);
428
+ }
429
+ function extractLocaleFromCookie() {
430
+ if (typeof document === "undefined" || !document.cookie) {
431
+ return;
432
+ }
433
+ const match = document.cookie.match(new RegExp(`(^| )${cookieName}=([^;]+)`));
434
+ const locale = match?.[2];
435
+ return toLocale(locale);
436
+ }
437
+ function extractLocaleFromNavigator() {
438
+ if (!navigator?.languages?.length) {
439
+ return;
440
+ }
441
+ const languages = navigator.languages.map((lang) => ({
442
+ fullTag: lang,
443
+ baseTag: lang.split("-")[0]
444
+ }));
445
+ for (const lang of languages) {
446
+ const fullLocale = toLocale(lang.fullTag);
447
+ if (fullLocale) {
448
+ return fullLocale;
449
+ }
450
+ const baseLocale2 = toLocale(lang.baseTag);
451
+ if (baseLocale2) {
452
+ return baseLocale2;
453
+ }
454
+ }
455
+ return;
456
+ }
457
+ var cachedUrl;
458
+ var cachedLocale;
459
+ function extractLocaleFromUrl(url) {
460
+ const urlString = typeof url === "string" ? url : url.href;
461
+ if (cachedUrl === urlString) {
462
+ return cachedLocale;
463
+ }
464
+ let result;
465
+ if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
466
+ result = defaultUrlPatternExtractLocale(url);
467
+ } else {
468
+ const urlObj = typeof url === "string" ? new URL(url) : url;
469
+ for (const element of urlPatterns) {
470
+ for (const [locale, localizedPattern] of element.localized) {
471
+ const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
472
+ if (match) {
473
+ result = locale;
474
+ break;
475
+ }
476
+ }
477
+ if (result)
478
+ break;
479
+ }
480
+ }
481
+ cachedUrl = urlString;
482
+ cachedLocale = result;
483
+ return result;
484
+ }
485
+ function defaultUrlPatternExtractLocale(url) {
486
+ const urlObj = new URL(url, "http://dummy.com");
487
+ const pathSegments = urlObj.pathname.split("/").filter(Boolean);
488
+ return toLocale(pathSegments[0]) || baseLocale;
489
+ }
490
+ function localizeUrl(url, options) {
491
+ const targetLocale = options?.locale ? assertIsLocale(options?.locale) : getLocale();
492
+ if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
493
+ return localizeUrlDefaultPattern(url, targetLocale);
494
+ }
495
+ const urlObj = typeof url === "string" ? new URL(url) : url;
496
+ for (const element of urlPatterns) {
497
+ for (const [, localizedPattern] of element.localized) {
498
+ const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
499
+ if (!match) {
500
+ continue;
501
+ }
502
+ const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
503
+ if (!targetPattern) {
504
+ continue;
505
+ }
506
+ const localizedUrl = fillPattern(targetPattern, aggregateGroups(match), urlObj.origin);
507
+ return fillMissingUrlParts(localizedUrl, match);
508
+ }
509
+ const unlocalizedMatch = new URLPattern(element.pattern, urlObj.href).exec(urlObj.href);
510
+ if (unlocalizedMatch) {
511
+ const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
512
+ if (targetPattern) {
513
+ const localizedUrl = fillPattern(targetPattern, aggregateGroups(unlocalizedMatch), urlObj.origin);
514
+ return fillMissingUrlParts(localizedUrl, unlocalizedMatch);
515
+ }
516
+ }
517
+ }
518
+ return urlObj;
519
+ }
520
+ function localizeUrlDefaultPattern(url, locale) {
521
+ const urlObj = typeof url === "string" ? new URL(url, getUrlOrigin()) : new URL(url);
522
+ const currentLocale = extractLocaleFromUrl(urlObj);
523
+ if (currentLocale === locale) {
524
+ return urlObj;
525
+ }
526
+ const pathSegments = urlObj.pathname.split("/").filter(Boolean);
527
+ if (pathSegments.length > 0 && toLocale(pathSegments[0])) {
528
+ pathSegments.shift();
529
+ }
530
+ if (locale === baseLocale) {
531
+ urlObj.pathname = "/" + pathSegments.join("/");
532
+ } else {
533
+ urlObj.pathname = "/" + locale + "/" + pathSegments.join("/");
534
+ }
535
+ return urlObj;
536
+ }
537
+ function fillMissingUrlParts(url, match) {
538
+ if (match.protocol.groups["0"]) {
539
+ url.protocol = match.protocol.groups["0"] ?? "";
540
+ }
541
+ if (match.hostname.groups["0"]) {
542
+ url.hostname = match.hostname.groups["0"] ?? "";
543
+ }
544
+ if (match.username.groups["0"]) {
545
+ url.username = match.username.groups["0"] ?? "";
546
+ }
547
+ if (match.password.groups["0"]) {
548
+ url.password = match.password.groups["0"] ?? "";
549
+ }
550
+ if (match.port.groups["0"]) {
551
+ url.port = match.port.groups["0"] ?? "";
552
+ }
553
+ if (match.pathname.groups["0"]) {
554
+ url.pathname = match.pathname.groups["0"] ?? "";
555
+ }
556
+ if (match.search.groups["0"]) {
557
+ url.search = match.search.groups["0"] ?? "";
558
+ }
559
+ if (match.hash.groups["0"]) {
560
+ url.hash = match.hash.groups["0"] ?? "";
561
+ }
562
+ return url;
563
+ }
564
+ function fillPattern(pattern, values, origin) {
565
+ let processedPattern = pattern.replace(/(https?:\/\/[^:/]+):(\d+)(\/|$)/g, (_, protocol, port, slash) => {
566
+ return `${protocol}#PORT-${port}#${slash}`;
567
+ });
568
+ let processedGroupDelimiters = processedPattern.replace(/\{([^{}]*)\}([?+*]?)/g, (_, content, modifier) => {
569
+ if (modifier === "?") {
570
+ return content;
571
+ }
572
+ return content;
573
+ });
574
+ let filled = processedGroupDelimiters.replace(/(\/?):([a-zA-Z0-9_]+)(\([^)]*\))?([?+*]?)/g, (_, slash, name, __, modifier) => {
575
+ const value = values[name];
576
+ if (value === null) {
577
+ return "";
578
+ }
579
+ if (modifier === "?") {
580
+ return value !== undefined ? `${slash}${value}` : "";
581
+ }
582
+ if (modifier === "+" || modifier === "*") {
583
+ if (value === undefined && modifier === "+") {
584
+ throw new Error(`Missing value for "${name}" (one or more required)`);
585
+ }
586
+ return value ? `${slash}${value}` : "";
587
+ }
588
+ if (value === undefined) {
589
+ throw new Error(`Missing value for "${name}"`);
590
+ }
591
+ return `${slash}${value}`;
592
+ });
593
+ filled = filled.replace(/#PORT-(\d+)#/g, ":$1");
594
+ return new URL(filled, origin);
595
+ }
596
+ function aggregateGroups(match) {
597
+ return {
598
+ ...match.hash.groups,
599
+ ...match.hostname.groups,
600
+ ...match.password.groups,
601
+ ...match.pathname.groups,
602
+ ...match.port.groups,
603
+ ...match.protocol.groups,
604
+ ...match.search.groups,
605
+ ...match.username.groups
606
+ };
607
+ }
608
+ var customServerStrategies = new Map;
609
+ var customClientStrategies = new Map;
610
+ function isCustomStrategy(strategy2) {
611
+ return typeof strategy2 === "string" && /^custom-[A-Za-z0-9_-]+$/.test(strategy2);
612
+ }
613
+
614
+ // ../../src/components/ui/file-picker.tsx
615
+ import { jsxDEV as jsxDEV4, Fragment } from "react/jsx-dev-runtime";
616
+ "use client";
617
+ var messages = {
618
+ en: {
619
+ accepts: (accepts) => `Accepts: ${accepts}`,
620
+ chooseFile: "Choose file",
621
+ deleteFile: "Delete",
622
+ dropFile: "Drag and drop a file here",
623
+ replaceFile: "Replace file"
624
+ },
625
+ fr: {
626
+ accepts: (accepts) => `Accepte : ${accepts}`,
627
+ chooseFile: "Choisir un fichier",
628
+ deleteFile: "Supprimer",
629
+ dropFile: "Glissez-déposez un fichier ici",
630
+ replaceFile: "Remplacer le fichier"
631
+ }
632
+ };
633
+ var filePickerMessages = (overrides) => ({
634
+ ...getLocale().startsWith("fr") ? messages.fr : messages.en,
635
+ ...overrides
636
+ });
637
+ var formatBytes = (bytes) => {
638
+ const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
639
+ if (bytes === 0)
640
+ return "0 Bytes";
641
+ const index = Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), sizes.length - 1);
642
+ if (index === 0)
643
+ return `${bytes} ${sizes[index]}`;
644
+ return `${(bytes / 1024 ** index).toFixed(1)} ${sizes[index]}`;
645
+ };
646
+ var fileDescription = (file) => [
647
+ file.type || file.name.split(".").pop()?.toUpperCase(),
648
+ formatBytes(file.size)
649
+ ].filter(Boolean).join(" · ");
650
+ var FilePicker = ({
651
+ accept = "",
652
+ canClear = false,
653
+ file,
654
+ id,
655
+ image,
656
+ invalid = false,
657
+ messages: messages2,
658
+ name,
659
+ onBlur,
660
+ onChange,
661
+ onClear,
662
+ required,
663
+ title
664
+ }) => {
665
+ const labels = filePickerMessages(messages2);
666
+ const inputRef = useRef(null);
667
+ const dragDepthRef = useRef(0);
668
+ const [dragging, setDragging] = useState(false);
669
+ const imageEnabled = image !== undefined;
670
+ const objectUrl = useMemo(() => file && imageEnabled ? URL.createObjectURL(file) : undefined, [file, imageEnabled]);
671
+ useEffect(() => () => {
672
+ if (objectUrl)
673
+ URL.revokeObjectURL(objectUrl);
674
+ }, [objectUrl]);
675
+ const imageUrl = objectUrl ?? image?.src;
676
+ const selected = Boolean(file || imageUrl);
677
+ const selectFile = (nextFile) => {
678
+ if (nextFile)
679
+ onChange(nextFile);
680
+ };
681
+ const handleDrop = (event) => {
682
+ event.preventDefault();
683
+ dragDepthRef.current = 0;
684
+ setDragging(false);
685
+ if (inputRef.current)
686
+ inputRef.current.files = event.dataTransfer.files;
687
+ selectFile(event.dataTransfer.files[0]);
688
+ onBlur?.();
689
+ };
690
+ const clear = () => {
691
+ onClear();
692
+ if (inputRef.current)
693
+ inputRef.current.value = "";
694
+ };
695
+ const input = /* @__PURE__ */ jsxDEV4(Input, {
696
+ ref: inputRef,
697
+ className: "sr-only",
698
+ id,
699
+ name,
700
+ type: "file",
701
+ accept,
702
+ required,
703
+ onBlur,
704
+ onChange: (event) => selectFile(event.target.files?.[0]),
705
+ "aria-invalid": invalid
706
+ }, undefined, false, undefined, this);
707
+ if (!selected) {
708
+ return /* @__PURE__ */ jsxDEV4("div", {
709
+ className: "bg-muted/30 data-[dragging=true]:bg-muted flex min-h-32 flex-col items-center justify-center gap-3 rounded-xl border border-dashed p-6 text-center transition-colors",
710
+ "data-dragging": dragging,
711
+ onDragEnter: (event) => {
712
+ event.preventDefault();
713
+ dragDepthRef.current += 1;
714
+ setDragging(true);
715
+ },
716
+ onDragLeave: (event) => {
717
+ event.preventDefault();
718
+ dragDepthRef.current -= 1;
719
+ if (dragDepthRef.current <= 0) {
720
+ dragDepthRef.current = 0;
721
+ setDragging(false);
722
+ }
723
+ },
724
+ onDragOver: (event) => event.preventDefault(),
725
+ onDrop: handleDrop,
726
+ children: [
727
+ /* @__PURE__ */ jsxDEV4(CloudUpload, {
728
+ className: "text-muted-foreground size-6"
729
+ }, undefined, false, undefined, this),
730
+ /* @__PURE__ */ jsxDEV4("div", {
731
+ children: [
732
+ /* @__PURE__ */ jsxDEV4("p", {
733
+ className: "text-sm font-medium",
734
+ children: labels.dropFile
735
+ }, undefined, false, undefined, this),
736
+ /* @__PURE__ */ jsxDEV4("p", {
737
+ className: "text-muted-foreground text-xs",
738
+ children: labels.accepts(accept)
739
+ }, undefined, false, undefined, this)
740
+ ]
741
+ }, undefined, true, undefined, this),
742
+ /* @__PURE__ */ jsxDEV4(Button, {
743
+ type: "button",
744
+ variant: "outline",
745
+ onClick: () => inputRef.current?.click(),
746
+ children: [
747
+ /* @__PURE__ */ jsxDEV4(FileUp, {
748
+ "data-icon": "inline-start"
749
+ }, undefined, false, undefined, this),
750
+ labels.chooseFile
751
+ ]
752
+ }, undefined, true, undefined, this),
753
+ input
754
+ ]
755
+ }, undefined, true, undefined, this);
756
+ }
757
+ return /* @__PURE__ */ jsxDEV4(Fragment, {
758
+ children: [
759
+ /* @__PURE__ */ jsxDEV4(Attachment, {
760
+ className: image ? "w-fit max-w-full" : "w-full",
761
+ orientation: image ? "vertical" : "horizontal",
762
+ state: invalid ? "error" : "done",
763
+ children: [
764
+ /* @__PURE__ */ jsxDEV4(AttachmentMedia, {
765
+ variant: image ? "image" : "icon",
766
+ className: image ? "aspect-auto w-full max-w-full [&_img]:aspect-auto! [&_img]:object-contain!" : undefined,
767
+ children: image && imageUrl ? /* @__PURE__ */ jsxDEV4("img", {
768
+ src: imageUrl,
769
+ alt: image.alt,
770
+ width: image.width,
771
+ height: image.height,
772
+ className: "h-auto max-w-full object-contain",
773
+ style: { maxHeight: image.height }
774
+ }, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV4(FileIcon, {}, undefined, false, undefined, this)
775
+ }, undefined, false, undefined, this),
776
+ /* @__PURE__ */ jsxDEV4(AttachmentContent, {
777
+ className: image ? "w-full" : undefined,
778
+ children: [
779
+ /* @__PURE__ */ jsxDEV4(AttachmentTitle, {
780
+ children: title
781
+ }, undefined, false, undefined, this),
782
+ file ? /* @__PURE__ */ jsxDEV4(AttachmentDescription, {
783
+ children: fileDescription(file)
784
+ }, undefined, false, undefined, this) : null
785
+ ]
786
+ }, undefined, true, undefined, this),
787
+ /* @__PURE__ */ jsxDEV4(AttachmentActions, {
788
+ children: [
789
+ /* @__PURE__ */ jsxDEV4(AttachmentAction, {
790
+ type: "button",
791
+ "aria-label": labels.replaceFile,
792
+ onClick: () => inputRef.current?.click(),
793
+ children: /* @__PURE__ */ jsxDEV4(RefreshCw, {}, undefined, false, undefined, this)
794
+ }, undefined, false, undefined, this),
795
+ canClear ? /* @__PURE__ */ jsxDEV4(AttachmentAction, {
796
+ type: "button",
797
+ "aria-label": `${labels.deleteFile} ${typeof title === "string" ? title : ""}`,
798
+ onClick: clear,
799
+ children: /* @__PURE__ */ jsxDEV4(Trash2, {}, undefined, false, undefined, this)
800
+ }, undefined, false, undefined, this) : null
801
+ ]
802
+ }, undefined, true, undefined, this)
803
+ ]
804
+ }, undefined, true, undefined, this),
805
+ input
806
+ ]
807
+ }, undefined, true, undefined, this);
808
+ };
809
+ export {
810
+ FilePicker
811
+ };