@octaviaflow/core 3.1.0-beta.115 → 3.1.0-beta.116

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 (92) hide show
  1. package/dist/chunk-23K2RF7Z.js +2694 -0
  2. package/dist/chunk-23K2RF7Z.js.map +1 -0
  3. package/dist/chunk-H3FCGN4P.js +6628 -0
  4. package/dist/chunk-H3FCGN4P.js.map +1 -0
  5. package/dist/chunk-ISJSOF3Z.js +3646 -0
  6. package/dist/chunk-ISJSOF3Z.js.map +1 -0
  7. package/dist/chunk-KSIZ7DLS.js +3582 -0
  8. package/dist/chunk-KSIZ7DLS.js.map +1 -0
  9. package/dist/chunk-NAG3EFQ6.js +6789 -0
  10. package/dist/chunk-NAG3EFQ6.js.map +1 -0
  11. package/dist/chunk-NMZWNZV7.js +1547 -0
  12. package/dist/chunk-NMZWNZV7.js.map +1 -0
  13. package/dist/chunk-QWOH2E3F.js +3189 -0
  14. package/dist/chunk-QWOH2E3F.js.map +1 -0
  15. package/dist/chunk-V22HCPVO.js +2856 -0
  16. package/dist/chunk-V22HCPVO.js.map +1 -0
  17. package/dist/chunk-VGAUSBP4.js +3181 -0
  18. package/dist/chunk-VGAUSBP4.js.map +1 -0
  19. package/dist/chunk-WTIM6E4X.js +3677 -0
  20. package/dist/chunk-WTIM6E4X.js.map +1 -0
  21. package/dist/chunk-XUBJHPJT.js +3680 -0
  22. package/dist/chunk-XUBJHPJT.js.map +1 -0
  23. package/dist/components/AgentCard/AgentCard.d.ts.map +1 -1
  24. package/dist/components/AssistantAura/AssistantAura.d.ts +21 -0
  25. package/dist/components/AssistantAura/AssistantAura.d.ts.map +1 -0
  26. package/dist/components/AssistantAura/index.d.ts +2 -0
  27. package/dist/components/AssistantAura/index.d.ts.map +1 -0
  28. package/dist/components/AssistantConversation/AssistantConversation.d.ts +112 -0
  29. package/dist/components/AssistantConversation/AssistantConversation.d.ts.map +1 -0
  30. package/dist/components/AssistantConversation/assistant.fixtures.d.ts +29 -0
  31. package/dist/components/AssistantConversation/assistant.fixtures.d.ts.map +1 -0
  32. package/dist/components/AssistantConversation/assistantGlyphs.d.ts +13 -0
  33. package/dist/components/AssistantConversation/assistantGlyphs.d.ts.map +1 -0
  34. package/dist/components/AssistantConversation/index.d.ts +2 -0
  35. package/dist/components/AssistantConversation/index.d.ts.map +1 -0
  36. package/dist/components/AssistantDock/AssistantDock.d.ts +25 -0
  37. package/dist/components/AssistantDock/AssistantDock.d.ts.map +1 -0
  38. package/dist/components/AssistantDock/index.d.ts +2 -0
  39. package/dist/components/AssistantDock/index.d.ts.map +1 -0
  40. package/dist/components/AssistantOrb/AssistantOrb.d.ts +14 -0
  41. package/dist/components/AssistantOrb/AssistantOrb.d.ts.map +1 -0
  42. package/dist/components/AssistantOrb/explorations/OvaIconConcepts.d.ts +22 -0
  43. package/dist/components/AssistantOrb/explorations/OvaIconConcepts.d.ts.map +1 -0
  44. package/dist/components/AssistantOrb/index.d.ts +2 -0
  45. package/dist/components/AssistantOrb/index.d.ts.map +1 -0
  46. package/dist/components/AssistantTrigger/AssistantTrigger.d.ts +17 -0
  47. package/dist/components/AssistantTrigger/AssistantTrigger.d.ts.map +1 -0
  48. package/dist/components/AssistantTrigger/index.d.ts +2 -0
  49. package/dist/components/AssistantTrigger/index.d.ts.map +1 -0
  50. package/dist/components/ChatComposer/ChatComposer.d.ts +8 -0
  51. package/dist/components/ChatComposer/ChatComposer.d.ts.map +1 -1
  52. package/dist/components/ChatDocPreview/ChatDocPreview.d.ts +20 -0
  53. package/dist/components/ChatDocPreview/ChatDocPreview.d.ts.map +1 -0
  54. package/dist/components/ChatDocPreview/index.d.ts +2 -0
  55. package/dist/components/ChatDocPreview/index.d.ts.map +1 -0
  56. package/dist/components/ChatInputRequest/ChatInputRequest.d.ts +68 -0
  57. package/dist/components/ChatInputRequest/ChatInputRequest.d.ts.map +1 -0
  58. package/dist/components/ChatInputRequest/index.d.ts +2 -0
  59. package/dist/components/ChatInputRequest/index.d.ts.map +1 -0
  60. package/dist/components/ChatLinkPreview/ChatLinkPreview.d.ts +33 -0
  61. package/dist/components/ChatLinkPreview/ChatLinkPreview.d.ts.map +1 -0
  62. package/dist/components/ChatLinkPreview/index.d.ts +2 -0
  63. package/dist/components/ChatLinkPreview/index.d.ts.map +1 -0
  64. package/dist/components/ChatSources/ChatSources.d.ts +10 -1
  65. package/dist/components/ChatSources/ChatSources.d.ts.map +1 -1
  66. package/dist/components/ChatSources/index.d.ts +1 -1
  67. package/dist/components/ChatSources/index.d.ts.map +1 -1
  68. package/dist/components/ChatVideoPreview/ChatVideoPreview.d.ts +37 -0
  69. package/dist/components/ChatVideoPreview/ChatVideoPreview.d.ts.map +1 -0
  70. package/dist/components/ChatVideoPreview/index.d.ts +2 -0
  71. package/dist/components/ChatVideoPreview/index.d.ts.map +1 -0
  72. package/dist/components/TruncatedText/TruncatedText.d.ts +15 -0
  73. package/dist/components/TruncatedText/TruncatedText.d.ts.map +1 -0
  74. package/dist/components/TruncatedText/index.d.ts +2 -0
  75. package/dist/components/TruncatedText/index.d.ts.map +1 -0
  76. package/dist/index.cjs +7716 -6548
  77. package/dist/index.cjs.map +1 -1
  78. package/dist/index.d.ts +10 -1
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/index.js +4742 -5654
  81. package/dist/index.js.map +1 -1
  82. package/dist/marketing/components/AssistantWidget/AssistantWidget.d.ts +60 -0
  83. package/dist/marketing/components/AssistantWidget/AssistantWidget.d.ts.map +1 -0
  84. package/dist/marketing/index.d.ts +1 -0
  85. package/dist/marketing/index.d.ts.map +1 -1
  86. package/dist/marketing.cjs +3709 -1196
  87. package/dist/marketing.cjs.map +1 -1
  88. package/dist/marketing.js +737 -482
  89. package/dist/marketing.js.map +1 -1
  90. package/dist/styles.css +1 -1
  91. package/dist/workflow.js +2 -2
  92. package/package.json +1 -1
