@helpwave/hightide 0.1.27 → 0.1.28

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 (134) hide show
  1. package/dist/coloring/index.d.mts +2 -0
  2. package/dist/coloring/index.d.ts +2 -0
  3. package/dist/coloring/index.js +85 -0
  4. package/dist/coloring/index.js.map +1 -0
  5. package/dist/coloring/index.mjs +48 -0
  6. package/dist/coloring/index.mjs.map +1 -0
  7. package/dist/components/branding/index.d.mts +3 -0
  8. package/dist/components/branding/index.d.ts +3 -0
  9. package/dist/components/branding/index.js +140 -0
  10. package/dist/components/branding/index.js.map +1 -0
  11. package/dist/components/branding/index.mjs +104 -0
  12. package/dist/components/branding/index.mjs.map +1 -0
  13. package/dist/components/date/index.d.mts +10 -0
  14. package/dist/components/date/index.d.ts +10 -0
  15. package/dist/components/date/index.js +1168 -0
  16. package/dist/components/date/index.js.map +1 -0
  17. package/dist/components/date/index.mjs +1124 -0
  18. package/dist/components/date/index.mjs.map +1 -0
  19. package/dist/components/dialog/index.js.map +1 -1
  20. package/dist/components/form/index.d.mts +5 -0
  21. package/dist/components/form/index.d.ts +5 -0
  22. package/dist/components/form/index.js +100 -0
  23. package/dist/components/form/index.js.map +1 -0
  24. package/dist/components/form/index.mjs +64 -0
  25. package/dist/components/form/index.mjs.map +1 -0
  26. package/dist/components/icons-and-geometry/index.d.mts +7 -0
  27. package/dist/components/icons-and-geometry/index.d.ts +7 -0
  28. package/dist/components/icons-and-geometry/index.js +3955 -0
  29. package/dist/components/icons-and-geometry/index.js.map +1 -0
  30. package/dist/components/icons-and-geometry/index.mjs +3939 -0
  31. package/dist/components/icons-and-geometry/index.mjs.map +1 -0
  32. package/dist/components/index.d.mts +83 -0
  33. package/dist/components/index.d.ts +83 -0
  34. package/dist/components/index.js +15471 -0
  35. package/dist/components/index.js.map +1 -0
  36. package/dist/components/index.mjs +15377 -0
  37. package/dist/components/index.mjs.map +1 -0
  38. package/dist/components/layout/index.d.mts +18 -0
  39. package/dist/components/layout/index.d.ts +18 -0
  40. package/dist/components/layout/index.js +3111 -0
  41. package/dist/components/layout/index.js.map +1 -0
  42. package/dist/components/layout/index.mjs +3064 -0
  43. package/dist/components/layout/index.mjs.map +1 -0
  44. package/dist/components/loading-states/index.d.mts +12 -0
  45. package/dist/components/loading-states/index.d.ts +12 -0
  46. package/dist/components/loading-states/index.js +614 -0
  47. package/dist/components/loading-states/index.js.map +1 -0
  48. package/dist/components/loading-states/index.mjs +573 -0
  49. package/dist/components/loading-states/index.mjs.map +1 -0
  50. package/dist/components/navigation/index.d.mts +9 -0
  51. package/dist/components/navigation/index.d.ts +9 -0
  52. package/dist/components/navigation/index.js +4660 -0
  53. package/dist/components/navigation/index.js.map +1 -0
  54. package/dist/components/navigation/index.mjs +4648 -0
  55. package/dist/components/navigation/index.mjs.map +1 -0
  56. package/dist/components/properties/index.d.mts +12 -0
  57. package/dist/components/properties/index.d.ts +12 -0
  58. package/dist/components/properties/index.js +2983 -0
  59. package/dist/components/properties/index.js.map +1 -0
  60. package/dist/components/properties/index.mjs +2951 -0
  61. package/dist/components/properties/index.mjs.map +1 -0
  62. package/dist/components/table/index.d.mts +10 -0
  63. package/dist/components/table/index.d.ts +10 -0
  64. package/dist/components/table/index.js +2329 -0
  65. package/dist/components/table/index.js.map +1 -0
  66. package/dist/components/table/index.mjs +2293 -0
  67. package/dist/components/table/index.mjs.map +1 -0
  68. package/dist/components/user-action/index.d.mts +30 -0
  69. package/dist/components/user-action/index.d.ts +30 -0
  70. package/dist/components/user-action/index.js +4257 -0
  71. package/dist/components/user-action/index.js.map +1 -0
  72. package/dist/components/user-action/index.mjs +4195 -0
  73. package/dist/components/user-action/index.mjs.map +1 -0
  74. package/dist/components/user-action/input/index.d.mts +6 -0
  75. package/dist/components/user-action/input/index.d.ts +6 -0
  76. package/dist/components/user-action/input/index.js +398 -0
  77. package/dist/components/user-action/input/index.js.map +1 -0
  78. package/dist/components/user-action/input/index.mjs +357 -0
  79. package/dist/components/user-action/input/index.mjs.map +1 -0
  80. package/dist/components/user-action/select/index.d.mts +4 -0
  81. package/dist/components/user-action/select/index.d.ts +4 -0
  82. package/dist/components/user-action/select/index.js +1369 -0
  83. package/dist/components/user-action/select/index.js.map +1 -0
  84. package/dist/components/user-action/select/index.mjs +1333 -0
  85. package/dist/components/user-action/select/index.mjs.map +1 -0
  86. package/dist/components/utils/index.d.mts +4 -0
  87. package/dist/components/utils/index.d.ts +4 -0
  88. package/dist/components/utils/index.js +302 -0
  89. package/dist/components/utils/index.js.map +1 -0
  90. package/dist/components/utils/index.mjs +275 -0
  91. package/dist/components/utils/index.mjs.map +1 -0
  92. package/dist/hooks/focus/index.d.mts +6 -0
  93. package/dist/hooks/focus/index.d.ts +6 -0
  94. package/dist/hooks/focus/index.js +379 -0
  95. package/dist/hooks/focus/index.js.map +1 -0
  96. package/dist/hooks/focus/index.mjs +339 -0
  97. package/dist/hooks/focus/index.mjs.map +1 -0
  98. package/dist/hooks/index.d.mts +16 -0
  99. package/dist/hooks/index.d.ts +16 -0
  100. package/dist/hooks/index.js +844 -0
  101. package/dist/hooks/index.js.map +1 -0
  102. package/dist/hooks/index.mjs +794 -0
  103. package/dist/hooks/index.mjs.map +1 -0
  104. package/dist/index.d.mts +110 -0
  105. package/dist/index.d.ts +110 -0
  106. package/dist/index.js +16101 -0
  107. package/dist/index.js.map +1 -0
  108. package/dist/index.mjs +15941 -0
  109. package/dist/index.mjs.map +1 -0
  110. package/dist/localization/defaults/index.d.mts +4 -0
  111. package/dist/localization/defaults/index.d.ts +4 -0
  112. package/dist/localization/defaults/index.js +223 -0
  113. package/dist/localization/defaults/index.js.map +1 -0
  114. package/dist/localization/defaults/index.mjs +195 -0
  115. package/dist/localization/defaults/index.mjs.map +1 -0
  116. package/dist/localization/index.d.mts +7 -0
  117. package/dist/localization/index.d.ts +7 -0
  118. package/dist/localization/index.js +415 -0
  119. package/dist/localization/index.js.map +1 -0
  120. package/dist/localization/index.mjs +380 -0
  121. package/dist/localization/index.mjs.map +1 -0
  122. package/dist/theming/index.d.mts +5 -0
  123. package/dist/theming/index.d.ts +5 -0
  124. package/dist/theming/index.js +174 -0
  125. package/dist/theming/index.js.map +1 -0
  126. package/dist/theming/index.mjs +145 -0
  127. package/dist/theming/index.mjs.map +1 -0
  128. package/dist/utils/index.d.mts +15 -0
  129. package/dist/utils/index.d.ts +15 -0
  130. package/dist/utils/index.js +553 -0
  131. package/dist/utils/index.js.map +1 -0
  132. package/dist/utils/index.mjs +493 -0
  133. package/dist/utils/index.mjs.map +1 -0
  134. package/package.json +25 -24