@@ -0,0 +1,2856 @@
1
+ import {
2
+ cn
3
+ } from "./chunk-ZAUUGK2Y.js";
4
+
5
+ // src/components/Accordion/Accordion.tsx
6
+ import { ChevronDownIcon } from "@octaviaflow/icons";
7
+ import { AnimatePresence, motion, useReducedMotion } from "framer-motion";
8
+ import {
9
+ forwardRef,
10
+ useCallback,
11
+ useId,
12
+ useState
13
+ } from "react";
14
+ import { jsx, jsxs } from "react/jsx-runtime";
15
+ var Accordion = forwardRef(function Accordion2({
16
+ items,
17
+ mode = "single",
18
+ value: controlledValue,
19
+ defaultValue,
20
+ onValueChange,
21
+ collapsible = true,
22
+ variant = "default",
23
+ size = "md",
24
+ disabled = false,
25
+ id: providedId,
26
+ className,
27
+ ...rest
28
+ }, ref) {
29
+ const reactId = useId();
30
+ const baseId = providedId ?? `ods-accordion-${reactId}`;
31
+ const reducedMotion = useReducedMotion();
32
+ const [internalValue, setInternalValue] = useState(defaultValue ?? []);
33
+ const isControlled = controlledValue !== void 0;
34
+ const value = isControlled ? controlledValue : internalValue;
35
+ const valueSet = new Set(value);
36
+ const setValue = useCallback(
37
+ (next) => {
38
+ if (!isControlled) setInternalValue(next);
39
+ onValueChange?.(next);
40
+ },
41
+ [isControlled, onValueChange]
42
+ );
43
+ const toggleItem = useCallback(
44
+ (id) => {
45
+ const isOpen = valueSet.has(id);
46
+ if (mode === "multiple") {
47
+ const next = isOpen ? value.filter((v) => v !== id) : [...value, id];
48
+ setValue(next);
49
+ return;
50
+ }
51
+ if (isOpen) {
52
+ if (collapsible) setValue([]);
53
+ return;
54
+ }
55
+ setValue([id]);
56
+ },
57
+ [collapsible, mode, setValue, value, valueSet]
58
+ );
59
+ const handleKeyDown = (e, index) => {
60
+ const enabledIdx = items.map((it, i) => it.disabled ? -1 : i).filter((i) => i !== -1);
61
+ const curr = enabledIdx.indexOf(index);
62
+ const focusIdx = (i) => {
63
+ const target = enabledIdx[i];
64
+ if (target === void 0) return;
65
+ const btn = document.getElementById(`${baseId}-trigger-${items[target].id}`);
66
+ btn?.focus();
67
+ };
68
+ if (e.key === "ArrowDown") {
69
+ e.preventDefault();
70
+ focusIdx((curr + 1) % enabledIdx.length);
71
+ } else if (e.key === "ArrowUp") {
72
+ e.preventDefault();
73
+ focusIdx((curr - 1 + enabledIdx.length) % enabledIdx.length);
74
+ } else if (e.key === "Home") {
75
+ e.preventDefault();
76
+ focusIdx(0);
77
+ } else if (e.key === "End") {
78
+ e.preventDefault();
79
+ focusIdx(enabledIdx.length - 1);
80
+ }
81
+ };
82
+ return /* @__PURE__ */ jsx(
83
+ "div",
84
+ {
85
+ ...rest,
86
+ ref,
87
+ id: baseId,
88
+ className: cn(
89
+ "ods-accordion",
90
+ `ods-accordion--${variant}`,
91
+ `ods-accordion--${size}`,
92
+ disabled && "ods-accordion--disabled",
93
+ className
94
+ ),
95
+ children: items.map((item, i) => {
96
+ const isOpen = valueSet.has(item.id);
97
+ const itemDisabled = item.disabled || disabled;
98
+ const triggerId = `${baseId}-trigger-${item.id}`;
99
+ const panelId = `${baseId}-panel-${item.id}`;
100
+ return /* @__PURE__ */ jsxs(
101
+ "div",
102
+ {
103
+ className: cn(
104
+ "ods-accordion__item",
105
+ isOpen && "ods-accordion__item--open",
106
+ itemDisabled && "ods-accordion__item--disabled"
107
+ ),
108
+ children: [
109
+ /* @__PURE__ */ jsxs(
110
+ "button",
111
+ {
112
+ id: triggerId,
113
+ type: "button",
114
+ className: "ods-accordion__trigger",
115
+ "aria-expanded": isOpen,
116
+ "aria-controls": panelId,
117
+ disabled: itemDisabled,
118
+ onClick: () => toggleItem(item.id),
119
+ onKeyDown: (e) => handleKeyDown(e, i),
120
+ children: [
121
+ item.icon && /* @__PURE__ */ jsx("span", { className: "ods-accordion__icon", "aria-hidden": "true", children: item.icon }),
122
+ /* @__PURE__ */ jsxs("span", { className: "ods-accordion__label-wrap", children: [
123
+ /* @__PURE__ */ jsx("span", { className: "ods-accordion__label", children: item.label }),
124
+ item.description && /* @__PURE__ */ jsx("span", { className: "ods-accordion__description", children: item.description })
125
+ ] }),
126
+ item.trailing && /* @__PURE__ */ jsx("span", { className: "ods-accordion__trailing", onClick: (e) => e.stopPropagation(), children: item.trailing }),
127
+ /* @__PURE__ */ jsx(
128
+ "span",
129
+ {
130
+ className: cn("ods-accordion__chevron", isOpen && "ods-accordion__chevron--open"),
131
+ "aria-hidden": "true",
132
+ children: /* @__PURE__ */ jsx(ChevronDownIcon, { size: "sm", "aria-hidden": true })
133
+ }
134
+ )
135
+ ]
136
+ }
137
+ ),
138
+ /* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: isOpen && /* @__PURE__ */ jsx(
139
+ motion.div,
140
+ {
141
+ role: "region",
142
+ id: panelId,
143
+ "aria-labelledby": triggerId,
144
+ className: "ods-accordion__panel",
145
+ initial: reducedMotion ? false : { height: 0, opacity: 0 },
146
+ animate: reducedMotion ? void 0 : { height: "auto", opacity: 1 },
147
+ exit: reducedMotion ? void 0 : { height: 0, opacity: 0 },
148
+ transition: reducedMotion ? { duration: 0 } : { duration: 0.18 },
149
+ style: { overflow: "hidden" },
150
+ children: /* @__PURE__ */ jsx("div", { className: "ods-accordion__content", children: item.content })
151
+ }
152
+ ) })
153
+ ]
154
+ },
155
+ item.id
156
+ );
157
+ })
158
+ }
159
+ );
160
+ });
161
+ Accordion.displayName = "Accordion";
162
+
163
+ // src/components/Checkbox/Checkbox.tsx
164
+ import {
165
+ forwardRef as forwardRef2,
166
+ useId as useId2,
167
+ useImperativeHandle,
168
+ useRef
169
+ } from "react";
170
+ import { useCheckbox } from "react-aria";
171
+
172
+ // ../../node_modules/react-stately/dist/private/utils/useControlledState.mjs
173
+ import $1CcWn$react, { useState as $1CcWn$useState, useRef as $1CcWn$useRef, useEffect as $1CcWn$useEffect, useReducer as $1CcWn$useReducer, useCallback as $1CcWn$useCallback } from "react";
174
+ var $3e6197669829fe11$var$useEarlyEffect = typeof document !== "undefined" ? (0, $1CcWn$react)["useInsertionEffect"] ?? (0, $1CcWn$react).useLayoutEffect : () => {
175
+ };
176
+ function $3e6197669829fe11$export$40bfa8c7b0832715(value, defaultValue, onChange) {
177
+ let [stateValue, setStateValue] = (0, $1CcWn$useState)(value || defaultValue);
178
+ let valueRef = (0, $1CcWn$useRef)(stateValue);
179
+ let isControlledRef = (0, $1CcWn$useRef)(value !== void 0);
180
+ let isControlled = value !== void 0;
181
+ (0, $1CcWn$useEffect)(() => {
182
+ let wasControlled = isControlledRef.current;
183
+ if (wasControlled !== isControlled && process.env.NODE_ENV !== "production") console.warn(`WARN: A component changed from ${wasControlled ? "controlled" : "uncontrolled"} to ${isControlled ? "controlled" : "uncontrolled"}.`);
184
+ isControlledRef.current = isControlled;
185
+ }, [
186
+ isControlled
187
+ ]);
188
+ let currentValue = isControlled ? value : stateValue;
189
+ $3e6197669829fe11$var$useEarlyEffect(() => {
190
+ valueRef.current = currentValue;
191
+ });
192
+ let [, forceUpdate] = (0, $1CcWn$useReducer)(() => ({}), {});
193
+ let setValue = (0, $1CcWn$useCallback)((value2, ...args) => {
194
+ let newValue = typeof value2 === "function" ? value2(valueRef.current) : value2;
195
+ if (!Object.is(valueRef.current, newValue)) {
196
+ valueRef.current = newValue;
197
+ setStateValue(newValue);
198
+ forceUpdate();
199
+ onChange?.(newValue, ...args);
200
+ }
201
+ }, [
202
+ onChange
203
+ ]);
204
+ return [
205
+ currentValue,
206
+ setValue
207
+ ];
208
+ }
209
+
210
+ // ../../node_modules/react-stately/dist/private/form/useFormValidationState.mjs
211
+ import { createContext as $8AuPP$createContext, useMemo as $8AuPP$useMemo, useContext as $8AuPP$useContext, useState as $8AuPP$useState, useRef as $8AuPP$useRef, useEffect as $8AuPP$useEffect } from "react";
212
+ var $fd2148440a13ec26$export$aca958c65c314e6c = {
213
+ badInput: false,
214
+ customError: false,
215
+ patternMismatch: false,
216
+ rangeOverflow: false,
217
+ rangeUnderflow: false,
218
+ stepMismatch: false,
219
+ tooLong: false,
220
+ tooShort: false,
221
+ typeMismatch: false,
222
+ valueMissing: false,
223
+ valid: true
224
+ };
225
+ var $fd2148440a13ec26$var$CUSTOM_VALIDITY_STATE = {
226
+ ...$fd2148440a13ec26$export$aca958c65c314e6c,
227
+ customError: true,
228
+ valid: false
229
+ };
230
+ var $fd2148440a13ec26$export$dad6ae84456c676a = {
231
+ isInvalid: false,
232
+ validationDetails: $fd2148440a13ec26$export$aca958c65c314e6c,
233
+ validationErrors: []
234
+ };
235
+ var $fd2148440a13ec26$export$571b5131b7e65c11 = (0, $8AuPP$createContext)({});
236
+ var $fd2148440a13ec26$export$a763b9476acd3eb = "__reactAriaFormValidationState";
237
+ function $fd2148440a13ec26$export$fc1a364ae1f3ff10(props) {
238
+ if (props[$fd2148440a13ec26$export$a763b9476acd3eb]) {
239
+ let { realtimeValidation, displayValidation, updateValidation, resetValidation, commitValidation } = props[$fd2148440a13ec26$export$a763b9476acd3eb];
240
+ return {
241
+ realtimeValidation,
242
+ displayValidation,
243
+ updateValidation,
244
+ resetValidation,
245
+ commitValidation
246
+ };
247
+ }
248
+ return $fd2148440a13ec26$var$useFormValidationStateImpl(props);
249
+ }
250
+ function $fd2148440a13ec26$var$useFormValidationStateImpl(props) {
251
+ let { isInvalid, validationState, name, value, builtinValidation, validate, validationBehavior = "aria" } = props;
252
+ if (validationState) isInvalid ||= validationState === "invalid";
253
+ let controlledError = isInvalid !== void 0 ? {
254
+ isInvalid,
255
+ validationErrors: [],
256
+ validationDetails: $fd2148440a13ec26$var$CUSTOM_VALIDITY_STATE
257
+ } : null;
258
+ let clientError = (0, $8AuPP$useMemo)(() => {
259
+ if (!validate || value == null) return null;
260
+ let validateErrors = $fd2148440a13ec26$var$runValidate(validate, value);
261
+ return $fd2148440a13ec26$var$getValidationResult(validateErrors);
262
+ }, [
263
+ validate,
264
+ value
265
+ ]);
266
+ if (builtinValidation?.validationDetails.valid) builtinValidation = void 0;
267
+ let serverErrors = (0, $8AuPP$useContext)($fd2148440a13ec26$export$571b5131b7e65c11);
268
+ let serverErrorMessages = (0, $8AuPP$useMemo)(() => {
269
+ if (name) return Array.isArray(name) ? name.flatMap((name2) => $fd2148440a13ec26$var$asArray(serverErrors[name2])) : $fd2148440a13ec26$var$asArray(serverErrors[name]);
270
+ return [];
271
+ }, [
272
+ serverErrors,
273
+ name
274
+ ]);
275
+ let [lastServerErrors, setLastServerErrors] = (0, $8AuPP$useState)(serverErrors);
276
+ let [isServerErrorCleared, setServerErrorCleared] = (0, $8AuPP$useState)(false);
277
+ if (serverErrors !== lastServerErrors) {
278
+ setLastServerErrors(serverErrors);
279
+ setServerErrorCleared(false);
280
+ }
281
+ let serverError = (0, $8AuPP$useMemo)(() => $fd2148440a13ec26$var$getValidationResult(isServerErrorCleared ? [] : serverErrorMessages), [
282
+ isServerErrorCleared,
283
+ serverErrorMessages
284
+ ]);
285
+ let nextValidation = (0, $8AuPP$useRef)($fd2148440a13ec26$export$dad6ae84456c676a);
286
+ let [currentValidity, setCurrentValidity] = (0, $8AuPP$useState)($fd2148440a13ec26$export$dad6ae84456c676a);
287
+ let lastError = (0, $8AuPP$useRef)($fd2148440a13ec26$export$dad6ae84456c676a);
288
+ let commitValidation = () => {
289
+ if (!commitQueued) return;
290
+ setCommitQueued(false);
291
+ let error = clientError || builtinValidation || nextValidation.current;
292
+ if (!$fd2148440a13ec26$var$isEqualValidation(error, lastError.current)) {
293
+ lastError.current = error;
294
+ setCurrentValidity(error);
295
+ }
296
+ };
297
+ let [commitQueued, setCommitQueued] = (0, $8AuPP$useState)(false);
298
+ (0, $8AuPP$useEffect)(commitValidation);
299
+ let realtimeValidation = controlledError || serverError || clientError || builtinValidation || $fd2148440a13ec26$export$dad6ae84456c676a;
300
+ let displayValidation = validationBehavior === "native" ? controlledError || serverError || currentValidity : controlledError || serverError || clientError || builtinValidation || currentValidity;
301
+ return {
302
+ realtimeValidation,
303
+ displayValidation,
304
+ updateValidation(value2) {
305
+ if (validationBehavior === "aria" && !$fd2148440a13ec26$var$isEqualValidation(currentValidity, value2)) setCurrentValidity(value2);
306
+ else nextValidation.current = value2;
307
+ },
308
+ resetValidation() {
309
+ let error = $fd2148440a13ec26$export$dad6ae84456c676a;
310
+ if (!$fd2148440a13ec26$var$isEqualValidation(error, lastError.current)) {
311
+ lastError.current = error;
312
+ setCurrentValidity(error);
313
+ }
314
+ if (validationBehavior === "native") setCommitQueued(false);
315
+ setServerErrorCleared(true);
316
+ },
317
+ commitValidation() {
318
+ if (validationBehavior === "native") setCommitQueued(true);
319
+ setServerErrorCleared(true);
320
+ }
321
+ };
322
+ }
323
+ function $fd2148440a13ec26$var$asArray(v) {
324
+ if (!v) return [];
325
+ return Array.isArray(v) ? v : [
326
+ v
327
+ ];
328
+ }
329
+ function $fd2148440a13ec26$var$runValidate(validate, value) {
330
+ if (typeof validate === "function") {
331
+ let e = validate(value);
332
+ if (e && typeof e !== "boolean") return $fd2148440a13ec26$var$asArray(e);
333
+ }
334
+ return [];
335
+ }
336
+ function $fd2148440a13ec26$var$getValidationResult(errors) {
337
+ return errors.length ? {
338
+ isInvalid: true,
339
+ validationErrors: errors,
340
+ validationDetails: $fd2148440a13ec26$var$CUSTOM_VALIDITY_STATE
341
+ } : null;
342
+ }
343
+ function $fd2148440a13ec26$var$isEqualValidation(a, b) {
344
+ if (a === b) return true;
345
+ return !!a && !!b && a.isInvalid === b.isInvalid && a.validationErrors.length === b.validationErrors.length && a.validationErrors.every((a2, i) => a2 === b.validationErrors[i]) && Object.entries(a.validationDetails).every(([k, v]) => b.validationDetails[k] === v);
346
+ }
347
+
348
+ // ../../node_modules/react-stately/dist/private/collections/getChildNodes.mjs
349
+ function $cd5ea4b915021f1d$export$1005530eda016c13(node, collection) {
350
+ if (typeof collection.getChildren === "function") return collection.getChildren(node.key);
351
+ return node.childNodes;
352
+ }
353
+ function $cd5ea4b915021f1d$export$fbdeaa6a76694f71(iterable) {
354
+ return $cd5ea4b915021f1d$export$5f3398f8733f90e2(iterable, 0);
355
+ }
356
+ function $cd5ea4b915021f1d$export$5f3398f8733f90e2(iterable, index) {
357
+ if (index < 0) return void 0;
358
+ let i = 0;
359
+ for (let item of iterable) {
360
+ if (i === index) return item;
361
+ i++;
362
+ }
363
+ }
364
+ function $cd5ea4b915021f1d$export$8c434b3a7a4dad6(collection, a, b) {
365
+ if (a.parentKey === b.parentKey) return a.index - b.index;
366
+ let aAncestors = [
367
+ ...$cd5ea4b915021f1d$var$getAncestors(collection, a),
368
+ a
369
+ ];
370
+ let bAncestors = [
371
+ ...$cd5ea4b915021f1d$var$getAncestors(collection, b),
372
+ b
373
+ ];
374
+ let firstNonMatchingAncestor = aAncestors.slice(0, bAncestors.length).findIndex((a2, i) => a2 !== bAncestors[i]);
375
+ if (firstNonMatchingAncestor !== -1) {
376
+ a = aAncestors[firstNonMatchingAncestor];
377
+ b = bAncestors[firstNonMatchingAncestor];
378
+ return a.index - b.index;
379
+ }
380
+ if (aAncestors.findIndex((node) => node === b) >= 0) return 1;
381
+ else if (bAncestors.findIndex((node) => node === a) >= 0) return -1;
382
+ return -1;
383
+ }
384
+ function $cd5ea4b915021f1d$var$getAncestors(collection, node) {
385
+ let parents = [];
386
+ let currNode = node;
387
+ while (currNode?.parentKey != null) {
388
+ currNode = collection.getItem(currNode.parentKey);
389
+ if (currNode) parents.unshift(currNode);
390
+ }
391
+ return parents;
392
+ }
393
+
394
+ // ../../node_modules/react-stately/dist/private/list/ListCollection.mjs
395
+ var $f664a81d022446b5$export$d085fb9e920b5ca7 = class {
396
+ constructor(nodes) {
397
+ this.keyMap = /* @__PURE__ */ new Map();
398
+ this.firstKey = null;
399
+ this.lastKey = null;
400
+ this.iterable = nodes;
401
+ let visit = (node) => {
402
+ this.keyMap.set(node.key, node);
403
+ if (node.childNodes && node.type === "section") for (let child of node.childNodes) visit(child);
404
+ };
405
+ for (let node of nodes) visit(node);
406
+ let last = null;
407
+ let index = 0;
408
+ let size = 0;
409
+ for (let [key, node] of this.keyMap) {
410
+ if (last) {
411
+ last.nextKey = key;
412
+ node.prevKey = last.key;
413
+ } else {
414
+ this.firstKey = key;
415
+ node.prevKey = void 0;
416
+ }
417
+ if (node.type === "item") node.index = index++;
418
+ if (node.type === "section" || node.type === "item") size++;
419
+ last = node;
420
+ last.nextKey = void 0;
421
+ }
422
+ this._size = size;
423
+ this.lastKey = last?.key ?? null;
424
+ }
425
+ *[Symbol.iterator]() {
426
+ yield* this.iterable;
427
+ }
428
+ get size() {
429
+ return this._size;
430
+ }
431
+ getKeys() {
432
+ return this.keyMap.keys();
433
+ }
434
+ getKeyBefore(key) {
435
+ let node = this.keyMap.get(key);
436
+ return node ? node.prevKey ?? null : null;
437
+ }
438
+ getKeyAfter(key) {
439
+ let node = this.keyMap.get(key);
440
+ return node ? node.nextKey ?? null : null;
441
+ }
442
+ getFirstKey() {
443
+ return this.firstKey;
444
+ }
445
+ getLastKey() {
446
+ return this.lastKey;
447
+ }
448
+ getItem(key) {
449
+ return this.keyMap.get(key) ?? null;
450
+ }
451
+ at(idx) {
452
+ const keys = [
453
+ ...this.getKeys()
454
+ ];
455
+ return this.getItem(keys[idx]);
456
+ }
457
+ getChildren(key) {
458
+ let node = this.keyMap.get(key);
459
+ return node?.childNodes || [];
460
+ }
461
+ };
462
+
463
+ // ../../node_modules/react-stately/dist/private/selection/Selection.mjs
464
+ var $8b2540e09867b15e$export$52baac22726c72bf = class _$8b2540e09867b15e$export$52baac22726c72bf extends Set {
465
+ constructor(keys, anchorKey, currentKey) {
466
+ super(keys);
467
+ if (keys instanceof _$8b2540e09867b15e$export$52baac22726c72bf) {
468
+ this.anchorKey = anchorKey ?? keys.anchorKey;
469
+ this.currentKey = currentKey ?? keys.currentKey;
470
+ } else {
471
+ this.anchorKey = anchorKey ?? null;
472
+ this.currentKey = currentKey ?? null;
473
+ }
474
+ }
475
+ };
476
+
477
+ // ../../node_modules/react-stately/dist/private/selection/useMultipleSelectionState.mjs
478
+ import { useRef as $7w3VE$useRef, useState as $7w3VE$useState, useMemo as $7w3VE$useMemo, useEffect as $7w3VE$useEffect } from "react";
479
+ function $60f19cefd567a3e4$var$equalSets(setA, setB) {
480
+ if (setA.size !== setB.size) return false;
481
+ for (let item of setA) {
482
+ if (!setB.has(item)) return false;
483
+ }
484
+ return true;
485
+ }
486
+ function $60f19cefd567a3e4$export$253fe78d46329472(props) {
487
+ let { selectionMode = "none", disallowEmptySelection = false, allowDuplicateSelectionEvents, selectionBehavior: selectionBehaviorProp = "toggle", disabledBehavior = "all" } = props;
488
+ let isFocusedRef = (0, $7w3VE$useRef)(false);
489
+ let [, setFocused] = (0, $7w3VE$useState)(false);
490
+ let focusedKeyRef = (0, $7w3VE$useRef)(null);
491
+ let childFocusStrategyRef = (0, $7w3VE$useRef)(null);
492
+ let [, setFocusedKey] = (0, $7w3VE$useState)(null);
493
+ let selectedKeysProp = (0, $7w3VE$useMemo)(() => $60f19cefd567a3e4$var$convertSelection(props.selectedKeys), [
494
+ props.selectedKeys
495
+ ]);
496
+ let defaultSelectedKeys = (0, $7w3VE$useMemo)(() => $60f19cefd567a3e4$var$convertSelection(props.defaultSelectedKeys, new (0, $8b2540e09867b15e$export$52baac22726c72bf)()), [
497
+ props.defaultSelectedKeys
498
+ ]);
499
+ let [selectedKeys, setSelectedKeys] = (0, $3e6197669829fe11$export$40bfa8c7b0832715)(selectedKeysProp, defaultSelectedKeys, props.onSelectionChange);
500
+ let disabledKeysProp = (0, $7w3VE$useMemo)(() => props.disabledKeys ? new Set(props.disabledKeys) : /* @__PURE__ */ new Set(), [
501
+ props.disabledKeys
502
+ ]);
503
+ let [selectionBehavior, setSelectionBehavior] = (0, $7w3VE$useState)(selectionBehaviorProp);
504
+ if (selectionBehaviorProp === "replace" && selectionBehavior === "toggle" && typeof selectedKeys === "object" && selectedKeys.size === 0) setSelectionBehavior("replace");
505
+ let lastSelectionBehavior = (0, $7w3VE$useRef)(selectionBehaviorProp);
506
+ (0, $7w3VE$useEffect)(() => {
507
+ if (selectionBehaviorProp !== lastSelectionBehavior.current) {
508
+ setSelectionBehavior(selectionBehaviorProp);
509
+ lastSelectionBehavior.current = selectionBehaviorProp;
510
+ }
511
+ }, [
512
+ selectionBehaviorProp
513
+ ]);
514
+ return {
515
+ selectionMode,
516
+ disallowEmptySelection,
517
+ selectionBehavior,
518
+ setSelectionBehavior,
519
+ get isFocused() {
520
+ return isFocusedRef.current;
521
+ },
522
+ setFocused(f) {
523
+ isFocusedRef.current = f;
524
+ setFocused(f);
525
+ },
526
+ get focusedKey() {
527
+ return focusedKeyRef.current;
528
+ },
529
+ get childFocusStrategy() {
530
+ return childFocusStrategyRef.current;
531
+ },
532
+ setFocusedKey(k, childFocusStrategy = "first") {
533
+ focusedKeyRef.current = k;
534
+ childFocusStrategyRef.current = childFocusStrategy;
535
+ setFocusedKey(k);
536
+ },
537
+ selectedKeys,
538
+ setSelectedKeys(keys) {
539
+ if (allowDuplicateSelectionEvents || !$60f19cefd567a3e4$var$equalSets(keys, selectedKeys)) setSelectedKeys(keys);
540
+ },
541
+ disabledKeys: disabledKeysProp,
542
+ disabledBehavior
543
+ };
544
+ }
545
+ function $60f19cefd567a3e4$var$convertSelection(selection, defaultValue) {
546
+ if (!selection) return defaultValue;
547
+ return selection === "all" ? "all" : new (0, $8b2540e09867b15e$export$52baac22726c72bf)(selection);
548
+ }
549
+
550
+ // ../../node_modules/react-stately/dist/private/selection/SelectionManager.mjs
551
+ var $4a07ac835f260f78$export$6c8a5aaad13c9852 = class _$4a07ac835f260f78$export$6c8a5aaad13c9852 {
552
+ constructor(collection, state, options) {
553
+ this.collection = collection;
554
+ this.state = state;
555
+ this.allowsCellSelection = options?.allowsCellSelection ?? false;
556
+ this._isSelectAll = null;
557
+ this.layoutDelegate = options?.layoutDelegate || null;
558
+ this.fullCollection = options?.fullCollection || null;
559
+ }
560
+ /**
561
+ * The type of selection that is allowed in the collection.
562
+ */
563
+ get selectionMode() {
564
+ return this.state.selectionMode;
565
+ }
566
+ /**
567
+ * Whether the collection allows empty selection.
568
+ */
569
+ get disallowEmptySelection() {
570
+ return this.state.disallowEmptySelection;
571
+ }
572
+ /**
573
+ * The selection behavior for the collection.
574
+ */
575
+ get selectionBehavior() {
576
+ return this.state.selectionBehavior;
577
+ }
578
+ /**
579
+ * Sets the selection behavior for the collection.
580
+ */
581
+ setSelectionBehavior(selectionBehavior) {
582
+ this.state.setSelectionBehavior(selectionBehavior);
583
+ }
584
+ /**
585
+ * Whether the collection is currently focused.
586
+ */
587
+ get isFocused() {
588
+ return this.state.isFocused;
589
+ }
590
+ /**
591
+ * Sets whether the collection is focused.
592
+ */
593
+ setFocused(isFocused) {
594
+ this.state.setFocused(isFocused);
595
+ }
596
+ /**
597
+ * The current focused key in the collection.
598
+ */
599
+ get focusedKey() {
600
+ return this.state.focusedKey;
601
+ }
602
+ /** Whether the first or last child of the focused key should receive focus. */
603
+ get childFocusStrategy() {
604
+ return this.state.childFocusStrategy;
605
+ }
606
+ /**
607
+ * Sets the focused key.
608
+ */
609
+ setFocusedKey(key, childFocusStrategy) {
610
+ if (key == null || this.collection.getItem(key)) this.state.setFocusedKey(key, childFocusStrategy);
611
+ }
612
+ /**
613
+ * The currently selected keys in the collection.
614
+ */
615
+ get selectedKeys() {
616
+ return this.state.selectedKeys === "all" ? new Set(this.getSelectAllKeys()) : this.state.selectedKeys;
617
+ }
618
+ /**
619
+ * The raw selection value for the collection.
620
+ * Either 'all' for select all, or a set of keys.
621
+ */
622
+ get rawSelection() {
623
+ return this.state.selectedKeys;
624
+ }
625
+ /**
626
+ * Returns whether a key is selected.
627
+ */
628
+ isSelected(key) {
629
+ if (this.state.selectionMode === "none") return false;
630
+ let mappedKey = this.getKey(key);
631
+ if (mappedKey == null) return false;
632
+ return this.state.selectedKeys === "all" ? this.canSelectItem(mappedKey) : this.state.selectedKeys.has(mappedKey);
633
+ }
634
+ /**
635
+ * Whether the selection is empty.
636
+ */
637
+ get isEmpty() {
638
+ return this.state.selectedKeys !== "all" && this.state.selectedKeys.size === 0;
639
+ }
640
+ /**
641
+ * Whether all items in the collection are selected.
642
+ */
643
+ get isSelectAll() {
644
+ if (this.isEmpty) return false;
645
+ if (this.state.selectedKeys === "all") return true;
646
+ if (this._isSelectAll != null) return this._isSelectAll;
647
+ let allKeys = this.getSelectAllKeys();
648
+ let selectedKeys = this.state.selectedKeys;
649
+ this._isSelectAll = allKeys.every((k) => selectedKeys.has(k));
650
+ return this._isSelectAll;
651
+ }
652
+ get firstSelectedKey() {
653
+ let first = null;
654
+ for (let key of this.state.selectedKeys) {
655
+ let item = this.collection.getItem(key);
656
+ if (!first || item && (0, $cd5ea4b915021f1d$export$8c434b3a7a4dad6)(this.collection, item, first) < 0) first = item;
657
+ }
658
+ return first?.key ?? null;
659
+ }
660
+ get lastSelectedKey() {
661
+ let last = null;
662
+ for (let key of this.state.selectedKeys) {
663
+ let item = this.collection.getItem(key);
664
+ if (!last || item && (0, $cd5ea4b915021f1d$export$8c434b3a7a4dad6)(this.collection, item, last) > 0) last = item;
665
+ }
666
+ return last?.key ?? null;
667
+ }
668
+ get disabledKeys() {
669
+ return this.state.disabledKeys;
670
+ }
671
+ get disabledBehavior() {
672
+ return this.state.disabledBehavior;
673
+ }
674
+ /**
675
+ * Extends the selection to the given key.
676
+ */
677
+ extendSelection(toKey) {
678
+ if (this.selectionMode === "none") return;
679
+ if (this.selectionMode === "single") {
680
+ this.replaceSelection(toKey);
681
+ return;
682
+ }
683
+ let mappedToKey = this.getKey(toKey);
684
+ if (mappedToKey == null) return;
685
+ let selection;
686
+ if (this.state.selectedKeys === "all") selection = new (0, $8b2540e09867b15e$export$52baac22726c72bf)([
687
+ mappedToKey
688
+ ], mappedToKey, mappedToKey);
689
+ else {
690
+ let selectedKeys = this.state.selectedKeys;
691
+ let anchorKey = selectedKeys.anchorKey ?? mappedToKey;
692
+ selection = new (0, $8b2540e09867b15e$export$52baac22726c72bf)(selectedKeys, anchorKey, mappedToKey);
693
+ for (let key of this.getKeyRange(anchorKey, selectedKeys.currentKey ?? mappedToKey)) selection.delete(key);
694
+ for (let key of this.getKeyRange(mappedToKey, anchorKey)) if (this.canSelectItem(key)) selection.add(key);
695
+ }
696
+ this.state.setSelectedKeys(selection);
697
+ }
698
+ getKeyRange(from, to) {
699
+ let fromItem = this.collection.getItem(from);
700
+ let toItem = this.collection.getItem(to);
701
+ if (fromItem && toItem) {
702
+ if ((0, $cd5ea4b915021f1d$export$8c434b3a7a4dad6)(this.collection, fromItem, toItem) <= 0) return this.getKeyRangeInternal(from, to);
703
+ return this.getKeyRangeInternal(to, from);
704
+ }
705
+ return [];
706
+ }
707
+ getKeyRangeInternal(from, to) {
708
+ if (this.layoutDelegate?.getKeyRange) return this.layoutDelegate.getKeyRange(from, to);
709
+ let keys = [];
710
+ let key = from;
711
+ while (key != null) {
712
+ let item = this.collection.getItem(key);
713
+ if (item && (item.type === "item" || item.type === "cell" && this.allowsCellSelection)) keys.push(key);
714
+ if (key === to) return keys;
715
+ key = this.collection.getKeyAfter(key);
716
+ }
717
+ return [];
718
+ }
719
+ getKey(key) {
720
+ let item = this.collection.getItem(key);
721
+ if (!item)
722
+ return key;
723
+ if (item.type === "cell" && this.allowsCellSelection) return key;
724
+ while (item && item.type !== "item" && item.parentKey != null) item = this.collection.getItem(item.parentKey);
725
+ if (!item || item.type !== "item") return null;
726
+ return item.key;
727
+ }
728
+ /**
729
+ * Toggles whether the given key is selected.
730
+ */
731
+ toggleSelection(key) {
732
+ if (this.selectionMode === "none") return;
733
+ if (this.selectionMode === "single" && !this.isSelected(key)) {
734
+ this.replaceSelection(key);
735
+ return;
736
+ }
737
+ let mappedKey = this.getKey(key);
738
+ if (mappedKey == null) return;
739
+ let keys = new (0, $8b2540e09867b15e$export$52baac22726c72bf)(this.state.selectedKeys === "all" ? this.getSelectAllKeys() : this.state.selectedKeys);
740
+ if (keys.has(mappedKey)) keys.delete(mappedKey);
741
+ else if (this.canSelectItem(mappedKey)) {
742
+ keys.add(mappedKey);
743
+ keys.anchorKey = mappedKey;
744
+ keys.currentKey = mappedKey;
745
+ }
746
+ if (this.disallowEmptySelection && keys.size === 0) return;
747
+ this.state.setSelectedKeys(keys);
748
+ }
749
+ /**
750
+ * Replaces the selection with only the given key.
751
+ */
752
+ replaceSelection(key) {
753
+ if (this.selectionMode === "none") return;
754
+ let mappedKey = this.getKey(key);
755
+ if (mappedKey == null) return;
756
+ let selection = this.canSelectItem(mappedKey) ? new (0, $8b2540e09867b15e$export$52baac22726c72bf)([
757
+ mappedKey
758
+ ], mappedKey, mappedKey) : new (0, $8b2540e09867b15e$export$52baac22726c72bf)();
759
+ this.state.setSelectedKeys(selection);
760
+ }
761
+ /**
762
+ * Replaces the selection with the given keys.
763
+ */
764
+ setSelectedKeys(keys) {
765
+ if (this.selectionMode === "none") return;
766
+ let selection = new (0, $8b2540e09867b15e$export$52baac22726c72bf)();
767
+ for (let key of keys) {
768
+ let mappedKey = this.getKey(key);
769
+ if (mappedKey != null) {
770
+ selection.add(mappedKey);
771
+ if (this.selectionMode === "single") break;
772
+ }
773
+ }
774
+ this.state.setSelectedKeys(selection);
775
+ }
776
+ getSelectAllKeys() {
777
+ let collection = this.fullCollection ?? this.collection;
778
+ let keys = [];
779
+ let addKeys = (key) => {
780
+ while (key != null) {
781
+ if (this.canSelectItemIn(key, collection)) {
782
+ let item = collection.getItem(key);
783
+ if (item?.type === "item") keys.push(key);
784
+ if (item?.hasChildNodes && (this.allowsCellSelection || item.type !== "item")) addKeys((0, $cd5ea4b915021f1d$export$fbdeaa6a76694f71)((0, $cd5ea4b915021f1d$export$1005530eda016c13)(item, collection))?.key ?? null);
785
+ }
786
+ key = collection.getKeyAfter(key);
787
+ }
788
+ };
789
+ addKeys(collection.getFirstKey());
790
+ return keys;
791
+ }
792
+ /**
793
+ * Selects all items in the collection.
794
+ */
795
+ selectAll() {
796
+ if (!this.isSelectAll && this.selectionMode === "multiple") this.state.setSelectedKeys("all");
797
+ }
798
+ /**
799
+ * Removes all keys from the selection.
800
+ */
801
+ clearSelection() {
802
+ if (!this.disallowEmptySelection && (this.state.selectedKeys === "all" || this.state.selectedKeys.size > 0)) this.state.setSelectedKeys(new (0, $8b2540e09867b15e$export$52baac22726c72bf)());
803
+ }
804
+ /**
805
+ * Toggles between select all and an empty selection.
806
+ */
807
+ toggleSelectAll() {
808
+ if (this.isSelectAll) this.clearSelection();
809
+ else this.selectAll();
810
+ }
811
+ select(key, e) {
812
+ if (this.selectionMode === "none") return;
813
+ if (this.selectionMode === "single") {
814
+ if (this.isSelected(key) && !this.disallowEmptySelection) this.toggleSelection(key);
815
+ else this.replaceSelection(key);
816
+ } else if (this.selectionBehavior === "toggle" || e && (e.pointerType === "touch" || e.pointerType === "virtual"))
817
+ this.toggleSelection(key);
818
+ else this.replaceSelection(key);
819
+ }
820
+ /**
821
+ * Returns whether the current selection is equal to the given selection.
822
+ */
823
+ isSelectionEqual(selection) {
824
+ if (selection === this.state.selectedKeys) return true;
825
+ let selectedKeys = this.selectedKeys;
826
+ if (selection.size !== selectedKeys.size) return false;
827
+ for (let key of selection) {
828
+ if (!selectedKeys.has(key)) return false;
829
+ }
830
+ for (let key of selectedKeys) {
831
+ if (!selection.has(key)) return false;
832
+ }
833
+ return true;
834
+ }
835
+ canSelectItem(key) {
836
+ return this.canSelectItemIn(key, this.collection);
837
+ }
838
+ canSelectItemIn(key, collection) {
839
+ if (this.state.selectionMode === "none" || this.state.disabledKeys.has(key)) return false;
840
+ let item = collection.getItem(key);
841
+ if (!item || item?.props?.isDisabled || item.type === "cell" && !this.allowsCellSelection) return false;
842
+ return true;
843
+ }
844
+ isDisabled(key) {
845
+ return this.state.disabledBehavior === "all" && (this.state.disabledKeys.has(key) || !!this.collection.getItem(key)?.props?.isDisabled);
846
+ }
847
+ isLink(key) {
848
+ return !!this.collection.getItem(key)?.props?.href;
849
+ }
850
+ getItemProps(key) {
851
+ return this.collection.getItem(key)?.props;
852
+ }
853
+ withCollection(collection) {
854
+ return new _$4a07ac835f260f78$export$6c8a5aaad13c9852(collection, this.state, {
855
+ allowsCellSelection: this.allowsCellSelection,
856
+ layoutDelegate: this.layoutDelegate || void 0,
857
+ fullCollection: this.fullCollection ?? this.collection
858
+ });
859
+ }
860
+ };
861
+
862
+ // ../../node_modules/react-stately/dist/private/collections/CollectionBuilder.mjs
863
+ import $jO8i1$react from "react";
864
+ var $bda7a7e55e1ff206$export$bf788dd355e3a401 = class {
865
+ build(props, context) {
866
+ this.context = context;
867
+ return $bda7a7e55e1ff206$var$iterable(() => this.iterateCollection(props));
868
+ }
869
+ *iterateCollection(props) {
870
+ let { children, items } = props;
871
+ if ((0, $jO8i1$react).isValidElement(children) && children.type === (0, $jO8i1$react).Fragment) yield* this.iterateCollection({
872
+ children: children.props.children,
873
+ items
874
+ });
875
+ else if (typeof children === "function") {
876
+ if (!items) throw new Error("props.children was a function but props.items is missing");
877
+ let index = 0;
878
+ for (let item of items) {
879
+ yield* this.getFullNode({
880
+ value: item,
881
+ index
882
+ }, {
883
+ renderer: children
884
+ });
885
+ index++;
886
+ }
887
+ } else {
888
+ let items2 = [];
889
+ (0, $jO8i1$react).Children.forEach(children, (child) => {
890
+ if (child) items2.push(child);
891
+ });
892
+ let index = 0;
893
+ for (let item of items2) {
894
+ let nodes = this.getFullNode({
895
+ element: item,
896
+ index
897
+ }, {});
898
+ for (let node of nodes) {
899
+ index++;
900
+ yield node;
901
+ }
902
+ }
903
+ }
904
+ }
905
+ getKey(item, partialNode, state, parentKey) {
906
+ if (item.key != null) return item.key;
907
+ if (partialNode.type === "cell" && partialNode.key != null) return `${parentKey}${partialNode.key}`;
908
+ let v = partialNode.value;
909
+ if (v != null) {
910
+ let key = v.key ?? v.id;
911
+ if (key == null) throw new Error("No key found for item");
912
+ return key;
913
+ }
914
+ return parentKey ? `${parentKey}.${partialNode.index}` : `$.${partialNode.index}`;
915
+ }
916
+ getChildState(state, partialNode) {
917
+ return {
918
+ renderer: partialNode.renderer || state.renderer
919
+ };
920
+ }
921
+ *getFullNode(partialNode, state, parentKey, parentNode) {
922
+ if ((0, $jO8i1$react).isValidElement(partialNode.element) && partialNode.element.type === (0, $jO8i1$react).Fragment) {
923
+ let children = [];
924
+ (0, $jO8i1$react).Children.forEach(partialNode.element.props.children, (child) => {
925
+ children.push(child);
926
+ });
927
+ let index = partialNode.index ?? 0;
928
+ for (const child of children) yield* this.getFullNode({
929
+ element: child,
930
+ index: index++
931
+ }, state, parentKey, parentNode);
932
+ return;
933
+ }
934
+ let element = partialNode.element;
935
+ if (!element && partialNode.value && state && state.renderer) {
936
+ let cached = this.cache.get(partialNode.value);
937
+ if (cached && (!cached.shouldInvalidate || !cached.shouldInvalidate(this.context))) {
938
+ cached.index = partialNode.index;
939
+ cached.parentKey = parentNode ? parentNode.key : null;
940
+ yield cached;
941
+ return;
942
+ }
943
+ element = state.renderer(partialNode.value);
944
+ }
945
+ if ((0, $jO8i1$react).isValidElement(element)) {
946
+ let type = element.type;
947
+ if (typeof type !== "function" && typeof type.getCollectionNode !== "function") {
948
+ let name = element.type;
949
+ throw new Error(`Unknown element <${name}> in collection.`);
950
+ }
951
+ let childNodes = type.getCollectionNode(element.props, this.context);
952
+ let index = partialNode.index ?? 0;
953
+ let result = childNodes.next();
954
+ while (!result.done && result.value) {
955
+ let childNode = result.value;
956
+ partialNode.index = index;
957
+ let nodeKey = childNode.key ?? null;
958
+ if (nodeKey == null) nodeKey = childNode.element ? null : this.getKey(element, partialNode, state, parentKey);
959
+ let nodes = this.getFullNode({
960
+ ...childNode,
961
+ key: nodeKey,
962
+ index,
963
+ wrapper: $bda7a7e55e1ff206$var$compose(partialNode.wrapper, childNode.wrapper)
964
+ }, this.getChildState(state, childNode), parentKey ? `${parentKey}${element.key}` : element.key, parentNode);
965
+ let children = [
966
+ ...nodes
967
+ ];
968
+ for (let node2 of children) {
969
+ node2.value = childNode.value ?? partialNode.value ?? null;
970
+ if (node2.value) this.cache.set(node2.value, node2);
971
+ if (partialNode.type && node2.type !== partialNode.type) throw new Error(`Unsupported type <${$bda7a7e55e1ff206$var$capitalize(node2.type)}> in <${$bda7a7e55e1ff206$var$capitalize(parentNode?.type ?? "unknown parent type")}>. Only <${$bda7a7e55e1ff206$var$capitalize(partialNode.type)}> is supported.`);
972
+ index++;
973
+ yield node2;
974
+ }
975
+ result = childNodes.next(children);
976
+ }
977
+ return;
978
+ }
979
+ if (partialNode.key == null || partialNode.type == null) return;
980
+ let builder = this;
981
+ let node = {
982
+ type: partialNode.type,
983
+ props: partialNode.props,
984
+ key: partialNode.key,
985
+ parentKey: parentNode ? parentNode.key : null,
986
+ value: partialNode.value ?? null,
987
+ level: (parentNode?.level ?? 0) + (parentNode?.type === "item" ? 1 : 0),
988
+ index: partialNode.index,
989
+ rendered: partialNode.rendered,
990
+ textValue: partialNode.textValue ?? "",
991
+ "aria-label": partialNode["aria-label"],
992
+ wrapper: partialNode.wrapper,
993
+ shouldInvalidate: partialNode.shouldInvalidate,
994
+ hasChildNodes: partialNode.hasChildNodes || false,
995
+ childNodes: $bda7a7e55e1ff206$var$iterable(function* () {
996
+ if (!partialNode.hasChildNodes || !partialNode.childNodes) return;
997
+ let index = 0;
998
+ for (let child of partialNode.childNodes()) {
999
+ if (child.key != null)
1000
+ child.key = `${node.key}${child.key}`;
1001
+ let nodes = builder.getFullNode({
1002
+ ...child,
1003
+ index
1004
+ }, builder.getChildState(state, child), node.key, node);
1005
+ for (let node2 of nodes) {
1006
+ index++;
1007
+ yield node2;
1008
+ }
1009
+ }
1010
+ })
1011
+ };
1012
+ yield node;
1013
+ }
1014
+ constructor() {
1015
+ this.cache = /* @__PURE__ */ new WeakMap();
1016
+ }
1017
+ };
1018
+ function $bda7a7e55e1ff206$var$iterable(iterator) {
1019
+ let cache = [];
1020
+ let iterable = null;
1021
+ return {
1022
+ *[Symbol.iterator]() {
1023
+ for (let item of cache) yield item;
1024
+ if (!iterable) iterable = iterator();
1025
+ for (let item of iterable) {
1026
+ cache.push(item);
1027
+ yield item;
1028
+ }
1029
+ }
1030
+ };
1031
+ }
1032
+ function $bda7a7e55e1ff206$var$compose(outer, inner) {
1033
+ if (outer && inner) return (element) => outer(inner(element));
1034
+ if (outer) return outer;
1035
+ if (inner) return inner;
1036
+ }
1037
+ function $bda7a7e55e1ff206$var$capitalize(str) {
1038
+ return str[0].toUpperCase() + str.slice(1);
1039
+ }
1040
+
1041
+ // ../../node_modules/react-stately/dist/private/collections/useCollection.mjs
1042
+ import { useMemo as $emYU7$useMemo } from "react";
1043
+ function $d03379b88399b8c5$export$6cd28814d92fa9c9(props, factory, context) {
1044
+ let builder = (0, $emYU7$useMemo)(() => new (0, $bda7a7e55e1ff206$export$bf788dd355e3a401)(), []);
1045
+ let { children, items, collection } = props;
1046
+ let result = (0, $emYU7$useMemo)(() => {
1047
+ if (collection) return collection;
1048
+ let nodes = builder.build({
1049
+ children,
1050
+ items
1051
+ }, context);
1052
+ return factory(nodes);
1053
+ }, [
1054
+ builder,
1055
+ children,
1056
+ items,
1057
+ collection,
1058
+ context,
1059
+ factory
1060
+ ]);
1061
+ return result;
1062
+ }
1063
+
1064
+ // ../../node_modules/react-stately/dist/private/list/useListState.mjs
1065
+ import { useMemo as $3yt54$useMemo, useCallback as $3yt54$useCallback, useRef as $3yt54$useRef, useEffect as $3yt54$useEffect } from "react";
1066
+ function $b14b6f590b50af39$export$2f645645f7bca764(props) {
1067
+ let { filter, layoutDelegate } = props;
1068
+ let selectionState = (0, $60f19cefd567a3e4$export$253fe78d46329472)(props);
1069
+ let disabledKeys = (0, $3yt54$useMemo)(() => props.disabledKeys ? new Set(props.disabledKeys) : /* @__PURE__ */ new Set(), [
1070
+ props.disabledKeys
1071
+ ]);
1072
+ let factory = (0, $3yt54$useCallback)((nodes) => filter ? new (0, $f664a81d022446b5$export$d085fb9e920b5ca7)(filter(nodes)) : new (0, $f664a81d022446b5$export$d085fb9e920b5ca7)(nodes), [
1073
+ filter
1074
+ ]);
1075
+ let context = (0, $3yt54$useMemo)(() => ({
1076
+ suppressTextValueWarning: props.suppressTextValueWarning
1077
+ }), [
1078
+ props.suppressTextValueWarning
1079
+ ]);
1080
+ let collection = (0, $d03379b88399b8c5$export$6cd28814d92fa9c9)(props, factory, context);
1081
+ let selectionManager = (0, $3yt54$useMemo)(() => new (0, $4a07ac835f260f78$export$6c8a5aaad13c9852)(collection, selectionState, {
1082
+ layoutDelegate
1083
+ }), [
1084
+ collection,
1085
+ selectionState,
1086
+ layoutDelegate
1087
+ ]);
1088
+ $b14b6f590b50af39$var$useFocusedKeyReset(collection, selectionManager);
1089
+ return {
1090
+ collection,
1091
+ disabledKeys,
1092
+ selectionManager
1093
+ };
1094
+ }
1095
+ function $b14b6f590b50af39$var$useFocusedKeyReset(collection, selectionManager) {
1096
+ const cachedCollection = (0, $3yt54$useRef)(null);
1097
+ (0, $3yt54$useEffect)(() => {
1098
+ if (selectionManager.focusedKey != null && !collection.getItem(selectionManager.focusedKey) && cachedCollection.current) {
1099
+ let key = cachedCollection.current.getKeyAfter(selectionManager.focusedKey);
1100
+ let nextFocusedKey = null;
1101
+ while (key != null) {
1102
+ let node = collection.getItem(key);
1103
+ if (node && node.type === "item" && !selectionManager.isDisabled(key)) {
1104
+ nextFocusedKey = key;
1105
+ break;
1106
+ }
1107
+ key = cachedCollection.current.getKeyAfter(key);
1108
+ }
1109
+ if (nextFocusedKey == null) {
1110
+ key = cachedCollection.current.getKeyBefore(selectionManager.focusedKey);
1111
+ while (key != null) {
1112
+ let node = collection.getItem(key);
1113
+ if (node && node.type === "item" && !selectionManager.isDisabled(key)) {
1114
+ nextFocusedKey = key;
1115
+ break;
1116
+ }
1117
+ key = cachedCollection.current.getKeyBefore(key);
1118
+ }
1119
+ }
1120
+ selectionManager.setFocusedKey(nextFocusedKey);
1121
+ }
1122
+ cachedCollection.current = collection;
1123
+ }, [
1124
+ collection,
1125
+ selectionManager
1126
+ ]);
1127
+ }
1128
+
1129
+ // ../../node_modules/react-stately/dist/private/overlays/useOverlayTriggerState.mjs
1130
+ import { useCallback as $kE40A$useCallback } from "react";
1131
+ function $f11fb0bcf1b2687a$export$61c6a8c84e605fb6(props) {
1132
+ let [isOpen, setOpen] = (0, $3e6197669829fe11$export$40bfa8c7b0832715)(props.isOpen, props.defaultOpen || false, props.onOpenChange);
1133
+ const open = (0, $kE40A$useCallback)(() => {
1134
+ setOpen(true);
1135
+ }, [
1136
+ setOpen
1137
+ ]);
1138
+ const close = (0, $kE40A$useCallback)(() => {
1139
+ setOpen(false);
1140
+ }, [
1141
+ setOpen
1142
+ ]);
1143
+ const toggle = (0, $kE40A$useCallback)(() => {
1144
+ setOpen(!isOpen);
1145
+ }, [
1146
+ setOpen,
1147
+ isOpen
1148
+ ]);
1149
+ return {
1150
+ isOpen,
1151
+ setOpen,
1152
+ open,
1153
+ close,
1154
+ toggle
1155
+ };
1156
+ }
1157
+
1158
+ // ../../node_modules/react-stately/dist/private/collections/Item.mjs
1159
+ import $dJmKC$react from "react";
1160
+ function $05678f3aee5e7d1a$var$Item(props) {
1161
+ return null;
1162
+ }
1163
+ $05678f3aee5e7d1a$var$Item.getCollectionNode = function* getCollectionNode(props, context) {
1164
+ let { childItems, title, children } = props;
1165
+ let rendered = props.title || props.children;
1166
+ let textValue = props.textValue || (typeof rendered === "string" ? rendered : "") || props["aria-label"] || "";
1167
+ if (!textValue && !context?.suppressTextValueWarning && process.env.NODE_ENV !== "production") console.warn("<Item> with non-plain text contents is unsupported by type to select for accessibility. Please add a `textValue` prop.");
1168
+ yield {
1169
+ type: "item",
1170
+ props,
1171
+ rendered,
1172
+ textValue,
1173
+ "aria-label": props["aria-label"],
1174
+ hasChildNodes: $05678f3aee5e7d1a$var$hasChildItems(props),
1175
+ *childNodes() {
1176
+ if (childItems) for (let child of childItems) yield {
1177
+ type: "item",
1178
+ value: child
1179
+ };
1180
+ else if (title) {
1181
+ let items = [];
1182
+ (0, $dJmKC$react).Children.forEach(children, (child) => {
1183
+ items.push({
1184
+ type: "item",
1185
+ element: child
1186
+ });
1187
+ });
1188
+ yield* items;
1189
+ }
1190
+ }
1191
+ };
1192
+ };
1193
+ function $05678f3aee5e7d1a$var$hasChildItems(props) {
1194
+ if (props.hasChildItems != null) return props.hasChildItems;
1195
+ if (props.childItems) return true;
1196
+ if (props.title && (0, $dJmKC$react).Children.count(props.children) > 0) return true;
1197
+ return false;
1198
+ }
1199
+ var $05678f3aee5e7d1a$export$6d08773d2e66f8f2 = $05678f3aee5e7d1a$var$Item;
1200
+
1201
+ // ../../node_modules/react-stately/dist/private/list/useSingleSelectListState.mjs
1202
+ import { useMemo as $jhfZc$useMemo } from "react";
1203
+ function $0fdb127d377ffd84$export$e7f05e985daf4b5f(props) {
1204
+ let [selectedKey, setSelectedKey] = (0, $3e6197669829fe11$export$40bfa8c7b0832715)(props.selectedKey, props.defaultSelectedKey ?? null, props.onSelectionChange);
1205
+ let selectedKeys = (0, $jhfZc$useMemo)(() => selectedKey != null ? [
1206
+ selectedKey
1207
+ ] : [], [
1208
+ selectedKey
1209
+ ]);
1210
+ let { collection, disabledKeys, selectionManager } = (0, $b14b6f590b50af39$export$2f645645f7bca764)({
1211
+ ...props,
1212
+ selectionMode: "single",
1213
+ disallowEmptySelection: true,
1214
+ allowDuplicateSelectionEvents: true,
1215
+ selectedKeys,
1216
+ onSelectionChange: (keys) => {
1217
+ if (keys === "all") return;
1218
+ let key = keys.values().next().value ?? null;
1219
+ if (key === selectedKey && props.onSelectionChange) props.onSelectionChange(key);
1220
+ setSelectedKey(key);
1221
+ }
1222
+ });
1223
+ let selectedItem = selectedKey != null ? collection.getItem(selectedKey) : null;
1224
+ return {
1225
+ collection,
1226
+ disabledKeys,
1227
+ selectionManager,
1228
+ selectedKey,
1229
+ setSelectedKey,
1230
+ selectedItem
1231
+ };
1232
+ }
1233
+
1234
+ // ../../node_modules/react-stately/dist/private/menu/useMenuTriggerState.mjs
1235
+ import { useState as $aoDK0$useState } from "react";
1236
+ function $e3403870bfb691da$export$79fefeb1c2091ac3(props) {
1237
+ let overlayTriggerState = (0, $f11fb0bcf1b2687a$export$61c6a8c84e605fb6)(props);
1238
+ let [focusStrategy, setFocusStrategy] = (0, $aoDK0$useState)(null);
1239
+ let [expandedKeysStack, setExpandedKeysStack] = (0, $aoDK0$useState)([]);
1240
+ let closeAll = () => {
1241
+ setExpandedKeysStack([]);
1242
+ overlayTriggerState.close();
1243
+ };
1244
+ let openSubmenu = (triggerKey, level) => {
1245
+ setExpandedKeysStack((oldStack) => {
1246
+ if (level > oldStack.length) return oldStack;
1247
+ return [
1248
+ ...oldStack.slice(0, level),
1249
+ triggerKey
1250
+ ];
1251
+ });
1252
+ };
1253
+ let closeSubmenu = (triggerKey, level) => {
1254
+ setExpandedKeysStack((oldStack) => {
1255
+ let key = oldStack[level];
1256
+ if (key === triggerKey) return oldStack.slice(0, level);
1257
+ else return oldStack;
1258
+ });
1259
+ };
1260
+ return {
1261
+ focusStrategy,
1262
+ ...overlayTriggerState,
1263
+ open(focusStrategy2 = null) {
1264
+ setFocusStrategy(focusStrategy2);
1265
+ overlayTriggerState.open();
1266
+ },
1267
+ toggle(focusStrategy2 = null) {
1268
+ setFocusStrategy(focusStrategy2);
1269
+ overlayTriggerState.toggle();
1270
+ },
1271
+ close() {
1272
+ closeAll();
1273
+ },
1274
+ expandedKeysStack,
1275
+ openSubmenu,
1276
+ closeSubmenu
1277
+ };
1278
+ }
1279
+
1280
+ // ../../node_modules/react-stately/dist/private/radio/useRadioGroupState.mjs
1281
+ import { useMemo as $6Hs9a$useMemo, useState as $6Hs9a$useState } from "react";
1282
+ var $384704861d32dbed$var$instance = Math.round(Math.random() * 1e10);
1283
+ var $384704861d32dbed$var$i = 0;
1284
+ function $384704861d32dbed$export$bca9d026f8e704eb(props) {
1285
+ let name = (0, $6Hs9a$useMemo)(() => props.name || `radio-group-${$384704861d32dbed$var$instance}-${++$384704861d32dbed$var$i}`, [
1286
+ props.name
1287
+ ]);
1288
+ let [selectedValue, setSelected] = (0, $3e6197669829fe11$export$40bfa8c7b0832715)(props.value, props.defaultValue ?? null, props.onChange);
1289
+ let [initialValue] = (0, $6Hs9a$useState)(selectedValue);
1290
+ let [lastFocusedValue, setLastFocusedValue] = (0, $6Hs9a$useState)(null);
1291
+ let validation = (0, $fd2148440a13ec26$export$fc1a364ae1f3ff10)({
1292
+ ...props,
1293
+ value: selectedValue
1294
+ });
1295
+ let setSelectedValue = (value) => {
1296
+ if (!props.isReadOnly && !props.isDisabled) {
1297
+ setSelected(value);
1298
+ validation.commitValidation();
1299
+ }
1300
+ };
1301
+ let isInvalid = validation.displayValidation.isInvalid;
1302
+ return {
1303
+ ...validation,
1304
+ name,
1305
+ selectedValue,
1306
+ defaultSelectedValue: props.value !== void 0 ? initialValue : props.defaultValue ?? null,
1307
+ setSelectedValue,
1308
+ lastFocusedValue,
1309
+ setLastFocusedValue,
1310
+ isDisabled: props.isDisabled || false,
1311
+ isReadOnly: props.isReadOnly || false,
1312
+ isRequired: props.isRequired || false,
1313
+ validationState: props.validationState || (isInvalid ? "invalid" : null),
1314
+ isInvalid
1315
+ };
1316
+ }
1317
+
1318
+ // ../../node_modules/react-stately/dist/private/select/useSelectState.mjs
1319
+ import { useState as $5t5rb$useState, useMemo as $5t5rb$useMemo } from "react";
1320
+ function $29256f53a2edafe9$export$5159ec8b34d4ec12(props) {
1321
+ let { selectionMode = "single", shouldCloseOnSelect = selectionMode === "single" } = props;
1322
+ let triggerState = (0, $f11fb0bcf1b2687a$export$61c6a8c84e605fb6)(props);
1323
+ let [focusStrategy, setFocusStrategy] = (0, $5t5rb$useState)(null);
1324
+ let defaultValue = (0, $5t5rb$useMemo)(() => {
1325
+ return props.defaultValue !== void 0 ? props.defaultValue : selectionMode === "single" ? props.defaultSelectedKey ?? null : [];
1326
+ }, [
1327
+ props.defaultValue,
1328
+ props.defaultSelectedKey,
1329
+ selectionMode
1330
+ ]);
1331
+ let value = (0, $5t5rb$useMemo)(() => {
1332
+ return props.value !== void 0 ? props.value : selectionMode === "single" ? props.selectedKey : void 0;
1333
+ }, [
1334
+ props.value,
1335
+ props.selectedKey,
1336
+ selectionMode
1337
+ ]);
1338
+ let [controlledValue, setControlledValue] = (0, $3e6197669829fe11$export$40bfa8c7b0832715)(value, defaultValue, props.onChange);
1339
+ let displayValue = selectionMode === "single" && Array.isArray(controlledValue) ? controlledValue[0] : controlledValue;
1340
+ let setValue = (value2) => {
1341
+ if (selectionMode === "single") {
1342
+ let key = Array.isArray(value2) ? value2[0] ?? null : value2;
1343
+ setControlledValue(key);
1344
+ if (key !== displayValue) props.onSelectionChange?.(key);
1345
+ } else {
1346
+ let keys = [];
1347
+ if (Array.isArray(value2)) keys = value2;
1348
+ else if (value2 != null) keys = [
1349
+ value2
1350
+ ];
1351
+ setControlledValue(keys);
1352
+ }
1353
+ };
1354
+ let listState = (0, $b14b6f590b50af39$export$2f645645f7bca764)({
1355
+ ...props,
1356
+ selectionMode,
1357
+ disallowEmptySelection: selectionMode === "single",
1358
+ allowDuplicateSelectionEvents: true,
1359
+ selectedKeys: (0, $5t5rb$useMemo)(() => $29256f53a2edafe9$var$convertValue(displayValue), [
1360
+ displayValue
1361
+ ]),
1362
+ onSelectionChange: (keys) => {
1363
+ if (keys === "all") return;
1364
+ if (selectionMode === "single") {
1365
+ let key = keys.values().next().value ?? null;
1366
+ setValue(key);
1367
+ } else setValue([
1368
+ ...keys
1369
+ ]);
1370
+ if (shouldCloseOnSelect) triggerState.close();
1371
+ validationState.commitValidation();
1372
+ }
1373
+ });
1374
+ let selectedKey = listState.selectionManager.firstSelectedKey;
1375
+ let selectedItems = (0, $5t5rb$useMemo)(() => {
1376
+ return [
1377
+ ...listState.selectionManager.selectedKeys
1378
+ ].map((key) => listState.collection.getItem(key)).filter((item) => item != null);
1379
+ }, [
1380
+ listState.selectionManager.selectedKeys,
1381
+ listState.collection
1382
+ ]);
1383
+ let validationState = (0, $fd2148440a13ec26$export$fc1a364ae1f3ff10)({
1384
+ ...props,
1385
+ value: Array.isArray(displayValue) && displayValue.length === 0 ? null : displayValue
1386
+ });
1387
+ let [isFocused, setFocused] = (0, $5t5rb$useState)(false);
1388
+ let [initialValue] = (0, $5t5rb$useState)(displayValue);
1389
+ return {
1390
+ ...validationState,
1391
+ ...listState,
1392
+ ...triggerState,
1393
+ value: displayValue,
1394
+ defaultValue: defaultValue ?? initialValue,
1395
+ setValue,
1396
+ selectedKey,
1397
+ setSelectedKey: setValue,
1398
+ selectedItem: selectedItems[0] ?? null,
1399
+ selectedItems,
1400
+ defaultSelectedKey: props.defaultSelectedKey ?? (props.selectionMode === "single" ? initialValue : null),
1401
+ focusStrategy,
1402
+ open(focusStrategy2 = null) {
1403
+ if (listState.collection.size !== 0 || props.allowsEmptyCollection) {
1404
+ setFocusStrategy(focusStrategy2);
1405
+ triggerState.open();
1406
+ }
1407
+ },
1408
+ toggle(focusStrategy2 = null) {
1409
+ if (listState.collection.size !== 0 || props.allowsEmptyCollection) {
1410
+ setFocusStrategy(focusStrategy2);
1411
+ triggerState.toggle();
1412
+ }
1413
+ },
1414
+ isFocused,
1415
+ setFocused
1416
+ };
1417
+ }
1418
+ function $29256f53a2edafe9$var$convertValue(value) {
1419
+ if (value === void 0) return void 0;
1420
+ if (value === null) return [];
1421
+ return Array.isArray(value) ? value : [
1422
+ value
1423
+ ];
1424
+ }
1425
+
1426
+ // ../../node_modules/react-stately/dist/private/tabs/useTabListState.mjs
1427
+ import { useRef as $eOo4G$useRef, useEffect as $eOo4G$useEffect } from "react";
1428
+ function $caeb030f09a278a1$export$4ba071daf4e486(props) {
1429
+ let state = (0, $0fdb127d377ffd84$export$e7f05e985daf4b5f)({
1430
+ ...props,
1431
+ onSelectionChange: props.onSelectionChange ? (key) => {
1432
+ if (key != null) props.onSelectionChange?.(key);
1433
+ } : void 0,
1434
+ suppressTextValueWarning: true,
1435
+ defaultSelectedKey: props.defaultSelectedKey ?? $caeb030f09a278a1$var$findDefaultSelectedKey(props.collection, props.disabledKeys ? new Set(props.disabledKeys) : /* @__PURE__ */ new Set()) ?? void 0
1436
+ });
1437
+ let { selectionManager, collection, selectedKey: currentSelectedKey } = state;
1438
+ let lastSelectedKey = (0, $eOo4G$useRef)(currentSelectedKey);
1439
+ (0, $eOo4G$useEffect)(() => {
1440
+ let selectedKey = currentSelectedKey;
1441
+ if (props.selectedKey == null && (selectionManager.isEmpty || selectedKey == null || !collection.getItem(selectedKey))) {
1442
+ selectedKey = $caeb030f09a278a1$var$findDefaultSelectedKey(collection, state.disabledKeys);
1443
+ if (selectedKey != null)
1444
+ selectionManager.setSelectedKeys([
1445
+ selectedKey
1446
+ ]);
1447
+ }
1448
+ if (selectedKey != null && selectionManager.focusedKey == null || !selectionManager.isFocused && selectedKey !== lastSelectedKey.current) selectionManager.setFocusedKey(selectedKey);
1449
+ lastSelectedKey.current = selectedKey;
1450
+ });
1451
+ return {
1452
+ ...state,
1453
+ isDisabled: props.isDisabled || false
1454
+ };
1455
+ }
1456
+ function $caeb030f09a278a1$var$findDefaultSelectedKey(collection, disabledKeys) {
1457
+ let selectedKey = null;
1458
+ if (collection) {
1459
+ selectedKey = collection.getFirstKey();
1460
+ while (selectedKey != null && (disabledKeys.has(selectedKey) || collection.getItem(selectedKey)?.props?.isDisabled) && selectedKey !== collection.getLastKey()) selectedKey = collection.getKeyAfter(selectedKey);
1461
+ if (selectedKey != null && (disabledKeys.has(selectedKey) || collection.getItem(selectedKey)?.props?.isDisabled) && selectedKey === collection.getLastKey()) selectedKey = collection.getFirstKey();
1462
+ }
1463
+ return selectedKey;
1464
+ }
1465
+
1466
+ // ../../node_modules/react-stately/dist/private/toggle/useToggleState.mjs
1467
+ import { useState as $dAajM$useState } from "react";
1468
+ function $fd3c5e01e837dc20$export$8042c6c013fd5226(props = {}) {
1469
+ let { isReadOnly } = props;
1470
+ let [isSelected, setSelected] = (0, $3e6197669829fe11$export$40bfa8c7b0832715)(props.isSelected, props.defaultSelected || false, props.onChange);
1471
+ let [initialValue] = (0, $dAajM$useState)(isSelected);
1472
+ function updateSelected(value) {
1473
+ if (!isReadOnly) setSelected(value);
1474
+ }
1475
+ function toggleState() {
1476
+ if (!isReadOnly) setSelected(!isSelected);
1477
+ }
1478
+ return {
1479
+ isSelected,
1480
+ defaultSelected: props.defaultSelected ?? initialValue,
1481
+ setSelected: updateSelected,
1482
+ toggle: toggleState
1483
+ };
1484
+ }
1485
+
1486
+ // ../../node_modules/react-stately/dist/private/tooltip/useTooltipTriggerState.mjs
1487
+ import { useMemo as $auOuY$useMemo, useRef as $auOuY$useRef, useEffect as $auOuY$useEffect } from "react";
1488
+ var $3834487504f4fc00$var$TOOLTIP_DELAY = 1500;
1489
+ var $3834487504f4fc00$var$TOOLTIP_COOLDOWN = 500;
1490
+ var $3834487504f4fc00$var$tooltips = {};
1491
+ var $3834487504f4fc00$var$tooltipId = 0;
1492
+ var $3834487504f4fc00$var$globalWarmedUp = false;
1493
+ var $3834487504f4fc00$var$globalWarmUpTimeout = null;
1494
+ var $3834487504f4fc00$var$globalCooldownTimeout = null;
1495
+ function $3834487504f4fc00$export$4d40659c25ecb50b(props = {}) {
1496
+ let { delay = $3834487504f4fc00$var$TOOLTIP_DELAY, closeDelay = $3834487504f4fc00$var$TOOLTIP_COOLDOWN } = props;
1497
+ let { isOpen, open, close } = (0, $f11fb0bcf1b2687a$export$61c6a8c84e605fb6)(props);
1498
+ let id = (0, $auOuY$useMemo)(() => `${++$3834487504f4fc00$var$tooltipId}`, []);
1499
+ let closeTimeout = (0, $auOuY$useRef)(null);
1500
+ let closeCallback = (0, $auOuY$useRef)(close);
1501
+ let ensureTooltipEntry = () => {
1502
+ $3834487504f4fc00$var$tooltips[id] = hideTooltip;
1503
+ };
1504
+ let closeOpenTooltips = () => {
1505
+ for (let hideTooltipId in $3834487504f4fc00$var$tooltips) if (hideTooltipId !== id) {
1506
+ $3834487504f4fc00$var$tooltips[hideTooltipId](true);
1507
+ delete $3834487504f4fc00$var$tooltips[hideTooltipId];
1508
+ }
1509
+ };
1510
+ let showTooltip = () => {
1511
+ if (closeTimeout.current) clearTimeout(closeTimeout.current);
1512
+ closeTimeout.current = null;
1513
+ closeOpenTooltips();
1514
+ ensureTooltipEntry();
1515
+ $3834487504f4fc00$var$globalWarmedUp = true;
1516
+ open();
1517
+ if ($3834487504f4fc00$var$globalWarmUpTimeout) {
1518
+ clearTimeout($3834487504f4fc00$var$globalWarmUpTimeout);
1519
+ $3834487504f4fc00$var$globalWarmUpTimeout = null;
1520
+ }
1521
+ if ($3834487504f4fc00$var$globalCooldownTimeout) {
1522
+ clearTimeout($3834487504f4fc00$var$globalCooldownTimeout);
1523
+ $3834487504f4fc00$var$globalCooldownTimeout = null;
1524
+ }
1525
+ };
1526
+ let hideTooltip = (immediate) => {
1527
+ if (immediate || closeDelay <= 0) {
1528
+ if (closeTimeout.current) clearTimeout(closeTimeout.current);
1529
+ closeTimeout.current = null;
1530
+ closeCallback.current();
1531
+ } else if (!closeTimeout.current) closeTimeout.current = setTimeout(() => {
1532
+ closeTimeout.current = null;
1533
+ closeCallback.current();
1534
+ }, closeDelay);
1535
+ if ($3834487504f4fc00$var$globalWarmUpTimeout) {
1536
+ clearTimeout($3834487504f4fc00$var$globalWarmUpTimeout);
1537
+ $3834487504f4fc00$var$globalWarmUpTimeout = null;
1538
+ }
1539
+ if ($3834487504f4fc00$var$globalWarmedUp) {
1540
+ if ($3834487504f4fc00$var$globalCooldownTimeout) clearTimeout($3834487504f4fc00$var$globalCooldownTimeout);
1541
+ $3834487504f4fc00$var$globalCooldownTimeout = setTimeout(() => {
1542
+ delete $3834487504f4fc00$var$tooltips[id];
1543
+ $3834487504f4fc00$var$globalCooldownTimeout = null;
1544
+ $3834487504f4fc00$var$globalWarmedUp = false;
1545
+ }, Math.max($3834487504f4fc00$var$TOOLTIP_COOLDOWN, closeDelay));
1546
+ }
1547
+ };
1548
+ let warmupTooltip = () => {
1549
+ closeOpenTooltips();
1550
+ ensureTooltipEntry();
1551
+ if (!isOpen && !$3834487504f4fc00$var$globalWarmedUp) {
1552
+ if ($3834487504f4fc00$var$globalWarmUpTimeout) clearTimeout($3834487504f4fc00$var$globalWarmUpTimeout);
1553
+ $3834487504f4fc00$var$globalWarmUpTimeout = setTimeout(() => {
1554
+ $3834487504f4fc00$var$globalWarmUpTimeout = null;
1555
+ $3834487504f4fc00$var$globalWarmedUp = true;
1556
+ showTooltip();
1557
+ }, delay);
1558
+ } else if (!isOpen) showTooltip();
1559
+ };
1560
+ (0, $auOuY$useEffect)(() => {
1561
+ closeCallback.current = close;
1562
+ }, [
1563
+ close
1564
+ ]);
1565
+ (0, $auOuY$useEffect)(() => {
1566
+ return () => {
1567
+ if (closeTimeout.current) clearTimeout(closeTimeout.current);
1568
+ let tooltip = $3834487504f4fc00$var$tooltips[id];
1569
+ if (tooltip) delete $3834487504f4fc00$var$tooltips[id];
1570
+ };
1571
+ }, [
1572
+ id
1573
+ ]);
1574
+ return {
1575
+ isOpen,
1576
+ open: (immediate) => {
1577
+ if (!immediate && delay > 0 && !closeTimeout.current) warmupTooltip();
1578
+ else showTooltip();
1579
+ },
1580
+ close: hideTooltip
1581
+ };
1582
+ }
1583
+
1584
+ // ../../node_modules/react-stately/dist/private/tree/TreeCollection.mjs
1585
+ var $df1fcc684d3b021a$export$863faf230ee2118a = class {
1586
+ constructor(nodes, { expandedKeys } = {}) {
1587
+ this.keyMap = /* @__PURE__ */ new Map();
1588
+ this.firstKey = null;
1589
+ this.lastKey = null;
1590
+ this.iterable = nodes;
1591
+ expandedKeys = expandedKeys || /* @__PURE__ */ new Set();
1592
+ let visit = (node) => {
1593
+ this.keyMap.set(node.key, node);
1594
+ if (node.childNodes && (node.type === "section" || expandedKeys.has(node.key))) for (let child of node.childNodes) visit(child);
1595
+ };
1596
+ for (let node of nodes) visit(node);
1597
+ let last = null;
1598
+ let index = 0;
1599
+ for (let [key, node] of this.keyMap) {
1600
+ if (last) {
1601
+ last.nextKey = key;
1602
+ node.prevKey = last.key;
1603
+ } else {
1604
+ this.firstKey = key;
1605
+ node.prevKey = void 0;
1606
+ }
1607
+ if (node.type === "item") node.index = index++;
1608
+ last = node;
1609
+ last.nextKey = void 0;
1610
+ }
1611
+ this.lastKey = last?.key ?? null;
1612
+ }
1613
+ *[Symbol.iterator]() {
1614
+ yield* this.iterable;
1615
+ }
1616
+ get size() {
1617
+ return this.keyMap.size;
1618
+ }
1619
+ getKeys() {
1620
+ return this.keyMap.keys();
1621
+ }
1622
+ getKeyBefore(key) {
1623
+ let node = this.keyMap.get(key);
1624
+ return node ? node.prevKey ?? null : null;
1625
+ }
1626
+ getKeyAfter(key) {
1627
+ let node = this.keyMap.get(key);
1628
+ return node ? node.nextKey ?? null : null;
1629
+ }
1630
+ getFirstKey() {
1631
+ return this.firstKey;
1632
+ }
1633
+ getLastKey() {
1634
+ return this.lastKey;
1635
+ }
1636
+ getItem(key) {
1637
+ return this.keyMap.get(key) ?? null;
1638
+ }
1639
+ at(idx) {
1640
+ const keys = [
1641
+ ...this.getKeys()
1642
+ ];
1643
+ return this.getItem(keys[idx]);
1644
+ }
1645
+ };
1646
+
1647
+ // ../../node_modules/react-stately/dist/private/tree/useTreeState.mjs
1648
+ import { useMemo as $aXIpm$useMemo, useCallback as $aXIpm$useCallback, useEffect as $aXIpm$useEffect } from "react";
1649
+ function $6b915bde6cd300dd$export$728d6ba534403756(props) {
1650
+ let { onExpandedChange } = props;
1651
+ let [expandedKeys, setExpandedKeys] = (0, $3e6197669829fe11$export$40bfa8c7b0832715)(props.expandedKeys ? new Set(props.expandedKeys) : void 0, props.defaultExpandedKeys ? new Set(props.defaultExpandedKeys) : /* @__PURE__ */ new Set(), onExpandedChange);
1652
+ let selectionState = (0, $60f19cefd567a3e4$export$253fe78d46329472)(props);
1653
+ let disabledKeys = (0, $aXIpm$useMemo)(() => props.disabledKeys ? new Set(props.disabledKeys) : /* @__PURE__ */ new Set(), [
1654
+ props.disabledKeys
1655
+ ]);
1656
+ let tree = (0, $d03379b88399b8c5$export$6cd28814d92fa9c9)(props, (0, $aXIpm$useCallback)((nodes) => new (0, $df1fcc684d3b021a$export$863faf230ee2118a)(nodes, {
1657
+ expandedKeys
1658
+ }), [
1659
+ expandedKeys
1660
+ ]), null);
1661
+ (0, $aXIpm$useEffect)(() => {
1662
+ if (selectionState.focusedKey != null && !tree.getItem(selectionState.focusedKey)) selectionState.setFocusedKey(null);
1663
+ }, [
1664
+ tree,
1665
+ selectionState.focusedKey
1666
+ ]);
1667
+ let onToggle = (key) => {
1668
+ setExpandedKeys($6b915bde6cd300dd$var$toggleKey(expandedKeys, key));
1669
+ };
1670
+ return {
1671
+ collection: tree,
1672
+ expandedKeys,
1673
+ disabledKeys,
1674
+ toggleKey: onToggle,
1675
+ setExpandedKeys,
1676
+ selectionManager: new (0, $4a07ac835f260f78$export$6c8a5aaad13c9852)(tree, selectionState)
1677
+ };
1678
+ }
1679
+ function $6b915bde6cd300dd$var$toggleKey(set, key) {
1680
+ let res = new Set(set);
1681
+ if (res.has(key)) res.delete(key);
1682
+ else res.add(key);
1683
+ return res;
1684
+ }
1685
+
1686
+ // src/utils/a11y.ts
1687
+ import { isValidElement } from "react";
1688
+ function hasRenderableText(node) {
1689
+ if (node === null || node === void 0 || typeof node === "boolean") return false;
1690
+ if (typeof node === "string") return node.trim().length > 0;
1691
+ if (typeof node === "number") return true;
1692
+ if (Array.isArray(node)) return node.some(hasRenderableText);
1693
+ if (isValidElement(node)) {
1694
+ return hasRenderableText(node.props.children);
1695
+ }
1696
+ return false;
1697
+ }
1698
+ function getRenderableText(node) {
1699
+ if (node === null || node === void 0 || typeof node === "boolean") return "";
1700
+ if (typeof node === "string") return node;
1701
+ if (typeof node === "number") return String(node);
1702
+ if (Array.isArray(node)) return node.map(getRenderableText).join("");
1703
+ if (isValidElement(node)) {
1704
+ return getRenderableText(node.props.children);
1705
+ }
1706
+ return "";
1707
+ }
1708
+ function resolveAccessibleName(input) {
1709
+ if (input.ariaLabelledby) {
1710
+ return { "aria-labelledby": input.ariaLabelledby };
1711
+ }
1712
+ if (input.ariaLabel) {
1713
+ return { "aria-label": input.ariaLabel };
1714
+ }
1715
+ if (typeof input.label === "string" && input.label.trim().length > 0) {
1716
+ return { "aria-label": input.label };
1717
+ }
1718
+ for (const candidate of input.fallbacks ?? []) {
1719
+ if (typeof candidate === "string" && candidate.trim().length > 0) {
1720
+ return { "aria-label": candidate };
1721
+ }
1722
+ }
1723
+ if (process.env.NODE_ENV !== "production") {
1724
+ console.error(
1725
+ `[@octaviaflow/core ${input.componentName}] No accessible name. Pass a string \`label\`, or \`aria-label\`, or \`aria-labelledby\` so screen readers can announce this control.`
1726
+ );
1727
+ }
1728
+ return { "aria-label": `Unlabeled ${input.componentName}` };
1729
+ }
1730
+
1731
+ // src/components/Checkbox/Checkbox.tsx
1732
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
1733
+ var Checkbox = forwardRef2(function Checkbox2({
1734
+ checked,
1735
+ defaultChecked,
1736
+ onChange,
1737
+ indeterminate = false,
1738
+ disabled = false,
1739
+ label,
1740
+ description,
1741
+ error = false,
1742
+ errorMessage,
1743
+ size = "md",
1744
+ required,
1745
+ className,
1746
+ ...props
1747
+ }, forwardedRef) {
1748
+ const internalRef = useRef(null);
1749
+ useImperativeHandle(forwardedRef, () => internalRef.current);
1750
+ const state = $fd3c5e01e837dc20$export$8042c6c013fd5226({
1751
+ isSelected: checked,
1752
+ defaultSelected: defaultChecked,
1753
+ onChange
1754
+ });
1755
+ const reactId = useId2();
1756
+ const baseId = props.id ?? `ods-cb-${reactId}`;
1757
+ const descId = description ? `${baseId}-desc` : void 0;
1758
+ const errId = error && errorMessage ? `${baseId}-err` : void 0;
1759
+ const describedBy = [descId, errId].filter(Boolean).join(" ") || void 0;
1760
+ const ariaNameProps = resolveAccessibleName({
1761
+ label,
1762
+ ariaLabel: props["aria-label"],
1763
+ ariaLabelledby: props["aria-labelledby"],
1764
+ componentName: "Checkbox"
1765
+ });
1766
+ const { inputProps } = useCheckbox(
1767
+ {
1768
+ isSelected: state.isSelected,
1769
+ isIndeterminate: indeterminate,
1770
+ isDisabled: disabled,
1771
+ isRequired: required,
1772
+ isInvalid: error,
1773
+ onChange,
1774
+ // useCheckbox returns `name`/`value`/`form` in its `inputProps`. If
1775
+ // we let them fall through as `undefined`, the spread overwrites
1776
+ // the consumer's attrs. Pass them via the config so react-aria
1777
+ // emits real values.
1778
+ name: props.name,
1779
+ value: props.value,
1780
+ form: props.form,
1781
+ ...ariaNameProps
1782
+ },
1783
+ state,
1784
+ internalRef
1785
+ );
1786
+ const isChecked = state.isSelected;
1787
+ const {
1788
+ onClick: _onClick,
1789
+ onKeyDown: _onKeyDown,
1790
+ onKeyUp: _onKeyUp,
1791
+ onFocus: _onFocus,
1792
+ onBlur: _onBlur,
1793
+ ...passthroughProps
1794
+ } = props;
1795
+ return /* @__PURE__ */ jsxs2(
1796
+ "label",
1797
+ {
1798
+ className: cn(
1799
+ "ods-checkbox",
1800
+ `ods-checkbox--${size}`,
1801
+ disabled && "ods-checkbox--disabled",
1802
+ error && "ods-checkbox--error",
1803
+ description && "ods-checkbox--with-description",
1804
+ className
1805
+ ),
1806
+ children: [
1807
+ /* @__PURE__ */ jsx2(
1808
+ "input",
1809
+ {
1810
+ ...passthroughProps,
1811
+ ...inputProps,
1812
+ id: baseId,
1813
+ ref: internalRef,
1814
+ "aria-describedby": describedBy,
1815
+ className: "ods-checkbox__input"
1816
+ }
1817
+ ),
1818
+ /* @__PURE__ */ jsx2(
1819
+ "span",
1820
+ {
1821
+ className: cn(
1822
+ "ods-checkbox__box",
1823
+ isChecked && !indeterminate && "ods-checkbox__box--checked",
1824
+ indeterminate && "ods-checkbox__box--indeterminate"
1825
+ ),
1826
+ "aria-hidden": "true",
1827
+ children: indeterminate ? /* @__PURE__ */ jsx2(
1828
+ "svg",
1829
+ {
1830
+ className: "ods-checkbox__dash",
1831
+ viewBox: "0 0 12 12",
1832
+ fill: "none",
1833
+ xmlns: "http://www.w3.org/2000/svg",
1834
+ children: /* @__PURE__ */ jsx2(
1835
+ "line",
1836
+ {
1837
+ x1: "2",
1838
+ y1: "6",
1839
+ x2: "10",
1840
+ y2: "6",
1841
+ stroke: "currentColor",
1842
+ strokeWidth: "2",
1843
+ strokeLinecap: "round"
1844
+ }
1845
+ )
1846
+ }
1847
+ ) : /* @__PURE__ */ jsx2(
1848
+ "svg",
1849
+ {
1850
+ className: cn(
1851
+ "ods-checkbox__checkmark",
1852
+ isChecked && "ods-checkbox__checkmark--checked"
1853
+ ),
1854
+ viewBox: "0 0 12 12",
1855
+ fill: "none",
1856
+ xmlns: "http://www.w3.org/2000/svg",
1857
+ children: /* @__PURE__ */ jsx2(
1858
+ "path",
1859
+ {
1860
+ d: "M2 6L5 9L10 3",
1861
+ stroke: "currentColor",
1862
+ strokeWidth: "2",
1863
+ strokeLinecap: "round",
1864
+ strokeLinejoin: "round"
1865
+ }
1866
+ )
1867
+ }
1868
+ )
1869
+ }
1870
+ ),
1871
+ (label || description || errorMessage) && /* @__PURE__ */ jsxs2("span", { className: "ods-checkbox__text", children: [
1872
+ label && /* @__PURE__ */ jsxs2("span", { className: "ods-checkbox__label", children: [
1873
+ label,
1874
+ required && /* @__PURE__ */ jsx2("span", { className: "ods-checkbox__required", "aria-hidden": "true", children: "*" })
1875
+ ] }),
1876
+ description && /* @__PURE__ */ jsx2("span", { id: descId, className: "ods-checkbox__description", children: description }),
1877
+ error && errorMessage && /* @__PURE__ */ jsx2("span", { id: errId, className: "ods-checkbox__error-message", role: "alert", children: errorMessage })
1878
+ ] })
1879
+ ]
1880
+ }
1881
+ );
1882
+ });
1883
+ Checkbox.displayName = "Checkbox";
1884
+
1885
+ // src/components/Tooltip/Tooltip.tsx
1886
+ import { AnimatePresence as AnimatePresence2, motion as motion2 } from "framer-motion";
1887
+ import {
1888
+ cloneElement,
1889
+ isValidElement as isValidElement2,
1890
+ useCallback as useCallback2,
1891
+ useEffect,
1892
+ useId as useId3,
1893
+ useLayoutEffect,
1894
+ useRef as useRef2,
1895
+ useState as useState2
1896
+ } from "react";
1897
+ import { useTooltip, useTooltipTrigger } from "react-aria";
1898
+ import { createPortal } from "react-dom";
1899
+ import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1900
+ var FLIP = {
1901
+ top: "bottom",
1902
+ bottom: "top",
1903
+ left: "right",
1904
+ right: "left"
1905
+ };
1906
+ function placeOn(rect, tipRect, position, offset) {
1907
+ const cx = rect.left + rect.width / 2;
1908
+ const cy = rect.top + rect.height / 2;
1909
+ switch (position) {
1910
+ case "top":
1911
+ return {
1912
+ top: rect.top - tipRect.height - offset,
1913
+ left: cx - tipRect.width / 2
1914
+ };
1915
+ case "bottom":
1916
+ return { top: rect.bottom + offset, left: cx - tipRect.width / 2 };
1917
+ case "left":
1918
+ return {
1919
+ top: cy - tipRect.height / 2,
1920
+ left: rect.left - tipRect.width - offset
1921
+ };
1922
+ case "right":
1923
+ return { top: cy - tipRect.height / 2, left: rect.right + offset };
1924
+ }
1925
+ }
1926
+ function computePosition(rect, tipRect, position, offset, viewport) {
1927
+ const tryAt = (p) => {
1928
+ const c = placeOn(rect, tipRect, p, offset);
1929
+ const fits = c.top >= 0 && c.left >= 0 && c.top + tipRect.height <= viewport.height && c.left + tipRect.width <= viewport.width;
1930
+ return { ...c, position: p, fits };
1931
+ };
1932
+ const preferred = tryAt(position);
1933
+ if (preferred.fits) return preferred;
1934
+ const flipped = tryAt(FLIP[position]);
1935
+ if (flipped.fits) return flipped;
1936
+ const fallback = preferred;
1937
+ const clampedLeft = Math.max(4, Math.min(fallback.left, viewport.width - tipRect.width - 4));
1938
+ const clampedTop = Math.max(4, Math.min(fallback.top, viewport.height - tipRect.height - 4));
1939
+ return { top: clampedTop, left: clampedLeft, position: fallback.position };
1940
+ }
1941
+ var animVariants = {
1942
+ top: { initial: { opacity: 0, y: 4 }, animate: { opacity: 1, y: 0 } },
1943
+ bottom: { initial: { opacity: 0, y: -4 }, animate: { opacity: 1, y: 0 } },
1944
+ left: { initial: { opacity: 0, x: 4 }, animate: { opacity: 1, x: 0 } },
1945
+ right: { initial: { opacity: 0, x: -4 }, animate: { opacity: 1, x: 0 } }
1946
+ };
1947
+ function TooltipContent({
1948
+ state,
1949
+ content,
1950
+ position,
1951
+ triggerRef,
1952
+ className,
1953
+ offset,
1954
+ tooltipId
1955
+ }) {
1956
+ const { tooltipProps } = useTooltip({ isOpen: state.isOpen }, state);
1957
+ const tipRef = useRef2(null);
1958
+ const [coords, setCoords] = useState2(null);
1959
+ const reposition = useCallback2(() => {
1960
+ if (!triggerRef.current || !tipRef.current) return;
1961
+ const trigRect = triggerRef.current.getBoundingClientRect();
1962
+ const tipRect = tipRef.current.getBoundingClientRect();
1963
+ const viewport = {
1964
+ width: window.innerWidth || document.documentElement.clientWidth,
1965
+ height: window.innerHeight || document.documentElement.clientHeight
1966
+ };
1967
+ setCoords(computePosition(trigRect, tipRect, position, offset, viewport));
1968
+ }, [triggerRef, position, offset]);
1969
+ useLayoutEffect(() => {
1970
+ if (!state.isOpen) return;
1971
+ reposition();
1972
+ const id = requestAnimationFrame(reposition);
1973
+ return () => cancelAnimationFrame(id);
1974
+ }, [state.isOpen, reposition]);
1975
+ useEffect(() => {
1976
+ if (!state.isOpen) return;
1977
+ const handler = () => reposition();
1978
+ window.addEventListener("scroll", handler, true);
1979
+ window.addEventListener("resize", handler);
1980
+ return () => {
1981
+ window.removeEventListener("scroll", handler, true);
1982
+ window.removeEventListener("resize", handler);
1983
+ };
1984
+ }, [state.isOpen, reposition]);
1985
+ const resolvedPos = coords?.position ?? position;
1986
+ const variants = animVariants[resolvedPos];
1987
+ const {
1988
+ onDrag: _onDrag,
1989
+ onDragStart: _onDragStart,
1990
+ onDragEnd: _onDragEnd,
1991
+ onAnimationStart: _onAnimationStart,
1992
+ ...safeTipProps
1993
+ } = tooltipProps;
1994
+ const portalContent = /* @__PURE__ */ jsx3(AnimatePresence2, { children: state.isOpen && /* @__PURE__ */ jsx3(
1995
+ "div",
1996
+ {
1997
+ className: "ods-tooltip__wrapper",
1998
+ style: {
1999
+ position: "fixed",
2000
+ zIndex: 1500,
2001
+ top: coords?.top ?? -9999,
2002
+ left: coords?.left ?? -9999,
2003
+ visibility: coords ? "visible" : "hidden",
2004
+ pointerEvents: "none"
2005
+ },
2006
+ children: /* @__PURE__ */ jsxs3(
2007
+ motion2.div,
2008
+ {
2009
+ ref: tipRef,
2010
+ ...safeTipProps,
2011
+ id: tooltipId,
2012
+ role: "tooltip",
2013
+ "data-position": resolvedPos,
2014
+ className: cn("ods-tooltip", className),
2015
+ initial: variants.initial,
2016
+ animate: variants.animate,
2017
+ exit: { opacity: 0 },
2018
+ transition: { duration: 0.15, ease: "easeOut" },
2019
+ children: [
2020
+ content,
2021
+ /* @__PURE__ */ jsx3("span", { className: "ods-tooltip__arrow", "aria-hidden": "true" })
2022
+ ]
2023
+ }
2024
+ )
2025
+ }
2026
+ ) });
2027
+ if (typeof document === "undefined") return null;
2028
+ return createPortal(portalContent, document.body);
2029
+ }
2030
+ function mergeRefs(...refs) {
2031
+ return (node) => {
2032
+ for (const r of refs) {
2033
+ if (!r) continue;
2034
+ if (typeof r === "function") r(node);
2035
+ else r.current = node;
2036
+ }
2037
+ };
2038
+ }
2039
+ function mergeHandler(childHandler, ariaHandler) {
2040
+ if (!childHandler && !ariaHandler) return void 0;
2041
+ return (e) => {
2042
+ childHandler?.(e);
2043
+ if (!e.defaultPrevented) ariaHandler?.(e);
2044
+ };
2045
+ }
2046
+ function Tooltip({
2047
+ content,
2048
+ position = "top",
2049
+ delay = 200,
2050
+ offset = 8,
2051
+ disabled = false,
2052
+ id: providedId,
2053
+ children,
2054
+ className
2055
+ }) {
2056
+ const reactId = useId3();
2057
+ const tooltipId = providedId ?? `ods-tooltip-${reactId}`;
2058
+ const triggerRef = useRef2(null);
2059
+ const state = $3834487504f4fc00$export$4d40659c25ecb50b({ delay });
2060
+ const { triggerProps } = useTooltipTrigger({ delay, isDisabled: disabled }, state, triggerRef);
2061
+ if (!isValidElement2(children)) {
2062
+ return /* @__PURE__ */ jsx3(Fragment, { children });
2063
+ }
2064
+ const childProps = children.props;
2065
+ const childRef = childProps.ref ?? children.ref;
2066
+ const merged = { ...childProps };
2067
+ for (const [key, value] of Object.entries(triggerProps)) {
2068
+ if (key.startsWith("on") && typeof value === "function") {
2069
+ merged[key] = mergeHandler(childProps[key], value);
2070
+ } else {
2071
+ merged[key] = value;
2072
+ }
2073
+ }
2074
+ merged.ref = mergeRefs(triggerRef, childRef);
2075
+ merged["aria-describedby"] = [childProps["aria-describedby"], tooltipId].filter(Boolean).join(" ");
2076
+ return /* @__PURE__ */ jsxs3(Fragment, { children: [
2077
+ cloneElement(children, merged),
2078
+ !disabled && /* @__PURE__ */ jsx3(
2079
+ TooltipContent,
2080
+ {
2081
+ state,
2082
+ content,
2083
+ position,
2084
+ triggerRef,
2085
+ offset,
2086
+ className,
2087
+ tooltipId
2088
+ }
2089
+ )
2090
+ ] });
2091
+ }
2092
+ Tooltip.displayName = "Tooltip";
2093
+
2094
+ // src/components/Button/Button.tsx
2095
+ import { motion as motion3, useReducedMotion as useReducedMotion2 } from "framer-motion";
2096
+ import {
2097
+ forwardRef as forwardRef4,
2098
+ useImperativeHandle as useImperativeHandle2,
2099
+ useRef as useRef3
2100
+ } from "react";
2101
+ import { useButton } from "react-aria";
2102
+
2103
+ // src/utils/Slot.tsx
2104
+ import {
2105
+ Children,
2106
+ cloneElement as cloneElement2,
2107
+ forwardRef as forwardRef3,
2108
+ isValidElement as isValidElement3
2109
+ } from "react";
2110
+
2111
+ // src/utils/composeRefs.ts
2112
+ function composeRefs(...refs) {
2113
+ return (node) => {
2114
+ for (const ref of refs) {
2115
+ if (typeof ref === "function") {
2116
+ ref(node);
2117
+ } else if (ref != null) {
2118
+ ref.current = node;
2119
+ }
2120
+ }
2121
+ };
2122
+ }
2123
+
2124
+ // src/utils/Slot.tsx
2125
+ var Slot = forwardRef3(function Slot2({ children, ...slotProps }, forwardedRef) {
2126
+ if (!isValidElement3(children)) {
2127
+ return null;
2128
+ }
2129
+ const child = Children.only(children);
2130
+ const childProps = child.props ?? {};
2131
+ const childRef = child.ref;
2132
+ return cloneElement2(child, {
2133
+ ...mergeProps(slotProps, childProps),
2134
+ ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef
2135
+ });
2136
+ });
2137
+ function mergeProps(slotProps, childProps) {
2138
+ const merged = { ...slotProps, ...childProps };
2139
+ for (const key of Object.keys(slotProps)) {
2140
+ const slotValue = slotProps[key];
2141
+ const childValue = childProps[key];
2142
+ if (/^on[A-Z]/.test(key) && typeof slotValue === "function" && typeof childValue === "function") {
2143
+ merged[key] = (...args) => {
2144
+ slotValue(...args);
2145
+ const event = args[0];
2146
+ if (event?.defaultPrevented) return;
2147
+ childValue(...args);
2148
+ };
2149
+ continue;
2150
+ }
2151
+ if (key === "className") {
2152
+ merged.className = [slotValue, childValue].filter(Boolean).join(" ");
2153
+ continue;
2154
+ }
2155
+ if (key === "style") {
2156
+ merged.style = {
2157
+ ...slotValue,
2158
+ ...childValue
2159
+ };
2160
+ }
2161
+ }
2162
+ return merged;
2163
+ }
2164
+
2165
+ // src/components/Button/Button.tsx
2166
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
2167
+ var Button = forwardRef4(function Button2({
2168
+ variant = "primary",
2169
+ size = "md",
2170
+ loading = false,
2171
+ loadingText,
2172
+ loadingLabel = "Loading",
2173
+ disabled = false,
2174
+ leftIcon,
2175
+ rightIcon,
2176
+ fullWidth = false,
2177
+ pressed,
2178
+ asChild = false,
2179
+ className,
2180
+ children,
2181
+ type,
2182
+ cursor,
2183
+ style,
2184
+ ...props
2185
+ }, forwardedRef) {
2186
+ const ref = useRef3(null);
2187
+ useImperativeHandle2(forwardedRef, () => ref.current);
2188
+ const isDisabled = disabled || loading;
2189
+ const prefersReducedMotion = useReducedMotion2();
2190
+ const hasAction = Boolean(props.onClick) || type === "submit" || type === "reset";
2191
+ const resolvedCursor = cursor ?? (disabled ? "not-allowed" : loading ? "progress" : hasAction ? "pointer" : "default");
2192
+ const resolvedType = type ?? "button";
2193
+ const hasVisibleText = hasRenderableText(children);
2194
+ const needsAriaName = !hasVisibleText && !asChild;
2195
+ const ariaNameProps = needsAriaName ? resolveAccessibleName({
2196
+ ariaLabel: props["aria-label"],
2197
+ ariaLabelledby: props["aria-labelledby"],
2198
+ componentName: "Button"
2199
+ }) : void 0;
2200
+ const onClick = props.onClick;
2201
+ const onPress = onClick ? (press) => {
2202
+ const event = press;
2203
+ if (typeof event.stopPropagation !== "function") event.stopPropagation = () => {
2204
+ };
2205
+ if (typeof event.preventDefault !== "function") event.preventDefault = () => {
2206
+ };
2207
+ if (event.currentTarget === void 0) event.currentTarget = event.target;
2208
+ onClick(event);
2209
+ } : void 0;
2210
+ const { buttonProps } = useButton(
2211
+ {
2212
+ isDisabled,
2213
+ onPress,
2214
+ type: resolvedType,
2215
+ ...ariaNameProps ?? {}
2216
+ },
2217
+ ref
2218
+ );
2219
+ const { onDrag, onDragStart, onDragEnd, onAnimationStart, ...safeButtonProps } = buttonProps;
2220
+ const {
2221
+ onClick: _onClick,
2222
+ onKeyDown: _onKeyDown,
2223
+ onKeyUp: _onKeyUp,
2224
+ onMouseDown: _onMouseDown,
2225
+ onPointerDown: _onPointerDown,
2226
+ onPointerUp: _onPointerUp,
2227
+ onFocus: _onFocus,
2228
+ onBlur: _onBlur,
2229
+ ...passthroughProps
2230
+ } = props;
2231
+ const rootClassName = cn(
2232
+ "ods-btn",
2233
+ `ods-btn--${variant}`,
2234
+ `ods-btn--${size}`,
2235
+ loading && "ods-btn--loading",
2236
+ fullWidth && "ods-btn--full",
2237
+ pressed && "ods-btn--pressed",
2238
+ className
2239
+ );
2240
+ if (asChild) {
2241
+ return /* @__PURE__ */ jsx4(
2242
+ Slot,
2243
+ {
2244
+ ...passthroughProps,
2245
+ ref: forwardedRef,
2246
+ className: rootClassName,
2247
+ style: { cursor: resolvedCursor, ...style },
2248
+ "aria-pressed": pressed,
2249
+ "aria-disabled": isDisabled || void 0,
2250
+ children
2251
+ }
2252
+ );
2253
+ }
2254
+ const visibleLabel = loading && loadingText !== void 0 ? loadingText : children;
2255
+ return /* @__PURE__ */ jsx4(
2256
+ motion3.button,
2257
+ {
2258
+ ...passthroughProps,
2259
+ ...safeButtonProps,
2260
+ type: resolvedType,
2261
+ ref,
2262
+ className: rootClassName,
2263
+ style: { cursor: resolvedCursor, ...style },
2264
+ "data-loading": loading || void 0,
2265
+ "aria-busy": loading || void 0,
2266
+ "aria-pressed": pressed,
2267
+ whileTap: isDisabled || prefersReducedMotion ? void 0 : { scale: 0.97 },
2268
+ transition: { duration: 0.1 },
2269
+ children: /* @__PURE__ */ jsxs4("span", { className: "ods-btn__content", children: [
2270
+ loading ? /* @__PURE__ */ jsx4(
2271
+ "span",
2272
+ {
2273
+ className: "ods-btn__icon ods-btn__icon--left ods-btn__icon--spinner",
2274
+ role: "status",
2275
+ "aria-label": loadingLabel,
2276
+ children: /* @__PURE__ */ jsx4("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: /* @__PURE__ */ jsx4(
2277
+ "circle",
2278
+ {
2279
+ cx: "12",
2280
+ cy: "12",
2281
+ r: "10",
2282
+ fill: "none",
2283
+ stroke: "currentColor",
2284
+ strokeWidth: "2.5",
2285
+ strokeLinecap: "round",
2286
+ strokeDasharray: "32",
2287
+ strokeDashoffset: "12"
2288
+ }
2289
+ ) })
2290
+ }
2291
+ ) : leftIcon && /* @__PURE__ */ jsx4("span", { className: "ods-btn__icon ods-btn__icon--left", children: leftIcon }),
2292
+ visibleLabel != null && visibleLabel !== false && /* @__PURE__ */ jsx4("span", { className: "ods-btn__label", children: visibleLabel }),
2293
+ rightIcon && !loading && /* @__PURE__ */ jsx4("span", { className: "ods-btn__icon ods-btn__icon--right", children: rightIcon })
2294
+ ] })
2295
+ }
2296
+ );
2297
+ });
2298
+ Button.displayName = "Button";
2299
+
2300
+ // src/components/Input/Input.tsx
2301
+ import { CloseIcon } from "@octaviaflow/icons";
2302
+ import {
2303
+ forwardRef as forwardRef5,
2304
+ useId as useId4,
2305
+ useImperativeHandle as useImperativeHandle3,
2306
+ useRef as useRef4
2307
+ } from "react";
2308
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
2309
+ var CLEAR_GLYPH = /* @__PURE__ */ jsx5(CloseIcon, { width: 12, height: 12, "aria-hidden": "true" });
2310
+ var Input = forwardRef5(
2311
+ ({
2312
+ type = "text",
2313
+ size = "md",
2314
+ error = false,
2315
+ errorMessage,
2316
+ label,
2317
+ helperText,
2318
+ leftIcon,
2319
+ rightIcon,
2320
+ clearable,
2321
+ onClear,
2322
+ shortcutHint,
2323
+ disabled = false,
2324
+ required,
2325
+ id,
2326
+ className,
2327
+ value,
2328
+ defaultValue,
2329
+ onChange,
2330
+ onKeyDown,
2331
+ ...props
2332
+ }, forwardedRef) => {
2333
+ const innerRef = useRef4(null);
2334
+ useImperativeHandle3(forwardedRef, () => innerRef.current);
2335
+ const reactId = useId4();
2336
+ const inputId = id ?? `${reactId}-input`;
2337
+ const errorId = `${reactId}-err`;
2338
+ const helperId = `${reactId}-help`;
2339
+ const isControlled = value !== void 0;
2340
+ const isClearable = (clearable ?? type === "search") && !disabled;
2341
+ const isSearch = type === "search";
2342
+ const currentValue = isControlled ? String(value ?? "") : innerRef.current?.value ?? String(defaultValue ?? "");
2343
+ const showClear = isClearable && currentValue.length > 0;
2344
+ const clearValue = () => {
2345
+ const el = innerRef.current;
2346
+ if (el && !isControlled) {
2347
+ const setter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set;
2348
+ setter?.call(el, "");
2349
+ el.dispatchEvent(new Event("input", { bubbles: true }));
2350
+ }
2351
+ onClear?.();
2352
+ el?.focus();
2353
+ };
2354
+ const handleClear = (e) => {
2355
+ e.preventDefault();
2356
+ e.stopPropagation();
2357
+ clearValue();
2358
+ };
2359
+ const handleKeyDown = (e) => {
2360
+ onKeyDown?.(e);
2361
+ if (e.defaultPrevented) return;
2362
+ if (isClearable && isSearch && e.key === "Escape" && currentValue) {
2363
+ e.preventDefault();
2364
+ clearValue();
2365
+ }
2366
+ };
2367
+ const describedBy = error && errorMessage ? errorId : helperText ? helperId : void 0;
2368
+ return /* @__PURE__ */ jsxs5(
2369
+ "div",
2370
+ {
2371
+ className: cn(
2372
+ "ods-input",
2373
+ `ods-input--${size}`,
2374
+ error && "ods-input--error",
2375
+ disabled && "ods-input--disabled",
2376
+ isSearch && "ods-input--search",
2377
+ className
2378
+ ),
2379
+ children: [
2380
+ label && /* @__PURE__ */ jsxs5("label", { htmlFor: inputId, className: "ods-input__label", children: [
2381
+ label,
2382
+ required && /* @__PURE__ */ jsx5("span", { className: "ods-input__required", "aria-hidden": "true", children: "*" })
2383
+ ] }),
2384
+ /* @__PURE__ */ jsxs5("div", { className: "ods-input__wrapper", children: [
2385
+ leftIcon && /* @__PURE__ */ jsx5("span", { className: "ods-input__icon--left", "aria-hidden": "true", children: leftIcon }),
2386
+ /* @__PURE__ */ jsx5(
2387
+ "input",
2388
+ {
2389
+ ...props,
2390
+ id: inputId,
2391
+ ref: innerRef,
2392
+ type,
2393
+ disabled,
2394
+ required,
2395
+ value,
2396
+ defaultValue,
2397
+ onChange,
2398
+ onKeyDown: handleKeyDown,
2399
+ className: cn(
2400
+ "ods-input__field",
2401
+ leftIcon && "ods-input__field--with-left-icon",
2402
+ (rightIcon || showClear || shortcutHint) && "ods-input__field--with-right-icon",
2403
+ showClear && shortcutHint && "ods-input__field--with-right-actions"
2404
+ ),
2405
+ "aria-invalid": error || void 0,
2406
+ "aria-required": required || void 0,
2407
+ "aria-describedby": describedBy
2408
+ }
2409
+ ),
2410
+ /* @__PURE__ */ jsxs5("span", { className: "ods-input__right", children: [
2411
+ showClear && /* @__PURE__ */ jsx5(
2412
+ "button",
2413
+ {
2414
+ type: "button",
2415
+ className: "ods-input__clear",
2416
+ onClick: handleClear,
2417
+ "aria-label": "Clear",
2418
+ tabIndex: -1,
2419
+ children: CLEAR_GLYPH
2420
+ }
2421
+ ),
2422
+ shortcutHint && !showClear && /* @__PURE__ */ jsx5("span", { className: "ods-input__kbd", "aria-hidden": "true", children: shortcutHint }),
2423
+ rightIcon && !showClear && !shortcutHint && /* @__PURE__ */ jsx5("span", { className: "ods-input__icon--right", "aria-hidden": "true", children: rightIcon })
2424
+ ] })
2425
+ ] }),
2426
+ error && errorMessage && /* @__PURE__ */ jsx5("div", { id: errorId, className: "ods-input__error-message", role: "alert", children: errorMessage }),
2427
+ !error && helperText && /* @__PURE__ */ jsx5("div", { id: helperId, className: "ods-input__helper", children: helperText })
2428
+ ]
2429
+ }
2430
+ );
2431
+ }
2432
+ );
2433
+ Input.displayName = "Input";
2434
+
2435
+ // src/components/Select/Select.tsx
2436
+ import { CheckmarkIcon, ChevronDownIcon as ChevronDownIcon2 } from "@octaviaflow/icons";
2437
+ import { AnimatePresence as AnimatePresence3, motion as motion4 } from "framer-motion";
2438
+ import {
2439
+ forwardRef as forwardRef6,
2440
+ useCallback as useCallback3,
2441
+ useEffect as useEffect2,
2442
+ useId as useId5,
2443
+ useMemo,
2444
+ useRef as useRef5,
2445
+ useState as useState3
2446
+ } from "react";
2447
+ import { HiddenSelect, useButton as useButton2, useListBox, useOption, useSelect } from "react-aria";
2448
+ import { createPortal as createPortal2 } from "react-dom";
2449
+ import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
2450
+ function OverflowTooltip({
2451
+ enabled,
2452
+ content,
2453
+ children
2454
+ }) {
2455
+ if (!enabled || content == null || content === "") return children;
2456
+ return /* @__PURE__ */ jsx6(Tooltip, { content, children });
2457
+ }
2458
+ function ListBox(props) {
2459
+ const ref = useRef5(null);
2460
+ const { listBoxRef = ref, state, showCheckmark, showOverflowTooltips } = props;
2461
+ const { listBoxProps } = useListBox(props, state, listBoxRef);
2462
+ return /* @__PURE__ */ jsx6("ul", { ...listBoxProps, ref: listBoxRef, className: "ods-select__options", children: [...state.collection].map((item) => /* @__PURE__ */ jsx6(
2463
+ Option,
2464
+ {
2465
+ item,
2466
+ state,
2467
+ showCheckmark,
2468
+ showOverflowTooltips
2469
+ },
2470
+ item.key
2471
+ )) });
2472
+ }
2473
+ function Option({
2474
+ item,
2475
+ state,
2476
+ showCheckmark,
2477
+ showOverflowTooltips
2478
+ }) {
2479
+ const ref = useRef5(null);
2480
+ const { optionProps, isSelected, isFocused, isDisabled } = useOption(
2481
+ { key: item.key },
2482
+ state,
2483
+ ref
2484
+ );
2485
+ const raw = item.value;
2486
+ const option = raw?.value ?? raw;
2487
+ const tooltipContent = option?.description ? /* @__PURE__ */ jsxs6(Fragment2, { children: [
2488
+ /* @__PURE__ */ jsx6("span", { children: option.label }),
2489
+ /* @__PURE__ */ jsx6("br", {}),
2490
+ /* @__PURE__ */ jsx6("span", { style: { opacity: 0.75 }, children: option.description })
2491
+ ] }) : option?.label;
2492
+ return /* @__PURE__ */ jsx6(OverflowTooltip, { enabled: !!showOverflowTooltips, content: tooltipContent, children: /* @__PURE__ */ jsxs6(
2493
+ "li",
2494
+ {
2495
+ ...optionProps,
2496
+ ref,
2497
+ className: cn(
2498
+ "ods-select__option",
2499
+ isFocused && "ods-select__option--highlighted",
2500
+ isSelected && "ods-select__option--selected",
2501
+ isDisabled && "ods-select__option--disabled"
2502
+ ),
2503
+ children: [
2504
+ option?.icon && /* @__PURE__ */ jsx6("span", { className: "ods-select__option-icon", children: option.icon }),
2505
+ /* @__PURE__ */ jsxs6("span", { className: "ods-select__option-text", children: [
2506
+ /* @__PURE__ */ jsx6("span", { className: "ods-select__option-label", children: item.rendered }),
2507
+ option?.description && /* @__PURE__ */ jsx6("span", { className: "ods-select__option-desc", children: option.description })
2508
+ ] }),
2509
+ isSelected && showCheckmark && /* @__PURE__ */ jsx6("span", { className: "ods-select__check", "aria-hidden": "true", children: /* @__PURE__ */ jsx6(CheckmarkIcon, { size: "xs", tone: "accent" }) })
2510
+ ]
2511
+ }
2512
+ ) });
2513
+ }
2514
+ var DEFAULT_SELECT_PLACEHOLDER = "Select an option...";
2515
+ var Select = forwardRef6(function Select2({
2516
+ options,
2517
+ value,
2518
+ defaultValue,
2519
+ onChange,
2520
+ placeholder = DEFAULT_SELECT_PLACEHOLDER,
2521
+ searchable = false,
2522
+ label,
2523
+ error = false,
2524
+ errorMessage,
2525
+ helperText,
2526
+ disabled = false,
2527
+ size = "md",
2528
+ className,
2529
+ name,
2530
+ required,
2531
+ id: providedId,
2532
+ form,
2533
+ autoFocus,
2534
+ "aria-label": ariaLabel,
2535
+ "aria-labelledby": ariaLabelledBy,
2536
+ "aria-describedby": consumerDescribedBy,
2537
+ showCheckmark = false,
2538
+ closeOnOutsideClick = true,
2539
+ showOverflowTooltips = false,
2540
+ dropdownMinWidth
2541
+ }, forwardedRef) {
2542
+ const triggerRef = useRef5(null);
2543
+ const listBoxRef = useRef5(null);
2544
+ const dropdownRef = useRef5(null);
2545
+ const searchRef = useRef5(null);
2546
+ const [searchQuery, setSearchQuery] = useState3("");
2547
+ const [dropdownPos, setDropdownPos] = useState3({ left: 0, width: 0, maxHeight: 240, direction: "down" });
2548
+ const setTriggerRef = (node) => {
2549
+ triggerRef.current = node;
2550
+ if (typeof forwardedRef === "function") forwardedRef(node);
2551
+ else if (forwardedRef) forwardedRef.current = node;
2552
+ };
2553
+ const reactId = useId5();
2554
+ const baseId = providedId ?? `ods-select-${reactId}`;
2555
+ const hintId = error || helperText ? `${baseId}-hint` : void 0;
2556
+ const describedBy = [consumerDescribedBy, hintId].filter(Boolean).join(" ") || void 0;
2557
+ const filteredOptions = useMemo(() => {
2558
+ if (!searchable || !searchQuery) return options;
2559
+ const q = searchQuery.toLowerCase();
2560
+ return options.filter(
2561
+ (o) => o.label.toLowerCase().includes(q) || o.description?.toLowerCase().includes(q)
2562
+ );
2563
+ }, [options, searchQuery, searchable]);
2564
+ const ariaNameProps = useMemo(
2565
+ () => resolveAccessibleName({
2566
+ label,
2567
+ ariaLabel,
2568
+ ariaLabelledby: ariaLabelledBy,
2569
+ componentName: "Select",
2570
+ fallbacks: [
2571
+ placeholder && placeholder !== DEFAULT_SELECT_PLACEHOLDER ? placeholder : void 0
2572
+ ]
2573
+ }),
2574
+ [label, ariaLabel, ariaLabelledBy, placeholder]
2575
+ );
2576
+ const ariaProps = useMemo(() => {
2577
+ const items = filteredOptions.map((o) => ({
2578
+ key: o.value,
2579
+ label: o.label,
2580
+ value: o,
2581
+ isDisabled: o.disabled
2582
+ }));
2583
+ const props = {
2584
+ // Visible string label when present; otherwise rely on the aria-*
2585
+ // props for screen-reader name.
2586
+ label: typeof label === "string" ? label : void 0,
2587
+ ...ariaNameProps,
2588
+ items,
2589
+ children: (item) => /* @__PURE__ */ jsx6($05678f3aee5e7d1a$export$6d08773d2e66f8f2, { textValue: item.label, children: item.label }, item.key),
2590
+ isDisabled: disabled,
2591
+ onSelectionChange: (key) => {
2592
+ onChange?.(String(key));
2593
+ setSearchQuery("");
2594
+ }
2595
+ };
2596
+ if (value !== void 0) {
2597
+ props.selectedKey = value;
2598
+ }
2599
+ if (defaultValue !== void 0) {
2600
+ props.defaultSelectedKey = defaultValue;
2601
+ }
2602
+ return props;
2603
+ }, [filteredOptions, label, disabled, value, defaultValue, onChange, ariaNameProps]);
2604
+ const state = $29256f53a2edafe9$export$5159ec8b34d4ec12(ariaProps);
2605
+ const { triggerProps, menuProps } = useSelect(ariaProps, state, triggerRef);
2606
+ const { buttonProps } = useButton2(triggerProps, triggerRef);
2607
+ const updatePosition = useCallback3(() => {
2608
+ if (!triggerRef.current) return;
2609
+ const rect = triggerRef.current.getBoundingClientRect();
2610
+ const viewportH = window.innerHeight;
2611
+ const margin = 8;
2612
+ const gap = 4;
2613
+ const spaceBelow = viewportH - rect.bottom - gap - margin;
2614
+ const spaceAbove = rect.top - gap - margin;
2615
+ const PREFERRED_MIN = 200;
2616
+ const openUp = spaceBelow < PREFERRED_MIN && spaceAbove > spaceBelow;
2617
+ setDropdownPos({
2618
+ ...openUp ? { bottom: viewportH - rect.top + gap } : { top: rect.bottom + gap },
2619
+ left: rect.left,
2620
+ width: rect.width,
2621
+ maxHeight: Math.max(120, openUp ? spaceAbove : spaceBelow),
2622
+ direction: openUp ? "up" : "down"
2623
+ });
2624
+ }, []);
2625
+ useEffect2(() => {
2626
+ if (state.isOpen) {
2627
+ updatePosition();
2628
+ window.addEventListener("scroll", updatePosition, true);
2629
+ window.addEventListener("resize", updatePosition);
2630
+ return () => {
2631
+ window.removeEventListener("scroll", updatePosition, true);
2632
+ window.removeEventListener("resize", updatePosition);
2633
+ };
2634
+ }
2635
+ }, [state.isOpen, updatePosition]);
2636
+ useEffect2(() => {
2637
+ if (state.isOpen && searchable && searchRef.current) {
2638
+ requestAnimationFrame(() => searchRef.current?.focus());
2639
+ }
2640
+ }, [state.isOpen, searchable]);
2641
+ useEffect2(() => {
2642
+ if (!state.isOpen || !closeOnOutsideClick) return;
2643
+ const onPointer = (e) => {
2644
+ const target = e.target;
2645
+ if (dropdownRef.current?.contains(target)) return;
2646
+ if (triggerRef.current?.contains(target)) return;
2647
+ state.close();
2648
+ };
2649
+ const onKey = (e) => {
2650
+ if (e.key === "Escape") state.close();
2651
+ };
2652
+ document.addEventListener("mousedown", onPointer);
2653
+ document.addEventListener("keydown", onKey);
2654
+ return () => {
2655
+ document.removeEventListener("mousedown", onPointer);
2656
+ document.removeEventListener("keydown", onKey);
2657
+ };
2658
+ }, [state.isOpen, state.close, closeOnOutsideClick]);
2659
+ const selectedOption = options.find((o) => o.value === String(state.selectedKey ?? ""));
2660
+ const wasOpenBeforePressRef = useRef5(false);
2661
+ const handleTriggerPointerDown = (e) => {
2662
+ wasOpenBeforePressRef.current = state.isOpen;
2663
+ const baseHandler = buttonProps.onPointerDown;
2664
+ baseHandler?.(e);
2665
+ };
2666
+ const handleTriggerClick = (e) => {
2667
+ const baseHandler = buttonProps.onClick;
2668
+ baseHandler?.(e);
2669
+ if (wasOpenBeforePressRef.current && state.isOpen) {
2670
+ state.close();
2671
+ }
2672
+ wasOpenBeforePressRef.current = false;
2673
+ };
2674
+ return /* @__PURE__ */ jsxs6(
2675
+ "div",
2676
+ {
2677
+ className: cn(
2678
+ "ods-select",
2679
+ `ods-select--${size}`,
2680
+ error && "ods-select--error",
2681
+ disabled && "ods-select--disabled",
2682
+ className
2683
+ ),
2684
+ children: [
2685
+ label && /* @__PURE__ */ jsx6("label", { className: "ods-select__label", htmlFor: baseId, children: label }),
2686
+ /* @__PURE__ */ jsx6(HiddenSelect, { state, triggerRef, label, name }),
2687
+ /* @__PURE__ */ jsxs6(
2688
+ "button",
2689
+ {
2690
+ ...buttonProps,
2691
+ onPointerDown: handleTriggerPointerDown,
2692
+ onClick: handleTriggerClick,
2693
+ ref: setTriggerRef,
2694
+ id: baseId,
2695
+ form,
2696
+ autoFocus,
2697
+ "aria-label": ariaLabel,
2698
+ "aria-labelledby": ariaLabelledBy,
2699
+ "aria-describedby": describedBy,
2700
+ "aria-required": required || void 0,
2701
+ "aria-invalid": error ? true : void 0,
2702
+ className: cn("ods-select__trigger", state.isOpen && "ods-select__trigger--open"),
2703
+ children: [
2704
+ /* @__PURE__ */ jsx6("span", { className: "ods-select__value", children: selectedOption ? /* @__PURE__ */ jsxs6(Fragment2, { children: [
2705
+ selectedOption.icon && /* @__PURE__ */ jsx6("span", { className: "ods-select__value-icon", children: selectedOption.icon }),
2706
+ selectedOption.label
2707
+ ] }) : /* @__PURE__ */ jsx6("span", { className: "ods-select__placeholder", children: placeholder }) }),
2708
+ /* @__PURE__ */ jsx6(
2709
+ "span",
2710
+ {
2711
+ className: cn("ods-select__chevron", state.isOpen && "ods-select__chevron--open"),
2712
+ "aria-hidden": "true",
2713
+ children: /* @__PURE__ */ jsx6(ChevronDownIcon2, { size: "xs" })
2714
+ }
2715
+ )
2716
+ ]
2717
+ }
2718
+ ),
2719
+ typeof document !== "undefined" && createPortal2(
2720
+ /* @__PURE__ */ jsx6(AnimatePresence3, { children: state.isOpen && /* @__PURE__ */ jsxs6(
2721
+ motion4.div,
2722
+ {
2723
+ ref: dropdownRef,
2724
+ "data-ods-floating": "",
2725
+ className: "ods-select__dropdown",
2726
+ style: {
2727
+ position: "fixed",
2728
+ ...dropdownPos.top !== void 0 && { top: dropdownPos.top },
2729
+ ...dropdownPos.bottom !== void 0 && { bottom: dropdownPos.bottom },
2730
+ left: dropdownPos.left,
2731
+ // `minWidth` (not `width`) keeps the popover at
2732
+ // least as wide as the trigger — preserves visual
2733
+ // alignment — but allows the consumer to widen it
2734
+ // explicitly when option labels demand more room
2735
+ // (pass `dropdownMinWidth` to set a higher floor).
2736
+ // Avoids the previous `max-content` recipe which
2737
+ // made the popover grow uncomfortably wide on
2738
+ // searchable / long-option menus.
2739
+ minWidth: Math.max(dropdownPos.width, dropdownMinWidth ?? 0),
2740
+ // Bound the popover to the available viewport edge so
2741
+ // it never spills off-screen on tall pages. Pairs with
2742
+ // `overflow-y: auto` from the .ods-select__dropdown
2743
+ // SCSS so long option lists scroll internally.
2744
+ maxHeight: dropdownPos.maxHeight
2745
+ },
2746
+ initial: { opacity: 0, scale: 0.95 },
2747
+ animate: { opacity: 1, scale: 1 },
2748
+ exit: { opacity: 0, scale: 0.95 },
2749
+ transition: { duration: 0.2, ease: [0.16, 1, 0.3, 1] },
2750
+ children: [
2751
+ searchable && /* @__PURE__ */ jsx6("div", { className: "ods-select__search-wrap", children: /* @__PURE__ */ jsx6(
2752
+ "input",
2753
+ {
2754
+ ref: searchRef,
2755
+ className: "ods-select__search",
2756
+ type: "text",
2757
+ placeholder: "Search...",
2758
+ value: searchQuery,
2759
+ onChange: (e) => setSearchQuery(e.target.value),
2760
+ "aria-label": "Search options",
2761
+ onKeyDown: (e) => {
2762
+ if (e.key === "Escape") {
2763
+ state.close();
2764
+ }
2765
+ }
2766
+ }
2767
+ ) }),
2768
+ /* @__PURE__ */ jsx6(
2769
+ ListBox,
2770
+ {
2771
+ ...menuProps,
2772
+ listBoxRef,
2773
+ state,
2774
+ showCheckmark,
2775
+ showOverflowTooltips
2776
+ }
2777
+ ),
2778
+ filteredOptions.length === 0 && /* @__PURE__ */ jsx6("div", { className: "ods-select__empty", children: "No results found" })
2779
+ ]
2780
+ }
2781
+ ) }),
2782
+ document.body
2783
+ ),
2784
+ error && errorMessage ? /* @__PURE__ */ jsx6("span", { id: hintId, className: "ods-select__error", role: "alert", children: errorMessage }) : helperText ? /* @__PURE__ */ jsx6("span", { id: hintId, className: "ods-select__hint", children: helperText }) : null
2785
+ ]
2786
+ }
2787
+ );
2788
+ });
2789
+ Select.displayName = "Select";
2790
+
2791
+ // src/components/Spinner/Spinner.tsx
2792
+ import { forwardRef as forwardRef7 } from "react";
2793
+ import { jsx as jsx7 } from "react/jsx-runtime";
2794
+ var SIZE_PX = {
2795
+ sm: 16,
2796
+ md: 24,
2797
+ lg: 32,
2798
+ xl: 48
2799
+ };
2800
+ var Spinner = forwardRef7(function Spinner2({ size = "md", tone = "accent", label = "Loading", className, style, ...rest }, ref) {
2801
+ const px = typeof size === "number" ? size : SIZE_PX[size];
2802
+ const isKeyword = typeof size === "string";
2803
+ return /* @__PURE__ */ jsx7(
2804
+ "svg",
2805
+ {
2806
+ ...rest,
2807
+ ref,
2808
+ className: cn(
2809
+ "ods-spinner",
2810
+ isKeyword && `ods-spinner--${size}`,
2811
+ `ods-spinner--${tone}`,
2812
+ className
2813
+ ),
2814
+ width: px,
2815
+ height: px,
2816
+ viewBox: "0 0 24 24",
2817
+ fill: "none",
2818
+ role: "status",
2819
+ "aria-label": label,
2820
+ style,
2821
+ children: /* @__PURE__ */ jsx7(
2822
+ "circle",
2823
+ {
2824
+ cx: "12",
2825
+ cy: "12",
2826
+ r: "10",
2827
+ strokeWidth: "3",
2828
+ strokeLinecap: "round",
2829
+ strokeDasharray: "31.4 31.4",
2830
+ className: "ods-spinner__circle"
2831
+ }
2832
+ )
2833
+ }
2834
+ );
2835
+ });
2836
+ Spinner.displayName = "Spinner";
2837
+
2838
+ export {
2839
+ Accordion,
2840
+ Slot,
2841
+ $05678f3aee5e7d1a$export$6d08773d2e66f8f2,
2842
+ $e3403870bfb691da$export$79fefeb1c2091ac3,
2843
+ $384704861d32dbed$export$bca9d026f8e704eb,
2844
+ $caeb030f09a278a1$export$4ba071daf4e486,
2845
+ $fd3c5e01e837dc20$export$8042c6c013fd5226,
2846
+ $6b915bde6cd300dd$export$728d6ba534403756,
2847
+ getRenderableText,
2848
+ resolveAccessibleName,
2849
+ Checkbox,
2850
+ Tooltip,
2851
+ Button,
2852
+ Input,
2853
+ Select,
2854
+ Spinner
2855
+ };
2856
+ //# sourceMappingURL=chunk-V22HCPVO.js.map