@@ -0,0 +1,4257 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/components/user-action/index.ts
30
+ var user_action_exports = {};
31
+ __export(user_action_exports, {
32
+ ButtonColorUtil: () => ButtonColorUtil,
33
+ ButtonUtil: () => ButtonUtil,
34
+ Checkbox: () => Checkbox2,
35
+ CheckboxUncontrolled: () => CheckboxUncontrolled,
36
+ CopyToClipboardWrapper: () => CopyToClipboardWrapper,
37
+ DateTimePicker: () => DateTimePicker,
38
+ IconButton: () => IconButton,
39
+ IconButtonUtil: () => IconButtonUtil,
40
+ Input: () => Input,
41
+ InputUncontrolled: () => InputUncontrolled,
42
+ InsideLabelInput: () => InsideLabelInput,
43
+ InsideLabelInputUncontrolled: () => InsideLabelInputUncontrolled,
44
+ Label: () => Label,
45
+ Menu: () => Menu,
46
+ MenuItem: () => MenuItem,
47
+ MultiSelect: () => MultiSelect,
48
+ MultiSelectChipDisplay: () => MultiSelectChipDisplay,
49
+ MultiSelectChipDisplayUncontrolled: () => MultiSelectChipDisplayUncontrolled,
50
+ MultiSelectUncontrolled: () => MultiSelectUncontrolled,
51
+ OutlineButton: () => OutlineButton,
52
+ ScrollPicker: () => ScrollPicker,
53
+ SearchBar: () => SearchBar,
54
+ Select: () => Select,
55
+ SelectButton: () => SelectButton,
56
+ SelectChipDisplay: () => SelectChipDisplay,
57
+ SelectContent: () => SelectContent,
58
+ SelectOption: () => SelectOption,
59
+ SelectRoot: () => SelectRoot,
60
+ SelectUncontrolled: () => SelectUncontrolled,
61
+ SolidButton: () => SolidButton,
62
+ TextButton: () => TextButton,
63
+ Textarea: () => Textarea,
64
+ TextareaUncontrolled: () => TextareaUncontrolled,
65
+ TextareaWithHeadline: () => TextareaWithHeadline,
66
+ ToggleableInput: () => ToggleableInput,
67
+ ToggleableInputUncontrolled: () => ToggleableInputUncontrolled,
68
+ Tooltip: () => Tooltip
69
+ });
70
+ module.exports = __toCommonJS(user_action_exports);
71
+
72
+ // src/components/user-action/Button.tsx
73
+ var import_react = require("react");
74
+ var import_clsx = __toESM(require("clsx"));
75
+ var import_jsx_runtime = require("react/jsx-runtime");
76
+ var ButtonColorUtil = {
77
+ solid: ["primary", "secondary", "tertiary", "positive", "warning", "negative", "neutral"],
78
+ text: ["primary", "negative", "neutral"],
79
+ outline: ["primary"]
80
+ };
81
+ var IconButtonUtil = {
82
+ icon: [...ButtonColorUtil.solid, "transparent"]
83
+ };
84
+ var paddingMapping = {
85
+ small: "btn-sm",
86
+ medium: "btn-md",
87
+ large: "btn-lg"
88
+ };
89
+ var iconPaddingMapping = {
90
+ tiny: "icon-btn-xs",
91
+ small: "icon-btn-sm",
92
+ medium: "icon-btn-md",
93
+ large: "icon-btn-lg"
94
+ };
95
+ var ButtonUtil = {
96
+ paddingMapping,
97
+ iconPaddingMapping
98
+ };
99
+ var SolidButton = (0, import_react.forwardRef)(function SolidButton2({
100
+ children,
101
+ color = "primary",
102
+ size = "medium",
103
+ startIcon,
104
+ endIcon,
105
+ onClick,
106
+ className,
107
+ ...restProps
108
+ }, ref) {
109
+ const colorClasses = {
110
+ primary: "not-disabled:bg-button-solid-primary-background not-disabled:text-button-solid-primary-text",
111
+ secondary: "not-disabled:bg-button-solid-secondary-background not-disabled:text-button-solid-secondary-text",
112
+ tertiary: "not-disabled:bg-button-solid-tertiary-background not-disabled:text-button-solid-tertiary-text",
113
+ positive: "not-disabled:bg-button-solid-positive-background not-disabled:text-button-solid-positive-text",
114
+ warning: "not-disabled:bg-button-solid-warning-background not-disabled:text-button-solid-warning-text",
115
+ negative: "not-disabled:bg-button-solid-negative-background not-disabled:text-button-solid-negative-text",
116
+ neutral: "not-disabled:bg-button-solid-neutral-background not-disabled:text-button-solid-neutral-text"
117
+ }[color];
118
+ const iconColorClasses = {
119
+ primary: "not-group-disabled:text-button-solid-primary-icon",
120
+ secondary: "not-group-disabled:text-button-solid-secondary-icon",
121
+ tertiary: "not-group-disabled:text-button-solid-tertiary-icon",
122
+ positive: "not-group-disabled:text-button-solid-positive-icon",
123
+ warning: "not-group-disabled:text-button-solid-warning-icon",
124
+ negative: "not-group-disabled:text-button-solid-negative-icon",
125
+ neutral: "not-group-disabled:text-button-solid-neutral-icon"
126
+ }[color];
127
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
128
+ "button",
129
+ {
130
+ ref,
131
+ onClick,
132
+ className: (0, import_clsx.default)(
133
+ "group font-semibold",
134
+ colorClasses,
135
+ "not-disabled:hover:brightness-90",
136
+ "disabled:text-disabled-text disabled:bg-disabled-background",
137
+ ButtonUtil.paddingMapping[size],
138
+ className
139
+ ),
140
+ ...restProps,
141
+ children: [
142
+ startIcon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
143
+ "span",
144
+ {
145
+ className: (0, import_clsx.default)(
146
+ iconColorClasses,
147
+ "group-disabled:text-disabled-icon"
148
+ ),
149
+ children: startIcon
150
+ }
151
+ ),
152
+ children,
153
+ endIcon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
154
+ "span",
155
+ {
156
+ className: (0, import_clsx.default)(
157
+ iconColorClasses,
158
+ "group-disabled:text-disabled-icon"
159
+ ),
160
+ children: endIcon
161
+ }
162
+ )
163
+ ]
164
+ }
165
+ );
166
+ });
167
+ var OutlineButton = ({
168
+ children,
169
+ color = "primary",
170
+ size = "medium",
171
+ startIcon,
172
+ endIcon,
173
+ onClick,
174
+ className,
175
+ ...restProps
176
+ }) => {
177
+ const colorClasses = {
178
+ primary: "not-disabled:border-button-outline-primary-text not-disabled:text-button-outline-primary-text"
179
+ }[color];
180
+ const iconColorClasses = {
181
+ primary: "not-group-disabled:text-button-outline-primary-icon"
182
+ }[color];
183
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
184
+ "button",
185
+ {
186
+ onClick,
187
+ className: (0, import_clsx.default)(
188
+ "group font-semibold bg-transparent border-2 ",
189
+ "not-disabled:hover:brightness-80",
190
+ colorClasses,
191
+ "disabled:text-disabled-text disabled:border-disabled-outline",
192
+ ButtonUtil.paddingMapping[size],
193
+ className
194
+ ),
195
+ ...restProps,
196
+ children: [
197
+ startIcon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
198
+ "span",
199
+ {
200
+ className: (0, import_clsx.default)(
201
+ iconColorClasses,
202
+ "group-disabled:text-disabled-icon"
203
+ ),
204
+ children: startIcon
205
+ }
206
+ ),
207
+ children,
208
+ endIcon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
209
+ "span",
210
+ {
211
+ className: (0, import_clsx.default)(
212
+ iconColorClasses,
213
+ "group-disabled:text-disabled-icon"
214
+ ),
215
+ children: endIcon
216
+ }
217
+ )
218
+ ]
219
+ }
220
+ );
221
+ };
222
+ var TextButton = ({
223
+ children,
224
+ color = "neutral",
225
+ size = "medium",
226
+ startIcon,
227
+ endIcon,
228
+ onClick,
229
+ coloredHoverBackground = true,
230
+ className,
231
+ ...restProps
232
+ }) => {
233
+ const colorClasses = {
234
+ primary: "not-disabled:bg-transparent not-disabled:text-button-text-primary-text focus-style-none focus-visible:ring-2 not-disabled:focus-visible:ring-button-text-primary-text",
235
+ negative: "not-disabled:bg-transparent not-disabled:text-button-text-negative-text focus-style-none focus-visible:ring-2 not-disabled:focus-visible:ring-button-text-negative-text",
236
+ neutral: "not-disabled:bg-transparent not-disabled:text-button-text-neutral-text focus-style-none focus-visible:ring-2 not-disabled:focus-visible:ring-button-text-neutral-text"
237
+ }[color];
238
+ const backgroundColor = {
239
+ primary: "not-disabled:hover:bg-button-text-primary-text/20 not-disabled:focus-visible:bg-button-text-primary-text/20",
240
+ negative: "not-disabled:hover:bg-button-text-negative-text/20 not-disabled:focus-visible:bg-button-text-negative-text/20",
241
+ neutral: "not-disabled:hover:bg-button-text-neutral-text/20 not-disabled:focus-visible:bg-button-text-neutral-text/20"
242
+ }[color];
243
+ const iconColorClasses = {
244
+ primary: "not-group-disabled:text-button-text-primary-icon",
245
+ negative: "not-group-disabled:text-button-text-negative-icon",
246
+ neutral: "not-group-disabled:text-button-text-neutral-icon"
247
+ }[color];
248
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
249
+ "button",
250
+ {
251
+ onClick,
252
+ className: (0, import_clsx.default)(
253
+ "group font-semibold",
254
+ "disabled:text-disabled-text",
255
+ colorClasses,
256
+ {
257
+ [backgroundColor]: coloredHoverBackground,
258
+ "not-disabled:hover:bg-button-text-hover-background": !coloredHoverBackground
259
+ },
260
+ ButtonUtil.paddingMapping[size],
261
+ className
262
+ ),
263
+ ...restProps,
264
+ children: [
265
+ startIcon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
266
+ "span",
267
+ {
268
+ className: (0, import_clsx.default)(
269
+ iconColorClasses,
270
+ "group-disabled:text-disabled-icon"
271
+ ),
272
+ children: startIcon
273
+ }
274
+ ),
275
+ children,
276
+ endIcon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
277
+ "span",
278
+ {
279
+ className: (0, import_clsx.default)(
280
+ iconColorClasses,
281
+ "group-disabled:text-disabled-icon"
282
+ ),
283
+ children: endIcon
284
+ }
285
+ )
286
+ ]
287
+ }
288
+ );
289
+ };
290
+ var IconButton = (0, import_react.forwardRef)(function IconButton2({
291
+ children,
292
+ color = "primary",
293
+ size = "medium",
294
+ className,
295
+ ...restProps
296
+ }, ref) {
297
+ const colorClasses = {
298
+ primary: "not-disabled:bg-button-solid-primary-background not-disabled:text-button-solid-primary-text",
299
+ secondary: "not-disabled:bg-button-solid-secondary-background not-disabled:text-button-solid-secondary-text",
300
+ tertiary: "not-disabled:bg-button-solid-tertiary-background not-disabled:text-button-solid-tertiary-text",
301
+ positive: "not-disabled:bg-button-solid-positive-background not-disabled:text-button-solid-positive-text",
302
+ warning: "not-disabled:bg-button-solid-warning-background not-disabled:text-button-solid-warning-text",
303
+ negative: "not-disabled:bg-button-solid-negative-background not-disabled:text-button-solid-negative-text",
304
+ neutral: "not-disabled:bg-button-solid-neutral-background not-disabled:text-button-solid-neutral-text",
305
+ transparent: "not-disabled:bg-transparent"
306
+ }[color];
307
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
308
+ "button",
309
+ {
310
+ ref,
311
+ className: (0, import_clsx.default)(
312
+ colorClasses,
313
+ "not-disabled:hover:brightness-90",
314
+ "disabled:text-disabled-text",
315
+ {
316
+ "disabled:bg-disabled-background": color !== "transparent",
317
+ "disabled:opacity-70": color === "transparent",
318
+ "not-disabled:hover:bg-button-text-hover-background": color === "transparent"
319
+ },
320
+ ButtonUtil.iconPaddingMapping[size],
321
+ className
322
+ ),
323
+ ...restProps,
324
+ children
325
+ }
326
+ );
327
+ });
328
+
329
+ // src/components/user-action/Checkbox.tsx
330
+ var import_react2 = require("react");
331
+ var import_lucide_react = require("lucide-react");
332
+ var import_clsx2 = __toESM(require("clsx"));
333
+
334
+ // node_modules/@radix-ui/react-checkbox/dist/index.mjs
335
+ var React10 = __toESM(require("react"), 1);
336
+
337
+ // node_modules/@radix-ui/react-compose-refs/dist/index.mjs
338
+ var React = __toESM(require("react"), 1);
339
+ function setRef(ref, value) {
340
+ if (typeof ref === "function") {
341
+ return ref(value);
342
+ } else if (ref !== null && ref !== void 0) {
343
+ ref.current = value;
344
+ }
345
+ }
346
+ function composeRefs(...refs) {
347
+ return (node) => {
348
+ let hasCleanup = false;
349
+ const cleanups = refs.map((ref) => {
350
+ const cleanup = setRef(ref, node);
351
+ if (!hasCleanup && typeof cleanup == "function") {
352
+ hasCleanup = true;
353
+ }
354
+ return cleanup;
355
+ });
356
+ if (hasCleanup) {
357
+ return () => {
358
+ for (let i = 0; i < cleanups.length; i++) {
359
+ const cleanup = cleanups[i];
360
+ if (typeof cleanup == "function") {
361
+ cleanup();
362
+ } else {
363
+ setRef(refs[i], null);
364
+ }
365
+ }
366
+ };
367
+ }
368
+ };
369
+ }
370
+ function useComposedRefs(...refs) {
371
+ return React.useCallback(composeRefs(...refs), refs);
372
+ }
373
+
374
+ // node_modules/@radix-ui/react-context/dist/index.mjs
375
+ var React2 = __toESM(require("react"), 1);
376
+ var import_jsx_runtime2 = require("react/jsx-runtime");
377
+ function createContextScope(scopeName, createContextScopeDeps = []) {
378
+ let defaultContexts = [];
379
+ function createContext32(rootComponentName, defaultContext) {
380
+ const BaseContext = React2.createContext(defaultContext);
381
+ const index = defaultContexts.length;
382
+ defaultContexts = [...defaultContexts, defaultContext];
383
+ const Provider = (props) => {
384
+ const { scope, children, ...context } = props;
385
+ const Context = scope?.[scopeName]?.[index] || BaseContext;
386
+ const value = React2.useMemo(() => context, Object.values(context));
387
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Context.Provider, { value, children });
388
+ };
389
+ Provider.displayName = rootComponentName + "Provider";
390
+ function useContext22(consumerName, scope) {
391
+ const Context = scope?.[scopeName]?.[index] || BaseContext;
392
+ const context = React2.useContext(Context);
393
+ if (context) return context;
394
+ if (defaultContext !== void 0) return defaultContext;
395
+ throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
396
+ }
397
+ return [Provider, useContext22];
398
+ }
399
+ const createScope = () => {
400
+ const scopeContexts = defaultContexts.map((defaultContext) => {
401
+ return React2.createContext(defaultContext);
402
+ });
403
+ return function useScope(scope) {
404
+ const contexts = scope?.[scopeName] || scopeContexts;
405
+ return React2.useMemo(
406
+ () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
407
+ [scope, contexts]
408
+ );
409
+ };
410
+ };
411
+ createScope.scopeName = scopeName;
412
+ return [createContext32, composeContextScopes(createScope, ...createContextScopeDeps)];
413
+ }
414
+ function composeContextScopes(...scopes) {
415
+ const baseScope = scopes[0];
416
+ if (scopes.length === 1) return baseScope;
417
+ const createScope = () => {
418
+ const scopeHooks = scopes.map((createScope2) => ({
419
+ useScope: createScope2(),
420
+ scopeName: createScope2.scopeName
421
+ }));
422
+ return function useComposedScopes(overrideScopes) {
423
+ const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
424
+ const scopeProps = useScope(overrideScopes);
425
+ const currentScope = scopeProps[`__scope${scopeName}`];
426
+ return { ...nextScopes2, ...currentScope };
427
+ }, {});
428
+ return React2.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
429
+ };
430
+ };
431
+ createScope.scopeName = baseScope.scopeName;
432
+ return createScope;
433
+ }
434
+
435
+ // node_modules/@radix-ui/primitive/dist/index.mjs
436
+ function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
437
+ return function handleEvent(event) {
438
+ originalEventHandler?.(event);
439
+ if (checkForDefaultPrevented === false || !event.defaultPrevented) {
440
+ return ourEventHandler?.(event);
441
+ }
442
+ };
443
+ }
444
+
445
+ // node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs
446
+ var React4 = __toESM(require("react"), 1);
447
+
448
+ // node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs
449
+ var React3 = __toESM(require("react"), 1);
450
+ var useLayoutEffect2 = globalThis?.document ? React3.useLayoutEffect : () => {
451
+ };
452
+
453
+ // node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs
454
+ var React22 = __toESM(require("react"), 1);
455
+ var useInsertionEffect = React4[" useInsertionEffect ".trim().toString()] || useLayoutEffect2;
456
+ function useControllableState({
457
+ prop,
458
+ defaultProp,
459
+ onChange = () => {
460
+ },
461
+ caller
462
+ }) {
463
+ const [uncontrolledProp, setUncontrolledProp, onChangeRef] = useUncontrolledState({
464
+ defaultProp,
465
+ onChange
466
+ });
467
+ const isControlled = prop !== void 0;
468
+ const value = isControlled ? prop : uncontrolledProp;
469
+ if (true) {
470
+ const isControlledRef = React4.useRef(prop !== void 0);
471
+ React4.useEffect(() => {
472
+ const wasControlled = isControlledRef.current;
473
+ if (wasControlled !== isControlled) {
474
+ const from = wasControlled ? "controlled" : "uncontrolled";
475
+ const to = isControlled ? "controlled" : "uncontrolled";
476
+ console.warn(
477
+ `${caller} is changing from ${from} to ${to}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`
478
+ );
479
+ }
480
+ isControlledRef.current = isControlled;
481
+ }, [isControlled, caller]);
482
+ }
483
+ const setValue = React4.useCallback(
484
+ (nextValue) => {
485
+ if (isControlled) {
486
+ const value2 = isFunction(nextValue) ? nextValue(prop) : nextValue;
487
+ if (value2 !== prop) {
488
+ onChangeRef.current?.(value2);
489
+ }
490
+ } else {
491
+ setUncontrolledProp(nextValue);
492
+ }
493
+ },
494
+ [isControlled, prop, setUncontrolledProp, onChangeRef]
495
+ );
496
+ return [value, setValue];
497
+ }
498
+ function useUncontrolledState({
499
+ defaultProp,
500
+ onChange
501
+ }) {
502
+ const [value, setValue] = React4.useState(defaultProp);
503
+ const prevValueRef = React4.useRef(value);
504
+ const onChangeRef = React4.useRef(onChange);
505
+ useInsertionEffect(() => {
506
+ onChangeRef.current = onChange;
507
+ }, [onChange]);
508
+ React4.useEffect(() => {
509
+ if (prevValueRef.current !== value) {
510
+ onChangeRef.current?.(value);
511
+ prevValueRef.current = value;
512
+ }
513
+ }, [value, prevValueRef]);
514
+ return [value, setValue, onChangeRef];
515
+ }
516
+ function isFunction(value) {
517
+ return typeof value === "function";
518
+ }
519
+ var SYNC_STATE = Symbol("RADIX:SYNC_STATE");
520
+
521
+ // node_modules/@radix-ui/react-use-previous/dist/index.mjs
522
+ var React5 = __toESM(require("react"), 1);
523
+ function usePrevious(value) {
524
+ const ref = React5.useRef({ value, previous: value });
525
+ return React5.useMemo(() => {
526
+ if (ref.current.value !== value) {
527
+ ref.current.previous = ref.current.value;
528
+ ref.current.value = value;
529
+ }
530
+ return ref.current.previous;
531
+ }, [value]);
532
+ }
533
+
534
+ // node_modules/@radix-ui/react-use-size/dist/index.mjs
535
+ var React6 = __toESM(require("react"), 1);
536
+ function useSize(element) {
537
+ const [size, setSize] = React6.useState(void 0);
538
+ useLayoutEffect2(() => {
539
+ if (element) {
540
+ setSize({ width: element.offsetWidth, height: element.offsetHeight });
541
+ const resizeObserver = new ResizeObserver((entries) => {
542
+ if (!Array.isArray(entries)) {
543
+ return;
544
+ }
545
+ if (!entries.length) {
546
+ return;
547
+ }
548
+ const entry = entries[0];
549
+ let width;
550
+ let height;
551
+ if ("borderBoxSize" in entry) {
552
+ const borderSizeEntry = entry["borderBoxSize"];
553
+ const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
554
+ width = borderSize["inlineSize"];
555
+ height = borderSize["blockSize"];
556
+ } else {
557
+ width = element.offsetWidth;
558
+ height = element.offsetHeight;
559
+ }
560
+ setSize({ width, height });
561
+ });
562
+ resizeObserver.observe(element, { box: "border-box" });
563
+ return () => resizeObserver.unobserve(element);
564
+ } else {
565
+ setSize(void 0);
566
+ }
567
+ }, [element]);
568
+ return size;
569
+ }
570
+
571
+ // node_modules/@radix-ui/react-presence/dist/index.mjs
572
+ var React23 = __toESM(require("react"), 1);
573
+ var React7 = __toESM(require("react"), 1);
574
+ function useStateMachine(initialState, machine) {
575
+ return React7.useReducer((state, event) => {
576
+ const nextState = machine[state][event];
577
+ return nextState ?? state;
578
+ }, initialState);
579
+ }
580
+ var Presence = (props) => {
581
+ const { present, children } = props;
582
+ const presence = usePresence(present);
583
+ const child = typeof children === "function" ? children({ present: presence.isPresent }) : React23.Children.only(children);
584
+ const ref = useComposedRefs(presence.ref, getElementRef(child));
585
+ const forceMount = typeof children === "function";
586
+ return forceMount || presence.isPresent ? React23.cloneElement(child, { ref }) : null;
587
+ };
588
+ Presence.displayName = "Presence";
589
+ function usePresence(present) {
590
+ const [node, setNode] = React23.useState();
591
+ const stylesRef = React23.useRef(null);
592
+ const prevPresentRef = React23.useRef(present);
593
+ const prevAnimationNameRef = React23.useRef("none");
594
+ const initialState = present ? "mounted" : "unmounted";
595
+ const [state, send] = useStateMachine(initialState, {
596
+ mounted: {
597
+ UNMOUNT: "unmounted",
598
+ ANIMATION_OUT: "unmountSuspended"
599
+ },
600
+ unmountSuspended: {
601
+ MOUNT: "mounted",
602
+ ANIMATION_END: "unmounted"
603
+ },
604
+ unmounted: {
605
+ MOUNT: "mounted"
606
+ }
607
+ });
608
+ React23.useEffect(() => {
609
+ const currentAnimationName = getAnimationName(stylesRef.current);
610
+ prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
611
+ }, [state]);
612
+ useLayoutEffect2(() => {
613
+ const styles = stylesRef.current;
614
+ const wasPresent = prevPresentRef.current;
615
+ const hasPresentChanged = wasPresent !== present;
616
+ if (hasPresentChanged) {
617
+ const prevAnimationName = prevAnimationNameRef.current;
618
+ const currentAnimationName = getAnimationName(styles);
619
+ if (present) {
620
+ send("MOUNT");
621
+ } else if (currentAnimationName === "none" || styles?.display === "none") {
622
+ send("UNMOUNT");
623
+ } else {
624
+ const isAnimating = prevAnimationName !== currentAnimationName;
625
+ if (wasPresent && isAnimating) {
626
+ send("ANIMATION_OUT");
627
+ } else {
628
+ send("UNMOUNT");
629
+ }
630
+ }
631
+ prevPresentRef.current = present;
632
+ }
633
+ }, [present, send]);
634
+ useLayoutEffect2(() => {
635
+ if (node) {
636
+ let timeoutId;
637
+ const ownerWindow = node.ownerDocument.defaultView ?? window;
638
+ const handleAnimationEnd = (event) => {
639
+ const currentAnimationName = getAnimationName(stylesRef.current);
640
+ const isCurrentAnimation = currentAnimationName.includes(event.animationName);
641
+ if (event.target === node && isCurrentAnimation) {
642
+ send("ANIMATION_END");
643
+ if (!prevPresentRef.current) {
644
+ const currentFillMode = node.style.animationFillMode;
645
+ node.style.animationFillMode = "forwards";
646
+ timeoutId = ownerWindow.setTimeout(() => {
647
+ if (node.style.animationFillMode === "forwards") {
648
+ node.style.animationFillMode = currentFillMode;
649
+ }
650
+ });
651
+ }
652
+ }
653
+ };
654
+ const handleAnimationStart = (event) => {
655
+ if (event.target === node) {
656
+ prevAnimationNameRef.current = getAnimationName(stylesRef.current);
657
+ }
658
+ };
659
+ node.addEventListener("animationstart", handleAnimationStart);
660
+ node.addEventListener("animationcancel", handleAnimationEnd);
661
+ node.addEventListener("animationend", handleAnimationEnd);
662
+ return () => {
663
+ ownerWindow.clearTimeout(timeoutId);
664
+ node.removeEventListener("animationstart", handleAnimationStart);
665
+ node.removeEventListener("animationcancel", handleAnimationEnd);
666
+ node.removeEventListener("animationend", handleAnimationEnd);
667
+ };
668
+ } else {
669
+ send("ANIMATION_END");
670
+ }
671
+ }, [node, send]);
672
+ return {
673
+ isPresent: ["mounted", "unmountSuspended"].includes(state),
674
+ ref: React23.useCallback((node2) => {
675
+ stylesRef.current = node2 ? getComputedStyle(node2) : null;
676
+ setNode(node2);
677
+ }, [])
678
+ };
679
+ }
680
+ function getAnimationName(styles) {
681
+ return styles?.animationName || "none";
682
+ }
683
+ function getElementRef(element) {
684
+ let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
685
+ let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
686
+ if (mayWarn) {
687
+ return element.ref;
688
+ }
689
+ getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
690
+ mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
691
+ if (mayWarn) {
692
+ return element.props.ref;
693
+ }
694
+ return element.props.ref || element.ref;
695
+ }
696
+
697
+ // node_modules/@radix-ui/react-primitive/dist/index.mjs
698
+ var React9 = __toESM(require("react"), 1);
699
+ var ReactDOM = __toESM(require("react-dom"), 1);
700
+
701
+ // node_modules/@radix-ui/react-slot/dist/index.mjs
702
+ var React8 = __toESM(require("react"), 1);
703
+ var import_jsx_runtime3 = require("react/jsx-runtime");
704
+ // @__NO_SIDE_EFFECTS__
705
+ function createSlot(ownerName) {
706
+ const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
707
+ const Slot2 = React8.forwardRef((props, forwardedRef) => {
708
+ const { children, ...slotProps } = props;
709
+ const childrenArray = React8.Children.toArray(children);
710
+ const slottable = childrenArray.find(isSlottable);
711
+ if (slottable) {
712
+ const newElement = slottable.props.children;
713
+ const newChildren = childrenArray.map((child) => {
714
+ if (child === slottable) {
715
+ if (React8.Children.count(newElement) > 1) return React8.Children.only(null);
716
+ return React8.isValidElement(newElement) ? newElement.props.children : null;
717
+ } else {
718
+ return child;
719
+ }
720
+ });
721
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SlotClone, { ...slotProps, ref: forwardedRef, children: React8.isValidElement(newElement) ? React8.cloneElement(newElement, void 0, newChildren) : null });
722
+ }
723
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SlotClone, { ...slotProps, ref: forwardedRef, children });
724
+ });
725
+ Slot2.displayName = `${ownerName}.Slot`;
726
+ return Slot2;
727
+ }
728
+ // @__NO_SIDE_EFFECTS__
729
+ function createSlotClone(ownerName) {
730
+ const SlotClone = React8.forwardRef((props, forwardedRef) => {
731
+ const { children, ...slotProps } = props;
732
+ if (React8.isValidElement(children)) {
733
+ const childrenRef = getElementRef2(children);
734
+ const props2 = mergeProps(slotProps, children.props);
735
+ if (children.type !== React8.Fragment) {
736
+ props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
737
+ }
738
+ return React8.cloneElement(children, props2);
739
+ }
740
+ return React8.Children.count(children) > 1 ? React8.Children.only(null) : null;
741
+ });
742
+ SlotClone.displayName = `${ownerName}.SlotClone`;
743
+ return SlotClone;
744
+ }
745
+ var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
746
+ function isSlottable(child) {
747
+ return React8.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
748
+ }
749
+ function mergeProps(slotProps, childProps) {
750
+ const overrideProps = { ...childProps };
751
+ for (const propName in childProps) {
752
+ const slotPropValue = slotProps[propName];
753
+ const childPropValue = childProps[propName];
754
+ const isHandler = /^on[A-Z]/.test(propName);
755
+ if (isHandler) {
756
+ if (slotPropValue && childPropValue) {
757
+ overrideProps[propName] = (...args) => {
758
+ const result = childPropValue(...args);
759
+ slotPropValue(...args);
760
+ return result;
761
+ };
762
+ } else if (slotPropValue) {
763
+ overrideProps[propName] = slotPropValue;
764
+ }
765
+ } else if (propName === "style") {
766
+ overrideProps[propName] = { ...slotPropValue, ...childPropValue };
767
+ } else if (propName === "className") {
768
+ overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
769
+ }
770
+ }
771
+ return { ...slotProps, ...overrideProps };
772
+ }
773
+ function getElementRef2(element) {
774
+ let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
775
+ let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
776
+ if (mayWarn) {
777
+ return element.ref;
778
+ }
779
+ getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
780
+ mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
781
+ if (mayWarn) {
782
+ return element.props.ref;
783
+ }
784
+ return element.props.ref || element.ref;
785
+ }
786
+
787
+ // node_modules/@radix-ui/react-primitive/dist/index.mjs
788
+ var import_jsx_runtime4 = require("react/jsx-runtime");
789
+ var NODES = [
790
+ "a",
791
+ "button",
792
+ "div",
793
+ "form",
794
+ "h2",
795
+ "h3",
796
+ "img",
797
+ "input",
798
+ "label",
799
+ "li",
800
+ "nav",
801
+ "ol",
802
+ "p",
803
+ "select",
804
+ "span",
805
+ "svg",
806
+ "ul"
807
+ ];
808
+ var Primitive = NODES.reduce((primitive, node) => {
809
+ const Slot = createSlot(`Primitive.${node}`);
810
+ const Node2 = React9.forwardRef((props, forwardedRef) => {
811
+ const { asChild, ...primitiveProps } = props;
812
+ const Comp = asChild ? Slot : node;
813
+ if (typeof window !== "undefined") {
814
+ window[Symbol.for("radix-ui")] = true;
815
+ }
816
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Comp, { ...primitiveProps, ref: forwardedRef });
817
+ });
818
+ Node2.displayName = `Primitive.${node}`;
819
+ return { ...primitive, [node]: Node2 };
820
+ }, {});
821
+
822
+ // node_modules/@radix-ui/react-checkbox/dist/index.mjs
823
+ var import_jsx_runtime5 = require("react/jsx-runtime");
824
+ var CHECKBOX_NAME = "Checkbox";
825
+ var [createCheckboxContext, createCheckboxScope] = createContextScope(CHECKBOX_NAME);
826
+ var [CheckboxProviderImpl, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME);
827
+ function CheckboxProvider(props) {
828
+ const {
829
+ __scopeCheckbox,
830
+ checked: checkedProp,
831
+ children,
832
+ defaultChecked,
833
+ disabled,
834
+ form,
835
+ name,
836
+ onCheckedChange,
837
+ required,
838
+ value = "on",
839
+ // @ts-expect-error
840
+ internal_do_not_use_render
841
+ } = props;
842
+ const [checked, setChecked] = useControllableState({
843
+ prop: checkedProp,
844
+ defaultProp: defaultChecked ?? false,
845
+ onChange: onCheckedChange,
846
+ caller: CHECKBOX_NAME
847
+ });
848
+ const [control, setControl] = React10.useState(null);
849
+ const [bubbleInput, setBubbleInput] = React10.useState(null);
850
+ const hasConsumerStoppedPropagationRef = React10.useRef(false);
851
+ const isFormControl = control ? !!form || !!control.closest("form") : (
852
+ // We set this to true by default so that events bubble to forms without JS (SSR)
853
+ true
854
+ );
855
+ const context = {
856
+ checked,
857
+ disabled,
858
+ setChecked,
859
+ control,
860
+ setControl,
861
+ name,
862
+ form,
863
+ value,
864
+ hasConsumerStoppedPropagationRef,
865
+ required,
866
+ defaultChecked: isIndeterminate(defaultChecked) ? false : defaultChecked,
867
+ isFormControl,
868
+ bubbleInput,
869
+ setBubbleInput
870
+ };
871
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
872
+ CheckboxProviderImpl,
873
+ {
874
+ scope: __scopeCheckbox,
875
+ ...context,
876
+ children: isFunction2(internal_do_not_use_render) ? internal_do_not_use_render(context) : children
877
+ }
878
+ );
879
+ }
880
+ var TRIGGER_NAME = "CheckboxTrigger";
881
+ var CheckboxTrigger = React10.forwardRef(
882
+ ({ __scopeCheckbox, onKeyDown, onClick, ...checkboxProps }, forwardedRef) => {
883
+ const {
884
+ control,
885
+ value,
886
+ disabled,
887
+ checked,
888
+ required,
889
+ setControl,
890
+ setChecked,
891
+ hasConsumerStoppedPropagationRef,
892
+ isFormControl,
893
+ bubbleInput
894
+ } = useCheckboxContext(TRIGGER_NAME, __scopeCheckbox);
895
+ const composedRefs = useComposedRefs(forwardedRef, setControl);
896
+ const initialCheckedStateRef = React10.useRef(checked);
897
+ React10.useEffect(() => {
898
+ const form = control?.form;
899
+ if (form) {
900
+ const reset = () => setChecked(initialCheckedStateRef.current);
901
+ form.addEventListener("reset", reset);
902
+ return () => form.removeEventListener("reset", reset);
903
+ }
904
+ }, [control, setChecked]);
905
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
906
+ Primitive.button,
907
+ {
908
+ type: "button",
909
+ role: "checkbox",
910
+ "aria-checked": isIndeterminate(checked) ? "mixed" : checked,
911
+ "aria-required": required,
912
+ "data-state": getState(checked),
913
+ "data-disabled": disabled ? "" : void 0,
914
+ disabled,
915
+ value,
916
+ ...checkboxProps,
917
+ ref: composedRefs,
918
+ onKeyDown: composeEventHandlers(onKeyDown, (event) => {
919
+ if (event.key === "Enter") event.preventDefault();
920
+ }),
921
+ onClick: composeEventHandlers(onClick, (event) => {
922
+ setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);
923
+ if (bubbleInput && isFormControl) {
924
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
925
+ if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
926
+ }
927
+ })
928
+ }
929
+ );
930
+ }
931
+ );
932
+ CheckboxTrigger.displayName = TRIGGER_NAME;
933
+ var Checkbox = React10.forwardRef(
934
+ (props, forwardedRef) => {
935
+ const {
936
+ __scopeCheckbox,
937
+ name,
938
+ checked,
939
+ defaultChecked,
940
+ required,
941
+ disabled,
942
+ value,
943
+ onCheckedChange,
944
+ form,
945
+ ...checkboxProps
946
+ } = props;
947
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
948
+ CheckboxProvider,
949
+ {
950
+ __scopeCheckbox,
951
+ checked,
952
+ defaultChecked,
953
+ disabled,
954
+ required,
955
+ onCheckedChange,
956
+ name,
957
+ form,
958
+ value,
959
+ internal_do_not_use_render: ({ isFormControl }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
960
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
961
+ CheckboxTrigger,
962
+ {
963
+ ...checkboxProps,
964
+ ref: forwardedRef,
965
+ __scopeCheckbox
966
+ }
967
+ ),
968
+ isFormControl && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
969
+ CheckboxBubbleInput,
970
+ {
971
+ __scopeCheckbox
972
+ }
973
+ )
974
+ ] })
975
+ }
976
+ );
977
+ }
978
+ );
979
+ Checkbox.displayName = CHECKBOX_NAME;
980
+ var INDICATOR_NAME = "CheckboxIndicator";
981
+ var CheckboxIndicator = React10.forwardRef(
982
+ (props, forwardedRef) => {
983
+ const { __scopeCheckbox, forceMount, ...indicatorProps } = props;
984
+ const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);
985
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
986
+ Presence,
987
+ {
988
+ present: forceMount || isIndeterminate(context.checked) || context.checked === true,
989
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
990
+ Primitive.span,
991
+ {
992
+ "data-state": getState(context.checked),
993
+ "data-disabled": context.disabled ? "" : void 0,
994
+ ...indicatorProps,
995
+ ref: forwardedRef,
996
+ style: { pointerEvents: "none", ...props.style }
997
+ }
998
+ )
999
+ }
1000
+ );
1001
+ }
1002
+ );
1003
+ CheckboxIndicator.displayName = INDICATOR_NAME;
1004
+ var BUBBLE_INPUT_NAME = "CheckboxBubbleInput";
1005
+ var CheckboxBubbleInput = React10.forwardRef(
1006
+ ({ __scopeCheckbox, ...props }, forwardedRef) => {
1007
+ const {
1008
+ control,
1009
+ hasConsumerStoppedPropagationRef,
1010
+ checked,
1011
+ defaultChecked,
1012
+ required,
1013
+ disabled,
1014
+ name,
1015
+ value,
1016
+ form,
1017
+ bubbleInput,
1018
+ setBubbleInput
1019
+ } = useCheckboxContext(BUBBLE_INPUT_NAME, __scopeCheckbox);
1020
+ const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);
1021
+ const prevChecked = usePrevious(checked);
1022
+ const controlSize = useSize(control);
1023
+ React10.useEffect(() => {
1024
+ const input = bubbleInput;
1025
+ if (!input) return;
1026
+ const inputProto = window.HTMLInputElement.prototype;
1027
+ const descriptor = Object.getOwnPropertyDescriptor(
1028
+ inputProto,
1029
+ "checked"
1030
+ );
1031
+ const setChecked = descriptor.set;
1032
+ const bubbles = !hasConsumerStoppedPropagationRef.current;
1033
+ if (prevChecked !== checked && setChecked) {
1034
+ const event = new Event("click", { bubbles });
1035
+ input.indeterminate = isIndeterminate(checked);
1036
+ setChecked.call(input, isIndeterminate(checked) ? false : checked);
1037
+ input.dispatchEvent(event);
1038
+ }
1039
+ }, [bubbleInput, prevChecked, checked, hasConsumerStoppedPropagationRef]);
1040
+ const defaultCheckedRef = React10.useRef(isIndeterminate(checked) ? false : checked);
1041
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1042
+ Primitive.input,
1043
+ {
1044
+ type: "checkbox",
1045
+ "aria-hidden": true,
1046
+ defaultChecked: defaultChecked ?? defaultCheckedRef.current,
1047
+ required,
1048
+ disabled,
1049
+ name,
1050
+ value,
1051
+ form,
1052
+ ...props,
1053
+ tabIndex: -1,
1054
+ ref: composedRefs,
1055
+ style: {
1056
+ ...props.style,
1057
+ ...controlSize,
1058
+ position: "absolute",
1059
+ pointerEvents: "none",
1060
+ opacity: 0,
1061
+ margin: 0,
1062
+ // We transform because the input is absolutely positioned but we have
1063
+ // rendered it **after** the button. This pulls it back to sit on top
1064
+ // of the button.
1065
+ transform: "translateX(-100%)"
1066
+ }
1067
+ }
1068
+ );
1069
+ }
1070
+ );
1071
+ CheckboxBubbleInput.displayName = BUBBLE_INPUT_NAME;
1072
+ function isFunction2(value) {
1073
+ return typeof value === "function";
1074
+ }
1075
+ function isIndeterminate(checked) {
1076
+ return checked === "indeterminate";
1077
+ }
1078
+ function getState(checked) {
1079
+ return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
1080
+ }
1081
+
1082
+ // src/components/user-action/Checkbox.tsx
1083
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1084
+ var checkboxSizeMapping = {
1085
+ sm: "size-5 border-1",
1086
+ md: "size-6 border-1",
1087
+ lg: "size-8 border-2"
1088
+ };
1089
+ var checkboxIconSizeMapping = {
1090
+ sm: "size-4 stroke-3",
1091
+ md: "size-5 stroke-3",
1092
+ lg: "size-7 stroke-3"
1093
+ };
1094
+ var Checkbox2 = ({
1095
+ disabled,
1096
+ checked = false,
1097
+ indeterminate = false,
1098
+ onChange,
1099
+ size = "md",
1100
+ className = "",
1101
+ ...props
1102
+ }) => {
1103
+ const usedSizeClass = checkboxSizeMapping[size];
1104
+ const innerIconSize = checkboxIconSizeMapping[size];
1105
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1106
+ Checkbox,
1107
+ {
1108
+ ...props,
1109
+ disabled,
1110
+ checked: indeterminate ? "indeterminate" : checked,
1111
+ onCheckedChange: onChange,
1112
+ className: (0, import_clsx2.default)(
1113
+ usedSizeClass,
1114
+ `flex-col-0 items-center justify-center rounded outline-none`,
1115
+ {
1116
+ "text-disabled-text border-disabled-outline bg-disabled-background cursor-not-allowed": disabled,
1117
+ "hover:border-primary": !disabled,
1118
+ "bg-input-background": !disabled && !checked,
1119
+ "bg-primary/30 border-primary text-primary": !disabled && (checked || indeterminate)
1120
+ },
1121
+ className
1122
+ ),
1123
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(CheckboxIndicator, { children: [
1124
+ !checked && !indeterminate && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: (0, import_clsx2.default)("bg-input-background", innerIconSize) }),
1125
+ checked && !indeterminate && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.Check, { className: innerIconSize }),
1126
+ indeterminate && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.Minus, { className: innerIconSize })
1127
+ ] })
1128
+ }
1129
+ );
1130
+ };
1131
+ var CheckboxUncontrolled = ({
1132
+ checked: initialChecked,
1133
+ onChange,
1134
+ ...props
1135
+ }) => {
1136
+ const [checked, setChecked] = (0, import_react2.useState)(initialChecked);
1137
+ (0, import_react2.useEffect)(() => {
1138
+ setChecked(initialChecked);
1139
+ }, [initialChecked]);
1140
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1141
+ Checkbox2,
1142
+ {
1143
+ ...props,
1144
+ checked,
1145
+ onChange: (value) => {
1146
+ setChecked(value);
1147
+ if (onChange) {
1148
+ onChange(value);
1149
+ }
1150
+ }
1151
+ }
1152
+ );
1153
+ };
1154
+
1155
+ // src/components/user-action/CopyToClipboardWrapper.tsx
1156
+ var import_react5 = require("react");
1157
+ var import_clsx3 = require("clsx");
1158
+
1159
+ // src/localization/defaults/form.ts
1160
+ var formTranslation = {
1161
+ en: {
1162
+ add: "Add",
1163
+ all: "All",
1164
+ apply: "Apply",
1165
+ back: "Back",
1166
+ cancel: "Cancel",
1167
+ change: "Change",
1168
+ clear: "Clear",
1169
+ click: "Click",
1170
+ clickToCopy: "Click to Copy",
1171
+ close: "Close",
1172
+ confirm: "Confirm",
1173
+ copy: "Copy",
1174
+ copied: "Copied",
1175
+ create: "Create",
1176
+ decline: "Decline",
1177
+ delete: "Delete",
1178
+ discard: "Discard",
1179
+ discardChanges: "Discard Changes",
1180
+ done: "Done",
1181
+ edit: "Edit",
1182
+ enterText: "Enter text here",
1183
+ error: "Error",
1184
+ exit: "Exit",
1185
+ fieldRequiredError: "This field is required.",
1186
+ invalidEmailError: "Please enter a valid email address.",
1187
+ less: "Less",
1188
+ loading: "Loading",
1189
+ maxLengthError: "Maximum length exceeded.",
1190
+ minLengthError: "Minimum length not met.",
1191
+ more: "More",
1192
+ next: "Next",
1193
+ no: "No",
1194
+ none: "None",
1195
+ nothingFound: "Nothing found",
1196
+ of: "of",
1197
+ optional: "Optional",
1198
+ pleaseWait: "Please wait...",
1199
+ previous: "Previous",
1200
+ remove: "Remove",
1201
+ required: "Required",
1202
+ reset: "Reset",
1203
+ save: "Save",
1204
+ saved: "Saved",
1205
+ search: "Search",
1206
+ select: "Select",
1207
+ selectOption: "Select an option",
1208
+ show: "Show",
1209
+ showMore: "Show more",
1210
+ showLess: "Show less",
1211
+ submit: "Submit",
1212
+ success: "Success",
1213
+ update: "Update",
1214
+ unsavedChanges: "Unsaved Changes",
1215
+ unsavedChangesSaveQuestion: "Do you want to save your changes?",
1216
+ yes: "Yes"
1217
+ },
1218
+ de: {
1219
+ add: "Hinzuf\xFCgen",
1220
+ all: "Alle",
1221
+ apply: "Anwenden",
1222
+ back: "Zur\xFCck",
1223
+ cancel: "Abbrechen",
1224
+ change: "\xC4ndern",
1225
+ clear: "L\xF6schen",
1226
+ click: "Klicken",
1227
+ clickToCopy: "Zum kopieren klicken",
1228
+ close: "Schlie\xDFen",
1229
+ confirm: "Best\xE4tigen",
1230
+ copy: "Kopieren",
1231
+ copied: "Kopiert",
1232
+ create: "Erstellen",
1233
+ decline: "Ablehnen",
1234
+ delete: "L\xF6schen",
1235
+ discard: "Verwerfen",
1236
+ discardChanges: "\xC4nderungen Verwerfen",
1237
+ done: "Fertig",
1238
+ edit: "Bearbeiten",
1239
+ enterText: "Text hier eingeben",
1240
+ error: "Fehler",
1241
+ exit: "Beenden",
1242
+ fieldRequiredError: "Dieses Feld ist erforderlich.",
1243
+ invalidEmailError: "Bitte geben Sie eine g\xFCltige E-Mail-Adresse ein.",
1244
+ less: "Weniger",
1245
+ loading: "L\xE4dt",
1246
+ maxLengthError: "Maximale L\xE4nge \xFCberschritten.",
1247
+ minLengthError: "Mindestl\xE4nge nicht erreicht.",
1248
+ more: "Mehr",
1249
+ next: "Weiter",
1250
+ no: "Nein",
1251
+ none: "Nichts",
1252
+ nothingFound: "Nichts gefunden",
1253
+ of: "von",
1254
+ optional: "Optional",
1255
+ pleaseWait: "Bitte warten...",
1256
+ previous: "Vorherige",
1257
+ remove: "Entfernen",
1258
+ required: "Erforderlich",
1259
+ reset: "Zur\xFCcksetzen",
1260
+ save: "Speichern",
1261
+ saved: "Gespeichert",
1262
+ search: "Suche",
1263
+ select: "Select",
1264
+ selectOption: "Option ausw\xE4hlen",
1265
+ show: "Anzeigen",
1266
+ showMore: "Mehr anzeigen",
1267
+ showLess: "Weniger anzeigen",
1268
+ submit: "Abschicken",
1269
+ success: "Erfolg",
1270
+ update: "Update",
1271
+ unsavedChanges: "Ungespeicherte \xC4nderungen",
1272
+ unsavedChangesSaveQuestion: "M\xF6chtest du die \xC4nderungen speichern?",
1273
+ yes: "Ja"
1274
+ }
1275
+ };
1276
+
1277
+ // src/localization/LanguageProvider.tsx
1278
+ var import_react4 = require("react");
1279
+
1280
+ // src/hooks/useLocalStorage.ts
1281
+ var import_react3 = require("react");
1282
+
1283
+ // src/localization/util.ts
1284
+ var languages = ["en", "de"];
1285
+ var languagesLocalNames = {
1286
+ en: "English",
1287
+ de: "Deutsch"
1288
+ };
1289
+ var DEFAULT_LANGUAGE = "en";
1290
+ var LanguageUtil = {
1291
+ languages,
1292
+ DEFAULT_LANGUAGE,
1293
+ languagesLocalNames
1294
+ };
1295
+
1296
+ // src/localization/LanguageProvider.tsx
1297
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1298
+ var LanguageContext = (0, import_react4.createContext)({
1299
+ language: LanguageUtil.DEFAULT_LANGUAGE,
1300
+ setLanguage: (v) => v
1301
+ });
1302
+ var useLanguage = () => (0, import_react4.useContext)(LanguageContext);
1303
+ var useLocale = (overWriteLanguage) => {
1304
+ const { language } = useLanguage();
1305
+ const mapping = {
1306
+ en: "en-US",
1307
+ de: "de-DE"
1308
+ };
1309
+ return mapping[overWriteLanguage ?? language];
1310
+ };
1311
+
1312
+ // src/localization/useTranslation.ts
1313
+ var TranslationPluralCount = {
1314
+ zero: 0,
1315
+ one: 1,
1316
+ two: 2,
1317
+ few: 3,
1318
+ many: 11,
1319
+ other: -1
1320
+ };
1321
+ var useTranslation = (translations, overwriteTranslation = {}) => {
1322
+ const { language: languageProp, translation: overwrite } = overwriteTranslation;
1323
+ const { language: inferredLanguage } = useLanguage();
1324
+ const usedLanguage = languageProp ?? inferredLanguage;
1325
+ const usedTranslations = [...translations];
1326
+ if (overwrite) {
1327
+ usedTranslations.push(overwrite);
1328
+ }
1329
+ return (key, options) => {
1330
+ const { count, replacements } = { ...{ count: 0, replacements: {} }, ...options };
1331
+ try {
1332
+ for (let i = translations.length - 1; i >= 0; i--) {
1333
+ const translation = translations[i];
1334
+ const localizedTranslation = translation[usedLanguage];
1335
+ if (!localizedTranslation) {
1336
+ continue;
1337
+ }
1338
+ const value = localizedTranslation[key];
1339
+ if (!value) {
1340
+ continue;
1341
+ }
1342
+ let forProcessing;
1343
+ if (typeof value !== "string") {
1344
+ if (count === TranslationPluralCount.zero && value?.zero) {
1345
+ forProcessing = value.zero;
1346
+ } else if (count === TranslationPluralCount.one && value?.one) {
1347
+ forProcessing = value.one;
1348
+ } else if (count === TranslationPluralCount.two && value?.two) {
1349
+ forProcessing = value.two;
1350
+ } else if (TranslationPluralCount.few <= count && count < TranslationPluralCount.many && value?.few) {
1351
+ forProcessing = value.few;
1352
+ } else if (count > TranslationPluralCount.many && value?.many) {
1353
+ forProcessing = value.many;
1354
+ } else {
1355
+ forProcessing = value.other;
1356
+ }
1357
+ } else {
1358
+ forProcessing = value;
1359
+ }
1360
+ forProcessing = forProcessing.replace(/\{\{(\w+)}}/g, (_, placeholder) => {
1361
+ return replacements[placeholder] ?? `{{key:${placeholder}}}`;
1362
+ });
1363
+ return forProcessing;
1364
+ }
1365
+ } catch (e) {
1366
+ console.error(e);
1367
+ }
1368
+ return `{{${usedLanguage}:${key}}}`;
1369
+ };
1370
+ };
1371
+
1372
+ // src/utils/writeToClipboard.ts
1373
+ var writeToClipboard = (text) => {
1374
+ return navigator.clipboard.writeText(text);
1375
+ };
1376
+
1377
+ // src/components/user-action/CopyToClipboardWrapper.tsx
1378
+ var import_lucide_react2 = require("lucide-react");
1379
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1380
+ var CopyToClipboardWrapper = ({
1381
+ children,
1382
+ textToCopy,
1383
+ tooltipClassName = "",
1384
+ containerClassName = "",
1385
+ position = "bottom",
1386
+ zIndex = 10
1387
+ }) => {
1388
+ const translation = useTranslation([formTranslation]);
1389
+ const [isShowingIndication, setIsShowingIndication] = (0, import_react5.useState)(false);
1390
+ const [isShowingConfirmation, setIsShowingConfirmation] = (0, import_react5.useState)(false);
1391
+ const positionClasses = {
1392
+ top: `bottom-full left-1/2 -translate-x-1/2 mb-[6px]`,
1393
+ bottom: `top-full left-1/2 -translate-x-1/2 mt-[6px]`,
1394
+ left: `right-full top-1/2 -translate-y-1/2 mr-[6px]`,
1395
+ right: `left-full top-1/2 -translate-y-1/2 ml-[6px]`
1396
+ };
1397
+ const triangleSize = 6;
1398
+ const triangleClasses = {
1399
+ top: `top-full left-1/2 -translate-x-1/2 border-t-tooltip-background border-l-transparent border-r-transparent`,
1400
+ bottom: `bottom-full left-1/2 -translate-x-1/2 border-b-tooltip-background border-l-transparent border-r-transparent`,
1401
+ left: `left-full top-1/2 -translate-y-1/2 border-l-tooltip-background border-t-transparent border-b-transparent`,
1402
+ right: `right-full top-1/2 -translate-y-1/2 border-r-tooltip-background border-t-transparent border-b-transparent`
1403
+ };
1404
+ const triangleStyle = {
1405
+ top: { borderWidth: `${triangleSize}px ${triangleSize}px 0 ${triangleSize}px` },
1406
+ bottom: { borderWidth: `0 ${triangleSize}px ${triangleSize}px ${triangleSize}px` },
1407
+ left: { borderWidth: `${triangleSize}px 0 ${triangleSize}px ${triangleSize}px` },
1408
+ right: { borderWidth: `${triangleSize}px ${triangleSize}px ${triangleSize}px 0` }
1409
+ };
1410
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1411
+ "div",
1412
+ {
1413
+ className: (0, import_clsx3.clsx)("relative inline-block cursor-copy", containerClassName),
1414
+ onMouseEnter: () => {
1415
+ setIsShowingIndication(true);
1416
+ },
1417
+ onMouseLeave: () => {
1418
+ setIsShowingIndication(false);
1419
+ setIsShowingConfirmation(false);
1420
+ },
1421
+ onClick: () => {
1422
+ writeToClipboard(textToCopy).catch(console.error);
1423
+ setIsShowingIndication(false);
1424
+ setIsShowingConfirmation(true);
1425
+ },
1426
+ children: [
1427
+ children,
1428
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1429
+ "div",
1430
+ {
1431
+ className: (0, import_clsx3.clsx)(
1432
+ `absolute text-xs font-semibold text-tooltip-text px-2 py-1 rounded whitespace-nowrap
1433
+ shadow-around-md bg-tooltip-background cursor-default pointer-events-none`,
1434
+ "transition-opacity duration-200",
1435
+ positionClasses[position],
1436
+ tooltipClassName
1437
+ ),
1438
+ style: {
1439
+ zIndex,
1440
+ opacity: isShowingIndication || isShowingConfirmation ? 1 : 0
1441
+ },
1442
+ children: [
1443
+ isShowingConfirmation && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex-row-1", children: [
1444
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react2.CheckIcon, { size: 16, className: "text-positive" }),
1445
+ translation("copied")
1446
+ ] }),
1447
+ isShowingIndication && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex-row-1 text-description", children: [
1448
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react2.Copy, { size: 16 }),
1449
+ translation("clickToCopy")
1450
+ ] }),
1451
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1452
+ "div",
1453
+ {
1454
+ className: (0, import_clsx3.clsx)(`absolute w-0 h-0`, triangleClasses[position]),
1455
+ style: { ...triangleStyle[position], zIndex: zIndex + 1 }
1456
+ }
1457
+ )
1458
+ ]
1459
+ }
1460
+ )
1461
+ ]
1462
+ }
1463
+ );
1464
+ };
1465
+
1466
+ // src/components/user-action/DateAndTimePicker.tsx
1467
+ var import_clsx9 = __toESM(require("clsx"));
1468
+
1469
+ // src/utils/noop.ts
1470
+ var noop = () => void 0;
1471
+
1472
+ // src/utils/array.ts
1473
+ var equalSizeGroups = (array, groupSize) => {
1474
+ if (groupSize <= 0) {
1475
+ console.warn(`group size should be greater than 0: groupSize = ${groupSize}`);
1476
+ return [[...array]];
1477
+ }
1478
+ const groups = [];
1479
+ for (let i = 0; i < array.length; i += groupSize) {
1480
+ groups.push(array.slice(i, Math.min(i + groupSize, array.length)));
1481
+ }
1482
+ return groups;
1483
+ };
1484
+ var defaultRangeOptions = {
1485
+ allowEmptyRange: false,
1486
+ stepSize: 1,
1487
+ exclusiveStart: false,
1488
+ exclusiveEnd: true
1489
+ };
1490
+ var range = (endOrRange, options) => {
1491
+ const { allowEmptyRange, stepSize, exclusiveStart, exclusiveEnd } = { ...defaultRangeOptions, ...options };
1492
+ let start = 0;
1493
+ let end;
1494
+ if (typeof endOrRange === "number") {
1495
+ end = endOrRange;
1496
+ } else {
1497
+ start = endOrRange[0];
1498
+ end = endOrRange[1];
1499
+ }
1500
+ if (!exclusiveEnd) {
1501
+ end -= 1;
1502
+ }
1503
+ if (exclusiveStart) {
1504
+ start += 1;
1505
+ }
1506
+ if (end - 1 < start) {
1507
+ if (!allowEmptyRange) {
1508
+ console.warn(`range: end (${end}) < start (${start}) should be allowed explicitly, set options.allowEmptyRange to true`);
1509
+ }
1510
+ return [];
1511
+ }
1512
+ return Array.from({ length: end - start }, (_, index) => index * stepSize + start);
1513
+ };
1514
+ var closestMatch = (list, firstCloser) => {
1515
+ return list.reduce((item1, item2) => {
1516
+ return firstCloser(item1, item2) ? item1 : item2;
1517
+ });
1518
+ };
1519
+ var getNeighbours = (list, item, neighbourDistance = 2) => {
1520
+ const index = list.indexOf(item);
1521
+ const totalItems = neighbourDistance * 2 + 1;
1522
+ if (list.length < totalItems) {
1523
+ console.warn("List is to short");
1524
+ return list;
1525
+ }
1526
+ if (index === -1) {
1527
+ console.error("item not found in list");
1528
+ return list.splice(0, totalItems);
1529
+ }
1530
+ let start = index - neighbourDistance;
1531
+ if (start < 0) {
1532
+ start += list.length;
1533
+ }
1534
+ const end = (index + neighbourDistance + 1) % list.length;
1535
+ const result = [];
1536
+ let ignoreOnce = list.length === totalItems;
1537
+ for (let i = start; i !== end || ignoreOnce; i = (i + 1) % list.length) {
1538
+ result.push(list[i]);
1539
+ if (end === i && ignoreOnce) {
1540
+ ignoreOnce = false;
1541
+ }
1542
+ }
1543
+ return result;
1544
+ };
1545
+
1546
+ // src/utils/date.ts
1547
+ var monthsList = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"];
1548
+ var weekDayList = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
1549
+ var changeDuration = (date, duration, isAdding) => {
1550
+ const {
1551
+ years = 0,
1552
+ months = 0,
1553
+ days = 0,
1554
+ hours = 0,
1555
+ minutes = 0,
1556
+ seconds = 0,
1557
+ milliseconds = 0
1558
+ } = duration;
1559
+ if (years < 0) {
1560
+ console.error(`Range error years must be greater than 0: received ${years}`);
1561
+ return new Date(date);
1562
+ }
1563
+ if (months < 0 || months > 11) {
1564
+ console.error(`Range error month must be 0 <= month <= 11: received ${months}`);
1565
+ return new Date(date);
1566
+ }
1567
+ if (days < 0) {
1568
+ console.error(`Range error days must be greater than 0: received ${days}`);
1569
+ return new Date(date);
1570
+ }
1571
+ if (hours < 0 || hours > 23) {
1572
+ console.error(`Range error hours must be 0 <= hours <= 23: received ${hours}`);
1573
+ return new Date(date);
1574
+ }
1575
+ if (minutes < 0 || minutes > 59) {
1576
+ console.error(`Range error minutes must be 0 <= minutes <= 59: received ${minutes}`);
1577
+ return new Date(date);
1578
+ }
1579
+ if (seconds < 0 || seconds > 59) {
1580
+ console.error(`Range error seconds must be 0 <= seconds <= 59: received ${seconds}`);
1581
+ return new Date(date);
1582
+ }
1583
+ if (milliseconds < 0) {
1584
+ console.error(`Range error seconds must be greater than 0: received ${milliseconds}`);
1585
+ return new Date(date);
1586
+ }
1587
+ const multiplier = isAdding ? 1 : -1;
1588
+ const newDate = new Date(date);
1589
+ newDate.setFullYear(newDate.getFullYear() + multiplier * years);
1590
+ newDate.setMonth(newDate.getMonth() + multiplier * months);
1591
+ newDate.setDate(newDate.getDate() + multiplier * days);
1592
+ newDate.setHours(newDate.getHours() + multiplier * hours);
1593
+ newDate.setMinutes(newDate.getMinutes() + multiplier * minutes);
1594
+ newDate.setSeconds(newDate.getSeconds() + multiplier * seconds);
1595
+ newDate.setMilliseconds(newDate.getMilliseconds() + multiplier * milliseconds);
1596
+ return newDate;
1597
+ };
1598
+ var addDuration = (date, duration) => {
1599
+ return changeDuration(date, duration, true);
1600
+ };
1601
+ var subtractDuration = (date, duration) => {
1602
+ return changeDuration(date, duration, false);
1603
+ };
1604
+ var isInTimeSpan = (value, startDate, endDate) => {
1605
+ if (startDate && endDate) {
1606
+ console.assert(startDate <= endDate);
1607
+ return startDate <= value && value <= endDate;
1608
+ } else if (startDate) {
1609
+ return startDate <= value;
1610
+ } else if (endDate) {
1611
+ return endDate >= value;
1612
+ } else {
1613
+ return true;
1614
+ }
1615
+ };
1616
+ var equalDate = (date1, date2) => {
1617
+ return date1.getFullYear() === date2.getFullYear() && date1.getMonth() === date2.getMonth() && date1.getDate() === date2.getDate();
1618
+ };
1619
+ var getWeeksForCalenderMonth = (date, weekStart, weeks = 6) => {
1620
+ const month = date.getMonth();
1621
+ const year = date.getFullYear();
1622
+ const dayList = [];
1623
+ let currentDate = new Date(year, month, 1);
1624
+ const weekStartIndex = weekDayList.indexOf(weekStart);
1625
+ while (currentDate.getDay() !== weekStartIndex) {
1626
+ currentDate = subtractDuration(currentDate, { days: 1 });
1627
+ }
1628
+ while (dayList.length < 7 * weeks) {
1629
+ const date2 = new Date(currentDate);
1630
+ date2.setHours(date2.getHours(), date2.getMinutes());
1631
+ dayList.push(date2);
1632
+ currentDate = addDuration(currentDate, { days: 1 });
1633
+ }
1634
+ return equalSizeGroups(dayList, 7);
1635
+ };
1636
+
1637
+ // src/components/date/TimePicker.tsx
1638
+ var import_react6 = require("react");
1639
+ var import_react_custom_scrollbars_2 = require("react-custom-scrollbars-2");
1640
+ var import_clsx4 = __toESM(require("clsx"));
1641
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1642
+ var TimePicker = ({
1643
+ time = /* @__PURE__ */ new Date(),
1644
+ onChange = noop,
1645
+ is24HourFormat = true,
1646
+ minuteIncrement = "5min",
1647
+ maxHeight = 300,
1648
+ className = ""
1649
+ }) => {
1650
+ const minuteRef = (0, import_react6.useRef)(null);
1651
+ const hourRef = (0, import_react6.useRef)(null);
1652
+ const isPM = time.getHours() >= 11;
1653
+ const hours = is24HourFormat ? range(24) : range([1, 12], { exclusiveEnd: false });
1654
+ let minutes = range(60);
1655
+ (0, import_react6.useEffect)(() => {
1656
+ const scrollToItem = () => {
1657
+ if (minuteRef.current) {
1658
+ const container = minuteRef.current.parentElement;
1659
+ const hasOverflow = container.scrollHeight > maxHeight;
1660
+ if (hasOverflow) {
1661
+ minuteRef.current.scrollIntoView({
1662
+ behavior: "instant",
1663
+ block: "nearest"
1664
+ });
1665
+ }
1666
+ }
1667
+ };
1668
+ scrollToItem();
1669
+ }, [minuteRef, minuteRef.current]);
1670
+ (0, import_react6.useEffect)(() => {
1671
+ const scrollToItem = () => {
1672
+ if (hourRef.current) {
1673
+ const container = hourRef.current.parentElement;
1674
+ const hasOverflow = container.scrollHeight > maxHeight;
1675
+ if (hasOverflow) {
1676
+ hourRef.current.scrollIntoView({
1677
+ behavior: "instant",
1678
+ block: "nearest"
1679
+ });
1680
+ }
1681
+ }
1682
+ };
1683
+ scrollToItem();
1684
+ }, [hourRef, hourRef.current]);
1685
+ switch (minuteIncrement) {
1686
+ case "5min":
1687
+ minutes = minutes.filter((value) => value % 5 === 0);
1688
+ break;
1689
+ case "10min":
1690
+ minutes = minutes.filter((value) => value % 10 === 0);
1691
+ break;
1692
+ case "15min":
1693
+ minutes = minutes.filter((value) => value % 15 === 0);
1694
+ break;
1695
+ case "30min":
1696
+ minutes = minutes.filter((value) => value % 30 === 0);
1697
+ break;
1698
+ }
1699
+ const closestMinute = closestMatch(minutes, (item1, item2) => Math.abs(item1 - time.getMinutes()) < Math.abs(item2 - time.getMinutes()));
1700
+ const style = (selected) => (0, import_clsx4.default)(
1701
+ "chip-full hover:brightness-90 hover:bg-primary hover:text-on-primary rounded-md mr-3",
1702
+ { "bg-primary text-on-primary": selected, "bg-white text-black": !selected }
1703
+ );
1704
+ const onChangeWrapper = (transformer) => {
1705
+ const newDate = new Date(time);
1706
+ transformer(newDate);
1707
+ onChange(newDate);
1708
+ };
1709
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: (0, import_clsx4.default)("flex-row-2 w-fit min-w-[150px] select-none", className), children: [
1710
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_custom_scrollbars_2.Scrollbars, { autoHeight: true, autoHeightMax: maxHeight, style: { height: "100%" }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex-col-1 h-full", children: hours.map((hour) => {
1711
+ const currentHour = hour === time.getHours() - (!is24HourFormat && isPM ? 12 : 0);
1712
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1713
+ "button",
1714
+ {
1715
+ ref: currentHour ? hourRef : void 0,
1716
+ className: style(currentHour),
1717
+ onClick: () => onChangeWrapper((newDate) => newDate.setHours(hour + (!is24HourFormat && isPM ? 12 : 0))),
1718
+ children: hour.toString().padStart(2, "0")
1719
+ },
1720
+ hour
1721
+ );
1722
+ }) }) }),
1723
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_custom_scrollbars_2.Scrollbars, { autoHeight: true, autoHeightMax: maxHeight, style: { height: "100%" }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex-col-1 h-full", children: minutes.map((minute) => {
1724
+ const currentMinute = minute === closestMinute;
1725
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1726
+ "button",
1727
+ {
1728
+ ref: currentMinute ? minuteRef : void 0,
1729
+ className: style(currentMinute),
1730
+ onClick: () => onChangeWrapper((newDate) => newDate.setMinutes(minute)),
1731
+ children: minute.toString().padStart(2, "0")
1732
+ },
1733
+ minute + minuteIncrement
1734
+ );
1735
+ }) }) }),
1736
+ !is24HourFormat && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex-col-1", children: [
1737
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1738
+ "button",
1739
+ {
1740
+ className: style(!isPM),
1741
+ onClick: () => onChangeWrapper((newDate) => isPM && newDate.setHours(newDate.getHours() - 12)),
1742
+ children: "AM"
1743
+ }
1744
+ ),
1745
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1746
+ "button",
1747
+ {
1748
+ className: style(isPM),
1749
+ onClick: () => onChangeWrapper((newDate) => !isPM && newDate.setHours(newDate.getHours() + 12)),
1750
+ children: "PM"
1751
+ }
1752
+ )
1753
+ ] })
1754
+ ] });
1755
+ };
1756
+
1757
+ // src/components/date/DatePicker.tsx
1758
+ var import_react10 = require("react");
1759
+ var import_lucide_react4 = require("lucide-react");
1760
+ var import_clsx8 = __toESM(require("clsx"));
1761
+
1762
+ // src/components/date/YearMonthPicker.tsx
1763
+ var import_react8 = require("react");
1764
+ var import_react_custom_scrollbars_22 = require("react-custom-scrollbars-2");
1765
+ var import_clsx6 = __toESM(require("clsx"));
1766
+
1767
+ // src/components/layout/Expandable.tsx
1768
+ var import_react7 = require("react");
1769
+ var import_lucide_react3 = require("lucide-react");
1770
+ var import_clsx5 = __toESM(require("clsx"));
1771
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1772
+ var ExpansionIcon = ({ isExpanded, className }) => {
1773
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1774
+ import_lucide_react3.ChevronDown,
1775
+ {
1776
+ "aria-hidden": true,
1777
+ className: (0, import_clsx5.default)(
1778
+ "min-w-6 w-6 min-h-6 h-6 transition-transform motion-safe:duration-200 motion-reduce:duration-0 ease-in-out",
1779
+ { "rotate-180": isExpanded },
1780
+ className
1781
+ )
1782
+ }
1783
+ );
1784
+ };
1785
+ var Expandable = (0, import_react7.forwardRef)(function Expandable2({
1786
+ children,
1787
+ id: providedId,
1788
+ label,
1789
+ icon,
1790
+ isExpanded = false,
1791
+ onChange = noop,
1792
+ clickOnlyOnHeader = true,
1793
+ disabled = false,
1794
+ className,
1795
+ headerClassName,
1796
+ contentClassName,
1797
+ contentExpandedClassName
1798
+ }, ref) {
1799
+ const defaultIcon = (0, import_react7.useCallback)((expanded) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ExpansionIcon, { isExpanded: expanded }), []);
1800
+ icon ??= defaultIcon;
1801
+ const generatedId = (0, import_react7.useId)();
1802
+ const id = providedId ?? generatedId;
1803
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1804
+ "div",
1805
+ {
1806
+ ref,
1807
+ onClick: () => !clickOnlyOnHeader && !disabled && onChange(!isExpanded),
1808
+ className: (0, import_clsx5.default)(
1809
+ "flex-col-0 bg-surface text-on-surface group rounded-lg shadow-sm",
1810
+ { "cursor-pointer": !clickOnlyOnHeader && !disabled },
1811
+ className
1812
+ ),
1813
+ children: [
1814
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1815
+ "button",
1816
+ {
1817
+ onClick: () => clickOnlyOnHeader && !disabled && onChange(!isExpanded),
1818
+ className: (0, import_clsx5.default)(
1819
+ "flex-row-2 py-2 px-4 rounded-lg justify-between items-center bg-surface text-on-surface select-none",
1820
+ {
1821
+ "group-hover:brightness-97": !isExpanded,
1822
+ "hover:brightness-97": isExpanded && !disabled,
1823
+ "cursor-pointer": clickOnlyOnHeader && !disabled
1824
+ },
1825
+ headerClassName
1826
+ ),
1827
+ "aria-expanded": isExpanded,
1828
+ "aria-controls": `${id}-content`,
1829
+ "aria-disabled": disabled ?? void 0,
1830
+ children: [
1831
+ label,
1832
+ icon(isExpanded)
1833
+ ]
1834
+ }
1835
+ ),
1836
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1837
+ "div",
1838
+ {
1839
+ id: `${id}-content`,
1840
+ className: (0, import_clsx5.default)(
1841
+ "flex-col-2 px-4 transition-all duration-300 ease-in-out",
1842
+ {
1843
+ [(0, import_clsx5.default)("max-h-96 opacity-100 pb-2 overflow-y-auto", contentExpandedClassName)]: isExpanded,
1844
+ "max-h-0 opacity-0 overflow-hidden": !isExpanded
1845
+ },
1846
+ contentClassName
1847
+ ),
1848
+ role: "region",
1849
+ children
1850
+ }
1851
+ )
1852
+ ]
1853
+ }
1854
+ );
1855
+ });
1856
+ var ExpandableUncontrolled = (0, import_react7.forwardRef)(function ExpandableUncontrolled2({
1857
+ isExpanded,
1858
+ onChange = noop,
1859
+ ...props
1860
+ }, ref) {
1861
+ const [usedIsExpanded, setUsedIsExpanded] = (0, import_react7.useState)(isExpanded);
1862
+ (0, import_react7.useEffect)(() => {
1863
+ setUsedIsExpanded(isExpanded);
1864
+ }, [isExpanded]);
1865
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1866
+ Expandable,
1867
+ {
1868
+ ...props,
1869
+ ref,
1870
+ isExpanded: usedIsExpanded,
1871
+ onChange: (value) => {
1872
+ onChange(value);
1873
+ setUsedIsExpanded(value);
1874
+ }
1875
+ }
1876
+ );
1877
+ });
1878
+
1879
+ // src/components/date/YearMonthPicker.tsx
1880
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1881
+ var YearMonthPicker = ({
1882
+ displayedYearMonth = /* @__PURE__ */ new Date(),
1883
+ start = subtractDuration(/* @__PURE__ */ new Date(), { years: 50 }),
1884
+ end = addDuration(/* @__PURE__ */ new Date(), { years: 50 }),
1885
+ onChange = noop,
1886
+ className = "",
1887
+ maxHeight = 300,
1888
+ showValueOpen = true
1889
+ }) => {
1890
+ const locale = useLocale();
1891
+ const ref = (0, import_react8.useRef)(null);
1892
+ (0, import_react8.useEffect)(() => {
1893
+ const scrollToItem = () => {
1894
+ if (ref.current) {
1895
+ ref.current.scrollIntoView({
1896
+ behavior: "instant",
1897
+ block: "center"
1898
+ });
1899
+ }
1900
+ };
1901
+ scrollToItem();
1902
+ }, [ref]);
1903
+ if (end < start) {
1904
+ console.error(`startYear: (${start}) less than endYear: (${end})`);
1905
+ return null;
1906
+ }
1907
+ const years = range([start.getFullYear(), end.getFullYear()], { exclusiveEnd: false });
1908
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: (0, import_clsx6.default)("flex-col-0 select-none", className), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_custom_scrollbars_22.Scrollbars, { autoHeight: true, autoHeightMax: maxHeight, style: { height: "100%" }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "flex-col-1 mr-3", children: years.map((year) => {
1909
+ const selectedYear = displayedYearMonth.getFullYear() === year;
1910
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1911
+ ExpandableUncontrolled,
1912
+ {
1913
+ ref: (displayedYearMonth.getFullYear() ?? (/* @__PURE__ */ new Date()).getFullYear()) === year ? ref : void 0,
1914
+ label: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: (0, import_clsx6.default)({ "text-primary font-bold": selectedYear }), children: year }),
1915
+ isExpanded: showValueOpen && selectedYear,
1916
+ contentClassName: "gap-y-1",
1917
+ children: equalSizeGroups([...monthsList], 3).map((monthList, index) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "flex-row-1", children: monthList.map((month) => {
1918
+ const monthIndex = monthsList.indexOf(month);
1919
+ const newDate = new Date(year, monthIndex);
1920
+ const selectedMonth = selectedYear && monthIndex === displayedYearMonth.getMonth();
1921
+ const firstOfMonth = new Date(year, monthIndex, 1);
1922
+ const lastOfMonth = new Date(year, monthIndex, 1);
1923
+ const isAfterStart = start === void 0 || start <= addDuration(subtractDuration(lastOfMonth, { days: 1 }), { months: 1 });
1924
+ const isBeforeEnd = end === void 0 || firstOfMonth <= end;
1925
+ const isValid = isAfterStart && isBeforeEnd;
1926
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1927
+ SolidButton,
1928
+ {
1929
+ disabled: !isValid,
1930
+ color: selectedMonth && isValid ? "primary" : "neutral",
1931
+ className: "flex-1",
1932
+ size: "small",
1933
+ onClick: () => {
1934
+ onChange(newDate);
1935
+ },
1936
+ children: new Intl.DateTimeFormat(locale, { month: "short" }).format(newDate)
1937
+ },
1938
+ month
1939
+ );
1940
+ }) }, index))
1941
+ },
1942
+ year
1943
+ );
1944
+ }) }) }) });
1945
+ };
1946
+
1947
+ // src/components/date/DayPicker.tsx
1948
+ var import_clsx7 = __toESM(require("clsx"));
1949
+ var import_react9 = require("react");
1950
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1951
+ var DayPicker = ({
1952
+ displayedMonth,
1953
+ selected,
1954
+ start,
1955
+ end,
1956
+ onChange = noop,
1957
+ weekStart = "monday",
1958
+ markToday = true,
1959
+ className = ""
1960
+ }) => {
1961
+ const locale = useLocale();
1962
+ const month = displayedMonth.getMonth();
1963
+ const weeks = getWeeksForCalenderMonth(displayedMonth, weekStart);
1964
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: (0, import_clsx7.default)("flex-col-1 min-w-[220px] select-none", className), children: [
1965
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex-row-2 text-center", children: weeks[0].map((weekDay, index) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex-1 font-semibold", children: new Intl.DateTimeFormat(locale, { weekday: "long" }).format(weekDay).substring(0, 2) }, index)) }),
1966
+ weeks.map((week, index) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex-row-2 text-center", children: week.map((date) => {
1967
+ const isSelected = !!selected && equalDate(selected, date);
1968
+ const isToday = equalDate(/* @__PURE__ */ new Date(), date);
1969
+ const isSameMonth = date.getMonth() === month;
1970
+ const isDayValid = isInTimeSpan(date, start, end);
1971
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1972
+ "button",
1973
+ {
1974
+ disabled: !isDayValid,
1975
+ className: (0, import_clsx7.default)(
1976
+ "flex-1 rounded-full border-2",
1977
+ {
1978
+ "text-description": !isSameMonth && !isSelected && isDayValid,
1979
+ "text-button-solid-neutral-text bg-button-solid-neutral-background": !isSelected && isSameMonth && isDayValid,
1980
+ "text-button-solid-primary-text bg-button-solid-primary-background": isSelected && isDayValid,
1981
+ "hover:brightness-90 hover:bg-button-solid-primary-background hover:text-button-solid-primary-text": isDayValid,
1982
+ "text-disabled-text bg-disabled-background cursor-not-allowed": !isDayValid,
1983
+ "border-secondary": isToday && markToday,
1984
+ "border-transparent": !isToday || !markToday
1985
+ }
1986
+ ),
1987
+ onClick: () => onChange(date),
1988
+ children: date.getDate()
1989
+ },
1990
+ date.getDate()
1991
+ );
1992
+ }) }, index))
1993
+ ] });
1994
+ };
1995
+
1996
+ // src/localization/defaults/time.ts
1997
+ var monthTranslation = {
1998
+ en: {
1999
+ january: "January",
2000
+ february: "Febuary",
2001
+ march: "March",
2002
+ april: "April",
2003
+ may: "May",
2004
+ june: "June",
2005
+ july: "July",
2006
+ august: "August",
2007
+ september: "September",
2008
+ october: "October",
2009
+ november: "November",
2010
+ december: "December"
2011
+ },
2012
+ de: {
2013
+ january: "Januar",
2014
+ february: "Febuar",
2015
+ march: "M\xE4rz",
2016
+ april: "April",
2017
+ may: "Mai",
2018
+ june: "Juni",
2019
+ july: "Juli",
2020
+ august: "August",
2021
+ september: "September",
2022
+ october: "October",
2023
+ november: "November",
2024
+ december: "December"
2025
+ }
2026
+ };
2027
+ var timeTranslation = {
2028
+ en: {
2029
+ ...monthTranslation.en,
2030
+ century: { one: "Century", other: "Centuries" },
2031
+ decade: { one: "Decade", other: "Decades" },
2032
+ year: { one: "Year", other: "Years" },
2033
+ month: { one: "Month", other: "Months" },
2034
+ day: { one: "Day", other: "Days" },
2035
+ hour: { one: "Hour", other: "Hours" },
2036
+ minute: { one: "Minute", other: "Minutes" },
2037
+ second: { one: "Second", other: "Seconds" },
2038
+ millisecond: { one: "Millisecond", other: "Milliseconds" },
2039
+ microsecond: { one: "Microsecond", other: "Microseconds" },
2040
+ nanosecond: { one: "Nanosecond", other: "Nanoseconds" },
2041
+ yesterday: "Yesterday",
2042
+ today: "Today",
2043
+ tomorrow: "Tomorrow",
2044
+ in: "in",
2045
+ ago: "ago"
2046
+ },
2047
+ de: {
2048
+ ...monthTranslation.de,
2049
+ century: { one: "Jahrhundert", other: "Jahrhunderte" },
2050
+ decade: { one: "Jahrzehnt", other: "Jahrzehnte" },
2051
+ year: { one: "Jahr", other: "Jahre" },
2052
+ month: { one: "Monat", other: "Monate" },
2053
+ day: { one: "Tag", other: "Tage" },
2054
+ hour: { one: "Stunde", other: "Stunden" },
2055
+ minute: { one: "Minute", other: "Minuten" },
2056
+ second: { one: "Sekunde", other: "Sekunden" },
2057
+ millisecond: { one: "Millisekunde", other: "Millisekunden" },
2058
+ microsecond: { one: "Mikrosekunde", other: "Mikrosekunden" },
2059
+ nanosecond: { one: "Nanosekunde", other: "Nanosekunden" },
2060
+ yesterday: "Gestern",
2061
+ today: "Heute",
2062
+ tomorrow: "Morgen",
2063
+ in: "in",
2064
+ ago: "vor"
2065
+ }
2066
+ };
2067
+
2068
+ // src/components/date/DatePicker.tsx
2069
+ var import_jsx_runtime13 = require("react/jsx-runtime");
2070
+ var DatePicker = ({
2071
+ overwriteTranslation,
2072
+ value = /* @__PURE__ */ new Date(),
2073
+ start = subtractDuration(/* @__PURE__ */ new Date(), { years: 50 }),
2074
+ end = addDuration(/* @__PURE__ */ new Date(), { years: 50 }),
2075
+ initialDisplay = "day",
2076
+ onChange = noop,
2077
+ yearMonthPickerProps,
2078
+ dayPickerProps,
2079
+ className = ""
2080
+ }) => {
2081
+ const locale = useLocale();
2082
+ const translation = useTranslation([timeTranslation], overwriteTranslation);
2083
+ const [displayedMonth, setDisplayedMonth] = (0, import_react10.useState)(value);
2084
+ const [displayMode, setDisplayMode] = (0, import_react10.useState)(initialDisplay);
2085
+ (0, import_react10.useEffect)(() => {
2086
+ setDisplayedMonth(value);
2087
+ }, [value]);
2088
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: (0, import_clsx8.default)("flex-col-4", className), children: [
2089
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex-row-2 items-center justify-between h-7", children: [
2090
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2091
+ TextButton,
2092
+ {
2093
+ className: (0, import_clsx8.default)("flex-row-1 items-center cursor-pointer select-none", {
2094
+ "text-disabled-text": displayMode !== "day"
2095
+ }),
2096
+ onClick: () => setDisplayMode(displayMode === "day" ? "yearMonth" : "day"),
2097
+ children: [
2098
+ `${new Intl.DateTimeFormat(locale, { month: "long" }).format(displayedMonth)} ${displayedMonth.getFullYear()}`,
2099
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react4.ChevronDown, { size: 16 })
2100
+ ]
2101
+ }
2102
+ ),
2103
+ displayMode === "day" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex-row-2 justify-end", children: [
2104
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2105
+ SolidButton,
2106
+ {
2107
+ size: "small",
2108
+ color: "primary",
2109
+ disabled: !isInTimeSpan(subtractDuration(displayedMonth, { months: 1 }), start, end),
2110
+ onClick: () => {
2111
+ setDisplayedMonth(subtractDuration(displayedMonth, { months: 1 }));
2112
+ },
2113
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react4.ArrowUp, { size: 20 })
2114
+ }
2115
+ ),
2116
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2117
+ SolidButton,
2118
+ {
2119
+ size: "small",
2120
+ color: "primary",
2121
+ disabled: !isInTimeSpan(addDuration(displayedMonth, { months: 1 }), start, end),
2122
+ onClick: () => {
2123
+ setDisplayedMonth(addDuration(displayedMonth, { months: 1 }));
2124
+ },
2125
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react4.ArrowDown, { size: 20 })
2126
+ }
2127
+ )
2128
+ ] })
2129
+ ] }),
2130
+ displayMode === "yearMonth" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2131
+ YearMonthPicker,
2132
+ {
2133
+ ...yearMonthPickerProps,
2134
+ displayedYearMonth: value,
2135
+ start,
2136
+ end,
2137
+ onChange: (newDate) => {
2138
+ setDisplayedMonth(newDate);
2139
+ setDisplayMode("day");
2140
+ }
2141
+ }
2142
+ ) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { children: [
2143
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2144
+ DayPicker,
2145
+ {
2146
+ ...dayPickerProps,
2147
+ displayedMonth,
2148
+ start,
2149
+ end,
2150
+ selected: value,
2151
+ onChange: (date) => {
2152
+ onChange(date);
2153
+ }
2154
+ }
2155
+ ),
2156
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "mt-2", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2157
+ TextButton,
2158
+ {
2159
+ color: "primary",
2160
+ onClick: () => {
2161
+ const newDate = /* @__PURE__ */ new Date();
2162
+ newDate.setHours(value.getHours(), value.getMinutes());
2163
+ onChange(newDate);
2164
+ },
2165
+ children: translation("today")
2166
+ }
2167
+ ) })
2168
+ ] })
2169
+ ] });
2170
+ };
2171
+
2172
+ // src/components/user-action/DateAndTimePicker.tsx
2173
+ var import_jsx_runtime14 = require("react/jsx-runtime");
2174
+ var DateTimePicker = ({
2175
+ overwriteTranslation,
2176
+ value = /* @__PURE__ */ new Date(),
2177
+ start = subtractDuration(/* @__PURE__ */ new Date(), { years: 50 }),
2178
+ end = addDuration(/* @__PURE__ */ new Date(), { years: 50 }),
2179
+ mode = "dateTime",
2180
+ onFinish = noop,
2181
+ onChange = noop,
2182
+ onRemove = noop,
2183
+ timePickerProps,
2184
+ datePickerProps
2185
+ }) => {
2186
+ const translation = useTranslation([formTranslation, timeTranslation], overwriteTranslation);
2187
+ const useDate = mode === "dateTime" || mode === "date";
2188
+ const useTime = mode === "dateTime" || mode === "time";
2189
+ let dateDisplay;
2190
+ let timeDisplay;
2191
+ if (useDate) {
2192
+ dateDisplay = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2193
+ DatePicker,
2194
+ {
2195
+ ...datePickerProps,
2196
+ className: "min-w-[320px] min-h-[250px]",
2197
+ yearMonthPickerProps: { maxHeight: 218 },
2198
+ value,
2199
+ start,
2200
+ end,
2201
+ onChange
2202
+ }
2203
+ );
2204
+ }
2205
+ if (useTime) {
2206
+ timeDisplay = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2207
+ TimePicker,
2208
+ {
2209
+ ...timePickerProps,
2210
+ className: (0, import_clsx9.default)("h-full", { "justify-between w-full": mode === "time" }),
2211
+ maxHeight: 250,
2212
+ time: value,
2213
+ onChange
2214
+ }
2215
+ );
2216
+ }
2217
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex-col-2 w-fit", children: [
2218
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex-row-4", children: [
2219
+ dateDisplay,
2220
+ timeDisplay
2221
+ ] }),
2222
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "flex-row-2 justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex-row-2 mt-1", children: [
2223
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SolidButton, { size: "medium", color: "negative", onClick: onRemove, children: translation("clear") }),
2224
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2225
+ SolidButton,
2226
+ {
2227
+ size: "medium",
2228
+ onClick: () => onFinish(value),
2229
+ children: translation("change")
2230
+ }
2231
+ )
2232
+ ] }) })
2233
+ ] });
2234
+ };
2235
+
2236
+ // src/components/user-action/Label.tsx
2237
+ var import_clsx10 = __toESM(require("clsx"));
2238
+ var import_jsx_runtime15 = require("react/jsx-runtime");
2239
+ var styleMapping = {
2240
+ sm: "typography-label-xs color-label-text",
2241
+ md: "typography-label-md color-label-text"
2242
+ };
2243
+ var Label = ({
2244
+ children,
2245
+ size = "md",
2246
+ className,
2247
+ ...props
2248
+ }) => {
2249
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("label", { ...props, className: (0, import_clsx10.default)(styleMapping[size], className), children });
2250
+ };
2251
+
2252
+ // src/components/user-action/Menu.tsx
2253
+ var import_react13 = require("react");
2254
+ var import_clsx11 = __toESM(require("clsx"));
2255
+
2256
+ // src/hooks/useOutsideClick.ts
2257
+ var import_react11 = require("react");
2258
+ var useOutsideClick = (refs, handler) => {
2259
+ (0, import_react11.useEffect)(() => {
2260
+ const listener = (event) => {
2261
+ if (event.target === null) return;
2262
+ if (refs.some((ref) => !ref.current || ref.current.contains(event.target))) {
2263
+ return;
2264
+ }
2265
+ handler();
2266
+ };
2267
+ document.addEventListener("mousedown", listener);
2268
+ document.addEventListener("touchstart", listener);
2269
+ return () => {
2270
+ document.removeEventListener("mousedown", listener);
2271
+ document.removeEventListener("touchstart", listener);
2272
+ };
2273
+ }, [refs, handler]);
2274
+ };
2275
+
2276
+ // src/hooks/useHoverState.ts
2277
+ var import_react12 = require("react");
2278
+ var defaultUseHoverStateProps = {
2279
+ closingDelay: 200,
2280
+ isDisabled: false
2281
+ };
2282
+ var useHoverState = (props = void 0) => {
2283
+ const { closingDelay, isDisabled } = { ...defaultUseHoverStateProps, ...props };
2284
+ const [isHovered, setIsHovered] = (0, import_react12.useState)(false);
2285
+ const [timer, setTimer] = (0, import_react12.useState)();
2286
+ const onMouseEnter = () => {
2287
+ if (isDisabled) {
2288
+ return;
2289
+ }
2290
+ clearTimeout(timer);
2291
+ setIsHovered(true);
2292
+ };
2293
+ const onMouseLeave = () => {
2294
+ if (isDisabled) {
2295
+ return;
2296
+ }
2297
+ setTimer(setTimeout(() => {
2298
+ setIsHovered(false);
2299
+ }, closingDelay));
2300
+ };
2301
+ (0, import_react12.useEffect)(() => {
2302
+ if (timer) {
2303
+ return () => {
2304
+ clearTimeout(timer);
2305
+ };
2306
+ }
2307
+ });
2308
+ (0, import_react12.useEffect)(() => {
2309
+ if (timer) {
2310
+ clearTimeout(timer);
2311
+ }
2312
+ }, [isDisabled]);
2313
+ return {
2314
+ isHovered,
2315
+ setIsHovered,
2316
+ handlers: { onMouseEnter, onMouseLeave }
2317
+ };
2318
+ };
2319
+
2320
+ // src/utils/bagFunctions.ts
2321
+ var resolve = (children, bag) => {
2322
+ if (typeof children === "function") {
2323
+ return children(bag);
2324
+ }
2325
+ return children ?? void 0;
2326
+ };
2327
+ var BagFunctionUtil = {
2328
+ resolve
2329
+ };
2330
+
2331
+ // src/hooks/usePopoverPosition.ts
2332
+ var defaultPopoverPositionOptions = {
2333
+ edgePadding: 16,
2334
+ outerGap: 4,
2335
+ horizontalAlignment: "leftInside",
2336
+ verticalAlignment: "bottomOutside",
2337
+ disabled: false
2338
+ };
2339
+ var usePopoverPosition = (trigger, options) => {
2340
+ const {
2341
+ edgePadding,
2342
+ outerGap,
2343
+ verticalAlignment,
2344
+ horizontalAlignment,
2345
+ disabled
2346
+ } = { ...defaultPopoverPositionOptions, ...options };
2347
+ if (disabled || !trigger) {
2348
+ return {};
2349
+ }
2350
+ const left = {
2351
+ leftOutside: trigger.left - outerGap,
2352
+ leftInside: trigger.left,
2353
+ rightOutside: trigger.right + outerGap,
2354
+ rightInside: trigger.right,
2355
+ center: trigger.left + trigger.width / 2
2356
+ }[horizontalAlignment];
2357
+ const top = {
2358
+ topOutside: trigger.top - outerGap,
2359
+ topInside: trigger.top,
2360
+ bottomOutside: trigger.bottom + outerGap,
2361
+ bottomInside: trigger.bottom,
2362
+ center: trigger.top + trigger.height / 2
2363
+ }[verticalAlignment];
2364
+ const translateX = {
2365
+ leftOutside: "-100%",
2366
+ leftInside: void 0,
2367
+ rightOutside: void 0,
2368
+ rightInside: "-100%",
2369
+ center: "-50%"
2370
+ }[horizontalAlignment];
2371
+ const translateY = {
2372
+ topOutside: "-100%",
2373
+ topInside: void 0,
2374
+ bottomOutside: void 0,
2375
+ bottomInside: "-100%",
2376
+ center: "-50%"
2377
+ }[verticalAlignment];
2378
+ return {
2379
+ left: Math.max(left, edgePadding),
2380
+ top: Math.max(top, edgePadding),
2381
+ translate: [translateX ?? "0", translateY ?? "0"].join(" ")
2382
+ };
2383
+ };
2384
+
2385
+ // src/components/user-action/Menu.tsx
2386
+ var import_react_dom = require("react-dom");
2387
+ var import_jsx_runtime16 = require("react/jsx-runtime");
2388
+ var MenuItem = ({
2389
+ children,
2390
+ onClick,
2391
+ alignment = "left",
2392
+ isDisabled = false,
2393
+ className
2394
+ }) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2395
+ "div",
2396
+ {
2397
+ className: (0, import_clsx11.default)("block px-3 py-1.5 first:rounded-t-md last:rounded-b-md text-sm font-semibold text-nowrap", {
2398
+ "text-right": alignment === "right",
2399
+ "text-left": alignment === "left",
2400
+ "text-disabled-text cursor-not-allowed": isDisabled,
2401
+ "text-menu-text hover:bg-primary/20": !isDisabled,
2402
+ "cursor-pointer": !!onClick
2403
+ }, className),
2404
+ onClick,
2405
+ children
2406
+ }
2407
+ );
2408
+ function getScrollableParents(element) {
2409
+ const scrollables = [];
2410
+ let parent = element.parentElement;
2411
+ while (parent) {
2412
+ scrollables.push(parent);
2413
+ parent = parent.parentElement;
2414
+ }
2415
+ return scrollables;
2416
+ }
2417
+ var Menu = ({
2418
+ trigger,
2419
+ children,
2420
+ alignmentHorizontal = "leftInside",
2421
+ alignmentVertical = "bottomOutside",
2422
+ showOnHover = false,
2423
+ disabled = false,
2424
+ menuClassName = ""
2425
+ }) => {
2426
+ const { isHovered: isOpen, setIsHovered: setIsOpen } = useHoverState({ isDisabled: !showOnHover || disabled });
2427
+ const triggerRef = (0, import_react13.useRef)(null);
2428
+ const menuRef = (0, import_react13.useRef)(null);
2429
+ useOutsideClick([triggerRef, menuRef], () => setIsOpen(false));
2430
+ const [isHidden, setIsHidden] = (0, import_react13.useState)(true);
2431
+ const bag = {
2432
+ isOpen,
2433
+ close: () => setIsOpen(false),
2434
+ toggleOpen: () => setIsOpen((prevState) => !prevState),
2435
+ disabled
2436
+ };
2437
+ const menuPosition = usePopoverPosition(
2438
+ triggerRef.current?.getBoundingClientRect(),
2439
+ { verticalAlignment: alignmentVertical, horizontalAlignment: alignmentHorizontal, disabled }
2440
+ );
2441
+ (0, import_react13.useEffect)(() => {
2442
+ if (!isOpen) return;
2443
+ const triggerEl = triggerRef.current;
2444
+ if (!triggerEl) return;
2445
+ const scrollableParents = getScrollableParents(triggerEl);
2446
+ const close = () => setIsOpen(false);
2447
+ scrollableParents.forEach((parent) => {
2448
+ parent.addEventListener("scroll", close);
2449
+ });
2450
+ window.addEventListener("resize", close);
2451
+ return () => {
2452
+ scrollableParents.forEach((parent) => {
2453
+ parent.removeEventListener("scroll", close);
2454
+ });
2455
+ window.removeEventListener("resize", close);
2456
+ };
2457
+ }, [isOpen, setIsOpen]);
2458
+ (0, import_react13.useEffect)(() => {
2459
+ if (isOpen) {
2460
+ setIsHidden(false);
2461
+ }
2462
+ }, [isOpen]);
2463
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
2464
+ trigger(bag, triggerRef),
2465
+ (0, import_react_dom.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2466
+ "div",
2467
+ {
2468
+ ref: menuRef,
2469
+ onClick: (e) => e.stopPropagation(),
2470
+ className: (0, import_clsx11.default)(
2471
+ "absolute rounded-md bg-menu-background text-menu-text shadow-around-lg shadow-strong z-[300]",
2472
+ {
2473
+ "animate-pop-in": isOpen,
2474
+ "animate-pop-out": !isOpen,
2475
+ "hidden": isHidden
2476
+ },
2477
+ menuClassName
2478
+ ),
2479
+ onAnimationEnd: () => {
2480
+ if (!isOpen) {
2481
+ setIsHidden(true);
2482
+ }
2483
+ },
2484
+ style: {
2485
+ ...menuPosition
2486
+ },
2487
+ children: BagFunctionUtil.resolve(children, bag)
2488
+ }
2489
+ ), document.body)
2490
+ ] });
2491
+ };
2492
+
2493
+ // src/components/user-action/ScrollPicker.tsx
2494
+ var import_react14 = require("react");
2495
+ var import_clsx12 = __toESM(require("clsx"));
2496
+
2497
+ // src/utils/math.ts
2498
+ var clamp = (value, range2 = [0, 1]) => {
2499
+ const [min, max] = range2;
2500
+ return Math.min(Math.max(value, min), max);
2501
+ };
2502
+
2503
+ // src/components/user-action/ScrollPicker.tsx
2504
+ var import_jsx_runtime17 = require("react/jsx-runtime");
2505
+ var up = 1;
2506
+ var down = -1;
2507
+ var ScrollPicker = ({
2508
+ options,
2509
+ mapping,
2510
+ selected,
2511
+ onChange = noop,
2512
+ disabled = false
2513
+ }) => {
2514
+ let selectedIndex = 0;
2515
+ if (selected && options.indexOf(selected) !== -1) {
2516
+ selectedIndex = options.indexOf(selected);
2517
+ }
2518
+ const [{
2519
+ currentIndex,
2520
+ transition,
2521
+ items,
2522
+ lastTimeStamp
2523
+ }, setAnimation] = (0, import_react14.useState)({
2524
+ targetIndex: selectedIndex,
2525
+ currentIndex: disabled ? selectedIndex : 0,
2526
+ velocity: 0,
2527
+ animationVelocity: Math.floor(options.length / 2),
2528
+ transition: 0,
2529
+ items: options
2530
+ });
2531
+ const itemsShownCount = 5;
2532
+ const shownItems = getNeighbours(range(items.length), currentIndex).map((index) => ({
2533
+ name: mapping(items[index]),
2534
+ index
2535
+ }));
2536
+ const itemHeight = 40;
2537
+ const distance = 8;
2538
+ const containerHeight = itemHeight * (itemsShownCount - 2) + distance * (itemsShownCount - 2 + 1);
2539
+ const getDirection = (0, import_react14.useCallback)((targetIndex, currentIndex2, transition2, length) => {
2540
+ if (targetIndex === currentIndex2) {
2541
+ return transition2 > 0 ? up : down;
2542
+ }
2543
+ let distanceForward = targetIndex - currentIndex2;
2544
+ if (distanceForward < 0) {
2545
+ distanceForward += length;
2546
+ }
2547
+ return distanceForward >= length / 2 ? down : up;
2548
+ }, []);
2549
+ const animate = (0, import_react14.useCallback)((timestamp, startTime) => {
2550
+ setAnimation((prevState) => {
2551
+ const {
2552
+ targetIndex,
2553
+ currentIndex: currentIndex2,
2554
+ transition: transition2,
2555
+ animationVelocity,
2556
+ velocity,
2557
+ items: items2,
2558
+ lastScrollTimeStamp
2559
+ } = prevState;
2560
+ if (disabled) {
2561
+ return { ...prevState, currentIndex: targetIndex, velocity: 0, lastTimeStamp: timestamp };
2562
+ }
2563
+ if (targetIndex === currentIndex2 && velocity === 0 && transition2 === 0 || !startTime) {
2564
+ return { ...prevState, lastTimeStamp: timestamp };
2565
+ }
2566
+ const progress = (timestamp - startTime) / 1e3;
2567
+ const direction = getDirection(targetIndex, currentIndex2, transition2, items2.length);
2568
+ let newVelocity = velocity;
2569
+ let usedVelocity;
2570
+ let newCurrentIndex = currentIndex2;
2571
+ const isAutoScrolling = velocity <= 10 && (!lastScrollTimeStamp || timestamp - lastScrollTimeStamp > 50);
2572
+ const newLastScrollTimeStamp = velocity !== 0 ? timestamp : lastScrollTimeStamp;
2573
+ if (isAutoScrolling) {
2574
+ usedVelocity = direction * animationVelocity;
2575
+ } else {
2576
+ usedVelocity = velocity;
2577
+ newVelocity = velocity * 0.5;
2578
+ if (Math.abs(newVelocity) <= 0.05) {
2579
+ newVelocity = 0;
2580
+ }
2581
+ }
2582
+ let newTransition = transition2 + usedVelocity * progress;
2583
+ const changeThreshold = 0.5;
2584
+ while (newTransition >= changeThreshold) {
2585
+ if (newCurrentIndex === targetIndex && newTransition >= changeThreshold && isAutoScrolling) {
2586
+ newTransition = 0;
2587
+ break;
2588
+ }
2589
+ newCurrentIndex = (currentIndex2 + 1) % items2.length;
2590
+ newTransition -= 1;
2591
+ }
2592
+ if (newTransition >= changeThreshold) {
2593
+ newTransition = 0;
2594
+ }
2595
+ while (newTransition <= -changeThreshold) {
2596
+ if (newCurrentIndex === targetIndex && newTransition <= -changeThreshold && isAutoScrolling) {
2597
+ newTransition = 0;
2598
+ break;
2599
+ }
2600
+ newCurrentIndex = currentIndex2 === 0 ? items2.length - 1 : currentIndex2 - 1;
2601
+ newTransition += 1;
2602
+ }
2603
+ let newTargetIndex = targetIndex;
2604
+ if (!isAutoScrolling) {
2605
+ newTargetIndex = newCurrentIndex;
2606
+ }
2607
+ if ((currentIndex2 !== newTargetIndex || newTargetIndex !== targetIndex) && newTargetIndex === newCurrentIndex) {
2608
+ onChange(items2[newCurrentIndex]);
2609
+ }
2610
+ return {
2611
+ targetIndex: newTargetIndex,
2612
+ currentIndex: newCurrentIndex,
2613
+ animationVelocity,
2614
+ transition: newTransition,
2615
+ velocity: newVelocity,
2616
+ items: items2,
2617
+ lastTimeStamp: timestamp,
2618
+ lastScrollTimeStamp: newLastScrollTimeStamp
2619
+ };
2620
+ });
2621
+ }, [disabled, getDirection, onChange]);
2622
+ (0, import_react14.useEffect)(() => {
2623
+ requestAnimationFrame((timestamp) => animate(timestamp, lastTimeStamp));
2624
+ });
2625
+ const opacity = (transition2, index, itemsCount) => {
2626
+ const max = 100;
2627
+ const min = 0;
2628
+ const distance2 = max - min;
2629
+ let opacityValue = min;
2630
+ const unitTransition = clamp(transition2 / 0.5);
2631
+ if (index === 1 || index === itemsCount - 2) {
2632
+ if (index === 1 && transition2 > 0) {
2633
+ opacityValue += Math.floor(unitTransition * distance2);
2634
+ }
2635
+ if (index === itemsCount - 2 && transition2 < 0) {
2636
+ opacityValue += Math.floor(unitTransition * distance2);
2637
+ }
2638
+ } else {
2639
+ opacityValue = max;
2640
+ }
2641
+ return clamp(1 - opacityValue / max);
2642
+ };
2643
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2644
+ "div",
2645
+ {
2646
+ className: "relative overflow-hidden",
2647
+ style: { height: containerHeight },
2648
+ onWheel: (event) => {
2649
+ if (event.deltaY !== 0) {
2650
+ const deltaY = clamp(event.deltaY, [-itemHeight * 2 / 3, itemHeight * 2 / 3]);
2651
+ setAnimation(({ velocity, ...animationData }) => ({ ...animationData, velocity: velocity + deltaY }));
2652
+ }
2653
+ },
2654
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "absolute top-1/2 -translate-y-1/2 -translate-x-1/2 left-1/2", children: [
2655
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2656
+ "div",
2657
+ {
2658
+ className: "absolute z-[1] top-1/2 -translate-y-1/2 -translate-x-1/2 left-1/2 w-full min-w-[40px] border border-divider/50 border-y-2 border-x-0 ",
2659
+ style: { height: `${itemHeight}px` }
2660
+ }
2661
+ ),
2662
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2663
+ "div",
2664
+ {
2665
+ className: "flex-col-2 select-none",
2666
+ style: {
2667
+ transform: `translateY(${-transition * (distance + itemHeight)}px)`,
2668
+ columnGap: `${distance}px`
2669
+ },
2670
+ children: shownItems.map(({ name, index }, arrayIndex) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2671
+ "div",
2672
+ {
2673
+ className: (0, import_clsx12.default)(
2674
+ `flex-col-2 items-center justify-center rounded-md`,
2675
+ {
2676
+ "text-primary font-bold": currentIndex === index,
2677
+ "text-on-background": currentIndex === index,
2678
+ "cursor-pointer": !disabled,
2679
+ "cursor-not-allowed": disabled
2680
+ }
2681
+ ),
2682
+ style: {
2683
+ opacity: currentIndex !== index ? opacity(transition, arrayIndex, shownItems.length) : void 0,
2684
+ height: `${itemHeight}px`,
2685
+ maxHeight: `${itemHeight}px`
2686
+ },
2687
+ onClick: () => !disabled && setAnimation((prevState) => ({ ...prevState, targetIndex: index })),
2688
+ children: name
2689
+ },
2690
+ index
2691
+ ))
2692
+ }
2693
+ )
2694
+ ] })
2695
+ }
2696
+ );
2697
+ };
2698
+
2699
+ // src/components/user-action/input/Input.tsx
2700
+ var import_react17 = require("react");
2701
+ var import_clsx13 = __toESM(require("clsx"));
2702
+
2703
+ // src/hooks/useDelay.ts
2704
+ var import_react15 = require("react");
2705
+ var defaultOptions = {
2706
+ delay: 3e3,
2707
+ disabled: false
2708
+ };
2709
+ function useDelay(options) {
2710
+ const [timer, setTimer] = (0, import_react15.useState)(void 0);
2711
+ const { delay, disabled } = {
2712
+ ...defaultOptions,
2713
+ ...options
2714
+ };
2715
+ const clearTimer = () => {
2716
+ clearTimeout(timer);
2717
+ setTimer(void 0);
2718
+ };
2719
+ const restartTimer = (onDelayFinish) => {
2720
+ if (disabled) {
2721
+ return;
2722
+ }
2723
+ clearTimeout(timer);
2724
+ setTimer(setTimeout(() => {
2725
+ onDelayFinish();
2726
+ setTimer(void 0);
2727
+ }, delay));
2728
+ };
2729
+ (0, import_react15.useEffect)(() => {
2730
+ return () => {
2731
+ clearTimeout(timer);
2732
+ };
2733
+ }, [timer]);
2734
+ (0, import_react15.useEffect)(() => {
2735
+ if (disabled) {
2736
+ clearTimeout(timer);
2737
+ setTimer(void 0);
2738
+ }
2739
+ }, [disabled, timer]);
2740
+ return { restartTimer, clearTimer, hasActiveTimer: !!timer };
2741
+ }
2742
+
2743
+ // src/hooks/focus/useFocusManagement.ts
2744
+ var import_react16 = require("react");
2745
+ function useFocusManagement() {
2746
+ const getFocusableElements = (0, import_react16.useCallback)(() => {
2747
+ return Array.from(
2748
+ document.querySelectorAll(
2749
+ 'input, button, select, textarea, a[href], [tabindex]:not([tabindex="-1"])'
2750
+ )
2751
+ ).filter(
2752
+ (el) => el instanceof HTMLElement && !el.hasAttribute("disabled") && !el.hasAttribute("hidden") && el.tabIndex !== -1
2753
+ );
2754
+ }, []);
2755
+ const getNextFocusElement = (0, import_react16.useCallback)(() => {
2756
+ const elements = getFocusableElements();
2757
+ if (elements.length === 0) {
2758
+ return void 0;
2759
+ }
2760
+ let nextElement = elements[0];
2761
+ if (document.activeElement instanceof HTMLElement) {
2762
+ const currentIndex = elements.indexOf(document.activeElement);
2763
+ nextElement = elements[(currentIndex + 1) % elements.length];
2764
+ }
2765
+ return nextElement;
2766
+ }, [getFocusableElements]);
2767
+ const focusNext = (0, import_react16.useCallback)(() => {
2768
+ const nextElement = getNextFocusElement();
2769
+ nextElement?.focus();
2770
+ }, [getNextFocusElement]);
2771
+ const getPreviousFocusElement = (0, import_react16.useCallback)(() => {
2772
+ const elements = getFocusableElements();
2773
+ if (elements.length === 0) {
2774
+ return void 0;
2775
+ }
2776
+ let previousElement = elements[0];
2777
+ if (document.activeElement instanceof HTMLElement) {
2778
+ const currentIndex = elements.indexOf(document.activeElement);
2779
+ if (currentIndex === 0) {
2780
+ previousElement = elements[elements.length - 1];
2781
+ } else {
2782
+ previousElement = elements[currentIndex - 1];
2783
+ }
2784
+ }
2785
+ return previousElement;
2786
+ }, [getFocusableElements]);
2787
+ const focusPrevious = (0, import_react16.useCallback)(() => {
2788
+ const previousElement = getPreviousFocusElement();
2789
+ if (previousElement) previousElement.focus();
2790
+ }, [getPreviousFocusElement]);
2791
+ return {
2792
+ getFocusableElements,
2793
+ getNextFocusElement,
2794
+ getPreviousFocusElement,
2795
+ focusNext,
2796
+ focusPrevious
2797
+ };
2798
+ }
2799
+
2800
+ // src/components/user-action/input/Input.tsx
2801
+ var import_jsx_runtime18 = require("react/jsx-runtime");
2802
+ var defaultEditCompleteOptions = {
2803
+ allowEnterComplete: false,
2804
+ onBlur: true,
2805
+ afterDelay: true,
2806
+ delay: 2500
2807
+ };
2808
+ var Input = (0, import_react17.forwardRef)(function Input2({
2809
+ value,
2810
+ onChange,
2811
+ onChangeText,
2812
+ onEditCompleted,
2813
+ editCompleteOptions,
2814
+ disabled = false,
2815
+ invalid = false,
2816
+ defaultStyle = true,
2817
+ className,
2818
+ ...props
2819
+ }, forwardedRef) {
2820
+ const {
2821
+ onBlur: allowEditCompleteOnBlur,
2822
+ afterDelay,
2823
+ delay,
2824
+ allowEnterComplete
2825
+ } = { ...defaultEditCompleteOptions, ...editCompleteOptions };
2826
+ const {
2827
+ restartTimer,
2828
+ clearTimer
2829
+ } = useDelay({ delay, disabled: !afterDelay });
2830
+ const innerRef = (0, import_react17.useRef)(null);
2831
+ (0, import_react17.useImperativeHandle)(forwardedRef, () => innerRef.current);
2832
+ const { focusNext } = useFocusManagement();
2833
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2834
+ "input",
2835
+ {
2836
+ ...props,
2837
+ ref: innerRef,
2838
+ value,
2839
+ disabled,
2840
+ className: defaultStyle ? (0, import_clsx13.default)(
2841
+ "px-2.5 py-1.75 rounded-md border-1 text-sm",
2842
+ {
2843
+ "bg-input-background text-input-text hover:border-primary focus:border-primary": !disabled && !invalid,
2844
+ "bg-on-negative text-negative border-negative-border hover:border-negative-border-hover focus-visible:ring-negative-border": !disabled && invalid,
2845
+ "bg-disabled-background text-disabled-text border-disabled-border": disabled
2846
+ },
2847
+ className
2848
+ ) : className,
2849
+ onKeyDown: (event) => {
2850
+ props.onKeyDown?.(event);
2851
+ if (!allowEnterComplete) {
2852
+ return;
2853
+ }
2854
+ if (event.key === "Enter" && !event.shiftKey) {
2855
+ event.preventDefault();
2856
+ innerRef.current?.blur();
2857
+ onEditCompleted?.(event.target.value);
2858
+ focusNext();
2859
+ }
2860
+ },
2861
+ onBlur: (event) => {
2862
+ props.onBlur?.(event);
2863
+ if (allowEditCompleteOnBlur) {
2864
+ onEditCompleted?.(event.target.value);
2865
+ clearTimer();
2866
+ }
2867
+ },
2868
+ onChange: (event) => {
2869
+ onChange?.(event);
2870
+ const value2 = event.target.value;
2871
+ restartTimer(() => {
2872
+ innerRef.current?.blur();
2873
+ onEditCompleted?.(value2);
2874
+ });
2875
+ onChangeText?.(value2);
2876
+ },
2877
+ "aria-invalid": props["aria-invalid"] ?? invalid,
2878
+ "aria-disabled": props["aria-disabled"] ?? disabled
2879
+ }
2880
+ );
2881
+ });
2882
+ var InputUncontrolled = ({
2883
+ value = "",
2884
+ onChangeText,
2885
+ ...props
2886
+ }) => {
2887
+ const [usedValue, setUsedValue] = (0, import_react17.useState)(value);
2888
+ (0, import_react17.useEffect)(() => {
2889
+ setUsedValue(value);
2890
+ }, [value]);
2891
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2892
+ Input,
2893
+ {
2894
+ ...props,
2895
+ value: usedValue,
2896
+ onChangeText: (text) => {
2897
+ onChangeText?.(text);
2898
+ setUsedValue(text);
2899
+ }
2900
+ }
2901
+ );
2902
+ };
2903
+
2904
+ // src/components/user-action/SearchBar.tsx
2905
+ var import_lucide_react5 = require("lucide-react");
2906
+ var import_clsx14 = require("clsx");
2907
+ var import_jsx_runtime19 = require("react/jsx-runtime");
2908
+ var SearchBar = ({
2909
+ placeholder,
2910
+ onSearch,
2911
+ disableOnSearch,
2912
+ containerClassName,
2913
+ ...inputProps
2914
+ }) => {
2915
+ const translation = useTranslation([formTranslation]);
2916
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: (0, import_clsx14.clsx)("flex-row-2 justify-between items-center", containerClassName), children: [
2917
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2918
+ Input,
2919
+ {
2920
+ ...inputProps,
2921
+ placeholder: placeholder ?? translation("search")
2922
+ }
2923
+ ),
2924
+ onSearch && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(IconButton, { color: "neutral", disabled: disableOnSearch, onClick: onSearch, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react5.Search, { className: "w-full h-full" }) })
2925
+ ] });
2926
+ };
2927
+
2928
+ // src/components/user-action/Textarea.tsx
2929
+ var import_react18 = require("react");
2930
+ var import_clsx15 = __toESM(require("clsx"));
2931
+ var import_jsx_runtime20 = require("react/jsx-runtime");
2932
+ var Textarea = (0, import_react18.forwardRef)(function Textarea2({
2933
+ id,
2934
+ onChange,
2935
+ onChangeText,
2936
+ onBlur,
2937
+ onEditCompleted,
2938
+ saveDelayOptions,
2939
+ defaultStyle = true,
2940
+ invalid = false,
2941
+ disabled = false,
2942
+ className,
2943
+ ...props
2944
+ }, ref) {
2945
+ const { restartTimer, clearTimer } = useDelay(saveDelayOptions);
2946
+ const onEditCompletedWrapper = (text) => {
2947
+ onEditCompleted?.(text);
2948
+ clearTimer();
2949
+ };
2950
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2951
+ "textarea",
2952
+ {
2953
+ ref,
2954
+ id,
2955
+ className: (0, import_clsx15.default)(
2956
+ "resize-none w-full h-32 overflow-y-scroll",
2957
+ "py-2 px-3 rounded-md border-1",
2958
+ {
2959
+ "bg-input-background text-input-text hover:border-primary focus-within:border-primary focus-within:ring-2 ring-focus": !disabled && !invalid,
2960
+ "bg-on-negative text-negative border-negative-border hover:border-negative-border-hover focus-visible:ring-negative-border": invalid && !disabled && defaultStyle,
2961
+ "text-disabled-text bg-disabled-background border-disabled-border": disabled && defaultStyle
2962
+ },
2963
+ className
2964
+ ),
2965
+ onChange: (event) => {
2966
+ const value = event.target.value;
2967
+ restartTimer(() => {
2968
+ onEditCompletedWrapper(value);
2969
+ });
2970
+ onChange?.(event);
2971
+ onChangeText?.(value);
2972
+ },
2973
+ onBlur: (event) => {
2974
+ onBlur?.(event);
2975
+ onEditCompletedWrapper(event.target.value);
2976
+ },
2977
+ disabled,
2978
+ ...props
2979
+ }
2980
+ );
2981
+ });
2982
+ var TextareaUncontrolled = ({
2983
+ value = "",
2984
+ onChangeText = noop,
2985
+ ...props
2986
+ }) => {
2987
+ const [text, setText] = (0, import_react18.useState)(value);
2988
+ (0, import_react18.useEffect)(() => {
2989
+ setText(value);
2990
+ }, [value]);
2991
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2992
+ Textarea,
2993
+ {
2994
+ ...props,
2995
+ value: text,
2996
+ onChangeText: (text2) => {
2997
+ setText(text2);
2998
+ onChangeText(text2);
2999
+ }
3000
+ }
3001
+ );
3002
+ };
3003
+ var TextareaWithHeadline = ({
3004
+ id,
3005
+ headline,
3006
+ headlineProps,
3007
+ disabled,
3008
+ className,
3009
+ containerClassName,
3010
+ ...props
3011
+ }) => {
3012
+ const genId = (0, import_react18.useId)();
3013
+ const usedId = id ?? genId;
3014
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
3015
+ "div",
3016
+ {
3017
+ className: (0, import_clsx15.default)(
3018
+ "group flex-col-3 border-2 rounded-lg",
3019
+ {
3020
+ "bg-input-background text-input-text hover:border-primary focus-within:border-primary": !disabled,
3021
+ "border-disabled-border bg-disabled-background cursor-not-allowed": disabled
3022
+ },
3023
+ containerClassName
3024
+ ),
3025
+ children: [
3026
+ headline && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Label, { size: "md", ...headlineProps, htmlFor: usedId, children: headline }),
3027
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3028
+ Textarea,
3029
+ {
3030
+ ...props,
3031
+ id: usedId,
3032
+ className: (0, import_clsx15.default)(
3033
+ "border-transparent focus:ring-0 focus-visible:ring-0 resize-none h-32",
3034
+ className
3035
+ ),
3036
+ defaultStyle: false
3037
+ }
3038
+ )
3039
+ ]
3040
+ }
3041
+ );
3042
+ };
3043
+
3044
+ // src/components/user-action/Tooltip.tsx
3045
+ var import_clsx16 = require("clsx");
3046
+ var import_jsx_runtime21 = require("react/jsx-runtime");
3047
+ var Tooltip = ({
3048
+ tooltip,
3049
+ children,
3050
+ animationDelay = 650,
3051
+ tooltipClassName = "",
3052
+ containerClassName = "",
3053
+ position = "bottom",
3054
+ zIndex = 10
3055
+ }) => {
3056
+ const { isHovered, handlers } = useHoverState();
3057
+ const positionClasses = {
3058
+ top: `bottom-full left-1/2 -translate-x-1/2 mb-[6px]`,
3059
+ bottom: `top-full left-1/2 -translate-x-1/2 mt-[6px]`,
3060
+ left: `right-full top-1/2 -translate-y-1/2 mr-[6px]`,
3061
+ right: `left-full top-1/2 -translate-y-1/2 ml-[6px]`
3062
+ };
3063
+ const triangleSize = 6;
3064
+ const triangleClasses = {
3065
+ top: `top-full left-1/2 -translate-x-1/2 border-t-tooltip-background border-l-transparent border-r-transparent`,
3066
+ bottom: `bottom-full left-1/2 -translate-x-1/2 border-b-tooltip-background border-l-transparent border-r-transparent`,
3067
+ left: `left-full top-1/2 -translate-y-1/2 border-l-tooltip-background border-t-transparent border-b-transparent`,
3068
+ right: `right-full top-1/2 -translate-y-1/2 border-r-tooltip-background border-t-transparent border-b-transparent`
3069
+ };
3070
+ const triangleStyle = {
3071
+ top: { borderWidth: `${triangleSize}px ${triangleSize}px 0 ${triangleSize}px` },
3072
+ bottom: { borderWidth: `0 ${triangleSize}px ${triangleSize}px ${triangleSize}px` },
3073
+ left: { borderWidth: `${triangleSize}px 0 ${triangleSize}px ${triangleSize}px` },
3074
+ right: { borderWidth: `${triangleSize}px ${triangleSize}px ${triangleSize}px 0` }
3075
+ };
3076
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3077
+ "div",
3078
+ {
3079
+ className: (0, import_clsx16.clsx)("relative inline-block", containerClassName),
3080
+ ...handlers,
3081
+ children: [
3082
+ children,
3083
+ isHovered && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3084
+ "div",
3085
+ {
3086
+ className: (0, import_clsx16.clsx)(
3087
+ `opacity-0 absolute text-xs font-semibold text-tooltip-text px-2 py-1 rounded whitespace-nowrap
3088
+ animate-tooltip-fade-in shadow-around-md bg-tooltip-background`,
3089
+ positionClasses[position],
3090
+ tooltipClassName
3091
+ ),
3092
+ style: { zIndex, animationDelay: animationDelay + "ms" },
3093
+ children: [
3094
+ tooltip,
3095
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3096
+ "div",
3097
+ {
3098
+ className: (0, import_clsx16.clsx)(`absolute w-0 h-0`, triangleClasses[position]),
3099
+ style: { ...triangleStyle[position], zIndex: zIndex + 1 }
3100
+ }
3101
+ )
3102
+ ]
3103
+ }
3104
+ )
3105
+ ]
3106
+ }
3107
+ );
3108
+ };
3109
+
3110
+ // src/components/user-action/input/InsideLabelInput.tsx
3111
+ var import_react19 = require("react");
3112
+ var import_react20 = require("react");
3113
+ var import_clsx17 = __toESM(require("clsx"));
3114
+ var import_jsx_runtime22 = require("react/jsx-runtime");
3115
+ var InsideLabelInput = (0, import_react20.forwardRef)(function InsideLabelInput2({
3116
+ id: customId,
3117
+ label,
3118
+ ...props
3119
+ }, forwardedRef) {
3120
+ const { value } = props;
3121
+ const [isFocused, setIsFocused] = (0, import_react20.useState)(false);
3122
+ const generatedId = (0, import_react19.useId)();
3123
+ const id = customId ?? generatedId;
3124
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: (0, import_clsx17.default)("relative"), children: [
3125
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3126
+ Input,
3127
+ {
3128
+ ...props,
3129
+ id,
3130
+ className: (0, import_clsx17.default)("h-14 px-4 pb-2 py-6.5", props.className),
3131
+ ref: forwardedRef,
3132
+ "aria-labelledby": id + "-label",
3133
+ onFocus: (event) => {
3134
+ props.onFocus?.(event);
3135
+ setIsFocused(true);
3136
+ },
3137
+ onBlur: (event) => {
3138
+ props.onBlur?.(event);
3139
+ setIsFocused(false);
3140
+ }
3141
+ }
3142
+ ),
3143
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3144
+ "label",
3145
+ {
3146
+ id: id + "-label",
3147
+ "aria-hidden": true,
3148
+ "data-display": isFocused || !!value ? "small" : "full",
3149
+ className: (0, import_clsx17.default)(
3150
+ "absolute left-4 top-2 transition-all pointer-events-none touch-none",
3151
+ "data-[display=small]:top-2 data-[display=small]:h-force-4.5 data-[display=small]:typography-caption-sm-regular data-[display=small]:overflow-y-hidden",
3152
+ "data-[display=full]:top-1/2 data-[display=full]:-translate-y-1/2 data-[display=full]:typography-body-md-regular"
3153
+ ),
3154
+ children: label
3155
+ }
3156
+ )
3157
+ ] });
3158
+ });
3159
+ var InsideLabelInputUncontrolled = ({
3160
+ value: initialValue,
3161
+ ...props
3162
+ }) => {
3163
+ const [value, setValue] = (0, import_react20.useState)(initialValue);
3164
+ (0, import_react20.useEffect)(() => {
3165
+ setValue(initialValue);
3166
+ }, [initialValue]);
3167
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3168
+ InsideLabelInput,
3169
+ {
3170
+ ...props,
3171
+ value,
3172
+ onChangeText: (text) => {
3173
+ props.onChangeText?.(text);
3174
+ setValue(text);
3175
+ }
3176
+ }
3177
+ );
3178
+ };
3179
+
3180
+ // src/components/user-action/input/ToggleableInput.tsx
3181
+ var import_react21 = require("react");
3182
+ var import_lucide_react6 = require("lucide-react");
3183
+ var import_clsx18 = __toESM(require("clsx"));
3184
+ var import_jsx_runtime23 = require("react/jsx-runtime");
3185
+ var ToggleableInput = (0, import_react21.forwardRef)(function ToggleableInput2({
3186
+ value,
3187
+ initialState = "display",
3188
+ editCompleteOptions,
3189
+ ...props
3190
+ }, forwardedRef) {
3191
+ const [isEditing, setIsEditing] = (0, import_react21.useState)(initialState !== "display");
3192
+ const innerRef = (0, import_react21.useRef)(null);
3193
+ (0, import_react21.useImperativeHandle)(forwardedRef, () => innerRef.current);
3194
+ (0, import_react21.useEffect)(() => {
3195
+ if (isEditing) {
3196
+ innerRef.current?.focus();
3197
+ }
3198
+ }, [isEditing]);
3199
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: (0, import_clsx18.default)("relative flex-row-2", { "flex-1": isEditing }), children: [
3200
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
3201
+ Input,
3202
+ {
3203
+ ...props,
3204
+ ref: innerRef,
3205
+ value,
3206
+ onEditCompleted: (text) => {
3207
+ props.onEditCompleted?.(text);
3208
+ setIsEditing(false);
3209
+ },
3210
+ onFocus: (event) => {
3211
+ props.onFocus?.(event);
3212
+ setIsEditing(true);
3213
+ event.target.select();
3214
+ },
3215
+ editCompleteOptions: {
3216
+ ...editCompleteOptions,
3217
+ allowEnterComplete: true
3218
+ },
3219
+ className: (0, import_clsx18.default)(`w-full ring-0 outline-0 decoration-primary underline-offset-4`, {
3220
+ "underline": isEditing,
3221
+ "text-transparent": !isEditing
3222
+ }),
3223
+ defaultStyle: false
3224
+ }
3225
+ ),
3226
+ !isEditing && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "absolute left-0 flex-row-2 items-center pointer-events-none touch-none w-full overflow-hidden", children: [
3227
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: (0, import_clsx18.default)(" truncate"), children: value }),
3228
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react6.Pencil, { className: (0, import_clsx18.default)(`size-force-4`, { "text-transparent": isEditing }) })
3229
+ ] })
3230
+ ] });
3231
+ });
3232
+ var ToggleableInputUncontrolled = ({
3233
+ value: initialValue,
3234
+ onChangeText,
3235
+ ...restProps
3236
+ }) => {
3237
+ const [value, setValue] = (0, import_react21.useState)(initialValue);
3238
+ (0, import_react21.useEffect)(() => {
3239
+ setValue(initialValue);
3240
+ }, [initialValue]);
3241
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
3242
+ ToggleableInput,
3243
+ {
3244
+ value,
3245
+ onChangeText: (text) => {
3246
+ onChangeText?.(text);
3247
+ setValue(text);
3248
+ },
3249
+ ...restProps
3250
+ }
3251
+ );
3252
+ };
3253
+
3254
+ // src/components/user-action/select/Select.tsx
3255
+ var import_react25 = require("react");
3256
+ var import_clsx20 = __toESM(require("clsx"));
3257
+
3258
+ // src/hooks/focus/useFocusTrap.ts
3259
+ var import_react23 = require("react");
3260
+
3261
+ // src/hooks/focus/useIsMounted.ts
3262
+ var import_react22 = require("react");
3263
+ var isClient = typeof window !== "undefined" && typeof document !== "undefined";
3264
+ var useIsomorphicEffect = isClient ? import_react22.useLayoutEffect : import_react22.useEffect;
3265
+ var useIsMounted = () => {
3266
+ const [isMounted, setIsMounted] = (0, import_react22.useState)(false);
3267
+ useIsomorphicEffect(() => {
3268
+ setIsMounted(true);
3269
+ return () => {
3270
+ setIsMounted(false);
3271
+ };
3272
+ }, []);
3273
+ return isMounted;
3274
+ };
3275
+
3276
+ // src/hooks/focus/useFocusTrap.ts
3277
+ var createFocusGuard = () => {
3278
+ const div = document.createElement("div");
3279
+ Object.assign(div.style, {
3280
+ opacity: "0",
3281
+ outline: "none",
3282
+ boxShadow: "none",
3283
+ position: "fixed",
3284
+ pointerEvents: "none",
3285
+ touchAction: "none"
3286
+ });
3287
+ div.tabIndex = 0;
3288
+ div.setAttribute("data-hw-focus-guard", "");
3289
+ document.body.appendChild(div);
3290
+ return div;
3291
+ };
3292
+ function getContainedFocusableElements(element) {
3293
+ return element?.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
3294
+ }
3295
+ var FocusTrapService = class {
3296
+ constructor() {
3297
+ // The last entry is always the active one
3298
+ this.listeners = [];
3299
+ this.onFocusIn = (event) => {
3300
+ const active = this.getActive();
3301
+ if (!active || !active.container.current) return;
3302
+ const { container } = active;
3303
+ if (!container.current.contains(event.target)) {
3304
+ this.focusElement();
3305
+ }
3306
+ };
3307
+ }
3308
+ getActive() {
3309
+ if (this.listeners.length === 0) return void 0;
3310
+ return this.listeners[this.listeners.length - 1];
3311
+ }
3312
+ focusElement() {
3313
+ const active = this.getActive();
3314
+ if (!active) return;
3315
+ const { container, initialFocusElement } = active;
3316
+ const containerElement = container.current;
3317
+ if (initialFocusElement?.current) {
3318
+ initialFocusElement.current.focus();
3319
+ } else {
3320
+ const elements = getContainedFocusableElements(containerElement);
3321
+ if (elements && elements.length > 0) {
3322
+ const first = elements.item(0);
3323
+ first.focus();
3324
+ } else {
3325
+ containerElement.focus();
3326
+ }
3327
+ }
3328
+ }
3329
+ removeGuards() {
3330
+ document.querySelectorAll("[data-hw-focus-guard]").forEach((node) => node.remove());
3331
+ }
3332
+ addGuards() {
3333
+ document.body.insertAdjacentElement("afterbegin", createFocusGuard());
3334
+ document.body.insertAdjacentElement("beforeend", createFocusGuard());
3335
+ }
3336
+ activate() {
3337
+ document.addEventListener("focusin", this.onFocusIn);
3338
+ this.addGuards();
3339
+ }
3340
+ deactivate() {
3341
+ document.removeEventListener("focusin", this.onFocusIn);
3342
+ this.removeGuards();
3343
+ }
3344
+ register(listener) {
3345
+ this.listeners.push(listener);
3346
+ if (this.listeners.length === 1) {
3347
+ this.activate();
3348
+ }
3349
+ const active = listener;
3350
+ this.listeners.forEach((listener2) => {
3351
+ const { focus, pause } = listener2;
3352
+ if (listener2 === active) {
3353
+ focus();
3354
+ } else {
3355
+ pause();
3356
+ }
3357
+ });
3358
+ }
3359
+ unregister(id) {
3360
+ const index = this.listeners.findIndex((trap) => trap.id === id);
3361
+ if (index !== -1) {
3362
+ const isActive = index === this.listeners.length - 1;
3363
+ const listener = this.listeners[index];
3364
+ this.listeners = this.listeners.filter((listener2) => listener2.id !== id);
3365
+ if (isActive) {
3366
+ this.deactivate();
3367
+ listener.focusLast();
3368
+ const active = this.getActive();
3369
+ this.listeners.forEach((listener2) => {
3370
+ const { pause, unpause } = listener2;
3371
+ if (listener2 === active) {
3372
+ unpause();
3373
+ } else {
3374
+ pause();
3375
+ }
3376
+ });
3377
+ if (this.listeners.length > 0) {
3378
+ this.activate();
3379
+ }
3380
+ }
3381
+ } else {
3382
+ console.warn(`Unable to unregister id ${id}: not found`);
3383
+ }
3384
+ }
3385
+ };
3386
+ var service = new FocusTrapService();
3387
+ var useFocusTrap = ({
3388
+ container,
3389
+ active = true,
3390
+ initialFocus,
3391
+ focusFirst = true
3392
+ }) => {
3393
+ const lastFocusRef = (0, import_react23.useRef)(null);
3394
+ const [paused, setPaused] = (0, import_react23.useState)(false);
3395
+ const isMounted = useIsMounted();
3396
+ const id = (0, import_react23.useId)();
3397
+ const focusElement = (0, import_react23.useCallback)(() => {
3398
+ const containerElement = container.current;
3399
+ if (initialFocus?.current) {
3400
+ initialFocus.current.focus();
3401
+ } else {
3402
+ const elements = getContainedFocusableElements(containerElement);
3403
+ if (elements && elements.length > 0) {
3404
+ const first = elements.item(0);
3405
+ first.focus();
3406
+ } else {
3407
+ containerElement.focus();
3408
+ }
3409
+ }
3410
+ }, [container, initialFocus]);
3411
+ (0, import_react23.useEffect)(() => {
3412
+ if (active && isMounted) {
3413
+ let pause = function() {
3414
+ setPaused(true);
3415
+ }, unpause = function() {
3416
+ setPaused(false);
3417
+ if (!container.current.contains(document.activeElement)) {
3418
+ focusElement();
3419
+ }
3420
+ }, focus = function() {
3421
+ focusElement();
3422
+ setPaused(false);
3423
+ }, focusLast = function() {
3424
+ lastFocusRef.current?.focus();
3425
+ };
3426
+ if (!lastFocusRef.current) {
3427
+ lastFocusRef.current = document.activeElement;
3428
+ }
3429
+ service.register({ id, pause, focus, focusLast, unpause, container, initialFocusElement: initialFocus });
3430
+ return () => {
3431
+ service.unregister(id);
3432
+ lastFocusRef.current = void 0;
3433
+ };
3434
+ }
3435
+ }, [active, container, focusElement, id, initialFocus, isMounted]);
3436
+ (0, import_react23.useEffect)(() => {
3437
+ if (active && !paused && isMounted) {
3438
+ let onKeyDown = function(event) {
3439
+ const key = event.key;
3440
+ const elements = getContainedFocusableElements(containerElement);
3441
+ const active2 = document.activeElement;
3442
+ const index = [...elements].findIndex((value) => value === active2);
3443
+ if (index === -1 || event.altKey || event.ctrlKey || event.metaKey) {
3444
+ return;
3445
+ }
3446
+ if (key === "Tab") {
3447
+ const next = event.shiftKey ? -1 : 1;
3448
+ const nextIndex = (index + next + elements.length) % elements.length;
3449
+ const nextElement = elements[nextIndex];
3450
+ nextElement.focus();
3451
+ event.preventDefault();
3452
+ }
3453
+ };
3454
+ const containerElement = container.current;
3455
+ containerElement.addEventListener("keydown", onKeyDown);
3456
+ return () => {
3457
+ containerElement.removeEventListener("keydown", onKeyDown);
3458
+ };
3459
+ }
3460
+ }, [active, paused, isMounted, container, initialFocus, focusFirst, focusElement]);
3461
+ };
3462
+
3463
+ // src/utils/match.ts
3464
+ var match = (key, values) => {
3465
+ return values[key];
3466
+ };
3467
+
3468
+ // src/components/user-action/select/Select.tsx
3469
+ var import_lucide_react7 = require("lucide-react");
3470
+
3471
+ // src/components/layout/Chip.tsx
3472
+ var import_clsx19 = __toESM(require("clsx"));
3473
+ var import_jsx_runtime24 = require("react/jsx-runtime");
3474
+ var Chip = ({
3475
+ children,
3476
+ trailingIcon,
3477
+ color = "default",
3478
+ size = "md",
3479
+ icon = false,
3480
+ variant = "normal",
3481
+ className = "",
3482
+ ...restProps
3483
+ }) => {
3484
+ const colorMapping = {
3485
+ default: "text-tag-default-text bg-tag-default-background",
3486
+ dark: "text-tag-dark-text bg-tag-dark-background",
3487
+ red: "text-tag-red-text bg-tag-red-background",
3488
+ yellow: "text-tag-yellow-text bg-tag-yellow-background",
3489
+ green: "text-tag-green-text bg-tag-green-background",
3490
+ blue: "text-tag-blue-text bg-tag-blue-background",
3491
+ pink: "text-tag-pink-text bg-tag-pink-background",
3492
+ orange: "text-tag-orange-text bg-tag-orange-background"
3493
+ }[color];
3494
+ const colorMappingIcon = {
3495
+ default: "text-tag-default-icon",
3496
+ dark: "text-tag-dark-icon",
3497
+ red: "text-tag-red-icon",
3498
+ yellow: "text-tag-yellow-icon",
3499
+ green: "text-tag-green-icon",
3500
+ blue: "text-tag-blue-icon",
3501
+ pink: "text-tag-pink-icon",
3502
+ orange: "text-tag-orange-icon"
3503
+ }[color];
3504
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
3505
+ "div",
3506
+ {
3507
+ ...restProps,
3508
+ className: (0, import_clsx19.default)(
3509
+ `flex-row-0 w-fit font-semibold`,
3510
+ colorMapping,
3511
+ !icon ? {
3512
+ "px-1 py-0.5": size === "sm",
3513
+ "px-2 py-1": size === "md",
3514
+ "px-4 py-2": size === "lg"
3515
+ } : {
3516
+ "p-0.5": size === "sm",
3517
+ "p-1": size === "md",
3518
+ "p-2": size === "lg"
3519
+ },
3520
+ {
3521
+ "rounded-md": variant === "normal",
3522
+ "rounded-full": variant === "fullyRounded"
3523
+ },
3524
+ className
3525
+ ),
3526
+ children: [
3527
+ children,
3528
+ trailingIcon && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: colorMappingIcon, children: trailingIcon })
3529
+ ]
3530
+ }
3531
+ );
3532
+ };
3533
+
3534
+ // src/hooks/useFloatingElement.ts
3535
+ var import_react24 = require("react");
3536
+ function calculatePosition({
3537
+ windowRect,
3538
+ containerRect,
3539
+ anchorRect,
3540
+ options
3541
+ }) {
3542
+ const { verticalAlignment, horizontalAlignment, gap, screenPadding } = options;
3543
+ const windowWidth = windowRect.width;
3544
+ const windowHeight = windowRect.height;
3545
+ const maxWidth = windowWidth - 2 * screenPadding;
3546
+ const maxHeight = windowHeight - 2 * screenPadding;
3547
+ const width = Math.min(containerRect.width, maxWidth);
3548
+ const height = Math.min(containerRect.height, maxHeight);
3549
+ const leftSuggestion = {
3550
+ beforeStart: anchorRect.left - width - gap,
3551
+ afterStart: anchorRect.left,
3552
+ center: anchorRect.left + anchorRect.width / 2 - width / 2,
3553
+ beforeEnd: anchorRect.right - width,
3554
+ afterEnd: anchorRect.right + gap
3555
+ }[horizontalAlignment];
3556
+ const topSuggestion = {
3557
+ beforeStart: anchorRect.top - height - gap,
3558
+ afterStart: anchorRect.top,
3559
+ center: anchorRect.top + anchorRect.height / 2 - height / 2,
3560
+ beforeEnd: anchorRect.bottom - height,
3561
+ afterEnd: anchorRect.bottom + gap
3562
+ }[verticalAlignment];
3563
+ const left = clamp(leftSuggestion, [
3564
+ screenPadding,
3565
+ windowWidth - screenPadding - width
3566
+ ]);
3567
+ const top = clamp(topSuggestion, [
3568
+ screenPadding,
3569
+ windowHeight - screenPadding - height
3570
+ ]);
3571
+ return {
3572
+ left,
3573
+ top,
3574
+ maxWidth,
3575
+ maxHeight
3576
+ };
3577
+ }
3578
+ function useFloatingElement({
3579
+ active = true,
3580
+ windowRef,
3581
+ anchorRef,
3582
+ containerRef,
3583
+ isPolling = false,
3584
+ pollingInterval = 100,
3585
+ verticalAlignment = "afterEnd",
3586
+ horizontalAlignment = "afterStart",
3587
+ screenPadding = 16,
3588
+ gap = 4
3589
+ }) {
3590
+ const [style, setStyle] = (0, import_react24.useState)();
3591
+ const isMounted = useIsMounted();
3592
+ const calculate = (0, import_react24.useCallback)(() => {
3593
+ const containerRect = containerRef.current.getBoundingClientRect();
3594
+ const windowRect = windowRef?.current.getBoundingClientRect() ?? {
3595
+ top: 0,
3596
+ bottom: window.innerHeight,
3597
+ left: 0,
3598
+ right: window.innerWidth,
3599
+ width: window.innerWidth,
3600
+ height: window.innerHeight
3601
+ };
3602
+ const anchorElement = anchorRef?.current;
3603
+ if (anchorRef && !anchorElement) {
3604
+ console.warn("FloatingContainer anchor provided, but its value is undefined");
3605
+ }
3606
+ const anchorRect = anchorElement?.getBoundingClientRect() ?? windowRect;
3607
+ const calculateProps = {
3608
+ windowRect,
3609
+ anchorRect,
3610
+ containerRect,
3611
+ options: {
3612
+ horizontalAlignment,
3613
+ verticalAlignment,
3614
+ screenPadding,
3615
+ gap
3616
+ }
3617
+ };
3618
+ setStyle(calculatePosition(calculateProps));
3619
+ }, [anchorRef, containerRef, gap, horizontalAlignment, screenPadding, verticalAlignment, windowRef]);
3620
+ const height = containerRef.current?.getBoundingClientRect().height;
3621
+ const width = containerRef.current?.getBoundingClientRect().width;
3622
+ (0, import_react24.useEffect)(() => {
3623
+ if (active && isMounted) {
3624
+ calculate();
3625
+ } else {
3626
+ setStyle(void 0);
3627
+ }
3628
+ }, [calculate, active, isMounted, height, width]);
3629
+ (0, import_react24.useEffect)(() => {
3630
+ window.addEventListener("resize", calculate);
3631
+ let timeout;
3632
+ if (isPolling) {
3633
+ timeout = setInterval(calculate, pollingInterval);
3634
+ }
3635
+ return () => {
3636
+ window.removeEventListener("resize", calculate);
3637
+ if (timeout) {
3638
+ clearInterval(timeout);
3639
+ }
3640
+ };
3641
+ }, [calculate, isPolling, pollingInterval]);
3642
+ return style;
3643
+ }
3644
+
3645
+ // src/components/user-action/select/Select.tsx
3646
+ var import_react_dom2 = require("react-dom");
3647
+ var import_jsx_runtime25 = require("react/jsx-runtime");
3648
+ var defaultToggleOpenOptions = {
3649
+ highlightStartPosition: "first"
3650
+ };
3651
+ var SelectContext = (0, import_react25.createContext)(null);
3652
+ function useSelectContext() {
3653
+ const ctx = (0, import_react25.useContext)(SelectContext);
3654
+ if (!ctx) {
3655
+ throw new Error("SelectContext must be used within a ListBoxPrimitive");
3656
+ }
3657
+ return ctx;
3658
+ }
3659
+ var SelectRoot = ({
3660
+ children,
3661
+ id,
3662
+ value,
3663
+ onValueChanged,
3664
+ values,
3665
+ onValuesChanged,
3666
+ isOpen = false,
3667
+ disabled = false,
3668
+ invalid = false,
3669
+ isMultiSelect = false,
3670
+ iconAppearance = "left"
3671
+ }) => {
3672
+ const optionsRef = (0, import_react25.useRef)([]);
3673
+ const triggerRef = (0, import_react25.useRef)(null);
3674
+ const generatedId = (0, import_react25.useId)();
3675
+ const usedId = id ?? generatedId;
3676
+ const [internalState, setInternalState] = (0, import_react25.useState)({
3677
+ isOpen
3678
+ });
3679
+ const state = {
3680
+ ...internalState,
3681
+ id: usedId,
3682
+ disabled,
3683
+ invalid,
3684
+ value: isMultiSelect ? values ?? [] : [value].filter(Boolean)
3685
+ };
3686
+ const config = {
3687
+ isMultiSelect,
3688
+ iconAppearance
3689
+ };
3690
+ const registerItem = (0, import_react25.useCallback)((item) => {
3691
+ optionsRef.current.push(item);
3692
+ optionsRef.current.sort((a, b) => {
3693
+ const aEl = a.ref.current;
3694
+ const bEl = b.ref.current;
3695
+ if (!aEl || !bEl) return 0;
3696
+ return aEl.compareDocumentPosition(bEl) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
3697
+ });
3698
+ }, []);
3699
+ const unregisterItem = (0, import_react25.useCallback)((value2) => {
3700
+ optionsRef.current = optionsRef.current.filter((i) => i.value !== value2);
3701
+ }, []);
3702
+ const toggleSelection = (value2, isSelected) => {
3703
+ if (disabled) {
3704
+ return;
3705
+ }
3706
+ const option = optionsRef.current.find((i) => i.value === value2);
3707
+ if (!option) {
3708
+ console.error(`SelectOption with value: ${value2} not found`);
3709
+ return;
3710
+ }
3711
+ let newValue;
3712
+ if (isMultiSelect) {
3713
+ const isSelectedBefore = state.value.includes(value2);
3714
+ const isSelectedAfter = isSelected ?? !isSelectedBefore;
3715
+ if (!isSelectedAfter) {
3716
+ newValue = state.value.filter((v) => v !== value2);
3717
+ } else {
3718
+ newValue = [...state.value, value2];
3719
+ }
3720
+ } else {
3721
+ newValue = [value2];
3722
+ }
3723
+ if (!isMultiSelect) {
3724
+ onValueChanged?.(newValue[0]);
3725
+ } else {
3726
+ onValuesChanged?.(newValue);
3727
+ }
3728
+ setInternalState((prevState) => ({
3729
+ ...prevState,
3730
+ highlightedValue: value2
3731
+ }));
3732
+ };
3733
+ const highlightItem = (value2) => {
3734
+ if (disabled) {
3735
+ return;
3736
+ }
3737
+ setInternalState((prevState) => ({
3738
+ ...prevState,
3739
+ highlightedValue: value2
3740
+ }));
3741
+ };
3742
+ const registerTrigger = (0, import_react25.useCallback)((ref) => {
3743
+ triggerRef.current = ref.current;
3744
+ }, []);
3745
+ const unregisterTrigger = (0, import_react25.useCallback)(() => {
3746
+ triggerRef.current = null;
3747
+ }, []);
3748
+ const toggleOpen = (isOpen2, options) => {
3749
+ const { highlightStartPosition } = { ...defaultToggleOpenOptions, ...options };
3750
+ let highlightedIndex;
3751
+ if (highlightStartPosition === "first") {
3752
+ highlightedIndex = optionsRef.current.findIndex((option) => !option.disabled);
3753
+ } else {
3754
+ highlightedIndex = optionsRef.current.length - 1 - [...optionsRef.current].reverse().findIndex((option) => !option.disabled);
3755
+ }
3756
+ if (highlightedIndex === -1 || highlightedIndex === optionsRef.current.length) {
3757
+ highlightedIndex = 0;
3758
+ }
3759
+ setInternalState((prevState) => ({
3760
+ ...prevState,
3761
+ isOpen: isOpen2 ?? !prevState.isOpen,
3762
+ highlightedValue: optionsRef.current[highlightedIndex].value
3763
+ }));
3764
+ };
3765
+ const moveHighlightedIndex = (delta) => {
3766
+ let highlightedIndex = optionsRef.current.findIndex((value2) => value2.value === internalState.highlightedValue);
3767
+ if (highlightedIndex === -1) {
3768
+ highlightedIndex = 0;
3769
+ }
3770
+ const optionLength = optionsRef.current.length;
3771
+ const startIndex = (highlightedIndex + delta % optionLength + optionLength) % optionLength;
3772
+ const isForward = delta >= 0;
3773
+ let highlightedValue = optionsRef.current[startIndex].value;
3774
+ for (let i = 0; i < optionsRef.current.length; i++) {
3775
+ const index = (startIndex + (isForward ? i : -i) + optionLength) % optionLength;
3776
+ if (!optionsRef.current[index].disabled) {
3777
+ highlightedValue = optionsRef.current[index].value;
3778
+ break;
3779
+ }
3780
+ }
3781
+ setInternalState((prevState) => ({
3782
+ ...prevState,
3783
+ highlightedValue
3784
+ }));
3785
+ };
3786
+ (0, import_react25.useEffect)(() => {
3787
+ if (!internalState.highlightedValue) return;
3788
+ const highlighted = optionsRef.current.find((value2) => value2.value === internalState.highlightedValue);
3789
+ if (highlighted) {
3790
+ highlighted.ref.current.scrollIntoView({ behavior: "instant", block: "nearest" });
3791
+ } else {
3792
+ console.error(`SelectRoot: Could not find highlighted value (${internalState.highlightedValue})`);
3793
+ }
3794
+ }, [internalState.highlightedValue]);
3795
+ const contextValue = {
3796
+ state,
3797
+ config,
3798
+ item: {
3799
+ register: registerItem,
3800
+ unregister: unregisterItem,
3801
+ toggleSelection,
3802
+ highlightItem,
3803
+ moveHighlightedIndex
3804
+ },
3805
+ trigger: {
3806
+ ref: triggerRef,
3807
+ register: registerTrigger,
3808
+ unregister: unregisterTrigger,
3809
+ toggleOpen
3810
+ }
3811
+ };
3812
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SelectContext.Provider, { value: contextValue, children });
3813
+ };
3814
+ var SelectOption = (0, import_react25.forwardRef)(
3815
+ function SelectOption2({ children, value, disabled = false, iconAppearance, className, ...restProps }, ref) {
3816
+ const { state, config, item, trigger } = useSelectContext();
3817
+ const { register, unregister, toggleSelection, highlightItem } = item;
3818
+ const itemRef = (0, import_react25.useRef)(null);
3819
+ iconAppearance ??= config.iconAppearance;
3820
+ (0, import_react25.useEffect)(() => {
3821
+ register({
3822
+ value,
3823
+ disabled,
3824
+ ref: itemRef
3825
+ });
3826
+ return () => unregister(value);
3827
+ }, [value, disabled, register, unregister, children]);
3828
+ const isHighlighted = state.highlightedValue === value;
3829
+ const isSelected = state.value.includes(value);
3830
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
3831
+ "li",
3832
+ {
3833
+ ...restProps,
3834
+ ref: (node) => {
3835
+ itemRef.current = node;
3836
+ if (typeof ref === "function") ref(node);
3837
+ else if (ref) ref.current = node;
3838
+ },
3839
+ id: value,
3840
+ role: "option",
3841
+ "aria-disabled": disabled,
3842
+ "aria-selected": isSelected,
3843
+ "data-highlighted": isHighlighted ? "" : void 0,
3844
+ "data-selected": isSelected ? "" : void 0,
3845
+ "data-disabled": disabled ? "" : void 0,
3846
+ className: (0, import_clsx20.default)(
3847
+ "flex-row-1 items-center px-2 py-1 rounded-md",
3848
+ "data-highlighted:bg-primary/20",
3849
+ "data-disabled:text-disabled data-disabled:cursor-not-allowed",
3850
+ "not-data-disabled:cursor-pointer",
3851
+ className
3852
+ ),
3853
+ onClick: (event) => {
3854
+ if (!disabled) {
3855
+ toggleSelection(value);
3856
+ if (!config.isMultiSelect) {
3857
+ trigger.toggleOpen(false);
3858
+ }
3859
+ restProps.onClick?.(event);
3860
+ }
3861
+ },
3862
+ onMouseEnter: (event) => {
3863
+ if (!disabled) {
3864
+ highlightItem(value);
3865
+ restProps.onMouseEnter?.(event);
3866
+ }
3867
+ },
3868
+ children: [
3869
+ iconAppearance === "left" && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3870
+ import_lucide_react7.CheckIcon,
3871
+ {
3872
+ className: (0, import_clsx20.default)("w-4 h-4", { "opacity-0": !isSelected || disabled }),
3873
+ "aria-hidden": true
3874
+ }
3875
+ ),
3876
+ children ?? value,
3877
+ iconAppearance === "right" && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3878
+ import_lucide_react7.CheckIcon,
3879
+ {
3880
+ className: (0, import_clsx20.default)("w-4 h-4", { "opacity-0": !isSelected || disabled }),
3881
+ "aria-hidden": true
3882
+ }
3883
+ )
3884
+ ]
3885
+ }
3886
+ );
3887
+ }
3888
+ );
3889
+ var defaultSelectButtonTranslation = {
3890
+ en: {
3891
+ clickToSelect: "Click to select"
3892
+ },
3893
+ de: {
3894
+ clickToSelect: "Zum ausw\xE4hlen dr\xFCcken"
3895
+ }
3896
+ };
3897
+ var SelectButton = (0, import_react25.forwardRef)(function SelectButton2({ placeholder, selectedDisplay, ...props }, ref) {
3898
+ const translation = useTranslation([defaultSelectButtonTranslation]);
3899
+ const { state, trigger } = useSelectContext();
3900
+ const { register, unregister, toggleOpen } = trigger;
3901
+ const innerRef = (0, import_react25.useRef)(null);
3902
+ (0, import_react25.useImperativeHandle)(ref, () => innerRef.current);
3903
+ (0, import_react25.useEffect)(() => {
3904
+ register(innerRef);
3905
+ return () => unregister();
3906
+ }, [register, unregister]);
3907
+ const disabled = !!props?.disabled || !!state.disabled;
3908
+ const invalid = state.invalid;
3909
+ const hasValue = state.value.length > 0;
3910
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
3911
+ "button",
3912
+ {
3913
+ ...props,
3914
+ ref: innerRef,
3915
+ id: state.id,
3916
+ className: (0, import_clsx20.default)(
3917
+ "flex-row-2 items-center justify-between bg-input-background text-input-text rounded-md px-2.5 py-2.5",
3918
+ "data-placeholder:text-description",
3919
+ props.className
3920
+ ),
3921
+ onClick: () => toggleOpen(!state.isOpen),
3922
+ onKeyDown: (event) => {
3923
+ switch (event.key) {
3924
+ case "ArrowDown":
3925
+ toggleOpen(true, { highlightStartPosition: "first" });
3926
+ break;
3927
+ case "ArrowUp":
3928
+ toggleOpen(true, { highlightStartPosition: "last" });
3929
+ break;
3930
+ }
3931
+ },
3932
+ "data-placeholder": !hasValue ? "" : void 0,
3933
+ "data-disabled": disabled ? "" : void 0,
3934
+ "data-invalid": invalid ? "" : void 0,
3935
+ "aria-invalid": invalid,
3936
+ "aria-disabled": disabled,
3937
+ "aria-haspopup": "listbox",
3938
+ "aria-expanded": state.isOpen,
3939
+ "aria-controls": state.isOpen ? `${state.id}-listbox` : void 0,
3940
+ children: [
3941
+ hasValue ? selectedDisplay?.(state.value) ?? state.value.join(", ") : placeholder ?? translation("clickToSelect"),
3942
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ExpansionIcon, { isExpanded: state.isOpen })
3943
+ ]
3944
+ }
3945
+ );
3946
+ });
3947
+ var SelectChipDisplay = (0, import_react25.forwardRef)(function SelectChipDisplay2({ ...props }, ref) {
3948
+ const { state, trigger, item } = useSelectContext();
3949
+ const { register, unregister, toggleOpen } = trigger;
3950
+ const innerRef = (0, import_react25.useRef)(null);
3951
+ (0, import_react25.useImperativeHandle)(ref, () => innerRef.current);
3952
+ (0, import_react25.useEffect)(() => {
3953
+ register(innerRef);
3954
+ return () => unregister();
3955
+ }, [register, unregister]);
3956
+ const disabled = !!props?.disabled || !!state.disabled;
3957
+ const invalid = state.invalid;
3958
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
3959
+ "div",
3960
+ {
3961
+ ...props,
3962
+ ref: innerRef,
3963
+ className: (0, import_clsx20.default)(
3964
+ "flex flex-wrap flex-row gap-2 items-center bg-input-background text-input-text rounded-md px-2.5 py-2.5",
3965
+ props.className
3966
+ ),
3967
+ "data-disabled": disabled ? "" : void 0,
3968
+ "data-invalid": invalid ? "" : void 0,
3969
+ "aria-invalid": invalid,
3970
+ "aria-disabled": disabled,
3971
+ children: [
3972
+ state.value.map((value) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(Chip, { className: "gap-x-2", children: [
3973
+ value,
3974
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3975
+ "button",
3976
+ {
3977
+ onClick: () => {
3978
+ item.toggleSelection(value, false);
3979
+ },
3980
+ className: "focus-within:text-negative hover:bg-negative/20 hover:text-negative rounded-md focus-style-none focus-visible:ring-2 focus-visible:ring-negative focus-visible:bg-negative/20",
3981
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react7.XIcon, {})
3982
+ }
3983
+ )
3984
+ ] }, value)),
3985
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3986
+ IconButton,
3987
+ {
3988
+ id: state.id,
3989
+ onClick: () => toggleOpen(),
3990
+ onKeyDown: (event) => {
3991
+ switch (event.key) {
3992
+ case "ArrowDown":
3993
+ toggleOpen(true, { highlightStartPosition: "first" });
3994
+ break;
3995
+ case "ArrowUp":
3996
+ toggleOpen(true, { highlightStartPosition: "last" });
3997
+ }
3998
+ },
3999
+ size: "small",
4000
+ color: "neutral",
4001
+ "aria-invalid": invalid,
4002
+ "aria-disabled": disabled,
4003
+ "aria-haspopup": "listbox",
4004
+ "aria-expanded": state.isOpen,
4005
+ "aria-controls": state.isOpen ? `${state.id}-listbox` : void 0,
4006
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react7.Plus, {})
4007
+ }
4008
+ )
4009
+ ]
4010
+ }
4011
+ );
4012
+ });
4013
+ var SelectContent = (0, import_react25.forwardRef)(
4014
+ function SelectContent2({
4015
+ alignment,
4016
+ orientation = "vertical",
4017
+ ...props
4018
+ }, ref) {
4019
+ const innerRef = (0, import_react25.useRef)(null);
4020
+ (0, import_react25.useImperativeHandle)(ref, () => innerRef.current);
4021
+ const { trigger, state, config, item } = useSelectContext();
4022
+ const position = useFloatingElement({
4023
+ active: state.isOpen,
4024
+ anchorRef: trigger.ref,
4025
+ containerRef: innerRef,
4026
+ ...alignment
4027
+ });
4028
+ useFocusTrap({
4029
+ container: innerRef,
4030
+ active: state.isOpen && !!position
4031
+ });
4032
+ return (0, import_react_dom2.createPortal)(
4033
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
4034
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4035
+ "div",
4036
+ {
4037
+ hidden: !state.isOpen,
4038
+ onClick: () => trigger.toggleOpen(false),
4039
+ className: (0, import_clsx20.default)("fixed w-screen h-screen inset-0")
4040
+ }
4041
+ ),
4042
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4043
+ "ul",
4044
+ {
4045
+ ...props,
4046
+ id: `${state.id}-listbox`,
4047
+ ref: innerRef,
4048
+ hidden: !state.isOpen,
4049
+ onKeyDown: (event) => {
4050
+ switch (event.key) {
4051
+ case "Escape":
4052
+ trigger.toggleOpen(false);
4053
+ event.preventDefault();
4054
+ event.stopPropagation();
4055
+ break;
4056
+ case match(orientation, {
4057
+ vertical: "ArrowDown",
4058
+ horizontal: "ArrowUp"
4059
+ }):
4060
+ item.moveHighlightedIndex(1);
4061
+ event.preventDefault();
4062
+ break;
4063
+ case match(orientation, {
4064
+ vertical: "ArrowUp",
4065
+ horizontal: "ArrowDown"
4066
+ }):
4067
+ item.moveHighlightedIndex(-1);
4068
+ event.preventDefault();
4069
+ break;
4070
+ case "Home":
4071
+ event.preventDefault();
4072
+ break;
4073
+ case "End":
4074
+ event.preventDefault();
4075
+ break;
4076
+ case "Enter":
4077
+ // Fall through
4078
+ case " ":
4079
+ if (state.highlightedValue) {
4080
+ item.toggleSelection(state.highlightedValue);
4081
+ if (!config.isMultiSelect) {
4082
+ trigger.toggleOpen(false);
4083
+ }
4084
+ event.preventDefault();
4085
+ }
4086
+ break;
4087
+ }
4088
+ },
4089
+ className: (0, import_clsx20.default)("flex-col-0 p-2 bg-menu-background text-menu-text rounded-md shadow-hw-bottom focus-style-within overflow-auto", props.className),
4090
+ style: {
4091
+ opacity: position ? void 0 : 0,
4092
+ position: "fixed",
4093
+ ...position
4094
+ },
4095
+ role: "listbox",
4096
+ "aria-multiselectable": config.isMultiSelect,
4097
+ "aria-orientation": orientation,
4098
+ tabIndex: position ? 0 : void 0,
4099
+ children: props.children
4100
+ }
4101
+ )
4102
+ ] }),
4103
+ document.body
4104
+ );
4105
+ }
4106
+ );
4107
+ var Select = (0, import_react25.forwardRef)(function Select2({
4108
+ children,
4109
+ contentPanelProps,
4110
+ buttonProps,
4111
+ ...props
4112
+ }, ref) {
4113
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(SelectRoot, { ...props, isMultiSelect: false, children: [
4114
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4115
+ SelectButton,
4116
+ {
4117
+ ref,
4118
+ ...buttonProps,
4119
+ selectedDisplay: (values) => {
4120
+ const value = values[0];
4121
+ if (!buttonProps?.selectedDisplay) return void 0;
4122
+ return buttonProps.selectedDisplay(value);
4123
+ }
4124
+ }
4125
+ ),
4126
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SelectContent, { ...contentPanelProps, children })
4127
+ ] });
4128
+ });
4129
+ var SelectUncontrolled = (0, import_react25.forwardRef)(function SelectUncontrolled2({
4130
+ value: initialValue,
4131
+ onValueChanged,
4132
+ ...props
4133
+ }, ref) {
4134
+ const [value, setValue] = (0, import_react25.useState)(initialValue);
4135
+ (0, import_react25.useEffect)(() => {
4136
+ setValue(initialValue);
4137
+ }, [initialValue]);
4138
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4139
+ Select,
4140
+ {
4141
+ ...props,
4142
+ ref,
4143
+ value,
4144
+ onValueChanged: (value2) => {
4145
+ setValue(value2);
4146
+ onValueChanged?.(value2);
4147
+ }
4148
+ }
4149
+ );
4150
+ });
4151
+ var MultiSelect = (0, import_react25.forwardRef)(function MultiSelect2({
4152
+ children,
4153
+ contentPanelProps,
4154
+ buttonProps,
4155
+ ...props
4156
+ }, ref) {
4157
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(SelectRoot, { ...props, isMultiSelect: true, children: [
4158
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SelectButton, { ref, ...buttonProps }),
4159
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SelectContent, { ...contentPanelProps, children })
4160
+ ] });
4161
+ });
4162
+ var MultiSelectUncontrolled = (0, import_react25.forwardRef)(function MultiSelectUncontrolled2({
4163
+ values: initialValues,
4164
+ onValuesChanged,
4165
+ ...props
4166
+ }, ref) {
4167
+ const [values, setValues] = (0, import_react25.useState)(initialValues);
4168
+ (0, import_react25.useEffect)(() => {
4169
+ setValues(initialValues);
4170
+ }, [initialValues]);
4171
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4172
+ MultiSelect,
4173
+ {
4174
+ ...props,
4175
+ ref,
4176
+ values,
4177
+ onValuesChanged: (value) => {
4178
+ setValues(value);
4179
+ onValuesChanged?.(value);
4180
+ }
4181
+ }
4182
+ );
4183
+ });
4184
+ var MultiSelectChipDisplay = (0, import_react25.forwardRef)(function MultiSelectChipDisplay2({
4185
+ children,
4186
+ contentPanelProps,
4187
+ chipDisplayProps,
4188
+ ...props
4189
+ }, ref) {
4190
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(SelectRoot, { ...props, isMultiSelect: true, children: [
4191
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SelectChipDisplay, { ref, ...chipDisplayProps }),
4192
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SelectContent, { ...contentPanelProps, children })
4193
+ ] });
4194
+ });
4195
+ var MultiSelectChipDisplayUncontrolled = (0, import_react25.forwardRef)(function MultiSelectChipDisplayUncontrolled2({
4196
+ values: initialValues,
4197
+ onValuesChanged,
4198
+ ...props
4199
+ }, ref) {
4200
+ const [values, setValues] = (0, import_react25.useState)(initialValues);
4201
+ (0, import_react25.useEffect)(() => {
4202
+ setValues(initialValues);
4203
+ }, [initialValues]);
4204
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4205
+ MultiSelectChipDisplay,
4206
+ {
4207
+ ...props,
4208
+ ref,
4209
+ values,
4210
+ onValuesChanged: (value) => {
4211
+ setValues(value);
4212
+ onValuesChanged?.(value);
4213
+ }
4214
+ }
4215
+ );
4216
+ });
4217
+ // Annotate the CommonJS export names for ESM import in node:
4218
+ 0 && (module.exports = {
4219
+ ButtonColorUtil,
4220
+ ButtonUtil,
4221
+ Checkbox,
4222
+ CheckboxUncontrolled,
4223
+ CopyToClipboardWrapper,
4224
+ DateTimePicker,
4225
+ IconButton,
4226
+ IconButtonUtil,
4227
+ Input,
4228
+ InputUncontrolled,
4229
+ InsideLabelInput,
4230
+ InsideLabelInputUncontrolled,
4231
+ Label,
4232
+ Menu,
4233
+ MenuItem,
4234
+ MultiSelect,
4235
+ MultiSelectChipDisplay,
4236
+ MultiSelectChipDisplayUncontrolled,
4237
+ MultiSelectUncontrolled,
4238
+ OutlineButton,
4239
+ ScrollPicker,
4240
+ SearchBar,
4241
+ Select,
4242
+ SelectButton,
4243
+ SelectChipDisplay,
4244
+ SelectContent,
4245
+ SelectOption,
4246
+ SelectRoot,
4247
+ SelectUncontrolled,
4248
+ SolidButton,
4249
+ TextButton,
4250
+ Textarea,
4251
+ TextareaUncontrolled,
4252
+ TextareaWithHeadline,
4253
+ ToggleableInput,
4254
+ ToggleableInputUncontrolled,
4255
+ Tooltip
4256
+ });
4257
+ //# sourceMappingURL=index.js.map