@proyecto-viviana/solid-stately 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/calendar/createDateFieldState.d.ts +56 -18
- package/dist/calendar/createRangeCalendarState.d.ts +10 -0
- package/dist/calendar/createTimeFieldState.d.ts +38 -67
- package/dist/calendar/intl/index.d.ts +10 -0
- package/dist/collections/ListCollection.d.ts +8 -0
- package/dist/collections/createListState.d.ts +12 -0
- package/dist/collections/getChildNodes.d.ts +8 -0
- package/dist/collections/index.d.ts +2 -2
- package/dist/collections/types.d.ts +9 -0
- package/dist/color/intl/index.d.ts +14 -0
- package/dist/dnd/createDroppableCollectionState.d.ts +17 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3444 -1304
- package/dist/index.js.map +1 -1
- package/dist/selection/SelectionManager.d.ts +9 -0
- package/package.json +1 -1
- package/src/calendar/createCalendarState.ts +26 -4
- package/src/calendar/createDateFieldState.ts +614 -459
- package/src/calendar/createRangeCalendarState.ts +212 -11
- package/src/calendar/createTimeFieldState.ts +179 -467
- package/src/calendar/intl/index.ts +364 -0
- package/src/collections/ListCollection.ts +31 -0
- package/src/collections/createListState.ts +92 -1
- package/src/collections/getChildNodes.ts +31 -0
- package/src/collections/index.ts +3 -0
- package/src/collections/types.ts +10 -0
- package/src/color/Color.ts +104 -133
- package/src/color/intl/index.ts +1409 -0
- package/src/combobox/createComboBoxState.ts +30 -13
- package/src/dnd/createDroppableCollectionState.ts +125 -6
- package/src/index.ts +3 -0
- package/src/selection/SelectionManager.ts +15 -0
- package/src/steplist/createStepListState.ts +27 -4
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_isServer","getInitialSelection","normalizeSelection","SelectionClass","dayOfWeekNames","getLocalTimeZone","DateFormatter","intlCreateCalendar","intlToCalendar","toCalendarDate","startOfMonth","endOfMonth","today","startOfWeek","convertValue","isSameDay","isSameMonth","getWeeksInMonth","intlToCalendarDate","GregorianCalendar","getLocalTimeZone","DateFormatter","intlCreateCalendar","intlToCalendar","toCalendarDate","maxDate","minDate","endOfMonth","startOfMonth","today","startOfWeek","isSameDay","isSameMonth","getWeeksInMonth","intlToCalendarDate","GregorianCalendar","getLocalTimeZone","GregorianCalendar","today","intlToCalendarDate","toCalendarDateTime","DateFormatter","DateFormatter","getLocalTimeZone","toCalendarDate","toCalendarDateTime","toZoned","DateFormatter","clamp","snapToStep","clamp","getInitialSelection","normalizeSelection","moveItems","candidate"],"sources":["../src/utils/reactivity.ts","../src/toggle/createToggleState.ts","../src/toggle/createToggleGroupState.ts","../src/autocomplete/createAutocompleteState.ts","../src/textfield/createTextFieldState.ts","../src/form/createFormValidationState.ts","../src/checkbox/createCheckboxGroupState.ts","../src/ssr/index.ts","../src/radio/createRadioGroupState.ts","../src/overlays/createOverlayTriggerState.ts","../src/collections/ListCollection.ts","../src/collections/createSelectionState.ts","../src/selection/Selection.ts","../src/selection/createMultipleSelectionState.ts","../src/collections/getChildNodes.ts","../src/selection/SelectionManager.ts","../src/collections/createListState.ts","../src/collections/createMenuState.ts","../src/calendar/createCalendarState.ts","../src/calendar/createRangeCalendarState.ts","../src/calendar/IncompleteDate.ts","../src/calendar/createDateFieldState.ts","../src/calendar/createTimeFieldState.ts","../src/calendar/createDatePickerState.ts","../src/select/createSelectState.ts","../src/combobox/createComboBoxState.ts","../src/tabs/createTabListState.ts","../src/numberfield/createNumberFieldState.ts","../src/searchfield/createSearchFieldState.ts","../src/slider/createSliderState.ts","../src/tooltip/createTooltipTriggerState.ts","../src/toast/createToastState.ts","../src/disclosure/createDisclosureState.ts","../src/grid/createGridState.ts","../src/table/createTableState.ts","../src/table/TableCollection.ts","../src/table/createTreeGridState.ts","../src/table/createTableColumnResizeState.ts","../src/tree/createTreeState.ts","../src/tree/TreeCollection.ts","../src/color/Color.ts","../src/color/createColorSliderState.ts","../src/color/createColorAreaState.ts","../src/color/createColorWheelState.ts","../src/color/createColorFieldState.ts","../src/dnd/createDragState.ts","../src/dnd/createDropState.ts","../src/dnd/createDraggableCollectionState.ts","../src/dnd/createDroppableCollectionState.ts","../src/data/createListData.ts","../src/data/createTreeData.ts","../src/data/createAsyncList.ts","../src/color/getColorChannels.ts","../src/steplist/createStepListState.ts"],"sourcesContent":["/**\n * Reactivity utilities for Solid Stately\n *\n * Provides type-safe utilities for working with SolidJS reactivity patterns.\n */\n\nimport { Accessor } from \"solid-js\";\n\n/**\n * A value that may be either a raw value or an accessor function.\n * This is a common pattern in SolidJS for props that may be reactive.\n */\nexport type MaybeAccessor<T> = T | Accessor<T>;\n\n/**\n * Unwraps a MaybeAccessor to get the underlying value.\n * If the input is a function, it calls it to get the value.\n * Otherwise, it returns the value directly.\n *\n * @param value - The value or accessor to unwrap.\n */\nexport function access<T>(value: MaybeAccessor<T>): T {\n return typeof value === \"function\" ? (value as Accessor<T>)() : value;\n}\n\n/**\n * A value that may be undefined or an accessor that returns the value or undefined.\n */\nexport type MaybeAccessorValue<T> = T | undefined | Accessor<T | undefined>;\n\n/**\n * Checks if a value is an accessor function.\n */\nexport function isAccessor<T>(value: MaybeAccessor<T>): value is Accessor<T> {\n return typeof value === \"function\";\n}\n","/**\n * Toggle state for Solid Stately\n *\n * Provides state management for toggle components like checkboxes and switches.\n *\n * This is a 1:1 port of @react-stately/toggle's useToggleState.\n */\n\nimport { createSignal, Accessor } from \"solid-js\";\nimport { type MaybeAccessor, access } from \"../utils\";\n\nexport interface ToggleStateOptions {\n /** Whether the element should be selected (controlled). */\n isSelected?: boolean;\n /** Whether the element should be selected by default (uncontrolled). */\n defaultSelected?: boolean;\n /** Handler that is called when the element's selection state changes. */\n onChange?: (isSelected: boolean) => void;\n /** Whether the element is read only. */\n isReadOnly?: boolean;\n}\n\nexport interface ToggleState {\n /** Whether the toggle is selected. */\n readonly isSelected: Accessor<boolean>;\n /** Whether the toggle is selected by default. */\n readonly defaultSelected: boolean;\n /** Updates selection state. */\n setSelected(isSelected: boolean): void;\n /** Toggle the selection state. */\n toggle(): void;\n}\n\n/**\n * Provides state management for toggle components like checkboxes and switches.\n */\nexport function createToggleState(props: MaybeAccessor<ToggleStateOptions> = {}): ToggleState {\n const getProps = () => access(props);\n\n const initialProps = getProps();\n const initialSelected = initialProps.isSelected ?? initialProps.defaultSelected ?? false;\n\n const [internalSelected, setInternalSelected] = createSignal(initialSelected);\n\n const isControlled = () => getProps().isSelected !== undefined;\n\n const isSelected: Accessor<boolean> = () => {\n const p = getProps();\n return isControlled() ? (p.isSelected ?? false) : internalSelected();\n };\n\n function setSelected(value: boolean): void {\n const p = getProps();\n if (p.isReadOnly) {\n return;\n }\n\n if (!isControlled()) {\n setInternalSelected(value);\n }\n\n p.onChange?.(value);\n }\n\n function toggle(): void {\n const p = getProps();\n if (p.isReadOnly) {\n return;\n }\n\n setSelected(!isSelected());\n }\n\n return {\n isSelected,\n defaultSelected: initialProps.defaultSelected ?? initialSelected,\n setSelected,\n toggle,\n };\n}\n","/**\n * Toggle group state for Solid Stately\n *\n * Provides state management for groups of toggle buttons with\n * single or multiple selection.\n *\n * This is a port of @react-stately/toggle's useToggleGroupState.\n */\n\nimport { createSignal } from \"solid-js\";\nimport type { Key } from \"../collections\";\nimport { type MaybeAccessor, access } from \"../utils\";\n\nexport interface ToggleGroupProps {\n /**\n * Whether single or multiple selection is enabled.\n * @default 'single'\n */\n selectionMode?: \"single\" | \"multiple\";\n /** Whether empty selection is disallowed. */\n disallowEmptySelection?: boolean;\n /** Controlled selected keys. */\n selectedKeys?: Iterable<Key>;\n /** Uncontrolled initial selected keys. */\n defaultSelectedKeys?: Iterable<Key>;\n /** Called when selected keys change. */\n onSelectionChange?: (keys: Set<Key>) => void;\n /** Whether all items are disabled. */\n isDisabled?: boolean;\n}\n\nexport interface ToggleGroupState {\n /** Whether single or multiple selection is enabled. */\n readonly selectionMode: \"single\" | \"multiple\";\n /** Whether all items are disabled. */\n readonly isDisabled: boolean;\n /** Current selected keys. */\n readonly selectedKeys: Set<Key>;\n /** Toggles selected state for a key. */\n toggleKey(key: Key): void;\n /** Sets selected state for a key. */\n setSelected(key: Key, isSelected: boolean): void;\n /** Replaces selected keys. */\n setSelectedKeys(keys: Set<Key>): void;\n}\n\nfunction toKeySet(keys?: Iterable<Key>): Set<Key> {\n return new Set(keys ? Array.from(keys) : []);\n}\n\n/**\n * Manages state for a group of toggle buttons.\n */\nexport function createToggleGroupState(\n props: MaybeAccessor<ToggleGroupProps> = {},\n): ToggleGroupState {\n const getProps = () => access(props);\n\n const initialProps = getProps();\n const [internalSelectedKeys, setInternalSelectedKeys] = createSignal<Set<Key>>(\n toKeySet(initialProps.defaultSelectedKeys),\n );\n\n const isControlled = () => getProps().selectedKeys !== undefined;\n const selectedKeys = () =>\n isControlled() ? toKeySet(getProps().selectedKeys) : internalSelectedKeys();\n\n function setSelectedKeys(keys: Set<Key>): void {\n const nextKeys = new Set(keys);\n if (!isControlled()) {\n setInternalSelectedKeys(nextKeys);\n }\n getProps().onSelectionChange?.(nextKeys);\n }\n\n function toggleKey(key: Key): void {\n const props = getProps();\n const mode = props.selectionMode ?? \"single\";\n const disallowEmptySelection = props.disallowEmptySelection ?? false;\n const currentKeys = selectedKeys();\n\n let nextKeys: Set<Key>;\n if (mode === \"multiple\") {\n nextKeys = new Set(currentKeys);\n if (nextKeys.has(key) && (!disallowEmptySelection || nextKeys.size > 1)) {\n nextKeys.delete(key);\n } else {\n nextKeys.add(key);\n }\n } else {\n nextKeys = new Set(currentKeys.has(key) && !disallowEmptySelection ? [] : [key]);\n }\n\n setSelectedKeys(nextKeys);\n }\n\n function setSelected(key: Key, isSelected: boolean): void {\n if (isSelected !== selectedKeys().has(key)) {\n toggleKey(key);\n }\n }\n\n return {\n get selectionMode() {\n return getProps().selectionMode ?? \"single\";\n },\n get isDisabled() {\n return getProps().isDisabled ?? false;\n },\n get selectedKeys() {\n return new Set(selectedKeys());\n },\n toggleKey,\n setSelected,\n setSelectedKeys,\n };\n}\n","/**\n * createAutocompleteState - State management for autocomplete components\n *\n * Based on @react-stately/autocomplete useAutocompleteState.\n */\n\nimport { createSignal, type Accessor } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils\";\n\nexport interface AutocompleteState {\n /** The current value of the autocomplete input. */\n inputValue: Accessor<string>;\n /** Sets the value of the autocomplete input. */\n setInputValue(value: string): void;\n /** The id of the current aria-activedescendant of the autocomplete input. */\n focusedNodeId: Accessor<string | null>;\n /** Sets the id of the current aria-activedescendant of the autocomplete input. */\n setFocusedNodeId(value: string | null): void;\n}\n\nexport interface AutocompleteStateOptions {\n /** The value of the autocomplete input (controlled). */\n inputValue?: string;\n /** The default value of the autocomplete input (uncontrolled). */\n defaultInputValue?: string;\n /** Handler that is called when the autocomplete input value changes. */\n onInputChange?: (value: string) => void;\n}\n\n/**\n * Provides state management for an autocomplete component.\n *\n * @example\n * ```tsx\n * const state = createAutocompleteState({\n * defaultInputValue: '',\n * onInputChange: (value) => console.log('Input changed:', value),\n * });\n *\n * // Access current input value\n * console.log(state.inputValue());\n *\n * // Update input value\n * state.setInputValue('new value');\n *\n * // Track focused node for aria-activedescendant\n * state.setFocusedNodeId('item-1');\n * ```\n */\nexport function createAutocompleteState(\n props: MaybeAccessor<AutocompleteStateOptions> = {},\n): AutocompleteState {\n const getProps = () => access(props);\n\n // Track focused node ID for aria-activedescendant\n const [focusedNodeId, setFocusedNodeId] = createSignal<string | null>(null);\n\n // Handle controlled vs uncontrolled input value\n const isControlled = () => getProps().inputValue !== undefined;\n const [uncontrolledValue, setUncontrolledValue] = createSignal(\n getProps().defaultInputValue ?? \"\",\n );\n\n const inputValue: Accessor<string> = () => {\n const p = getProps();\n return isControlled() ? (p.inputValue ?? \"\") : uncontrolledValue();\n };\n\n const setInputValue = (value: string) => {\n const p = getProps();\n if (!isControlled()) {\n setUncontrolledValue(value);\n }\n p.onInputChange?.(value);\n };\n\n return {\n inputValue,\n setInputValue,\n focusedNodeId,\n setFocusedNodeId,\n };\n}\n","/**\n * TextField state for Solid Stately\n *\n * Provides state management for text input components.\n *\n * This is a port of @react-stately/utils's useControlledState pattern\n * as used by @react-aria/textfield.\n */\n\nimport { createSignal, Accessor } from \"solid-js\";\nimport { type MaybeAccessor, access } from \"../utils\";\n\nexport interface TextFieldStateOptions {\n /** The current value (controlled). */\n value?: string;\n /** The default value (uncontrolled). */\n defaultValue?: string;\n /** Handler that is called when the value changes. */\n onChange?: (value: string) => void;\n}\n\nexport interface TextFieldState {\n /** The current value of the text field. */\n readonly value: Accessor<string>;\n /** Sets the value of the text field. */\n setValue(value: string): void;\n}\n\n/**\n * Provides state management for text input components.\n * Supports both controlled and uncontrolled modes.\n */\nexport function createTextFieldState(\n props: MaybeAccessor<TextFieldStateOptions> = {},\n): TextFieldState {\n const getProps = () => access(props);\n\n const initialProps = getProps();\n const initialValue = initialProps.value ?? initialProps.defaultValue ?? \"\";\n\n const [internalValue, setInternalValue] = createSignal(initialValue);\n\n const isControlled = () => getProps().value !== undefined;\n\n const value: Accessor<string> = () => {\n const p = getProps();\n return isControlled() ? (p.value ?? \"\") : internalValue();\n };\n\n function setValue(newValue: string): void {\n const p = getProps();\n\n if (!isControlled()) {\n setInternalValue(newValue);\n }\n\n p.onChange?.(newValue);\n }\n\n return {\n value,\n setValue,\n };\n}\n","/**\n * createFormValidationState for solid-stately\n *\n * Manages form validation state including realtime and displayed validation results.\n * Supports both ARIA (live) and native (on submit) validation behaviors.\n *\n * Port of react-stately's useFormValidationState.\n */\n\nimport {\n type Accessor,\n createContext,\n createEffect,\n createMemo,\n createSignal,\n useContext,\n} from \"solid-js\";\n\n/** Standard HTML ValidityState interface. */\nexport interface ValidityState {\n badInput: boolean;\n customError: boolean;\n patternMismatch: boolean;\n rangeOverflow: boolean;\n rangeUnderflow: boolean;\n stepMismatch: boolean;\n tooLong: boolean;\n tooShort: boolean;\n typeMismatch: boolean;\n valueMissing: boolean;\n valid: boolean;\n}\n\n/** Result of validation. */\nexport interface ValidationResult {\n /** Whether the value is invalid. */\n isInvalid: boolean;\n /** Details about which validation constraints failed. */\n validationDetails: ValidityState;\n /** Error messages to display. */\n validationErrors: string[];\n}\n\n/** Map of field names to their validation errors. */\nexport type ValidationErrors = Record<string, string | string[]>;\n\n/** Validation function that returns error messages or true/false. */\nexport type ValidationFunction<T> = (value: T) => boolean | string | string[] | null | undefined;\n\n/** Validation behavior mode. */\nexport type ValidationBehavior = \"aria\" | \"native\";\n\nexport interface FormValidationProps<T> {\n /** Whether the value is invalid (controlled). */\n isInvalid?: boolean;\n /** @deprecated Use isInvalid instead. */\n validationState?: \"valid\" | \"invalid\";\n /** Custom validation function. */\n validate?: ValidationFunction<T>;\n /** Validation behavior: 'aria' for realtime, 'native' for on submit. */\n validationBehavior?: ValidationBehavior;\n /** Built-in validation result from native input. */\n builtinValidation?: ValidationResult;\n /** Field name(s) for server error lookup. */\n name?: string | string[];\n /** Current field value. */\n value: T | null;\n}\n\nexport interface FormValidationState {\n /** Realtime validation results, updated as the user edits the value. */\n realtimeValidation: Accessor<ValidationResult>;\n /** Currently displayed validation results, updated when the user commits their changes. */\n displayValidation: Accessor<ValidationResult>;\n /** Updates the current validation result. Not displayed to the user until `commitValidation` is called. */\n updateValidation(result: ValidationResult): void;\n /** Resets the displayed validation state to valid when the user resets the form. */\n resetValidation(): void;\n /** Commits the realtime validation so it is displayed to the user. */\n commitValidation(): void;\n}\n\n/** A valid validity state. */\nexport const VALID_VALIDITY_STATE: ValidityState = {\n badInput: false,\n customError: false,\n patternMismatch: false,\n rangeOverflow: false,\n rangeUnderflow: false,\n stepMismatch: false,\n tooLong: false,\n tooShort: false,\n typeMismatch: false,\n valueMissing: false,\n valid: true,\n};\n\n/** A custom error validity state. */\nconst CUSTOM_VALIDITY_STATE: ValidityState = {\n ...VALID_VALIDITY_STATE,\n customError: true,\n valid: false,\n};\n\n/** Default validation result (valid). */\nexport const DEFAULT_VALIDATION_RESULT: ValidationResult = {\n isInvalid: false,\n validationDetails: VALID_VALIDITY_STATE,\n validationErrors: [],\n};\n\n/** Context for server-side validation errors. */\nexport const FormValidationContext = createContext<ValidationErrors>({});\n\n/** Private prop key for passing validation state to children. */\nexport const privateValidationStateProp = \"__formValidationState\" + Date.now();\n\nfunction asArray<T>(v: T | T[] | undefined): T[] {\n if (!v) {\n return [];\n }\n return Array.isArray(v) ? v : [v];\n}\n\nfunction runValidate<T>(validate: ValidationFunction<T>, value: T): string[] {\n if (typeof validate === \"function\") {\n const e = validate(value);\n if (e && typeof e !== \"boolean\") {\n return asArray(e);\n }\n }\n return [];\n}\n\nfunction getValidationResult(errors: string[]): ValidationResult | null {\n return errors.length\n ? {\n isInvalid: true,\n validationErrors: errors,\n validationDetails: CUSTOM_VALIDITY_STATE,\n }\n : null;\n}\n\nfunction isEqualValidation(a: ValidationResult | null, b: ValidationResult | null): boolean {\n if (a === b) {\n return true;\n }\n return (\n !!a &&\n !!b &&\n a.isInvalid === b.isInvalid &&\n a.validationErrors.length === b.validationErrors.length &&\n a.validationErrors.every((ae, i) => ae === b.validationErrors[i]) &&\n Object.entries(a.validationDetails).every(\n ([k, v]) => b.validationDetails[k as keyof ValidityState] === v,\n )\n );\n}\n\n/**\n * Creates form validation state for a field.\n *\n * @example\n * ```tsx\n * const validationState = createFormValidationState({\n * value: inputValue(),\n * validate: (value) => {\n * if (!value) return 'This field is required';\n * if (value.length < 3) return 'Must be at least 3 characters';\n * return null;\n * },\n * validationBehavior: 'aria',\n * });\n *\n * // Access validation state\n * const isInvalid = () => validationState.displayValidation().isInvalid;\n * const errors = () => validationState.displayValidation().validationErrors;\n * ```\n */\nexport function createFormValidationState<T>(props: FormValidationProps<T>): FormValidationState {\n const validationBehavior = () => props.validationBehavior ?? \"aria\";\n\n // Backward compatibility\n const isInvalidProp = createMemo(\n () => props.isInvalid ?? (props.validationState === \"invalid\" ? true : undefined),\n );\n\n // Controlled error from isInvalid prop\n const controlledError = createMemo<ValidationResult | null>(() =>\n isInvalidProp() !== undefined\n ? {\n isInvalid: isInvalidProp()!,\n validationErrors: [],\n validationDetails: CUSTOM_VALIDITY_STATE,\n }\n : null,\n );\n\n // Client-side validation\n const clientError = createMemo<ValidationResult | null>(() => {\n const validate = props.validate;\n if (!validate || props.value == null) {\n return null;\n }\n const validateErrors = runValidate(validate, props.value);\n return getValidationResult(validateErrors);\n });\n\n // Built-in validation (skip if valid)\n const builtinValidation = createMemo<ValidationResult | undefined>(() => {\n const builtinValidationProp = props.builtinValidation;\n if (builtinValidationProp?.validationDetails.valid) {\n return undefined;\n }\n return builtinValidationProp;\n });\n\n // Server errors from context\n const serverErrors = useContext(FormValidationContext);\n const serverErrorMessages = createMemo(() => {\n const name = props.name;\n if (name) {\n return Array.isArray(name)\n ? name.flatMap((n) => asArray(serverErrors[n]))\n : asArray(serverErrors[name]);\n }\n return [];\n });\n\n // Track server errors clearing\n const [lastServerErrors, setLastServerErrors] = createSignal(serverErrors);\n const [isServerErrorCleared, setServerErrorCleared] = createSignal(false);\n\n createEffect(() => {\n if (serverErrors !== lastServerErrors()) {\n setLastServerErrors(serverErrors);\n setServerErrorCleared(false);\n }\n });\n\n const serverError = createMemo<ValidationResult | null>(() =>\n getValidationResult(isServerErrorCleared() ? [] : serverErrorMessages()),\n );\n\n // Track validation state\n const [currentValidity, setCurrentValidity] = createSignal(DEFAULT_VALIDATION_RESULT);\n const [commitQueued, setCommitQueued] = createSignal(false);\n\n let nextValidation = DEFAULT_VALIDATION_RESULT;\n let lastError = DEFAULT_VALIDATION_RESULT;\n\n // Commit validation effect\n createEffect(() => {\n if (!commitQueued()) {\n return;\n }\n setCommitQueued(false);\n const error = clientError() || builtinValidation() || nextValidation;\n if (!isEqualValidation(error, lastError)) {\n lastError = error;\n setCurrentValidity(error);\n }\n });\n\n // Realtime validation (for native input state)\n const realtimeValidation = createMemo<ValidationResult>(\n () =>\n controlledError() ||\n serverError() ||\n clientError() ||\n builtinValidation() ||\n DEFAULT_VALIDATION_RESULT,\n );\n\n // Display validation (what the user sees)\n const displayValidation = createMemo<ValidationResult>(() => {\n if (validationBehavior() === \"native\") {\n return controlledError() || serverError() || currentValidity();\n }\n return (\n controlledError() ||\n serverError() ||\n clientError() ||\n builtinValidation() ||\n currentValidity()\n );\n });\n\n return {\n realtimeValidation,\n displayValidation,\n updateValidation(value: ValidationResult) {\n // If validationBehavior is 'aria', update in realtime. Otherwise, store until commit.\n if (validationBehavior() === \"aria\" && !isEqualValidation(currentValidity(), value)) {\n setCurrentValidity(value);\n } else {\n nextValidation = value;\n }\n },\n resetValidation() {\n // Update the currently displayed validation state to valid on form reset.\n const error = DEFAULT_VALIDATION_RESULT;\n if (!isEqualValidation(error, lastError)) {\n lastError = error;\n setCurrentValidity(error);\n }\n // Do not commit validation after the next render for native behavior.\n if (validationBehavior() === \"native\") {\n setCommitQueued(false);\n }\n setServerErrorCleared(true);\n },\n commitValidation() {\n // Commit validation state so the user sees it on blur/change/submit.\n if (validationBehavior() === \"native\") {\n const error = clientError() || builtinValidation() || nextValidation;\n if (!isEqualValidation(error, lastError)) {\n lastError = error;\n setCurrentValidity(error);\n }\n setCommitQueued(false);\n }\n setServerErrorCleared(true);\n },\n };\n}\n\n/**\n * Merges multiple validation results into one.\n */\nexport function mergeValidation(...results: ValidationResult[]): ValidationResult {\n const errors = new Set<string>();\n let isInvalid = false;\n const validationDetails: ValidityState = { ...VALID_VALIDITY_STATE };\n\n for (const v of results) {\n for (const e of v.validationErrors) {\n errors.add(e);\n }\n isInvalid = isInvalid || v.isInvalid;\n for (const key in validationDetails) {\n const k = key as keyof ValidityState;\n (validationDetails as unknown as Record<string, boolean>)[k] =\n (validationDetails as unknown as Record<string, boolean>)[k] ||\n (v.validationDetails as unknown as Record<string, boolean>)[k];\n }\n }\n\n validationDetails.valid = !isInvalid;\n return {\n isInvalid,\n validationErrors: [...errors],\n validationDetails,\n };\n}\n","/**\n * Checkbox group state for Solid Stately\n *\n * Provides state management for a checkbox group component.\n * Provides a name for the group, and manages selection and focus state.\n *\n * This is a 1:1 port of @react-stately/checkbox's useCheckboxGroupState.\n */\n\nimport { createMemo, createSignal, Accessor } from \"solid-js\";\nimport { type MaybeAccessor, access } from \"../utils\";\nimport {\n createFormValidationState,\n type FormValidationState,\n type ValidationFunction,\n type ValidationResult,\n} from \"../form\";\n\nexport interface CheckboxGroupProps {\n /** The current selected values (controlled). */\n value?: string[];\n /** The default selected values (uncontrolled). */\n defaultValue?: string[];\n /** Handler that is called when the value changes. */\n onChange?: (value: string[]) => void;\n /** Whether the checkbox group is disabled. */\n isDisabled?: boolean;\n /** Whether the checkbox group is read only. */\n isReadOnly?: boolean;\n /** Whether the checkbox group is required. */\n isRequired?: boolean;\n /** Whether the checkbox group is invalid. */\n isInvalid?: boolean;\n /** The name of the checkbox group, used when submitting an HTML form. */\n name?: string;\n /** The form to associate the checkbox group with. */\n form?: string;\n /** The label for the checkbox group. */\n label?: string;\n /** Handler that is called when the checkbox group receives focus. */\n onFocus?: (e: FocusEvent) => void;\n /** Handler that is called when the checkbox group loses focus. */\n onBlur?: (e: FocusEvent) => void;\n /** Handler that is called when the checkbox group's focus status changes. */\n onFocusChange?: (isFocused: boolean) => void;\n /** Backward-compatible controlled validation state. */\n validationState?: \"valid\" | \"invalid\";\n /** Custom validation function. */\n validate?: ValidationFunction<readonly string[]>;\n /** Validation behavior for the checkbox group. */\n validationBehavior?: \"aria\" | \"native\";\n}\n\nexport interface CheckboxGroupState extends Pick<\n FormValidationState,\n | \"realtimeValidation\"\n | \"displayValidation\"\n | \"updateValidation\"\n | \"resetValidation\"\n | \"commitValidation\"\n> {\n /** Current selected values. */\n readonly value: Accessor<readonly string[]>;\n /** Default selected values. */\n readonly defaultValue: readonly string[];\n /** Whether the checkbox group is disabled. */\n readonly isDisabled: boolean;\n /** Whether the checkbox group is read only. */\n readonly isReadOnly: boolean;\n /** Whether the checkbox group is invalid. */\n readonly isInvalid: boolean;\n /**\n * Whether the checkboxes in the group are required.\n * This changes to false once at least one item is selected.\n */\n readonly isRequired: Accessor<boolean>;\n /** Returns whether the given value is selected. */\n isSelected(value: string): boolean;\n /** Sets the selected values. */\n setValue(value: string[]): void;\n /** Adds a value to the set of selected values. */\n addValue(value: string): void;\n /** Removes a value from the set of selected values. */\n removeValue(value: string): void;\n /** Toggles a value in the set of selected values. */\n toggleValue(value: string): void;\n\n /** Current display validation result for the group. */\n readonly displayValidation: Accessor<ValidationResult>;\n}\n\n/**\n * Provides state management for a checkbox group component.\n * Provides a name for the group, and manages selection and focus state.\n */\nexport function createCheckboxGroupState(\n props: MaybeAccessor<CheckboxGroupProps> = {},\n): CheckboxGroupState {\n const getProps = () => access(props);\n\n const initialProps = getProps();\n const initialValue = initialProps.value ?? initialProps.defaultValue ?? [];\n\n const [internalValue, setInternalValue] = createSignal<readonly string[]>(initialValue);\n\n const controlledValue = createMemo<readonly string[] | undefined>(() => getProps().value);\n\n const isControlled = () => controlledValue() !== undefined;\n\n const value: Accessor<readonly string[]> = () => {\n const controlled = controlledValue();\n return controlled !== undefined ? controlled : internalValue();\n };\n\n const isRequired: Accessor<boolean> = () => {\n const p = getProps();\n return !!p.isRequired && value().length === 0;\n };\n\n const validation = createFormValidationState<readonly string[]>({\n get value() {\n return value();\n },\n get isInvalid() {\n return getProps().isInvalid;\n },\n get validationState() {\n return getProps().validationState;\n },\n get validate() {\n return getProps().validate;\n },\n get validationBehavior() {\n return getProps().validationBehavior ?? \"native\";\n },\n get name() {\n return getProps().name;\n },\n });\n\n function setValue(newValue: string[]): void {\n const p = getProps();\n if (p.isReadOnly || p.isDisabled) {\n return;\n }\n\n if (!isControlled()) {\n setInternalValue(newValue);\n }\n\n p.onChange?.(newValue);\n }\n\n function isSelected(checkValue: string): boolean {\n return value().includes(checkValue);\n }\n\n function addValue(addVal: string): void {\n const p = getProps();\n if (p.isReadOnly || p.isDisabled) {\n return;\n }\n\n const current = value();\n if (!current.includes(addVal)) {\n setValue([...current, addVal]);\n }\n }\n\n function removeValue(removeVal: string): void {\n const p = getProps();\n if (p.isReadOnly || p.isDisabled) {\n return;\n }\n\n const current = value();\n if (current.includes(removeVal)) {\n setValue(current.filter((v) => v !== removeVal));\n }\n }\n\n function toggleValue(toggleVal: string): void {\n const p = getProps();\n if (p.isReadOnly || p.isDisabled) {\n return;\n }\n\n const current = value();\n if (current.includes(toggleVal)) {\n setValue(current.filter((v) => v !== toggleVal));\n } else {\n setValue([...current, toggleVal]);\n }\n }\n\n return {\n value,\n defaultValue: initialProps.defaultValue ?? initialValue,\n get isDisabled() {\n return getProps().isDisabled ?? false;\n },\n get isReadOnly() {\n return getProps().isReadOnly ?? false;\n },\n get isInvalid() {\n return validation.displayValidation().isInvalid;\n },\n isRequired,\n isSelected,\n setValue,\n addValue,\n removeValue,\n toggleValue,\n realtimeValidation: validation.realtimeValidation,\n displayValidation: validation.displayValidation,\n updateValidation: validation.updateValidation,\n resetValidation: validation.resetValidation,\n commitValidation: validation.commitValidation,\n };\n}\n","/**\n * SSR utilities for Solid Stately\n *\n * SolidJS has built-in SSR support with `isServer` and `createUniqueId()`.\n * These utilities provide a consistent API matching React-Stately's patterns.\n */\n\nimport { createUniqueId } from \"solid-js\";\nimport { isServer as _isServer } from \"solid-js/web\";\n\n/**\n * Re-export isServer from solid-js/web for convenience.\n */\nexport const isServer = _isServer;\n\n/**\n * Returns whether the component is currently being server side rendered.\n * Can be used to delay browser-specific rendering until after hydration.\n */\nexport function createIsSSR(): boolean {\n return isServer;\n}\n\n/**\n * Generate a unique ID that is stable across server and client.\n * Uses SolidJS's built-in createUniqueId which handles SSR correctly.\n *\n * @param defaultId - Optional default ID to use instead of generating one.\n */\nexport function createId(defaultId?: string): string {\n if (defaultId) {\n return defaultId;\n }\n return `solid-stately-${createUniqueId()}`;\n}\n\n/**\n * Check if we can use DOM APIs.\n * This is useful for code that needs to run only in the browser.\n */\nexport const canUseDOM = !isServer;\n","/**\n * Radio group state for Solid Stately\n *\n * Provides state management for a radio group component.\n * Provides a name for the group, and manages selection and focus state.\n *\n * This is a 1:1 port of @react-stately/radio's useRadioGroupState.\n */\n\nimport { createMemo, createSignal, Accessor, untrack } from \"solid-js\";\nimport { type MaybeAccessor, access } from \"../utils\";\nimport { createId } from \"../ssr\";\nimport {\n createFormValidationState,\n type FormValidationState,\n type ValidationFunction,\n type ValidationResult,\n} from \"../form\";\n\nexport interface RadioGroupProps {\n /** The current selected value (controlled). */\n value?: string | null;\n /** The default selected value (uncontrolled). */\n defaultValue?: string | null;\n /** Handler that is called when the value changes. */\n onChange?: (value: string) => void;\n /** Whether the radio group is disabled. */\n isDisabled?: boolean;\n /** Whether the radio group is read only. */\n isReadOnly?: boolean;\n /** Whether the radio group is required. */\n isRequired?: boolean;\n /** Whether the radio group is invalid. */\n isInvalid?: boolean;\n /** The name of the radio group, used when submitting an HTML form. */\n name?: string;\n /** The form to associate the radio group with. */\n form?: string;\n /** The label for the radio group. */\n label?: string;\n /** Orientation of the radio group. */\n orientation?: \"horizontal\" | \"vertical\";\n /** Handler that is called when the radio group receives focus. */\n onFocus?: (e: FocusEvent) => void;\n /** Handler that is called when the radio group loses focus. */\n onBlur?: (e: FocusEvent) => void;\n /** Handler that is called when the radio group's focus status changes. */\n onFocusChange?: (isFocused: boolean) => void;\n /** Backward-compatible controlled validation state. */\n validationState?: \"valid\" | \"invalid\";\n /** Custom validation function. */\n validate?: ValidationFunction<string | null>;\n /** Validation behavior for the radio group. */\n validationBehavior?: \"aria\" | \"native\";\n}\n\nexport interface RadioGroupState extends Pick<\n FormValidationState,\n | \"realtimeValidation\"\n | \"displayValidation\"\n | \"updateValidation\"\n | \"resetValidation\"\n | \"commitValidation\"\n> {\n /** The name for the group, used for native form submission. */\n readonly name: string;\n\n /** Whether the radio group is disabled. */\n readonly isDisabled: boolean;\n\n /** Whether the radio group is read only. */\n readonly isReadOnly: boolean;\n\n /** Whether the radio group is required. */\n readonly isRequired: boolean;\n\n /** Whether the radio group is invalid. */\n readonly isInvalid: boolean;\n\n /** The currently selected value. */\n readonly selectedValue: Accessor<string | null>;\n\n /** The default selected value. */\n readonly defaultSelectedValue: string | null;\n\n /** Sets the selected value. */\n setSelectedValue(value: string | null): void;\n\n /** The value of the last focused radio. */\n readonly lastFocusedValue: Accessor<string | null>;\n\n /** Sets the last focused value. */\n setLastFocusedValue(value: string | null): void;\n\n /** Current display validation result for the group. */\n readonly displayValidation: Accessor<ValidationResult>;\n}\n\n/**\n * Internal WeakMap to store sync version accessors for each radio group state.\n * This is used by createRadio to trigger DOM sync when native radio behavior\n * causes the DOM checked state to desync from our reactive state.\n *\n * This is kept separate from RadioGroupState to maintain API parity with React-Stately.\n * @internal\n */\nexport const radioGroupSyncVersion: WeakMap<RadioGroupState, Accessor<number>> = new WeakMap();\n\n/**\n * Provides state management for a radio group component.\n * Provides a name for the group, and manages selection and focus state.\n */\nexport function createRadioGroupState(props: MaybeAccessor<RadioGroupProps> = {}): RadioGroupState {\n const getProps = () => access(props);\n\n // Get initial props using untrack to avoid setting up dependencies\n // This ensures we capture the initial defaultValue without reactivity issues\n const initialProps = untrack(() => getProps());\n\n // Generate name - preserved for backward compatibility\n // React Aria now generates the name instead of stately\n const name = initialProps.name || `radio-group-${createId()}`;\n\n // Create internal signal for uncontrolled mode\n // Initialize with defaultValue only (not value, which is for controlled mode)\n const [internalValue, setInternalValue] = createSignal<string | null>(\n initialProps.defaultValue ?? null,\n );\n const [lastFocusedValue, setLastFocusedValueInternal] = createSignal<string | null>(null);\n\n // SolidJS-specific: Version counter for triggering DOM sync across all radios\n // This handles the case where native radio behavior causes DOM state to desync\n // from our reactive state (e.g., clicking a radio unchecks siblings in the DOM)\n const [syncVersion, setSyncVersion] = createSignal(0);\n\n const controlledValue = createMemo<string | null | undefined>(() => {\n const value = getProps().value;\n return value === undefined ? undefined : (value ?? null);\n });\n\n // Determine if controlled - must be reactive to handle dynamic props\n const isControlled = () => controlledValue() !== undefined;\n\n // Get current value - reactive for both controlled and uncontrolled modes\n const selectedValue: Accessor<string | null> = () => {\n // In controlled mode, always read from props.value reactively\n // In uncontrolled mode, read from internal signal\n const value = controlledValue();\n if (value !== undefined) {\n return value;\n }\n return internalValue();\n };\n\n const validation = createFormValidationState<string | null>({\n get value() {\n return selectedValue();\n },\n get isInvalid() {\n return getProps().isInvalid;\n },\n get validationState() {\n return getProps().validationState;\n },\n get validate() {\n return getProps().validate;\n },\n get validationBehavior() {\n return getProps().validationBehavior ?? \"native\";\n },\n get name() {\n return getProps().name;\n },\n });\n\n // Set value\n function setSelectedValue(value: string | null): void {\n const p = getProps();\n if (p.isReadOnly || p.isDisabled) {\n return;\n }\n\n // Always increment syncVersion to trigger DOM sync across all radios\n // This is crucial for SolidJS because:\n // 1. Native radio behavior unchecks siblings when one is checked\n // 2. In controlled mode, isSelected() may not change even though DOM changed\n // 3. We need ALL radios to re-sync their checked state after any click\n setSyncVersion((v) => v + 1);\n\n if (!isControlled()) {\n setInternalValue(value);\n }\n\n if (value != null) {\n p.onChange?.(value);\n }\n\n validation.commitValidation();\n }\n\n // Set last focused value\n function setLastFocusedValue(value: string | null): void {\n setLastFocusedValueInternal(value);\n }\n\n const state: RadioGroupState = {\n name,\n selectedValue,\n defaultSelectedValue: initialProps.defaultValue ?? null,\n setSelectedValue,\n lastFocusedValue,\n setLastFocusedValue,\n realtimeValidation: validation.realtimeValidation,\n displayValidation: validation.displayValidation,\n updateValidation: validation.updateValidation,\n resetValidation: validation.resetValidation,\n commitValidation: validation.commitValidation,\n get isDisabled() {\n return getProps().isDisabled ?? false;\n },\n get isReadOnly() {\n return getProps().isReadOnly ?? false;\n },\n get isRequired() {\n return getProps().isRequired ?? false;\n },\n get isInvalid() {\n return validation.displayValidation().isInvalid;\n },\n };\n\n // Store syncVersion in internal WeakMap (not part of public API)\n // This maintains API parity with React-Stately while supporting SolidJS's reactivity needs\n radioGroupSyncVersion.set(state, syncVersion);\n\n return state;\n}\n","/**\n * Manages state for an overlay trigger.\n * Based on @react-stately/overlays useOverlayTriggerState.\n */\n\nimport { createSignal, type Accessor } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils\";\n\nexport interface OverlayTriggerProps {\n /** Whether the overlay is open by default (uncontrolled). */\n defaultOpen?: boolean;\n /** Whether the overlay is open (controlled). */\n isOpen?: boolean;\n /** Handler that is called when the overlay's open state changes. */\n onOpenChange?: (isOpen: boolean) => void;\n}\n\nexport interface OverlayTriggerState {\n /** Whether the overlay is currently open. */\n readonly isOpen: Accessor<boolean>;\n /** Sets whether the overlay is open. */\n setOpen(isOpen: boolean): void;\n /** Opens the overlay. */\n open(): void;\n /** Closes the overlay. */\n close(): void;\n /** Toggles the overlay's visibility. */\n toggle(): void;\n}\n\n/**\n * Manages state for an overlay trigger. Tracks whether the overlay is open, and provides\n * methods to toggle this state.\n */\nexport function createOverlayTriggerState(\n props: MaybeAccessor<OverlayTriggerProps> = {},\n): OverlayTriggerState {\n const propsAccessor = () => access(props);\n\n const [internalOpen, setInternalOpen] = createSignal(propsAccessor().defaultOpen ?? false);\n\n const isOpen: Accessor<boolean> = () => {\n const p = propsAccessor();\n return p.isOpen !== undefined ? p.isOpen : internalOpen();\n };\n\n const setOpen = (open: boolean) => {\n const p = propsAccessor();\n if (p.isOpen === undefined) {\n setInternalOpen(open);\n }\n p.onOpenChange?.(open);\n };\n\n const open = () => setOpen(true);\n const close = () => setOpen(false);\n const toggle = () => setOpen(!isOpen());\n\n return {\n isOpen,\n setOpen,\n open,\n close,\n toggle,\n };\n}\n","/**\n * A simple list collection implementation.\n * Provides a Collection interface over an array of nodes.\n */\n\nimport type { Collection, CollectionItemLike, CollectionNode, Key } from \"./types\";\n\n/**\n * A basic implementation of Collection for list-based components.\n */\nexport class ListCollection<T = unknown> implements Collection<T> {\n private nodes: CollectionNode<T>[];\n private keyMap: Map<Key, CollectionNode<T>>;\n\n constructor(nodes: CollectionNode<T>[]) {\n this.nodes = nodes;\n this.keyMap = new Map();\n\n // Build key map for O(1) lookups\n const addToMap = (node: CollectionNode<T>) => {\n this.keyMap.set(node.key, node);\n if (node.childNodes) {\n for (const child of node.childNodes) {\n addToMap(child);\n }\n }\n };\n\n for (const node of nodes) {\n addToMap(node);\n }\n }\n\n get size(): number {\n return this.keyMap.size;\n }\n\n *[Symbol.iterator](): Iterator<CollectionNode<T>> {\n yield* this.nodes;\n }\n\n *getKeys(): Iterable<Key> {\n for (const node of this.keyMap.values()) {\n yield node.key;\n }\n }\n\n getItem(key: Key): CollectionNode<T> | null {\n return this.keyMap.get(key) ?? null;\n }\n\n at(index: number): CollectionNode<T> | null {\n // Flatten all items for indexing\n const items = this.getAllItems();\n return items[index] ?? null;\n }\n\n getKeyBefore(key: Key): Key | null {\n const items = this.getAllItems();\n const index = items.findIndex((item) => item.key === key);\n if (index <= 0) return null;\n return items[index - 1].key;\n }\n\n getKeyAfter(key: Key): Key | null {\n const items = this.getAllItems();\n const index = items.findIndex((item) => item.key === key);\n if (index < 0 || index >= items.length - 1) return null;\n return items[index + 1].key;\n }\n\n getFirstKey(): Key | null {\n const items = this.getAllItems();\n return items[0]?.key ?? null;\n }\n\n getLastKey(): Key | null {\n const items = this.getAllItems();\n return items[items.length - 1]?.key ?? null;\n }\n\n *getChildren(key: Key): Iterable<CollectionNode<T>> {\n const node = this.getItem(key);\n if (node?.childNodes) {\n yield* node.childNodes;\n }\n }\n\n getTextValue(key: Key): string {\n return this.getItem(key)?.textValue ?? \"\";\n }\n\n /**\n * Get all items (excluding sections, including items within sections).\n */\n private getAllItems(): CollectionNode<T>[] {\n const items: CollectionNode<T>[] = [];\n\n const addItems = (nodes: CollectionNode<T>[]) => {\n for (const node of nodes) {\n if (node.type === \"item\") {\n items.push(node);\n } else if (node.type === \"section\" && node.childNodes) {\n addItems(node.childNodes);\n }\n }\n };\n\n addItems(this.nodes);\n return items;\n }\n}\n\n/**\n * Create a collection from an array of items.\n */\nexport function createListCollection<T>(\n items: T[],\n options: {\n getKey?: (item: T, index: number) => Key;\n getTextValue?: (item: T) => string;\n getDisabled?: (item: T) => boolean;\n } = {},\n): ListCollection<T> {\n const {\n getKey = (item: T, index: number) => {\n const o = item as CollectionItemLike;\n return o.key ?? o.id ?? index;\n },\n getTextValue = (item: T) => {\n const o = item as CollectionItemLike;\n return o.textValue ?? o.label ?? String(item);\n },\n getDisabled = (item: T) => (item as CollectionItemLike).isDisabled ?? false,\n } = options;\n\n const nodes: CollectionNode<T>[] = items.map((item, index) => ({\n type: \"item\" as const,\n key: getKey(item, index),\n value: item,\n textValue: getTextValue(item),\n rendered: null!, // Will be set by component\n level: 0,\n index,\n parentKey: null,\n hasChildNodes: false,\n childNodes: [],\n isDisabled: getDisabled(item),\n }));\n\n return new ListCollection(nodes);\n}\n","/**\n * Selection state management for collections.\n * Based on @react-stately/selection.\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils\";\nimport type {\n Collection,\n DisabledBehavior,\n FocusStrategy,\n Key,\n Selection,\n SelectionBehavior,\n SelectionMode,\n} from \"./types\";\n\nexport interface SelectionStateProps {\n /** The selection mode. */\n selectionMode?: SelectionMode;\n /** How selection behaves on interaction. */\n selectionBehavior?: SelectionBehavior;\n /** Whether empty selection is disallowed. */\n disallowEmptySelection?: boolean;\n /** Currently selected keys (controlled). */\n selectedKeys?: \"all\" | Iterable<Key>;\n /** Default selected keys (uncontrolled). */\n defaultSelectedKeys?: \"all\" | Iterable<Key>;\n /** Handler for selection changes. */\n onSelectionChange?: (keys: Selection) => void;\n /** Keys of disabled items. */\n disabledKeys?: Iterable<Key>;\n /** How disabled keys behave. */\n disabledBehavior?: DisabledBehavior;\n /** Whether to allow duplicate selection events. */\n allowDuplicateSelectionEvents?: boolean;\n}\n\nexport interface SelectionState {\n /** The selection mode. */\n readonly selectionMode: Accessor<SelectionMode>;\n /** The selection behavior. */\n readonly selectionBehavior: Accessor<SelectionBehavior>;\n /** Whether empty selection is disallowed. */\n readonly disallowEmptySelection: Accessor<boolean>;\n /** The currently selected keys. */\n readonly selectedKeys: Accessor<Selection>;\n /** Set of disabled keys. */\n readonly disabledKeys: Accessor<Set<Key>>;\n /** How disabled keys behave. */\n readonly disabledBehavior: Accessor<DisabledBehavior>;\n /** Whether the selection is empty. */\n readonly isEmpty: Accessor<boolean>;\n /** Whether all items are selected. */\n readonly isSelectAll: Accessor<boolean>;\n /** Check if a key is selected. */\n isSelected(key: Key): boolean;\n /** Check if a key is disabled. */\n isDisabled(key: Key): boolean;\n /** Set the selection behavior. */\n setSelectionBehavior(behavior: SelectionBehavior): void;\n /** Toggle selection for a key. */\n toggleSelection(key: Key): void;\n /** Replace selection with a single key. */\n replaceSelection(key: Key): void;\n /** Set multiple selected keys. */\n setSelectedKeys(keys: Iterable<Key>): void;\n /** Select all items. */\n selectAll(): void;\n /** Clear all selection. */\n clearSelection(): void;\n /** Toggle between select all and clear. */\n toggleSelectAll(): void;\n /** Extend selection to a key (for shift-click). */\n extendSelection(toKey: Key, collection: Collection): void;\n /** Select a key based on interaction. */\n select(key: Key, e?: SelectionPressEvent): void;\n}\n\n/**\n * The press/pointer interaction consulted by {@link SelectionState.select}.\n * Mirrors react-stately's `SelectionManager.select(e)`: only `pointerType` is\n * read here (touch / virtual force toggle, since those devices have no modifier\n * keys). Modifier keys (ctrl / meta / shift) are resolved one layer up in the\n * aria-layer `onSelect` (solidaria `selectItem`), matching upstream's split\n * between react-stately and react-aria. The modifier fields are accepted so a\n * full press/pointer event is assignable, but they are not read here.\n */\nexport interface SelectionPressEvent {\n pointerType?: \"mouse\" | \"pen\" | \"touch\" | \"keyboard\" | \"virtual\";\n shiftKey?: boolean;\n ctrlKey?: boolean;\n metaKey?: boolean;\n altKey?: boolean;\n}\n\n/**\n * Creates selection state for a collection.\n */\nexport function createSelectionState(\n props: MaybeAccessor<SelectionStateProps> = {},\n): SelectionState {\n const getProps = () => access(props);\n\n // Selection behavior state\n const [internalBehavior, setInternalBehavior] = createSignal<SelectionBehavior>(\"toggle\");\n\n // Internal selection state\n const [internalSelectedKeys, setInternalSelectedKeys] = createSignal<Selection>(\n getInitialSelection(getProps().defaultSelectedKeys),\n );\n\n // Track anchor for range selection\n const [anchorKey, setAnchorKey] = createSignal<Key | null>(null);\n\n // Computed values\n const selectionMode: Accessor<SelectionMode> = () => getProps().selectionMode ?? \"none\";\n\n const selectionBehavior: Accessor<SelectionBehavior> = () => {\n return getProps().selectionBehavior ?? internalBehavior();\n };\n\n const disallowEmptySelection: Accessor<boolean> = () => {\n return getProps().disallowEmptySelection ?? false;\n };\n\n const selectedKeys: Accessor<Selection> = createMemo(() => {\n const p = getProps();\n if (p.selectedKeys !== undefined) {\n return normalizeSelection(p.selectedKeys);\n }\n return internalSelectedKeys();\n });\n\n const disabledKeys: Accessor<Set<Key>> = createMemo(() => {\n const keys = getProps().disabledKeys;\n return keys ? new Set<Key>(keys) : new Set<Key>();\n });\n\n const disabledBehavior: Accessor<DisabledBehavior> = () => {\n return getProps().disabledBehavior ?? \"all\";\n };\n\n const isEmpty: Accessor<boolean> = () => {\n const keys = selectedKeys();\n return keys !== \"all\" && keys.size === 0;\n };\n\n const isSelectAll: Accessor<boolean> = () => {\n return selectedKeys() === \"all\";\n };\n\n // Methods\n const isSelected = (key: Key): boolean => {\n const keys = selectedKeys();\n if (keys === \"all\") return true;\n return keys.has(key);\n };\n\n const isDisabled = (key: Key): boolean => {\n return disabledKeys().has(key);\n };\n\n const updateSelection = (newSelection: Selection) => {\n const p = getProps();\n\n // Controlled mode\n if (p.selectedKeys !== undefined) {\n p.onSelectionChange?.(newSelection);\n return;\n }\n\n // Uncontrolled mode\n const current = internalSelectedKeys();\n const isDifferent =\n current === \"all\" ||\n newSelection === \"all\" ||\n current.size !== (newSelection as Set<Key>).size ||\n ![...current].every((k) => (newSelection as Set<Key>).has(k));\n\n if (isDifferent || p.allowDuplicateSelectionEvents) {\n setInternalSelectedKeys(newSelection);\n p.onSelectionChange?.(newSelection);\n }\n };\n\n const toggleSelection = (key: Key) => {\n if (isDisabled(key)) return;\n if (selectionMode() === \"none\") return;\n\n const current = selectedKeys();\n\n if (selectionMode() === \"single\") {\n if (isSelected(key) && !disallowEmptySelection()) {\n updateSelection(new Set());\n } else {\n updateSelection(new Set([key]));\n }\n return;\n }\n\n // Multiple selection\n if (current === \"all\") {\n // Can't toggle when all selected without collection\n return;\n }\n\n const newSelection = new Set(current);\n if (newSelection.has(key)) {\n if (newSelection.size > 1 || !disallowEmptySelection()) {\n newSelection.delete(key);\n }\n } else {\n newSelection.add(key);\n }\n\n updateSelection(newSelection);\n setAnchorKey(key);\n };\n\n const replaceSelection = (key: Key) => {\n if (isDisabled(key)) return;\n if (selectionMode() === \"none\") return;\n\n updateSelection(new Set([key]));\n setAnchorKey(key);\n };\n\n const setSelectedKeys = (keys: Iterable<Key>) => {\n const filtered = [...keys].filter((k) => !isDisabled(k));\n updateSelection(new Set(filtered));\n };\n\n const selectAll = () => {\n if (selectionMode() !== \"multiple\") return;\n updateSelection(\"all\");\n };\n\n const clearSelection = () => {\n if (disallowEmptySelection()) return;\n updateSelection(new Set());\n };\n\n const toggleSelectAll = () => {\n if (selectionMode() !== \"multiple\") return;\n\n if (isSelectAll()) {\n clearSelection();\n } else {\n selectAll();\n }\n };\n\n const extendSelection = (toKey: Key, collection: Collection) => {\n if (isDisabled(toKey)) return;\n if (selectionMode() !== \"multiple\") {\n replaceSelection(toKey);\n return;\n }\n\n const anchor = anchorKey();\n if (!anchor) {\n replaceSelection(toKey);\n return;\n }\n\n // Get keys between anchor and toKey\n const keys = [...collection.getKeys()];\n const anchorIndex = keys.indexOf(anchor);\n const toIndex = keys.indexOf(toKey);\n\n if (anchorIndex === -1 || toIndex === -1) {\n replaceSelection(toKey);\n return;\n }\n\n const start = Math.min(anchorIndex, toIndex);\n const end = Math.max(anchorIndex, toIndex);\n const rangeKeys = keys.slice(start, end + 1).filter((k) => !isDisabled(k));\n\n updateSelection(new Set(rangeKeys));\n };\n\n const select = (key: Key, e?: SelectionPressEvent) => {\n // Mirrors react-stately's SelectionManager.select: only pointerType +\n // selectionBehavior are consulted here. Modifier-key handling (ctrl / meta\n // ⇒ toggle, shift ⇒ extend) lives one layer up in solidaria's aria-layer\n // `selectItem`, which is where the platform-aware isCtrlKeyPressed is\n // available. The primitives self-guard disabled keys, so no guard is\n // needed here (matching upstream).\n if (selectionMode() === \"none\") return;\n\n if (selectionMode() === \"single\") {\n // Single mode ignores selectionBehavior. Re-selecting the current item\n // deselects it when empty selection is allowed; otherwise it stays\n // selected (replace).\n if (isSelected(key) && !disallowEmptySelection()) {\n toggleSelection(key);\n } else {\n replaceSelection(key);\n }\n } else if (\n selectionBehavior() === \"toggle\" ||\n (e != null && (e.pointerType === \"touch\" || e.pointerType === \"virtual\"))\n ) {\n // touch / virtual (VoiceOver) have no modifier keys, so multi-select is\n // only reachable by toggling.\n toggleSelection(key);\n } else {\n replaceSelection(key);\n }\n };\n\n const setSelectionBehavior = (behavior: SelectionBehavior) => {\n setInternalBehavior(behavior);\n };\n\n return {\n selectionMode,\n selectionBehavior,\n disallowEmptySelection,\n selectedKeys,\n disabledKeys,\n disabledBehavior,\n isEmpty,\n isSelectAll,\n isSelected,\n isDisabled,\n setSelectionBehavior,\n toggleSelection,\n replaceSelection,\n setSelectedKeys,\n selectAll,\n clearSelection,\n toggleSelectAll,\n extendSelection,\n select,\n };\n}\n\n// Helper functions\nfunction getInitialSelection(defaultKeys?: \"all\" | Iterable<Key>): Selection {\n if (defaultKeys === undefined) return new Set();\n return normalizeSelection(defaultKeys);\n}\n\nfunction normalizeSelection(keys: \"all\" | Iterable<Key>): Selection {\n if (keys === \"all\") return \"all\";\n return new Set(keys);\n}\n","/**\n * A Selection is a special Set containing Keys, which also has an anchor\n * and current selected key for use when range selecting.\n *\n * Based on @react-stately/selection.\n */\n\nimport type { Key } from \"../collections/types\";\n\n/**\n * A Selection is a special Set containing Keys, which also has an anchor\n * and current selected key for use when range selecting.\n */\nexport class Selection extends Set<Key> {\n anchorKey: Key | null;\n currentKey: Key | null;\n\n constructor(keys?: Iterable<Key> | Selection, anchorKey?: Key | null, currentKey?: Key | null) {\n super(keys);\n if (keys instanceof Selection) {\n this.anchorKey = anchorKey ?? keys.anchorKey;\n this.currentKey = currentKey ?? keys.currentKey;\n } else {\n this.anchorKey = anchorKey ?? null;\n this.currentKey = currentKey ?? null;\n }\n }\n}\n","/**\n * Raw multiple-selection + focus state for a collection.\n *\n * The lower of the two selection layers ported from upstream\n * (`@react-stately/selection`'s `useMultipleSelectionState`): it owns the\n * selected keys, focus, selection behavior, and disabled keys, but is NOT\n * collection-aware. The collection-aware operations (toggle, extend, select\n * all, range, etc.) live in {@link SelectionManager}, which is built on top of\n * this state.\n *\n * Based on @react-stately/selection.\n */\n\nimport { createSignal, createMemo, createComputed, untrack, type Accessor } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils\";\nimport type { SelectionStateProps } from \"../collections/createSelectionState\";\nimport type {\n DisabledBehavior,\n FocusStrategy,\n Key,\n Selection,\n SelectionBehavior,\n SelectionMode,\n} from \"../collections/types\";\nimport { Selection as SelectionClass } from \"./Selection\";\n\n/**\n * The raw state consumed by {@link SelectionManager}. Mirrors upstream's\n * `MultipleSelectionState`: property reads (not Solid accessors) so the manager\n * can read `state.selectionMode` etc. exactly as upstream does — the getters\n * read the underlying signals, so reads inside reactive scopes still track.\n */\nexport interface MultipleSelectionState {\n /** The type of selection that is allowed in the collection. */\n readonly selectionMode: SelectionMode;\n /** The selection behavior for the collection. */\n readonly selectionBehavior: SelectionBehavior;\n /** Sets the selection behavior for the collection. */\n setSelectionBehavior(selectionBehavior: SelectionBehavior): void;\n /** Whether the collection allows empty selection. */\n readonly disallowEmptySelection: boolean;\n /** Whether the collection is currently focused. */\n readonly isFocused: boolean;\n /** Sets whether the collection is focused. */\n setFocused(isFocused: boolean): void;\n /** The current focused key in the collection. */\n readonly focusedKey: Key | null;\n /** Whether the first or last child of the focused key should receive focus. */\n readonly childFocusStrategy: FocusStrategy | null;\n /** Sets the focused key, and optionally, whether the first or last child of that key should receive focus. */\n setFocusedKey(key: Key | null, childFocusStrategy?: FocusStrategy): void;\n /** The currently selected keys in the collection. */\n readonly selectedKeys: Selection;\n /** The last selection payload emitted through onSelectionChange. @internal */\n readonly lastSelectionEvent: Selection | null;\n /** Sets the selected keys in the collection. */\n setSelectedKeys(keys: Selection): void;\n /** Re-emits a selection payload without recomputing or mutating selection. @internal */\n emitDuplicateSelectionEvent(keys?: Selection): void;\n /** The currently disabled keys in the collection. */\n readonly disabledKeys: Set<Key>;\n /** Whether `disabledKeys` applies to all interactions, or only selection. */\n readonly disabledBehavior: DisabledBehavior;\n}\n\nfunction equalSets(setA: Set<Key>, setB: Set<Key>): boolean {\n if (setA.size !== setB.size) {\n return false;\n }\n\n for (const item of setA) {\n if (!setB.has(item)) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction convertSelection(\n selection: \"all\" | Iterable<Key> | null | undefined,\n defaultValue: Selection,\n): Selection;\nfunction convertSelection(\n selection: \"all\" | Iterable<Key> | null | undefined,\n): Selection | undefined;\nfunction convertSelection(\n selection: \"all\" | Iterable<Key> | null | undefined,\n defaultValue?: Selection,\n): Selection | undefined {\n if (!selection) {\n return defaultValue;\n }\n\n return selection === \"all\" ? \"all\" : new SelectionClass(selection);\n}\n\n/**\n * Manages raw state for multiple selection and focus in a collection.\n */\nexport function createMultipleSelectionState(\n props: MaybeAccessor<SelectionStateProps> = {},\n): MultipleSelectionState {\n const getProps = () => access(props);\n\n // Focus is a plain signal in Solid; upstream needs a ref + state pair only\n // because React requires both a synchronous read and a re-render trigger.\n const [isFocused, setIsFocused] = createSignal(false);\n const [focusedKey, setFocusedKeySignal] = createSignal<Key | null>(null);\n const [childFocusStrategy, setChildFocusStrategy] = createSignal<FocusStrategy | null>(null);\n\n const defaultSelectedKeys = convertSelection(\n getProps().defaultSelectedKeys,\n new SelectionClass(),\n );\n const [uncontrolledSelectedKeys, setUncontrolledSelectedKeys] =\n createSignal<Selection>(defaultSelectedKeys);\n\n const selectedKeys = createMemo<Selection>(() => {\n const p = getProps();\n if (p.selectedKeys !== undefined) {\n return convertSelection(p.selectedKeys, new SelectionClass());\n }\n return uncontrolledSelectedKeys();\n });\n\n // Selection behavior is seeded from the prop but kept in internal state so\n // that `setSelectionBehavior` (e.g. the long-press-to-select touch flow) can\n // override it. Two reactive rules mirror upstream's render-time logic.\n const selectionBehaviorProp = (): SelectionBehavior => getProps().selectionBehavior ?? \"toggle\";\n\n const [selectionBehavior, setSelectionBehaviorState] =\n createSignal<SelectionBehavior>(selectionBehaviorProp());\n\n // If the selectionBehavior prop is 'replace' but the current state is 'toggle'\n // (e.g. due to a long press to enter selection mode on touch) and the\n // selection becomes empty, reset the behavior back to 'replace'.\n createComputed(() => {\n const keys = selectedKeys();\n if (\n selectionBehaviorProp() === \"replace\" &&\n untrack(selectionBehavior) === \"toggle\" &&\n typeof keys === \"object\" &&\n keys.size === 0\n ) {\n setSelectionBehaviorState(\"replace\");\n }\n });\n\n // If the selectionBehavior prop changes, sync it into state.\n let lastSelectionBehavior = selectionBehaviorProp();\n createComputed(() => {\n const prop = selectionBehaviorProp();\n if (prop !== lastSelectionBehavior) {\n setSelectionBehaviorState(prop);\n lastSelectionBehavior = prop;\n }\n });\n\n const disabledKeys = createMemo<Set<Key>>(() => {\n const keys = getProps().disabledKeys;\n return keys ? new Set<Key>(keys) : new Set<Key>();\n });\n\n let lastSelectionEvent: Selection | null = null;\n\n const emitSelectionEvent = (keys: Selection) => {\n lastSelectionEvent = keys;\n getProps().onSelectionChange?.(keys);\n };\n\n const setSelectedKeys = (keys: Selection) => {\n const p = getProps();\n const current = selectedKeys();\n const shouldUpdate =\n p.allowDuplicateSelectionEvents ||\n keys === \"all\" ||\n current === \"all\" ||\n !equalSets(keys, current);\n\n if (!shouldUpdate) {\n return;\n }\n\n // Uncontrolled: store internally. Controlled: only notify.\n if (p.selectedKeys === undefined) {\n setUncontrolledSelectedKeys(keys);\n }\n emitSelectionEvent(keys);\n };\n\n const emitDuplicateSelectionEvent = (keys?: Selection) => {\n const eventKeys = keys ?? lastSelectionEvent;\n if (eventKeys == null) {\n return;\n }\n emitSelectionEvent(eventKeys);\n };\n\n return {\n get selectionMode() {\n return getProps().selectionMode ?? \"none\";\n },\n get selectionBehavior() {\n return selectionBehavior();\n },\n setSelectionBehavior(behavior: SelectionBehavior) {\n setSelectionBehaviorState(behavior);\n },\n get disallowEmptySelection() {\n return getProps().disallowEmptySelection ?? false;\n },\n get isFocused() {\n return isFocused();\n },\n setFocused(f: boolean) {\n setIsFocused(f);\n },\n get focusedKey() {\n return focusedKey();\n },\n get childFocusStrategy() {\n return childFocusStrategy();\n },\n setFocusedKey(key: Key | null, strategy: FocusStrategy = \"first\") {\n setFocusedKeySignal(key);\n setChildFocusStrategy(strategy);\n },\n get selectedKeys() {\n return selectedKeys();\n },\n get lastSelectionEvent() {\n return lastSelectionEvent;\n },\n setSelectedKeys,\n emitDuplicateSelectionEvent,\n get disabledKeys() {\n return disabledKeys();\n },\n get disabledBehavior() {\n return getProps().disabledBehavior ?? \"all\";\n },\n };\n}\n\n// Re-export the accessor type for convenience where a reactive read is wanted.\nexport type { Accessor };\n","/**\n * Helpers for traversing collection nodes and comparing their document order.\n *\n * Based on @react-stately/collections.\n */\n\nimport type { Collection, CollectionNode } from \"./types\";\n\nexport function getChildNodes<T>(\n node: CollectionNode<T>,\n collection: Collection<T>,\n): Iterable<CollectionNode<T>> {\n // New API: call collection.getChildren with the node key.\n if (typeof collection.getChildren === \"function\") {\n return collection.getChildren(node.key);\n }\n\n // Old API: access childNodes directly.\n return node.childNodes;\n}\n\nexport function getFirstItem<T>(iterable: Iterable<T>): T | undefined {\n return getNthItem(iterable, 0);\n}\n\nexport function getNthItem<T>(iterable: Iterable<T>, index: number): T | undefined {\n if (index < 0) {\n return undefined;\n }\n\n let i = 0;\n for (const item of iterable) {\n if (i === index) {\n return item;\n }\n\n i++;\n }\n}\n\nexport function getLastItem<T>(iterable: Iterable<T>): T | undefined {\n let lastItem: T | undefined = undefined;\n for (const value of iterable) {\n lastItem = value;\n }\n\n return lastItem;\n}\n\nexport function compareNodeOrder<T>(\n collection: Collection<T>,\n a: CollectionNode<T>,\n b: CollectionNode<T>,\n): number {\n // If the two nodes have the same parent, compare their indices.\n if (a.parentKey === b.parentKey) {\n return a.index - b.index;\n }\n\n // Otherwise, collect all of the ancestors from each node, and find the first one that doesn't match starting from the root.\n // Include the base nodes in case we are comparing nodes of different levels so that we can compare the higher node to the lower level node's\n // ancestor of the same level\n const aAncestors = [...getAncestors(collection, a), a];\n const bAncestors = [...getAncestors(collection, b), b];\n const firstNonMatchingAncestor = aAncestors\n .slice(0, bAncestors.length)\n .findIndex((a, i) => a !== bAncestors[i]);\n if (firstNonMatchingAncestor !== -1) {\n // Compare the indices of two children within the common ancestor.\n a = aAncestors[firstNonMatchingAncestor];\n b = bAncestors[firstNonMatchingAncestor];\n return a.index - b.index;\n }\n\n // If there isn't a non matching ancestor, we might be in a case where one of the nodes is the ancestor of the other.\n if (aAncestors.findIndex((node) => node === b) >= 0) {\n return 1;\n } else if (bAncestors.findIndex((node) => node === a) >= 0) {\n return -1;\n }\n\n // 🤷\n return -1;\n}\n\nfunction getAncestors<T>(collection: Collection<T>, node: CollectionNode<T>): CollectionNode<T>[] {\n const parents: CollectionNode<T>[] = [];\n\n let currNode: CollectionNode<T> | null = node;\n while (currNode?.parentKey != null) {\n currNode = collection.getItem(currNode.parentKey);\n if (currNode) {\n parents.unshift(currNode);\n }\n }\n\n return parents;\n}\n","/**\n * An interface for reading and updating multiple selection state.\n *\n * The upper of the two selection layers ported from upstream\n * (`@react-stately/selection`'s `SelectionManager`): the collection-aware\n * operations built on top of the raw {@link MultipleSelectionState}.\n *\n * React → Solid adaptations, all faithful to upstream's observable contract:\n * - Upstream re-instantiates `SelectionManager` every render to capture a\n * fresh `collection`. Here the manager is long-lived, so it captures a\n * reactive `collection` accessor and reads it live via `get collection()`.\n * - Upstream caches `_isSelectAll` for the lifetime of one render. A\n * long-lived manager would let that cache go stale, so it is dropped and\n * `isSelectAll` recomputes (it is consulted rarely — only by select-all UI).\n * - Our `CollectionNode` has no `'cell'` type (grids/trees use a separate\n * state engine), so the cell-selection branches are omitted.\n *\n * Based on @react-stately/selection.\n */\n\nimport { compareNodeOrder, getChildNodes, getFirstItem } from \"../collections/getChildNodes\";\nimport type { SelectionPressEvent } from \"../collections/createSelectionState\";\nimport type {\n Collection,\n CollectionNode,\n DisabledBehavior,\n FocusStrategy,\n Key,\n Selection as SelectionValue,\n SelectionBehavior,\n SelectionMode,\n} from \"../collections/types\";\nimport type { MultipleSelectionState } from \"./createMultipleSelectionState\";\nimport { Selection } from \"./Selection\";\n\n/** A delegate that can resolve a key range without walking the collection (e.g. a virtualized layout). */\nexport interface LayoutDelegate {\n getKeyRange?(from: Key, to: Key): Key[];\n}\n\nexport interface SelectionManagerOptions<T = unknown> {\n layoutDelegate?: LayoutDelegate;\n /**\n * The full (unfiltered) collection, used when materializing the 'all'\n * selection so that filtered-out items (e.g. by Autocomplete) are still\n * included.\n */\n fullCollection?: Collection<T>;\n}\n\n/**\n * An interface for reading and updating multiple selection state.\n */\nexport class SelectionManager<T = unknown> {\n private collectionAccessor: () => Collection<T>;\n private state: MultipleSelectionState;\n private layoutDelegate: LayoutDelegate | null;\n private fullCollection: Collection<T> | null;\n\n constructor(\n collection: () => Collection<T>,\n state: MultipleSelectionState,\n options?: SelectionManagerOptions<T>,\n ) {\n this.collectionAccessor = collection;\n this.state = state;\n this.layoutDelegate = options?.layoutDelegate ?? null;\n this.fullCollection = options?.fullCollection ?? null;\n }\n\n /** The collection the manager operates over (read live so it stays reactive). */\n get collection(): Collection<T> {\n return this.collectionAccessor();\n }\n\n /** The type of selection that is allowed in the collection. */\n get selectionMode(): SelectionMode {\n return this.state.selectionMode;\n }\n\n /** Whether the collection allows empty selection. */\n get disallowEmptySelection(): boolean {\n return this.state.disallowEmptySelection;\n }\n\n /** The selection behavior for the collection. */\n get selectionBehavior(): SelectionBehavior {\n return this.state.selectionBehavior;\n }\n\n /** Sets the selection behavior for the collection. */\n setSelectionBehavior(selectionBehavior: SelectionBehavior): void {\n this.state.setSelectionBehavior(selectionBehavior);\n }\n\n /** Whether the collection is currently focused. */\n get isFocused(): boolean {\n return this.state.isFocused;\n }\n\n /** Sets whether the collection is focused. */\n setFocused(isFocused: boolean): void {\n this.state.setFocused(isFocused);\n }\n\n /** The current focused key in the collection. */\n get focusedKey(): Key | null {\n return this.state.focusedKey;\n }\n\n /** Whether the first or last child of the focused key should receive focus. */\n get childFocusStrategy(): FocusStrategy | null {\n return this.state.childFocusStrategy;\n }\n\n /** Sets the focused key. */\n setFocusedKey(key: Key | null, childFocusStrategy?: FocusStrategy): void {\n if (key == null || this.collection.getItem(key)) {\n this.state.setFocusedKey(key, childFocusStrategy);\n }\n }\n\n /** The currently selected keys in the collection (materialized — 'all' is expanded). */\n get selectedKeys(): Set<Key> {\n const keys = this.state.selectedKeys;\n return keys === \"all\" ? new Set(this.getSelectAllKeys()) : keys;\n }\n\n /** The raw selection value for the collection. Either 'all' for select all, or a set of keys. */\n get rawSelection(): SelectionValue {\n return this.state.selectedKeys;\n }\n\n /** Last selection payload emitted through onSelectionChange. @internal */\n get lastSelectionEvent(): SelectionValue | null {\n return this.state.lastSelectionEvent;\n }\n\n /** Re-emits a selection payload without recomputing selection. @internal */\n emitDuplicateSelectionEvent(keys: SelectionValue | null = this.state.lastSelectionEvent): void {\n if (keys == null || this.selectionMode === \"none\") {\n return;\n }\n\n this.state.emitDuplicateSelectionEvent(keys);\n }\n\n /** Returns whether a key is selected. */\n isSelected(key: Key): boolean {\n if (this.state.selectionMode === \"none\") {\n return false;\n }\n\n const mappedKey = this.getKey(key);\n if (mappedKey == null) {\n return false;\n }\n const selectedKeys = this.state.selectedKeys;\n return selectedKeys === \"all\" ? this.canSelectItem(mappedKey) : selectedKeys.has(mappedKey);\n }\n\n /** Whether the selection is empty. */\n get isEmpty(): boolean {\n return this.state.selectedKeys !== \"all\" && this.state.selectedKeys.size === 0;\n }\n\n /** Whether all items in the collection are selected. */\n get isSelectAll(): boolean {\n if (this.isEmpty) {\n return false;\n }\n\n const selectedKeys = this.state.selectedKeys;\n if (selectedKeys === \"all\") {\n return true;\n }\n\n const allKeys = this.getSelectAllKeys();\n return allKeys.every((k) => selectedKeys.has(k));\n }\n\n get firstSelectedKey(): Key | null {\n let first: CollectionNode<T> | null = null;\n for (const key of this.state.selectedKeys) {\n const item = this.collection.getItem(key);\n if (!first || (item && compareNodeOrder(this.collection, item, first) < 0)) {\n first = item;\n }\n }\n\n return first?.key ?? null;\n }\n\n get lastSelectedKey(): Key | null {\n let last: CollectionNode<T> | null = null;\n for (const key of this.state.selectedKeys) {\n const item = this.collection.getItem(key);\n if (!last || (item && compareNodeOrder(this.collection, item, last) > 0)) {\n last = item;\n }\n }\n\n return last?.key ?? null;\n }\n\n get disabledKeys(): Set<Key> {\n return this.state.disabledKeys;\n }\n\n get disabledBehavior(): DisabledBehavior {\n return this.state.disabledBehavior;\n }\n\n /** Extends the selection to the given key. */\n extendSelection(toKey: Key): void {\n if (this.selectionMode === \"none\") {\n return;\n }\n\n if (this.selectionMode === \"single\") {\n this.replaceSelection(toKey);\n return;\n }\n\n const mappedToKey = this.getKey(toKey);\n if (mappedToKey == null) {\n return;\n }\n\n let selection: Selection;\n\n // Only select the one key if coming from a select all.\n const currentSelection = this.state.selectedKeys;\n if (currentSelection === \"all\") {\n selection = new Selection([mappedToKey], mappedToKey, mappedToKey);\n } else {\n const selectedKeys = currentSelection as Selection;\n const anchorKey = selectedKeys.anchorKey ?? mappedToKey;\n selection = new Selection(selectedKeys, anchorKey, mappedToKey);\n for (const key of this.getKeyRange(anchorKey, selectedKeys.currentKey ?? mappedToKey)) {\n selection.delete(key);\n }\n\n for (const key of this.getKeyRange(mappedToKey, anchorKey)) {\n if (this.canSelectItem(key)) {\n selection.add(key);\n }\n }\n }\n\n this.state.setSelectedKeys(selection);\n }\n\n private getKeyRange(from: Key, to: Key): Key[] {\n const fromItem = this.collection.getItem(from);\n const toItem = this.collection.getItem(to);\n if (fromItem && toItem) {\n if (compareNodeOrder(this.collection, fromItem, toItem) <= 0) {\n return this.getKeyRangeInternal(from, to);\n }\n\n return this.getKeyRangeInternal(to, from);\n }\n\n return [];\n }\n\n private getKeyRangeInternal(from: Key, to: Key): Key[] {\n if (this.layoutDelegate?.getKeyRange) {\n return this.layoutDelegate.getKeyRange(from, to);\n }\n\n const keys: Key[] = [];\n let key: Key | null = from;\n while (key != null) {\n const item = this.collection.getItem(key);\n if (item && item.type === \"item\") {\n keys.push(key);\n }\n\n if (key === to) {\n return keys;\n }\n\n key = this.collection.getKeyAfter(key);\n }\n\n return [];\n }\n\n private getKey(key: Key): Key | null {\n let item = this.collection.getItem(key);\n if (!item) {\n // ¯\\_(ツ)_/¯\n return key;\n }\n\n // Find a parent item to select.\n while (item && item.type !== \"item\" && item.parentKey != null) {\n item = this.collection.getItem(item.parentKey);\n }\n\n if (!item || item.type !== \"item\") {\n return null;\n }\n\n return item.key;\n }\n\n /** Toggles whether the given key is selected. */\n toggleSelection(key: Key): void {\n if (this.selectionMode === \"none\") {\n return;\n }\n\n if (this.selectionMode === \"single\" && !this.isSelected(key)) {\n this.replaceSelection(key);\n return;\n }\n\n const mappedKey = this.getKey(key);\n if (mappedKey == null) {\n return;\n }\n\n const keys = new Selection(\n this.state.selectedKeys === \"all\" ? this.getSelectAllKeys() : this.state.selectedKeys,\n );\n if (keys.has(mappedKey)) {\n keys.delete(mappedKey);\n // TODO: move anchor to last selected key...\n } else if (this.canSelectItem(mappedKey)) {\n keys.add(mappedKey);\n keys.anchorKey = mappedKey;\n keys.currentKey = mappedKey;\n }\n\n if (this.disallowEmptySelection && keys.size === 0) {\n return;\n }\n\n this.state.setSelectedKeys(keys);\n }\n\n /** Replaces the selection with only the given key. */\n replaceSelection(key: Key): void {\n if (this.selectionMode === \"none\") {\n return;\n }\n\n const mappedKey = this.getKey(key);\n if (mappedKey == null) {\n return;\n }\n\n const selection = this.canSelectItem(mappedKey)\n ? new Selection([mappedKey], mappedKey, mappedKey)\n : new Selection();\n\n this.state.setSelectedKeys(selection);\n }\n\n /** Replaces the selection with the given keys. */\n setSelectedKeys(keys: Iterable<Key>): void {\n if (this.selectionMode === \"none\") {\n return;\n }\n\n const selection = new Selection();\n for (const key of keys) {\n const mappedKey = this.getKey(key);\n if (mappedKey != null) {\n selection.add(mappedKey);\n if (this.selectionMode === \"single\") {\n break;\n }\n }\n }\n\n this.state.setSelectedKeys(selection);\n }\n\n private getSelectAllKeys(): Key[] {\n // Use the full (unfiltered) collection when available so that materializing\n // the 'all' selection includes items that are currently filtered out.\n const collection = this.fullCollection ?? this.collection;\n const keys: Key[] = [];\n const addKeys = (key: Key | null) => {\n while (key != null) {\n if (this.canSelectItemIn(key, collection)) {\n const item = collection.getItem(key);\n if (item?.type === \"item\") {\n keys.push(key);\n }\n\n // Add child keys for sections.\n if (item?.hasChildNodes && item.type !== \"item\") {\n addKeys(getFirstItem(getChildNodes(item, collection))?.key ?? null);\n }\n }\n\n key = collection.getKeyAfter(key);\n }\n };\n\n addKeys(collection.getFirstKey());\n return keys;\n }\n\n /** Selects all items in the collection. */\n selectAll(): void {\n if (!this.isSelectAll && this.selectionMode === \"multiple\") {\n this.state.setSelectedKeys(\"all\");\n }\n }\n\n /** Removes all keys from the selection. */\n clearSelection(): void {\n if (\n !this.disallowEmptySelection &&\n (this.state.selectedKeys === \"all\" || this.state.selectedKeys.size > 0)\n ) {\n this.state.setSelectedKeys(new Selection());\n }\n }\n\n /** Toggles between select all and an empty selection. */\n toggleSelectAll(): void {\n if (this.isSelectAll) {\n this.clearSelection();\n } else {\n this.selectAll();\n }\n }\n\n select(key: Key, e?: SelectionPressEvent): void {\n if (this.selectionMode === \"none\") {\n return;\n }\n\n if (this.selectionMode === \"single\") {\n if (this.isSelected(key) && !this.disallowEmptySelection) {\n this.toggleSelection(key);\n } else {\n this.replaceSelection(key);\n }\n } else if (\n this.selectionBehavior === \"toggle\" ||\n (e && (e.pointerType === \"touch\" || e.pointerType === \"virtual\"))\n ) {\n // touch / virtual (VoiceOver) have no modifier keys, so multi-select is\n // only reachable by toggling.\n this.toggleSelection(key);\n } else {\n this.replaceSelection(key);\n }\n }\n\n /** Returns whether the current selection is equal to the given selection. */\n isSelectionEqual(selection: Set<Key>): boolean {\n if (selection === this.state.selectedKeys) {\n return true;\n }\n\n // Check if the set of keys match.\n const selectedKeys = this.selectedKeys;\n if (selection.size !== selectedKeys.size) {\n return false;\n }\n\n for (const key of selection) {\n if (!selectedKeys.has(key)) {\n return false;\n }\n }\n\n for (const key of selectedKeys) {\n if (!selection.has(key)) {\n return false;\n }\n }\n\n return true;\n }\n\n canSelectItem(key: Key): boolean {\n return this.canSelectItemIn(key, this.collection);\n }\n\n private canSelectItemIn(key: Key, collection: Collection<T>): boolean {\n if (this.state.selectionMode === \"none\" || this.state.disabledKeys.has(key)) {\n return false;\n }\n\n const item = collection.getItem(key);\n if (!item || item.isDisabled || item.props?.isDisabled) {\n return false;\n }\n\n return true;\n }\n\n isDisabled(key: Key): boolean {\n const item = this.collection.getItem(key);\n return (\n this.state.disabledBehavior === \"all\" &&\n (this.state.disabledKeys.has(key) || !!item?.props?.isDisabled) &&\n item?.props?.disabledBehavior !== \"selection\"\n );\n }\n\n isLink(key: Key): boolean {\n return !!this.collection.getItem(key)?.props?.href;\n }\n\n getItemProps(key: Key): Record<string, unknown> | undefined {\n return this.collection.getItem(key)?.props;\n }\n\n withCollection(collection: Collection<T>): SelectionManager<T> {\n return new SelectionManager<T>(() => collection, this.state, {\n layoutDelegate: this.layoutDelegate ?? undefined,\n fullCollection: this.fullCollection ?? this.collection,\n });\n }\n}\n","/**\n * State management for list-like components.\n * Combines collection and selection state.\n * Based on @react-stately/list.\n */\n\nimport { createMemo, type Accessor } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils\";\nimport { ListCollection } from \"./ListCollection\";\nimport type { SelectionState, SelectionPressEvent } from \"./createSelectionState\";\nimport { createMultipleSelectionState } from \"../selection/createMultipleSelectionState\";\nimport { SelectionManager } from \"../selection/SelectionManager\";\nimport type {\n Collection,\n CollectionItemLike,\n CollectionNode,\n DisabledBehavior,\n FocusStrategy,\n Key,\n SelectionBehavior,\n SelectionMode,\n} from \"./types\";\n\nexport interface ListStateProps<T = unknown> {\n /** The items in the list (for dynamic rendering). */\n items?: T[];\n /** Function to get a key from an item. */\n getKey?: (item: T) => Key;\n /** Function to get text value from an item. */\n getTextValue?: (item: T) => string;\n /** Function to check if an item is disabled. */\n getDisabled?: (item: T) => boolean;\n /** Keys of disabled items. */\n disabledKeys?: Iterable<Key>;\n /** How disabled keys behave. */\n disabledBehavior?: DisabledBehavior;\n /** The selection mode. */\n selectionMode?: SelectionMode;\n /** How selection behaves on interaction. */\n selectionBehavior?: SelectionBehavior;\n /** Whether empty selection is disallowed. */\n disallowEmptySelection?: boolean;\n /** Currently selected keys (controlled). */\n selectedKeys?: \"all\" | Iterable<Key>;\n /** Default selected keys (uncontrolled). */\n defaultSelectedKeys?: \"all\" | Iterable<Key>;\n /** Handler for selection changes. */\n onSelectionChange?: (keys: \"all\" | Set<Key>) => void;\n /** Whether to allow duplicate selection events. */\n allowDuplicateSelectionEvents?: boolean;\n}\n\nexport interface ListState<T = unknown> extends SelectionState {\n /** The collection of items. */\n readonly collection: Accessor<Collection<T>>;\n /** The collection-aware selection manager (single source of truth for selection). */\n readonly selectionManager: SelectionManager<T>;\n /** Whether the collection is focused. */\n readonly isFocused: Accessor<boolean>;\n /** Set the focused state. */\n setFocused(isFocused: boolean): void;\n /** The currently focused key. */\n readonly focusedKey: Accessor<Key | null>;\n /** Set the focused key. */\n setFocusedKey(key: Key | null, childStrategy?: FocusStrategy): void;\n /** The child focus strategy. */\n readonly childFocusStrategy: Accessor<FocusStrategy | null>;\n}\n\n/**\n * Creates state for a list component with selection.\n */\nexport function createListState<T = unknown>(\n props: MaybeAccessor<ListStateProps<T>>,\n): ListState<T> {\n const getProps = () => access(props);\n\n // Build collection from items (memoized to avoid rebuilding on every access)\n const collection: Accessor<Collection<T>> = createMemo(() => {\n const p = getProps();\n const items = p.items ?? [];\n\n const nodes: CollectionNode<T>[] = items.map((item, index) => {\n const o = item as CollectionItemLike;\n const key = p.getKey?.(item) ?? o.key ?? o.id ?? index;\n const textValue = p.getTextValue?.(item) ?? o.textValue ?? o.label ?? String(item);\n const isDisabled = p.getDisabled?.(item) ?? o.isDisabled ?? false;\n\n return {\n type: \"item\" as const,\n key,\n value: item,\n textValue,\n rendered: null!,\n level: 0,\n index,\n parentKey: null,\n hasChildNodes: false,\n childNodes: [],\n isDisabled,\n };\n });\n\n return new ListCollection(nodes);\n });\n\n // Combine disabled keys from props and items (memoized)\n const combinedDisabledKeys = createMemo((): Iterable<Key> => {\n const p = getProps();\n const propsDisabled = p.disabledKeys ? [...p.disabledKeys] : [];\n const itemDisabled: Key[] = [];\n\n const coll = collection();\n for (const node of coll) {\n if (node.isDisabled) {\n itemDisabled.push(node.key);\n }\n }\n\n return [...new Set([...propsDisabled, ...itemDisabled])];\n });\n\n // Raw selection + focus state (the lower layer). This owns the selected keys,\n // focus, selection behavior, and disabled keys, but is not collection-aware.\n const state = createMultipleSelectionState({\n get selectionMode() {\n return getProps().selectionMode;\n },\n get selectionBehavior() {\n return getProps().selectionBehavior;\n },\n get disallowEmptySelection() {\n return getProps().disallowEmptySelection;\n },\n get selectedKeys() {\n return getProps().selectedKeys;\n },\n get defaultSelectedKeys() {\n return getProps().defaultSelectedKeys;\n },\n get onSelectionChange() {\n return getProps().onSelectionChange;\n },\n get disabledKeys() {\n return combinedDisabledKeys();\n },\n get disabledBehavior() {\n return getProps().disabledBehavior;\n },\n get allowDuplicateSelectionEvents() {\n return getProps().allowDuplicateSelectionEvents;\n },\n });\n\n // The collection-aware selection manager (the upper layer): the single source\n // of truth for every selection operation. It reads the collection live so it\n // stays reactive as the collection memo recomputes.\n const selectionManager = new SelectionManager<T>(() => collection(), state);\n\n return {\n collection,\n selectionManager,\n\n // Focus — delegate to the raw state (the single source of truth). The\n // setter routes through the manager so it inherits the existence guard and\n // the upstream 'first' child-focus default.\n isFocused: () => state.isFocused,\n setFocused: (isFocused: boolean) => state.setFocused(isFocused),\n focusedKey: () => state.focusedKey,\n setFocusedKey: (key: Key | null, childStrategy?: FocusStrategy) =>\n selectionManager.setFocusedKey(key, childStrategy),\n childFocusStrategy: () => state.childFocusStrategy,\n\n // Flattened selection surface — delegates to the manager so the list path\n // shares one faithful engine. extendSelection keeps its legacy second\n // argument for back-compat, but ignores it (the manager reads the\n // collection itself).\n selectionMode: () => selectionManager.selectionMode,\n selectionBehavior: () => selectionManager.selectionBehavior,\n disallowEmptySelection: () => selectionManager.disallowEmptySelection,\n selectedKeys: () => state.selectedKeys,\n disabledKeys: () => selectionManager.disabledKeys,\n disabledBehavior: () => selectionManager.disabledBehavior,\n isEmpty: () => selectionManager.isEmpty,\n isSelectAll: () => selectionManager.isSelectAll,\n isSelected: (key: Key) => selectionManager.isSelected(key),\n isDisabled: (key: Key) => selectionManager.isDisabled(key),\n setSelectionBehavior: (behavior: SelectionBehavior) =>\n selectionManager.setSelectionBehavior(behavior),\n toggleSelection: (key: Key) => selectionManager.toggleSelection(key),\n replaceSelection: (key: Key) => selectionManager.replaceSelection(key),\n setSelectedKeys: (keys: Iterable<Key>) => selectionManager.setSelectedKeys(keys),\n selectAll: () => selectionManager.selectAll(),\n clearSelection: () => selectionManager.clearSelection(),\n toggleSelectAll: () => selectionManager.toggleSelectAll(),\n extendSelection: (toKey: Key, _collection?: Collection) =>\n selectionManager.extendSelection(toKey),\n select: (key: Key, e?: SelectionPressEvent) => selectionManager.select(key, e),\n };\n}\n\n/**\n * Props for single selection list state.\n */\nexport interface SingleSelectListStateProps<T = unknown> extends Omit<\n ListStateProps<T>,\n \"selectionMode\" | \"selectedKeys\" | \"defaultSelectedKeys\" | \"onSelectionChange\"\n> {\n /** The currently selected key (controlled). */\n selectedKey?: Key | null;\n /** The default selected key (uncontrolled). */\n defaultSelectedKey?: Key;\n /** Handler for selection changes. */\n onSelectionChange?: (key: Key | null) => void;\n}\n\nexport interface SingleSelectListState<T = unknown> extends ListState<T> {\n /** The currently selected key. */\n readonly selectedKey: Accessor<Key | null>;\n /** Set the selected key. */\n setSelectedKey(key: Key | null): void;\n /** The currently selected item. */\n readonly selectedItem: Accessor<CollectionNode<T> | null>;\n}\n\n/**\n * Creates state for a single-select list component.\n */\nexport function createSingleSelectListState<T = unknown>(\n props: MaybeAccessor<SingleSelectListStateProps<T>>,\n): SingleSelectListState<T> {\n const getProps = () => access(props);\n\n // Convert single selection props to multiple selection props\n const listState = createListState<T>({\n get items() {\n return getProps().items;\n },\n get getKey() {\n return getProps().getKey;\n },\n get getTextValue() {\n return getProps().getTextValue;\n },\n get getDisabled() {\n return getProps().getDisabled;\n },\n get disabledKeys() {\n return getProps().disabledKeys;\n },\n get disabledBehavior() {\n return getProps().disabledBehavior;\n },\n selectionMode: \"single\",\n disallowEmptySelection: true,\n allowDuplicateSelectionEvents: true,\n get selectedKeys() {\n const key = getProps().selectedKey;\n return key != null ? [key] : [];\n },\n get defaultSelectedKeys() {\n const key = getProps().defaultSelectedKey;\n return key != null ? [key] : undefined;\n },\n onSelectionChange(keys) {\n if (keys === \"all\") return;\n const key = keys.values().next().value ?? null;\n getProps().onSelectionChange?.(key);\n },\n });\n\n const selectedKey: Accessor<Key | null> = () => {\n const keys = listState.selectedKeys();\n if (keys === \"all\") return null;\n return keys.values().next().value ?? null;\n };\n\n const setSelectedKey = (key: Key | null) => {\n if (key === null) {\n listState.clearSelection();\n } else {\n listState.replaceSelection(key);\n }\n };\n\n const selectedItem: Accessor<CollectionNode<T> | null> = () => {\n const key = selectedKey();\n if (key === null) return null;\n return listState.collection().getItem(key);\n };\n\n return {\n ...listState,\n selectedKey,\n setSelectedKey,\n selectedItem,\n };\n}\n","/**\n * State management for menu components.\n * Based on @react-stately/menu.\n */\n\nimport { access, type MaybeAccessor } from \"../utils\";\nimport { createListState, type ListState, type ListStateProps } from \"./createListState\";\nimport type { Key } from \"./types\";\n\nexport interface MenuStateProps<T = unknown> extends ListStateProps<T> {\n /** Handler called when an item is activated (pressed). */\n onAction?: (key: Key) => void;\n /** Handler called when the menu should close. */\n onClose?: () => void;\n}\n\nexport interface MenuState<T = unknown> extends ListState<T> {\n /** Close the menu. */\n close(): void;\n}\n\n/**\n * Creates state for a menu component.\n * Menus are single-select lists that support actions.\n */\nexport function createMenuState<T = unknown>(\n props: MaybeAccessor<MenuStateProps<T>>,\n): MenuState<T> {\n const getProps = () => access(props);\n\n // Menus default to action-only items, but can opt into single or multiple selection.\n const listState = createListState<T>({\n get items() {\n return getProps().items;\n },\n get getKey() {\n return getProps().getKey;\n },\n get getTextValue() {\n return getProps().getTextValue;\n },\n get getDisabled() {\n return getProps().getDisabled;\n },\n get disabledKeys() {\n return getProps().disabledKeys;\n },\n get disabledBehavior() {\n return getProps().disabledBehavior;\n },\n get selectionMode() {\n return getProps().selectionMode ?? \"none\";\n },\n get disallowEmptySelection() {\n return getProps().disallowEmptySelection;\n },\n get selectedKeys() {\n if ((getProps().selectionMode ?? \"none\") === \"none\") return undefined;\n return getProps().selectedKeys;\n },\n get defaultSelectedKeys() {\n if ((getProps().selectionMode ?? \"none\") === \"none\") return undefined;\n return getProps().defaultSelectedKeys;\n },\n get onSelectionChange() {\n if ((getProps().selectionMode ?? \"none\") === \"none\") return undefined;\n return getProps().onSelectionChange;\n },\n get selectionBehavior() {\n return getProps().selectionBehavior;\n },\n get allowDuplicateSelectionEvents() {\n return getProps().allowDuplicateSelectionEvents;\n },\n });\n\n const close = () => {\n getProps().onClose?.();\n };\n\n return {\n ...listState,\n close,\n };\n}\n\nexport interface MenuTriggerStateProps {\n /** Whether the menu is open (controlled). */\n isOpen?: boolean;\n /** Default open state (uncontrolled). */\n defaultOpen?: boolean;\n /** Handler called when the open state changes. */\n onOpenChange?: (isOpen: boolean) => void;\n}\n\nexport interface MenuTriggerState {\n /** Whether the menu is open. */\n readonly isOpen: () => boolean;\n /** Open the menu. */\n open(): void;\n /** Close the menu. */\n close(): void;\n /** Toggle the menu. */\n toggle(): void;\n /** Focus strategy for when the menu opens. */\n readonly focusStrategy: () => \"first\" | \"last\" | null;\n /** Set the focus strategy. */\n setFocusStrategy(strategy: \"first\" | \"last\" | null): void;\n}\n\n/**\n * Creates state for a menu trigger (button that opens a menu).\n * This is essentially the same as overlay trigger state but with focus strategy.\n */\nexport { createOverlayTriggerState as createMenuTriggerState } from \"../overlays\";\n","/**\n * CalendarState for Solid-Stately\n *\n * Provides state management for calendar components.\n * Based on @react-stately/calendar useCalendarState\n */\n\nimport { createSignal, createMemo, createEffect, type Accessor } from \"solid-js\";\nimport {\n type Calendar as InternationalizedCalendar,\n type CalendarDate,\n type CalendarIdentifier,\n type DateValue,\n GregorianCalendar,\n today,\n getLocalTimeZone,\n isEqualCalendar,\n isSameDay,\n isSameMonth,\n startOfMonth,\n endOfMonth,\n startOfWeek,\n getWeeksInMonth,\n DateFormatter,\n createCalendar as intlCreateCalendar,\n toCalendar as intlToCalendar,\n toCalendarDate as intlToCalendarDate,\n} from \"@internationalized/date\";\nimport { access, type MaybeAccessor } from \"../utils\";\n\nexport type ValidationState = \"valid\" | \"invalid\";\nexport type CalendarPageBehavior = \"single\" | \"visible\";\nexport type CalendarSelectionAlignment = \"start\" | \"center\" | \"end\";\nexport type CalendarDayOfWeek = \"sun\" | \"mon\" | \"tue\" | \"wed\" | \"thu\" | \"fri\" | \"sat\";\n\nconst dayOfWeekNames: CalendarDayOfWeek[] = [\"sun\", \"mon\", \"tue\", \"wed\", \"thu\", \"fri\", \"sat\"];\n\nexport type CalendarSelectionMode = \"single\" | \"multiple\";\nexport type CalendarValueType<T, M extends CalendarSelectionMode> = M extends \"single\"\n ? T\n : readonly T[];\n\nexport interface CalendarStateProps<\n T extends DateValue = DateValue,\n M extends CalendarSelectionMode = \"single\",\n> {\n /** The current value (controlled). */\n value?: MaybeAccessor<CalendarValueType<T | null, M> | undefined>;\n /** The default value (uncontrolled). */\n defaultValue?: CalendarValueType<T | null, M> | null;\n /** Handler called when the value changes. */\n onChange?: (value: CalendarValueType<T | null, M>) => void;\n /** Whether single or multiple date selection is enabled. */\n selectionMode?: MaybeAccessor<M>;\n /** The minimum allowed date. */\n minValue?: MaybeAccessor<DateValue | undefined>;\n /** The maximum allowed date. */\n maxValue?: MaybeAccessor<DateValue | undefined>;\n /** Whether the calendar is disabled. */\n isDisabled?: MaybeAccessor<boolean>;\n /** Whether the calendar is read-only. */\n isReadOnly?: MaybeAccessor<boolean>;\n /** Whether dates outside the visible range are automatically focused. */\n autoFocus?: boolean;\n /** The date that is focused when the calendar first mounts. */\n focusedValue?: MaybeAccessor<DateValue | null | undefined>;\n /** The default focused date (uncontrolled). */\n defaultFocusedValue?: DateValue;\n /** Handler called when the focused date changes. */\n onFocusChange?: (date: CalendarDate) => void;\n /** The locale to use for formatting. */\n locale?: MaybeAccessor<string | undefined>;\n /** Creates a calendar object for a locale calendar identifier. */\n createCalendar?: (identifier: CalendarIdentifier) => InternationalizedCalendar;\n /** Callback that is called for each date in the calendar to determine if it is unavailable. */\n isDateUnavailable?: (date: DateValue) => boolean;\n /** The number of months to display at once. */\n visibleMonths?: number;\n /** Controls whether paging advances by one month or by the visible month range. */\n pageBehavior?: CalendarPageBehavior;\n /** Determines how the visible months align around the initial focused date. */\n selectionAlignment?: CalendarSelectionAlignment;\n /** Whether to automatically focus the calendar when it is mounted. */\n autoFocusOnMount?: boolean;\n /** Controls which days are disabled. */\n isDateDisabled?: (date: DateValue) => boolean;\n /** Validation state. */\n validationState?: MaybeAccessor<ValidationState | undefined>;\n /** Error message. */\n errorMessage?: string;\n /** The first day of the week (0 = Sunday, 1 = Monday, etc.). */\n firstDayOfWeek?: 0 | 1 | 2 | 3 | 4 | 5 | 6;\n}\n\nexport interface CalendarState<\n T extends DateValue = DateValue,\n M extends CalendarSelectionMode = \"single\",\n> {\n /** Whether single or multiple selection is enabled. */\n selectionMode: Accessor<CalendarSelectionMode>;\n /** The currently selected date(s). */\n value: Accessor<CalendarValueType<T | null, M>>;\n /** Sets the selected date(s). */\n setValue: (value: CalendarValueType<T | null, M>) => void;\n /** The currently focused date. */\n focusedDate: Accessor<CalendarDate>;\n /** Sets the focused date. */\n setFocusedDate: (date: CalendarDate) => void;\n /** The minimum allowed date that a user may select. */\n minValue: Accessor<DateValue | null>;\n /** The maximum allowed date that a user may select. */\n maxValue: Accessor<DateValue | null>;\n /** Whether the calendar is disabled. */\n isDisabled: Accessor<boolean>;\n /** Whether the calendar is read-only. */\n isReadOnly: Accessor<boolean>;\n /** The visible date range (first and last day of visible month(s)). */\n visibleRange: Accessor<{ start: CalendarDate; end: CalendarDate }>;\n /** The timezone used for date calculations. */\n timeZone: string;\n /** The locale used for formatting and locale-specific week starts. */\n locale: Accessor<string>;\n /** The explicitly requested first weekday, or undefined for the locale default. */\n firstDayOfWeek: Accessor<CalendarDayOfWeek | undefined>;\n /** The validation state. */\n validationState: Accessor<ValidationState | undefined>;\n /** Whether the current value is invalid according to validation state. */\n isValueInvalid: Accessor<boolean>;\n /** Whether a date is selected. */\n isSelected: (date: DateValue) => boolean;\n /** Whether a date is focused. */\n isCellFocused: (date: DateValue) => boolean;\n /** Whether a date is unavailable. */\n isCellUnavailable: (date: DateValue) => boolean;\n /** Whether a date is disabled. */\n isCellDisabled: (date: DateValue) => boolean;\n /** Whether a date is outside the visible range. */\n isOutsideVisibleRange: (date: DateValue) => boolean;\n /** Whether a date is invalid. */\n isInvalid: (date: DateValue) => boolean;\n /** Moves focus to the previous page (month). */\n focusPreviousPage: () => void;\n /** Moves focus to the next page (month). */\n focusNextPage: () => void;\n /** Moves focus to the previous section (year). */\n focusPreviousSection: () => void;\n /** Moves focus to the next section (year). */\n focusNextSection: () => void;\n /** Moves focus to the previous day. */\n focusPreviousDay: () => void;\n /** Moves focus to the next day. */\n focusNextDay: () => void;\n /** Moves focus to the previous week. */\n focusPreviousWeek: () => void;\n /** Moves focus to the next week. */\n focusNextWeek: () => void;\n /** Moves focus to the start of the month. */\n focusPageStart: () => void;\n /** Moves focus to the end of the month. */\n focusPageEnd: () => void;\n /** Selects the focused date. */\n selectFocusedDate: () => void;\n /** Selects a specific date. */\n selectDate: (date: CalendarDate) => void;\n /** Whether focus is currently within the calendar. */\n isFocused: Accessor<boolean>;\n /** Sets whether focus is within the calendar. */\n setFocused: (focused: boolean) => void;\n /** Gets the dates for a week in the visible range. */\n getDatesInWeek: (weekIndex: number, monthStartDate?: CalendarDate) => (CalendarDate | null)[];\n /** Gets the number of weeks in a month. */\n getWeeksInMonth: (date?: CalendarDate) => number;\n /** The week day headers. */\n weekDays: Accessor<string[]>;\n /** The title for the calendar (formatted month and year). */\n title: Accessor<string>;\n /** The number of visible months. */\n visibleMonths: number;\n /** Whether the calendar is paginating (for animations). */\n isPaginating: Accessor<boolean>;\n}\n\n/**\n * Provides state management for a calendar component.\n */\nexport function createCalendarState<\n T extends DateValue = CalendarDate,\n M extends CalendarSelectionMode = \"single\",\n>(props: CalendarStateProps<T, M> = {}): CalendarState<T, M> {\n const timeZone = getLocalTimeZone();\n const locale = createMemo(() => access(props.locale) ?? \"en-US\");\n const minValueState = createMemo(() => access(props.minValue) ?? null);\n const maxValueState = createMemo(() => access(props.maxValue) ?? null);\n const selectionMode = createMemo<CalendarSelectionMode>(\n () => access(props.selectionMode) ?? \"single\",\n );\n const resolvedOptions = createMemo(() => new DateFormatter(locale()).resolvedOptions());\n const calendar = createMemo(() =>\n (props.createCalendar ?? intlCreateCalendar)(resolvedOptions().calendar as CalendarIdentifier),\n );\n const visibleMonths = props.visibleMonths ?? 1;\n const firstDayOfWeekName = (): CalendarDayOfWeek | undefined =>\n props.firstDayOfWeek == null ? undefined : dayOfWeekNames[props.firstDayOfWeek];\n\n const toDisplayCalendarDate = (date: DateValue): CalendarDate =>\n intlToCalendar(toCalendarDate(date), calendar());\n\n const selectionAlignmentOffset = (): number => {\n // Mirrors @react-stately/calendar useCalendarState, where selectionAlignment\n // defaults to \"center\" (alignCenter) when not provided.\n switch (props.selectionAlignment) {\n case \"start\":\n return 0;\n case \"end\":\n return Math.max(visibleMonths - 1, 0);\n case \"center\":\n default: {\n let halfDuration = Math.floor(visibleMonths / 2);\n if (halfDuration > 0 && visibleMonths % 2 === 0) {\n halfDuration--;\n }\n return halfDuration;\n }\n }\n };\n\n const alignVisibleRangeStart = (date: CalendarDate): CalendarDate => {\n const offset = selectionAlignmentOffset();\n return startOfMonth(offset > 0 ? date.subtract({ months: offset }) : date);\n };\n\n const visibleRangeEnd = (start: CalendarDate): CalendarDate => {\n let end = endOfMonth(start);\n\n for (let i = 1; i < visibleMonths; i++) {\n end = endOfMonth(end.add({ months: 1 }));\n }\n\n return end;\n };\n\n const constrainDate = (date: CalendarDate): CalendarDate => {\n const minValue = access(props.minValue);\n const maxValue = access(props.maxValue);\n\n let constrained = date;\n\n if (minValue && constrained.compare(toDisplayCalendarDate(minValue)) < 0) {\n constrained = toDisplayCalendarDate(minValue);\n }\n if (maxValue && constrained.compare(toDisplayCalendarDate(maxValue)) > 0) {\n constrained = toDisplayCalendarDate(maxValue);\n }\n\n return constrained;\n };\n\n // Determine the initially focused date\n const getInitialFocusedDate = (): CalendarDate => {\n const controlledFocused = access(props.focusedValue);\n if (controlledFocused) {\n return toDisplayCalendarDate(controlledFocused);\n }\n if (props.defaultFocusedValue) {\n return toDisplayCalendarDate(props.defaultFocusedValue);\n }\n const controlledValue = access(props.value);\n const controlledFirst = Array.isArray(controlledValue) ? controlledValue[0] : controlledValue;\n if (controlledFirst) {\n return toDisplayCalendarDate(controlledFirst);\n }\n const defaultFirst = Array.isArray(props.defaultValue)\n ? props.defaultValue[0]\n : props.defaultValue;\n if (defaultFirst) {\n return toDisplayCalendarDate(defaultFirst);\n }\n return intlToCalendar(today(timeZone), calendar());\n };\n\n // State signals\n const initialFocusedDate = constrainDate(getInitialFocusedDate());\n const [internalValue, setInternalValue] = createSignal<T | T[] | null>(\n (props.defaultValue as T | T[] | null) ?? null,\n );\n const [focusedDate, setFocusedDateInternal] = createSignal<CalendarDate>(initialFocusedDate);\n const [visibleRangeStart, setVisibleRangeStart] = createSignal<CalendarDate>(\n alignVisibleRangeStart(initialFocusedDate),\n );\n const [isFocused, setFocused] = createSignal(false);\n const [isPaginating, setIsPaginating] = createSignal(false);\n\n // Controlled vs uncontrolled value\n const sourceValue = createMemo<T | T[] | null>(() => {\n const controlled = access(props.value);\n return controlled !== undefined ? (controlled as T | T[] | null) : internalValue();\n });\n const value = createMemo<T | T[] | null>(() => {\n const currentValue = sourceValue();\n if (Array.isArray(currentValue)) {\n return currentValue.map((v) => toDisplayCalendarDate(v) as unknown as T);\n }\n return currentValue ? (toDisplayCalendarDate(currentValue) as unknown as T) : null;\n });\n\n // Derived states\n const isDisabled = createMemo(() => access(props.isDisabled) ?? false);\n const isReadOnly = createMemo(() => access(props.isReadOnly) ?? false);\n const validationState = createMemo(() => access(props.validationState));\n const isValueInvalid = createMemo(() => validationState() === \"invalid\");\n\n // Visible range based on the paged range start.\n const visibleRange = createMemo(() => {\n const start = visibleRangeStart();\n const end = visibleRangeEnd(start);\n\n return { start, end };\n });\n\n const syncVisibleRangeForFocusedDate = (nextFocusedDate: CalendarDate) => {\n const range = visibleRange();\n\n if (nextFocusedDate.compare(range.start) < 0) {\n setVisibleRangeStart(startOfMonth(nextFocusedDate.subtract({ months: visibleMonths - 1 })));\n } else if (nextFocusedDate.compare(range.end) > 0) {\n setVisibleRangeStart(startOfMonth(nextFocusedDate));\n }\n };\n\n createEffect(() => {\n const controlledFocused = access(props.focusedValue);\n if (!controlledFocused) {\n return;\n }\n\n const nextFocusedDate = constrainDate(toDisplayCalendarDate(controlledFocused));\n\n const currentFocusedDate = focusedDate();\n if (\n nextFocusedDate.compare(currentFocusedDate) !== 0 ||\n !isEqualCalendar(nextFocusedDate.calendar, currentFocusedDate.calendar)\n ) {\n setFocusedDateInternal(nextFocusedDate);\n }\n\n syncVisibleRangeForFocusedDate(nextFocusedDate);\n });\n\n createEffect(() => {\n const controlledFocused = access(props.focusedValue);\n if (controlledFocused) {\n return;\n }\n\n const currentFocusedDate = focusedDate();\n const nextFocusedDate = constrainDate(currentFocusedDate);\n\n if (\n nextFocusedDate.compare(currentFocusedDate) === 0 &&\n isEqualCalendar(nextFocusedDate.calendar, currentFocusedDate.calendar)\n ) {\n return;\n }\n\n syncVisibleRangeForFocusedDate(nextFocusedDate);\n setFocusedDateInternal(nextFocusedDate);\n props.onFocusChange?.(nextFocusedDate);\n });\n\n createEffect(() => {\n const currentFocusedDate = focusedDate();\n const nextFocusedDate = toDisplayCalendarDate(currentFocusedDate);\n\n if (isEqualCalendar(currentFocusedDate.calendar, nextFocusedDate.calendar)) {\n return;\n }\n\n setFocusedDateInternal(nextFocusedDate);\n setVisibleRangeStart(alignVisibleRangeStart(nextFocusedDate));\n });\n\n // Format week days for headers\n const weekDays = createMemo(() => {\n const formatter = new DateFormatter(locale(), { weekday: \"narrow\" });\n const days: string[] = [];\n const weekStart = startOfWeek(today(timeZone), locale(), firstDayOfWeekName());\n\n for (let i = 0; i < 7; i++) {\n const day = weekStart.add({ days: i });\n days.push(formatter.format(day.toDate(timeZone)));\n }\n\n return days;\n });\n\n // Title (formatted month/year)\n const title = createMemo(() => {\n const formatter = new DateFormatter(locale(), {\n month: \"long\",\n year: \"numeric\",\n calendar: focusedDate().calendar.identifier,\n });\n const date = focusedDate();\n const formattableMonth = date.calendar.getFormattableMonth?.(date) ?? date;\n return formatter.format(formattableMonth.toDate(timeZone));\n });\n\n // Set value with onChange callback\n const setValue = (newValue: T | T[] | null) => {\n if (isDisabled() || isReadOnly()) return;\n\n const oldValue = sourceValue();\n const referenceValue = Array.isArray(oldValue) ? (oldValue[0] ?? null) : oldValue;\n\n let nextValue: T | T[] | null;\n if (newValue == null) {\n nextValue = selectionMode() === \"multiple\" ? ([] as T[]) : null;\n } else if (Array.isArray(newValue)) {\n nextValue = newValue.map(\n (v) => convertValue(constrainDate(toDisplayCalendarDate(v)), referenceValue) as T,\n );\n } else {\n nextValue = convertValue(constrainDate(toDisplayCalendarDate(newValue)), referenceValue) as T;\n }\n\n const controlled = access(props.value);\n if (controlled === undefined) {\n setInternalValue(() => nextValue);\n }\n\n if (!Object.is(oldValue, nextValue) && props.onChange) {\n props.onChange(nextValue as CalendarValueType<T | null, M>);\n }\n };\n\n // Set focused date with constraints\n const setFocusedDate = (date: CalendarDate) => {\n const constrained = constrainDate(date);\n\n if (Object.is(constrained, focusedDate())) {\n return;\n }\n\n syncVisibleRangeForFocusedDate(constrained);\n setFocusedDateInternal(constrained);\n props.onFocusChange?.(constrained);\n };\n\n // Check if a date is selected\n const isSelected = (date: DateValue): boolean => {\n const v = value();\n if (v == null) return false;\n const target = toDisplayCalendarDate(date);\n if (Array.isArray(v)) {\n return v.some((d) => isSameDay(target, toDisplayCalendarDate(d)));\n }\n return isSameDay(target, toDisplayCalendarDate(v));\n };\n\n // Check if a date is focused\n const isCellFocused = (date: DateValue): boolean => {\n return isSameDay(toDisplayCalendarDate(date), focusedDate());\n };\n\n // Check if a date is unavailable\n const isCellUnavailable = (date: DateValue): boolean => {\n return props.isDateUnavailable?.(date) ?? false;\n };\n\n // Check if a date is disabled\n const isCellDisabled = (date: DateValue): boolean => {\n if (isDisabled()) return true;\n if (props.isDateDisabled?.(date)) return true;\n\n const minValue = access(props.minValue);\n const maxValue = access(props.maxValue);\n const calDate = toDisplayCalendarDate(date);\n\n if (minValue && calDate.compare(toDisplayCalendarDate(minValue)) < 0) return true;\n if (maxValue && calDate.compare(toDisplayCalendarDate(maxValue)) > 0) return true;\n\n return false;\n };\n\n // Check if a date is outside the visible range\n const isOutsideVisibleRange = (date: DateValue): boolean => {\n const range = visibleRange();\n const calDate = toDisplayCalendarDate(date);\n return !isSameMonth(calDate, range.start) && !isSameMonth(calDate, range.end);\n };\n\n // Check if a date is invalid\n const isInvalid = (date: DateValue): boolean => {\n return isCellDisabled(date) || isCellUnavailable(date);\n };\n\n // Navigation methods\n const focusPreviousPage = () => {\n setIsPaginating(true);\n const pageMonths = props.pageBehavior === \"single\" ? 1 : visibleMonths;\n const nextFocusedDate = constrainDate(focusedDate().subtract({ months: pageMonths }));\n setFocusedDateInternal(nextFocusedDate);\n setVisibleRangeStart(startOfMonth(visibleRangeStart().subtract({ months: pageMonths })));\n props.onFocusChange?.(nextFocusedDate);\n setIsPaginating(false);\n };\n\n const focusNextPage = () => {\n setIsPaginating(true);\n const pageMonths = props.pageBehavior === \"single\" ? 1 : visibleMonths;\n const nextFocusedDate = constrainDate(focusedDate().add({ months: pageMonths }));\n setFocusedDateInternal(nextFocusedDate);\n setVisibleRangeStart(startOfMonth(visibleRangeStart().add({ months: pageMonths })));\n props.onFocusChange?.(nextFocusedDate);\n setIsPaginating(false);\n };\n\n const focusPreviousSection = () => {\n setFocusedDate(focusedDate().subtract({ years: 1 }));\n };\n\n const focusNextSection = () => {\n setFocusedDate(focusedDate().add({ years: 1 }));\n };\n\n const focusPreviousDay = () => {\n setFocusedDate(focusedDate().subtract({ days: 1 }));\n };\n\n const focusNextDay = () => {\n setFocusedDate(focusedDate().add({ days: 1 }));\n };\n\n const focusPreviousWeek = () => {\n setFocusedDate(focusedDate().subtract({ weeks: 1 }));\n };\n\n const focusNextWeek = () => {\n setFocusedDate(focusedDate().add({ weeks: 1 }));\n };\n\n const focusPageStart = () => {\n setFocusedDate(startOfMonth(focusedDate()));\n };\n\n const focusPageEnd = () => {\n setFocusedDate(endOfMonth(focusedDate()));\n };\n\n // Selection methods\n const selectFocusedDate = () => {\n if (isReadOnly() || isDisabled()) return;\n const date = focusedDate();\n if (!isCellUnavailable(date)) {\n selectDate(date);\n }\n };\n\n const selectDate = (date: CalendarDate) => {\n if (isReadOnly() || isDisabled()) return;\n if (isCellDisabled(date) || isCellUnavailable(date)) return;\n\n if (selectionMode() === \"multiple\") {\n const current = value();\n const base: CalendarDate[] = Array.isArray(current)\n ? current.map((v) => toDisplayCalendarDate(v))\n : current != null\n ? [toDisplayCalendarDate(current)]\n : [];\n const target = toDisplayCalendarDate(date);\n const index = base.findIndex((d) => isSameDay(d, target));\n const nextValue =\n index >= 0 ? [...base.slice(0, index), ...base.slice(index + 1)] : [...base, target];\n setValue(nextValue as unknown as T[]);\n } else {\n setValue(date as unknown as T);\n }\n\n setFocusedDate(date);\n };\n\n // Get dates in a specific week\n const getDatesInWeek = (\n weekIndex: number,\n monthStartDate?: CalendarDate,\n ): (CalendarDate | null)[] => {\n const startDate = monthStartDate ?? visibleRange().start;\n\n const monthStart = startOfMonth(startDate);\n const weekStart = startOfWeek(monthStart, locale(), firstDayOfWeekName());\n\n const week: (CalendarDate | null)[] = [];\n const firstDayOfWeek = weekStart.add({ weeks: weekIndex });\n\n for (let i = 0; i < 7; i++) {\n const date = firstDayOfWeek.add({ days: i });\n // Only include dates that are in the same month\n if (isSameMonth(date, startDate)) {\n week.push(date);\n } else {\n week.push(date); // Still include for proper grid alignment\n }\n }\n\n return week;\n };\n\n // Get number of weeks in a month\n const getWeeksInMonthFn = (date?: CalendarDate): number => {\n const monthDate = date ?? focusedDate();\n return getWeeksInMonth(monthDate, locale(), firstDayOfWeekName());\n };\n\n return {\n selectionMode,\n value: value as unknown as Accessor<CalendarValueType<T | null, M>>,\n setValue: setValue as unknown as (value: CalendarValueType<T | null, M>) => void,\n focusedDate,\n setFocusedDate,\n isDisabled,\n isReadOnly,\n visibleRange,\n timeZone,\n locale,\n minValue: minValueState,\n maxValue: maxValueState,\n firstDayOfWeek: firstDayOfWeekName,\n validationState,\n isValueInvalid,\n isSelected,\n isCellFocused,\n isCellUnavailable,\n isCellDisabled,\n isOutsideVisibleRange,\n isInvalid,\n focusPreviousPage,\n focusNextPage,\n focusPreviousSection,\n focusNextSection,\n focusPreviousDay,\n focusNextDay,\n focusPreviousWeek,\n focusNextWeek,\n focusPageStart,\n focusPageEnd,\n selectFocusedDate,\n selectDate,\n isFocused,\n setFocused,\n getDatesInWeek,\n getWeeksInMonth: getWeeksInMonthFn,\n weekDays,\n title,\n visibleMonths,\n isPaginating,\n };\n}\n\n/**\n * Converts a DateValue to a CalendarDate.\n */\nfunction toCalendarDate(date: DateValue): CalendarDate {\n // Use the library function to convert\n return intlToCalendarDate(date);\n}\n\nfunction convertValue(newValue: CalendarDate, oldValue?: DateValue | null): DateValue {\n const localValue = intlToCalendar(newValue, oldValue?.calendar ?? new GregorianCalendar());\n\n if (oldValue && \"hour\" in oldValue) {\n return oldValue.set(localValue);\n }\n\n return localValue;\n}\n","/**\n * RangeCalendarState for Solid-Stately\n *\n * Provides state management for range calendar components.\n * Based on @react-stately/calendar useRangeCalendarState\n */\n\nimport { createSignal, createMemo, createEffect, type Accessor } from \"solid-js\";\nimport {\n type Calendar as InternationalizedCalendar,\n type CalendarDate,\n type CalendarIdentifier,\n type DateValue,\n GregorianCalendar,\n today,\n getLocalTimeZone,\n isEqualCalendar,\n isSameDay,\n isSameMonth,\n startOfMonth,\n endOfMonth,\n startOfWeek,\n getWeeksInMonth,\n maxDate,\n minDate,\n DateFormatter,\n createCalendar as intlCreateCalendar,\n toCalendar as intlToCalendar,\n toCalendarDate as intlToCalendarDate,\n} from \"@internationalized/date\";\nimport { access, type MaybeAccessor } from \"../utils\";\nimport type { CalendarDayOfWeek, ValidationState } from \"./createCalendarState\";\n\nconst dayOfWeekNames: CalendarDayOfWeek[] = [\"sun\", \"mon\", \"tue\", \"wed\", \"thu\", \"fri\", \"sat\"];\ntype RangeCalendarSelectionAlignment = \"start\" | \"center\" | \"end\";\ntype RangeCalendarPageBehavior = \"single\" | \"visible\";\n\nexport interface DateRange {\n start: CalendarDate;\n end: CalendarDate;\n}\n\nexport interface RangeValue<T> {\n start: T;\n end: T;\n}\n\nexport interface RangeCalendarStateProps<T extends DateValue = DateValue> {\n /** The current value (controlled). */\n value?: MaybeAccessor<RangeValue<T> | null>;\n /** The default value (uncontrolled). */\n defaultValue?: RangeValue<T> | null;\n /** Handler called when the value changes. */\n onChange?: (value: RangeValue<T> | null) => void;\n /** The minimum allowed date. */\n minValue?: MaybeAccessor<DateValue | undefined>;\n /** The maximum allowed date. */\n maxValue?: MaybeAccessor<DateValue | undefined>;\n /** Whether the calendar is disabled. */\n isDisabled?: MaybeAccessor<boolean>;\n /** Whether the calendar is read-only. */\n isReadOnly?: MaybeAccessor<boolean>;\n /** The date that is focused when the calendar first mounts. */\n focusedValue?: MaybeAccessor<DateValue | null | undefined>;\n /** The default focused date (uncontrolled). */\n defaultFocusedValue?: DateValue;\n /** Handler called when the focused date changes. */\n onFocusChange?: (date: CalendarDate) => void;\n /** The locale to use for formatting. */\n locale?: MaybeAccessor<string | undefined>;\n /** Creates a calendar object for a locale calendar identifier. */\n createCalendar?: (identifier: CalendarIdentifier) => InternationalizedCalendar;\n /**\n * Callback that determines if a date is unavailable. The second argument is the\n * current selection anchor (the first selected date), so availability can be\n * derived from it. Mirrors @react-stately/calendar 1.18.\n */\n isDateUnavailable?: (date: DateValue, anchorDate: CalendarDate | null) => boolean;\n /** The number of months to display at once. */\n visibleMonths?: MaybeAccessor<number | undefined>;\n /** Controls how the initial visible months are aligned around the current value. */\n selectionAlignment?: MaybeAccessor<RangeCalendarSelectionAlignment | undefined>;\n /** Controls whether pagination moves by one month or the visible month count. */\n pageBehavior?: MaybeAccessor<RangeCalendarPageBehavior | undefined>;\n /** Controls which days are disabled. */\n isDateDisabled?: (date: DateValue) => boolean;\n /** Validation state. */\n validationState?: MaybeAccessor<ValidationState | undefined>;\n /** Whether to allow selecting the same date for start and end. */\n allowsNonContiguousRanges?: boolean;\n /** The first day of the week (0 = Sunday, 1 = Monday, etc.). */\n firstDayOfWeek?: 0 | 1 | 2 | 3 | 4 | 5 | 6;\n}\n\nexport interface RangeCalendarState<T extends DateValue = DateValue> {\n /** The currently selected date range. */\n value: Accessor<RangeValue<T> | null>;\n /** Sets the selected date range. */\n setValue: (value: RangeValue<T> | null) => void;\n /** The currently focused date. */\n focusedDate: Accessor<CalendarDate>;\n /** Sets the focused date. */\n setFocusedDate: (date: CalendarDate) => void;\n /** The minimum allowed date that a user may select. */\n minValue: Accessor<DateValue | null>;\n /** The maximum allowed date that a user may select. */\n maxValue: Accessor<DateValue | null>;\n /** The anchor date when selecting a range (first click). */\n anchorDate: Accessor<CalendarDate | null>;\n /** Sets the anchor date. */\n setAnchorDate: (date: CalendarDate | null) => void;\n /** The highlighted range during selection. */\n highlightedRange: Accessor<RangeValue<CalendarDate> | null>;\n /** Whether the calendar is disabled. */\n isDisabled: Accessor<boolean>;\n /** Whether the calendar is read-only. */\n isReadOnly: Accessor<boolean>;\n /** The visible date range (first and last day of visible month(s)). */\n visibleRange: Accessor<{ start: CalendarDate; end: CalendarDate }>;\n /** The timezone used for date calculations. */\n timeZone: string;\n /** The locale used for formatting and locale-specific week starts. */\n locale: Accessor<string>;\n /** The explicitly requested first weekday, or undefined for the locale default. */\n firstDayOfWeek: Accessor<CalendarDayOfWeek | undefined>;\n /** The validation state. */\n validationState: Accessor<ValidationState | undefined>;\n /** Whether the current value is invalid according to validation state. */\n isValueInvalid: Accessor<boolean>;\n /** Whether a date is within the selected range. */\n isSelected: (date: DateValue) => boolean;\n /** Whether a date is the start of the selection. */\n isSelectionStart: (date: DateValue) => boolean;\n /** Whether a date is the end of the selection. */\n isSelectionEnd: (date: DateValue) => boolean;\n /** Whether a date is focused. */\n isCellFocused: (date: DateValue) => boolean;\n /** Whether a date is unavailable. */\n isCellUnavailable: (date: DateValue) => boolean;\n /** Whether a date is disabled. */\n isCellDisabled: (date: DateValue) => boolean;\n /** Whether a date is outside the visible range. */\n isOutsideVisibleRange: (date: DateValue) => boolean;\n /** Whether a date is invalid. */\n isInvalid: (date: DateValue) => boolean;\n /** Moves focus to the previous page (month). */\n focusPreviousPage: () => void;\n /** Moves focus to the next page (month). */\n focusNextPage: () => void;\n /** Moves focus to the previous section (year). */\n focusPreviousSection: () => void;\n /** Moves focus to the next section (year). */\n focusNextSection: () => void;\n /** Whether the previous visible range would be outside the allowed date range. */\n isPreviousVisibleRangeInvalid: () => boolean;\n /** Whether the next visible range would be outside the allowed date range. */\n isNextVisibleRangeInvalid: () => boolean;\n /** Moves focus to the previous day. */\n focusPreviousDay: () => void;\n /** Moves focus to the next day. */\n focusNextDay: () => void;\n /** Moves focus to the previous week. */\n focusPreviousWeek: () => void;\n /** Moves focus to the next week. */\n focusNextWeek: () => void;\n /** Moves focus to the start of the month. */\n focusPageStart: () => void;\n /** Moves focus to the end of the month. */\n focusPageEnd: () => void;\n /** Selects the focused date. */\n selectFocusedDate: () => void;\n /** Selects a specific date. */\n selectDate: (date: CalendarDate) => void;\n /** Whether focus is currently within the calendar. */\n isFocused: Accessor<boolean>;\n /** Sets whether focus is within the calendar. */\n setFocused: (focused: boolean) => void;\n /** Gets the dates for a week in the visible range. */\n getDatesInWeek: (weekIndex: number, monthStartDate?: CalendarDate) => (CalendarDate | null)[];\n /** Gets the number of weeks in a month. */\n getWeeksInMonth: (date?: CalendarDate) => number;\n /** The week day headers. */\n weekDays: Accessor<string[]>;\n /** The title for the calendar (formatted month and year). */\n title: Accessor<string>;\n /** The number of visible months. */\n visibleMonths: number;\n /** Whether the user is currently selecting a range. */\n isDragging: Accessor<boolean>;\n /** Sets whether the user is dragging to select. */\n setDragging: (dragging: boolean) => void;\n}\n\n/**\n * Provides state management for a range calendar component.\n */\nexport function createRangeCalendarState<T extends DateValue = CalendarDate>(\n props: RangeCalendarStateProps<T> = {},\n): RangeCalendarState<T> {\n const timeZone = getLocalTimeZone();\n const locale = createMemo(() => access(props.locale) ?? \"en-US\");\n const minValueState = createMemo(() => access(props.minValue) ?? null);\n const maxValueState = createMemo(() => access(props.maxValue) ?? null);\n const resolvedOptions = createMemo(() => new DateFormatter(locale()).resolvedOptions());\n const calendar = createMemo(() =>\n (props.createCalendar ?? intlCreateCalendar)(resolvedOptions().calendar as CalendarIdentifier),\n );\n const visibleMonths = Math.max(1, Number(access(props.visibleMonths) ?? 1));\n const firstDayOfWeekName = (): CalendarDayOfWeek | undefined =>\n props.firstDayOfWeek == null ? undefined : dayOfWeekNames[props.firstDayOfWeek];\n\n const toDisplayCalendarDate = (date: DateValue): CalendarDate =>\n intlToCalendar(toCalendarDate(date), calendar());\n\n // The anchor date is the first selected date during a range drag. Declared up\n // here (ahead of constrainDate) because the available-range derivation below\n // depends on it, and constrainDate consults that range.\n const [anchorDate, setAnchorDate] = createSignal<CalendarDate | null>(null);\n\n // Mirrors @react-stately/calendar useRangeCalendarState getAvailableRange: once\n // a range selection is anchored and unavailable dates exist, contiguous ranges\n // are required (unless allowsNonContiguousRanges), so the selectable span is\n // bounded by the nearest unavailable date on each side of the anchor.\n const getAvailableRange = (\n anchor: CalendarDate | null,\n ): { start?: CalendarDate; end?: CalendarDate } | null => {\n if (anchor && props.isDateUnavailable && !props.allowsNonContiguousRanges) {\n const predicate = (date: CalendarDate): boolean => props.isDateUnavailable!(date, anchor);\n return {\n start: nextUnavailableDate(anchor, predicate, visibleMonths, -1),\n end: nextUnavailableDate(anchor, predicate, visibleMonths, 1),\n };\n }\n return null;\n };\n\n const availableRange = createMemo(() => getAvailableRange(anchorDate()));\n\n // minValue/maxValue narrowed by the available range, in display-calendar space\n // (what every cell/navigation bound below compares against). Mirrors upstream's\n // maxDate(minValue, availableRange?.start) / minDate(maxValue, availableRange?.end);\n // maxDate/minDate ignore undefined operands, so an absent bound passes through.\n const effectiveMinValue = createMemo<CalendarDate | null>(() => {\n const min = access(props.minValue);\n const minCal = min != null ? toDisplayCalendarDate(min) : undefined;\n return maxDate(minCal, availableRange()?.start) ?? null;\n });\n const effectiveMaxValue = createMemo<CalendarDate | null>(() => {\n const max = access(props.maxValue);\n const maxCal = max != null ? toDisplayCalendarDate(max) : undefined;\n return minDate(maxCal, availableRange()?.end) ?? null;\n });\n\n const constrainDate = (date: CalendarDate): CalendarDate => {\n const min = effectiveMinValue();\n const max = effectiveMaxValue();\n\n let constrained = date;\n\n if (min && constrained.compare(min) < 0) {\n constrained = min;\n }\n if (max && constrained.compare(max) > 0) {\n constrained = max;\n }\n\n return constrained;\n };\n\n const visibleRangeEndFromStart = (start: CalendarDate): CalendarDate => {\n let end = endOfMonth(start);\n\n for (let i = 1; i < visibleMonths; i++) {\n end = endOfMonth(end.add({ months: 1 }));\n }\n\n return end;\n };\n\n const rawAlignStart = (date: CalendarDate): CalendarDate => startOfMonth(date);\n\n const rawAlignEnd = (date: CalendarDate): CalendarDate =>\n startOfMonth(date).subtract({ months: Math.max(visibleMonths - 1, 0) });\n\n const constrainVisibleRangeStart = (date: CalendarDate, aligned: CalendarDate): CalendarDate => {\n const minValue = access(props.minValue);\n const maxValue = access(props.maxValue);\n let constrained = aligned;\n\n if (minValue && date.compare(toDisplayCalendarDate(minValue)) >= 0) {\n const minStart = rawAlignStart(toDisplayCalendarDate(minValue));\n if (minStart.compare(constrained) > 0) {\n constrained = minStart;\n }\n }\n\n if (maxValue && date.compare(toDisplayCalendarDate(maxValue)) <= 0) {\n const maxStart = rawAlignEnd(toDisplayCalendarDate(maxValue));\n if (maxStart.compare(constrained) < 0) {\n constrained = maxStart;\n }\n }\n\n return constrained;\n };\n\n const alignStart = (date: CalendarDate): CalendarDate =>\n constrainVisibleRangeStart(date, rawAlignStart(date));\n\n const alignEnd = (date: CalendarDate): CalendarDate =>\n constrainVisibleRangeStart(date, rawAlignEnd(date));\n\n const alignCenter = (date: CalendarDate): CalendarDate => {\n let offset = Math.floor(visibleMonths / 2);\n if (offset > 0 && visibleMonths % 2 === 0) {\n offset--;\n }\n\n return constrainVisibleRangeStart(date, rawAlignStart(date).subtract({ months: offset }));\n };\n\n const defaultSelectionAlignment = (): RangeCalendarSelectionAlignment => {\n const currentValue = access(props.value) ?? props.defaultValue;\n if (!currentValue?.start || !currentValue?.end) {\n return \"center\";\n }\n\n const start = alignCenter(toDisplayCalendarDate(currentValue.start));\n const end = visibleRangeEndFromStart(start);\n return toDisplayCalendarDate(currentValue.end).compare(end) > 0 ? \"start\" : \"center\";\n };\n\n const alignVisibleRangeStart = (date: CalendarDate): CalendarDate => {\n switch (access(props.selectionAlignment) ?? defaultSelectionAlignment()) {\n case \"start\":\n return alignStart(date);\n case \"end\":\n return alignEnd(date);\n case \"center\":\n default:\n return alignCenter(date);\n }\n };\n\n // Determine the initially focused date\n const getInitialFocusedDate = (): CalendarDate => {\n const controlledFocused = access(props.focusedValue);\n if (controlledFocused) {\n return toDisplayCalendarDate(controlledFocused);\n }\n if (props.defaultFocusedValue) {\n return toDisplayCalendarDate(props.defaultFocusedValue);\n }\n const controlledValue = access(props.value);\n if (controlledValue?.start) {\n return toDisplayCalendarDate(controlledValue.start);\n }\n if (props.defaultValue?.start) {\n return toDisplayCalendarDate(props.defaultValue.start);\n }\n return intlToCalendar(today(timeZone), calendar());\n };\n\n // State signals\n const [internalValue, setInternalValue] = createSignal<RangeValue<T> | null>(\n props.defaultValue ?? null,\n );\n const initialFocusedDate = constrainDate(getInitialFocusedDate());\n const [focusedDate, setFocusedDateInternal] = createSignal<CalendarDate>(initialFocusedDate);\n const [visibleRangeStart, setVisibleRangeStart] = createSignal<CalendarDate>(\n alignVisibleRangeStart(initialFocusedDate),\n );\n const [isFocused, setFocused] = createSignal(false);\n const [isDragging, setDragging] = createSignal(false);\n\n // Controlled vs uncontrolled value\n const sourceValue = createMemo<RangeValue<T> | null>(() => {\n const controlled = access(props.value);\n return controlled !== undefined ? controlled : internalValue();\n });\n const value = createMemo<RangeValue<T> | null>(() => {\n const currentValue = sourceValue();\n if (!currentValue) {\n return null;\n }\n\n return {\n start: toDisplayCalendarDate(currentValue.start) as unknown as T,\n end: toDisplayCalendarDate(currentValue.end) as unknown as T,\n };\n });\n\n // Derived states\n const isDisabled = createMemo(() => access(props.isDisabled) ?? false);\n const isReadOnly = createMemo(() => access(props.isReadOnly) ?? false);\n const validationState = createMemo(() => access(props.validationState));\n // A committed range is invalid when (not mid-drag) either endpoint is\n // unavailable or falls outside [minValue, maxValue]. Mirrors upstream\n // useRangeCalendarState's isInvalid derivation. Calls props.isDateUnavailable\n // directly (with a null anchor) rather than the closures defined further down,\n // since this memo runs eagerly during init.\n const isInvalidSelection = createMemo(() => {\n const v = sourceValue();\n if (!v || anchorDate()) return false;\n if (props.isDateUnavailable?.(v.start, null) || props.isDateUnavailable?.(v.end, null)) {\n return true;\n }\n const min = access(props.minValue);\n const max = access(props.maxValue);\n const minCal = min != null ? toDisplayCalendarDate(min) : null;\n const maxCal = max != null ? toDisplayCalendarDate(max) : null;\n return (\n isDateOutsideRange(toDisplayCalendarDate(v.start), minCal, maxCal) ||\n isDateOutsideRange(toDisplayCalendarDate(v.end), minCal, maxCal)\n );\n });\n const isValueInvalid = createMemo(() => validationState() === \"invalid\" || isInvalidSelection());\n\n // Highlighted range during selection\n const highlightedRange = createMemo<RangeValue<CalendarDate> | null>(() => {\n const anchor = anchorDate();\n if (!anchor) {\n const v = value();\n if (v) {\n return {\n start: toDisplayCalendarDate(v.start),\n end: toDisplayCalendarDate(v.end),\n };\n }\n return null;\n }\n\n const focused = focusedDate();\n if (anchor.compare(focused) <= 0) {\n return { start: anchor, end: focused };\n }\n return { start: focused, end: anchor };\n });\n\n // Visible range based on React Stately's selection alignment rules.\n const visibleRange = createMemo(() => {\n const start = visibleRangeStart();\n return { start, end: visibleRangeEndFromStart(start) };\n });\n\n createEffect(() => {\n const controlledFocused = access(props.focusedValue);\n if (!controlledFocused) {\n return;\n }\n\n const nextFocusedDate = constrainDate(toDisplayCalendarDate(controlledFocused));\n const currentFocusedDate = focusedDate();\n\n if (\n nextFocusedDate.compare(currentFocusedDate) !== 0 ||\n !isEqualCalendar(nextFocusedDate.calendar, currentFocusedDate.calendar)\n ) {\n setFocusedDateInternal(nextFocusedDate);\n setVisibleRangeStart(alignVisibleRangeStart(nextFocusedDate));\n }\n });\n\n createEffect(() => {\n const controlledFocused = access(props.focusedValue);\n if (controlledFocused) {\n return;\n }\n\n const currentFocusedDate = focusedDate();\n const nextFocusedDate = constrainDate(currentFocusedDate);\n\n if (\n nextFocusedDate.compare(currentFocusedDate) === 0 &&\n isEqualCalendar(nextFocusedDate.calendar, currentFocusedDate.calendar)\n ) {\n return;\n }\n\n setFocusedDateInternal(nextFocusedDate);\n setVisibleRangeStart(alignVisibleRangeStart(nextFocusedDate));\n props.onFocusChange?.(nextFocusedDate);\n });\n\n createEffect(() => {\n const currentFocusedDate = focusedDate();\n const nextFocusedDate = toDisplayCalendarDate(currentFocusedDate);\n\n if (isEqualCalendar(currentFocusedDate.calendar, nextFocusedDate.calendar)) {\n return;\n }\n\n setFocusedDateInternal(nextFocusedDate);\n setVisibleRangeStart(alignVisibleRangeStart(nextFocusedDate));\n });\n\n // Format week days for headers\n const weekDays = createMemo(() => {\n const formatter = new DateFormatter(locale(), { weekday: \"narrow\" });\n const days: string[] = [];\n const weekStart = startOfWeek(today(timeZone), locale(), firstDayOfWeekName());\n\n for (let i = 0; i < 7; i++) {\n const day = weekStart.add({ days: i });\n days.push(formatter.format(day.toDate(timeZone)));\n }\n\n return days;\n });\n\n // Title (formatted month/year)\n const title = createMemo(() => {\n const formatter = new DateFormatter(locale(), {\n month: \"long\",\n year: \"numeric\",\n calendar: focusedDate().calendar.identifier,\n });\n const date = focusedDate();\n const formattableMonth = date.calendar.getFormattableMonth?.(date) ?? date;\n return formatter.format(formattableMonth.toDate(timeZone));\n });\n\n // Set value with onChange callback\n const setValue = (newValue: RangeValue<T> | null) => {\n if (isDisabled() || isReadOnly()) return;\n\n const oldValue = sourceValue();\n const nextValue = newValue\n ? {\n start: convertValue(\n constrainDate(toDisplayCalendarDate(newValue.start)),\n oldValue?.start,\n ) as T,\n end: convertValue(constrainDate(toDisplayCalendarDate(newValue.end)), oldValue?.end) as T,\n }\n : null;\n\n const controlled = access(props.value);\n if (controlled === undefined) {\n setInternalValue(() => nextValue);\n }\n\n if (!Object.is(oldValue, nextValue) && props.onChange) {\n props.onChange(nextValue);\n }\n };\n\n // Set focused date with constraints\n const setFocusedDate = (date: CalendarDate) => {\n const constrained = constrainDate(date);\n\n if (Object.is(constrained, focusedDate())) {\n return;\n }\n\n setFocusedDateInternal(constrained);\n setVisibleRangeStart(alignVisibleRangeStart(constrained));\n props.onFocusChange?.(constrained);\n };\n\n // Check if a date is within the selected range\n const isSelected = (date: DateValue): boolean => {\n const range = highlightedRange();\n if (!range) return false;\n\n const calDate = toDisplayCalendarDate(date);\n return calDate.compare(range.start) >= 0 && calDate.compare(range.end) <= 0;\n };\n\n // Check if a date is the start of the selection\n const isSelectionStart = (date: DateValue): boolean => {\n const range = highlightedRange();\n if (!range) return false;\n return isSameDay(toDisplayCalendarDate(date), range.start);\n };\n\n // Check if a date is the end of the selection\n const isSelectionEnd = (date: DateValue): boolean => {\n const range = highlightedRange();\n if (!range) return false;\n return isSameDay(toDisplayCalendarDate(date), range.end);\n };\n\n // Check if a date is focused\n const isCellFocused = (date: DateValue): boolean => {\n return isSameDay(toDisplayCalendarDate(date), focusedDate());\n };\n\n // Check if a date is unavailable\n const isCellUnavailable = (date: DateValue): boolean => {\n return props.isDateUnavailable?.(date, anchorDate()) ?? false;\n };\n\n // Check if a date is disabled\n const isCellDisabled = (date: DateValue): boolean => {\n if (isDisabled()) return true;\n if (props.isDateDisabled?.(date)) return true;\n\n const min = effectiveMinValue();\n const max = effectiveMaxValue();\n const calDate = toDisplayCalendarDate(date);\n\n if (min && calDate.compare(min) < 0) return true;\n if (max && calDate.compare(max) > 0) return true;\n\n return false;\n };\n\n const isDateOutsideAllowedRange = (date: DateValue): boolean => {\n const min = effectiveMinValue();\n const max = effectiveMaxValue();\n const calDate = toDisplayCalendarDate(date);\n\n if (min && calDate.compare(min) < 0) return true;\n if (max && calDate.compare(max) > 0) return true;\n\n return false;\n };\n\n // Check if a date is outside the visible range\n const isOutsideVisibleRange = (date: DateValue): boolean => {\n const range = visibleRange();\n const calDate = toDisplayCalendarDate(date);\n return !isSameMonth(calDate, range.start) && !isSameMonth(calDate, range.end);\n };\n\n // Check if a date is invalid\n const isInvalid = (date: DateValue): boolean => {\n return isCellDisabled(date) || isCellUnavailable(date);\n };\n\n // Navigation methods\n const focusPreviousPage = () => {\n const pageMonths = access(props.pageBehavior) === \"single\" ? 1 : visibleMonths;\n setFocusedDate(focusedDate().subtract({ months: pageMonths }));\n };\n\n const focusNextPage = () => {\n const pageMonths = access(props.pageBehavior) === \"single\" ? 1 : visibleMonths;\n setFocusedDate(focusedDate().add({ months: pageMonths }));\n };\n\n const focusPreviousSection = () => {\n setFocusedDate(focusedDate().subtract({ years: 1 }));\n };\n\n const focusNextSection = () => {\n setFocusedDate(focusedDate().add({ years: 1 }));\n };\n\n const isPreviousVisibleRangeInvalid = () => {\n const start = visibleRange().start;\n const previous = start.subtract({ days: 1 });\n return isSameDay(previous, start) || isDateOutsideAllowedRange(previous);\n };\n\n const isNextVisibleRangeInvalid = () => {\n const end = visibleRange().end;\n const next = end.add({ days: 1 });\n return isSameDay(next, end) || isDateOutsideAllowedRange(next);\n };\n\n const focusPreviousDay = () => {\n setFocusedDate(focusedDate().subtract({ days: 1 }));\n };\n\n const focusNextDay = () => {\n setFocusedDate(focusedDate().add({ days: 1 }));\n };\n\n const focusPreviousWeek = () => {\n setFocusedDate(focusedDate().subtract({ weeks: 1 }));\n };\n\n const focusNextWeek = () => {\n setFocusedDate(focusedDate().add({ weeks: 1 }));\n };\n\n const focusPageStart = () => {\n setFocusedDate(startOfMonth(focusedDate()));\n };\n\n const focusPageEnd = () => {\n setFocusedDate(endOfMonth(focusedDate()));\n };\n\n // Selection methods\n const selectFocusedDate = () => {\n if (isReadOnly() || isDisabled()) return;\n selectDate(focusedDate());\n };\n\n const selectDate = (date: CalendarDate) => {\n if (isReadOnly() || isDisabled()) return;\n if (isCellDisabled(date) || isCellUnavailable(date)) return;\n\n const anchor = anchorDate();\n\n if (!anchor) {\n // First click - set anchor\n setAnchorDate(date);\n setDragging(true);\n } else {\n // Second click - complete selection\n let start: CalendarDate;\n let end: CalendarDate;\n\n if (date.compare(anchor) < 0) {\n start = date;\n end = anchor;\n } else {\n start = anchor;\n end = date;\n }\n\n setValue({\n start: start as unknown as T,\n end: end as unknown as T,\n });\n setAnchorDate(null);\n setDragging(false);\n }\n\n setFocusedDate(date);\n };\n\n // Get dates in a specific week\n const getDatesInWeek = (\n weekIndex: number,\n monthStartDate?: CalendarDate,\n ): (CalendarDate | null)[] => {\n const startDate = monthStartDate ?? visibleRange().start;\n\n const monthStart = startOfMonth(startDate);\n const weekStart = startOfWeek(monthStart, locale(), firstDayOfWeekName());\n\n const week: (CalendarDate | null)[] = [];\n const firstDayOfWeek = weekStart.add({ weeks: weekIndex });\n\n for (let i = 0; i < 7; i++) {\n const date = firstDayOfWeek.add({ days: i });\n week.push(date);\n }\n\n return week;\n };\n\n // Get number of weeks in a month\n const getWeeksInMonthFn = (date?: CalendarDate): number => {\n const monthDate = date ?? focusedDate();\n return getWeeksInMonth(monthDate, locale(), firstDayOfWeekName());\n };\n\n return {\n value,\n setValue,\n focusedDate,\n setFocusedDate,\n anchorDate,\n setAnchorDate,\n highlightedRange,\n isDisabled,\n isReadOnly,\n visibleRange,\n timeZone,\n locale,\n minValue: minValueState,\n maxValue: maxValueState,\n firstDayOfWeek: firstDayOfWeekName,\n validationState,\n isValueInvalid,\n isSelected,\n isSelectionStart,\n isSelectionEnd,\n isCellFocused,\n isCellUnavailable,\n isCellDisabled,\n isOutsideVisibleRange,\n isInvalid,\n focusPreviousPage,\n focusNextPage,\n focusPreviousSection,\n focusNextSection,\n isPreviousVisibleRangeInvalid,\n isNextVisibleRangeInvalid,\n focusPreviousDay,\n focusNextDay,\n focusPreviousWeek,\n focusNextWeek,\n focusPageStart,\n focusPageEnd,\n selectFocusedDate,\n selectDate,\n isFocused,\n setFocused,\n getDatesInWeek,\n getWeeksInMonth: getWeeksInMonthFn,\n weekDays,\n title,\n visibleMonths,\n isDragging,\n setDragging,\n };\n}\n\n/**\n * Converts a DateValue to a CalendarDate.\n */\nfunction toCalendarDate(date: DateValue): CalendarDate {\n return intlToCalendarDate(date);\n}\n\nfunction convertValue(newValue: CalendarDate, oldValue?: DateValue | null): DateValue {\n const localValue = intlToCalendar(newValue, oldValue?.calendar ?? new GregorianCalendar());\n\n if (oldValue && \"hour\" in oldValue) {\n return oldValue.set(localValue);\n }\n\n return localValue;\n}\n\n/** Whether a date falls outside the closed [minValue, maxValue] interval. */\nfunction isDateOutsideRange(\n date: CalendarDate,\n minValue?: CalendarDate | null,\n maxValue?: CalendarDate | null,\n): boolean {\n return (\n (minValue != null && date.compare(minValue) < 0) ||\n (maxValue != null && date.compare(maxValue) > 0)\n );\n}\n\n/**\n * Walks outward from the anchor one day at a time in `dir` until it reaches an\n * unavailable date, then returns the last available date before it — or\n * undefined when no unavailable date is found within `visibleMonths` of the\n * anchor (no narrowing needed on that side). Mirrors @react-stately/calendar\n * nextUnavailableDate.\n */\nfunction nextUnavailableDate(\n anchorDate: CalendarDate,\n isDateUnavailable: (date: CalendarDate) => boolean,\n visibleMonths: number,\n dir: number,\n): CalendarDate | undefined {\n let nextDate = anchorDate.add({ days: dir });\n const minBound = anchorDate.subtract({ months: visibleMonths });\n const maxBound = anchorDate.add({ months: visibleMonths });\n while (\n (dir < 0 ? nextDate.compare(minBound) >= 0 : nextDate.compare(maxBound) <= 0) &&\n !isDateUnavailable(nextDate)\n ) {\n nextDate = nextDate.add({ days: dir });\n }\n if (isDateUnavailable(nextDate)) {\n return nextDate.add({ days: -dir });\n }\n return undefined;\n}\n","/**\n * IncompleteDate for Solid-Stately\n *\n * Represents a date that is incomplete or otherwise invalid as a result of user\n * editing (for example February 31st, if the day is edited before the month).\n * This lets a date field hold an invalid intermediate value while typing and\n * only constrain it on blur, matching upstream behavior.\n *\n * Based on @react-stately/datepicker IncompleteDate\n */\n\nimport {\n type AnyDateTime,\n type Calendar,\n CalendarDate,\n type DateValue,\n ZonedDateTime,\n} from \"@internationalized/date\";\nimport type { DateSegmentType } from \"./createDateFieldState\";\n\ntype HourCycle = \"h12\" | \"h11\" | \"h23\" | \"h24\";\n\n/**\n * This class represents a date that is incomplete or otherwise invalid as a result of user editing.\n * For example, it can represent temporary dates such as February 31st if the user edits the day\n * before the month. Times are represented according to an hour cycle rather than always in 24 hour\n * time. This enables the user to adjust the day period (e.g. am/pm) independently from the hour.\n */\nexport class IncompleteDate {\n calendar: Calendar;\n era: string | null;\n year: number | null;\n month: number | null;\n day: number | null;\n hour: number | null;\n hourCycle: HourCycle;\n dayPeriod: number | null;\n minute: number | null;\n second: number | null;\n millisecond: number | null;\n offset: number | null;\n\n constructor(\n calendar: Calendar,\n hourCycle: HourCycle,\n dateValue?: Partial<Omit<AnyDateTime, \"copy\">> | null,\n ) {\n this.era = dateValue?.era ?? null;\n this.calendar = calendar;\n this.year = dateValue?.year ?? null;\n this.month = dateValue?.month ?? null;\n this.day = dateValue?.day ?? null;\n this.hour = dateValue?.hour ?? null;\n this.hourCycle = hourCycle;\n this.dayPeriod = null;\n this.minute = dateValue?.minute ?? null;\n this.second = dateValue?.second ?? null;\n this.millisecond = dateValue?.millisecond ?? null;\n this.offset = \"offset\" in (dateValue ?? {}) ? (dateValue as { offset: number }).offset : null;\n\n // Convert the hour from 24 hour time to the given hour cycle.\n if (this.hour != null) {\n const [dayPeriod, hour] = toHourCycle(this.hour, hourCycle);\n this.dayPeriod = dayPeriod;\n this.hour = hour;\n }\n }\n\n copy(): IncompleteDate {\n const res = new IncompleteDate(this.calendar, this.hourCycle);\n res.era = this.era;\n res.year = this.year;\n res.month = this.month;\n res.day = this.day;\n res.hour = this.hour;\n res.dayPeriod = this.dayPeriod;\n res.minute = this.minute;\n res.second = this.second;\n res.millisecond = this.millisecond;\n res.offset = this.offset;\n return res;\n }\n\n /** Checks whether all the specified segments have a value. */\n isComplete(segments: DateSegmentType[]): boolean {\n return segments.every((segment) => this[segment as keyof IncompleteDate] != null);\n }\n\n /** Checks whether the given date value matches this value for the specified segments. */\n validate(dt: DateValue, segments: DateSegmentType[]): boolean {\n return segments.every((segment) => {\n if ((segment === \"hour\" || segment === \"dayPeriod\") && \"hour\" in dt) {\n const [dayPeriod, hour] = toHourCycle(dt.hour, this.hourCycle);\n return this.dayPeriod === dayPeriod && this.hour === hour;\n }\n return this[segment as keyof IncompleteDate] === dt[segment as keyof DateValue];\n });\n }\n\n /** Checks if the date is empty (i.e. all specified segments are null). */\n isCleared(segments: DateSegmentType[]): boolean {\n return segments.every((segment) => this[segment as keyof IncompleteDate] === null);\n }\n\n /** Sets the given field. */\n set(field: DateSegmentType, value: number | string, placeholder: DateValue): IncompleteDate {\n const result = this.copy();\n (result as unknown as Record<string, unknown>)[field] = value;\n if (field === \"hour\" && result.dayPeriod == null && \"hour\" in placeholder) {\n result.dayPeriod = toHourCycle(placeholder.hour, this.hourCycle)[0];\n }\n if (field === \"year\" && result.era == null) {\n result.era = placeholder.era;\n }\n\n // clear offset when a date/time field changes since it may no longer be valid\n if (field !== \"second\" && field !== \"literal\" && field !== \"timeZoneName\") {\n result.offset = null;\n }\n return result;\n }\n\n /** Sets the given field to null. */\n clear(field: DateSegmentType): IncompleteDate {\n const result = this.copy();\n (result as unknown as Record<string, unknown>)[field] = null;\n if (field === \"year\") {\n result.era = null;\n }\n\n // clear offset when a field is cleared since it may no longer be valid\n result.offset = null;\n return result;\n }\n\n /**\n * Increments or decrements the given field. If it is null, then it is set to the placeholder\n * value.\n */\n cycle(\n field: DateSegmentType,\n amount: number,\n placeholder: DateValue,\n displaySegments: DateSegmentType[],\n ): IncompleteDate {\n const res = this.copy();\n\n // If field is null, default to placeholder.\n if (res[field as keyof IncompleteDate] == null && field !== \"dayPeriod\" && field !== \"era\") {\n if (field === \"hour\" && \"hour\" in placeholder) {\n const [dayPeriod, hour] = toHourCycle(placeholder.hour, this.hourCycle);\n res.dayPeriod = dayPeriod;\n res.hour = hour;\n } else {\n (res as unknown as Record<string, unknown>)[field] = placeholder[field as keyof DateValue];\n }\n if (field === \"year\" && res.era == null) {\n res.era = placeholder.era;\n }\n\n return res;\n }\n\n switch (field) {\n case \"era\": {\n const eras = this.calendar.getEras();\n let index = eras.indexOf(res.era!);\n index = cycleValue(index, amount, 0, eras.length - 1);\n res.era = eras[index];\n break;\n }\n case \"year\": {\n // Use CalendarDate to cycle so that we update the era when going between 1 AD and 1 BC.\n let date = new CalendarDate(\n this.calendar,\n this.era ?? placeholder.era,\n this.year ?? placeholder.year,\n this.month ?? 1,\n this.day ?? 1,\n );\n date = date.cycle(field, amount, { round: field === \"year\" });\n res.era = date.era;\n res.year = date.year;\n break;\n }\n case \"month\":\n res.month = cycleValue(res.month ?? 1, amount, 1, this.calendar.getMaximumMonthsInYear());\n break;\n case \"day\":\n // Allow incrementing up to the maximum number of days in any month.\n res.day = cycleValue(res.day ?? 1, amount, 1, this.calendar.getMaximumDaysInMonth());\n break;\n case \"hour\": {\n // if date is fully defined or it is just a time field, and we have a time zone, use toValue to get a ZonedDateTime to cycle\n // so DST fallback is properly handled\n const hasDateSegements = displaySegments.some((s) => [\"year\", \"month\", \"day\"].includes(s));\n if (\n \"timeZone\" in placeholder &&\n (!hasDateSegements || (res.year != null && res.month != null && res.day != null))\n ) {\n let date = this.toValue(placeholder) as ZonedDateTime;\n date = date.cycle(\"hour\", amount, {\n hourCycle: this.hourCycle === \"h12\" ? 12 : 24,\n round: false,\n });\n const [dayPeriod, adjustedHour] = toHourCycle(date.hour, this.hourCycle);\n res.hour = adjustedHour;\n res.dayPeriod = dayPeriod;\n res.offset = date.offset;\n } else {\n const hours = res.hour ?? 0;\n const limits = this.getSegmentLimits(\"hour\")!;\n res.hour = cycleValue(hours, amount, limits.minValue, limits.maxValue);\n if (res.dayPeriod == null && \"hour\" in placeholder) {\n res.dayPeriod = toHourCycle(placeholder.hour, this.hourCycle)[0];\n }\n }\n break;\n }\n case \"dayPeriod\":\n res.dayPeriod = cycleValue(res.dayPeriod ?? 0, amount, 0, 1);\n break;\n case \"minute\":\n res.minute = cycleValue(res.minute ?? 0, amount, 0, 59, true);\n break;\n case \"second\":\n res.second = cycleValue(res.second ?? 0, amount, 0, 59, true);\n break;\n }\n\n return res;\n }\n\n /**\n * Converts the incomplete date to a full date value, using the provided value for any unset\n * fields.\n */\n toValue(value: DateValue): DateValue {\n if (\"hour\" in value) {\n let hour = this.hour;\n if (hour != null) {\n hour = fromHourCycle(hour, this.dayPeriod ?? 0, this.hourCycle);\n } else if (this.hourCycle === \"h12\" || this.hourCycle === \"h11\") {\n hour = this.dayPeriod === 1 ? 12 : 0;\n }\n\n let res = value.set({\n era: this.era ?? value.era,\n year: this.year ?? value.year,\n month: this.month ?? value.month,\n day: this.day ?? value.day,\n hour: hour ?? value.hour,\n minute: this.minute ?? value.minute,\n second: this.second ?? value.second,\n millisecond: this.millisecond ?? value.millisecond,\n });\n\n if (\"offset\" in res && this.offset != null && res.offset !== this.offset) {\n res = res.add({ milliseconds: res.offset - this.offset });\n }\n\n return res;\n } else {\n return value.set({\n era: this.era ?? value.era,\n year: this.year ?? value.year,\n month: this.month ?? value.month,\n day: this.day ?? value.day,\n });\n }\n }\n\n getSegmentLimits(\n type: string,\n ): { value: number | null; minValue: number; maxValue: number } | undefined {\n switch (type) {\n case \"era\": {\n const eras = this.calendar.getEras();\n return {\n value: this.era != null ? eras.indexOf(this.era) : eras.length - 1,\n minValue: 0,\n maxValue: eras.length - 1,\n };\n }\n case \"year\":\n return {\n value: this.year,\n minValue: 1,\n maxValue: 9999,\n };\n case \"month\":\n return {\n value: this.month,\n minValue: 1,\n maxValue: this.calendar.getMaximumMonthsInYear(),\n };\n case \"day\":\n return {\n value: this.day,\n minValue: 1,\n maxValue: this.calendar.getMaximumDaysInMonth(),\n };\n case \"dayPeriod\": {\n return {\n value: this.dayPeriod,\n minValue: 0,\n maxValue: 1,\n };\n }\n case \"hour\": {\n let minValue = 0;\n let maxValue = 23;\n if (this.hourCycle === \"h12\") {\n minValue = 1;\n maxValue = 12;\n } else if (this.hourCycle === \"h11\") {\n minValue = 0;\n maxValue = 11;\n }\n\n return {\n value: this.hour,\n minValue,\n maxValue,\n };\n }\n case \"minute\":\n return {\n value: this.minute,\n minValue: 0,\n maxValue: 59,\n };\n case \"second\":\n return {\n value: this.second,\n minValue: 0,\n maxValue: 59,\n };\n }\n }\n}\n\nfunction cycleValue(\n value: number,\n amount: number,\n min: number,\n max: number,\n round = false,\n): number {\n if (round) {\n value += Math.sign(amount);\n\n if (value < min) {\n value = max;\n }\n\n const div = Math.abs(amount);\n if (amount > 0) {\n value = Math.ceil(value / div) * div;\n } else {\n value = Math.floor(value / div) * div;\n }\n\n if (value > max) {\n value = min;\n }\n } else {\n value += amount;\n if (value < min) {\n value = max - (min - value - 1);\n } else if (value > max) {\n value = min + (value - max - 1);\n }\n }\n\n return value;\n}\n\nfunction toHourCycle(hour: number, hourCycle: HourCycle): [number | null, number] {\n let dayPeriod: number | null = hour >= 12 ? 1 : 0;\n switch (hourCycle) {\n case \"h11\":\n // Hours are numbered from 0 to 11. Used in Japan.\n if (hour >= 12) {\n hour -= 12;\n }\n break;\n case \"h12\":\n // Hours are numbered from 12 (representing 0) to 11.\n if (hour === 0) {\n hour = 12;\n } else if (hour > 12) {\n hour -= 12;\n }\n break;\n case \"h23\":\n // 24 hour time, numbered 0 to 23.\n dayPeriod = null;\n break;\n case \"h24\":\n // 24 hour time numbered 24 to 23. Unused but supported by Intl.DateTimeFormat.\n hour += 1;\n dayPeriod = null;\n }\n\n return [dayPeriod, hour];\n}\n\nfunction fromHourCycle(hour: number, dayPeriod: number, hourCycle: HourCycle): number {\n switch (hourCycle) {\n case \"h11\":\n if (dayPeriod === 1) {\n hour += 12;\n }\n break;\n case \"h12\":\n if (hour === 12) {\n hour = 0;\n }\n if (dayPeriod === 1) {\n hour += 12;\n }\n break;\n case \"h24\":\n hour -= 1;\n break;\n }\n\n return hour;\n}\n","/**\n * DateFieldState for Solid-Stately\n *\n * Provides state management for date field components with segment-based editing.\n * Based on @react-stately/datepicker useDateFieldState\n *\n * Editing is modeled with an {@link IncompleteDate} display value so that invalid\n * intermediate dates (e.g. February 31st, produced by editing the day before the\n * month) are held as-typed while the field is focused and only constrained on blur\n * via `confirmPlaceholder`, matching upstream behavior. Out-of-range values are\n * never snapped to `minValue`/`maxValue`; they are kept and reported as invalid.\n */\n\nimport { createSignal, createMemo, createEffect, type Accessor } from \"solid-js\";\nimport {\n type AnyDateTime,\n type Calendar,\n type CalendarDateTime,\n type DateValue,\n GregorianCalendar,\n today,\n getLocalTimeZone,\n DateFormatter,\n toCalendarDate as intlToCalendarDate,\n toCalendarDateTime,\n} from \"@internationalized/date\";\nimport { access, type MaybeAccessor } from \"../utils\";\nimport type { ValidationState } from \"./createCalendarState\";\nimport { IncompleteDate } from \"./IncompleteDate\";\nimport {\n createFormValidationState,\n DEFAULT_VALIDATION_RESULT,\n VALID_VALIDITY_STATE,\n type ValidationBehavior,\n type ValidationFunction,\n type ValidationResult,\n type ValidityState,\n} from \"../form\";\n\nexport type DateSegmentType =\n | \"year\"\n | \"month\"\n | \"day\"\n | \"hour\"\n | \"minute\"\n | \"second\"\n | \"dayPeriod\"\n | \"era\"\n | \"timeZoneName\"\n | \"literal\";\n\nexport interface DateSegment {\n /** The type of segment. */\n type: DateSegmentType;\n /** The text content of the segment. */\n text: string;\n /** The numeric value of the segment (if applicable). */\n value?: number | null;\n /** The minimum value for the segment. */\n minValue?: number;\n /** The maximum value for the segment. */\n maxValue?: number;\n /** Whether this segment is editable. */\n isEditable: boolean;\n /** Whether this segment is a placeholder. */\n isPlaceholder: boolean;\n /** A placeholder string for the segment. */\n placeholder: string;\n}\n\nexport interface DateFieldStateProps<T extends DateValue = DateValue> {\n /** The current value (controlled). */\n value?: MaybeAccessor<T | null>;\n /** The default value (uncontrolled). */\n defaultValue?: T | null;\n /** Handler called when the value changes. */\n onChange?: (value: T | null) => void;\n /** The minimum allowed date. */\n minValue?: MaybeAccessor<DateValue | undefined>;\n /** The maximum allowed date. */\n maxValue?: MaybeAccessor<DateValue | undefined>;\n /** Whether the field is disabled. */\n isDisabled?: MaybeAccessor<boolean>;\n /** Whether the field is read-only. */\n isReadOnly?: MaybeAccessor<boolean>;\n /** Whether the field is required. */\n isRequired?: MaybeAccessor<boolean>;\n /** Whether the value is invalid (controlled). */\n isInvalid?: boolean;\n /** The locale to use for formatting. */\n locale?: string;\n /** The granularity of the date/time (day, hour, minute, second). */\n granularity?: \"day\" | \"hour\" | \"minute\" | \"second\";\n /** Whether to show the hour in 12 or 24 hour format. */\n hourCycle?: 12 | 24;\n /** Whether to hide the time zone. */\n hideTimeZone?: boolean;\n /** The placeholder date (determines segment structure). */\n placeholderValue?: DateValue;\n /** Whether to force leading zeroes in month/day segments. */\n shouldForceLeadingZeros?: boolean;\n /** Validation state. */\n validationState?: MaybeAccessor<ValidationState | undefined>;\n /** Validation behavior mode. */\n validationBehavior?: ValidationBehavior;\n /** Custom validation function. */\n validate?: ValidationFunction<T>;\n /** Description text. */\n description?: string;\n /** Error message. */\n errorMessage?: string;\n /** Whether dates outside the min/max range are allowed. */\n allowsNonContiguousRanges?: boolean;\n /** Whether to create a date or datetime. */\n createCalendar?: (name: string) => unknown;\n /** Whether a date is unavailable. */\n isDateUnavailable?: (date: DateValue) => boolean;\n}\n\nexport interface DateFieldState<T extends DateValue = DateValue> {\n /** The current value. */\n value: Accessor<T | null>;\n /** The date value (may be partial during editing). */\n dateValue: Accessor<DateValue | null>;\n /** Sets the date value. */\n setValue: (value: T | null) => void;\n /** The segments that make up the date. */\n segments: Accessor<DateSegment[]>;\n /** The format string. */\n formatValue: (fieldOptions?: Intl.DateTimeFormatOptions) => string;\n /** Sets a segment value. */\n setSegment: (type: DateSegmentType, value: number) => void;\n /** Increments a segment. */\n incrementSegment: (type: DateSegmentType) => void;\n /** Decrements a segment. */\n decrementSegment: (type: DateSegmentType) => void;\n /** Clears a segment. */\n clearSegment: (type: DateSegmentType) => void;\n /** Confirms the value (after typing). */\n confirmPlaceholder: () => void;\n /** Whether the field is disabled. */\n isDisabled: Accessor<boolean>;\n /** Whether the field is read-only. */\n isReadOnly: Accessor<boolean>;\n /** Whether the field is required. */\n isRequired: Accessor<boolean>;\n /** The validation state. */\n validationState: Accessor<ValidationState | undefined>;\n /** The granularity. */\n granularity: \"day\" | \"hour\" | \"minute\" | \"second\";\n /** Whether the value is invalid. */\n isInvalid: Accessor<boolean>;\n /** Realtime validation results, including native and custom constraints. */\n realtimeValidation: Accessor<ValidationResult>;\n /** Currently displayed validation results. */\n displayValidation: Accessor<ValidationResult>;\n /** Updates the current validation result. */\n updateValidation: (result: ValidationResult) => void;\n /** Resets displayed validation to valid. */\n resetValidation: () => void;\n /** Commits realtime validation to displayed validation. */\n commitValidation: () => void;\n /** The locale. */\n locale: string;\n /** The time zone. */\n timeZone: string;\n /** The default value. */\n defaultValue: T | null;\n}\n\ntype HourCycle = \"h11\" | \"h12\" | \"h23\" | \"h24\";\n\n/**\n * Provides state management for a date field component.\n */\nexport function createDateFieldState<T extends DateValue = DateValue>(\n props: DateFieldStateProps<T> = {},\n): DateFieldState<T> {\n const timeZone = getLocalTimeZone();\n const locale = props.locale ?? \"en-US\";\n const granularity = props.granularity ?? \"day\";\n const calendar: Calendar = new GregorianCalendar();\n const hourCycle = resolveHourCycle(locale, props.hourCycle);\n const displaySegments = computeDisplaySegments(granularity, hourCycle);\n\n const getPlaceholderValue = (): DateValue => {\n const base = props.placeholderValue ?? today(timeZone);\n return granularity === \"day\" ? intlToCalendarDate(base) : toCalendarDateTime(base);\n };\n\n const toSource = (v: DateValue | null): Partial<Omit<AnyDateTime, \"copy\">> | null =>\n (v as Partial<Omit<AnyDateTime, \"copy\">> | null) ?? null;\n\n // State signals\n const initialValue = props.defaultValue ?? null;\n const [internalValue, setInternalValue] = createSignal<T | null>(initialValue);\n\n // Controlled vs uncontrolled committed value\n const value = createMemo<T | null>(() => {\n const controlled = access(props.value);\n return controlled !== undefined ? controlled : internalValue();\n });\n\n // The display override: holds the (possibly invalid/incomplete) value being edited.\n const [displayValue, setDisplayValue] = createSignal<IncompleteDate>(\n new IncompleteDate(calendar, hourCycle, toSource(value())),\n );\n\n // Reset the display override whenever the committed value changes from the outside\n // (e.g. a controlled `value` prop update).\n let lastSyncedValue = value();\n createEffect(() => {\n const v = value();\n if (v !== lastSyncedValue) {\n lastSyncedValue = v;\n setDisplayValue(new IncompleteDate(calendar, hourCycle, toSource(v)));\n }\n });\n\n // Derived states\n const isDisabled = createMemo(() => access(props.isDisabled) ?? false);\n const isReadOnly = createMemo(() => access(props.isReadOnly) ?? false);\n const isRequired = createMemo(() => access(props.isRequired) ?? false);\n const explicitValidationState = createMemo(() => access(props.validationState));\n const validationBehavior = () => props.validationBehavior ?? \"native\";\n const builtinValidation = createMemo<ValidationResult>(() => {\n const v = value();\n if (!v) return DEFAULT_VALIDATION_RESULT;\n\n const minValue = access(props.minValue);\n const maxValue = access(props.maxValue);\n const validationDetails: ValidityState = { ...VALID_VALIDITY_STATE };\n const validationErrors: string[] = [];\n\n if (minValue && v.compare(minValue) < 0) {\n validationDetails.rangeUnderflow = true;\n validationErrors.push(\"Value is below the minimum date.\");\n }\n\n if (maxValue && v.compare(maxValue) > 0) {\n validationDetails.rangeOverflow = true;\n validationErrors.push(\"Value is above the maximum date.\");\n }\n\n if (props.isDateUnavailable?.(v)) {\n validationDetails.customError = true;\n validationErrors.push(\"Date is unavailable.\");\n }\n\n if (validationErrors.length === 0) {\n return DEFAULT_VALIDATION_RESULT;\n }\n\n validationDetails.valid = false;\n return {\n isInvalid: true,\n validationDetails,\n validationErrors,\n };\n });\n const validation = createFormValidationState<T>({\n get value() {\n return value();\n },\n get isInvalid() {\n return props.isInvalid;\n },\n get validationState() {\n return explicitValidationState();\n },\n get validationBehavior() {\n return validationBehavior();\n },\n get validate() {\n return props.validate;\n },\n get builtinValidation() {\n return builtinValidation();\n },\n });\n const isInvalid = createMemo(() => validation.displayValidation().isInvalid);\n const validationState = createMemo<ValidationState | undefined>(\n () => explicitValidationState() ?? (isInvalid() ? \"invalid\" : undefined),\n );\n\n // The effective date value, derived from the display override.\n const dateValue = createMemo<DateValue | null>(() => {\n const v = value();\n if (v) return v;\n const dv = displayValue();\n if (dv.isCleared(displaySegments)) return null;\n return dv.toValue(getPlaceholderValue());\n });\n\n // Generate segments from the display override (so invalid intermediate values render as typed).\n const segments = createMemo<DateSegment[]>(() => {\n const dv = displayValue();\n const base = value() ?? getPlaceholderValue();\n const resolved = dv.toValue(base);\n const jsDate = resolved.toDate(timeZone);\n\n const shouldForceLeadingZeros = props.shouldForceLeadingZeros === true;\n const formatOptions = buildFormatOptions(granularity, shouldForceLeadingZeros, props.hourCycle);\n const formatter = new DateFormatter(locale, formatOptions);\n const resolvedOptions = formatter.resolvedOptions() as unknown as Record<string, string>;\n const parts = formatter.formatToParts(jsDate);\n\n const numberFormatter = new Intl.NumberFormat(locale, { useGrouping: false });\n const twoDigitFormatter = new Intl.NumberFormat(locale, {\n useGrouping: false,\n minimumIntegerDigits: 2,\n });\n\n const result: DateSegment[] = [];\n for (const part of parts) {\n const type = mapPartType(part.type);\n\n if (type === \"literal\") {\n result.push({\n type: \"literal\",\n text: part.value,\n isEditable: false,\n isPlaceholder: false,\n placeholder: part.value,\n });\n continue;\n }\n if (!type) continue;\n\n const editable = isEditableSegment(type);\n const rawValue = rawSegmentValue(dv, type);\n const isPlaceholder = editable && rawValue == null;\n const limits = dv.getSegmentLimits(type);\n const placeholderText = getPlaceholderText(\n type,\n locale,\n granularity,\n shouldForceLeadingZeros,\n );\n\n // For numeric date/time segments, render the raw edited value (e.g. \"31\" even\n // when the resolved date is Feb 28) using a NumberFormatter, mirroring upstream.\n let text = part.value;\n if (\n (type === \"year\" || type === \"month\" || type === \"day\" || type === \"hour\") &&\n typeof rawValue === \"number\"\n ) {\n const numeric = rawValue ?? 0;\n text =\n resolvedOptions[type] === \"2-digit\"\n ? twoDigitFormatter.format(numeric)\n : numberFormatter.format(numeric);\n }\n\n result.push({\n type,\n text: isPlaceholder ? placeholderText : text,\n value: limits?.value,\n minValue: limits?.minValue,\n maxValue: limits?.maxValue,\n isEditable: editable && !isDisabled() && !isReadOnly(),\n isPlaceholder,\n placeholder: placeholderText,\n });\n }\n\n return result;\n });\n\n // Commit a concrete value (updates the controlled/uncontrolled value and fires onChange).\n const commitDate = (newValue: T | null) => {\n const controlled = access(props.value);\n if (controlled === undefined) {\n lastSyncedValue = newValue;\n setInternalValue(() => newValue);\n }\n props.onChange?.(newValue);\n };\n\n // Set value with the upstream split: complete + valid commits eagerly; an incomplete\n // or invalid (e.g. Feb 31) value is held as a display override until blur.\n const setValue = (newValue: T | IncompleteDate | null) => {\n if (isDisabled() || isReadOnly()) return;\n\n if (\n newValue == null ||\n (newValue instanceof IncompleteDate && newValue.isCleared(displaySegments))\n ) {\n commitDate(null);\n setDisplayValue(new IncompleteDate(calendar, hourCycle, null));\n return;\n }\n\n if (!(newValue instanceof IncompleteDate)) {\n commitDate(newValue);\n setDisplayValue(new IncompleteDate(calendar, hourCycle, toSource(newValue)));\n return;\n }\n\n // If the new value is complete and valid, trigger onChange eagerly. If it represents\n // an incomplete or invalid value (e.g. February 30th), wait until blur to trigger onChange.\n if (newValue.isComplete(displaySegments)) {\n const resolved = newValue.toValue(value() ?? getPlaceholderValue());\n if (newValue.validate(resolved, displaySegments)) {\n const committed = value();\n if (!committed || resolved.compare(committed) !== 0) {\n setDisplayValue(new IncompleteDate(calendar, hourCycle, toSource(resolved)));\n commitDate(resolved as T);\n return;\n }\n }\n }\n\n // Incomplete/invalid value. Set temporary display override.\n setDisplayValue(newValue);\n };\n\n const adjustSegment = (type: DateSegmentType, amount: number) => {\n if (isDisabled() || isReadOnly()) return;\n setValue(displayValue().cycle(type, amount, getPlaceholderValue(), displaySegments));\n };\n\n // Set a specific segment value\n const setSegment = (type: DateSegmentType, newValue: number) => {\n if (isDisabled() || isReadOnly()) return;\n setValue(displayValue().set(type, newValue, getPlaceholderValue()));\n };\n\n const incrementSegment = (type: DateSegmentType) => adjustSegment(type, 1);\n const decrementSegment = (type: DateSegmentType) => adjustSegment(type, -1);\n\n // Clear a segment, reverting it to its placeholder.\n const clearSegment = (type: DateSegmentType) => {\n if (isDisabled() || isReadOnly()) return;\n let dv = displayValue();\n if (type !== \"timeZoneName\" && type !== \"literal\") {\n dv = dv.clear(type);\n }\n setValue(dv);\n };\n\n // When the field is blurred, constrain a complete-but-invalid display value\n // (e.g. February 31st -> February 28th) and emit onChange. Out-of-range values\n // are left as-is and reported via validation rather than being snapped.\n const confirmPlaceholder = () => {\n if (isDisabled() || isReadOnly()) return;\n const dv = displayValue();\n if (!dv.isComplete(displaySegments)) return;\n\n const resolved = dv.toValue(value() ?? getPlaceholderValue());\n const committed = value();\n const needsCommit = !committed || resolved.compare(committed) !== 0;\n if (needsCommit) {\n commitDate(resolved as T);\n }\n\n // Reset the display override so a constrained value (e.g. February 31st ->\n // February 28th) renders. Only touch the signal when the displayed raw value\n // diverged from the resolved value, or when we committed — otherwise leave it\n // untouched so blur (which fires on every focus move) does not churn the\n // segments and drop focus.\n if (needsCommit || !dv.validate(resolved, displaySegments)) {\n setDisplayValue(new IncompleteDate(calendar, hourCycle, toSource(value() ?? resolved)));\n }\n };\n\n // Format the current value\n const formatValue = (fieldOptions?: Intl.DateTimeFormatOptions): string => {\n const v = value();\n if (!v) return \"\";\n\n const options: Intl.DateTimeFormatOptions = fieldOptions ?? {\n year: \"numeric\",\n month: props.shouldForceLeadingZeros === true ? \"2-digit\" : \"numeric\",\n day: props.shouldForceLeadingZeros === true ? \"2-digit\" : \"numeric\",\n };\n\n if (granularity !== \"day\") {\n options.hour = \"2-digit\";\n options.minute = \"2-digit\";\n if (granularity === \"second\") {\n options.second = \"2-digit\";\n }\n }\n\n const formatter = new DateFormatter(locale, options);\n return formatter.format(v.toDate(timeZone));\n };\n\n return {\n value,\n defaultValue: initialValue,\n dateValue,\n setValue,\n segments,\n formatValue,\n setSegment,\n incrementSegment,\n decrementSegment,\n clearSegment,\n confirmPlaceholder,\n isDisabled,\n isReadOnly,\n isRequired,\n validationState,\n granularity,\n isInvalid,\n realtimeValidation: validation.realtimeValidation,\n displayValidation: validation.displayValidation,\n updateValidation: validation.updateValidation,\n resetValidation: validation.resetValidation,\n commitValidation: validation.commitValidation,\n locale,\n timeZone,\n };\n}\n\nconst EDITABLE_SEGMENTS: Record<string, boolean> = {\n year: true,\n month: true,\n day: true,\n hour: true,\n minute: true,\n second: true,\n dayPeriod: true,\n era: true,\n};\n\nfunction isEditableSegment(type: DateSegmentType): boolean {\n return EDITABLE_SEGMENTS[type] === true;\n}\n\nfunction rawSegmentValue(dv: IncompleteDate, type: DateSegmentType): number | string | null {\n switch (type) {\n case \"era\":\n return dv.era;\n case \"year\":\n return dv.year;\n case \"month\":\n return dv.month;\n case \"day\":\n return dv.day;\n case \"hour\":\n return dv.hour;\n case \"minute\":\n return dv.minute;\n case \"second\":\n return dv.second;\n case \"dayPeriod\":\n return dv.dayPeriod;\n default:\n return null;\n }\n}\n\nfunction resolveHourCycle(locale: string, hourCycle?: 12 | 24): HourCycle {\n const formatter = new DateFormatter(locale, {\n hour: \"numeric\",\n hour12: hourCycle != null ? hourCycle === 12 : undefined,\n });\n return (formatter.resolvedOptions().hourCycle as HourCycle) ?? \"h23\";\n}\n\nfunction computeDisplaySegments(\n granularity: \"day\" | \"hour\" | \"minute\" | \"second\",\n hourCycle: HourCycle,\n): DateSegmentType[] {\n const is12HourClock = hourCycle === \"h11\" || hourCycle === \"h12\";\n const segments: DateSegmentType[] = [\n \"era\",\n \"year\",\n \"month\",\n \"day\",\n \"hour\",\n ...(is12HourClock ? ([\"dayPeriod\"] as const) : []),\n \"minute\",\n \"second\",\n ];\n // We never expose era as an editable segment, so the maximum displayed unit is the year.\n const minIndex = segments.indexOf(\"era\");\n const maxIndex = segments.indexOf(\n granularity === \"hour\" && is12HourClock ? \"dayPeriod\" : granularity,\n );\n return segments.slice(minIndex, maxIndex + 1);\n}\n\nfunction buildFormatOptions(\n granularity: \"day\" | \"hour\" | \"minute\" | \"second\",\n shouldForceLeadingZeros: boolean,\n hourCycle?: 12 | 24,\n): Intl.DateTimeFormatOptions {\n const formatOptions: Intl.DateTimeFormatOptions = {\n year: \"numeric\",\n month: shouldForceLeadingZeros ? \"2-digit\" : \"numeric\",\n day: shouldForceLeadingZeros ? \"2-digit\" : \"numeric\",\n };\n\n if (granularity !== \"day\") {\n formatOptions.hour = \"2-digit\";\n formatOptions.minute = \"2-digit\";\n if (granularity === \"second\") {\n formatOptions.second = \"2-digit\";\n }\n if (hourCycle) {\n formatOptions.hourCycle = hourCycle === 12 ? \"h12\" : \"h23\";\n }\n }\n\n return formatOptions;\n}\n\nfunction mapPartType(type: Intl.DateTimeFormatPartTypes): DateSegmentType | null {\n switch (type) {\n case \"year\":\n return \"year\";\n case \"month\":\n return \"month\";\n case \"day\":\n return \"day\";\n case \"hour\":\n return \"hour\";\n case \"minute\":\n return \"minute\";\n case \"second\":\n return \"second\";\n case \"dayPeriod\":\n return \"dayPeriod\";\n case \"era\":\n return \"era\";\n case \"timeZoneName\":\n return \"timeZoneName\";\n case \"literal\":\n return \"literal\";\n default:\n return null;\n }\n}\n\nfunction getPlaceholderText(\n type: DateSegmentType,\n locale: string,\n granularity: \"day\" | \"hour\" | \"minute\" | \"second\",\n shouldForceLeadingZeros = false,\n): string {\n if (type === \"literal\") return \"\";\n if (type === \"dayPeriod\") return \"AM\";\n\n const formatOptions: Intl.DateTimeFormatOptions = {\n year: \"numeric\",\n month: shouldForceLeadingZeros ? \"2-digit\" : \"numeric\",\n day: shouldForceLeadingZeros ? \"2-digit\" : \"numeric\",\n };\n\n if (granularity !== \"day\") {\n formatOptions.hour = \"2-digit\";\n formatOptions.minute = \"2-digit\";\n if (granularity === \"second\") {\n formatOptions.second = \"2-digit\";\n }\n }\n\n const formatter = new DateFormatter(locale, formatOptions);\n // Use a reference date with recognizable digits\n const refDate = new Date(2222, 10, 22, 22, 22, 22);\n const parts = formatter.formatToParts(refDate);\n\n for (const part of parts) {\n const mappedType = mapPartType(part.type);\n if (mappedType === type) {\n return part.value.replace(/\\d/g, (_d) => {\n if (type === \"year\") return \"y\";\n if (type === \"month\") return \"m\";\n if (type === \"day\") return \"d\";\n return \"–\";\n });\n }\n }\n\n switch (type) {\n case \"year\":\n return \"yyyy\";\n case \"month\":\n return \"mm\";\n case \"day\":\n return \"dd\";\n case \"hour\":\n return \"––\";\n case \"minute\":\n return \"––\";\n case \"second\":\n return \"––\";\n default:\n return \"\";\n }\n}\n\n// Re-export so existing imports of CalendarDateTime keep resolving through this module.\nexport type { CalendarDateTime };\n","/**\n * TimeFieldState for Solid-Stately\n *\n * Provides state management for time field components with segment-based editing.\n * Based on @react-stately/datepicker useTimeFieldState\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport {\n type Time,\n type CalendarDateTime,\n type ZonedDateTime,\n type DateValue,\n getLocalTimeZone,\n DateFormatter,\n} from \"@internationalized/date\";\nimport { access, type MaybeAccessor } from \"../utils\";\nimport type { ValidationState } from \"./createCalendarState\";\nimport {\n createFormValidationState,\n DEFAULT_VALIDATION_RESULT,\n VALID_VALIDITY_STATE,\n type ValidationBehavior,\n type ValidationFunction,\n type ValidationResult,\n type ValidityState,\n} from \"../form\";\n\nexport type TimeValue = Time | CalendarDateTime | ZonedDateTime;\n\nexport type TimeSegmentType = \"hour\" | \"minute\" | \"second\" | \"dayPeriod\" | \"literal\";\n\nexport interface TimeSegment {\n /** The type of segment. */\n type: TimeSegmentType;\n /** The text content of the segment. */\n text: string;\n /** The numeric value of the segment (if applicable). */\n value?: number;\n /** The minimum value for the segment. */\n minValue?: number;\n /** The maximum value for the segment. */\n maxValue?: number;\n /** Whether this segment is editable. */\n isEditable: boolean;\n /** Whether this segment is a placeholder. */\n isPlaceholder: boolean;\n /** A placeholder string for the segment. */\n placeholder: string;\n}\n\nexport interface TimeFieldStateProps<T extends TimeValue = Time> {\n /** The current value (controlled). */\n value?: MaybeAccessor<T | null>;\n /** The default value (uncontrolled). */\n defaultValue?: T | null;\n /** Handler called when the value changes. */\n onChange?: (value: T | null) => void;\n /** The minimum allowed time. */\n minValue?: MaybeAccessor<TimeValue | undefined>;\n /** The maximum allowed time. */\n maxValue?: MaybeAccessor<TimeValue | undefined>;\n /** Whether the field is disabled. */\n isDisabled?: MaybeAccessor<boolean>;\n /** Whether the field is read-only. */\n isReadOnly?: MaybeAccessor<boolean>;\n /** Whether the field is required. */\n isRequired?: MaybeAccessor<boolean>;\n /** Whether the value is invalid (controlled). */\n isInvalid?: boolean;\n /** The locale to use for formatting. */\n locale?: string;\n /** The granularity (hour, minute, second). */\n granularity?: \"hour\" | \"minute\" | \"second\";\n /** Whether to show 12 or 24 hour format. */\n hourCycle?: 12 | 24;\n /** Whether to force leading zeroes in the hour segment. */\n shouldForceLeadingZeros?: boolean;\n /** Validation state. */\n validationState?: MaybeAccessor<ValidationState | undefined>;\n /** Validation behavior mode. */\n validationBehavior?: ValidationBehavior;\n /** Custom validation function. */\n validate?: ValidationFunction<T>;\n /** Description text. */\n description?: string;\n /** Error message. */\n errorMessage?: string;\n /** The placeholder value. */\n placeholderValue?: T;\n /** Whether dates outside the min/max range are unavailable. Added for API consistency. */\n isDateUnavailable?: (date: DateValue) => boolean;\n}\n\nexport interface TimeFieldState<T extends TimeValue = Time> {\n /** The current value. */\n value: Accessor<T | null>;\n /** The default value. */\n defaultValue: T | null;\n /** Sets the value. */\n setValue: (value: T | null) => void;\n /** The segments that make up the time. */\n segments: Accessor<TimeSegment[]>;\n /** Sets a segment value. */\n setSegment: (type: TimeSegmentType, value: number) => void;\n /** Increments a segment. */\n incrementSegment: (type: TimeSegmentType) => void;\n /** Decrements a segment. */\n decrementSegment: (type: TimeSegmentType) => void;\n /** Clears a segment. */\n clearSegment: (type: TimeSegmentType) => void;\n /** Whether the field is disabled. */\n isDisabled: Accessor<boolean>;\n /** Whether the field is read-only. */\n isReadOnly: Accessor<boolean>;\n /** Whether the field is required. */\n isRequired: Accessor<boolean>;\n /** The validation state. */\n validationState: Accessor<ValidationState | undefined>;\n /** The granularity. */\n granularity: \"hour\" | \"minute\" | \"second\";\n /** Whether the value is invalid. */\n isInvalid: Accessor<boolean>;\n /** Realtime validation results, including native and custom constraints. */\n realtimeValidation: Accessor<ValidationResult>;\n /** Currently displayed validation results. */\n displayValidation: Accessor<ValidationResult>;\n /** Updates the current validation result. */\n updateValidation: (result: ValidationResult) => void;\n /** Resets displayed validation to valid. */\n resetValidation: () => void;\n /** Commits realtime validation to displayed validation. */\n commitValidation: () => void;\n /** The locale. */\n locale: string;\n /** The hour cycle. */\n hourCycle: 12 | 24;\n}\n\n/**\n * Provides state management for a time field component.\n */\nexport function createTimeFieldState<T extends TimeValue = Time>(\n props: TimeFieldStateProps<T> = {},\n): TimeFieldState<T> {\n const timeZone = getLocalTimeZone();\n const locale = props.locale ?? \"en-US\";\n const granularity = props.granularity ?? \"minute\";\n const hourCycle = props.hourCycle ?? 12;\n\n const initialValue = props.defaultValue ?? null;\n\n // State signals\n const [internalValue, setInternalValue] = createSignal<T | null>(initialValue);\n\n // Track partial values during editing\n const [placeholderParts, setPlaceholderParts] = createSignal<Partial<TimeParts>>({});\n\n // Controlled vs uncontrolled value\n const value = createMemo<T | null>(() => {\n const controlled = access(props.value);\n return controlled !== undefined ? controlled : internalValue();\n });\n\n // Derived states\n const isDisabled = createMemo(() => access(props.isDisabled) ?? false);\n const isReadOnly = createMemo(() => access(props.isReadOnly) ?? false);\n const isRequired = createMemo(() => access(props.isRequired) ?? false);\n const explicitValidationState = createMemo(() => access(props.validationState));\n const validationBehavior = () => props.validationBehavior ?? \"native\";\n const builtinValidation = createMemo<ValidationResult>(() => {\n const v = value();\n if (!v) return DEFAULT_VALIDATION_RESULT;\n\n const minValue = access(props.minValue);\n const maxValue = access(props.maxValue);\n const validationDetails: ValidityState = { ...VALID_VALIDITY_STATE };\n const validationErrors: string[] = [];\n\n if (minValue && compareTime(v, minValue) < 0) {\n validationDetails.rangeUnderflow = true;\n validationErrors.push(\"Value is below the minimum time.\");\n }\n\n if (maxValue && compareTime(v, maxValue) > 0) {\n validationDetails.rangeOverflow = true;\n validationErrors.push(\"Value is above the maximum time.\");\n }\n\n if (validationErrors.length === 0) {\n return DEFAULT_VALIDATION_RESULT;\n }\n\n validationDetails.valid = false;\n return {\n isInvalid: true,\n validationDetails,\n validationErrors,\n };\n });\n const validation = createFormValidationState<T>({\n get value() {\n return value();\n },\n get isInvalid() {\n return props.isInvalid;\n },\n get validationState() {\n return explicitValidationState();\n },\n get validationBehavior() {\n return validationBehavior();\n },\n get validate() {\n return props.validate;\n },\n get builtinValidation() {\n return builtinValidation();\n },\n });\n const isInvalid = createMemo(() => validation.displayValidation().isInvalid);\n const validationState = createMemo<ValidationState | undefined>(\n () => explicitValidationState() ?? (isInvalid() ? \"invalid\" : undefined),\n );\n\n // Generate segments based on granularity\n const segments = createMemo<TimeSegment[]>(() => {\n const v = value();\n const parts = placeholderParts();\n const segs: TimeSegment[] = [];\n\n // Determine format options\n const shouldForceLeadingZeros = props.shouldForceLeadingZeros === true;\n const formatOptions: Intl.DateTimeFormatOptions = {\n hour: shouldForceLeadingZeros ? \"2-digit\" : \"numeric\",\n minute: \"2-digit\",\n hourCycle: hourCycle === 12 ? \"h12\" : \"h23\",\n };\n\n if (granularity === \"second\") {\n formatOptions.second = \"2-digit\";\n }\n\n // Use a base date for formatting\n const baseDate = new Date();\n if (v) {\n baseDate.setHours(getHour(v), getMinute(v), getSecond(v));\n }\n\n const formatter = new DateFormatter(locale, formatOptions);\n const formattedParts = formatter.formatToParts(baseDate);\n\n for (const part of formattedParts) {\n const type = mapTimePartType(part.type);\n\n if (type === \"literal\") {\n segs.push({\n type: \"literal\",\n text: part.value,\n isEditable: false,\n isPlaceholder: false,\n placeholder: part.value,\n });\n } else if (type) {\n const segValue = getTimeSegmentValue(v, type);\n const partValue = parts[type as keyof TimeParts];\n const hasValue = v !== null || partValue !== undefined;\n\n segs.push({\n type,\n text: hasValue ? part.value : getTimePlaceholderText(type),\n value: segValue ?? partValue,\n minValue: getTimeMinValue(type, hourCycle),\n maxValue: getTimeMaxValue(type, hourCycle),\n isEditable: !isDisabled() && !isReadOnly(),\n isPlaceholder: !hasValue,\n placeholder: getTimePlaceholderText(type),\n });\n }\n }\n\n return segs;\n });\n\n // Set value with onChange callback\n const setValue = (newValue: T | null) => {\n if (isDisabled() || isReadOnly()) return;\n\n const controlled = access(props.value);\n if (controlled === undefined) {\n setInternalValue(() => newValue);\n }\n\n if (props.onChange) {\n props.onChange(newValue);\n }\n\n setPlaceholderParts({});\n };\n\n // Set a specific segment value\n const setSegment = (type: TimeSegmentType, newValue: number) => {\n if (isDisabled() || isReadOnly()) return;\n if (type === \"literal\") return;\n\n const v = value();\n\n if (v) {\n const updated = updateTimePart(v, type, newValue, hourCycle);\n setValue(updated as T);\n } else {\n setPlaceholderParts((prev) => ({\n ...prev,\n [type]: newValue,\n }));\n }\n };\n\n // Increment a segment\n const incrementSegment = (type: TimeSegmentType) => {\n if (isDisabled() || isReadOnly()) return;\n if (type === \"literal\") return;\n\n const v = value();\n const current = v ? getTimeSegmentValue(v, type) : placeholderParts()[type as keyof TimeParts];\n const max = getTimeMaxValue(type, hourCycle);\n const min = getTimeMinValue(type, hourCycle);\n\n if (type === \"dayPeriod\") {\n // Toggle AM/PM\n const currentHour = v ? getHour(v) : (placeholderParts().hour ?? 0);\n const newHour = currentHour >= 12 ? currentHour - 12 : currentHour + 12;\n setSegment(\"hour\", newHour);\n return;\n }\n\n const newValue = current !== undefined ? current + 1 : min;\n setSegment(type, newValue > max ? min : newValue);\n };\n\n // Decrement a segment\n const decrementSegment = (type: TimeSegmentType) => {\n if (isDisabled() || isReadOnly()) return;\n if (type === \"literal\") return;\n\n const v = value();\n const current = v ? getTimeSegmentValue(v, type) : placeholderParts()[type as keyof TimeParts];\n const max = getTimeMaxValue(type, hourCycle);\n const min = getTimeMinValue(type, hourCycle);\n\n if (type === \"dayPeriod\") {\n // Toggle AM/PM\n const currentHour = v ? getHour(v) : (placeholderParts().hour ?? 0);\n const newHour = currentHour >= 12 ? currentHour - 12 : currentHour + 12;\n setSegment(\"hour\", newHour);\n return;\n }\n\n const newValue = current !== undefined ? current - 1 : max;\n setSegment(type, newValue < min ? max : newValue);\n };\n\n // Clear a segment\n const clearSegment = (type: TimeSegmentType) => {\n if (isDisabled() || isReadOnly()) return;\n\n const v = value();\n if (v) {\n setValue(null);\n } else {\n setPlaceholderParts((prev) => {\n const next = { ...prev };\n delete next[type as keyof TimeParts];\n return next;\n });\n }\n };\n\n return {\n value,\n defaultValue: initialValue,\n setValue,\n segments,\n setSegment,\n incrementSegment,\n decrementSegment,\n clearSegment,\n isDisabled,\n isReadOnly,\n isRequired,\n validationState,\n granularity,\n isInvalid,\n realtimeValidation: validation.realtimeValidation,\n displayValidation: validation.displayValidation,\n updateValidation: validation.updateValidation,\n resetValidation: validation.resetValidation,\n commitValidation: validation.commitValidation,\n locale,\n hourCycle,\n };\n}\n\ninterface TimeParts {\n hour?: number;\n minute?: number;\n second?: number;\n}\n\nfunction mapTimePartType(type: Intl.DateTimeFormatPartTypes): TimeSegmentType | null {\n switch (type) {\n case \"hour\":\n return \"hour\";\n case \"minute\":\n return \"minute\";\n case \"second\":\n return \"second\";\n case \"dayPeriod\":\n return \"dayPeriod\";\n case \"literal\":\n return \"literal\";\n default:\n return null;\n }\n}\n\nfunction getHour(time: TimeValue): number {\n if (\"hour\" in time) {\n return time.hour;\n }\n return 0;\n}\n\nfunction getMinute(time: TimeValue): number {\n if (\"minute\" in time) {\n return time.minute;\n }\n return 0;\n}\n\nfunction getSecond(time: TimeValue): number {\n if (\"second\" in time) {\n return time.second;\n }\n return 0;\n}\n\nfunction getTimeSegmentValue(time: TimeValue | null, type: TimeSegmentType): number | undefined {\n if (!time) return undefined;\n\n switch (type) {\n case \"hour\":\n return getHour(time);\n case \"minute\":\n return getMinute(time);\n case \"second\":\n return getSecond(time);\n case \"dayPeriod\":\n return getHour(time) >= 12 ? 1 : 0;\n default:\n return undefined;\n }\n}\n\nfunction getTimeMinValue(type: TimeSegmentType, hourCycle: number): number {\n switch (type) {\n case \"hour\":\n return hourCycle === 12 ? 1 : 0;\n case \"minute\":\n return 0;\n case \"second\":\n return 0;\n case \"dayPeriod\":\n return 0;\n default:\n return 0;\n }\n}\n\nfunction getTimeMaxValue(type: TimeSegmentType, hourCycle: number): number {\n switch (type) {\n case \"hour\":\n // In 12-hour mode, the spinbutton displays 1–12, so aria-valuemax is 12.\n return hourCycle === 12 ? 12 : 23;\n case \"minute\":\n return 59;\n case \"second\":\n return 59;\n case \"dayPeriod\":\n return 1;\n default:\n return 0;\n }\n}\n\nfunction getTimePlaceholderText(type: TimeSegmentType): string {\n switch (type) {\n case \"hour\":\n return \"––\";\n case \"minute\":\n return \"––\";\n case \"second\":\n return \"––\";\n case \"dayPeriod\":\n return \"AM\";\n default:\n return \"\";\n }\n}\n\nfunction updateTimePart(\n time: TimeValue,\n type: TimeSegmentType,\n value: number,\n _hourCycle: number,\n): TimeValue {\n if (!time) return time;\n\n // All TimeValue types in @internationalized/date have a .set() method\n const settable = time as { set(props: Record<string, number>): TimeValue };\n if (typeof settable.set !== \"function\") {\n return time;\n }\n\n switch (type) {\n case \"hour\":\n return settable.set({ hour: value });\n case \"minute\":\n return settable.set({ minute: value });\n case \"second\":\n return settable.set({ second: value });\n case \"dayPeriod\": {\n // dayPeriod 0 = AM, 1 = PM. Adjust hour by +/- 12 based on desired period.\n const currentHour = getHour(time);\n const isPM = value === 1;\n const isCurrentlyPM = currentHour >= 12;\n if (isPM && !isCurrentlyPM) {\n return settable.set({ hour: currentHour + 12 });\n }\n if (!isPM && isCurrentlyPM) {\n return settable.set({ hour: currentHour - 12 });\n }\n return time;\n }\n default:\n return time;\n }\n}\n\nfunction compareTime(a: TimeValue, b: TimeValue): number {\n const aHour = getHour(a);\n const bHour = getHour(b);\n if (aHour !== bHour) return aHour - bHour;\n\n const aMinute = getMinute(a);\n const bMinute = getMinute(b);\n if (aMinute !== bMinute) return aMinute - bMinute;\n\n const aSecond = getSecond(a);\n const bSecond = getSecond(b);\n return aSecond - bSecond;\n}\n","/**\n * DatePickerState for Solid-Stately\n *\n * Provides unified state management for DatePicker components.\n * Based on @react-stately/datepicker useDatePickerState\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport {\n type DateValue,\n type CalendarDateTime,\n Time,\n DateFormatter,\n toCalendarDate,\n toCalendarDateTime,\n toZoned,\n getLocalTimeZone,\n} from \"@internationalized/date\";\nimport { access, type MaybeAccessor } from \"../utils\";\nimport type { ValidationState } from \"./createCalendarState\";\nimport type { TimeValue } from \"./createTimeFieldState\";\n\nexport type Granularity = \"day\" | \"hour\" | \"minute\" | \"second\";\n\nexport type DatePickerStateProps<T extends DateValue = DateValue> = DatePickerStateOptions<T>;\n\nexport interface DatePickerStateOptions<T extends DateValue = DateValue> {\n value?: MaybeAccessor<T | null>;\n defaultValue?: T | null;\n onChange?: (value: T | null) => void;\n minValue?: MaybeAccessor<DateValue | undefined>;\n maxValue?: MaybeAccessor<DateValue | undefined>;\n isDisabled?: MaybeAccessor<boolean>;\n isReadOnly?: MaybeAccessor<boolean>;\n isRequired?: MaybeAccessor<boolean>;\n granularity?: Granularity;\n hourCycle?: 12 | 24;\n hideTimeZone?: boolean;\n placeholderValue?: DateValue;\n shouldCloseOnSelect?: boolean | (() => boolean);\n defaultOpen?: boolean;\n isOpen?: MaybeAccessor<boolean | undefined>;\n onOpenChange?: (isOpen: boolean) => void;\n isDateUnavailable?: (date: DateValue) => boolean;\n validationState?: MaybeAccessor<ValidationState | undefined>;\n}\n\nexport interface DatePickerState<T extends DateValue = DateValue> {\n value: Accessor<T | null>;\n defaultValue: T | null;\n setValue: (value: T | null) => void;\n dateValue: Accessor<DateValue | null>;\n setDateValue: (value: DateValue) => void;\n timeValue: Accessor<TimeValue | null>;\n setTimeValue: (value: TimeValue) => void;\n granularity: Granularity;\n hasTime: boolean;\n isOpen: Accessor<boolean>;\n open: () => void;\n close: () => void;\n setOpen: (isOpen: boolean) => void;\n isInvalid: Accessor<boolean>;\n validationState: Accessor<ValidationState | undefined>;\n builtinValidation: Accessor<{ isInvalid: boolean }>;\n showEra: Accessor<boolean>;\n formatValue: (locale: string, fieldOptions?: Intl.DateTimeFormatOptions) => string;\n getDateFormatter: (locale: string, formatOptions?: Intl.DateTimeFormatOptions) => DateFormatter;\n}\n\n/**\n * Provides unified state management for a DatePicker component.\n */\nexport function createDatePickerState<T extends DateValue = DateValue>(\n props: DatePickerStateOptions<T> = {},\n): DatePickerState<T> {\n const timeZone = getLocalTimeZone();\n\n // Internal signals for value and overlay state\n const [internalValue, setInternalValue] = createSignal<T | null>(props.defaultValue ?? null);\n const [internalOpen, setInternalOpen] = createSignal(props.defaultOpen ?? false);\n\n // Transient selections for date and time\n const [selectedDate, setSelectedDate] = createSignal<DateValue | null>(null);\n const [selectedTime, setSelectedTime] = createSignal<TimeValue | null>(null);\n\n // Controlled vs uncontrolled value\n const value = createMemo<T | null>(() => {\n const controlled = access(props.value);\n return controlled !== undefined ? controlled : internalValue();\n });\n\n // Granularity: auto-detect from value type if not provided\n const granularity = createMemo<Granularity>(() => {\n if (props.granularity) return props.granularity;\n const v = value();\n if (v && \"hour\" in v) {\n if (\"second\" in v) return \"second\";\n return \"minute\";\n }\n return \"day\";\n });\n\n const hasTime = createMemo(() => {\n const g = granularity();\n return g === \"hour\" || g === \"minute\" || g === \"second\";\n });\n\n // Derived states\n const isDisabled = createMemo(() => access(props.isDisabled) ?? false);\n const isReadOnly = createMemo(() => access(props.isReadOnly) ?? false);\n const validationState = createMemo(() => access(props.validationState));\n const isOpen: Accessor<boolean> = () => access(props.isOpen) ?? internalOpen();\n\n // Date and time portions of the current value\n const dateValue = createMemo<DateValue | null>(() => {\n const v = value();\n if (!v) return null;\n return toCalendarDate(v);\n });\n\n const timeValue = createMemo<TimeValue | null>(() => {\n const v = value();\n if (!v || !(\"hour\" in v)) return null;\n return v as unknown as TimeValue;\n });\n\n // Helper to resolve placeholder time (midnight fallback)\n const getPlaceholderTime = (): TimeValue => {\n const placeholder = props.placeholderValue;\n if (placeholder && \"hour\" in placeholder) {\n return placeholder as TimeValue;\n }\n return new Time(0, 0, 0);\n };\n\n // Commit combined date + time value\n const commitValue = (date: DateValue, time: TimeValue | null) => {\n if (isDisabled() || isReadOnly()) return;\n\n let combined: DateValue;\n if (time && hasTime()) {\n combined = toCalendarDateTime(date, time);\n } else {\n combined = date;\n }\n\n // Preserve ZonedDateTime timezone if the current committed value has one\n const current = value();\n if (current && \"timeZone\" in current && !(\"timeZone\" in combined)) {\n combined = toZoned(combined as CalendarDateTime, current.timeZone);\n }\n\n // Clear transient states\n setSelectedDate(null);\n setSelectedTime(null);\n\n // Update internal state if uncontrolled\n const controlled = access(props.value);\n if (controlled === undefined) {\n setInternalValue(() => combined as T);\n }\n\n if (props.onChange) {\n props.onChange(combined as T);\n }\n };\n\n // Set the full value directly\n const setValue = (newValue: T | null) => {\n if (isDisabled() || isReadOnly()) return;\n\n const controlled = access(props.value);\n if (controlled === undefined) {\n setInternalValue(() => newValue);\n }\n\n if (props.onChange) {\n props.onChange(newValue);\n }\n\n // Clear transient states\n setSelectedDate(null);\n setSelectedTime(null);\n };\n\n // Select a date (may commit if time is already selected or shouldCloseOnSelect)\n const setDateValue = (date: DateValue) => {\n if (isDisabled() || isReadOnly()) return;\n\n const currentTime = selectedTime();\n const currentValue = value();\n const shouldClose =\n typeof props.shouldCloseOnSelect === \"function\"\n ? props.shouldCloseOnSelect()\n : (props.shouldCloseOnSelect ?? true);\n\n if (hasTime() && (currentTime || shouldClose)) {\n // Preserve existing time from committed value if user hasn't explicitly selected a new time\n const existingTime =\n currentTime ??\n (currentValue && \"hour\" in currentValue ? (currentValue as unknown as TimeValue) : null);\n const timePart = existingTime ?? getPlaceholderTime();\n commitValue(date, timePart);\n\n if (shouldClose) {\n setOpen(false);\n }\n } else if (hasTime()) {\n // Store date transiently, waiting for time selection\n setSelectedDate(date);\n } else {\n // No time needed, commit immediately\n commitValue(date, null);\n\n if (shouldClose) {\n setOpen(false);\n }\n }\n };\n\n // Select a time (may commit if date is already selected)\n const setTimeValue = (time: TimeValue) => {\n if (isDisabled() || isReadOnly()) return;\n\n const currentDate = selectedDate();\n const currentValue = value();\n\n if (currentDate) {\n // We have a transient date, commit combined\n commitValue(currentDate, time);\n } else if (currentValue && hasTime()) {\n // We have an existing value with time, update the time portion\n const datePart = toCalendarDate(currentValue);\n commitValue(datePart, time);\n } else {\n // Store time transiently, waiting for date selection\n setSelectedTime(time);\n }\n };\n\n // Open / close helpers\n const open = () => setOpen(true);\n const close = () => setOpen(false);\n\n const setOpen = (openValue: boolean) => {\n if (openValue) {\n if (access(props.isOpen) === undefined) {\n setInternalOpen(true);\n }\n props.onOpenChange?.(true);\n } else {\n // When closing, only commit if both date and time are available (when time is required).\n // Don't auto-commit partial selections with placeholder time to avoid phantom values.\n const currentValue = value();\n const currentDate = selectedDate();\n const currentTime = selectedTime();\n\n if (!currentValue && currentDate && hasTime() && currentTime) {\n // Both date and time explicitly selected — safe to commit\n commitValue(currentDate, currentTime);\n }\n\n // Clear any remaining transient state\n setSelectedDate(null);\n setSelectedTime(null);\n if (access(props.isOpen) === undefined) {\n setInternalOpen(false);\n }\n props.onOpenChange?.(false);\n }\n };\n\n // Builtin validation against minValue, maxValue, and isDateUnavailable\n const builtinValidation = createMemo(() => {\n const v = value();\n if (!v) return { isInvalid: false };\n\n const minValue = access(props.minValue);\n const maxValue = access(props.maxValue);\n\n if (minValue && v.compare(minValue) < 0) return { isInvalid: true };\n if (maxValue && v.compare(maxValue) > 0) return { isInvalid: true };\n if (props.isDateUnavailable?.(v)) return { isInvalid: true };\n\n return { isInvalid: false };\n });\n\n const isInvalid = createMemo(() => {\n return builtinValidation().isInvalid || validationState() === \"invalid\";\n });\n\n // Show era for BC dates\n const showEra = createMemo(() => {\n const v = value();\n return v ? v.year < 1 : false;\n });\n\n // Format the current value using DateFormatter with era support for BC dates\n const formatValue = (locale: string, fieldOptions?: Intl.DateTimeFormatOptions): string => {\n const v = value();\n if (!v) return \"\";\n\n const options: Intl.DateTimeFormatOptions = { ...fieldOptions };\n\n // Add era for BC dates\n if (v.year < 1) {\n options.era = \"short\";\n }\n\n const formatter = new DateFormatter(locale, options);\n return formatter.format(v.toDate(timeZone));\n };\n\n // Get a DateFormatter instance\n const getDateFormatter = (\n locale: string,\n formatOptions?: Intl.DateTimeFormatOptions,\n ): DateFormatter => {\n return new DateFormatter(locale, formatOptions);\n };\n\n return {\n value,\n defaultValue: props.defaultValue ?? null,\n setValue,\n dateValue,\n setDateValue,\n timeValue,\n setTimeValue,\n get granularity() {\n return granularity();\n },\n get hasTime() {\n return hasTime();\n },\n isOpen,\n open,\n close,\n setOpen,\n isInvalid,\n validationState,\n builtinValidation,\n showEra,\n formatValue,\n getDateFormatter,\n };\n}\n","/**\n * State management for select components.\n * Based on @react-stately/select useSelectState.\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils\";\nimport { createListState } from \"../collections/createListState\";\nimport { createOverlayTriggerState } from \"../overlays\";\nimport type { Key, CollectionNode, Collection } from \"../collections/types\";\nimport type { SelectionMode, Selection } from \"../collections/types\";\nimport type { SelectionManager } from \"../selection/SelectionManager\";\n\nexport interface SelectStateProps<T = unknown> {\n /** The items to display in the select. */\n items: T[];\n /** Function to get the key for an item. */\n getKey?: (item: T) => Key;\n /** Function to get the text value for an item. */\n getTextValue?: (item: T) => string;\n /** Function to check if an item is disabled. */\n getDisabled?: (item: T) => boolean;\n /** Keys of disabled items. */\n disabledKeys?: Iterable<Key>;\n /** The currently selected key (controlled). */\n selectedKey?: Key | null;\n /** The default selected key (uncontrolled). */\n defaultSelectedKey?: Key | null;\n /** The selected keys (controlled, for multiple selection mode). */\n selectedKeys?: \"all\" | Iterable<Key>;\n /** Default selected keys (uncontrolled, for multiple selection mode). */\n defaultSelectedKeys?: \"all\" | Iterable<Key>;\n /** Handler called when the selection changes. */\n onSelectionChange?: (key: Key | null) => void;\n /** Handler called when selected keys change. */\n onSelectionChangeKeys?: (keys: Selection) => void;\n /** Selection mode for the select. */\n selectionMode?: Extract<SelectionMode, \"single\" | \"multiple\">;\n /** Whether the select is open (controlled). */\n isOpen?: boolean;\n /** Whether the select is open by default (uncontrolled). */\n defaultOpen?: boolean;\n /** Handler called when the open state changes. */\n onOpenChange?: (isOpen: boolean) => void;\n /** Whether the select is disabled. */\n isDisabled?: boolean;\n /** Whether the select is required. */\n isRequired?: boolean;\n}\n\nexport interface SelectState<T = unknown> {\n /** The collection of items. */\n readonly collection: Accessor<Collection<T>>;\n /**\n * The collection-aware selection manager. Mirrors upstream `useSelectState`,\n * which spreads the underlying `useListState` (including its selection manager).\n */\n readonly selectionManager: SelectionManager<T>;\n /** Whether the select dropdown is open. */\n readonly isOpen: Accessor<boolean>;\n /** Open the select dropdown. */\n open(): void;\n /** Close the select dropdown. */\n close(): void;\n /** Toggle the select dropdown. */\n toggle(): void;\n /** The currently selected key. */\n readonly selectedKey: Accessor<Key | null>;\n /** The selected keys. */\n readonly selectedKeys: Accessor<Selection>;\n /** The currently selected item. */\n readonly selectedItem: Accessor<CollectionNode<T> | null>;\n /** The currently selected items. */\n readonly selectedItems: Accessor<CollectionNode<T>[]>;\n /** Set the selected key. */\n setSelectedKey(key: Key | null): void;\n /** Set selected keys. */\n setSelectedKeys(keys: Iterable<Key>): void;\n /** The currently focused key. */\n readonly focusedKey: Accessor<Key | null>;\n /** Set the focused key. */\n setFocusedKey(key: Key | null): void;\n /** Whether the select has focus. */\n readonly isFocused: Accessor<boolean>;\n /** Set whether the select has focus. */\n setFocused(isFocused: boolean): void;\n /** Whether a specific key is disabled. */\n isKeyDisabled(key: Key): boolean;\n /** Whether the select is disabled. */\n readonly isDisabled: boolean;\n /** Whether the select is required. */\n readonly isRequired: boolean;\n /** The selection mode. */\n readonly selectionMode: Accessor<\"single\" | \"multiple\">;\n}\n\n/**\n * Creates state for a select component.\n * Combines list state with overlay trigger state for dropdown behavior.\n */\nexport function createSelectState<T = unknown>(\n props: MaybeAccessor<SelectStateProps<T>>,\n): SelectState<T> {\n const getProps = () => access(props);\n const selectionMode: Accessor<\"single\" | \"multiple\"> = () => getProps().selectionMode ?? \"single\";\n\n // Overlay trigger state for open/close\n const overlayState = createOverlayTriggerState({\n get isOpen() {\n return getProps().isOpen;\n },\n get defaultOpen() {\n return getProps().defaultOpen;\n },\n get onOpenChange() {\n return getProps().onOpenChange;\n },\n });\n\n // Track selected key\n const isControlledSingle = () => getProps().selectedKey !== undefined;\n const isControlledMultiple = () => getProps().selectedKeys !== undefined;\n const [internalSelectedKey, setInternalSelectedKey] = createSignal<Key | null>(\n getProps().defaultSelectedKey ?? null,\n );\n const [internalSelectedKeys, setInternalSelectedKeys] = createSignal<Selection>(\n getProps().defaultSelectedKeys === \"all\"\n ? \"all\"\n : new Set(getProps().defaultSelectedKeys ?? []),\n );\n\n const selectedKey: Accessor<Key | null> = () => {\n if (selectionMode() === \"multiple\") {\n const keys = selectedKeys();\n if (keys === \"all\") return null;\n return keys.size > 0 ? Array.from(keys)[0] : null;\n }\n\n return isControlledSingle() ? (getProps().selectedKey ?? null) : internalSelectedKey();\n };\n\n const setSelectedKey = (key: Key | null) => {\n if (selectionMode() === \"multiple\") {\n if (key == null) {\n if (!isControlledMultiple()) {\n setInternalSelectedKeys(new Set<Key>());\n }\n getProps().onSelectionChangeKeys?.(new Set<Key>());\n getProps().onSelectionChange?.(null);\n } else {\n const next = new Set([key]);\n if (!isControlledMultiple()) {\n setInternalSelectedKeys(next);\n }\n getProps().onSelectionChangeKeys?.(next);\n getProps().onSelectionChange?.(key);\n }\n return;\n }\n\n if (!isControlledSingle()) {\n setInternalSelectedKey(key);\n }\n getProps().onSelectionChange?.(key);\n getProps().onSelectionChangeKeys?.(key != null ? new Set([key]) : new Set<Key>());\n };\n\n const selectedKeys: Accessor<Selection> = createMemo(() => {\n if (selectionMode() === \"multiple\") {\n if (isControlledMultiple()) {\n const keys = getProps().selectedKeys;\n return keys === \"all\" ? \"all\" : new Set<Key>(keys ?? []);\n }\n return internalSelectedKeys();\n }\n\n const key = selectedKey();\n return key != null ? new Set<Key>([key]) : new Set<Key>();\n });\n\n const setSelectedKeys = (keys: Iterable<Key>) => {\n const next = new Set(keys);\n if (selectionMode() === \"multiple\") {\n if (!isControlledMultiple()) {\n setInternalSelectedKeys(next);\n }\n getProps().onSelectionChangeKeys?.(next);\n getProps().onSelectionChange?.(next.size > 0 ? Array.from(next)[0] : null);\n return;\n }\n\n const key = next.size > 0 ? Array.from(next)[0] : null;\n setSelectedKey(key);\n };\n\n // Create list state with select selection mode\n const listState = createListState<T>({\n get items() {\n return getProps().items;\n },\n get getKey() {\n return getProps().getKey;\n },\n get getTextValue() {\n return getProps().getTextValue;\n },\n get getDisabled() {\n return getProps().getDisabled;\n },\n get disabledKeys() {\n return getProps().disabledKeys;\n },\n get selectionMode() {\n return selectionMode();\n },\n disallowEmptySelection: true,\n get selectedKeys() {\n const keys = selectedKeys();\n if (keys === \"all\") return \"all\";\n return keys;\n },\n onSelectionChange(keys) {\n if (selectionMode() === \"multiple\") {\n if (!isControlledMultiple()) {\n setInternalSelectedKeys(keys);\n }\n getProps().onSelectionChangeKeys?.(keys);\n if (keys !== \"all\") {\n getProps().onSelectionChange?.(keys.size > 0 ? Array.from(keys)[0] : null);\n }\n return;\n }\n\n // Get the first (and only) selected key\n if (keys === \"all\") return;\n const key = keys.size > 0 ? Array.from(keys)[0] : null;\n setSelectedKey(key);\n // Close the dropdown after selection in single mode\n overlayState.close();\n },\n });\n\n // The select's own focus state (the trigger), separate from the collection's\n // focus-within state on the selection manager — upstream useSelectState keeps\n // these apart with a dedicated useState. Sharing the manager's signal makes\n // trigger focus re-arm the item roving-focus effect and steal focus back.\n const [isFocused, setFocused] = createSignal(false);\n\n // Get the selected item from the collection (memoized)\n const selectedItem: Accessor<CollectionNode<T> | null> = createMemo(() => {\n const key = selectedKey();\n if (key == null) return null;\n return listState.collection().getItem(key);\n });\n\n const selectedItems: Accessor<CollectionNode<T>[]> = createMemo(() => {\n const keys = selectedKeys();\n if (keys === \"all\") {\n return Array.from(listState.collection());\n }\n\n const items: CollectionNode<T>[] = [];\n for (const key of keys) {\n const item = listState.collection().getItem(key);\n if (item) items.push(item);\n }\n return items;\n });\n\n return {\n // Collection\n collection: listState.collection,\n selectionManager: listState.selectionManager,\n\n // Focus management\n focusedKey: listState.focusedKey,\n setFocusedKey: listState.setFocusedKey,\n isFocused,\n setFocused,\n\n // Overlay state\n isOpen: overlayState.isOpen,\n open: overlayState.open,\n close: overlayState.close,\n toggle: overlayState.toggle,\n\n // Select-specific\n selectionMode,\n selectedKey,\n selectedKeys,\n selectedItem,\n selectedItems,\n setSelectedKey,\n setSelectedKeys,\n isKeyDisabled: (key: Key) => listState.isDisabled(key),\n get isDisabled() {\n return getProps().isDisabled ?? false;\n },\n get isRequired() {\n return getProps().isRequired ?? false;\n },\n };\n}\n","/**\n * State management for ComboBox components.\n * Based on @react-stately/combobox useComboBoxState.\n *\n * ComboBox combines a text input with a dropdown list, allowing users to\n * either type to filter options or select from a list.\n */\n\nimport { createSignal, createMemo, createEffect, type Accessor } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils\";\nimport { createListState } from \"../collections/createListState\";\nimport { createOverlayTriggerState } from \"../overlays\";\nimport type { Key, CollectionNode, Collection, FocusStrategy } from \"../collections/types\";\nimport type { SelectionManager } from \"../selection/SelectionManager\";\n\nexport type MenuTriggerAction = \"focus\" | \"input\" | \"manual\";\n\nexport type { FocusStrategy } from \"../collections/types\";\n\nexport type FilterFn = (textValue: string, inputValue: string) => boolean;\n\nexport interface ComboBoxStateProps<T = unknown> {\n /** The items to display in the combobox dropdown. */\n items?: T[];\n /** Default items when uncontrolled. */\n defaultItems?: T[];\n /** Function to get the key for an item. */\n getKey?: (item: T) => Key;\n /** Function to get the text value for an item. */\n getTextValue?: (item: T) => string;\n /** Function to check if an item is disabled. */\n getDisabled?: (item: T) => boolean;\n /** Keys of disabled items. */\n disabledKeys?: Iterable<Key>;\n /** The selection mode for the combobox. */\n selectionMode?: \"single\" | \"multiple\";\n /** The currently selected key (controlled, single mode). */\n selectedKey?: Key | null;\n /** The default selected key (uncontrolled, single mode). */\n defaultSelectedKey?: Key | null;\n /** The currently selected keys (controlled, multiple mode). */\n selectedKeys?: Iterable<Key>;\n /** The default selected keys (uncontrolled, multiple mode). */\n defaultSelectedKeys?: Iterable<Key>;\n /** Handler called when the selection changes (single mode). */\n onSelectionChange?: (key: Key | null) => void;\n /** Handler called when the selection changes (multiple mode). */\n onSelectionChangeMultiple?: (keys: Set<Key>) => void;\n /** The current input value (controlled). */\n inputValue?: string;\n /** The default input value (uncontrolled). */\n defaultInputValue?: string;\n /** Handler called when the input value changes. */\n onInputChange?: (value: string) => void;\n /** Whether the combobox is open (controlled). */\n isOpen?: boolean;\n /** Whether the combobox is open by default (uncontrolled). */\n defaultOpen?: boolean;\n /** Handler called when the open state changes. */\n onOpenChange?: (isOpen: boolean, trigger?: MenuTriggerAction) => void;\n /** Whether the combobox is disabled. */\n isDisabled?: boolean;\n /** Whether the combobox is read-only. */\n isReadOnly?: boolean;\n /** Whether the combobox is required. */\n isRequired?: boolean;\n /** The filter function to use when filtering items. */\n defaultFilter?: FilterFn;\n /** Whether to allow the menu to open when there are no items. */\n allowsEmptyCollection?: boolean;\n /** Whether to allow custom values that don't match any option. */\n allowsCustomValue?: boolean;\n /** What triggers the menu to open. */\n menuTrigger?: MenuTriggerAction;\n /** Whether to close the menu on blur. */\n shouldCloseOnBlur?: boolean;\n}\n\nexport interface ComboBoxState<T = unknown> {\n /** The collection of items (may be filtered). */\n readonly collection: Accessor<Collection<T>>;\n /**\n * The collection-aware selection manager. Mirrors upstream `useComboBoxState`,\n * which returns the `useListState` selection manager bound to the unfiltered\n * collection (selection spans all items; filtering is display-only).\n */\n readonly selectionManager: SelectionManager<T>;\n /** Whether the combobox dropdown is open. */\n readonly isOpen: Accessor<boolean>;\n /** Open the combobox dropdown. */\n open(focusStrategy?: FocusStrategy | null, trigger?: MenuTriggerAction): void;\n /** Close the combobox dropdown. */\n close(): void;\n /** Toggle the combobox dropdown. */\n toggle(focusStrategy?: FocusStrategy | null, trigger?: MenuTriggerAction): void;\n /** The currently selected key (single mode). */\n readonly selectedKey: Accessor<Key | null>;\n /** The default selected key. */\n readonly defaultSelectedKey: Key | null;\n /** The currently selected item (single mode). */\n readonly selectedItem: Accessor<CollectionNode<T> | null>;\n /** Set the selected key. */\n setSelectedKey(key: Key | null): void;\n /** The currently selected keys (multiple mode). */\n readonly selectedKeys: Accessor<Set<Key>>;\n /** The currently selected items (multiple mode). */\n readonly selectedItems: Accessor<CollectionNode<T>[]>;\n /** Remove a selected key (multiple mode). */\n removeSelectedKey(key: Key): void;\n /** The current input value. */\n readonly inputValue: Accessor<string>;\n /** The default input value. */\n readonly defaultInputValue: string;\n /** Set the input value. */\n setInputValue(value: string): void;\n /** The currently focused key in the list. */\n readonly focusedKey: Accessor<Key | null>;\n /** Set the focused key. */\n setFocusedKey(key: Key | null): void;\n /** Whether the combobox input has focus. */\n readonly isFocused: Accessor<boolean>;\n /** Set whether the combobox has focus. */\n setFocused(isFocused: boolean): void;\n /** The focus strategy to use when opening. */\n readonly focusStrategy: Accessor<FocusStrategy | null>;\n /** Commit the current selection (select focused item or custom value). */\n commit(): void;\n /** Revert input to the selected item's text and close menu. */\n revert(): void;\n /** Whether a specific key is disabled. */\n isKeyDisabled(key: Key): boolean;\n /** Select a key and close the menu (for ListState compatibility). */\n select(key: Key): void;\n /** The selection mode. */\n readonly selectionMode: Accessor<\"single\" | \"multiple\">;\n /** Check if a key is selected. */\n isSelected(key: Key): boolean;\n /** Whether the combobox is disabled. */\n readonly isDisabled: boolean;\n /** Whether the combobox is read-only. */\n readonly isReadOnly: boolean;\n /** Whether the combobox is required. */\n readonly isRequired: boolean;\n}\n\n/**\n * Default filter function that does case-insensitive \"contains\" matching.\n */\nexport const defaultContainsFilter: FilterFn = (textValue, inputValue) => {\n return textValue.toLowerCase().includes(inputValue.toLowerCase());\n};\n\n/**\n * Creates state for a combobox component.\n * Combines list state with input value management and filtering.\n */\nexport function createComboBoxState<T = unknown>(\n props: MaybeAccessor<ComboBoxStateProps<T>>,\n): ComboBoxState<T> {\n const getProps = () => access(props);\n\n // Extract options with defaults\n const menuTrigger = () => getProps().menuTrigger ?? \"input\";\n const allowsEmptyCollection = () => getProps().allowsEmptyCollection ?? false;\n const allowsCustomValue = () => getProps().allowsCustomValue ?? false;\n const shouldCloseOnBlur = () => getProps().shouldCloseOnBlur ?? true;\n const isMultiple = () => getProps().selectionMode === \"multiple\";\n\n // Track focus strategy for list navigation\n const [focusStrategy, setFocusStrategy] = createSignal<FocusStrategy | null>(null);\n\n // Track whether we're showing all items (vs filtered)\n const [showAllItems, setShowAllItems] = createSignal(false);\n\n // Track the menu open trigger\n let menuOpenTrigger: MenuTriggerAction = \"focus\";\n\n // ---- Multi-select State ----\n const isMultiSelectionControlled = () => getProps().selectedKeys !== undefined;\n const [internalSelectedKeys, setInternalSelectedKeys] = createSignal<Set<Key>>(\n new Set(getProps().defaultSelectedKeys ?? []),\n );\n\n const selectedKeys: Accessor<Set<Key>> = () => {\n return isMultiSelectionControlled()\n ? new Set(getProps().selectedKeys ?? [])\n : internalSelectedKeys();\n };\n\n const setSelectedKeys = (keys: Set<Key>) => {\n if (!isMultiSelectionControlled()) {\n setInternalSelectedKeys(new Set(keys));\n }\n getProps().onSelectionChangeMultiple?.(keys);\n };\n\n // ---- Selection State (single mode) ----\n // Note: Selection state is initialized first because input value may depend on it\n const isSelectionControlled = () => getProps().selectedKey !== undefined;\n const [internalSelectedKey, setInternalSelectedKey] = createSignal<Key | null>(\n getProps().defaultSelectedKey ?? null,\n );\n\n // ---- Input Value State ----\n // Initialized after selection so we can derive from selected item if needed\n const isInputControlled = () => getProps().inputValue !== undefined;\n\n // We'll set the proper initial value after collection is created\n const [internalInputValue, setInternalInputValue] = createSignal(\n getProps().defaultInputValue ?? \"\",\n );\n // Track if we've initialized input from selection\n let inputInitialized = false;\n\n const inputValue: Accessor<string> = () => {\n return isInputControlled() ? (getProps().inputValue ?? \"\") : internalInputValue();\n };\n\n const setInputValue = (value: string) => {\n if (!isInputControlled()) {\n setInternalInputValue(value);\n }\n getProps().onInputChange?.(value);\n };\n\n // Track last committed input value\n const [lastValue, setLastValue] = createSignal(inputValue());\n\n const selectedKey: Accessor<Key | null> = () => {\n return isSelectionControlled() ? (getProps().selectedKey ?? null) : internalSelectedKey();\n };\n\n const setSelectedKey = (key: Key | null) => {\n if (!isSelectionControlled()) {\n setInternalSelectedKey(key);\n }\n getProps().onSelectionChange?.(key);\n };\n\n // ---- Overlay State ----\n const overlayState = createOverlayTriggerState({\n get isOpen() {\n return getProps().isOpen;\n },\n get defaultOpen() {\n return getProps().defaultOpen;\n },\n onOpenChange(isOpen: boolean) {\n getProps().onOpenChange?.(isOpen, isOpen ? menuOpenTrigger : undefined);\n },\n });\n\n // ---- List State (unfiltered collection) ----\n const listState = createListState<T>({\n get items() {\n // Use items or defaultItems\n return getProps().items ?? getProps().defaultItems ?? [];\n },\n get getKey() {\n return getProps().getKey;\n },\n get getTextValue() {\n return getProps().getTextValue;\n },\n get getDisabled() {\n return getProps().getDisabled;\n },\n get disabledKeys() {\n return getProps().disabledKeys;\n },\n get selectionMode() {\n return isMultiple() ? (\"multiple\" as const) : (\"single\" as const);\n },\n disallowEmptySelection: false,\n get selectedKeys() {\n if (isMultiple()) {\n return Array.from(selectedKeys());\n }\n const key = selectedKey();\n return key != null ? [key] : [];\n },\n onSelectionChange(keys) {\n if (keys === \"all\") return;\n\n if (isMultiple()) {\n // In multiple mode, toggle selections\n const newKeys = new Set(keys);\n setSelectedKeys(newKeys);\n return;\n }\n\n const key = keys.size > 0 ? Array.from(keys)[0] : null;\n\n // If same key selected, just reset input and close\n if (key === selectedKey()) {\n resetInputValue();\n closeMenu();\n return;\n }\n\n setSelectedKey(key);\n },\n });\n\n // ---- Filtered Collection ----\n const originalCollection = listState.collection;\n\n const filteredCollection = createMemo<Collection<T>>(() => {\n const collection = originalCollection();\n const input = inputValue();\n const filter = getProps().defaultFilter;\n\n // If no filter function provided, return original collection\n if (!filter) {\n return collection;\n }\n\n // Filter the collection based on input value\n return filterCollection(collection, input, filter);\n });\n\n // The displayed collection depends on showAllItems flag\n // Always show filtered collection (or all items if showAllItems is true)\n const displayedCollection = createMemo<Collection<T>>(() => {\n return showAllItems() ? originalCollection() : filteredCollection();\n });\n\n // ---- Selected Item(s) ----\n const selectedItem: Accessor<CollectionNode<T> | null> = () => {\n const key = selectedKey();\n if (key == null) return null;\n return originalCollection().getItem(key);\n };\n\n const selectedItems = createMemo<CollectionNode<T>[]>(() => {\n const keys = selectedKeys();\n const collection = originalCollection();\n const items: CollectionNode<T>[] = [];\n for (const key of keys) {\n const item = collection.getItem(key);\n if (item) items.push(item);\n }\n return items;\n });\n\n // Initialize input value from selected item if not already set\n // This runs once on creation\n if (!inputInitialized && !isInputControlled()) {\n const defaultKey = getProps().defaultSelectedKey;\n if (defaultKey != null && !getProps().defaultInputValue) {\n // Get the text value from the collection for the default selected key\n const item = originalCollection().getItem(defaultKey);\n if (item) {\n setInternalInputValue(item.textValue);\n setLastValue(item.textValue);\n }\n }\n inputInitialized = true;\n }\n\n // ---- Helper Functions ----\n const resetInputValue = () => {\n const item = selectedItem();\n const textValue = item?.textValue ?? \"\";\n setLastValue(textValue);\n setInputValue(textValue);\n };\n\n const closeMenu = () => {\n if (overlayState.isOpen()) {\n overlayState.close();\n }\n };\n\n // ---- Open/Toggle Logic ----\n const open = (strategy: FocusStrategy | null = null, trigger?: MenuTriggerAction) => {\n const displayAll = trigger === \"manual\" || (trigger === \"focus\" && menuTrigger() === \"focus\");\n\n // Check if we should open\n const filtered = filteredCollection();\n const original = originalCollection();\n const canOpen =\n allowsEmptyCollection() || filtered.size > 0 || (displayAll && original.size > 0);\n\n if (!canOpen) return;\n\n if (displayAll && !overlayState.isOpen()) {\n setShowAllItems(true);\n }\n\n menuOpenTrigger = trigger ?? \"focus\";\n setFocusStrategy(strategy);\n if (!overlayState.isOpen()) {\n const key = selectedKey();\n const nextFocusedKey =\n key != null && !listState.isDisabled(key)\n ? key\n : strategy === \"first\"\n ? displayedCollection().getFirstKey()\n : strategy === \"last\"\n ? displayedCollection().getLastKey()\n : null;\n listState.setFocused(true);\n listState.setFocusedKey(nextFocusedKey);\n }\n overlayState.open();\n };\n\n const toggle = (strategy: FocusStrategy | null = null, trigger?: MenuTriggerAction) => {\n const displayAll = trigger === \"manual\" || (trigger === \"focus\" && menuTrigger() === \"focus\");\n\n // Check if we can open (if closed)\n const filtered = filteredCollection();\n const original = originalCollection();\n const canOpen =\n allowsEmptyCollection() || filtered.size > 0 || (displayAll && original.size > 0);\n\n if (!canOpen && !overlayState.isOpen()) return;\n\n if (displayAll && !overlayState.isOpen()) {\n setShowAllItems(true);\n }\n\n if (!overlayState.isOpen()) {\n menuOpenTrigger = trigger ?? \"focus\";\n }\n\n setFocusStrategy(strategy);\n overlayState.toggle();\n };\n\n // ---- Commit/Revert Logic ----\n const commitCustomValue = () => {\n setSelectedKey(null);\n closeMenu();\n };\n\n const commitSelection = () => {\n // If both are controlled, just call onSelectionChange\n if (isSelectionControlled() && isInputControlled()) {\n getProps().onSelectionChange?.(selectedKey());\n const item = selectedItem();\n setLastValue(item?.textValue ?? \"\");\n closeMenu();\n } else {\n // Reset input to selected item's text\n resetInputValue();\n closeMenu();\n }\n };\n\n const commitValue = () => {\n if (allowsCustomValue()) {\n const item = selectedItem();\n const itemText = item?.textValue ?? \"\";\n if (inputValue() === itemText) {\n commitSelection();\n } else {\n commitCustomValue();\n }\n } else {\n commitSelection();\n }\n };\n\n const commit = () => {\n const focusedKey = listState.focusedKey();\n\n if (isMultiple()) {\n // In multiple mode, toggle the focused item without closing\n if (overlayState.isOpen() && focusedKey != null) {\n select(focusedKey);\n }\n return;\n }\n\n if (overlayState.isOpen() && focusedKey != null) {\n // If focused key is already selected, just commit\n if (selectedKey() === focusedKey) {\n commitSelection();\n } else {\n // Select the focused item\n setSelectedKey(focusedKey);\n closeMenu();\n }\n } else {\n commitValue();\n }\n };\n\n const revert = () => {\n if (allowsCustomValue() && selectedKey() == null) {\n commitCustomValue();\n } else {\n commitSelection();\n }\n };\n\n // ---- Focus Handling ----\n const [isFocused, setIsFocused] = createSignal(false);\n let valueOnFocus = \"\";\n\n const setFocused = (focused: boolean) => {\n if (focused) {\n valueOnFocus = inputValue();\n if (menuTrigger() === \"focus\" && !getProps().isReadOnly) {\n open(null, \"focus\");\n }\n } else {\n if (shouldCloseOnBlur()) {\n commitValue();\n }\n }\n setIsFocused(focused);\n };\n\n // ---- Effects for Auto Open/Close ----\n createEffect(() => {\n const input = inputValue();\n const filtered = filteredCollection();\n const isOpen = overlayState.isOpen();\n const last = lastValue();\n const focused = isFocused();\n\n // Auto-open when typing\n if (\n focused &&\n (filtered.size > 0 || allowsEmptyCollection()) &&\n !isOpen &&\n input !== last &&\n menuTrigger() !== \"manual\"\n ) {\n open(null, \"input\");\n }\n\n // Auto-close when empty (unless showing all)\n if (!showAllItems() && !allowsEmptyCollection() && isOpen && filtered.size === 0) {\n closeMenu();\n }\n\n // Clear focused key when input changes\n if (input !== last) {\n listState.setFocusedKey(null);\n setShowAllItems(false);\n\n // Clear selection when input is cleared (if not fully controlled)\n if (input === \"\" && (!isInputControlled() || !isSelectionControlled())) {\n setSelectedKey(null);\n }\n\n setLastValue(input);\n }\n });\n\n // Update input when selection changes (only in single mode)\n createEffect(() => {\n if (isMultiple()) return;\n const key = selectedKey();\n const item = key != null ? originalCollection().getItem(key) : null;\n const textValue = item?.textValue ?? \"\";\n\n // Only update if selection changed and not fully controlled\n if (!isInputControlled() || !isSelectionControlled()) {\n if (key != null && textValue !== inputValue()) {\n setInputValue(textValue);\n setLastValue(textValue);\n }\n }\n });\n\n // Close when selection changes (only in single mode)\n createEffect((prevKey: Key | null | undefined) => {\n if (isMultiple()) return undefined;\n const key = selectedKey();\n if (key != null && key !== prevKey) {\n closeMenu();\n }\n return key;\n }, undefined);\n\n // ---- Selection Methods for ListState compatibility ----\n // These methods allow createOption to work with ComboBoxState\n const select = (key: Key) => {\n if (isMultiple()) {\n // Toggle selection in multiple mode\n const current = new Set(selectedKeys());\n if (current.has(key)) {\n current.delete(key);\n } else {\n current.add(key);\n }\n setSelectedKeys(current);\n // Don't close menu and don't reset input in multi-select mode\n } else {\n setSelectedKey(key);\n closeMenu();\n }\n };\n\n const removeSelectedKey = (key: Key) => {\n if (isMultiple()) {\n const current = new Set(selectedKeys());\n current.delete(key);\n setSelectedKeys(current);\n }\n };\n\n const selectionMode: Accessor<\"single\" | \"multiple\"> = () => getProps().selectionMode ?? \"single\";\n\n const isSelected = (key: Key) => {\n if (isMultiple()) {\n return selectedKeys().has(key);\n }\n return selectedKey() === key;\n };\n\n // ---- Return State ----\n return {\n collection: displayedCollection,\n isOpen: overlayState.isOpen,\n open,\n close: commitValue,\n toggle,\n selectedKey,\n defaultSelectedKey: getProps().defaultSelectedKey ?? null,\n selectedItem,\n setSelectedKey,\n selectedKeys,\n selectedItems,\n removeSelectedKey,\n inputValue,\n defaultInputValue: getProps().defaultInputValue ?? \"\",\n setInputValue,\n selectionManager: listState.selectionManager,\n focusedKey: listState.focusedKey,\n setFocusedKey: listState.setFocusedKey,\n isFocused,\n setFocused,\n focusStrategy,\n commit,\n revert,\n // Selection state methods for ListState compatibility\n select,\n selectionMode,\n isSelected,\n isKeyDisabled: (key: Key) => listState.isDisabled(key),\n get isDisabled() {\n return getProps().isDisabled ?? false;\n },\n get isReadOnly() {\n return getProps().isReadOnly ?? false;\n },\n get isRequired() {\n return getProps().isRequired ?? false;\n },\n };\n}\n\n/**\n * Filter a collection based on input value.\n */\nfunction filterCollection<T>(\n collection: Collection<T>,\n inputValue: string,\n filter: FilterFn,\n): Collection<T> {\n if (!inputValue) {\n return collection;\n }\n\n const filteredItems: CollectionNode<T>[] = [];\n\n for (const item of collection) {\n if (item.type === \"section\") {\n // Filter section children\n const filteredChildren: CollectionNode<T>[] = [];\n if (item.childNodes) {\n for (const child of item.childNodes) {\n if (child.type === \"item\" && filter(child.textValue, inputValue)) {\n filteredChildren.push(child);\n }\n }\n }\n // Only include section if it has matching children\n if (filteredChildren.length > 0) {\n filteredItems.push({\n ...item,\n childNodes: filteredChildren,\n });\n }\n } else if (item.type === \"item\") {\n if (filter(item.textValue, inputValue)) {\n filteredItems.push(item);\n }\n }\n }\n\n // Create a new collection from filtered items\n return createFilteredCollection(filteredItems, collection);\n}\n\n/**\n * Create a filtered collection wrapper.\n */\nfunction createFilteredCollection<T>(\n items: CollectionNode<T>[],\n original: Collection<T>,\n): Collection<T> {\n const itemMap = new Map<Key, CollectionNode<T>>();\n\n for (const item of items) {\n itemMap.set(item.key, item);\n if (item.childNodes) {\n for (const child of item.childNodes) {\n itemMap.set(child.key, child);\n }\n }\n }\n\n return {\n get size() {\n let count = 0;\n for (const item of items) {\n if (item.type === \"item\") {\n count++;\n } else if (item.childNodes) {\n count += Array.from(item.childNodes).filter((c) => c.type === \"item\").length;\n }\n }\n return count;\n },\n getItem(key: Key) {\n return itemMap.get(key) ?? null;\n },\n getKeys() {\n return itemMap.keys();\n },\n getFirstKey() {\n for (const item of items) {\n if (item.type === \"item\") return item.key;\n if (item.childNodes) {\n for (const child of item.childNodes) {\n if (child.type === \"item\") return child.key;\n }\n }\n }\n return null;\n },\n getLastKey() {\n for (let i = items.length - 1; i >= 0; i--) {\n const item = items[i];\n if (item.type === \"item\") return item.key;\n if (item.childNodes) {\n const children = Array.from(item.childNodes);\n for (let j = children.length - 1; j >= 0; j--) {\n if (children[j].type === \"item\") return children[j].key;\n }\n }\n }\n return null;\n },\n getKeyBefore(key: Key) {\n return original.getKeyBefore(key);\n },\n getKeyAfter(key: Key) {\n return original.getKeyAfter(key);\n },\n at(index: number) {\n // Flatten items for indexing\n let currentIndex = 0;\n for (const item of items) {\n if (item.type === \"item\") {\n if (currentIndex === index) return item;\n currentIndex++;\n } else if (item.childNodes) {\n for (const child of item.childNodes) {\n if (child.type === \"item\") {\n if (currentIndex === index) return child;\n currentIndex++;\n }\n }\n }\n }\n return null;\n },\n getChildren(key: Key) {\n const item = itemMap.get(key);\n return item?.childNodes ?? [];\n },\n getTextValue(key: Key) {\n const item = itemMap.get(key);\n return item?.textValue ?? \"\";\n },\n [Symbol.iterator]() {\n return items[Symbol.iterator]();\n },\n };\n}\n","/**\n * State management for tab components.\n * Based on @react-stately/tabs.\n */\n\nimport { createComputed, createMemo, createSignal, type Accessor } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils\";\nimport { ListCollection } from \"../collections/ListCollection\";\nimport type {\n Collection,\n CollectionItemLike,\n CollectionNode,\n Key,\n FocusStrategy,\n} from \"../collections/types\";\n\nexport type KeyboardActivation = \"automatic\" | \"manual\";\nexport type TabOrientation = \"horizontal\" | \"vertical\";\n\nexport interface TabListStateProps<T = unknown> {\n /** The items in the tab list. */\n items?: T[];\n /** Function to get a key from an item. */\n getKey?: (item: T) => Key;\n /** Function to get text value from an item. */\n getTextValue?: (item: T) => string;\n /** Function to check if an item is disabled. */\n getDisabled?: (item: T) => boolean;\n /** Keys of disabled tabs. */\n disabledKeys?: Iterable<Key>;\n /** The currently selected tab key (controlled). */\n selectedKey?: Key | null;\n /** The default selected tab key (uncontrolled). */\n defaultSelectedKey?: Key;\n /** Handler for tab selection changes. */\n onSelectionChange?: (key: Key) => void;\n /** Whether the entire tab list is disabled. */\n isDisabled?: boolean;\n /** Whether tabs are activated automatically on focus or manually. */\n keyboardActivation?: KeyboardActivation;\n /** The orientation of the tab list. */\n orientation?: TabOrientation;\n}\n\nexport interface TabListState<T = unknown> {\n /** The collection of tabs. */\n readonly collection: Accessor<Collection<T>>;\n /** The currently selected tab key. */\n readonly selectedKey: Accessor<Key | null>;\n /** Set the selected tab key. */\n setSelectedKey(key: Key): void;\n /** The currently selected tab item. */\n readonly selectedItem: Accessor<CollectionNode<T> | null>;\n /** Whether the tab list is disabled. */\n readonly isDisabled: Accessor<boolean>;\n /** The keyboard activation mode. */\n readonly keyboardActivation: Accessor<KeyboardActivation>;\n /** The orientation of the tab list. */\n readonly orientation: Accessor<TabOrientation>;\n /** Whether a tab key is disabled. */\n isKeyDisabled(key: Key): boolean;\n /** The set of disabled keys. */\n readonly disabledKeys: Accessor<Set<Key>>;\n /** Whether the collection is focused. */\n readonly isFocused: Accessor<boolean>;\n /** Set the focused state. */\n setFocused(isFocused: boolean): void;\n /** The currently focused tab key. */\n readonly focusedKey: Accessor<Key | null>;\n /** Set the focused tab key. */\n setFocusedKey(key: Key | null, childStrategy?: FocusStrategy): void;\n /** The child focus strategy. */\n readonly childFocusStrategy: Accessor<FocusStrategy | null>;\n}\n\n/**\n * Creates state for a tab list component.\n */\nexport function createTabListState<T = unknown>(\n props: MaybeAccessor<TabListStateProps<T>>,\n): TabListState<T> {\n const getProps = () => access(props);\n\n const collection: Accessor<Collection<T>> = createMemo(() => {\n const p = getProps();\n const items = p.items ?? [];\n\n const nodes: CollectionNode<T>[] = items.map((item, index) => {\n const o = item as CollectionItemLike;\n const key = p.getKey?.(item) ?? o.key ?? o.id ?? index;\n const textValue = p.getTextValue?.(item) ?? o.textValue ?? o.label ?? String(item);\n const isDisabled = p.getDisabled?.(item) ?? o.isDisabled ?? false;\n\n return {\n type: \"item\" as const,\n key,\n value: item,\n textValue,\n rendered: null!,\n level: 0,\n index,\n parentKey: null,\n hasChildNodes: false,\n childNodes: [],\n isDisabled,\n };\n });\n\n return new ListCollection(nodes);\n });\n\n // Compute disabled keys (memoized to avoid rebuilding Set per access)\n const disabledKeys: Accessor<Set<Key>> = createMemo(() => {\n const p = getProps();\n const result = new Set<Key>(p.disabledKeys ?? []);\n\n const coll = collection();\n for (const node of coll) {\n if (node.isDisabled) {\n result.add(node.key);\n }\n }\n\n return result;\n });\n\n const isKeyDisabled = (key: Key): boolean => {\n const p = getProps();\n if (p.isDisabled) return true;\n return disabledKeys().has(key);\n };\n\n // Find the first non-disabled key\n const findFirstNonDisabledKey = (): Key | null => {\n const coll = collection();\n for (const node of coll) {\n if (!isKeyDisabled(node.key)) {\n return node.key;\n }\n }\n return null;\n };\n\n const getInitialSelectedKey = (): Key | null => {\n const p = getProps();\n\n if (p.selectedKey !== undefined) {\n return p.selectedKey;\n }\n\n if (p.defaultSelectedKey !== undefined && !isKeyDisabled(p.defaultSelectedKey)) {\n return p.defaultSelectedKey;\n }\n\n return findFirstNonDisabledKey();\n };\n\n const [selectedKeyInternal, setSelectedKeyInternal] = createSignal<Key | null>(\n getInitialSelectedKey(),\n );\n\n const selectedKey: Accessor<Key | null> = () => {\n const p = getProps();\n if (p.selectedKey !== undefined) {\n return p.selectedKey;\n }\n return selectedKeyInternal();\n };\n\n const setSelectedKey = (key: Key) => {\n if (isKeyDisabled(key)) return;\n if (selectedKey() === key) return;\n\n const p = getProps();\n if (p.selectedKey === undefined) {\n setSelectedKeyInternal(key);\n }\n\n p.onSelectionChange?.(key);\n };\n\n const selectedItem: Accessor<CollectionNode<T> | null> = () => {\n const key = selectedKey();\n if (key === null) return null;\n return collection().getItem(key);\n };\n\n const isDisabled: Accessor<boolean> = () => getProps().isDisabled ?? false;\n\n const keyboardActivation: Accessor<KeyboardActivation> = () =>\n getProps().keyboardActivation ?? \"automatic\";\n\n const orientation: Accessor<TabOrientation> = () => getProps().orientation ?? \"horizontal\";\n\n const [isFocused, setIsFocused] = createSignal(false);\n const [focusedKey, setFocusedKeyInternal] = createSignal<Key | null>(null);\n const [childFocusStrategy, setChildFocusStrategy] = createSignal<FocusStrategy | null>(null);\n\n const setFocusedKey = (key: Key | null, childStrategy?: FocusStrategy) => {\n setFocusedKeyInternal(key);\n setChildFocusStrategy(childStrategy ?? null);\n };\n\n // If the tab list doesn't have focus and the selected key changes, or if there\n // isn't a focused key yet, move the focused key to the selected key so the\n // roving tabIndex stays on the selected tab (mirrors useTabListState's effect).\n let lastSelectedKey: Key | null = selectedKey();\n createComputed(() => {\n const sel = selectedKey();\n if ((sel !== null && focusedKey() === null) || (!isFocused() && sel !== lastSelectedKey)) {\n setFocusedKey(sel);\n }\n lastSelectedKey = sel;\n });\n\n // Keep uncontrolled selection valid as items/disabled keys change.\n createComputed(() => {\n const p = getProps();\n if (p.selectedKey !== undefined) return;\n\n const coll = collection();\n const current = selectedKeyInternal();\n const currentExists = current !== null && coll.getItem(current) !== null;\n const currentEnabled = current !== null && !isKeyDisabled(current);\n\n if (currentExists && currentEnabled) return;\n\n if (\n p.defaultSelectedKey !== undefined &&\n coll.getItem(p.defaultSelectedKey) !== null &&\n !isKeyDisabled(p.defaultSelectedKey)\n ) {\n if (p.defaultSelectedKey !== current) {\n setSelectedKeyInternal(p.defaultSelectedKey);\n }\n return;\n }\n\n const nextKey = findFirstNonDisabledKey();\n if (nextKey !== current) {\n setSelectedKeyInternal(nextKey);\n }\n });\n\n return {\n collection,\n selectedKey,\n setSelectedKey,\n selectedItem,\n isDisabled,\n keyboardActivation,\n orientation,\n isKeyDisabled,\n disabledKeys,\n isFocused,\n setFocused: setIsFocused,\n focusedKey,\n setFocusedKey,\n childFocusStrategy,\n };\n}\n","/**\n * State management for NumberField.\n * Based on @react-stately/numberfield useNumberFieldState.\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils\";\n\nexport interface NumberFieldStateProps {\n /** The current value (controlled). */\n value?: number;\n /** The default value (uncontrolled). */\n defaultValue?: number;\n /** Handler called when the value changes. */\n onChange?: (value: number) => void;\n /** The minimum value. */\n minValue?: number;\n /** The maximum value. */\n maxValue?: number;\n /** The step value for increment/decrement. */\n step?: number;\n /** Whether the field is disabled. */\n isDisabled?: boolean;\n /** Whether the field is read-only. */\n isReadOnly?: boolean;\n /** The locale for number formatting. */\n locale?: string;\n /** Number format options. */\n formatOptions?: Intl.NumberFormatOptions;\n}\n\nexport interface NumberFieldState {\n /** The current input value as a string. */\n inputValue: Accessor<string>;\n /** The current numeric value. */\n numberValue: Accessor<number>;\n /** Whether the value can be incremented. */\n canIncrement: Accessor<boolean>;\n /** Whether the value can be decremented. */\n canDecrement: Accessor<boolean>;\n /** Whether the field is disabled. */\n isDisabled: Accessor<boolean>;\n /** Whether the field is read-only. */\n isReadOnly: Accessor<boolean>;\n /** The minimum value. */\n minValue: Accessor<number | undefined>;\n /** The maximum value. */\n maxValue: Accessor<number | undefined>;\n /** Set the input value. */\n setInputValue: (value: string) => void;\n /** Validate a partial input value. */\n validate: (value: string) => boolean;\n /** Commit the current input value. */\n commit: () => void;\n /** Increment the value by step. */\n increment: () => void;\n /** Decrement the value by step. */\n decrement: () => void;\n /** Set to maximum value. */\n incrementToMax: () => void;\n /** Set to minimum value. */\n decrementToMin: () => void;\n}\n\n/**\n * Handles decimal operations to avoid floating point errors.\n */\nfunction handleDecimalOperation(operator: \"+\" | \"-\", value1: number, value2: number): number {\n // Find the number of decimal places\n const getDecimals = (n: number) => {\n const str = String(n);\n const idx = str.indexOf(\".\");\n return idx === -1 ? 0 : str.length - idx - 1;\n };\n\n const decimals = Math.max(getDecimals(value1), getDecimals(value2));\n const multiplier = Math.pow(10, decimals);\n\n const int1 = Math.round(value1 * multiplier);\n const int2 = Math.round(value2 * multiplier);\n\n const result = operator === \"+\" ? int1 + int2 : int1 - int2;\n return result / multiplier;\n}\n\n/**\n * Clamps a value between min and max.\n */\nfunction clamp(value: number, min?: number, max?: number): number {\n let result = value;\n if (min != null && result < min) result = min;\n if (max != null && result > max) result = max;\n return result;\n}\n\n/**\n * Snaps a value to the nearest step.\n */\nfunction snapToStep(value: number, step: number, min?: number): number {\n const base = min ?? 0;\n const diff = value - base;\n const steps = Math.round(diff / step);\n return handleDecimalOperation(\"+\", base, steps * step);\n}\n\nfunction isValidStep(step: number | undefined): step is number {\n return step != null && !isNaN(step) && step > 0;\n}\n\n/**\n * Creates state for a number field.\n */\nexport function createNumberFieldState(\n props: MaybeAccessor<NumberFieldStateProps>,\n): NumberFieldState {\n const getProps = () => access(props);\n\n // Get locale and formatter\n const locale = () => getProps().locale ?? \"en-US\";\n const formatOptions = () => getProps().formatOptions ?? {};\n\n // Create number formatter\n const formatter = createMemo(() => {\n return new Intl.NumberFormat(locale(), formatOptions());\n });\n\n // Create number parser (simplified - real implementation would be more robust)\n const parseNumber = (value: string): number => {\n if (!value || value === \"\" || value === \"-\") return NaN;\n\n // Handle locale-specific decimal separators\n const opts = formatOptions();\n const testNumber = formatter().format(1.1);\n const decimalSeparator = testNumber.charAt(1);\n\n // Normalize the input\n let normalized = value;\n if (decimalSeparator !== \".\") {\n normalized = normalized.replace(decimalSeparator, \".\");\n }\n\n // Remove grouping separators and currency symbols\n normalized = normalized.replace(/[^\\d.-]/g, \"\");\n\n const parsed = parseFloat(normalized);\n if (isNaN(parsed)) return parsed;\n\n if (opts.style === \"percent\") {\n return parsed / 100;\n }\n\n return parsed;\n };\n\n // Format a number to string\n const formatNumber = (value: number): string => {\n if (isNaN(value)) return \"\";\n return formatter().format(value);\n };\n\n // Determine step value\n const hasCustomStep = createMemo(() => isValidStep(getProps().step));\n\n const step = createMemo(() => {\n const p = getProps();\n if (hasCustomStep()) return p.step as number;\n // Default step for percent is 0.01\n if (p.formatOptions?.style === \"percent\") return 0.01;\n return 1;\n });\n\n // Internal signals\n const [inputValue, setInputValueInternal] = createSignal<string>(\"\");\n const [numberValue, setNumberValue] = createSignal<number>(NaN);\n\n const applyConstraints = (value: number): number => {\n const p = getProps();\n if (isNaN(value)) return NaN;\n\n if (hasCustomStep()) {\n return clamp(snapToStep(value, step(), p.minValue), p.minValue, p.maxValue);\n }\n\n return clamp(value, p.minValue, p.maxValue);\n };\n\n // Initialize from props\n const initValue = () => {\n const p = getProps();\n const initial = p.value ?? p.defaultValue;\n if (initial != null) {\n const constrained = applyConstraints(initial);\n setNumberValue(constrained);\n setInputValueInternal(formatNumber(constrained));\n }\n };\n\n // Call init on first access\n let initialized = false;\n const ensureInitialized = () => {\n if (!initialized) {\n initialized = true;\n initValue();\n }\n };\n\n // Controlled mode: sync with props.value\n const actualNumberValue = createMemo(() => {\n ensureInitialized();\n const p = getProps();\n if (p.value !== undefined) {\n return applyConstraints(p.value);\n }\n return numberValue();\n });\n\n let lastControlledValue: number | undefined = undefined;\n const syncControlledValue = () => {\n const p = getProps();\n if (p.value === undefined) {\n lastControlledValue = undefined;\n return;\n }\n\n const constrained = applyConstraints(p.value);\n if (lastControlledValue === undefined || !Object.is(lastControlledValue, constrained)) {\n lastControlledValue = constrained;\n setNumberValue(constrained);\n setInputValueInternal(formatNumber(constrained));\n }\n };\n\n const parsedInputValue = () => {\n ensureInitialized();\n syncControlledValue();\n return parseNumber(inputValue());\n };\n\n // Validate partial input\n const validate = (value: string): boolean => {\n if (value === \"\" || value === \"-\") return true;\n\n // Allow partial decimal input like \"1.\"\n const opts = formatOptions();\n const testNumber = formatter().format(1.1);\n const decimalSeparator = testNumber.charAt(1);\n\n // Check if it's a valid partial number\n const pattern = new RegExp(\n `^-?\\\\d*${decimalSeparator === \".\" ? \"\\\\.\" : decimalSeparator}?\\\\d*$`,\n );\n return pattern.test(value);\n };\n\n // Set input value with validation\n const setInputValue = (value: string) => {\n ensureInitialized();\n syncControlledValue();\n setInputValueInternal(value);\n };\n\n // Commit the current input value\n const commit = () => {\n ensureInitialized();\n const p = getProps();\n const input = inputValue();\n\n if (input === \"\" || input === \"-\") {\n // Clear value\n setNumberValue(NaN);\n setInputValueInternal(p.value === undefined ? \"\" : formatNumber(actualNumberValue()));\n p.onChange?.(NaN);\n return;\n }\n\n let parsed = parseNumber(input);\n\n if (isNaN(parsed)) {\n // Invalid input - revert to current value\n setInputValueInternal(formatNumber(actualNumberValue()));\n return;\n }\n\n // Clamp and optionally snap to custom step.\n parsed = applyConstraints(parsed);\n\n // Update state\n setNumberValue(parsed);\n setInputValueInternal(formatNumber(parsed));\n\n p.onChange?.(parsed);\n };\n\n // Check if can increment\n const canIncrement = createMemo(() => {\n ensureInitialized();\n const p = getProps();\n if (p.isDisabled || p.isReadOnly) return false;\n\n const current = parsedInputValue();\n if (isNaN(current)) return true; // Can start from min\n\n if (p.maxValue == null) return true;\n return (\n snapToStep(current, step(), p.minValue) > current ||\n handleDecimalOperation(\"+\", current, step()) <= p.maxValue\n );\n });\n\n // Check if can decrement\n const canDecrement = createMemo(() => {\n ensureInitialized();\n const p = getProps();\n if (p.isDisabled || p.isReadOnly) return false;\n\n const current = parsedInputValue();\n if (isNaN(current)) return true; // Can start from max\n\n if (p.minValue == null) return true;\n return (\n snapToStep(current, step(), p.minValue) < current ||\n handleDecimalOperation(\"-\", current, step()) >= p.minValue\n );\n });\n\n const safeNextStep = (operation: \"+\" | \"-\", minOrMaxValue: number = 0): number => {\n const p = getProps();\n const parsed = parsedInputValue();\n\n if (isNaN(parsed)) {\n const base = isNaN(minOrMaxValue) ? 0 : minOrMaxValue;\n return clamp(snapToStep(base, step(), p.minValue), p.minValue, p.maxValue);\n }\n\n const snapped = snapToStep(parsed, step(), p.minValue);\n if ((operation === \"+\" && snapped > parsed) || (operation === \"-\" && snapped < parsed)) {\n return clamp(snapped, p.minValue, p.maxValue);\n }\n\n const next = handleDecimalOperation(operation, parsed, step());\n return clamp(snapToStep(next, step(), p.minValue), p.minValue, p.maxValue);\n };\n\n // Increment by step\n const increment = () => {\n ensureInitialized();\n syncControlledValue();\n const p = getProps();\n if (p.isDisabled || p.isReadOnly) return;\n\n const current = safeNextStep(\"+\", p.minValue);\n setNumberValue(current);\n setInputValueInternal(formatNumber(current));\n p.onChange?.(current);\n };\n\n // Decrement by step\n const decrement = () => {\n ensureInitialized();\n syncControlledValue();\n const p = getProps();\n if (p.isDisabled || p.isReadOnly) return;\n\n const current = safeNextStep(\"-\", p.maxValue);\n setNumberValue(current);\n setInputValueInternal(formatNumber(current));\n p.onChange?.(current);\n };\n\n // Set to max\n const incrementToMax = () => {\n ensureInitialized();\n syncControlledValue();\n const p = getProps();\n if (p.isDisabled || p.isReadOnly) return;\n\n if (p.maxValue == null) return;\n\n const snapped = snapToStep(p.maxValue, step(), p.minValue);\n setNumberValue(snapped);\n setInputValueInternal(formatNumber(snapped));\n p.onChange?.(snapped);\n };\n\n // Set to min\n const decrementToMin = () => {\n ensureInitialized();\n syncControlledValue();\n const p = getProps();\n if (p.isDisabled || p.isReadOnly) return;\n\n if (p.minValue == null) return;\n\n setNumberValue(p.minValue);\n setInputValueInternal(formatNumber(p.minValue));\n p.onChange?.(p.minValue);\n };\n\n return {\n get inputValue() {\n ensureInitialized();\n syncControlledValue();\n return inputValue;\n },\n get numberValue() {\n return actualNumberValue;\n },\n canIncrement,\n canDecrement,\n isDisabled: () => getProps().isDisabled ?? false,\n isReadOnly: () => getProps().isReadOnly ?? false,\n minValue: () => getProps().minValue,\n maxValue: () => getProps().maxValue,\n setInputValue,\n validate,\n commit,\n increment,\n decrement,\n incrementToMax,\n decrementToMin,\n };\n}\n","/**\n * Creates state for a search field component.\n * Based on @react-stately/searchfield useSearchFieldState.\n */\n\nimport { type Accessor, createSignal, createMemo } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils\";\n\nexport interface SearchFieldStateProps {\n /** The current value (controlled). */\n value?: string;\n /** The default value (uncontrolled). */\n defaultValue?: string;\n /** Handler that is called when the value changes. */\n onChange?: (value: string) => void;\n}\n\nexport interface SearchFieldState {\n /** The current value of the search field. */\n value: Accessor<string>;\n /** Sets the value of the search field. */\n setValue: (value: string) => void;\n}\n\n/**\n * Provides state management for a search field.\n */\nexport function createSearchFieldState(\n props: MaybeAccessor<SearchFieldStateProps>,\n): SearchFieldState {\n const getProps = () => access(props);\n\n const isControlled = () => getProps().value !== undefined;\n\n const [internalValue, setInternalValue] = createSignal(getProps().defaultValue ?? \"\");\n\n const value = createMemo(() => {\n const p = getProps();\n return isControlled() ? (p.value ?? \"\") : internalValue();\n });\n\n const setValue = (newValue: string) => {\n const p = getProps();\n\n if (!isControlled()) {\n setInternalValue(newValue);\n }\n\n p.onChange?.(newValue);\n };\n\n return {\n value,\n setValue,\n };\n}\n","/**\n * Creates state for a slider component.\n * Based on @react-stately/slider useSliderState.\n */\n\nimport { type Accessor, createSignal, createMemo } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils\";\n\nexport type SliderOrientation = \"horizontal\" | \"vertical\";\n\nexport interface SliderStateProps {\n /** The current value (controlled). */\n value?: number;\n /** The default value (uncontrolled). */\n defaultValue?: number;\n /** Handler called when the value changes. */\n onChange?: (value: number) => void;\n /** Handler called when the user stops dragging. */\n onChangeEnd?: (value: number) => void;\n /** The minimum value. */\n minValue?: number;\n /** The maximum value. */\n maxValue?: number;\n /** The step value. */\n step?: number;\n /** The orientation of the slider. */\n orientation?: SliderOrientation;\n /** Whether the slider is disabled. */\n isDisabled?: boolean;\n /** The locale for number formatting. */\n locale?: string;\n /** Number format options. */\n formatOptions?: Intl.NumberFormatOptions;\n}\n\nexport interface SliderState {\n /** The current value. */\n value: Accessor<number>;\n /** Sets the value. */\n setValue: (value: number) => void;\n /** Sets the value by percent (0-1). */\n setValuePercent: (percent: number) => void;\n /** Gets the value as a percent (0-1). */\n getValuePercent: Accessor<number>;\n /** Gets the formatted value string. */\n getFormattedValue: Accessor<string>;\n /** Whether the thumb is being dragged. */\n isDragging: Accessor<boolean>;\n /** Sets the dragging state. */\n setDragging: (dragging: boolean) => void;\n /** Whether the slider is focused. */\n isFocused: Accessor<boolean>;\n /** Sets the focused state. */\n setFocused: (focused: boolean) => void;\n /** Increments the value by step. */\n increment: (stepMultiplier?: number) => void;\n /** Decrements the value by step. */\n decrement: (stepMultiplier?: number) => void;\n /** The minimum value. */\n minValue: number;\n /** The maximum value. */\n maxValue: number;\n /** The step value. */\n step: number;\n /** The page step (larger step for Page Up/Down). */\n pageStep: number;\n /** The orientation. */\n orientation: SliderOrientation;\n /** Whether the slider is disabled. */\n isDisabled: boolean;\n}\n\nconst DEFAULT_MIN = 0;\nconst DEFAULT_MAX = 100;\nconst DEFAULT_STEP = 1;\n\n/**\n * Clamps a value between min and max.\n */\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(Math.max(value, min), max);\n}\n\n/**\n * Snaps a value to the nearest step.\n */\nfunction snapToStep(value: number, min: number, max: number, step: number): number {\n const snapped = Math.round((value - min) / step) * step + min;\n // Handle floating point precision issues\n const decimalPlaces = (step.toString().split(\".\")[1] || \"\").length;\n const rounded = parseFloat(snapped.toFixed(decimalPlaces));\n return clamp(rounded, min, max);\n}\n\n/**\n * Provides state management for a slider component.\n */\nexport function createSliderState(props: MaybeAccessor<SliderStateProps>): SliderState {\n const getProps = () => access(props);\n\n const initialProps = getProps();\n const initialMinValue = initialProps.minValue ?? DEFAULT_MIN;\n const initialMaxValue = initialProps.maxValue ?? DEFAULT_MAX;\n const initialStep = initialProps.step ?? DEFAULT_STEP;\n\n const minValue = createMemo(() => getProps().minValue ?? DEFAULT_MIN);\n const maxValue = createMemo(() => getProps().maxValue ?? DEFAULT_MAX);\n const step = createMemo(() => getProps().step ?? DEFAULT_STEP);\n const orientation = createMemo(() => getProps().orientation ?? \"horizontal\");\n const isDisabled = createMemo(() => getProps().isDisabled ?? false);\n const pageStep = createMemo(() =>\n Math.max(\n step(),\n snapToStep((maxValue() - minValue()) / 10, 0, maxValue() - minValue(), step()),\n ),\n );\n\n // Controlled vs uncontrolled\n const isControlled = () => getProps().value !== undefined;\n\n // Internal signal for uncontrolled mode\n const [internalValue, setInternalValue] = createSignal(\n snapToStep(\n initialProps.defaultValue ?? initialMinValue,\n initialMinValue,\n initialMaxValue,\n initialStep,\n ),\n );\n\n // Dragging and focus state\n const [isDragging, setIsDragging] = createSignal(false);\n const [isFocused, setIsFocused] = createSignal(false);\n\n // Current value accessor\n const value = createMemo(() => {\n const p = getProps();\n const rawValue = isControlled() ? (p.value ?? minValue()) : internalValue();\n return snapToStep(rawValue, minValue(), maxValue(), step());\n });\n\n // Value as percent (0-1)\n const getValuePercent = createMemo(() => {\n return (value() - minValue()) / (maxValue() - minValue());\n });\n\n // Formatted value\n const getFormattedValue = createMemo(() => {\n const p = getProps();\n const formatter = new Intl.NumberFormat(p.locale, p.formatOptions);\n return formatter.format(value());\n });\n\n // Set value function\n const setValue = (newValue: number) => {\n if (isDisabled()) return;\n\n const p = getProps();\n const snappedValue = snapToStep(newValue, minValue(), maxValue(), step());\n\n if (!isControlled()) {\n setInternalValue(snappedValue);\n }\n\n p.onChange?.(snappedValue);\n };\n\n // Set value by percent\n const setValuePercent = (percent: number) => {\n const clampedPercent = clamp(percent, 0, 1);\n const newValue = clampedPercent * (maxValue() - minValue()) + minValue();\n setValue(newValue);\n };\n\n // Dragging state management\n const setDragging = (dragging: boolean) => {\n const wasDragging = isDragging();\n setIsDragging(dragging);\n\n // Call onChangeEnd when dragging stops\n if (wasDragging && !dragging) {\n getProps().onChangeEnd?.(value());\n }\n };\n\n // Increment/decrement\n const increment = (stepMultiplier = 1) => {\n if (isDisabled()) return;\n setValue(value() + step() * stepMultiplier);\n };\n\n const decrement = (stepMultiplier = 1) => {\n if (isDisabled()) return;\n setValue(value() - step() * stepMultiplier);\n };\n\n // Set focused state\n const setFocused = (focused: boolean) => {\n setIsFocused(focused);\n };\n\n return {\n value,\n setValue,\n setValuePercent,\n getValuePercent,\n getFormattedValue,\n isDragging,\n setDragging,\n isFocused,\n setFocused,\n increment,\n decrement,\n get minValue() {\n return minValue();\n },\n get maxValue() {\n return maxValue();\n },\n get step() {\n return step();\n },\n get pageStep() {\n return pageStep();\n },\n get orientation() {\n return orientation();\n },\n get isDisabled() {\n return isDisabled();\n },\n };\n}\n","/**\n * Manages state for a tooltip trigger.\n * Based on @react-stately/tooltip useTooltipTriggerState.\n *\n * Tracks whether the tooltip is open, and provides methods to toggle this state.\n * Ensures only one tooltip is open at a time and controls the delay for showing a tooltip.\n */\n\nimport { createSignal, onCleanup, type Accessor } from \"solid-js\";\nimport { createOverlayTriggerState, type OverlayTriggerProps } from \"../overlays\";\nimport { isServer } from \"../ssr\";\n\n// Default delays (in ms)\nconst TOOLTIP_DELAY = 1500;\nconst TOOLTIP_COOLDOWN = 500;\n\nexport interface TooltipTriggerProps extends OverlayTriggerProps {\n /** The delay time in milliseconds for the tooltip to show up. */\n delay?: number;\n /** The delay time in milliseconds for the tooltip to close. */\n closeDelay?: number;\n}\n\nexport interface TooltipTriggerState {\n /** Whether the tooltip is currently showing. */\n readonly isOpen: Accessor<boolean>;\n /**\n * Shows the tooltip. By default, the tooltip becomes visible after a delay\n * depending on a global warmup timer. The `immediate` option shows the\n * tooltip immediately instead.\n */\n open(immediate?: boolean): void;\n /** Hides the tooltip. */\n close(immediate?: boolean): void;\n}\n\n// Global state for coordinating tooltips\nlet tooltips: Record<string, (immediate?: boolean) => void> = {};\nlet tooltipId = 0;\nlet globalWarmedUp = false;\nlet globalWarmUpTimeout: ReturnType<typeof setTimeout> | null = null;\nlet globalCooldownTimeout: ReturnType<typeof setTimeout> | null = null;\n\n/**\n * Resets the global tooltip state. Useful for testing.\n * @internal\n */\nexport function resetTooltipState(): void {\n tooltips = {};\n tooltipId = 0;\n globalWarmedUp = false;\n if (globalWarmUpTimeout) {\n clearTimeout(globalWarmUpTimeout);\n globalWarmUpTimeout = null;\n }\n if (globalCooldownTimeout) {\n clearTimeout(globalCooldownTimeout);\n globalCooldownTimeout = null;\n }\n}\n\n/**\n * Manages state for a tooltip trigger. Tracks whether the tooltip is open, and provides\n * methods to toggle this state. Ensures only one tooltip is open at a time and controls\n * the delay for showing a tooltip.\n */\nexport function createTooltipTriggerState(props: TooltipTriggerProps = {}): TooltipTriggerState {\n const delay = () => props.delay ?? TOOLTIP_DELAY;\n const closeDelay = () => props.closeDelay ?? TOOLTIP_COOLDOWN;\n\n const overlayState = createOverlayTriggerState(props);\n const id = `tooltip-${++tooltipId}`;\n\n let closeTimeout: ReturnType<typeof setTimeout> | null = null;\n const [closeCallback, setCloseCallback] = createSignal<() => void>(() => overlayState.close());\n\n const ensureTooltipEntry = () => {\n tooltips[id] = hideTooltip;\n };\n\n const closeOpenTooltips = () => {\n for (const hideTooltipId in tooltips) {\n if (hideTooltipId !== id) {\n tooltips[hideTooltipId](true);\n delete tooltips[hideTooltipId];\n }\n }\n };\n\n const showTooltip = () => {\n if (closeTimeout) {\n clearTimeout(closeTimeout);\n closeTimeout = null;\n }\n closeOpenTooltips();\n ensureTooltipEntry();\n globalWarmedUp = true;\n overlayState.open();\n\n if (globalWarmUpTimeout) {\n clearTimeout(globalWarmUpTimeout);\n globalWarmUpTimeout = null;\n }\n if (globalCooldownTimeout) {\n clearTimeout(globalCooldownTimeout);\n globalCooldownTimeout = null;\n }\n };\n\n const hideTooltip = (immediate?: boolean) => {\n if (immediate || closeDelay() <= 0) {\n if (closeTimeout) {\n clearTimeout(closeTimeout);\n closeTimeout = null;\n }\n closeCallback()();\n } else if (!closeTimeout) {\n closeTimeout = setTimeout(() => {\n closeTimeout = null;\n closeCallback()();\n }, closeDelay());\n }\n\n if (globalWarmUpTimeout) {\n clearTimeout(globalWarmUpTimeout);\n globalWarmUpTimeout = null;\n }\n\n if (globalWarmedUp) {\n if (globalCooldownTimeout) {\n clearTimeout(globalCooldownTimeout);\n }\n globalCooldownTimeout = setTimeout(\n () => {\n delete tooltips[id];\n globalCooldownTimeout = null;\n globalWarmedUp = false;\n },\n Math.max(TOOLTIP_COOLDOWN, closeDelay()),\n );\n }\n };\n\n const warmupTooltip = () => {\n closeOpenTooltips();\n ensureTooltipEntry();\n\n if (!overlayState.isOpen() && !globalWarmUpTimeout && !globalWarmedUp) {\n globalWarmUpTimeout = setTimeout(() => {\n globalWarmUpTimeout = null;\n globalWarmedUp = true;\n showTooltip();\n }, delay());\n } else if (!overlayState.isOpen()) {\n showTooltip();\n }\n };\n\n // Update close callback when overlayState.close changes\n setCloseCallback(() => overlayState.close);\n\n // Cleanup on unmount\n onCleanup(() => {\n if (closeTimeout) {\n clearTimeout(closeTimeout);\n }\n if (tooltips[id]) {\n delete tooltips[id];\n }\n });\n\n return {\n isOpen: overlayState.isOpen,\n open: (immediate?: boolean) => {\n if (isServer) return;\n if (!immediate && delay() > 0 && !closeTimeout) {\n warmupTooltip();\n } else {\n showTooltip();\n }\n },\n close: hideTooltip,\n };\n}\n","/**\n * Toast state management for SolidJS\n * Based on @react-stately/toast useToastState\n */\n\nimport { createSignal, onCleanup, type Accessor } from \"solid-js\";\n\nexport interface ToastOptions {\n /** A timeout to automatically close the toast, in milliseconds. */\n timeout?: number;\n /** The priority of the toast relative to other toasts. */\n priority?: number;\n /** Handler called when the toast is closed. */\n onClose?: () => void;\n}\n\nexport interface QueuedToast<T> {\n /** The content of the toast. */\n content: T;\n /** A unique key for the toast. */\n key: string;\n /** The timer for the toast. */\n timer: Timer | null;\n /** Whether the toast should be animated. */\n animation?: \"entering\" | \"exiting\" | \"queued\";\n /** The priority of the toast. */\n priority: number;\n /** Handler called when the toast is closed. */\n onClose?: () => void;\n /** The timeout for the toast. */\n timeout?: number;\n}\n\n/** The kind of queue mutation that triggered a notification, passed to `wrapUpdate`. */\nexport type ToastAction = \"add\" | \"remove\" | \"clear\";\n\nexport interface ToastQueueOptions {\n /** The maximum number of toasts to display at once. */\n maxVisibleToasts?: number;\n /** Whether toasts should stack (true) or queue (false). */\n hasExitAnimation?: boolean;\n /**\n * Wraps each update to the visible toasts (e.g. in `document.startViewTransition()`),\n * so the resulting re-render can be animated. Receives the action that triggered the\n * update. Mirrors `@react-stately/toast`'s `wrapUpdate`.\n */\n wrapUpdate?: (fn: () => void, action: ToastAction) => void;\n}\n\nexport interface ToastStateProps<T> {\n /** The toast queue to use. */\n queue: ToastQueue<T>;\n}\n\nexport interface ToastState<T> {\n /** The currently visible toasts. */\n visibleToasts: Accessor<QueuedToast<T>[]>;\n /** Adds a toast to the queue. */\n add: (content: T, options?: ToastOptions) => string;\n /** Closes a toast by key. Starts exit animation if hasExitAnimation is enabled. */\n close: (key: string) => void;\n /**\n * Removes a toast after exit animation completes.\n * Call this from the component layer when the CSS exit animation finishes.\n * If hasExitAnimation is false, close() removes immediately and this is not needed.\n */\n remove: (key: string) => void;\n /** Clears all queued and visible toasts. */\n clear: () => void;\n /** Pauses all toast timers. */\n pauseAll: () => void;\n /** Resumes all toast timers. */\n resumeAll: () => void;\n}\n\n/**\n * A Timer that supports pause and resume.\n */\nexport class Timer {\n private timerId: number | null = null;\n private startTime: number = 0;\n private remaining: number;\n private callback: () => void;\n\n constructor(callback: () => void, delay: number) {\n this.callback = callback;\n this.remaining = delay;\n this.resume();\n }\n\n pause() {\n if (this.timerId === null) {\n return;\n }\n clearTimeout(this.timerId);\n this.timerId = null;\n this.remaining -= Date.now() - this.startTime;\n }\n\n resume() {\n if (this.timerId !== null) {\n return;\n }\n this.startTime = Date.now();\n this.timerId = window.setTimeout(() => {\n this.timerId = null;\n this.callback();\n }, this.remaining);\n }\n\n reset(delay: number) {\n this.pause();\n this.remaining = delay;\n this.resume();\n }\n\n cancel() {\n if (this.timerId !== null) {\n clearTimeout(this.timerId);\n this.timerId = null;\n }\n }\n}\n\ntype SubscribeCallback<T> = (toasts: QueuedToast<T>[]) => void;\n\n/**\n * A queue that manages toast notifications.\n * Can be created once and shared across the app (singleton pattern).\n */\nexport class ToastQueue<T> {\n private queue: QueuedToast<T>[] = [];\n private subscriptions = new Set<SubscribeCallback<T>>();\n private maxVisibleToasts: number;\n private hasExitAnimation: boolean;\n private keyCounter = 0;\n private wrapUpdate?: (fn: () => void, action: ToastAction) => void;\n\n constructor(options: ToastQueueOptions = {}) {\n this.maxVisibleToasts = options.maxVisibleToasts ?? 5;\n this.hasExitAnimation = options.hasExitAnimation ?? false;\n this.wrapUpdate = options.wrapUpdate;\n }\n\n /**\n * Installs (or clears) the function that wraps visible-toast updates, so the\n * resulting re-render can be animated. Used to attach `document.startViewTransition`\n * to a shared queue (e.g. the global queue) after construction.\n */\n setWrapUpdate(wrapUpdate?: (fn: () => void, action: ToastAction) => void): void {\n this.wrapUpdate = wrapUpdate;\n }\n\n private runWithWrapUpdate(fn: () => void, action: ToastAction): void {\n if (this.wrapUpdate) {\n this.wrapUpdate(fn, action);\n } else {\n fn();\n }\n }\n\n /**\n * Subscribe to queue changes.\n */\n subscribe(callback: SubscribeCallback<T>): () => void {\n this.subscriptions.add(callback);\n return () => {\n this.subscriptions.delete(callback);\n };\n }\n\n /**\n * Add a toast to the queue.\n */\n add(content: T, options: ToastOptions = {}): string {\n const key = String(this.keyCounter++);\n\n const toast: QueuedToast<T> = {\n content,\n key,\n timer: null,\n priority: options.priority ?? 0,\n onClose: options.onClose,\n timeout: options.timeout,\n animation: \"entering\",\n };\n\n // Find insertion point based on priority\n let low = 0;\n let high = this.queue.length;\n while (low < high) {\n const mid = Math.floor((low + high) / 2);\n if (toast.priority >= this.queue[mid].priority) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n // Insert at the correct position\n this.queue = [...this.queue.slice(0, low), toast, ...this.queue.slice(low)];\n\n // Start timer for visible toasts\n this.updateVisibility(\"add\");\n\n return key;\n }\n\n /**\n * Close a toast by key.\n */\n close(key: string): void {\n const toast = this.queue.find((t) => t.key === key);\n if (!toast) return;\n\n // Cancel any existing timer\n toast.timer?.cancel();\n\n if (this.hasExitAnimation && toast.animation !== \"queued\") {\n // Mark as exiting for animation\n this.queue = this.queue.map((t) =>\n t.key === key ? { ...t, timer: null, animation: \"exiting\" } : t,\n );\n this.notify(\"remove\");\n } else {\n // Remove immediately\n this.remove(key);\n }\n }\n\n /**\n * Remove a toast after exit animation completes.\n */\n remove(key: string): void {\n const toast = this.queue.find((t) => t.key === key);\n if (toast) {\n toast.onClose?.();\n toast.timer?.cancel();\n }\n\n this.queue = this.queue.filter((t) => t.key !== key);\n this.updateVisibility(\"remove\");\n }\n\n /**\n * Clear all queued and visible toasts.\n */\n clear(): void {\n for (const toast of this.queue) {\n toast.timer?.cancel();\n }\n\n this.queue = [];\n this.notify(\"clear\");\n }\n\n /**\n * Pause all toast timers.\n */\n pauseAll(): void {\n for (const toast of this.queue) {\n toast.timer?.pause();\n }\n }\n\n /**\n * Resume all toast timers.\n */\n resumeAll(): void {\n for (const toast of this.queue) {\n toast.timer?.resume();\n }\n }\n\n private updateVisibility(action: ToastAction): void {\n // Mark toasts as visible or queued based on maxVisibleToasts\n const visibleCount = this.queue.filter(\n (t) => t.animation !== \"queued\" && t.animation !== \"exiting\",\n ).length;\n\n let promoted = 0;\n this.queue = this.queue.map((toast) => {\n let nextToast = toast;\n\n if (nextToast.animation === \"queued\" && visibleCount + promoted < this.maxVisibleToasts) {\n nextToast = { ...nextToast, animation: \"entering\" };\n promoted++;\n }\n if (nextToast.animation === \"queued\") return nextToast;\n\n // Start timer for visible toasts\n if (\n nextToast.timeout != null &&\n nextToast.timer === null &&\n nextToast.animation !== \"exiting\"\n ) {\n nextToast = {\n ...nextToast,\n timer: new Timer(() => {\n this.close(nextToast.key);\n }, nextToast.timeout),\n };\n }\n\n return nextToast;\n });\n\n this.notify(action);\n }\n\n private notify(action: ToastAction = \"add\"): void {\n const toasts = [...this.queue];\n // The new visible toasts are computed synchronously above; only the subscriber\n // fan-out (which drives the re-render) is wrapped, so it can run inside a view\n // transition. Mirrors @react-stately/toast's updateVisibleToasts.\n this.runWithWrapUpdate(() => {\n for (const callback of this.subscriptions) {\n callback(toasts);\n }\n }, action);\n }\n}\n\n/**\n * Creates reactive toast state from a ToastQueue.\n * Use this hook to subscribe to toast changes in your component.\n */\nexport function createToastState<T>(props: ToastStateProps<T>): ToastState<T> {\n const [visibleToasts, setVisibleToasts] = createSignal<QueuedToast<T>[]>([]);\n\n // Subscribe to queue changes\n const unsubscribe = props.queue.subscribe((toasts) => {\n setVisibleToasts(toasts);\n });\n\n onCleanup(() => {\n unsubscribe();\n });\n\n return {\n visibleToasts,\n add: (content, options) => props.queue.add(content, options),\n close: (key) => props.queue.close(key),\n remove: (key) => props.queue.remove(key),\n clear: () => props.queue.clear(),\n pauseAll: () => props.queue.pauseAll(),\n resumeAll: () => props.queue.resumeAll(),\n };\n}\n\n/**\n * Creates a new ToastQueue and returns reactive state.\n * Use this if you don't need a global queue.\n */\nexport function createToastQueue<T>(\n options?: ToastQueueOptions,\n): ToastState<T> & { queue: ToastQueue<T> } {\n const queue = new ToastQueue<T>(options);\n const state = createToastState({ queue });\n return { ...state, queue };\n}\n","/**\n * Disclosure state management for SolidJS\n * Based on @react-stately/disclosure useDisclosureState and useDisclosureGroupState\n */\n\nimport { createSignal, createEffect, createMemo, type Accessor } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils\";\n\nexport interface DisclosureStateProps {\n /** Whether the disclosure is expanded (controlled). */\n isExpanded?: boolean;\n /** Whether the disclosure is expanded by default (uncontrolled). */\n defaultExpanded?: boolean;\n /** Handler that is called when the disclosure expanded state changes. */\n onExpandedChange?: (isExpanded: boolean) => void;\n}\n\nexport interface DisclosureState {\n /** Whether the disclosure is currently expanded. */\n readonly isExpanded: Accessor<boolean>;\n /** Sets whether the disclosure is expanded. */\n setExpanded(isExpanded: boolean): void;\n /** Expand the disclosure. */\n expand(): void;\n /** Collapse the disclosure. */\n collapse(): void;\n /** Toggles the disclosure's visibility. */\n toggle(): void;\n}\n\n/**\n * Manages state for a disclosure widget. Tracks whether the disclosure is expanded,\n * and provides methods to toggle this state.\n */\nexport function createDisclosureState(\n props: MaybeAccessor<DisclosureStateProps> = {},\n): DisclosureState {\n const propsAccessor = () => access(props);\n\n const [internalExpanded, setInternalExpanded] = createSignal(\n propsAccessor().defaultExpanded ?? false,\n );\n\n const isExpanded: Accessor<boolean> = () => {\n const p = propsAccessor();\n return p.isExpanded !== undefined ? p.isExpanded : internalExpanded();\n };\n\n const setExpanded = (expanded: boolean) => {\n const p = propsAccessor();\n if (p.isExpanded === undefined) {\n setInternalExpanded(expanded);\n }\n p.onExpandedChange?.(expanded);\n };\n\n const expand = () => setExpanded(true);\n const collapse = () => setExpanded(false);\n const toggle = () => setExpanded(!isExpanded());\n\n return {\n isExpanded,\n setExpanded,\n expand,\n collapse,\n toggle,\n };\n}\n\nexport type Key = string | number;\n\nexport interface DisclosureGroupStateProps {\n /** Whether multiple items can be expanded at the same time. */\n allowsMultipleExpanded?: boolean;\n /** Whether all items are disabled. */\n isDisabled?: boolean;\n /** The currently expanded keys in the group (controlled). */\n expandedKeys?: Iterable<Key>;\n /** The initial expanded keys in the group (uncontrolled). */\n defaultExpandedKeys?: Iterable<Key>;\n /** Handler that is called when items are expanded or collapsed. */\n onExpandedChange?: (keys: Set<Key>) => void;\n}\n\nexport interface DisclosureGroupState {\n /** Whether multiple items can be expanded at the same time. */\n readonly allowsMultipleExpanded: boolean;\n /** Whether all items are disabled. */\n readonly isDisabled: boolean;\n /** A set of keys for items that are expanded. */\n readonly expandedKeys: Accessor<Set<Key>>;\n /** Toggles the expanded state for an item by its key. */\n toggleKey(key: Key): void;\n /** Replaces the set of expanded keys. */\n setExpandedKeys(keys: Set<Key>): void;\n /** Check if a specific key is expanded. */\n isExpanded(key: Key): boolean;\n}\n\n/**\n * Manages state for a group of disclosures, e.g. an accordion.\n * It supports both single and multiple expanded items.\n */\nexport function createDisclosureGroupState(\n props: MaybeAccessor<DisclosureGroupStateProps> = {},\n): DisclosureGroupState {\n const propsAccessor = () => access(props);\n\n const [internalKeys, setInternalKeys] = createSignal<Set<Key>>(\n new Set(propsAccessor().defaultExpandedKeys ?? []),\n );\n\n const expandedKeys: Accessor<Set<Key>> = createMemo(() => {\n const p = propsAccessor();\n return p.expandedKeys !== undefined ? new Set(p.expandedKeys) : internalKeys();\n });\n\n const setExpandedKeys = (keys: Set<Key>) => {\n const p = propsAccessor();\n if (p.expandedKeys === undefined) {\n setInternalKeys(keys);\n }\n p.onExpandedChange?.(keys);\n };\n\n // Ensure only one item is expanded if allowsMultipleExpanded is false.\n createEffect(() => {\n const p = propsAccessor();\n const allowsMultiple = p.allowsMultipleExpanded ?? false;\n const keys = expandedKeys();\n\n if (!allowsMultiple && keys.size > 1) {\n // Use queueMicrotask to defer the update and avoid infinite effect loop\n const firstKey = keys.values().next().value;\n if (firstKey != null) {\n queueMicrotask(() => {\n setExpandedKeys(new Set([firstKey]));\n });\n }\n }\n });\n\n const toggleKey = (key: Key) => {\n const p = propsAccessor();\n const allowsMultiple = p.allowsMultipleExpanded ?? false;\n const currentKeys = expandedKeys();\n\n let newKeys: Set<Key>;\n if (allowsMultiple) {\n newKeys = new Set(currentKeys);\n if (newKeys.has(key)) {\n newKeys.delete(key);\n } else {\n newKeys.add(key);\n }\n } else {\n newKeys = new Set(currentKeys.has(key) ? [] : [key]);\n }\n\n setExpandedKeys(newKeys);\n };\n\n const isExpanded = (key: Key): boolean => {\n return expandedKeys().has(key);\n };\n\n return {\n get allowsMultipleExpanded() {\n return propsAccessor().allowsMultipleExpanded ?? false;\n },\n get isDisabled() {\n return propsAccessor().isDisabled ?? false;\n },\n expandedKeys,\n toggleKey,\n setExpandedKeys,\n isExpanded,\n };\n}\n","/**\n * Grid state management for Table and GridList components.\n * Based on @react-stately/grid/useGridState.\n */\n\nimport { createSignal, createEffect, createMemo, on, type Accessor } from \"solid-js\";\nimport type { GridState, GridStateOptions, GridCollection, GridNode } from \"./types\";\nimport type { Key, FocusStrategy, SelectionBehavior, Selection } from \"../collections/types\";\n\n/**\n * Creates state management for a grid component.\n * Handles row selection, focus management, and keyboard navigation state.\n */\nexport function createGridState<T extends object, C extends GridCollection<T> = GridCollection<T>>(\n options: Accessor<GridStateOptions<T, C>>,\n): GridState<T, C> {\n const getOptions = () => options();\n\n const disabledKeys = createMemo(() => {\n const keys = getOptions().disabledKeys;\n return keys ? new Set(keys) : new Set<Key>();\n });\n\n const [isFocused, setIsFocused] = createSignal(false);\n const [focusedKey, setFocusedKeyInternal] = createSignal<Key | null>(null);\n const [childFocusStrategy, setChildFocusStrategy] = createSignal<FocusStrategy | null>(null);\n const [isKeyboardNavigationDisabled, setKeyboardNavigationDisabled] = createSignal(false);\n\n const [internalSelectedKeys, setInternalSelectedKeys] = createSignal<\"all\" | Set<Key>>(\n getInitialSelection(getOptions().defaultSelectedKeys),\n );\n const [anchorKey, setAnchorKey] = createSignal<Key | null>(null);\n\n const selectedKeys = createMemo(() => {\n const opts = getOptions();\n if (opts.selectedKeys !== undefined) {\n return normalizeSelection(opts.selectedKeys);\n }\n return internalSelectedKeys();\n });\n\n const selectionMode = createMemo(() => getOptions().selectionMode ?? \"none\");\n const selectionBehaviorProp = (): SelectionBehavior => getOptions().selectionBehavior ?? \"toggle\";\n const [selectionBehaviorState, setSelectionBehaviorState] =\n createSignal<SelectionBehavior>(selectionBehaviorProp());\n const selectionBehavior = createMemo(() => selectionBehaviorState());\n const disallowEmptySelection = createMemo(() => getOptions().disallowEmptySelection ?? false);\n const disabledBehavior = createMemo(() => getOptions().disabledBehavior ?? \"all\");\n\n const focusMode = createMemo(() => getOptions().focusMode ?? \"row\");\n\n createEffect(\n on(selectionBehaviorProp, (behavior) => {\n setSelectionBehaviorState(behavior);\n }),\n );\n\n createEffect(() => {\n const keys = selectedKeys();\n if (\n selectionBehaviorProp() === \"replace\" &&\n selectionBehaviorState() === \"toggle\" &&\n keys !== \"all\" &&\n keys.size === 0\n ) {\n setSelectionBehaviorState(\"replace\");\n }\n });\n\n const setFocusedKey = (key: Key | null, strategy: FocusStrategy = \"first\") => {\n const opts = getOptions();\n const collection = opts.collection;\n\n // If focusMode is cell and an item is focused, focus a child cell instead\n if (focusMode() === \"cell\" && key != null) {\n const item = collection.getItem(key);\n if (item?.type === \"item\") {\n const children = [...collection.getChildren(key)];\n if (strategy === \"last\") {\n key = children[children.length - 1]?.key ?? key;\n } else {\n key = children[0]?.key ?? key;\n }\n }\n }\n\n setFocusedKeyInternal(key);\n setChildFocusStrategy(strategy);\n };\n\n // Reset focused key if the item is deleted from the collection\n let cachedCollection: C | null = null;\n\n createEffect(\n on(\n () => getOptions().collection,\n (collection) => {\n const currentFocusedKey = focusedKey();\n\n if (\n currentFocusedKey != null &&\n cachedCollection &&\n !collection.getItem(currentFocusedKey)\n ) {\n // The focused item was deleted, find a new one to focus\n const node = cachedCollection.getItem(currentFocusedKey);\n const parentNode =\n node?.parentKey != null &&\n (node.type === \"cell\" || node.type === \"rowheader\" || node.type === \"column\")\n ? cachedCollection.getItem(node.parentKey)\n : node;\n\n if (!parentNode) {\n setFocusedKeyInternal(null);\n cachedCollection = collection;\n return;\n }\n\n const cachedRows = cachedCollection.rows;\n const rows = collection.rows;\n const diff = cachedRows.length - rows.length;\n\n let index = Math.min(\n diff > 1 ? Math.max(parentNode.index - diff + 1, 0) : parentNode.index,\n rows.length - 1,\n );\n\n let newRow: GridNode<T> | null = null;\n while (index >= 0) {\n const row = rows[index];\n if (!disabledKeys().has(row.key) && row.type !== \"headerrow\") {\n newRow = row;\n break;\n }\n // Find next, not disabled row\n if (index < rows.length - 1) {\n index++;\n } else {\n // Otherwise, find previous, not disabled row\n if (index > parentNode.index) {\n index = parentNode.index;\n }\n index--;\n }\n }\n\n if (newRow) {\n const childNodes = newRow.hasChildNodes ? [...collection.getChildren(newRow.key)] : [];\n const keyToFocus =\n newRow.hasChildNodes && parentNode !== node && node && node.index < childNodes.length\n ? childNodes[node.index].key\n : newRow.key;\n setFocusedKeyInternal(keyToFocus);\n } else {\n setFocusedKeyInternal(null);\n }\n }\n\n cachedCollection = collection;\n },\n ),\n );\n\n // Selection methods\n const isSelected = (key: Key): boolean => {\n const keys = selectedKeys();\n if (keys === \"all\") return true;\n return keys.has(key);\n };\n\n const isDisabled = (key: Key): boolean => {\n return disabledKeys().has(key);\n };\n\n const updateSelection = (newSelection: \"all\" | Set<Key>) => {\n const opts = getOptions();\n\n // Controlled mode\n if (opts.selectedKeys !== undefined) {\n opts.onSelectionChange?.(newSelection);\n return;\n }\n\n // Uncontrolled mode\n const current = internalSelectedKeys();\n const isDifferent =\n current === \"all\" ||\n newSelection === \"all\" ||\n current.size !== (newSelection as Set<Key>).size ||\n ![...current].every((k) => (newSelection as Set<Key>).has(k));\n\n if (isDifferent) {\n setInternalSelectedKeys(newSelection);\n opts.onSelectionChange?.(newSelection);\n }\n };\n\n const toggleSelection = (key: Key) => {\n if (isDisabled(key)) return;\n if (selectionMode() === \"none\") return;\n\n const current = selectedKeys();\n\n if (selectionMode() === \"single\") {\n if (isSelected(key) && !disallowEmptySelection()) {\n updateSelection(new Set());\n } else {\n updateSelection(new Set([key]));\n }\n return;\n }\n\n // Multiple selection\n if (current === \"all\") {\n // Can't toggle when all selected without knowing all keys\n return;\n }\n\n const newSelection = new Set(current);\n if (newSelection.has(key)) {\n if (newSelection.size > 1 || !disallowEmptySelection()) {\n newSelection.delete(key);\n }\n } else {\n newSelection.add(key);\n }\n\n updateSelection(newSelection);\n setAnchorKey(key);\n };\n\n const replaceSelection = (key: Key) => {\n if (isDisabled(key)) return;\n if (selectionMode() === \"none\") return;\n\n updateSelection(new Set([key]));\n setAnchorKey(key);\n };\n\n const setSelectedKeys = (keys: Selection | Iterable<Key>) => {\n updateSelection(normalizeSelection(keys));\n };\n\n const extendSelection = (toKey: Key) => {\n if (isDisabled(toKey)) return;\n if (selectionMode() !== \"multiple\") {\n replaceSelection(toKey);\n return;\n }\n\n const anchor = anchorKey();\n if (!anchor) {\n replaceSelection(toKey);\n return;\n }\n\n const collection = getOptions().collection;\n const rows = collection.rows.filter((r) => r.type === \"item\");\n const keys = rows.map((r) => r.key);\n const anchorIndex = keys.indexOf(anchor);\n const toIndex = keys.indexOf(toKey);\n\n if (anchorIndex === -1 || toIndex === -1) {\n replaceSelection(toKey);\n return;\n }\n\n const start = Math.min(anchorIndex, toIndex);\n const end = Math.max(anchorIndex, toIndex);\n const rangeKeys = keys.slice(start, end + 1).filter((k) => !isDisabled(k));\n\n updateSelection(new Set(rangeKeys));\n };\n\n const selectAll = () => {\n if (selectionMode() !== \"multiple\") return;\n updateSelection(\"all\");\n };\n\n const clearSelection = () => {\n if (disallowEmptySelection()) return;\n updateSelection(new Set());\n };\n\n const toggleSelectAll = () => {\n if (selectionMode() !== \"multiple\") return;\n\n if (selectedKeys() === \"all\") {\n clearSelection();\n } else {\n selectAll();\n }\n };\n\n return {\n get collection() {\n return getOptions().collection;\n },\n get disabledKeys() {\n return disabledKeys();\n },\n get disabledBehavior() {\n return disabledBehavior();\n },\n get isKeyboardNavigationDisabled() {\n return isKeyboardNavigationDisabled();\n },\n get focusedKey() {\n return focusedKey();\n },\n get childFocusStrategy() {\n return childFocusStrategy();\n },\n get isFocused() {\n return isFocused();\n },\n get selectionMode() {\n return selectionMode();\n },\n get selectionBehavior() {\n return selectionBehavior();\n },\n get disallowEmptySelection() {\n return disallowEmptySelection();\n },\n get selectedKeys() {\n return selectedKeys();\n },\n isSelected,\n isDisabled,\n setFocusedKey,\n setFocused: setIsFocused,\n setSelectionBehavior: setSelectionBehaviorState,\n toggleSelection,\n replaceSelection,\n setSelectedKeys,\n extendSelection,\n selectAll,\n clearSelection,\n toggleSelectAll,\n setKeyboardNavigationDisabled,\n };\n}\n\n// Helper functions\nfunction getInitialSelection(defaultKeys?: \"all\" | Iterable<Key>): \"all\" | Set<Key> {\n if (defaultKeys === undefined) return new Set();\n return normalizeSelection(defaultKeys);\n}\n\nfunction normalizeSelection(keys: \"all\" | Iterable<Key>): \"all\" | Set<Key> {\n if (keys === \"all\") return \"all\";\n return new Set(keys);\n}\n","/**\n * Table state management for Table components.\n * Based on @react-stately/table/useTableState.\n */\n\nimport { createMemo, type Accessor } from \"solid-js\";\nimport { createGridState } from \"../grid/createGridState\";\nimport type { Key } from \"../collections/types\";\nimport type {\n TableState,\n TableStateOptions,\n TableCollection,\n SortDescriptor,\n SortDirection,\n} from \"./types\";\n\nconst OPPOSITE_SORT_DIRECTION: Record<SortDirection, SortDirection> = {\n ascending: \"descending\",\n descending: \"ascending\",\n};\n\n/**\n * Creates state management for a table component.\n * Extends grid state with sorting and table-specific features.\n */\nexport function createTableState<\n T extends object,\n C extends TableCollection<T> = TableCollection<T>,\n>(options: Accessor<TableStateOptions<T, C>>): TableState<T, C> {\n const getOptions = () => options();\n\n // Create the underlying grid state\n const gridState = createGridState<T, C>(() => ({\n collection: getOptions().collection,\n disabledKeys: getOptions().disabledKeys,\n disabledBehavior: getOptions().disabledBehavior,\n focusMode: getOptions().focusMode,\n selectionMode: getOptions().selectionMode,\n selectionBehavior: getOptions().selectionBehavior,\n disallowEmptySelection: getOptions().disallowEmptySelection,\n selectedKeys: getOptions().selectedKeys,\n defaultSelectedKeys: getOptions().defaultSelectedKeys,\n onSelectionChange: getOptions().onSelectionChange,\n }));\n\n // Memoized sort descriptor\n const sortDescriptor = createMemo<SortDescriptor | null>(() => {\n return getOptions().sortDescriptor ?? null;\n });\n\n // Show selection checkboxes\n const showSelectionCheckboxes = createMemo(() => {\n return getOptions().showSelectionCheckboxes ?? false;\n });\n\n // Sort function\n const sort = (columnKey: Key, direction?: SortDirection) => {\n const opts = getOptions();\n const currentSort = opts.sortDescriptor;\n\n // Determine direction\n let newDirection: SortDirection;\n if (direction) {\n newDirection = direction;\n } else if (currentSort?.column === columnKey) {\n // Toggle direction if sorting same column\n newDirection = OPPOSITE_SORT_DIRECTION[currentSort.direction];\n } else {\n // Default to ascending for new column\n newDirection = \"ascending\";\n }\n\n opts.onSortChange?.({\n column: columnKey,\n direction: newDirection,\n });\n };\n\n return {\n // Forward grid state properties\n get collection() {\n return getOptions().collection;\n },\n get disabledKeys() {\n return gridState.disabledKeys;\n },\n get disabledBehavior() {\n return gridState.disabledBehavior;\n },\n get isKeyboardNavigationDisabled() {\n return gridState.isKeyboardNavigationDisabled;\n },\n get focusedKey() {\n return gridState.focusedKey;\n },\n get childFocusStrategy() {\n return gridState.childFocusStrategy;\n },\n get isFocused() {\n return gridState.isFocused;\n },\n get selectionMode() {\n return gridState.selectionMode;\n },\n get selectionBehavior() {\n return gridState.selectionBehavior;\n },\n get disallowEmptySelection() {\n return gridState.disallowEmptySelection;\n },\n get selectedKeys() {\n return gridState.selectedKeys;\n },\n\n // Grid state methods\n isSelected: gridState.isSelected,\n isDisabled: gridState.isDisabled,\n setFocusedKey: gridState.setFocusedKey,\n setFocused: gridState.setFocused,\n toggleSelection: gridState.toggleSelection,\n replaceSelection: gridState.replaceSelection,\n setSelectionBehavior: gridState.setSelectionBehavior,\n setSelectedKeys: gridState.setSelectedKeys,\n extendSelection: gridState.extendSelection,\n selectAll: gridState.selectAll,\n clearSelection: gridState.clearSelection,\n toggleSelectAll: gridState.toggleSelectAll,\n setKeyboardNavigationDisabled: gridState.setKeyboardNavigationDisabled,\n\n // Table-specific properties\n get showSelectionCheckboxes() {\n return showSelectionCheckboxes();\n },\n get sortDescriptor() {\n return sortDescriptor();\n },\n sort,\n\n // A plain table has no expandable rows.\n get expandedKeys(): \"all\" | Set<Key> {\n return EMPTY_EXPANDED_KEYS;\n },\n get treeColumn(): Key | null {\n return getOptions().collection.treeColumn ?? null;\n },\n toggleKey: () => {},\n };\n}\n\nconst EMPTY_EXPANDED_KEYS: Set<Key> = new Set();\n","/**\n * TableCollection - A collection class for table data.\n * Based on @react-stately/table/TableCollection.\n *\n * Supports a plain (flat) table and, when an `expandedKeys` option is supplied, a\n * tree grid: `childRows` are walked recursively, each parent row keeps its full\n * structure (cells followed by every child row), and only rows whose ancestors are\n * all expanded are flattened into the navigable body. Mirrors the structure produced\n * by `@react-stately/table`'s `generateTreeGridCollection`.\n */\n\nimport type { Key } from \"../collections/types\";\nimport type { GridNode, GridNodeType } from \"../grid/types\";\nimport type {\n TableCollection as ITableCollection,\n TableCollectionOptions,\n ColumnDefinition,\n RowDefinition,\n} from \"./types\";\n\n/**\n * Creates a table collection from column and row definitions.\n */\nexport class TableCollection<T = unknown> implements ITableCollection<T> {\n private _columns: GridNode<T>[] = [];\n private _rows: GridNode<T>[] = [];\n private _headerRows: GridNode<T>[] = [];\n private _body: GridNode<T>;\n private _head: GridNode<T> | undefined;\n private _keyMap: Map<Key, GridNode<T>> = new Map();\n private _rowHeaderColumnKeys: Set<Key>;\n private _size: number = 0;\n /** Visible rows in DFS order. Drives size, navigation, iteration and the `rows` list. */\n private _flattenedRows: GridNode<T>[] = [];\n private _treeColumn: Key | null = null;\n private _userColumnCount: number = 0;\n\n constructor(options: TableCollectionOptions<T>) {\n const {\n columns,\n rows,\n getKey,\n getTextValue,\n showSelectionCheckboxes = false,\n rowHeaderColumnKeys,\n expandedKeys,\n } = options;\n\n // Passing `expandedKeys` (even an empty set) selects tree-grid mode.\n const isTreeGrid = expandedKeys !== undefined;\n\n this._columns = this.buildColumns(columns, showSelectionCheckboxes);\n\n this._rowHeaderColumnKeys = rowHeaderColumnKeys ?? this.getDefaultRowHeaderColumnKeys();\n\n this._headerRows = this.buildHeaderRows();\n\n if (this._headerRows.length > 0) {\n this._head = {\n type: \"headerrow\" as GridNodeType,\n key: \"header\",\n index: 0,\n level: 0,\n hasChildNodes: true,\n childNodes: this._headerRows,\n value: null,\n textValue: \"\",\n };\n this._keyMap.set(\"header\", this._head);\n }\n\n let bodyChildren: GridNode<T>[];\n if (isTreeGrid) {\n const built = this.buildTreeRows(rows, expandedKeys, getKey, getTextValue);\n bodyChildren = built.topLevelRows;\n this._flattenedRows = built.flattenedRows;\n this._userColumnCount = this.countLeafColumns();\n this._treeColumn =\n options.treeColumn !== undefined\n ? options.treeColumn\n : (this._rowHeaderColumnKeys.values().next().value ?? null);\n } else {\n const bodyRows = this.buildRows(rows, getKey, getTextValue);\n bodyChildren = bodyRows;\n this._flattenedRows = bodyRows;\n this._userColumnCount = this.countLeafColumns();\n this._treeColumn = null;\n }\n\n this._size = this._flattenedRows.length;\n\n this._body = {\n type: \"item\" as GridNodeType,\n key: \"body\",\n index: this._headerRows.length,\n level: 0,\n hasChildNodes: true,\n // The body's children retain the full tree structure (top-level rows with their\n // child rows nested inside) so sibling-based aria-posinset/aria-setsize work; the\n // flattened visible list lives in `_flattenedRows`. For a flat table these are the\n // same array.\n childNodes: bodyChildren,\n value: null,\n textValue: \"\",\n };\n this._keyMap.set(\"body\", this._body);\n\n this._rows = [...this._headerRows, ...this._flattenedRows];\n }\n\n private buildColumns(\n columns: ColumnDefinition<T>[],\n showSelectionCheckboxes: boolean,\n ): GridNode<T>[] {\n const result: GridNode<T>[] = [];\n let colIndex = 0;\n\n if (showSelectionCheckboxes) {\n const selectionColumn: GridNode<T> = {\n type: \"column\" as GridNodeType,\n key: \"__selection__\",\n index: colIndex,\n column: 0,\n level: 0,\n hasChildNodes: false,\n childNodes: [],\n value: null,\n textValue: \"Selection\",\n };\n result.push(selectionColumn);\n this._keyMap.set(selectionColumn.key, selectionColumn);\n colIndex++;\n }\n\n for (const col of columns) {\n const node = this.buildColumnNode(col, colIndex);\n result.push(node);\n colIndex++;\n }\n\n return result;\n }\n\n private buildColumnNode(col: ColumnDefinition<T>, index: number): GridNode<T> {\n const key = col.key ?? (col as ColumnDefinition<T> & { id?: Key }).id ?? index;\n const node: GridNode<T> = {\n type: \"column\" as GridNodeType,\n key,\n index,\n column: index,\n level: 0,\n hasChildNodes: (col.children?.length ?? 0) > 0,\n childNodes: [],\n value: null,\n props: { columnDefinition: { ...col, key } },\n textValue: col.textValue ?? col.name ?? String(key),\n };\n\n if (col.children && col.children.length > 0) {\n let childIndex = 0;\n for (const child of col.children) {\n const childNode = this.buildColumnNode(child, childIndex);\n childNode.parentKey = key;\n childNode.level = 1;\n node.childNodes.push(childNode);\n childIndex++;\n }\n }\n\n this._keyMap.set(node.key, node);\n return node;\n }\n\n private getDefaultRowHeaderColumnKeys(): Set<Key> {\n const explicitRowHeaderKeys = this._columns\n .filter((col) => col.key !== \"__selection__\")\n .filter((col) => {\n const definition = col.props?.columnDefinition as ColumnDefinition<T> | undefined;\n return !!definition?.isRowHeader;\n })\n .map((col) => col.key);\n\n if (explicitRowHeaderKeys.length > 0) {\n return new Set(explicitRowHeaderKeys);\n }\n\n // Default to first non-selection column as row header.\n for (const col of this._columns) {\n if (col.key !== \"__selection__\") {\n return new Set([col.key]);\n }\n }\n return new Set();\n }\n\n /** Counts the leaf columns supplied by the user (excludes the selection column). */\n private countLeafColumns(): number {\n let count = 0;\n const visit = (col: GridNode<T>) => {\n if (col.key === \"__selection__\") {\n return;\n }\n if (col.childNodes.length > 0) {\n col.childNodes.forEach(visit);\n } else {\n count++;\n }\n };\n this._columns.forEach(visit);\n return count;\n }\n\n private buildHeaderRows(): GridNode<T>[] {\n if (this._columns.length === 0) {\n return [];\n }\n\n const headerCells: GridNode<T>[] = this._columns.map((col, index) => ({\n type: \"column\" as GridNodeType,\n key: `header-${col.key}`,\n index,\n column: index,\n level: 1,\n hasChildNodes: false,\n childNodes: [],\n value: null,\n textValue: col.textValue,\n parentKey: \"headerrow-0\",\n }));\n\n const headerRow: GridNode<T> = {\n type: \"headerrow\" as GridNodeType,\n key: \"headerrow-0\",\n index: 0,\n rowIndex: 0,\n level: 0,\n hasChildNodes: true,\n childNodes: headerCells,\n value: null,\n textValue: \"\",\n };\n\n this._keyMap.set(headerRow.key, headerRow);\n headerCells.forEach((cell) => this._keyMap.set(cell.key, cell));\n\n return [headerRow];\n }\n\n /**\n * Builds the cell nodes for one row. Does not register the cells in the key map;\n * the caller registers cells once the owning row is known to be present.\n */\n private buildCells(\n rowKey: Key,\n value: T,\n rowLevel: number,\n getTextValue?: (item: T, column: ColumnDefinition<T>) => string,\n ): GridNode<T>[] {\n return this._columns.map((col, colIndex) => {\n const cellKey = `${rowKey}-${col.key}`;\n const columnDefinition =\n (col.props?.columnDefinition as ColumnDefinition<T> | undefined) ??\n ({ key: col.key } as ColumnDefinition<T>);\n const cellTextValue =\n col.key === \"__selection__\"\n ? \"Selection\"\n : getTextValue\n ? getTextValue(value, columnDefinition)\n : String((value as Record<string, unknown>)?.[String(col.key)] ?? \"\");\n\n const cell: GridNode<T> = {\n type: this._rowHeaderColumnKeys.has(col.key)\n ? (\"rowheader\" as GridNodeType)\n : (\"cell\" as GridNodeType),\n key: cellKey,\n index: colIndex,\n column: colIndex,\n level: rowLevel + 1,\n hasChildNodes: false,\n childNodes: [],\n value,\n textValue: cellTextValue,\n parentKey: rowKey,\n };\n\n return cell;\n });\n }\n\n private buildRows(\n rows: RowDefinition<T>[] | T[],\n getKey?: (item: T) => Key,\n getTextValue?: (item: T, column: ColumnDefinition<T>) => string,\n ): GridNode<T>[] {\n const result: GridNode<T>[] = [];\n const rowIndexOffset = this._headerRows.length;\n\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i];\n const isRowDef = this.isRowDefinition(row);\n\n const key = isRowDef ? row.key : (getKey?.(row as T) ?? i);\n const value = isRowDef ? row.value : (row as T);\n const textValue = isRowDef\n ? row.textValue\n : typeof (row as Record<string, unknown>)?.textValue === \"string\"\n ? ((row as Record<string, unknown>).textValue as string)\n : undefined;\n\n const cells = this.buildCells(key, value as T, 0, getTextValue);\n cells.forEach((cell) => this._keyMap.set(cell.key, cell));\n\n const rowNode: GridNode<T> = {\n type: \"item\" as GridNodeType,\n key,\n index: i,\n rowIndex: rowIndexOffset + i,\n level: 0,\n hasChildNodes: true,\n childNodes: cells,\n value,\n textValue: textValue ?? cells.map((c) => c.textValue).join(\" \"),\n };\n\n this._keyMap.set(key, rowNode);\n result.push(rowNode);\n }\n\n return result;\n }\n\n /**\n * Builds the tree-grid rows: every row keeps its full structure (cells then all child\n * rows, expanded or not) while only the rows whose ancestors are all expanded are\n * registered in the key map and pushed into the flattened body. Mirrors\n * `generateTreeGridCollection` upstream.\n */\n private buildTreeRows(\n rows: RowDefinition<T>[] | T[],\n expandedKeys: \"all\" | Set<Key>,\n getKey?: (item: T) => Key,\n getTextValue?: (item: T, column: ColumnDefinition<T>) => string,\n ): { topLevelRows: GridNode<T>[]; flattenedRows: GridNode<T>[] } {\n const isExpanded = (key: Key): boolean => expandedKeys === \"all\" || expandedKeys.has(key);\n\n // Build the full tree structure without touching the key map. `index` is the row's\n // position among its same-level siblings, so aria-posinset/aria-setsize read directly.\n const buildRowNode = (\n row: RowDefinition<T> | T,\n level: number,\n parentKey: Key | null,\n indexAmongSiblings: number,\n ): GridNode<T> => {\n const isRowDef = this.isRowDefinition(row);\n const key = isRowDef ? row.key : (getKey?.(row as T) ?? indexAmongSiblings);\n const value = (isRowDef ? row.value : (row as T)) as T;\n const textValue = isRowDef\n ? row.textValue\n : typeof (row as Record<string, unknown>)?.textValue === \"string\"\n ? ((row as Record<string, unknown>).textValue as string)\n : undefined;\n\n const cells = this.buildCells(key, value, level, getTextValue);\n\n const childRowDefs = isRowDef ? (row.childRows ?? []) : [];\n const hasChildRows = childRowDefs.length > 0 || (isRowDef && !!row.hasChildRows);\n\n const childRowNodes = childRowDefs.map((child, childIdx) =>\n buildRowNode(child, level + 1, key, childIdx),\n );\n\n const childNodes = [...cells, ...childRowNodes];\n const rowNode: GridNode<T> = {\n type: \"item\" as GridNodeType,\n key,\n index: indexAmongSiblings,\n level,\n parentKey,\n hasChildNodes: true,\n childNodes,\n value,\n textValue: textValue ?? cells.map((c) => c.textValue).join(\" \"),\n isExpandable: hasChildRows,\n isExpanded: hasChildRows && isExpanded(key),\n firstChildKey: childNodes[0]?.key ?? null,\n lastChildKey: childNodes[childNodes.length - 1]?.key ?? null,\n };\n\n return rowNode;\n };\n\n const topLevelRows = rows.map((row, i) => buildRowNode(row, 0, \"body\", i));\n\n // Flatten the visible rows (DFS). A row is visited iff every ancestor is expanded;\n // visiting a row registers it and its cells, then descends into its child rows only\n // when the row itself is expanded.\n const flattenedRows: GridNode<T>[] = [];\n const rowIndexOffset = this._headerRows.length;\n const visit = (node: GridNode<T>) => {\n node.rowIndex = rowIndexOffset + flattenedRows.length;\n flattenedRows.push(node);\n this._keyMap.set(node.key, node);\n for (const child of node.childNodes) {\n if (child.type !== \"item\") {\n this._keyMap.set(child.key, child);\n }\n }\n if (isExpanded(node.key)) {\n for (const child of node.childNodes) {\n if (child.type === \"item\") {\n visit(child);\n }\n }\n }\n };\n for (const node of topLevelRows) {\n visit(node);\n }\n\n return { topLevelRows, flattenedRows };\n }\n\n private isRowDefinition(row: unknown): row is RowDefinition<T> {\n return typeof row === \"object\" && row !== null && \"key\" in row && \"value\" in row;\n }\n\n get size(): number {\n return this._size;\n }\n\n get rows(): GridNode<T>[] {\n return this._rows;\n }\n\n get columns(): GridNode<T>[] {\n return this._columns;\n }\n\n get headerRows(): GridNode<T>[] {\n return this._headerRows;\n }\n\n get head(): GridNode<T> | undefined {\n return this._head;\n }\n\n get body(): GridNode<T> {\n return this._body;\n }\n\n get rowCount(): number {\n return this._rows.length;\n }\n\n get columnCount(): number {\n return this._columns.length;\n }\n\n get rowHeaderColumnKeys(): Set<Key> {\n return this._rowHeaderColumnKeys;\n }\n\n /** The key of the column that renders the tree-grid affordance, or `null` for a flat table. */\n get treeColumn(): Key | null {\n return this._treeColumn;\n }\n\n /** The number of leaf columns provided by the user (excludes the selection column). */\n get userColumnCount(): number {\n return this._userColumnCount;\n }\n\n /** The key map of all present nodes (visible rows, their cells, columns and the body). */\n get keyMap(): Map<Key, GridNode<T>> {\n return this._keyMap;\n }\n\n getKeys(): Iterable<Key> {\n return this._keyMap.keys();\n }\n\n getItem(key: Key): GridNode<T> | null {\n return this._keyMap.get(key) ?? null;\n }\n\n at(index: number): GridNode<T> | null {\n if (index < 0 || index >= this._flattenedRows.length) {\n return null;\n }\n return this._flattenedRows[index];\n }\n\n getChildren(key: Key): Iterable<GridNode<T>> {\n const node = this._keyMap.get(key);\n return node?.childNodes ?? [];\n }\n\n getTextValue(key: Key): string {\n const node = this._keyMap.get(key);\n return node?.textValue ?? \"\";\n }\n\n getCell(rowKey: Key, columnKey: Key): GridNode<T> | null {\n const cellKey = `${rowKey}-${columnKey}`;\n return this._keyMap.get(cellKey) ?? null;\n }\n\n getFirstKey(): Key | null {\n const bodyRows = this._flattenedRows;\n return bodyRows.length > 0 ? bodyRows[0].key : null;\n }\n\n getLastKey(): Key | null {\n const bodyRows = this._flattenedRows;\n return bodyRows.length > 0 ? bodyRows[bodyRows.length - 1].key : null;\n }\n\n getKeyBefore(key: Key): Key | null {\n const node = this._keyMap.get(key);\n if (!node) return null;\n\n const bodyRows = this._flattenedRows;\n const index = bodyRows.findIndex((r) => r.key === key);\n if (index > 0) {\n return bodyRows[index - 1].key;\n }\n return null;\n }\n\n getKeyAfter(key: Key): Key | null {\n const node = this._keyMap.get(key);\n if (!node) return null;\n\n const bodyRows = this._flattenedRows;\n const index = bodyRows.findIndex((r) => r.key === key);\n if (index >= 0 && index < bodyRows.length - 1) {\n return bodyRows[index + 1].key;\n }\n return null;\n }\n\n *[Symbol.iterator](): Iterator<GridNode<T>> {\n // Only iterate visible body rows, not header rows.\n for (const row of this._flattenedRows) {\n yield row;\n }\n }\n}\n\n/**\n * Creates a table collection from options.\n */\nexport function createTableCollection<T>(options: TableCollectionOptions<T>): TableCollection<T> {\n return new TableCollection(options);\n}\n","/**\n * Tree grid state management for expandable Table rows.\n * Based on @react-stately/table/useTreeGridState (the `UNSTABLE_` tree-grid feature).\n *\n * Owns the expanded-keys signal (controlled or uncontrolled), rebuilds the table\n * collection from it, and layers the expansion API on top of {@link createTableState}.\n */\n\nimport { createMemo, createSignal, type Accessor } from \"solid-js\";\nimport { createTableState } from \"./createTableState\";\nimport { createTableCollection, TableCollection } from \"./TableCollection\";\nimport type { Key } from \"../collections/types\";\nimport type { TreeGridState, TreeGridStateOptions } from \"./types\";\n\n/**\n * Creates state management for a tree grid (a table with expandable rows). Handles the\n * expanded rows in addition to the selection, sort and focus handled by the table state.\n */\nexport function createTreeGridState<\n T extends object,\n C extends TableCollection<T> = TableCollection<T>,\n>(options: Accessor<TreeGridStateOptions<T, C>>): TreeGridState<T, C> {\n const getOptions = () => options();\n\n // Expanded keys: controlled via `UNSTABLE_expandedKeys`, otherwise the internal signal\n // seeded from `UNSTABLE_defaultExpandedKeys`.\n const [internalExpandedKeys, setInternalExpandedKeys] = createSignal<\"all\" | Set<Key>>(\n getInitialExpanded(getOptions().UNSTABLE_defaultExpandedKeys),\n );\n\n const expandedKeys = createMemo<\"all\" | Set<Key>>(() => {\n const controlled = getOptions().UNSTABLE_expandedKeys;\n if (controlled !== undefined) {\n return convertExpanded(controlled);\n }\n return internalExpandedKeys();\n });\n\n // Rebuild the tree collection whenever the expanded keys (or the data) change.\n const collection = createMemo(\n () =>\n createTableCollection<T>({\n columns: getOptions().columns,\n rows: getOptions().rows,\n getKey: getOptions().getKey,\n getTextValue: getOptions().getTextValue,\n showSelectionCheckboxes: getOptions().showSelectionCheckboxes ?? false,\n rowHeaderColumnKeys: getOptions().rowHeaderColumnKeys,\n expandedKeys: expandedKeys(),\n }) as unknown as C,\n );\n\n const tableState = createTableState<T, C>(() => ({\n collection: collection(),\n disabledKeys: getOptions().disabledKeys,\n focusMode: getOptions().focusMode,\n selectionMode: getOptions().selectionMode,\n selectionBehavior: getOptions().selectionBehavior,\n disallowEmptySelection: getOptions().disallowEmptySelection,\n selectedKeys: getOptions().selectedKeys,\n defaultSelectedKeys: getOptions().defaultSelectedKeys,\n onSelectionChange: getOptions().onSelectionChange,\n sortDescriptor: getOptions().sortDescriptor,\n onSortChange: getOptions().onSortChange,\n showSelectionCheckboxes: getOptions().showSelectionCheckboxes,\n }));\n\n const toggleKey = (key: Key) => {\n const updated = toggleExpandedKey(expandedKeys(), key, collection());\n\n // Only own the value when uncontrolled.\n if (getOptions().UNSTABLE_expandedKeys === undefined) {\n setInternalExpandedKeys(updated);\n }\n getOptions().UNSTABLE_onExpandedChange?.(updated);\n };\n\n // Layer the expansion API onto the table state object, preserving the reactive getters\n // already defined on it (spreading would eagerly evaluate them and break reactivity).\n const treeGridState = tableState as TreeGridState<T, C>;\n Object.defineProperty(treeGridState, \"expandedKeys\", {\n get: () => expandedKeys(),\n configurable: true,\n enumerable: true,\n });\n Object.defineProperty(treeGridState, \"treeColumn\", {\n get: () => collection().treeColumn ?? null,\n configurable: true,\n enumerable: true,\n });\n Object.defineProperty(treeGridState, \"keyMap\", {\n get: () => collection().keyMap,\n configurable: true,\n enumerable: true,\n });\n Object.defineProperty(treeGridState, \"userColumnCount\", {\n get: () => collection().userColumnCount,\n configurable: true,\n enumerable: true,\n });\n treeGridState.toggleKey = toggleKey;\n\n return treeGridState;\n}\n\n/**\n * Computes the next expanded-key set when a row is toggled. Mirrors the upstream\n * `toggleKey`: collapsing from `'all'` materialises every expandable row first.\n */\nfunction toggleExpandedKey<T>(\n current: \"all\" | Set<Key>,\n key: Key,\n collection: TableCollection<T>,\n): Set<Key> {\n let updated: Set<Key>;\n if (current === \"all\") {\n updated = new Set(\n collection.rows\n .filter((row) => row.type === \"item\" && row.isExpandable)\n .map((row) => row.key),\n );\n updated.delete(key);\n } else {\n updated = new Set(current);\n if (updated.has(key)) {\n updated.delete(key);\n } else {\n updated.add(key);\n }\n }\n return updated;\n}\n\nfunction getInitialExpanded(defaultExpanded?: \"all\" | Iterable<Key>): \"all\" | Set<Key> {\n if (defaultExpanded === undefined) {\n return new Set();\n }\n return convertExpanded(defaultExpanded);\n}\n\nfunction convertExpanded(expanded: \"all\" | Iterable<Key>): \"all\" | Set<Key> {\n if (!expanded) {\n return new Set<Key>();\n }\n return expanded === \"all\" ? \"all\" : new Set(expanded);\n}\n","/**\n * Table column resize state management.\n * Based on @react-stately/table/useTableColumnResizeState.\n *\n * Provides column width state management for a table with column resizing.\n * Tracks column widths, the currently resizing column, and handles\n * width distribution and clamping.\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport type { Key } from \"../collections/types\";\n\n/** Column size: a number (px) or a string ('100px', '50%', '1fr'). */\nexport type ColumnSize = number | string;\n\nexport interface ColumnResizeDefinition {\n /** The column key. */\n key: Key;\n /** The width of the column. Numbers are px, strings can be 'Xfr', 'Xpx', or 'X%'. */\n width?: ColumnSize;\n /** Minimum width in pixels. Default: 75. */\n minWidth?: number;\n /** Maximum width in pixels. Default: Infinity. */\n maxWidth?: number;\n}\n\nexport interface TableColumnResizeStateProps {\n /** Current width of the table or table viewport. */\n tableWidth: number;\n /** Column definitions with width/min/max. */\n columns: ColumnResizeDefinition[];\n}\n\nexport interface TableColumnResizeState {\n /** The key of the column currently being resized, or null. */\n readonly resizingColumn: Accessor<Key | null>;\n /** A reactive map of computed column widths in pixels. */\n readonly columnWidths: Accessor<Map<Key, number>>;\n /** Begin a resize operation for the given column. */\n startResize(key: Key): void;\n /** End the current resize operation. */\n endResize(): void;\n /** Update column widths during a resize drag. Returns the new widths map. */\n updateResizedColumns(key: Key, width: number): Map<Key, number>;\n /** Get the current computed width for a column. */\n getColumnWidth(key: Key): number;\n /** Get the minimum width for a column. */\n getColumnMinWidth(key: Key): number;\n /** Get the maximum width for a column. */\n getColumnMaxWidth(key: Key): number;\n}\n\nconst DEFAULT_MIN_WIDTH = 75;\nconst DEFAULT_MAX_WIDTH = Infinity;\n\ninterface ParsedColumn {\n key: Key;\n /** Fraction units (from 'Xfr' or unspecified width). 0 if fixed. */\n fr: number;\n /** Fixed pixel width, or 0 if fractional. */\n fixedPx: number;\n minWidth: number;\n maxWidth: number;\n}\n\nfunction parseColumnDef(col: ColumnResizeDefinition, tableWidth: number): ParsedColumn {\n const minWidth = col.minWidth ?? DEFAULT_MIN_WIDTH;\n const maxWidth = col.maxWidth ?? DEFAULT_MAX_WIDTH;\n\n if (col.width == null) {\n // Default: 1fr\n return { key: col.key, fr: 1, fixedPx: 0, minWidth, maxWidth };\n }\n\n if (typeof col.width === \"number\") {\n return { key: col.key, fr: 0, fixedPx: col.width, minWidth, maxWidth };\n }\n\n const str = col.width.trim();\n\n // Fractional: '2fr', '1.5fr'\n if (str.endsWith(\"fr\")) {\n const val = parseFloat(str);\n return { key: col.key, fr: isNaN(val) ? 1 : val, fixedPx: 0, minWidth, maxWidth };\n }\n\n // Percentage: '25%'\n if (str.endsWith(\"%\")) {\n const pct = parseFloat(str);\n const px = isNaN(pct) ? 0 : (pct / 100) * tableWidth;\n return { key: col.key, fr: 0, fixedPx: px, minWidth, maxWidth };\n }\n\n // Pixel: '200px' or just a numeric string\n const px = parseFloat(str);\n return { key: col.key, fr: 0, fixedPx: isNaN(px) ? 0 : px, minWidth, maxWidth };\n}\n\n/**\n * Distribute `tableWidth` among columns:\n * 1. Fixed-width columns get their declared width (clamped to min/max).\n * 2. Remaining space is distributed among fractional columns proportionally.\n */\nfunction distributeWidths(columns: ColumnResizeDefinition[], tableWidth: number): Map<Key, number> {\n const parsed = columns.map((c) => parseColumnDef(c, tableWidth));\n\n // Pass 1 — allocate fixed columns\n let usedSpace = 0;\n let totalFr = 0;\n for (const p of parsed) {\n if (p.fr > 0) {\n totalFr += p.fr;\n } else {\n const w = Math.max(p.minWidth, Math.min(p.maxWidth, p.fixedPx));\n usedSpace += w;\n }\n }\n\n const remainingSpace = Math.max(0, tableWidth - usedSpace);\n const perFr = totalFr > 0 ? remainingSpace / totalFr : 0;\n\n // Pass 2 — build map\n const widths = new Map<Key, number>();\n for (const p of parsed) {\n let w: number;\n if (p.fr > 0) {\n w = p.fr * perFr;\n } else {\n w = p.fixedPx;\n }\n // Clamp\n w = Math.max(p.minWidth, Math.min(p.maxWidth, w));\n widths.set(p.key, Math.round(w));\n }\n\n return widths;\n}\n\n/**\n * Creates column resize state for a table component.\n *\n * Builds an initial column width map from column definitions + table width,\n * then tracks resize operations that clamp to min/max and redistribute\n * remaining space among flex columns.\n */\nexport function createTableColumnResizeState(\n props: Accessor<TableColumnResizeStateProps>,\n): TableColumnResizeState {\n const getProps = () => props();\n\n // Memoize initial width distribution (re-distributes when table width or columns change)\n const initialWidths = createMemo(() =>\n distributeWidths(getProps().columns, getProps().tableWidth),\n );\n\n // User-overridden widths (set during/after resize)\n const [overrides, setOverrides] = createSignal<Map<Key, number>>(new Map());\n const [resizingColumn, setResizingColumn] = createSignal<Key | null>(null);\n\n // Computed widths: initial merged with overrides\n const columnWidths = createMemo(() => {\n const base = initialWidths();\n const over = overrides();\n if (over.size === 0) return base;\n\n const merged = new Map(base);\n for (const [key, width] of over) {\n if (merged.has(key)) {\n merged.set(key, width);\n }\n }\n return merged;\n });\n\n // Build min/max lookup\n const minWidthMap = createMemo(() => {\n const map = new Map<Key, number>();\n for (const col of getProps().columns) {\n map.set(col.key, col.minWidth ?? DEFAULT_MIN_WIDTH);\n }\n return map;\n });\n\n const maxWidthMap = createMemo(() => {\n const map = new Map<Key, number>();\n for (const col of getProps().columns) {\n map.set(col.key, col.maxWidth ?? DEFAULT_MAX_WIDTH);\n }\n return map;\n });\n\n const getColumnWidth = (key: Key): number => {\n return columnWidths().get(key) ?? 0;\n };\n\n const getColumnMinWidth = (key: Key): number => {\n return minWidthMap().get(key) ?? DEFAULT_MIN_WIDTH;\n };\n\n const getColumnMaxWidth = (key: Key): number => {\n return maxWidthMap().get(key) ?? DEFAULT_MAX_WIDTH;\n };\n\n const startResize = (key: Key) => {\n setResizingColumn(key);\n };\n\n const endResize = () => {\n setResizingColumn(null);\n };\n\n const updateResizedColumns = (key: Key, width: number): Map<Key, number> => {\n const minW = getColumnMinWidth(key);\n const maxW = getColumnMaxWidth(key);\n const clampedWidth = Math.round(Math.max(minW, Math.min(maxW, width)));\n\n const newOverrides = new Map(overrides());\n newOverrides.set(key, clampedWidth);\n setOverrides(newOverrides);\n\n // Return the resulting widths\n const base = initialWidths();\n const merged = new Map(base);\n for (const [k, w] of newOverrides) {\n if (merged.has(k)) {\n merged.set(k, w);\n }\n }\n return merged;\n };\n\n return {\n resizingColumn,\n columnWidths,\n startResize,\n endResize,\n updateResizedColumns,\n getColumnWidth,\n getColumnMinWidth,\n getColumnMaxWidth,\n };\n}\n","/**\n * Tree state management for Tree components.\n * Based on @react-stately/tree/useTreeState.\n *\n * Manages expansion state, selection, and focus for hierarchical tree data.\n */\n\nimport { createSignal, createEffect, createMemo, on, type Accessor } from \"solid-js\";\nimport type { TreeState, TreeStateOptions, TreeCollection } from \"./types\";\nimport type { Key, FocusStrategy, Selection, SelectionBehavior } from \"../collections/types\";\n\n/**\n * Creates state management for a tree component.\n * Handles expansion, selection, focus management, and keyboard navigation state.\n */\nexport function createTreeState<T extends object, C extends TreeCollection<T> = TreeCollection<T>>(\n options: Accessor<TreeStateOptions<T, C>>,\n): TreeState<T, C> {\n const getOptions = () => options();\n\n // Disabled keys as a Set\n const disabledKeys = createMemo(() => {\n const keys = getOptions().disabledKeys;\n return keys ? new Set(keys) : new Set<Key>();\n });\n\n // Expansion state (uncontrolled)\n const [internalExpandedKeys, setInternalExpandedKeys] = createSignal<Set<Key>>(\n getInitialExpandedKeys(getOptions().defaultExpandedKeys),\n );\n\n // Computed expanded keys (controlled or uncontrolled)\n const expandedKeys = createMemo(() => {\n const opts = getOptions();\n if (opts.expandedKeys !== undefined) {\n return new Set(opts.expandedKeys);\n }\n return internalExpandedKeys();\n });\n\n // Collection - rebuilt when expanded keys change\n const collection = createMemo(() => {\n const opts = getOptions();\n return opts.collectionFactory(expandedKeys());\n });\n\n // Focus state\n const [isFocused, setIsFocused] = createSignal(false);\n const [focusedKey, setFocusedKeyInternal] = createSignal<Key | null>(null);\n const [childFocusStrategy, setChildFocusStrategy] = createSignal<FocusStrategy | null>(null);\n const [isKeyboardNavigationDisabled, setKeyboardNavigationDisabled] = createSignal(false);\n\n // Selection state\n const [internalSelectedKeys, setInternalSelectedKeys] = createSignal<\"all\" | Set<Key>>(\n getInitialSelection(getOptions().defaultSelectedKeys),\n );\n const [anchorKey, setAnchorKey] = createSignal<Key | null>(null);\n\n // Computed selection\n const selectedKeys = createMemo(() => {\n const opts = getOptions();\n if (opts.selectedKeys !== undefined) {\n return normalizeSelection(opts.selectedKeys);\n }\n return internalSelectedKeys();\n });\n\n const selectionMode = createMemo(() => getOptions().selectionMode ?? \"none\");\n const selectionBehaviorProp = (): SelectionBehavior => getOptions().selectionBehavior ?? \"toggle\";\n const [selectionBehaviorState, setSelectionBehaviorState] =\n createSignal<SelectionBehavior>(selectionBehaviorProp());\n const selectionBehavior = createMemo(() => selectionBehaviorState());\n const disallowEmptySelection = createMemo(() => getOptions().disallowEmptySelection ?? false);\n const disabledBehavior = createMemo(() => getOptions().disabledBehavior ?? \"all\");\n\n createEffect(on(selectionBehaviorProp, (behavior) => setSelectionBehaviorState(behavior)));\n\n createEffect(() => {\n const keys = selectedKeys();\n if (\n selectionBehaviorProp() === \"replace\" &&\n selectionBehaviorState() === \"toggle\" &&\n keys !== \"all\" &&\n keys.size === 0\n ) {\n setSelectionBehaviorState(\"replace\");\n }\n });\n\n // Set focused key\n const setFocusedKey = (key: Key | null, strategy: FocusStrategy = \"first\") => {\n setFocusedKeyInternal(key);\n setChildFocusStrategy(strategy);\n };\n\n // Reset focused key if the item is removed from visible collection\n let cachedCollection: C | null = null;\n\n createEffect(\n on(collection, (coll) => {\n const currentFocusedKey = focusedKey();\n\n if (currentFocusedKey != null && cachedCollection) {\n // Check if the focused item is still visible\n const visibleKeys = [...coll.getKeys()];\n if (!visibleKeys.includes(currentFocusedKey)) {\n // The focused item was collapsed or removed, find a new one to focus\n // Try to find the parent and focus it\n const node = cachedCollection.getItem(currentFocusedKey);\n if (node?.parentKey != null) {\n const parent = coll.getItem(node.parentKey);\n if (parent && visibleKeys.includes(parent.key)) {\n setFocusedKeyInternal(parent.key);\n cachedCollection = coll;\n return;\n }\n }\n\n // Otherwise, find the nearest visible sibling or previous item\n const rows = coll.rows;\n if (rows.length > 0) {\n // Find the closest item to where the focused item was\n const cachedNode = cachedCollection.getItem(currentFocusedKey);\n if (cachedNode?.rowIndex !== undefined) {\n const newIndex = Math.min(cachedNode.rowIndex, rows.length - 1);\n const newNode = rows[newIndex];\n if (newNode && !disabledKeys().has(newNode.key)) {\n setFocusedKeyInternal(newNode.key);\n cachedCollection = coll;\n return;\n }\n }\n // Fall back to first non-disabled item\n for (const row of rows) {\n if (!disabledKeys().has(row.key)) {\n setFocusedKeyInternal(row.key);\n break;\n }\n }\n } else {\n setFocusedKeyInternal(null);\n }\n }\n }\n\n cachedCollection = coll;\n }),\n );\n\n // Selection methods\n const isSelected = (key: Key): boolean => {\n const keys = selectedKeys();\n if (keys === \"all\") return true;\n return keys.has(key);\n };\n\n const isDisabled = (key: Key): boolean => {\n return disabledKeys().has(key) || collection().getItem(key)?.isDisabled === true;\n };\n\n const isExpanded = (key: Key): boolean => {\n return expandedKeys().has(key);\n };\n\n const updateSelection = (newSelection: \"all\" | Set<Key>) => {\n const opts = getOptions();\n\n // Controlled mode\n if (opts.selectedKeys !== undefined) {\n opts.onSelectionChange?.(newSelection);\n return;\n }\n\n // Uncontrolled mode\n const current = internalSelectedKeys();\n const isDifferent =\n current === \"all\" ||\n newSelection === \"all\" ||\n current.size !== (newSelection as Set<Key>).size ||\n ![...current].every((k) => (newSelection as Set<Key>).has(k));\n\n if (isDifferent) {\n setInternalSelectedKeys(newSelection);\n opts.onSelectionChange?.(newSelection);\n }\n };\n\n const toggleSelection = (key: Key) => {\n // Disabled keys are never selectable, regardless of disabledBehavior\n // (mirrors SelectionManager.canSelectItem, which ignores disabledBehavior).\n if (isDisabled(key)) return;\n if (selectionMode() === \"none\") return;\n\n const current = selectedKeys();\n\n if (selectionMode() === \"single\") {\n if (isSelected(key) && !disallowEmptySelection()) {\n updateSelection(new Set());\n } else {\n updateSelection(new Set([key]));\n }\n return;\n }\n\n // Multiple selection\n if (current === \"all\") {\n // Can't toggle when all selected without knowing all keys\n return;\n }\n\n const newSelection = new Set(current);\n if (newSelection.has(key)) {\n if (newSelection.size > 1 || !disallowEmptySelection()) {\n newSelection.delete(key);\n }\n } else {\n newSelection.add(key);\n }\n\n updateSelection(newSelection);\n setAnchorKey(key);\n };\n\n const replaceSelection = (key: Key) => {\n if (isDisabled(key)) return;\n if (selectionMode() === \"none\") return;\n\n updateSelection(new Set([key]));\n setAnchorKey(key);\n };\n\n const setSelectedKeys = (keys: Selection | Iterable<Key>) => {\n updateSelection(normalizeSelection(keys));\n };\n\n const extendSelection = (toKey: Key) => {\n if (isDisabled(toKey)) return;\n if (selectionMode() !== \"multiple\") {\n replaceSelection(toKey);\n return;\n }\n\n const anchor = anchorKey();\n if (!anchor) {\n replaceSelection(toKey);\n return;\n }\n\n const coll = collection();\n const rows = coll.rows.filter((r) => r.type === \"item\");\n const keys = rows.map((r) => r.key);\n const anchorIndex = keys.indexOf(anchor);\n const toIndex = keys.indexOf(toKey);\n\n if (anchorIndex === -1 || toIndex === -1) {\n replaceSelection(toKey);\n return;\n }\n\n const start = Math.min(anchorIndex, toIndex);\n const end = Math.max(anchorIndex, toIndex);\n const rangeKeys = keys.slice(start, end + 1).filter((k) => !isDisabled(k));\n\n updateSelection(new Set(rangeKeys));\n };\n\n const selectAll = () => {\n if (selectionMode() !== \"multiple\") return;\n updateSelection(\"all\");\n };\n\n const clearSelection = () => {\n if (disallowEmptySelection()) return;\n updateSelection(new Set());\n };\n\n const toggleSelectAll = () => {\n if (selectionMode() !== \"multiple\") return;\n\n if (selectedKeys() === \"all\") {\n clearSelection();\n } else {\n selectAll();\n }\n };\n\n // Expansion methods\n const updateExpandedKeys = (newKeys: Set<Key>) => {\n const opts = getOptions();\n\n // Controlled mode\n if (opts.expandedKeys !== undefined) {\n opts.onExpandedChange?.(newKeys);\n return;\n }\n\n // Uncontrolled mode\n setInternalExpandedKeys(newKeys);\n opts.onExpandedChange?.(newKeys);\n };\n\n const toggleKey = (key: Key) => {\n const node = collection().getItem(key);\n if (!node || !node.isExpandable) return;\n if (isDisabled(key) && disabledBehavior() === \"all\") return;\n\n const current = expandedKeys();\n const newKeys = new Set(current);\n\n if (newKeys.has(key)) {\n newKeys.delete(key);\n } else {\n newKeys.add(key);\n }\n\n updateExpandedKeys(newKeys);\n };\n\n const expandKey = (key: Key) => {\n const node = collection().getItem(key);\n if (!node || !node.isExpandable) return;\n if (isDisabled(key) && disabledBehavior() === \"all\") return;\n\n const current = expandedKeys();\n if (current.has(key)) return;\n\n const newKeys = new Set(current);\n newKeys.add(key);\n updateExpandedKeys(newKeys);\n };\n\n const collapseKey = (key: Key) => {\n const node = collection().getItem(key);\n if (!node || !node.isExpandable) return;\n if (isDisabled(key) && disabledBehavior() === \"all\") return;\n\n const current = expandedKeys();\n if (!current.has(key)) return;\n\n const newKeys = new Set(current);\n newKeys.delete(key);\n updateExpandedKeys(newKeys);\n };\n\n const setExpandedKeys = (keys: Set<Key>) => {\n updateExpandedKeys(keys);\n };\n\n return {\n get collection() {\n return collection();\n },\n get disabledKeys() {\n return disabledKeys();\n },\n get disabledBehavior() {\n return disabledBehavior();\n },\n get expandedKeys() {\n return expandedKeys();\n },\n get isKeyboardNavigationDisabled() {\n return isKeyboardNavigationDisabled();\n },\n get focusedKey() {\n return focusedKey();\n },\n get childFocusStrategy() {\n return childFocusStrategy();\n },\n get isFocused() {\n return isFocused();\n },\n get selectionMode() {\n return selectionMode();\n },\n get selectionBehavior() {\n return selectionBehavior();\n },\n get disallowEmptySelection() {\n return disallowEmptySelection();\n },\n get selectedKeys() {\n return selectedKeys();\n },\n isSelected,\n isDisabled,\n isExpanded,\n setFocusedKey,\n setFocused: setIsFocused,\n toggleSelection,\n replaceSelection,\n setSelectedKeys,\n setSelectionBehavior: setSelectionBehaviorState,\n extendSelection,\n selectAll,\n clearSelection,\n toggleSelectAll,\n toggleKey,\n expandKey,\n collapseKey,\n setExpandedKeys,\n setKeyboardNavigationDisabled,\n };\n}\n\n// Helper functions\nfunction getInitialSelection(defaultKeys?: \"all\" | Iterable<Key>): \"all\" | Set<Key> {\n if (defaultKeys === undefined) return new Set();\n return normalizeSelection(defaultKeys);\n}\n\nfunction normalizeSelection(keys: \"all\" | Iterable<Key>): \"all\" | Set<Key> {\n if (keys === \"all\") return \"all\";\n return new Set(keys);\n}\n\nfunction getInitialExpandedKeys(defaultKeys?: Iterable<Key>): Set<Key> {\n if (defaultKeys === undefined) return new Set();\n return new Set(defaultKeys);\n}\n","/**\n * TreeCollection implementation.\n * Based on @react-stately/tree/TreeCollection.\n *\n * A flattened view of tree nodes that respects expanded state.\n * Only visible nodes (root + expanded children) are included in iteration.\n */\n\nimport type { Key } from \"../collections/types\";\nimport type { TreeCollection as ITreeCollection, TreeNode, TreeItemData } from \"./types\";\n\nfunction getItemKey<T>(item: TreeItemData<T>): Key {\n const key = item.key ?? item.id;\n if (key == null) {\n throw new Error(\"Tree items must define either a key or id.\");\n }\n return key;\n}\n\n/**\n * Creates a TreeCollection from hierarchical data.\n * The collection is flattened based on expanded keys.\n */\nexport class TreeCollection<T> implements ITreeCollection<T> {\n private keyMap: Map<Key, TreeNode<T>> = new Map();\n private visibleRows: TreeNode<T>[] = [];\n private firstKey: Key | null = null;\n private lastKey: Key | null = null;\n\n constructor(items: TreeItemData<T>[], expandedKeys: Set<Key>) {\n this.buildCollection(items, expandedKeys);\n }\n\n private buildCollection(items: TreeItemData<T>[], expandedKeys: Set<Key>): void {\n let globalIndex = 0;\n let previousNode: TreeNode<T> | null = null;\n\n const visit = (\n item: TreeItemData<T>,\n level: number,\n parentKey: Key | null,\n indexInParent: number,\n ): TreeNode<T> => {\n const key = getItemKey(item);\n const hasLoadedChildren = Boolean(item.children && item.children.length > 0);\n const hasChildren = hasLoadedChildren || !!item.hasChildItems;\n const isExpanded = hasChildren && expandedKeys.has(key);\n\n // Build child nodes first (even if not visible, for the map)\n const childNodes: TreeNode<T>[] = [];\n if (hasLoadedChildren && item.children) {\n for (let i = 0; i < item.children.length; i++) {\n const childNode = visit(item.children[i], level + 1, key, i);\n childNodes.push(childNode);\n }\n }\n\n const node: TreeNode<T> = {\n type: \"item\",\n key,\n value: (item.value ?? item) as T,\n textValue: item.textValue || String(key),\n level,\n index: indexInParent,\n parentKey,\n hasChildNodes: hasChildren || false,\n childNodes,\n isDisabled: item.isDisabled,\n isExpandable: hasChildren,\n isExpanded,\n };\n\n // Always add to keyMap (for getItem lookups)\n this.keyMap.set(key, node);\n\n return node;\n };\n\n // First pass: build all nodes\n const rootNodes: TreeNode<T>[] = [];\n for (let i = 0; i < items.length; i++) {\n const node = visit(items[i], 0, null, i);\n rootNodes.push(node);\n }\n\n // Second pass: build visible rows list\n const addVisibleNodes = (nodes: TreeNode<T>[]): void => {\n for (const node of nodes) {\n node.rowIndex = globalIndex++;\n this.visibleRows.push(node);\n node.prevKey = previousNode?.key ?? null;\n node.nextKey = undefined;\n if (previousNode) {\n previousNode.nextKey = node.key;\n }\n previousNode = node;\n\n if (node.isExpanded && node.childNodes.length > 0) {\n addVisibleNodes(node.childNodes);\n }\n }\n };\n\n addVisibleNodes(rootNodes);\n this.firstKey = this.visibleRows[0]?.key ?? null;\n this.lastKey = this.visibleRows[this.visibleRows.length - 1]?.key ?? null;\n }\n\n // Collection properties\n\n get size(): number {\n return this.visibleRows.length;\n }\n\n get rows(): TreeNode<T>[] {\n return this.visibleRows;\n }\n\n get rowCount(): number {\n return this.visibleRows.length;\n }\n\n // Collection methods\n\n getKeys(): Iterable<Key> {\n return this.visibleRows.map((node) => node.key);\n }\n\n getItem(key: Key): TreeNode<T> | null {\n return this.keyMap.get(key) ?? null;\n }\n\n at(index: number): TreeNode<T> | null {\n if (index < 0 || index >= this.visibleRows.length) {\n return null;\n }\n return this.visibleRows[index];\n }\n\n getKeyBefore(key: Key): Key | null {\n const node = this.keyMap.get(key);\n let previousKey = node?.prevKey ?? null;\n while (previousKey != null) {\n const candidate = this.keyMap.get(previousKey);\n if (!candidate) break;\n if (candidate.type !== \"content\") {\n return candidate.key;\n }\n previousKey = candidate.prevKey ?? null;\n }\n return null;\n }\n\n getKeyAfter(key: Key): Key | null {\n const node = this.keyMap.get(key);\n let nextKey = node?.nextKey ?? null;\n while (nextKey != null) {\n const candidate = this.keyMap.get(nextKey);\n if (!candidate) break;\n if (candidate.type !== \"content\") {\n return candidate.key;\n }\n nextKey = candidate.nextKey ?? null;\n }\n return null;\n }\n\n getFirstKey(): Key | null {\n if (this.firstKey == null) return null;\n const candidate = this.keyMap.get(this.firstKey);\n if (candidate?.type === \"content\") {\n return this.getKeyAfter(candidate.key);\n }\n return this.firstKey;\n }\n\n getLastKey(): Key | null {\n if (this.lastKey == null) return null;\n const candidate = this.keyMap.get(this.lastKey);\n if (candidate?.type === \"content\") {\n return this.getKeyBefore(candidate.key);\n }\n return this.lastKey;\n }\n\n getChildren(key: Key): Iterable<TreeNode<T>> {\n const node = this.keyMap.get(key);\n return node?.childNodes ?? [];\n }\n\n getTextValue(key: Key): string {\n const node = this.keyMap.get(key);\n return node?.textValue ?? \"\";\n }\n\n getParentKey(key: Key): Key | null {\n const node = this.keyMap.get(key);\n return node?.parentKey ?? null;\n }\n\n [Symbol.iterator](): Iterator<TreeNode<T>> {\n return this.visibleRows[Symbol.iterator]();\n }\n}\n\n/**\n * Factory function to create a TreeCollection.\n * Useful for the collectionFactory pattern in TreeStateOptions.\n */\nexport function createTreeCollection<T>(\n items: TreeItemData<T>[],\n expandedKeys: Set<Key>,\n): TreeCollection<T> {\n return new TreeCollection(items, expandedKeys);\n}\n","/**\n * Color class implementation.\n * Based on @react-stately/color.\n *\n * Provides color manipulation, conversion, and formatting.\n */\n\nimport type {\n Color,\n ColorFormat,\n ColorSpace,\n ColorChannel,\n ColorChannelRange,\n ColorAxes,\n RGBColor,\n HSLColor,\n HSBColor,\n} from \"./types\";\n\n// Channel ranges\nconst RGB_CHANNEL_RANGE: ColorChannelRange = {\n minValue: 0,\n maxValue: 255,\n step: 1,\n pageSize: 17,\n};\n\nconst ALPHA_CHANNEL_RANGE: ColorChannelRange = {\n minValue: 0,\n maxValue: 1,\n step: 0.01,\n pageSize: 0.1,\n};\n\nconst HUE_CHANNEL_RANGE: ColorChannelRange = {\n minValue: 0,\n maxValue: 360,\n step: 1,\n pageSize: 15,\n};\n\nconst PERCENT_CHANNEL_RANGE: ColorChannelRange = {\n minValue: 0,\n maxValue: 100,\n step: 1,\n pageSize: 10,\n};\n\n// Channel names (English only for now)\nconst CHANNEL_NAMES: Record<ColorChannel, string> = {\n hue: \"Hue\",\n saturation: \"Saturation\",\n brightness: \"Brightness\",\n lightness: \"Lightness\",\n red: \"Red\",\n green: \"Green\",\n blue: \"Blue\",\n alpha: \"Alpha\",\n};\n\n// React Stately uses OKLCH for color names so that lightness is perceptually\n// consistent across hues.\nconst ORANGE_LIGHTNESS_THRESHOLD = 0.68;\nconst YELLOW_GREEN_LIGHTNESS_THRESHOLD = 0.85;\nconst MAX_DARK_LIGHTNESS = 0.55;\nconst GRAY_THRESHOLD = 0.001;\nconst OKLCH_HUES: Array<[number, string]> = [\n [0, \"pink\"],\n [15, \"red\"],\n [48, \"orange\"],\n [94, \"yellow\"],\n [135, \"green\"],\n [175, \"cyan\"],\n [264, \"blue\"],\n [284, \"purple\"],\n [320, \"magenta\"],\n [349, \"pink\"],\n];\n\n/**\n * Clamp a value to a range.\n */\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(Math.max(value, min), max);\n}\n\n/**\n * Round to fixed decimal places.\n */\nfunction toFixed(value: number, decimals: number): number {\n return Math.round(value * Math.pow(10, decimals)) / Math.pow(10, decimals);\n}\n\n/**\n * Convert RGB to HSL.\n */\nfunction rgbToHsl(r: number, g: number, b: number): { h: number; s: number; l: number } {\n r /= 255;\n g /= 255;\n b /= 255;\n\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n let h = 0;\n let s = 0;\n const l = (max + min) / 2;\n\n if (max !== min) {\n const d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n\n switch (max) {\n case r:\n h = ((g - b) / d + (g < b ? 6 : 0)) / 6;\n break;\n case g:\n h = ((b - r) / d + 2) / 6;\n break;\n case b:\n h = ((r - g) / d + 4) / 6;\n break;\n }\n }\n\n return {\n h: Math.round(h * 360),\n s: Math.round(s * 100),\n l: Math.round(l * 100),\n };\n}\n\n/**\n * Convert HSL to RGB.\n */\nfunction hslToRgb(h: number, s: number, l: number): { r: number; g: number; b: number } {\n h /= 360;\n s /= 100;\n l /= 100;\n\n let r: number, g: number, b: number;\n\n if (s === 0) {\n r = g = b = l;\n } else {\n const hue2rgb = (p: number, q: number, t: number) => {\n if (t < 0) t += 1;\n if (t > 1) t -= 1;\n if (t < 1 / 6) return p + (q - p) * 6 * t;\n if (t < 1 / 2) return q;\n if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;\n return p;\n };\n\n const q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n const p = 2 * l - q;\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n\n return {\n r: Math.round(r * 255),\n g: Math.round(g * 255),\n b: Math.round(b * 255),\n };\n}\n\n/**\n * Convert RGB to HSB.\n */\nfunction rgbToHsb(r: number, g: number, b: number): { h: number; s: number; b: number } {\n r /= 255;\n g /= 255;\n b /= 255;\n\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n let h = 0;\n const v = max;\n const d = max - min;\n const s = max === 0 ? 0 : d / max;\n\n if (max !== min) {\n switch (max) {\n case r:\n h = ((g - b) / d + (g < b ? 6 : 0)) / 6;\n break;\n case g:\n h = ((b - r) / d + 2) / 6;\n break;\n case b:\n h = ((r - g) / d + 4) / 6;\n break;\n }\n }\n\n return {\n h: Math.round(h * 360),\n s: Math.round(s * 100),\n b: Math.round(v * 100),\n };\n}\n\n/**\n * Convert HSB to RGB.\n */\nfunction hsbToRgb(h: number, s: number, b: number): { r: number; g: number; b: number } {\n h /= 360;\n s /= 100;\n b /= 100;\n\n let r: number, g: number, bl: number;\n\n const i = Math.floor(h * 6);\n const f = h * 6 - i;\n const p = b * (1 - s);\n const q = b * (1 - f * s);\n const t = b * (1 - (1 - f) * s);\n\n switch (i % 6) {\n case 0:\n r = b;\n g = t;\n bl = p;\n break;\n case 1:\n r = q;\n g = b;\n bl = p;\n break;\n case 2:\n r = p;\n g = b;\n bl = t;\n break;\n case 3:\n r = p;\n g = q;\n bl = b;\n break;\n case 4:\n r = t;\n g = p;\n bl = b;\n break;\n default:\n r = b;\n g = p;\n bl = q;\n break;\n }\n\n return {\n r: Math.round(r * 255),\n g: Math.round(g * 255),\n b: Math.round(bl * 255),\n };\n}\n\nfunction getOklchHueName(l: number, c: number, h: number): [string, number] {\n if (c < GRAY_THRESHOLD) {\n return [\"gray\", l];\n }\n\n for (let i = 0; i < OKLCH_HUES.length; i += 1) {\n let [hue, hueName] = OKLCH_HUES[i];\n const [nextHue, nextHueName] = OKLCH_HUES[i + 1] || [360, \"pink\"];\n if (h >= hue && h < nextHue) {\n if (hueName === \"orange\") {\n if (l < ORANGE_LIGHTNESS_THRESHOLD) {\n hueName = \"brown\";\n } else {\n l = l - ORANGE_LIGHTNESS_THRESHOLD + MAX_DARK_LIGHTNESS;\n }\n }\n\n if (h > hue + (nextHue - hue) / 2 && hueName !== nextHueName) {\n hueName = `${hueName} ${nextHueName}`;\n } else if (hueName === \"yellow\" && l < YELLOW_GREEN_LIGHTNESS_THRESHOLD) {\n hueName = \"yellow green\";\n }\n\n return [hueName.toLocaleLowerCase(), l];\n }\n }\n\n return [\"pink\", l];\n}\n\nfunction getColorNameFromColor(color: Color): string {\n let [l, c, h] = toOKLCH(color);\n const alpha = color.getChannelValue(\"alpha\");\n\n if (l > 0.999) {\n return alpha < 1 ? `white ${Math.round((1 - alpha) * 100)}% transparent` : \"white\";\n }\n\n if (l < 0.001) {\n return alpha < 1 ? `black ${Math.round((1 - alpha) * 100)}% transparent` : \"black\";\n }\n\n let hue: string;\n [hue, l] = getOklchHueName(l, c, h);\n\n let chroma = \"\";\n if (c <= 0.1 && c >= GRAY_THRESHOLD) {\n chroma = l >= 0.7 ? \"pale\" : \"grayish\";\n } else if (c >= 0.15) {\n chroma = \"vibrant\";\n }\n\n let lightness = \"\";\n if (l < 0.3) {\n lightness = \"very dark\";\n } else if (l < MAX_DARK_LIGHTNESS) {\n lightness = \"dark\";\n } else if (l < 0.7) {\n lightness = \"\";\n } else if (l < 0.85) {\n lightness = \"light\";\n } else {\n lightness = \"very light\";\n }\n\n const name = [lightness, chroma, hue].filter(Boolean).join(\" \").replace(/\\s+/g, \" \").trim();\n if (alpha < 1) {\n return `${Math.round((1 - alpha) * 100)}% transparent ${name}`.trim();\n }\n\n return name;\n}\n\nfunction getHueNameFromColor(color: Color): string {\n const [l, c, h] = toOKLCH(color);\n const [name] = getOklchHueName(l, c, h);\n return name;\n}\n\nfunction toOKLCH(color: Color): [number, number, number] {\n const rgb = color.toFormat(\"rgb\");\n let red = rgb.getChannelValue(\"red\") / 255;\n let green = rgb.getChannelValue(\"green\") / 255;\n let blue = rgb.getChannelValue(\"blue\") / 255;\n [red, green, blue] = linSRGB(red, green, blue);\n const [x, y, z] = linSRGBToXYZ(red, green, blue);\n const [l, a, b] = xyzToOKLab(x, y, z);\n return okLabToOKLCH(l, a, b);\n}\n\nfunction okLabToOKLCH(l: number, a: number, b: number): [number, number, number] {\n const hue = (Math.atan2(b, a) * 180) / Math.PI;\n return [l, Math.sqrt(a ** 2 + b ** 2), hue >= 0 ? hue : hue + 360];\n}\n\nfunction linSRGB(r: number, g: number, b: number): [number, number, number] {\n return [linSRGBComponent(r), linSRGBComponent(g), linSRGBComponent(b)];\n}\n\nfunction linSRGBComponent(value: number) {\n const sign = value < 0 ? -1 : 1;\n const abs = Math.abs(value);\n\n if (abs <= 0.04045) {\n return value / 12.92;\n }\n\n return sign * Math.pow((abs + 0.055) / 1.055, 2.4);\n}\n\nfunction linSRGBToXYZ(r: number, g: number, b: number): [number, number, number] {\n const matrix = [\n 506752 / 1228815,\n 87881 / 245763,\n 12673 / 70218,\n 87098 / 409605,\n 175762 / 245763,\n 12673 / 175545,\n 7918 / 409605,\n 87881 / 737289,\n 1001167 / 1053270,\n ];\n return multiplyMatrix(matrix, r, g, b);\n}\n\nfunction xyzToOKLab(x: number, y: number, z: number): [number, number, number] {\n const xyzToLMS = [\n 0.819022437996703, 0.3619062600528904, -0.1288737815209879, 0.0329836539323885,\n 0.9292868615863434, 0.0361446663506424, 0.0481771893596242, 0.2642395317527308,\n 0.6335478284694309,\n ];\n const lmsToOKLab = [\n 0.210454268309314, 0.7936177747023054, -0.0040720430116193, 1.9779985324311684,\n -2.4285922420485799, 0.450593709617411, 0.0259040424655478, 0.7827717124575296,\n -0.8086757549230774,\n ];\n\n const [a, b, c] = multiplyMatrix(xyzToLMS, x, y, z);\n return multiplyMatrix(lmsToOKLab, Math.cbrt(a), Math.cbrt(b), Math.cbrt(c));\n}\n\nfunction multiplyMatrix(\n matrix: number[],\n x: number,\n y: number,\n z: number,\n): [number, number, number] {\n const a = matrix[0] * x + matrix[1] * y + matrix[2] * z;\n const b = matrix[3] * x + matrix[4] * y + matrix[5] * z;\n const c = matrix[6] * x + matrix[7] * y + matrix[8] * z;\n return [a, b, c];\n}\n\n/**\n * RGB Color implementation.\n */\nclass RGBColorImpl implements Color {\n private red: number;\n private green: number;\n private blue: number;\n private alpha: number;\n\n constructor(red: number, green: number, blue: number, alpha: number = 1) {\n this.red = clamp(Math.round(red), 0, 255);\n this.green = clamp(Math.round(green), 0, 255);\n this.blue = clamp(Math.round(blue), 0, 255);\n this.alpha = clamp(toFixed(alpha, 2), 0, 1);\n }\n\n toFormat(format: ColorFormat): Color {\n switch (format) {\n case \"hex\":\n case \"hexa\":\n case \"rgb\":\n case \"rgba\":\n return this.clone();\n case \"hsl\":\n case \"hsla\": {\n const { h, s, l } = rgbToHsl(this.red, this.green, this.blue);\n return new HSLColorImpl(h, s, l, this.alpha);\n }\n case \"hsb\":\n case \"hsba\": {\n const { h, s, b } = rgbToHsb(this.red, this.green, this.blue);\n return new HSBColorImpl(h, s, b, this.alpha);\n }\n default:\n throw new Error(`Unsupported format: ${format}`);\n }\n }\n\n toString(format?: ColorFormat | \"css\"): string {\n const f = format ?? \"css\";\n\n switch (f) {\n case \"hex\":\n return `#${this.red.toString(16).padStart(2, \"0\")}${this.green.toString(16).padStart(2, \"0\")}${this.blue.toString(16).padStart(2, \"0\")}`;\n case \"hexa\":\n return `#${this.red.toString(16).padStart(2, \"0\")}${this.green.toString(16).padStart(2, \"0\")}${this.blue.toString(16).padStart(2, \"0\")}${Math.round(\n this.alpha * 255,\n )\n .toString(16)\n .padStart(2, \"0\")}`;\n case \"rgb\":\n return `rgb(${this.red}, ${this.green}, ${this.blue})`;\n case \"rgba\":\n case \"css\":\n return this.alpha === 1\n ? `rgb(${this.red}, ${this.green}, ${this.blue})`\n : `rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`;\n default:\n return this.toFormat(f as ColorFormat).toString(f);\n }\n }\n\n clone(): Color {\n return new RGBColorImpl(this.red, this.green, this.blue, this.alpha);\n }\n\n toHexInt(): number {\n return (this.red << 16) | (this.green << 8) | this.blue;\n }\n\n getChannelValue(channel: ColorChannel): number {\n switch (channel) {\n case \"red\":\n return this.red;\n case \"green\":\n return this.green;\n case \"blue\":\n return this.blue;\n case \"alpha\":\n return this.alpha;\n // Cross-color-space channels - convert to HSB\n case \"hue\":\n case \"saturation\":\n case \"brightness\":\n return this.toFormat(\"hsb\").getChannelValue(channel);\n case \"lightness\":\n return this.toFormat(\"hsl\").getChannelValue(channel);\n default:\n throw new Error(`Invalid channel: ${channel}`);\n }\n }\n\n withChannelValue(channel: ColorChannel, value: number): Color {\n switch (channel) {\n case \"red\":\n return new RGBColorImpl(value, this.green, this.blue, this.alpha);\n case \"green\":\n return new RGBColorImpl(this.red, value, this.blue, this.alpha);\n case \"blue\":\n return new RGBColorImpl(this.red, this.green, value, this.alpha);\n case \"alpha\":\n return new RGBColorImpl(this.red, this.green, this.blue, value);\n // Cross-color-space channels - convert, update, convert back\n case \"hue\":\n case \"saturation\":\n case \"brightness\":\n return this.toFormat(\"hsb\").withChannelValue(channel, value).toFormat(\"rgb\");\n case \"lightness\":\n return this.toFormat(\"hsl\").withChannelValue(channel, value).toFormat(\"rgb\");\n default:\n throw new Error(`Invalid channel: ${channel}`);\n }\n }\n\n getChannelRange(channel: ColorChannel): ColorChannelRange {\n switch (channel) {\n case \"red\":\n case \"green\":\n case \"blue\":\n return RGB_CHANNEL_RANGE;\n case \"alpha\":\n return ALPHA_CHANNEL_RANGE;\n case \"hue\":\n return HUE_CHANNEL_RANGE;\n case \"saturation\":\n case \"brightness\":\n case \"lightness\":\n return PERCENT_CHANNEL_RANGE;\n default:\n throw new Error(`Invalid channel: ${channel}`);\n }\n }\n\n getChannelName(channel: ColorChannel, _locale: string): string {\n return CHANNEL_NAMES[channel] || channel;\n }\n\n getChannelFormatOptions(channel: ColorChannel): Intl.NumberFormatOptions {\n if (channel === \"alpha\") {\n return { style: \"percent\" };\n }\n return { maximumFractionDigits: 0 };\n }\n\n formatChannelValue(channel: ColorChannel, locale: string): string {\n const value = this.getChannelValue(channel);\n const options = this.getChannelFormatOptions(channel);\n return new Intl.NumberFormat(locale, options).format(value);\n }\n\n getColorSpace(): ColorSpace {\n return \"rgb\";\n }\n\n getColorSpaceAxes(xyChannels?: { xChannel?: ColorChannel; yChannel?: ColorChannel }): ColorAxes {\n const xChannel = xyChannels?.xChannel ?? \"red\";\n const yChannel = xyChannels?.yChannel ?? \"green\";\n const channels: ColorChannel[] = [\"red\", \"green\", \"blue\"];\n const zChannel = channels.find((c) => c !== xChannel && c !== yChannel) ?? \"blue\";\n return { xChannel, yChannel, zChannel };\n }\n\n getColorChannels(): [ColorChannel, ColorChannel, ColorChannel] {\n return [\"red\", \"green\", \"blue\"];\n }\n\n getColorName(_locale: string): string {\n return getColorNameFromColor(this);\n }\n\n getHueName(_locale: string): string {\n return getHueNameFromColor(this);\n }\n}\n\n/**\n * HSL Color implementation.\n */\nclass HSLColorImpl implements Color {\n private hue: number;\n private saturation: number;\n private lightness: number;\n private alpha: number;\n\n constructor(hue: number, saturation: number, lightness: number, alpha: number = 1) {\n this.hue = clamp(Math.round(hue) % 360, 0, 360);\n this.saturation = clamp(Math.round(saturation), 0, 100);\n this.lightness = clamp(Math.round(lightness), 0, 100);\n this.alpha = clamp(toFixed(alpha, 2), 0, 1);\n }\n\n toFormat(format: ColorFormat): Color {\n switch (format) {\n case \"hsl\":\n case \"hsla\":\n return this.clone();\n case \"hex\":\n case \"hexa\":\n case \"rgb\":\n case \"rgba\": {\n const { r, g, b } = hslToRgb(this.hue, this.saturation, this.lightness);\n return new RGBColorImpl(r, g, b, this.alpha);\n }\n case \"hsb\":\n case \"hsba\": {\n const { r, g, b } = hslToRgb(this.hue, this.saturation, this.lightness);\n const hsb = rgbToHsb(r, g, b);\n return new HSBColorImpl(hsb.h, hsb.s, hsb.b, this.alpha);\n }\n default:\n throw new Error(`Unsupported format: ${format}`);\n }\n }\n\n toString(format?: ColorFormat | \"css\"): string {\n const f = format ?? \"css\";\n\n switch (f) {\n case \"hsl\":\n return `hsl(${this.hue}, ${this.saturation}%, ${this.lightness}%)`;\n case \"hsla\":\n case \"css\":\n return this.alpha === 1\n ? `hsl(${this.hue}, ${this.saturation}%, ${this.lightness}%)`\n : `hsla(${this.hue}, ${this.saturation}%, ${this.lightness}%, ${this.alpha})`;\n default:\n return this.toFormat(f as ColorFormat).toString(f);\n }\n }\n\n clone(): Color {\n return new HSLColorImpl(this.hue, this.saturation, this.lightness, this.alpha);\n }\n\n toHexInt(): number {\n return this.toFormat(\"rgb\").toHexInt();\n }\n\n getChannelValue(channel: ColorChannel): number {\n switch (channel) {\n case \"hue\":\n return this.hue;\n case \"saturation\":\n return this.saturation;\n case \"lightness\":\n return this.lightness;\n case \"alpha\":\n return this.alpha;\n // Cross-color-space channels\n case \"red\":\n case \"green\":\n case \"blue\":\n return this.toFormat(\"rgb\").getChannelValue(channel);\n case \"brightness\":\n return this.toFormat(\"hsb\").getChannelValue(channel);\n default:\n throw new Error(`Invalid channel: ${channel}`);\n }\n }\n\n withChannelValue(channel: ColorChannel, value: number): Color {\n switch (channel) {\n case \"hue\":\n return new HSLColorImpl(value, this.saturation, this.lightness, this.alpha);\n case \"saturation\":\n return new HSLColorImpl(this.hue, value, this.lightness, this.alpha);\n case \"lightness\":\n return new HSLColorImpl(this.hue, this.saturation, value, this.alpha);\n case \"alpha\":\n return new HSLColorImpl(this.hue, this.saturation, this.lightness, value);\n // Cross-color-space channels\n case \"red\":\n case \"green\":\n case \"blue\":\n return this.toFormat(\"rgb\").withChannelValue(channel, value).toFormat(\"hsl\");\n case \"brightness\":\n return this.toFormat(\"hsb\").withChannelValue(channel, value).toFormat(\"hsl\");\n default:\n throw new Error(`Invalid channel: ${channel}`);\n }\n }\n\n getChannelRange(channel: ColorChannel): ColorChannelRange {\n switch (channel) {\n case \"hue\":\n return HUE_CHANNEL_RANGE;\n case \"saturation\":\n case \"lightness\":\n case \"brightness\":\n return PERCENT_CHANNEL_RANGE;\n case \"alpha\":\n return ALPHA_CHANNEL_RANGE;\n case \"red\":\n case \"green\":\n case \"blue\":\n return RGB_CHANNEL_RANGE;\n default:\n throw new Error(`Invalid channel: ${channel}`);\n }\n }\n\n getChannelName(channel: ColorChannel, _locale: string): string {\n return CHANNEL_NAMES[channel] || channel;\n }\n\n getChannelFormatOptions(channel: ColorChannel): Intl.NumberFormatOptions {\n if (channel === \"alpha\") {\n return { style: \"percent\" };\n }\n if (channel === \"hue\") {\n return { style: \"unit\", unit: \"degree\", unitDisplay: \"narrow\", maximumFractionDigits: 0 };\n }\n return { style: \"percent\", maximumFractionDigits: 0 };\n }\n\n formatChannelValue(channel: ColorChannel, locale: string): string {\n const value = this.getChannelValue(channel);\n const options = this.getChannelFormatOptions(channel);\n if (channel === \"saturation\" || channel === \"lightness\") {\n return new Intl.NumberFormat(locale, options).format(value / 100);\n }\n return new Intl.NumberFormat(locale, options).format(value);\n }\n\n getColorSpace(): ColorSpace {\n return \"hsl\";\n }\n\n getColorSpaceAxes(xyChannels?: { xChannel?: ColorChannel; yChannel?: ColorChannel }): ColorAxes {\n const xChannel = xyChannels?.xChannel ?? \"saturation\";\n const yChannel = xyChannels?.yChannel ?? \"lightness\";\n const channels: ColorChannel[] = [\"hue\", \"saturation\", \"lightness\"];\n const zChannel = channels.find((c) => c !== xChannel && c !== yChannel) ?? \"hue\";\n return { xChannel, yChannel, zChannel };\n }\n\n getColorChannels(): [ColorChannel, ColorChannel, ColorChannel] {\n return [\"hue\", \"saturation\", \"lightness\"];\n }\n\n getColorName(_locale: string): string {\n return getColorNameFromColor(this);\n }\n\n getHueName(_locale: string): string {\n return getHueNameFromColor(this);\n }\n}\n\n/**\n * HSB Color implementation.\n */\nclass HSBColorImpl implements Color {\n private hue: number;\n private saturation: number;\n private brightness: number;\n private alpha: number;\n\n constructor(hue: number, saturation: number, brightness: number, alpha: number = 1) {\n this.hue = clamp(Math.round(hue) % 360, 0, 360);\n this.saturation = clamp(Math.round(saturation), 0, 100);\n this.brightness = clamp(Math.round(brightness), 0, 100);\n this.alpha = clamp(toFixed(alpha, 2), 0, 1);\n }\n\n toFormat(format: ColorFormat): Color {\n switch (format) {\n case \"hsb\":\n case \"hsba\":\n return this.clone();\n case \"hex\":\n case \"hexa\":\n case \"rgb\":\n case \"rgba\": {\n const { r, g, b } = hsbToRgb(this.hue, this.saturation, this.brightness);\n return new RGBColorImpl(r, g, b, this.alpha);\n }\n case \"hsl\":\n case \"hsla\": {\n const { r, g, b } = hsbToRgb(this.hue, this.saturation, this.brightness);\n const hsl = rgbToHsl(r, g, b);\n return new HSLColorImpl(hsl.h, hsl.s, hsl.l, this.alpha);\n }\n default:\n throw new Error(`Unsupported format: ${format}`);\n }\n }\n\n toString(format?: ColorFormat | \"css\"): string {\n const f = format ?? \"css\";\n\n switch (f) {\n case \"hsb\":\n return `hsb(${this.hue}, ${this.saturation}%, ${this.brightness}%)`;\n case \"hsba\":\n case \"css\":\n // HSB is not a standard CSS format, convert to RGB\n return this.toFormat(\"rgba\").toString(\"css\");\n default:\n return this.toFormat(f as ColorFormat).toString(f);\n }\n }\n\n clone(): Color {\n return new HSBColorImpl(this.hue, this.saturation, this.brightness, this.alpha);\n }\n\n toHexInt(): number {\n return this.toFormat(\"rgb\").toHexInt();\n }\n\n getChannelValue(channel: ColorChannel): number {\n switch (channel) {\n case \"hue\":\n return this.hue;\n case \"saturation\":\n return this.saturation;\n case \"brightness\":\n return this.brightness;\n case \"alpha\":\n return this.alpha;\n // Cross-color-space channels\n case \"red\":\n case \"green\":\n case \"blue\":\n return this.toFormat(\"rgb\").getChannelValue(channel);\n case \"lightness\":\n return this.toFormat(\"hsl\").getChannelValue(channel);\n default:\n throw new Error(`Invalid channel: ${channel}`);\n }\n }\n\n withChannelValue(channel: ColorChannel, value: number): Color {\n switch (channel) {\n case \"hue\":\n return new HSBColorImpl(value, this.saturation, this.brightness, this.alpha);\n case \"saturation\":\n return new HSBColorImpl(this.hue, value, this.brightness, this.alpha);\n case \"brightness\":\n return new HSBColorImpl(this.hue, this.saturation, value, this.alpha);\n case \"alpha\":\n return new HSBColorImpl(this.hue, this.saturation, this.brightness, value);\n // Cross-color-space channels\n case \"red\":\n case \"green\":\n case \"blue\":\n return this.toFormat(\"rgb\").withChannelValue(channel, value).toFormat(\"hsb\");\n case \"lightness\":\n return this.toFormat(\"hsl\").withChannelValue(channel, value).toFormat(\"hsb\");\n default:\n throw new Error(`Invalid channel: ${channel}`);\n }\n }\n\n getChannelRange(channel: ColorChannel): ColorChannelRange {\n switch (channel) {\n case \"hue\":\n return HUE_CHANNEL_RANGE;\n case \"saturation\":\n case \"brightness\":\n case \"lightness\":\n return PERCENT_CHANNEL_RANGE;\n case \"alpha\":\n return ALPHA_CHANNEL_RANGE;\n case \"red\":\n case \"green\":\n case \"blue\":\n return RGB_CHANNEL_RANGE;\n default:\n throw new Error(`Invalid channel: ${channel}`);\n }\n }\n\n getChannelName(channel: ColorChannel, _locale: string): string {\n return CHANNEL_NAMES[channel] || channel;\n }\n\n getChannelFormatOptions(channel: ColorChannel): Intl.NumberFormatOptions {\n if (channel === \"alpha\") {\n return { style: \"percent\" };\n }\n if (channel === \"hue\") {\n return { style: \"unit\", unit: \"degree\", unitDisplay: \"narrow\", maximumFractionDigits: 0 };\n }\n return { style: \"percent\", maximumFractionDigits: 0 };\n }\n\n formatChannelValue(channel: ColorChannel, locale: string): string {\n const value = this.getChannelValue(channel);\n const options = this.getChannelFormatOptions(channel);\n if (channel === \"saturation\" || channel === \"brightness\") {\n return new Intl.NumberFormat(locale, options).format(value / 100);\n }\n return new Intl.NumberFormat(locale, options).format(value);\n }\n\n getColorSpace(): ColorSpace {\n return \"hsb\";\n }\n\n getColorSpaceAxes(xyChannels?: { xChannel?: ColorChannel; yChannel?: ColorChannel }): ColorAxes {\n const xChannel = xyChannels?.xChannel ?? \"saturation\";\n const yChannel = xyChannels?.yChannel ?? \"brightness\";\n const channels: ColorChannel[] = [\"hue\", \"saturation\", \"brightness\"];\n const zChannel = channels.find((c) => c !== xChannel && c !== yChannel) ?? \"hue\";\n return { xChannel, yChannel, zChannel };\n }\n\n getColorChannels(): [ColorChannel, ColorChannel, ColorChannel] {\n return [\"hue\", \"saturation\", \"brightness\"];\n }\n\n getColorName(_locale: string): string {\n return getColorNameFromColor(this);\n }\n\n getHueName(_locale: string): string {\n return getHueNameFromColor(this);\n }\n}\n\n/**\n * Parse a color string into a Color object.\n */\nexport function parseColor(value: string): Color {\n const trimmed = value.trim().toLowerCase();\n\n // Hex format\n if (trimmed.startsWith(\"#\")) {\n const hex = trimmed.slice(1);\n if (!/^[0-9a-f]+$/i.test(hex)) {\n throw new Error(`Invalid hex color: ${value}`);\n }\n if (hex.length === 3) {\n const r = parseInt(hex[0] + hex[0], 16);\n const g = parseInt(hex[1] + hex[1], 16);\n const b = parseInt(hex[2] + hex[2], 16);\n return new RGBColorImpl(r, g, b);\n }\n if (hex.length === 4) {\n const r = parseInt(hex[0] + hex[0], 16);\n const g = parseInt(hex[1] + hex[1], 16);\n const b = parseInt(hex[2] + hex[2], 16);\n const a = parseInt(hex[3] + hex[3], 16) / 255;\n return new RGBColorImpl(r, g, b, a);\n }\n if (hex.length === 6) {\n const r = parseInt(hex.slice(0, 2), 16);\n const g = parseInt(hex.slice(2, 4), 16);\n const b = parseInt(hex.slice(4, 6), 16);\n return new RGBColorImpl(r, g, b);\n }\n if (hex.length === 8) {\n const r = parseInt(hex.slice(0, 2), 16);\n const g = parseInt(hex.slice(2, 4), 16);\n const b = parseInt(hex.slice(4, 6), 16);\n const a = parseInt(hex.slice(6, 8), 16) / 255;\n return new RGBColorImpl(r, g, b, a);\n }\n throw new Error(`Invalid hex color: ${value}`);\n }\n\n // RGB/RGBA format\n const rgbMatch = trimmed.match(\n /^rgba?\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*(?:,\\s*([\\d.]+))?\\s*\\)$/,\n );\n if (rgbMatch) {\n const r = parseInt(rgbMatch[1], 10);\n const g = parseInt(rgbMatch[2], 10);\n const b = parseInt(rgbMatch[3], 10);\n const a = rgbMatch[4] !== undefined ? parseFloat(rgbMatch[4]) : 1;\n return new RGBColorImpl(r, g, b, a);\n }\n\n // HSL/HSLA format\n const hslMatch = trimmed.match(\n /^hsla?\\(\\s*(\\d+)\\s*,\\s*(\\d+)%\\s*,\\s*(\\d+)%\\s*(?:,\\s*([\\d.]+))?\\s*\\)$/,\n );\n if (hslMatch) {\n const h = parseInt(hslMatch[1], 10);\n const s = parseInt(hslMatch[2], 10);\n const l = parseInt(hslMatch[3], 10);\n const a = hslMatch[4] !== undefined ? parseFloat(hslMatch[4]) : 1;\n return new HSLColorImpl(h, s, l, a);\n }\n\n // HSB/HSBA format\n const hsbMatch = trimmed.match(\n /^hsba?\\(\\s*(\\d+)\\s*,\\s*(\\d+)%\\s*,\\s*(\\d+)%\\s*(?:,\\s*([\\d.]+))?\\s*\\)$/,\n );\n if (hsbMatch) {\n const h = parseInt(hsbMatch[1], 10);\n const s = parseInt(hsbMatch[2], 10);\n const b = parseInt(hsbMatch[3], 10);\n const a = hsbMatch[4] !== undefined ? parseFloat(hsbMatch[4]) : 1;\n return new HSBColorImpl(h, s, b, a);\n }\n\n throw new Error(`Invalid color format: ${value}`);\n}\n\n/**\n * Create an RGB color.\n */\nexport function createRGBColor(red: number, green: number, blue: number, alpha: number = 1): Color {\n return new RGBColorImpl(red, green, blue, alpha);\n}\n\n/**\n * Create an HSL color.\n */\nexport function createHSLColor(\n hue: number,\n saturation: number,\n lightness: number,\n alpha: number = 1,\n): Color {\n return new HSLColorImpl(hue, saturation, lightness, alpha);\n}\n\n/**\n * Create an HSB color.\n */\nexport function createHSBColor(\n hue: number,\n saturation: number,\n brightness: number,\n alpha: number = 1,\n): Color {\n return new HSBColorImpl(hue, saturation, brightness, alpha);\n}\n\n/**\n * Normalize a color value (string or Color) to a Color object.\n */\nexport function normalizeColor(value: string | Color): Color {\n if (typeof value === \"string\") {\n return parseColor(value);\n }\n return value;\n}\n","/**\n * ColorSlider state management.\n * Based on @react-stately/color useColorSliderState.\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport type { Color, ColorChannel, ColorSpace } from \"./types\";\nimport { normalizeColor } from \"./Color\";\n\nexport type ColorSliderOrientation = \"horizontal\" | \"vertical\";\n\nexport interface ColorSliderStateOptions {\n /** The current color value (controlled). */\n value?: Color | string;\n /** The default color value (uncontrolled). */\n defaultValue?: Color | string;\n /** Handler called when the color changes. */\n onChange?: (color: Color) => void;\n /** Handler called when dragging ends. */\n onChangeEnd?: (color: Color) => void;\n /** The color channel this slider controls. */\n channel: ColorChannel;\n /** The color space to use for channel values. */\n colorSpace?: ColorSpace;\n /** The slider orientation. */\n orientation?: ColorSliderOrientation;\n /** Whether the slider is disabled. */\n isDisabled?: boolean;\n /** The locale for formatting. */\n locale?: string;\n}\n\nexport interface ColorSliderState {\n /** The current color value. */\n readonly value: Color;\n /** Whether the slider is being dragged. */\n readonly isDragging: boolean;\n /** The color channel being controlled. */\n readonly channel: ColorChannel;\n /** The slider orientation. */\n readonly orientation: ColorSliderOrientation;\n /** The step value for the channel. */\n readonly step: number;\n /** The page step value for the channel. */\n readonly pageSize: number;\n /** The minimum value for the channel. */\n readonly minValue: number;\n /** The maximum value for the channel. */\n readonly maxValue: number;\n /** Whether the slider is disabled. */\n readonly isDisabled: boolean;\n\n /** Get the current channel value. */\n getThumbValue(): number;\n /** Get the minimum percent. */\n getThumbMinValue(): number;\n /** Get the maximum percent. */\n getThumbMaxValue(): number;\n /** Get the thumb value as a percentage. */\n getThumbPercent(): number;\n /** Set the channel value. */\n setThumbValue(value: number): void;\n /** Set the thumb value from a percentage (0-1). */\n setThumbPercent(percent: number): void;\n /** Increment the channel value. */\n incrementThumb(stepSize?: number): void;\n /** Decrement the channel value. */\n decrementThumb(stepSize?: number): void;\n /** Set the dragging state. */\n setDragging(isDragging: boolean): void;\n /** Get the display color (with alpha = 1). */\n getDisplayColor(): Color;\n /** Get the formatted value label. */\n getThumbValueLabel(): string;\n}\n\n/**\n * Creates state for a color slider.\n */\nexport function createColorSliderState(\n options: Accessor<ColorSliderStateOptions>,\n): ColorSliderState {\n const getOptions = () => options();\n\n const normalizeValue = (value: Color | string) => {\n const color = normalizeColor(value);\n const colorSpace = getOptions().colorSpace;\n return colorSpace ? color.toFormat(colorSpace) : color;\n };\n\n // Internal value state\n const [internalValue, setInternalValue] = createSignal<Color | null>(null);\n const [isDragging, setIsDragging] = createSignal(false);\n\n // Initialize internal value\n const initValue = () => {\n const opts = getOptions();\n if (opts.defaultValue) {\n return normalizeValue(opts.defaultValue);\n }\n return null;\n };\n\n // Set initial value\n if (internalValue() === null) {\n const init = initValue();\n if (init) {\n setInternalValue(init);\n }\n }\n\n // Controlled vs uncontrolled value\n const value = createMemo(() => {\n const opts = getOptions();\n if (opts.value !== undefined) {\n return normalizeValue(opts.value);\n }\n const fallback = internalValue() ?? normalizeValue(\"#ff0000\");\n return opts.colorSpace ? fallback.toFormat(opts.colorSpace) : fallback;\n });\n\n const channel = createMemo(() => getOptions().channel);\n const orientation = createMemo<ColorSliderOrientation>(\n () => getOptions().orientation ?? \"horizontal\",\n );\n const isDisabled = createMemo(() => getOptions().isDisabled ?? false);\n const locale = createMemo(() => getOptions().locale ?? \"en-US\");\n\n // Get channel range\n const channelRange = createMemo(() => value().getChannelRange(channel()));\n\n const step = createMemo(() => channelRange().step);\n const pageSize = createMemo(() => channelRange().pageSize);\n const minValue = createMemo(() => channelRange().minValue);\n const maxValue = createMemo(() => channelRange().maxValue);\n\n // Update value\n const updateValue = (newColor: Color) => {\n const opts = getOptions();\n const nextColor = opts.colorSpace ? newColor.toFormat(opts.colorSpace) : newColor;\n\n // Controlled mode\n if (opts.value !== undefined) {\n opts.onChange?.(nextColor);\n return;\n }\n\n // Uncontrolled mode\n setInternalValue(nextColor);\n opts.onChange?.(nextColor);\n };\n\n // Get thumb value\n const getThumbValue = () => {\n return value().getChannelValue(channel());\n };\n\n // Get min/max values\n const getThumbMinValue = () => minValue();\n const getThumbMaxValue = () => maxValue();\n\n // Get thumb percent\n const getThumbPercent = () => {\n const val = getThumbValue();\n const min = minValue();\n const max = maxValue();\n return (val - min) / (max - min);\n };\n\n // Set thumb value\n const setThumbValue = (newValue: number) => {\n const min = minValue();\n const max = maxValue();\n const stepValue = step();\n const clamped = Math.max(min, Math.min(max, newValue));\n const precision = `${stepValue}`.split(\".\")[1]?.length ?? 0;\n const rounded = Number(\n (Math.round((clamped - min) / stepValue) * stepValue + min).toFixed(precision),\n );\n const newColor = value().withChannelValue(channel(), rounded);\n updateValue(newColor);\n };\n\n // Set thumb from percent\n const setThumbPercent = (percent: number) => {\n const min = minValue();\n const max = maxValue();\n const val = min + (max - min) * percent;\n setThumbValue(val);\n };\n\n // Increment\n const incrementThumb = (stepSize?: number) => {\n const s = stepSize ?? step();\n setThumbValue(getThumbValue() + s);\n };\n\n // Decrement\n const decrementThumb = (stepSize?: number) => {\n const s = stepSize ?? step();\n setThumbValue(getThumbValue() - s);\n };\n\n // Set dragging\n const setDraggingState = (dragging: boolean) => {\n const wasDragging = isDragging();\n setIsDragging(dragging);\n\n // Call onChangeEnd when dragging ends\n if (wasDragging && !dragging) {\n getOptions().onChangeEnd?.(value());\n }\n };\n\n // Get display color (alpha = 1)\n const getDisplayColor = () => {\n const v = value();\n if (channel() === \"hue\") {\n return normalizeColor(`hsl(${v.getChannelValue(\"hue\")}, 100%, 50%)`);\n }\n return v.withChannelValue(\"alpha\", 1);\n };\n\n // Get formatted value label\n const getThumbValueLabel = () => {\n const v = value();\n const ch = channel();\n const loc = locale();\n return v.formatChannelValue(ch, loc);\n };\n\n return {\n get value() {\n return value();\n },\n get isDragging() {\n return isDragging();\n },\n get channel() {\n return channel();\n },\n get orientation() {\n return orientation();\n },\n get step() {\n return step();\n },\n get pageSize() {\n return pageSize();\n },\n get minValue() {\n return minValue();\n },\n get maxValue() {\n return maxValue();\n },\n get isDisabled() {\n return isDisabled();\n },\n getThumbValue,\n getThumbMinValue,\n getThumbMaxValue,\n getThumbPercent,\n setThumbValue,\n setThumbPercent,\n incrementThumb,\n decrementThumb,\n setDragging: setDraggingState,\n getDisplayColor,\n getThumbValueLabel,\n };\n}\n","/**\n * ColorArea state management.\n * Based on @react-stately/color useColorAreaState.\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport type { Color, ColorChannel, ColorAxes, ColorSpace } from \"./types\";\nimport { normalizeColor } from \"./Color\";\n\nexport interface ColorAreaStateOptions {\n /** The current color value (controlled). */\n value?: Color | string;\n /** The default color value (uncontrolled). */\n defaultValue?: Color | string;\n /** Handler called when the color changes. */\n onChange?: (color: Color) => void;\n /** Handler called when dragging ends. */\n onChangeEnd?: (color: Color) => void;\n /** The color channel for the X axis. */\n xChannel?: ColorChannel;\n /** The color channel for the Y axis. */\n yChannel?: ColorChannel;\n /** The color space to use for the color area. */\n colorSpace?: ColorSpace;\n /** Whether the area is disabled. */\n isDisabled?: boolean;\n}\n\nexport interface ColorAreaState {\n /** The current color value. */\n readonly value: Color;\n /** The X axis channel. */\n readonly xChannel: ColorChannel;\n /** The Y axis channel. */\n readonly yChannel: ColorChannel;\n /** The Z axis channel (the third channel). */\n readonly zChannel: ColorChannel;\n /** Whether the area is being dragged. */\n readonly isDragging: boolean;\n /** Whether the area is disabled. */\n readonly isDisabled: boolean;\n /** Step for X channel. */\n readonly xChannelStep: number;\n /** Step for Y channel. */\n readonly yChannelStep: number;\n /** Page step for X channel. */\n readonly xChannelPageStep: number;\n /** Page step for Y channel. */\n readonly yChannelPageStep: number;\n\n /** Get the X channel value. */\n getXValue(): number;\n /** Get the Y channel value. */\n getYValue(): number;\n /** Set the X channel value. */\n setXValue(value: number): void;\n /** Set the Y channel value. */\n setYValue(value: number): void;\n /** Set color from a point (0-1, 0-1). */\n setColorFromPoint(x: number, y: number): void;\n /** Get the thumb position as percentages. */\n getThumbPosition(): { x: number; y: number };\n /** Increment X value. */\n incrementX(stepSize?: number): void;\n /** Decrement X value. */\n decrementX(stepSize?: number): void;\n /** Increment Y value. */\n incrementY(stepSize?: number): void;\n /** Decrement Y value. */\n decrementY(stepSize?: number): void;\n /** Set the dragging state. */\n setDragging(isDragging: boolean): void;\n /** Get the display color (with alpha = 1). */\n getDisplayColor(): Color;\n}\n\n/**\n * Creates state for a color area (2D color picker).\n */\nexport function createColorAreaState(options: Accessor<ColorAreaStateOptions>): ColorAreaState {\n const getOptions = () => options();\n\n const normalizeValue = (value: Color | string) => {\n const color = normalizeColor(value);\n const colorSpace = getOptions().colorSpace;\n return colorSpace ? color.toFormat(colorSpace) : color;\n };\n\n // Internal value state\n const [internalValue, setInternalValue] = createSignal<Color | null>(null);\n const [isDragging, setIsDragging] = createSignal(false);\n\n // Initialize internal value\n const initValue = () => {\n const opts = getOptions();\n if (opts.defaultValue) {\n return normalizeValue(opts.defaultValue);\n }\n return null;\n };\n\n // Set initial value\n if (internalValue() === null) {\n const init = initValue();\n if (init) {\n setInternalValue(init);\n }\n }\n\n // Controlled vs uncontrolled value\n const value = createMemo(() => {\n const opts = getOptions();\n if (opts.value !== undefined) {\n return normalizeValue(opts.value);\n }\n const fallback = internalValue() ?? normalizeValue(\"#ff0000\");\n return opts.colorSpace ? fallback.toFormat(opts.colorSpace) : fallback;\n });\n\n const isDisabled = createMemo(() => getOptions().isDisabled ?? false);\n\n // Get color axes\n const axes = createMemo<ColorAxes>(() => {\n const opts = getOptions();\n return value().getColorSpaceAxes({\n xChannel: opts.xChannel,\n yChannel: opts.yChannel,\n });\n });\n\n const xChannel = createMemo(() => axes().xChannel);\n const yChannel = createMemo(() => axes().yChannel);\n const zChannel = createMemo(() => axes().zChannel);\n\n // Get channel ranges\n const xRange = createMemo(() => value().getChannelRange(xChannel()));\n const yRange = createMemo(() => value().getChannelRange(yChannel()));\n\n const xChannelStep = createMemo(() => xRange().step);\n const yChannelStep = createMemo(() => yRange().step);\n const xChannelPageStep = createMemo(() => xRange().pageSize);\n const yChannelPageStep = createMemo(() => yRange().pageSize);\n\n // Update value\n const updateValue = (newColor: Color) => {\n const opts = getOptions();\n const nextColor = opts.colorSpace ? newColor.toFormat(opts.colorSpace) : newColor;\n\n // Controlled mode\n if (opts.value !== undefined) {\n opts.onChange?.(nextColor);\n return;\n }\n\n // Uncontrolled mode\n setInternalValue(nextColor);\n opts.onChange?.(nextColor);\n };\n\n // Get X value\n const getXValue = () => value().getChannelValue(xChannel());\n\n // Get Y value\n const getYValue = () => value().getChannelValue(yChannel());\n\n // Set X value\n const setXValue = (newValue: number) => {\n const range = xRange();\n const clamped = Math.max(range.minValue, Math.min(range.maxValue, newValue));\n const rounded = Math.round(clamped / range.step) * range.step;\n const newColor = value().withChannelValue(xChannel(), rounded);\n updateValue(newColor);\n };\n\n // Set Y value\n const setYValue = (newValue: number) => {\n const range = yRange();\n const clamped = Math.max(range.minValue, Math.min(range.maxValue, newValue));\n const rounded = Math.round(clamped / range.step) * range.step;\n const newColor = value().withChannelValue(yChannel(), rounded);\n updateValue(newColor);\n };\n\n // Set color from point (x: 0-1, y: 0-1)\n const setColorFromPoint = (x: number, y: number) => {\n const xR = xRange();\n const yR = yRange();\n\n const xVal = xR.minValue + (xR.maxValue - xR.minValue) * x;\n const yVal = yR.minValue + (yR.maxValue - yR.minValue) * (1 - y); // Y is inverted\n\n const xClamped = Math.max(xR.minValue, Math.min(xR.maxValue, xVal));\n const yClamped = Math.max(yR.minValue, Math.min(yR.maxValue, yVal));\n\n const xRounded = Math.round(xClamped / xR.step) * xR.step;\n const yRounded = Math.round(yClamped / yR.step) * yR.step;\n\n const newColor = value()\n .withChannelValue(xChannel(), xRounded)\n .withChannelValue(yChannel(), yRounded);\n updateValue(newColor);\n };\n\n // Get thumb position as percentages\n const getThumbPosition = () => {\n const xR = xRange();\n const yR = yRange();\n const xVal = getXValue();\n const yVal = getYValue();\n\n return {\n x: (xVal - xR.minValue) / (xR.maxValue - xR.minValue),\n y: 1 - (yVal - yR.minValue) / (yR.maxValue - yR.minValue), // Y is inverted\n };\n };\n\n // Increment X\n const incrementX = (stepSize?: number) => {\n const s = stepSize ?? xChannelStep();\n setXValue(getXValue() + s);\n };\n\n // Decrement X\n const decrementX = (stepSize?: number) => {\n const s = stepSize ?? xChannelStep();\n setXValue(getXValue() - s);\n };\n\n // Increment Y\n const incrementY = (stepSize?: number) => {\n const s = stepSize ?? yChannelStep();\n setYValue(getYValue() + s);\n };\n\n // Decrement Y\n const decrementY = (stepSize?: number) => {\n const s = stepSize ?? yChannelStep();\n setYValue(getYValue() - s);\n };\n\n // Set dragging\n const setDraggingState = (dragging: boolean) => {\n const wasDragging = isDragging();\n setIsDragging(dragging);\n\n // Call onChangeEnd when dragging ends\n if (wasDragging && !dragging) {\n getOptions().onChangeEnd?.(value());\n }\n };\n\n // Get display color (alpha = 1)\n const getDisplayColor = () => {\n return value().withChannelValue(\"alpha\", 1);\n };\n\n return {\n get value() {\n return value();\n },\n get xChannel() {\n return xChannel();\n },\n get yChannel() {\n return yChannel();\n },\n get zChannel() {\n return zChannel();\n },\n get isDragging() {\n return isDragging();\n },\n get isDisabled() {\n return isDisabled();\n },\n get xChannelStep() {\n return xChannelStep();\n },\n get yChannelStep() {\n return yChannelStep();\n },\n get xChannelPageStep() {\n return xChannelPageStep();\n },\n get yChannelPageStep() {\n return yChannelPageStep();\n },\n getXValue,\n getYValue,\n setXValue,\n setYValue,\n setColorFromPoint,\n getThumbPosition,\n incrementX,\n decrementX,\n incrementY,\n decrementY,\n setDragging: setDraggingState,\n getDisplayColor,\n };\n}\n","/**\n * ColorWheel state management.\n * Based on @react-stately/color useColorWheelState.\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport type { Color } from \"./types\";\nimport { createHSLColor, normalizeColor } from \"./Color\";\n\nexport interface ColorWheelStateOptions {\n /** The current color value (controlled). */\n value?: Color | string;\n /** The default color value (uncontrolled). */\n defaultValue?: Color | string;\n /** Handler called when the color changes. */\n onChange?: (color: Color) => void;\n /** Handler called when dragging ends. */\n onChangeEnd?: (color: Color) => void;\n /** Whether the wheel is disabled. */\n isDisabled?: boolean;\n}\n\nexport interface ColorWheelState {\n /** The current color value. */\n readonly value: Color;\n /** The initial color value. */\n readonly defaultValue: Color;\n /** Whether the wheel is being dragged. */\n readonly isDragging: boolean;\n /** Whether the wheel is disabled. */\n readonly isDisabled: boolean;\n /** Step value for hue changes. */\n readonly step: number;\n /** Page step value for hue changes. */\n readonly pageStep: number;\n\n /** Get the current hue value (0-360). */\n getHue(): number;\n /** Set the full color value. */\n setValue(value: Color | string): void;\n /** Set the hue value. */\n setHue(value: number): void;\n /** Set hue from an angle in radians. */\n setHueFromAngle(angle: number): void;\n /** Set hue from a point relative to the wheel center. */\n setHueFromPoint(x: number, y: number, radius: number): void;\n /** Get the thumb angle in radians (0 = right, increases counterclockwise). */\n getThumbAngle(): number;\n /** Get the thumb position relative to the wheel center. */\n getThumbPosition(radius: number): { x: number; y: number };\n /** Increment hue value. */\n increment(stepSize?: number): void;\n /** Decrement hue value. */\n decrement(stepSize?: number): void;\n /** Set the dragging state. */\n setDragging(isDragging: boolean): void;\n /** Get the display color (with full saturation/brightness for wheel). */\n getDisplayColor(): Color;\n}\n\n/**\n * Creates state for a color wheel (circular hue picker).\n */\nexport function createColorWheelState(options: Accessor<ColorWheelStateOptions>): ColorWheelState {\n const getOptions = () => options();\n const defaultColor = createHSLColor(0, 100, 50);\n\n const normalizeWheelValue = (color: Color | string) => {\n const value = normalizeColor(color);\n return value.toFormat(value.getColorSpace() === \"hsb\" ? \"hsb\" : \"hsl\");\n };\n\n const initialValue = normalizeWheelValue(getOptions().defaultValue ?? defaultColor);\n const [internalValue, setInternalValue] = createSignal<Color>(initialValue);\n const [isDragging, setIsDragging] = createSignal(false);\n let valueRef = initialValue;\n\n // Controlled vs uncontrolled value\n const value = createMemo(() => {\n const opts = getOptions();\n const nextValue = opts.value !== undefined ? normalizeWheelValue(opts.value) : internalValue();\n valueRef = nextValue;\n return nextValue;\n });\n\n const isDisabled = createMemo(() => getOptions().isDisabled ?? false);\n\n // Hue step and page step\n const hueRange = createMemo(() => value().getChannelRange(\"hue\"));\n const step = createMemo(() => hueRange().step);\n const pageStep = createMemo(() => hueRange().pageSize);\n\n // Update value\n const updateValue = (newColor: Color) => {\n const opts = getOptions();\n const nextColor = normalizeWheelValue(newColor);\n valueRef = nextColor;\n\n // Controlled mode\n if (opts.value !== undefined) {\n opts.onChange?.(nextColor);\n return;\n }\n\n // Uncontrolled mode\n setInternalValue(nextColor);\n opts.onChange?.(nextColor);\n };\n\n // Get hue value (0-360)\n const getHue = () => value().getChannelValue(\"hue\");\n\n const setValue = (newValue: Color | string) => {\n updateValue(normalizeWheelValue(newValue));\n };\n\n const roundToStep = (num: number, stepValue: number) => {\n const rounded = Math.round(num / stepValue) * stepValue;\n const precision = `${stepValue}`.split(\".\")[1]?.length ?? 0;\n return Number(rounded.toFixed(precision));\n };\n\n const roundDown = (num: number) => {\n const rounded = Math.floor(num);\n return rounded === num ? num - 1 : rounded;\n };\n\n const mod = (n: number, m: number) => ((n % m) + m) % m;\n\n const radToDeg = (rad: number) => (rad * 180) / Math.PI;\n const degToRad = (deg: number) => (deg * Math.PI) / 180;\n\n const cartesianToAngle = (x: number, y: number, radius: number) => {\n const clampedX = Math.max(-radius, Math.min(radius, x));\n const clampedY = Math.max(-radius, Math.min(radius, y));\n return mod(radToDeg(Math.atan2(clampedY, clampedX)), 360);\n };\n\n const angleToCartesian = (angle: number, radius: number) => ({\n x: radius * Math.cos(degToRad(angle)),\n y: radius * Math.sin(degToRad(angle)),\n });\n\n // Set hue value\n const setHue = (newValue: number) => {\n const currentHue = getHue();\n const range = hueRange();\n const hue = newValue > range.maxValue ? range.minValue : newValue;\n const rounded = roundToStep(mod(hue, range.maxValue), range.step);\n if (rounded === currentHue) return;\n\n const newColor = value().withChannelValue(\"hue\", rounded);\n updateValue(newColor);\n };\n\n // Set hue from angle (radians, 0 = right, counterclockwise)\n const setHueFromAngle = (angle: number) => {\n setHue(mod(360 - radToDeg(angle), 360));\n };\n\n const setHueFromPoint = (x: number, y: number, radius: number) => {\n setHue(cartesianToAngle(x, y, radius));\n };\n\n // Get thumb angle in radians\n const getThumbAngle = () => {\n return degToRad(360 - getHue());\n };\n\n const getThumbPosition = (radius: number) => {\n return angleToCartesian(getHue(), radius);\n };\n\n // Increment hue\n const increment = (stepSize?: number) => {\n const range = hueRange();\n const s = Math.max(stepSize ?? range.step, range.step);\n const nextValue = getHue() + s;\n if (nextValue >= range.maxValue) {\n setHue(range.minValue);\n return;\n }\n setHue(roundToStep(mod(nextValue, range.maxValue), s));\n };\n\n // Decrement hue\n const decrement = (stepSize?: number) => {\n const range = hueRange();\n const s = Math.max(stepSize ?? range.step, range.step);\n if (getHue() === range.minValue) {\n setHue(roundDown(range.maxValue / s) * s);\n return;\n }\n setHue(roundToStep(mod(getHue() - s, range.maxValue), s));\n };\n\n // Set dragging state\n const setDraggingState = (dragging: boolean) => {\n const wasDragging = isDragging();\n setIsDragging(dragging);\n\n // Call onChangeEnd when dragging ends\n if (wasDragging && !dragging) {\n getOptions().onChangeEnd?.(valueRef);\n }\n };\n\n // Get display color (full saturation and brightness for wheel preview)\n const getDisplayColor = () => {\n return value()\n .toFormat(\"hsl\")\n .withChannelValue(\"saturation\", 100)\n .withChannelValue(\"lightness\", 50)\n .withChannelValue(\"alpha\", 1);\n };\n\n return {\n get value() {\n return value();\n },\n get defaultValue() {\n return initialValue;\n },\n get isDragging() {\n return isDragging();\n },\n get isDisabled() {\n return isDisabled();\n },\n get step() {\n return step();\n },\n get pageStep() {\n return pageStep();\n },\n getHue,\n setValue,\n setHue,\n setHueFromAngle,\n setHueFromPoint,\n getThumbAngle,\n getThumbPosition,\n increment,\n decrement,\n setDragging: setDraggingState,\n getDisplayColor,\n };\n}\n","/**\n * ColorField state management.\n * Based on @react-stately/color useColorFieldState and useColorChannelFieldState.\n */\n\nimport { createEffect, createMemo, createSignal, type Accessor } from \"solid-js\";\nimport type { Color, ColorChannel, ColorChannelRange, ColorFormat, ColorSpace } from \"./types\";\nimport { createRGBColor, normalizeColor, parseColor } from \"./Color\";\n\nconst HEX_COLOR_MAX = 0xffffff;\nconst PARTIAL_HEX_PATTERN = /^#?[0-9a-f]{0,6}$/i;\n\nexport interface ColorFieldStateOptions {\n /** The current color value (controlled). */\n value?: Color | string | null;\n /** The default color value (uncontrolled). */\n defaultValue?: Color | string | null;\n /** Handler called when the color changes. */\n onChange?: (color: Color | null) => void;\n /** The color channel to edit (for single channel mode). */\n channel?: ColorChannel;\n /** The color space to use for channel mode. */\n colorSpace?: ColorSpace;\n /** The color format for parsing/displaying in hex mode. */\n colorFormat?: ColorFormat;\n /** Locale used to format channel values. */\n locale?: string;\n /** Whether the field is disabled. */\n isDisabled?: boolean;\n /** Whether the field is read-only. */\n isReadOnly?: boolean;\n /** Whether the field is invalid. */\n isInvalid?: boolean;\n /** Whether the field is required. */\n isRequired?: boolean;\n}\n\nexport interface ColorFieldState {\n /** The current color value (null if empty). */\n readonly value: Color | null;\n /** The color used for channel calculations. */\n readonly colorValue: Color;\n /** The current input text. */\n readonly inputValue: string;\n /** The numeric value exposed by channel fields. */\n readonly numberValue: number;\n /** The channel minimum value after formatting normalization. */\n readonly minValue: number;\n /** The channel maximum value after formatting normalization. */\n readonly maxValue: number;\n /** The channel keyboard step after formatting normalization. */\n readonly step: number;\n /** The channel page step after formatting normalization. */\n readonly pageSize: number;\n /** Number formatter options for channel fields. */\n readonly formatOptions: Intl.NumberFormatOptions;\n /** Whether the input is invalid. */\n readonly isInvalid: boolean;\n /** Whether the field is disabled. */\n readonly isDisabled: boolean;\n /** Whether the field is read-only. */\n readonly isReadOnly: boolean;\n /** Whether the field is required. */\n readonly isRequired: boolean;\n /** The color channel being edited (if single channel mode). */\n readonly channel: ColorChannel | undefined;\n\n /** Set the input text value. */\n setInputValue(value: string): void;\n /** Set the color value. */\n setColorValue(value: Color | null): void;\n /** Commit the current input value. */\n commit(): void;\n /** Increment the color value. */\n increment(): void;\n /** Decrement the color value. */\n decrement(): void;\n /** Increment by page size or to the maximum. */\n incrementToMax(): void;\n /** Decrement by page size or to the minimum. */\n decrementToMin(): void;\n /** Validate the current input or a candidate input. */\n validate(value?: string): boolean;\n}\n\nfunction normalizeNullableColor(value: Color | string | null | undefined): Color | null {\n if (value == null) {\n return null;\n }\n return normalizeColor(value);\n}\n\nfunction getDefaultValue(options: ColorFieldStateOptions): Color | null {\n if (options.defaultValue !== undefined) {\n return normalizeNullableColor(options.defaultValue);\n }\n\n if (options.value !== undefined) {\n return normalizeNullableColor(options.value);\n }\n\n return null;\n}\n\nfunction convertColor(color: Color, colorSpace: ColorSpace | undefined): Color {\n return colorSpace ? color.toFormat(colorSpace) : color;\n}\n\nfunction getDisplayColor(color: Color | null, colorSpace: ColorSpace | undefined): Color {\n return convertColor(color ?? createRGBColor(0, 0, 0), colorSpace);\n}\n\nfunction getChannelMultiplier(color: Color, channel: ColorChannel): number {\n const range = color.getChannelRange(channel);\n const formatOptions = color.getChannelFormatOptions(channel);\n return formatOptions.style === \"percent\" && range.maxValue === 100 ? 100 : 1;\n}\n\nfunction getNormalizedRange(color: Color, channel: ColorChannel): ColorChannelRange {\n const multiplier = getChannelMultiplier(color, channel);\n const range = color.getChannelRange(channel);\n\n return {\n minValue: range.minValue / multiplier,\n maxValue: range.maxValue / multiplier,\n step: range.step / multiplier,\n pageSize: range.pageSize / multiplier,\n };\n}\n\nfunction formatColorValue(\n color: Color | null,\n channel: ColorChannel | undefined,\n colorSpace: ColorSpace | undefined,\n format: ColorFormat | undefined,\n locale: string,\n): string {\n if (!color) {\n return \"\";\n }\n\n const displayColor = getDisplayColor(color, colorSpace);\n\n if (channel) {\n return displayColor.formatChannelValue(channel, locale);\n }\n\n return displayColor.toString(format ?? \"hex\");\n}\n\nfunction normalizeHexInput(value: string): string {\n return value.startsWith(\"#\") ? value : `#${value}`;\n}\n\nfunction parseHexValue(value: string, format: ColorFormat | undefined): Color {\n const color = parseColor(normalizeHexInput(value));\n return format ? color.toFormat(format) : color;\n}\n\nfunction parseChannelValue(text: string, color: Color, channel: ColorChannel): number | null {\n const trimmed = text.trim();\n const hasPercent = trimmed.endsWith(\"%\");\n const parsed = Number.parseFloat(hasPercent ? trimmed.slice(0, -1) : trimmed);\n\n if (Number.isNaN(parsed)) {\n return null;\n }\n\n const range = color.getChannelRange(channel);\n const formatOptions = color.getChannelFormatOptions(channel);\n const multiplier = getChannelMultiplier(color, channel);\n const rawValue = hasPercent && formatOptions.style === \"percent\" ? parsed : parsed * multiplier;\n\n return Math.min(range.maxValue, Math.max(range.minValue, rawValue));\n}\n\nfunction hexIntToColor(value: number): Color {\n const clamped = Math.min(HEX_COLOR_MAX, Math.max(0, Math.round(value)));\n const red = (clamped >> 16) & 0xff;\n const green = (clamped >> 8) & 0xff;\n const blue = clamped & 0xff;\n return createRGBColor(red, green, blue);\n}\n\n/**\n * Creates state for a color field (text input for color values).\n */\nexport function createColorFieldState(options: Accessor<ColorFieldStateOptions>): ColorFieldState {\n const getOptions = () => options();\n const initialOptions = getOptions();\n const initialValue = getDefaultValue(initialOptions);\n\n const [internalValue, setInternalValue] = createSignal<Color | null>(initialValue);\n const [inputValue, setInputValueInternal] = createSignal(\n formatColorValue(\n initialValue,\n initialOptions.channel,\n initialOptions.colorSpace,\n initialOptions.colorFormat,\n initialOptions.locale ?? \"en-US\",\n ),\n );\n const [invalidInput, setInvalidInput] = createSignal(false);\n\n const channel = createMemo(() => getOptions().channel);\n const colorSpace = createMemo(() => getOptions().colorSpace);\n const locale = createMemo(() => getOptions().locale ?? \"en-US\");\n\n const value = createMemo(() => {\n const opts = getOptions();\n if (opts.value !== undefined) {\n return normalizeNullableColor(opts.value);\n }\n return internalValue();\n });\n\n const colorValue = createMemo(() => getDisplayColor(value(), colorSpace()));\n const isDisabled = createMemo(() => getOptions().isDisabled ?? false);\n const isReadOnly = createMemo(() => getOptions().isReadOnly ?? false);\n const isRequired = createMemo(() => getOptions().isRequired ?? false);\n const isInvalid = createMemo(() => (getOptions().isInvalid ?? false) || invalidInput());\n\n const formatCurrentValue = (color: Color | null = value()) =>\n formatColorValue(color, channel(), colorSpace(), getOptions().colorFormat, locale());\n\n createEffect(() => {\n setInputValueInternal(formatCurrentValue());\n setInvalidInput(false);\n });\n\n const updateValue = (newColor: Color | null) => {\n const opts = getOptions();\n\n if (opts.value === undefined) {\n setInternalValue(newColor);\n }\n\n opts.onChange?.(newColor);\n setInputValueInternal(formatCurrentValue(newColor));\n setInvalidInput(false);\n };\n\n const setInputValue = (text: string) => {\n setInputValueInternal(text);\n setInvalidInput(false);\n };\n\n const setColorValue = (newColor: Color | null) => {\n updateValue(newColor);\n };\n\n const commit = () => {\n const text = inputValue().trim();\n const opts = getOptions();\n const chan = channel();\n\n if (!text) {\n updateValue(null);\n return;\n }\n\n if (chan) {\n const displayColor = colorValue();\n const rawValue = parseChannelValue(text, displayColor, chan);\n if (rawValue == null) {\n setInputValueInternal(formatCurrentValue());\n setInvalidInput(false);\n return;\n }\n\n updateValue(displayColor.withChannelValue(chan, rawValue));\n return;\n }\n\n try {\n updateValue(parseHexValue(text, opts.colorFormat));\n } catch {\n setInputValueInternal(formatCurrentValue());\n setInvalidInput(false);\n }\n };\n\n const incrementHex = (amount: number) => {\n const currentColor = value();\n if (!currentColor) {\n return;\n }\n\n const newColor = hexIntToColor(currentColor.toFormat(\"rgb\").toHexInt() + amount);\n updateValue(getOptions().colorFormat ? newColor.toFormat(getOptions().colorFormat!) : newColor);\n };\n\n const updateChannel = (amount: number | \"min\" | \"max\") => {\n const chan = channel();\n if (!chan) {\n return;\n }\n\n const displayColor = colorValue();\n const range = displayColor.getChannelRange(chan);\n const currentValue = displayColor.getChannelValue(chan);\n const nextValue =\n amount === \"min\"\n ? range.minValue\n : amount === \"max\"\n ? range.maxValue\n : Math.min(range.maxValue, Math.max(range.minValue, currentValue + amount));\n\n updateValue(displayColor.withChannelValue(chan, nextValue));\n };\n\n const increment = () => {\n const chan = channel();\n if (!chan) {\n incrementHex(1);\n return;\n }\n\n updateChannel(colorValue().getChannelRange(chan).step);\n };\n\n const decrement = () => {\n const chan = channel();\n if (!chan) {\n incrementHex(-1);\n return;\n }\n\n updateChannel(-colorValue().getChannelRange(chan).step);\n };\n\n const incrementToMax = () => {\n const chan = channel();\n if (!chan) {\n incrementHex(HEX_COLOR_MAX);\n return;\n }\n\n updateChannel(\"max\");\n };\n\n const decrementToMin = () => {\n const chan = channel();\n if (!chan) {\n incrementHex(-HEX_COLOR_MAX);\n return;\n }\n\n updateChannel(\"min\");\n };\n\n const validate = (candidate?: string) => {\n const text = (candidate ?? inputValue()).trim();\n const chan = channel();\n\n if (!text) {\n return true;\n }\n\n if (chan) {\n return parseChannelValue(text, colorValue(), chan) != null;\n }\n\n return PARTIAL_HEX_PATTERN.test(text);\n };\n\n return {\n get value() {\n return value();\n },\n get colorValue() {\n return colorValue();\n },\n get inputValue() {\n return inputValue();\n },\n get numberValue() {\n const chan = channel();\n if (!chan || value() === null) {\n return Number.NaN;\n }\n return colorValue().getChannelValue(chan) / getChannelMultiplier(colorValue(), chan);\n },\n get minValue() {\n const chan = channel();\n return chan ? getNormalizedRange(colorValue(), chan).minValue : 0;\n },\n get maxValue() {\n const chan = channel();\n return chan ? getNormalizedRange(colorValue(), chan).maxValue : HEX_COLOR_MAX;\n },\n get step() {\n const chan = channel();\n return chan ? getNormalizedRange(colorValue(), chan).step : 1;\n },\n get pageSize() {\n const chan = channel();\n return chan ? getNormalizedRange(colorValue(), chan).pageSize : 0x100000;\n },\n get formatOptions() {\n const chan = channel();\n return chan ? colorValue().getChannelFormatOptions(chan) : {};\n },\n get isInvalid() {\n return isInvalid();\n },\n get isDisabled() {\n return isDisabled();\n },\n get isReadOnly() {\n return isReadOnly();\n },\n get isRequired() {\n return isRequired();\n },\n get channel() {\n return channel();\n },\n setInputValue,\n setColorValue,\n commit,\n increment,\n decrement,\n incrementToMax,\n decrementToMin,\n validate,\n };\n}\n","/**\n * Drag state management for solid-stately.\n *\n * Provides reactive state for drag operations.\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport type {\n DragItem,\n DragStartEvent,\n DragMoveEvent,\n DragEndEvent,\n DropOperation,\n DragPreviewRenderer,\n} from \"./types\";\n\nexport interface DragStateOptions {\n /** A function that returns the items being dragged. */\n getItems: () => DragItem[];\n /** Function that returns the allowed drop operations. */\n getAllowedDropOperations?: () => DropOperation[];\n /** Handler that is called when a drag operation is started. */\n onDragStart?: (e: DragStartEvent) => void;\n /** Handler that is called when the drag is moved. */\n onDragMove?: (e: DragMoveEvent) => void;\n /** Handler that is called when the drag operation ends. */\n onDragEnd?: (e: DragEndEvent) => void;\n /** Whether the drag operation is disabled. */\n isDisabled?: boolean;\n /** Whether there is a separate drag button affordance. */\n hasDragButton?: boolean;\n /** Preview renderer function ref. */\n preview?: { current: DragPreviewRenderer | null };\n}\n\nexport interface DragState {\n /** Whether an element is currently being dragged. */\n readonly isDragging: boolean;\n /** Whether drag is disabled. */\n readonly isDisabled: boolean;\n /** Start a drag operation. */\n startDrag(x: number, y: number): void;\n /** Update drag position. */\n moveDrag(x: number, y: number): void;\n /** End a drag operation. */\n endDrag(x: number, y: number, dropOperation: DropOperation): void;\n /** Cancel a drag operation. */\n cancelDrag(): void;\n /** Get the items being dragged. */\n getItems(): DragItem[];\n /** Get allowed drop operations. */\n getAllowedDropOperations(): DropOperation[];\n /** Whether there is a drag button. */\n readonly hasDragButton: boolean;\n /** Preview renderer. */\n readonly preview: { current: DragPreviewRenderer | null } | undefined;\n}\n\n/**\n * Creates drag state for managing drag operations.\n *\n * @param props - Accessor returning drag state options\n * @returns Drag state object\n */\nexport function createDragState(props: Accessor<DragStateOptions>): DragState {\n const getProps = createMemo(() => props());\n\n const [isDragging, setIsDragging] = createSignal(false);\n\n const startDrag = (x: number, y: number) => {\n const p = getProps();\n if (p.isDisabled) return;\n\n setIsDragging(true);\n\n if (typeof p.onDragStart === \"function\") {\n p.onDragStart({\n type: \"dragstart\",\n x,\n y,\n });\n }\n };\n\n const moveDrag = (x: number, y: number) => {\n const p = getProps();\n if (!isDragging() || p.isDisabled) return;\n\n if (typeof p.onDragMove === \"function\") {\n p.onDragMove({\n type: \"dragmove\",\n x,\n y,\n });\n }\n };\n\n const endDrag = (x: number, y: number, dropOperation: DropOperation) => {\n const p = getProps();\n if (!isDragging()) return;\n\n setIsDragging(false);\n\n if (typeof p.onDragEnd === \"function\") {\n p.onDragEnd({\n type: \"dragend\",\n x,\n y,\n dropOperation,\n });\n }\n };\n\n const cancelDrag = () => {\n endDrag(0, 0, \"cancel\");\n };\n\n const getItems = () => {\n const p = getProps();\n return p.getItems();\n };\n\n const getAllowedDropOperations = (): DropOperation[] => {\n const p = getProps();\n if (typeof p.getAllowedDropOperations === \"function\") {\n return p.getAllowedDropOperations();\n }\n return [\"move\", \"copy\", \"link\"];\n };\n\n return {\n get isDragging() {\n return isDragging();\n },\n get isDisabled() {\n return getProps().isDisabled ?? false;\n },\n get hasDragButton() {\n return getProps().hasDragButton ?? false;\n },\n get preview() {\n return getProps().preview;\n },\n startDrag,\n moveDrag,\n endDrag,\n cancelDrag,\n getItems,\n getAllowedDropOperations,\n };\n}\n","/**\n * Drop state management for solid-stately.\n *\n * Provides reactive state for drop target operations.\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport type {\n DropItem,\n DropEnterEvent,\n DropMoveEvent,\n DropExitEvent,\n DropActivateEvent,\n DropEvent,\n DropOperation,\n DragTypes,\n} from \"./types\";\n\nexport interface DropStateOptions {\n /**\n * A function returning the drop operation to be performed.\n */\n getDropOperation?: (types: DragTypes, allowedOperations: DropOperation[]) => DropOperation;\n /**\n * A function returning the drop operation for a specific point.\n */\n getDropOperationForPoint?: (\n types: DragTypes,\n allowedOperations: DropOperation[],\n x: number,\n y: number,\n ) => DropOperation;\n /** Handler that is called when a valid drag enters the drop target. */\n onDropEnter?: (e: DropEnterEvent) => void;\n /** Handler that is called when a valid drag is moved within the drop target. */\n onDropMove?: (e: DropMoveEvent) => void;\n /** Handler that is called after a valid drag is held over the drop target. */\n onDropActivate?: (e: DropActivateEvent) => void;\n /** Handler that is called when a valid drag exits the drop target. */\n onDropExit?: (e: DropExitEvent) => void;\n /** Handler that is called when a valid drag is dropped on the drop target. */\n onDrop?: (e: DropEvent) => void;\n /** Whether there is a separate drop button affordance. */\n hasDropButton?: boolean;\n /** Whether the drop target is disabled. */\n isDisabled?: boolean;\n}\n\nexport interface DropState {\n /** Whether the drop target is currently being hovered or focused. */\n readonly isDropTarget: boolean;\n /** Whether the drop target is disabled. */\n readonly isDisabled: boolean;\n /** Whether there is a drop button. */\n readonly hasDropButton: boolean;\n /** Enter the drop target. */\n enterTarget(x: number, y: number): void;\n /** Move within the drop target. */\n moveInTarget(x: number, y: number): void;\n /** Exit the drop target. */\n exitTarget(x: number, y: number): void;\n /** Activate the drop target (after holding). */\n activateTarget(x: number, y: number): void;\n /** Perform a drop on the target. */\n drop(x: number, y: number, items: DropItem[], dropOperation: DropOperation): void;\n /** Get the drop operation for given types. */\n getDropOperation(types: DragTypes, allowedOperations: DropOperation[]): DropOperation;\n /** Get the drop operation for a specific point. */\n getDropOperationForPoint(\n types: DragTypes,\n allowedOperations: DropOperation[],\n x: number,\n y: number,\n ): DropOperation;\n}\n\n/**\n * Creates drop state for managing drop target operations.\n *\n * @param props - Accessor returning drop state options\n * @returns Drop state object\n */\nexport function createDropState(props: Accessor<DropStateOptions>): DropState {\n const getProps = createMemo(() => props());\n\n const [isDropTarget, setIsDropTarget] = createSignal(false);\n\n const enterTarget = (x: number, y: number) => {\n const p = getProps();\n if (p.isDisabled) return;\n\n setIsDropTarget(true);\n\n if (typeof p.onDropEnter === \"function\") {\n p.onDropEnter({\n type: \"dropenter\",\n x,\n y,\n });\n }\n };\n\n const moveInTarget = (x: number, y: number) => {\n const p = getProps();\n if (!isDropTarget() || p.isDisabled) return;\n\n if (typeof p.onDropMove === \"function\") {\n p.onDropMove({\n type: \"dropmove\",\n x,\n y,\n });\n }\n };\n\n const exitTarget = (x: number, y: number) => {\n const p = getProps();\n\n setIsDropTarget(false);\n\n if (typeof p.onDropExit === \"function\") {\n p.onDropExit({\n type: \"dropexit\",\n x,\n y,\n });\n }\n };\n\n const activateTarget = (x: number, y: number) => {\n const p = getProps();\n if (p.isDisabled) return;\n\n if (typeof p.onDropActivate === \"function\") {\n p.onDropActivate({\n type: \"dropactivate\",\n x,\n y,\n });\n }\n };\n\n const drop = (x: number, y: number, items: DropItem[], dropOperation: DropOperation) => {\n const p = getProps();\n if (p.isDisabled) return;\n\n setIsDropTarget(false);\n\n if (typeof p.onDrop === \"function\") {\n p.onDrop({\n type: \"drop\",\n x,\n y,\n items,\n dropOperation,\n });\n }\n };\n\n const getDropOperation = (\n types: DragTypes,\n allowedOperations: DropOperation[],\n ): DropOperation => {\n const p = getProps();\n if (typeof p.getDropOperation === \"function\") {\n return p.getDropOperation(types, allowedOperations);\n }\n return allowedOperations[0] ?? \"cancel\";\n };\n\n const getDropOperationForPoint = (\n types: DragTypes,\n allowedOperations: DropOperation[],\n x: number,\n y: number,\n ): DropOperation => {\n const p = getProps();\n if (typeof p.getDropOperationForPoint === \"function\") {\n return p.getDropOperationForPoint(types, allowedOperations, x, y);\n }\n return getDropOperation(types, allowedOperations);\n };\n\n return {\n get isDropTarget() {\n return isDropTarget();\n },\n get isDisabled() {\n return getProps().isDisabled ?? false;\n },\n get hasDropButton() {\n return getProps().hasDropButton ?? false;\n },\n enterTarget,\n moveInTarget,\n exitTarget,\n activateTarget,\n drop,\n getDropOperation,\n getDropOperationForPoint,\n };\n}\n","/**\n * Draggable collection state management for solid-stately.\n *\n * Provides reactive state for dragging items from a collection.\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport type {\n DragItem,\n DraggableCollectionStartEvent,\n DraggableCollectionMoveEvent,\n DraggableCollectionEndEvent,\n DropOperation,\n DragPreviewRenderer,\n} from \"./types\";\n\nexport interface DraggableCollectionStateOptions<T = object> {\n /** A function that returns the items being dragged. */\n getItems: (keys: Set<string | number>) => DragItem[];\n /** Function that returns the allowed drop operations. */\n getAllowedDropOperations?: () => DropOperation[];\n /** Handler that is called when a drag operation is started. */\n onDragStart?: (e: DraggableCollectionStartEvent) => void;\n /** Handler that is called when the drag is moved. */\n onDragMove?: (e: DraggableCollectionMoveEvent) => void;\n /** Handler that is called when the drag operation ends. */\n onDragEnd?: (e: DraggableCollectionEndEvent) => void;\n /** Whether the drag operation is disabled. */\n isDisabled?: boolean;\n /** Preview renderer function ref. */\n preview?: { current: DragPreviewRenderer | null };\n}\n\nexport interface DraggableCollectionState {\n /** Whether items are currently being dragged. */\n readonly isDragging: boolean;\n /** The keys of the items being dragged. */\n readonly draggingKeys: Set<string | number>;\n /** Whether dragging is disabled. */\n readonly isDisabled: boolean;\n /** Start a drag operation with the given keys. */\n startDrag(keys: Set<string | number>, x: number, y: number): void;\n /** Update drag position. */\n moveDrag(x: number, y: number): void;\n /** End a drag operation. */\n endDrag(x: number, y: number, dropOperation: DropOperation, isInternal: boolean): void;\n /** Cancel a drag operation. */\n cancelDrag(): void;\n /** Get the items being dragged for the given keys. */\n getItems(keys: Set<string | number>): DragItem[];\n /** Get allowed drop operations. */\n getAllowedDropOperations(): DropOperation[];\n /** Preview renderer. */\n readonly preview: { current: DragPreviewRenderer | null } | undefined;\n}\n\n/**\n * Creates state for dragging items from a collection.\n *\n * @param props - Accessor returning draggable collection options\n * @returns Draggable collection state object\n */\nexport function createDraggableCollectionState<T = object>(\n props: Accessor<DraggableCollectionStateOptions<T>>,\n): DraggableCollectionState {\n const getProps = createMemo(() => props());\n\n const [isDragging, setIsDragging] = createSignal(false);\n const [draggingKeys, setDraggingKeys] = createSignal<Set<string | number>>(new Set());\n\n const startDrag = (keys: Set<string | number>, x: number, y: number) => {\n const p = getProps();\n if (p.isDisabled) return;\n\n setIsDragging(true);\n setDraggingKeys(keys);\n\n if (typeof p.onDragStart === \"function\") {\n p.onDragStart({\n type: \"dragstart\",\n x,\n y,\n keys,\n });\n }\n };\n\n const moveDrag = (x: number, y: number) => {\n const p = getProps();\n if (!isDragging() || p.isDisabled) return;\n\n if (typeof p.onDragMove === \"function\") {\n p.onDragMove({\n type: \"dragmove\",\n x,\n y,\n keys: draggingKeys(),\n });\n }\n };\n\n const endDrag = (x: number, y: number, dropOperation: DropOperation, isInternal: boolean) => {\n const p = getProps();\n const keys = draggingKeys();\n\n setIsDragging(false);\n setDraggingKeys(new Set<string | number>());\n\n if (typeof p.onDragEnd === \"function\") {\n p.onDragEnd({\n type: \"dragend\",\n x,\n y,\n dropOperation,\n keys,\n isInternal,\n });\n }\n };\n\n const cancelDrag = () => {\n endDrag(0, 0, \"cancel\", false);\n };\n\n const getItems = (keys: Set<string | number>) => {\n const p = getProps();\n return p.getItems(keys);\n };\n\n const getAllowedDropOperations = (): DropOperation[] => {\n const p = getProps();\n if (typeof p.getAllowedDropOperations === \"function\") {\n return p.getAllowedDropOperations();\n }\n return [\"move\", \"copy\", \"link\"];\n };\n\n return {\n get isDragging() {\n return isDragging();\n },\n get draggingKeys() {\n return draggingKeys();\n },\n get isDisabled() {\n return getProps().isDisabled ?? false;\n },\n get preview() {\n return getProps().preview;\n },\n startDrag,\n moveDrag,\n endDrag,\n cancelDrag,\n getItems,\n getAllowedDropOperations,\n };\n}\n","/**\n * Droppable collection state management for solid-stately.\n *\n * Provides reactive state for accepting drops onto a collection.\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport type {\n DropItem,\n DropTarget,\n DropOperation,\n DragTypes,\n DroppableCollectionEnterEvent,\n DroppableCollectionMoveEvent,\n DroppableCollectionActivateEvent,\n DroppableCollectionExitEvent,\n DroppableCollectionDropEvent,\n DroppableCollectionInsertDropEvent,\n DroppableCollectionRootDropEvent,\n DroppableCollectionOnItemDropEvent,\n DroppableCollectionReorderEvent,\n ItemDropTarget,\n} from \"./types\";\n\nexport interface DroppableCollectionStateOptions {\n /**\n * The drag types that the droppable collection accepts.\n * @default 'all'\n */\n acceptedDragTypes?: \"all\" | Array<string | symbol>;\n /**\n * A function returning the drop operation to be performed.\n */\n getDropOperation?: (\n target: DropTarget,\n types: DragTypes,\n allowedOperations: DropOperation[],\n ) => DropOperation;\n /** Handler that is called when a valid drag enters a drop target. */\n onDropEnter?: (e: DroppableCollectionEnterEvent) => void;\n /** Handler that is called after a valid drag is held over a drop target. */\n onDropActivate?: (e: DroppableCollectionActivateEvent) => void;\n /** Handler that is called when a valid drag exits a drop target. */\n onDropExit?: (e: DroppableCollectionExitEvent) => void;\n /** Handler that is called when a valid drag is dropped. */\n onDrop?: (e: DroppableCollectionDropEvent) => void;\n /** Handler that is called when external items are dropped \"between\" items. */\n onInsert?: (e: DroppableCollectionInsertDropEvent) => void;\n /** Handler that is called when external items are dropped on the collection's root. */\n onRootDrop?: (e: DroppableCollectionRootDropEvent) => void;\n /** Handler that is called when items are dropped \"on\" an item. */\n onItemDrop?: (e: DroppableCollectionOnItemDropEvent) => void;\n /** Handler that is called when items are reordered within the collection. */\n onReorder?: (e: DroppableCollectionReorderEvent) => void;\n /** Handler that is called when items are moved within the source collection. */\n onMove?: (e: DroppableCollectionReorderEvent) => void;\n /** A function returning whether a given target is a valid \"on\" drop target. */\n shouldAcceptItemDrop?: (target: ItemDropTarget, types: DragTypes) => boolean;\n /** Whether the droppable collection is disabled. */\n isDisabled?: boolean;\n}\n\nexport interface DroppableCollectionState {\n /** Whether a drag is currently over the collection. */\n readonly isDropTarget: boolean;\n /** The current drop target within the collection. */\n readonly target: DropTarget | null;\n /** Whether the collection is disabled for drops. */\n readonly isDisabled: boolean;\n /** Set the current drop target. */\n setTarget(target: DropTarget | null): void;\n /** Check if a drag type is accepted. */\n isAccepted(types: DragTypes): boolean;\n /** Enter the collection with a drop target. */\n enterTarget(target: DropTarget, x: number, y: number): void;\n /** Move to a new target within the collection. */\n moveToTarget(target: DropTarget, x: number, y: number): void;\n /** Exit the collection. */\n exitTarget(x: number, y: number): void;\n /** Activate the current target. */\n activateTarget(x: number, y: number): void;\n /** Perform a drop on the collection. */\n drop(\n items: DropItem[],\n dropOperation: DropOperation,\n isInternal: boolean,\n draggingKeys?: Set<string | number>,\n ): void;\n /** Get the drop operation for a target. */\n getDropOperation(\n target: DropTarget,\n types: DragTypes,\n allowedOperations: DropOperation[],\n ): DropOperation;\n /** Check if an item drop should be accepted. */\n shouldAcceptItemDrop(target: ItemDropTarget, types: DragTypes): boolean;\n}\n\n/**\n * Symbol for directory drag type.\n */\nexport const DIRECTORY_DRAG_TYPE: symbol = Symbol(\"directory\");\n\n/**\n * Creates state for accepting drops onto a collection.\n *\n * @param props - Accessor returning droppable collection options\n * @returns Droppable collection state object\n */\nexport function createDroppableCollectionState(\n props: Accessor<DroppableCollectionStateOptions>,\n): DroppableCollectionState {\n const getProps = createMemo(() => props());\n\n const [isDropTarget, setIsDropTarget] = createSignal(false);\n const [target, setTarget] = createSignal<DropTarget | null>(null);\n\n const isAccepted = (types: DragTypes): boolean => {\n const p = getProps();\n const acceptedTypes = p.acceptedDragTypes ?? \"all\";\n\n if (acceptedTypes === \"all\") {\n return true;\n }\n\n for (const type of acceptedTypes) {\n if (types.has(type)) {\n return true;\n }\n }\n\n return false;\n };\n\n const enterTarget = (dropTarget: DropTarget, x: number, y: number) => {\n const p = getProps();\n if (p.isDisabled) return;\n\n setIsDropTarget(true);\n setTarget(dropTarget);\n\n if (typeof p.onDropEnter === \"function\") {\n p.onDropEnter({\n type: \"dropenter\",\n x,\n y,\n target: dropTarget,\n });\n }\n };\n\n const moveToTarget = (dropTarget: DropTarget, x: number, y: number) => {\n const p = getProps();\n if (p.isDisabled) return;\n\n const prevTarget = target();\n setTarget(dropTarget);\n\n // Fire exit/enter events if target changed\n if (prevTarget && !targetsEqual(prevTarget, dropTarget)) {\n if (typeof p.onDropExit === \"function\") {\n p.onDropExit({\n type: \"dropexit\",\n x,\n y,\n target: prevTarget,\n });\n }\n\n if (typeof p.onDropEnter === \"function\") {\n p.onDropEnter({\n type: \"dropenter\",\n x,\n y,\n target: dropTarget,\n });\n }\n }\n };\n\n const exitTarget = (x: number, y: number) => {\n const p = getProps();\n const currentTarget = target();\n\n setIsDropTarget(false);\n setTarget(null);\n\n if (currentTarget && typeof p.onDropExit === \"function\") {\n p.onDropExit({\n type: \"dropexit\",\n x,\n y,\n target: currentTarget,\n });\n }\n };\n\n const activateTarget = (x: number, y: number) => {\n const p = getProps();\n const currentTarget = target();\n if (p.isDisabled || !currentTarget) return;\n\n if (typeof p.onDropActivate === \"function\") {\n p.onDropActivate({\n type: \"dropactivate\",\n x,\n y,\n target: currentTarget,\n });\n }\n };\n\n const drop = (\n items: DropItem[],\n dropOperation: DropOperation,\n isInternal: boolean,\n draggingKeys?: Set<string | number>,\n ) => {\n const p = getProps();\n const currentTarget = target();\n if (p.isDisabled || !currentTarget) return;\n\n setIsDropTarget(false);\n setTarget(null);\n\n // Call the generic onDrop handler\n if (typeof p.onDrop === \"function\") {\n p.onDrop({\n type: \"drop\",\n x: 0,\n y: 0,\n items,\n dropOperation,\n target: currentTarget,\n });\n }\n\n // Call specific handlers based on the drop type\n if (currentTarget.type === \"root\") {\n if (typeof p.onRootDrop === \"function\") {\n p.onRootDrop({\n items,\n dropOperation,\n });\n }\n } else if (currentTarget.type === \"item\") {\n if (isInternal && draggingKeys) {\n // Reorder or move within the same collection\n if (currentTarget.dropPosition === \"on\") {\n if (typeof p.onMove === \"function\") {\n p.onMove({\n keys: draggingKeys,\n dropOperation,\n target: currentTarget,\n });\n }\n } else {\n if (typeof p.onReorder === \"function\") {\n p.onReorder({\n keys: draggingKeys,\n dropOperation,\n target: currentTarget,\n });\n }\n }\n } else {\n // External drop\n if (currentTarget.dropPosition === \"on\") {\n if (typeof p.onItemDrop === \"function\") {\n p.onItemDrop({\n items,\n dropOperation,\n isInternal,\n target: currentTarget,\n });\n }\n } else {\n if (typeof p.onInsert === \"function\") {\n p.onInsert({\n items,\n dropOperation,\n target: currentTarget,\n });\n }\n }\n }\n }\n };\n\n const getDropOperation = (\n dropTarget: DropTarget,\n types: DragTypes,\n allowedOperations: DropOperation[],\n ): DropOperation => {\n const p = getProps();\n\n if (!isAccepted(types)) {\n return \"cancel\";\n }\n\n if (typeof p.getDropOperation === \"function\") {\n return p.getDropOperation(dropTarget, types, allowedOperations);\n }\n\n return allowedOperations[0] ?? \"cancel\";\n };\n\n const shouldAcceptItemDrop = (dropTarget: ItemDropTarget, types: DragTypes): boolean => {\n const p = getProps();\n\n if (!isAccepted(types)) {\n return false;\n }\n\n if (typeof p.shouldAcceptItemDrop === \"function\") {\n return p.shouldAcceptItemDrop(dropTarget, types);\n }\n\n return true;\n };\n\n return {\n get isDropTarget() {\n return isDropTarget();\n },\n get target() {\n return target();\n },\n get isDisabled() {\n return getProps().isDisabled ?? false;\n },\n setTarget,\n isAccepted,\n enterTarget,\n moveToTarget,\n exitTarget,\n activateTarget,\n drop,\n getDropOperation,\n shouldAcceptItemDrop,\n };\n}\n\n/**\n * Check if two drop targets are equal.\n */\nfunction targetsEqual(a: DropTarget, b: DropTarget): boolean {\n if (a.type !== b.type) return false;\n if (a.type === \"root\" && b.type === \"root\") return true;\n if (a.type === \"item\" && b.type === \"item\") {\n return a.key === b.key && a.dropPosition === b.dropPosition;\n }\n return false;\n}\n","/**\n * createListData - SolidJS port of React Spectrum's useListData\n *\n * Manages state for an immutable list data structure, and provides\n * convenience methods to update the data over time.\n */\n\nimport { createSignal, createMemo } from \"solid-js\";\n\nexport type Key = string | number;\nexport type Selection = \"all\" | Set<Key>;\n\nexport interface ListOptions<T> {\n /** Initial items in the list. */\n initialItems?: T[];\n /** The keys for the initially selected items. */\n initialSelectedKeys?: \"all\" | Iterable<Key>;\n /** The initial text to filter the list by. */\n initialFilterText?: string;\n /** A function that returns a unique key for an item object. */\n getKey?: (item: T) => Key;\n /** A function that returns whether an item matches the current filter text. */\n filter?: (item: T, filterText: string) => boolean;\n}\n\nexport interface ListData<T> {\n /** The items in the list. */\n readonly items: T[];\n /** The keys of the currently selected items in the list. */\n readonly selectedKeys: Selection;\n /** The current filter text. */\n readonly filterText: string;\n /** Sets the selected keys. */\n setSelectedKeys(keys: Selection): void;\n /** Adds the given keys to the current selected keys. */\n addKeysToSelection(keys: Selection): void;\n /** Removes the given keys from the current selected keys. */\n removeKeysFromSelection(keys: Selection): void;\n /** Sets the filter text. */\n setFilterText(filterText: string): void;\n /** Gets an item from the list by key. */\n getItem(key: Key): T | undefined;\n /** Inserts items into the list at the given index. */\n insert(index: number, ...values: T[]): void;\n /** Inserts items into the list before the item at the given key. */\n insertBefore(key: Key, ...values: T[]): void;\n /** Inserts items into the list after the item at the given key. */\n insertAfter(key: Key, ...values: T[]): void;\n /** Appends items to the list. */\n append(...values: T[]): void;\n /** Prepends items to the list. */\n prepend(...values: T[]): void;\n /** Removes items from the list by their keys. */\n remove(...keys: Key[]): void;\n /** Removes all items from the list that are currently in the set of selected items. */\n removeSelectedItems(): void;\n /** Moves an item within the list. */\n move(key: Key, toIndex: number): void;\n /** Moves one or more items before a given key. */\n moveBefore(key: Key, keys: Iterable<Key>): void;\n /** Moves one or more items after a given key. */\n moveAfter(key: Key, keys: Iterable<Key>): void;\n /** Updates an item in the list. */\n update(key: Key, newValue: T | ((prev: T) => T)): void;\n}\n\ninterface ListState<T> {\n items: T[];\n selectedKeys: Selection;\n filterText: string;\n}\n\n/**\n * Manages state for an immutable list data structure, and provides\n * convenience methods to update the data over time.\n */\nexport function createListData<T>(options: ListOptions<T>): ListData<T> {\n const defaultGetKey = (item: T): Key => {\n const candidate = item as { id?: Key; key?: Key };\n return candidate.id ?? candidate.key ?? String(item);\n };\n\n const {\n initialItems = [],\n initialSelectedKeys,\n getKey = defaultGetKey,\n filter,\n initialFilterText = \"\",\n } = options;\n\n const [state, setState] = createSignal<ListState<T>>({\n items: initialItems,\n selectedKeys: initialSelectedKeys === \"all\" ? \"all\" : new Set(initialSelectedKeys || []),\n filterText: initialFilterText,\n });\n\n const filteredItems = createMemo(() => {\n const s = state();\n return filter ? s.items.filter((item) => filter(item, s.filterText)) : s.items;\n });\n\n return {\n get items() {\n return filteredItems();\n },\n get selectedKeys() {\n return state().selectedKeys;\n },\n get filterText() {\n return state().filterText;\n },\n\n setSelectedKeys(selectedKeys: Selection) {\n setState((s) => ({ ...s, selectedKeys }));\n },\n\n addKeysToSelection(selectedKeys: Selection) {\n setState((s) => {\n if (s.selectedKeys === \"all\") return s;\n if (selectedKeys === \"all\") return { ...s, selectedKeys: \"all\" };\n return { ...s, selectedKeys: new Set([...s.selectedKeys, ...selectedKeys]) };\n });\n },\n\n removeKeysFromSelection(selectedKeys: Selection) {\n setState((s) => {\n if (selectedKeys === \"all\") return { ...s, selectedKeys: new Set() };\n const selection: Set<Key> =\n s.selectedKeys === \"all\" ? new Set(s.items.map(getKey)) : new Set(s.selectedKeys);\n for (const key of selectedKeys) {\n selection.delete(key);\n }\n return { ...s, selectedKeys: selection };\n });\n },\n\n setFilterText(filterText: string) {\n setState((s) => ({ ...s, filterText }));\n },\n\n getItem(key: Key) {\n return state().items.find((item) => getKey(item) === key);\n },\n\n insert(index: number, ...values: T[]) {\n setState((s) => insertItems(s, index, ...values));\n },\n\n insertBefore(key: Key, ...values: T[]) {\n setState((s) => {\n const index = s.items.findIndex((item) => getKey(item) === key);\n if (index === -1) return s;\n return insertItems(s, index, ...values);\n });\n },\n\n insertAfter(key: Key, ...values: T[]) {\n setState((s) => {\n let index = s.items.findIndex((item) => getKey(item) === key);\n if (index === -1) {\n if (s.items.length === 0) {\n index = 0;\n } else {\n return s;\n }\n }\n return insertItems(s, index + 1, ...values);\n });\n },\n\n prepend(...values: T[]) {\n setState((s) => insertItems(s, 0, ...values));\n },\n\n append(...values: T[]) {\n setState((s) => insertItems(s, s.items.length, ...values));\n },\n\n remove(...keys: Key[]) {\n setState((s) => {\n const keySet = new Set(keys);\n const items = s.items.filter((item) => !keySet.has(getKey(item)));\n let selection: Selection = \"all\";\n if (s.selectedKeys !== \"all\") {\n selection = new Set(s.selectedKeys);\n for (const key of keys) {\n (selection as Set<Key>).delete(key);\n }\n }\n if (items.length === 0) selection = new Set();\n return { ...s, items, selectedKeys: selection };\n });\n },\n\n removeSelectedItems() {\n setState((s) => {\n if (s.selectedKeys === \"all\") {\n return { ...s, items: [], selectedKeys: new Set() };\n }\n const selectedKeys = s.selectedKeys;\n const items = s.items.filter((item) => !selectedKeys.has(getKey(item)));\n return { ...s, items, selectedKeys: new Set() };\n });\n },\n\n move(key: Key, toIndex: number) {\n setState((s) => {\n const index = s.items.findIndex((item) => getKey(item) === key);\n if (index === -1) return s;\n const copy = s.items.slice();\n const [item] = copy.splice(index, 1);\n copy.splice(toIndex, 0, item);\n return { ...s, items: copy };\n });\n },\n\n moveBefore(key: Key, keys: Iterable<Key>) {\n setState((s) => {\n const toIndex = s.items.findIndex((item) => getKey(item) === key);\n if (toIndex === -1) return s;\n const keyArray = Array.isArray(keys) ? keys : [...keys];\n const indices = keyArray\n .map((k) => s.items.findIndex((item) => getKey(item) === k))\n .sort((a, b) => a - b);\n return moveItems(s, indices, toIndex);\n });\n },\n\n moveAfter(key: Key, keys: Iterable<Key>) {\n setState((s) => {\n const toIndex = s.items.findIndex((item) => getKey(item) === key);\n if (toIndex === -1) return s;\n const keyArray = Array.isArray(keys) ? keys : [...keys];\n const indices = keyArray\n .map((k) => s.items.findIndex((item) => getKey(item) === k))\n .sort((a, b) => a - b);\n return moveItems(s, indices, toIndex + 1);\n });\n },\n\n update(key: Key, newValue: T | ((prev: T) => T)) {\n setState((s) => {\n const index = s.items.findIndex((item) => getKey(item) === key);\n if (index === -1) return s;\n const updatedValue =\n typeof newValue === \"function\" ? (newValue as (prev: T) => T)(s.items[index]) : newValue;\n return {\n ...s,\n items: [...s.items.slice(0, index), updatedValue, ...s.items.slice(index + 1)],\n };\n });\n },\n };\n}\n\nfunction insertItems<T>(state: ListState<T>, index: number, ...values: T[]): ListState<T> {\n return {\n ...state,\n items: [...state.items.slice(0, index), ...values, ...state.items.slice(index)],\n };\n}\n\nfunction moveItems<T>(state: ListState<T>, indices: number[], toIndex: number): ListState<T> {\n toIndex -= indices.filter((index) => index < toIndex).length;\n\n const moves = indices.map((from) => ({\n from,\n to: toIndex++,\n }));\n\n for (let i = 0; i < moves.length; i++) {\n const a = moves[i].from;\n for (let j = i; j < moves.length; j++) {\n const b = moves[j].from;\n if (b > a) moves[j].from--;\n }\n }\n\n for (let i = 0; i < moves.length; i++) {\n const a = moves[i];\n for (let j = moves.length - 1; j > i; j--) {\n const b = moves[j];\n if (b.from < a.to) {\n a.to++;\n } else {\n b.from++;\n }\n }\n }\n\n const copy = state.items.slice();\n for (const m of moves) {\n const [item] = copy.splice(m.from, 1);\n copy.splice(m.to, 0, item);\n }\n\n return { ...state, items: copy };\n}\n","/**\n * createTreeData - SolidJS port of React Spectrum's useTreeData\n *\n * Manages state for an immutable tree data structure, and provides\n * convenience methods to update the data over time.\n */\n\nimport { createSignal } from \"solid-js\";\n\nexport type Key = string | number;\nexport type Selection = \"all\" | Set<Key>;\n\nexport interface TreeNode<T> {\n /** A unique key for the tree node. */\n key: Key;\n /** The key of the parent node. */\n parentKey: Key | null;\n /** The value object for the tree node. */\n value: T;\n /** The children of this node. */\n children: TreeNode<T>[] | null;\n}\n\nexport interface TreeOptions<T> {\n /** Initial items in the tree. */\n initialItems?: T[];\n /** The keys for the initially selected items. */\n initialSelectedKeys?: \"all\" | Iterable<Key>;\n /** A function that returns a unique key for an item object. */\n getKey?: (item: T) => Key;\n /** A function that returns the children of an item object. */\n getChildren?: (item: T) => T[];\n}\n\nexport interface TreeData<T> {\n /** The root items in the tree. */\n readonly items: TreeNode<T>[];\n /** The keys of the currently selected items in the tree. */\n readonly selectedKeys: Selection;\n /** Sets the selected keys. */\n setSelectedKeys(keys: Selection): void;\n /** Gets an item from the tree by key. */\n getItem(key: Key): TreeNode<T> | undefined;\n /** Inserts items into the tree. */\n insert(parentKey: Key | null, index: number, ...values: T[]): void;\n /** Inserts items before a given key. */\n insertBefore(key: Key, ...values: T[]): void;\n /** Inserts items after a given key. */\n insertAfter(key: Key, ...values: T[]): void;\n /** Appends items to a parent node. */\n append(parentKey: Key | null, ...values: T[]): void;\n /** Prepends items to a parent node. */\n prepend(parentKey: Key | null, ...values: T[]): void;\n /** Removes items from the tree by their keys. */\n remove(...keys: Key[]): void;\n /** Removes all items from the tree that are currently in the set of selected items. */\n removeSelectedItems(): void;\n /** Moves an item to a new parent. */\n move(key: Key, toParentKey: Key | null, index: number): void;\n /** Moves items before a given key. */\n moveBefore(key: Key, keys: Iterable<Key>): void;\n /** Moves items after a given key. */\n moveAfter(key: Key, keys: Iterable<Key>): void;\n /** Updates an item in the tree. */\n update(key: Key, newValue: T): void;\n}\n\ninterface TreeDataState<T> {\n items: TreeNode<T>[];\n nodeMap: Map<Key, TreeNode<T>>;\n}\n\n/**\n * Manages state for an immutable tree data structure, and provides\n * convenience methods to update the data over time.\n */\nexport function createTreeData<T>(options: TreeOptions<T>): TreeData<T> {\n const defaultGetKey = (item: T): Key => {\n const candidate = item as { id?: Key; key?: Key };\n return candidate.id ?? candidate.key ?? String(item);\n };\n const defaultGetChildren = (item: T): T[] => {\n const candidate = item as { children?: T[] };\n return candidate.children ?? [];\n };\n\n const {\n initialItems = [],\n initialSelectedKeys,\n getKey = defaultGetKey,\n getChildren = defaultGetChildren,\n } = options;\n\n // Build initial tree\n const initialTree = buildTree(initialItems, new Map(), null, getKey, getChildren);\n\n const [treeState, setTreeState] = createSignal<TreeDataState<T>>(initialTree);\n const [selectedKeys, setSelectedKeys] = createSignal<Selection>(\n initialSelectedKeys === \"all\" ? \"all\" : new Set(initialSelectedKeys || []),\n );\n\n function updateTree(\n items: TreeNode<T>[],\n key: Key | null,\n update: (node: TreeNode<T>) => TreeNode<T> | null,\n originalMap: Map<Key, TreeNode<T>>,\n ): TreeDataState<T> {\n let node = key != null ? originalMap.get(key) : null;\n if (key != null && !node) return { items, nodeMap: originalMap };\n\n const newMap = new Map(originalMap);\n\n if (node) {\n const updated = update(node);\n if (!updated) {\n // Delete node\n deleteNode(node, newMap);\n if (node.parentKey != null) {\n return updateTree(\n items,\n node.parentKey,\n (parent) => ({\n ...parent,\n children: parent.children!.filter((c) => c.key !== key),\n }),\n newMap,\n );\n }\n return { items: items.filter((i) => i.key !== key), nodeMap: newMap };\n }\n\n newMap.set(key!, updated);\n if (updated.children) {\n for (const child of updated.children) {\n addNode(child, newMap);\n }\n }\n\n if (node.parentKey != null) {\n return updateTree(\n items,\n node.parentKey,\n (parent) => ({\n ...parent,\n children: parent.children!.map((c) => (c.key === key ? updated : c)),\n }),\n newMap,\n );\n }\n\n return { items: items.map((i) => (i.key === key ? updated : i)), nodeMap: newMap };\n }\n\n return { items, nodeMap: newMap };\n }\n\n return {\n get items() {\n return treeState().items;\n },\n get selectedKeys() {\n return selectedKeys();\n },\n\n setSelectedKeys(keys: Selection) {\n setSelectedKeys(keys);\n },\n\n getItem(key: Key) {\n return treeState().nodeMap.get(key);\n },\n\n insert(parentKey: Key | null, index: number, ...values: T[]) {\n setTreeState((state) => {\n const { items, nodeMap } = state;\n const newMap = new Map(nodeMap);\n const newNodes = values.map((v) => {\n const tree = buildTree([v], newMap, parentKey, getKey, getChildren);\n return tree.items[0];\n });\n\n if (parentKey == null) {\n return {\n items: [...items.slice(0, index), ...newNodes, ...items.slice(index)],\n nodeMap: newMap,\n };\n }\n\n return updateTree(\n items,\n parentKey,\n (parent) => ({\n ...parent,\n children: [\n ...(parent.children || []).slice(0, index),\n ...newNodes,\n ...(parent.children || []).slice(index),\n ],\n }),\n newMap,\n );\n });\n },\n\n insertBefore(key: Key, ...values: T[]) {\n setTreeState((state) => {\n const { items, nodeMap } = state;\n const node = nodeMap.get(key);\n if (!node) return state;\n\n const parent = node.parentKey != null ? nodeMap.get(node.parentKey) : null;\n const siblings = parent?.children ?? items;\n const index = siblings.findIndex((n) => n.key === key);\n if (index === -1) return state;\n\n const newMap = new Map(nodeMap);\n const newNodes = values.map((v) => {\n const tree = buildTree([v], newMap, node.parentKey, getKey, getChildren);\n return tree.items[0];\n });\n\n if (node.parentKey == null) {\n return {\n items: [...items.slice(0, index), ...newNodes, ...items.slice(index)],\n nodeMap: newMap,\n };\n }\n\n return updateTree(\n items,\n node.parentKey,\n (p) => ({\n ...p,\n children: [...p.children!.slice(0, index), ...newNodes, ...p.children!.slice(index)],\n }),\n newMap,\n );\n });\n },\n\n insertAfter(key: Key, ...values: T[]) {\n setTreeState((state) => {\n const { items, nodeMap } = state;\n const node = nodeMap.get(key);\n if (!node) return state;\n\n const parent = node.parentKey != null ? nodeMap.get(node.parentKey) : null;\n const siblings = parent?.children ?? items;\n const index = siblings.findIndex((n) => n.key === key);\n if (index === -1) return state;\n\n const newMap = new Map(nodeMap);\n const newNodes = values.map((v) => {\n const tree = buildTree([v], newMap, node.parentKey, getKey, getChildren);\n return tree.items[0];\n });\n\n if (node.parentKey == null) {\n return {\n items: [...items.slice(0, index + 1), ...newNodes, ...items.slice(index + 1)],\n nodeMap: newMap,\n };\n }\n\n return updateTree(\n items,\n node.parentKey,\n (p) => ({\n ...p,\n children: [\n ...p.children!.slice(0, index + 1),\n ...newNodes,\n ...p.children!.slice(index + 1),\n ],\n }),\n newMap,\n );\n });\n },\n\n append(parentKey: Key | null, ...values: T[]) {\n setTreeState((state) => {\n const { items, nodeMap } = state;\n const newMap = new Map(nodeMap);\n const newNodes = values.map((v) => {\n const tree = buildTree([v], newMap, parentKey, getKey, getChildren);\n return tree.items[0];\n });\n\n if (parentKey == null) {\n return { items: [...items, ...newNodes], nodeMap: newMap };\n }\n\n return updateTree(\n items,\n parentKey,\n (parent) => ({\n ...parent,\n children: [...(parent.children || []), ...newNodes],\n }),\n newMap,\n );\n });\n },\n\n prepend(parentKey: Key | null, ...values: T[]) {\n setTreeState((state) => {\n const { items, nodeMap } = state;\n const newMap = new Map(nodeMap);\n const newNodes = values.map((v) => {\n const tree = buildTree([v], newMap, parentKey, getKey, getChildren);\n return tree.items[0];\n });\n\n if (parentKey == null) {\n return { items: [...newNodes, ...items], nodeMap: newMap };\n }\n\n return updateTree(\n items,\n parentKey,\n (parent) => ({\n ...parent,\n children: [...newNodes, ...(parent.children || [])],\n }),\n newMap,\n );\n });\n },\n\n remove(...keys: Key[]) {\n setTreeState((state) => {\n let { items, nodeMap } = state;\n let newMap = new Map(nodeMap);\n let newItems = items;\n\n for (const key of keys) {\n const result = updateTree(newItems, key, () => null, newMap);\n newItems = result.items;\n newMap = result.nodeMap;\n }\n\n return { items: newItems, nodeMap: newMap };\n });\n\n setSelectedKeys((sel) => {\n if (sel === \"all\") return sel;\n const newSel = new Set(sel);\n for (const key of keys) {\n newSel.delete(key);\n }\n return newSel;\n });\n },\n\n removeSelectedItems() {\n const sel = selectedKeys();\n if (sel === \"all\") {\n setTreeState({ items: [], nodeMap: new Map() });\n setSelectedKeys(new Set<Key>());\n return;\n }\n\n const keysToRemove = [...sel];\n setTreeState((state) => {\n let { items, nodeMap } = state;\n let newMap = new Map(nodeMap);\n let newItems = items;\n for (const key of keysToRemove) {\n const result = updateTree(newItems, key, () => null, newMap);\n newItems = result.items;\n newMap = result.nodeMap;\n }\n return { items: newItems, nodeMap: newMap };\n });\n setSelectedKeys(new Set<Key>());\n },\n\n move(key: Key, toParentKey: Key | null, index: number) {\n setTreeState((state) => {\n const { items, nodeMap } = state;\n const node = nodeMap.get(key);\n if (!node) return state;\n\n // Cyclical move validation: prevent moving a node into its own subtree\n if (toParentKey != null) {\n let parent: TreeNode<T> | undefined = nodeMap.get(toParentKey);\n while (parent) {\n if (parent.key === key) return state;\n parent = parent.parentKey != null ? nodeMap.get(parent.parentKey) : undefined;\n }\n }\n\n // Remove the node\n let newMap = new Map(nodeMap);\n const removeResult = updateTree(items, key, () => null, newMap);\n let newItems = removeResult.items;\n newMap = removeResult.nodeMap;\n\n // Re-add it at the target\n const movedNode: TreeNode<T> = { ...node, parentKey: toParentKey };\n addNode(movedNode, newMap);\n\n if (toParentKey == null) {\n return {\n items: [...newItems.slice(0, index), movedNode, ...newItems.slice(index)],\n nodeMap: newMap,\n };\n }\n\n return updateTree(\n newItems,\n toParentKey,\n (parent) => ({\n ...parent,\n children: [\n ...(parent.children || []).slice(0, index),\n movedNode,\n ...(parent.children || []).slice(index),\n ],\n }),\n newMap,\n );\n });\n },\n\n moveBefore(key: Key, keys: Iterable<Key>) {\n setTreeState((state) => {\n const { items, nodeMap } = state;\n const node = nodeMap.get(key);\n if (!node) return state;\n\n const toParentKey = node.parentKey ?? null;\n let parent: TreeNode<T> | null = null;\n if (toParentKey != null) {\n parent = nodeMap.get(toParentKey) ?? null;\n }\n const toIndex = parent?.children ? parent.children.indexOf(node) : items.indexOf(node);\n return moveItems(state, keys, parent, toIndex, updateTree, addNode);\n });\n },\n\n moveAfter(key: Key, keys: Iterable<Key>) {\n setTreeState((state) => {\n const { items, nodeMap } = state;\n const node = nodeMap.get(key);\n if (!node) return state;\n\n const toParentKey = node.parentKey ?? null;\n let parent: TreeNode<T> | null = null;\n if (toParentKey != null) {\n parent = nodeMap.get(toParentKey) ?? null;\n }\n let toIndex = parent?.children ? parent.children.indexOf(node) : items.indexOf(node);\n toIndex++;\n return moveItems(state, keys, parent, toIndex, updateTree, addNode);\n });\n },\n\n update(key: Key, newValue: T) {\n setTreeState((state) => {\n const { items, nodeMap } = state;\n const newMap = new Map(nodeMap);\n\n return updateTree(\n items,\n key,\n (oldNode) => {\n const node: TreeNode<T> = {\n key: oldNode.key,\n parentKey: oldNode.parentKey,\n value: newValue,\n children: null,\n };\n const tree = buildTree(getChildren(newValue), newMap, node.key, getKey, getChildren);\n node.children = tree.items;\n return node;\n },\n newMap,\n );\n });\n },\n };\n}\n\nfunction buildTree<T>(\n items: T[],\n nodeMap: Map<Key, TreeNode<T>>,\n parentKey: Key | null,\n getKey: (item: T) => Key,\n getChildren: (item: T) => T[],\n): TreeDataState<T> {\n const nodes: TreeNode<T>[] = [];\n\n for (const item of items) {\n const key = getKey(item);\n const children = getChildren(item);\n\n const childTree =\n children.length > 0\n ? buildTree(children, nodeMap, key, getKey, getChildren)\n : { items: [], nodeMap };\n\n const node: TreeNode<T> = {\n key,\n parentKey,\n value: item,\n children: childTree.items.length > 0 ? childTree.items : null,\n };\n\n nodeMap.set(key, node);\n nodes.push(node);\n }\n\n return { items: nodes, nodeMap };\n}\n\nfunction addNode<T>(node: TreeNode<T>, map: Map<Key, TreeNode<T>>): void {\n map.set(node.key, node);\n if (node.children) {\n for (const child of node.children) {\n addNode(child, map);\n }\n }\n}\n\nfunction deleteNode<T>(node: TreeNode<T>, map: Map<Key, TreeNode<T>>): void {\n map.delete(node.key);\n if (node.children) {\n for (const child of node.children) {\n deleteNode(child, map);\n }\n }\n}\n\nfunction moveItems<T>(\n state: TreeDataState<T>,\n keys: Iterable<Key>,\n toParent: TreeNode<T> | null,\n toIndex: number,\n updateTreeFn: (\n items: TreeNode<T>[],\n key: Key | null,\n update: (node: TreeNode<T>) => TreeNode<T> | null,\n originalMap: Map<Key, TreeNode<T>>,\n ) => TreeDataState<T>,\n addNodeFn: (node: TreeNode<T>, map: Map<Key, TreeNode<T>>) => void,\n): TreeDataState<T> {\n const { items, nodeMap } = state;\n\n // Cyclical move validation: prevent moving a node into its own subtree\n const removeKeys = new Set(keys);\n let ancestor: TreeNode<T> | null = toParent;\n while (ancestor != null) {\n if (removeKeys.has(ancestor.key)) {\n throw new Error(\"Cannot move an item to be a child of itself.\");\n }\n ancestor = ancestor.parentKey != null ? (nodeMap.get(ancestor.parentKey) ?? null) : null;\n }\n\n const originalToIndex = toIndex;\n const keyArray = [...removeKeys];\n\n // Depth-first traversal to determine in-order positions and remove items\n const inOrderKeys = new Map<Key, number>();\n const removedItems: TreeNode<T>[] = [];\n let newItems = items;\n let newMap = nodeMap;\n let i = 0;\n\n function traversal(\n node: { children?: TreeNode<T>[] | null },\n callbacks: {\n inorder?: (child: TreeNode<T>) => void;\n postorder?: (child: TreeNode<T>) => void;\n },\n ) {\n callbacks.inorder?.(node as TreeNode<T>);\n if (node.children) {\n for (const child of node.children) {\n traversal(child, callbacks);\n callbacks.postorder?.(child);\n }\n }\n }\n\n traversal(\n { children: items },\n {\n inorder(child) {\n if (keyArray.includes(child.key)) {\n inOrderKeys.set(child.key, i++);\n }\n },\n postorder(child) {\n if (keyArray.includes(child.key)) {\n removedItems.push({ ...newMap.get(child.key)!, parentKey: toParent?.key ?? null });\n const result = updateTreeFn(newItems, child.key, () => null, newMap);\n newItems = result.items;\n newMap = result.nodeMap;\n }\n // Decrement index if the removed child is in the target parent and before the target index\n if (\n (child.parentKey === toParent || child.parentKey === toParent?.key) &&\n keyArray.includes(child.key) &&\n (toParent?.children ? toParent.children.indexOf(child) : items.indexOf(child)) <\n originalToIndex\n ) {\n toIndex--;\n }\n },\n },\n );\n\n const inOrderItems = removedItems.sort((a, b) =>\n inOrderKeys.get(a.key)! > inOrderKeys.get(b.key)! ? 1 : -1,\n );\n\n // If parentKey is null, insert into the root.\n if (!toParent || toParent.key == null) {\n inOrderItems.forEach((movedNode) => {\n addNodeFn(movedNode, newMap);\n });\n return {\n items: [...newItems.slice(0, toIndex), ...inOrderItems, ...newItems.slice(toIndex)],\n nodeMap: newMap,\n };\n }\n\n // Otherwise, update the parent node and its ancestors.\n return updateTreeFn(\n newItems,\n toParent.key,\n (parentNode) => ({\n key: parentNode.key,\n parentKey: parentNode.parentKey,\n value: parentNode.value,\n children: [\n ...parentNode.children!.slice(0, toIndex),\n ...inOrderItems,\n ...parentNode.children!.slice(toIndex),\n ],\n }),\n newMap,\n );\n}\n","/**\n * createAsyncList - SolidJS port of React Spectrum's useAsyncList\n *\n * Manages state for an immutable async loaded list data structure, and provides\n * convenience methods to update the data over time. Manages loading and error\n * states, pagination, and sorting.\n */\n\nimport { createSignal, untrack } from \"solid-js\";\n\nexport type Key = string | number;\nexport type Selection = \"all\" | Set<Key>;\nexport type LoadingState = \"idle\" | \"loading\" | \"loadingMore\" | \"sorting\" | \"filtering\" | \"error\";\n\nexport interface SortDescriptor {\n /** The key of the column to sort by. */\n column?: Key;\n /** The direction to sort by. */\n direction?: \"ascending\" | \"descending\";\n}\n\nexport interface AsyncListLoadOptions<T, C> {\n /** The items currently in the list. */\n items: T[];\n /** The keys of the currently selected items in the list. */\n selectedKeys: Selection;\n /** The current sort descriptor for the list. */\n sortDescriptor?: SortDescriptor;\n /** An abort signal used to notify the load function that the request has been aborted. */\n signal: AbortSignal;\n /** The pagination cursor returned from the last page load. */\n cursor?: C;\n /** The current filter text used to perform server side filtering. */\n filterText?: string;\n /** The current loading state of the list. */\n loadingState?: LoadingState;\n}\n\nexport interface AsyncListStateUpdate<T, C> {\n /** The new items to append to the list. */\n items: Iterable<T>;\n /** The keys to add to the selection. */\n selectedKeys?: Iterable<Key>;\n /** The sort descriptor to set. */\n sortDescriptor?: SortDescriptor;\n /** The pagination cursor to be used for the next page load. */\n cursor?: C;\n /** The updated filter text for the list. */\n filterText?: string;\n}\n\nexport type AsyncListLoadFunction<T, C> = (\n state: AsyncListLoadOptions<T, C>,\n) => AsyncListStateUpdate<T, C> | Promise<AsyncListStateUpdate<T, C>>;\n\nexport interface AsyncListOptions<T, C> {\n /** The keys for the initially selected items. */\n initialSelectedKeys?: \"all\" | Iterable<Key>;\n /** The initial sort descriptor. */\n initialSortDescriptor?: SortDescriptor;\n /** The initial filter text. */\n initialFilterText?: string;\n /** A function that returns a unique key for an item object. */\n getKey?: (item: T) => Key;\n /** A function that loads the data for the items in the list. */\n load: AsyncListLoadFunction<T, C>;\n /** An optional function that performs sorting. */\n sort?: AsyncListLoadFunction<T, C>;\n}\n\nexport interface AsyncListData<T> {\n /** The items in the list. */\n readonly items: T[];\n /** The keys of the currently selected items in the list. */\n readonly selectedKeys: Selection;\n /** The current sort descriptor for the list. */\n readonly sortDescriptor: SortDescriptor | undefined;\n /** Whether data is currently being loaded. */\n readonly isLoading: boolean;\n /** If loading data failed, then this contains the error that occurred. */\n readonly error: Error | undefined;\n /** The current filter text. */\n readonly filterText: string;\n /** The current loading state for the list. */\n readonly loadingState: LoadingState;\n\n /** Reloads the data in the list. */\n reload(): void;\n /** Loads the next page of data in the list. */\n loadMore(): void;\n /** Triggers sorting for the list. */\n sort(descriptor: SortDescriptor): void;\n\n /** Sets the selected keys. */\n setSelectedKeys(keys: Selection): void;\n /** Sets the filter text. */\n setFilterText(filterText: string): void;\n\n /** Gets an item from the list by key. */\n getItem(key: Key): T | undefined;\n /** Inserts items into the list at the given index. */\n insert(index: number, ...values: T[]): void;\n /** Inserts items before a given key. */\n insertBefore(key: Key, ...values: T[]): void;\n /** Inserts items after a given key. */\n insertAfter(key: Key, ...values: T[]): void;\n /** Appends items to the list. */\n append(...values: T[]): void;\n /** Prepends items to the list. */\n prepend(...values: T[]): void;\n /** Removes items from the list by their keys. */\n remove(...keys: Key[]): void;\n /** Removes all items from the list that are currently in the set of selected items. */\n removeSelectedItems(): void;\n /** Moves an item within the list. */\n move(key: Key, toIndex: number): void;\n /** Updates an item in the list. */\n update(key: Key, newValue: T): void;\n}\n\ninterface InternalState<T, C> {\n loadingState: LoadingState;\n items: T[];\n selectedKeys: Selection;\n sortDescriptor?: SortDescriptor;\n error?: Error;\n cursor?: C;\n filterText: string;\n abortController?: AbortController;\n}\n\n/**\n * Manages state for an immutable async loaded list data structure, and provides\n * convenience methods to update the data over time. Manages loading and error\n * states, pagination, and sorting.\n */\nexport function createAsyncList<T, C = string>(options: AsyncListOptions<T, C>): AsyncListData<T> {\n const defaultGetKey = (item: T): Key => {\n const candidate = item as { id?: Key; key?: Key };\n return candidate.id ?? candidate.key ?? String(item);\n };\n\n const {\n load,\n sort: sortFn,\n initialSelectedKeys,\n initialSortDescriptor,\n getKey = defaultGetKey,\n initialFilterText = \"\",\n } = options;\n\n const [state, setState] = createSignal<InternalState<T, C>>({\n loadingState: \"idle\",\n items: [],\n selectedKeys: initialSelectedKeys === \"all\" ? \"all\" : new Set(initialSelectedKeys || []),\n sortDescriptor: initialSortDescriptor,\n filterText: initialFilterText,\n });\n\n async function dispatchFetch(\n type: \"loading\" | \"loadingMore\" | \"sorting\" | \"filtering\",\n fn: AsyncListLoadFunction<T, C>,\n opts?: { sortDescriptor?: SortDescriptor; filterText?: string },\n ) {\n const abortController = new AbortController();\n const currentState = untrack(state);\n\n // Update to loading state\n setState((s) => {\n // Abort previous request if one is in progress\n if (s.abortController) {\n s.abortController.abort();\n }\n return {\n ...s,\n loadingState: type,\n items: type === \"loading\" ? [] : s.items,\n sortDescriptor: opts?.sortDescriptor ?? s.sortDescriptor,\n filterText: opts?.filterText ?? s.filterText,\n abortController,\n };\n });\n\n try {\n const previousFilterText = opts?.filterText ?? currentState.filterText;\n const response = await fn({\n items: currentState.items.slice(),\n selectedKeys: currentState.selectedKeys,\n sortDescriptor: opts?.sortDescriptor ?? currentState.sortDescriptor,\n signal: abortController.signal,\n cursor: type === \"loadingMore\" ? currentState.cursor : undefined,\n filterText: previousFilterText,\n loadingState: currentState.loadingState,\n });\n\n setState((s) => {\n // Ignore stale response\n if (s.abortController !== abortController) return s;\n\n const newItems = [...(response.items ?? [])];\n const items = type === \"loadingMore\" ? [...s.items, ...newItems] : newItems;\n\n let selectedKeys: Selection;\n if (type === \"loadingMore\") {\n selectedKeys =\n s.selectedKeys === \"all\" || response.selectedKeys === \"all\"\n ? \"all\"\n : new Set([...(s.selectedKeys as Set<Key>), ...(response.selectedKeys ?? [])]);\n } else {\n selectedKeys = response.selectedKeys\n ? response.selectedKeys === \"all\"\n ? \"all\"\n : new Set(response.selectedKeys)\n : s.selectedKeys;\n }\n\n return {\n ...s,\n loadingState: \"idle\",\n items,\n selectedKeys,\n sortDescriptor: response.sortDescriptor ?? s.sortDescriptor,\n cursor: response.cursor as C | undefined,\n filterText: response.filterText ?? s.filterText,\n error: undefined,\n abortController: undefined,\n };\n });\n\n // Trigger another filter if filterText changed in the response\n const responseFilterText = response.filterText ?? previousFilterText;\n if (\n responseFilterText &&\n responseFilterText !== previousFilterText &&\n !abortController.signal.aborted\n ) {\n dispatchFetch(\"filtering\", load, { filterText: responseFilterText });\n }\n } catch (e) {\n setState((s) => {\n if (s.abortController !== abortController) return s;\n return {\n ...s,\n loadingState: \"error\",\n error: e as Error,\n abortController: undefined,\n };\n });\n }\n }\n\n // Trigger initial load immediately\n dispatchFetch(\"loading\", load);\n\n return {\n get items() {\n return state().items;\n },\n get selectedKeys() {\n return state().selectedKeys;\n },\n get sortDescriptor() {\n return state().sortDescriptor;\n },\n get isLoading() {\n const ls = state().loadingState;\n return ls === \"loading\" || ls === \"loadingMore\" || ls === \"sorting\" || ls === \"filtering\";\n },\n get error() {\n return state().error;\n },\n get filterText() {\n return state().filterText;\n },\n get loadingState() {\n return state().loadingState;\n },\n\n reload() {\n dispatchFetch(\"loading\", load);\n },\n\n loadMore() {\n const s = state();\n if (\n s.loadingState === \"loading\" ||\n s.loadingState === \"loadingMore\" ||\n s.loadingState === \"filtering\" ||\n s.cursor == null\n ) {\n return;\n }\n dispatchFetch(\"loadingMore\", load);\n },\n\n sort(descriptor: SortDescriptor) {\n dispatchFetch(\"sorting\", (sortFn || load) as AsyncListLoadFunction<T, C>, {\n sortDescriptor: descriptor,\n });\n },\n\n setSelectedKeys(keys: Selection) {\n setState((s) => ({ ...s, selectedKeys: keys }));\n },\n\n setFilterText(filterText: string) {\n dispatchFetch(\"filtering\", load, { filterText });\n },\n\n getItem(key: Key) {\n return state().items.find((item) => getKey(item) === key);\n },\n\n insert(index: number, ...values: T[]) {\n setState((s) => ({\n ...s,\n items: [...s.items.slice(0, index), ...values, ...s.items.slice(index)],\n }));\n },\n\n insertBefore(key: Key, ...values: T[]) {\n setState((s) => {\n const index = s.items.findIndex((item) => getKey(item) === key);\n if (index === -1) return s;\n return {\n ...s,\n items: [...s.items.slice(0, index), ...values, ...s.items.slice(index)],\n };\n });\n },\n\n insertAfter(key: Key, ...values: T[]) {\n setState((s) => {\n const index = s.items.findIndex((item) => getKey(item) === key);\n if (index === -1) return s;\n return {\n ...s,\n items: [...s.items.slice(0, index + 1), ...values, ...s.items.slice(index + 1)],\n };\n });\n },\n\n append(...values: T[]) {\n setState((s) => ({ ...s, items: [...s.items, ...values] }));\n },\n\n prepend(...values: T[]) {\n setState((s) => ({ ...s, items: [...values, ...s.items] }));\n },\n\n remove(...keys: Key[]) {\n setState((s) => {\n const keySet = new Set(keys);\n const items = s.items.filter((item) => !keySet.has(getKey(item)));\n let selectedKeys = s.selectedKeys;\n if (selectedKeys !== \"all\") {\n const newSelection = new Set(selectedKeys);\n for (const key of keys) {\n newSelection.delete(key);\n }\n selectedKeys = newSelection;\n }\n return { ...s, items, selectedKeys };\n });\n },\n\n removeSelectedItems() {\n setState((s) => {\n if (s.selectedKeys === \"all\") {\n return { ...s, items: [], selectedKeys: new Set() };\n }\n const sel = s.selectedKeys;\n return {\n ...s,\n items: s.items.filter((item) => !sel.has(getKey(item))),\n selectedKeys: new Set(),\n };\n });\n },\n\n move(key: Key, toIndex: number) {\n setState((s) => {\n const index = s.items.findIndex((item) => getKey(item) === key);\n if (index === -1) return s;\n const copy = s.items.slice();\n const [item] = copy.splice(index, 1);\n copy.splice(toIndex, 0, item);\n return { ...s, items: copy };\n });\n },\n\n update(key: Key, newValue: T) {\n setState((s) => {\n const index = s.items.findIndex((item) => getKey(item) === key);\n if (index === -1) return s;\n return {\n ...s,\n items: [...s.items.slice(0, index), newValue, ...s.items.slice(index + 1)],\n };\n });\n },\n };\n}\n","/**\n * getColorChannels - Standalone function to get color channels for a color space.\n *\n * Returns the three channels for a given color space.\n */\n\nimport type { ColorChannel, ColorSpace } from \"./types\";\n\nconst COLOR_SPACE_CHANNELS: Record<ColorSpace, [ColorChannel, ColorChannel, ColorChannel]> = {\n rgb: [\"red\", \"green\", \"blue\"],\n hsl: [\"hue\", \"saturation\", \"lightness\"],\n hsb: [\"hue\", \"saturation\", \"brightness\"],\n};\n\n/**\n * Returns the color channels for a given color space.\n *\n * @param colorSpace - The color space to get channels for.\n * @returns A tuple of three color channels.\n *\n * @example\n * ```ts\n * getColorChannels('rgb') // ['red', 'green', 'blue']\n * getColorChannels('hsl') // ['hue', 'saturation', 'lightness']\n * getColorChannels('hsb') // ['hue', 'saturation', 'brightness']\n * ```\n */\nexport function getColorChannels(\n colorSpace: ColorSpace,\n): [ColorChannel, ColorChannel, ColorChannel] {\n const channels = COLOR_SPACE_CHANNELS[colorSpace];\n if (!channels) {\n throw new Error(`Unknown color space: ${colorSpace}`);\n }\n return channels;\n}\n","/**\n * State management for step list components.\n * Tracks selected step, completion status, and selectability.\n */\n\nimport { createMemo, createSignal, type Accessor } from \"solid-js\";\nimport type { Key } from \"../collections/types\";\n\nexport interface StepListStateProps {\n /** The currently selected step key (controlled). */\n selectedKey?: Key;\n /** The default selected step key (uncontrolled). */\n defaultSelectedKey?: Key;\n /** Called when the selected step changes. */\n onSelectionChange?: (key: Key) => void;\n /** The last completed step key (controlled). */\n lastCompletedStep?: Key;\n /** The default last completed step key (uncontrolled). */\n defaultLastCompletedStep?: Key;\n /** Called when last completed step changes. */\n onLastCompletedStepChange?: (key: Key | null) => void;\n /** Whether all steps are disabled. */\n isDisabled?: boolean;\n /** Whether all steps are read-only. */\n isReadOnly?: boolean;\n /** Keys of individually disabled steps. */\n disabledKeys?: Iterable<Key>;\n /** The step items. */\n items: Array<{ key: Key; [key: string]: any }>;\n}\n\nexport interface StepListState {\n readonly selectedKey: Accessor<Key | null>;\n readonly lastCompletedStep: Accessor<Key | null>;\n readonly items: Accessor<Array<{ key: Key }>>;\n setSelectedKey(key: Key): void;\n setLastCompletedStep(key: Key): void;\n isCompleted(key: Key): boolean;\n isSelectable(key: Key): boolean;\n isDisabled: Accessor<boolean>;\n isReadOnly: Accessor<boolean>;\n}\n\n/**\n * Creates state for a step list component.\n */\nexport function createStepListState(props: StepListStateProps): StepListState {\n const items = () => props.items;\n\n // Build an index map: Key -> index\n const indexMap = createMemo(() => {\n const map = new Map<Key, number>();\n const currentItems = items();\n for (let i = 0; i < currentItems.length; i++) {\n map.set(currentItems[i].key, i);\n }\n return map;\n });\n\n // Disabled keys set\n const disabledKeysSet = createMemo(() => new Set<Key>(props.disabledKeys ?? []));\n\n const isDisabled: Accessor<boolean> = () => props.isDisabled ?? false;\n const isReadOnly: Accessor<boolean> = () => props.isReadOnly ?? false;\n\n // Last completed step signal (uncontrolled)\n const [lastCompletedStepInternal, setLastCompletedStepInternal] = createSignal<Key | null>(\n props.defaultLastCompletedStep ?? null,\n );\n\n const lastCompletedStep: Accessor<Key | null> = () => {\n if (props.lastCompletedStep !== undefined) {\n return props.lastCompletedStep;\n }\n return lastCompletedStepInternal();\n };\n\n const setLastCompletedStep = (key: Key) => {\n const currentIndex = indexMap().get(key);\n const prevIndex = lastCompletedStep() !== null ? indexMap().get(lastCompletedStep()!) : -1;\n\n // Only advance completion, never go back\n if (\n currentIndex !== undefined &&\n (prevIndex === undefined || currentIndex > (prevIndex ?? -1))\n ) {\n if (props.lastCompletedStep === undefined) {\n setLastCompletedStepInternal(key);\n }\n props.onLastCompletedStepChange?.(key);\n }\n };\n\n const isCompleted = (key: Key): boolean => {\n const completed = lastCompletedStep();\n if (completed === null) return false;\n const keyIndex = indexMap().get(key);\n const completedIndex = indexMap().get(completed);\n if (keyIndex === undefined || completedIndex === undefined) return false;\n return keyIndex <= completedIndex;\n };\n\n const isStepDisabled = (key: Key): boolean => {\n if (isDisabled()) return true;\n return disabledKeysSet().has(key);\n };\n\n const isSelectable = (key: Key): boolean => {\n if (isDisabled() || isReadOnly() || isStepDisabled(key)) return false;\n // Completed steps are always selectable\n if (isCompleted(key)) return true;\n // First step is always selectable\n const keyIndex = indexMap().get(key);\n if (keyIndex === 0) return true;\n // A step is selectable if the previous step is completed OR is the currently selected step\n const currentItems = items();\n if (keyIndex !== undefined && keyIndex > 0) {\n const prevKey = currentItems[keyIndex - 1].key;\n if (isCompleted(prevKey)) return true;\n // Allow advancing to the step immediately after the selected step\n if (prevKey === selectedKey()) return true;\n }\n return false;\n };\n\n // Find the first selectable non-completed step\n const findDefaultSelectedKey = (): Key | null => {\n const currentItems = items();\n for (const item of currentItems) {\n if (!isCompleted(item.key) && !isStepDisabled(item.key)) {\n return item.key;\n }\n }\n // All completed - select first non-disabled\n for (const item of currentItems) {\n if (!isStepDisabled(item.key)) {\n return item.key;\n }\n }\n return currentItems.length > 0 ? currentItems[0].key : null;\n };\n\n // Selected key signal (uncontrolled)\n const [selectedKeyInternal, setSelectedKeyInternal] = createSignal<Key | null>(\n props.defaultSelectedKey ?? findDefaultSelectedKey(),\n );\n\n const selectedKey: Accessor<Key | null> = () => {\n if (props.selectedKey !== undefined) {\n return props.selectedKey;\n }\n return selectedKeyInternal();\n };\n\n const setSelectedKey = (key: Key) => {\n if (isReadOnly() || isDisabled()) return;\n if (!isSelectable(key)) return;\n\n // Mark previous selected step as completed if advancing\n const currentSelected = selectedKey();\n if (currentSelected !== null) {\n const currentIndex = indexMap().get(currentSelected);\n const newIndex = indexMap().get(key);\n if (\n currentIndex !== undefined &&\n newIndex !== undefined &&\n newIndex > currentIndex &&\n !isCompleted(currentSelected)\n ) {\n setLastCompletedStep(currentSelected);\n }\n }\n\n if (props.selectedKey === undefined) {\n setSelectedKeyInternal(key);\n }\n props.onSelectionChange?.(key);\n };\n\n return {\n selectedKey,\n lastCompletedStep,\n items,\n setSelectedKey,\n setLastCompletedStep,\n isCompleted,\n isSelectable,\n isDisabled,\n isReadOnly,\n };\n}\n"],"mappings":";;;;;;;;;;;AAqBA,SAAgB,OAAU,OAA4B;CACpD,OAAO,OAAO,UAAU,aAAc,MAAsB,IAAI;AAClE;;;;AAUA,SAAgB,WAAc,OAA+C;CAC3E,OAAO,OAAO,UAAU;AAC1B;;;;;;;;;;;;;ACCA,SAAgB,kBAAkB,QAA2C,CAAC,GAAgB;CAC5F,MAAM,iBAAiB,OAAO,KAAK;CAEnC,MAAM,eAAe,SAAS;CAC9B,MAAM,kBAAkB,aAAa,cAAc,aAAa,mBAAmB;CAEnF,MAAM,CAAC,kBAAkB,uBAAuB,aAAa,eAAe;CAE5E,MAAM,qBAAqB,SAAS,CAAC,CAAC,eAAe,KAAA;CAErD,MAAM,mBAAsC;EAC1C,MAAM,IAAI,SAAS;EACnB,OAAO,aAAa,IAAK,EAAE,cAAc,QAAS,iBAAiB;CACrE;CAEA,SAAS,YAAY,OAAsB;EACzC,MAAM,IAAI,SAAS;EACnB,IAAI,EAAE,YACJ;EAGF,IAAI,CAAC,aAAa,GAChB,oBAAoB,KAAK;EAG3B,EAAE,WAAW,KAAK;CACpB;CAEA,SAAS,SAAe;EAEtB,IADU,SACN,CAAC,CAAC,YACJ;EAGF,YAAY,CAAC,WAAW,CAAC;CAC3B;CAEA,OAAO;EACL;EACA,iBAAiB,aAAa,mBAAmB;EACjD;EACA;CACF;AACF;;;;;;;;;;;ACjCA,SAAS,SAAS,MAAgC;CAChD,OAAO,IAAI,IAAI,OAAO,MAAM,KAAK,IAAI,IAAI,CAAC,CAAC;AAC7C;;;;AAKA,SAAgB,uBACd,Q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Aa;EACnC,IAAI,WAAW,KAAK,WAAW,GAAG;EAClC,IAAI,CAAC,aAAa,GAAG,GAAG;EAGxB,MAAM,kBAAkB,YAAY;EACpC,IAAI,oBAAoB,MAAM;GAC5B,MAAM,eAAe,SAAS,CAAC,CAAC,IAAI,eAAe;GACnD,MAAM,WAAW,SAAS,CAAC,CAAC,IAAI,GAAG;GACnC,IACE,iBAAiB,KAAA,KACjB,aAAa,KAAA,KACb,WAAW,gBACX,CAAC,YAAY,eAAe,GAE5B,qBAAqB,eAAe;EAExC;EAEA,IAAI,MAAM,gBAAgB,KAAA,GACxB,uBAAuB,GAAG;EAE5B,MAAM,oBAAoB,GAAG;CAC/B;CAEA,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["getValidationResult","_isServer","getInitialSelection","normalizeSelection","SelectionClass","dayOfWeekNames","getLocalTimeZone","DateFormatter","intlCreateCalendar","intlToCalendar","toCalendarDate","startOfMonth","endOfMonth","today","startOfWeek","convertValue","isSameDay","isSameMonth","getWeeksInMonth","intlToCalendarDate","GregorianCalendar","DEFAULT_LOCALE","intlCreateCalendar","DateFormatter","convertValue","toCalendar","GregorianCalendar","now","getLocalTimeZone","toCalendarDate","toCalendarDateTime","getLocalTimeZone","DateFormatter","intlCreateCalendar","intlToCalendar","toCalendarDate","maxDate","minDate","endOfMonth","startOfMonth","today","startOfWeek","convertValue","isSameDay","isSameMonth","getWeeksInMonth","intlToCalendarDate","GregorianCalendar","today","getLocalTimeZone","toCalendarDateTime","toZoned","toTime","GregorianCalendar","getLocalTimeZone","toCalendarDate","toCalendarDateTime","toZoned","DateFormatter","clamp","snapToStep","clamp","getInitialSelection","normalizeSelection","moveItems","candidate"],"sources":["../src/utils/reactivity.ts","../src/toggle/createToggleState.ts","../src/toggle/createToggleGroupState.ts","../src/autocomplete/createAutocompleteState.ts","../src/textfield/createTextFieldState.ts","../src/form/createFormValidationState.ts","../src/checkbox/createCheckboxGroupState.ts","../src/ssr/index.ts","../src/radio/createRadioGroupState.ts","../src/overlays/createOverlayTriggerState.ts","../src/collections/ListCollection.ts","../src/collections/getChildNodes.ts","../src/collections/createSelectionState.ts","../src/selection/Selection.ts","../src/selection/createMultipleSelectionState.ts","../src/selection/SelectionManager.ts","../src/collections/createListState.ts","../src/collections/createMenuState.ts","../src/calendar/createCalendarState.ts","../src/calendar/IncompleteDate.ts","../src/calendar/intl/index.ts","../src/calendar/createDateFieldState.ts","../src/calendar/createRangeCalendarState.ts","../src/calendar/createTimeFieldState.ts","../src/calendar/createDatePickerState.ts","../src/select/createSelectState.ts","../src/combobox/createComboBoxState.ts","../src/tabs/createTabListState.ts","../src/numberfield/createNumberFieldState.ts","../src/searchfield/createSearchFieldState.ts","../src/slider/createSliderState.ts","../src/tooltip/createTooltipTriggerState.ts","../src/toast/createToastState.ts","../src/disclosure/createDisclosureState.ts","../src/grid/createGridState.ts","../src/table/createTableState.ts","../src/table/TableCollection.ts","../src/table/createTreeGridState.ts","../src/table/createTableColumnResizeState.ts","../src/tree/createTreeState.ts","../src/tree/TreeCollection.ts","../src/color/intl/index.ts","../src/color/Color.ts","../src/color/createColorSliderState.ts","../src/color/createColorAreaState.ts","../src/color/createColorWheelState.ts","../src/color/createColorFieldState.ts","../src/dnd/createDragState.ts","../src/dnd/createDropState.ts","../src/dnd/createDraggableCollectionState.ts","../src/dnd/createDroppableCollectionState.ts","../src/data/createListData.ts","../src/data/createTreeData.ts","../src/data/createAsyncList.ts","../src/color/getColorChannels.ts","../src/steplist/createStepListState.ts"],"sourcesContent":["/**\n * Reactivity utilities for Solid Stately\n *\n * Provides type-safe utilities for working with SolidJS reactivity patterns.\n */\n\nimport { Accessor } from \"solid-js\";\n\n/**\n * A value that may be either a raw value or an accessor function.\n * This is a common pattern in SolidJS for props that may be reactive.\n */\nexport type MaybeAccessor<T> = T | Accessor<T>;\n\n/**\n * Unwraps a MaybeAccessor to get the underlying value.\n * If the input is a function, it calls it to get the value.\n * Otherwise, it returns the value directly.\n *\n * @param value - The value or accessor to unwrap.\n */\nexport function access<T>(value: MaybeAccessor<T>): T {\n return typeof value === \"function\" ? (value as Accessor<T>)() : value;\n}\n\n/**\n * A value that may be undefined or an accessor that returns the value or undefined.\n */\nexport type MaybeAccessorValue<T> = T | undefined | Accessor<T | undefined>;\n\n/**\n * Checks if a value is an accessor function.\n */\nexport function isAccessor<T>(value: MaybeAccessor<T>): value is Accessor<T> {\n return typeof value === \"function\";\n}\n","/**\n * Toggle state for Solid Stately\n *\n * Provides state management for toggle components like checkboxes and switches.\n *\n * This is a 1:1 port of @react-stately/toggle's useToggleState.\n */\n\nimport { createSignal, Accessor } from \"solid-js\";\nimport { type MaybeAccessor, access } from \"../utils\";\n\nexport interface ToggleStateOptions {\n /** Whether the element should be selected (controlled). */\n isSelected?: boolean;\n /** Whether the element should be selected by default (uncontrolled). */\n defaultSelected?: boolean;\n /** Handler that is called when the element's selection state changes. */\n onChange?: (isSelected: boolean) => void;\n /** Whether the element is read only. */\n isReadOnly?: boolean;\n}\n\nexport interface ToggleState {\n /** Whether the toggle is selected. */\n readonly isSelected: Accessor<boolean>;\n /** Whether the toggle is selected by default. */\n readonly defaultSelected: boolean;\n /** Updates selection state. */\n setSelected(isSelected: boolean): void;\n /** Toggle the selection state. */\n toggle(): void;\n}\n\n/**\n * Provides state management for toggle components like checkboxes and switches.\n */\nexport function createToggleState(props: MaybeAccessor<ToggleStateOptions> = {}): ToggleState {\n const getProps = () => access(props);\n\n const initialProps = getProps();\n const initialSelected = initialProps.isSelected ?? initialProps.defaultSelected ?? false;\n\n const [internalSelected, setInternalSelected] = createSignal(initialSelected);\n\n const isControlled = () => getProps().isSelected !== undefined;\n\n const isSelected: Accessor<boolean> = () => {\n const p = getProps();\n return isControlled() ? (p.isSelected ?? false) : internalSelected();\n };\n\n function setSelected(value: boolean): void {\n const p = getProps();\n if (p.isReadOnly) {\n return;\n }\n\n if (!isControlled()) {\n setInternalSelected(value);\n }\n\n p.onChange?.(value);\n }\n\n function toggle(): void {\n const p = getProps();\n if (p.isReadOnly) {\n return;\n }\n\n setSelected(!isSelected());\n }\n\n return {\n isSelected,\n defaultSelected: initialProps.defaultSelected ?? initialSelected,\n setSelected,\n toggle,\n };\n}\n","/**\n * Toggle group state for Solid Stately\n *\n * Provides state management for groups of toggle buttons with\n * single or multiple selection.\n *\n * This is a port of @react-stately/toggle's useToggleGroupState.\n */\n\nimport { createSignal } from \"solid-js\";\nimport type { Key } from \"../collections\";\nimport { type MaybeAccessor, access } from \"../utils\";\n\nexport interface ToggleGroupProps {\n /**\n * Whether single or multiple selection is enabled.\n * @default 'single'\n */\n selectionMode?: \"single\" | \"multiple\";\n /** Whether empty selection is disallowed. */\n disallowEmptySelection?: boolean;\n /** Controlled selected keys. */\n selectedKeys?: Iterable<Key>;\n /** Uncontrolled initial selected keys. */\n defaultSelectedKeys?: Iterable<Key>;\n /** Called when selected keys change. */\n onSelectionChange?: (keys: Set<Key>) => void;\n /** Whether all items are disabled. */\n isDisabled?: boolean;\n}\n\nexport interface ToggleGroupState {\n /** Whether single or multiple selection is enabled. */\n readonly selectionMode: \"single\" | \"multiple\";\n /** Whether all items are disabled. */\n readonly isDisabled: boolean;\n /** Current selected keys. */\n readonly selectedKeys: Set<Key>;\n /** Toggles selected state for a key. */\n toggleKey(key: Key): void;\n /** Sets selected state for a key. */\n setSelected(key: Key, isSelected: boolean): void;\n /** Replaces selected keys. */\n setSelectedKeys(keys: Set<Key>): void;\n}\n\nfunction toKeySet(keys?: Iterable<Key>): Set<Key> {\n return new Set(keys ? Array.from(keys) : []);\n}\n\n/**\n * Manages state for a group of toggle buttons.\n */\nexport function createToggleGroupState(\n props: MaybeAccessor<ToggleGroupProps> = {},\n): ToggleGroupState {\n const getProps = () => access(props);\n\n const initialProps = getProps();\n const [internalSelectedKeys, setInternalSelectedKeys] = createSignal<Set<Key>>(\n toKeySet(initialProps.defaultSelectedKeys),\n );\n\n const isControlled = () => getProps().selectedKeys !== undefined;\n const selectedKeys = () =>\n isControlled() ? toKeySet(getProps().selectedKeys) : internalSelectedKeys();\n\n function setSelectedKeys(keys: Set<Key>): void {\n const nextKeys = new Set(keys);\n if (!isControlled()) {\n setInternalSelectedKeys(nextKeys);\n }\n getProps().onSelectionChange?.(nextKeys);\n }\n\n function toggleKey(key: Key): void {\n const props = getProps();\n const mode = props.selectionMode ?? \"single\";\n const disallowEmptySelection = props.disallowEmptySelection ?? false;\n const currentKeys = selectedKeys();\n\n let nextKeys: Set<Key>;\n if (mode === \"multiple\") {\n nextKeys = new Set(currentKeys);\n if (nextKeys.has(key) && (!disallowEmptySelection || nextKeys.size > 1)) {\n nextKeys.delete(key);\n } else {\n nextKeys.add(key);\n }\n } else {\n nextKeys = new Set(currentKeys.has(key) && !disallowEmptySelection ? [] : [key]);\n }\n\n setSelectedKeys(nextKeys);\n }\n\n function setSelected(key: Key, isSelected: boolean): void {\n if (isSelected !== selectedKeys().has(key)) {\n toggleKey(key);\n }\n }\n\n return {\n get selectionMode() {\n return getProps().selectionMode ?? \"single\";\n },\n get isDisabled() {\n return getProps().isDisabled ?? false;\n },\n get selectedKeys() {\n return new Set(selectedKeys());\n },\n toggleKey,\n setSelected,\n setSelectedKeys,\n };\n}\n","/**\n * createAutocompleteState - State management for autocomplete components\n *\n * Based on @react-stately/autocomplete useAutocompleteState.\n */\n\nimport { createSignal, type Accessor } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils\";\n\nexport interface AutocompleteState {\n /** The current value of the autocomplete input. */\n inputValue: Accessor<string>;\n /** Sets the value of the autocomplete input. */\n setInputValue(value: string): void;\n /** The id of the current aria-activedescendant of the autocomplete input. */\n focusedNodeId: Accessor<string | null>;\n /** Sets the id of the current aria-activedescendant of the autocomplete input. */\n setFocusedNodeId(value: string | null): void;\n}\n\nexport interface AutocompleteStateOptions {\n /** The value of the autocomplete input (controlled). */\n inputValue?: string;\n /** The default value of the autocomplete input (uncontrolled). */\n defaultInputValue?: string;\n /** Handler that is called when the autocomplete input value changes. */\n onInputChange?: (value: string) => void;\n}\n\n/**\n * Provides state management for an autocomplete component.\n *\n * @example\n * ```tsx\n * const state = createAutocompleteState({\n * defaultInputValue: '',\n * onInputChange: (value) => console.log('Input changed:', value),\n * });\n *\n * // Access current input value\n * console.log(state.inputValue());\n *\n * // Update input value\n * state.setInputValue('new value');\n *\n * // Track focused node for aria-activedescendant\n * state.setFocusedNodeId('item-1');\n * ```\n */\nexport function createAutocompleteState(\n props: MaybeAccessor<AutocompleteStateOptions> = {},\n): AutocompleteState {\n const getProps = () => access(props);\n\n // Track focused node ID for aria-activedescendant\n const [focusedNodeId, setFocusedNodeId] = createSignal<string | null>(null);\n\n // Handle controlled vs uncontrolled input value\n const isControlled = () => getProps().inputValue !== undefined;\n const [uncontrolledValue, setUncontrolledValue] = createSignal(\n getProps().defaultInputValue ?? \"\",\n );\n\n const inputValue: Accessor<string> = () => {\n const p = getProps();\n return isControlled() ? (p.inputValue ?? \"\") : uncontrolledValue();\n };\n\n const setInputValue = (value: string) => {\n const p = getProps();\n if (!isControlled()) {\n setUncontrolledValue(value);\n }\n p.onInputChange?.(value);\n };\n\n return {\n inputValue,\n setInputValue,\n focusedNodeId,\n setFocusedNodeId,\n };\n}\n","/**\n * TextField state for Solid Stately\n *\n * Provides state management for text input components.\n *\n * This is a port of @react-stately/utils's useControlledState pattern\n * as used by @react-aria/textfield.\n */\n\nimport { createSignal, Accessor } from \"solid-js\";\nimport { type MaybeAccessor, access } from \"../utils\";\n\nexport interface TextFieldStateOptions {\n /** The current value (controlled). */\n value?: string;\n /** The default value (uncontrolled). */\n defaultValue?: string;\n /** Handler that is called when the value changes. */\n onChange?: (value: string) => void;\n}\n\nexport interface TextFieldState {\n /** The current value of the text field. */\n readonly value: Accessor<string>;\n /** Sets the value of the text field. */\n setValue(value: string): void;\n}\n\n/**\n * Provides state management for text input components.\n * Supports both controlled and uncontrolled modes.\n */\nexport function createTextFieldState(\n props: MaybeAccessor<TextFieldStateOptions> = {},\n): TextFieldState {\n const getProps = () => access(props);\n\n const initialProps = getProps();\n const initialValue = initialProps.value ?? initialProps.defaultValue ?? \"\";\n\n const [internalValue, setInternalValue] = createSignal(initialValue);\n\n const isControlled = () => getProps().value !== undefined;\n\n const value: Accessor<string> = () => {\n const p = getProps();\n return isControlled() ? (p.value ?? \"\") : internalValue();\n };\n\n function setValue(newValue: string): void {\n const p = getProps();\n\n if (!isControlled()) {\n setInternalValue(newValue);\n }\n\n p.onChange?.(newValue);\n }\n\n return {\n value,\n setValue,\n };\n}\n","/**\n * createFormValidationState for solid-stately\n *\n * Manages form validation state including realtime and displayed validation results.\n * Supports both ARIA (live) and native (on submit) validation behaviors.\n *\n * Port of react-stately's useFormValidationState.\n */\n\nimport {\n type Accessor,\n createContext,\n createEffect,\n createMemo,\n createSignal,\n useContext,\n} from \"solid-js\";\n\n/** Standard HTML ValidityState interface. */\nexport interface ValidityState {\n badInput: boolean;\n customError: boolean;\n patternMismatch: boolean;\n rangeOverflow: boolean;\n rangeUnderflow: boolean;\n stepMismatch: boolean;\n tooLong: boolean;\n tooShort: boolean;\n typeMismatch: boolean;\n valueMissing: boolean;\n valid: boolean;\n}\n\n/** Result of validation. */\nexport interface ValidationResult {\n /** Whether the value is invalid. */\n isInvalid: boolean;\n /** Details about which validation constraints failed. */\n validationDetails: ValidityState;\n /** Error messages to display. */\n validationErrors: string[];\n}\n\n/** Map of field names to their validation errors. */\nexport type ValidationErrors = Record<string, string | string[]>;\n\n/** Validation function that returns error messages or true/false. */\nexport type ValidationFunction<T> = (value: T) => boolean | string | string[] | null | undefined;\n\n/** Validation behavior mode. */\nexport type ValidationBehavior = \"aria\" | \"native\";\n\nexport interface FormValidationProps<T> {\n /** Whether the value is invalid (controlled). */\n isInvalid?: boolean;\n /** @deprecated Use isInvalid instead. */\n validationState?: \"valid\" | \"invalid\";\n /** Custom validation function. */\n validate?: ValidationFunction<T>;\n /** Validation behavior: 'aria' for realtime, 'native' for on submit. */\n validationBehavior?: ValidationBehavior;\n /** Built-in validation result from native input. */\n builtinValidation?: ValidationResult;\n /** Field name(s) for server error lookup. */\n name?: string | string[];\n /** Current field value. */\n value: T | null;\n}\n\nexport interface FormValidationState {\n /** Realtime validation results, updated as the user edits the value. */\n realtimeValidation: Accessor<ValidationResult>;\n /** Currently displayed validation results, updated when the user commits their changes. */\n displayValidation: Accessor<ValidationResult>;\n /** Updates the current validation result. Not displayed to the user until `commitValidation` is called. */\n updateValidation(result: ValidationResult): void;\n /** Resets the displayed validation state to valid when the user resets the form. */\n resetValidation(): void;\n /** Commits the realtime validation so it is displayed to the user. */\n commitValidation(): void;\n}\n\n/** A valid validity state. */\nexport const VALID_VALIDITY_STATE: ValidityState = {\n badInput: false,\n customError: false,\n patternMismatch: false,\n rangeOverflow: false,\n rangeUnderflow: false,\n stepMismatch: false,\n tooLong: false,\n tooShort: false,\n typeMismatch: false,\n valueMissing: false,\n valid: true,\n};\n\n/** A custom error validity state. */\nconst CUSTOM_VALIDITY_STATE: ValidityState = {\n ...VALID_VALIDITY_STATE,\n customError: true,\n valid: false,\n};\n\n/** Default validation result (valid). */\nexport const DEFAULT_VALIDATION_RESULT: ValidationResult = {\n isInvalid: false,\n validationDetails: VALID_VALIDITY_STATE,\n validationErrors: [],\n};\n\n/** Context for server-side validation errors. */\nexport const FormValidationContext = createContext<ValidationErrors>({});\n\n/** Private prop key for passing validation state to children. */\nexport const privateValidationStateProp = \"__formValidationState\" + Date.now();\n\nfunction asArray<T>(v: T | T[] | undefined): T[] {\n if (!v) {\n return [];\n }\n return Array.isArray(v) ? v : [v];\n}\n\nfunction runValidate<T>(validate: ValidationFunction<T>, value: T): string[] {\n if (typeof validate === \"function\") {\n const e = validate(value);\n if (e && typeof e !== \"boolean\") {\n return asArray(e);\n }\n }\n return [];\n}\n\nfunction getValidationResult(errors: string[]): ValidationResult | null {\n return errors.length\n ? {\n isInvalid: true,\n validationErrors: errors,\n validationDetails: CUSTOM_VALIDITY_STATE,\n }\n : null;\n}\n\nfunction isEqualValidation(a: ValidationResult | null, b: ValidationResult | null): boolean {\n if (a === b) {\n return true;\n }\n return (\n !!a &&\n !!b &&\n a.isInvalid === b.isInvalid &&\n a.validationErrors.length === b.validationErrors.length &&\n a.validationErrors.every((ae, i) => ae === b.validationErrors[i]) &&\n Object.entries(a.validationDetails).every(\n ([k, v]) => b.validationDetails[k as keyof ValidityState] === v,\n )\n );\n}\n\n/**\n * Creates form validation state for a field.\n *\n * @example\n * ```tsx\n * const validationState = createFormValidationState({\n * value: inputValue(),\n * validate: (value) => {\n * if (!value) return 'This field is required';\n * if (value.length < 3) return 'Must be at least 3 characters';\n * return null;\n * },\n * validationBehavior: 'aria',\n * });\n *\n * // Access validation state\n * const isInvalid = () => validationState.displayValidation().isInvalid;\n * const errors = () => validationState.displayValidation().validationErrors;\n * ```\n */\nexport function createFormValidationState<T>(props: FormValidationProps<T>): FormValidationState {\n const validationBehavior = () => props.validationBehavior ?? \"aria\";\n\n // Backward compatibility\n const isInvalidProp = createMemo(\n () => props.isInvalid ?? (props.validationState === \"invalid\" ? true : undefined),\n );\n\n // Controlled error from isInvalid prop\n const controlledError = createMemo<ValidationResult | null>(() =>\n isInvalidProp() !== undefined\n ? {\n isInvalid: isInvalidProp()!,\n validationErrors: [],\n validationDetails: CUSTOM_VALIDITY_STATE,\n }\n : null,\n );\n\n // Client-side validation\n const clientError = createMemo<ValidationResult | null>(() => {\n const validate = props.validate;\n if (!validate || props.value == null) {\n return null;\n }\n const validateErrors = runValidate(validate, props.value);\n return getValidationResult(validateErrors);\n });\n\n // Built-in validation (skip if valid)\n const builtinValidation = createMemo<ValidationResult | undefined>(() => {\n const builtinValidationProp = props.builtinValidation;\n if (builtinValidationProp?.validationDetails.valid) {\n return undefined;\n }\n return builtinValidationProp;\n });\n\n // Server errors from context\n const serverErrors = useContext(FormValidationContext);\n const serverErrorMessages = createMemo(() => {\n const name = props.name;\n if (name) {\n return Array.isArray(name)\n ? name.flatMap((n) => asArray(serverErrors[n]))\n : asArray(serverErrors[name]);\n }\n return [];\n });\n\n // Track server errors clearing\n const [lastServerErrors, setLastServerErrors] = createSignal(serverErrors);\n const [isServerErrorCleared, setServerErrorCleared] = createSignal(false);\n\n createEffect(() => {\n if (serverErrors !== lastServerErrors()) {\n setLastServerErrors(serverErrors);\n setServerErrorCleared(false);\n }\n });\n\n const serverError = createMemo<ValidationResult | null>(() =>\n getValidationResult(isServerErrorCleared() ? [] : serverErrorMessages()),\n );\n\n // Track validation state\n const [currentValidity, setCurrentValidity] = createSignal(DEFAULT_VALIDATION_RESULT);\n const [commitQueued, setCommitQueued] = createSignal(false);\n\n let nextValidation = DEFAULT_VALIDATION_RESULT;\n let lastError = DEFAULT_VALIDATION_RESULT;\n\n // Commit validation effect\n createEffect(() => {\n if (!commitQueued()) {\n return;\n }\n setCommitQueued(false);\n const error = clientError() || builtinValidation() || nextValidation;\n if (!isEqualValidation(error, lastError)) {\n lastError = error;\n setCurrentValidity(error);\n }\n });\n\n // Realtime validation (for native input state)\n const realtimeValidation = createMemo<ValidationResult>(\n () =>\n controlledError() ||\n serverError() ||\n clientError() ||\n builtinValidation() ||\n DEFAULT_VALIDATION_RESULT,\n );\n\n // Display validation (what the user sees)\n const displayValidation = createMemo<ValidationResult>(() => {\n if (validationBehavior() === \"native\") {\n return controlledError() || serverError() || currentValidity();\n }\n return (\n controlledError() ||\n serverError() ||\n clientError() ||\n builtinValidation() ||\n currentValidity()\n );\n });\n\n return {\n realtimeValidation,\n displayValidation,\n updateValidation(value: ValidationResult) {\n // If validationBehavior is 'aria', update in realtime. Otherwise, store until commit.\n if (validationBehavior() === \"aria\" && !isEqualValidation(currentValidity(), value)) {\n setCurrentValidity(value);\n } else {\n nextValidation = value;\n }\n },\n resetValidation() {\n // Update the currently displayed validation state to valid on form reset.\n const error = DEFAULT_VALIDATION_RESULT;\n if (!isEqualValidation(error, lastError)) {\n lastError = error;\n setCurrentValidity(error);\n }\n // Do not commit validation after the next render for native behavior.\n if (validationBehavior() === \"native\") {\n setCommitQueued(false);\n }\n setServerErrorCleared(true);\n },\n commitValidation() {\n // Commit validation state so the user sees it on blur/change/submit.\n if (validationBehavior() === \"native\") {\n const error = clientError() || builtinValidation() || nextValidation;\n if (!isEqualValidation(error, lastError)) {\n lastError = error;\n setCurrentValidity(error);\n }\n setCommitQueued(false);\n }\n setServerErrorCleared(true);\n },\n };\n}\n\n/**\n * Merges multiple validation results into one.\n */\nexport function mergeValidation(...results: ValidationResult[]): ValidationResult {\n const errors = new Set<string>();\n let isInvalid = false;\n const validationDetails: ValidityState = { ...VALID_VALIDITY_STATE };\n\n for (const v of results) {\n for (const e of v.validationErrors) {\n errors.add(e);\n }\n isInvalid = isInvalid || v.isInvalid;\n for (const key in validationDetails) {\n const k = key as keyof ValidityState;\n (validationDetails as unknown as Record<string, boolean>)[k] =\n (validationDetails as unknown as Record<string, boolean>)[k] ||\n (v.validationDetails as unknown as Record<string, boolean>)[k];\n }\n }\n\n validationDetails.valid = !isInvalid;\n return {\n isInvalid,\n validationErrors: [...errors],\n validationDetails,\n };\n}\n","/**\n * Checkbox group state for Solid Stately\n *\n * Provides state management for a checkbox group component.\n * Provides a name for the group, and manages selection and focus state.\n *\n * This is a 1:1 port of @react-stately/checkbox's useCheckboxGroupState.\n */\n\nimport { createMemo, createSignal, Accessor } from \"solid-js\";\nimport { type MaybeAccessor, access } from \"../utils\";\nimport {\n createFormValidationState,\n type FormValidationState,\n type ValidationFunction,\n type ValidationResult,\n} from \"../form\";\n\nexport interface CheckboxGroupProps {\n /** The current selected values (controlled). */\n value?: string[];\n /** The default selected values (uncontrolled). */\n defaultValue?: string[];\n /** Handler that is called when the value changes. */\n onChange?: (value: string[]) => void;\n /** Whether the checkbox group is disabled. */\n isDisabled?: boolean;\n /** Whether the checkbox group is read only. */\n isReadOnly?: boolean;\n /** Whether the checkbox group is required. */\n isRequired?: boolean;\n /** Whether the checkbox group is invalid. */\n isInvalid?: boolean;\n /** The name of the checkbox group, used when submitting an HTML form. */\n name?: string;\n /** The form to associate the checkbox group with. */\n form?: string;\n /** The label for the checkbox group. */\n label?: string;\n /** Handler that is called when the checkbox group receives focus. */\n onFocus?: (e: FocusEvent) => void;\n /** Handler that is called when the checkbox group loses focus. */\n onBlur?: (e: FocusEvent) => void;\n /** Handler that is called when the checkbox group's focus status changes. */\n onFocusChange?: (isFocused: boolean) => void;\n /** Backward-compatible controlled validation state. */\n validationState?: \"valid\" | \"invalid\";\n /** Custom validation function. */\n validate?: ValidationFunction<readonly string[]>;\n /** Validation behavior for the checkbox group. */\n validationBehavior?: \"aria\" | \"native\";\n}\n\nexport interface CheckboxGroupState extends Pick<\n FormValidationState,\n | \"realtimeValidation\"\n | \"displayValidation\"\n | \"updateValidation\"\n | \"resetValidation\"\n | \"commitValidation\"\n> {\n /** Current selected values. */\n readonly value: Accessor<readonly string[]>;\n /** Default selected values. */\n readonly defaultValue: readonly string[];\n /** Whether the checkbox group is disabled. */\n readonly isDisabled: boolean;\n /** Whether the checkbox group is read only. */\n readonly isReadOnly: boolean;\n /** Whether the checkbox group is invalid. */\n readonly isInvalid: boolean;\n /**\n * Whether the checkboxes in the group are required.\n * This changes to false once at least one item is selected.\n */\n readonly isRequired: Accessor<boolean>;\n /** Returns whether the given value is selected. */\n isSelected(value: string): boolean;\n /** Sets the selected values. */\n setValue(value: string[]): void;\n /** Adds a value to the set of selected values. */\n addValue(value: string): void;\n /** Removes a value from the set of selected values. */\n removeValue(value: string): void;\n /** Toggles a value in the set of selected values. */\n toggleValue(value: string): void;\n\n /** Current display validation result for the group. */\n readonly displayValidation: Accessor<ValidationResult>;\n}\n\n/**\n * Provides state management for a checkbox group component.\n * Provides a name for the group, and manages selection and focus state.\n */\nexport function createCheckboxGroupState(\n props: MaybeAccessor<CheckboxGroupProps> = {},\n): CheckboxGroupState {\n const getProps = () => access(props);\n\n const initialProps = getProps();\n const initialValue = initialProps.value ?? initialProps.defaultValue ?? [];\n\n const [internalValue, setInternalValue] = createSignal<readonly string[]>(initialValue);\n\n const controlledValue = createMemo<readonly string[] | undefined>(() => getProps().value);\n\n const isControlled = () => controlledValue() !== undefined;\n\n const value: Accessor<readonly string[]> = () => {\n const controlled = controlledValue();\n return controlled !== undefined ? controlled : internalValue();\n };\n\n const isRequired: Accessor<boolean> = () => {\n const p = getProps();\n return !!p.isRequired && value().length === 0;\n };\n\n const validation = createFormValidationState<readonly string[]>({\n get value() {\n return value();\n },\n get isInvalid() {\n return getProps().isInvalid;\n },\n get validationState() {\n return getProps().validationState;\n },\n get validate() {\n return getProps().validate;\n },\n get validationBehavior() {\n return getProps().validationBehavior ?? \"native\";\n },\n get name() {\n return getProps().name;\n },\n });\n\n function setValue(newValue: string[]): void {\n const p = getProps();\n if (p.isReadOnly || p.isDisabled) {\n return;\n }\n\n if (!isControlled()) {\n setInternalValue(newValue);\n }\n\n p.onChange?.(newValue);\n }\n\n function isSelected(checkValue: string): boolean {\n return value().includes(checkValue);\n }\n\n function addValue(addVal: string): void {\n const p = getProps();\n if (p.isReadOnly || p.isDisabled) {\n return;\n }\n\n const current = value();\n if (!current.includes(addVal)) {\n setValue([...current, addVal]);\n }\n }\n\n function removeValue(removeVal: string): void {\n const p = getProps();\n if (p.isReadOnly || p.isDisabled) {\n return;\n }\n\n const current = value();\n if (current.includes(removeVal)) {\n setValue(current.filter((v) => v !== removeVal));\n }\n }\n\n function toggleValue(toggleVal: string): void {\n const p = getProps();\n if (p.isReadOnly || p.isDisabled) {\n return;\n }\n\n const current = value();\n if (current.includes(toggleVal)) {\n setValue(current.filter((v) => v !== toggleVal));\n } else {\n setValue([...current, toggleVal]);\n }\n }\n\n return {\n value,\n defaultValue: initialProps.defaultValue ?? initialValue,\n get isDisabled() {\n return getProps().isDisabled ?? false;\n },\n get isReadOnly() {\n return getProps().isReadOnly ?? false;\n },\n get isInvalid() {\n return validation.displayValidation().isInvalid;\n },\n isRequired,\n isSelected,\n setValue,\n addValue,\n removeValue,\n toggleValue,\n realtimeValidation: validation.realtimeValidation,\n displayValidation: validation.displayValidation,\n updateValidation: validation.updateValidation,\n resetValidation: validation.resetValidation,\n commitValidation: validation.commitValidation,\n };\n}\n","/**\n * SSR utilities for Solid Stately\n *\n * SolidJS has built-in SSR support with `isServer` and `createUniqueId()`.\n * These utilities provide a consistent API matching React-Stately's patterns.\n */\n\nimport { createUniqueId } from \"solid-js\";\nimport { isServer as _isServer } from \"solid-js/web\";\n\n/**\n * Re-export isServer from solid-js/web for convenience.\n */\nexport const isServer = _isServer;\n\n/**\n * Returns whether the component is currently being server side rendered.\n * Can be used to delay browser-specific rendering until after hydration.\n */\nexport function createIsSSR(): boolean {\n return isServer;\n}\n\n/**\n * Generate a unique ID that is stable across server and client.\n * Uses SolidJS's built-in createUniqueId which handles SSR correctly.\n *\n * @param defaultId - Optional default ID to use instead of generating one.\n */\nexport function createId(defaultId?: string): string {\n if (defaultId) {\n return defaultId;\n }\n return `solid-stately-${createUniqueId()}`;\n}\n\n/**\n * Check if we can use DOM APIs.\n * This is useful for code that needs to run only in the browser.\n */\nexport const canUseDOM = !isServer;\n","/**\n * Radio group state for Solid Stately\n *\n * Provides state management for a radio group component.\n * Provides a name for the group, and manages selection and focus state.\n *\n * This is a 1:1 port of @react-stately/radio's useRadioGroupState.\n */\n\nimport { createMemo, createSignal, Accessor, untrack } from \"solid-js\";\nimport { type MaybeAccessor, access } from \"../utils\";\nimport { createId } from \"../ssr\";\nimport {\n createFormValidationState,\n type FormValidationState,\n type ValidationFunction,\n type ValidationResult,\n} from \"../form\";\n\nexport interface RadioGroupProps {\n /** The current selected value (controlled). */\n value?: string | null;\n /** The default selected value (uncontrolled). */\n defaultValue?: string | null;\n /** Handler that is called when the value changes. */\n onChange?: (value: string) => void;\n /** Whether the radio group is disabled. */\n isDisabled?: boolean;\n /** Whether the radio group is read only. */\n isReadOnly?: boolean;\n /** Whether the radio group is required. */\n isRequired?: boolean;\n /** Whether the radio group is invalid. */\n isInvalid?: boolean;\n /** The name of the radio group, used when submitting an HTML form. */\n name?: string;\n /** The form to associate the radio group with. */\n form?: string;\n /** The label for the radio group. */\n label?: string;\n /** Orientation of the radio group. */\n orientation?: \"horizontal\" | \"vertical\";\n /** Handler that is called when the radio group receives focus. */\n onFocus?: (e: FocusEvent) => void;\n /** Handler that is called when the radio group loses focus. */\n onBlur?: (e: FocusEvent) => void;\n /** Handler that is called when the radio group's focus status changes. */\n onFocusChange?: (isFocused: boolean) => void;\n /** Backward-compatible controlled validation state. */\n validationState?: \"valid\" | \"invalid\";\n /** Custom validation function. */\n validate?: ValidationFunction<string | null>;\n /** Validation behavior for the radio group. */\n validationBehavior?: \"aria\" | \"native\";\n}\n\nexport interface RadioGroupState extends Pick<\n FormValidationState,\n | \"realtimeValidation\"\n | \"displayValidation\"\n | \"updateValidation\"\n | \"resetValidation\"\n | \"commitValidation\"\n> {\n /** The name for the group, used for native form submission. */\n readonly name: string;\n\n /** Whether the radio group is disabled. */\n readonly isDisabled: boolean;\n\n /** Whether the radio group is read only. */\n readonly isReadOnly: boolean;\n\n /** Whether the radio group is required. */\n readonly isRequired: boolean;\n\n /** Whether the radio group is invalid. */\n readonly isInvalid: boolean;\n\n /** The currently selected value. */\n readonly selectedValue: Accessor<string | null>;\n\n /** The default selected value. */\n readonly defaultSelectedValue: string | null;\n\n /** Sets the selected value. */\n setSelectedValue(value: string | null): void;\n\n /** The value of the last focused radio. */\n readonly lastFocusedValue: Accessor<string | null>;\n\n /** Sets the last focused value. */\n setLastFocusedValue(value: string | null): void;\n\n /** Current display validation result for the group. */\n readonly displayValidation: Accessor<ValidationResult>;\n}\n\n/**\n * Internal WeakMap to store sync version accessors for each radio group state.\n * This is used by createRadio to trigger DOM sync when native radio behavior\n * causes the DOM checked state to desync from our reactive state.\n *\n * This is kept separate from RadioGroupState to maintain API parity with React-Stately.\n * @internal\n */\nexport const radioGroupSyncVersion: WeakMap<RadioGroupState, Accessor<number>> = new WeakMap();\n\n/**\n * Provides state management for a radio group component.\n * Provides a name for the group, and manages selection and focus state.\n */\nexport function createRadioGroupState(props: MaybeAccessor<RadioGroupProps> = {}): RadioGroupState {\n const getProps = () => access(props);\n\n // Get initial props using untrack to avoid setting up dependencies\n // This ensures we capture the initial defaultValue without reactivity issues\n const initialProps = untrack(() => getProps());\n\n // Generate name - preserved for backward compatibility\n // React Aria now generates the name instead of stately\n const name = initialProps.name || `radio-group-${createId()}`;\n\n // Create internal signal for uncontrolled mode\n // Initialize with defaultValue only (not value, which is for controlled mode)\n const [internalValue, setInternalValue] = createSignal<string | null>(\n initialProps.defaultValue ?? null,\n );\n const [lastFocusedValue, setLastFocusedValueInternal] = createSignal<string | null>(null);\n\n // SolidJS-specific: Version counter for triggering DOM sync across all radios\n // This handles the case where native radio behavior causes DOM state to desync\n // from our reactive state (e.g., clicking a radio unchecks siblings in the DOM)\n const [syncVersion, setSyncVersion] = createSignal(0);\n\n const controlledValue = createMemo<string | null | undefined>(() => {\n const value = getProps().value;\n return value === undefined ? undefined : (value ?? null);\n });\n\n // Determine if controlled - must be reactive to handle dynamic props\n const isControlled = () => controlledValue() !== undefined;\n\n // Get current value - reactive for both controlled and uncontrolled modes\n const selectedValue: Accessor<string | null> = () => {\n // In controlled mode, always read from props.value reactively\n // In uncontrolled mode, read from internal signal\n const value = controlledValue();\n if (value !== undefined) {\n return value;\n }\n return internalValue();\n };\n\n const validation = createFormValidationState<string | null>({\n get value() {\n return selectedValue();\n },\n get isInvalid() {\n return getProps().isInvalid;\n },\n get validationState() {\n return getProps().validationState;\n },\n get validate() {\n return getProps().validate;\n },\n get validationBehavior() {\n return getProps().validationBehavior ?? \"native\";\n },\n get name() {\n return getProps().name;\n },\n });\n\n // Set value\n function setSelectedValue(value: string | null): void {\n const p = getProps();\n if (p.isReadOnly || p.isDisabled) {\n return;\n }\n\n // Always increment syncVersion to trigger DOM sync across all radios\n // This is crucial for SolidJS because:\n // 1. Native radio behavior unchecks siblings when one is checked\n // 2. In controlled mode, isSelected() may not change even though DOM changed\n // 3. We need ALL radios to re-sync their checked state after any click\n setSyncVersion((v) => v + 1);\n\n if (!isControlled()) {\n setInternalValue(value);\n }\n\n if (value != null) {\n p.onChange?.(value);\n }\n\n validation.commitValidation();\n }\n\n // Set last focused value\n function setLastFocusedValue(value: string | null): void {\n setLastFocusedValueInternal(value);\n }\n\n const state: RadioGroupState = {\n name,\n selectedValue,\n defaultSelectedValue: initialProps.defaultValue ?? null,\n setSelectedValue,\n lastFocusedValue,\n setLastFocusedValue,\n realtimeValidation: validation.realtimeValidation,\n displayValidation: validation.displayValidation,\n updateValidation: validation.updateValidation,\n resetValidation: validation.resetValidation,\n commitValidation: validation.commitValidation,\n get isDisabled() {\n return getProps().isDisabled ?? false;\n },\n get isReadOnly() {\n return getProps().isReadOnly ?? false;\n },\n get isRequired() {\n return getProps().isRequired ?? false;\n },\n get isInvalid() {\n return validation.displayValidation().isInvalid;\n },\n };\n\n // Store syncVersion in internal WeakMap (not part of public API)\n // This maintains API parity with React-Stately while supporting SolidJS's reactivity needs\n radioGroupSyncVersion.set(state, syncVersion);\n\n return state;\n}\n","/**\n * Manages state for an overlay trigger.\n * Based on @react-stately/overlays useOverlayTriggerState.\n */\n\nimport { createSignal, type Accessor } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils\";\n\nexport interface OverlayTriggerProps {\n /** Whether the overlay is open by default (uncontrolled). */\n defaultOpen?: boolean;\n /** Whether the overlay is open (controlled). */\n isOpen?: boolean;\n /** Handler that is called when the overlay's open state changes. */\n onOpenChange?: (isOpen: boolean) => void;\n}\n\nexport interface OverlayTriggerState {\n /** Whether the overlay is currently open. */\n readonly isOpen: Accessor<boolean>;\n /** Sets whether the overlay is open. */\n setOpen(isOpen: boolean): void;\n /** Opens the overlay. */\n open(): void;\n /** Closes the overlay. */\n close(): void;\n /** Toggles the overlay's visibility. */\n toggle(): void;\n}\n\n/**\n * Manages state for an overlay trigger. Tracks whether the overlay is open, and provides\n * methods to toggle this state.\n */\nexport function createOverlayTriggerState(\n props: MaybeAccessor<OverlayTriggerProps> = {},\n): OverlayTriggerState {\n const propsAccessor = () => access(props);\n\n const [internalOpen, setInternalOpen] = createSignal(propsAccessor().defaultOpen ?? false);\n\n const isOpen: Accessor<boolean> = () => {\n const p = propsAccessor();\n return p.isOpen !== undefined ? p.isOpen : internalOpen();\n };\n\n const setOpen = (open: boolean) => {\n const p = propsAccessor();\n if (p.isOpen === undefined) {\n setInternalOpen(open);\n }\n p.onOpenChange?.(open);\n };\n\n const open = () => setOpen(true);\n const close = () => setOpen(false);\n const toggle = () => setOpen(!isOpen());\n\n return {\n isOpen,\n setOpen,\n open,\n close,\n toggle,\n };\n}\n","/**\n * A simple list collection implementation.\n * Provides a Collection interface over an array of nodes.\n */\n\nimport type { Collection, CollectionItemLike, CollectionNode, Key } from \"./types\";\n\n/**\n * A basic implementation of Collection for list-based components.\n */\nexport class ListCollection<T = unknown> implements Collection<T> {\n private nodes: CollectionNode<T>[];\n private keyMap: Map<Key, CollectionNode<T>>;\n\n constructor(nodes: CollectionNode<T>[]) {\n this.nodes = nodes;\n this.keyMap = new Map();\n\n // Build key map for O(1) lookups\n const addToMap = (node: CollectionNode<T>) => {\n this.keyMap.set(node.key, node);\n if (node.childNodes) {\n for (const child of node.childNodes) {\n addToMap(child);\n }\n }\n };\n\n for (const node of nodes) {\n addToMap(node);\n }\n }\n\n get size(): number {\n return this.keyMap.size;\n }\n\n *[Symbol.iterator](): Iterator<CollectionNode<T>> {\n yield* this.nodes;\n }\n\n *getKeys(): Iterable<Key> {\n for (const node of this.keyMap.values()) {\n yield node.key;\n }\n }\n\n getItem(key: Key): CollectionNode<T> | null {\n return this.keyMap.get(key) ?? null;\n }\n\n at(index: number): CollectionNode<T> | null {\n // Flatten all items for indexing\n const items = this.getAllItems();\n return items[index] ?? null;\n }\n\n getKeyBefore(key: Key): Key | null {\n const items = this.getAllItems();\n const index = items.findIndex((item) => item.key === key);\n if (index <= 0) return null;\n return items[index - 1].key;\n }\n\n getKeyAfter(key: Key): Key | null {\n const items = this.getAllItems();\n const index = items.findIndex((item) => item.key === key);\n if (index < 0 || index >= items.length - 1) return null;\n return items[index + 1].key;\n }\n\n getFirstKey(): Key | null {\n const items = this.getAllItems();\n return items[0]?.key ?? null;\n }\n\n getLastKey(): Key | null {\n const items = this.getAllItems();\n return items[items.length - 1]?.key ?? null;\n }\n\n *getChildren(key: Key): Iterable<CollectionNode<T>> {\n const node = this.getItem(key);\n if (node?.childNodes) {\n yield* node.childNodes;\n }\n }\n\n getTextValue(key: Key): string {\n return this.getItem(key)?.textValue ?? \"\";\n }\n\n /**\n * Filter the collection, returning a new `ListCollection` containing only the\n * item nodes for which `filterFn(node.textValue, node)` returns true. Sections\n * whose children are all filtered out are dropped; surviving sections are\n * rebuilt with their filtered children. Node order is preserved. Mirrors the\n * behaviour of @react-aria/collections `BaseCollection.filter`.\n */\n filter(filterFn: (nodeValue: string, node: CollectionNode<T>) => boolean): ListCollection<T> {\n const filterNodes = (nodes: CollectionNode<T>[]): CollectionNode<T>[] => {\n const result: CollectionNode<T>[] = [];\n for (const node of nodes) {\n if (node.type === \"section\") {\n const children = filterNodes(node.childNodes ?? []);\n if (children.length > 0) {\n result.push({ ...node, childNodes: children, hasChildNodes: true });\n }\n } else if (node.type === \"item\") {\n if (filterFn(node.textValue, node)) {\n result.push(node);\n }\n } else {\n // Non-item, non-section nodes (e.g. separators) pass through unfiltered.\n result.push(node);\n }\n }\n return result;\n };\n\n return new ListCollection<T>(filterNodes(this.nodes));\n }\n\n /**\n * Get all items (excluding sections, including items within sections).\n */\n private getAllItems(): CollectionNode<T>[] {\n const items: CollectionNode<T>[] = [];\n\n const addItems = (nodes: CollectionNode<T>[]) => {\n for (const node of nodes) {\n if (node.type === \"item\") {\n items.push(node);\n } else if (node.type === \"section\" && node.childNodes) {\n addItems(node.childNodes);\n }\n }\n };\n\n addItems(this.nodes);\n return items;\n }\n}\n\n/**\n * Create a collection from an array of items.\n */\nexport function createListCollection<T>(\n items: T[],\n options: {\n getKey?: (item: T, index: number) => Key;\n getTextValue?: (item: T) => string;\n getDisabled?: (item: T) => boolean;\n } = {},\n): ListCollection<T> {\n const {\n getKey = (item: T, index: number) => {\n const o = item as CollectionItemLike;\n return o.key ?? o.id ?? index;\n },\n getTextValue = (item: T) => {\n const o = item as CollectionItemLike;\n return o.textValue ?? o.label ?? String(item);\n },\n getDisabled = (item: T) => (item as CollectionItemLike).isDisabled ?? false,\n } = options;\n\n const nodes: CollectionNode<T>[] = items.map((item, index) => ({\n type: \"item\" as const,\n key: getKey(item, index),\n value: item,\n textValue: getTextValue(item),\n rendered: null!, // Will be set by component\n level: 0,\n index,\n parentKey: null,\n hasChildNodes: false,\n childNodes: [],\n isDisabled: getDisabled(item),\n }));\n\n return new ListCollection(nodes);\n}\n","/**\n * Helpers for traversing collection nodes and comparing their document order.\n *\n * Based on @react-stately/collections.\n */\n\nimport type { Collection, CollectionNode } from \"./types\";\n\nexport function getChildNodes<T>(\n node: CollectionNode<T>,\n collection: Collection<T>,\n): Iterable<CollectionNode<T>> {\n // New API: call collection.getChildren with the node key.\n if (typeof collection.getChildren === \"function\") {\n return collection.getChildren(node.key);\n }\n\n // Old API: access childNodes directly.\n return node.childNodes;\n}\n\nexport function getFirstItem<T>(iterable: Iterable<T>): T | undefined {\n return getNthItem(iterable, 0);\n}\n\nexport function getNthItem<T>(iterable: Iterable<T>, index: number): T | undefined {\n if (index < 0) {\n return undefined;\n }\n\n let i = 0;\n for (const item of iterable) {\n if (i === index) {\n return item;\n }\n\n i++;\n }\n}\n\nexport function getLastItem<T>(iterable: Iterable<T>): T | undefined {\n let lastItem: T | undefined = undefined;\n for (const value of iterable) {\n lastItem = value;\n }\n\n return lastItem;\n}\n\nconst itemCountCache = new WeakMap<Collection<unknown>, number>();\n\n/**\n * Counts the item nodes (recursing into sections, ignoring section headers and\n * other non-item nodes) in a collection. Faithful port of\n * @react-stately/collections `getItemCount`; used by createOption to populate\n * `aria-setsize` when the listbox is virtualized. Cached per (immutable)\n * collection identity, exactly like upstream.\n */\nexport function getItemCount<T>(collection: Collection<T>): number {\n const cached = itemCountCache.get(collection);\n if (cached != null) {\n return cached;\n }\n\n let counter = 0;\n const countItems = (items: Iterable<CollectionNode<T>>) => {\n for (const item of items) {\n if (item.type === \"section\") {\n countItems(getChildNodes(item, collection));\n } else if (item.type === \"item\") {\n counter++;\n }\n }\n };\n\n countItems(collection);\n itemCountCache.set(collection, counter);\n return counter;\n}\n\nexport function compareNodeOrder<T>(\n collection: Collection<T>,\n a: CollectionNode<T>,\n b: CollectionNode<T>,\n): number {\n // If the two nodes have the same parent, compare their indices.\n if (a.parentKey === b.parentKey) {\n return a.index - b.index;\n }\n\n // Otherwise, collect all of the ancestors from each node, and find the first one that doesn't match starting from the root.\n // Include the base nodes in case we are comparing nodes of different levels so that we can compare the higher node to the lower level node's\n // ancestor of the same level\n const aAncestors = [...getAncestors(collection, a), a];\n const bAncestors = [...getAncestors(collection, b), b];\n const firstNonMatchingAncestor = aAncestors\n .slice(0, bAncestors.length)\n .findIndex((a, i) => a !== bAncestors[i]);\n if (firstNonMatchingAncestor !== -1) {\n // Compare the indices of two children within the common ancestor.\n a = aAncestors[firstNonMatchingAncestor];\n b = bAncestors[firstNonMatchingAncestor];\n return a.index - b.index;\n }\n\n // If there isn't a non matching ancestor, we might be in a case where one of the nodes is the ancestor of the other.\n if (aAncestors.findIndex((node) => node === b) >= 0) {\n return 1;\n } else if (bAncestors.findIndex((node) => node === a) >= 0) {\n return -1;\n }\n\n // 🤷\n return -1;\n}\n\nfunction getAncestors<T>(collection: Collection<T>, node: CollectionNode<T>): CollectionNode<T>[] {\n const parents: CollectionNode<T>[] = [];\n\n let currNode: CollectionNode<T> | null = node;\n while (currNode?.parentKey != null) {\n currNode = collection.getItem(currNode.parentKey);\n if (currNode) {\n parents.unshift(currNode);\n }\n }\n\n return parents;\n}\n","/**\n * Selection state management for collections.\n * Based on @react-stately/selection.\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils\";\nimport type {\n Collection,\n DisabledBehavior,\n FocusStrategy,\n Key,\n Selection,\n SelectionBehavior,\n SelectionMode,\n} from \"./types\";\n\nexport interface SelectionStateProps {\n /** The selection mode. */\n selectionMode?: SelectionMode;\n /** How selection behaves on interaction. */\n selectionBehavior?: SelectionBehavior;\n /** Whether empty selection is disallowed. */\n disallowEmptySelection?: boolean;\n /** Currently selected keys (controlled). */\n selectedKeys?: \"all\" | Iterable<Key>;\n /** Default selected keys (uncontrolled). */\n defaultSelectedKeys?: \"all\" | Iterable<Key>;\n /** Handler for selection changes. */\n onSelectionChange?: (keys: Selection) => void;\n /** Keys of disabled items. */\n disabledKeys?: Iterable<Key>;\n /** How disabled keys behave. */\n disabledBehavior?: DisabledBehavior;\n /** Whether to allow duplicate selection events. */\n allowDuplicateSelectionEvents?: boolean;\n}\n\nexport interface SelectionState {\n /** The selection mode. */\n readonly selectionMode: Accessor<SelectionMode>;\n /** The selection behavior. */\n readonly selectionBehavior: Accessor<SelectionBehavior>;\n /** Whether empty selection is disallowed. */\n readonly disallowEmptySelection: Accessor<boolean>;\n /** The currently selected keys. */\n readonly selectedKeys: Accessor<Selection>;\n /** Set of disabled keys. */\n readonly disabledKeys: Accessor<Set<Key>>;\n /** How disabled keys behave. */\n readonly disabledBehavior: Accessor<DisabledBehavior>;\n /** Whether the selection is empty. */\n readonly isEmpty: Accessor<boolean>;\n /** Whether all items are selected. */\n readonly isSelectAll: Accessor<boolean>;\n /** Check if a key is selected. */\n isSelected(key: Key): boolean;\n /** Check if a key is disabled. */\n isDisabled(key: Key): boolean;\n /** Set the selection behavior. */\n setSelectionBehavior(behavior: SelectionBehavior): void;\n /** Toggle selection for a key. */\n toggleSelection(key: Key): void;\n /** Replace selection with a single key. */\n replaceSelection(key: Key): void;\n /** Set multiple selected keys. */\n setSelectedKeys(keys: Iterable<Key>): void;\n /** Select all items. */\n selectAll(): void;\n /** Clear all selection. */\n clearSelection(): void;\n /** Toggle between select all and clear. */\n toggleSelectAll(): void;\n /** Extend selection to a key (for shift-click). */\n extendSelection(toKey: Key, collection: Collection): void;\n /** Select a key based on interaction. */\n select(key: Key, e?: SelectionPressEvent): void;\n}\n\n/**\n * The press/pointer interaction consulted by {@link SelectionState.select}.\n * Mirrors react-stately's `SelectionManager.select(e)`: only `pointerType` is\n * read here (touch / virtual force toggle, since those devices have no modifier\n * keys). Modifier keys (ctrl / meta / shift) are resolved one layer up in the\n * aria-layer `onSelect` (solidaria `selectItem`), matching upstream's split\n * between react-stately and react-aria. The modifier fields are accepted so a\n * full press/pointer event is assignable, but they are not read here.\n */\nexport interface SelectionPressEvent {\n pointerType?: \"mouse\" | \"pen\" | \"touch\" | \"keyboard\" | \"virtual\";\n shiftKey?: boolean;\n ctrlKey?: boolean;\n metaKey?: boolean;\n altKey?: boolean;\n}\n\n/**\n * Creates selection state for a collection.\n */\nexport function createSelectionState(\n props: MaybeAccessor<SelectionStateProps> = {},\n): SelectionState {\n const getProps = () => access(props);\n\n // Selection behavior state\n const [internalBehavior, setInternalBehavior] = createSignal<SelectionBehavior>(\"toggle\");\n\n // Internal selection state\n const [internalSelectedKeys, setInternalSelectedKeys] = createSignal<Selection>(\n getInitialSelection(getProps().defaultSelectedKeys),\n );\n\n // Track anchor for range selection\n const [anchorKey, setAnchorKey] = createSignal<Key | null>(null);\n\n // Computed values\n const selectionMode: Accessor<SelectionMode> = () => getProps().selectionMode ?? \"none\";\n\n const selectionBehavior: Accessor<SelectionBehavior> = () => {\n return getProps().selectionBehavior ?? internalBehavior();\n };\n\n const disallowEmptySelection: Accessor<boolean> = () => {\n return getProps().disallowEmptySelection ?? false;\n };\n\n const selectedKeys: Accessor<Selection> = createMemo(() => {\n const p = getProps();\n if (p.selectedKeys !== undefined) {\n return normalizeSelection(p.selectedKeys);\n }\n return internalSelectedKeys();\n });\n\n const disabledKeys: Accessor<Set<Key>> = createMemo(() => {\n const keys = getProps().disabledKeys;\n return keys ? new Set<Key>(keys) : new Set<Key>();\n });\n\n const disabledBehavior: Accessor<DisabledBehavior> = () => {\n return getProps().disabledBehavior ?? \"all\";\n };\n\n const isEmpty: Accessor<boolean> = () => {\n const keys = selectedKeys();\n return keys !== \"all\" && keys.size === 0;\n };\n\n const isSelectAll: Accessor<boolean> = () => {\n return selectedKeys() === \"all\";\n };\n\n // Methods\n const isSelected = (key: Key): boolean => {\n const keys = selectedKeys();\n if (keys === \"all\") return true;\n return keys.has(key);\n };\n\n const isDisabled = (key: Key): boolean => {\n return disabledKeys().has(key);\n };\n\n const updateSelection = (newSelection: Selection) => {\n const p = getProps();\n\n // Controlled mode\n if (p.selectedKeys !== undefined) {\n p.onSelectionChange?.(newSelection);\n return;\n }\n\n // Uncontrolled mode\n const current = internalSelectedKeys();\n const isDifferent =\n current === \"all\" ||\n newSelection === \"all\" ||\n current.size !== (newSelection as Set<Key>).size ||\n ![...current].every((k) => (newSelection as Set<Key>).has(k));\n\n if (isDifferent || p.allowDuplicateSelectionEvents) {\n setInternalSelectedKeys(newSelection);\n p.onSelectionChange?.(newSelection);\n }\n };\n\n const toggleSelection = (key: Key) => {\n if (isDisabled(key)) return;\n if (selectionMode() === \"none\") return;\n\n const current = selectedKeys();\n\n if (selectionMode() === \"single\") {\n if (isSelected(key) && !disallowEmptySelection()) {\n updateSelection(new Set());\n } else {\n updateSelection(new Set([key]));\n }\n return;\n }\n\n // Multiple selection\n if (current === \"all\") {\n // Can't toggle when all selected without collection\n return;\n }\n\n const newSelection = new Set(current);\n if (newSelection.has(key)) {\n if (newSelection.size > 1 || !disallowEmptySelection()) {\n newSelection.delete(key);\n }\n } else {\n newSelection.add(key);\n }\n\n updateSelection(newSelection);\n setAnchorKey(key);\n };\n\n const replaceSelection = (key: Key) => {\n if (isDisabled(key)) return;\n if (selectionMode() === \"none\") return;\n\n updateSelection(new Set([key]));\n setAnchorKey(key);\n };\n\n const setSelectedKeys = (keys: Iterable<Key>) => {\n const filtered = [...keys].filter((k) => !isDisabled(k));\n updateSelection(new Set(filtered));\n };\n\n const selectAll = () => {\n if (selectionMode() !== \"multiple\") return;\n updateSelection(\"all\");\n };\n\n const clearSelection = () => {\n if (disallowEmptySelection()) return;\n updateSelection(new Set());\n };\n\n const toggleSelectAll = () => {\n if (selectionMode() !== \"multiple\") return;\n\n if (isSelectAll()) {\n clearSelection();\n } else {\n selectAll();\n }\n };\n\n const extendSelection = (toKey: Key, collection: Collection) => {\n if (isDisabled(toKey)) return;\n if (selectionMode() !== \"multiple\") {\n replaceSelection(toKey);\n return;\n }\n\n const anchor = anchorKey();\n if (!anchor) {\n replaceSelection(toKey);\n return;\n }\n\n // Get keys between anchor and toKey\n const keys = [...collection.getKeys()];\n const anchorIndex = keys.indexOf(anchor);\n const toIndex = keys.indexOf(toKey);\n\n if (anchorIndex === -1 || toIndex === -1) {\n replaceSelection(toKey);\n return;\n }\n\n const start = Math.min(anchorIndex, toIndex);\n const end = Math.max(anchorIndex, toIndex);\n const rangeKeys = keys.slice(start, end + 1).filter((k) => !isDisabled(k));\n\n updateSelection(new Set(rangeKeys));\n };\n\n const select = (key: Key, e?: SelectionPressEvent) => {\n // Mirrors react-stately's SelectionManager.select: only pointerType +\n // selectionBehavior are consulted here. Modifier-key handling (ctrl / meta\n // ⇒ toggle, shift ⇒ extend) lives one layer up in solidaria's aria-layer\n // `selectItem`, which is where the platform-aware isCtrlKeyPressed is\n // available. The primitives self-guard disabled keys, so no guard is\n // needed here (matching upstream).\n if (selectionMode() === \"none\") return;\n\n if (selectionMode() === \"single\") {\n // Single mode ignores selectionBehavior. Re-selecting the current item\n // deselects it when empty selection is allowed; otherwise it stays\n // selected (replace).\n if (isSelected(key) && !disallowEmptySelection()) {\n toggleSelection(key);\n } else {\n replaceSelection(key);\n }\n } else if (\n selectionBehavior() === \"toggle\" ||\n (e != null && (e.pointerType === \"touch\" || e.pointerType === \"virtual\"))\n ) {\n // touch / virtual (VoiceOver) have no modifier keys, so multi-select is\n // only reachable by toggling.\n toggleSelection(key);\n } else {\n replaceSelection(key);\n }\n };\n\n const setSelectionBehavior = (behavior: SelectionBehavior) => {\n setInternalBehavior(behavior);\n };\n\n return {\n selectionMode,\n selectionBehavior,\n disallowEmptySelection,\n selectedKeys,\n disabledKeys,\n disabledBehavior,\n isEmpty,\n isSelectAll,\n isSelected,\n isDisabled,\n setSelectionBehavior,\n toggleSelection,\n replaceSelection,\n setSelectedKeys,\n selectAll,\n clearSelection,\n toggleSelectAll,\n extendSelection,\n select,\n };\n}\n\n// Helper functions\nfunction getInitialSelection(defaultKeys?: \"all\" | Iterable<Key>): Selection {\n if (defaultKeys === undefined) return new Set();\n return normalizeSelection(defaultKeys);\n}\n\nfunction normalizeSelection(keys: \"all\" | Iterable<Key>): Selection {\n if (keys === \"all\") return \"all\";\n return new Set(keys);\n}\n","/**\n * A Selection is a special Set containing Keys, which also has an anchor\n * and current selected key for use when range selecting.\n *\n * Based on @react-stately/selection.\n */\n\nimport type { Key } from \"../collections/types\";\n\n/**\n * A Selection is a special Set containing Keys, which also has an anchor\n * and current selected key for use when range selecting.\n */\nexport class Selection extends Set<Key> {\n anchorKey: Key | null;\n currentKey: Key | null;\n\n constructor(keys?: Iterable<Key> | Selection, anchorKey?: Key | null, currentKey?: Key | null) {\n super(keys);\n if (keys instanceof Selection) {\n this.anchorKey = anchorKey ?? keys.anchorKey;\n this.currentKey = currentKey ?? keys.currentKey;\n } else {\n this.anchorKey = anchorKey ?? null;\n this.currentKey = currentKey ?? null;\n }\n }\n}\n","/**\n * Raw multiple-selection + focus state for a collection.\n *\n * The lower of the two selection layers ported from upstream\n * (`@react-stately/selection`'s `useMultipleSelectionState`): it owns the\n * selected keys, focus, selection behavior, and disabled keys, but is NOT\n * collection-aware. The collection-aware operations (toggle, extend, select\n * all, range, etc.) live in {@link SelectionManager}, which is built on top of\n * this state.\n *\n * Based on @react-stately/selection.\n */\n\nimport { createSignal, createMemo, createComputed, untrack, type Accessor } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils\";\nimport type { SelectionStateProps } from \"../collections/createSelectionState\";\nimport type {\n DisabledBehavior,\n FocusStrategy,\n Key,\n Selection,\n SelectionBehavior,\n SelectionMode,\n} from \"../collections/types\";\nimport { Selection as SelectionClass } from \"./Selection\";\n\n/**\n * The raw state consumed by {@link SelectionManager}. Mirrors upstream's\n * `MultipleSelectionState`: property reads (not Solid accessors) so the manager\n * can read `state.selectionMode` etc. exactly as upstream does — the getters\n * read the underlying signals, so reads inside reactive scopes still track.\n */\nexport interface MultipleSelectionState {\n /** The type of selection that is allowed in the collection. */\n readonly selectionMode: SelectionMode;\n /** The selection behavior for the collection. */\n readonly selectionBehavior: SelectionBehavior;\n /** Sets the selection behavior for the collection. */\n setSelectionBehavior(selectionBehavior: SelectionBehavior): void;\n /** Whether the collection allows empty selection. */\n readonly disallowEmptySelection: boolean;\n /** Whether the collection is currently focused. */\n readonly isFocused: boolean;\n /** Sets whether the collection is focused. */\n setFocused(isFocused: boolean): void;\n /** The current focused key in the collection. */\n readonly focusedKey: Key | null;\n /** Whether the first or last child of the focused key should receive focus. */\n readonly childFocusStrategy: FocusStrategy | null;\n /** Sets the focused key, and optionally, whether the first or last child of that key should receive focus. */\n setFocusedKey(key: Key | null, childFocusStrategy?: FocusStrategy): void;\n /** The currently selected keys in the collection. */\n readonly selectedKeys: Selection;\n /** The last selection payload emitted through onSelectionChange. @internal */\n readonly lastSelectionEvent: Selection | null;\n /** Sets the selected keys in the collection. */\n setSelectedKeys(keys: Selection): void;\n /** Re-emits a selection payload without recomputing or mutating selection. @internal */\n emitDuplicateSelectionEvent(keys?: Selection): void;\n /** The currently disabled keys in the collection. */\n readonly disabledKeys: Set<Key>;\n /** Whether `disabledKeys` applies to all interactions, or only selection. */\n readonly disabledBehavior: DisabledBehavior;\n}\n\nfunction equalSets(setA: Set<Key>, setB: Set<Key>): boolean {\n if (setA.size !== setB.size) {\n return false;\n }\n\n for (const item of setA) {\n if (!setB.has(item)) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction convertSelection(\n selection: \"all\" | Iterable<Key> | null | undefined,\n defaultValue: Selection,\n): Selection;\nfunction convertSelection(\n selection: \"all\" | Iterable<Key> | null | undefined,\n): Selection | undefined;\nfunction convertSelection(\n selection: \"all\" | Iterable<Key> | null | undefined,\n defaultValue?: Selection,\n): Selection | undefined {\n if (!selection) {\n return defaultValue;\n }\n\n return selection === \"all\" ? \"all\" : new SelectionClass(selection);\n}\n\n/**\n * Manages raw state for multiple selection and focus in a collection.\n */\nexport function createMultipleSelectionState(\n props: MaybeAccessor<SelectionStateProps> = {},\n): MultipleSelectionState {\n const getProps = () => access(props);\n\n // Focus is a plain signal in Solid; upstream needs a ref + state pair only\n // because React requires both a synchronous read and a re-render trigger.\n const [isFocused, setIsFocused] = createSignal(false);\n const [focusedKey, setFocusedKeySignal] = createSignal<Key | null>(null);\n const [childFocusStrategy, setChildFocusStrategy] = createSignal<FocusStrategy | null>(null);\n\n const defaultSelectedKeys = convertSelection(\n getProps().defaultSelectedKeys,\n new SelectionClass(),\n );\n const [uncontrolledSelectedKeys, setUncontrolledSelectedKeys] =\n createSignal<Selection>(defaultSelectedKeys);\n\n const selectedKeys = createMemo<Selection>(() => {\n const p = getProps();\n if (p.selectedKeys !== undefined) {\n return convertSelection(p.selectedKeys, new SelectionClass());\n }\n return uncontrolledSelectedKeys();\n });\n\n // Selection behavior is seeded from the prop but kept in internal state so\n // that `setSelectionBehavior` (e.g. the long-press-to-select touch flow) can\n // override it. Two reactive rules mirror upstream's render-time logic.\n const selectionBehaviorProp = (): SelectionBehavior => getProps().selectionBehavior ?? \"toggle\";\n\n const [selectionBehavior, setSelectionBehaviorState] =\n createSignal<SelectionBehavior>(selectionBehaviorProp());\n\n // If the selectionBehavior prop is 'replace' but the current state is 'toggle'\n // (e.g. due to a long press to enter selection mode on touch) and the\n // selection becomes empty, reset the behavior back to 'replace'.\n createComputed(() => {\n const keys = selectedKeys();\n if (\n selectionBehaviorProp() === \"replace\" &&\n untrack(selectionBehavior) === \"toggle\" &&\n typeof keys === \"object\" &&\n keys.size === 0\n ) {\n setSelectionBehaviorState(\"replace\");\n }\n });\n\n // If the selectionBehavior prop changes, sync it into state.\n let lastSelectionBehavior = selectionBehaviorProp();\n createComputed(() => {\n const prop = selectionBehaviorProp();\n if (prop !== lastSelectionBehavior) {\n setSelectionBehaviorState(prop);\n lastSelectionBehavior = prop;\n }\n });\n\n const disabledKeys = createMemo<Set<Key>>(() => {\n const keys = getProps().disabledKeys;\n return keys ? new Set<Key>(keys) : new Set<Key>();\n });\n\n let lastSelectionEvent: Selection | null = null;\n\n const emitSelectionEvent = (keys: Selection) => {\n lastSelectionEvent = keys;\n getProps().onSelectionChange?.(keys);\n };\n\n const setSelectedKeys = (keys: Selection) => {\n const p = getProps();\n const current = selectedKeys();\n const shouldUpdate =\n p.allowDuplicateSelectionEvents ||\n keys === \"all\" ||\n current === \"all\" ||\n !equalSets(keys, current);\n\n if (!shouldUpdate) {\n return;\n }\n\n // Uncontrolled: store internally. Controlled: only notify.\n if (p.selectedKeys === undefined) {\n setUncontrolledSelectedKeys(keys);\n }\n emitSelectionEvent(keys);\n };\n\n const emitDuplicateSelectionEvent = (keys?: Selection) => {\n const eventKeys = keys ?? lastSelectionEvent;\n if (eventKeys == null) {\n return;\n }\n emitSelectionEvent(eventKeys);\n };\n\n return {\n get selectionMode() {\n return getProps().selectionMode ?? \"none\";\n },\n get selectionBehavior() {\n return selectionBehavior();\n },\n setSelectionBehavior(behavior: SelectionBehavior) {\n setSelectionBehaviorState(behavior);\n },\n get disallowEmptySelection() {\n return getProps().disallowEmptySelection ?? false;\n },\n get isFocused() {\n return isFocused();\n },\n setFocused(f: boolean) {\n setIsFocused(f);\n },\n get focusedKey() {\n return focusedKey();\n },\n get childFocusStrategy() {\n return childFocusStrategy();\n },\n setFocusedKey(key: Key | null, strategy: FocusStrategy = \"first\") {\n setFocusedKeySignal(key);\n setChildFocusStrategy(strategy);\n },\n get selectedKeys() {\n return selectedKeys();\n },\n get lastSelectionEvent() {\n return lastSelectionEvent;\n },\n setSelectedKeys,\n emitDuplicateSelectionEvent,\n get disabledKeys() {\n return disabledKeys();\n },\n get disabledBehavior() {\n return getProps().disabledBehavior ?? \"all\";\n },\n };\n}\n\n// Re-export the accessor type for convenience where a reactive read is wanted.\nexport type { Accessor };\n","/**\n * An interface for reading and updating multiple selection state.\n *\n * The upper of the two selection layers ported from upstream\n * (`@react-stately/selection`'s `SelectionManager`): the collection-aware\n * operations built on top of the raw {@link MultipleSelectionState}.\n *\n * React → Solid adaptations, all faithful to upstream's observable contract:\n * - Upstream re-instantiates `SelectionManager` every render to capture a\n * fresh `collection`. Here the manager is long-lived, so it captures a\n * reactive `collection` accessor and reads it live via `get collection()`.\n * - Upstream caches `_isSelectAll` for the lifetime of one render. A\n * long-lived manager would let that cache go stale, so it is dropped and\n * `isSelectAll` recomputes (it is consulted rarely — only by select-all UI).\n * - Our `CollectionNode` has no `'cell'` type (grids/trees use a separate\n * state engine), so the cell-selection branches are omitted.\n *\n * Based on @react-stately/selection.\n */\n\nimport { compareNodeOrder, getChildNodes, getFirstItem } from \"../collections/getChildNodes\";\nimport type { SelectionPressEvent } from \"../collections/createSelectionState\";\nimport type {\n Collection,\n CollectionNode,\n DisabledBehavior,\n FocusStrategy,\n Key,\n Selection as SelectionValue,\n SelectionBehavior,\n SelectionMode,\n} from \"../collections/types\";\nimport type { MultipleSelectionState } from \"./createMultipleSelectionState\";\nimport { Selection } from \"./Selection\";\n\n/** A delegate that can resolve a key range without walking the collection (e.g. a virtualized layout). */\nexport interface LayoutDelegate {\n getKeyRange?(from: Key, to: Key): Key[];\n}\n\nexport interface SelectionManagerOptions<T = unknown> {\n layoutDelegate?: LayoutDelegate;\n /**\n * The full (unfiltered) collection, used when materializing the 'all'\n * selection so that filtered-out items (e.g. by Autocomplete) are still\n * included.\n */\n fullCollection?: Collection<T>;\n}\n\n/**\n * An interface for reading and updating multiple selection state.\n */\nexport class SelectionManager<T = unknown> {\n private collectionAccessor: () => Collection<T>;\n private state: MultipleSelectionState;\n private layoutDelegate: LayoutDelegate | null;\n private fullCollection: Collection<T> | null;\n\n constructor(\n collection: () => Collection<T>,\n state: MultipleSelectionState,\n options?: SelectionManagerOptions<T>,\n ) {\n this.collectionAccessor = collection;\n this.state = state;\n this.layoutDelegate = options?.layoutDelegate ?? null;\n this.fullCollection = options?.fullCollection ?? null;\n }\n\n /** The collection the manager operates over (read live so it stays reactive). */\n get collection(): Collection<T> {\n return this.collectionAccessor();\n }\n\n /** The type of selection that is allowed in the collection. */\n get selectionMode(): SelectionMode {\n return this.state.selectionMode;\n }\n\n /** Whether the collection allows empty selection. */\n get disallowEmptySelection(): boolean {\n return this.state.disallowEmptySelection;\n }\n\n /** The selection behavior for the collection. */\n get selectionBehavior(): SelectionBehavior {\n return this.state.selectionBehavior;\n }\n\n /** Sets the selection behavior for the collection. */\n setSelectionBehavior(selectionBehavior: SelectionBehavior): void {\n this.state.setSelectionBehavior(selectionBehavior);\n }\n\n /** Whether the collection is currently focused. */\n get isFocused(): boolean {\n return this.state.isFocused;\n }\n\n /** Sets whether the collection is focused. */\n setFocused(isFocused: boolean): void {\n this.state.setFocused(isFocused);\n }\n\n /** The current focused key in the collection. */\n get focusedKey(): Key | null {\n return this.state.focusedKey;\n }\n\n /** Whether the first or last child of the focused key should receive focus. */\n get childFocusStrategy(): FocusStrategy | null {\n return this.state.childFocusStrategy;\n }\n\n /** Sets the focused key. */\n setFocusedKey(key: Key | null, childFocusStrategy?: FocusStrategy): void {\n if (key == null || this.collection.getItem(key)) {\n this.state.setFocusedKey(key, childFocusStrategy);\n }\n }\n\n /** The currently selected keys in the collection (materialized — 'all' is expanded). */\n get selectedKeys(): Set<Key> {\n const keys = this.state.selectedKeys;\n return keys === \"all\" ? new Set(this.getSelectAllKeys()) : keys;\n }\n\n /** The raw selection value for the collection. Either 'all' for select all, or a set of keys. */\n get rawSelection(): SelectionValue {\n return this.state.selectedKeys;\n }\n\n /** Last selection payload emitted through onSelectionChange. @internal */\n get lastSelectionEvent(): SelectionValue | null {\n return this.state.lastSelectionEvent;\n }\n\n /** Re-emits a selection payload without recomputing selection. @internal */\n emitDuplicateSelectionEvent(keys: SelectionValue | null = this.state.lastSelectionEvent): void {\n if (keys == null || this.selectionMode === \"none\") {\n return;\n }\n\n this.state.emitDuplicateSelectionEvent(keys);\n }\n\n /** Returns whether a key is selected. */\n isSelected(key: Key): boolean {\n if (this.state.selectionMode === \"none\") {\n return false;\n }\n\n const mappedKey = this.getKey(key);\n if (mappedKey == null) {\n return false;\n }\n const selectedKeys = this.state.selectedKeys;\n return selectedKeys === \"all\" ? this.canSelectItem(mappedKey) : selectedKeys.has(mappedKey);\n }\n\n /** Whether the selection is empty. */\n get isEmpty(): boolean {\n return this.state.selectedKeys !== \"all\" && this.state.selectedKeys.size === 0;\n }\n\n /** Whether all items in the collection are selected. */\n get isSelectAll(): boolean {\n if (this.isEmpty) {\n return false;\n }\n\n const selectedKeys = this.state.selectedKeys;\n if (selectedKeys === \"all\") {\n return true;\n }\n\n const allKeys = this.getSelectAllKeys();\n return allKeys.every((k) => selectedKeys.has(k));\n }\n\n get firstSelectedKey(): Key | null {\n let first: CollectionNode<T> | null = null;\n for (const key of this.state.selectedKeys) {\n const item = this.collection.getItem(key);\n if (!first || (item && compareNodeOrder(this.collection, item, first) < 0)) {\n first = item;\n }\n }\n\n return first?.key ?? null;\n }\n\n get lastSelectedKey(): Key | null {\n let last: CollectionNode<T> | null = null;\n for (const key of this.state.selectedKeys) {\n const item = this.collection.getItem(key);\n if (!last || (item && compareNodeOrder(this.collection, item, last) > 0)) {\n last = item;\n }\n }\n\n return last?.key ?? null;\n }\n\n get disabledKeys(): Set<Key> {\n return this.state.disabledKeys;\n }\n\n get disabledBehavior(): DisabledBehavior {\n return this.state.disabledBehavior;\n }\n\n /** Extends the selection to the given key. */\n extendSelection(toKey: Key): void {\n if (this.selectionMode === \"none\") {\n return;\n }\n\n if (this.selectionMode === \"single\") {\n this.replaceSelection(toKey);\n return;\n }\n\n const mappedToKey = this.getKey(toKey);\n if (mappedToKey == null) {\n return;\n }\n\n let selection: Selection;\n\n // Only select the one key if coming from a select all.\n const currentSelection = this.state.selectedKeys;\n if (currentSelection === \"all\") {\n selection = new Selection([mappedToKey], mappedToKey, mappedToKey);\n } else {\n const selectedKeys = currentSelection as Selection;\n const anchorKey = selectedKeys.anchorKey ?? mappedToKey;\n selection = new Selection(selectedKeys, anchorKey, mappedToKey);\n for (const key of this.getKeyRange(anchorKey, selectedKeys.currentKey ?? mappedToKey)) {\n selection.delete(key);\n }\n\n for (const key of this.getKeyRange(mappedToKey, anchorKey)) {\n if (this.canSelectItem(key)) {\n selection.add(key);\n }\n }\n }\n\n this.state.setSelectedKeys(selection);\n }\n\n private getKeyRange(from: Key, to: Key): Key[] {\n const fromItem = this.collection.getItem(from);\n const toItem = this.collection.getItem(to);\n if (fromItem && toItem) {\n if (compareNodeOrder(this.collection, fromItem, toItem) <= 0) {\n return this.getKeyRangeInternal(from, to);\n }\n\n return this.getKeyRangeInternal(to, from);\n }\n\n return [];\n }\n\n private getKeyRangeInternal(from: Key, to: Key): Key[] {\n if (this.layoutDelegate?.getKeyRange) {\n return this.layoutDelegate.getKeyRange(from, to);\n }\n\n const keys: Key[] = [];\n let key: Key | null = from;\n while (key != null) {\n const item = this.collection.getItem(key);\n if (item && item.type === \"item\") {\n keys.push(key);\n }\n\n if (key === to) {\n return keys;\n }\n\n key = this.collection.getKeyAfter(key);\n }\n\n return [];\n }\n\n private getKey(key: Key): Key | null {\n let item = this.collection.getItem(key);\n if (!item) {\n // ¯\\_(ツ)_/¯\n return key;\n }\n\n // Find a parent item to select.\n while (item && item.type !== \"item\" && item.parentKey != null) {\n item = this.collection.getItem(item.parentKey);\n }\n\n if (!item || item.type !== \"item\") {\n return null;\n }\n\n return item.key;\n }\n\n /** Toggles whether the given key is selected. */\n toggleSelection(key: Key): void {\n if (this.selectionMode === \"none\") {\n return;\n }\n\n if (this.selectionMode === \"single\" && !this.isSelected(key)) {\n this.replaceSelection(key);\n return;\n }\n\n const mappedKey = this.getKey(key);\n if (mappedKey == null) {\n return;\n }\n\n const keys = new Selection(\n this.state.selectedKeys === \"all\" ? this.getSelectAllKeys() : this.state.selectedKeys,\n );\n if (keys.has(mappedKey)) {\n keys.delete(mappedKey);\n // TODO: move anchor to last selected key...\n } else if (this.canSelectItem(mappedKey)) {\n keys.add(mappedKey);\n keys.anchorKey = mappedKey;\n keys.currentKey = mappedKey;\n }\n\n if (this.disallowEmptySelection && keys.size === 0) {\n return;\n }\n\n this.state.setSelectedKeys(keys);\n }\n\n /** Replaces the selection with only the given key. */\n replaceSelection(key: Key): void {\n if (this.selectionMode === \"none\") {\n return;\n }\n\n const mappedKey = this.getKey(key);\n if (mappedKey == null) {\n return;\n }\n\n const selection = this.canSelectItem(mappedKey)\n ? new Selection([mappedKey], mappedKey, mappedKey)\n : new Selection();\n\n this.state.setSelectedKeys(selection);\n }\n\n /** Replaces the selection with the given keys. */\n setSelectedKeys(keys: Iterable<Key>): void {\n if (this.selectionMode === \"none\") {\n return;\n }\n\n const selection = new Selection();\n for (const key of keys) {\n const mappedKey = this.getKey(key);\n if (mappedKey != null) {\n selection.add(mappedKey);\n if (this.selectionMode === \"single\") {\n break;\n }\n }\n }\n\n this.state.setSelectedKeys(selection);\n }\n\n private getSelectAllKeys(): Key[] {\n // Use the full (unfiltered) collection when available so that materializing\n // the 'all' selection includes items that are currently filtered out.\n const collection = this.fullCollection ?? this.collection;\n const keys: Key[] = [];\n const addKeys = (key: Key | null) => {\n while (key != null) {\n if (this.canSelectItemIn(key, collection)) {\n const item = collection.getItem(key);\n if (item?.type === \"item\") {\n keys.push(key);\n }\n\n // Add child keys for sections.\n if (item?.hasChildNodes && item.type !== \"item\") {\n addKeys(getFirstItem(getChildNodes(item, collection))?.key ?? null);\n }\n }\n\n key = collection.getKeyAfter(key);\n }\n };\n\n addKeys(collection.getFirstKey());\n return keys;\n }\n\n /** Selects all items in the collection. */\n selectAll(): void {\n if (!this.isSelectAll && this.selectionMode === \"multiple\") {\n this.state.setSelectedKeys(\"all\");\n }\n }\n\n /** Removes all keys from the selection. */\n clearSelection(): void {\n if (\n !this.disallowEmptySelection &&\n (this.state.selectedKeys === \"all\" || this.state.selectedKeys.size > 0)\n ) {\n this.state.setSelectedKeys(new Selection());\n }\n }\n\n /** Toggles between select all and an empty selection. */\n toggleSelectAll(): void {\n if (this.isSelectAll) {\n this.clearSelection();\n } else {\n this.selectAll();\n }\n }\n\n select(key: Key, e?: SelectionPressEvent): void {\n if (this.selectionMode === \"none\") {\n return;\n }\n\n if (this.selectionMode === \"single\") {\n if (this.isSelected(key) && !this.disallowEmptySelection) {\n this.toggleSelection(key);\n } else {\n this.replaceSelection(key);\n }\n } else if (\n this.selectionBehavior === \"toggle\" ||\n (e && (e.pointerType === \"touch\" || e.pointerType === \"virtual\"))\n ) {\n // touch / virtual (VoiceOver) have no modifier keys, so multi-select is\n // only reachable by toggling.\n this.toggleSelection(key);\n } else {\n this.replaceSelection(key);\n }\n }\n\n /** Returns whether the current selection is equal to the given selection. */\n isSelectionEqual(selection: Set<Key>): boolean {\n if (selection === this.state.selectedKeys) {\n return true;\n }\n\n // Check if the set of keys match.\n const selectedKeys = this.selectedKeys;\n if (selection.size !== selectedKeys.size) {\n return false;\n }\n\n for (const key of selection) {\n if (!selectedKeys.has(key)) {\n return false;\n }\n }\n\n for (const key of selectedKeys) {\n if (!selection.has(key)) {\n return false;\n }\n }\n\n return true;\n }\n\n canSelectItem(key: Key): boolean {\n return this.canSelectItemIn(key, this.collection);\n }\n\n private canSelectItemIn(key: Key, collection: Collection<T>): boolean {\n if (this.state.selectionMode === \"none\" || this.state.disabledKeys.has(key)) {\n return false;\n }\n\n const item = collection.getItem(key);\n if (!item || item.isDisabled || item.props?.isDisabled) {\n return false;\n }\n\n return true;\n }\n\n isDisabled(key: Key): boolean {\n const item = this.collection.getItem(key);\n return (\n this.state.disabledBehavior === \"all\" &&\n (this.state.disabledKeys.has(key) || !!item?.props?.isDisabled) &&\n item?.props?.disabledBehavior !== \"selection\"\n );\n }\n\n isLink(key: Key): boolean {\n return !!this.collection.getItem(key)?.props?.href;\n }\n\n getItemProps(key: Key): Record<string, unknown> | undefined {\n return this.collection.getItem(key)?.props;\n }\n\n withCollection(collection: Collection<T>): SelectionManager<T> {\n return new SelectionManager<T>(() => collection, this.state, {\n layoutDelegate: this.layoutDelegate ?? undefined,\n fullCollection: this.fullCollection ?? this.collection,\n });\n }\n\n /**\n * Like {@link withCollection}, but the collection is supplied as a live\n * accessor so the returned manager stays reactive as the collection recomputes\n * (e.g. an Autocomplete filter narrowing the list as the user types). The\n * shared underlying selection/focus state is preserved, and the original\n * (unfiltered) collection is retained as `fullCollection` so a select-all\n * still materializes the filtered-out keys.\n */\n withCollectionAccessor(collection: () => Collection<T>): SelectionManager<T> {\n return new SelectionManager<T>(collection, this.state, {\n layoutDelegate: this.layoutDelegate ?? undefined,\n fullCollection: this.fullCollection ?? this.collection,\n });\n }\n}\n","/**\n * State management for list-like components.\n * Combines collection and selection state.\n * Based on @react-stately/list.\n */\n\nimport { createMemo, createEffect, untrack, type Accessor } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils\";\nimport { ListCollection } from \"./ListCollection\";\nimport type { SelectionState, SelectionPressEvent } from \"./createSelectionState\";\nimport { createMultipleSelectionState } from \"../selection/createMultipleSelectionState\";\nimport { SelectionManager } from \"../selection/SelectionManager\";\nimport type {\n Collection,\n CollectionItemLike,\n CollectionNode,\n DisabledBehavior,\n FocusStrategy,\n Key,\n SelectionBehavior,\n SelectionMode,\n} from \"./types\";\n\nexport interface ListStateProps<T = unknown> {\n /** The items in the list (for dynamic rendering). */\n items?: T[];\n /** Function to get a key from an item. */\n getKey?: (item: T) => Key;\n /** Function to get text value from an item. */\n getTextValue?: (item: T) => string;\n /** Function to check if an item is disabled. */\n getDisabled?: (item: T) => boolean;\n /** Keys of disabled items. */\n disabledKeys?: Iterable<Key>;\n /** How disabled keys behave. */\n disabledBehavior?: DisabledBehavior;\n /** The selection mode. */\n selectionMode?: SelectionMode;\n /** How selection behaves on interaction. */\n selectionBehavior?: SelectionBehavior;\n /** Whether empty selection is disallowed. */\n disallowEmptySelection?: boolean;\n /** Currently selected keys (controlled). */\n selectedKeys?: \"all\" | Iterable<Key>;\n /** Default selected keys (uncontrolled). */\n defaultSelectedKeys?: \"all\" | Iterable<Key>;\n /** Handler for selection changes. */\n onSelectionChange?: (keys: \"all\" | Set<Key>) => void;\n /** Whether to allow duplicate selection events. */\n allowDuplicateSelectionEvents?: boolean;\n}\n\nexport interface ListState<T = unknown> extends SelectionState {\n /** The collection of items. */\n readonly collection: Accessor<Collection<T>>;\n /** The collection-aware selection manager (single source of truth for selection). */\n readonly selectionManager: SelectionManager<T>;\n /** Whether the collection is focused. */\n readonly isFocused: Accessor<boolean>;\n /** Set the focused state. */\n setFocused(isFocused: boolean): void;\n /** The currently focused key. */\n readonly focusedKey: Accessor<Key | null>;\n /** Set the focused key. */\n setFocusedKey(key: Key | null, childStrategy?: FocusStrategy): void;\n /** The child focus strategy. */\n readonly childFocusStrategy: Accessor<FocusStrategy | null>;\n}\n\n/**\n * Creates state for a list component with selection.\n */\nexport function createListState<T = unknown>(\n props: MaybeAccessor<ListStateProps<T>>,\n): ListState<T> {\n const getProps = () => access(props);\n\n // Build collection from items (memoized to avoid rebuilding on every access)\n const collection: Accessor<Collection<T>> = createMemo(() => {\n const p = getProps();\n const items = p.items ?? [];\n\n const nodes: CollectionNode<T>[] = items.map((item, index) => {\n const o = item as CollectionItemLike;\n const key = p.getKey?.(item) ?? o.key ?? o.id ?? index;\n const textValue = p.getTextValue?.(item) ?? o.textValue ?? o.label ?? String(item);\n const isDisabled = p.getDisabled?.(item) ?? o.isDisabled ?? false;\n\n return {\n type: \"item\" as const,\n key,\n value: item,\n textValue,\n rendered: null!,\n level: 0,\n index,\n parentKey: null,\n hasChildNodes: false,\n childNodes: [],\n isDisabled,\n };\n });\n\n return new ListCollection(nodes);\n });\n\n // Combine disabled keys from props and items (memoized)\n const combinedDisabledKeys = createMemo((): Iterable<Key> => {\n const p = getProps();\n const propsDisabled = p.disabledKeys ? [...p.disabledKeys] : [];\n const itemDisabled: Key[] = [];\n\n const coll = collection();\n for (const node of coll) {\n if (node.isDisabled) {\n itemDisabled.push(node.key);\n }\n }\n\n return [...new Set([...propsDisabled, ...itemDisabled])];\n });\n\n // Raw selection + focus state (the lower layer). This owns the selected keys,\n // focus, selection behavior, and disabled keys, but is not collection-aware.\n const state = createMultipleSelectionState({\n get selectionMode() {\n return getProps().selectionMode;\n },\n get selectionBehavior() {\n return getProps().selectionBehavior;\n },\n get disallowEmptySelection() {\n return getProps().disallowEmptySelection;\n },\n get selectedKeys() {\n return getProps().selectedKeys;\n },\n get defaultSelectedKeys() {\n return getProps().defaultSelectedKeys;\n },\n get onSelectionChange() {\n return getProps().onSelectionChange;\n },\n get disabledKeys() {\n return combinedDisabledKeys();\n },\n get disabledBehavior() {\n return getProps().disabledBehavior;\n },\n get allowDuplicateSelectionEvents() {\n return getProps().allowDuplicateSelectionEvents;\n },\n });\n\n // The collection-aware selection manager (the upper layer): the single source\n // of truth for every selection operation. It reads the collection live so it\n // stays reactive as the collection memo recomputes.\n const selectionManager = new SelectionManager<T>(() => collection(), state);\n\n return {\n collection,\n selectionManager,\n\n // Focus — delegate to the raw state (the single source of truth). The\n // setter routes through the manager so it inherits the existence guard and\n // the upstream 'first' child-focus default.\n isFocused: () => state.isFocused,\n setFocused: (isFocused: boolean) => state.setFocused(isFocused),\n focusedKey: () => state.focusedKey,\n setFocusedKey: (key: Key | null, childStrategy?: FocusStrategy) =>\n selectionManager.setFocusedKey(key, childStrategy),\n childFocusStrategy: () => state.childFocusStrategy,\n\n // Flattened selection surface — delegates to the manager so the list path\n // shares one faithful engine. extendSelection keeps its legacy second\n // argument for back-compat, but ignores it (the manager reads the\n // collection itself).\n selectionMode: () => selectionManager.selectionMode,\n selectionBehavior: () => selectionManager.selectionBehavior,\n disallowEmptySelection: () => selectionManager.disallowEmptySelection,\n selectedKeys: () => state.selectedKeys,\n disabledKeys: () => selectionManager.disabledKeys,\n disabledBehavior: () => selectionManager.disabledBehavior,\n isEmpty: () => selectionManager.isEmpty,\n isSelectAll: () => selectionManager.isSelectAll,\n isSelected: (key: Key) => selectionManager.isSelected(key),\n isDisabled: (key: Key) => selectionManager.isDisabled(key),\n setSelectionBehavior: (behavior: SelectionBehavior) =>\n selectionManager.setSelectionBehavior(behavior),\n toggleSelection: (key: Key) => selectionManager.toggleSelection(key),\n replaceSelection: (key: Key) => selectionManager.replaceSelection(key),\n setSelectedKeys: (keys: Iterable<Key>) => selectionManager.setSelectedKeys(keys),\n selectAll: () => selectionManager.selectAll(),\n clearSelection: () => selectionManager.clearSelection(),\n toggleSelectAll: () => selectionManager.toggleSelectAll(),\n extendSelection: (toKey: Key, _collection?: Collection) =>\n selectionManager.extendSelection(toKey),\n select: (key: Key, e?: SelectionPressEvent) => selectionManager.select(key, e),\n };\n}\n\n/** A collection filter predicate: `(nodeTextValue, node) => keep`. */\nexport type ListFilterFn<T = unknown> = (nodeValue: string, node: CollectionNode<T>) => boolean;\n\n/**\n * Wraps a {@link ListState} so its collection is filtered by `filterFn`, returning\n * a new (reactive) ListState. Mirrors @react-stately's `UNSTABLE_useFilteredListState`\n * (used by Autocomplete): the filter re-runs as the predicate — which typically\n * closes over the current input value — or the base collection changes; a single\n * stable, collection-aware manager reads the narrowed collection live and shares\n * the base selection/focus state; and the focused key is reset to the nearest\n * surviving item when the current one is filtered out.\n */\nexport function createFilteredListState<T = unknown>(\n state: ListState<T>,\n filterFn: Accessor<ListFilterFn<T> | null | undefined>,\n): ListState<T> {\n const collection: Accessor<Collection<T>> = createMemo(() => {\n const fn = filterFn();\n const base = state.collection();\n return fn && base.filter ? base.filter(fn) : base;\n });\n\n // One stable manager reading the filtered collection live; shares the base\n // manager's underlying selection/focus state and retains the unfiltered\n // collection as `fullCollection` (so select-all still covers filtered-out keys).\n const selectionManager = state.selectionManager.withCollectionAccessor(() => collection());\n\n // Reset the focused key if the item it points at was filtered out, walking\n // forward (then backward) through the previous collection to the nearest\n // surviving, enabled item. Mirrors @react-stately's useFocusedKeyReset.\n let cachedCollection: Collection<T> | null = null;\n createEffect(() => {\n const coll = collection();\n const focusedKey = untrack(() => state.focusedKey());\n if (focusedKey != null && !coll.getItem(focusedKey) && cachedCollection) {\n let key = cachedCollection.getKeyAfter(focusedKey);\n let nextFocusedKey: Key | null = null;\n while (key != null) {\n const node = coll.getItem(key);\n if (node && node.type === \"item\" && !selectionManager.isDisabled(key)) {\n nextFocusedKey = key;\n break;\n }\n key = cachedCollection.getKeyAfter(key);\n }\n if (nextFocusedKey == null) {\n key = cachedCollection.getKeyBefore(focusedKey);\n while (key != null) {\n const node = coll.getItem(key);\n if (node && node.type === \"item\" && !selectionManager.isDisabled(key)) {\n nextFocusedKey = key;\n break;\n }\n key = cachedCollection.getKeyBefore(key);\n }\n }\n untrack(() => state.setFocusedKey(nextFocusedKey));\n }\n cachedCollection = coll;\n });\n\n // Spread the base state for type completeness + shared focus fields, then\n // override the collection and every collection-aware operation so navigation,\n // selection, and disabled checks all see the narrowed collection.\n return {\n ...state,\n collection,\n selectionManager,\n setFocusedKey: (key: Key | null, childStrategy?: FocusStrategy) =>\n selectionManager.setFocusedKey(key, childStrategy),\n selectionMode: () => selectionManager.selectionMode,\n selectionBehavior: () => selectionManager.selectionBehavior,\n disallowEmptySelection: () => selectionManager.disallowEmptySelection,\n disabledKeys: () => selectionManager.disabledKeys,\n isEmpty: () => selectionManager.isEmpty,\n isSelectAll: () => selectionManager.isSelectAll,\n isSelected: (key: Key) => selectionManager.isSelected(key),\n isDisabled: (key: Key) => selectionManager.isDisabled(key),\n setSelectionBehavior: (behavior: SelectionBehavior) =>\n selectionManager.setSelectionBehavior(behavior),\n toggleSelection: (key: Key) => selectionManager.toggleSelection(key),\n replaceSelection: (key: Key) => selectionManager.replaceSelection(key),\n setSelectedKeys: (keys: Iterable<Key>) => selectionManager.setSelectedKeys(keys),\n selectAll: () => selectionManager.selectAll(),\n clearSelection: () => selectionManager.clearSelection(),\n toggleSelectAll: () => selectionManager.toggleSelectAll(),\n extendSelection: (toKey: Key) => selectionManager.extendSelection(toKey),\n select: (key: Key, e?: SelectionPressEvent) => selectionManager.select(key, e),\n };\n}\n\n/**\n * Props for single selection list state.\n */\nexport interface SingleSelectListStateProps<T = unknown> extends Omit<\n ListStateProps<T>,\n \"selectionMode\" | \"selectedKeys\" | \"defaultSelectedKeys\" | \"onSelectionChange\"\n> {\n /** The currently selected key (controlled). */\n selectedKey?: Key | null;\n /** The default selected key (uncontrolled). */\n defaultSelectedKey?: Key;\n /** Handler for selection changes. */\n onSelectionChange?: (key: Key | null) => void;\n}\n\nexport interface SingleSelectListState<T = unknown> extends ListState<T> {\n /** The currently selected key. */\n readonly selectedKey: Accessor<Key | null>;\n /** Set the selected key. */\n setSelectedKey(key: Key | null): void;\n /** The currently selected item. */\n readonly selectedItem: Accessor<CollectionNode<T> | null>;\n}\n\n/**\n * Creates state for a single-select list component.\n */\nexport function createSingleSelectListState<T = unknown>(\n props: MaybeAccessor<SingleSelectListStateProps<T>>,\n): SingleSelectListState<T> {\n const getProps = () => access(props);\n\n // Convert single selection props to multiple selection props\n const listState = createListState<T>({\n get items() {\n return getProps().items;\n },\n get getKey() {\n return getProps().getKey;\n },\n get getTextValue() {\n return getProps().getTextValue;\n },\n get getDisabled() {\n return getProps().getDisabled;\n },\n get disabledKeys() {\n return getProps().disabledKeys;\n },\n get disabledBehavior() {\n return getProps().disabledBehavior;\n },\n selectionMode: \"single\",\n disallowEmptySelection: true,\n allowDuplicateSelectionEvents: true,\n get selectedKeys() {\n const key = getProps().selectedKey;\n return key != null ? [key] : [];\n },\n get defaultSelectedKeys() {\n const key = getProps().defaultSelectedKey;\n return key != null ? [key] : undefined;\n },\n onSelectionChange(keys) {\n if (keys === \"all\") return;\n const key = keys.values().next().value ?? null;\n getProps().onSelectionChange?.(key);\n },\n });\n\n const selectedKey: Accessor<Key | null> = () => {\n const keys = listState.selectedKeys();\n if (keys === \"all\") return null;\n return keys.values().next().value ?? null;\n };\n\n const setSelectedKey = (key: Key | null) => {\n if (key === null) {\n listState.clearSelection();\n } else {\n listState.replaceSelection(key);\n }\n };\n\n const selectedItem: Accessor<CollectionNode<T> | null> = () => {\n const key = selectedKey();\n if (key === null) return null;\n return listState.collection().getItem(key);\n };\n\n return {\n ...listState,\n selectedKey,\n setSelectedKey,\n selectedItem,\n };\n}\n","/**\n * State management for menu components.\n * Based on @react-stately/menu.\n */\n\nimport { access, type MaybeAccessor } from \"../utils\";\nimport { createListState, type ListState, type ListStateProps } from \"./createListState\";\nimport type { Key } from \"./types\";\n\nexport interface MenuStateProps<T = unknown> extends ListStateProps<T> {\n /** Handler called when an item is activated (pressed). */\n onAction?: (key: Key) => void;\n /** Handler called when the menu should close. */\n onClose?: () => void;\n}\n\nexport interface MenuState<T = unknown> extends ListState<T> {\n /** Close the menu. */\n close(): void;\n}\n\n/**\n * Creates state for a menu component.\n * Menus are single-select lists that support actions.\n */\nexport function createMenuState<T = unknown>(\n props: MaybeAccessor<MenuStateProps<T>>,\n): MenuState<T> {\n const getProps = () => access(props);\n\n // Menus default to action-only items, but can opt into single or multiple selection.\n const listState = createListState<T>({\n get items() {\n return getProps().items;\n },\n get getKey() {\n return getProps().getKey;\n },\n get getTextValue() {\n return getProps().getTextValue;\n },\n get getDisabled() {\n return getProps().getDisabled;\n },\n get disabledKeys() {\n return getProps().disabledKeys;\n },\n get disabledBehavior() {\n return getProps().disabledBehavior;\n },\n get selectionMode() {\n return getProps().selectionMode ?? \"none\";\n },\n get disallowEmptySelection() {\n return getProps().disallowEmptySelection;\n },\n get selectedKeys() {\n if ((getProps().selectionMode ?? \"none\") === \"none\") return undefined;\n return getProps().selectedKeys;\n },\n get defaultSelectedKeys() {\n if ((getProps().selectionMode ?? \"none\") === \"none\") return undefined;\n return getProps().defaultSelectedKeys;\n },\n get onSelectionChange() {\n if ((getProps().selectionMode ?? \"none\") === \"none\") return undefined;\n return getProps().onSelectionChange;\n },\n get selectionBehavior() {\n return getProps().selectionBehavior;\n },\n get allowDuplicateSelectionEvents() {\n return getProps().allowDuplicateSelectionEvents;\n },\n });\n\n const close = () => {\n getProps().onClose?.();\n };\n\n return {\n ...listState,\n close,\n };\n}\n\nexport interface MenuTriggerStateProps {\n /** Whether the menu is open (controlled). */\n isOpen?: boolean;\n /** Default open state (uncontrolled). */\n defaultOpen?: boolean;\n /** Handler called when the open state changes. */\n onOpenChange?: (isOpen: boolean) => void;\n}\n\nexport interface MenuTriggerState {\n /** Whether the menu is open. */\n readonly isOpen: () => boolean;\n /** Open the menu. */\n open(): void;\n /** Close the menu. */\n close(): void;\n /** Toggle the menu. */\n toggle(): void;\n /** Focus strategy for when the menu opens. */\n readonly focusStrategy: () => \"first\" | \"last\" | null;\n /** Set the focus strategy. */\n setFocusStrategy(strategy: \"first\" | \"last\" | null): void;\n}\n\n/**\n * Creates state for a menu trigger (button that opens a menu).\n * This is essentially the same as overlay trigger state but with focus strategy.\n */\nexport { createOverlayTriggerState as createMenuTriggerState } from \"../overlays\";\n","/**\n * CalendarState for Solid-Stately\n *\n * Provides state management for calendar components.\n * Based on @react-stately/calendar useCalendarState\n */\n\nimport { createSignal, createMemo, createEffect, type Accessor } from \"solid-js\";\nimport {\n type Calendar as InternationalizedCalendar,\n type CalendarDate,\n type CalendarIdentifier,\n type DateValue,\n GregorianCalendar,\n today,\n getLocalTimeZone,\n isEqualCalendar,\n isSameDay,\n isSameMonth,\n startOfMonth,\n endOfMonth,\n startOfWeek,\n getWeeksInMonth,\n DateFormatter,\n createCalendar as intlCreateCalendar,\n toCalendar as intlToCalendar,\n toCalendarDate as intlToCalendarDate,\n} from \"@internationalized/date\";\nimport { access, type MaybeAccessor } from \"../utils\";\n\nexport type ValidationState = \"valid\" | \"invalid\";\nexport type CalendarPageBehavior = \"single\" | \"visible\";\nexport type CalendarSelectionAlignment = \"start\" | \"center\" | \"end\";\nexport type CalendarDayOfWeek = \"sun\" | \"mon\" | \"tue\" | \"wed\" | \"thu\" | \"fri\" | \"sat\";\n\nconst dayOfWeekNames: CalendarDayOfWeek[] = [\"sun\", \"mon\", \"tue\", \"wed\", \"thu\", \"fri\", \"sat\"];\n\nexport type CalendarSelectionMode = \"single\" | \"multiple\";\nexport type CalendarValueType<T, M extends CalendarSelectionMode> = M extends \"single\"\n ? T\n : readonly T[];\n\nexport interface CalendarStateProps<\n T extends DateValue = DateValue,\n M extends CalendarSelectionMode = \"single\",\n> {\n /** The current value (controlled). */\n value?: MaybeAccessor<CalendarValueType<T | null, M> | undefined>;\n /** The default value (uncontrolled). */\n defaultValue?: CalendarValueType<T | null, M> | null;\n /** Handler called when the value changes. */\n onChange?: (value: CalendarValueType<T | null, M>) => void;\n /** Whether single or multiple date selection is enabled. */\n selectionMode?: MaybeAccessor<M>;\n /** The minimum allowed date. */\n minValue?: MaybeAccessor<DateValue | undefined>;\n /** The maximum allowed date. */\n maxValue?: MaybeAccessor<DateValue | undefined>;\n /** Whether the calendar is disabled. */\n isDisabled?: MaybeAccessor<boolean>;\n /** Whether the calendar is read-only. */\n isReadOnly?: MaybeAccessor<boolean>;\n /** Whether dates outside the visible range are automatically focused. */\n autoFocus?: boolean;\n /** The date that is focused when the calendar first mounts. */\n focusedValue?: MaybeAccessor<DateValue | null | undefined>;\n /** The default focused date (uncontrolled). */\n defaultFocusedValue?: DateValue;\n /** Handler called when the focused date changes. */\n onFocusChange?: (date: CalendarDate) => void;\n /** The locale to use for formatting. */\n locale?: MaybeAccessor<string | undefined>;\n /** Creates a calendar object for a locale calendar identifier. */\n createCalendar?: (identifier: CalendarIdentifier) => InternationalizedCalendar;\n /** Callback that is called for each date in the calendar to determine if it is unavailable. */\n isDateUnavailable?: (date: DateValue) => boolean;\n /** The number of months to display at once. */\n visibleMonths?: number;\n /** Controls whether paging advances by one month or by the visible month range. */\n pageBehavior?: CalendarPageBehavior;\n /** Determines how the visible months align around the initial focused date. */\n selectionAlignment?: CalendarSelectionAlignment;\n /** Whether to automatically focus the calendar when it is mounted. */\n autoFocusOnMount?: boolean;\n /** Controls which days are disabled. */\n isDateDisabled?: (date: DateValue) => boolean;\n /** Validation state. */\n validationState?: MaybeAccessor<ValidationState | undefined>;\n /** Error message. */\n errorMessage?: string;\n /** The first day of the week (0 = Sunday, 1 = Monday, etc.). */\n firstDayOfWeek?: 0 | 1 | 2 | 3 | 4 | 5 | 6;\n}\n\nexport interface CalendarState<\n T extends DateValue = DateValue,\n M extends CalendarSelectionMode = \"single\",\n> {\n /** Whether single or multiple selection is enabled. */\n selectionMode: Accessor<CalendarSelectionMode>;\n /** The currently selected date(s). */\n value: Accessor<CalendarValueType<T | null, M>>;\n /** Sets the selected date(s). */\n setValue: (value: CalendarValueType<T | null, M>) => void;\n /** The currently focused date. */\n focusedDate: Accessor<CalendarDate>;\n /** Sets the focused date. */\n setFocusedDate: (date: CalendarDate) => void;\n /** The minimum allowed date that a user may select. */\n minValue: Accessor<DateValue | null>;\n /** The maximum allowed date that a user may select. */\n maxValue: Accessor<DateValue | null>;\n /** Whether the calendar is disabled. */\n isDisabled: Accessor<boolean>;\n /** Whether the calendar is read-only. */\n isReadOnly: Accessor<boolean>;\n /** The visible date range (first and last day of visible month(s)). */\n visibleRange: Accessor<{ start: CalendarDate; end: CalendarDate }>;\n /** The timezone used for date calculations. */\n timeZone: string;\n /** The locale used for formatting and locale-specific week starts. */\n locale: Accessor<string>;\n /** The explicitly requested first weekday, or undefined for the locale default. */\n firstDayOfWeek: Accessor<CalendarDayOfWeek | undefined>;\n /** The validation state. */\n validationState: Accessor<ValidationState | undefined>;\n /** Whether the current value is invalid according to validation state. */\n isValueInvalid: Accessor<boolean>;\n /** Whether a date is selected. */\n isSelected: (date: DateValue) => boolean;\n /** Whether a date is focused. */\n isCellFocused: (date: DateValue) => boolean;\n /** Whether a date is unavailable. */\n isCellUnavailable: (date: DateValue) => boolean;\n /** Whether a date is disabled. */\n isCellDisabled: (date: DateValue) => boolean;\n /** Whether a date is outside the visible range. */\n isOutsideVisibleRange: (date: DateValue) => boolean;\n /** Whether a date is invalid. */\n isInvalid: (date: DateValue) => boolean;\n /** Moves focus to the previous page (month). */\n focusPreviousPage: () => void;\n /** Moves focus to the next page (month). */\n focusNextPage: () => void;\n /** Moves focus to the previous section (year). */\n focusPreviousSection: () => void;\n /** Moves focus to the next section (year). */\n focusNextSection: () => void;\n /** Moves focus to the previous day. */\n focusPreviousDay: () => void;\n /** Moves focus to the next day. */\n focusNextDay: () => void;\n /** Moves focus to the previous week. */\n focusPreviousWeek: () => void;\n /** Moves focus to the next week. */\n focusNextWeek: () => void;\n /** Moves focus to the start of the month. */\n focusPageStart: () => void;\n /** Moves focus to the end of the month. */\n focusPageEnd: () => void;\n /** Selects the focused date. */\n selectFocusedDate: () => void;\n /** Selects a specific date. */\n selectDate: (date: CalendarDate) => void;\n /** Whether focus is currently within the calendar. */\n isFocused: Accessor<boolean>;\n /** Sets whether focus is within the calendar. */\n setFocused: (focused: boolean) => void;\n /** Gets the dates for a week in the visible range. */\n getDatesInWeek: (weekIndex: number, monthStartDate?: CalendarDate) => (CalendarDate | null)[];\n /** Gets the number of weeks in a month. */\n getWeeksInMonth: (date?: CalendarDate) => number;\n /** The week day headers. */\n weekDays: Accessor<string[]>;\n /** The title for the calendar (formatted month and year). */\n title: Accessor<string>;\n /** The number of visible months. */\n visibleMonths: number;\n /** Whether the calendar is paginating (for animations). */\n isPaginating: Accessor<boolean>;\n}\n\n/**\n * Provides state management for a calendar component.\n */\nexport function createCalendarState<\n T extends DateValue = CalendarDate,\n M extends CalendarSelectionMode = \"single\",\n>(props: CalendarStateProps<T, M> = {}): CalendarState<T, M> {\n const timeZone = getLocalTimeZone();\n const locale = createMemo(() => access(props.locale) ?? \"en-US\");\n const minValueState = createMemo(() => access(props.minValue) ?? null);\n const maxValueState = createMemo(() => access(props.maxValue) ?? null);\n const selectionMode = createMemo<CalendarSelectionMode>(\n () => access(props.selectionMode) ?? \"single\",\n );\n const resolvedOptions = createMemo(() => new DateFormatter(locale()).resolvedOptions());\n const calendar = createMemo(() =>\n (props.createCalendar ?? intlCreateCalendar)(resolvedOptions().calendar as CalendarIdentifier),\n );\n const visibleMonths = props.visibleMonths ?? 1;\n const firstDayOfWeekName = (): CalendarDayOfWeek | undefined =>\n props.firstDayOfWeek == null ? undefined : dayOfWeekNames[props.firstDayOfWeek];\n\n const toDisplayCalendarDate = (date: DateValue): CalendarDate =>\n intlToCalendar(toCalendarDate(date), calendar());\n\n const selectionAlignmentOffset = (): number => {\n // Mirrors @react-stately/calendar useCalendarState, where selectionAlignment\n // defaults to \"center\" (alignCenter) when not provided.\n switch (props.selectionAlignment) {\n case \"start\":\n return 0;\n case \"end\":\n return Math.max(visibleMonths - 1, 0);\n case \"center\":\n default: {\n let halfDuration = Math.floor(visibleMonths / 2);\n if (halfDuration > 0 && visibleMonths % 2 === 0) {\n halfDuration--;\n }\n return halfDuration;\n }\n }\n };\n\n const alignVisibleRangeStart = (date: CalendarDate): CalendarDate => {\n const offset = selectionAlignmentOffset();\n return startOfMonth(offset > 0 ? date.subtract({ months: offset }) : date);\n };\n\n const visibleRangeEnd = (start: CalendarDate): CalendarDate => {\n let end = endOfMonth(start);\n\n for (let i = 1; i < visibleMonths; i++) {\n end = endOfMonth(end.add({ months: 1 }));\n }\n\n return end;\n };\n\n const constrainDate = (date: CalendarDate): CalendarDate => {\n const minValue = access(props.minValue);\n const maxValue = access(props.maxValue);\n\n let constrained = date;\n\n if (minValue && constrained.compare(toDisplayCalendarDate(minValue)) < 0) {\n constrained = toDisplayCalendarDate(minValue);\n }\n if (maxValue && constrained.compare(toDisplayCalendarDate(maxValue)) > 0) {\n constrained = toDisplayCalendarDate(maxValue);\n }\n\n return constrained;\n };\n\n // Determine the initially focused date\n const getInitialFocusedDate = (): CalendarDate => {\n const controlledFocused = access(props.focusedValue);\n if (controlledFocused) {\n return toDisplayCalendarDate(controlledFocused);\n }\n if (props.defaultFocusedValue) {\n return toDisplayCalendarDate(props.defaultFocusedValue);\n }\n const controlledValue = access(props.value);\n const controlledFirst = Array.isArray(controlledValue) ? controlledValue[0] : controlledValue;\n if (controlledFirst) {\n return toDisplayCalendarDate(controlledFirst);\n }\n const defaultFirst = Array.isArray(props.defaultValue)\n ? props.defaultValue[0]\n : props.defaultValue;\n if (defaultFirst) {\n return toDisplayCalendarDate(defaultFirst);\n }\n return intlToCalendar(today(timeZone), calendar());\n };\n\n // State signals\n const initialFocusedDate = constrainDate(getInitialFocusedDate());\n const [internalValue, setInternalValue] = createSignal<T | T[] | null>(\n (props.defaultValue as T | T[] | null) ?? null,\n );\n const [focusedDate, setFocusedDateInternal] = createSignal<CalendarDate>(initialFocusedDate);\n const [visibleRangeStart, setVisibleRangeStart] = createSignal<CalendarDate>(\n alignVisibleRangeStart(initialFocusedDate),\n );\n // Init from autoFocus, mirroring @react-stately useCalendarState\n // (`useState(props.autoFocus || false)`). Without autoFocus the calendar\n // mounts unfocused and never steals DOM focus.\n const [isFocused, setFocused] = createSignal(props.autoFocus ?? false);\n const [isPaginating, setIsPaginating] = createSignal(false);\n\n // Controlled vs uncontrolled value\n const sourceValue = createMemo<T | T[] | null>(() => {\n const controlled = access(props.value);\n return controlled !== undefined ? (controlled as T | T[] | null) : internalValue();\n });\n const value = createMemo<T | T[] | null>(() => {\n const currentValue = sourceValue();\n if (Array.isArray(currentValue)) {\n return currentValue.map((v) => toDisplayCalendarDate(v) as unknown as T);\n }\n return currentValue ? (toDisplayCalendarDate(currentValue) as unknown as T) : null;\n });\n\n // Derived states\n const isDisabled = createMemo(() => access(props.isDisabled) ?? false);\n const isReadOnly = createMemo(() => access(props.isReadOnly) ?? false);\n const validationState = createMemo(() => access(props.validationState));\n const isValueInvalid = createMemo(() => validationState() === \"invalid\");\n\n // Visible range based on the paged range start.\n const visibleRange = createMemo(() => {\n const start = visibleRangeStart();\n const end = visibleRangeEnd(start);\n\n return { start, end };\n });\n\n const syncVisibleRangeForFocusedDate = (nextFocusedDate: CalendarDate) => {\n const range = visibleRange();\n\n if (nextFocusedDate.compare(range.start) < 0) {\n setVisibleRangeStart(startOfMonth(nextFocusedDate.subtract({ months: visibleMonths - 1 })));\n } else if (nextFocusedDate.compare(range.end) > 0) {\n setVisibleRangeStart(startOfMonth(nextFocusedDate));\n }\n };\n\n createEffect(() => {\n const controlledFocused = access(props.focusedValue);\n if (!controlledFocused) {\n return;\n }\n\n const nextFocusedDate = constrainDate(toDisplayCalendarDate(controlledFocused));\n\n const currentFocusedDate = focusedDate();\n if (\n nextFocusedDate.compare(currentFocusedDate) !== 0 ||\n !isEqualCalendar(nextFocusedDate.calendar, currentFocusedDate.calendar)\n ) {\n setFocusedDateInternal(nextFocusedDate);\n }\n\n syncVisibleRangeForFocusedDate(nextFocusedDate);\n });\n\n createEffect(() => {\n const controlledFocused = access(props.focusedValue);\n if (controlledFocused) {\n return;\n }\n\n const currentFocusedDate = focusedDate();\n const nextFocusedDate = constrainDate(currentFocusedDate);\n\n if (\n nextFocusedDate.compare(currentFocusedDate) === 0 &&\n isEqualCalendar(nextFocusedDate.calendar, currentFocusedDate.calendar)\n ) {\n return;\n }\n\n syncVisibleRangeForFocusedDate(nextFocusedDate);\n setFocusedDateInternal(nextFocusedDate);\n props.onFocusChange?.(nextFocusedDate);\n });\n\n createEffect(() => {\n const currentFocusedDate = focusedDate();\n const nextFocusedDate = toDisplayCalendarDate(currentFocusedDate);\n\n if (isEqualCalendar(currentFocusedDate.calendar, nextFocusedDate.calendar)) {\n return;\n }\n\n setFocusedDateInternal(nextFocusedDate);\n setVisibleRangeStart(alignVisibleRangeStart(nextFocusedDate));\n });\n\n // Format week days for headers\n const weekDays = createMemo(() => {\n const formatter = new DateFormatter(locale(), { weekday: \"narrow\" });\n const days: string[] = [];\n const weekStart = startOfWeek(today(timeZone), locale(), firstDayOfWeekName());\n\n for (let i = 0; i < 7; i++) {\n const day = weekStart.add({ days: i });\n days.push(formatter.format(day.toDate(timeZone)));\n }\n\n return days;\n });\n\n // Title (formatted month/year)\n const title = createMemo(() => {\n const formatter = new DateFormatter(locale(), {\n month: \"long\",\n year: \"numeric\",\n calendar: focusedDate().calendar.identifier,\n });\n const date = focusedDate();\n const formattableMonth = date.calendar.getFormattableMonth?.(date) ?? date;\n return formatter.format(formattableMonth.toDate(timeZone));\n });\n\n // Set value with onChange callback\n const setValue = (newValue: T | T[] | null) => {\n if (isDisabled() || isReadOnly()) return;\n\n const oldValue = sourceValue();\n const referenceValue = Array.isArray(oldValue) ? (oldValue[0] ?? null) : oldValue;\n\n let nextValue: T | T[] | null;\n if (newValue == null) {\n nextValue = selectionMode() === \"multiple\" ? ([] as T[]) : null;\n } else if (Array.isArray(newValue)) {\n nextValue = newValue.map(\n (v) => convertValue(constrainDate(toDisplayCalendarDate(v)), referenceValue) as T,\n );\n } else {\n nextValue = convertValue(constrainDate(toDisplayCalendarDate(newValue)), referenceValue) as T;\n }\n\n const controlled = access(props.value);\n if (controlled === undefined) {\n setInternalValue(() => nextValue);\n }\n\n if (!Object.is(oldValue, nextValue) && props.onChange) {\n props.onChange(nextValue as CalendarValueType<T | null, M>);\n }\n };\n\n // Set focused date with constraints\n const setFocusedDate = (date: CalendarDate) => {\n const constrained = constrainDate(date);\n\n if (Object.is(constrained, focusedDate())) {\n return;\n }\n\n syncVisibleRangeForFocusedDate(constrained);\n setFocusedDateInternal(constrained);\n props.onFocusChange?.(constrained);\n };\n\n // Check if a date is selected\n const isSelected = (date: DateValue): boolean => {\n const v = value();\n if (v == null) return false;\n const target = toDisplayCalendarDate(date);\n if (Array.isArray(v)) {\n return v.some((d) => isSameDay(target, toDisplayCalendarDate(d)));\n }\n return isSameDay(target, toDisplayCalendarDate(v));\n };\n\n // Check if a date is focused. Mirrors @react-stately/calendar isCellFocused\n // (`isFocused && focusedDate && isSameDay(date, focusedDate)`): the\n // calendar-level `isFocused` flag gates cell focus so the calendar does NOT\n // steal DOM focus on mount. The roving tabbable cell is tracked separately by\n // the cell's `tabIndex` (isSameDay against focusedDate, ungated).\n const isCellFocused = (date: DateValue): boolean => {\n return isFocused() && isSameDay(toDisplayCalendarDate(date), focusedDate());\n };\n\n // Check if a date is unavailable\n const isCellUnavailable = (date: DateValue): boolean => {\n return props.isDateUnavailable?.(date) ?? false;\n };\n\n // Check if a date is disabled\n const isCellDisabled = (date: DateValue): boolean => {\n if (isDisabled()) return true;\n if (props.isDateDisabled?.(date)) return true;\n\n const minValue = access(props.minValue);\n const maxValue = access(props.maxValue);\n const calDate = toDisplayCalendarDate(date);\n\n // Dates outside the visible range are disabled, mirroring\n // @react-stately/calendar isCellDisabled (`date.compare(startDate) < 0 ||\n // date.compare(endDate) > 0` over the visible range). This is what marks the\n // leading/trailing padding cells (days from the adjacent months that fill out\n // the first/last grid weeks) as aria-disabled.\n const range = visibleRange();\n if (calDate.compare(toDisplayCalendarDate(range.start)) < 0) return true;\n if (calDate.compare(toDisplayCalendarDate(range.end)) > 0) return true;\n\n if (minValue && calDate.compare(toDisplayCalendarDate(minValue)) < 0) return true;\n if (maxValue && calDate.compare(toDisplayCalendarDate(maxValue)) > 0) return true;\n\n return false;\n };\n\n // Check if a date is outside the visible range\n const isOutsideVisibleRange = (date: DateValue): boolean => {\n const range = visibleRange();\n const calDate = toDisplayCalendarDate(date);\n return !isSameMonth(calDate, range.start) && !isSameMonth(calDate, range.end);\n };\n\n // Check if a date is invalid\n const isInvalid = (date: DateValue): boolean => {\n return isCellDisabled(date) || isCellUnavailable(date);\n };\n\n // Navigation methods\n const focusPreviousPage = () => {\n setIsPaginating(true);\n const pageMonths = props.pageBehavior === \"single\" ? 1 : visibleMonths;\n const nextFocusedDate = constrainDate(focusedDate().subtract({ months: pageMonths }));\n setFocusedDateInternal(nextFocusedDate);\n setVisibleRangeStart(startOfMonth(visibleRangeStart().subtract({ months: pageMonths })));\n props.onFocusChange?.(nextFocusedDate);\n setIsPaginating(false);\n };\n\n const focusNextPage = () => {\n setIsPaginating(true);\n const pageMonths = props.pageBehavior === \"single\" ? 1 : visibleMonths;\n const nextFocusedDate = constrainDate(focusedDate().add({ months: pageMonths }));\n setFocusedDateInternal(nextFocusedDate);\n setVisibleRangeStart(startOfMonth(visibleRangeStart().add({ months: pageMonths })));\n props.onFocusChange?.(nextFocusedDate);\n setIsPaginating(false);\n };\n\n const focusPreviousSection = () => {\n setFocusedDate(focusedDate().subtract({ years: 1 }));\n };\n\n const focusNextSection = () => {\n setFocusedDate(focusedDate().add({ years: 1 }));\n };\n\n const focusPreviousDay = () => {\n setFocusedDate(focusedDate().subtract({ days: 1 }));\n };\n\n const focusNextDay = () => {\n setFocusedDate(focusedDate().add({ days: 1 }));\n };\n\n const focusPreviousWeek = () => {\n setFocusedDate(focusedDate().subtract({ weeks: 1 }));\n };\n\n const focusNextWeek = () => {\n setFocusedDate(focusedDate().add({ weeks: 1 }));\n };\n\n const focusPageStart = () => {\n setFocusedDate(startOfMonth(focusedDate()));\n };\n\n const focusPageEnd = () => {\n setFocusedDate(endOfMonth(focusedDate()));\n };\n\n // Selection methods\n const selectFocusedDate = () => {\n if (isReadOnly() || isDisabled()) return;\n const date = focusedDate();\n if (!isCellUnavailable(date)) {\n selectDate(date);\n }\n };\n\n const selectDate = (date: CalendarDate) => {\n // Mirror @react-stately/calendar `selectDate(date) { setValue(date); }`:\n // no isCellDisabled/isCellUnavailable guard here. Upstream gates selection\n // at the cell layer (createCalendarCell handlePointerDown/handleClick guard\n // on isDisabled/isUnavailable before calling selectDate); the state method\n // only refuses when the whole calendar is disabled/readOnly (setValue's\n // guard). Double-guarding here also broke programmatic selection of dates\n // outside the current visible range.\n if (isReadOnly() || isDisabled()) return;\n\n if (selectionMode() === \"multiple\") {\n const current = value();\n const base: CalendarDate[] = Array.isArray(current)\n ? current.map((v) => toDisplayCalendarDate(v))\n : current != null\n ? [toDisplayCalendarDate(current)]\n : [];\n const target = toDisplayCalendarDate(date);\n const index = base.findIndex((d) => isSameDay(d, target));\n const nextValue =\n index >= 0 ? [...base.slice(0, index), ...base.slice(index + 1)] : [...base, target];\n setValue(nextValue as unknown as T[]);\n } else {\n setValue(date as unknown as T);\n }\n\n setFocusedDate(date);\n };\n\n // Get dates in a specific week\n const getDatesInWeek = (\n weekIndex: number,\n monthStartDate?: CalendarDate,\n ): (CalendarDate | null)[] => {\n const startDate = monthStartDate ?? visibleRange().start;\n\n const monthStart = startOfMonth(startDate);\n const weekStart = startOfWeek(monthStart, locale(), firstDayOfWeekName());\n\n const week: (CalendarDate | null)[] = [];\n const firstDayOfWeek = weekStart.add({ weeks: weekIndex });\n\n for (let i = 0; i < 7; i++) {\n const date = firstDayOfWeek.add({ days: i });\n // Only include dates that are in the same month\n if (isSameMonth(date, startDate)) {\n week.push(date);\n } else {\n week.push(date); // Still include for proper grid alignment\n }\n }\n\n return week;\n };\n\n // Get number of weeks in a month\n const getWeeksInMonthFn = (date?: CalendarDate): number => {\n const monthDate = date ?? focusedDate();\n return getWeeksInMonth(monthDate, locale(), firstDayOfWeekName());\n };\n\n return {\n selectionMode,\n value: value as unknown as Accessor<CalendarValueType<T | null, M>>,\n setValue: setValue as unknown as (value: CalendarValueType<T | null, M>) => void,\n focusedDate,\n setFocusedDate,\n isDisabled,\n isReadOnly,\n visibleRange,\n timeZone,\n locale,\n minValue: minValueState,\n maxValue: maxValueState,\n firstDayOfWeek: firstDayOfWeekName,\n validationState,\n isValueInvalid,\n isSelected,\n isCellFocused,\n isCellUnavailable,\n isCellDisabled,\n isOutsideVisibleRange,\n isInvalid,\n focusPreviousPage,\n focusNextPage,\n focusPreviousSection,\n focusNextSection,\n focusPreviousDay,\n focusNextDay,\n focusPreviousWeek,\n focusNextWeek,\n focusPageStart,\n focusPageEnd,\n selectFocusedDate,\n selectDate,\n isFocused,\n setFocused,\n getDatesInWeek,\n getWeeksInMonth: getWeeksInMonthFn,\n weekDays,\n title,\n visibleMonths,\n isPaginating,\n };\n}\n\n/**\n * Converts a DateValue to a CalendarDate.\n */\nfunction toCalendarDate(date: DateValue): CalendarDate {\n // Use the library function to convert\n return intlToCalendarDate(date);\n}\n\nfunction convertValue(newValue: CalendarDate, oldValue?: DateValue | null): DateValue {\n const localValue = intlToCalendar(newValue, oldValue?.calendar ?? new GregorianCalendar());\n\n if (oldValue && \"hour\" in oldValue) {\n return oldValue.set(localValue);\n }\n\n return localValue;\n}\n","/**\n * IncompleteDate for Solid-Stately\n *\n * Represents a date that is incomplete or otherwise invalid as a result of user\n * editing (for example February 31st, if the day is edited before the month).\n * This lets a date field hold an invalid intermediate value while typing and\n * only constrain it on blur, matching upstream behavior.\n *\n * Based on @react-stately/datepicker IncompleteDate\n */\n\nimport {\n type AnyDateTime,\n type Calendar,\n CalendarDate,\n type DateValue,\n ZonedDateTime,\n} from \"@internationalized/date\";\nimport type { DateSegmentType } from \"./createDateFieldState\";\n\ntype HourCycle = \"h12\" | \"h11\" | \"h23\" | \"h24\";\n\n/**\n * This class represents a date that is incomplete or otherwise invalid as a result of user editing.\n * For example, it can represent temporary dates such as February 31st if the user edits the day\n * before the month. Times are represented according to an hour cycle rather than always in 24 hour\n * time. This enables the user to adjust the day period (e.g. am/pm) independently from the hour.\n */\nexport class IncompleteDate {\n calendar: Calendar;\n era: string | null;\n year: number | null;\n month: number | null;\n day: number | null;\n hour: number | null;\n hourCycle: HourCycle;\n dayPeriod: number | null;\n minute: number | null;\n second: number | null;\n millisecond: number | null;\n offset: number | null;\n\n constructor(\n calendar: Calendar,\n hourCycle: HourCycle,\n dateValue?: Partial<Omit<AnyDateTime, \"copy\">> | null,\n ) {\n this.era = dateValue?.era ?? null;\n this.calendar = calendar;\n this.year = dateValue?.year ?? null;\n this.month = dateValue?.month ?? null;\n this.day = dateValue?.day ?? null;\n this.hour = dateValue?.hour ?? null;\n this.hourCycle = hourCycle;\n this.dayPeriod = null;\n this.minute = dateValue?.minute ?? null;\n this.second = dateValue?.second ?? null;\n this.millisecond = dateValue?.millisecond ?? null;\n this.offset = \"offset\" in (dateValue ?? {}) ? (dateValue as { offset: number }).offset : null;\n\n // Convert the hour from 24 hour time to the given hour cycle.\n if (this.hour != null) {\n const [dayPeriod, hour] = toHourCycle(this.hour, hourCycle);\n this.dayPeriod = dayPeriod;\n this.hour = hour;\n }\n }\n\n copy(): IncompleteDate {\n const res = new IncompleteDate(this.calendar, this.hourCycle);\n res.era = this.era;\n res.year = this.year;\n res.month = this.month;\n res.day = this.day;\n res.hour = this.hour;\n res.dayPeriod = this.dayPeriod;\n res.minute = this.minute;\n res.second = this.second;\n res.millisecond = this.millisecond;\n res.offset = this.offset;\n return res;\n }\n\n /** Checks whether all the specified segments have a value. */\n isComplete(segments: DateSegmentType[]): boolean {\n return segments.every((segment) => this[segment as keyof IncompleteDate] != null);\n }\n\n /** Checks whether the given date value matches this value for the specified segments. */\n validate(dt: DateValue, segments: DateSegmentType[]): boolean {\n return segments.every((segment) => {\n if ((segment === \"hour\" || segment === \"dayPeriod\") && \"hour\" in dt) {\n const [dayPeriod, hour] = toHourCycle(dt.hour, this.hourCycle);\n return this.dayPeriod === dayPeriod && this.hour === hour;\n }\n return this[segment as keyof IncompleteDate] === dt[segment as keyof DateValue];\n });\n }\n\n /** Checks if the date is empty (i.e. all specified segments are null). */\n isCleared(segments: DateSegmentType[]): boolean {\n return segments.every((segment) => this[segment as keyof IncompleteDate] === null);\n }\n\n /** Sets the given field. */\n set(field: DateSegmentType, value: number | string, placeholder: DateValue): IncompleteDate {\n const result = this.copy();\n (result as unknown as Record<string, unknown>)[field] = value;\n if (field === \"hour\" && result.dayPeriod == null && \"hour\" in placeholder) {\n result.dayPeriod = toHourCycle(placeholder.hour, this.hourCycle)[0];\n }\n if (field === \"year\" && result.era == null) {\n result.era = placeholder.era;\n }\n\n // clear offset when a date/time field changes since it may no longer be valid\n if (field !== \"second\" && field !== \"literal\" && field !== \"timeZoneName\") {\n result.offset = null;\n }\n return result;\n }\n\n /** Sets the given field to null. */\n clear(field: DateSegmentType): IncompleteDate {\n const result = this.copy();\n (result as unknown as Record<string, unknown>)[field] = null;\n if (field === \"year\") {\n result.era = null;\n }\n\n // clear offset when a field is cleared since it may no longer be valid\n result.offset = null;\n return result;\n }\n\n /**\n * Increments or decrements the given field. If it is null, then it is set to the placeholder\n * value.\n */\n cycle(\n field: DateSegmentType,\n amount: number,\n placeholder: DateValue,\n displaySegments: DateSegmentType[],\n ): IncompleteDate {\n const res = this.copy();\n\n // If field is null, default to placeholder.\n if (res[field as keyof IncompleteDate] == null && field !== \"dayPeriod\" && field !== \"era\") {\n if (field === \"hour\" && \"hour\" in placeholder) {\n const [dayPeriod, hour] = toHourCycle(placeholder.hour, this.hourCycle);\n res.dayPeriod = dayPeriod;\n res.hour = hour;\n } else {\n (res as unknown as Record<string, unknown>)[field] = placeholder[field as keyof DateValue];\n }\n if (field === \"year\" && res.era == null) {\n res.era = placeholder.era;\n }\n\n return res;\n }\n\n switch (field) {\n case \"era\": {\n const eras = this.calendar.getEras();\n let index = eras.indexOf(res.era!);\n index = cycleValue(index, amount, 0, eras.length - 1);\n res.era = eras[index];\n break;\n }\n case \"year\": {\n // Use CalendarDate to cycle so that we update the era when going between 1 AD and 1 BC.\n let date = new CalendarDate(\n this.calendar,\n this.era ?? placeholder.era,\n this.year ?? placeholder.year,\n this.month ?? 1,\n this.day ?? 1,\n );\n date = date.cycle(field, amount, { round: field === \"year\" });\n res.era = date.era;\n res.year = date.year;\n break;\n }\n case \"month\":\n res.month = cycleValue(res.month ?? 1, amount, 1, this.calendar.getMaximumMonthsInYear());\n break;\n case \"day\":\n // Allow incrementing up to the maximum number of days in any month.\n res.day = cycleValue(res.day ?? 1, amount, 1, this.calendar.getMaximumDaysInMonth());\n break;\n case \"hour\": {\n // if date is fully defined or it is just a time field, and we have a time zone, use toValue to get a ZonedDateTime to cycle\n // so DST fallback is properly handled\n const hasDateSegements = displaySegments.some((s) => [\"year\", \"month\", \"day\"].includes(s));\n if (\n \"timeZone\" in placeholder &&\n (!hasDateSegements || (res.year != null && res.month != null && res.day != null))\n ) {\n let date = this.toValue(placeholder) as ZonedDateTime;\n date = date.cycle(\"hour\", amount, {\n hourCycle: this.hourCycle === \"h12\" ? 12 : 24,\n round: false,\n });\n const [dayPeriod, adjustedHour] = toHourCycle(date.hour, this.hourCycle);\n res.hour = adjustedHour;\n res.dayPeriod = dayPeriod;\n res.offset = date.offset;\n } else {\n const hours = res.hour ?? 0;\n const limits = this.getSegmentLimits(\"hour\")!;\n res.hour = cycleValue(hours, amount, limits.minValue, limits.maxValue);\n if (res.dayPeriod == null && \"hour\" in placeholder) {\n res.dayPeriod = toHourCycle(placeholder.hour, this.hourCycle)[0];\n }\n }\n break;\n }\n case \"dayPeriod\":\n res.dayPeriod = cycleValue(res.dayPeriod ?? 0, amount, 0, 1);\n break;\n case \"minute\":\n res.minute = cycleValue(res.minute ?? 0, amount, 0, 59, true);\n break;\n case \"second\":\n res.second = cycleValue(res.second ?? 0, amount, 0, 59, true);\n break;\n }\n\n return res;\n }\n\n /**\n * Converts the incomplete date to a full date value, using the provided value for any unset\n * fields.\n */\n toValue(value: DateValue): DateValue {\n if (\"hour\" in value) {\n let hour = this.hour;\n if (hour != null) {\n hour = fromHourCycle(hour, this.dayPeriod ?? 0, this.hourCycle);\n } else if (this.hourCycle === \"h12\" || this.hourCycle === \"h11\") {\n hour = this.dayPeriod === 1 ? 12 : 0;\n }\n\n let res = value.set({\n era: this.era ?? value.era,\n year: this.year ?? value.year,\n month: this.month ?? value.month,\n day: this.day ?? value.day,\n hour: hour ?? value.hour,\n minute: this.minute ?? value.minute,\n second: this.second ?? value.second,\n millisecond: this.millisecond ?? value.millisecond,\n });\n\n if (\"offset\" in res && this.offset != null && res.offset !== this.offset) {\n res = res.add({ milliseconds: res.offset - this.offset });\n }\n\n return res;\n } else {\n return value.set({\n era: this.era ?? value.era,\n year: this.year ?? value.year,\n month: this.month ?? value.month,\n day: this.day ?? value.day,\n });\n }\n }\n\n getSegmentLimits(\n type: string,\n ): { value: number | null; minValue: number; maxValue: number } | undefined {\n switch (type) {\n case \"era\": {\n const eras = this.calendar.getEras();\n return {\n value: this.era != null ? eras.indexOf(this.era) : eras.length - 1,\n minValue: 0,\n maxValue: eras.length - 1,\n };\n }\n case \"year\":\n return {\n value: this.year,\n minValue: 1,\n maxValue: 9999,\n };\n case \"month\":\n return {\n value: this.month,\n minValue: 1,\n maxValue: this.calendar.getMaximumMonthsInYear(),\n };\n case \"day\":\n return {\n value: this.day,\n minValue: 1,\n maxValue: this.calendar.getMaximumDaysInMonth(),\n };\n case \"dayPeriod\": {\n return {\n value: this.dayPeriod,\n minValue: 0,\n maxValue: 1,\n };\n }\n case \"hour\": {\n let minValue = 0;\n let maxValue = 23;\n if (this.hourCycle === \"h12\") {\n minValue = 1;\n maxValue = 12;\n } else if (this.hourCycle === \"h11\") {\n minValue = 0;\n maxValue = 11;\n }\n\n return {\n value: this.hour,\n minValue,\n maxValue,\n };\n }\n case \"minute\":\n return {\n value: this.minute,\n minValue: 0,\n maxValue: 59,\n };\n case \"second\":\n return {\n value: this.second,\n minValue: 0,\n maxValue: 59,\n };\n }\n }\n}\n\nfunction cycleValue(\n value: number,\n amount: number,\n min: number,\n max: number,\n round = false,\n): number {\n if (round) {\n value += Math.sign(amount);\n\n if (value < min) {\n value = max;\n }\n\n const div = Math.abs(amount);\n if (amount > 0) {\n value = Math.ceil(value / div) * div;\n } else {\n value = Math.floor(value / div) * div;\n }\n\n if (value > max) {\n value = min;\n }\n } else {\n value += amount;\n if (value < min) {\n value = max - (min - value - 1);\n } else if (value > max) {\n value = min + (value - max - 1);\n }\n }\n\n return value;\n}\n\nfunction toHourCycle(hour: number, hourCycle: HourCycle): [number | null, number] {\n let dayPeriod: number | null = hour >= 12 ? 1 : 0;\n switch (hourCycle) {\n case \"h11\":\n // Hours are numbered from 0 to 11. Used in Japan.\n if (hour >= 12) {\n hour -= 12;\n }\n break;\n case \"h12\":\n // Hours are numbered from 12 (representing 0) to 11.\n if (hour === 0) {\n hour = 12;\n } else if (hour > 12) {\n hour -= 12;\n }\n break;\n case \"h23\":\n // 24 hour time, numbered 0 to 23.\n dayPeriod = null;\n break;\n case \"h24\":\n // 24 hour time numbered 24 to 23. Unused but supported by Intl.DateTimeFormat.\n hour += 1;\n dayPeriod = null;\n }\n\n return [dayPeriod, hour];\n}\n\nfunction fromHourCycle(hour: number, dayPeriod: number, hourCycle: HourCycle): number {\n switch (hourCycle) {\n case \"h11\":\n if (dayPeriod === 1) {\n hour += 12;\n }\n break;\n case \"h12\":\n if (hour === 12) {\n hour = 0;\n }\n if (dayPeriod === 1) {\n hour += 12;\n }\n break;\n case \"h24\":\n hour -= 1;\n break;\n }\n\n return hour;\n}\n","// DateField validation-message catalog, ported verbatim from @react-stately/datepicker's\n// intl/*.json (34 locales). Keep in sync with the vendored react-spectrum source on every\n// pin bump. Hand-rolled resolver so solid-stately needs no @internationalized/string dep.\n\nexport type DateFieldErrorKey =\n | \"rangeUnderflow\"\n | \"rangeOverflow\"\n | \"rangeReversed\"\n | \"unavailableDate\";\n\ntype DateFieldErrorArgs = { minValue?: string; maxValue?: string };\ntype DateFieldErrorMessage = string | ((args: DateFieldErrorArgs) => string);\n\nconst errorStrings: Record<string, Record<DateFieldErrorKey, DateFieldErrorMessage>> = {\n \"ar-AE\": {\n \"rangeOverflow\": (args)=>`\\u{64A}\\u{62C}\\u{628} \\u{623}\\u{646} \\u{62A}\\u{643}\\u{648}\\u{646} \\u{627}\\u{644}\\u{642}\\u{64A}\\u{645}\\u{629} ${args.maxValue} \\u{623}\\u{648} \\u{642}\\u{628}\\u{644} \\u{630}\\u{644}\\u{643}.`,\n \"rangeReversed\": `\\u{62A}\\u{627}\\u{631}\\u{64A}\\u{62E} \\u{627}\\u{644}\\u{628}\\u{62F}\\u{621} \\u{64A}\\u{62C}\\u{628} \\u{623}\\u{646} \\u{64A}\\u{643}\\u{648}\\u{646} \\u{642}\\u{628}\\u{644} \\u{62A}\\u{627}\\u{631}\\u{64A}\\u{62E} \\u{627}\\u{644}\\u{627}\\u{646}\\u{62A}\\u{647}\\u{627}\\u{621}.`,\n \"rangeUnderflow\": (args)=>`\\u{64A}\\u{62C}\\u{628} \\u{623}\\u{646} \\u{62A}\\u{643}\\u{648}\\u{646} \\u{627}\\u{644}\\u{642}\\u{64A}\\u{645}\\u{629} ${args.minValue} \\u{623}\\u{648} \\u{628}\\u{639}\\u{62F} \\u{630}\\u{644}\\u{643}.`,\n \"unavailableDate\": `\\u{627}\\u{644}\\u{628}\\u{64A}\\u{627}\\u{646}\\u{627}\\u{62A} \\u{627}\\u{644}\\u{645}\\u{62D}\\u{62F}\\u{62F}\\u{629} \\u{63A}\\u{64A}\\u{631} \\u{645}\\u{62A}\\u{627}\\u{62D}\\u{629}.`\n },\n \"bg-BG\": {\n \"rangeOverflow\": (args)=>`\\u{421}\\u{442}\\u{43E}\\u{439}\\u{43D}\\u{43E}\\u{441}\\u{442}\\u{442}\\u{430} \\u{442}\\u{440}\\u{44F}\\u{431}\\u{432}\\u{430} \\u{434}\\u{430} \\u{435} ${args.maxValue} \\u{438}\\u{43B}\\u{438} \\u{43F}\\u{43E}-\\u{440}\\u{430}\\u{43D}\\u{43D}\\u{430}.`,\n \"rangeReversed\": `\\u{41D}\\u{430}\\u{447}\\u{430}\\u{43B}\\u{43D}\\u{430}\\u{442}\\u{430} \\u{434}\\u{430}\\u{442}\\u{430} \\u{442}\\u{440}\\u{44F}\\u{431}\\u{432}\\u{430} \\u{434}\\u{430} \\u{435} \\u{43F}\\u{440}\\u{435}\\u{434}\\u{438} \\u{43A}\\u{440}\\u{430}\\u{439}\\u{43D}\\u{430}\\u{442}\\u{430}.`,\n \"rangeUnderflow\": (args)=>`\\u{421}\\u{442}\\u{43E}\\u{439}\\u{43D}\\u{43E}\\u{441}\\u{442}\\u{442}\\u{430} \\u{442}\\u{440}\\u{44F}\\u{431}\\u{432}\\u{430} \\u{434}\\u{430} \\u{435} ${args.minValue} \\u{438}\\u{43B}\\u{438} \\u{43F}\\u{43E}-\\u{43A}\\u{44A}\\u{441}\\u{43D}\\u{43E}.`,\n \"unavailableDate\": `\\u{418}\\u{437}\\u{431}\\u{440}\\u{430}\\u{43D}\\u{430}\\u{442}\\u{430} \\u{434}\\u{430}\\u{442}\\u{430} \\u{43D}\\u{435} \\u{435} \\u{43D}\\u{430}\\u{43B}\\u{438}\\u{447}\\u{43D}\\u{430}.`\n },\n \"cs-CZ\": {\n \"rangeOverflow\": (args)=>`Hodnota mus\\xed b\\xfdt ${args.maxValue} nebo d\\u{159}\\xedv\\u{11B}j\\u{161}\\xed.`,\n \"rangeReversed\": `Datum zah\\xe1jen\\xed mus\\xed p\\u{159}edch\\xe1zet datu ukon\\u{10D}en\\xed.`,\n \"rangeUnderflow\": (args)=>`Hodnota mus\\xed b\\xfdt ${args.minValue} nebo pozd\\u{11B}j\\u{161}\\xed.`,\n \"unavailableDate\": `Vybran\\xe9 datum nen\\xed k dispozici.`\n },\n \"da-DK\": {\n \"rangeOverflow\": (args)=>`V\\xe6rdien skal v\\xe6re ${args.maxValue} eller tidligere.`,\n \"rangeReversed\": `Startdatoen skal v\\xe6re f\\xf8r slutdatoen.`,\n \"rangeUnderflow\": (args)=>`V\\xe6rdien skal v\\xe6re ${args.minValue} eller nyere.`,\n \"unavailableDate\": `Den valgte dato er ikke tilg\\xe6ngelig.`\n },\n \"de-DE\": {\n \"rangeOverflow\": (args)=>`Der Wert muss ${args.maxValue} oder fr\\xfcher sein.`,\n \"rangeReversed\": `Das Startdatum muss vor dem Enddatum liegen.`,\n \"rangeUnderflow\": (args)=>`Der Wert muss ${args.minValue} oder sp\\xe4ter sein.`,\n \"unavailableDate\": `Das ausgew\\xe4hlte Datum ist nicht verf\\xfcgbar.`\n },\n \"el-GR\": {\n \"rangeOverflow\": (args)=>`\\u{397} \\u{3C4}\\u{3B9}\\u{3BC}\\u{3AE} \\u{3C0}\\u{3C1}\\u{3AD}\\u{3C0}\\u{3B5}\\u{3B9} \\u{3BD}\\u{3B1} \\u{3B5}\\u{3AF}\\u{3BD}\\u{3B1}\\u{3B9} ${args.maxValue} \\u{3AE} \\u{3C0}\\u{3B1}\\u{3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3AF}\\u{3BD}\\u{3B1}\\u{3B9} \\u{3B4}\\u{3B9}\\u{3B1}\\u{3B8}\\u{3AD}\\u{3C3}\\u{3B9}\\u{3BC}\\u{3B7}.`\n },\n \"en-US\": {\n \"rangeUnderflow\": (args)=>`Value must be ${args.minValue} or later.`,\n \"rangeOverflow\": (args)=>`Value must be ${args.maxValue} or earlier.`,\n \"rangeReversed\": `Start date must be before end date.`,\n \"unavailableDate\": `Selected date unavailable.`\n },\n \"es-ES\": {\n \"rangeOverflow\": (args)=>`El valor debe ser ${args.maxValue} o anterior.`,\n \"rangeReversed\": `La fecha de inicio debe ser anterior a la fecha de finalizaci\\xf3n.`,\n \"rangeUnderflow\": (args)=>`El valor debe ser ${args.minValue} o posterior.`,\n \"unavailableDate\": `Fecha seleccionada no disponible.`\n },\n \"et-EE\": {\n \"rangeOverflow\": (args)=>`V\\xe4\\xe4rtus peab olema ${args.maxValue} v\\xf5i varasem.`,\n \"rangeReversed\": `Alguskuup\\xe4ev peab olema enne l\\xf5ppkuup\\xe4eva.`,\n \"rangeUnderflow\": (args)=>`V\\xe4\\xe4rtus peab olema ${args.minValue} v\\xf5i hilisem.`,\n \"unavailableDate\": `Valitud kuup\\xe4ev pole saadaval.`\n },\n \"fi-FI\": {\n \"rangeOverflow\": (args)=>`Arvon on oltava ${args.maxValue} tai sit\\xe4 aikaisempi.`,\n \"rangeReversed\": `Aloitusp\\xe4iv\\xe4n on oltava ennen lopetusp\\xe4iv\\xe4\\xe4.`,\n \"rangeUnderflow\": (args)=>`Arvon on oltava ${args.minValue} tai sit\\xe4 my\\xf6h\\xe4isempi.`,\n \"unavailableDate\": `Valittu p\\xe4iv\\xe4m\\xe4\\xe4r\\xe4 ei ole k\\xe4ytett\\xe4viss\\xe4.`\n },\n \"fr-FR\": {\n \"rangeOverflow\": (args)=>`La valeur doit \\xeatre ${args.maxValue} ou ant\\xe9rieure.`,\n \"rangeReversed\": `La date de d\\xe9but doit \\xeatre ant\\xe9rieure \\xe0 la date de fin.`,\n \"rangeUnderflow\": (args)=>`La valeur doit \\xeatre ${args.minValue} ou ult\\xe9rieure.`,\n \"unavailableDate\": `La date s\\xe9lectionn\\xe9e n\\u{2019}est pas disponible.`\n },\n \"he-IL\": {\n \"rangeOverflow\": (args)=>`\\u{5D4}\\u{5E2}\\u{5E8}\\u{5DA} \\u{5D7}\\u{5D9}\\u{5D9}\\u{5D1} \\u{5DC}\\u{5D4}\\u{5D9}\\u{5D5}\\u{5EA} ${args.maxValue} \\u{5D0}\\u{5D5} \\u{5DE}\\u{5D5}\\u{5E7}\\u{5D3}\\u{5DD} \\u{5D9}\\u{5D5}\\u{5EA}\\u{5E8}.`,\n \"rangeReversed\": `\\u{5EA}\\u{5D0}\\u{5E8}\\u{5D9}\\u{5DA} \\u{5D4}\\u{5D4}\\u{5EA}\\u{5D7}\\u{5DC}\\u{5D4} \\u{5D7}\\u{5D9}\\u{5D9}\\u{5D1} \\u{5DC}\\u{5D4}\\u{5D9}\\u{5D5}\\u{5EA} \\u{5DC}\\u{5E4}\\u{5E0}\\u{5D9} \\u{5EA}\\u{5D0}\\u{5E8}\\u{5D9}\\u{5DA} \\u{5D4}\\u{5E1}\\u{5D9}\\u{5D5}\\u{5DD}.`,\n \"rangeUnderflow\": (args)=>`\\u{5D4}\\u{5E2}\\u{5E8}\\u{5DA} \\u{5D7}\\u{5D9}\\u{5D9}\\u{5D1} \\u{5DC}\\u{5D4}\\u{5D9}\\u{5D5}\\u{5EA} ${args.minValue} \\u{5D0}\\u{5D5} \\u{5DE}\\u{5D0}\\u{5D5}\\u{5D7}\\u{5E8} \\u{5D9}\\u{5D5}\\u{5EA}\\u{5E8}.`,\n \"unavailableDate\": `\\u{5D4}\\u{5EA}\\u{5D0}\\u{5E8}\\u{5D9}\\u{5DA} \\u{5D4}\\u{5E0}\\u{5D1}\\u{5D7}\\u{5E8} \\u{5D0}\\u{5D9}\\u{5E0}\\u{5D5} \\u{5D6}\\u{5DE}\\u{5D9}\\u{5DF}.`\n },\n \"hr-HR\": {\n \"rangeOverflow\": (args)=>`Vrijednost mora biti ${args.maxValue} ili ranije.`,\n \"rangeReversed\": `Datum po\\u{10D}etka mora biti prije datuma zavr\\u{161}etka.`,\n \"rangeUnderflow\": (args)=>`Vrijednost mora biti ${args.minValue} ili kasnije.`,\n \"unavailableDate\": `Odabrani datum nije dostupan.`\n },\n \"hu-HU\": {\n \"rangeOverflow\": (args)=>`Az \\xe9rt\\xe9knek ${args.maxValue} vagy kor\\xe1bbinak kell lennie.`,\n \"rangeReversed\": `A kezd\\u{151} d\\xe1tumnak a befejez\\u{151} d\\xe1tumn\\xe1l kor\\xe1bbinak kell lennie.`,\n \"rangeUnderflow\": (args)=>`Az \\xe9rt\\xe9knek ${args.minValue} vagy k\\xe9s\\u{151}bbinek kell lennie.`,\n \"unavailableDate\": `A kiv\\xe1lasztott d\\xe1tum nem \\xe9rhet\\u{151} el.`\n },\n \"it-IT\": {\n \"rangeOverflow\": (args)=>`Il valore deve essere ${args.maxValue} o precedente.`,\n \"rangeReversed\": `La data di inizio deve essere antecedente alla data di fine.`,\n \"rangeUnderflow\": (args)=>`Il valore deve essere ${args.minValue} o successivo.`,\n \"unavailableDate\": `Data selezionata non disponibile.`\n },\n \"ja-JP\": {\n \"rangeOverflow\": (args)=>`\\u{5024}\\u{306F} ${args.maxValue} \\u{4EE5}\\u{4E0B}\\u{306B}\\u{3059}\\u{308B}\\u{5FC5}\\u{8981}\\u{304C}\\u{3042}\\u{308A}\\u{307E}\\u{3059}\\u{3002}`,\n \"rangeReversed\": `\\u{958B}\\u{59CB}\\u{65E5}\\u{306F}\\u{7D42}\\u{4E86}\\u{65E5}\\u{3088}\\u{308A}\\u{524D}\\u{306B}\\u{3059}\\u{308B}\\u{5FC5}\\u{8981}\\u{304C}\\u{3042}\\u{308A}\\u{307E}\\u{3059}\\u{3002}`,\n \"rangeUnderflow\": (args)=>`\\u{5024}\\u{306F} ${args.minValue} \\u{4EE5}\\u{4E0A}\\u{306B}\\u{3059}\\u{308B}\\u{5FC5}\\u{8981}\\u{304C}\\u{3042}\\u{308A}\\u{307E}\\u{3059}\\u{3002}`,\n \"unavailableDate\": `\\u{9078}\\u{629E}\\u{3057}\\u{305F}\\u{65E5}\\u{4ED8}\\u{306F}\\u{4F7F}\\u{7528}\\u{3067}\\u{304D}\\u{307E}\\u{305B}\\u{3093}\\u{3002}`\n },\n \"ko-KR\": {\n \"rangeOverflow\": (args)=>`\\u{AC12}\\u{C740} ${args.maxValue} \\u{C774}\\u{C804}\\u{C774}\\u{C5B4}\\u{C57C} \\u{D569}\\u{B2C8}\\u{B2E4}.`,\n \"rangeReversed\": `\\u{C2DC}\\u{C791}\\u{C77C}\\u{C740} \\u{C885}\\u{B8CC}\\u{C77C} \\u{C774}\\u{C804}\\u{C774}\\u{C5B4}\\u{C57C} \\u{D569}\\u{B2C8}\\u{B2E4}.`,\n \"rangeUnderflow\": (args)=>`\\u{AC12}\\u{C740} ${args.minValue} \\u{C774}\\u{D6C4}\\u{C5EC}\\u{C57C} \\u{D569}\\u{B2C8}\\u{B2E4}.`,\n \"unavailableDate\": `\\u{C120}\\u{D0DD}\\u{D55C} \\u{B0A0}\\u{C9DC}\\u{B97C} \\u{C0AC}\\u{C6A9}\\u{D560} \\u{C218} \\u{C5C6}\\u{C2B5}\\u{B2C8}\\u{B2E4}.`\n },\n \"lt-LT\": {\n \"rangeOverflow\": (args)=>`Reik\\u{161}m\\u{117} turi b\\u{16B}ti ${args.maxValue} arba ankstesn\\u{117}.`,\n \"rangeReversed\": `Prad\\u{17E}ios data turi b\\u{16B}ti ankstesn\\u{117} nei pabaigos data.`,\n \"rangeUnderflow\": (args)=>`Reik\\u{161}m\\u{117} turi b\\u{16B}ti ${args.minValue} arba naujesn\\u{117}.`,\n \"unavailableDate\": `Pasirinkta data nepasiekiama.`\n },\n \"lv-LV\": {\n \"rangeOverflow\": (args)=>`V\\u{113}rt\\u{12B}bai ir j\\u{101}b\\u{16B}t ${args.maxValue} vai agr\\u{101}kai.`,\n \"rangeReversed\": `S\\u{101}kuma datumam ir j\\u{101}b\\u{16B}t pirms beigu datuma.`,\n \"rangeUnderflow\": (args)=>`V\\u{113}rt\\u{12B}bai ir j\\u{101}b\\u{16B}t ${args.minValue} vai v\\u{113}l\\u{101}kai.`,\n \"unavailableDate\": `Atlas\\u{12B}tais datums nav pieejams.`\n },\n \"nb-NO\": {\n \"rangeOverflow\": (args)=>`Verdien m\\xe5 v\\xe6re ${args.maxValue} eller tidligere.`,\n \"rangeReversed\": `Startdatoen m\\xe5 v\\xe6re f\\xf8r sluttdatoen.`,\n \"rangeUnderflow\": (args)=>`Verdien m\\xe5 v\\xe6re ${args.minValue} eller senere.`,\n \"unavailableDate\": `Valgt dato utilgjengelig.`\n },\n \"nl-NL\": {\n \"rangeOverflow\": (args)=>`Waarde moet ${args.maxValue} of eerder zijn.`,\n \"rangeReversed\": `De startdatum moet voor de einddatum liggen.`,\n \"rangeUnderflow\": (args)=>`Waarde moet ${args.minValue} of later zijn.`,\n \"unavailableDate\": `Geselecteerde datum niet beschikbaar.`\n },\n \"pl-PL\": {\n \"rangeOverflow\": (args)=>`Warto\\u{15B}\\u{107} musi mie\\u{107} warto\\u{15B}\\u{107} ${args.maxValue} lub wcze\\u{15B}niejsz\\u{105}.`,\n \"rangeReversed\": `Data rozpocz\\u{119}cia musi by\\u{107} wcze\\u{15B}niejsza ni\\u{17C} data zako\\u{144}czenia.`,\n \"rangeUnderflow\": (args)=>`Warto\\u{15B}\\u{107} musi mie\\u{107} warto\\u{15B}\\u{107} ${args.minValue} lub p\\xf3\\u{17A}niejsz\\u{105}.`,\n \"unavailableDate\": `Wybrana data jest niedost\\u{119}pna.`\n },\n \"pt-BR\": {\n \"rangeOverflow\": (args)=>`O valor deve ser ${args.maxValue} ou anterior.`,\n \"rangeReversed\": `A data inicial deve ser anterior \\xe0 data final.`,\n \"rangeUnderflow\": (args)=>`O valor deve ser ${args.minValue} ou posterior.`,\n \"unavailableDate\": `Data selecionada indispon\\xedvel.`\n },\n \"pt-PT\": {\n \"rangeOverflow\": (args)=>`O valor tem de ser ${args.maxValue} ou anterior.`,\n \"rangeReversed\": `A data de in\\xedcio deve ser anterior \\xe0 data de fim.`,\n \"rangeUnderflow\": (args)=>`O valor tem de ser ${args.minValue} ou posterior.`,\n \"unavailableDate\": `Data selecionada indispon\\xedvel.`\n },\n \"ro-RO\": {\n \"rangeOverflow\": (args)=>`Valoarea trebuie s\\u{103} fie ${args.maxValue} sau anterioar\\u{103}.`,\n \"rangeReversed\": `Data de \\xeenceput trebuie s\\u{103} fie anterioar\\u{103} datei de sf\\xe2r\\u{219}it.`,\n \"rangeUnderflow\": (args)=>`Valoarea trebuie s\\u{103} fie ${args.minValue} sau ulterioar\\u{103}.`,\n \"unavailableDate\": `Data selectat\\u{103} nu este disponibil\\u{103}.`\n },\n \"ru-RU\": {\n \"rangeOverflow\": (args)=>`\\u{417}\\u{43D}\\u{430}\\u{447}\\u{435}\\u{43D}\\u{438}\\u{435} \\u{434}\\u{43E}\\u{43B}\\u{436}\\u{43D}\\u{43E} \\u{431}\\u{44B}\\u{442}\\u{44C} \\u{43D}\\u{435} \\u{43F}\\u{43E}\\u{437}\\u{436}\\u{435} ${args.maxValue}.`,\n \"rangeReversed\": `\\u{414}\\u{430}\\u{442}\\u{430} \\u{43D}\\u{430}\\u{447}\\u{430}\\u{43B}\\u{430} \\u{434}\\u{43E}\\u{43B}\\u{436}\\u{43D}\\u{430} \\u{43F}\\u{440}\\u{435}\\u{434}\\u{448}\\u{435}\\u{441}\\u{442}\\u{432}\\u{43E}\\u{432}\\u{430}\\u{442}\\u{44C} \\u{434}\\u{430}\\u{442}\\u{435} \\u{43E}\\u{43A}\\u{43E}\\u{43D}\\u{447}\\u{430}\\u{43D}\\u{438}\\u{44F}.`,\n \"rangeUnderflow\": (args)=>`\\u{417}\\u{43D}\\u{430}\\u{447}\\u{435}\\u{43D}\\u{438}\\u{435} \\u{434}\\u{43E}\\u{43B}\\u{436}\\u{43D}\\u{43E} \\u{431}\\u{44B}\\u{442}\\u{44C} \\u{43D}\\u{435} \\u{440}\\u{430}\\u{43D}\\u{44C}\\u{448}\\u{435} ${args.minValue}.`,\n \"unavailableDate\": `\\u{412}\\u{44B}\\u{431}\\u{440}\\u{430}\\u{43D}\\u{43D}\\u{430}\\u{44F} \\u{434}\\u{430}\\u{442}\\u{430} \\u{43D}\\u{435}\\u{434}\\u{43E}\\u{441}\\u{442}\\u{443}\\u{43F}\\u{43D}\\u{430}.`\n },\n \"sk-SK\": {\n \"rangeOverflow\": (args)=>`Hodnota mus\\xed by\\u{165} ${args.maxValue} alebo skor\\u{161}ia.`,\n \"rangeReversed\": `D\\xe1tum za\\u{10D}iatku mus\\xed by\\u{165} skor\\u{161}\\xed ako d\\xe1tum konca.`,\n \"rangeUnderflow\": (args)=>`Hodnota mus\\xed by\\u{165} ${args.minValue} alebo neskor\\u{161}ia.`,\n \"unavailableDate\": `Vybrat\\xfd d\\xe1tum je nedostupn\\xfd.`\n },\n \"sl-SI\": {\n \"rangeOverflow\": (args)=>`Vrednost mora biti ${args.maxValue} ali starej\\u{161}a.`,\n \"rangeReversed\": `Za\\u{10D}etni datum mora biti pred kon\\u{10D}nim datumom.`,\n \"rangeUnderflow\": (args)=>`Vrednost mora biti ${args.minValue} ali novej\\u{161}a.`,\n \"unavailableDate\": `Izbrani datum ni na voljo.`\n },\n \"sr-SP\": {\n \"rangeOverflow\": (args)=>`Vrednost mora da bude ${args.maxValue} ili starija.`,\n \"rangeReversed\": `Datum po\\u{10D}etka mora biti pre datuma zavr\\u{161}etka.`,\n \"rangeUnderflow\": (args)=>`Vrednost mora da bude ${args.minValue} ili novija.`,\n \"unavailableDate\": `Izabrani datum nije dostupan.`\n },\n \"sv-SE\": {\n \"rangeOverflow\": (args)=>`V\\xe4rdet m\\xe5ste vara ${args.maxValue} eller tidigare.`,\n \"rangeReversed\": `Startdatumet m\\xe5ste vara f\\xf6re slutdatumet.`,\n \"rangeUnderflow\": (args)=>`V\\xe4rdet m\\xe5ste vara ${args.minValue} eller senare.`,\n \"unavailableDate\": `Det valda datumet \\xe4r inte tillg\\xe4ngligt.`\n },\n \"tr-TR\": {\n \"rangeOverflow\": (args)=>`De\\u{11F}er, ${args.maxValue} veya \\xf6ncesi olmal\\u{131}d\\u{131}r.`,\n \"rangeReversed\": `Ba\\u{15F}lang\\u{131}\\xe7 tarihi biti\\u{15F} tarihinden \\xf6nce olmal\\u{131}d\\u{131}r.`,\n \"rangeUnderflow\": (args)=>`De\\u{11F}er, ${args.minValue} veya sonras\\u{131} olmal\\u{131}d\\u{131}r.`,\n \"unavailableDate\": `Se\\xe7ilen tarih kullan\\u{131}lam\\u{131}yor.`\n },\n \"uk-UA\": {\n \"rangeOverflow\": (args)=>`\\u{417}\\u{43D}\\u{430}\\u{447}\\u{435}\\u{43D}\\u{43D}\\u{44F} \\u{43C}\\u{430}\\u{454} \\u{431}\\u{443}\\u{442}\\u{438} \\u{43D}\\u{435} \\u{43F}\\u{456}\\u{437}\\u{43D}\\u{456}\\u{448}\\u{435} ${args.maxValue}.`,\n \"rangeReversed\": `\\u{414}\\u{430}\\u{442}\\u{430} \\u{43F}\\u{43E}\\u{447}\\u{430}\\u{442}\\u{43A}\\u{443} \\u{43C}\\u{430}\\u{454} \\u{43F}\\u{435}\\u{440}\\u{435}\\u{434}\\u{443}\\u{432}\\u{430}\\u{442}\\u{438} \\u{434}\\u{430}\\u{442}\\u{456} \\u{437}\\u{430}\\u{432}\\u{435}\\u{440}\\u{448}\\u{435}\\u{43D}\\u{43D}\\u{44F}.`,\n \"rangeUnderflow\": (args)=>`\\u{417}\\u{43D}\\u{430}\\u{447}\\u{435}\\u{43D}\\u{43D}\\u{44F} \\u{43C}\\u{430}\\u{454} \\u{431}\\u{443}\\u{442}\\u{438} \\u{43D}\\u{435} \\u{440}\\u{430}\\u{43D}\\u{456}\\u{448}\\u{435} ${args.minValue}.`,\n \"unavailableDate\": `\\u{412}\\u{438}\\u{431}\\u{440}\\u{430}\\u{43D}\\u{430} \\u{434}\\u{430}\\u{442}\\u{430} \\u{43D}\\u{435}\\u{434}\\u{43E}\\u{441}\\u{442}\\u{443}\\u{43F}\\u{43D}\\u{430}.`\n },\n \"zh-CN\": {\n \"rangeOverflow\": (args)=>`\\u{503C}\\u{5FC5}\\u{987B}\\u{662F} ${args.maxValue} \\u{6216}\\u{66F4}\\u{65E9}\\u{65E5}\\u{671F}\\u{3002}`,\n \"rangeReversed\": `\\u{5F00}\\u{59CB}\\u{65E5}\\u{671F}\\u{5FC5}\\u{987B}\\u{65E9}\\u{4E8E}\\u{7ED3}\\u{675F}\\u{65E5}\\u{671F}\\u{3002}`,\n \"rangeUnderflow\": (args)=>`\\u{503C}\\u{5FC5}\\u{987B}\\u{662F} ${args.minValue} \\u{6216}\\u{66F4}\\u{665A}\\u{65E5}\\u{671F}\\u{3002}`,\n \"unavailableDate\": `\\u{6240}\\u{9009}\\u{65E5}\\u{671F}\\u{4E0D}\\u{53EF}\\u{7528}\\u{3002}`\n },\n \"zh-TW\": {\n \"rangeOverflow\": (args)=>`\\u{503C}\\u{5FC5}\\u{9808}\\u{662F} ${args.maxValue} \\u{6216}\\u{66F4}\\u{65E9}\\u{3002}`,\n \"rangeReversed\": `\\u{958B}\\u{59CB}\\u{65E5}\\u{671F}\\u{5FC5}\\u{9808}\\u{5728}\\u{7D50}\\u{675F}\\u{65E5}\\u{671F}\\u{4E4B}\\u{524D}\\u{3002}`,\n \"rangeUnderflow\": (args)=>`\\u{503C}\\u{5FC5}\\u{9808}\\u{662F} ${args.minValue} \\u{6216}\\u{66F4}\\u{665A}\\u{3002}`,\n \"unavailableDate\": `\\u{6240}\\u{9078}\\u{65E5}\\u{671F}\\u{7121}\\u{6CD5}\\u{4F7F}\\u{7528}\\u{3002}`\n },\n};\n\nconst DEFAULT_LOCALE = \"en-US\";\n\nfunction getMessageForLocale(\n key: DateFieldErrorKey,\n locale: string,\n): DateFieldErrorMessage {\n const exact = errorStrings[locale];\n if (exact && exact[key] != null) return exact[key];\n\n const language = locale.split(\"-\")[0];\n const match = Object.keys(errorStrings).find((l) => l.split(\"-\")[0] === language);\n if (match && errorStrings[match][key] != null) return errorStrings[match][key];\n\n return errorStrings[DEFAULT_LOCALE][key];\n}\n\n/** Mirrors LocalizedStringFormatter.format for the datepicker validation messages. */\nexport function formatDateFieldError(\n locale: string,\n key: DateFieldErrorKey,\n args?: DateFieldErrorArgs,\n): string {\n const message = getMessageForLocale(key, locale);\n return typeof message === \"function\" ? message(args ?? {}) : message;\n}\n\n// ---------------------------------------------------------------------------\n// Placeholder-text catalog, ported verbatim from @react-stately/datepicker's\n// placeholders.ts. Based on the <input type=\"date\"> placeholders used by Chrome\n// and Firefox; more languages than React Spectrum's usual translations. Default\n// locale is \"en\".\n// ---------------------------------------------------------------------------\n\nconst placeholderStrings: Record<string, { year: string; month: string; day: string }> = {\n ach: { year: \"mwaka\", month: \"dwe\", day: \"nino\" },\n af: { year: \"jjjj\", month: \"mm\", day: \"dd\" },\n am: { year: \"ዓዓዓዓ\", month: \"ሚሜ\", day: \"ቀቀ\" },\n an: { year: \"aaaa\", month: \"mm\", day: \"dd\" },\n ar: { year: \"سنة\", month: \"شهر\", day: \"يوم\" },\n ast: { year: \"aaaa\", month: \"mm\", day: \"dd\" },\n az: { year: \"iiii\", month: \"aa\", day: \"gg\" },\n be: { year: \"гггг\", month: \"мм\", day: \"дд\" },\n bg: { year: \"гггг\", month: \"мм\", day: \"дд\" },\n bn: { year: \"yyyy\", month: \"মিমি\", day: \"dd\" },\n br: { year: \"bbbb\", month: \"mm\", day: \"dd\" },\n bs: { year: \"gggg\", month: \"mm\", day: \"dd\" },\n ca: { year: \"aaaa\", month: \"mm\", day: \"dd\" },\n cak: { year: \"jjjj\", month: \"ii\", day: \"q'q'\" },\n ckb: { year: \"ساڵ\", month: \"مانگ\", day: \"ڕۆژ\" },\n cs: { year: \"rrrr\", month: \"mm\", day: \"dd\" },\n cy: { year: \"bbbb\", month: \"mm\", day: \"dd\" },\n da: { year: \"åååå\", month: \"mm\", day: \"dd\" },\n de: { year: \"jjjj\", month: \"mm\", day: \"tt\" },\n dsb: { year: \"llll\", month: \"mm\", day: \"źź\" },\n el: { year: \"εεεε\", month: \"μμ\", day: \"ηη\" },\n en: { year: \"yyyy\", month: \"mm\", day: \"dd\" },\n eo: { year: \"jjjj\", month: \"mm\", day: \"tt\" },\n es: { year: \"aaaa\", month: \"mm\", day: \"dd\" },\n et: { year: \"aaaa\", month: \"kk\", day: \"pp\" },\n eu: { year: \"uuuu\", month: \"hh\", day: \"ee\" },\n fa: { year: \"سال\", month: \"ماه\", day: \"روز\" },\n ff: { year: \"hhhh\", month: \"ll\", day: \"ññ\" },\n fi: { year: \"vvvv\", month: \"kk\", day: \"pp\" },\n fr: { year: \"aaaa\", month: \"mm\", day: \"jj\" },\n fy: { year: \"jjjj\", month: \"mm\", day: \"dd\" },\n ga: { year: \"bbbb\", month: \"mm\", day: \"ll\" },\n gd: { year: \"bbbb\", month: \"mm\", day: \"ll\" },\n gl: { year: \"aaaa\", month: \"mm\", day: \"dd\" },\n he: { year: \"שנה\", month: \"חודש\", day: \"יום\" },\n hr: { year: \"gggg\", month: \"mm\", day: \"dd\" },\n hsb: { year: \"llll\", month: \"mm\", day: \"dd\" },\n hu: { year: \"éééé\", month: \"hh\", day: \"nn\" },\n ia: { year: \"aaaa\", month: \"mm\", day: \"dd\" },\n id: { year: \"tttt\", month: \"bb\", day: \"hh\" },\n is: { year: \"áááá\", month: \"mm\", day: \"dd\" },\n it: { year: \"aaaa\", month: \"mm\", day: \"gg\" },\n ja: { year: \"年\", month: \"月\", day: \"日\" },\n ka: { year: \"წწწწ\", month: \"თთ\", day: \"რრ\" },\n kk: { year: \"жжжж\", month: \"аа\", day: \"кк\" },\n kn: { year: \"ವವವವ\", month: \"ಮಿಮೀ\", day: \"ದಿದಿ\" },\n ko: { year: \"연도\", month: \"월\", day: \"일\" },\n lb: { year: \"jjjj\", month: \"mm\", day: \"dd\" },\n lo: { year: \"ປປປປ\", month: \"ດດ\", day: \"ວວ\" },\n lt: { year: \"mmmm\", month: \"mm\", day: \"dd\" },\n lv: { year: \"gggg\", month: \"mm\", day: \"dd\" },\n meh: { year: \"aaaa\", month: \"mm\", day: \"dd\" },\n ml: { year: \"വർഷം\", month: \"മാസം\", day: \"തീയതി\" },\n ms: { year: \"tttt\", month: \"mm\", day: \"hh\" },\n nb: { year: \"åååå\", month: \"mm\", day: \"dd\" },\n nl: { year: \"jjjj\", month: \"mm\", day: \"dd\" },\n nn: { year: \"åååå\", month: \"mm\", day: \"dd\" },\n no: { year: \"åååå\", month: \"mm\", day: \"dd\" },\n oc: { year: \"aaaa\", month: \"mm\", day: \"jj\" },\n pl: { year: \"rrrr\", month: \"mm\", day: \"dd\" },\n pt: { year: \"aaaa\", month: \"mm\", day: \"dd\" },\n rm: { year: \"oooo\", month: \"mm\", day: \"dd\" },\n ro: { year: \"aaaa\", month: \"ll\", day: \"zz\" },\n ru: { year: \"гггг\", month: \"мм\", day: \"дд\" },\n sc: { year: \"aaaa\", month: \"mm\", day: \"dd\" },\n scn: { year: \"aaaa\", month: \"mm\", day: \"jj\" },\n sk: { year: \"rrrr\", month: \"mm\", day: \"dd\" },\n sl: { year: \"llll\", month: \"mm\", day: \"dd\" },\n sr: { year: \"гггг\", month: \"мм\", day: \"дд\" },\n \"sr-Latn\": { year: \"gggg\", month: \"mm\", day: \"dd\" },\n sv: { year: \"åååå\", month: \"mm\", day: \"dd\" },\n szl: { year: \"rrrr\", month: \"mm\", day: \"dd\" },\n tg: { year: \"сссс\", month: \"мм\", day: \"рр\" },\n th: { year: \"ปปปป\", month: \"ดด\", day: \"วว\" },\n tr: { year: \"yyyy\", month: \"aa\", day: \"gg\" },\n uk: { year: \"рррр\", month: \"мм\", day: \"дд\" },\n \"zh-CN\": { year: \"年\", month: \"月\", day: \"日\" },\n \"zh-TW\": { year: \"年\", month: \"月\", day: \"日\" },\n};\n\nconst PLACEHOLDER_DEFAULT_LOCALE = \"en\";\n\nfunction getPlaceholderStringForLocale(field: \"year\" | \"month\" | \"day\", locale: string): string {\n const exact = placeholderStrings[locale];\n if (exact) return exact[field];\n\n const language = locale.split(\"-\")[0];\n const direct = placeholderStrings[language];\n if (direct) return direct[field];\n\n const scan = Object.keys(placeholderStrings).find((l) => l.split(\"-\")[0] === language);\n if (scan) return placeholderStrings[scan][field];\n\n return placeholderStrings[PLACEHOLDER_DEFAULT_LOCALE][field];\n}\n\n/** Mirrors @react-stately/datepicker getPlaceholder. */\nexport function getPlaceholder(field: string, value: string, locale: string): string {\n // Use the actual placeholder value for the era and day period fields.\n if (field === \"era\" || field === \"dayPeriod\") {\n return value;\n }\n\n if (field === \"year\" || field === \"month\" || field === \"day\") {\n return getPlaceholderStringForLocale(field, locale);\n }\n\n // For time fields (e.g. hour, minute, etc.), use two dashes as the placeholder.\n return \"––\";\n}\n","/**\n * DateFieldState for Solid-Stately\n *\n * Provides state management for date field components with segment-based editing.\n * Faithful port of @react-stately/datepicker useDateFieldState.\n *\n * Editing is modeled with an {@link IncompleteDate} display value so that invalid\n * intermediate dates (e.g. February 31st, produced by editing the day before the\n * month) are held as-typed while the field is focused and only constrained on blur\n * via `confirmPlaceholder`, matching upstream behavior. Out-of-range values are\n * never snapped to `minValue`/`maxValue`; they are kept and reported as invalid.\n *\n * The upstream \"derived state during render\" resync (which re-mints the display\n * value when the committed value / calendar / hour cycle changes) is ported to a\n * Solid `createComputed` so it runs synchronously before render effects — mirroring\n * React's render-phase setState rather than a post-render `createEffect`.\n */\n\nimport { createSignal, createMemo, createComputed, untrack, type Accessor } from \"solid-js\";\nimport {\n type Calendar,\n type CalendarDateTime,\n type CalendarIdentifier,\n type DateValue,\n GregorianCalendar,\n DateFormatter,\n Time,\n now,\n getLocalTimeZone,\n toCalendar,\n toCalendarDate,\n toCalendarDateTime,\n isEqualCalendar,\n createCalendar as intlCreateCalendar,\n} from \"@internationalized/date\";\nimport { access, type MaybeAccessor } from \"../utils\";\nimport type { ValidationState } from \"./createCalendarState\";\nimport { IncompleteDate } from \"./IncompleteDate\";\nimport { formatDateFieldError, getPlaceholder, type DateFieldErrorKey } from \"./intl\";\nimport {\n createFormValidationState,\n VALID_VALIDITY_STATE,\n type ValidationBehavior,\n type ValidationFunction,\n type ValidationResult,\n type ValidityState,\n} from \"../form\";\n\nexport type DateSegmentType =\n | \"year\"\n | \"month\"\n | \"day\"\n | \"hour\"\n | \"minute\"\n | \"second\"\n | \"dayPeriod\"\n | \"era\"\n | \"timeZoneName\"\n | \"literal\";\n\ntype Granularity = \"year\" | \"month\" | \"day\" | \"hour\" | \"minute\" | \"second\";\ntype FieldGranularity = \"day\" | \"hour\" | \"minute\" | \"second\";\n\nexport interface DateSegment {\n /** The type of segment. */\n type: DateSegmentType;\n /** The text content of the segment. */\n text: string;\n /** The numeric value of the segment (if applicable). */\n value?: number | null;\n /** The minimum value for the segment. */\n minValue?: number;\n /** The maximum value for the segment. */\n maxValue?: number;\n /** Whether this segment is editable. */\n isEditable: boolean;\n /** Whether this segment is a placeholder. */\n isPlaceholder: boolean;\n /** A placeholder string for the segment. */\n placeholder: string;\n}\n\nexport interface DateFieldStateProps<T extends DateValue = DateValue> {\n /** The current value (controlled). */\n value?: MaybeAccessor<T | null>;\n /** The default value (uncontrolled). */\n defaultValue?: T | null;\n /** Handler called when the value changes. */\n onChange?: (value: T | null) => void;\n /** The minimum allowed date. */\n minValue?: MaybeAccessor<DateValue | undefined>;\n /** The maximum allowed date. */\n maxValue?: MaybeAccessor<DateValue | undefined>;\n /** Whether the field is disabled. */\n isDisabled?: MaybeAccessor<boolean>;\n /** Whether the field is read-only. */\n isReadOnly?: MaybeAccessor<boolean>;\n /** Whether the field is required. */\n isRequired?: MaybeAccessor<boolean>;\n /** Whether the value is invalid (controlled). */\n isInvalid?: boolean;\n /** The locale to use for formatting. */\n locale?: string;\n /** The granularity of the date/time (day, hour, minute, second). */\n granularity?: FieldGranularity;\n /** The maximum granularity (largest editable unit). Defaults to `year`. */\n maxGranularity?: \"year\" | \"month\" | \"day\" | \"hour\" | \"minute\";\n /** Whether to show the hour in 12 or 24 hour format. */\n hourCycle?: 12 | 24;\n /** Whether to hide the time zone. */\n hideTimeZone?: boolean;\n /** The placeholder date (determines segment structure). */\n placeholderValue?: DateValue;\n /** Whether to force leading zeroes in month/day segments. */\n shouldForceLeadingZeros?: boolean;\n /** Validation state. */\n validationState?: MaybeAccessor<ValidationState | undefined>;\n /** Validation behavior mode. */\n validationBehavior?: ValidationBehavior;\n /** Custom validation function. */\n validate?: ValidationFunction<T>;\n /** Description text. */\n description?: string;\n /** Error message. */\n errorMessage?: string;\n /** Whether dates outside the min/max range are allowed. */\n allowsNonContiguousRanges?: boolean;\n /** Resolves a calendar system by its Unicode identifier. */\n createCalendar?: (name: CalendarIdentifier) => Calendar;\n /** Whether a date is unavailable. */\n isDateUnavailable?: (date: DateValue) => boolean;\n}\n\nexport interface DateFieldState<T extends DateValue = DateValue> {\n /** The current value, converted to the display calendar. */\n value: Accessor<DateValue | null>;\n /** The current value as a native JavaScript Date (may be partial during editing). */\n dateValue: Accessor<Date>;\n /** The display calendar system. */\n readonly calendar: Calendar;\n /** Sets the date value. */\n setValue: (value: T | null) => void;\n /** The segments that make up the date. */\n segments: Accessor<DateSegment[]>;\n /** The formatter used to render the field. */\n readonly dateFormatter: DateFormatter;\n /** Formats the current value with the given field options. */\n formatValue: (fieldOptions?: Intl.DateTimeFormatOptions) => string;\n /** Returns a formatter with the field's resolved options merged with the given ones. */\n getDateFormatter: (locale: string, formatOptions: FormatterOptions) => DateFormatter;\n /** Sets a segment value. */\n setSegment: (type: DateSegmentType, value: number) => void;\n /** Increments a segment by one. */\n increment: (type: DateSegmentType) => void;\n /** Decrements a segment by one. */\n decrement: (type: DateSegmentType) => void;\n /** Increments a segment by a larger page step. */\n incrementPage: (type: DateSegmentType) => void;\n /** Decrements a segment by a larger page step. */\n decrementPage: (type: DateSegmentType) => void;\n /** Sets a segment to its maximum value. */\n incrementToMax: (type: DateSegmentType) => void;\n /** Sets a segment to its minimum value. */\n decrementToMin: (type: DateSegmentType) => void;\n /** Clears a segment. */\n clearSegment: (type: DateSegmentType) => void;\n /** Confirms the value (after typing). */\n confirmPlaceholder: () => void;\n /** Whether the field is disabled. */\n isDisabled: Accessor<boolean>;\n /** Whether the field is read-only. */\n isReadOnly: Accessor<boolean>;\n /** Whether the field is required. */\n isRequired: Accessor<boolean>;\n /** The validation state. */\n validationState: Accessor<ValidationState | undefined>;\n /** The granularity. */\n readonly granularity: FieldGranularity;\n /** The maximum granularity. */\n readonly maxGranularity: \"year\" | \"month\" | \"day\" | \"hour\" | \"minute\";\n /** Whether the value is invalid. */\n isInvalid: Accessor<boolean>;\n /** Realtime validation results, including native and custom constraints. */\n realtimeValidation: Accessor<ValidationResult>;\n /** Currently displayed validation results. */\n displayValidation: Accessor<ValidationResult>;\n /** Updates the current validation result. */\n updateValidation: (result: ValidationResult) => void;\n /** Resets displayed validation to valid. */\n resetValidation: () => void;\n /** Commits realtime validation to displayed validation. */\n commitValidation: () => void;\n /** The locale. */\n readonly locale: string;\n /** The time zone. */\n readonly timeZone: string;\n /** The default value. */\n defaultValue: DateValue | null;\n}\n\ntype HourCycle = \"h11\" | \"h12\" | \"h23\" | \"h24\";\n\nconst EDITABLE_SEGMENTS: Record<string, boolean> = {\n year: true,\n month: true,\n day: true,\n hour: true,\n minute: true,\n second: true,\n dayPeriod: true,\n era: true,\n};\n\nconst PAGE_STEP: Record<string, number> = {\n year: 5,\n month: 2,\n day: 7,\n hour: 2,\n minute: 15,\n second: 15,\n};\n\nconst TYPE_MAPPING: Record<string, string> = {\n // Node seems to convert everything to lowercase...\n dayperiod: \"dayPeriod\",\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts#named_years\n relatedYear: \"year\",\n yearName: \"literal\",\n unknown: \"literal\",\n};\n\n/**\n * Provides state management for a date field component.\n */\nexport function createDateFieldState<T extends DateValue = DateValue>(\n props: DateFieldStateProps<T> = {},\n): DateFieldState<T> {\n const locale = (): string => props.locale ?? \"en-US\";\n const createCalendarFn = (name: CalendarIdentifier): Calendar =>\n (props.createCalendar ?? intlCreateCalendar)(name);\n\n // The initial resolved value (used only for its calendar identity and defaults).\n const v0 = (): DateValue | null =>\n access(props.value) ?? props.defaultValue ?? props.placeholderValue ?? null;\n\n // Compute default granularity and time zone from the value, keeping the last\n // values when the value becomes null (mirrors useDefaultProps).\n const initialDefaults = untrack(() => {\n const v = v0();\n return {\n granularity: (v && \"minute\" in v ? \"minute\" : \"day\") as Granularity,\n timeZone: v && \"timeZone\" in v ? (v as { timeZone: string }).timeZone : undefined,\n };\n });\n const [lastDefaults, setLastDefaults] = createSignal<{\n granularity: Granularity;\n timeZone: string | undefined;\n }>(initialDefaults);\n createComputed(() => {\n const v = v0();\n if (!v) return;\n const defaultGranularity = (\"minute\" in v ? \"minute\" : \"day\") as Granularity;\n const defaultTimeZone = \"timeZone\" in v ? (v as { timeZone: string }).timeZone : undefined;\n const last = untrack(lastDefaults);\n if (last.granularity !== defaultGranularity || last.timeZone !== defaultTimeZone) {\n setLastDefaults({ granularity: defaultGranularity, timeZone: defaultTimeZone });\n }\n });\n const granularity = (): FieldGranularity => {\n if (props.granularity) return props.granularity;\n const v = v0();\n if (v) return (\"minute\" in v ? \"minute\" : \"day\") as FieldGranularity;\n return lastDefaults().granularity as FieldGranularity;\n };\n const defaultTimeZone = (): string | undefined => {\n const v = v0();\n return v\n ? \"timeZone\" in v\n ? (v as { timeZone: string }).timeZone\n : undefined\n : lastDefaults().timeZone;\n };\n const timeZone = (): string => defaultTimeZone() || \"UTC\";\n\n // Resolve default hour cycle and calendar system.\n const calendarAndHourCycle = createMemo<[Calendar, HourCycle]>(() => {\n const formatter = new DateFormatter(locale(), {\n dateStyle: \"short\",\n timeStyle: \"short\",\n hour12: props.hourCycle != null ? props.hourCycle === 12 : undefined,\n });\n const opts = formatter.resolvedOptions();\n return [createCalendarFn(opts.calendar as CalendarIdentifier), opts.hourCycle as HourCycle];\n });\n const calendar = (): Calendar => calendarAndHourCycle()[0];\n const hourCycle = (): HourCycle => calendarAndHourCycle()[1];\n\n // Controlled vs uncontrolled committed value.\n const [internalValue, setInternalValue] = createSignal<T | null>(props.defaultValue ?? null);\n const rawValue = createMemo<T | null>(() => {\n const controlled = access(props.value);\n return controlled !== undefined ? controlled : internalValue();\n });\n const setDate = (v: T | null) => {\n if (access(props.value) === undefined) setInternalValue(() => v);\n props.onChange?.(v);\n };\n\n // The current value, converted to the display calendar.\n const calendarValue = createMemo<DateValue | null>(() => convertValue(rawValue(), calendar()) ?? null);\n\n const initialValue = untrack(calendarValue);\n\n // The display override: holds the (possibly invalid/incomplete) value being edited.\n const [displayValue, setDisplayValue] = createSignal<IncompleteDate>(\n untrack(() => new IncompleteDate(calendar(), hourCycle(), untrack(calendarValue))),\n );\n\n // Render-phase resync: whenever the committed value, calendar, or hour cycle changes\n // from the outside, re-mint the display override. Ported to createComputed so it runs\n // synchronously (like React's render-phase setState), never leaving a stale frame.\n let lastValue = untrack(calendarValue);\n let lastCalendar = untrack(calendar);\n let lastHourCycle = untrack(hourCycle);\n createComputed(() => {\n const cv = calendarValue();\n const cal = calendar();\n const hc = hourCycle();\n if (cv !== lastValue || hc !== lastHourCycle || !isEqualCalendar(cal, lastCalendar)) {\n lastValue = cv;\n lastCalendar = cal;\n lastHourCycle = hc;\n setDisplayValue(new IncompleteDate(cal, hc, cv));\n }\n });\n\n const showEra = (): boolean => calendar().identifier === \"gregory\" && displayValue().era === \"BC\";\n const maxGranularity = (): \"year\" | \"month\" | \"day\" | \"hour\" | \"minute\" =>\n props.maxGranularity ?? \"year\";\n\n const placeholderDate = createMemo<DateValue>(() =>\n createPlaceholderDate(props.placeholderValue, granularity(), calendar(), defaultTimeZone()),\n );\n\n const formatOpts = createMemo<FormatterOptions>(() => ({\n granularity: granularity(),\n maxGranularity: maxGranularity(),\n timeZone: defaultTimeZone(),\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle,\n showEra: showEra(),\n shouldForceLeadingZeros: props.shouldForceLeadingZeros,\n }));\n\n const dateFormatter = createMemo(() => new DateFormatter(locale(), getFormatOptions({}, formatOpts())));\n const resolvedOptions = createMemo(() => dateFormatter().resolvedOptions());\n\n const displaySegments = createMemo<DateSegmentType[]>(() => {\n const hc = hourCycle();\n const is12HourClock = hc === \"h11\" || hc === \"h12\";\n const segments: DateSegmentType[] = [\n \"era\",\n \"year\",\n \"month\",\n \"day\",\n \"hour\",\n ...(is12HourClock ? ([\"dayPeriod\"] as const) : []),\n \"minute\",\n \"second\",\n ];\n const minIndex = segments.indexOf((maxGranularity() as DateSegmentType) || \"era\");\n const maxIndex = segments.indexOf(\n granularity() === \"hour\" && is12HourClock ? \"dayPeriod\" : granularity(),\n );\n return segments.slice(minIndex, maxIndex + 1);\n });\n\n // The effective date value as a native Date, derived from the display override.\n const dateValue = createMemo<Date>(() => {\n const v = displayValue().toValue(calendarValue() ?? placeholderDate());\n return v.toDate(timeZone());\n });\n\n const segments = createMemo<DateSegment[]>(() =>\n processSegments(\n dateValue(),\n displayValue(),\n dateFormatter(),\n resolvedOptions() as unknown as Record<string, string>,\n calendar(),\n locale(),\n granularity(),\n ),\n );\n\n // Set value with the upstream split: complete + valid commits eagerly; an incomplete\n // or invalid (e.g. Feb 31) value is held as a display override until blur.\n const setValue = (newValue: T | IncompleteDate | null) => {\n if (access(props.isDisabled) || access(props.isReadOnly)) return;\n\n const cv = calendarValue();\n const cal = calendar();\n const hc = hourCycle();\n const v = v0();\n\n if (\n newValue == null ||\n (newValue instanceof IncompleteDate && newValue.isCleared(displaySegments()))\n ) {\n setDisplayValue(new IncompleteDate(cal, hc, cv));\n setDate(null);\n } else if (!(newValue instanceof IncompleteDate)) {\n // The display calendar should not have any effect on the emitted value.\n // Emit dates in the same calendar as the original value, if any, otherwise gregorian.\n const emitted = toCalendar(\n newValue as DateValue,\n (v as { calendar?: Calendar } | null)?.calendar || new GregorianCalendar(),\n );\n setDisplayValue(new IncompleteDate(cal, hc, cv));\n setDate(emitted as T);\n } else {\n // If the new value is complete and valid, trigger onChange eagerly. If it represents\n // an incomplete or invalid value (e.g. February 30th), wait until blur to trigger onChange.\n if (newValue.isComplete(displaySegments())) {\n const dv = newValue.toValue(cv ?? placeholderDate());\n if (newValue.validate(dv, displaySegments())) {\n const newDateValue = toCalendar(\n dv,\n (v as { calendar?: Calendar } | null)?.calendar || new GregorianCalendar(),\n );\n const committed = rawValue();\n if (!committed || newDateValue.compare(committed) !== 0) {\n setDisplayValue(new IncompleteDate(cal, hc, cv)); // reset in case prop isn't updated\n setDate(newDateValue as T);\n return;\n }\n }\n }\n // Incomplete/invalid value. Set temporary display override.\n setDisplayValue(newValue);\n }\n };\n\n const adjustSegment = (type: DateSegmentType, amount: number) => {\n setValue(displayValue().cycle(type, amount, placeholderDate(), displaySegments()));\n };\n\n const builtinValidation = createMemo<ValidationResult>(() =>\n getValidationResult(\n rawValue(),\n access(props.minValue),\n access(props.maxValue),\n props.isDateUnavailable,\n formatOpts(),\n ),\n );\n\n const isDisabled = createMemo(() => access(props.isDisabled) ?? false);\n const isReadOnly = createMemo(() => access(props.isReadOnly) ?? false);\n const isRequired = createMemo(() => access(props.isRequired) ?? false);\n const explicitValidationState = createMemo(() => access(props.validationState));\n const validationBehavior = () => props.validationBehavior ?? \"native\";\n\n const validation = createFormValidationState<T>({\n get value() {\n return rawValue();\n },\n get isInvalid() {\n return props.isInvalid;\n },\n get validationState() {\n return explicitValidationState();\n },\n get validationBehavior() {\n return validationBehavior();\n },\n get validate() {\n return props.validate;\n },\n get builtinValidation() {\n return builtinValidation();\n },\n });\n const isInvalid = createMemo(() => validation.displayValidation().isInvalid);\n const validationState = createMemo<ValidationState | undefined>(\n () => explicitValidationState() ?? (isInvalid() ? \"invalid\" : undefined),\n );\n\n return {\n ...validation,\n value: calendarValue,\n defaultValue: props.defaultValue ?? initialValue,\n dateValue,\n get calendar() {\n return calendar();\n },\n setValue,\n segments,\n get dateFormatter() {\n return dateFormatter();\n },\n validationState,\n isInvalid,\n get granularity() {\n return granularity();\n },\n get maxGranularity() {\n return maxGranularity();\n },\n isDisabled,\n isReadOnly,\n isRequired,\n increment(part) {\n adjustSegment(part, 1);\n },\n decrement(part) {\n adjustSegment(part, -1);\n },\n incrementPage(part) {\n adjustSegment(part, PAGE_STEP[part] || 1);\n },\n decrementPage(part) {\n adjustSegment(part, -(PAGE_STEP[part] || 1));\n },\n incrementToMax(part) {\n const max =\n part === \"hour\" && hourCycle() === \"h12\"\n ? 11\n : displayValue().getSegmentLimits(part)?.maxValue;\n if (max != null) setValue(displayValue().set(part, max, placeholderDate()));\n },\n decrementToMin(part) {\n const min =\n part === \"hour\" && hourCycle() === \"h12\"\n ? 12\n : displayValue().getSegmentLimits(part)?.minValue;\n if (min != null) setValue(displayValue().set(part, min, placeholderDate()));\n },\n setSegment(part, value) {\n setValue(displayValue().set(part, value, placeholderDate()));\n },\n confirmPlaceholder() {\n if (access(props.isDisabled) || access(props.isReadOnly)) return;\n // If the display value is complete but invalid, constrain it and emit onChange on blur.\n if (displayValue().isComplete(displaySegments())) {\n const cv = calendarValue();\n const dv = displayValue().toValue(cv ?? placeholderDate());\n const v = v0();\n const newDateValue = toCalendar(\n dv,\n (v as { calendar?: Calendar } | null)?.calendar || new GregorianCalendar(),\n );\n const committed = rawValue();\n if (!committed || newDateValue.compare(committed) !== 0) setDate(newDateValue as T);\n setDisplayValue(new IncompleteDate(calendar(), hourCycle(), cv));\n }\n },\n clearSegment(part) {\n let value = displayValue();\n if (part !== \"timeZoneName\" && part !== \"literal\") value = displayValue().clear(part);\n setValue(value);\n },\n formatValue(fieldOptions) {\n if (!calendarValue()) return \"\";\n const formatOptions = getFormatOptions(fieldOptions, formatOpts());\n const formatter = new DateFormatter(locale(), formatOptions);\n return formatter.format(dateValue());\n },\n getDateFormatter(loc, formatOptions) {\n const newOptions = { ...formatOpts(), ...formatOptions };\n const newFormatOptions = getFormatOptions({}, newOptions);\n return new DateFormatter(loc, newFormatOptions);\n },\n get locale() {\n return locale();\n },\n get timeZone() {\n return timeZone();\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// Segment processing\n// ---------------------------------------------------------------------------\n\nfunction processSegments(\n dateValue: Date,\n displayValue: IncompleteDate,\n dateFormatter: DateFormatter,\n resolvedOptions: Record<string, string>,\n calendar: Calendar,\n locale: string,\n granularity: FieldGranularity,\n): DateSegment[] {\n const timeValue = [\"hour\", \"minute\", \"second\"];\n const parts = dateFormatter.formatToParts(dateValue) as Array<{\n type: string;\n value: string;\n }>;\n\n // Allow formatting temporarily invalid dates during editing (e.g. February 30th) by\n // rendering numeric segments directly from raw numbers. On blur they are constrained.\n const numberFormatter = new Intl.NumberFormat(locale, { useGrouping: false });\n const twoDigitFormatter = new Intl.NumberFormat(locale, {\n useGrouping: false,\n minimumIntegerDigits: 2,\n });\n\n for (const segment of parts) {\n if (\n segment.type === \"year\" ||\n segment.type === \"month\" ||\n segment.type === \"day\" ||\n segment.type === \"hour\"\n ) {\n const value =\n (displayValue[segment.type as keyof IncompleteDate] as number | null | undefined) ?? 0;\n if (resolvedOptions[segment.type] === \"2-digit\") {\n segment.value = twoDigitFormatter.format(value);\n } else {\n segment.value = numberFormatter.format(value);\n }\n }\n }\n\n const processedSegments: DateSegment[] = [];\n for (const segment of parts) {\n const type = (TYPE_MAPPING[segment.type] || segment.type) as DateSegmentType;\n let isEditable = EDITABLE_SEGMENTS[type] === true;\n if (type === \"era\" && calendar.getEras().length === 1) isEditable = false;\n const isPlaceholder =\n EDITABLE_SEGMENTS[type] === true &&\n displayValue[segment.type as keyof IncompleteDate] == null;\n const placeholder = EDITABLE_SEGMENTS[type]\n ? getPlaceholder(type, segment.value, locale)\n : \"\";\n const limits = displayValue.getSegmentLimits(type);\n const dateSegment: DateSegment = {\n type,\n text: isPlaceholder ? placeholder : segment.value,\n value: limits?.value ?? undefined,\n minValue: limits?.minValue,\n maxValue: limits?.maxValue,\n isPlaceholder,\n placeholder,\n isEditable,\n };\n\n // There is an issue in RTL languages where time fields render (minute:hour) instead of\n // (hour:minute). To force LTR on the time field, wrap the time segments in LRI/PDI\n // (left-to-right isolate) unicode marks. See\n // https://www.w3.org/International/questions/qa-bidi-unicode-controls.\n if (type === \"hour\") {\n processedSegments.push({\n type: \"literal\",\n text: \"\",\n value: undefined,\n isPlaceholder: false,\n placeholder: \"\",\n isEditable: false,\n });\n processedSegments.push(dateSegment);\n if (type === granularity) {\n processedSegments.push({\n type: \"literal\",\n text: \"\",\n value: undefined,\n isPlaceholder: false,\n placeholder: \"\",\n isEditable: false,\n });\n }\n } else if (timeValue.includes(type) && type === granularity) {\n processedSegments.push(dateSegment);\n processedSegments.push({\n type: \"literal\",\n text: \"\",\n value: undefined,\n isPlaceholder: false,\n placeholder: \"\",\n isEditable: false,\n });\n } else {\n processedSegments.push(dateSegment);\n }\n }\n\n return processedSegments;\n}\n\n// ---------------------------------------------------------------------------\n// Utilities ported from @react-stately/datepicker utils\n// ---------------------------------------------------------------------------\n\ninterface FormatterOptions {\n timeZone?: string;\n hideTimeZone?: boolean;\n granularity?: Granularity;\n maxGranularity?: \"year\" | \"month\" | \"day\" | \"hour\" | \"minute\";\n hourCycle?: 12 | 24;\n showEra?: boolean;\n shouldForceLeadingZeros?: boolean;\n}\n\nconst DEFAULT_FIELD_OPTIONS: Intl.DateTimeFormatOptions = {\n year: \"numeric\",\n month: \"numeric\",\n day: \"numeric\",\n hour: \"numeric\",\n minute: \"2-digit\",\n second: \"2-digit\",\n};\n\nconst TWO_DIGIT_FIELD_OPTIONS: Intl.DateTimeFormatOptions = {\n year: \"numeric\",\n month: \"2-digit\",\n day: \"2-digit\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n second: \"2-digit\",\n};\n\nexport function getFormatOptions(\n fieldOptions: Intl.DateTimeFormatOptions | undefined,\n options: FormatterOptions,\n): Intl.DateTimeFormatOptions {\n const defaultFieldOptions = options.shouldForceLeadingZeros\n ? TWO_DIGIT_FIELD_OPTIONS\n : DEFAULT_FIELD_OPTIONS;\n const merged: Record<string, unknown> = { ...defaultFieldOptions, ...fieldOptions };\n const granularity = options.granularity || \"minute\";\n const keys = Object.keys(merged);\n let startIdx = keys.indexOf(options.maxGranularity ?? \"year\");\n if (startIdx < 0) startIdx = 0;\n let endIdx = keys.indexOf(granularity);\n if (endIdx < 0) endIdx = 2;\n if (startIdx > endIdx) throw new Error(\"maxGranularity must be greater than granularity\");\n const opts: Record<string, unknown> = keys.slice(startIdx, endIdx + 1).reduce(\n (acc: Record<string, unknown>, key) => {\n acc[key] = merged[key];\n return acc;\n },\n {},\n );\n if (options.hourCycle != null) opts.hour12 = options.hourCycle === 12;\n opts.timeZone = options.timeZone || \"UTC\";\n const hasTime = granularity === \"hour\" || granularity === \"minute\" || granularity === \"second\";\n if (hasTime && options.timeZone && !options.hideTimeZone) opts.timeZoneName = \"short\";\n if (options.showEra && startIdx === 0) opts.era = \"short\";\n return opts as Intl.DateTimeFormatOptions;\n}\n\nfunction convertValue(value: DateValue | null | undefined, calendar: Calendar): DateValue | null | undefined {\n if (value === null) return null;\n if (!value) return undefined;\n return toCalendar(value, calendar);\n}\n\nfunction createPlaceholderDate(\n placeholderValue: DateValue | undefined,\n granularity: string,\n calendar: Calendar,\n timeZone: string | undefined,\n): DateValue {\n if (placeholderValue) return convertValue(placeholderValue, calendar) as DateValue;\n const date = toCalendar(\n now(timeZone ?? getLocalTimeZone()).set({ hour: 0, minute: 0, second: 0, millisecond: 0 }),\n calendar,\n );\n if (granularity === \"year\" || granularity === \"month\" || granularity === \"day\") {\n return toCalendarDate(date);\n }\n if (!timeZone) return toCalendarDateTime(date);\n return date;\n}\n\n/** The placeholder time, used by time-only fields. */\nexport function getPlaceholderTime(placeholderValue?: DateValue): Time | DateValue {\n if (placeholderValue && \"hour\" in placeholderValue) return placeholderValue;\n return new Time();\n}\n\nfunction getValidationLocale(): string {\n let locale =\n (typeof navigator !== \"undefined\" &&\n ((navigator.language as string) ||\n (navigator as unknown as { userLanguage?: string }).userLanguage)) ||\n \"en-US\";\n try {\n Intl.DateTimeFormat.supportedLocalesOf([locale]);\n } catch {\n locale = \"en-US\";\n }\n return locale;\n}\n\nexport function getValidationResult(\n value: DateValue | null,\n minValue: DateValue | undefined,\n maxValue: DateValue | undefined,\n isDateUnavailable: ((date: DateValue) => boolean) | undefined,\n options: FormatterOptions,\n): ValidationResult {\n const rangeOverflow = value != null && maxValue != null && value.compare(maxValue) > 0;\n const rangeUnderflow = value != null && minValue != null && value.compare(minValue) < 0;\n const isUnavailable = (value != null && isDateUnavailable?.(value)) || false;\n const isInvalid = rangeOverflow || rangeUnderflow || isUnavailable;\n const errors: string[] = [];\n if (isInvalid) {\n const locale = getValidationLocale();\n const dateFormatter = new DateFormatter(locale, getFormatOptions({}, options));\n const timeZone = dateFormatter.resolvedOptions().timeZone;\n if (rangeUnderflow && minValue != null) {\n errors.push(\n formatError(locale, \"rangeUnderflow\", {\n minValue: dateFormatter.format(minValue.toDate(timeZone)),\n }),\n );\n }\n if (rangeOverflow && maxValue != null) {\n errors.push(\n formatError(locale, \"rangeOverflow\", {\n maxValue: dateFormatter.format(maxValue.toDate(timeZone)),\n }),\n );\n }\n if (isUnavailable) errors.push(formatError(locale, \"unavailableDate\"));\n }\n const validationDetails: ValidityState = {\n ...VALID_VALIDITY_STATE,\n badInput: isUnavailable,\n rangeOverflow,\n rangeUnderflow,\n valid: !isInvalid,\n };\n return {\n isInvalid,\n validationErrors: errors,\n validationDetails,\n };\n}\n\nfunction formatError(\n locale: string,\n key: DateFieldErrorKey,\n args?: { minValue?: string; maxValue?: string },\n): string {\n return formatDateFieldError(locale, key, args);\n}\n\n// Re-export so existing imports of CalendarDateTime keep resolving through this module.\nexport type { CalendarDateTime };\n","/**\n * RangeCalendarState for Solid-Stately\n *\n * Provides state management for range calendar components.\n * Based on @react-stately/calendar useRangeCalendarState\n */\n\nimport { createSignal, createMemo, createEffect, type Accessor } from \"solid-js\";\nimport {\n type Calendar as InternationalizedCalendar,\n type CalendarDate,\n type CalendarIdentifier,\n type DateValue,\n GregorianCalendar,\n today,\n getLocalTimeZone,\n isEqualCalendar,\n isSameDay,\n isSameMonth,\n startOfMonth,\n endOfMonth,\n startOfWeek,\n getWeeksInMonth,\n maxDate,\n minDate,\n DateFormatter,\n createCalendar as intlCreateCalendar,\n toCalendar as intlToCalendar,\n toCalendarDate as intlToCalendarDate,\n} from \"@internationalized/date\";\nimport { access, type MaybeAccessor } from \"../utils\";\nimport type { CalendarDayOfWeek, ValidationState } from \"./createCalendarState\";\nimport { getFormatOptions } from \"./createDateFieldState\";\n\nconst dayOfWeekNames: CalendarDayOfWeek[] = [\"sun\", \"mon\", \"tue\", \"wed\", \"thu\", \"fri\", \"sat\"];\ntype RangeCalendarSelectionAlignment = \"start\" | \"center\" | \"end\";\ntype RangeCalendarPageBehavior = \"single\" | \"visible\";\n\nexport interface DateRange {\n start: CalendarDate;\n end: CalendarDate;\n}\n\nexport interface RangeValue<T> {\n start: T;\n end: T;\n}\n\nexport interface RangeCalendarStateProps<T extends DateValue = DateValue> {\n /** The current value (controlled). */\n value?: MaybeAccessor<RangeValue<T> | null>;\n /** The default value (uncontrolled). */\n defaultValue?: RangeValue<T> | null;\n /** Handler called when the value changes. */\n onChange?: (value: RangeValue<T> | null) => void;\n /** The minimum allowed date. */\n minValue?: MaybeAccessor<DateValue | undefined>;\n /** The maximum allowed date. */\n maxValue?: MaybeAccessor<DateValue | undefined>;\n /** Whether the calendar is disabled. */\n isDisabled?: MaybeAccessor<boolean>;\n /** Whether the calendar is read-only. */\n isReadOnly?: MaybeAccessor<boolean>;\n /** The date that is focused when the calendar first mounts. */\n focusedValue?: MaybeAccessor<DateValue | null | undefined>;\n /** The default focused date (uncontrolled). */\n defaultFocusedValue?: DateValue;\n /** Handler called when the focused date changes. */\n onFocusChange?: (date: CalendarDate) => void;\n /** The locale to use for formatting. */\n locale?: MaybeAccessor<string | undefined>;\n /** Creates a calendar object for a locale calendar identifier. */\n createCalendar?: (identifier: CalendarIdentifier) => InternationalizedCalendar;\n /**\n * Callback that determines if a date is unavailable. The second argument is the\n * current selection anchor (the first selected date), so availability can be\n * derived from it. Mirrors @react-stately/calendar 1.18.\n */\n isDateUnavailable?: (date: DateValue, anchorDate: CalendarDate | null) => boolean;\n /** The number of months to display at once. */\n visibleMonths?: MaybeAccessor<number | undefined>;\n /** Controls how the initial visible months are aligned around the current value. */\n selectionAlignment?: MaybeAccessor<RangeCalendarSelectionAlignment | undefined>;\n /** Controls whether pagination moves by one month or the visible month count. */\n pageBehavior?: MaybeAccessor<RangeCalendarPageBehavior | undefined>;\n /** Controls which days are disabled. */\n isDateDisabled?: (date: DateValue) => boolean;\n /** Validation state. */\n validationState?: MaybeAccessor<ValidationState | undefined>;\n /** Whether to allow selecting the same date for start and end. */\n allowsNonContiguousRanges?: boolean;\n /** The first day of the week (0 = Sunday, 1 = Monday, etc.). */\n firstDayOfWeek?: 0 | 1 | 2 | 3 | 4 | 5 | 6;\n}\n\nexport interface RangeCalendarState<T extends DateValue = DateValue> {\n /** The currently selected date range. */\n value: Accessor<RangeValue<T> | null>;\n /** Sets the selected date range. */\n setValue: (value: RangeValue<T> | null) => void;\n /** The currently focused date. */\n focusedDate: Accessor<CalendarDate>;\n /** Sets the focused date. */\n setFocusedDate: (date: CalendarDate) => void;\n /** The minimum allowed date that a user may select. */\n minValue: Accessor<DateValue | null>;\n /** The maximum allowed date that a user may select. */\n maxValue: Accessor<DateValue | null>;\n /** The anchor date when selecting a range (first click). */\n anchorDate: Accessor<CalendarDate | null>;\n /** Sets the anchor date. */\n setAnchorDate: (date: CalendarDate | null) => void;\n /** The highlighted range during selection. */\n highlightedRange: Accessor<RangeValue<CalendarDate> | null>;\n /** Whether the calendar is disabled. */\n isDisabled: Accessor<boolean>;\n /** Whether the calendar is read-only. */\n isReadOnly: Accessor<boolean>;\n /** The visible date range (first and last day of visible month(s)). */\n visibleRange: Accessor<{ start: CalendarDate; end: CalendarDate }>;\n /** The timezone used for date calculations. */\n timeZone: string;\n /** The locale used for formatting and locale-specific week starts. */\n locale: Accessor<string>;\n /** The explicitly requested first weekday, or undefined for the locale default. */\n firstDayOfWeek: Accessor<CalendarDayOfWeek | undefined>;\n /** The validation state. */\n validationState: Accessor<ValidationState | undefined>;\n /** Whether the current value is invalid according to validation state. */\n isValueInvalid: Accessor<boolean>;\n /** Whether a date is within the selected range. */\n isSelected: (date: DateValue) => boolean;\n /** Whether a date is the start of the selection. */\n isSelectionStart: (date: DateValue) => boolean;\n /** Whether a date is the end of the selection. */\n isSelectionEnd: (date: DateValue) => boolean;\n /** Whether a date is focused. */\n isCellFocused: (date: DateValue) => boolean;\n /** Whether a date is unavailable. */\n isCellUnavailable: (date: DateValue) => boolean;\n /** Whether a date is disabled. */\n isCellDisabled: (date: DateValue) => boolean;\n /** Whether a date is outside the visible range. */\n isOutsideVisibleRange: (date: DateValue) => boolean;\n /** Whether a date is invalid. */\n isInvalid: (date: DateValue) => boolean;\n /** Moves focus to the previous page (month). */\n focusPreviousPage: () => void;\n /** Moves focus to the next page (month). */\n focusNextPage: () => void;\n /** Moves focus to the previous section (year). */\n focusPreviousSection: () => void;\n /** Moves focus to the next section (year). */\n focusNextSection: () => void;\n /** Whether the previous visible range would be outside the allowed date range. */\n isPreviousVisibleRangeInvalid: () => boolean;\n /** Whether the next visible range would be outside the allowed date range. */\n isNextVisibleRangeInvalid: () => boolean;\n /** Moves focus to the previous day. */\n focusPreviousDay: () => void;\n /** Moves focus to the next day. */\n focusNextDay: () => void;\n /** Moves focus to the previous week. */\n focusPreviousWeek: () => void;\n /** Moves focus to the next week. */\n focusNextWeek: () => void;\n /** Moves focus to the start of the month. */\n focusPageStart: () => void;\n /** Moves focus to the end of the month. */\n focusPageEnd: () => void;\n /** Selects the focused date. */\n selectFocusedDate: () => void;\n /** Selects a specific date. */\n selectDate: (date: CalendarDate) => void;\n /** Whether focus is currently within the calendar. */\n isFocused: Accessor<boolean>;\n /** Sets whether focus is within the calendar. */\n setFocused: (focused: boolean) => void;\n /** Gets the dates for a week in the visible range. */\n getDatesInWeek: (weekIndex: number, monthStartDate?: CalendarDate) => (CalendarDate | null)[];\n /** Gets the number of weeks in a month. */\n getWeeksInMonth: (date?: CalendarDate) => number;\n /** The week day headers. */\n weekDays: Accessor<string[]>;\n /** The title for the calendar (formatted month and year). */\n title: Accessor<string>;\n /** The number of visible months. */\n visibleMonths: number;\n /** Whether the user is currently selecting a range. */\n isDragging: Accessor<boolean>;\n /** Sets whether the user is dragging to select. */\n setDragging: (dragging: boolean) => void;\n /**\n * Formats the selected range as a `{ start, end }` pair of localized strings,\n * or `null` when the range is incomplete. Mirrors upstream\n * `DateRangePickerState.formatValue` — the port collapses that state into the\n * range calendar state, so the range picker reads its SR description from here.\n */\n formatValue: (\n locale: string,\n fieldOptions: Intl.DateTimeFormatOptions,\n ) => { start: string; end: string } | null;\n}\n\n/**\n * Provides state management for a range calendar component.\n */\nexport function createRangeCalendarState<T extends DateValue = CalendarDate>(\n props: RangeCalendarStateProps<T> = {},\n): RangeCalendarState<T> {\n const timeZone = getLocalTimeZone();\n const locale = createMemo(() => access(props.locale) ?? \"en-US\");\n const minValueState = createMemo(() => access(props.minValue) ?? null);\n const maxValueState = createMemo(() => access(props.maxValue) ?? null);\n const resolvedOptions = createMemo(() => new DateFormatter(locale()).resolvedOptions());\n const calendar = createMemo(() =>\n (props.createCalendar ?? intlCreateCalendar)(resolvedOptions().calendar as CalendarIdentifier),\n );\n const visibleMonths = Math.max(1, Number(access(props.visibleMonths) ?? 1));\n const firstDayOfWeekName = (): CalendarDayOfWeek | undefined =>\n props.firstDayOfWeek == null ? undefined : dayOfWeekNames[props.firstDayOfWeek];\n\n const toDisplayCalendarDate = (date: DateValue): CalendarDate =>\n intlToCalendar(toCalendarDate(date), calendar());\n\n // The anchor date is the first selected date during a range drag. Declared up\n // here (ahead of constrainDate) because the available-range derivation below\n // depends on it, and constrainDate consults that range.\n const [anchorDate, setAnchorDate] = createSignal<CalendarDate | null>(null);\n\n // Mirrors @react-stately/calendar useRangeCalendarState getAvailableRange: once\n // a range selection is anchored and unavailable dates exist, contiguous ranges\n // are required (unless allowsNonContiguousRanges), so the selectable span is\n // bounded by the nearest unavailable date on each side of the anchor.\n const getAvailableRange = (\n anchor: CalendarDate | null,\n ): { start?: CalendarDate; end?: CalendarDate } | null => {\n if (anchor && props.isDateUnavailable && !props.allowsNonContiguousRanges) {\n const predicate = (date: CalendarDate): boolean => props.isDateUnavailable!(date, anchor);\n return {\n start: nextUnavailableDate(anchor, predicate, visibleMonths, -1),\n end: nextUnavailableDate(anchor, predicate, visibleMonths, 1),\n };\n }\n return null;\n };\n\n const availableRange = createMemo(() => getAvailableRange(anchorDate()));\n\n // minValue/maxValue narrowed by the available range, in display-calendar space\n // (what every cell/navigation bound below compares against). Mirrors upstream's\n // maxDate(minValue, availableRange?.start) / minDate(maxValue, availableRange?.end);\n // maxDate/minDate ignore undefined operands, so an absent bound passes through.\n const effectiveMinValue = createMemo<CalendarDate | null>(() => {\n const min = access(props.minValue);\n const minCal = min != null ? toDisplayCalendarDate(min) : undefined;\n return maxDate(minCal, availableRange()?.start) ?? null;\n });\n const effectiveMaxValue = createMemo<CalendarDate | null>(() => {\n const max = access(props.maxValue);\n const maxCal = max != null ? toDisplayCalendarDate(max) : undefined;\n return minDate(maxCal, availableRange()?.end) ?? null;\n });\n\n const constrainDate = (date: CalendarDate): CalendarDate => {\n const min = effectiveMinValue();\n const max = effectiveMaxValue();\n\n let constrained = date;\n\n if (min && constrained.compare(min) < 0) {\n constrained = min;\n }\n if (max && constrained.compare(max) > 0) {\n constrained = max;\n }\n\n return constrained;\n };\n\n const visibleRangeEndFromStart = (start: CalendarDate): CalendarDate => {\n let end = endOfMonth(start);\n\n for (let i = 1; i < visibleMonths; i++) {\n end = endOfMonth(end.add({ months: 1 }));\n }\n\n return end;\n };\n\n const rawAlignStart = (date: CalendarDate): CalendarDate => startOfMonth(date);\n\n const rawAlignEnd = (date: CalendarDate): CalendarDate =>\n startOfMonth(date).subtract({ months: Math.max(visibleMonths - 1, 0) });\n\n const constrainVisibleRangeStart = (date: CalendarDate, aligned: CalendarDate): CalendarDate => {\n const minValue = access(props.minValue);\n const maxValue = access(props.maxValue);\n let constrained = aligned;\n\n if (minValue && date.compare(toDisplayCalendarDate(minValue)) >= 0) {\n const minStart = rawAlignStart(toDisplayCalendarDate(minValue));\n if (minStart.compare(constrained) > 0) {\n constrained = minStart;\n }\n }\n\n if (maxValue && date.compare(toDisplayCalendarDate(maxValue)) <= 0) {\n const maxStart = rawAlignEnd(toDisplayCalendarDate(maxValue));\n if (maxStart.compare(constrained) < 0) {\n constrained = maxStart;\n }\n }\n\n return constrained;\n };\n\n const alignStart = (date: CalendarDate): CalendarDate =>\n constrainVisibleRangeStart(date, rawAlignStart(date));\n\n const alignEnd = (date: CalendarDate): CalendarDate =>\n constrainVisibleRangeStart(date, rawAlignEnd(date));\n\n const alignCenter = (date: CalendarDate): CalendarDate => {\n let offset = Math.floor(visibleMonths / 2);\n if (offset > 0 && visibleMonths % 2 === 0) {\n offset--;\n }\n\n return constrainVisibleRangeStart(date, rawAlignStart(date).subtract({ months: offset }));\n };\n\n const defaultSelectionAlignment = (): RangeCalendarSelectionAlignment => {\n const currentValue = access(props.value) ?? props.defaultValue;\n if (!currentValue?.start || !currentValue?.end) {\n return \"center\";\n }\n\n const start = alignCenter(toDisplayCalendarDate(currentValue.start));\n const end = visibleRangeEndFromStart(start);\n return toDisplayCalendarDate(currentValue.end).compare(end) > 0 ? \"start\" : \"center\";\n };\n\n const alignVisibleRangeStart = (date: CalendarDate): CalendarDate => {\n switch (access(props.selectionAlignment) ?? defaultSelectionAlignment()) {\n case \"start\":\n return alignStart(date);\n case \"end\":\n return alignEnd(date);\n case \"center\":\n default:\n return alignCenter(date);\n }\n };\n\n // Determine the initially focused date\n const getInitialFocusedDate = (): CalendarDate => {\n const controlledFocused = access(props.focusedValue);\n if (controlledFocused) {\n return toDisplayCalendarDate(controlledFocused);\n }\n if (props.defaultFocusedValue) {\n return toDisplayCalendarDate(props.defaultFocusedValue);\n }\n const controlledValue = access(props.value);\n if (controlledValue?.start) {\n return toDisplayCalendarDate(controlledValue.start);\n }\n if (props.defaultValue?.start) {\n return toDisplayCalendarDate(props.defaultValue.start);\n }\n return intlToCalendar(today(timeZone), calendar());\n };\n\n // State signals\n const [internalValue, setInternalValue] = createSignal<RangeValue<T> | null>(\n props.defaultValue ?? null,\n );\n const initialFocusedDate = constrainDate(getInitialFocusedDate());\n const [focusedDate, setFocusedDateInternal] = createSignal<CalendarDate>(initialFocusedDate);\n const [visibleRangeStart, setVisibleRangeStart] = createSignal<CalendarDate>(\n alignVisibleRangeStart(initialFocusedDate),\n );\n const [isFocused, setFocused] = createSignal(false);\n const [isDragging, setDragging] = createSignal(false);\n\n // Controlled vs uncontrolled value\n const sourceValue = createMemo<RangeValue<T> | null>(() => {\n const controlled = access(props.value);\n return controlled !== undefined ? controlled : internalValue();\n });\n const value = createMemo<RangeValue<T> | null>(() => {\n const currentValue = sourceValue();\n if (!currentValue) {\n return null;\n }\n\n return {\n start: toDisplayCalendarDate(currentValue.start) as unknown as T,\n end: toDisplayCalendarDate(currentValue.end) as unknown as T,\n };\n });\n\n // Derived states\n const isDisabled = createMemo(() => access(props.isDisabled) ?? false);\n const isReadOnly = createMemo(() => access(props.isReadOnly) ?? false);\n const validationState = createMemo(() => access(props.validationState));\n // A committed range is invalid when (not mid-drag) either endpoint is\n // unavailable or falls outside [minValue, maxValue]. Mirrors upstream\n // useRangeCalendarState's isInvalid derivation. Calls props.isDateUnavailable\n // directly (with a null anchor) rather than the closures defined further down,\n // since this memo runs eagerly during init.\n const isInvalidSelection = createMemo(() => {\n const v = sourceValue();\n if (!v || anchorDate()) return false;\n if (props.isDateUnavailable?.(v.start, null) || props.isDateUnavailable?.(v.end, null)) {\n return true;\n }\n const min = access(props.minValue);\n const max = access(props.maxValue);\n const minCal = min != null ? toDisplayCalendarDate(min) : null;\n const maxCal = max != null ? toDisplayCalendarDate(max) : null;\n return (\n isDateOutsideRange(toDisplayCalendarDate(v.start), minCal, maxCal) ||\n isDateOutsideRange(toDisplayCalendarDate(v.end), minCal, maxCal)\n );\n });\n const isValueInvalid = createMemo(() => validationState() === \"invalid\" || isInvalidSelection());\n\n // Highlighted range during selection\n const highlightedRange = createMemo<RangeValue<CalendarDate> | null>(() => {\n const anchor = anchorDate();\n if (!anchor) {\n const v = value();\n if (v) {\n return {\n start: toDisplayCalendarDate(v.start),\n end: toDisplayCalendarDate(v.end),\n };\n }\n return null;\n }\n\n const focused = focusedDate();\n if (anchor.compare(focused) <= 0) {\n return { start: anchor, end: focused };\n }\n return { start: focused, end: anchor };\n });\n\n // Visible range based on React Stately's selection alignment rules.\n const visibleRange = createMemo(() => {\n const start = visibleRangeStart();\n return { start, end: visibleRangeEndFromStart(start) };\n });\n\n // Realign the visible range only when the focused date moves outside it,\n // mirroring @react-stately/calendar useCalendarState (the render-time\n // `focusedDate.compare(startDate) < 0 → alignEnd` / `compare(endDate) > 0 →\n // alignStart` branches — focusCell itself never touches the range). Guarding\n // on out-of-range keeps a same-month focus from re-firing visibleRangeStart\n // with a fresh equal-valued object, which would otherwise recompute the grid\n // and recreate every cell on focus.\n const syncVisibleRangeForFocusedDate = (nextFocusedDate: CalendarDate) => {\n const range = visibleRange();\n\n if (nextFocusedDate.compare(range.start) < 0) {\n setVisibleRangeStart(alignEnd(nextFocusedDate));\n } else if (nextFocusedDate.compare(range.end) > 0) {\n setVisibleRangeStart(alignStart(nextFocusedDate));\n }\n };\n\n createEffect(() => {\n const controlledFocused = access(props.focusedValue);\n if (!controlledFocused) {\n return;\n }\n\n const nextFocusedDate = constrainDate(toDisplayCalendarDate(controlledFocused));\n const currentFocusedDate = focusedDate();\n\n if (\n nextFocusedDate.compare(currentFocusedDate) !== 0 ||\n !isEqualCalendar(nextFocusedDate.calendar, currentFocusedDate.calendar)\n ) {\n setFocusedDateInternal(nextFocusedDate);\n setVisibleRangeStart(alignVisibleRangeStart(nextFocusedDate));\n }\n });\n\n createEffect(() => {\n const controlledFocused = access(props.focusedValue);\n if (controlledFocused) {\n return;\n }\n\n const currentFocusedDate = focusedDate();\n const nextFocusedDate = constrainDate(currentFocusedDate);\n\n if (\n nextFocusedDate.compare(currentFocusedDate) === 0 &&\n isEqualCalendar(nextFocusedDate.calendar, currentFocusedDate.calendar)\n ) {\n return;\n }\n\n setFocusedDateInternal(nextFocusedDate);\n setVisibleRangeStart(alignVisibleRangeStart(nextFocusedDate));\n props.onFocusChange?.(nextFocusedDate);\n });\n\n createEffect(() => {\n const currentFocusedDate = focusedDate();\n const nextFocusedDate = toDisplayCalendarDate(currentFocusedDate);\n\n if (isEqualCalendar(currentFocusedDate.calendar, nextFocusedDate.calendar)) {\n return;\n }\n\n setFocusedDateInternal(nextFocusedDate);\n setVisibleRangeStart(alignVisibleRangeStart(nextFocusedDate));\n });\n\n // Format week days for headers\n const weekDays = createMemo(() => {\n const formatter = new DateFormatter(locale(), { weekday: \"narrow\" });\n const days: string[] = [];\n const weekStart = startOfWeek(today(timeZone), locale(), firstDayOfWeekName());\n\n for (let i = 0; i < 7; i++) {\n const day = weekStart.add({ days: i });\n days.push(formatter.format(day.toDate(timeZone)));\n }\n\n return days;\n });\n\n // Title (formatted month/year)\n const title = createMemo(() => {\n const formatter = new DateFormatter(locale(), {\n month: \"long\",\n year: \"numeric\",\n calendar: focusedDate().calendar.identifier,\n });\n const date = focusedDate();\n const formattableMonth = date.calendar.getFormattableMonth?.(date) ?? date;\n return formatter.format(formattableMonth.toDate(timeZone));\n });\n\n // Set value with onChange callback\n const setValue = (newValue: RangeValue<T> | null) => {\n if (isDisabled() || isReadOnly()) return;\n\n const oldValue = sourceValue();\n const nextValue = newValue\n ? {\n start: convertValue(\n constrainDate(toDisplayCalendarDate(newValue.start)),\n oldValue?.start,\n ) as T,\n end: convertValue(constrainDate(toDisplayCalendarDate(newValue.end)), oldValue?.end) as T,\n }\n : null;\n\n const controlled = access(props.value);\n if (controlled === undefined) {\n setInternalValue(() => nextValue);\n }\n\n if (!Object.is(oldValue, nextValue) && props.onChange) {\n props.onChange(nextValue);\n }\n };\n\n // Set focused date with constraints\n const setFocusedDate = (date: CalendarDate) => {\n const constrained = constrainDate(date);\n\n if (Object.is(constrained, focusedDate())) {\n return;\n }\n\n syncVisibleRangeForFocusedDate(constrained);\n setFocusedDateInternal(constrained);\n props.onFocusChange?.(constrained);\n };\n\n // Check if a date is within the selected range\n const isSelected = (date: DateValue): boolean => {\n const range = highlightedRange();\n if (!range) return false;\n\n const calDate = toDisplayCalendarDate(date);\n // Mirror @react-stately/calendar useRangeCalendarState isSelected: a disabled\n // or unavailable cell is NOT reported selected, so its accessible name drops\n // the \"… selected\" suffix + aria-selected (e.g. when the whole calendar is\n // disabled). The \"Selected Range: …\" description prefix is separate and still\n // applies to the range endpoints.\n return (\n calDate.compare(range.start) >= 0 &&\n calDate.compare(range.end) <= 0 &&\n !isCellDisabled(date) &&\n !isCellUnavailable(date)\n );\n };\n\n // Check if a date is the start of the selection\n const isSelectionStart = (date: DateValue): boolean => {\n const range = highlightedRange();\n if (!range) return false;\n return isSameDay(toDisplayCalendarDate(date), range.start);\n };\n\n // Check if a date is the end of the selection\n const isSelectionEnd = (date: DateValue): boolean => {\n const range = highlightedRange();\n if (!range) return false;\n return isSameDay(toDisplayCalendarDate(date), range.end);\n };\n\n // Check if a date is focused\n const isCellFocused = (date: DateValue): boolean => {\n // Gate on the calendar-level `isFocused` flag, mirroring @react-stately\n // useCalendarState (`isFocused && focusedDate && isSameDay`, inherited by\n // useRangeCalendarState). The roving tabIndex tracks `focusedDate` directly\n // at the cell layer, so one cell stays tabbable without this being true —\n // this drives focusSafely + the range-selection prompt, which must NOT fire\n // until the calendar actually holds focus.\n return isFocused() && isSameDay(toDisplayCalendarDate(date), focusedDate());\n };\n\n // Check if a date is unavailable\n const isCellUnavailable = (date: DateValue): boolean => {\n return props.isDateUnavailable?.(date, anchorDate()) ?? false;\n };\n\n // Check if a date is disabled\n const isCellDisabled = (date: DateValue): boolean => {\n if (isDisabled()) return true;\n if (props.isDateDisabled?.(date)) return true;\n\n const min = effectiveMinValue();\n const max = effectiveMaxValue();\n const calDate = toDisplayCalendarDate(date);\n\n // Dates outside the visible range are disabled, mirroring @react-stately\n // useCalendarState isCellDisabled (`date.compare(startDate) < 0 ||\n // date.compare(endDate) > 0` over the visible range, inherited by\n // useRangeCalendarState). This marks the leading/trailing padding cells\n // (days from adjacent months filling the first/last grid weeks) as\n // aria-disabled.\n const range = visibleRange();\n if (calDate.compare(toDisplayCalendarDate(range.start)) < 0) return true;\n if (calDate.compare(toDisplayCalendarDate(range.end)) > 0) return true;\n\n if (min && calDate.compare(min) < 0) return true;\n if (max && calDate.compare(max) > 0) return true;\n\n return false;\n };\n\n const isDateOutsideAllowedRange = (date: DateValue): boolean => {\n const min = effectiveMinValue();\n const max = effectiveMaxValue();\n const calDate = toDisplayCalendarDate(date);\n\n if (min && calDate.compare(min) < 0) return true;\n if (max && calDate.compare(max) > 0) return true;\n\n return false;\n };\n\n // Check if a date is outside the visible range\n const isOutsideVisibleRange = (date: DateValue): boolean => {\n const range = visibleRange();\n const calDate = toDisplayCalendarDate(date);\n return !isSameMonth(calDate, range.start) && !isSameMonth(calDate, range.end);\n };\n\n // Check if a date is invalid\n const isInvalid = (date: DateValue): boolean => {\n return isCellDisabled(date) || isCellUnavailable(date);\n };\n\n // Navigation methods\n // Paging realigns the visible range start explicitly, mirroring\n // @react-stately/calendar focusPreviousPage/focusNextPage (which set both\n // focusedDate and startDate directly). This must NOT route through\n // setFocusedDate: that only realigns the range when the focused date leaves\n // the window, so a single-month page whose focus stays in view would never\n // advance the grid.\n const focusPreviousPage = () => {\n const pageMonths = access(props.pageBehavior) === \"single\" ? 1 : visibleMonths;\n const nextFocusedDate = constrainDate(focusedDate().subtract({ months: pageMonths }));\n setFocusedDateInternal(nextFocusedDate);\n setVisibleRangeStart(startOfMonth(visibleRangeStart().subtract({ months: pageMonths })));\n props.onFocusChange?.(nextFocusedDate);\n };\n\n const focusNextPage = () => {\n const pageMonths = access(props.pageBehavior) === \"single\" ? 1 : visibleMonths;\n const nextFocusedDate = constrainDate(focusedDate().add({ months: pageMonths }));\n setFocusedDateInternal(nextFocusedDate);\n setVisibleRangeStart(startOfMonth(visibleRangeStart().add({ months: pageMonths })));\n props.onFocusChange?.(nextFocusedDate);\n };\n\n const focusPreviousSection = () => {\n setFocusedDate(focusedDate().subtract({ years: 1 }));\n };\n\n const focusNextSection = () => {\n setFocusedDate(focusedDate().add({ years: 1 }));\n };\n\n const isPreviousVisibleRangeInvalid = () => {\n const start = visibleRange().start;\n const previous = start.subtract({ days: 1 });\n return isSameDay(previous, start) || isDateOutsideAllowedRange(previous);\n };\n\n const isNextVisibleRangeInvalid = () => {\n const end = visibleRange().end;\n const next = end.add({ days: 1 });\n return isSameDay(next, end) || isDateOutsideAllowedRange(next);\n };\n\n const focusPreviousDay = () => {\n setFocusedDate(focusedDate().subtract({ days: 1 }));\n };\n\n const focusNextDay = () => {\n setFocusedDate(focusedDate().add({ days: 1 }));\n };\n\n const focusPreviousWeek = () => {\n setFocusedDate(focusedDate().subtract({ weeks: 1 }));\n };\n\n const focusNextWeek = () => {\n setFocusedDate(focusedDate().add({ weeks: 1 }));\n };\n\n const focusPageStart = () => {\n setFocusedDate(startOfMonth(focusedDate()));\n };\n\n const focusPageEnd = () => {\n setFocusedDate(endOfMonth(focusedDate()));\n };\n\n // Selection methods\n const selectFocusedDate = () => {\n if (isReadOnly() || isDisabled()) return;\n selectDate(focusedDate());\n };\n\n const selectDate = (date: CalendarDate) => {\n // Mirror @react-stately/calendar useRangeCalendarState.selectDate: NO\n // isCellDisabled/isCellUnavailable guard here. Upstream gates selection at\n // the cell layer (createRangeCalendarCell handlePointerDown/handleClick check\n // isSelectable before calling selectDate); the state method itself constrains\n // to [minValue, maxValue] (narrowed by the available range) and walks back\n // over unavailable dates, refusing only when no available date remains — and\n // when the whole calendar is disabled/readOnly. Double-guarding on\n // isCellDisabled also broke programmatic selection of dates outside the\n // current visible range (now that isCellDisabled bounds on the visible range,\n // like upstream useCalendarState).\n if (isReadOnly() || isDisabled()) return;\n\n // constrainDate == upstream constrainValue(date, min, max): clamp into the\n // (available-range-narrowed) [minValue, maxValue] interval.\n const constrainedDate = constrainDate(date);\n // Availability is evaluated relative to the current anchor, matching\n // isCellUnavailable, then previousAvailableDate walks back to the last\n // available date at/before the constrained date within the visible range.\n const predicate = props.isDateUnavailable\n ? (d: CalendarDate) => props.isDateUnavailable!(d, anchorDate())\n : undefined;\n const selectableDate = previousAvailableDate(\n constrainedDate,\n toDisplayCalendarDate(visibleRange().start),\n predicate,\n );\n if (!selectableDate) return;\n\n const anchor = anchorDate();\n\n if (!anchor) {\n // First click - set anchor\n setAnchorDate(selectableDate);\n setDragging(true);\n } else {\n // Second click - complete selection\n let start: CalendarDate;\n let end: CalendarDate;\n\n if (selectableDate.compare(anchor) < 0) {\n start = selectableDate;\n end = anchor;\n } else {\n start = anchor;\n end = selectableDate;\n }\n\n setValue({\n start: start as unknown as T,\n end: end as unknown as T,\n });\n setAnchorDate(null);\n setDragging(false);\n }\n\n setFocusedDate(selectableDate);\n };\n\n // Get dates in a specific week\n const getDatesInWeek = (\n weekIndex: number,\n monthStartDate?: CalendarDate,\n ): (CalendarDate | null)[] => {\n const startDate = monthStartDate ?? visibleRange().start;\n\n const monthStart = startOfMonth(startDate);\n const weekStart = startOfWeek(monthStart, locale(), firstDayOfWeekName());\n\n const week: (CalendarDate | null)[] = [];\n const firstDayOfWeek = weekStart.add({ weeks: weekIndex });\n\n for (let i = 0; i < 7; i++) {\n const date = firstDayOfWeek.add({ days: i });\n week.push(date);\n }\n\n return week;\n };\n\n // Get number of weeks in a month\n const getWeeksInMonthFn = (date?: CalendarDate): number => {\n const monthDate = date ?? focusedDate();\n return getWeeksInMonth(monthDate, locale(), firstDayOfWeekName());\n };\n\n // Format the selected range as `{ start, end }` strings. Faithful port of\n // @react-stately/datepicker `useDateRangePickerState.formatValue`: when both\n // endpoints share timezone + granularity and are distinct, it uses\n // `formatRangeToParts` to split at the last shared literal so shared fields\n // (e.g. the month/year) render once (=> \"February 3\" / \"14, 2025\").\n const formatValue = (\n locale2: string,\n fieldOptions: Intl.DateTimeFormatOptions,\n ): { start: string; end: string } | null => {\n const v = value();\n if (!v || !v.start || !v.end) {\n return null;\n }\n\n const start = v.start as unknown as DateValue;\n const end = v.end as unknown as DateValue;\n const startTimeZone = \"timeZone\" in start ? (start as { timeZone: string }).timeZone : undefined;\n const startGranularity = \"minute\" in start ? \"minute\" : \"day\";\n const endTimeZone = \"timeZone\" in end ? (end as { timeZone: string }).timeZone : undefined;\n const endGranularity = \"minute\" in end ? \"minute\" : \"day\";\n\n const startOptions = getFormatOptions(fieldOptions, {\n granularity: startGranularity,\n timeZone: startTimeZone,\n showEra:\n (start.calendar.identifier === \"gregory\" && (start as { era: string }).era === \"BC\") ||\n (end.calendar.identifier === \"gregory\" && (end as { era: string }).era === \"BC\"),\n });\n\n const startDate = start.toDate(startTimeZone || \"UTC\");\n const endDate = end.toDate(endTimeZone || \"UTC\");\n\n const startFormatter = new DateFormatter(locale2, startOptions);\n let endFormatter: DateFormatter;\n if (\n startTimeZone === endTimeZone &&\n startGranularity === endGranularity &&\n start.compare(end) !== 0\n ) {\n // Use formatRange, as it results in shorter output when some of the fields\n // are shared between the start and end dates (e.g. the same month).\n try {\n const parts = startFormatter.formatRangeToParts(startDate, endDate);\n\n // Find the separator between the start and end date: the last shared\n // literal before the end range begins.\n let separatorIndex = -1;\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i];\n if (part.source === \"shared\" && part.type === \"literal\") {\n separatorIndex = i;\n } else if (part.source === \"endRange\") {\n break;\n }\n }\n\n let startStr = \"\";\n let endStr = \"\";\n for (let i = 0; i < parts.length; i++) {\n if (i < separatorIndex) startStr += parts[i].value;\n else if (i > separatorIndex) endStr += parts[i].value;\n }\n\n return { start: startStr, end: endStr };\n } catch {\n // ignore — fall through to per-endpoint formatting\n }\n\n endFormatter = startFormatter;\n } else {\n const endOptions = getFormatOptions(fieldOptions, {\n granularity: endGranularity,\n timeZone: endTimeZone,\n });\n endFormatter = new DateFormatter(locale2, endOptions);\n }\n\n return {\n start: startFormatter.format(startDate),\n end: endFormatter.format(endDate),\n };\n };\n\n return {\n value,\n setValue,\n focusedDate,\n setFocusedDate,\n anchorDate,\n setAnchorDate,\n highlightedRange,\n isDisabled,\n isReadOnly,\n visibleRange,\n timeZone,\n locale,\n minValue: minValueState,\n maxValue: maxValueState,\n firstDayOfWeek: firstDayOfWeekName,\n validationState,\n isValueInvalid,\n isSelected,\n isSelectionStart,\n isSelectionEnd,\n isCellFocused,\n isCellUnavailable,\n isCellDisabled,\n isOutsideVisibleRange,\n isInvalid,\n focusPreviousPage,\n focusNextPage,\n focusPreviousSection,\n focusNextSection,\n isPreviousVisibleRangeInvalid,\n isNextVisibleRangeInvalid,\n focusPreviousDay,\n focusNextDay,\n focusPreviousWeek,\n focusNextWeek,\n focusPageStart,\n focusPageEnd,\n selectFocusedDate,\n selectDate,\n isFocused,\n setFocused,\n getDatesInWeek,\n getWeeksInMonth: getWeeksInMonthFn,\n weekDays,\n title,\n visibleMonths,\n isDragging,\n setDragging,\n formatValue,\n };\n}\n\n/**\n * Converts a DateValue to a CalendarDate.\n */\nfunction toCalendarDate(date: DateValue): CalendarDate {\n return intlToCalendarDate(date);\n}\n\nfunction convertValue(newValue: CalendarDate, oldValue?: DateValue | null): DateValue {\n const localValue = intlToCalendar(newValue, oldValue?.calendar ?? new GregorianCalendar());\n\n if (oldValue && \"hour\" in oldValue) {\n return oldValue.set(localValue);\n }\n\n return localValue;\n}\n\n/** Whether a date falls outside the closed [minValue, maxValue] interval. */\nfunction isDateOutsideRange(\n date: CalendarDate,\n minValue?: CalendarDate | null,\n maxValue?: CalendarDate | null,\n): boolean {\n return (\n (minValue != null && date.compare(minValue) < 0) ||\n (maxValue != null && date.compare(maxValue) > 0)\n );\n}\n\n/**\n * Walks backward from `date` one day at a time while the date is unavailable and\n * still at/after `minValue` (the visible-range start), returning the last\n * available date — or null when the walk falls before `minValue`. With no\n * `isDateUnavailable` predicate the date is returned unchanged. Mirrors\n * @react-stately/calendar previousAvailableDate.\n */\nfunction previousAvailableDate(\n date: CalendarDate,\n minValue: CalendarDate,\n isDateUnavailable?: (date: CalendarDate) => boolean,\n): CalendarDate | null {\n if (!isDateUnavailable) {\n return date;\n }\n\n while (date.compare(minValue) >= 0 && isDateUnavailable(date)) {\n date = date.subtract({ days: 1 });\n }\n\n if (date.compare(minValue) >= 0) {\n return date;\n }\n return null;\n}\n\n/**\n * Walks outward from the anchor one day at a time in `dir` until it reaches an\n * unavailable date, then returns the last available date before it — or\n * undefined when no unavailable date is found within `visibleMonths` of the\n * anchor (no narrowing needed on that side). Mirrors @react-stately/calendar\n * nextUnavailableDate.\n */\nfunction nextUnavailableDate(\n anchorDate: CalendarDate,\n isDateUnavailable: (date: CalendarDate) => boolean,\n visibleMonths: number,\n dir: number,\n): CalendarDate | undefined {\n let nextDate = anchorDate.add({ days: dir });\n const minBound = anchorDate.subtract({ months: visibleMonths });\n const maxBound = anchorDate.add({ months: visibleMonths });\n while (\n (dir < 0 ? nextDate.compare(minBound) >= 0 : nextDate.compare(maxBound) <= 0) &&\n !isDateUnavailable(nextDate)\n ) {\n nextDate = nextDate.add({ days: dir });\n }\n if (isDateUnavailable(nextDate)) {\n return nextDate.add({ days: -dir });\n }\n return undefined;\n}\n","/**\n * TimeFieldState for Solid-Stately\n *\n * Faithful port of `@react-stately/datepicker` `useTimeFieldState`, which is a\n * thin wrapper over `useDateFieldState`: a time-only `Time` value is converted\n * to a `CalendarDateTime` (anchored on today's date, or a zoned date when the\n * value/default carries a time zone) and fed to the date-field state machine\n * with `maxGranularity: 'hour'` so the date segments drop away and only\n * hour/minute[/second]/dayPeriod remain. The returned state IS the\n * `DateFieldState`, plus a `timeValue` accessor holding the value back in the\n * `Time` domain. This means TimeField reuses the certified DateField segment\n * stack (`createDateSegment`, `DateInput`, `DateSegment`) exactly as RAC's\n * TimeField reuses `DateInput`/`DateSegment` — there is no parallel time\n * primitive.\n *\n * The `timeValue` is layered on with a Proxy rather than an object spread\n * because `DateFieldState`'s `calendar`/`dateFormatter`/`granularity`/\n * `maxGranularity`/`locale`/`timeZone` members are getters — spreading would\n * invoke and freeze them, breaking reactivity.\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport {\n Time,\n type CalendarDate,\n type CalendarDateTime,\n type ZonedDateTime,\n type DateValue,\n getLocalTimeZone,\n today,\n toTime,\n toZoned,\n toCalendarDateTime,\n GregorianCalendar,\n} from \"@internationalized/date\";\nimport { access, type MaybeAccessor } from \"../utils\";\nimport type { ValidationState } from \"./createCalendarState\";\nimport type { ValidationBehavior, ValidationFunction } from \"../form\";\nimport {\n createDateFieldState,\n type DateFieldState,\n type DateSegment as DateSegmentInternal,\n type DateSegmentType as DateSegmentTypeInternal,\n} from \"./createDateFieldState\";\n\nexport type TimeValue = Time | CalendarDateTime | ZonedDateTime;\n\n/**\n * TimeField reuses the DateField segment vocabulary (RAC TimeField reuses\n * `DateInput`/`DateSegment`); the legacy `TimeSegment`/`TimeSegmentType` names\n * are kept as aliases of the shared date-segment types.\n */\nexport type TimeSegmentType = DateSegmentTypeInternal;\nexport type TimeSegment = DateSegmentInternal;\n\nexport interface TimeFieldStateProps<T extends TimeValue = Time> {\n /** The current value (controlled). */\n value?: MaybeAccessor<T | null>;\n /** The default value (uncontrolled). */\n defaultValue?: T | null;\n /** Handler called when the value changes. */\n onChange?: (value: T | null) => void;\n /** The minimum allowed time. */\n minValue?: MaybeAccessor<TimeValue | undefined>;\n /** The maximum allowed time. */\n maxValue?: MaybeAccessor<TimeValue | undefined>;\n /** Whether the field is disabled. */\n isDisabled?: MaybeAccessor<boolean>;\n /** Whether the field is read-only. */\n isReadOnly?: MaybeAccessor<boolean>;\n /** Whether the field is required. */\n isRequired?: MaybeAccessor<boolean>;\n /** Whether the value is invalid (controlled). */\n isInvalid?: boolean;\n /** The locale to use for formatting. */\n locale?: string;\n /** The granularity (hour, minute, second). */\n granularity?: \"hour\" | \"minute\" | \"second\";\n /** Whether to show 12 or 24 hour format. */\n hourCycle?: 12 | 24;\n /** Whether to hide the time zone. */\n hideTimeZone?: boolean;\n /** Whether to force leading zeroes in the hour segment. */\n shouldForceLeadingZeros?: boolean;\n /** Validation state. */\n validationState?: MaybeAccessor<ValidationState | undefined>;\n /** Validation behavior mode. */\n validationBehavior?: ValidationBehavior;\n /** Custom validation function. */\n validate?: ValidationFunction<T | null>;\n /** Description text. */\n description?: string;\n /** Error message. */\n errorMessage?: string;\n /** The placeholder value. */\n placeholderValue?: T;\n /** Whether dates outside the min/max range are unavailable. Added for API consistency. */\n isDateUnavailable?: (date: DateValue) => boolean;\n}\n\n/**\n * The TimeField state IS the certified DateField state (segments, validation,\n * increment/decrement, formatter, etc.) with a `timeValue` accessor added. The\n * `T` generic is retained for API back-compat with existing `TimeFieldState<T>`\n * consumers.\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport interface TimeFieldState<T extends TimeValue = Time> extends DateFieldState {\n /** The current value in the `Time`/`CalendarDateTime`/`ZonedDateTime` domain. */\n timeValue: Accessor<TimeValue | null>;\n}\n\n/**\n * Anchors a `Time` onto a date so the date-field machine can edit it. Values\n * that already carry a date (`CalendarDateTime`/`ZonedDateTime`) pass through.\n * Mirrors `@react-stately/datepicker`'s `convertValue`.\n */\nfunction convertValue(\n value: TimeValue | null | undefined,\n date: DateValue = today(getLocalTimeZone()),\n): CalendarDateTime | ZonedDateTime | null {\n if (!value) {\n return null;\n }\n if (\"day\" in value) {\n return value as CalendarDateTime | ZonedDateTime;\n }\n return toCalendarDateTime(date as CalendarDate | CalendarDateTime | ZonedDateTime, value as Time);\n}\n\n/**\n * Provides state management for a time field component.\n */\nexport function createTimeFieldState<T extends TimeValue = Time>(\n props: TimeFieldStateProps<T> = {},\n): TimeFieldState<T> {\n const placeholderValue: TimeValue = props.placeholderValue ?? new Time();\n\n // Controlled/uncontrolled Time value (mirrors useControlledState).\n const [internalValue, setInternalValue] = createSignal<T | null>(props.defaultValue ?? null);\n const value = (): T | null => {\n const controlled = access(props.value);\n return controlled !== undefined ? controlled : internalValue();\n };\n\n const defaultValueTimeZone =\n props.defaultValue && \"timeZone\" in props.defaultValue\n ? (props.defaultValue as ZonedDateTime).timeZone\n : undefined;\n\n const v = (): TimeValue => value() || placeholderValue;\n const day = (): DateValue | undefined => {\n const current = v();\n return current && \"day\" in current ? (current as CalendarDateTime | ZonedDateTime) : undefined;\n };\n\n const placeholderDate = createMemo<CalendarDateTime | ZonedDateTime | null>(() => {\n const current = v();\n const valueTimeZone =\n current && \"timeZone\" in current ? (current as ZonedDateTime).timeZone : undefined;\n const zone = valueTimeZone || defaultValueTimeZone;\n if (zone && placeholderValue) {\n return toZoned(convertValue(placeholderValue) as CalendarDateTime, zone);\n }\n return convertValue(placeholderValue);\n });\n\n const minDate = createMemo(() => convertValue(access(props.minValue), day()) ?? undefined);\n const maxDate = createMemo(() => convertValue(access(props.maxValue), day()) ?? undefined);\n\n const timeValue = createMemo<TimeValue | null>(() => {\n const current = value();\n return current && \"day\" in current\n ? toTime(current as CalendarDateTime | ZonedDateTime)\n : current;\n });\n const dateTime = createMemo<DateValue | null>(() => {\n const current = value();\n return current == null ? null : convertValue(current);\n });\n const defaultDateTime = props.defaultValue == null ? null : convertValue(props.defaultValue);\n\n // Route the inner date-field onChange back into the Time domain, mirroring\n // upstream: keep the CalendarDateTime when the value carries a date/zone,\n // otherwise collapse to a plain Time.\n const onChange = (newValue: DateValue | null): void => {\n const converted = (\n day() || defaultValueTimeZone\n ? newValue\n : newValue && toTime(newValue as CalendarDateTime | ZonedDateTime)\n ) as T | null;\n if (access(props.value) === undefined) {\n setInternalValue(() => converted);\n }\n props.onChange?.(converted);\n };\n\n const dateState = createDateFieldState({\n get value() {\n return dateTime();\n },\n defaultValue: defaultDateTime,\n onChange,\n get minValue() {\n return minDate();\n },\n get maxValue() {\n return maxDate();\n },\n get isDisabled() {\n return access(props.isDisabled);\n },\n get isReadOnly() {\n return access(props.isReadOnly);\n },\n get isRequired() {\n return access(props.isRequired);\n },\n get isInvalid() {\n return props.isInvalid;\n },\n get locale() {\n return props.locale;\n },\n get granularity() {\n return props.granularity || \"minute\";\n },\n maxGranularity: \"hour\",\n get hourCycle() {\n return props.hourCycle;\n },\n get hideTimeZone() {\n return props.hideTimeZone;\n },\n get placeholderValue() {\n return placeholderDate() ?? undefined;\n },\n get shouldForceLeadingZeros() {\n return props.shouldForceLeadingZeros;\n },\n createCalendar: () => new GregorianCalendar(),\n get validationState() {\n return access(props.validationState);\n },\n get validationBehavior() {\n return props.validationBehavior;\n },\n validate: props.validate ? () => props.validate?.(value()) : undefined,\n get description() {\n return props.description;\n },\n get errorMessage() {\n return props.errorMessage;\n },\n get isDateUnavailable() {\n return props.isDateUnavailable;\n },\n });\n\n // Add `timeValue` without spreading (spread would freeze DateFieldState's\n // getter members). The same proxy identity is threaded to createTimeField and\n // the field/segment contexts so `hookData` WeakMap keying stays consistent.\n return new Proxy(dateState, {\n get(target, prop, receiver) {\n if (prop === \"timeValue\") {\n return timeValue;\n }\n return Reflect.get(target, prop, receiver);\n },\n has(target, prop) {\n return prop === \"timeValue\" || Reflect.has(target, prop);\n },\n }) as unknown as TimeFieldState<T>;\n}\n","/**\n * DatePickerState for Solid-Stately\n *\n * Provides unified state management for DatePicker components.\n * Based on @react-stately/datepicker useDatePickerState\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport {\n type DateValue,\n type CalendarDateTime,\n Time,\n DateFormatter,\n toCalendarDate,\n toCalendarDateTime,\n toZoned,\n getLocalTimeZone,\n} from \"@internationalized/date\";\nimport { access, type MaybeAccessor } from \"../utils\";\nimport type { ValidationState } from \"./createCalendarState\";\nimport type { TimeValue } from \"./createTimeFieldState\";\n\nexport type Granularity = \"day\" | \"hour\" | \"minute\" | \"second\";\n\nexport type DatePickerStateProps<T extends DateValue = DateValue> = DatePickerStateOptions<T>;\n\nexport interface DatePickerStateOptions<T extends DateValue = DateValue> {\n value?: MaybeAccessor<T | null>;\n defaultValue?: T | null;\n onChange?: (value: T | null) => void;\n minValue?: MaybeAccessor<DateValue | undefined>;\n maxValue?: MaybeAccessor<DateValue | undefined>;\n isDisabled?: MaybeAccessor<boolean>;\n isReadOnly?: MaybeAccessor<boolean>;\n isRequired?: MaybeAccessor<boolean>;\n granularity?: Granularity;\n hourCycle?: 12 | 24;\n hideTimeZone?: boolean;\n placeholderValue?: DateValue;\n shouldCloseOnSelect?: boolean | (() => boolean);\n defaultOpen?: boolean;\n isOpen?: MaybeAccessor<boolean | undefined>;\n onOpenChange?: (isOpen: boolean) => void;\n isDateUnavailable?: (date: DateValue) => boolean;\n validationState?: MaybeAccessor<ValidationState | undefined>;\n}\n\nexport interface DatePickerState<T extends DateValue = DateValue> {\n value: Accessor<T | null>;\n defaultValue: T | null;\n setValue: (value: T | null) => void;\n dateValue: Accessor<DateValue | null>;\n setDateValue: (value: DateValue) => void;\n timeValue: Accessor<TimeValue | null>;\n setTimeValue: (value: TimeValue) => void;\n granularity: Granularity;\n hasTime: boolean;\n isOpen: Accessor<boolean>;\n open: () => void;\n close: () => void;\n setOpen: (isOpen: boolean) => void;\n isInvalid: Accessor<boolean>;\n validationState: Accessor<ValidationState | undefined>;\n builtinValidation: Accessor<{ isInvalid: boolean }>;\n showEra: Accessor<boolean>;\n formatValue: (locale: string, fieldOptions?: Intl.DateTimeFormatOptions) => string;\n getDateFormatter: (locale: string, formatOptions?: Intl.DateTimeFormatOptions) => DateFormatter;\n}\n\n/**\n * Provides unified state management for a DatePicker component.\n */\nexport function createDatePickerState<T extends DateValue = DateValue>(\n props: DatePickerStateOptions<T> = {},\n): DatePickerState<T> {\n const timeZone = getLocalTimeZone();\n\n // Internal signals for value and overlay state\n const [internalValue, setInternalValue] = createSignal<T | null>(props.defaultValue ?? null);\n const [internalOpen, setInternalOpen] = createSignal(props.defaultOpen ?? false);\n\n // Transient selections for date and time\n const [selectedDate, setSelectedDate] = createSignal<DateValue | null>(null);\n const [selectedTime, setSelectedTime] = createSignal<TimeValue | null>(null);\n\n // Controlled vs uncontrolled value\n const value = createMemo<T | null>(() => {\n const controlled = access(props.value);\n return controlled !== undefined ? controlled : internalValue();\n });\n\n // Granularity: auto-detect from value type if not provided\n const granularity = createMemo<Granularity>(() => {\n if (props.granularity) return props.granularity;\n const v = value();\n if (v && \"hour\" in v) {\n if (\"second\" in v) return \"second\";\n return \"minute\";\n }\n return \"day\";\n });\n\n const hasTime = createMemo(() => {\n const g = granularity();\n return g === \"hour\" || g === \"minute\" || g === \"second\";\n });\n\n // Derived states\n const isDisabled = createMemo(() => access(props.isDisabled) ?? false);\n const isReadOnly = createMemo(() => access(props.isReadOnly) ?? false);\n const validationState = createMemo(() => access(props.validationState));\n const isOpen: Accessor<boolean> = () => access(props.isOpen) ?? internalOpen();\n\n // Date and time portions of the current value\n const dateValue = createMemo<DateValue | null>(() => {\n const v = value();\n if (!v) return null;\n return toCalendarDate(v);\n });\n\n const timeValue = createMemo<TimeValue | null>(() => {\n const v = value();\n if (!v || !(\"hour\" in v)) return null;\n return v as unknown as TimeValue;\n });\n\n // Helper to resolve placeholder time (midnight fallback)\n const getPlaceholderTime = (): TimeValue => {\n const placeholder = props.placeholderValue;\n if (placeholder && \"hour\" in placeholder) {\n return placeholder as TimeValue;\n }\n return new Time(0, 0, 0);\n };\n\n // Commit combined date + time value\n const commitValue = (date: DateValue, time: TimeValue | null) => {\n if (isDisabled() || isReadOnly()) return;\n\n let combined: DateValue;\n if (time && hasTime()) {\n combined = toCalendarDateTime(date, time);\n } else {\n combined = date;\n }\n\n // Preserve ZonedDateTime timezone if the current committed value has one\n const current = value();\n if (current && \"timeZone\" in current && !(\"timeZone\" in combined)) {\n combined = toZoned(combined as CalendarDateTime, current.timeZone);\n }\n\n // Clear transient states\n setSelectedDate(null);\n setSelectedTime(null);\n\n // Update internal state if uncontrolled\n const controlled = access(props.value);\n if (controlled === undefined) {\n setInternalValue(() => combined as T);\n }\n\n if (props.onChange) {\n props.onChange(combined as T);\n }\n };\n\n // Set the full value directly\n const setValue = (newValue: T | null) => {\n if (isDisabled() || isReadOnly()) return;\n\n const controlled = access(props.value);\n if (controlled === undefined) {\n setInternalValue(() => newValue);\n }\n\n if (props.onChange) {\n props.onChange(newValue);\n }\n\n // Clear transient states\n setSelectedDate(null);\n setSelectedTime(null);\n };\n\n // Select a date (may commit if time is already selected or shouldCloseOnSelect)\n const setDateValue = (date: DateValue) => {\n if (isDisabled() || isReadOnly()) return;\n\n const currentTime = selectedTime();\n const currentValue = value();\n const shouldClose =\n typeof props.shouldCloseOnSelect === \"function\"\n ? props.shouldCloseOnSelect()\n : (props.shouldCloseOnSelect ?? true);\n\n if (hasTime() && (currentTime || shouldClose)) {\n // Preserve existing time from committed value if user hasn't explicitly selected a new time\n const existingTime =\n currentTime ??\n (currentValue && \"hour\" in currentValue ? (currentValue as unknown as TimeValue) : null);\n const timePart = existingTime ?? getPlaceholderTime();\n commitValue(date, timePart);\n\n if (shouldClose) {\n setOpen(false);\n }\n } else if (hasTime()) {\n // Store date transiently, waiting for time selection\n setSelectedDate(date);\n } else {\n // No time needed, commit immediately\n commitValue(date, null);\n\n if (shouldClose) {\n setOpen(false);\n }\n }\n };\n\n // Select a time (may commit if date is already selected)\n const setTimeValue = (time: TimeValue) => {\n if (isDisabled() || isReadOnly()) return;\n\n const currentDate = selectedDate();\n const currentValue = value();\n\n if (currentDate) {\n // We have a transient date, commit combined\n commitValue(currentDate, time);\n } else if (currentValue && hasTime()) {\n // We have an existing value with time, update the time portion\n const datePart = toCalendarDate(currentValue);\n commitValue(datePart, time);\n } else {\n // Store time transiently, waiting for date selection\n setSelectedTime(time);\n }\n };\n\n // Open / close helpers\n const open = () => setOpen(true);\n const close = () => setOpen(false);\n\n const setOpen = (openValue: boolean) => {\n if (openValue) {\n if (access(props.isOpen) === undefined) {\n setInternalOpen(true);\n }\n props.onOpenChange?.(true);\n } else {\n // When closing, only commit if both date and time are available (when time is required).\n // Don't auto-commit partial selections with placeholder time to avoid phantom values.\n const currentValue = value();\n const currentDate = selectedDate();\n const currentTime = selectedTime();\n\n if (!currentValue && currentDate && hasTime() && currentTime) {\n // Both date and time explicitly selected — safe to commit\n commitValue(currentDate, currentTime);\n }\n\n // Clear any remaining transient state\n setSelectedDate(null);\n setSelectedTime(null);\n if (access(props.isOpen) === undefined) {\n setInternalOpen(false);\n }\n props.onOpenChange?.(false);\n }\n };\n\n // Builtin validation against minValue, maxValue, and isDateUnavailable\n const builtinValidation = createMemo(() => {\n const v = value();\n if (!v) return { isInvalid: false };\n\n const minValue = access(props.minValue);\n const maxValue = access(props.maxValue);\n\n if (minValue && v.compare(minValue) < 0) return { isInvalid: true };\n if (maxValue && v.compare(maxValue) > 0) return { isInvalid: true };\n if (props.isDateUnavailable?.(v)) return { isInvalid: true };\n\n return { isInvalid: false };\n });\n\n const isInvalid = createMemo(() => {\n return builtinValidation().isInvalid || validationState() === \"invalid\";\n });\n\n // Show era for BC dates\n const showEra = createMemo(() => {\n const v = value();\n return v ? v.year < 1 : false;\n });\n\n // Format the current value using DateFormatter with era support for BC dates\n const formatValue = (locale: string, fieldOptions?: Intl.DateTimeFormatOptions): string => {\n const v = value();\n if (!v) return \"\";\n\n const options: Intl.DateTimeFormatOptions = { ...fieldOptions };\n\n // Add era for BC dates\n if (v.year < 1) {\n options.era = \"short\";\n }\n\n const formatter = new DateFormatter(locale, options);\n return formatter.format(v.toDate(timeZone));\n };\n\n // Get a DateFormatter instance\n const getDateFormatter = (\n locale: string,\n formatOptions?: Intl.DateTimeFormatOptions,\n ): DateFormatter => {\n return new DateFormatter(locale, formatOptions);\n };\n\n return {\n value,\n defaultValue: props.defaultValue ?? null,\n setValue,\n dateValue,\n setDateValue,\n timeValue,\n setTimeValue,\n get granularity() {\n return granularity();\n },\n get hasTime() {\n return hasTime();\n },\n isOpen,\n open,\n close,\n setOpen,\n isInvalid,\n validationState,\n builtinValidation,\n showEra,\n formatValue,\n getDateFormatter,\n };\n}\n","/**\n * State management for select components.\n * Based on @react-stately/select useSelectState.\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils\";\nimport { createListState } from \"../collections/createListState\";\nimport { createOverlayTriggerState } from \"../overlays\";\nimport type { Key, CollectionNode, Collection } from \"../collections/types\";\nimport type { SelectionMode, Selection } from \"../collections/types\";\nimport type { SelectionManager } from \"../selection/SelectionManager\";\n\nexport interface SelectStateProps<T = unknown> {\n /** The items to display in the select. */\n items: T[];\n /** Function to get the key for an item. */\n getKey?: (item: T) => Key;\n /** Function to get the text value for an item. */\n getTextValue?: (item: T) => string;\n /** Function to check if an item is disabled. */\n getDisabled?: (item: T) => boolean;\n /** Keys of disabled items. */\n disabledKeys?: Iterable<Key>;\n /** The currently selected key (controlled). */\n selectedKey?: Key | null;\n /** The default selected key (uncontrolled). */\n defaultSelectedKey?: Key | null;\n /** The selected keys (controlled, for multiple selection mode). */\n selectedKeys?: \"all\" | Iterable<Key>;\n /** Default selected keys (uncontrolled, for multiple selection mode). */\n defaultSelectedKeys?: \"all\" | Iterable<Key>;\n /** Handler called when the selection changes. */\n onSelectionChange?: (key: Key | null) => void;\n /** Handler called when selected keys change. */\n onSelectionChangeKeys?: (keys: Selection) => void;\n /** Selection mode for the select. */\n selectionMode?: Extract<SelectionMode, \"single\" | \"multiple\">;\n /** Whether the select is open (controlled). */\n isOpen?: boolean;\n /** Whether the select is open by default (uncontrolled). */\n defaultOpen?: boolean;\n /** Handler called when the open state changes. */\n onOpenChange?: (isOpen: boolean) => void;\n /** Whether the select is disabled. */\n isDisabled?: boolean;\n /** Whether the select is required. */\n isRequired?: boolean;\n}\n\nexport interface SelectState<T = unknown> {\n /** The collection of items. */\n readonly collection: Accessor<Collection<T>>;\n /**\n * The collection-aware selection manager. Mirrors upstream `useSelectState`,\n * which spreads the underlying `useListState` (including its selection manager).\n */\n readonly selectionManager: SelectionManager<T>;\n /** Whether the select dropdown is open. */\n readonly isOpen: Accessor<boolean>;\n /** Open the select dropdown. */\n open(): void;\n /** Close the select dropdown. */\n close(): void;\n /** Toggle the select dropdown. */\n toggle(): void;\n /** The currently selected key. */\n readonly selectedKey: Accessor<Key | null>;\n /** The selected keys. */\n readonly selectedKeys: Accessor<Selection>;\n /** The currently selected item. */\n readonly selectedItem: Accessor<CollectionNode<T> | null>;\n /** The currently selected items. */\n readonly selectedItems: Accessor<CollectionNode<T>[]>;\n /** Set the selected key. */\n setSelectedKey(key: Key | null): void;\n /** Set selected keys. */\n setSelectedKeys(keys: Iterable<Key>): void;\n /** The currently focused key. */\n readonly focusedKey: Accessor<Key | null>;\n /** Set the focused key. */\n setFocusedKey(key: Key | null): void;\n /** Whether the select has focus. */\n readonly isFocused: Accessor<boolean>;\n /** Set whether the select has focus. */\n setFocused(isFocused: boolean): void;\n /** Whether a specific key is disabled. */\n isKeyDisabled(key: Key): boolean;\n /** Whether the select is disabled. */\n readonly isDisabled: boolean;\n /** Whether the select is required. */\n readonly isRequired: boolean;\n /** The selection mode. */\n readonly selectionMode: Accessor<\"single\" | \"multiple\">;\n}\n\n/**\n * Creates state for a select component.\n * Combines list state with overlay trigger state for dropdown behavior.\n */\nexport function createSelectState<T = unknown>(\n props: MaybeAccessor<SelectStateProps<T>>,\n): SelectState<T> {\n const getProps = () => access(props);\n const selectionMode: Accessor<\"single\" | \"multiple\"> = () => getProps().selectionMode ?? \"single\";\n\n // Overlay trigger state for open/close\n const overlayState = createOverlayTriggerState({\n get isOpen() {\n return getProps().isOpen;\n },\n get defaultOpen() {\n return getProps().defaultOpen;\n },\n get onOpenChange() {\n return getProps().onOpenChange;\n },\n });\n\n // Track selected key\n const isControlledSingle = () => getProps().selectedKey !== undefined;\n const isControlledMultiple = () => getProps().selectedKeys !== undefined;\n const [internalSelectedKey, setInternalSelectedKey] = createSignal<Key | null>(\n getProps().defaultSelectedKey ?? null,\n );\n const [internalSelectedKeys, setInternalSelectedKeys] = createSignal<Selection>(\n getProps().defaultSelectedKeys === \"all\"\n ? \"all\"\n : new Set(getProps().defaultSelectedKeys ?? []),\n );\n\n const selectedKey: Accessor<Key | null> = () => {\n if (selectionMode() === \"multiple\") {\n const keys = selectedKeys();\n if (keys === \"all\") return null;\n return keys.size > 0 ? Array.from(keys)[0] : null;\n }\n\n return isControlledSingle() ? (getProps().selectedKey ?? null) : internalSelectedKey();\n };\n\n const setSelectedKey = (key: Key | null) => {\n if (selectionMode() === \"multiple\") {\n if (key == null) {\n if (!isControlledMultiple()) {\n setInternalSelectedKeys(new Set<Key>());\n }\n getProps().onSelectionChangeKeys?.(new Set<Key>());\n getProps().onSelectionChange?.(null);\n } else {\n const next = new Set([key]);\n if (!isControlledMultiple()) {\n setInternalSelectedKeys(next);\n }\n getProps().onSelectionChangeKeys?.(next);\n getProps().onSelectionChange?.(key);\n }\n return;\n }\n\n if (!isControlledSingle()) {\n setInternalSelectedKey(key);\n }\n getProps().onSelectionChange?.(key);\n getProps().onSelectionChangeKeys?.(key != null ? new Set([key]) : new Set<Key>());\n };\n\n const selectedKeys: Accessor<Selection> = createMemo(() => {\n if (selectionMode() === \"multiple\") {\n if (isControlledMultiple()) {\n const keys = getProps().selectedKeys;\n return keys === \"all\" ? \"all\" : new Set<Key>(keys ?? []);\n }\n return internalSelectedKeys();\n }\n\n const key = selectedKey();\n return key != null ? new Set<Key>([key]) : new Set<Key>();\n });\n\n const setSelectedKeys = (keys: Iterable<Key>) => {\n const next = new Set(keys);\n if (selectionMode() === \"multiple\") {\n if (!isControlledMultiple()) {\n setInternalSelectedKeys(next);\n }\n getProps().onSelectionChangeKeys?.(next);\n getProps().onSelectionChange?.(next.size > 0 ? Array.from(next)[0] : null);\n return;\n }\n\n const key = next.size > 0 ? Array.from(next)[0] : null;\n setSelectedKey(key);\n };\n\n // Create list state with select selection mode\n const listState = createListState<T>({\n get items() {\n return getProps().items;\n },\n get getKey() {\n return getProps().getKey;\n },\n get getTextValue() {\n return getProps().getTextValue;\n },\n get getDisabled() {\n return getProps().getDisabled;\n },\n get disabledKeys() {\n return getProps().disabledKeys;\n },\n get selectionMode() {\n return selectionMode();\n },\n disallowEmptySelection: true,\n get selectedKeys() {\n const keys = selectedKeys();\n if (keys === \"all\") return \"all\";\n return keys;\n },\n onSelectionChange(keys) {\n if (selectionMode() === \"multiple\") {\n if (!isControlledMultiple()) {\n setInternalSelectedKeys(keys);\n }\n getProps().onSelectionChangeKeys?.(keys);\n if (keys !== \"all\") {\n getProps().onSelectionChange?.(keys.size > 0 ? Array.from(keys)[0] : null);\n }\n return;\n }\n\n // Get the first (and only) selected key\n if (keys === \"all\") return;\n const key = keys.size > 0 ? Array.from(keys)[0] : null;\n setSelectedKey(key);\n // Close the dropdown after selection in single mode\n overlayState.close();\n },\n });\n\n // The select's own focus state (the trigger), separate from the collection's\n // focus-within state on the selection manager — upstream useSelectState keeps\n // these apart with a dedicated useState. Sharing the manager's signal makes\n // trigger focus re-arm the item roving-focus effect and steal focus back.\n const [isFocused, setFocused] = createSignal(false);\n\n // Get the selected item from the collection (memoized)\n const selectedItem: Accessor<CollectionNode<T> | null> = createMemo(() => {\n const key = selectedKey();\n if (key == null) return null;\n return listState.collection().getItem(key);\n });\n\n const selectedItems: Accessor<CollectionNode<T>[]> = createMemo(() => {\n const keys = selectedKeys();\n if (keys === \"all\") {\n return Array.from(listState.collection());\n }\n\n const items: CollectionNode<T>[] = [];\n for (const key of keys) {\n const item = listState.collection().getItem(key);\n if (item) items.push(item);\n }\n return items;\n });\n\n return {\n // Collection\n collection: listState.collection,\n selectionManager: listState.selectionManager,\n\n // Focus management\n focusedKey: listState.focusedKey,\n setFocusedKey: listState.setFocusedKey,\n isFocused,\n setFocused,\n\n // Overlay state\n isOpen: overlayState.isOpen,\n open: overlayState.open,\n close: overlayState.close,\n toggle: overlayState.toggle,\n\n // Select-specific\n selectionMode,\n selectedKey,\n selectedKeys,\n selectedItem,\n selectedItems,\n setSelectedKey,\n setSelectedKeys,\n isKeyDisabled: (key: Key) => listState.isDisabled(key),\n get isDisabled() {\n return getProps().isDisabled ?? false;\n },\n get isRequired() {\n return getProps().isRequired ?? false;\n },\n };\n}\n","/**\n * State management for ComboBox components.\n * Based on @react-stately/combobox useComboBoxState.\n *\n * ComboBox combines a text input with a dropdown list, allowing users to\n * either type to filter options or select from a list.\n */\n\nimport { createSignal, createMemo, createEffect, type Accessor } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils\";\nimport { createListState } from \"../collections/createListState\";\nimport { createOverlayTriggerState } from \"../overlays\";\nimport type { Key, CollectionNode, Collection, FocusStrategy } from \"../collections/types\";\nimport type { SelectionManager } from \"../selection/SelectionManager\";\n\nexport type MenuTriggerAction = \"focus\" | \"input\" | \"manual\";\n\nexport type { FocusStrategy } from \"../collections/types\";\n\nexport type FilterFn = (textValue: string, inputValue: string) => boolean;\n\nexport interface ComboBoxStateProps<T = unknown> {\n /** The items to display in the combobox dropdown. */\n items?: T[];\n /** Default items when uncontrolled. */\n defaultItems?: T[];\n /** Function to get the key for an item. */\n getKey?: (item: T) => Key;\n /** Function to get the text value for an item. */\n getTextValue?: (item: T) => string;\n /** Function to check if an item is disabled. */\n getDisabled?: (item: T) => boolean;\n /** Keys of disabled items. */\n disabledKeys?: Iterable<Key>;\n /** The selection mode for the combobox. */\n selectionMode?: \"single\" | \"multiple\";\n /** The currently selected key (controlled, single mode). */\n selectedKey?: Key | null;\n /** The default selected key (uncontrolled, single mode). */\n defaultSelectedKey?: Key | null;\n /** The currently selected keys (controlled, multiple mode). */\n selectedKeys?: Iterable<Key>;\n /** The default selected keys (uncontrolled, multiple mode). */\n defaultSelectedKeys?: Iterable<Key>;\n /** Handler called when the selection changes (single mode). */\n onSelectionChange?: (key: Key | null) => void;\n /** Handler called when the selection changes (multiple mode). */\n onSelectionChangeMultiple?: (keys: Set<Key>) => void;\n /** The current input value (controlled). */\n inputValue?: string;\n /** The default input value (uncontrolled). */\n defaultInputValue?: string;\n /** Handler called when the input value changes. */\n onInputChange?: (value: string) => void;\n /** Whether the combobox is open (controlled). */\n isOpen?: boolean;\n /** Whether the combobox is open by default (uncontrolled). */\n defaultOpen?: boolean;\n /** Handler called when the open state changes. */\n onOpenChange?: (isOpen: boolean, trigger?: MenuTriggerAction) => void;\n /** Whether the combobox is disabled. */\n isDisabled?: boolean;\n /** Whether the combobox is read-only. */\n isReadOnly?: boolean;\n /** Whether the combobox is required. */\n isRequired?: boolean;\n /** The filter function to use when filtering items. */\n defaultFilter?: FilterFn;\n /** Whether to allow the menu to open when there are no items. */\n allowsEmptyCollection?: boolean;\n /** Whether to allow custom values that don't match any option. */\n allowsCustomValue?: boolean;\n /** What triggers the menu to open. */\n menuTrigger?: MenuTriggerAction;\n /** Whether to close the menu on blur. */\n shouldCloseOnBlur?: boolean;\n}\n\nexport interface ComboBoxState<T = unknown> {\n /** The collection of items (may be filtered). */\n readonly collection: Accessor<Collection<T>>;\n /**\n * The collection-aware selection manager. Mirrors upstream `useComboBoxState`,\n * which returns the `useListState` selection manager bound to the unfiltered\n * collection (selection spans all items; filtering is display-only).\n */\n readonly selectionManager: SelectionManager<T>;\n /** Whether the combobox dropdown is open. */\n readonly isOpen: Accessor<boolean>;\n /** Open the combobox dropdown. */\n open(focusStrategy?: FocusStrategy | null, trigger?: MenuTriggerAction): void;\n /** Close the combobox dropdown. */\n close(): void;\n /** Toggle the combobox dropdown. */\n toggle(focusStrategy?: FocusStrategy | null, trigger?: MenuTriggerAction): void;\n /** The currently selected key (single mode). */\n readonly selectedKey: Accessor<Key | null>;\n /** The default selected key. */\n readonly defaultSelectedKey: Key | null;\n /** The currently selected item (single mode). */\n readonly selectedItem: Accessor<CollectionNode<T> | null>;\n /** Set the selected key. */\n setSelectedKey(key: Key | null): void;\n /** The currently selected keys (multiple mode). */\n readonly selectedKeys: Accessor<Set<Key>>;\n /** The currently selected items (multiple mode). */\n readonly selectedItems: Accessor<CollectionNode<T>[]>;\n /** Remove a selected key (multiple mode). */\n removeSelectedKey(key: Key): void;\n /** The current input value. */\n readonly inputValue: Accessor<string>;\n /** The default input value. */\n readonly defaultInputValue: string;\n /** Set the input value. */\n setInputValue(value: string): void;\n /** The currently focused key in the list. */\n readonly focusedKey: Accessor<Key | null>;\n /** Set the focused key. */\n setFocusedKey(key: Key | null): void;\n /** Whether the combobox input has focus. */\n readonly isFocused: Accessor<boolean>;\n /** Set whether the combobox has focus. */\n setFocused(isFocused: boolean): void;\n /** The focus strategy to use when opening. */\n readonly focusStrategy: Accessor<FocusStrategy | null>;\n /** Commit the current selection (select focused item or custom value). */\n commit(): void;\n /** Revert input to the selected item's text and close menu. */\n revert(): void;\n /** Whether a specific key is disabled. */\n isKeyDisabled(key: Key): boolean;\n /** Select a key and close the menu (for ListState compatibility). */\n select(key: Key): void;\n /** The selection mode. */\n readonly selectionMode: Accessor<\"single\" | \"multiple\">;\n /** Check if a key is selected. */\n isSelected(key: Key): boolean;\n /** Whether the combobox is disabled. */\n readonly isDisabled: boolean;\n /** Whether the combobox is read-only. */\n readonly isReadOnly: boolean;\n /** Whether the combobox is required. */\n readonly isRequired: boolean;\n}\n\n/**\n * Default filter function that does case-insensitive \"contains\" matching.\n */\nexport const defaultContainsFilter: FilterFn = (textValue, inputValue) => {\n return textValue.toLowerCase().includes(inputValue.toLowerCase());\n};\n\n/**\n * Creates state for a combobox component.\n * Combines list state with input value management and filtering.\n */\nexport function createComboBoxState<T = unknown>(\n props: MaybeAccessor<ComboBoxStateProps<T>>,\n): ComboBoxState<T> {\n const getProps = () => access(props);\n\n // Extract options with defaults\n const menuTrigger = () => getProps().menuTrigger ?? \"input\";\n const allowsEmptyCollection = () => getProps().allowsEmptyCollection ?? false;\n const allowsCustomValue = () => getProps().allowsCustomValue ?? false;\n const shouldCloseOnBlur = () => getProps().shouldCloseOnBlur ?? true;\n const isMultiple = () => getProps().selectionMode === \"multiple\";\n\n // Track focus strategy for list navigation\n const [focusStrategy, setFocusStrategy] = createSignal<FocusStrategy | null>(null);\n\n // Track whether we're showing all items (vs filtered)\n const [showAllItems, setShowAllItems] = createSignal(false);\n\n // Track the menu open trigger\n let menuOpenTrigger: MenuTriggerAction = \"focus\";\n\n // ---- Multi-select State ----\n const isMultiSelectionControlled = () => getProps().selectedKeys !== undefined;\n const [internalSelectedKeys, setInternalSelectedKeys] = createSignal<Set<Key>>(\n new Set(getProps().defaultSelectedKeys ?? []),\n );\n\n const selectedKeys: Accessor<Set<Key>> = () => {\n return isMultiSelectionControlled()\n ? new Set(getProps().selectedKeys ?? [])\n : internalSelectedKeys();\n };\n\n const setSelectedKeys = (keys: Set<Key>) => {\n if (!isMultiSelectionControlled()) {\n setInternalSelectedKeys(new Set(keys));\n }\n getProps().onSelectionChangeMultiple?.(keys);\n };\n\n // ---- Selection State (single mode) ----\n // Note: Selection state is initialized first because input value may depend on it\n const isSelectionControlled = () => getProps().selectedKey !== undefined;\n const [internalSelectedKey, setInternalSelectedKey] = createSignal<Key | null>(\n getProps().defaultSelectedKey ?? null,\n );\n\n // ---- Input Value State ----\n // Initialized after selection so we can derive from selected item if needed\n const isInputControlled = () => getProps().inputValue !== undefined;\n\n // We'll set the proper initial value after collection is created\n const [internalInputValue, setInternalInputValue] = createSignal(\n getProps().defaultInputValue ?? \"\",\n );\n // Track if we've initialized input from selection\n let inputInitialized = false;\n\n const inputValue: Accessor<string> = () => {\n return isInputControlled() ? (getProps().inputValue ?? \"\") : internalInputValue();\n };\n\n const setInputValue = (value: string) => {\n if (!isInputControlled()) {\n setInternalInputValue(value);\n }\n getProps().onInputChange?.(value);\n };\n\n // Track last committed input value\n const [lastValue, setLastValue] = createSignal(inputValue());\n\n const selectedKey: Accessor<Key | null> = () => {\n return isSelectionControlled() ? (getProps().selectedKey ?? null) : internalSelectedKey();\n };\n\n const setSelectedKey = (key: Key | null) => {\n if (!isSelectionControlled()) {\n setInternalSelectedKey(key);\n }\n getProps().onSelectionChange?.(key);\n };\n\n // ---- Overlay State ----\n const overlayState = createOverlayTriggerState({\n get isOpen() {\n return getProps().isOpen;\n },\n get defaultOpen() {\n return getProps().defaultOpen;\n },\n onOpenChange(isOpen: boolean) {\n getProps().onOpenChange?.(isOpen, isOpen ? menuOpenTrigger : undefined);\n },\n });\n\n // ---- List State (unfiltered collection) ----\n const listState = createListState<T>({\n get items() {\n // Use items or defaultItems\n return getProps().items ?? getProps().defaultItems ?? [];\n },\n get getKey() {\n return getProps().getKey;\n },\n get getTextValue() {\n return getProps().getTextValue;\n },\n get getDisabled() {\n return getProps().getDisabled;\n },\n get disabledKeys() {\n return getProps().disabledKeys;\n },\n get selectionMode() {\n return isMultiple() ? (\"multiple\" as const) : (\"single\" as const);\n },\n disallowEmptySelection: false,\n get selectedKeys() {\n if (isMultiple()) {\n return Array.from(selectedKeys());\n }\n const key = selectedKey();\n return key != null ? [key] : [];\n },\n onSelectionChange(keys) {\n if (keys === \"all\") return;\n\n if (isMultiple()) {\n // In multiple mode, toggle selections\n const newKeys = new Set(keys);\n setSelectedKeys(newKeys);\n return;\n }\n\n const key = keys.size > 0 ? Array.from(keys)[0] : null;\n\n // If same key selected, just reset input and close\n if (key === selectedKey()) {\n resetInputValue();\n closeMenu();\n return;\n }\n\n setSelectedKey(key);\n },\n });\n\n // ---- Filtered Collection ----\n const originalCollection = listState.collection;\n\n const filteredCollection = createMemo<Collection<T>>(() => {\n const collection = originalCollection();\n const input = inputValue();\n const filter = getProps().defaultFilter;\n\n // If no filter function provided, return original collection\n if (!filter) {\n return collection;\n }\n\n // Filter the collection based on input value\n return filterCollection(collection, input, filter);\n });\n\n // The displayed collection depends on showAllItems flag\n // Always show filtered collection (or all items if showAllItems is true)\n const displayedCollection = createMemo<Collection<T>>(() => {\n return showAllItems() ? originalCollection() : filteredCollection();\n });\n\n // ---- Selected Item(s) ----\n const selectedItem: Accessor<CollectionNode<T> | null> = () => {\n const key = selectedKey();\n if (key == null) return null;\n return originalCollection().getItem(key);\n };\n\n const selectedItems = createMemo<CollectionNode<T>[]>(() => {\n const keys = selectedKeys();\n const collection = originalCollection();\n const items: CollectionNode<T>[] = [];\n for (const key of keys) {\n const item = collection.getItem(key);\n if (item) items.push(item);\n }\n return items;\n });\n\n // Initialize input value from selected item if not already set\n // This runs once on creation\n if (!inputInitialized && !isInputControlled()) {\n const defaultKey = getProps().defaultSelectedKey;\n if (defaultKey != null && !getProps().defaultInputValue) {\n // Get the text value from the collection for the default selected key\n const item = originalCollection().getItem(defaultKey);\n if (item) {\n setInternalInputValue(item.textValue);\n setLastValue(item.textValue);\n }\n }\n inputInitialized = true;\n }\n\n // ---- Helper Functions ----\n const resetInputValue = () => {\n const item = selectedItem();\n const textValue = item?.textValue ?? \"\";\n setLastValue(textValue);\n setInputValue(textValue);\n };\n\n const closeMenu = () => {\n if (overlayState.isOpen()) {\n overlayState.close();\n }\n };\n\n // ---- Open/Toggle Logic ----\n // Auto-focus the menu on open the way upstream's listbox does via its\n // `autoFocus: state.focusStrategy || true` prop (useComboBox.ts:490 → useSelectableCollection):\n // the first selectable selected key, else the first/last key for an explicit\n // strategy, else nothing. The port drives this from the state (createListBox\n // reimplements nav inline and does not honor a listbox `autoFocus` prop), so\n // BOTH open() and toggle() must apply it — a button/mouse open routes through\n // toggle(), and omitting it there left the menu opened with no active option\n // (no aria-activedescendant / no highlighted row) unlike upstream.\n const applyOpenFocus = (strategy: FocusStrategy | null) => {\n const key = selectedKey();\n const nextFocusedKey =\n key != null && !listState.isDisabled(key)\n ? key\n : strategy === \"first\"\n ? displayedCollection().getFirstKey()\n : strategy === \"last\"\n ? displayedCollection().getLastKey()\n : null;\n listState.setFocused(true);\n listState.setFocusedKey(nextFocusedKey);\n };\n\n const open = (strategy: FocusStrategy | null = null, trigger?: MenuTriggerAction) => {\n const displayAll = trigger === \"manual\" || (trigger === \"focus\" && menuTrigger() === \"focus\");\n\n // Check if we should open\n const filtered = filteredCollection();\n const original = originalCollection();\n const canOpen =\n allowsEmptyCollection() || filtered.size > 0 || (displayAll && original.size > 0);\n\n if (!canOpen) return;\n\n if (displayAll && !overlayState.isOpen()) {\n setShowAllItems(true);\n }\n\n menuOpenTrigger = trigger ?? \"focus\";\n setFocusStrategy(strategy);\n if (!overlayState.isOpen()) {\n applyOpenFocus(strategy);\n }\n overlayState.open();\n };\n\n const toggle = (strategy: FocusStrategy | null = null, trigger?: MenuTriggerAction) => {\n const displayAll = trigger === \"manual\" || (trigger === \"focus\" && menuTrigger() === \"focus\");\n\n // Check if we can open (if closed)\n const filtered = filteredCollection();\n const original = originalCollection();\n const canOpen =\n allowsEmptyCollection() || filtered.size > 0 || (displayAll && original.size > 0);\n\n if (!canOpen && !overlayState.isOpen()) return;\n\n const willOpen = !overlayState.isOpen();\n\n if (displayAll && willOpen) {\n setShowAllItems(true);\n }\n\n if (willOpen) {\n menuOpenTrigger = trigger ?? \"focus\";\n }\n\n setFocusStrategy(strategy);\n if (willOpen) {\n applyOpenFocus(strategy);\n }\n overlayState.toggle();\n };\n\n // ---- Commit/Revert Logic ----\n const commitCustomValue = () => {\n setSelectedKey(null);\n closeMenu();\n };\n\n const commitSelection = () => {\n // If both are controlled, just call onSelectionChange\n if (isSelectionControlled() && isInputControlled()) {\n getProps().onSelectionChange?.(selectedKey());\n const item = selectedItem();\n setLastValue(item?.textValue ?? \"\");\n closeMenu();\n } else {\n // Reset input to selected item's text\n resetInputValue();\n closeMenu();\n }\n };\n\n const commitValue = () => {\n if (allowsCustomValue()) {\n const item = selectedItem();\n const itemText = item?.textValue ?? \"\";\n if (inputValue() === itemText) {\n commitSelection();\n } else {\n commitCustomValue();\n }\n } else {\n commitSelection();\n }\n };\n\n const commit = () => {\n const focusedKey = listState.focusedKey();\n\n if (isMultiple()) {\n // In multiple mode, toggle the focused item without closing\n if (overlayState.isOpen() && focusedKey != null) {\n select(focusedKey);\n }\n return;\n }\n\n if (overlayState.isOpen() && focusedKey != null) {\n // If focused key is already selected, just commit\n if (selectedKey() === focusedKey) {\n commitSelection();\n } else {\n // Select the focused item\n setSelectedKey(focusedKey);\n closeMenu();\n }\n } else {\n commitValue();\n }\n };\n\n const revert = () => {\n if (allowsCustomValue() && selectedKey() == null) {\n commitCustomValue();\n } else {\n commitSelection();\n }\n };\n\n // ---- Focus Handling ----\n const [isFocused, setIsFocused] = createSignal(false);\n let valueOnFocus = \"\";\n\n const setFocused = (focused: boolean) => {\n if (focused) {\n valueOnFocus = inputValue();\n if (menuTrigger() === \"focus\" && !getProps().isReadOnly) {\n open(null, \"focus\");\n }\n } else {\n if (shouldCloseOnBlur()) {\n commitValue();\n }\n }\n setIsFocused(focused);\n };\n\n // ---- Effects for Auto Open/Close ----\n createEffect(() => {\n const input = inputValue();\n const filtered = filteredCollection();\n const isOpen = overlayState.isOpen();\n const last = lastValue();\n const focused = isFocused();\n\n // Auto-open when typing\n if (\n focused &&\n (filtered.size > 0 || allowsEmptyCollection()) &&\n !isOpen &&\n input !== last &&\n menuTrigger() !== \"manual\"\n ) {\n open(null, \"input\");\n }\n\n // Auto-close when empty (unless showing all)\n if (!showAllItems() && !allowsEmptyCollection() && isOpen && filtered.size === 0) {\n closeMenu();\n }\n\n // Clear focused key when input changes\n if (input !== last) {\n listState.setFocusedKey(null);\n setShowAllItems(false);\n\n // Clear selection when input is cleared (if not fully controlled)\n if (input === \"\" && (!isInputControlled() || !isSelectionControlled())) {\n setSelectedKey(null);\n }\n\n setLastValue(input);\n }\n });\n\n // Update input when selection changes (only in single mode)\n createEffect(() => {\n if (isMultiple()) return;\n const key = selectedKey();\n const item = key != null ? originalCollection().getItem(key) : null;\n const textValue = item?.textValue ?? \"\";\n\n // Only update if selection changed and not fully controlled\n if (!isInputControlled() || !isSelectionControlled()) {\n if (key != null && textValue !== inputValue()) {\n setInputValue(textValue);\n setLastValue(textValue);\n }\n }\n });\n\n // Close when selection changes (only in single mode)\n createEffect((prevKey: Key | null | undefined) => {\n if (isMultiple()) return undefined;\n const key = selectedKey();\n if (key != null && key !== prevKey) {\n closeMenu();\n }\n return key;\n }, undefined);\n\n // ---- Selection Methods for ListState compatibility ----\n // These methods allow createOption to work with ComboBoxState\n const select = (key: Key) => {\n if (isMultiple()) {\n // Toggle selection in multiple mode\n const current = new Set(selectedKeys());\n if (current.has(key)) {\n current.delete(key);\n } else {\n current.add(key);\n }\n setSelectedKeys(current);\n // Don't close menu and don't reset input in multi-select mode\n } else {\n setSelectedKey(key);\n closeMenu();\n }\n };\n\n const removeSelectedKey = (key: Key) => {\n if (isMultiple()) {\n const current = new Set(selectedKeys());\n current.delete(key);\n setSelectedKeys(current);\n }\n };\n\n const selectionMode: Accessor<\"single\" | \"multiple\"> = () => getProps().selectionMode ?? \"single\";\n\n const isSelected = (key: Key) => {\n if (isMultiple()) {\n return selectedKeys().has(key);\n }\n return selectedKey() === key;\n };\n\n // ---- Return State ----\n return {\n collection: displayedCollection,\n isOpen: overlayState.isOpen,\n open,\n close: commitValue,\n toggle,\n selectedKey,\n defaultSelectedKey: getProps().defaultSelectedKey ?? null,\n selectedItem,\n setSelectedKey,\n selectedKeys,\n selectedItems,\n removeSelectedKey,\n inputValue,\n defaultInputValue: getProps().defaultInputValue ?? \"\",\n setInputValue,\n selectionManager: listState.selectionManager,\n focusedKey: listState.focusedKey,\n setFocusedKey: listState.setFocusedKey,\n isFocused,\n setFocused,\n focusStrategy,\n commit,\n revert,\n // Selection state methods for ListState compatibility\n select,\n selectionMode,\n isSelected,\n isKeyDisabled: (key: Key) => listState.isDisabled(key),\n get isDisabled() {\n return getProps().isDisabled ?? false;\n },\n get isReadOnly() {\n return getProps().isReadOnly ?? false;\n },\n get isRequired() {\n return getProps().isRequired ?? false;\n },\n };\n}\n\n/**\n * Filter a collection based on input value.\n */\nfunction filterCollection<T>(\n collection: Collection<T>,\n inputValue: string,\n filter: FilterFn,\n): Collection<T> {\n if (!inputValue) {\n return collection;\n }\n\n const filteredItems: CollectionNode<T>[] = [];\n\n for (const item of collection) {\n if (item.type === \"section\") {\n // Filter section children\n const filteredChildren: CollectionNode<T>[] = [];\n if (item.childNodes) {\n for (const child of item.childNodes) {\n if (child.type === \"item\" && filter(child.textValue, inputValue)) {\n filteredChildren.push(child);\n }\n }\n }\n // Only include section if it has matching children\n if (filteredChildren.length > 0) {\n filteredItems.push({\n ...item,\n childNodes: filteredChildren,\n });\n }\n } else if (item.type === \"item\") {\n if (filter(item.textValue, inputValue)) {\n filteredItems.push(item);\n }\n }\n }\n\n // Create a new collection from filtered items\n return createFilteredCollection(filteredItems, collection);\n}\n\n/**\n * Create a filtered collection wrapper.\n */\nfunction createFilteredCollection<T>(\n items: CollectionNode<T>[],\n original: Collection<T>,\n): Collection<T> {\n const itemMap = new Map<Key, CollectionNode<T>>();\n\n for (const item of items) {\n itemMap.set(item.key, item);\n if (item.childNodes) {\n for (const child of item.childNodes) {\n itemMap.set(child.key, child);\n }\n }\n }\n\n return {\n get size() {\n let count = 0;\n for (const item of items) {\n if (item.type === \"item\") {\n count++;\n } else if (item.childNodes) {\n count += Array.from(item.childNodes).filter((c) => c.type === \"item\").length;\n }\n }\n return count;\n },\n getItem(key: Key) {\n return itemMap.get(key) ?? null;\n },\n getKeys() {\n return itemMap.keys();\n },\n getFirstKey() {\n for (const item of items) {\n if (item.type === \"item\") return item.key;\n if (item.childNodes) {\n for (const child of item.childNodes) {\n if (child.type === \"item\") return child.key;\n }\n }\n }\n return null;\n },\n getLastKey() {\n for (let i = items.length - 1; i >= 0; i--) {\n const item = items[i];\n if (item.type === \"item\") return item.key;\n if (item.childNodes) {\n const children = Array.from(item.childNodes);\n for (let j = children.length - 1; j >= 0; j--) {\n if (children[j].type === \"item\") return children[j].key;\n }\n }\n }\n return null;\n },\n getKeyBefore(key: Key) {\n return original.getKeyBefore(key);\n },\n getKeyAfter(key: Key) {\n return original.getKeyAfter(key);\n },\n at(index: number) {\n // Flatten items for indexing\n let currentIndex = 0;\n for (const item of items) {\n if (item.type === \"item\") {\n if (currentIndex === index) return item;\n currentIndex++;\n } else if (item.childNodes) {\n for (const child of item.childNodes) {\n if (child.type === \"item\") {\n if (currentIndex === index) return child;\n currentIndex++;\n }\n }\n }\n }\n return null;\n },\n getChildren(key: Key) {\n const item = itemMap.get(key);\n return item?.childNodes ?? [];\n },\n getTextValue(key: Key) {\n const item = itemMap.get(key);\n return item?.textValue ?? \"\";\n },\n [Symbol.iterator]() {\n return items[Symbol.iterator]();\n },\n };\n}\n","/**\n * State management for tab components.\n * Based on @react-stately/tabs.\n */\n\nimport { createComputed, createMemo, createSignal, type Accessor } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils\";\nimport { ListCollection } from \"../collections/ListCollection\";\nimport type {\n Collection,\n CollectionItemLike,\n CollectionNode,\n Key,\n FocusStrategy,\n} from \"../collections/types\";\n\nexport type KeyboardActivation = \"automatic\" | \"manual\";\nexport type TabOrientation = \"horizontal\" | \"vertical\";\n\nexport interface TabListStateProps<T = unknown> {\n /** The items in the tab list. */\n items?: T[];\n /** Function to get a key from an item. */\n getKey?: (item: T) => Key;\n /** Function to get text value from an item. */\n getTextValue?: (item: T) => string;\n /** Function to check if an item is disabled. */\n getDisabled?: (item: T) => boolean;\n /** Keys of disabled tabs. */\n disabledKeys?: Iterable<Key>;\n /** The currently selected tab key (controlled). */\n selectedKey?: Key | null;\n /** The default selected tab key (uncontrolled). */\n defaultSelectedKey?: Key;\n /** Handler for tab selection changes. */\n onSelectionChange?: (key: Key) => void;\n /** Whether the entire tab list is disabled. */\n isDisabled?: boolean;\n /** Whether tabs are activated automatically on focus or manually. */\n keyboardActivation?: KeyboardActivation;\n /** The orientation of the tab list. */\n orientation?: TabOrientation;\n}\n\nexport interface TabListState<T = unknown> {\n /** The collection of tabs. */\n readonly collection: Accessor<Collection<T>>;\n /** The currently selected tab key. */\n readonly selectedKey: Accessor<Key | null>;\n /** Set the selected tab key. */\n setSelectedKey(key: Key): void;\n /** The currently selected tab item. */\n readonly selectedItem: Accessor<CollectionNode<T> | null>;\n /** Whether the tab list is disabled. */\n readonly isDisabled: Accessor<boolean>;\n /** The keyboard activation mode. */\n readonly keyboardActivation: Accessor<KeyboardActivation>;\n /** The orientation of the tab list. */\n readonly orientation: Accessor<TabOrientation>;\n /** Whether a tab key is disabled. */\n isKeyDisabled(key: Key): boolean;\n /** The set of disabled keys. */\n readonly disabledKeys: Accessor<Set<Key>>;\n /** Whether the collection is focused. */\n readonly isFocused: Accessor<boolean>;\n /** Set the focused state. */\n setFocused(isFocused: boolean): void;\n /** The currently focused tab key. */\n readonly focusedKey: Accessor<Key | null>;\n /** Set the focused tab key. */\n setFocusedKey(key: Key | null, childStrategy?: FocusStrategy): void;\n /** The child focus strategy. */\n readonly childFocusStrategy: Accessor<FocusStrategy | null>;\n}\n\n/**\n * Creates state for a tab list component.\n */\nexport function createTabListState<T = unknown>(\n props: MaybeAccessor<TabListStateProps<T>>,\n): TabListState<T> {\n const getProps = () => access(props);\n\n const collection: Accessor<Collection<T>> = createMemo(() => {\n const p = getProps();\n const items = p.items ?? [];\n\n const nodes: CollectionNode<T>[] = items.map((item, index) => {\n const o = item as CollectionItemLike;\n const key = p.getKey?.(item) ?? o.key ?? o.id ?? index;\n const textValue = p.getTextValue?.(item) ?? o.textValue ?? o.label ?? String(item);\n const isDisabled = p.getDisabled?.(item) ?? o.isDisabled ?? false;\n\n return {\n type: \"item\" as const,\n key,\n value: item,\n textValue,\n rendered: null!,\n level: 0,\n index,\n parentKey: null,\n hasChildNodes: false,\n childNodes: [],\n isDisabled,\n };\n });\n\n return new ListCollection(nodes);\n });\n\n // Compute disabled keys (memoized to avoid rebuilding Set per access)\n const disabledKeys: Accessor<Set<Key>> = createMemo(() => {\n const p = getProps();\n const result = new Set<Key>(p.disabledKeys ?? []);\n\n const coll = collection();\n for (const node of coll) {\n if (node.isDisabled) {\n result.add(node.key);\n }\n }\n\n return result;\n });\n\n const isKeyDisabled = (key: Key): boolean => {\n const p = getProps();\n if (p.isDisabled) return true;\n return disabledKeys().has(key);\n };\n\n // Find the first non-disabled key\n const findFirstNonDisabledKey = (): Key | null => {\n const coll = collection();\n for (const node of coll) {\n if (!isKeyDisabled(node.key)) {\n return node.key;\n }\n }\n return null;\n };\n\n const getInitialSelectedKey = (): Key | null => {\n const p = getProps();\n\n if (p.selectedKey !== undefined) {\n return p.selectedKey;\n }\n\n if (p.defaultSelectedKey !== undefined && !isKeyDisabled(p.defaultSelectedKey)) {\n return p.defaultSelectedKey;\n }\n\n return findFirstNonDisabledKey();\n };\n\n const [selectedKeyInternal, setSelectedKeyInternal] = createSignal<Key | null>(\n getInitialSelectedKey(),\n );\n\n const selectedKey: Accessor<Key | null> = () => {\n const p = getProps();\n if (p.selectedKey !== undefined) {\n return p.selectedKey;\n }\n return selectedKeyInternal();\n };\n\n const setSelectedKey = (key: Key) => {\n if (isKeyDisabled(key)) return;\n if (selectedKey() === key) return;\n\n const p = getProps();\n if (p.selectedKey === undefined) {\n setSelectedKeyInternal(key);\n }\n\n p.onSelectionChange?.(key);\n };\n\n const selectedItem: Accessor<CollectionNode<T> | null> = () => {\n const key = selectedKey();\n if (key === null) return null;\n return collection().getItem(key);\n };\n\n const isDisabled: Accessor<boolean> = () => getProps().isDisabled ?? false;\n\n const keyboardActivation: Accessor<KeyboardActivation> = () =>\n getProps().keyboardActivation ?? \"automatic\";\n\n const orientation: Accessor<TabOrientation> = () => getProps().orientation ?? \"horizontal\";\n\n const [isFocused, setIsFocused] = createSignal(false);\n const [focusedKey, setFocusedKeyInternal] = createSignal<Key | null>(null);\n const [childFocusStrategy, setChildFocusStrategy] = createSignal<FocusStrategy | null>(null);\n\n const setFocusedKey = (key: Key | null, childStrategy?: FocusStrategy) => {\n setFocusedKeyInternal(key);\n setChildFocusStrategy(childStrategy ?? null);\n };\n\n // If the tab list doesn't have focus and the selected key changes, or if there\n // isn't a focused key yet, move the focused key to the selected key so the\n // roving tabIndex stays on the selected tab (mirrors useTabListState's effect).\n let lastSelectedKey: Key | null = selectedKey();\n createComputed(() => {\n const sel = selectedKey();\n if ((sel !== null && focusedKey() === null) || (!isFocused() && sel !== lastSelectedKey)) {\n setFocusedKey(sel);\n }\n lastSelectedKey = sel;\n });\n\n // Keep uncontrolled selection valid as items/disabled keys change.\n createComputed(() => {\n const p = getProps();\n if (p.selectedKey !== undefined) return;\n\n const coll = collection();\n const current = selectedKeyInternal();\n const currentExists = current !== null && coll.getItem(current) !== null;\n const currentEnabled = current !== null && !isKeyDisabled(current);\n\n if (currentExists && currentEnabled) return;\n\n if (\n p.defaultSelectedKey !== undefined &&\n coll.getItem(p.defaultSelectedKey) !== null &&\n !isKeyDisabled(p.defaultSelectedKey)\n ) {\n if (p.defaultSelectedKey !== current) {\n setSelectedKeyInternal(p.defaultSelectedKey);\n }\n return;\n }\n\n const nextKey = findFirstNonDisabledKey();\n if (nextKey !== current) {\n setSelectedKeyInternal(nextKey);\n }\n });\n\n return {\n collection,\n selectedKey,\n setSelectedKey,\n selectedItem,\n isDisabled,\n keyboardActivation,\n orientation,\n isKeyDisabled,\n disabledKeys,\n isFocused,\n setFocused: setIsFocused,\n focusedKey,\n setFocusedKey,\n childFocusStrategy,\n };\n}\n","/**\n * State management for NumberField.\n * Based on @react-stately/numberfield useNumberFieldState.\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils\";\n\nexport interface NumberFieldStateProps {\n /** The current value (controlled). */\n value?: number;\n /** The default value (uncontrolled). */\n defaultValue?: number;\n /** Handler called when the value changes. */\n onChange?: (value: number) => void;\n /** The minimum value. */\n minValue?: number;\n /** The maximum value. */\n maxValue?: number;\n /** The step value for increment/decrement. */\n step?: number;\n /** Whether the field is disabled. */\n isDisabled?: boolean;\n /** Whether the field is read-only. */\n isReadOnly?: boolean;\n /** The locale for number formatting. */\n locale?: string;\n /** Number format options. */\n formatOptions?: Intl.NumberFormatOptions;\n}\n\nexport interface NumberFieldState {\n /** The current input value as a string. */\n inputValue: Accessor<string>;\n /** The current numeric value. */\n numberValue: Accessor<number>;\n /** Whether the value can be incremented. */\n canIncrement: Accessor<boolean>;\n /** Whether the value can be decremented. */\n canDecrement: Accessor<boolean>;\n /** Whether the field is disabled. */\n isDisabled: Accessor<boolean>;\n /** Whether the field is read-only. */\n isReadOnly: Accessor<boolean>;\n /** The minimum value. */\n minValue: Accessor<number | undefined>;\n /** The maximum value. */\n maxValue: Accessor<number | undefined>;\n /** Set the input value. */\n setInputValue: (value: string) => void;\n /** Validate a partial input value. */\n validate: (value: string) => boolean;\n /** Commit the current input value. */\n commit: () => void;\n /** Increment the value by step. */\n increment: () => void;\n /** Decrement the value by step. */\n decrement: () => void;\n /** Set to maximum value. */\n incrementToMax: () => void;\n /** Set to minimum value. */\n decrementToMin: () => void;\n}\n\n/**\n * Handles decimal operations to avoid floating point errors.\n */\nfunction handleDecimalOperation(operator: \"+\" | \"-\", value1: number, value2: number): number {\n // Find the number of decimal places\n const getDecimals = (n: number) => {\n const str = String(n);\n const idx = str.indexOf(\".\");\n return idx === -1 ? 0 : str.length - idx - 1;\n };\n\n const decimals = Math.max(getDecimals(value1), getDecimals(value2));\n const multiplier = Math.pow(10, decimals);\n\n const int1 = Math.round(value1 * multiplier);\n const int2 = Math.round(value2 * multiplier);\n\n const result = operator === \"+\" ? int1 + int2 : int1 - int2;\n return result / multiplier;\n}\n\n/**\n * Clamps a value between min and max.\n */\nfunction clamp(value: number, min?: number, max?: number): number {\n let result = value;\n if (min != null && result < min) result = min;\n if (max != null && result > max) result = max;\n return result;\n}\n\n/**\n * Snaps a value to the nearest step.\n */\nfunction snapToStep(value: number, step: number, min?: number): number {\n const base = min ?? 0;\n const diff = value - base;\n const steps = Math.round(diff / step);\n return handleDecimalOperation(\"+\", base, steps * step);\n}\n\nfunction isValidStep(step: number | undefined): step is number {\n return step != null && !isNaN(step) && step > 0;\n}\n\n/**\n * Creates state for a number field.\n */\nexport function createNumberFieldState(\n props: MaybeAccessor<NumberFieldStateProps>,\n): NumberFieldState {\n const getProps = () => access(props);\n\n // Get locale and formatter\n const locale = () => getProps().locale ?? \"en-US\";\n const formatOptions = () => getProps().formatOptions ?? {};\n\n // Create number formatter\n const formatter = createMemo(() => {\n return new Intl.NumberFormat(locale(), formatOptions());\n });\n\n // Create number parser (simplified - real implementation would be more robust)\n const parseNumber = (value: string): number => {\n if (!value || value === \"\" || value === \"-\") return NaN;\n\n // Handle locale-specific decimal separators\n const opts = formatOptions();\n const testNumber = formatter().format(1.1);\n const decimalSeparator = testNumber.charAt(1);\n\n // Normalize the input\n let normalized = value;\n if (decimalSeparator !== \".\") {\n normalized = normalized.replace(decimalSeparator, \".\");\n }\n\n // Remove grouping separators and currency symbols\n normalized = normalized.replace(/[^\\d.-]/g, \"\");\n\n const parsed = parseFloat(normalized);\n if (isNaN(parsed)) return parsed;\n\n if (opts.style === \"percent\") {\n return parsed / 100;\n }\n\n return parsed;\n };\n\n // Format a number to string\n const formatNumber = (value: number): string => {\n if (isNaN(value)) return \"\";\n return formatter().format(value);\n };\n\n // Determine step value\n const hasCustomStep = createMemo(() => isValidStep(getProps().step));\n\n const step = createMemo(() => {\n const p = getProps();\n if (hasCustomStep()) return p.step as number;\n // Default step for percent is 0.01\n if (p.formatOptions?.style === \"percent\") return 0.01;\n return 1;\n });\n\n // Internal signals\n const [inputValue, setInputValueInternal] = createSignal<string>(\"\");\n const [numberValue, setNumberValue] = createSignal<number>(NaN);\n\n const applyConstraints = (value: number): number => {\n const p = getProps();\n if (isNaN(value)) return NaN;\n\n if (hasCustomStep()) {\n return clamp(snapToStep(value, step(), p.minValue), p.minValue, p.maxValue);\n }\n\n return clamp(value, p.minValue, p.maxValue);\n };\n\n // Initialize from props\n const initValue = () => {\n const p = getProps();\n const initial = p.value ?? p.defaultValue;\n if (initial != null) {\n const constrained = applyConstraints(initial);\n setNumberValue(constrained);\n setInputValueInternal(formatNumber(constrained));\n }\n };\n\n // Call init on first access\n let initialized = false;\n const ensureInitialized = () => {\n if (!initialized) {\n initialized = true;\n initValue();\n }\n };\n\n // Controlled mode: sync with props.value\n const actualNumberValue = createMemo(() => {\n ensureInitialized();\n const p = getProps();\n if (p.value !== undefined) {\n return applyConstraints(p.value);\n }\n return numberValue();\n });\n\n let lastControlledValue: number | undefined = undefined;\n const syncControlledValue = () => {\n const p = getProps();\n if (p.value === undefined) {\n lastControlledValue = undefined;\n return;\n }\n\n const constrained = applyConstraints(p.value);\n if (lastControlledValue === undefined || !Object.is(lastControlledValue, constrained)) {\n lastControlledValue = constrained;\n setNumberValue(constrained);\n setInputValueInternal(formatNumber(constrained));\n }\n };\n\n const parsedInputValue = () => {\n ensureInitialized();\n syncControlledValue();\n return parseNumber(inputValue());\n };\n\n // Validate partial input\n const validate = (value: string): boolean => {\n if (value === \"\" || value === \"-\") return true;\n\n // Allow partial decimal input like \"1.\"\n const opts = formatOptions();\n const testNumber = formatter().format(1.1);\n const decimalSeparator = testNumber.charAt(1);\n\n // Check if it's a valid partial number\n const pattern = new RegExp(\n `^-?\\\\d*${decimalSeparator === \".\" ? \"\\\\.\" : decimalSeparator}?\\\\d*$`,\n );\n return pattern.test(value);\n };\n\n // Set input value with validation\n const setInputValue = (value: string) => {\n ensureInitialized();\n syncControlledValue();\n setInputValueInternal(value);\n };\n\n // Commit the current input value\n const commit = () => {\n ensureInitialized();\n const p = getProps();\n const input = inputValue();\n\n if (input === \"\" || input === \"-\") {\n // Clear value\n setNumberValue(NaN);\n setInputValueInternal(p.value === undefined ? \"\" : formatNumber(actualNumberValue()));\n p.onChange?.(NaN);\n return;\n }\n\n let parsed = parseNumber(input);\n\n if (isNaN(parsed)) {\n // Invalid input - revert to current value\n setInputValueInternal(formatNumber(actualNumberValue()));\n return;\n }\n\n // Clamp and optionally snap to custom step.\n parsed = applyConstraints(parsed);\n\n // Update state\n setNumberValue(parsed);\n setInputValueInternal(formatNumber(parsed));\n\n p.onChange?.(parsed);\n };\n\n // Check if can increment\n const canIncrement = createMemo(() => {\n ensureInitialized();\n const p = getProps();\n if (p.isDisabled || p.isReadOnly) return false;\n\n const current = parsedInputValue();\n if (isNaN(current)) return true; // Can start from min\n\n if (p.maxValue == null) return true;\n return (\n snapToStep(current, step(), p.minValue) > current ||\n handleDecimalOperation(\"+\", current, step()) <= p.maxValue\n );\n });\n\n // Check if can decrement\n const canDecrement = createMemo(() => {\n ensureInitialized();\n const p = getProps();\n if (p.isDisabled || p.isReadOnly) return false;\n\n const current = parsedInputValue();\n if (isNaN(current)) return true; // Can start from max\n\n if (p.minValue == null) return true;\n return (\n snapToStep(current, step(), p.minValue) < current ||\n handleDecimalOperation(\"-\", current, step()) >= p.minValue\n );\n });\n\n const safeNextStep = (operation: \"+\" | \"-\", minOrMaxValue: number = 0): number => {\n const p = getProps();\n const parsed = parsedInputValue();\n\n if (isNaN(parsed)) {\n const base = isNaN(minOrMaxValue) ? 0 : minOrMaxValue;\n return clamp(snapToStep(base, step(), p.minValue), p.minValue, p.maxValue);\n }\n\n const snapped = snapToStep(parsed, step(), p.minValue);\n if ((operation === \"+\" && snapped > parsed) || (operation === \"-\" && snapped < parsed)) {\n return clamp(snapped, p.minValue, p.maxValue);\n }\n\n const next = handleDecimalOperation(operation, parsed, step());\n return clamp(snapToStep(next, step(), p.minValue), p.minValue, p.maxValue);\n };\n\n // Increment by step\n const increment = () => {\n ensureInitialized();\n syncControlledValue();\n const p = getProps();\n if (p.isDisabled || p.isReadOnly) return;\n\n const current = safeNextStep(\"+\", p.minValue);\n setNumberValue(current);\n setInputValueInternal(formatNumber(current));\n p.onChange?.(current);\n };\n\n // Decrement by step\n const decrement = () => {\n ensureInitialized();\n syncControlledValue();\n const p = getProps();\n if (p.isDisabled || p.isReadOnly) return;\n\n const current = safeNextStep(\"-\", p.maxValue);\n setNumberValue(current);\n setInputValueInternal(formatNumber(current));\n p.onChange?.(current);\n };\n\n // Set to max\n const incrementToMax = () => {\n ensureInitialized();\n syncControlledValue();\n const p = getProps();\n if (p.isDisabled || p.isReadOnly) return;\n\n if (p.maxValue == null) return;\n\n const snapped = snapToStep(p.maxValue, step(), p.minValue);\n setNumberValue(snapped);\n setInputValueInternal(formatNumber(snapped));\n p.onChange?.(snapped);\n };\n\n // Set to min\n const decrementToMin = () => {\n ensureInitialized();\n syncControlledValue();\n const p = getProps();\n if (p.isDisabled || p.isReadOnly) return;\n\n if (p.minValue == null) return;\n\n setNumberValue(p.minValue);\n setInputValueInternal(formatNumber(p.minValue));\n p.onChange?.(p.minValue);\n };\n\n return {\n get inputValue() {\n ensureInitialized();\n syncControlledValue();\n return inputValue;\n },\n get numberValue() {\n return actualNumberValue;\n },\n canIncrement,\n canDecrement,\n isDisabled: () => getProps().isDisabled ?? false,\n isReadOnly: () => getProps().isReadOnly ?? false,\n minValue: () => getProps().minValue,\n maxValue: () => getProps().maxValue,\n setInputValue,\n validate,\n commit,\n increment,\n decrement,\n incrementToMax,\n decrementToMin,\n };\n}\n","/**\n * Creates state for a search field component.\n * Based on @react-stately/searchfield useSearchFieldState.\n */\n\nimport { type Accessor, createSignal, createMemo } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils\";\n\nexport interface SearchFieldStateProps {\n /** The current value (controlled). */\n value?: string;\n /** The default value (uncontrolled). */\n defaultValue?: string;\n /** Handler that is called when the value changes. */\n onChange?: (value: string) => void;\n}\n\nexport interface SearchFieldState {\n /** The current value of the search field. */\n value: Accessor<string>;\n /** Sets the value of the search field. */\n setValue: (value: string) => void;\n}\n\n/**\n * Provides state management for a search field.\n */\nexport function createSearchFieldState(\n props: MaybeAccessor<SearchFieldStateProps>,\n): SearchFieldState {\n const getProps = () => access(props);\n\n const isControlled = () => getProps().value !== undefined;\n\n const [internalValue, setInternalValue] = createSignal(getProps().defaultValue ?? \"\");\n\n const value = createMemo(() => {\n const p = getProps();\n return isControlled() ? (p.value ?? \"\") : internalValue();\n });\n\n const setValue = (newValue: string) => {\n const p = getProps();\n\n if (!isControlled()) {\n setInternalValue(newValue);\n }\n\n p.onChange?.(newValue);\n };\n\n return {\n value,\n setValue,\n };\n}\n","/**\n * Creates state for a slider component.\n * Based on @react-stately/slider useSliderState.\n */\n\nimport { type Accessor, createSignal, createMemo } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils\";\n\nexport type SliderOrientation = \"horizontal\" | \"vertical\";\n\nexport interface SliderStateProps {\n /** The current value (controlled). */\n value?: number;\n /** The default value (uncontrolled). */\n defaultValue?: number;\n /** Handler called when the value changes. */\n onChange?: (value: number) => void;\n /** Handler called when the user stops dragging. */\n onChangeEnd?: (value: number) => void;\n /** The minimum value. */\n minValue?: number;\n /** The maximum value. */\n maxValue?: number;\n /** The step value. */\n step?: number;\n /** The orientation of the slider. */\n orientation?: SliderOrientation;\n /** Whether the slider is disabled. */\n isDisabled?: boolean;\n /** The locale for number formatting. */\n locale?: string;\n /** Number format options. */\n formatOptions?: Intl.NumberFormatOptions;\n}\n\nexport interface SliderState {\n /** The current value. */\n value: Accessor<number>;\n /** Sets the value. */\n setValue: (value: number) => void;\n /** Sets the value by percent (0-1). */\n setValuePercent: (percent: number) => void;\n /** Gets the value as a percent (0-1). */\n getValuePercent: Accessor<number>;\n /** Gets the formatted value string. */\n getFormattedValue: Accessor<string>;\n /** Whether the thumb is being dragged. */\n isDragging: Accessor<boolean>;\n /** Sets the dragging state. */\n setDragging: (dragging: boolean) => void;\n /** Whether the slider is focused. */\n isFocused: Accessor<boolean>;\n /** Sets the focused state. */\n setFocused: (focused: boolean) => void;\n /** Increments the value by step. */\n increment: (stepMultiplier?: number) => void;\n /** Decrements the value by step. */\n decrement: (stepMultiplier?: number) => void;\n /** The minimum value. */\n minValue: number;\n /** The maximum value. */\n maxValue: number;\n /** The step value. */\n step: number;\n /** The page step (larger step for Page Up/Down). */\n pageStep: number;\n /** The orientation. */\n orientation: SliderOrientation;\n /** Whether the slider is disabled. */\n isDisabled: boolean;\n}\n\nconst DEFAULT_MIN = 0;\nconst DEFAULT_MAX = 100;\nconst DEFAULT_STEP = 1;\n\n/**\n * Clamps a value between min and max.\n */\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(Math.max(value, min), max);\n}\n\n/**\n * Snaps a value to the nearest step.\n */\nfunction snapToStep(value: number, min: number, max: number, step: number): number {\n const snapped = Math.round((value - min) / step) * step + min;\n // Handle floating point precision issues\n const decimalPlaces = (step.toString().split(\".\")[1] || \"\").length;\n const rounded = parseFloat(snapped.toFixed(decimalPlaces));\n return clamp(rounded, min, max);\n}\n\n/**\n * Provides state management for a slider component.\n */\nexport function createSliderState(props: MaybeAccessor<SliderStateProps>): SliderState {\n const getProps = () => access(props);\n\n const initialProps = getProps();\n const initialMinValue = initialProps.minValue ?? DEFAULT_MIN;\n const initialMaxValue = initialProps.maxValue ?? DEFAULT_MAX;\n const initialStep = initialProps.step ?? DEFAULT_STEP;\n\n const minValue = createMemo(() => getProps().minValue ?? DEFAULT_MIN);\n const maxValue = createMemo(() => getProps().maxValue ?? DEFAULT_MAX);\n const step = createMemo(() => getProps().step ?? DEFAULT_STEP);\n const orientation = createMemo(() => getProps().orientation ?? \"horizontal\");\n const isDisabled = createMemo(() => getProps().isDisabled ?? false);\n const pageStep = createMemo(() =>\n Math.max(\n step(),\n snapToStep((maxValue() - minValue()) / 10, 0, maxValue() - minValue(), step()),\n ),\n );\n\n // Controlled vs uncontrolled\n const isControlled = () => getProps().value !== undefined;\n\n // Internal signal for uncontrolled mode\n const [internalValue, setInternalValue] = createSignal(\n snapToStep(\n initialProps.defaultValue ?? initialMinValue,\n initialMinValue,\n initialMaxValue,\n initialStep,\n ),\n );\n\n // Dragging and focus state\n const [isDragging, setIsDragging] = createSignal(false);\n const [isFocused, setIsFocused] = createSignal(false);\n\n // Current value accessor\n const value = createMemo(() => {\n const p = getProps();\n const rawValue = isControlled() ? (p.value ?? minValue()) : internalValue();\n return snapToStep(rawValue, minValue(), maxValue(), step());\n });\n\n // Value as percent (0-1)\n const getValuePercent = createMemo(() => {\n return (value() - minValue()) / (maxValue() - minValue());\n });\n\n // Formatted value\n const getFormattedValue = createMemo(() => {\n const p = getProps();\n const formatter = new Intl.NumberFormat(p.locale, p.formatOptions);\n return formatter.format(value());\n });\n\n // Set value function\n const setValue = (newValue: number) => {\n if (isDisabled()) return;\n\n const p = getProps();\n const snappedValue = snapToStep(newValue, minValue(), maxValue(), step());\n\n if (!isControlled()) {\n setInternalValue(snappedValue);\n }\n\n p.onChange?.(snappedValue);\n };\n\n // Set value by percent\n const setValuePercent = (percent: number) => {\n const clampedPercent = clamp(percent, 0, 1);\n const newValue = clampedPercent * (maxValue() - minValue()) + minValue();\n setValue(newValue);\n };\n\n // Dragging state management\n const setDragging = (dragging: boolean) => {\n const wasDragging = isDragging();\n setIsDragging(dragging);\n\n // Call onChangeEnd when dragging stops\n if (wasDragging && !dragging) {\n getProps().onChangeEnd?.(value());\n }\n };\n\n // Increment/decrement\n const increment = (stepMultiplier = 1) => {\n if (isDisabled()) return;\n setValue(value() + step() * stepMultiplier);\n };\n\n const decrement = (stepMultiplier = 1) => {\n if (isDisabled()) return;\n setValue(value() - step() * stepMultiplier);\n };\n\n // Set focused state\n const setFocused = (focused: boolean) => {\n setIsFocused(focused);\n };\n\n return {\n value,\n setValue,\n setValuePercent,\n getValuePercent,\n getFormattedValue,\n isDragging,\n setDragging,\n isFocused,\n setFocused,\n increment,\n decrement,\n get minValue() {\n return minValue();\n },\n get maxValue() {\n return maxValue();\n },\n get step() {\n return step();\n },\n get pageStep() {\n return pageStep();\n },\n get orientation() {\n return orientation();\n },\n get isDisabled() {\n return isDisabled();\n },\n };\n}\n","/**\n * Manages state for a tooltip trigger.\n * Based on @react-stately/tooltip useTooltipTriggerState.\n *\n * Tracks whether the tooltip is open, and provides methods to toggle this state.\n * Ensures only one tooltip is open at a time and controls the delay for showing a tooltip.\n */\n\nimport { createSignal, onCleanup, type Accessor } from \"solid-js\";\nimport { createOverlayTriggerState, type OverlayTriggerProps } from \"../overlays\";\nimport { isServer } from \"../ssr\";\n\n// Default delays (in ms)\nconst TOOLTIP_DELAY = 1500;\nconst TOOLTIP_COOLDOWN = 500;\n\nexport interface TooltipTriggerProps extends OverlayTriggerProps {\n /** The delay time in milliseconds for the tooltip to show up. */\n delay?: number;\n /** The delay time in milliseconds for the tooltip to close. */\n closeDelay?: number;\n}\n\nexport interface TooltipTriggerState {\n /** Whether the tooltip is currently showing. */\n readonly isOpen: Accessor<boolean>;\n /**\n * Shows the tooltip. By default, the tooltip becomes visible after a delay\n * depending on a global warmup timer. The `immediate` option shows the\n * tooltip immediately instead.\n */\n open(immediate?: boolean): void;\n /** Hides the tooltip. */\n close(immediate?: boolean): void;\n}\n\n// Global state for coordinating tooltips\nlet tooltips: Record<string, (immediate?: boolean) => void> = {};\nlet tooltipId = 0;\nlet globalWarmedUp = false;\nlet globalWarmUpTimeout: ReturnType<typeof setTimeout> | null = null;\nlet globalCooldownTimeout: ReturnType<typeof setTimeout> | null = null;\n\n/**\n * Resets the global tooltip state. Useful for testing.\n * @internal\n */\nexport function resetTooltipState(): void {\n tooltips = {};\n tooltipId = 0;\n globalWarmedUp = false;\n if (globalWarmUpTimeout) {\n clearTimeout(globalWarmUpTimeout);\n globalWarmUpTimeout = null;\n }\n if (globalCooldownTimeout) {\n clearTimeout(globalCooldownTimeout);\n globalCooldownTimeout = null;\n }\n}\n\n/**\n * Manages state for a tooltip trigger. Tracks whether the tooltip is open, and provides\n * methods to toggle this state. Ensures only one tooltip is open at a time and controls\n * the delay for showing a tooltip.\n */\nexport function createTooltipTriggerState(props: TooltipTriggerProps = {}): TooltipTriggerState {\n const delay = () => props.delay ?? TOOLTIP_DELAY;\n const closeDelay = () => props.closeDelay ?? TOOLTIP_COOLDOWN;\n\n const overlayState = createOverlayTriggerState(props);\n const id = `tooltip-${++tooltipId}`;\n\n let closeTimeout: ReturnType<typeof setTimeout> | null = null;\n const [closeCallback, setCloseCallback] = createSignal<() => void>(() => overlayState.close());\n\n const ensureTooltipEntry = () => {\n tooltips[id] = hideTooltip;\n };\n\n const closeOpenTooltips = () => {\n for (const hideTooltipId in tooltips) {\n if (hideTooltipId !== id) {\n tooltips[hideTooltipId](true);\n delete tooltips[hideTooltipId];\n }\n }\n };\n\n const showTooltip = () => {\n if (closeTimeout) {\n clearTimeout(closeTimeout);\n closeTimeout = null;\n }\n closeOpenTooltips();\n ensureTooltipEntry();\n globalWarmedUp = true;\n overlayState.open();\n\n if (globalWarmUpTimeout) {\n clearTimeout(globalWarmUpTimeout);\n globalWarmUpTimeout = null;\n }\n if (globalCooldownTimeout) {\n clearTimeout(globalCooldownTimeout);\n globalCooldownTimeout = null;\n }\n };\n\n const hideTooltip = (immediate?: boolean) => {\n if (immediate || closeDelay() <= 0) {\n if (closeTimeout) {\n clearTimeout(closeTimeout);\n closeTimeout = null;\n }\n closeCallback()();\n } else if (!closeTimeout) {\n closeTimeout = setTimeout(() => {\n closeTimeout = null;\n closeCallback()();\n }, closeDelay());\n }\n\n if (globalWarmUpTimeout) {\n clearTimeout(globalWarmUpTimeout);\n globalWarmUpTimeout = null;\n }\n\n if (globalWarmedUp) {\n if (globalCooldownTimeout) {\n clearTimeout(globalCooldownTimeout);\n }\n globalCooldownTimeout = setTimeout(\n () => {\n delete tooltips[id];\n globalCooldownTimeout = null;\n globalWarmedUp = false;\n },\n Math.max(TOOLTIP_COOLDOWN, closeDelay()),\n );\n }\n };\n\n const warmupTooltip = () => {\n closeOpenTooltips();\n ensureTooltipEntry();\n\n if (!overlayState.isOpen() && !globalWarmUpTimeout && !globalWarmedUp) {\n globalWarmUpTimeout = setTimeout(() => {\n globalWarmUpTimeout = null;\n globalWarmedUp = true;\n showTooltip();\n }, delay());\n } else if (!overlayState.isOpen()) {\n showTooltip();\n }\n };\n\n // Update close callback when overlayState.close changes\n setCloseCallback(() => overlayState.close);\n\n // Cleanup on unmount\n onCleanup(() => {\n if (closeTimeout) {\n clearTimeout(closeTimeout);\n }\n if (tooltips[id]) {\n delete tooltips[id];\n }\n });\n\n return {\n isOpen: overlayState.isOpen,\n open: (immediate?: boolean) => {\n if (isServer) return;\n if (!immediate && delay() > 0 && !closeTimeout) {\n warmupTooltip();\n } else {\n showTooltip();\n }\n },\n close: hideTooltip,\n };\n}\n","/**\n * Toast state management for SolidJS\n * Based on @react-stately/toast useToastState\n */\n\nimport { createSignal, onCleanup, type Accessor } from \"solid-js\";\n\nexport interface ToastOptions {\n /** A timeout to automatically close the toast, in milliseconds. */\n timeout?: number;\n /** The priority of the toast relative to other toasts. */\n priority?: number;\n /** Handler called when the toast is closed. */\n onClose?: () => void;\n}\n\nexport interface QueuedToast<T> {\n /** The content of the toast. */\n content: T;\n /** A unique key for the toast. */\n key: string;\n /** The timer for the toast. */\n timer: Timer | null;\n /** Whether the toast should be animated. */\n animation?: \"entering\" | \"exiting\" | \"queued\";\n /** The priority of the toast. */\n priority: number;\n /** Handler called when the toast is closed. */\n onClose?: () => void;\n /** The timeout for the toast. */\n timeout?: number;\n}\n\n/** The kind of queue mutation that triggered a notification, passed to `wrapUpdate`. */\nexport type ToastAction = \"add\" | \"remove\" | \"clear\";\n\nexport interface ToastQueueOptions {\n /** The maximum number of toasts to display at once. */\n maxVisibleToasts?: number;\n /** Whether toasts should stack (true) or queue (false). */\n hasExitAnimation?: boolean;\n /**\n * Wraps each update to the visible toasts (e.g. in `document.startViewTransition()`),\n * so the resulting re-render can be animated. Receives the action that triggered the\n * update. Mirrors `@react-stately/toast`'s `wrapUpdate`.\n */\n wrapUpdate?: (fn: () => void, action: ToastAction) => void;\n}\n\nexport interface ToastStateProps<T> {\n /** The toast queue to use. */\n queue: ToastQueue<T>;\n}\n\nexport interface ToastState<T> {\n /** The currently visible toasts. */\n visibleToasts: Accessor<QueuedToast<T>[]>;\n /** Adds a toast to the queue. */\n add: (content: T, options?: ToastOptions) => string;\n /** Closes a toast by key. Starts exit animation if hasExitAnimation is enabled. */\n close: (key: string) => void;\n /**\n * Removes a toast after exit animation completes.\n * Call this from the component layer when the CSS exit animation finishes.\n * If hasExitAnimation is false, close() removes immediately and this is not needed.\n */\n remove: (key: string) => void;\n /** Clears all queued and visible toasts. */\n clear: () => void;\n /** Pauses all toast timers. */\n pauseAll: () => void;\n /** Resumes all toast timers. */\n resumeAll: () => void;\n}\n\n/**\n * A Timer that supports pause and resume.\n */\nexport class Timer {\n private timerId: number | null = null;\n private startTime: number = 0;\n private remaining: number;\n private callback: () => void;\n\n constructor(callback: () => void, delay: number) {\n this.callback = callback;\n this.remaining = delay;\n this.resume();\n }\n\n pause() {\n if (this.timerId === null) {\n return;\n }\n clearTimeout(this.timerId);\n this.timerId = null;\n this.remaining -= Date.now() - this.startTime;\n }\n\n resume() {\n if (this.timerId !== null) {\n return;\n }\n this.startTime = Date.now();\n this.timerId = window.setTimeout(() => {\n this.timerId = null;\n this.callback();\n }, this.remaining);\n }\n\n reset(delay: number) {\n this.pause();\n this.remaining = delay;\n this.resume();\n }\n\n cancel() {\n if (this.timerId !== null) {\n clearTimeout(this.timerId);\n this.timerId = null;\n }\n }\n}\n\ntype SubscribeCallback<T> = (toasts: QueuedToast<T>[]) => void;\n\n/**\n * A queue that manages toast notifications.\n * Can be created once and shared across the app (singleton pattern).\n */\nexport class ToastQueue<T> {\n private queue: QueuedToast<T>[] = [];\n private subscriptions = new Set<SubscribeCallback<T>>();\n private maxVisibleToasts: number;\n private hasExitAnimation: boolean;\n private keyCounter = 0;\n private wrapUpdate?: (fn: () => void, action: ToastAction) => void;\n\n constructor(options: ToastQueueOptions = {}) {\n this.maxVisibleToasts = options.maxVisibleToasts ?? 5;\n this.hasExitAnimation = options.hasExitAnimation ?? false;\n this.wrapUpdate = options.wrapUpdate;\n }\n\n /**\n * Installs (or clears) the function that wraps visible-toast updates, so the\n * resulting re-render can be animated. Used to attach `document.startViewTransition`\n * to a shared queue (e.g. the global queue) after construction.\n */\n setWrapUpdate(wrapUpdate?: (fn: () => void, action: ToastAction) => void): void {\n this.wrapUpdate = wrapUpdate;\n }\n\n private runWithWrapUpdate(fn: () => void, action: ToastAction): void {\n if (this.wrapUpdate) {\n this.wrapUpdate(fn, action);\n } else {\n fn();\n }\n }\n\n /**\n * Subscribe to queue changes.\n */\n subscribe(callback: SubscribeCallback<T>): () => void {\n this.subscriptions.add(callback);\n return () => {\n this.subscriptions.delete(callback);\n };\n }\n\n /**\n * Add a toast to the queue.\n */\n add(content: T, options: ToastOptions = {}): string {\n const key = String(this.keyCounter++);\n\n const toast: QueuedToast<T> = {\n content,\n key,\n timer: null,\n priority: options.priority ?? 0,\n onClose: options.onClose,\n timeout: options.timeout,\n animation: \"entering\",\n };\n\n // Find insertion point based on priority\n let low = 0;\n let high = this.queue.length;\n while (low < high) {\n const mid = Math.floor((low + high) / 2);\n if (toast.priority >= this.queue[mid].priority) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n // Insert at the correct position\n this.queue = [...this.queue.slice(0, low), toast, ...this.queue.slice(low)];\n\n // Start timer for visible toasts\n this.updateVisibility(\"add\");\n\n return key;\n }\n\n /**\n * Close a toast by key.\n */\n close(key: string): void {\n const toast = this.queue.find((t) => t.key === key);\n if (!toast) return;\n\n // Cancel any existing timer\n toast.timer?.cancel();\n\n if (this.hasExitAnimation && toast.animation !== \"queued\") {\n // Mark as exiting for animation\n this.queue = this.queue.map((t) =>\n t.key === key ? { ...t, timer: null, animation: \"exiting\" } : t,\n );\n this.notify(\"remove\");\n } else {\n // Remove immediately\n this.remove(key);\n }\n }\n\n /**\n * Remove a toast after exit animation completes.\n */\n remove(key: string): void {\n const toast = this.queue.find((t) => t.key === key);\n if (toast) {\n toast.onClose?.();\n toast.timer?.cancel();\n }\n\n this.queue = this.queue.filter((t) => t.key !== key);\n this.updateVisibility(\"remove\");\n }\n\n /**\n * Clear all queued and visible toasts.\n */\n clear(): void {\n for (const toast of this.queue) {\n toast.timer?.cancel();\n }\n\n this.queue = [];\n this.notify(\"clear\");\n }\n\n /**\n * Pause all toast timers.\n */\n pauseAll(): void {\n for (const toast of this.queue) {\n toast.timer?.pause();\n }\n }\n\n /**\n * Resume all toast timers.\n */\n resumeAll(): void {\n for (const toast of this.queue) {\n toast.timer?.resume();\n }\n }\n\n private updateVisibility(action: ToastAction): void {\n // Mark toasts as visible or queued based on maxVisibleToasts\n const visibleCount = this.queue.filter(\n (t) => t.animation !== \"queued\" && t.animation !== \"exiting\",\n ).length;\n\n let promoted = 0;\n this.queue = this.queue.map((toast) => {\n let nextToast = toast;\n\n if (nextToast.animation === \"queued\" && visibleCount + promoted < this.maxVisibleToasts) {\n nextToast = { ...nextToast, animation: \"entering\" };\n promoted++;\n }\n if (nextToast.animation === \"queued\") return nextToast;\n\n // Start timer for visible toasts\n if (\n nextToast.timeout != null &&\n nextToast.timer === null &&\n nextToast.animation !== \"exiting\"\n ) {\n nextToast = {\n ...nextToast,\n timer: new Timer(() => {\n this.close(nextToast.key);\n }, nextToast.timeout),\n };\n }\n\n return nextToast;\n });\n\n this.notify(action);\n }\n\n private notify(action: ToastAction = \"add\"): void {\n const toasts = [...this.queue];\n // The new visible toasts are computed synchronously above; only the subscriber\n // fan-out (which drives the re-render) is wrapped, so it can run inside a view\n // transition. Mirrors @react-stately/toast's updateVisibleToasts.\n this.runWithWrapUpdate(() => {\n for (const callback of this.subscriptions) {\n callback(toasts);\n }\n }, action);\n }\n}\n\n/**\n * Creates reactive toast state from a ToastQueue.\n * Use this hook to subscribe to toast changes in your component.\n */\nexport function createToastState<T>(props: ToastStateProps<T>): ToastState<T> {\n const [visibleToasts, setVisibleToasts] = createSignal<QueuedToast<T>[]>([]);\n\n // Subscribe to queue changes\n const unsubscribe = props.queue.subscribe((toasts) => {\n setVisibleToasts(toasts);\n });\n\n onCleanup(() => {\n unsubscribe();\n });\n\n return {\n visibleToasts,\n add: (content, options) => props.queue.add(content, options),\n close: (key) => props.queue.close(key),\n remove: (key) => props.queue.remove(key),\n clear: () => props.queue.clear(),\n pauseAll: () => props.queue.pauseAll(),\n resumeAll: () => props.queue.resumeAll(),\n };\n}\n\n/**\n * Creates a new ToastQueue and returns reactive state.\n * Use this if you don't need a global queue.\n */\nexport function createToastQueue<T>(\n options?: ToastQueueOptions,\n): ToastState<T> & { queue: ToastQueue<T> } {\n const queue = new ToastQueue<T>(options);\n const state = createToastState({ queue });\n return { ...state, queue };\n}\n","/**\n * Disclosure state management for SolidJS\n * Based on @react-stately/disclosure useDisclosureState and useDisclosureGroupState\n */\n\nimport { createSignal, createEffect, createMemo, type Accessor } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils\";\n\nexport interface DisclosureStateProps {\n /** Whether the disclosure is expanded (controlled). */\n isExpanded?: boolean;\n /** Whether the disclosure is expanded by default (uncontrolled). */\n defaultExpanded?: boolean;\n /** Handler that is called when the disclosure expanded state changes. */\n onExpandedChange?: (isExpanded: boolean) => void;\n}\n\nexport interface DisclosureState {\n /** Whether the disclosure is currently expanded. */\n readonly isExpanded: Accessor<boolean>;\n /** Sets whether the disclosure is expanded. */\n setExpanded(isExpanded: boolean): void;\n /** Expand the disclosure. */\n expand(): void;\n /** Collapse the disclosure. */\n collapse(): void;\n /** Toggles the disclosure's visibility. */\n toggle(): void;\n}\n\n/**\n * Manages state for a disclosure widget. Tracks whether the disclosure is expanded,\n * and provides methods to toggle this state.\n */\nexport function createDisclosureState(\n props: MaybeAccessor<DisclosureStateProps> = {},\n): DisclosureState {\n const propsAccessor = () => access(props);\n\n const [internalExpanded, setInternalExpanded] = createSignal(\n propsAccessor().defaultExpanded ?? false,\n );\n\n const isExpanded: Accessor<boolean> = () => {\n const p = propsAccessor();\n return p.isExpanded !== undefined ? p.isExpanded : internalExpanded();\n };\n\n const setExpanded = (expanded: boolean) => {\n const p = propsAccessor();\n if (p.isExpanded === undefined) {\n setInternalExpanded(expanded);\n }\n p.onExpandedChange?.(expanded);\n };\n\n const expand = () => setExpanded(true);\n const collapse = () => setExpanded(false);\n const toggle = () => setExpanded(!isExpanded());\n\n return {\n isExpanded,\n setExpanded,\n expand,\n collapse,\n toggle,\n };\n}\n\nexport type Key = string | number;\n\nexport interface DisclosureGroupStateProps {\n /** Whether multiple items can be expanded at the same time. */\n allowsMultipleExpanded?: boolean;\n /** Whether all items are disabled. */\n isDisabled?: boolean;\n /** The currently expanded keys in the group (controlled). */\n expandedKeys?: Iterable<Key>;\n /** The initial expanded keys in the group (uncontrolled). */\n defaultExpandedKeys?: Iterable<Key>;\n /** Handler that is called when items are expanded or collapsed. */\n onExpandedChange?: (keys: Set<Key>) => void;\n}\n\nexport interface DisclosureGroupState {\n /** Whether multiple items can be expanded at the same time. */\n readonly allowsMultipleExpanded: boolean;\n /** Whether all items are disabled. */\n readonly isDisabled: boolean;\n /** A set of keys for items that are expanded. */\n readonly expandedKeys: Accessor<Set<Key>>;\n /** Toggles the expanded state for an item by its key. */\n toggleKey(key: Key): void;\n /** Replaces the set of expanded keys. */\n setExpandedKeys(keys: Set<Key>): void;\n /** Check if a specific key is expanded. */\n isExpanded(key: Key): boolean;\n}\n\n/**\n * Manages state for a group of disclosures, e.g. an accordion.\n * It supports both single and multiple expanded items.\n */\nexport function createDisclosureGroupState(\n props: MaybeAccessor<DisclosureGroupStateProps> = {},\n): DisclosureGroupState {\n const propsAccessor = () => access(props);\n\n const [internalKeys, setInternalKeys] = createSignal<Set<Key>>(\n new Set(propsAccessor().defaultExpandedKeys ?? []),\n );\n\n const expandedKeys: Accessor<Set<Key>> = createMemo(() => {\n const p = propsAccessor();\n return p.expandedKeys !== undefined ? new Set(p.expandedKeys) : internalKeys();\n });\n\n const setExpandedKeys = (keys: Set<Key>) => {\n const p = propsAccessor();\n if (p.expandedKeys === undefined) {\n setInternalKeys(keys);\n }\n p.onExpandedChange?.(keys);\n };\n\n // Ensure only one item is expanded if allowsMultipleExpanded is false.\n createEffect(() => {\n const p = propsAccessor();\n const allowsMultiple = p.allowsMultipleExpanded ?? false;\n const keys = expandedKeys();\n\n if (!allowsMultiple && keys.size > 1) {\n // Use queueMicrotask to defer the update and avoid infinite effect loop\n const firstKey = keys.values().next().value;\n if (firstKey != null) {\n queueMicrotask(() => {\n setExpandedKeys(new Set([firstKey]));\n });\n }\n }\n });\n\n const toggleKey = (key: Key) => {\n const p = propsAccessor();\n const allowsMultiple = p.allowsMultipleExpanded ?? false;\n const currentKeys = expandedKeys();\n\n let newKeys: Set<Key>;\n if (allowsMultiple) {\n newKeys = new Set(currentKeys);\n if (newKeys.has(key)) {\n newKeys.delete(key);\n } else {\n newKeys.add(key);\n }\n } else {\n newKeys = new Set(currentKeys.has(key) ? [] : [key]);\n }\n\n setExpandedKeys(newKeys);\n };\n\n const isExpanded = (key: Key): boolean => {\n return expandedKeys().has(key);\n };\n\n return {\n get allowsMultipleExpanded() {\n return propsAccessor().allowsMultipleExpanded ?? false;\n },\n get isDisabled() {\n return propsAccessor().isDisabled ?? false;\n },\n expandedKeys,\n toggleKey,\n setExpandedKeys,\n isExpanded,\n };\n}\n","/**\n * Grid state management for Table and GridList components.\n * Based on @react-stately/grid/useGridState.\n */\n\nimport { createSignal, createEffect, createMemo, on, type Accessor } from \"solid-js\";\nimport type { GridState, GridStateOptions, GridCollection, GridNode } from \"./types\";\nimport type { Key, FocusStrategy, SelectionBehavior, Selection } from \"../collections/types\";\n\n/**\n * Creates state management for a grid component.\n * Handles row selection, focus management, and keyboard navigation state.\n */\nexport function createGridState<T extends object, C extends GridCollection<T> = GridCollection<T>>(\n options: Accessor<GridStateOptions<T, C>>,\n): GridState<T, C> {\n const getOptions = () => options();\n\n const disabledKeys = createMemo(() => {\n const keys = getOptions().disabledKeys;\n return keys ? new Set(keys) : new Set<Key>();\n });\n\n const [isFocused, setIsFocused] = createSignal(false);\n const [focusedKey, setFocusedKeyInternal] = createSignal<Key | null>(null);\n const [childFocusStrategy, setChildFocusStrategy] = createSignal<FocusStrategy | null>(null);\n const [isKeyboardNavigationDisabled, setKeyboardNavigationDisabled] = createSignal(false);\n\n const [internalSelectedKeys, setInternalSelectedKeys] = createSignal<\"all\" | Set<Key>>(\n getInitialSelection(getOptions().defaultSelectedKeys),\n );\n const [anchorKey, setAnchorKey] = createSignal<Key | null>(null);\n\n const selectedKeys = createMemo(() => {\n const opts = getOptions();\n if (opts.selectedKeys !== undefined) {\n return normalizeSelection(opts.selectedKeys);\n }\n return internalSelectedKeys();\n });\n\n const selectionMode = createMemo(() => getOptions().selectionMode ?? \"none\");\n const selectionBehaviorProp = (): SelectionBehavior => getOptions().selectionBehavior ?? \"toggle\";\n const [selectionBehaviorState, setSelectionBehaviorState] =\n createSignal<SelectionBehavior>(selectionBehaviorProp());\n const selectionBehavior = createMemo(() => selectionBehaviorState());\n const disallowEmptySelection = createMemo(() => getOptions().disallowEmptySelection ?? false);\n const disabledBehavior = createMemo(() => getOptions().disabledBehavior ?? \"all\");\n\n const focusMode = createMemo(() => getOptions().focusMode ?? \"row\");\n\n createEffect(\n on(selectionBehaviorProp, (behavior) => {\n setSelectionBehaviorState(behavior);\n }),\n );\n\n createEffect(() => {\n const keys = selectedKeys();\n if (\n selectionBehaviorProp() === \"replace\" &&\n selectionBehaviorState() === \"toggle\" &&\n keys !== \"all\" &&\n keys.size === 0\n ) {\n setSelectionBehaviorState(\"replace\");\n }\n });\n\n const setFocusedKey = (key: Key | null, strategy: FocusStrategy = \"first\") => {\n const opts = getOptions();\n const collection = opts.collection;\n\n // If focusMode is cell and an item is focused, focus a child cell instead\n if (focusMode() === \"cell\" && key != null) {\n const item = collection.getItem(key);\n if (item?.type === \"item\") {\n const children = [...collection.getChildren(key)];\n if (strategy === \"last\") {\n key = children[children.length - 1]?.key ?? key;\n } else {\n key = children[0]?.key ?? key;\n }\n }\n }\n\n setFocusedKeyInternal(key);\n setChildFocusStrategy(strategy);\n };\n\n // Reset focused key if the item is deleted from the collection\n let cachedCollection: C | null = null;\n\n createEffect(\n on(\n () => getOptions().collection,\n (collection) => {\n const currentFocusedKey = focusedKey();\n\n if (\n currentFocusedKey != null &&\n cachedCollection &&\n !collection.getItem(currentFocusedKey)\n ) {\n // The focused item was deleted, find a new one to focus\n const node = cachedCollection.getItem(currentFocusedKey);\n const parentNode =\n node?.parentKey != null &&\n (node.type === \"cell\" || node.type === \"rowheader\" || node.type === \"column\")\n ? cachedCollection.getItem(node.parentKey)\n : node;\n\n if (!parentNode) {\n setFocusedKeyInternal(null);\n cachedCollection = collection;\n return;\n }\n\n const cachedRows = cachedCollection.rows;\n const rows = collection.rows;\n const diff = cachedRows.length - rows.length;\n\n let index = Math.min(\n diff > 1 ? Math.max(parentNode.index - diff + 1, 0) : parentNode.index,\n rows.length - 1,\n );\n\n let newRow: GridNode<T> | null = null;\n while (index >= 0) {\n const row = rows[index];\n if (!disabledKeys().has(row.key) && row.type !== \"headerrow\") {\n newRow = row;\n break;\n }\n // Find next, not disabled row\n if (index < rows.length - 1) {\n index++;\n } else {\n // Otherwise, find previous, not disabled row\n if (index > parentNode.index) {\n index = parentNode.index;\n }\n index--;\n }\n }\n\n if (newRow) {\n const childNodes = newRow.hasChildNodes ? [...collection.getChildren(newRow.key)] : [];\n const keyToFocus =\n newRow.hasChildNodes && parentNode !== node && node && node.index < childNodes.length\n ? childNodes[node.index].key\n : newRow.key;\n setFocusedKeyInternal(keyToFocus);\n } else {\n setFocusedKeyInternal(null);\n }\n }\n\n cachedCollection = collection;\n },\n ),\n );\n\n // Selection methods\n const isSelected = (key: Key): boolean => {\n const keys = selectedKeys();\n if (keys === \"all\") return true;\n return keys.has(key);\n };\n\n const isDisabled = (key: Key): boolean => {\n return disabledKeys().has(key);\n };\n\n const updateSelection = (newSelection: \"all\" | Set<Key>) => {\n const opts = getOptions();\n\n // Controlled mode\n if (opts.selectedKeys !== undefined) {\n opts.onSelectionChange?.(newSelection);\n return;\n }\n\n // Uncontrolled mode\n const current = internalSelectedKeys();\n const isDifferent =\n current === \"all\" ||\n newSelection === \"all\" ||\n current.size !== (newSelection as Set<Key>).size ||\n ![...current].every((k) => (newSelection as Set<Key>).has(k));\n\n if (isDifferent) {\n setInternalSelectedKeys(newSelection);\n opts.onSelectionChange?.(newSelection);\n }\n };\n\n const toggleSelection = (key: Key) => {\n if (isDisabled(key)) return;\n if (selectionMode() === \"none\") return;\n\n const current = selectedKeys();\n\n if (selectionMode() === \"single\") {\n if (isSelected(key) && !disallowEmptySelection()) {\n updateSelection(new Set());\n } else {\n updateSelection(new Set([key]));\n }\n return;\n }\n\n // Multiple selection\n if (current === \"all\") {\n // Can't toggle when all selected without knowing all keys\n return;\n }\n\n const newSelection = new Set(current);\n if (newSelection.has(key)) {\n if (newSelection.size > 1 || !disallowEmptySelection()) {\n newSelection.delete(key);\n }\n } else {\n newSelection.add(key);\n }\n\n updateSelection(newSelection);\n setAnchorKey(key);\n };\n\n const replaceSelection = (key: Key) => {\n if (isDisabled(key)) return;\n if (selectionMode() === \"none\") return;\n\n updateSelection(new Set([key]));\n setAnchorKey(key);\n };\n\n const setSelectedKeys = (keys: Selection | Iterable<Key>) => {\n updateSelection(normalizeSelection(keys));\n };\n\n const extendSelection = (toKey: Key) => {\n if (isDisabled(toKey)) return;\n if (selectionMode() !== \"multiple\") {\n replaceSelection(toKey);\n return;\n }\n\n const anchor = anchorKey();\n if (!anchor) {\n replaceSelection(toKey);\n return;\n }\n\n const collection = getOptions().collection;\n const rows = collection.rows.filter((r) => r.type === \"item\");\n const keys = rows.map((r) => r.key);\n const anchorIndex = keys.indexOf(anchor);\n const toIndex = keys.indexOf(toKey);\n\n if (anchorIndex === -1 || toIndex === -1) {\n replaceSelection(toKey);\n return;\n }\n\n const start = Math.min(anchorIndex, toIndex);\n const end = Math.max(anchorIndex, toIndex);\n const rangeKeys = keys.slice(start, end + 1).filter((k) => !isDisabled(k));\n\n updateSelection(new Set(rangeKeys));\n };\n\n const selectAll = () => {\n if (selectionMode() !== \"multiple\") return;\n updateSelection(\"all\");\n };\n\n const clearSelection = () => {\n if (disallowEmptySelection()) return;\n updateSelection(new Set());\n };\n\n const toggleSelectAll = () => {\n if (selectionMode() !== \"multiple\") return;\n\n if (selectedKeys() === \"all\") {\n clearSelection();\n } else {\n selectAll();\n }\n };\n\n return {\n get collection() {\n return getOptions().collection;\n },\n get disabledKeys() {\n return disabledKeys();\n },\n get disabledBehavior() {\n return disabledBehavior();\n },\n get isKeyboardNavigationDisabled() {\n return isKeyboardNavigationDisabled();\n },\n get focusedKey() {\n return focusedKey();\n },\n get childFocusStrategy() {\n return childFocusStrategy();\n },\n get isFocused() {\n return isFocused();\n },\n get selectionMode() {\n return selectionMode();\n },\n get selectionBehavior() {\n return selectionBehavior();\n },\n get disallowEmptySelection() {\n return disallowEmptySelection();\n },\n get selectedKeys() {\n return selectedKeys();\n },\n isSelected,\n isDisabled,\n setFocusedKey,\n setFocused: setIsFocused,\n setSelectionBehavior: setSelectionBehaviorState,\n toggleSelection,\n replaceSelection,\n setSelectedKeys,\n extendSelection,\n selectAll,\n clearSelection,\n toggleSelectAll,\n setKeyboardNavigationDisabled,\n };\n}\n\n// Helper functions\nfunction getInitialSelection(defaultKeys?: \"all\" | Iterable<Key>): \"all\" | Set<Key> {\n if (defaultKeys === undefined) return new Set();\n return normalizeSelection(defaultKeys);\n}\n\nfunction normalizeSelection(keys: \"all\" | Iterable<Key>): \"all\" | Set<Key> {\n if (keys === \"all\") return \"all\";\n return new Set(keys);\n}\n","/**\n * Table state management for Table components.\n * Based on @react-stately/table/useTableState.\n */\n\nimport { createMemo, type Accessor } from \"solid-js\";\nimport { createGridState } from \"../grid/createGridState\";\nimport type { Key } from \"../collections/types\";\nimport type {\n TableState,\n TableStateOptions,\n TableCollection,\n SortDescriptor,\n SortDirection,\n} from \"./types\";\n\nconst OPPOSITE_SORT_DIRECTION: Record<SortDirection, SortDirection> = {\n ascending: \"descending\",\n descending: \"ascending\",\n};\n\n/**\n * Creates state management for a table component.\n * Extends grid state with sorting and table-specific features.\n */\nexport function createTableState<\n T extends object,\n C extends TableCollection<T> = TableCollection<T>,\n>(options: Accessor<TableStateOptions<T, C>>): TableState<T, C> {\n const getOptions = () => options();\n\n // Create the underlying grid state\n const gridState = createGridState<T, C>(() => ({\n collection: getOptions().collection,\n disabledKeys: getOptions().disabledKeys,\n disabledBehavior: getOptions().disabledBehavior,\n focusMode: getOptions().focusMode,\n selectionMode: getOptions().selectionMode,\n selectionBehavior: getOptions().selectionBehavior,\n disallowEmptySelection: getOptions().disallowEmptySelection,\n selectedKeys: getOptions().selectedKeys,\n defaultSelectedKeys: getOptions().defaultSelectedKeys,\n onSelectionChange: getOptions().onSelectionChange,\n }));\n\n // Memoized sort descriptor\n const sortDescriptor = createMemo<SortDescriptor | null>(() => {\n return getOptions().sortDescriptor ?? null;\n });\n\n // Show selection checkboxes\n const showSelectionCheckboxes = createMemo(() => {\n return getOptions().showSelectionCheckboxes ?? false;\n });\n\n // Sort function\n const sort = (columnKey: Key, direction?: SortDirection) => {\n const opts = getOptions();\n const currentSort = opts.sortDescriptor;\n\n // Determine direction\n let newDirection: SortDirection;\n if (direction) {\n newDirection = direction;\n } else if (currentSort?.column === columnKey) {\n // Toggle direction if sorting same column\n newDirection = OPPOSITE_SORT_DIRECTION[currentSort.direction];\n } else {\n // Default to ascending for new column\n newDirection = \"ascending\";\n }\n\n opts.onSortChange?.({\n column: columnKey,\n direction: newDirection,\n });\n };\n\n return {\n // Forward grid state properties\n get collection() {\n return getOptions().collection;\n },\n get disabledKeys() {\n return gridState.disabledKeys;\n },\n get disabledBehavior() {\n return gridState.disabledBehavior;\n },\n get isKeyboardNavigationDisabled() {\n return gridState.isKeyboardNavigationDisabled;\n },\n get focusedKey() {\n return gridState.focusedKey;\n },\n get childFocusStrategy() {\n return gridState.childFocusStrategy;\n },\n get isFocused() {\n return gridState.isFocused;\n },\n get selectionMode() {\n return gridState.selectionMode;\n },\n get selectionBehavior() {\n return gridState.selectionBehavior;\n },\n get disallowEmptySelection() {\n return gridState.disallowEmptySelection;\n },\n get selectedKeys() {\n return gridState.selectedKeys;\n },\n\n // Grid state methods\n isSelected: gridState.isSelected,\n isDisabled: gridState.isDisabled,\n setFocusedKey: gridState.setFocusedKey,\n setFocused: gridState.setFocused,\n toggleSelection: gridState.toggleSelection,\n replaceSelection: gridState.replaceSelection,\n setSelectionBehavior: gridState.setSelectionBehavior,\n setSelectedKeys: gridState.setSelectedKeys,\n extendSelection: gridState.extendSelection,\n selectAll: gridState.selectAll,\n clearSelection: gridState.clearSelection,\n toggleSelectAll: gridState.toggleSelectAll,\n setKeyboardNavigationDisabled: gridState.setKeyboardNavigationDisabled,\n\n // Table-specific properties\n get showSelectionCheckboxes() {\n return showSelectionCheckboxes();\n },\n get sortDescriptor() {\n return sortDescriptor();\n },\n sort,\n\n // A plain table has no expandable rows.\n get expandedKeys(): \"all\" | Set<Key> {\n return EMPTY_EXPANDED_KEYS;\n },\n get treeColumn(): Key | null {\n return getOptions().collection.treeColumn ?? null;\n },\n toggleKey: () => {},\n };\n}\n\nconst EMPTY_EXPANDED_KEYS: Set<Key> = new Set();\n","/**\n * TableCollection - A collection class for table data.\n * Based on @react-stately/table/TableCollection.\n *\n * Supports a plain (flat) table and, when an `expandedKeys` option is supplied, a\n * tree grid: `childRows` are walked recursively, each parent row keeps its full\n * structure (cells followed by every child row), and only rows whose ancestors are\n * all expanded are flattened into the navigable body. Mirrors the structure produced\n * by `@react-stately/table`'s `generateTreeGridCollection`.\n */\n\nimport type { Key } from \"../collections/types\";\nimport type { GridNode, GridNodeType } from \"../grid/types\";\nimport type {\n TableCollection as ITableCollection,\n TableCollectionOptions,\n ColumnDefinition,\n RowDefinition,\n} from \"./types\";\n\n/**\n * Creates a table collection from column and row definitions.\n */\nexport class TableCollection<T = unknown> implements ITableCollection<T> {\n private _columns: GridNode<T>[] = [];\n private _rows: GridNode<T>[] = [];\n private _headerRows: GridNode<T>[] = [];\n private _body: GridNode<T>;\n private _head: GridNode<T> | undefined;\n private _keyMap: Map<Key, GridNode<T>> = new Map();\n private _rowHeaderColumnKeys: Set<Key>;\n private _size: number = 0;\n /** Visible rows in DFS order. Drives size, navigation, iteration and the `rows` list. */\n private _flattenedRows: GridNode<T>[] = [];\n private _treeColumn: Key | null = null;\n private _userColumnCount: number = 0;\n\n constructor(options: TableCollectionOptions<T>) {\n const {\n columns,\n rows,\n getKey,\n getTextValue,\n showSelectionCheckboxes = false,\n rowHeaderColumnKeys,\n expandedKeys,\n } = options;\n\n // Passing `expandedKeys` (even an empty set) selects tree-grid mode.\n const isTreeGrid = expandedKeys !== undefined;\n\n this._columns = this.buildColumns(columns, showSelectionCheckboxes);\n\n this._rowHeaderColumnKeys = rowHeaderColumnKeys ?? this.getDefaultRowHeaderColumnKeys();\n\n this._headerRows = this.buildHeaderRows();\n\n if (this._headerRows.length > 0) {\n this._head = {\n type: \"headerrow\" as GridNodeType,\n key: \"header\",\n index: 0,\n level: 0,\n hasChildNodes: true,\n childNodes: this._headerRows,\n value: null,\n textValue: \"\",\n };\n this._keyMap.set(\"header\", this._head);\n }\n\n let bodyChildren: GridNode<T>[];\n if (isTreeGrid) {\n const built = this.buildTreeRows(rows, expandedKeys, getKey, getTextValue);\n bodyChildren = built.topLevelRows;\n this._flattenedRows = built.flattenedRows;\n this._userColumnCount = this.countLeafColumns();\n this._treeColumn =\n options.treeColumn !== undefined\n ? options.treeColumn\n : (this._rowHeaderColumnKeys.values().next().value ?? null);\n } else {\n const bodyRows = this.buildRows(rows, getKey, getTextValue);\n bodyChildren = bodyRows;\n this._flattenedRows = bodyRows;\n this._userColumnCount = this.countLeafColumns();\n this._treeColumn = null;\n }\n\n this._size = this._flattenedRows.length;\n\n this._body = {\n type: \"item\" as GridNodeType,\n key: \"body\",\n index: this._headerRows.length,\n level: 0,\n hasChildNodes: true,\n // The body's children retain the full tree structure (top-level rows with their\n // child rows nested inside) so sibling-based aria-posinset/aria-setsize work; the\n // flattened visible list lives in `_flattenedRows`. For a flat table these are the\n // same array.\n childNodes: bodyChildren,\n value: null,\n textValue: \"\",\n };\n this._keyMap.set(\"body\", this._body);\n\n this._rows = [...this._headerRows, ...this._flattenedRows];\n }\n\n private buildColumns(\n columns: ColumnDefinition<T>[],\n showSelectionCheckboxes: boolean,\n ): GridNode<T>[] {\n const result: GridNode<T>[] = [];\n let colIndex = 0;\n\n if (showSelectionCheckboxes) {\n const selectionColumn: GridNode<T> = {\n type: \"column\" as GridNodeType,\n key: \"__selection__\",\n index: colIndex,\n column: 0,\n level: 0,\n hasChildNodes: false,\n childNodes: [],\n value: null,\n textValue: \"Selection\",\n };\n result.push(selectionColumn);\n this._keyMap.set(selectionColumn.key, selectionColumn);\n colIndex++;\n }\n\n for (const col of columns) {\n const node = this.buildColumnNode(col, colIndex);\n result.push(node);\n colIndex++;\n }\n\n return result;\n }\n\n private buildColumnNode(col: ColumnDefinition<T>, index: number): GridNode<T> {\n const key = col.key ?? (col as ColumnDefinition<T> & { id?: Key }).id ?? index;\n const node: GridNode<T> = {\n type: \"column\" as GridNodeType,\n key,\n index,\n column: index,\n level: 0,\n hasChildNodes: (col.children?.length ?? 0) > 0,\n childNodes: [],\n value: null,\n props: { columnDefinition: { ...col, key } },\n textValue: col.textValue ?? col.name ?? String(key),\n };\n\n if (col.children && col.children.length > 0) {\n let childIndex = 0;\n for (const child of col.children) {\n const childNode = this.buildColumnNode(child, childIndex);\n childNode.parentKey = key;\n childNode.level = 1;\n node.childNodes.push(childNode);\n childIndex++;\n }\n }\n\n this._keyMap.set(node.key, node);\n return node;\n }\n\n private getDefaultRowHeaderColumnKeys(): Set<Key> {\n const explicitRowHeaderKeys = this._columns\n .filter((col) => col.key !== \"__selection__\")\n .filter((col) => {\n const definition = col.props?.columnDefinition as ColumnDefinition<T> | undefined;\n return !!definition?.isRowHeader;\n })\n .map((col) => col.key);\n\n if (explicitRowHeaderKeys.length > 0) {\n return new Set(explicitRowHeaderKeys);\n }\n\n // Default to first non-selection column as row header.\n for (const col of this._columns) {\n if (col.key !== \"__selection__\") {\n return new Set([col.key]);\n }\n }\n return new Set();\n }\n\n /** Counts the leaf columns supplied by the user (excludes the selection column). */\n private countLeafColumns(): number {\n let count = 0;\n const visit = (col: GridNode<T>) => {\n if (col.key === \"__selection__\") {\n return;\n }\n if (col.childNodes.length > 0) {\n col.childNodes.forEach(visit);\n } else {\n count++;\n }\n };\n this._columns.forEach(visit);\n return count;\n }\n\n private buildHeaderRows(): GridNode<T>[] {\n if (this._columns.length === 0) {\n return [];\n }\n\n const headerCells: GridNode<T>[] = this._columns.map((col, index) => ({\n type: \"column\" as GridNodeType,\n key: `header-${col.key}`,\n index,\n column: index,\n level: 1,\n hasChildNodes: false,\n childNodes: [],\n value: null,\n textValue: col.textValue,\n parentKey: \"headerrow-0\",\n }));\n\n const headerRow: GridNode<T> = {\n type: \"headerrow\" as GridNodeType,\n key: \"headerrow-0\",\n index: 0,\n rowIndex: 0,\n level: 0,\n hasChildNodes: true,\n childNodes: headerCells,\n value: null,\n textValue: \"\",\n };\n\n this._keyMap.set(headerRow.key, headerRow);\n headerCells.forEach((cell) => this._keyMap.set(cell.key, cell));\n\n return [headerRow];\n }\n\n /**\n * Builds the cell nodes for one row. Does not register the cells in the key map;\n * the caller registers cells once the owning row is known to be present.\n */\n private buildCells(\n rowKey: Key,\n value: T,\n rowLevel: number,\n getTextValue?: (item: T, column: ColumnDefinition<T>) => string,\n ): GridNode<T>[] {\n return this._columns.map((col, colIndex) => {\n const cellKey = `${rowKey}-${col.key}`;\n const columnDefinition =\n (col.props?.columnDefinition as ColumnDefinition<T> | undefined) ??\n ({ key: col.key } as ColumnDefinition<T>);\n const cellTextValue =\n col.key === \"__selection__\"\n ? \"Selection\"\n : getTextValue\n ? getTextValue(value, columnDefinition)\n : String((value as Record<string, unknown>)?.[String(col.key)] ?? \"\");\n\n const cell: GridNode<T> = {\n type: this._rowHeaderColumnKeys.has(col.key)\n ? (\"rowheader\" as GridNodeType)\n : (\"cell\" as GridNodeType),\n key: cellKey,\n index: colIndex,\n column: colIndex,\n level: rowLevel + 1,\n hasChildNodes: false,\n childNodes: [],\n value,\n textValue: cellTextValue,\n parentKey: rowKey,\n };\n\n return cell;\n });\n }\n\n private buildRows(\n rows: RowDefinition<T>[] | T[],\n getKey?: (item: T) => Key,\n getTextValue?: (item: T, column: ColumnDefinition<T>) => string,\n ): GridNode<T>[] {\n const result: GridNode<T>[] = [];\n const rowIndexOffset = this._headerRows.length;\n\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i];\n const isRowDef = this.isRowDefinition(row);\n\n const key = isRowDef ? row.key : (getKey?.(row as T) ?? i);\n const value = isRowDef ? row.value : (row as T);\n const textValue = isRowDef\n ? row.textValue\n : typeof (row as Record<string, unknown>)?.textValue === \"string\"\n ? ((row as Record<string, unknown>).textValue as string)\n : undefined;\n\n const cells = this.buildCells(key, value as T, 0, getTextValue);\n cells.forEach((cell) => this._keyMap.set(cell.key, cell));\n\n const rowNode: GridNode<T> = {\n type: \"item\" as GridNodeType,\n key,\n index: i,\n rowIndex: rowIndexOffset + i,\n level: 0,\n hasChildNodes: true,\n childNodes: cells,\n value,\n textValue: textValue ?? cells.map((c) => c.textValue).join(\" \"),\n };\n\n this._keyMap.set(key, rowNode);\n result.push(rowNode);\n }\n\n return result;\n }\n\n /**\n * Builds the tree-grid rows: every row keeps its full structure (cells then all child\n * rows, expanded or not) while only the rows whose ancestors are all expanded are\n * registered in the key map and pushed into the flattened body. Mirrors\n * `generateTreeGridCollection` upstream.\n */\n private buildTreeRows(\n rows: RowDefinition<T>[] | T[],\n expandedKeys: \"all\" | Set<Key>,\n getKey?: (item: T) => Key,\n getTextValue?: (item: T, column: ColumnDefinition<T>) => string,\n ): { topLevelRows: GridNode<T>[]; flattenedRows: GridNode<T>[] } {\n const isExpanded = (key: Key): boolean => expandedKeys === \"all\" || expandedKeys.has(key);\n\n // Build the full tree structure without touching the key map. `index` is the row's\n // position among its same-level siblings, so aria-posinset/aria-setsize read directly.\n const buildRowNode = (\n row: RowDefinition<T> | T,\n level: number,\n parentKey: Key | null,\n indexAmongSiblings: number,\n ): GridNode<T> => {\n const isRowDef = this.isRowDefinition(row);\n const key = isRowDef ? row.key : (getKey?.(row as T) ?? indexAmongSiblings);\n const value = (isRowDef ? row.value : (row as T)) as T;\n const textValue = isRowDef\n ? row.textValue\n : typeof (row as Record<string, unknown>)?.textValue === \"string\"\n ? ((row as Record<string, unknown>).textValue as string)\n : undefined;\n\n const cells = this.buildCells(key, value, level, getTextValue);\n\n const childRowDefs = isRowDef ? (row.childRows ?? []) : [];\n const hasChildRows = childRowDefs.length > 0 || (isRowDef && !!row.hasChildRows);\n\n const childRowNodes = childRowDefs.map((child, childIdx) =>\n buildRowNode(child, level + 1, key, childIdx),\n );\n\n const childNodes = [...cells, ...childRowNodes];\n const rowNode: GridNode<T> = {\n type: \"item\" as GridNodeType,\n key,\n index: indexAmongSiblings,\n level,\n parentKey,\n hasChildNodes: true,\n childNodes,\n value,\n textValue: textValue ?? cells.map((c) => c.textValue).join(\" \"),\n isExpandable: hasChildRows,\n isExpanded: hasChildRows && isExpanded(key),\n firstChildKey: childNodes[0]?.key ?? null,\n lastChildKey: childNodes[childNodes.length - 1]?.key ?? null,\n };\n\n return rowNode;\n };\n\n const topLevelRows = rows.map((row, i) => buildRowNode(row, 0, \"body\", i));\n\n // Flatten the visible rows (DFS). A row is visited iff every ancestor is expanded;\n // visiting a row registers it and its cells, then descends into its child rows only\n // when the row itself is expanded.\n const flattenedRows: GridNode<T>[] = [];\n const rowIndexOffset = this._headerRows.length;\n const visit = (node: GridNode<T>) => {\n node.rowIndex = rowIndexOffset + flattenedRows.length;\n flattenedRows.push(node);\n this._keyMap.set(node.key, node);\n for (const child of node.childNodes) {\n if (child.type !== \"item\") {\n this._keyMap.set(child.key, child);\n }\n }\n if (isExpanded(node.key)) {\n for (const child of node.childNodes) {\n if (child.type === \"item\") {\n visit(child);\n }\n }\n }\n };\n for (const node of topLevelRows) {\n visit(node);\n }\n\n return { topLevelRows, flattenedRows };\n }\n\n private isRowDefinition(row: unknown): row is RowDefinition<T> {\n return typeof row === \"object\" && row !== null && \"key\" in row && \"value\" in row;\n }\n\n get size(): number {\n return this._size;\n }\n\n get rows(): GridNode<T>[] {\n return this._rows;\n }\n\n get columns(): GridNode<T>[] {\n return this._columns;\n }\n\n get headerRows(): GridNode<T>[] {\n return this._headerRows;\n }\n\n get head(): GridNode<T> | undefined {\n return this._head;\n }\n\n get body(): GridNode<T> {\n return this._body;\n }\n\n get rowCount(): number {\n return this._rows.length;\n }\n\n get columnCount(): number {\n return this._columns.length;\n }\n\n get rowHeaderColumnKeys(): Set<Key> {\n return this._rowHeaderColumnKeys;\n }\n\n /** The key of the column that renders the tree-grid affordance, or `null` for a flat table. */\n get treeColumn(): Key | null {\n return this._treeColumn;\n }\n\n /** The number of leaf columns provided by the user (excludes the selection column). */\n get userColumnCount(): number {\n return this._userColumnCount;\n }\n\n /** The key map of all present nodes (visible rows, their cells, columns and the body). */\n get keyMap(): Map<Key, GridNode<T>> {\n return this._keyMap;\n }\n\n getKeys(): Iterable<Key> {\n return this._keyMap.keys();\n }\n\n getItem(key: Key): GridNode<T> | null {\n return this._keyMap.get(key) ?? null;\n }\n\n at(index: number): GridNode<T> | null {\n if (index < 0 || index >= this._flattenedRows.length) {\n return null;\n }\n return this._flattenedRows[index];\n }\n\n getChildren(key: Key): Iterable<GridNode<T>> {\n const node = this._keyMap.get(key);\n return node?.childNodes ?? [];\n }\n\n getTextValue(key: Key): string {\n const node = this._keyMap.get(key);\n return node?.textValue ?? \"\";\n }\n\n getCell(rowKey: Key, columnKey: Key): GridNode<T> | null {\n const cellKey = `${rowKey}-${columnKey}`;\n return this._keyMap.get(cellKey) ?? null;\n }\n\n getFirstKey(): Key | null {\n const bodyRows = this._flattenedRows;\n return bodyRows.length > 0 ? bodyRows[0].key : null;\n }\n\n getLastKey(): Key | null {\n const bodyRows = this._flattenedRows;\n return bodyRows.length > 0 ? bodyRows[bodyRows.length - 1].key : null;\n }\n\n getKeyBefore(key: Key): Key | null {\n const node = this._keyMap.get(key);\n if (!node) return null;\n\n const bodyRows = this._flattenedRows;\n const index = bodyRows.findIndex((r) => r.key === key);\n if (index > 0) {\n return bodyRows[index - 1].key;\n }\n return null;\n }\n\n getKeyAfter(key: Key): Key | null {\n const node = this._keyMap.get(key);\n if (!node) return null;\n\n const bodyRows = this._flattenedRows;\n const index = bodyRows.findIndex((r) => r.key === key);\n if (index >= 0 && index < bodyRows.length - 1) {\n return bodyRows[index + 1].key;\n }\n return null;\n }\n\n *[Symbol.iterator](): Iterator<GridNode<T>> {\n // Only iterate visible body rows, not header rows.\n for (const row of this._flattenedRows) {\n yield row;\n }\n }\n}\n\n/**\n * Creates a table collection from options.\n */\nexport function createTableCollection<T>(options: TableCollectionOptions<T>): TableCollection<T> {\n return new TableCollection(options);\n}\n","/**\n * Tree grid state management for expandable Table rows.\n * Based on @react-stately/table/useTreeGridState (the `UNSTABLE_` tree-grid feature).\n *\n * Owns the expanded-keys signal (controlled or uncontrolled), rebuilds the table\n * collection from it, and layers the expansion API on top of {@link createTableState}.\n */\n\nimport { createMemo, createSignal, type Accessor } from \"solid-js\";\nimport { createTableState } from \"./createTableState\";\nimport { createTableCollection, TableCollection } from \"./TableCollection\";\nimport type { Key } from \"../collections/types\";\nimport type { TreeGridState, TreeGridStateOptions } from \"./types\";\n\n/**\n * Creates state management for a tree grid (a table with expandable rows). Handles the\n * expanded rows in addition to the selection, sort and focus handled by the table state.\n */\nexport function createTreeGridState<\n T extends object,\n C extends TableCollection<T> = TableCollection<T>,\n>(options: Accessor<TreeGridStateOptions<T, C>>): TreeGridState<T, C> {\n const getOptions = () => options();\n\n // Expanded keys: controlled via `UNSTABLE_expandedKeys`, otherwise the internal signal\n // seeded from `UNSTABLE_defaultExpandedKeys`.\n const [internalExpandedKeys, setInternalExpandedKeys] = createSignal<\"all\" | Set<Key>>(\n getInitialExpanded(getOptions().UNSTABLE_defaultExpandedKeys),\n );\n\n const expandedKeys = createMemo<\"all\" | Set<Key>>(() => {\n const controlled = getOptions().UNSTABLE_expandedKeys;\n if (controlled !== undefined) {\n return convertExpanded(controlled);\n }\n return internalExpandedKeys();\n });\n\n // Rebuild the tree collection whenever the expanded keys (or the data) change.\n const collection = createMemo(\n () =>\n createTableCollection<T>({\n columns: getOptions().columns,\n rows: getOptions().rows,\n getKey: getOptions().getKey,\n getTextValue: getOptions().getTextValue,\n showSelectionCheckboxes: getOptions().showSelectionCheckboxes ?? false,\n rowHeaderColumnKeys: getOptions().rowHeaderColumnKeys,\n expandedKeys: expandedKeys(),\n }) as unknown as C,\n );\n\n const tableState = createTableState<T, C>(() => ({\n collection: collection(),\n disabledKeys: getOptions().disabledKeys,\n focusMode: getOptions().focusMode,\n selectionMode: getOptions().selectionMode,\n selectionBehavior: getOptions().selectionBehavior,\n disallowEmptySelection: getOptions().disallowEmptySelection,\n selectedKeys: getOptions().selectedKeys,\n defaultSelectedKeys: getOptions().defaultSelectedKeys,\n onSelectionChange: getOptions().onSelectionChange,\n sortDescriptor: getOptions().sortDescriptor,\n onSortChange: getOptions().onSortChange,\n showSelectionCheckboxes: getOptions().showSelectionCheckboxes,\n }));\n\n const toggleKey = (key: Key) => {\n const updated = toggleExpandedKey(expandedKeys(), key, collection());\n\n // Only own the value when uncontrolled.\n if (getOptions().UNSTABLE_expandedKeys === undefined) {\n setInternalExpandedKeys(updated);\n }\n getOptions().UNSTABLE_onExpandedChange?.(updated);\n };\n\n // Layer the expansion API onto the table state object, preserving the reactive getters\n // already defined on it (spreading would eagerly evaluate them and break reactivity).\n const treeGridState = tableState as TreeGridState<T, C>;\n Object.defineProperty(treeGridState, \"expandedKeys\", {\n get: () => expandedKeys(),\n configurable: true,\n enumerable: true,\n });\n Object.defineProperty(treeGridState, \"treeColumn\", {\n get: () => collection().treeColumn ?? null,\n configurable: true,\n enumerable: true,\n });\n Object.defineProperty(treeGridState, \"keyMap\", {\n get: () => collection().keyMap,\n configurable: true,\n enumerable: true,\n });\n Object.defineProperty(treeGridState, \"userColumnCount\", {\n get: () => collection().userColumnCount,\n configurable: true,\n enumerable: true,\n });\n treeGridState.toggleKey = toggleKey;\n\n return treeGridState;\n}\n\n/**\n * Computes the next expanded-key set when a row is toggled. Mirrors the upstream\n * `toggleKey`: collapsing from `'all'` materialises every expandable row first.\n */\nfunction toggleExpandedKey<T>(\n current: \"all\" | Set<Key>,\n key: Key,\n collection: TableCollection<T>,\n): Set<Key> {\n let updated: Set<Key>;\n if (current === \"all\") {\n updated = new Set(\n collection.rows\n .filter((row) => row.type === \"item\" && row.isExpandable)\n .map((row) => row.key),\n );\n updated.delete(key);\n } else {\n updated = new Set(current);\n if (updated.has(key)) {\n updated.delete(key);\n } else {\n updated.add(key);\n }\n }\n return updated;\n}\n\nfunction getInitialExpanded(defaultExpanded?: \"all\" | Iterable<Key>): \"all\" | Set<Key> {\n if (defaultExpanded === undefined) {\n return new Set();\n }\n return convertExpanded(defaultExpanded);\n}\n\nfunction convertExpanded(expanded: \"all\" | Iterable<Key>): \"all\" | Set<Key> {\n if (!expanded) {\n return new Set<Key>();\n }\n return expanded === \"all\" ? \"all\" : new Set(expanded);\n}\n","/**\n * Table column resize state management.\n * Based on @react-stately/table/useTableColumnResizeState.\n *\n * Provides column width state management for a table with column resizing.\n * Tracks column widths, the currently resizing column, and handles\n * width distribution and clamping.\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport type { Key } from \"../collections/types\";\n\n/** Column size: a number (px) or a string ('100px', '50%', '1fr'). */\nexport type ColumnSize = number | string;\n\nexport interface ColumnResizeDefinition {\n /** The column key. */\n key: Key;\n /** The width of the column. Numbers are px, strings can be 'Xfr', 'Xpx', or 'X%'. */\n width?: ColumnSize;\n /** Minimum width in pixels. Default: 75. */\n minWidth?: number;\n /** Maximum width in pixels. Default: Infinity. */\n maxWidth?: number;\n}\n\nexport interface TableColumnResizeStateProps {\n /** Current width of the table or table viewport. */\n tableWidth: number;\n /** Column definitions with width/min/max. */\n columns: ColumnResizeDefinition[];\n}\n\nexport interface TableColumnResizeState {\n /** The key of the column currently being resized, or null. */\n readonly resizingColumn: Accessor<Key | null>;\n /** A reactive map of computed column widths in pixels. */\n readonly columnWidths: Accessor<Map<Key, number>>;\n /** Begin a resize operation for the given column. */\n startResize(key: Key): void;\n /** End the current resize operation. */\n endResize(): void;\n /** Update column widths during a resize drag. Returns the new widths map. */\n updateResizedColumns(key: Key, width: number): Map<Key, number>;\n /** Get the current computed width for a column. */\n getColumnWidth(key: Key): number;\n /** Get the minimum width for a column. */\n getColumnMinWidth(key: Key): number;\n /** Get the maximum width for a column. */\n getColumnMaxWidth(key: Key): number;\n}\n\nconst DEFAULT_MIN_WIDTH = 75;\nconst DEFAULT_MAX_WIDTH = Infinity;\n\ninterface ParsedColumn {\n key: Key;\n /** Fraction units (from 'Xfr' or unspecified width). 0 if fixed. */\n fr: number;\n /** Fixed pixel width, or 0 if fractional. */\n fixedPx: number;\n minWidth: number;\n maxWidth: number;\n}\n\nfunction parseColumnDef(col: ColumnResizeDefinition, tableWidth: number): ParsedColumn {\n const minWidth = col.minWidth ?? DEFAULT_MIN_WIDTH;\n const maxWidth = col.maxWidth ?? DEFAULT_MAX_WIDTH;\n\n if (col.width == null) {\n // Default: 1fr\n return { key: col.key, fr: 1, fixedPx: 0, minWidth, maxWidth };\n }\n\n if (typeof col.width === \"number\") {\n return { key: col.key, fr: 0, fixedPx: col.width, minWidth, maxWidth };\n }\n\n const str = col.width.trim();\n\n // Fractional: '2fr', '1.5fr'\n if (str.endsWith(\"fr\")) {\n const val = parseFloat(str);\n return { key: col.key, fr: isNaN(val) ? 1 : val, fixedPx: 0, minWidth, maxWidth };\n }\n\n // Percentage: '25%'\n if (str.endsWith(\"%\")) {\n const pct = parseFloat(str);\n const px = isNaN(pct) ? 0 : (pct / 100) * tableWidth;\n return { key: col.key, fr: 0, fixedPx: px, minWidth, maxWidth };\n }\n\n // Pixel: '200px' or just a numeric string\n const px = parseFloat(str);\n return { key: col.key, fr: 0, fixedPx: isNaN(px) ? 0 : px, minWidth, maxWidth };\n}\n\n/**\n * Distribute `tableWidth` among columns:\n * 1. Fixed-width columns get their declared width (clamped to min/max).\n * 2. Remaining space is distributed among fractional columns proportionally.\n */\nfunction distributeWidths(columns: ColumnResizeDefinition[], tableWidth: number): Map<Key, number> {\n const parsed = columns.map((c) => parseColumnDef(c, tableWidth));\n\n // Pass 1 — allocate fixed columns\n let usedSpace = 0;\n let totalFr = 0;\n for (const p of parsed) {\n if (p.fr > 0) {\n totalFr += p.fr;\n } else {\n const w = Math.max(p.minWidth, Math.min(p.maxWidth, p.fixedPx));\n usedSpace += w;\n }\n }\n\n const remainingSpace = Math.max(0, tableWidth - usedSpace);\n const perFr = totalFr > 0 ? remainingSpace / totalFr : 0;\n\n // Pass 2 — build map\n const widths = new Map<Key, number>();\n for (const p of parsed) {\n let w: number;\n if (p.fr > 0) {\n w = p.fr * perFr;\n } else {\n w = p.fixedPx;\n }\n // Clamp\n w = Math.max(p.minWidth, Math.min(p.maxWidth, w));\n widths.set(p.key, Math.round(w));\n }\n\n return widths;\n}\n\n/**\n * Creates column resize state for a table component.\n *\n * Builds an initial column width map from column definitions + table width,\n * then tracks resize operations that clamp to min/max and redistribute\n * remaining space among flex columns.\n */\nexport function createTableColumnResizeState(\n props: Accessor<TableColumnResizeStateProps>,\n): TableColumnResizeState {\n const getProps = () => props();\n\n // Memoize initial width distribution (re-distributes when table width or columns change)\n const initialWidths = createMemo(() =>\n distributeWidths(getProps().columns, getProps().tableWidth),\n );\n\n // User-overridden widths (set during/after resize)\n const [overrides, setOverrides] = createSignal<Map<Key, number>>(new Map());\n const [resizingColumn, setResizingColumn] = createSignal<Key | null>(null);\n\n // Computed widths: initial merged with overrides\n const columnWidths = createMemo(() => {\n const base = initialWidths();\n const over = overrides();\n if (over.size === 0) return base;\n\n const merged = new Map(base);\n for (const [key, width] of over) {\n if (merged.has(key)) {\n merged.set(key, width);\n }\n }\n return merged;\n });\n\n // Build min/max lookup\n const minWidthMap = createMemo(() => {\n const map = new Map<Key, number>();\n for (const col of getProps().columns) {\n map.set(col.key, col.minWidth ?? DEFAULT_MIN_WIDTH);\n }\n return map;\n });\n\n const maxWidthMap = createMemo(() => {\n const map = new Map<Key, number>();\n for (const col of getProps().columns) {\n map.set(col.key, col.maxWidth ?? DEFAULT_MAX_WIDTH);\n }\n return map;\n });\n\n const getColumnWidth = (key: Key): number => {\n return columnWidths().get(key) ?? 0;\n };\n\n const getColumnMinWidth = (key: Key): number => {\n return minWidthMap().get(key) ?? DEFAULT_MIN_WIDTH;\n };\n\n const getColumnMaxWidth = (key: Key): number => {\n return maxWidthMap().get(key) ?? DEFAULT_MAX_WIDTH;\n };\n\n const startResize = (key: Key) => {\n setResizingColumn(key);\n };\n\n const endResize = () => {\n setResizingColumn(null);\n };\n\n const updateResizedColumns = (key: Key, width: number): Map<Key, number> => {\n const minW = getColumnMinWidth(key);\n const maxW = getColumnMaxWidth(key);\n const clampedWidth = Math.round(Math.max(minW, Math.min(maxW, width)));\n\n const newOverrides = new Map(overrides());\n newOverrides.set(key, clampedWidth);\n setOverrides(newOverrides);\n\n // Return the resulting widths\n const base = initialWidths();\n const merged = new Map(base);\n for (const [k, w] of newOverrides) {\n if (merged.has(k)) {\n merged.set(k, w);\n }\n }\n return merged;\n };\n\n return {\n resizingColumn,\n columnWidths,\n startResize,\n endResize,\n updateResizedColumns,\n getColumnWidth,\n getColumnMinWidth,\n getColumnMaxWidth,\n };\n}\n","/**\n * Tree state management for Tree components.\n * Based on @react-stately/tree/useTreeState.\n *\n * Manages expansion state, selection, and focus for hierarchical tree data.\n */\n\nimport { createSignal, createEffect, createMemo, on, type Accessor } from \"solid-js\";\nimport type { TreeState, TreeStateOptions, TreeCollection } from \"./types\";\nimport type { Key, FocusStrategy, Selection, SelectionBehavior } from \"../collections/types\";\n\n/**\n * Creates state management for a tree component.\n * Handles expansion, selection, focus management, and keyboard navigation state.\n */\nexport function createTreeState<T extends object, C extends TreeCollection<T> = TreeCollection<T>>(\n options: Accessor<TreeStateOptions<T, C>>,\n): TreeState<T, C> {\n const getOptions = () => options();\n\n // Disabled keys as a Set\n const disabledKeys = createMemo(() => {\n const keys = getOptions().disabledKeys;\n return keys ? new Set(keys) : new Set<Key>();\n });\n\n // Expansion state (uncontrolled)\n const [internalExpandedKeys, setInternalExpandedKeys] = createSignal<Set<Key>>(\n getInitialExpandedKeys(getOptions().defaultExpandedKeys),\n );\n\n // Computed expanded keys (controlled or uncontrolled)\n const expandedKeys = createMemo(() => {\n const opts = getOptions();\n if (opts.expandedKeys !== undefined) {\n return new Set(opts.expandedKeys);\n }\n return internalExpandedKeys();\n });\n\n // Collection - rebuilt when expanded keys change\n const collection = createMemo(() => {\n const opts = getOptions();\n return opts.collectionFactory(expandedKeys());\n });\n\n // Focus state\n const [isFocused, setIsFocused] = createSignal(false);\n const [focusedKey, setFocusedKeyInternal] = createSignal<Key | null>(null);\n const [childFocusStrategy, setChildFocusStrategy] = createSignal<FocusStrategy | null>(null);\n const [isKeyboardNavigationDisabled, setKeyboardNavigationDisabled] = createSignal(false);\n\n // Selection state\n const [internalSelectedKeys, setInternalSelectedKeys] = createSignal<\"all\" | Set<Key>>(\n getInitialSelection(getOptions().defaultSelectedKeys),\n );\n const [anchorKey, setAnchorKey] = createSignal<Key | null>(null);\n\n // Computed selection\n const selectedKeys = createMemo(() => {\n const opts = getOptions();\n if (opts.selectedKeys !== undefined) {\n return normalizeSelection(opts.selectedKeys);\n }\n return internalSelectedKeys();\n });\n\n const selectionMode = createMemo(() => getOptions().selectionMode ?? \"none\");\n const selectionBehaviorProp = (): SelectionBehavior => getOptions().selectionBehavior ?? \"toggle\";\n const [selectionBehaviorState, setSelectionBehaviorState] =\n createSignal<SelectionBehavior>(selectionBehaviorProp());\n const selectionBehavior = createMemo(() => selectionBehaviorState());\n const disallowEmptySelection = createMemo(() => getOptions().disallowEmptySelection ?? false);\n const disabledBehavior = createMemo(() => getOptions().disabledBehavior ?? \"all\");\n\n createEffect(on(selectionBehaviorProp, (behavior) => setSelectionBehaviorState(behavior)));\n\n createEffect(() => {\n const keys = selectedKeys();\n if (\n selectionBehaviorProp() === \"replace\" &&\n selectionBehaviorState() === \"toggle\" &&\n keys !== \"all\" &&\n keys.size === 0\n ) {\n setSelectionBehaviorState(\"replace\");\n }\n });\n\n // Set focused key\n const setFocusedKey = (key: Key | null, strategy: FocusStrategy = \"first\") => {\n setFocusedKeyInternal(key);\n setChildFocusStrategy(strategy);\n };\n\n // Reset focused key if the item is removed from visible collection\n let cachedCollection: C | null = null;\n\n createEffect(\n on(collection, (coll) => {\n const currentFocusedKey = focusedKey();\n\n if (currentFocusedKey != null && cachedCollection) {\n // Check if the focused item is still visible\n const visibleKeys = [...coll.getKeys()];\n if (!visibleKeys.includes(currentFocusedKey)) {\n // The focused item was collapsed or removed, find a new one to focus\n // Try to find the parent and focus it\n const node = cachedCollection.getItem(currentFocusedKey);\n if (node?.parentKey != null) {\n const parent = coll.getItem(node.parentKey);\n if (parent && visibleKeys.includes(parent.key)) {\n setFocusedKeyInternal(parent.key);\n cachedCollection = coll;\n return;\n }\n }\n\n // Otherwise, find the nearest visible sibling or previous item\n const rows = coll.rows;\n if (rows.length > 0) {\n // Find the closest item to where the focused item was\n const cachedNode = cachedCollection.getItem(currentFocusedKey);\n if (cachedNode?.rowIndex !== undefined) {\n const newIndex = Math.min(cachedNode.rowIndex, rows.length - 1);\n const newNode = rows[newIndex];\n if (newNode && !disabledKeys().has(newNode.key)) {\n setFocusedKeyInternal(newNode.key);\n cachedCollection = coll;\n return;\n }\n }\n // Fall back to first non-disabled item\n for (const row of rows) {\n if (!disabledKeys().has(row.key)) {\n setFocusedKeyInternal(row.key);\n break;\n }\n }\n } else {\n setFocusedKeyInternal(null);\n }\n }\n }\n\n cachedCollection = coll;\n }),\n );\n\n // Selection methods\n const isSelected = (key: Key): boolean => {\n const keys = selectedKeys();\n if (keys === \"all\") return true;\n return keys.has(key);\n };\n\n const isDisabled = (key: Key): boolean => {\n return disabledKeys().has(key) || collection().getItem(key)?.isDisabled === true;\n };\n\n const isExpanded = (key: Key): boolean => {\n return expandedKeys().has(key);\n };\n\n const updateSelection = (newSelection: \"all\" | Set<Key>) => {\n const opts = getOptions();\n\n // Controlled mode\n if (opts.selectedKeys !== undefined) {\n opts.onSelectionChange?.(newSelection);\n return;\n }\n\n // Uncontrolled mode\n const current = internalSelectedKeys();\n const isDifferent =\n current === \"all\" ||\n newSelection === \"all\" ||\n current.size !== (newSelection as Set<Key>).size ||\n ![...current].every((k) => (newSelection as Set<Key>).has(k));\n\n if (isDifferent) {\n setInternalSelectedKeys(newSelection);\n opts.onSelectionChange?.(newSelection);\n }\n };\n\n const toggleSelection = (key: Key) => {\n // Disabled keys are never selectable, regardless of disabledBehavior\n // (mirrors SelectionManager.canSelectItem, which ignores disabledBehavior).\n if (isDisabled(key)) return;\n if (selectionMode() === \"none\") return;\n\n const current = selectedKeys();\n\n if (selectionMode() === \"single\") {\n if (isSelected(key) && !disallowEmptySelection()) {\n updateSelection(new Set());\n } else {\n updateSelection(new Set([key]));\n }\n return;\n }\n\n // Multiple selection\n if (current === \"all\") {\n // Can't toggle when all selected without knowing all keys\n return;\n }\n\n const newSelection = new Set(current);\n if (newSelection.has(key)) {\n if (newSelection.size > 1 || !disallowEmptySelection()) {\n newSelection.delete(key);\n }\n } else {\n newSelection.add(key);\n }\n\n updateSelection(newSelection);\n setAnchorKey(key);\n };\n\n const replaceSelection = (key: Key) => {\n if (isDisabled(key)) return;\n if (selectionMode() === \"none\") return;\n\n updateSelection(new Set([key]));\n setAnchorKey(key);\n };\n\n const setSelectedKeys = (keys: Selection | Iterable<Key>) => {\n updateSelection(normalizeSelection(keys));\n };\n\n const extendSelection = (toKey: Key) => {\n if (isDisabled(toKey)) return;\n if (selectionMode() !== \"multiple\") {\n replaceSelection(toKey);\n return;\n }\n\n const anchor = anchorKey();\n if (!anchor) {\n replaceSelection(toKey);\n return;\n }\n\n const coll = collection();\n const rows = coll.rows.filter((r) => r.type === \"item\");\n const keys = rows.map((r) => r.key);\n const anchorIndex = keys.indexOf(anchor);\n const toIndex = keys.indexOf(toKey);\n\n if (anchorIndex === -1 || toIndex === -1) {\n replaceSelection(toKey);\n return;\n }\n\n const start = Math.min(anchorIndex, toIndex);\n const end = Math.max(anchorIndex, toIndex);\n const rangeKeys = keys.slice(start, end + 1).filter((k) => !isDisabled(k));\n\n updateSelection(new Set(rangeKeys));\n };\n\n const selectAll = () => {\n if (selectionMode() !== \"multiple\") return;\n updateSelection(\"all\");\n };\n\n const clearSelection = () => {\n if (disallowEmptySelection()) return;\n updateSelection(new Set());\n };\n\n const toggleSelectAll = () => {\n if (selectionMode() !== \"multiple\") return;\n\n if (selectedKeys() === \"all\") {\n clearSelection();\n } else {\n selectAll();\n }\n };\n\n // Expansion methods\n const updateExpandedKeys = (newKeys: Set<Key>) => {\n const opts = getOptions();\n\n // Controlled mode\n if (opts.expandedKeys !== undefined) {\n opts.onExpandedChange?.(newKeys);\n return;\n }\n\n // Uncontrolled mode\n setInternalExpandedKeys(newKeys);\n opts.onExpandedChange?.(newKeys);\n };\n\n const toggleKey = (key: Key) => {\n const node = collection().getItem(key);\n if (!node || !node.isExpandable) return;\n if (isDisabled(key) && disabledBehavior() === \"all\") return;\n\n const current = expandedKeys();\n const newKeys = new Set(current);\n\n if (newKeys.has(key)) {\n newKeys.delete(key);\n } else {\n newKeys.add(key);\n }\n\n updateExpandedKeys(newKeys);\n };\n\n const expandKey = (key: Key) => {\n const node = collection().getItem(key);\n if (!node || !node.isExpandable) return;\n if (isDisabled(key) && disabledBehavior() === \"all\") return;\n\n const current = expandedKeys();\n if (current.has(key)) return;\n\n const newKeys = new Set(current);\n newKeys.add(key);\n updateExpandedKeys(newKeys);\n };\n\n const collapseKey = (key: Key) => {\n const node = collection().getItem(key);\n if (!node || !node.isExpandable) return;\n if (isDisabled(key) && disabledBehavior() === \"all\") return;\n\n const current = expandedKeys();\n if (!current.has(key)) return;\n\n const newKeys = new Set(current);\n newKeys.delete(key);\n updateExpandedKeys(newKeys);\n };\n\n const setExpandedKeys = (keys: Set<Key>) => {\n updateExpandedKeys(keys);\n };\n\n return {\n get collection() {\n return collection();\n },\n get disabledKeys() {\n return disabledKeys();\n },\n get disabledBehavior() {\n return disabledBehavior();\n },\n get expandedKeys() {\n return expandedKeys();\n },\n get isKeyboardNavigationDisabled() {\n return isKeyboardNavigationDisabled();\n },\n get focusedKey() {\n return focusedKey();\n },\n get childFocusStrategy() {\n return childFocusStrategy();\n },\n get isFocused() {\n return isFocused();\n },\n get selectionMode() {\n return selectionMode();\n },\n get selectionBehavior() {\n return selectionBehavior();\n },\n get disallowEmptySelection() {\n return disallowEmptySelection();\n },\n get selectedKeys() {\n return selectedKeys();\n },\n isSelected,\n isDisabled,\n isExpanded,\n setFocusedKey,\n setFocused: setIsFocused,\n toggleSelection,\n replaceSelection,\n setSelectedKeys,\n setSelectionBehavior: setSelectionBehaviorState,\n extendSelection,\n selectAll,\n clearSelection,\n toggleSelectAll,\n toggleKey,\n expandKey,\n collapseKey,\n setExpandedKeys,\n setKeyboardNavigationDisabled,\n };\n}\n\n// Helper functions\nfunction getInitialSelection(defaultKeys?: \"all\" | Iterable<Key>): \"all\" | Set<Key> {\n if (defaultKeys === undefined) return new Set();\n return normalizeSelection(defaultKeys);\n}\n\nfunction normalizeSelection(keys: \"all\" | Iterable<Key>): \"all\" | Set<Key> {\n if (keys === \"all\") return \"all\";\n return new Set(keys);\n}\n\nfunction getInitialExpandedKeys(defaultKeys?: Iterable<Key>): Set<Key> {\n if (defaultKeys === undefined) return new Set();\n return new Set(defaultKeys);\n}\n","/**\n * TreeCollection implementation.\n * Based on @react-stately/tree/TreeCollection.\n *\n * A flattened view of tree nodes that respects expanded state.\n * Only visible nodes (root + expanded children) are included in iteration.\n */\n\nimport type { Key } from \"../collections/types\";\nimport type { TreeCollection as ITreeCollection, TreeNode, TreeItemData } from \"./types\";\n\nfunction getItemKey<T>(item: TreeItemData<T>): Key {\n const key = item.key ?? item.id;\n if (key == null) {\n throw new Error(\"Tree items must define either a key or id.\");\n }\n return key;\n}\n\n/**\n * Creates a TreeCollection from hierarchical data.\n * The collection is flattened based on expanded keys.\n */\nexport class TreeCollection<T> implements ITreeCollection<T> {\n private keyMap: Map<Key, TreeNode<T>> = new Map();\n private visibleRows: TreeNode<T>[] = [];\n private firstKey: Key | null = null;\n private lastKey: Key | null = null;\n\n constructor(items: TreeItemData<T>[], expandedKeys: Set<Key>) {\n this.buildCollection(items, expandedKeys);\n }\n\n private buildCollection(items: TreeItemData<T>[], expandedKeys: Set<Key>): void {\n let globalIndex = 0;\n let previousNode: TreeNode<T> | null = null;\n\n const visit = (\n item: TreeItemData<T>,\n level: number,\n parentKey: Key | null,\n indexInParent: number,\n ): TreeNode<T> => {\n const key = getItemKey(item);\n const hasLoadedChildren = Boolean(item.children && item.children.length > 0);\n const hasChildren = hasLoadedChildren || !!item.hasChildItems;\n const isExpanded = hasChildren && expandedKeys.has(key);\n\n // Build child nodes first (even if not visible, for the map)\n const childNodes: TreeNode<T>[] = [];\n if (hasLoadedChildren && item.children) {\n for (let i = 0; i < item.children.length; i++) {\n const childNode = visit(item.children[i], level + 1, key, i);\n childNodes.push(childNode);\n }\n }\n\n const node: TreeNode<T> = {\n type: \"item\",\n key,\n value: (item.value ?? item) as T,\n textValue: item.textValue || String(key),\n level,\n index: indexInParent,\n parentKey,\n hasChildNodes: hasChildren || false,\n childNodes,\n isDisabled: item.isDisabled,\n isExpandable: hasChildren,\n isExpanded,\n };\n\n // Always add to keyMap (for getItem lookups)\n this.keyMap.set(key, node);\n\n return node;\n };\n\n // First pass: build all nodes\n const rootNodes: TreeNode<T>[] = [];\n for (let i = 0; i < items.length; i++) {\n const node = visit(items[i], 0, null, i);\n rootNodes.push(node);\n }\n\n // Second pass: build visible rows list\n const addVisibleNodes = (nodes: TreeNode<T>[]): void => {\n for (const node of nodes) {\n node.rowIndex = globalIndex++;\n this.visibleRows.push(node);\n node.prevKey = previousNode?.key ?? null;\n node.nextKey = undefined;\n if (previousNode) {\n previousNode.nextKey = node.key;\n }\n previousNode = node;\n\n if (node.isExpanded && node.childNodes.length > 0) {\n addVisibleNodes(node.childNodes);\n }\n }\n };\n\n addVisibleNodes(rootNodes);\n this.firstKey = this.visibleRows[0]?.key ?? null;\n this.lastKey = this.visibleRows[this.visibleRows.length - 1]?.key ?? null;\n }\n\n // Collection properties\n\n get size(): number {\n return this.visibleRows.length;\n }\n\n get rows(): TreeNode<T>[] {\n return this.visibleRows;\n }\n\n get rowCount(): number {\n return this.visibleRows.length;\n }\n\n // Collection methods\n\n getKeys(): Iterable<Key> {\n return this.visibleRows.map((node) => node.key);\n }\n\n getItem(key: Key): TreeNode<T> | null {\n return this.keyMap.get(key) ?? null;\n }\n\n at(index: number): TreeNode<T> | null {\n if (index < 0 || index >= this.visibleRows.length) {\n return null;\n }\n return this.visibleRows[index];\n }\n\n getKeyBefore(key: Key): Key | null {\n const node = this.keyMap.get(key);\n let previousKey = node?.prevKey ?? null;\n while (previousKey != null) {\n const candidate = this.keyMap.get(previousKey);\n if (!candidate) break;\n if (candidate.type !== \"content\") {\n return candidate.key;\n }\n previousKey = candidate.prevKey ?? null;\n }\n return null;\n }\n\n getKeyAfter(key: Key): Key | null {\n const node = this.keyMap.get(key);\n let nextKey = node?.nextKey ?? null;\n while (nextKey != null) {\n const candidate = this.keyMap.get(nextKey);\n if (!candidate) break;\n if (candidate.type !== \"content\") {\n return candidate.key;\n }\n nextKey = candidate.nextKey ?? null;\n }\n return null;\n }\n\n getFirstKey(): Key | null {\n if (this.firstKey == null) return null;\n const candidate = this.keyMap.get(this.firstKey);\n if (candidate?.type === \"content\") {\n return this.getKeyAfter(candidate.key);\n }\n return this.firstKey;\n }\n\n getLastKey(): Key | null {\n if (this.lastKey == null) return null;\n const candidate = this.keyMap.get(this.lastKey);\n if (candidate?.type === \"content\") {\n return this.getKeyBefore(candidate.key);\n }\n return this.lastKey;\n }\n\n getChildren(key: Key): Iterable<TreeNode<T>> {\n const node = this.keyMap.get(key);\n return node?.childNodes ?? [];\n }\n\n getTextValue(key: Key): string {\n const node = this.keyMap.get(key);\n return node?.textValue ?? \"\";\n }\n\n getParentKey(key: Key): Key | null {\n const node = this.keyMap.get(key);\n return node?.parentKey ?? null;\n }\n\n [Symbol.iterator](): Iterator<TreeNode<T>> {\n return this.visibleRows[Symbol.iterator]();\n }\n}\n\n/**\n * Factory function to create a TreeCollection.\n * Useful for the collectionFactory pattern in TreeStateOptions.\n */\nexport function createTreeCollection<T>(\n items: TreeItemData<T>[],\n expandedKeys: Set<Key>,\n): TreeCollection<T> {\n return new TreeCollection(items, expandedKeys);\n}\n","// Color-name / channel-name intl catalog, ported verbatim from\n// @react-stately/color's intl/color/*.json (34 locales). Keep in sync\n// with the vendored react-spectrum source on every pin bump.\n\nexport type ColorStringKey =\n | \"hue\"\n | \"saturation\"\n | \"lightness\"\n | \"brightness\"\n | \"red\"\n | \"green\"\n | \"blue\"\n | \"alpha\"\n | \"colorName\"\n | \"transparentColorName\"\n | \"very dark\"\n | \"dark\"\n | \"light\"\n | \"very light\"\n | \"pale\"\n | \"grayish\"\n | \"vibrant\"\n | \"black\"\n | \"white\"\n | \"gray\"\n | \"pink\"\n | \"pink red\"\n | \"red orange\"\n | \"brown\"\n | \"orange\"\n | \"orange yellow\"\n | \"brown yellow\"\n | \"yellow\"\n | \"yellow green\"\n | \"green cyan\"\n | \"cyan\"\n | \"cyan blue\"\n | \"blue purple\"\n | \"purple\"\n | \"purple magenta\"\n | \"magenta\"\n | \"magenta pink\";\n\nexport const colorStrings: Record<string, Record<ColorStringKey, string>> = {\n \"en-US\": {\n \"hue\": \"Hue\",\n \"saturation\": \"Saturation\",\n \"lightness\": \"Lightness\",\n \"brightness\": \"Brightness\",\n \"red\": \"Red\",\n \"green\": \"Green\",\n \"blue\": \"Blue\",\n \"alpha\": \"Alpha\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} transparent\",\n \"very dark\": \"very dark\",\n \"dark\": \"dark\",\n \"light\": \"light\",\n \"very light\": \"very light\",\n \"pale\": \"pale\",\n \"grayish\": \"grayish\",\n \"vibrant\": \"vibrant\",\n \"black\": \"black\",\n \"white\": \"white\",\n \"gray\": \"gray\",\n \"pink\": \"pink\",\n \"pink red\": \"pink red\",\n \"red orange\": \"red orange\",\n \"brown\": \"brown\",\n \"orange\": \"orange\",\n \"orange yellow\": \"orange yellow\",\n \"brown yellow\": \"brown yellow\",\n \"yellow\": \"yellow\",\n \"yellow green\": \"yellow green\",\n \"green cyan\": \"green cyan\",\n \"cyan\": \"cyan\",\n \"cyan blue\": \"cyan blue\",\n \"blue purple\": \"blue purple\",\n \"purple\": \"purple\",\n \"purple magenta\": \"purple magenta\",\n \"magenta\": \"magenta\",\n \"magenta pink\": \"magenta pink\",\n },\n \"ar-AE\": {\n \"hue\": \"درجة اللون\",\n \"saturation\": \"التشبع\",\n \"lightness\": \"الإضاءة\",\n \"brightness\": \"السطوع\",\n \"red\": \"أحمر\",\n \"green\": \"أخضر\",\n \"blue\": \"أزرق\",\n \"alpha\": \"ألفا\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} شفاف\",\n \"very dark\": \"داكن جدًا\",\n \"dark\": \"داكن\",\n \"light\": \"فاتح\",\n \"very light\": \"فاتح جدًا\",\n \"pale\": \"باهت\",\n \"grayish\": \"مائل للرمادي\",\n \"vibrant\": \"ساطع\",\n \"black\": \"أسود\",\n \"white\": \"أبيض\",\n \"gray\": \"رمادي\",\n \"pink\": \"وردي\",\n \"pink red\": \"أحمر وردي\",\n \"red orange\": \"برتقالي محمر\",\n \"brown\": \"بني\",\n \"orange\": \"برتقالي\",\n \"orange yellow\": \"أصفر برتقالي\",\n \"brown yellow\": \"أصفر بني\",\n \"yellow\": \"أصفر\",\n \"yellow green\": \"أخضر مصفر\",\n \"green cyan\": \"سماوي مخضر\",\n \"cyan\": \"سماوي\",\n \"cyan blue\": \"أزرق سماوي\",\n \"blue purple\": \"أرجواني مزرق\",\n \"purple\": \"أرجواني\",\n \"purple magenta\": \"بنفسجي\",\n \"magenta\": \"أرجواني\",\n \"magenta pink\": \"أرجواني وردي\",\n },\n \"bg-BG\": {\n \"hue\": \"Оттенък\",\n \"saturation\": \"Наситеност\",\n \"lightness\": \"Лекота\",\n \"brightness\": \"Яркост\",\n \"red\": \"Червено\",\n \"green\": \"Зелено\",\n \"blue\": \"Синьо\",\n \"alpha\": \"Алфа\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} прозрачен\",\n \"very dark\": \"много тъмно\",\n \"dark\": \"тъмно\",\n \"light\": \"светло\",\n \"very light\": \"много светло\",\n \"pale\": \"бледо\",\n \"grayish\": \"сивкав\",\n \"vibrant\": \" ярко\",\n \"black\": \"черно\",\n \"white\": \"бяло\",\n \"gray\": \"сиво\",\n \"pink\": \"розово\",\n \"pink red\": \"розово червено\",\n \"red orange\": \"червен портокал\",\n \"brown\": \"кафяво\",\n \"orange\": \"оранжево\",\n \"orange yellow\": \"оранжево жълто\",\n \"brown yellow\": \"кафяво жълто\",\n \"yellow\": \"жълто\",\n \"yellow green\": \"жълто зелен\",\n \"green cyan\": \"зелен циан\",\n \"cyan\": \"циан\",\n \"cyan blue\": \"циан синьо\",\n \"blue purple\": \"синьо лилаво\",\n \"purple\": \"лилаво\",\n \"purple magenta\": \"лилаво магента\",\n \"magenta\": \"магента\",\n \"magenta pink\": \"магента розово\",\n },\n \"cs-CZ\": {\n \"hue\": \"Odstín\",\n \"saturation\": \"Sytost\",\n \"lightness\": \"Světlost\",\n \"brightness\": \"Jas\",\n \"red\": \"Červená\",\n \"green\": \"Zelená\",\n \"blue\": \"Modrá\",\n \"alpha\": \"Alfa\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} průhledné\",\n \"very dark\": \"velmi tmavá\",\n \"dark\": \"tmavá\",\n \"light\": \"světlá\",\n \"very light\": \"velmi světlá\",\n \"pale\": \"bledá\",\n \"grayish\": \"našedlá\",\n \"vibrant\": \"zářivá\",\n \"black\": \"černá\",\n \"white\": \"bílá\",\n \"gray\": \"šedá\",\n \"pink\": \"růžová\",\n \"pink red\": \"růžovočervená\",\n \"red orange\": \"červenooranžová\",\n \"brown\": \"hnědá\",\n \"orange\": \"oranžová\",\n \"orange yellow\": \"oranžovožlutá\",\n \"brown yellow\": \"hnědožlutá\",\n \"yellow\": \"žlutá\",\n \"yellow green\": \"žlutozelená\",\n \"green cyan\": \"zelenotyrkysová\",\n \"cyan\": \"tyrkysová\",\n \"cyan blue\": \"tyrkysovomodrá\",\n \"blue purple\": \"modrofialová\",\n \"purple\": \"fialová\",\n \"purple magenta\": \"fialově purpurová\",\n \"magenta\": \"purpurová\",\n \"magenta pink\": \"purpurově růžová\",\n },\n \"da-DK\": {\n \"hue\": \"Tone\",\n \"saturation\": \"Farvemætning\",\n \"lightness\": \"Lyshed\",\n \"brightness\": \"Lysstyrke\",\n \"red\": \"Rød\",\n \"green\": \"Grøn\",\n \"blue\": \"Blå\",\n \"alpha\": \"Alfa\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} gennemsigtig\",\n \"very dark\": \"meget mørk\",\n \"dark\": \"mørk\",\n \"light\": \"lys\",\n \"very light\": \"meget lys\",\n \"pale\": \"bleg\",\n \"grayish\": \"grålig\",\n \"vibrant\": \"klar\",\n \"black\": \"sort\",\n \"white\": \"hvid\",\n \"gray\": \"grå\",\n \"pink\": \"lyserød\",\n \"pink red\": \"lyserødlig rød\",\n \"red orange\": \"rødorange\",\n \"brown\": \"brun\",\n \"orange\": \"orange\",\n \"orange yellow\": \"orangegul\",\n \"brown yellow\": \"brungul\",\n \"yellow\": \"gul\",\n \"yellow green\": \"gulgrøn\",\n \"green cyan\": \"grøn cyan\",\n \"cyan\": \"cyan\",\n \"cyan blue\": \"cyan blå\",\n \"blue purple\": \"blålilla\",\n \"purple\": \"lilla\",\n \"purple magenta\": \"lilla magenta\",\n \"magenta\": \"magenta\",\n \"magenta pink\": \"magenta pink\",\n },\n \"de-DE\": {\n \"hue\": \"Farbton\",\n \"saturation\": \"Sättigung\",\n \"lightness\": \"Leuchtkraft\",\n \"brightness\": \"Helligkeit\",\n \"red\": \"Rot\",\n \"green\": \"Grün\",\n \"blue\": \"Blau\",\n \"alpha\": \"Alpha\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, zu {percentTransparent} transparent\",\n \"very dark\": \"sehr dunkles\",\n \"dark\": \"dunkles\",\n \"light\": \"helles\",\n \"very light\": \"sehr helles\",\n \"pale\": \"blasses\",\n \"grayish\": \"gräuliches\",\n \"vibrant\": \"lebhaftes\",\n \"black\": \"Schwarz\",\n \"white\": \"Weiß\",\n \"gray\": \"Grau\",\n \"pink\": \"Rosa\",\n \"pink red\": \"Rosarot\",\n \"red orange\": \"Rotorange\",\n \"brown\": \"Braun\",\n \"orange\": \"Orange\",\n \"orange yellow\": \"Orangegelb\",\n \"brown yellow\": \"Braungelb\",\n \"yellow\": \"Gelb\",\n \"yellow green\": \"Gelbgrün\",\n \"green cyan\": \"Grüncyan\",\n \"cyan\": \"Cyan\",\n \"cyan blue\": \"Cyanblau\",\n \"blue purple\": \"Blaulila\",\n \"purple\": \"Lila\",\n \"purple magenta\": \"Lilamagenta\",\n \"magenta\": \"Magenta\",\n \"magenta pink\": \"Magentarosa\",\n },\n \"el-GR\": {\n \"hue\": \"Τόνος\",\n \"saturation\": \"Κορεσμός\",\n \"lightness\": \"Φωτεινότητα\",\n \"brightness\": \"Φωτεινότητα\",\n \"red\": \"Κόκκινο\",\n \"green\": \"Πράσινο\",\n \"blue\": \"Μπλε\",\n \"alpha\": \"Άλφα\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} διαφανές\",\n \"very dark\": \"πολύ σκούρο\",\n \"dark\": \"σκούρο\",\n \"light\": \"ανοιχτό\",\n \"very light\": \"πολύ ανοιχτό\",\n \"pale\": \"ανοιχτό\",\n \"grayish\": \"γκριζωπό\",\n \"vibrant\": \"έντονο\",\n \"black\": \"μαύρο\",\n \"white\": \"λευκό\",\n \"gray\": \"γκρι\",\n \"pink\": \"ροζ\",\n \"pink red\": \"ροζ κόκκινο\",\n \"red orange\": \"κόκκινο πορτοκαλί\",\n \"brown\": \"καφέ\",\n \"orange\": \"πορτοκαλί\",\n \"orange yellow\": \"πορτοκαλί κίτρινο\",\n \"brown yellow\": \"καφέ κίτρινο\",\n \"yellow\": \"κίτρινο\",\n \"yellow green\": \"κίτρινο πράσινο\",\n \"green cyan\": \"πράσινο κυανό\",\n \"cyan\": \"κυανό\",\n \"cyan blue\": \"κυανό μπλε\",\n \"blue purple\": \"μπλε μωβ\",\n \"purple\": \"μωβ\",\n \"purple magenta\": \"μωβ ματζέντα\",\n \"magenta\": \"ματζέντα\",\n \"magenta pink\": \"ματζέντα ροζ\",\n },\n \"es-ES\": {\n \"hue\": \"Tono\",\n \"saturation\": \"Saturación\",\n \"lightness\": \"Luminosidad\",\n \"brightness\": \"Brillo\",\n \"red\": \"Rojo\",\n \"green\": \"Verde\",\n \"blue\": \"Azul\",\n \"alpha\": \"Alpha\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} transparente\",\n \"very dark\": \"muy oscuro\",\n \"dark\": \"oscuro\",\n \"light\": \"claro\",\n \"very light\": \"muy claro\",\n \"pale\": \"pálido\",\n \"grayish\": \"grisáceo\",\n \"vibrant\": \"intenso\",\n \"black\": \"negro\",\n \"white\": \"blanco\",\n \"gray\": \"gris\",\n \"pink\": \"rosa\",\n \"pink red\": \"rojo rosado\",\n \"red orange\": \"naranja rojizo\",\n \"brown\": \"marrón\",\n \"orange\": \"naranja\",\n \"orange yellow\": \"amarillo anaranjado\",\n \"brown yellow\": \"amarillo amarronado\",\n \"yellow\": \"amarillo\",\n \"yellow green\": \"verde amarillento\",\n \"green cyan\": \"cian verdoso\",\n \"cyan\": \"cian\",\n \"cyan blue\": \"azul cian\",\n \"blue purple\": \"púrpura azulado\",\n \"purple\": \"morado\",\n \"purple magenta\": \"magenta violáceo\",\n \"magenta\": \"magenta\",\n \"magenta pink\": \"rosa magenta\",\n },\n \"et-EE\": {\n \"hue\": \"Värv\",\n \"saturation\": \"Küllastus\",\n \"lightness\": \"Valgus\",\n \"brightness\": \"Heledus\",\n \"red\": \"Punane\",\n \"green\": \"Roheline\",\n \"blue\": \"Sinine\",\n \"alpha\": \"Alfa\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} läbipaistev\",\n \"very dark\": \"väga tume\",\n \"dark\": \"tume\",\n \"light\": \"valgus\",\n \"very light\": \"väga hele\",\n \"pale\": \"kahvatu\",\n \"grayish\": \"hallikas\",\n \"vibrant\": \"ere\",\n \"black\": \"must\",\n \"white\": \"valge\",\n \"gray\": \"hall\",\n \"pink\": \"roosa\",\n \"pink red\": \"vaarikapunane\",\n \"red orange\": \"punakasoranž\",\n \"brown\": \"pruun\",\n \"orange\": \"oranž\",\n \"orange yellow\": \"oranžikaskollane\",\n \"brown yellow\": \"pruunikaskollane\",\n \"yellow\": \"kollane\",\n \"yellow green\": \"kollakasroheline\",\n \"green cyan\": \"tsüaanroheline\",\n \"cyan\": \"tsüaan\",\n \"cyan blue\": \"tsüaansinine\",\n \"blue purple\": \"sinakaslilla\",\n \"purple\": \"lilla\",\n \"purple magenta\": \"purpurne magenta\",\n \"magenta\": \"magentapunane\",\n \"magenta pink\": \"magentaroosa\",\n },\n \"fi-FI\": {\n \"hue\": \"Sävy\",\n \"saturation\": \"Värikylläisyys\",\n \"lightness\": \"Valomäärä\",\n \"brightness\": \"Kirkkaus\",\n \"red\": \"Punainen\",\n \"green\": \"Vihreä\",\n \"blue\": \"Sininen\",\n \"alpha\": \"Alpha\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} läpinäkyvä\",\n \"very dark\": \"hyvin tumma\",\n \"dark\": \"tumma\",\n \"light\": \"vaalea\",\n \"very light\": \"erittäin vaalea\",\n \"pale\": \"vaalea\",\n \"grayish\": \"harmahtava\",\n \"vibrant\": \"eloisa\",\n \"black\": \"musta\",\n \"white\": \"valkea\",\n \"gray\": \"harmaa\",\n \"pink\": \"pinkki\",\n \"pink red\": \"vaaleanpunainen\",\n \"red orange\": \"punaoranssi\",\n \"brown\": \"ruskea\",\n \"orange\": \"oranssi\",\n \"orange yellow\": \"oranssinkeltainen\",\n \"brown yellow\": \"ruskeankeltainen\",\n \"yellow\": \"keltainen\",\n \"yellow green\": \"keltavihreä\",\n \"green cyan\": \"vihreänsyaani\",\n \"cyan\": \"syaani\",\n \"cyan blue\": \"syaaninsininen\",\n \"blue purple\": \"sinivioletti\",\n \"purple\": \"violetti\",\n \"purple magenta\": \"violettimagenta\",\n \"magenta\": \"magenta\",\n \"magenta pink\": \"magentapinkki\",\n },\n \"fr-FR\": {\n \"hue\": \"Teinte\",\n \"saturation\": \"Saturation\",\n \"lightness\": \"Luminosité\",\n \"brightness\": \"Luminosité\",\n \"red\": \"Rouge\",\n \"green\": \"Vert\",\n \"blue\": \"Bleu\",\n \"alpha\": \"Alpha\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} transparent\",\n \"very dark\": \"Très sombre\",\n \"dark\": \"Sombre\",\n \"light\": \"Clair\",\n \"very light\": \"Très clair\",\n \"pale\": \"Pâle\",\n \"grayish\": \"Grisâtre\",\n \"vibrant\": \"Vif\",\n \"black\": \"Noir\",\n \"white\": \"Blanc\",\n \"gray\": \"Gris\",\n \"pink\": \"Rose\",\n \"pink red\": \"Rouge rosé\",\n \"red orange\": \"Orange rouge\",\n \"brown\": \"Brun\",\n \"orange\": \"Orange\",\n \"orange yellow\": \"Jaune orangé\",\n \"brown yellow\": \"Jaune brun\",\n \"yellow\": \"Jaune\",\n \"yellow green\": \"Vert jaune\",\n \"green cyan\": \"Cyan vert\",\n \"cyan\": \"Cyan\",\n \"cyan blue\": \"Bleu cyan\",\n \"blue purple\": \"Violet bleu\",\n \"purple\": \"Violet\",\n \"purple magenta\": \"Magenta violet\",\n \"magenta\": \"Magenta\",\n \"magenta pink\": \"Rose magenta\",\n },\n \"he-IL\": {\n \"hue\": \"גוון\",\n \"saturation\": \"רוויה\",\n \"lightness\": \"כמות אור\",\n \"brightness\": \"בהירות\",\n \"red\": \"אדום\",\n \"green\": \"ירוק\",\n \"blue\": \"כחול\",\n \"alpha\": \"אלפא\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} שקוף\",\n \"very dark\": \"כהה מאוד\",\n \"dark\": \"כהה\",\n \"light\": \"אור\",\n \"very light\": \"בהיר מאוד\",\n \"pale\": \"חיוור\",\n \"grayish\": \"אפרפר\",\n \"vibrant\": \"תוסס\",\n \"black\": \"שחור\",\n \"white\": \"לבן\",\n \"gray\": \"אפור\",\n \"pink\": \"ורוד\",\n \"pink red\": \"ורוד אדום\",\n \"red orange\": \"כתום אדום\",\n \"brown\": \"חום\",\n \"orange\": \"כתום\",\n \"orange yellow\": \"כתום צהוב\",\n \"brown yellow\": \"חום צהוב\",\n \"yellow\": \"צהוב\",\n \"yellow green\": \"צהוב ירוק\",\n \"green cyan\": \"ציאן ירוק\",\n \"cyan\": \"טורקיז\",\n \"cyan blue\": \"כחול ציאן\",\n \"blue purple\": \"כחול סגול\",\n \"purple\": \"סגול\",\n \"purple magenta\": \"מג'נטה סגול\",\n \"magenta\": \"מג'נטה\",\n \"magenta pink\": \"ורוד מג'נטה\",\n },\n \"hr-HR\": {\n \"hue\": \"Nijansa\",\n \"saturation\": \"Zasićenost\",\n \"lightness\": \"Osvijetljenost\",\n \"brightness\": \"Svjetlina\",\n \"red\": \"Crvena\",\n \"green\": \"Zelena\",\n \"blue\": \"Plava\",\n \"alpha\": \"Alfa\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} prozirnosti\",\n \"very dark\": \"jako tamna\",\n \"dark\": \"tamno\",\n \"light\": \"svjetlo\",\n \"very light\": \"vrlo svijetlo\",\n \"pale\": \"blijeda\",\n \"grayish\": \"sivkasto\",\n \"vibrant\": \"vibrantna\",\n \"black\": \"crno\",\n \"white\": \"bijela\",\n \"gray\": \"siva\",\n \"pink\": \"ružičasta\",\n \"pink red\": \"ružičasto crvena\",\n \"red orange\": \"crveno narančasta\",\n \"brown\": \"smeđa\",\n \"orange\": \"narančasta\",\n \"orange yellow\": \"narančasto žuta\",\n \"brown yellow\": \"smeđe žuta\",\n \"yellow\": \"žuto\",\n \"yellow green\": \"žuto zelena\",\n \"green cyan\": \"zelena cijan\",\n \"cyan\": \"cijan\",\n \"cyan blue\": \"cijan plava\",\n \"blue purple\": \"plavo ljubičasta\",\n \"purple\": \"ljubičasta\",\n \"purple magenta\": \"ljubičasta magenta\",\n \"magenta\": \"magenta\",\n \"magenta pink\": \"magentno ružičasta\",\n },\n \"hu-HU\": {\n \"hue\": \"Színárnyalat\",\n \"saturation\": \"Telítettség\",\n \"lightness\": \"Világosság\",\n \"brightness\": \"Fényesség\",\n \"red\": \"Piros\",\n \"green\": \"Zöld\",\n \"blue\": \"Kék\",\n \"alpha\": \"Alfa\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} átlátszó\",\n \"very dark\": \"nagyon sötét\",\n \"dark\": \"sötét\",\n \"light\": \"világos\",\n \"very light\": \"nagyon világos\",\n \"pale\": \"halvány\",\n \"grayish\": \"szürkés\",\n \"vibrant\": \"élénk\",\n \"black\": \"fekete\",\n \"white\": \"fehér\",\n \"gray\": \"szürke\",\n \"pink\": \"rózsaszín\",\n \"pink red\": \"rózsaszín piros\",\n \"red orange\": \"piros narancs\",\n \"brown\": \"barna\",\n \"orange\": \"narancs\",\n \"orange yellow\": \"narancssárga\",\n \"brown yellow\": \"barna sárga\",\n \"yellow\": \"sárga\",\n \"yellow green\": \"sárga zöld\",\n \"green cyan\": \"zöld ciánkék\",\n \"cyan\": \"ciánkék\",\n \"cyan blue\": \"ciánkék\",\n \"blue purple\": \"kék lila\",\n \"purple\": \"lila\",\n \"purple magenta\": \"lila bíbor\",\n \"magenta\": \"bíbor\",\n \"magenta pink\": \"bíbor rózsaszín\",\n },\n \"it-IT\": {\n \"hue\": \"Tonalità\",\n \"saturation\": \"Saturazione\",\n \"lightness\": \"Luminosità\",\n \"brightness\": \"Luminosità\",\n \"red\": \"Rosso\",\n \"green\": \"Verde\",\n \"blue\": \"Blu\",\n \"alpha\": \"Alfa\",\n \"colorName\": \"{hue} {chroma} {lightness}\",\n \"transparentColorName\": \"{hue} {chroma} {lightness}, trasparenza {percentTransparent}\",\n \"very dark\": \"molto scuro\",\n \"dark\": \"scuro\",\n \"light\": \"chiaro\",\n \"very light\": \"molto chiaro\",\n \"pale\": \"tenue\",\n \"grayish\": \"grigiastro\",\n \"vibrant\": \"vivace\",\n \"black\": \"nero\",\n \"white\": \"bianco\",\n \"gray\": \"grigio\",\n \"pink\": \"rosa\",\n \"pink red\": \"rosa rosso\",\n \"red orange\": \"rosso arancio\",\n \"brown\": \"marrone\",\n \"orange\": \"arancio\",\n \"orange yellow\": \"giallo arancio\",\n \"brown yellow\": \"giallo bruno\",\n \"yellow\": \"giallo\",\n \"yellow green\": \"giallo verde\",\n \"green cyan\": \"verde ciano\",\n \"cyan\": \"ciano\",\n \"cyan blue\": \"blu ciano\",\n \"blue purple\": \"blu viola\",\n \"purple\": \"viola\",\n \"purple magenta\": \"viola magenta\",\n \"magenta\": \"magenta\",\n \"magenta pink\": \"rosa magenta\",\n },\n \"ja-JP\": {\n \"hue\": \"色相\",\n \"saturation\": \"彩度\",\n \"lightness\": \"明度\",\n \"brightness\": \"明るさ\",\n \"red\": \"赤\",\n \"green\": \"緑\",\n \"blue\": \"青\",\n \"alpha\": \"アルファ\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} 透明\",\n \"very dark\": \"最も暗い\",\n \"dark\": \"ダーク\",\n \"light\": \"ライト\",\n \"very light\": \"ベリーライト\",\n \"pale\": \"ペール\",\n \"grayish\": \"グレイッシュ\",\n \"vibrant\": \"鮮やか\",\n \"black\": \"ブラック\",\n \"white\": \"ホワイト\",\n \"gray\": \"グレー\",\n \"pink\": \"ピンク\",\n \"pink red\": \"ピンクレッド\",\n \"red orange\": \"レッドオレンジ\",\n \"brown\": \"ブラウン\",\n \"orange\": \"オレンジ\",\n \"orange yellow\": \"オレンジイエロー\",\n \"brown yellow\": \"ブラウンイエロー\",\n \"yellow\": \"イエロー\",\n \"yellow green\": \"イエローグリーン\",\n \"green cyan\": \"グリーンシアン\",\n \"cyan\": \"シアン\",\n \"cyan blue\": \"シアンブルー\",\n \"blue purple\": \"ブルーパープル\",\n \"purple\": \"パープル\",\n \"purple magenta\": \"パープルマゼンタ\",\n \"magenta\": \"マゼンタ\",\n \"magenta pink\": \"マゼンタピンク\",\n },\n \"ko-KR\": {\n \"hue\": \"색조\",\n \"saturation\": \"채도\",\n \"lightness\": \"밝기\",\n \"brightness\": \"명도\",\n \"red\": \"빨강\",\n \"green\": \"초록\",\n \"blue\": \"파랑\",\n \"alpha\": \"알파\",\n \"colorName\": \"{lightness}, {chroma}, {hue}\",\n \"transparentColorName\": \"{lightness}, {chroma}, {hue}, {percentTransparent} 투명도\",\n \"very dark\": \"매우 어두운\",\n \"dark\": \"다크\",\n \"light\": \"라이트\",\n \"very light\": \"매우 연함\",\n \"pale\": \"흙색\",\n \"grayish\": \"회갈색\",\n \"vibrant\": \"강렬한\",\n \"black\": \"검은색\",\n \"white\": \"흰색\",\n \"gray\": \"회색\",\n \"pink\": \"분홍색\",\n \"pink red\": \"핑크 레드\",\n \"red orange\": \"붉은 주황색\",\n \"brown\": \"갈색\",\n \"orange\": \"주황색\",\n \"orange yellow\": \"불그스름한 노랑\",\n \"brown yellow\": \"황갈색\",\n \"yellow\": \"노란색\",\n \"yellow green\": \"연두색\",\n \"green cyan\": \"청록색\",\n \"cyan\": \"청록색\",\n \"cyan blue\": \"청록색\",\n \"blue purple\": \"청자색\",\n \"purple\": \"자주색\",\n \"purple magenta\": \"보라빛 자홍색\",\n \"magenta\": \"자홍색\",\n \"magenta pink\": \"마젠타 핑크\",\n },\n \"lt-LT\": {\n \"hue\": \"Atspalvis\",\n \"saturation\": \"Įsotinimas\",\n \"lightness\": \"Šviesumas\",\n \"brightness\": \"Ryškumas\",\n \"red\": \"Raudona\",\n \"green\": \"Žalia\",\n \"blue\": \"Mėlyna\",\n \"alpha\": \"Alfa\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} skaidri\",\n \"very dark\": \"labai tamsi\",\n \"dark\": \"tamsi\",\n \"light\": \"šviesi\",\n \"very light\": \"labai šviesi\",\n \"pale\": \"blyški\",\n \"grayish\": \"pilkšva\",\n \"vibrant\": \"ryški\",\n \"black\": \"juoda\",\n \"white\": \"balta\",\n \"gray\": \"pilka\",\n \"pink\": \"rožinė\",\n \"pink red\": \"rožinė raudona\",\n \"red orange\": \"rausvai oranžinė\",\n \"brown\": \"ruda\",\n \"orange\": \"oranžinė\",\n \"orange yellow\": \"oranžinio atspalvio geltona\",\n \"brown yellow\": \"rusvai geltona\",\n \"yellow\": \"geltona\",\n \"yellow green\": \"gelsvai žalia\",\n \"green cyan\": \"žalsvai mėlyna\",\n \"cyan\": \"žalsvai mėlyna\",\n \"cyan blue\": \"žalsvai mėlyna\",\n \"blue purple\": \"melsvai violetinė\",\n \"purple\": \"violetinė\",\n \"purple magenta\": \"purpurinė rausvai raudona\",\n \"magenta\": \"rausvai raudona\",\n \"magenta pink\": \"purpurinė\",\n },\n \"lv-LV\": {\n \"hue\": \"Nokrāsa\",\n \"saturation\": \"Piesātinājums\",\n \"lightness\": \"Gaišums\",\n \"brightness\": \"Spilgtums\",\n \"red\": \"Sarkana\",\n \"green\": \"Zaļa\",\n \"blue\": \"Zila\",\n \"alpha\": \"Alfa\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} caurspīdīgs\",\n \"very dark\": \"ļoti tumšs\",\n \"dark\": \"tumšs\",\n \"light\": \"gaišs\",\n \"very light\": \"ļoti gaišs\",\n \"pale\": \"bāls\",\n \"grayish\": \"pelēcīgs\",\n \"vibrant\": \"košs\",\n \"black\": \"melns\",\n \"white\": \"balts\",\n \"gray\": \"pelēks\",\n \"pink\": \"rozā\",\n \"pink red\": \"rozīgi sarkans\",\n \"red orange\": \"sarkanīgi oranžs\",\n \"brown\": \"brūns\",\n \"orange\": \"oranžs\",\n \"orange yellow\": \"oranži dzeltens\",\n \"brown yellow\": \"brūni dzeltens\",\n \"yellow\": \"dzeltens\",\n \"yellow green\": \"dzelteni zaļš\",\n \"green cyan\": \"zaļš ciāns\",\n \"cyan\": \"ciāns\",\n \"cyan blue\": \"ciāna zils\",\n \"blue purple\": \"zili violets\",\n \"purple\": \"violets\",\n \"purple magenta\": \"violets fuksiju\",\n \"magenta\": \"fuksiju\",\n \"magenta pink\": \"fuksiju rozā\",\n },\n \"nb-NO\": {\n \"hue\": \"Fargetone\",\n \"saturation\": \"Metning\",\n \"lightness\": \"Lyshet\",\n \"brightness\": \"Lysstyrke\",\n \"red\": \"Rød\",\n \"green\": \"Grønn\",\n \"blue\": \"Blå\",\n \"alpha\": \"Alfa\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} gjennomsiktig\",\n \"very dark\": \"svært mørk\",\n \"dark\": \"mørk\",\n \"light\": \"lys\",\n \"very light\": \"svært lys\",\n \"pale\": \"blek\",\n \"grayish\": \"gråaktig\",\n \"vibrant\": \"levende\",\n \"black\": \"svart\",\n \"white\": \"hvit\",\n \"gray\": \"grå\",\n \"pink\": \"rosa\",\n \"pink red\": \"rosarød\",\n \"red orange\": \"rødoransje\",\n \"brown\": \"brun\",\n \"orange\": \"oransje\",\n \"orange yellow\": \"oransjegul\",\n \"brown yellow\": \"brungul\",\n \"yellow\": \"gul\",\n \"yellow green\": \"gulgrønn\",\n \"green cyan\": \"grønncyan\",\n \"cyan\": \"cyan\",\n \"cyan blue\": \"cyanblå\",\n \"blue purple\": \"blålilla\",\n \"purple\": \"lilla\",\n \"purple magenta\": \"lillamagenta\",\n \"magenta\": \"magenta\",\n \"magenta pink\": \"magentarosa\",\n },\n \"nl-NL\": {\n \"hue\": \"Kleurtoon\",\n \"saturation\": \"Verzadiging\",\n \"lightness\": \"Lichtsterkte\",\n \"brightness\": \"Helderheid\",\n \"red\": \"Rood\",\n \"green\": \"Groen\",\n \"blue\": \"Blauw\",\n \"alpha\": \"Alfa\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} transparant\",\n \"very dark\": \"heel donker\",\n \"dark\": \"donker\",\n \"light\": \"licht\",\n \"very light\": \"heel licht\",\n \"pale\": \"bleek\",\n \"grayish\": \"grijsachtig\",\n \"vibrant\": \"levendig\",\n \"black\": \"zwart\",\n \"white\": \"wit\",\n \"gray\": \"grijs\",\n \"pink\": \"roze\",\n \"pink red\": \"rozerood\",\n \"red orange\": \"roodoranje\",\n \"brown\": \"bruin\",\n \"orange\": \"oranje\",\n \"orange yellow\": \"oranjegeel\",\n \"brown yellow\": \"bruingeel\",\n \"yellow\": \"geel\",\n \"yellow green\": \"geelgroen\",\n \"green cyan\": \"cyaangroen\",\n \"cyan\": \"cyaan\",\n \"cyan blue\": \"cyaanblauw\",\n \"blue purple\": \"paarsblauw\",\n \"purple\": \"paars\",\n \"purple magenta\": \"magentapaars\",\n \"magenta\": \"magenta\",\n \"magenta pink\": \"magentaroze\",\n },\n \"pl-PL\": {\n \"hue\": \"Odcień\",\n \"saturation\": \"Nasycenie\",\n \"lightness\": \"Jaskrawość\",\n \"brightness\": \"Jasność\",\n \"red\": \"Czerwony\",\n \"green\": \"Zielony\",\n \"blue\": \"Niebieski\",\n \"alpha\": \"Alfa\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} przezroczystości\",\n \"very dark\": \"bardzo ciemny\",\n \"dark\": \"ciemny\",\n \"light\": \"jasny\",\n \"very light\": \"bardzo jasny\",\n \"pale\": \"blady\",\n \"grayish\": \"szarawy\",\n \"vibrant\": \"intensywny\",\n \"black\": \"czarny\",\n \"white\": \"biały\",\n \"gray\": \"szary\",\n \"pink\": \"różowy\",\n \"pink red\": \"różowo-czerwony\",\n \"red orange\": \"czerwono-pomarańczowy\",\n \"brown\": \"brązowy\",\n \"orange\": \"pomarańczowy\",\n \"orange yellow\": \"pomarańczowo-żółty\",\n \"brown yellow\": \"brązowo-żółty\",\n \"yellow\": \"żółty\",\n \"yellow green\": \"żółto-zielony\",\n \"green cyan\": \"zielono-cyjanowy\",\n \"cyan\": \"cyjanowy\",\n \"cyan blue\": \"cyjanowo-niebieski\",\n \"blue purple\": \"niebiesko-fioletowy\",\n \"purple\": \"fioletowy\",\n \"purple magenta\": \"fioletowo-purpurowy\",\n \"magenta\": \"purpurowy\",\n \"magenta pink\": \"purpurowo-różowy\",\n },\n \"pt-BR\": {\n \"hue\": \"Matiz\",\n \"saturation\": \"Saturação\",\n \"lightness\": \"Luminosidade\",\n \"brightness\": \"Brilho\",\n \"red\": \"Vermelho\",\n \"green\": \"Verde\",\n \"blue\": \"Azul\",\n \"alpha\": \"Alfa\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} transparente\",\n \"very dark\": \"muito escuro\",\n \"dark\": \"escuro\",\n \"light\": \"claro\",\n \"very light\": \"muito claro\",\n \"pale\": \"pálido\",\n \"grayish\": \"acinzentado\",\n \"vibrant\": \"vibrante\",\n \"black\": \"preto\",\n \"white\": \"branco\",\n \"gray\": \"cinza\",\n \"pink\": \"rosa\",\n \"pink red\": \"rosa avermelhado\",\n \"red orange\": \"laranja avermelhado\",\n \"brown\": \"marrom\",\n \"orange\": \"laranja\",\n \"orange yellow\": \"amarelo alaranjado\",\n \"brown yellow\": \"marrom amarelado\",\n \"yellow\": \"amarelo\",\n \"yellow green\": \"verde amarelado\",\n \"green cyan\": \"verde-ciano\",\n \"cyan\": \"ciano\",\n \"cyan blue\": \"azul-ciano\",\n \"blue purple\": \"roxo azulado\",\n \"purple\": \"roxo\",\n \"purple magenta\": \"roxo-magenta\",\n \"magenta\": \"magenta\",\n \"magenta pink\": \"rosa-magenta\",\n },\n \"pt-PT\": {\n \"hue\": \"Tonalidade\",\n \"saturation\": \"Saturação\",\n \"lightness\": \"Claridade\",\n \"brightness\": \"Luminosidade\",\n \"red\": \"Vermelho\",\n \"green\": \"Verde\",\n \"blue\": \"Azul\",\n \"alpha\": \"Alfa\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} transparente\",\n \"very dark\": \"muito escuro\",\n \"dark\": \"escuro\",\n \"light\": \"claro\",\n \"very light\": \"muito claro\",\n \"pale\": \"pálido\",\n \"grayish\": \"acinzentado\",\n \"vibrant\": \"vibrante\",\n \"black\": \"preto\",\n \"white\": \"branco\",\n \"gray\": \"cinzento\",\n \"pink\": \"cor-de-rosa\",\n \"pink red\": \"vermelho-rosa\",\n \"red orange\": \"laranja-vermelho\",\n \"brown\": \"castanho\",\n \"orange\": \"laranja\",\n \"orange yellow\": \"amarelo-laranja\",\n \"brown yellow\": \"amarelo-castanho\",\n \"yellow\": \"amarelo\",\n \"yellow green\": \"verde-amarelo\",\n \"green cyan\": \"verde-ciano\",\n \"cyan\": \"ciano\",\n \"cyan blue\": \"azul-ciano\",\n \"blue purple\": \"azul-púrpura\",\n \"purple\": \"púrpura\",\n \"purple magenta\": \"púrpura-magenta\",\n \"magenta\": \"magenta\",\n \"magenta pink\": \"rosa-magenta\",\n },\n \"ro-RO\": {\n \"hue\": \"Nuanță\",\n \"saturation\": \"Saturație\",\n \"lightness\": \"Luminozitate\",\n \"brightness\": \"Luminozitate\",\n \"red\": \"Roșu\",\n \"green\": \"Verde\",\n \"blue\": \"Albastru\",\n \"alpha\": \"Alfa\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} transparent\",\n \"very dark\": \"foarte închis\",\n \"dark\": \"închis\",\n \"light\": \"deschis\",\n \"very light\": \"foarte deschis\",\n \"pale\": \"pal\",\n \"grayish\": \"cenușiu\",\n \"vibrant\": \"plin de viață\",\n \"black\": \"negru\",\n \"white\": \"alb\",\n \"gray\": \"gri\",\n \"pink\": \"roz\",\n \"pink red\": \"roz-roșu\",\n \"red orange\": \"portocaliu-roșu\",\n \"brown\": \"maro\",\n \"orange\": \"portocaliu\",\n \"orange yellow\": \"galben-portocaliu\",\n \"brown yellow\": \"galben maro\",\n \"yellow\": \"galben\",\n \"yellow green\": \"galben-verde\",\n \"green cyan\": \"verde bleu\",\n \"cyan\": \"bleu\",\n \"cyan blue\": \"albastru-bleu\",\n \"blue purple\": \"albastru-violet\",\n \"purple\": \"violet\",\n \"purple magenta\": \"violet-fucsia\",\n \"magenta\": \"fucsia\",\n \"magenta pink\": \"roz-fucsia\",\n },\n \"ru-RU\": {\n \"hue\": \"Оттенок\",\n \"saturation\": \"Насыщенность\",\n \"lightness\": \"Освещенность\",\n \"brightness\": \"Яркость\",\n \"red\": \"Красный\",\n \"green\": \"Зеленый\",\n \"blue\": \"Синий\",\n \"alpha\": \"Альфа\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, прозрачный на {percentTransparent}\",\n \"very dark\": \"очень темный\",\n \"dark\": \"темный\",\n \"light\": \"светлый\",\n \"very light\": \"очень светлый\",\n \"pale\": \"бледный\",\n \"grayish\": \"сероватый\",\n \"vibrant\": \"яркий\",\n \"black\": \"черный\",\n \"white\": \"белый\",\n \"gray\": \"серый\",\n \"pink\": \"розовый\",\n \"pink red\": \"розово-красный\",\n \"red orange\": \"красно-оранжевый\",\n \"brown\": \"коричневый\",\n \"orange\": \"оранжевый\",\n \"orange yellow\": \"оранжево-желтый\",\n \"brown yellow\": \"коричнево-желтый\",\n \"yellow\": \"желтый\",\n \"yellow green\": \"желто-зеленый\",\n \"green cyan\": \"сине-зеленый\",\n \"cyan\": \"голубой\",\n \"cyan blue\": \"цвет морской волны\",\n \"blue purple\": \"сине-фиолетовый\",\n \"purple\": \"фиолетовый\",\n \"purple magenta\": \"фиолетово-пурпурный\",\n \"magenta\": \"пурпурный\",\n \"magenta pink\": \"пурпурно-розовый\",\n },\n \"sk-SK\": {\n \"hue\": \"Odtieň\",\n \"saturation\": \"Sýtosť\",\n \"lightness\": \"Svetlosť\",\n \"brightness\": \"Jas\",\n \"red\": \"Červená\",\n \"green\": \"Zelená\",\n \"blue\": \"Modrá\",\n \"alpha\": \"Alfa\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} priehľadná\",\n \"very dark\": \"veľmi tmavá\",\n \"dark\": \"tmavá\",\n \"light\": \"svetlá\",\n \"very light\": \"veľmi svetlá\",\n \"pale\": \"bledá\",\n \"grayish\": \"sivastá\",\n \"vibrant\": \"energická\",\n \"black\": \"čierna\",\n \"white\": \"biela\",\n \"gray\": \"sivá\",\n \"pink\": \"ružová\",\n \"pink red\": \"ružovočervená\",\n \"red orange\": \"červenooranžová\",\n \"brown\": \"hnedá\",\n \"orange\": \"oranžová\",\n \"orange yellow\": \"oranžovožltá\",\n \"brown yellow\": \"hnedožltá\",\n \"yellow\": \"žltá\",\n \"yellow green\": \"žltozelená\",\n \"green cyan\": \"zelená azúrová\",\n \"cyan\": \"azúrová\",\n \"cyan blue\": \"azúrová modrá\",\n \"blue purple\": \"modrofialová\",\n \"purple\": \"fialová\",\n \"purple magenta\": \"fialová purpurová\",\n \"magenta\": \"purpurová\",\n \"magenta pink\": \"ružová purpurová\",\n },\n \"sl-SI\": {\n \"hue\": \"Barva\",\n \"saturation\": \"Nasičenost\",\n \"lightness\": \"Lahkost\",\n \"brightness\": \"Svetlost\",\n \"red\": \"Rdeča\",\n \"green\": \"Zelena\",\n \"blue\": \"Modra\",\n \"alpha\": \"Alfa\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} prozorna\",\n \"very dark\": \"zelo temna\",\n \"dark\": \"temna\",\n \"light\": \"svetla\",\n \"very light\": \"zelo svetla\",\n \"pale\": \"bleda\",\n \"grayish\": \"sivkasta\",\n \"vibrant\": \"živahna\",\n \"black\": \"črna\",\n \"white\": \"bela\",\n \"gray\": \"siva\",\n \"pink\": \"roza\",\n \"pink red\": \"roza rdeča\",\n \"red orange\": \"rdeče oranžna\",\n \"brown\": \"rjava\",\n \"orange\": \"oranžna\",\n \"orange yellow\": \"oranžno rumena\",\n \"brown yellow\": \"rjavo rumena\",\n \"yellow\": \"rumena\",\n \"yellow green\": \"rumeno zelena\",\n \"green cyan\": \"zelena cian\",\n \"cyan\": \"cian\",\n \"cyan blue\": \"cian modra\",\n \"blue purple\": \"modro vijolična\",\n \"purple\": \"vijolična\",\n \"purple magenta\": \"vijolično škrlatna\",\n \"magenta\": \"škrlatna\",\n \"magenta pink\": \"škrlatno roza\",\n },\n \"sr-SP\": {\n \"hue\": \"Nijansa\",\n \"saturation\": \"Zasićenje\",\n \"lightness\": \"Osvetljenje\",\n \"brightness\": \"Osvetljenost\",\n \"red\": \"Crvena\",\n \"green\": \"Zelena\",\n \"blue\": \"Plava\",\n \"alpha\": \"Alfa\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} prozirna\",\n \"very dark\": \"veoma tamno\",\n \"dark\": \"tamno\",\n \"light\": \"svetla\",\n \"very light\": \"vrlo svetlo\",\n \"pale\": \"bledo\",\n \"grayish\": \"sivkasta\",\n \"vibrant\": \"živopisna\",\n \"black\": \"crno\",\n \"white\": \"bela\",\n \"gray\": \"siva\",\n \"pink\": \"ružičasta\",\n \"pink red\": \"ružičastocrvena\",\n \"red orange\": \"crvenonarandžasta\",\n \"brown\": \"smeđa\",\n \"orange\": \"narandžasta\",\n \"orange yellow\": \"narandžastožuta\",\n \"brown yellow\": \"smeđežuta\",\n \"yellow\": \"žuto\",\n \"yellow green\": \"žutozelena\",\n \"green cyan\": \"zeleno cijan\",\n \"cyan\": \"cijan\",\n \"cyan blue\": \"cijan plava\",\n \"blue purple\": \"plavoljubičasta\",\n \"purple\": \"ljubičasta\",\n \"purple magenta\": \"ljubičasta magenta\",\n \"magenta\": \"purpurnocrvena\",\n \"magenta pink\": \"magenta ružičasta\",\n },\n \"sv-SE\": {\n \"hue\": \"Nyans\",\n \"saturation\": \"Mättnad\",\n \"lightness\": \"Ljushet\",\n \"brightness\": \"Ljusstyrka\",\n \"red\": \"Rött\",\n \"green\": \"Grönt\",\n \"blue\": \"Blått\",\n \"alpha\": \"Alfa\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} genomskinlig\",\n \"very dark\": \"mycket mörk\",\n \"dark\": \"mörk\",\n \"light\": \"ljus\",\n \"very light\": \"mycket ljus\",\n \"pale\": \"blek\",\n \"grayish\": \"gråaktig\",\n \"vibrant\": \"livfull\",\n \"black\": \"svart\",\n \"white\": \"vit\",\n \"gray\": \"grå\",\n \"pink\": \"rosa\",\n \"pink red\": \"rosaröd\",\n \"red orange\": \"rödorange\",\n \"brown\": \"brun\",\n \"orange\": \"orange\",\n \"orange yellow\": \"orangegul\",\n \"brown yellow\": \"brungul\",\n \"yellow\": \"gul\",\n \"yellow green\": \"gulgrön\",\n \"green cyan\": \"grön cyan\",\n \"cyan\": \"cyan\",\n \"cyan blue\": \"cyanblå\",\n \"blue purple\": \"blålila\",\n \"purple\": \"lila\",\n \"purple magenta\": \"lila magenta\",\n \"magenta\": \"magenta\",\n \"magenta pink\": \"magentarosa\",\n },\n \"tr-TR\": {\n \"hue\": \"Ton\",\n \"saturation\": \"Doygunluk\",\n \"lightness\": \"Canlılık\",\n \"brightness\": \"Parlaklık\",\n \"red\": \"Kırmızı\",\n \"green\": \"Yeşil\",\n \"blue\": \"Mavi\",\n \"alpha\": \"Alfa\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} saydam\",\n \"very dark\": \"çok koyu\",\n \"dark\": \"koyu\",\n \"light\": \"açık\",\n \"very light\": \"çok açık\",\n \"pale\": \"solgun\",\n \"grayish\": \"grimsi\",\n \"vibrant\": \"canlı\",\n \"black\": \"siyah\",\n \"white\": \"beyaz\",\n \"gray\": \"gri\",\n \"pink\": \"pembe\",\n \"pink red\": \"pembe kırmızı\",\n \"red orange\": \"kırmızı portakal\",\n \"brown\": \"kahverengi\",\n \"orange\": \"turuncu\",\n \"orange yellow\": \"turuncu sarı\",\n \"brown yellow\": \"kahverengi sarı\",\n \"yellow\": \"sarı\",\n \"yellow green\": \"sarı yeşil\",\n \"green cyan\": \"yeşil camgöbeği\",\n \"cyan\": \"camgöbeği\",\n \"cyan blue\": \"camgöbeği mavi\",\n \"blue purple\": \"mavi mor\",\n \"purple\": \"mor\",\n \"purple magenta\": \"mor eflatun\",\n \"magenta\": \"eflatun\",\n \"magenta pink\": \"eflatun pembe\",\n },\n \"uk-UA\": {\n \"hue\": \"Тон\",\n \"saturation\": \"Насиченість\",\n \"lightness\": \"Освітленість\",\n \"brightness\": \"Яскравість\",\n \"red\": \"Червоний\",\n \"green\": \"Зелений\",\n \"blue\": \"Синій\",\n \"alpha\": \"Альфа\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, прозорий на {percentTransparent}\",\n \"very dark\": \"дуже темний\",\n \"dark\": \"темний\",\n \"light\": \"світлий\",\n \"very light\": \"дуже світлий\",\n \"pale\": \"блідий\",\n \"grayish\": \"сіруватий\",\n \"vibrant\": \"яскравий\",\n \"black\": \"чорний\",\n \"white\": \"білий\",\n \"gray\": \"сірий\",\n \"pink\": \"рожевий\",\n \"pink red\": \"рожево-червоний\",\n \"red orange\": \"червоно-помаранчевий\",\n \"brown\": \"коричневий\",\n \"orange\": \"помаранчевий\",\n \"orange yellow\": \"помаранчево-жовтий\",\n \"brown yellow\": \"коричнево-жовтий\",\n \"yellow\": \"жовтий\",\n \"yellow green\": \"жовто-зелений\",\n \"green cyan\": \"зелено-блакитний\",\n \"cyan\": \"блакитний\",\n \"cyan blue\": \"синьо-блакитний\",\n \"blue purple\": \"синьо-фіолетовий\",\n \"purple\": \"фіолетовий\",\n \"purple magenta\": \"фіолетово-пурпуровий\",\n \"magenta\": \"пурпуровий\",\n \"magenta pink\": \"пурпурово-рожевий\",\n },\n \"zh-CN\": {\n \"hue\": \"色相\",\n \"saturation\": \"饱和度\",\n \"lightness\": \"明亮度\",\n \"brightness\": \"亮度\",\n \"red\": \"红色\",\n \"green\": \"绿色\",\n \"blue\": \"蓝色\",\n \"alpha\": \"Alpha\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} 透明\",\n \"very dark\": \"很暗\",\n \"dark\": \"深色\",\n \"light\": \"浅色\",\n \"very light\": \"很浅\",\n \"pale\": \"苍白的\",\n \"grayish\": \"浅灰色的\",\n \"vibrant\": \"生机勃勃\",\n \"black\": \"黑色\",\n \"white\": \"白色\",\n \"gray\": \"灰色\",\n \"pink\": \"粉色\",\n \"pink red\": \"粉红色\",\n \"red orange\": \"红橙色\",\n \"brown\": \"棕色的\",\n \"orange\": \"橙色\",\n \"orange yellow\": \"橙黄色\",\n \"brown yellow\": \"棕黄色\",\n \"yellow\": \"黄色\",\n \"yellow green\": \"黄色/绿色\",\n \"green cyan\": \"绿青色\",\n \"cyan\": \"蓝绿色\",\n \"cyan blue\": \"青蓝色\",\n \"blue purple\": \"蓝紫色\",\n \"purple\": \"紫色\",\n \"purple magenta\": \"紫洋红色\",\n \"magenta\": \"紫红色\",\n \"magenta pink\": \"紫粉色\",\n },\n \"zh-TW\": {\n \"hue\": \"色相\",\n \"saturation\": \"飽和度\",\n \"lightness\": \"明亮\",\n \"brightness\": \"亮度\",\n \"red\": \"紅色\",\n \"green\": \"綠色\",\n \"blue\": \"藍色\",\n \"alpha\": \"Alpha\",\n \"colorName\": \"{lightness} {chroma} {hue}\",\n \"transparentColorName\": \"{lightness} {chroma} {hue}, {percentTransparent} 透明\",\n \"very dark\": \"很暗\",\n \"dark\": \"暗\",\n \"light\": \"淺\",\n \"very light\": \"很淺\",\n \"pale\": \"淡\",\n \"grayish\": \"偏灰\",\n \"vibrant\": \"鮮豔\",\n \"black\": \"黑\",\n \"white\": \"白\",\n \"gray\": \"灰\",\n \"pink\": \"粉紅\",\n \"pink red\": \"粉紅\",\n \"red orange\": \"橙紅\",\n \"brown\": \"棕\",\n \"orange\": \"橙\",\n \"orange yellow\": \"橙黃\",\n \"brown yellow\": \"棕黃\",\n \"yellow\": \"黃\",\n \"yellow green\": \"黃綠\",\n \"green cyan\": \"青綠\",\n \"cyan\": \"青\",\n \"cyan blue\": \"青藍\",\n \"blue purple\": \"藍紫\",\n \"purple\": \"紫\",\n \"purple magenta\": \"紫洋紅\",\n \"magenta\": \"洋紅\",\n \"magenta pink\": \"淺洋紅\",\n },\n};\n\nconst DEFAULT_LOCALE = \"en-US\";\n\n/**\n * Mirrors LocalizedStringDictionary.getStringForLocale: exact-locale match,\n * then language-only match (e.g. \"ar\" for \"ar-AE\"), then the en-US fallback.\n * Ported so solid-stately's Color needs no @internationalized/string dependency.\n */\nexport function getColorStringForLocale(key: ColorStringKey, locale: string): string {\n const exact = colorStrings[locale];\n if (exact) {\n return exact[key];\n }\n\n const language = locale.split(\"-\")[0];\n const match = Object.keys(colorStrings).find((l) => l.split(\"-\")[0] === language);\n if (match) {\n return colorStrings[match][key];\n }\n\n return colorStrings[DEFAULT_LOCALE][key];\n}\n\n/**\n * Mirrors LocalizedStringFormatter.format for the plain `{variable}` messages\n * used by color names (colorName / transparentColorName). Substitutes each\n * `{name}` token with the matching variable's string value.\n */\nexport function formatColorMessage(\n key: ColorStringKey,\n locale: string,\n variables: Record<string, string>\n): string {\n const message = getColorStringForLocale(key, locale);\n return message.replace(/\\{(\\w+)\\}/g, (_, name) =>\n variables[name] !== undefined ? variables[name] : \"\"\n );\n}\n","/**\n * Color class implementation.\n * Based on @react-stately/color.\n *\n * Provides color manipulation, conversion, and formatting.\n */\n\nimport type {\n Color,\n ColorFormat,\n ColorSpace,\n ColorChannel,\n ColorChannelRange,\n ColorAxes,\n RGBColor,\n HSLColor,\n HSBColor,\n} from \"./types\";\nimport {\n getColorStringForLocale,\n formatColorMessage,\n type ColorStringKey,\n} from \"./intl\";\n\n// Channel ranges\nconst RGB_CHANNEL_RANGE: ColorChannelRange = {\n minValue: 0,\n maxValue: 255,\n step: 1,\n pageSize: 17,\n};\n\nconst ALPHA_CHANNEL_RANGE: ColorChannelRange = {\n minValue: 0,\n maxValue: 1,\n step: 0.01,\n pageSize: 0.1,\n};\n\nconst HUE_CHANNEL_RANGE: ColorChannelRange = {\n minValue: 0,\n maxValue: 360,\n step: 1,\n pageSize: 15,\n};\n\nconst PERCENT_CHANNEL_RANGE: ColorChannelRange = {\n minValue: 0,\n maxValue: 100,\n step: 1,\n pageSize: 10,\n};\n\n// React Stately uses OKLCH for color names so that lightness is perceptually\n// consistent across hues.\nconst ORANGE_LIGHTNESS_THRESHOLD = 0.68;\nconst YELLOW_GREEN_LIGHTNESS_THRESHOLD = 0.85;\nconst MAX_DARK_LIGHTNESS = 0.55;\nconst GRAY_THRESHOLD = 0.001;\nconst OKLCH_HUES: Array<[number, string]> = [\n [0, \"pink\"],\n [15, \"red\"],\n [48, \"orange\"],\n [94, \"yellow\"],\n [135, \"green\"],\n [175, \"cyan\"],\n [264, \"blue\"],\n [284, \"purple\"],\n [320, \"magenta\"],\n [349, \"pink\"],\n];\n\n/**\n * Clamp a value to a range.\n */\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(Math.max(value, min), max);\n}\n\n/**\n * Round to fixed decimal places.\n */\nfunction toFixed(value: number, decimals: number): number {\n return Math.round(value * Math.pow(10, decimals)) / Math.pow(10, decimals);\n}\n\n/**\n * Convert RGB to HSL.\n */\nfunction rgbToHsl(r: number, g: number, b: number): { h: number; s: number; l: number } {\n r /= 255;\n g /= 255;\n b /= 255;\n\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n let h = 0;\n let s = 0;\n const l = (max + min) / 2;\n\n if (max !== min) {\n const d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n\n switch (max) {\n case r:\n h = ((g - b) / d + (g < b ? 6 : 0)) / 6;\n break;\n case g:\n h = ((b - r) / d + 2) / 6;\n break;\n case b:\n h = ((r - g) / d + 4) / 6;\n break;\n }\n }\n\n // 2-decimal precision mirrors upstream RGBColor.toHSL (toFixedNumber(_, 2)); the\n // old integer rounding silently shifted converted hues by up to half a degree,\n // which surfaced as a 1-LSB gradient divergence in ColorArea.\n return {\n h: toFixed(h * 360, 2),\n s: toFixed(s * 100, 2),\n l: toFixed(l * 100, 2),\n };\n}\n\n/**\n * Convert HSL to RGB. Mirrors upstream @react-stately/color HSLColor.toRGB\n * bit-for-bit — the Wikipedia \"HSL to RGB alternative\" formula\n * (https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative) — so the\n * float64 LSB rounding matches the oracle exactly. The classic hue2rgb algorithm\n * is equivalent in the reals but rounds a channel differently at .5 boundaries\n * (e.g. hsl(50,100%,50%) green computes to 212.5 → 213 here, 212 upstream).\n * h is in degrees [0,360]; s and l are percentages [0,100].\n */\nfunction hslToRgb(h: number, s: number, l: number): { r: number; g: number; b: number } {\n const saturation = s / 100;\n const lightness = l / 100;\n const a = saturation * Math.min(lightness, 1 - lightness);\n const fn = (n: number, k = (n + h / 30) % 12) =>\n lightness - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);\n\n return {\n r: Math.round(fn(0) * 255),\n g: Math.round(fn(8) * 255),\n b: Math.round(fn(4) * 255),\n };\n}\n\n/**\n * Convert RGB to HSB.\n */\nfunction rgbToHsb(r: number, g: number, b: number): { h: number; s: number; b: number } {\n r /= 255;\n g /= 255;\n b /= 255;\n\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n let h = 0;\n const v = max;\n const d = max - min;\n const s = max === 0 ? 0 : d / max;\n\n if (max !== min) {\n switch (max) {\n case r:\n h = ((g - b) / d + (g < b ? 6 : 0)) / 6;\n break;\n case g:\n h = ((b - r) / d + 2) / 6;\n break;\n case b:\n h = ((r - g) / d + 4) / 6;\n break;\n }\n }\n\n // 2-decimal precision mirrors upstream RGBColor.toHSB (toFixedNumber(_, 2)).\n return {\n h: toFixed(h * 360, 2),\n s: toFixed(s * 100, 2),\n b: toFixed(v * 100, 2),\n };\n}\n\n/**\n * Convert HSB (HSV) to RGB. Mirrors upstream @react-stately/color HSBColor.toRGB\n * bit-for-bit — the Wikipedia \"HSV to RGB alternative\" formula\n * (https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_RGB_alternative) — so the\n * float64 LSB rounding matches the oracle exactly. The classic sextant algorithm\n * is equivalent in the reals but can round a channel differently at .5 boundaries.\n * h is in degrees [0,360]; s and b are percentages [0,100].\n */\nfunction hsbToRgb(h: number, s: number, b: number): { r: number; g: number; b: number } {\n const saturation = s / 100;\n const brightness = b / 100;\n const fn = (n: number, k = (n + h / 60) % 6) =>\n brightness - saturation * brightness * Math.max(Math.min(k, 4 - k, 1), 0);\n\n return {\n r: Math.round(fn(5) * 255),\n g: Math.round(fn(3) * 255),\n b: Math.round(fn(1) * 255),\n };\n}\n\nfunction getOklchHueName(l: number, c: number, h: number, locale: string): [string, number] {\n if (c < GRAY_THRESHOLD) {\n return [getColorStringForLocale(\"gray\", locale), l];\n }\n\n for (let i = 0; i < OKLCH_HUES.length; i += 1) {\n let [hue, hueName] = OKLCH_HUES[i];\n const [nextHue, nextHueName] = OKLCH_HUES[i + 1] || [360, \"pink\"];\n if (h >= hue && h < nextHue) {\n if (hueName === \"orange\") {\n if (l < ORANGE_LIGHTNESS_THRESHOLD) {\n hueName = \"brown\";\n } else {\n l = l - ORANGE_LIGHTNESS_THRESHOLD + MAX_DARK_LIGHTNESS;\n }\n }\n\n if (h > hue + (nextHue - hue) / 2 && hueName !== nextHueName) {\n hueName = `${hueName} ${nextHueName}`;\n } else if (hueName === \"yellow\" && l < YELLOW_GREEN_LIGHTNESS_THRESHOLD) {\n hueName = \"yellow green\";\n }\n\n const name = getColorStringForLocale(hueName as ColorStringKey, locale).toLocaleLowerCase(\n locale\n );\n return [name, l];\n }\n }\n\n return [getColorStringForLocale(\"pink\", locale).toLocaleLowerCase(locale), l];\n}\n\nfunction getColorNameFromColor(color: Color, locale: string): string {\n let [l, c, h] = toOKLCH(color);\n\n if (l > 0.999) {\n return getColorStringForLocale(\"white\", locale);\n }\n\n if (l < 0.001) {\n return getColorStringForLocale(\"black\", locale);\n }\n\n let hue: string;\n [hue, l] = getOklchHueName(l, c, h, locale);\n\n let chroma = \"\";\n if (c <= 0.1 && c >= GRAY_THRESHOLD) {\n chroma = l >= 0.7 ? \"pale\" : \"grayish\";\n } else if (c >= 0.15) {\n chroma = \"vibrant\";\n }\n\n let lightness = \"\";\n if (l < 0.3) {\n lightness = \"very dark\";\n } else if (l < MAX_DARK_LIGHTNESS) {\n lightness = \"dark\";\n } else if (l < 0.7) {\n lightness = \"\";\n } else if (l < 0.85) {\n lightness = \"light\";\n } else {\n lightness = \"very light\";\n }\n\n if (chroma) {\n chroma = getColorStringForLocale(chroma as ColorStringKey, locale);\n }\n if (lightness) {\n lightness = getColorStringForLocale(lightness as ColorStringKey, locale);\n }\n\n const alpha = color.getChannelValue(\"alpha\");\n if (alpha < 1) {\n const percentTransparent = new Intl.NumberFormat(locale, { style: \"percent\" }).format(1 - alpha);\n return formatColorMessage(\"transparentColorName\", locale, {\n lightness,\n chroma,\n hue,\n percentTransparent,\n })\n .replace(/\\s+/g, \" \")\n .trim();\n }\n\n return formatColorMessage(\"colorName\", locale, { lightness, chroma, hue })\n .replace(/\\s+/g, \" \")\n .trim();\n}\n\nfunction getHueNameFromColor(color: Color, locale: string): string {\n const [l, c, h] = toOKLCH(color);\n const [name] = getOklchHueName(l, c, h, locale);\n return name;\n}\n\nfunction toOKLCH(color: Color): [number, number, number] {\n const rgb = color.toFormat(\"rgb\");\n let red = rgb.getChannelValue(\"red\") / 255;\n let green = rgb.getChannelValue(\"green\") / 255;\n let blue = rgb.getChannelValue(\"blue\") / 255;\n [red, green, blue] = linSRGB(red, green, blue);\n const [x, y, z] = linSRGBToXYZ(red, green, blue);\n const [l, a, b] = xyzToOKLab(x, y, z);\n return okLabToOKLCH(l, a, b);\n}\n\nfunction okLabToOKLCH(l: number, a: number, b: number): [number, number, number] {\n const hue = (Math.atan2(b, a) * 180) / Math.PI;\n return [l, Math.sqrt(a ** 2 + b ** 2), hue >= 0 ? hue : hue + 360];\n}\n\nfunction linSRGB(r: number, g: number, b: number): [number, number, number] {\n return [linSRGBComponent(r), linSRGBComponent(g), linSRGBComponent(b)];\n}\n\nfunction linSRGBComponent(value: number) {\n const sign = value < 0 ? -1 : 1;\n const abs = Math.abs(value);\n\n if (abs <= 0.04045) {\n return value / 12.92;\n }\n\n return sign * Math.pow((abs + 0.055) / 1.055, 2.4);\n}\n\nfunction linSRGBToXYZ(r: number, g: number, b: number): [number, number, number] {\n const matrix = [\n 506752 / 1228815,\n 87881 / 245763,\n 12673 / 70218,\n 87098 / 409605,\n 175762 / 245763,\n 12673 / 175545,\n 7918 / 409605,\n 87881 / 737289,\n 1001167 / 1053270,\n ];\n return multiplyMatrix(matrix, r, g, b);\n}\n\nfunction xyzToOKLab(x: number, y: number, z: number): [number, number, number] {\n const xyzToLMS = [\n 0.819022437996703, 0.3619062600528904, -0.1288737815209879, 0.0329836539323885,\n 0.9292868615863434, 0.0361446663506424, 0.0481771893596242, 0.2642395317527308,\n 0.6335478284694309,\n ];\n const lmsToOKLab = [\n 0.210454268309314, 0.7936177747023054, -0.0040720430116193, 1.9779985324311684,\n -2.4285922420485799, 0.450593709617411, 0.0259040424655478, 0.7827717124575296,\n -0.8086757549230774,\n ];\n\n const [a, b, c] = multiplyMatrix(xyzToLMS, x, y, z);\n return multiplyMatrix(lmsToOKLab, Math.cbrt(a), Math.cbrt(b), Math.cbrt(c));\n}\n\nfunction multiplyMatrix(\n matrix: number[],\n x: number,\n y: number,\n z: number,\n): [number, number, number] {\n const a = matrix[0] * x + matrix[1] * y + matrix[2] * z;\n const b = matrix[3] * x + matrix[4] * y + matrix[5] * z;\n const c = matrix[6] * x + matrix[7] * y + matrix[8] * z;\n return [a, b, c];\n}\n\n/**\n * RGB Color implementation.\n */\nclass RGBColorImpl implements Color {\n private red: number;\n private green: number;\n private blue: number;\n private alpha: number;\n\n constructor(red: number, green: number, blue: number, alpha: number = 1) {\n this.red = clamp(Math.round(red), 0, 255);\n this.green = clamp(Math.round(green), 0, 255);\n this.blue = clamp(Math.round(blue), 0, 255);\n this.alpha = clamp(toFixed(alpha, 2), 0, 1);\n }\n\n toFormat(format: ColorFormat): Color {\n switch (format) {\n case \"hex\":\n case \"hexa\":\n case \"rgb\":\n case \"rgba\":\n return this.clone();\n case \"hsl\":\n case \"hsla\": {\n const { h, s, l } = rgbToHsl(this.red, this.green, this.blue);\n return new HSLColorImpl(h, s, l, this.alpha);\n }\n case \"hsb\":\n case \"hsba\": {\n const { h, s, b } = rgbToHsb(this.red, this.green, this.blue);\n return new HSBColorImpl(h, s, b, this.alpha);\n }\n default:\n throw new Error(`Unsupported format: ${format}`);\n }\n }\n\n toString(format?: ColorFormat | \"css\"): string {\n const f = format ?? \"css\";\n\n switch (f) {\n case \"hex\":\n return `#${this.red.toString(16).padStart(2, \"0\")}${this.green.toString(16).padStart(2, \"0\")}${this.blue.toString(16).padStart(2, \"0\")}`;\n case \"hexa\":\n return `#${this.red.toString(16).padStart(2, \"0\")}${this.green.toString(16).padStart(2, \"0\")}${this.blue.toString(16).padStart(2, \"0\")}${Math.round(\n this.alpha * 255,\n )\n .toString(16)\n .padStart(2, \"0\")}`;\n case \"rgb\":\n return `rgb(${this.red}, ${this.green}, ${this.blue})`;\n case \"rgba\":\n case \"css\":\n return this.alpha === 1\n ? `rgb(${this.red}, ${this.green}, ${this.blue})`\n : `rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`;\n default:\n return this.toFormat(f as ColorFormat).toString(f);\n }\n }\n\n clone(): Color {\n return new RGBColorImpl(this.red, this.green, this.blue, this.alpha);\n }\n\n toHexInt(): number {\n return (this.red << 16) | (this.green << 8) | this.blue;\n }\n\n getChannelValue(channel: ColorChannel): number {\n switch (channel) {\n case \"red\":\n return this.red;\n case \"green\":\n return this.green;\n case \"blue\":\n return this.blue;\n case \"alpha\":\n return this.alpha;\n // Cross-color-space channels - convert to HSB\n case \"hue\":\n case \"saturation\":\n case \"brightness\":\n return this.toFormat(\"hsb\").getChannelValue(channel);\n case \"lightness\":\n return this.toFormat(\"hsl\").getChannelValue(channel);\n default:\n throw new Error(`Invalid channel: ${channel}`);\n }\n }\n\n withChannelValue(channel: ColorChannel, value: number): Color {\n switch (channel) {\n case \"red\":\n return new RGBColorImpl(value, this.green, this.blue, this.alpha);\n case \"green\":\n return new RGBColorImpl(this.red, value, this.blue, this.alpha);\n case \"blue\":\n return new RGBColorImpl(this.red, this.green, value, this.alpha);\n case \"alpha\":\n return new RGBColorImpl(this.red, this.green, this.blue, value);\n // Cross-color-space channels - convert, update, convert back\n case \"hue\":\n case \"saturation\":\n case \"brightness\":\n return this.toFormat(\"hsb\").withChannelValue(channel, value).toFormat(\"rgb\");\n case \"lightness\":\n return this.toFormat(\"hsl\").withChannelValue(channel, value).toFormat(\"rgb\");\n default:\n throw new Error(`Invalid channel: ${channel}`);\n }\n }\n\n getChannelRange(channel: ColorChannel): ColorChannelRange {\n switch (channel) {\n case \"red\":\n case \"green\":\n case \"blue\":\n return RGB_CHANNEL_RANGE;\n case \"alpha\":\n return ALPHA_CHANNEL_RANGE;\n case \"hue\":\n return HUE_CHANNEL_RANGE;\n case \"saturation\":\n case \"brightness\":\n case \"lightness\":\n return PERCENT_CHANNEL_RANGE;\n default:\n throw new Error(`Invalid channel: ${channel}`);\n }\n }\n\n getChannelName(channel: ColorChannel, locale: string): string {\n return getColorStringForLocale(channel as ColorStringKey, locale);\n }\n\n getChannelFormatOptions(channel: ColorChannel): Intl.NumberFormatOptions {\n if (channel === \"alpha\") {\n return { style: \"percent\" };\n }\n return { maximumFractionDigits: 0 };\n }\n\n formatChannelValue(channel: ColorChannel, locale: string): string {\n const value = this.getChannelValue(channel);\n const options = this.getChannelFormatOptions(channel);\n return new Intl.NumberFormat(locale, options).format(value);\n }\n\n getColorSpace(): ColorSpace {\n return \"rgb\";\n }\n\n getColorSpaceAxes(xyChannels?: { xChannel?: ColorChannel; yChannel?: ColorChannel }): ColorAxes {\n const xChannel = xyChannels?.xChannel ?? \"red\";\n const yChannel = xyChannels?.yChannel ?? \"green\";\n const channels: ColorChannel[] = [\"red\", \"green\", \"blue\"];\n const zChannel = channels.find((c) => c !== xChannel && c !== yChannel) ?? \"blue\";\n return { xChannel, yChannel, zChannel };\n }\n\n getColorChannels(): [ColorChannel, ColorChannel, ColorChannel] {\n return [\"red\", \"green\", \"blue\"];\n }\n\n getColorName(locale: string): string {\n return getColorNameFromColor(this, locale);\n }\n\n getHueName(locale: string): string {\n return getHueNameFromColor(this, locale);\n }\n}\n\n/**\n * HSL Color implementation.\n */\nclass HSLColorImpl implements Color {\n private hue: number;\n private saturation: number;\n private lightness: number;\n private alpha: number;\n\n constructor(hue: number, saturation: number, lightness: number, alpha: number = 1) {\n // Store raw like upstream HSLColor's constructor — precision comes from the\n // conversion (toFixed(_, 2)); rounding to integers here diverged from S2.\n this.hue = clamp(hue % 360, 0, 360);\n this.saturation = clamp(saturation, 0, 100);\n this.lightness = clamp(lightness, 0, 100);\n this.alpha = clamp(toFixed(alpha, 2), 0, 1);\n }\n\n toFormat(format: ColorFormat): Color {\n switch (format) {\n case \"hsl\":\n case \"hsla\":\n return this.clone();\n case \"hex\":\n case \"hexa\":\n case \"rgb\":\n case \"rgba\": {\n const { r, g, b } = hslToRgb(this.hue, this.saturation, this.lightness);\n return new RGBColorImpl(r, g, b, this.alpha);\n }\n case \"hsb\":\n case \"hsba\": {\n const { r, g, b } = hslToRgb(this.hue, this.saturation, this.lightness);\n const hsb = rgbToHsb(r, g, b);\n return new HSBColorImpl(hsb.h, hsb.s, hsb.b, this.alpha);\n }\n default:\n throw new Error(`Unsupported format: ${format}`);\n }\n }\n\n toString(format?: ColorFormat | \"css\"): string {\n const f = format ?? \"css\";\n\n switch (f) {\n case \"hsl\":\n return `hsl(${this.hue}, ${this.saturation}%, ${this.lightness}%)`;\n case \"hsla\":\n case \"css\":\n return this.alpha === 1\n ? `hsl(${this.hue}, ${this.saturation}%, ${this.lightness}%)`\n : `hsla(${this.hue}, ${this.saturation}%, ${this.lightness}%, ${this.alpha})`;\n default:\n return this.toFormat(f as ColorFormat).toString(f);\n }\n }\n\n clone(): Color {\n return new HSLColorImpl(this.hue, this.saturation, this.lightness, this.alpha);\n }\n\n toHexInt(): number {\n return this.toFormat(\"rgb\").toHexInt();\n }\n\n getChannelValue(channel: ColorChannel): number {\n switch (channel) {\n case \"hue\":\n return this.hue;\n case \"saturation\":\n return this.saturation;\n case \"lightness\":\n return this.lightness;\n case \"alpha\":\n return this.alpha;\n // Cross-color-space channels\n case \"red\":\n case \"green\":\n case \"blue\":\n return this.toFormat(\"rgb\").getChannelValue(channel);\n case \"brightness\":\n return this.toFormat(\"hsb\").getChannelValue(channel);\n default:\n throw new Error(`Invalid channel: ${channel}`);\n }\n }\n\n withChannelValue(channel: ColorChannel, value: number): Color {\n switch (channel) {\n case \"hue\":\n return new HSLColorImpl(value, this.saturation, this.lightness, this.alpha);\n case \"saturation\":\n return new HSLColorImpl(this.hue, value, this.lightness, this.alpha);\n case \"lightness\":\n return new HSLColorImpl(this.hue, this.saturation, value, this.alpha);\n case \"alpha\":\n return new HSLColorImpl(this.hue, this.saturation, this.lightness, value);\n // Cross-color-space channels\n case \"red\":\n case \"green\":\n case \"blue\":\n return this.toFormat(\"rgb\").withChannelValue(channel, value).toFormat(\"hsl\");\n case \"brightness\":\n return this.toFormat(\"hsb\").withChannelValue(channel, value).toFormat(\"hsl\");\n default:\n throw new Error(`Invalid channel: ${channel}`);\n }\n }\n\n getChannelRange(channel: ColorChannel): ColorChannelRange {\n switch (channel) {\n case \"hue\":\n return HUE_CHANNEL_RANGE;\n case \"saturation\":\n case \"lightness\":\n case \"brightness\":\n return PERCENT_CHANNEL_RANGE;\n case \"alpha\":\n return ALPHA_CHANNEL_RANGE;\n case \"red\":\n case \"green\":\n case \"blue\":\n return RGB_CHANNEL_RANGE;\n default:\n throw new Error(`Invalid channel: ${channel}`);\n }\n }\n\n getChannelName(channel: ColorChannel, locale: string): string {\n return getColorStringForLocale(channel as ColorStringKey, locale);\n }\n\n getChannelFormatOptions(channel: ColorChannel): Intl.NumberFormatOptions {\n if (channel === \"alpha\") {\n return { style: \"percent\" };\n }\n if (channel === \"hue\") {\n return { style: \"unit\", unit: \"degree\", unitDisplay: \"narrow\", maximumFractionDigits: 0 };\n }\n return { style: \"percent\", maximumFractionDigits: 0 };\n }\n\n formatChannelValue(channel: ColorChannel, locale: string): string {\n const value = this.getChannelValue(channel);\n const options = this.getChannelFormatOptions(channel);\n if (channel === \"saturation\" || channel === \"lightness\") {\n return new Intl.NumberFormat(locale, options).format(value / 100);\n }\n return new Intl.NumberFormat(locale, options).format(value);\n }\n\n getColorSpace(): ColorSpace {\n return \"hsl\";\n }\n\n getColorSpaceAxes(xyChannels?: { xChannel?: ColorChannel; yChannel?: ColorChannel }): ColorAxes {\n const xChannel = xyChannels?.xChannel ?? \"saturation\";\n const yChannel = xyChannels?.yChannel ?? \"lightness\";\n const channels: ColorChannel[] = [\"hue\", \"saturation\", \"lightness\"];\n const zChannel = channels.find((c) => c !== xChannel && c !== yChannel) ?? \"hue\";\n return { xChannel, yChannel, zChannel };\n }\n\n getColorChannels(): [ColorChannel, ColorChannel, ColorChannel] {\n return [\"hue\", \"saturation\", \"lightness\"];\n }\n\n getColorName(locale: string): string {\n return getColorNameFromColor(this, locale);\n }\n\n getHueName(locale: string): string {\n return getHueNameFromColor(this, locale);\n }\n}\n\n/**\n * HSB Color implementation.\n */\nclass HSBColorImpl implements Color {\n private hue: number;\n private saturation: number;\n private brightness: number;\n private alpha: number;\n\n constructor(hue: number, saturation: number, brightness: number, alpha: number = 1) {\n // Store raw like upstream HSBColor's constructor (see HSLColorImpl).\n this.hue = clamp(hue % 360, 0, 360);\n this.saturation = clamp(saturation, 0, 100);\n this.brightness = clamp(brightness, 0, 100);\n this.alpha = clamp(toFixed(alpha, 2), 0, 1);\n }\n\n toFormat(format: ColorFormat): Color {\n switch (format) {\n case \"hsb\":\n case \"hsba\":\n return this.clone();\n case \"hex\":\n case \"hexa\":\n case \"rgb\":\n case \"rgba\": {\n const { r, g, b } = hsbToRgb(this.hue, this.saturation, this.brightness);\n return new RGBColorImpl(r, g, b, this.alpha);\n }\n case \"hsl\":\n case \"hsla\": {\n const { r, g, b } = hsbToRgb(this.hue, this.saturation, this.brightness);\n const hsl = rgbToHsl(r, g, b);\n return new HSLColorImpl(hsl.h, hsl.s, hsl.l, this.alpha);\n }\n default:\n throw new Error(`Unsupported format: ${format}`);\n }\n }\n\n toString(format?: ColorFormat | \"css\"): string {\n const f = format ?? \"css\";\n\n switch (f) {\n case \"hsb\":\n return `hsb(${this.hue}, ${this.saturation}%, ${this.brightness}%)`;\n case \"hsba\":\n case \"css\":\n // HSB is not a standard CSS format, convert to RGB\n return this.toFormat(\"rgba\").toString(\"css\");\n default:\n return this.toFormat(f as ColorFormat).toString(f);\n }\n }\n\n clone(): Color {\n return new HSBColorImpl(this.hue, this.saturation, this.brightness, this.alpha);\n }\n\n toHexInt(): number {\n return this.toFormat(\"rgb\").toHexInt();\n }\n\n getChannelValue(channel: ColorChannel): number {\n switch (channel) {\n case \"hue\":\n return this.hue;\n case \"saturation\":\n return this.saturation;\n case \"brightness\":\n return this.brightness;\n case \"alpha\":\n return this.alpha;\n // Cross-color-space channels\n case \"red\":\n case \"green\":\n case \"blue\":\n return this.toFormat(\"rgb\").getChannelValue(channel);\n case \"lightness\":\n return this.toFormat(\"hsl\").getChannelValue(channel);\n default:\n throw new Error(`Invalid channel: ${channel}`);\n }\n }\n\n withChannelValue(channel: ColorChannel, value: number): Color {\n switch (channel) {\n case \"hue\":\n return new HSBColorImpl(value, this.saturation, this.brightness, this.alpha);\n case \"saturation\":\n return new HSBColorImpl(this.hue, value, this.brightness, this.alpha);\n case \"brightness\":\n return new HSBColorImpl(this.hue, this.saturation, value, this.alpha);\n case \"alpha\":\n return new HSBColorImpl(this.hue, this.saturation, this.brightness, value);\n // Cross-color-space channels\n case \"red\":\n case \"green\":\n case \"blue\":\n return this.toFormat(\"rgb\").withChannelValue(channel, value).toFormat(\"hsb\");\n case \"lightness\":\n return this.toFormat(\"hsl\").withChannelValue(channel, value).toFormat(\"hsb\");\n default:\n throw new Error(`Invalid channel: ${channel}`);\n }\n }\n\n getChannelRange(channel: ColorChannel): ColorChannelRange {\n switch (channel) {\n case \"hue\":\n return HUE_CHANNEL_RANGE;\n case \"saturation\":\n case \"brightness\":\n case \"lightness\":\n return PERCENT_CHANNEL_RANGE;\n case \"alpha\":\n return ALPHA_CHANNEL_RANGE;\n case \"red\":\n case \"green\":\n case \"blue\":\n return RGB_CHANNEL_RANGE;\n default:\n throw new Error(`Invalid channel: ${channel}`);\n }\n }\n\n getChannelName(channel: ColorChannel, locale: string): string {\n return getColorStringForLocale(channel as ColorStringKey, locale);\n }\n\n getChannelFormatOptions(channel: ColorChannel): Intl.NumberFormatOptions {\n if (channel === \"alpha\") {\n return { style: \"percent\" };\n }\n if (channel === \"hue\") {\n return { style: \"unit\", unit: \"degree\", unitDisplay: \"narrow\", maximumFractionDigits: 0 };\n }\n return { style: \"percent\", maximumFractionDigits: 0 };\n }\n\n formatChannelValue(channel: ColorChannel, locale: string): string {\n const value = this.getChannelValue(channel);\n const options = this.getChannelFormatOptions(channel);\n if (channel === \"saturation\" || channel === \"brightness\") {\n return new Intl.NumberFormat(locale, options).format(value / 100);\n }\n return new Intl.NumberFormat(locale, options).format(value);\n }\n\n getColorSpace(): ColorSpace {\n return \"hsb\";\n }\n\n getColorSpaceAxes(xyChannels?: { xChannel?: ColorChannel; yChannel?: ColorChannel }): ColorAxes {\n const xChannel = xyChannels?.xChannel ?? \"saturation\";\n const yChannel = xyChannels?.yChannel ?? \"brightness\";\n const channels: ColorChannel[] = [\"hue\", \"saturation\", \"brightness\"];\n const zChannel = channels.find((c) => c !== xChannel && c !== yChannel) ?? \"hue\";\n return { xChannel, yChannel, zChannel };\n }\n\n getColorChannels(): [ColorChannel, ColorChannel, ColorChannel] {\n return [\"hue\", \"saturation\", \"brightness\"];\n }\n\n getColorName(locale: string): string {\n return getColorNameFromColor(this, locale);\n }\n\n getHueName(locale: string): string {\n return getHueNameFromColor(this, locale);\n }\n}\n\n/**\n * Parse a color string into a Color object.\n */\nexport function parseColor(value: string): Color {\n const trimmed = value.trim().toLowerCase();\n\n // Hex format\n if (trimmed.startsWith(\"#\")) {\n const hex = trimmed.slice(1);\n if (!/^[0-9a-f]+$/i.test(hex)) {\n throw new Error(`Invalid hex color: ${value}`);\n }\n if (hex.length === 3) {\n const r = parseInt(hex[0] + hex[0], 16);\n const g = parseInt(hex[1] + hex[1], 16);\n const b = parseInt(hex[2] + hex[2], 16);\n return new RGBColorImpl(r, g, b);\n }\n if (hex.length === 4) {\n const r = parseInt(hex[0] + hex[0], 16);\n const g = parseInt(hex[1] + hex[1], 16);\n const b = parseInt(hex[2] + hex[2], 16);\n const a = parseInt(hex[3] + hex[3], 16) / 255;\n return new RGBColorImpl(r, g, b, a);\n }\n if (hex.length === 6) {\n const r = parseInt(hex.slice(0, 2), 16);\n const g = parseInt(hex.slice(2, 4), 16);\n const b = parseInt(hex.slice(4, 6), 16);\n return new RGBColorImpl(r, g, b);\n }\n if (hex.length === 8) {\n const r = parseInt(hex.slice(0, 2), 16);\n const g = parseInt(hex.slice(2, 4), 16);\n const b = parseInt(hex.slice(4, 6), 16);\n const a = parseInt(hex.slice(6, 8), 16) / 255;\n return new RGBColorImpl(r, g, b, a);\n }\n throw new Error(`Invalid hex color: ${value}`);\n }\n\n // RGB/RGBA format\n const rgbMatch = trimmed.match(\n /^rgba?\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*(?:,\\s*([\\d.]+))?\\s*\\)$/,\n );\n if (rgbMatch) {\n const r = parseInt(rgbMatch[1], 10);\n const g = parseInt(rgbMatch[2], 10);\n const b = parseInt(rgbMatch[3], 10);\n const a = rgbMatch[4] !== undefined ? parseFloat(rgbMatch[4]) : 1;\n return new RGBColorImpl(r, g, b, a);\n }\n\n // HSL/HSLA format\n const hslMatch = trimmed.match(\n /^hsla?\\(\\s*(\\d+)\\s*,\\s*(\\d+)%\\s*,\\s*(\\d+)%\\s*(?:,\\s*([\\d.]+))?\\s*\\)$/,\n );\n if (hslMatch) {\n const h = parseInt(hslMatch[1], 10);\n const s = parseInt(hslMatch[2], 10);\n const l = parseInt(hslMatch[3], 10);\n const a = hslMatch[4] !== undefined ? parseFloat(hslMatch[4]) : 1;\n return new HSLColorImpl(h, s, l, a);\n }\n\n // HSB/HSBA format\n const hsbMatch = trimmed.match(\n /^hsba?\\(\\s*(\\d+)\\s*,\\s*(\\d+)%\\s*,\\s*(\\d+)%\\s*(?:,\\s*([\\d.]+))?\\s*\\)$/,\n );\n if (hsbMatch) {\n const h = parseInt(hsbMatch[1], 10);\n const s = parseInt(hsbMatch[2], 10);\n const b = parseInt(hsbMatch[3], 10);\n const a = hsbMatch[4] !== undefined ? parseFloat(hsbMatch[4]) : 1;\n return new HSBColorImpl(h, s, b, a);\n }\n\n throw new Error(`Invalid color format: ${value}`);\n}\n\n/**\n * Create an RGB color.\n */\nexport function createRGBColor(red: number, green: number, blue: number, alpha: number = 1): Color {\n return new RGBColorImpl(red, green, blue, alpha);\n}\n\n/**\n * Create an HSL color.\n */\nexport function createHSLColor(\n hue: number,\n saturation: number,\n lightness: number,\n alpha: number = 1,\n): Color {\n return new HSLColorImpl(hue, saturation, lightness, alpha);\n}\n\n/**\n * Create an HSB color.\n */\nexport function createHSBColor(\n hue: number,\n saturation: number,\n brightness: number,\n alpha: number = 1,\n): Color {\n return new HSBColorImpl(hue, saturation, brightness, alpha);\n}\n\n/**\n * Normalize a color value (string or Color) to a Color object.\n */\nexport function normalizeColor(value: string | Color): Color {\n if (typeof value === \"string\") {\n return parseColor(value);\n }\n return value;\n}\n","/**\n * ColorSlider state management.\n * Based on @react-stately/color useColorSliderState.\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport type { Color, ColorChannel, ColorSpace } from \"./types\";\nimport { normalizeColor } from \"./Color\";\n\nexport type ColorSliderOrientation = \"horizontal\" | \"vertical\";\n\nexport interface ColorSliderStateOptions {\n /** The current color value (controlled). */\n value?: Color | string;\n /** The default color value (uncontrolled). */\n defaultValue?: Color | string;\n /** Handler called when the color changes. */\n onChange?: (color: Color) => void;\n /** Handler called when dragging ends. */\n onChangeEnd?: (color: Color) => void;\n /** The color channel this slider controls. */\n channel: ColorChannel;\n /** The color space to use for channel values. */\n colorSpace?: ColorSpace;\n /** The slider orientation. */\n orientation?: ColorSliderOrientation;\n /** Whether the slider is disabled. */\n isDisabled?: boolean;\n /** The locale for formatting. */\n locale?: string;\n}\n\nexport interface ColorSliderState {\n /** The current color value. */\n readonly value: Color;\n /** Whether the slider is being dragged. */\n readonly isDragging: boolean;\n /** The color channel being controlled. */\n readonly channel: ColorChannel;\n /** The slider orientation. */\n readonly orientation: ColorSliderOrientation;\n /** The step value for the channel. */\n readonly step: number;\n /** The page step value for the channel. */\n readonly pageSize: number;\n /** The minimum value for the channel. */\n readonly minValue: number;\n /** The maximum value for the channel. */\n readonly maxValue: number;\n /** Whether the slider is disabled. */\n readonly isDisabled: boolean;\n\n /** Get the current channel value. */\n getThumbValue(): number;\n /** Get the minimum percent. */\n getThumbMinValue(): number;\n /** Get the maximum percent. */\n getThumbMaxValue(): number;\n /** Get the thumb value as a percentage. */\n getThumbPercent(): number;\n /** Set the channel value. */\n setThumbValue(value: number): void;\n /** Set the thumb value from a percentage (0-1). */\n setThumbPercent(percent: number): void;\n /** Increment the channel value. */\n incrementThumb(stepSize?: number): void;\n /** Decrement the channel value. */\n decrementThumb(stepSize?: number): void;\n /** Set the dragging state. */\n setDragging(isDragging: boolean): void;\n /** Get the display color (with alpha = 1). */\n getDisplayColor(): Color;\n /** Get the formatted value label. */\n getThumbValueLabel(): string;\n}\n\n/**\n * Creates state for a color slider.\n */\nexport function createColorSliderState(\n options: Accessor<ColorSliderStateOptions>,\n): ColorSliderState {\n const getOptions = () => options();\n\n const normalizeValue = (value: Color | string) => {\n const color = normalizeColor(value);\n const colorSpace = getOptions().colorSpace;\n return colorSpace ? color.toFormat(colorSpace) : color;\n };\n\n // Internal value state\n const [internalValue, setInternalValue] = createSignal<Color | null>(null);\n const [isDragging, setIsDragging] = createSignal(false);\n\n // Initialize internal value\n const initValue = () => {\n const opts = getOptions();\n if (opts.defaultValue) {\n return normalizeValue(opts.defaultValue);\n }\n return null;\n };\n\n // Set initial value\n if (internalValue() === null) {\n const init = initValue();\n if (init) {\n setInternalValue(init);\n }\n }\n\n // Controlled vs uncontrolled value\n const value = createMemo(() => {\n const opts = getOptions();\n if (opts.value !== undefined) {\n return normalizeValue(opts.value);\n }\n const fallback = internalValue() ?? normalizeValue(\"#ff0000\");\n return opts.colorSpace ? fallback.toFormat(opts.colorSpace) : fallback;\n });\n\n const channel = createMemo(() => getOptions().channel);\n const orientation = createMemo<ColorSliderOrientation>(\n () => getOptions().orientation ?? \"horizontal\",\n );\n const isDisabled = createMemo(() => getOptions().isDisabled ?? false);\n const locale = createMemo(() => getOptions().locale ?? \"en-US\");\n\n // Get channel range\n const channelRange = createMemo(() => value().getChannelRange(channel()));\n\n const step = createMemo(() => channelRange().step);\n const pageSize = createMemo(() => channelRange().pageSize);\n const minValue = createMemo(() => channelRange().minValue);\n const maxValue = createMemo(() => channelRange().maxValue);\n\n // Update value\n const updateValue = (newColor: Color) => {\n const opts = getOptions();\n const nextColor = opts.colorSpace ? newColor.toFormat(opts.colorSpace) : newColor;\n\n // Controlled mode\n if (opts.value !== undefined) {\n opts.onChange?.(nextColor);\n return;\n }\n\n // Uncontrolled mode\n setInternalValue(nextColor);\n opts.onChange?.(nextColor);\n };\n\n // Get thumb value\n const getThumbValue = () => {\n return value().getChannelValue(channel());\n };\n\n // Get min/max values\n const getThumbMinValue = () => minValue();\n const getThumbMaxValue = () => maxValue();\n\n // Get thumb percent\n const getThumbPercent = () => {\n const val = getThumbValue();\n const min = minValue();\n const max = maxValue();\n return (val - min) / (max - min);\n };\n\n // Set thumb value\n const setThumbValue = (newValue: number) => {\n const min = minValue();\n const max = maxValue();\n const stepValue = step();\n const clamped = Math.max(min, Math.min(max, newValue));\n const precision = `${stepValue}`.split(\".\")[1]?.length ?? 0;\n const rounded = Number(\n (Math.round((clamped - min) / stepValue) * stepValue + min).toFixed(precision),\n );\n const newColor = value().withChannelValue(channel(), rounded);\n updateValue(newColor);\n };\n\n // Set thumb from percent\n const setThumbPercent = (percent: number) => {\n const min = minValue();\n const max = maxValue();\n const val = min + (max - min) * percent;\n setThumbValue(val);\n };\n\n // Increment\n const incrementThumb = (stepSize?: number) => {\n const s = stepSize ?? step();\n setThumbValue(getThumbValue() + s);\n };\n\n // Decrement\n const decrementThumb = (stepSize?: number) => {\n const s = stepSize ?? step();\n setThumbValue(getThumbValue() - s);\n };\n\n // Set dragging\n const setDraggingState = (dragging: boolean) => {\n const wasDragging = isDragging();\n setIsDragging(dragging);\n\n // Call onChangeEnd when dragging ends\n if (wasDragging && !dragging) {\n getOptions().onChangeEnd?.(value());\n }\n };\n\n // Get display color (alpha = 1)\n const getDisplayColor = () => {\n const v = value();\n if (channel() === \"hue\") {\n return normalizeColor(`hsl(${v.getChannelValue(\"hue\")}, 100%, 50%)`);\n }\n return v.withChannelValue(\"alpha\", 1);\n };\n\n // Get formatted value label\n const getThumbValueLabel = () => {\n const v = value();\n const ch = channel();\n const loc = locale();\n return v.formatChannelValue(ch, loc);\n };\n\n return {\n get value() {\n return value();\n },\n get isDragging() {\n return isDragging();\n },\n get channel() {\n return channel();\n },\n get orientation() {\n return orientation();\n },\n get step() {\n return step();\n },\n get pageSize() {\n return pageSize();\n },\n get minValue() {\n return minValue();\n },\n get maxValue() {\n return maxValue();\n },\n get isDisabled() {\n return isDisabled();\n },\n getThumbValue,\n getThumbMinValue,\n getThumbMaxValue,\n getThumbPercent,\n setThumbValue,\n setThumbPercent,\n incrementThumb,\n decrementThumb,\n setDragging: setDraggingState,\n getDisplayColor,\n getThumbValueLabel,\n };\n}\n","/**\n * ColorArea state management.\n * Based on @react-stately/color useColorAreaState.\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport type { Color, ColorChannel, ColorAxes, ColorSpace } from \"./types\";\nimport { normalizeColor } from \"./Color\";\n\nexport interface ColorAreaStateOptions {\n /** The current color value (controlled). */\n value?: Color | string;\n /** The default color value (uncontrolled). */\n defaultValue?: Color | string;\n /** Handler called when the color changes. */\n onChange?: (color: Color) => void;\n /** Handler called when dragging ends. */\n onChangeEnd?: (color: Color) => void;\n /** The color channel for the X axis. */\n xChannel?: ColorChannel;\n /** The color channel for the Y axis. */\n yChannel?: ColorChannel;\n /** The color space to use for the color area. */\n colorSpace?: ColorSpace;\n /** Whether the area is disabled. */\n isDisabled?: boolean;\n}\n\nexport interface ColorAreaState {\n /** The current color value. */\n readonly value: Color;\n /** The X axis channel. */\n readonly xChannel: ColorChannel;\n /** The Y axis channel. */\n readonly yChannel: ColorChannel;\n /** The Z axis channel (the third channel). */\n readonly zChannel: ColorChannel;\n /** Whether the area is being dragged. */\n readonly isDragging: boolean;\n /** Whether the area is disabled. */\n readonly isDisabled: boolean;\n /** Step for X channel. */\n readonly xChannelStep: number;\n /** Step for Y channel. */\n readonly yChannelStep: number;\n /** Page step for X channel. */\n readonly xChannelPageStep: number;\n /** Page step for Y channel. */\n readonly yChannelPageStep: number;\n\n /** Get the X channel value. */\n getXValue(): number;\n /** Get the Y channel value. */\n getYValue(): number;\n /** Set the X channel value. */\n setXValue(value: number): void;\n /** Set the Y channel value. */\n setYValue(value: number): void;\n /** Set color from a point (0-1, 0-1). */\n setColorFromPoint(x: number, y: number): void;\n /** Get the thumb position as percentages. */\n getThumbPosition(): { x: number; y: number };\n /** Increment X value. */\n incrementX(stepSize?: number): void;\n /** Decrement X value. */\n decrementX(stepSize?: number): void;\n /** Increment Y value. */\n incrementY(stepSize?: number): void;\n /** Decrement Y value. */\n decrementY(stepSize?: number): void;\n /** Set the dragging state. */\n setDragging(isDragging: boolean): void;\n /** Get the display color (with alpha = 1). */\n getDisplayColor(): Color;\n}\n\n/**\n * Creates state for a color area (2D color picker).\n */\nexport function createColorAreaState(options: Accessor<ColorAreaStateOptions>): ColorAreaState {\n const getOptions = () => options();\n\n const normalizeValue = (value: Color | string) => {\n const color = normalizeColor(value);\n const colorSpace = getOptions().colorSpace;\n return colorSpace ? color.toFormat(colorSpace) : color;\n };\n\n // Internal value state\n const [internalValue, setInternalValue] = createSignal<Color | null>(null);\n const [isDragging, setIsDragging] = createSignal(false);\n\n // Initialize internal value\n const initValue = () => {\n const opts = getOptions();\n if (opts.defaultValue) {\n return normalizeValue(opts.defaultValue);\n }\n return null;\n };\n\n // Set initial value\n if (internalValue() === null) {\n const init = initValue();\n if (init) {\n setInternalValue(init);\n }\n }\n\n // Controlled vs uncontrolled value\n const value = createMemo(() => {\n const opts = getOptions();\n if (opts.value !== undefined) {\n return normalizeValue(opts.value);\n }\n const fallback = internalValue() ?? normalizeValue(\"#ff0000\");\n return opts.colorSpace ? fallback.toFormat(opts.colorSpace) : fallback;\n });\n\n const isDisabled = createMemo(() => getOptions().isDisabled ?? false);\n\n // Get color axes\n const axes = createMemo<ColorAxes>(() => {\n const opts = getOptions();\n return value().getColorSpaceAxes({\n xChannel: opts.xChannel,\n yChannel: opts.yChannel,\n });\n });\n\n const xChannel = createMemo(() => axes().xChannel);\n const yChannel = createMemo(() => axes().yChannel);\n const zChannel = createMemo(() => axes().zChannel);\n\n // Get channel ranges\n const xRange = createMemo(() => value().getChannelRange(xChannel()));\n const yRange = createMemo(() => value().getChannelRange(yChannel()));\n\n const xChannelStep = createMemo(() => xRange().step);\n const yChannelStep = createMemo(() => yRange().step);\n const xChannelPageStep = createMemo(() => xRange().pageSize);\n const yChannelPageStep = createMemo(() => yRange().pageSize);\n\n // Update value\n const updateValue = (newColor: Color) => {\n const opts = getOptions();\n const nextColor = opts.colorSpace ? newColor.toFormat(opts.colorSpace) : newColor;\n\n // Controlled mode\n if (opts.value !== undefined) {\n opts.onChange?.(nextColor);\n return;\n }\n\n // Uncontrolled mode\n setInternalValue(nextColor);\n opts.onChange?.(nextColor);\n };\n\n // Get X value\n const getXValue = () => value().getChannelValue(xChannel());\n\n // Get Y value\n const getYValue = () => value().getChannelValue(yChannel());\n\n // Set X value\n const setXValue = (newValue: number) => {\n const range = xRange();\n const clamped = Math.max(range.minValue, Math.min(range.maxValue, newValue));\n const rounded = Math.round(clamped / range.step) * range.step;\n const newColor = value().withChannelValue(xChannel(), rounded);\n updateValue(newColor);\n };\n\n // Set Y value\n const setYValue = (newValue: number) => {\n const range = yRange();\n const clamped = Math.max(range.minValue, Math.min(range.maxValue, newValue));\n const rounded = Math.round(clamped / range.step) * range.step;\n const newColor = value().withChannelValue(yChannel(), rounded);\n updateValue(newColor);\n };\n\n // Set color from point (x: 0-1, y: 0-1)\n const setColorFromPoint = (x: number, y: number) => {\n const xR = xRange();\n const yR = yRange();\n\n const xVal = xR.minValue + (xR.maxValue - xR.minValue) * x;\n const yVal = yR.minValue + (yR.maxValue - yR.minValue) * (1 - y); // Y is inverted\n\n const xClamped = Math.max(xR.minValue, Math.min(xR.maxValue, xVal));\n const yClamped = Math.max(yR.minValue, Math.min(yR.maxValue, yVal));\n\n const xRounded = Math.round(xClamped / xR.step) * xR.step;\n const yRounded = Math.round(yClamped / yR.step) * yR.step;\n\n const newColor = value()\n .withChannelValue(xChannel(), xRounded)\n .withChannelValue(yChannel(), yRounded);\n updateValue(newColor);\n };\n\n // Get thumb position as percentages\n const getThumbPosition = () => {\n const xR = xRange();\n const yR = yRange();\n const xVal = getXValue();\n const yVal = getYValue();\n\n return {\n x: (xVal - xR.minValue) / (xR.maxValue - xR.minValue),\n y: 1 - (yVal - yR.minValue) / (yR.maxValue - yR.minValue), // Y is inverted\n };\n };\n\n // Increment X\n const incrementX = (stepSize?: number) => {\n const s = stepSize ?? xChannelStep();\n setXValue(getXValue() + s);\n };\n\n // Decrement X\n const decrementX = (stepSize?: number) => {\n const s = stepSize ?? xChannelStep();\n setXValue(getXValue() - s);\n };\n\n // Increment Y\n const incrementY = (stepSize?: number) => {\n const s = stepSize ?? yChannelStep();\n setYValue(getYValue() + s);\n };\n\n // Decrement Y\n const decrementY = (stepSize?: number) => {\n const s = stepSize ?? yChannelStep();\n setYValue(getYValue() - s);\n };\n\n // Set dragging\n const setDraggingState = (dragging: boolean) => {\n const wasDragging = isDragging();\n setIsDragging(dragging);\n\n // Call onChangeEnd when dragging ends\n if (wasDragging && !dragging) {\n getOptions().onChangeEnd?.(value());\n }\n };\n\n // Get display color (alpha = 1)\n const getDisplayColor = () => {\n return value().withChannelValue(\"alpha\", 1);\n };\n\n return {\n get value() {\n return value();\n },\n get xChannel() {\n return xChannel();\n },\n get yChannel() {\n return yChannel();\n },\n get zChannel() {\n return zChannel();\n },\n get isDragging() {\n return isDragging();\n },\n get isDisabled() {\n return isDisabled();\n },\n get xChannelStep() {\n return xChannelStep();\n },\n get yChannelStep() {\n return yChannelStep();\n },\n get xChannelPageStep() {\n return xChannelPageStep();\n },\n get yChannelPageStep() {\n return yChannelPageStep();\n },\n getXValue,\n getYValue,\n setXValue,\n setYValue,\n setColorFromPoint,\n getThumbPosition,\n incrementX,\n decrementX,\n incrementY,\n decrementY,\n setDragging: setDraggingState,\n getDisplayColor,\n };\n}\n","/**\n * ColorWheel state management.\n * Based on @react-stately/color useColorWheelState.\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport type { Color } from \"./types\";\nimport { createHSLColor, normalizeColor } from \"./Color\";\n\nexport interface ColorWheelStateOptions {\n /** The current color value (controlled). */\n value?: Color | string;\n /** The default color value (uncontrolled). */\n defaultValue?: Color | string;\n /** Handler called when the color changes. */\n onChange?: (color: Color) => void;\n /** Handler called when dragging ends. */\n onChangeEnd?: (color: Color) => void;\n /** Whether the wheel is disabled. */\n isDisabled?: boolean;\n}\n\nexport interface ColorWheelState {\n /** The current color value. */\n readonly value: Color;\n /** The initial color value. */\n readonly defaultValue: Color;\n /** Whether the wheel is being dragged. */\n readonly isDragging: boolean;\n /** Whether the wheel is disabled. */\n readonly isDisabled: boolean;\n /** Step value for hue changes. */\n readonly step: number;\n /** Page step value for hue changes. */\n readonly pageStep: number;\n\n /** Get the current hue value (0-360). */\n getHue(): number;\n /** Set the full color value. */\n setValue(value: Color | string): void;\n /** Set the hue value. */\n setHue(value: number): void;\n /** Set hue from an angle in radians. */\n setHueFromAngle(angle: number): void;\n /** Set hue from a point relative to the wheel center. */\n setHueFromPoint(x: number, y: number, radius: number): void;\n /** Get the thumb angle in radians (0 = right, increases counterclockwise). */\n getThumbAngle(): number;\n /** Get the thumb position relative to the wheel center. */\n getThumbPosition(radius: number): { x: number; y: number };\n /** Increment hue value. */\n increment(stepSize?: number): void;\n /** Decrement hue value. */\n decrement(stepSize?: number): void;\n /** Set the dragging state. */\n setDragging(isDragging: boolean): void;\n /** Get the display color (with full saturation/brightness for wheel). */\n getDisplayColor(): Color;\n}\n\n/**\n * Creates state for a color wheel (circular hue picker).\n */\nexport function createColorWheelState(options: Accessor<ColorWheelStateOptions>): ColorWheelState {\n const getOptions = () => options();\n const defaultColor = createHSLColor(0, 100, 50);\n\n const normalizeWheelValue = (color: Color | string) => {\n const value = normalizeColor(color);\n return value.toFormat(value.getColorSpace() === \"hsb\" ? \"hsb\" : \"hsl\");\n };\n\n const initialValue = normalizeWheelValue(getOptions().defaultValue ?? defaultColor);\n const [internalValue, setInternalValue] = createSignal<Color>(initialValue);\n const [isDragging, setIsDragging] = createSignal(false);\n let valueRef = initialValue;\n\n // Controlled vs uncontrolled value\n const value = createMemo(() => {\n const opts = getOptions();\n const nextValue = opts.value !== undefined ? normalizeWheelValue(opts.value) : internalValue();\n valueRef = nextValue;\n return nextValue;\n });\n\n const isDisabled = createMemo(() => getOptions().isDisabled ?? false);\n\n // Hue step and page step\n const hueRange = createMemo(() => value().getChannelRange(\"hue\"));\n const step = createMemo(() => hueRange().step);\n const pageStep = createMemo(() => hueRange().pageSize);\n\n // Update value\n const updateValue = (newColor: Color) => {\n const opts = getOptions();\n const nextColor = normalizeWheelValue(newColor);\n valueRef = nextColor;\n\n // Controlled mode\n if (opts.value !== undefined) {\n opts.onChange?.(nextColor);\n return;\n }\n\n // Uncontrolled mode\n setInternalValue(nextColor);\n opts.onChange?.(nextColor);\n };\n\n // Get hue value (0-360)\n const getHue = () => value().getChannelValue(\"hue\");\n\n const setValue = (newValue: Color | string) => {\n updateValue(normalizeWheelValue(newValue));\n };\n\n const roundToStep = (num: number, stepValue: number) => {\n const rounded = Math.round(num / stepValue) * stepValue;\n const precision = `${stepValue}`.split(\".\")[1]?.length ?? 0;\n return Number(rounded.toFixed(precision));\n };\n\n const roundDown = (num: number) => {\n const rounded = Math.floor(num);\n return rounded === num ? num - 1 : rounded;\n };\n\n const mod = (n: number, m: number) => ((n % m) + m) % m;\n\n const radToDeg = (rad: number) => (rad * 180) / Math.PI;\n const degToRad = (deg: number) => (deg * Math.PI) / 180;\n\n const cartesianToAngle = (x: number, y: number, radius: number) => {\n const clampedX = Math.max(-radius, Math.min(radius, x));\n const clampedY = Math.max(-radius, Math.min(radius, y));\n return mod(radToDeg(Math.atan2(clampedY, clampedX)), 360);\n };\n\n const angleToCartesian = (angle: number, radius: number) => ({\n x: radius * Math.cos(degToRad(angle)),\n y: radius * Math.sin(degToRad(angle)),\n });\n\n // Set hue value\n const setHue = (newValue: number) => {\n const currentHue = getHue();\n const range = hueRange();\n const hue = newValue > range.maxValue ? range.minValue : newValue;\n const rounded = roundToStep(mod(hue, range.maxValue), range.step);\n if (rounded === currentHue) return;\n\n const newColor = value().withChannelValue(\"hue\", rounded);\n updateValue(newColor);\n };\n\n // Set hue from angle (radians, 0 = right, counterclockwise)\n const setHueFromAngle = (angle: number) => {\n setHue(mod(360 - radToDeg(angle), 360));\n };\n\n const setHueFromPoint = (x: number, y: number, radius: number) => {\n setHue(cartesianToAngle(x, y, radius));\n };\n\n // Get thumb angle in radians\n const getThumbAngle = () => {\n return degToRad(360 - getHue());\n };\n\n const getThumbPosition = (radius: number) => {\n return angleToCartesian(getHue(), radius);\n };\n\n // Increment hue\n const increment = (stepSize?: number) => {\n const range = hueRange();\n const s = Math.max(stepSize ?? range.step, range.step);\n const nextValue = getHue() + s;\n if (nextValue >= range.maxValue) {\n setHue(range.minValue);\n return;\n }\n setHue(roundToStep(mod(nextValue, range.maxValue), s));\n };\n\n // Decrement hue\n const decrement = (stepSize?: number) => {\n const range = hueRange();\n const s = Math.max(stepSize ?? range.step, range.step);\n if (getHue() === range.minValue) {\n setHue(roundDown(range.maxValue / s) * s);\n return;\n }\n setHue(roundToStep(mod(getHue() - s, range.maxValue), s));\n };\n\n // Set dragging state\n const setDraggingState = (dragging: boolean) => {\n const wasDragging = isDragging();\n setIsDragging(dragging);\n\n // Call onChangeEnd when dragging ends\n if (wasDragging && !dragging) {\n getOptions().onChangeEnd?.(valueRef);\n }\n };\n\n // Get display color (full saturation and brightness for wheel preview)\n const getDisplayColor = () => {\n return value()\n .toFormat(\"hsl\")\n .withChannelValue(\"saturation\", 100)\n .withChannelValue(\"lightness\", 50)\n .withChannelValue(\"alpha\", 1);\n };\n\n return {\n get value() {\n return value();\n },\n get defaultValue() {\n return initialValue;\n },\n get isDragging() {\n return isDragging();\n },\n get isDisabled() {\n return isDisabled();\n },\n get step() {\n return step();\n },\n get pageStep() {\n return pageStep();\n },\n getHue,\n setValue,\n setHue,\n setHueFromAngle,\n setHueFromPoint,\n getThumbAngle,\n getThumbPosition,\n increment,\n decrement,\n setDragging: setDraggingState,\n getDisplayColor,\n };\n}\n","/**\n * ColorField state management.\n * Based on @react-stately/color useColorFieldState and useColorChannelFieldState.\n */\n\nimport { createEffect, createMemo, createSignal, type Accessor } from \"solid-js\";\nimport type { Color, ColorChannel, ColorChannelRange, ColorFormat, ColorSpace } from \"./types\";\nimport { createRGBColor, normalizeColor, parseColor } from \"./Color\";\n\nconst HEX_COLOR_MAX = 0xffffff;\nconst PARTIAL_HEX_PATTERN = /^#?[0-9a-f]{0,6}$/i;\n\nexport interface ColorFieldStateOptions {\n /** The current color value (controlled). */\n value?: Color | string | null;\n /** The default color value (uncontrolled). */\n defaultValue?: Color | string | null;\n /** Handler called when the color changes. */\n onChange?: (color: Color | null) => void;\n /** The color channel to edit (for single channel mode). */\n channel?: ColorChannel;\n /** The color space to use for channel mode. */\n colorSpace?: ColorSpace;\n /** The color format for parsing/displaying in hex mode. */\n colorFormat?: ColorFormat;\n /** Locale used to format channel values. */\n locale?: string;\n /** Whether the field is disabled. */\n isDisabled?: boolean;\n /** Whether the field is read-only. */\n isReadOnly?: boolean;\n /** Whether the field is invalid. */\n isInvalid?: boolean;\n /** Whether the field is required. */\n isRequired?: boolean;\n}\n\nexport interface ColorFieldState {\n /** The current color value (null if empty). */\n readonly value: Color | null;\n /** The color used for channel calculations. */\n readonly colorValue: Color;\n /** The current input text. */\n readonly inputValue: string;\n /** The numeric value exposed by channel fields. */\n readonly numberValue: number;\n /** The channel minimum value after formatting normalization. */\n readonly minValue: number;\n /** The channel maximum value after formatting normalization. */\n readonly maxValue: number;\n /** The channel keyboard step after formatting normalization. */\n readonly step: number;\n /** The channel page step after formatting normalization. */\n readonly pageSize: number;\n /** Number formatter options for channel fields. */\n readonly formatOptions: Intl.NumberFormatOptions;\n /** Whether the input is invalid. */\n readonly isInvalid: boolean;\n /** Whether the field is disabled. */\n readonly isDisabled: boolean;\n /** Whether the field is read-only. */\n readonly isReadOnly: boolean;\n /** Whether the field is required. */\n readonly isRequired: boolean;\n /** The color channel being edited (if single channel mode). */\n readonly channel: ColorChannel | undefined;\n\n /** Set the input text value. */\n setInputValue(value: string): void;\n /** Set the color value. */\n setColorValue(value: Color | null): void;\n /** Commit the current input value. */\n commit(): void;\n /** Increment the color value. */\n increment(): void;\n /** Decrement the color value. */\n decrement(): void;\n /** Increment by page size or to the maximum. */\n incrementToMax(): void;\n /** Decrement by page size or to the minimum. */\n decrementToMin(): void;\n /** Validate the current input or a candidate input. */\n validate(value?: string): boolean;\n}\n\nfunction normalizeNullableColor(value: Color | string | null | undefined): Color | null {\n if (value == null) {\n return null;\n }\n return normalizeColor(value);\n}\n\nfunction getDefaultValue(options: ColorFieldStateOptions): Color | null {\n if (options.defaultValue !== undefined) {\n return normalizeNullableColor(options.defaultValue);\n }\n\n if (options.value !== undefined) {\n return normalizeNullableColor(options.value);\n }\n\n return null;\n}\n\nfunction convertColor(color: Color, colorSpace: ColorSpace | undefined): Color {\n return colorSpace ? color.toFormat(colorSpace) : color;\n}\n\nfunction getDisplayColor(color: Color | null, colorSpace: ColorSpace | undefined): Color {\n return convertColor(color ?? createRGBColor(0, 0, 0), colorSpace);\n}\n\nfunction getChannelMultiplier(color: Color, channel: ColorChannel): number {\n const range = color.getChannelRange(channel);\n const formatOptions = color.getChannelFormatOptions(channel);\n return formatOptions.style === \"percent\" && range.maxValue === 100 ? 100 : 1;\n}\n\nfunction getNormalizedRange(color: Color, channel: ColorChannel): ColorChannelRange {\n const multiplier = getChannelMultiplier(color, channel);\n const range = color.getChannelRange(channel);\n\n return {\n minValue: range.minValue / multiplier,\n maxValue: range.maxValue / multiplier,\n step: range.step / multiplier,\n pageSize: range.pageSize / multiplier,\n };\n}\n\nfunction formatColorValue(\n color: Color | null,\n channel: ColorChannel | undefined,\n colorSpace: ColorSpace | undefined,\n format: ColorFormat | undefined,\n locale: string,\n): string {\n if (!color) {\n return \"\";\n }\n\n const displayColor = getDisplayColor(color, colorSpace);\n\n if (channel) {\n return displayColor.formatChannelValue(channel, locale);\n }\n\n return displayColor.toString(format ?? \"hex\");\n}\n\nfunction normalizeHexInput(value: string): string {\n return value.startsWith(\"#\") ? value : `#${value}`;\n}\n\nfunction parseHexValue(value: string, format: ColorFormat | undefined): Color {\n const color = parseColor(normalizeHexInput(value));\n return format ? color.toFormat(format) : color;\n}\n\nfunction parseChannelValue(text: string, color: Color, channel: ColorChannel): number | null {\n const trimmed = text.trim();\n const hasPercent = trimmed.endsWith(\"%\");\n const parsed = Number.parseFloat(hasPercent ? trimmed.slice(0, -1) : trimmed);\n\n if (Number.isNaN(parsed)) {\n return null;\n }\n\n const range = color.getChannelRange(channel);\n const formatOptions = color.getChannelFormatOptions(channel);\n const multiplier = getChannelMultiplier(color, channel);\n const rawValue = hasPercent && formatOptions.style === \"percent\" ? parsed : parsed * multiplier;\n\n return Math.min(range.maxValue, Math.max(range.minValue, rawValue));\n}\n\nfunction hexIntToColor(value: number): Color {\n const clamped = Math.min(HEX_COLOR_MAX, Math.max(0, Math.round(value)));\n const red = (clamped >> 16) & 0xff;\n const green = (clamped >> 8) & 0xff;\n const blue = clamped & 0xff;\n return createRGBColor(red, green, blue);\n}\n\n/**\n * Creates state for a color field (text input for color values).\n */\nexport function createColorFieldState(options: Accessor<ColorFieldStateOptions>): ColorFieldState {\n const getOptions = () => options();\n const initialOptions = getOptions();\n const initialValue = getDefaultValue(initialOptions);\n\n const [internalValue, setInternalValue] = createSignal<Color | null>(initialValue);\n const [inputValue, setInputValueInternal] = createSignal(\n formatColorValue(\n initialValue,\n initialOptions.channel,\n initialOptions.colorSpace,\n initialOptions.colorFormat,\n initialOptions.locale ?? \"en-US\",\n ),\n );\n const [invalidInput, setInvalidInput] = createSignal(false);\n\n const channel = createMemo(() => getOptions().channel);\n const colorSpace = createMemo(() => getOptions().colorSpace);\n const locale = createMemo(() => getOptions().locale ?? \"en-US\");\n\n const value = createMemo(() => {\n const opts = getOptions();\n if (opts.value !== undefined) {\n return normalizeNullableColor(opts.value);\n }\n return internalValue();\n });\n\n const colorValue = createMemo(() => getDisplayColor(value(), colorSpace()));\n const isDisabled = createMemo(() => getOptions().isDisabled ?? false);\n const isReadOnly = createMemo(() => getOptions().isReadOnly ?? false);\n const isRequired = createMemo(() => getOptions().isRequired ?? false);\n const isInvalid = createMemo(() => (getOptions().isInvalid ?? false) || invalidInput());\n\n const formatCurrentValue = (color: Color | null = value()) =>\n formatColorValue(color, channel(), colorSpace(), getOptions().colorFormat, locale());\n\n createEffect(() => {\n setInputValueInternal(formatCurrentValue());\n setInvalidInput(false);\n });\n\n const updateValue = (newColor: Color | null) => {\n const opts = getOptions();\n\n if (opts.value === undefined) {\n setInternalValue(newColor);\n }\n\n opts.onChange?.(newColor);\n setInputValueInternal(formatCurrentValue(newColor));\n setInvalidInput(false);\n };\n\n const setInputValue = (text: string) => {\n setInputValueInternal(text);\n setInvalidInput(false);\n };\n\n const setColorValue = (newColor: Color | null) => {\n updateValue(newColor);\n };\n\n const commit = () => {\n const text = inputValue().trim();\n const opts = getOptions();\n const chan = channel();\n\n if (!text) {\n updateValue(null);\n return;\n }\n\n if (chan) {\n const displayColor = colorValue();\n const rawValue = parseChannelValue(text, displayColor, chan);\n if (rawValue == null) {\n setInputValueInternal(formatCurrentValue());\n setInvalidInput(false);\n return;\n }\n\n updateValue(displayColor.withChannelValue(chan, rawValue));\n return;\n }\n\n try {\n updateValue(parseHexValue(text, opts.colorFormat));\n } catch {\n setInputValueInternal(formatCurrentValue());\n setInvalidInput(false);\n }\n };\n\n const incrementHex = (amount: number) => {\n const currentColor = value();\n if (!currentColor) {\n return;\n }\n\n const newColor = hexIntToColor(currentColor.toFormat(\"rgb\").toHexInt() + amount);\n updateValue(getOptions().colorFormat ? newColor.toFormat(getOptions().colorFormat!) : newColor);\n };\n\n const updateChannel = (amount: number | \"min\" | \"max\") => {\n const chan = channel();\n if (!chan) {\n return;\n }\n\n const displayColor = colorValue();\n const range = displayColor.getChannelRange(chan);\n const currentValue = displayColor.getChannelValue(chan);\n const nextValue =\n amount === \"min\"\n ? range.minValue\n : amount === \"max\"\n ? range.maxValue\n : Math.min(range.maxValue, Math.max(range.minValue, currentValue + amount));\n\n updateValue(displayColor.withChannelValue(chan, nextValue));\n };\n\n const increment = () => {\n const chan = channel();\n if (!chan) {\n incrementHex(1);\n return;\n }\n\n updateChannel(colorValue().getChannelRange(chan).step);\n };\n\n const decrement = () => {\n const chan = channel();\n if (!chan) {\n incrementHex(-1);\n return;\n }\n\n updateChannel(-colorValue().getChannelRange(chan).step);\n };\n\n const incrementToMax = () => {\n const chan = channel();\n if (!chan) {\n incrementHex(HEX_COLOR_MAX);\n return;\n }\n\n updateChannel(\"max\");\n };\n\n const decrementToMin = () => {\n const chan = channel();\n if (!chan) {\n incrementHex(-HEX_COLOR_MAX);\n return;\n }\n\n updateChannel(\"min\");\n };\n\n const validate = (candidate?: string) => {\n const text = (candidate ?? inputValue()).trim();\n const chan = channel();\n\n if (!text) {\n return true;\n }\n\n if (chan) {\n return parseChannelValue(text, colorValue(), chan) != null;\n }\n\n return PARTIAL_HEX_PATTERN.test(text);\n };\n\n return {\n get value() {\n return value();\n },\n get colorValue() {\n return colorValue();\n },\n get inputValue() {\n return inputValue();\n },\n get numberValue() {\n const chan = channel();\n if (!chan || value() === null) {\n return Number.NaN;\n }\n return colorValue().getChannelValue(chan) / getChannelMultiplier(colorValue(), chan);\n },\n get minValue() {\n const chan = channel();\n return chan ? getNormalizedRange(colorValue(), chan).minValue : 0;\n },\n get maxValue() {\n const chan = channel();\n return chan ? getNormalizedRange(colorValue(), chan).maxValue : HEX_COLOR_MAX;\n },\n get step() {\n const chan = channel();\n return chan ? getNormalizedRange(colorValue(), chan).step : 1;\n },\n get pageSize() {\n const chan = channel();\n return chan ? getNormalizedRange(colorValue(), chan).pageSize : 0x100000;\n },\n get formatOptions() {\n const chan = channel();\n return chan ? colorValue().getChannelFormatOptions(chan) : {};\n },\n get isInvalid() {\n return isInvalid();\n },\n get isDisabled() {\n return isDisabled();\n },\n get isReadOnly() {\n return isReadOnly();\n },\n get isRequired() {\n return isRequired();\n },\n get channel() {\n return channel();\n },\n setInputValue,\n setColorValue,\n commit,\n increment,\n decrement,\n incrementToMax,\n decrementToMin,\n validate,\n };\n}\n","/**\n * Drag state management for solid-stately.\n *\n * Provides reactive state for drag operations.\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport type {\n DragItem,\n DragStartEvent,\n DragMoveEvent,\n DragEndEvent,\n DropOperation,\n DragPreviewRenderer,\n} from \"./types\";\n\nexport interface DragStateOptions {\n /** A function that returns the items being dragged. */\n getItems: () => DragItem[];\n /** Function that returns the allowed drop operations. */\n getAllowedDropOperations?: () => DropOperation[];\n /** Handler that is called when a drag operation is started. */\n onDragStart?: (e: DragStartEvent) => void;\n /** Handler that is called when the drag is moved. */\n onDragMove?: (e: DragMoveEvent) => void;\n /** Handler that is called when the drag operation ends. */\n onDragEnd?: (e: DragEndEvent) => void;\n /** Whether the drag operation is disabled. */\n isDisabled?: boolean;\n /** Whether there is a separate drag button affordance. */\n hasDragButton?: boolean;\n /** Preview renderer function ref. */\n preview?: { current: DragPreviewRenderer | null };\n}\n\nexport interface DragState {\n /** Whether an element is currently being dragged. */\n readonly isDragging: boolean;\n /** Whether drag is disabled. */\n readonly isDisabled: boolean;\n /** Start a drag operation. */\n startDrag(x: number, y: number): void;\n /** Update drag position. */\n moveDrag(x: number, y: number): void;\n /** End a drag operation. */\n endDrag(x: number, y: number, dropOperation: DropOperation): void;\n /** Cancel a drag operation. */\n cancelDrag(): void;\n /** Get the items being dragged. */\n getItems(): DragItem[];\n /** Get allowed drop operations. */\n getAllowedDropOperations(): DropOperation[];\n /** Whether there is a drag button. */\n readonly hasDragButton: boolean;\n /** Preview renderer. */\n readonly preview: { current: DragPreviewRenderer | null } | undefined;\n}\n\n/**\n * Creates drag state for managing drag operations.\n *\n * @param props - Accessor returning drag state options\n * @returns Drag state object\n */\nexport function createDragState(props: Accessor<DragStateOptions>): DragState {\n const getProps = createMemo(() => props());\n\n const [isDragging, setIsDragging] = createSignal(false);\n\n const startDrag = (x: number, y: number) => {\n const p = getProps();\n if (p.isDisabled) return;\n\n setIsDragging(true);\n\n if (typeof p.onDragStart === \"function\") {\n p.onDragStart({\n type: \"dragstart\",\n x,\n y,\n });\n }\n };\n\n const moveDrag = (x: number, y: number) => {\n const p = getProps();\n if (!isDragging() || p.isDisabled) return;\n\n if (typeof p.onDragMove === \"function\") {\n p.onDragMove({\n type: \"dragmove\",\n x,\n y,\n });\n }\n };\n\n const endDrag = (x: number, y: number, dropOperation: DropOperation) => {\n const p = getProps();\n if (!isDragging()) return;\n\n setIsDragging(false);\n\n if (typeof p.onDragEnd === \"function\") {\n p.onDragEnd({\n type: \"dragend\",\n x,\n y,\n dropOperation,\n });\n }\n };\n\n const cancelDrag = () => {\n endDrag(0, 0, \"cancel\");\n };\n\n const getItems = () => {\n const p = getProps();\n return p.getItems();\n };\n\n const getAllowedDropOperations = (): DropOperation[] => {\n const p = getProps();\n if (typeof p.getAllowedDropOperations === \"function\") {\n return p.getAllowedDropOperations();\n }\n return [\"move\", \"copy\", \"link\"];\n };\n\n return {\n get isDragging() {\n return isDragging();\n },\n get isDisabled() {\n return getProps().isDisabled ?? false;\n },\n get hasDragButton() {\n return getProps().hasDragButton ?? false;\n },\n get preview() {\n return getProps().preview;\n },\n startDrag,\n moveDrag,\n endDrag,\n cancelDrag,\n getItems,\n getAllowedDropOperations,\n };\n}\n","/**\n * Drop state management for solid-stately.\n *\n * Provides reactive state for drop target operations.\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport type {\n DropItem,\n DropEnterEvent,\n DropMoveEvent,\n DropExitEvent,\n DropActivateEvent,\n DropEvent,\n DropOperation,\n DragTypes,\n} from \"./types\";\n\nexport interface DropStateOptions {\n /**\n * A function returning the drop operation to be performed.\n */\n getDropOperation?: (types: DragTypes, allowedOperations: DropOperation[]) => DropOperation;\n /**\n * A function returning the drop operation for a specific point.\n */\n getDropOperationForPoint?: (\n types: DragTypes,\n allowedOperations: DropOperation[],\n x: number,\n y: number,\n ) => DropOperation;\n /** Handler that is called when a valid drag enters the drop target. */\n onDropEnter?: (e: DropEnterEvent) => void;\n /** Handler that is called when a valid drag is moved within the drop target. */\n onDropMove?: (e: DropMoveEvent) => void;\n /** Handler that is called after a valid drag is held over the drop target. */\n onDropActivate?: (e: DropActivateEvent) => void;\n /** Handler that is called when a valid drag exits the drop target. */\n onDropExit?: (e: DropExitEvent) => void;\n /** Handler that is called when a valid drag is dropped on the drop target. */\n onDrop?: (e: DropEvent) => void;\n /** Whether there is a separate drop button affordance. */\n hasDropButton?: boolean;\n /** Whether the drop target is disabled. */\n isDisabled?: boolean;\n}\n\nexport interface DropState {\n /** Whether the drop target is currently being hovered or focused. */\n readonly isDropTarget: boolean;\n /** Whether the drop target is disabled. */\n readonly isDisabled: boolean;\n /** Whether there is a drop button. */\n readonly hasDropButton: boolean;\n /** Enter the drop target. */\n enterTarget(x: number, y: number): void;\n /** Move within the drop target. */\n moveInTarget(x: number, y: number): void;\n /** Exit the drop target. */\n exitTarget(x: number, y: number): void;\n /** Activate the drop target (after holding). */\n activateTarget(x: number, y: number): void;\n /** Perform a drop on the target. */\n drop(x: number, y: number, items: DropItem[], dropOperation: DropOperation): void;\n /** Get the drop operation for given types. */\n getDropOperation(types: DragTypes, allowedOperations: DropOperation[]): DropOperation;\n /** Get the drop operation for a specific point. */\n getDropOperationForPoint(\n types: DragTypes,\n allowedOperations: DropOperation[],\n x: number,\n y: number,\n ): DropOperation;\n}\n\n/**\n * Creates drop state for managing drop target operations.\n *\n * @param props - Accessor returning drop state options\n * @returns Drop state object\n */\nexport function createDropState(props: Accessor<DropStateOptions>): DropState {\n const getProps = createMemo(() => props());\n\n const [isDropTarget, setIsDropTarget] = createSignal(false);\n\n const enterTarget = (x: number, y: number) => {\n const p = getProps();\n if (p.isDisabled) return;\n\n setIsDropTarget(true);\n\n if (typeof p.onDropEnter === \"function\") {\n p.onDropEnter({\n type: \"dropenter\",\n x,\n y,\n });\n }\n };\n\n const moveInTarget = (x: number, y: number) => {\n const p = getProps();\n if (!isDropTarget() || p.isDisabled) return;\n\n if (typeof p.onDropMove === \"function\") {\n p.onDropMove({\n type: \"dropmove\",\n x,\n y,\n });\n }\n };\n\n const exitTarget = (x: number, y: number) => {\n const p = getProps();\n\n setIsDropTarget(false);\n\n if (typeof p.onDropExit === \"function\") {\n p.onDropExit({\n type: \"dropexit\",\n x,\n y,\n });\n }\n };\n\n const activateTarget = (x: number, y: number) => {\n const p = getProps();\n if (p.isDisabled) return;\n\n if (typeof p.onDropActivate === \"function\") {\n p.onDropActivate({\n type: \"dropactivate\",\n x,\n y,\n });\n }\n };\n\n const drop = (x: number, y: number, items: DropItem[], dropOperation: DropOperation) => {\n const p = getProps();\n if (p.isDisabled) return;\n\n setIsDropTarget(false);\n\n if (typeof p.onDrop === \"function\") {\n p.onDrop({\n type: \"drop\",\n x,\n y,\n items,\n dropOperation,\n });\n }\n };\n\n const getDropOperation = (\n types: DragTypes,\n allowedOperations: DropOperation[],\n ): DropOperation => {\n const p = getProps();\n if (typeof p.getDropOperation === \"function\") {\n return p.getDropOperation(types, allowedOperations);\n }\n return allowedOperations[0] ?? \"cancel\";\n };\n\n const getDropOperationForPoint = (\n types: DragTypes,\n allowedOperations: DropOperation[],\n x: number,\n y: number,\n ): DropOperation => {\n const p = getProps();\n if (typeof p.getDropOperationForPoint === \"function\") {\n return p.getDropOperationForPoint(types, allowedOperations, x, y);\n }\n return getDropOperation(types, allowedOperations);\n };\n\n return {\n get isDropTarget() {\n return isDropTarget();\n },\n get isDisabled() {\n return getProps().isDisabled ?? false;\n },\n get hasDropButton() {\n return getProps().hasDropButton ?? false;\n },\n enterTarget,\n moveInTarget,\n exitTarget,\n activateTarget,\n drop,\n getDropOperation,\n getDropOperationForPoint,\n };\n}\n","/**\n * Draggable collection state management for solid-stately.\n *\n * Provides reactive state for dragging items from a collection.\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport type {\n DragItem,\n DraggableCollectionStartEvent,\n DraggableCollectionMoveEvent,\n DraggableCollectionEndEvent,\n DropOperation,\n DragPreviewRenderer,\n} from \"./types\";\n\nexport interface DraggableCollectionStateOptions<T = object> {\n /** A function that returns the items being dragged. */\n getItems: (keys: Set<string | number>) => DragItem[];\n /** Function that returns the allowed drop operations. */\n getAllowedDropOperations?: () => DropOperation[];\n /** Handler that is called when a drag operation is started. */\n onDragStart?: (e: DraggableCollectionStartEvent) => void;\n /** Handler that is called when the drag is moved. */\n onDragMove?: (e: DraggableCollectionMoveEvent) => void;\n /** Handler that is called when the drag operation ends. */\n onDragEnd?: (e: DraggableCollectionEndEvent) => void;\n /** Whether the drag operation is disabled. */\n isDisabled?: boolean;\n /** Preview renderer function ref. */\n preview?: { current: DragPreviewRenderer | null };\n}\n\nexport interface DraggableCollectionState {\n /** Whether items are currently being dragged. */\n readonly isDragging: boolean;\n /** The keys of the items being dragged. */\n readonly draggingKeys: Set<string | number>;\n /** Whether dragging is disabled. */\n readonly isDisabled: boolean;\n /** Start a drag operation with the given keys. */\n startDrag(keys: Set<string | number>, x: number, y: number): void;\n /** Update drag position. */\n moveDrag(x: number, y: number): void;\n /** End a drag operation. */\n endDrag(x: number, y: number, dropOperation: DropOperation, isInternal: boolean): void;\n /** Cancel a drag operation. */\n cancelDrag(): void;\n /** Get the items being dragged for the given keys. */\n getItems(keys: Set<string | number>): DragItem[];\n /** Get allowed drop operations. */\n getAllowedDropOperations(): DropOperation[];\n /** Preview renderer. */\n readonly preview: { current: DragPreviewRenderer | null } | undefined;\n}\n\n/**\n * Creates state for dragging items from a collection.\n *\n * @param props - Accessor returning draggable collection options\n * @returns Draggable collection state object\n */\nexport function createDraggableCollectionState<T = object>(\n props: Accessor<DraggableCollectionStateOptions<T>>,\n): DraggableCollectionState {\n const getProps = createMemo(() => props());\n\n const [isDragging, setIsDragging] = createSignal(false);\n const [draggingKeys, setDraggingKeys] = createSignal<Set<string | number>>(new Set());\n\n const startDrag = (keys: Set<string | number>, x: number, y: number) => {\n const p = getProps();\n if (p.isDisabled) return;\n\n setIsDragging(true);\n setDraggingKeys(keys);\n\n if (typeof p.onDragStart === \"function\") {\n p.onDragStart({\n type: \"dragstart\",\n x,\n y,\n keys,\n });\n }\n };\n\n const moveDrag = (x: number, y: number) => {\n const p = getProps();\n if (!isDragging() || p.isDisabled) return;\n\n if (typeof p.onDragMove === \"function\") {\n p.onDragMove({\n type: \"dragmove\",\n x,\n y,\n keys: draggingKeys(),\n });\n }\n };\n\n const endDrag = (x: number, y: number, dropOperation: DropOperation, isInternal: boolean) => {\n const p = getProps();\n const keys = draggingKeys();\n\n setIsDragging(false);\n setDraggingKeys(new Set<string | number>());\n\n if (typeof p.onDragEnd === \"function\") {\n p.onDragEnd({\n type: \"dragend\",\n x,\n y,\n dropOperation,\n keys,\n isInternal,\n });\n }\n };\n\n const cancelDrag = () => {\n endDrag(0, 0, \"cancel\", false);\n };\n\n const getItems = (keys: Set<string | number>) => {\n const p = getProps();\n return p.getItems(keys);\n };\n\n const getAllowedDropOperations = (): DropOperation[] => {\n const p = getProps();\n if (typeof p.getAllowedDropOperations === \"function\") {\n return p.getAllowedDropOperations();\n }\n return [\"move\", \"copy\", \"link\"];\n };\n\n return {\n get isDragging() {\n return isDragging();\n },\n get draggingKeys() {\n return draggingKeys();\n },\n get isDisabled() {\n return getProps().isDisabled ?? false;\n },\n get preview() {\n return getProps().preview;\n },\n startDrag,\n moveDrag,\n endDrag,\n cancelDrag,\n getItems,\n getAllowedDropOperations,\n };\n}\n","/**\n * Droppable collection state management for solid-stately.\n *\n * Provides reactive state for accepting drops onto a collection.\n */\n\nimport { createSignal, createMemo, type Accessor } from \"solid-js\";\nimport type {\n DropItem,\n DropTarget,\n DropOperation,\n DragTypes,\n DroppableCollectionEnterEvent,\n DroppableCollectionMoveEvent,\n DroppableCollectionActivateEvent,\n DroppableCollectionExitEvent,\n DroppableCollectionDropEvent,\n DroppableCollectionInsertDropEvent,\n DroppableCollectionRootDropEvent,\n DroppableCollectionOnItemDropEvent,\n DroppableCollectionReorderEvent,\n ItemDropTarget,\n} from \"./types\";\nimport type { Collection } from \"../collections/types\";\n\nexport interface DroppableCollectionStateOptions {\n /**\n * The drag types that the droppable collection accepts.\n * @default 'all'\n */\n acceptedDragTypes?: \"all\" | Array<string | symbol>;\n /**\n * A function returning the drop operation to be performed.\n */\n getDropOperation?: (\n target: DropTarget,\n types: DragTypes,\n allowedOperations: DropOperation[],\n ) => DropOperation;\n /** Handler that is called when a valid drag enters a drop target. */\n onDropEnter?: (e: DroppableCollectionEnterEvent) => void;\n /** Handler that is called after a valid drag is held over a drop target. */\n onDropActivate?: (e: DroppableCollectionActivateEvent) => void;\n /** Handler that is called when a valid drag exits a drop target. */\n onDropExit?: (e: DroppableCollectionExitEvent) => void;\n /** Handler that is called when a valid drag is dropped. */\n onDrop?: (e: DroppableCollectionDropEvent) => void;\n /** Handler that is called when external items are dropped \"between\" items. */\n onInsert?: (e: DroppableCollectionInsertDropEvent) => void;\n /** Handler that is called when external items are dropped on the collection's root. */\n onRootDrop?: (e: DroppableCollectionRootDropEvent) => void;\n /** Handler that is called when items are dropped \"on\" an item. */\n onItemDrop?: (e: DroppableCollectionOnItemDropEvent) => void;\n /** Handler that is called when items are reordered within the collection. */\n onReorder?: (e: DroppableCollectionReorderEvent) => void;\n /** Handler that is called when items are moved within the source collection. */\n onMove?: (e: DroppableCollectionReorderEvent) => void;\n /** A function returning whether a given target is a valid \"on\" drop target. */\n shouldAcceptItemDrop?: (target: ItemDropTarget, types: DragTypes) => boolean;\n /**\n * The host collection. Used by the default drop-operation feature detection to\n * confirm a reorder stays within the same parent and to prevent dropping an\n * item onto itself or a descendant. Optional: a flat collection (e.g. a plain\n * ListBox) is always \"within parent\" and has no descendants, so omitting it is\n * faithful for flat hosts.\n */\n collection?: Collection<unknown>;\n /** Whether the droppable collection is disabled. */\n isDisabled?: boolean;\n}\n\nexport interface DroppableCollectionState {\n /** Whether a drag is currently over the collection. */\n readonly isDropTarget: boolean;\n /** The current drop target within the collection. */\n readonly target: DropTarget | null;\n /** Whether the collection is disabled for drops. */\n readonly isDisabled: boolean;\n /** Set the current drop target. */\n setTarget(target: DropTarget | null): void;\n /** Check if a drag type is accepted. */\n isAccepted(types: DragTypes): boolean;\n /** Enter the collection with a drop target. */\n enterTarget(target: DropTarget, x: number, y: number): void;\n /** Move to a new target within the collection. */\n moveToTarget(target: DropTarget, x: number, y: number): void;\n /** Exit the collection. */\n exitTarget(x: number, y: number): void;\n /** Activate the current target. */\n activateTarget(x: number, y: number): void;\n /** Perform a drop on the collection. */\n drop(\n items: DropItem[],\n dropOperation: DropOperation,\n isInternal: boolean,\n draggingKeys?: Set<string | number>,\n ): void;\n /**\n * Get the drop operation for a target. `isInternal` is true when the active\n * drag originated from this same collection; `draggingKeys` are the keys being\n * dragged. Both feed the handler-aware feature detection that decides whether a\n * given drop position (before/after/on/root) is a valid target — e.g. a\n * reorder-only collection rejects \"on\" targets, matching React Aria.\n */\n getDropOperation(\n target: DropTarget,\n types: DragTypes,\n allowedOperations: DropOperation[],\n isInternal?: boolean,\n draggingKeys?: Set<string | number>,\n ): DropOperation;\n /** Check if an item drop should be accepted. */\n shouldAcceptItemDrop(target: ItemDropTarget, types: DragTypes): boolean;\n}\n\n/**\n * Symbol for directory drag type.\n */\nexport const DIRECTORY_DRAG_TYPE: symbol = Symbol(\"directory\");\n\n/**\n * Creates state for accepting drops onto a collection.\n *\n * @param props - Accessor returning droppable collection options\n * @returns Droppable collection state object\n */\nexport function createDroppableCollectionState(\n props: Accessor<DroppableCollectionStateOptions>,\n): DroppableCollectionState {\n const getProps = createMemo(() => props());\n\n const [isDropTarget, setIsDropTarget] = createSignal(false);\n const [target, setTarget] = createSignal<DropTarget | null>(null);\n\n const isAccepted = (types: DragTypes): boolean => {\n const p = getProps();\n const acceptedTypes = p.acceptedDragTypes ?? \"all\";\n\n if (acceptedTypes === \"all\") {\n return true;\n }\n\n for (const type of acceptedTypes) {\n if (types.has(type)) {\n return true;\n }\n }\n\n return false;\n };\n\n const enterTarget = (dropTarget: DropTarget, x: number, y: number) => {\n const p = getProps();\n if (p.isDisabled) return;\n\n setIsDropTarget(true);\n setTarget(dropTarget);\n\n if (typeof p.onDropEnter === \"function\") {\n p.onDropEnter({\n type: \"dropenter\",\n x,\n y,\n target: dropTarget,\n });\n }\n };\n\n const moveToTarget = (dropTarget: DropTarget, x: number, y: number) => {\n const p = getProps();\n if (p.isDisabled) return;\n\n const prevTarget = target();\n setTarget(dropTarget);\n\n // Fire exit/enter events if target changed\n if (prevTarget && !targetsEqual(prevTarget, dropTarget)) {\n if (typeof p.onDropExit === \"function\") {\n p.onDropExit({\n type: \"dropexit\",\n x,\n y,\n target: prevTarget,\n });\n }\n\n if (typeof p.onDropEnter === \"function\") {\n p.onDropEnter({\n type: \"dropenter\",\n x,\n y,\n target: dropTarget,\n });\n }\n }\n };\n\n const exitTarget = (x: number, y: number) => {\n const p = getProps();\n const currentTarget = target();\n\n setIsDropTarget(false);\n setTarget(null);\n\n if (currentTarget && typeof p.onDropExit === \"function\") {\n p.onDropExit({\n type: \"dropexit\",\n x,\n y,\n target: currentTarget,\n });\n }\n };\n\n const activateTarget = (x: number, y: number) => {\n const p = getProps();\n const currentTarget = target();\n if (p.isDisabled || !currentTarget) return;\n\n if (typeof p.onDropActivate === \"function\") {\n p.onDropActivate({\n type: \"dropactivate\",\n x,\n y,\n target: currentTarget,\n });\n }\n };\n\n const drop = (\n items: DropItem[],\n dropOperation: DropOperation,\n isInternal: boolean,\n draggingKeys?: Set<string | number>,\n ) => {\n const p = getProps();\n const currentTarget = target();\n if (p.isDisabled || !currentTarget) return;\n\n setIsDropTarget(false);\n setTarget(null);\n\n // Call the generic onDrop handler\n if (typeof p.onDrop === \"function\") {\n p.onDrop({\n type: \"drop\",\n x: 0,\n y: 0,\n items,\n dropOperation,\n target: currentTarget,\n });\n }\n\n // Call specific handlers based on the drop type\n if (currentTarget.type === \"root\") {\n if (typeof p.onRootDrop === \"function\") {\n p.onRootDrop({\n items,\n dropOperation,\n });\n }\n } else if (currentTarget.type === \"item\") {\n if (isInternal && draggingKeys) {\n // Reorder or move within the same collection\n if (currentTarget.dropPosition === \"on\") {\n if (typeof p.onMove === \"function\") {\n p.onMove({\n keys: draggingKeys,\n dropOperation,\n target: currentTarget,\n });\n }\n } else {\n if (typeof p.onReorder === \"function\") {\n p.onReorder({\n keys: draggingKeys,\n dropOperation,\n target: currentTarget,\n });\n }\n }\n } else {\n // External drop\n if (currentTarget.dropPosition === \"on\") {\n if (typeof p.onItemDrop === \"function\") {\n p.onItemDrop({\n items,\n dropOperation,\n isInternal,\n target: currentTarget,\n });\n }\n } else {\n if (typeof p.onInsert === \"function\") {\n p.onInsert({\n items,\n dropOperation,\n target: currentTarget,\n });\n }\n }\n }\n }\n };\n\n // Faithful of react-stately's `isDraggingWithinParent`: every dragged item must\n // share the target's parent for a reorder to be valid. A flat collection (no\n // `collection` provided) has a single implicit parent, so this is always true.\n const isDraggingWithinParent = (\n target: ItemDropTarget,\n draggingKeys: Set<string | number>,\n ): boolean => {\n const collection = getProps().collection;\n if (!collection) return true;\n const targetNode = collection.getItem(target.key);\n for (const key of draggingKeys) {\n const node = collection.getItem(key);\n if (node?.parentKey !== targetNode?.parentKey) {\n return false;\n }\n }\n return true;\n };\n\n // Faithful of react-stately's `defaultGetDropOperation`: decide whether a drop\n // position is a valid target from the handlers that are actually wired. A\n // reorder-only collection (only `onReorder`) accepts before/after but rejects\n // \"on\"; an item-drop collection accepts \"on\"; and so on.\n const defaultGetDropOperation = (\n target: DropTarget,\n types: DragTypes,\n allowedOperations: DropOperation[],\n isInternal: boolean,\n draggingKeys: Set<string | number>,\n ): DropOperation => {\n const p = getProps();\n\n if (p.isDisabled || !target) {\n return \"cancel\";\n }\n\n if (!isAccepted(types)) {\n return \"cancel\";\n }\n\n const isValidInsert =\n p.onInsert &&\n target.type === \"item\" &&\n !isInternal &&\n (target.dropPosition === \"before\" || target.dropPosition === \"after\");\n const isValidReorder =\n p.onReorder &&\n target.type === \"item\" &&\n isInternal &&\n (target.dropPosition === \"before\" || target.dropPosition === \"after\") &&\n isDraggingWithinParent(target, draggingKeys);\n\n const isItemDropAllowed =\n target.type !== \"item\" ||\n target.dropPosition !== \"on\" ||\n !p.shouldAcceptItemDrop ||\n p.shouldAcceptItemDrop(target, types);\n\n const isValidMove = p.onMove && target.type === \"item\" && isInternal && isItemDropAllowed;\n\n // Feedback was that internal root drop was weird, so it is prevented.\n const isValidRootDrop = p.onRootDrop && target.type === \"root\" && !isInternal;\n\n // Automatically prevent items (e.g. folders) from being dropped on themselves.\n const isValidOnItemDrop =\n p.onItemDrop &&\n target.type === \"item\" &&\n target.dropPosition === \"on\" &&\n !(isInternal && target.key != null && draggingKeys.has(target.key)) &&\n isItemDropAllowed;\n\n if (\n p.onDrop ||\n isValidInsert ||\n isValidReorder ||\n isValidMove ||\n isValidRootDrop ||\n isValidOnItemDrop\n ) {\n if (typeof p.getDropOperation === \"function\") {\n return p.getDropOperation(target, types, allowedOperations);\n }\n return allowedOperations[0] ?? \"cancel\";\n }\n\n return \"cancel\";\n };\n\n const getDropOperation = (\n dropTarget: DropTarget,\n types: DragTypes,\n allowedOperations: DropOperation[],\n isInternal: boolean = false,\n draggingKeys: Set<string | number> = new Set(),\n ): DropOperation => {\n // Prevent dropping items onto themselves or their descendants (faithful of\n // react-stately's `getDropOperation` guard). Only meaningful for a nested\n // collection; a flat host has no descendants.\n if (isInternal && dropTarget.type === \"item\" && draggingKeys.size > 0) {\n if (draggingKeys.has(dropTarget.key) && dropTarget.dropPosition === \"on\") {\n return \"cancel\";\n }\n\n const collection = getProps().collection;\n if (collection) {\n let currentKey: string | number | null = dropTarget.key;\n while (currentKey != null) {\n const item = collection.getItem(currentKey);\n const parentKey = item?.parentKey;\n if (parentKey != null && draggingKeys.has(parentKey)) {\n return \"cancel\";\n }\n currentKey = parentKey ?? null;\n }\n }\n }\n\n return defaultGetDropOperation(dropTarget, types, allowedOperations, isInternal, draggingKeys);\n };\n\n const shouldAcceptItemDrop = (dropTarget: ItemDropTarget, types: DragTypes): boolean => {\n const p = getProps();\n\n if (!isAccepted(types)) {\n return false;\n }\n\n if (typeof p.shouldAcceptItemDrop === \"function\") {\n return p.shouldAcceptItemDrop(dropTarget, types);\n }\n\n return true;\n };\n\n return {\n get isDropTarget() {\n return isDropTarget();\n },\n get target() {\n return target();\n },\n get isDisabled() {\n return getProps().isDisabled ?? false;\n },\n setTarget,\n isAccepted,\n enterTarget,\n moveToTarget,\n exitTarget,\n activateTarget,\n drop,\n getDropOperation,\n shouldAcceptItemDrop,\n };\n}\n\n/**\n * Check if two drop targets are equal.\n */\nfunction targetsEqual(a: DropTarget, b: DropTarget): boolean {\n if (a.type !== b.type) return false;\n if (a.type === \"root\" && b.type === \"root\") return true;\n if (a.type === \"item\" && b.type === \"item\") {\n return a.key === b.key && a.dropPosition === b.dropPosition;\n }\n return false;\n}\n","/**\n * createListData - SolidJS port of React Spectrum's useListData\n *\n * Manages state for an immutable list data structure, and provides\n * convenience methods to update the data over time.\n */\n\nimport { createSignal, createMemo } from \"solid-js\";\n\nexport type Key = string | number;\nexport type Selection = \"all\" | Set<Key>;\n\nexport interface ListOptions<T> {\n /** Initial items in the list. */\n initialItems?: T[];\n /** The keys for the initially selected items. */\n initialSelectedKeys?: \"all\" | Iterable<Key>;\n /** The initial text to filter the list by. */\n initialFilterText?: string;\n /** A function that returns a unique key for an item object. */\n getKey?: (item: T) => Key;\n /** A function that returns whether an item matches the current filter text. */\n filter?: (item: T, filterText: string) => boolean;\n}\n\nexport interface ListData<T> {\n /** The items in the list. */\n readonly items: T[];\n /** The keys of the currently selected items in the list. */\n readonly selectedKeys: Selection;\n /** The current filter text. */\n readonly filterText: string;\n /** Sets the selected keys. */\n setSelectedKeys(keys: Selection): void;\n /** Adds the given keys to the current selected keys. */\n addKeysToSelection(keys: Selection): void;\n /** Removes the given keys from the current selected keys. */\n removeKeysFromSelection(keys: Selection): void;\n /** Sets the filter text. */\n setFilterText(filterText: string): void;\n /** Gets an item from the list by key. */\n getItem(key: Key): T | undefined;\n /** Inserts items into the list at the given index. */\n insert(index: number, ...values: T[]): void;\n /** Inserts items into the list before the item at the given key. */\n insertBefore(key: Key, ...values: T[]): void;\n /** Inserts items into the list after the item at the given key. */\n insertAfter(key: Key, ...values: T[]): void;\n /** Appends items to the list. */\n append(...values: T[]): void;\n /** Prepends items to the list. */\n prepend(...values: T[]): void;\n /** Removes items from the list by their keys. */\n remove(...keys: Key[]): void;\n /** Removes all items from the list that are currently in the set of selected items. */\n removeSelectedItems(): void;\n /** Moves an item within the list. */\n move(key: Key, toIndex: number): void;\n /** Moves one or more items before a given key. */\n moveBefore(key: Key, keys: Iterable<Key>): void;\n /** Moves one or more items after a given key. */\n moveAfter(key: Key, keys: Iterable<Key>): void;\n /** Updates an item in the list. */\n update(key: Key, newValue: T | ((prev: T) => T)): void;\n}\n\ninterface ListState<T> {\n items: T[];\n selectedKeys: Selection;\n filterText: string;\n}\n\n/**\n * Manages state for an immutable list data structure, and provides\n * convenience methods to update the data over time.\n */\nexport function createListData<T>(options: ListOptions<T>): ListData<T> {\n const defaultGetKey = (item: T): Key => {\n const candidate = item as { id?: Key; key?: Key };\n return candidate.id ?? candidate.key ?? String(item);\n };\n\n const {\n initialItems = [],\n initialSelectedKeys,\n getKey = defaultGetKey,\n filter,\n initialFilterText = \"\",\n } = options;\n\n const [state, setState] = createSignal<ListState<T>>({\n items: initialItems,\n selectedKeys: initialSelectedKeys === \"all\" ? \"all\" : new Set(initialSelectedKeys || []),\n filterText: initialFilterText,\n });\n\n const filteredItems = createMemo(() => {\n const s = state();\n return filter ? s.items.filter((item) => filter(item, s.filterText)) : s.items;\n });\n\n return {\n get items() {\n return filteredItems();\n },\n get selectedKeys() {\n return state().selectedKeys;\n },\n get filterText() {\n return state().filterText;\n },\n\n setSelectedKeys(selectedKeys: Selection) {\n setState((s) => ({ ...s, selectedKeys }));\n },\n\n addKeysToSelection(selectedKeys: Selection) {\n setState((s) => {\n if (s.selectedKeys === \"all\") return s;\n if (selectedKeys === \"all\") return { ...s, selectedKeys: \"all\" };\n return { ...s, selectedKeys: new Set([...s.selectedKeys, ...selectedKeys]) };\n });\n },\n\n removeKeysFromSelection(selectedKeys: Selection) {\n setState((s) => {\n if (selectedKeys === \"all\") return { ...s, selectedKeys: new Set() };\n const selection: Set<Key> =\n s.selectedKeys === \"all\" ? new Set(s.items.map(getKey)) : new Set(s.selectedKeys);\n for (const key of selectedKeys) {\n selection.delete(key);\n }\n return { ...s, selectedKeys: selection };\n });\n },\n\n setFilterText(filterText: string) {\n setState((s) => ({ ...s, filterText }));\n },\n\n getItem(key: Key) {\n return state().items.find((item) => getKey(item) === key);\n },\n\n insert(index: number, ...values: T[]) {\n setState((s) => insertItems(s, index, ...values));\n },\n\n insertBefore(key: Key, ...values: T[]) {\n setState((s) => {\n const index = s.items.findIndex((item) => getKey(item) === key);\n if (index === -1) return s;\n return insertItems(s, index, ...values);\n });\n },\n\n insertAfter(key: Key, ...values: T[]) {\n setState((s) => {\n let index = s.items.findIndex((item) => getKey(item) === key);\n if (index === -1) {\n if (s.items.length === 0) {\n index = 0;\n } else {\n return s;\n }\n }\n return insertItems(s, index + 1, ...values);\n });\n },\n\n prepend(...values: T[]) {\n setState((s) => insertItems(s, 0, ...values));\n },\n\n append(...values: T[]) {\n setState((s) => insertItems(s, s.items.length, ...values));\n },\n\n remove(...keys: Key[]) {\n setState((s) => {\n const keySet = new Set(keys);\n const items = s.items.filter((item) => !keySet.has(getKey(item)));\n let selection: Selection = \"all\";\n if (s.selectedKeys !== \"all\") {\n selection = new Set(s.selectedKeys);\n for (const key of keys) {\n (selection as Set<Key>).delete(key);\n }\n }\n if (items.length === 0) selection = new Set();\n return { ...s, items, selectedKeys: selection };\n });\n },\n\n removeSelectedItems() {\n setState((s) => {\n if (s.selectedKeys === \"all\") {\n return { ...s, items: [], selectedKeys: new Set() };\n }\n const selectedKeys = s.selectedKeys;\n const items = s.items.filter((item) => !selectedKeys.has(getKey(item)));\n return { ...s, items, selectedKeys: new Set() };\n });\n },\n\n move(key: Key, toIndex: number) {\n setState((s) => {\n const index = s.items.findIndex((item) => getKey(item) === key);\n if (index === -1) return s;\n const copy = s.items.slice();\n const [item] = copy.splice(index, 1);\n copy.splice(toIndex, 0, item);\n return { ...s, items: copy };\n });\n },\n\n moveBefore(key: Key, keys: Iterable<Key>) {\n setState((s) => {\n const toIndex = s.items.findIndex((item) => getKey(item) === key);\n if (toIndex === -1) return s;\n const keyArray = Array.isArray(keys) ? keys : [...keys];\n const indices = keyArray\n .map((k) => s.items.findIndex((item) => getKey(item) === k))\n .sort((a, b) => a - b);\n return moveItems(s, indices, toIndex);\n });\n },\n\n moveAfter(key: Key, keys: Iterable<Key>) {\n setState((s) => {\n const toIndex = s.items.findIndex((item) => getKey(item) === key);\n if (toIndex === -1) return s;\n const keyArray = Array.isArray(keys) ? keys : [...keys];\n const indices = keyArray\n .map((k) => s.items.findIndex((item) => getKey(item) === k))\n .sort((a, b) => a - b);\n return moveItems(s, indices, toIndex + 1);\n });\n },\n\n update(key: Key, newValue: T | ((prev: T) => T)) {\n setState((s) => {\n const index = s.items.findIndex((item) => getKey(item) === key);\n if (index === -1) return s;\n const updatedValue =\n typeof newValue === \"function\" ? (newValue as (prev: T) => T)(s.items[index]) : newValue;\n return {\n ...s,\n items: [...s.items.slice(0, index), updatedValue, ...s.items.slice(index + 1)],\n };\n });\n },\n };\n}\n\nfunction insertItems<T>(state: ListState<T>, index: number, ...values: T[]): ListState<T> {\n return {\n ...state,\n items: [...state.items.slice(0, index), ...values, ...state.items.slice(index)],\n };\n}\n\nfunction moveItems<T>(state: ListState<T>, indices: number[], toIndex: number): ListState<T> {\n toIndex -= indices.filter((index) => index < toIndex).length;\n\n const moves = indices.map((from) => ({\n from,\n to: toIndex++,\n }));\n\n for (let i = 0; i < moves.length; i++) {\n const a = moves[i].from;\n for (let j = i; j < moves.length; j++) {\n const b = moves[j].from;\n if (b > a) moves[j].from--;\n }\n }\n\n for (let i = 0; i < moves.length; i++) {\n const a = moves[i];\n for (let j = moves.length - 1; j > i; j--) {\n const b = moves[j];\n if (b.from < a.to) {\n a.to++;\n } else {\n b.from++;\n }\n }\n }\n\n const copy = state.items.slice();\n for (const m of moves) {\n const [item] = copy.splice(m.from, 1);\n copy.splice(m.to, 0, item);\n }\n\n return { ...state, items: copy };\n}\n","/**\n * createTreeData - SolidJS port of React Spectrum's useTreeData\n *\n * Manages state for an immutable tree data structure, and provides\n * convenience methods to update the data over time.\n */\n\nimport { createSignal } from \"solid-js\";\n\nexport type Key = string | number;\nexport type Selection = \"all\" | Set<Key>;\n\nexport interface TreeNode<T> {\n /** A unique key for the tree node. */\n key: Key;\n /** The key of the parent node. */\n parentKey: Key | null;\n /** The value object for the tree node. */\n value: T;\n /** The children of this node. */\n children: TreeNode<T>[] | null;\n}\n\nexport interface TreeOptions<T> {\n /** Initial items in the tree. */\n initialItems?: T[];\n /** The keys for the initially selected items. */\n initialSelectedKeys?: \"all\" | Iterable<Key>;\n /** A function that returns a unique key for an item object. */\n getKey?: (item: T) => Key;\n /** A function that returns the children of an item object. */\n getChildren?: (item: T) => T[];\n}\n\nexport interface TreeData<T> {\n /** The root items in the tree. */\n readonly items: TreeNode<T>[];\n /** The keys of the currently selected items in the tree. */\n readonly selectedKeys: Selection;\n /** Sets the selected keys. */\n setSelectedKeys(keys: Selection): void;\n /** Gets an item from the tree by key. */\n getItem(key: Key): TreeNode<T> | undefined;\n /** Inserts items into the tree. */\n insert(parentKey: Key | null, index: number, ...values: T[]): void;\n /** Inserts items before a given key. */\n insertBefore(key: Key, ...values: T[]): void;\n /** Inserts items after a given key. */\n insertAfter(key: Key, ...values: T[]): void;\n /** Appends items to a parent node. */\n append(parentKey: Key | null, ...values: T[]): void;\n /** Prepends items to a parent node. */\n prepend(parentKey: Key | null, ...values: T[]): void;\n /** Removes items from the tree by their keys. */\n remove(...keys: Key[]): void;\n /** Removes all items from the tree that are currently in the set of selected items. */\n removeSelectedItems(): void;\n /** Moves an item to a new parent. */\n move(key: Key, toParentKey: Key | null, index: number): void;\n /** Moves items before a given key. */\n moveBefore(key: Key, keys: Iterable<Key>): void;\n /** Moves items after a given key. */\n moveAfter(key: Key, keys: Iterable<Key>): void;\n /** Updates an item in the tree. */\n update(key: Key, newValue: T): void;\n}\n\ninterface TreeDataState<T> {\n items: TreeNode<T>[];\n nodeMap: Map<Key, TreeNode<T>>;\n}\n\n/**\n * Manages state for an immutable tree data structure, and provides\n * convenience methods to update the data over time.\n */\nexport function createTreeData<T>(options: TreeOptions<T>): TreeData<T> {\n const defaultGetKey = (item: T): Key => {\n const candidate = item as { id?: Key; key?: Key };\n return candidate.id ?? candidate.key ?? String(item);\n };\n const defaultGetChildren = (item: T): T[] => {\n const candidate = item as { children?: T[] };\n return candidate.children ?? [];\n };\n\n const {\n initialItems = [],\n initialSelectedKeys,\n getKey = defaultGetKey,\n getChildren = defaultGetChildren,\n } = options;\n\n // Build initial tree\n const initialTree = buildTree(initialItems, new Map(), null, getKey, getChildren);\n\n const [treeState, setTreeState] = createSignal<TreeDataState<T>>(initialTree);\n const [selectedKeys, setSelectedKeys] = createSignal<Selection>(\n initialSelectedKeys === \"all\" ? \"all\" : new Set(initialSelectedKeys || []),\n );\n\n function updateTree(\n items: TreeNode<T>[],\n key: Key | null,\n update: (node: TreeNode<T>) => TreeNode<T> | null,\n originalMap: Map<Key, TreeNode<T>>,\n ): TreeDataState<T> {\n let node = key != null ? originalMap.get(key) : null;\n if (key != null && !node) return { items, nodeMap: originalMap };\n\n const newMap = new Map(originalMap);\n\n if (node) {\n const updated = update(node);\n if (!updated) {\n // Delete node\n deleteNode(node, newMap);\n if (node.parentKey != null) {\n return updateTree(\n items,\n node.parentKey,\n (parent) => ({\n ...parent,\n children: parent.children!.filter((c) => c.key !== key),\n }),\n newMap,\n );\n }\n return { items: items.filter((i) => i.key !== key), nodeMap: newMap };\n }\n\n newMap.set(key!, updated);\n if (updated.children) {\n for (const child of updated.children) {\n addNode(child, newMap);\n }\n }\n\n if (node.parentKey != null) {\n return updateTree(\n items,\n node.parentKey,\n (parent) => ({\n ...parent,\n children: parent.children!.map((c) => (c.key === key ? updated : c)),\n }),\n newMap,\n );\n }\n\n return { items: items.map((i) => (i.key === key ? updated : i)), nodeMap: newMap };\n }\n\n return { items, nodeMap: newMap };\n }\n\n return {\n get items() {\n return treeState().items;\n },\n get selectedKeys() {\n return selectedKeys();\n },\n\n setSelectedKeys(keys: Selection) {\n setSelectedKeys(keys);\n },\n\n getItem(key: Key) {\n return treeState().nodeMap.get(key);\n },\n\n insert(parentKey: Key | null, index: number, ...values: T[]) {\n setTreeState((state) => {\n const { items, nodeMap } = state;\n const newMap = new Map(nodeMap);\n const newNodes = values.map((v) => {\n const tree = buildTree([v], newMap, parentKey, getKey, getChildren);\n return tree.items[0];\n });\n\n if (parentKey == null) {\n return {\n items: [...items.slice(0, index), ...newNodes, ...items.slice(index)],\n nodeMap: newMap,\n };\n }\n\n return updateTree(\n items,\n parentKey,\n (parent) => ({\n ...parent,\n children: [\n ...(parent.children || []).slice(0, index),\n ...newNodes,\n ...(parent.children || []).slice(index),\n ],\n }),\n newMap,\n );\n });\n },\n\n insertBefore(key: Key, ...values: T[]) {\n setTreeState((state) => {\n const { items, nodeMap } = state;\n const node = nodeMap.get(key);\n if (!node) return state;\n\n const parent = node.parentKey != null ? nodeMap.get(node.parentKey) : null;\n const siblings = parent?.children ?? items;\n const index = siblings.findIndex((n) => n.key === key);\n if (index === -1) return state;\n\n const newMap = new Map(nodeMap);\n const newNodes = values.map((v) => {\n const tree = buildTree([v], newMap, node.parentKey, getKey, getChildren);\n return tree.items[0];\n });\n\n if (node.parentKey == null) {\n return {\n items: [...items.slice(0, index), ...newNodes, ...items.slice(index)],\n nodeMap: newMap,\n };\n }\n\n return updateTree(\n items,\n node.parentKey,\n (p) => ({\n ...p,\n children: [...p.children!.slice(0, index), ...newNodes, ...p.children!.slice(index)],\n }),\n newMap,\n );\n });\n },\n\n insertAfter(key: Key, ...values: T[]) {\n setTreeState((state) => {\n const { items, nodeMap } = state;\n const node = nodeMap.get(key);\n if (!node) return state;\n\n const parent = node.parentKey != null ? nodeMap.get(node.parentKey) : null;\n const siblings = parent?.children ?? items;\n const index = siblings.findIndex((n) => n.key === key);\n if (index === -1) return state;\n\n const newMap = new Map(nodeMap);\n const newNodes = values.map((v) => {\n const tree = buildTree([v], newMap, node.parentKey, getKey, getChildren);\n return tree.items[0];\n });\n\n if (node.parentKey == null) {\n return {\n items: [...items.slice(0, index + 1), ...newNodes, ...items.slice(index + 1)],\n nodeMap: newMap,\n };\n }\n\n return updateTree(\n items,\n node.parentKey,\n (p) => ({\n ...p,\n children: [\n ...p.children!.slice(0, index + 1),\n ...newNodes,\n ...p.children!.slice(index + 1),\n ],\n }),\n newMap,\n );\n });\n },\n\n append(parentKey: Key | null, ...values: T[]) {\n setTreeState((state) => {\n const { items, nodeMap } = state;\n const newMap = new Map(nodeMap);\n const newNodes = values.map((v) => {\n const tree = buildTree([v], newMap, parentKey, getKey, getChildren);\n return tree.items[0];\n });\n\n if (parentKey == null) {\n return { items: [...items, ...newNodes], nodeMap: newMap };\n }\n\n return updateTree(\n items,\n parentKey,\n (parent) => ({\n ...parent,\n children: [...(parent.children || []), ...newNodes],\n }),\n newMap,\n );\n });\n },\n\n prepend(parentKey: Key | null, ...values: T[]) {\n setTreeState((state) => {\n const { items, nodeMap } = state;\n const newMap = new Map(nodeMap);\n const newNodes = values.map((v) => {\n const tree = buildTree([v], newMap, parentKey, getKey, getChildren);\n return tree.items[0];\n });\n\n if (parentKey == null) {\n return { items: [...newNodes, ...items], nodeMap: newMap };\n }\n\n return updateTree(\n items,\n parentKey,\n (parent) => ({\n ...parent,\n children: [...newNodes, ...(parent.children || [])],\n }),\n newMap,\n );\n });\n },\n\n remove(...keys: Key[]) {\n setTreeState((state) => {\n let { items, nodeMap } = state;\n let newMap = new Map(nodeMap);\n let newItems = items;\n\n for (const key of keys) {\n const result = updateTree(newItems, key, () => null, newMap);\n newItems = result.items;\n newMap = result.nodeMap;\n }\n\n return { items: newItems, nodeMap: newMap };\n });\n\n setSelectedKeys((sel) => {\n if (sel === \"all\") return sel;\n const newSel = new Set(sel);\n for (const key of keys) {\n newSel.delete(key);\n }\n return newSel;\n });\n },\n\n removeSelectedItems() {\n const sel = selectedKeys();\n if (sel === \"all\") {\n setTreeState({ items: [], nodeMap: new Map() });\n setSelectedKeys(new Set<Key>());\n return;\n }\n\n const keysToRemove = [...sel];\n setTreeState((state) => {\n let { items, nodeMap } = state;\n let newMap = new Map(nodeMap);\n let newItems = items;\n for (const key of keysToRemove) {\n const result = updateTree(newItems, key, () => null, newMap);\n newItems = result.items;\n newMap = result.nodeMap;\n }\n return { items: newItems, nodeMap: newMap };\n });\n setSelectedKeys(new Set<Key>());\n },\n\n move(key: Key, toParentKey: Key | null, index: number) {\n setTreeState((state) => {\n const { items, nodeMap } = state;\n const node = nodeMap.get(key);\n if (!node) return state;\n\n // Cyclical move validation: prevent moving a node into its own subtree\n if (toParentKey != null) {\n let parent: TreeNode<T> | undefined = nodeMap.get(toParentKey);\n while (parent) {\n if (parent.key === key) return state;\n parent = parent.parentKey != null ? nodeMap.get(parent.parentKey) : undefined;\n }\n }\n\n // Remove the node\n let newMap = new Map(nodeMap);\n const removeResult = updateTree(items, key, () => null, newMap);\n let newItems = removeResult.items;\n newMap = removeResult.nodeMap;\n\n // Re-add it at the target\n const movedNode: TreeNode<T> = { ...node, parentKey: toParentKey };\n addNode(movedNode, newMap);\n\n if (toParentKey == null) {\n return {\n items: [...newItems.slice(0, index), movedNode, ...newItems.slice(index)],\n nodeMap: newMap,\n };\n }\n\n return updateTree(\n newItems,\n toParentKey,\n (parent) => ({\n ...parent,\n children: [\n ...(parent.children || []).slice(0, index),\n movedNode,\n ...(parent.children || []).slice(index),\n ],\n }),\n newMap,\n );\n });\n },\n\n moveBefore(key: Key, keys: Iterable<Key>) {\n setTreeState((state) => {\n const { items, nodeMap } = state;\n const node = nodeMap.get(key);\n if (!node) return state;\n\n const toParentKey = node.parentKey ?? null;\n let parent: TreeNode<T> | null = null;\n if (toParentKey != null) {\n parent = nodeMap.get(toParentKey) ?? null;\n }\n const toIndex = parent?.children ? parent.children.indexOf(node) : items.indexOf(node);\n return moveItems(state, keys, parent, toIndex, updateTree, addNode);\n });\n },\n\n moveAfter(key: Key, keys: Iterable<Key>) {\n setTreeState((state) => {\n const { items, nodeMap } = state;\n const node = nodeMap.get(key);\n if (!node) return state;\n\n const toParentKey = node.parentKey ?? null;\n let parent: TreeNode<T> | null = null;\n if (toParentKey != null) {\n parent = nodeMap.get(toParentKey) ?? null;\n }\n let toIndex = parent?.children ? parent.children.indexOf(node) : items.indexOf(node);\n toIndex++;\n return moveItems(state, keys, parent, toIndex, updateTree, addNode);\n });\n },\n\n update(key: Key, newValue: T) {\n setTreeState((state) => {\n const { items, nodeMap } = state;\n const newMap = new Map(nodeMap);\n\n return updateTree(\n items,\n key,\n (oldNode) => {\n const node: TreeNode<T> = {\n key: oldNode.key,\n parentKey: oldNode.parentKey,\n value: newValue,\n children: null,\n };\n const tree = buildTree(getChildren(newValue), newMap, node.key, getKey, getChildren);\n node.children = tree.items;\n return node;\n },\n newMap,\n );\n });\n },\n };\n}\n\nfunction buildTree<T>(\n items: T[],\n nodeMap: Map<Key, TreeNode<T>>,\n parentKey: Key | null,\n getKey: (item: T) => Key,\n getChildren: (item: T) => T[],\n): TreeDataState<T> {\n const nodes: TreeNode<T>[] = [];\n\n for (const item of items) {\n const key = getKey(item);\n const children = getChildren(item);\n\n const childTree =\n children.length > 0\n ? buildTree(children, nodeMap, key, getKey, getChildren)\n : { items: [], nodeMap };\n\n const node: TreeNode<T> = {\n key,\n parentKey,\n value: item,\n children: childTree.items.length > 0 ? childTree.items : null,\n };\n\n nodeMap.set(key, node);\n nodes.push(node);\n }\n\n return { items: nodes, nodeMap };\n}\n\nfunction addNode<T>(node: TreeNode<T>, map: Map<Key, TreeNode<T>>): void {\n map.set(node.key, node);\n if (node.children) {\n for (const child of node.children) {\n addNode(child, map);\n }\n }\n}\n\nfunction deleteNode<T>(node: TreeNode<T>, map: Map<Key, TreeNode<T>>): void {\n map.delete(node.key);\n if (node.children) {\n for (const child of node.children) {\n deleteNode(child, map);\n }\n }\n}\n\nfunction moveItems<T>(\n state: TreeDataState<T>,\n keys: Iterable<Key>,\n toParent: TreeNode<T> | null,\n toIndex: number,\n updateTreeFn: (\n items: TreeNode<T>[],\n key: Key | null,\n update: (node: TreeNode<T>) => TreeNode<T> | null,\n originalMap: Map<Key, TreeNode<T>>,\n ) => TreeDataState<T>,\n addNodeFn: (node: TreeNode<T>, map: Map<Key, TreeNode<T>>) => void,\n): TreeDataState<T> {\n const { items, nodeMap } = state;\n\n // Cyclical move validation: prevent moving a node into its own subtree\n const removeKeys = new Set(keys);\n let ancestor: TreeNode<T> | null = toParent;\n while (ancestor != null) {\n if (removeKeys.has(ancestor.key)) {\n throw new Error(\"Cannot move an item to be a child of itself.\");\n }\n ancestor = ancestor.parentKey != null ? (nodeMap.get(ancestor.parentKey) ?? null) : null;\n }\n\n const originalToIndex = toIndex;\n const keyArray = [...removeKeys];\n\n // Depth-first traversal to determine in-order positions and remove items\n const inOrderKeys = new Map<Key, number>();\n const removedItems: TreeNode<T>[] = [];\n let newItems = items;\n let newMap = nodeMap;\n let i = 0;\n\n function traversal(\n node: { children?: TreeNode<T>[] | null },\n callbacks: {\n inorder?: (child: TreeNode<T>) => void;\n postorder?: (child: TreeNode<T>) => void;\n },\n ) {\n callbacks.inorder?.(node as TreeNode<T>);\n if (node.children) {\n for (const child of node.children) {\n traversal(child, callbacks);\n callbacks.postorder?.(child);\n }\n }\n }\n\n traversal(\n { children: items },\n {\n inorder(child) {\n if (keyArray.includes(child.key)) {\n inOrderKeys.set(child.key, i++);\n }\n },\n postorder(child) {\n if (keyArray.includes(child.key)) {\n removedItems.push({ ...newMap.get(child.key)!, parentKey: toParent?.key ?? null });\n const result = updateTreeFn(newItems, child.key, () => null, newMap);\n newItems = result.items;\n newMap = result.nodeMap;\n }\n // Decrement index if the removed child is in the target parent and before the target index\n if (\n (child.parentKey === toParent || child.parentKey === toParent?.key) &&\n keyArray.includes(child.key) &&\n (toParent?.children ? toParent.children.indexOf(child) : items.indexOf(child)) <\n originalToIndex\n ) {\n toIndex--;\n }\n },\n },\n );\n\n const inOrderItems = removedItems.sort((a, b) =>\n inOrderKeys.get(a.key)! > inOrderKeys.get(b.key)! ? 1 : -1,\n );\n\n // If parentKey is null, insert into the root.\n if (!toParent || toParent.key == null) {\n inOrderItems.forEach((movedNode) => {\n addNodeFn(movedNode, newMap);\n });\n return {\n items: [...newItems.slice(0, toIndex), ...inOrderItems, ...newItems.slice(toIndex)],\n nodeMap: newMap,\n };\n }\n\n // Otherwise, update the parent node and its ancestors.\n return updateTreeFn(\n newItems,\n toParent.key,\n (parentNode) => ({\n key: parentNode.key,\n parentKey: parentNode.parentKey,\n value: parentNode.value,\n children: [\n ...parentNode.children!.slice(0, toIndex),\n ...inOrderItems,\n ...parentNode.children!.slice(toIndex),\n ],\n }),\n newMap,\n );\n}\n","/**\n * createAsyncList - SolidJS port of React Spectrum's useAsyncList\n *\n * Manages state for an immutable async loaded list data structure, and provides\n * convenience methods to update the data over time. Manages loading and error\n * states, pagination, and sorting.\n */\n\nimport { createSignal, untrack } from \"solid-js\";\n\nexport type Key = string | number;\nexport type Selection = \"all\" | Set<Key>;\nexport type LoadingState = \"idle\" | \"loading\" | \"loadingMore\" | \"sorting\" | \"filtering\" | \"error\";\n\nexport interface SortDescriptor {\n /** The key of the column to sort by. */\n column?: Key;\n /** The direction to sort by. */\n direction?: \"ascending\" | \"descending\";\n}\n\nexport interface AsyncListLoadOptions<T, C> {\n /** The items currently in the list. */\n items: T[];\n /** The keys of the currently selected items in the list. */\n selectedKeys: Selection;\n /** The current sort descriptor for the list. */\n sortDescriptor?: SortDescriptor;\n /** An abort signal used to notify the load function that the request has been aborted. */\n signal: AbortSignal;\n /** The pagination cursor returned from the last page load. */\n cursor?: C;\n /** The current filter text used to perform server side filtering. */\n filterText?: string;\n /** The current loading state of the list. */\n loadingState?: LoadingState;\n}\n\nexport interface AsyncListStateUpdate<T, C> {\n /** The new items to append to the list. */\n items: Iterable<T>;\n /** The keys to add to the selection. */\n selectedKeys?: Iterable<Key>;\n /** The sort descriptor to set. */\n sortDescriptor?: SortDescriptor;\n /** The pagination cursor to be used for the next page load. */\n cursor?: C;\n /** The updated filter text for the list. */\n filterText?: string;\n}\n\nexport type AsyncListLoadFunction<T, C> = (\n state: AsyncListLoadOptions<T, C>,\n) => AsyncListStateUpdate<T, C> | Promise<AsyncListStateUpdate<T, C>>;\n\nexport interface AsyncListOptions<T, C> {\n /** The keys for the initially selected items. */\n initialSelectedKeys?: \"all\" | Iterable<Key>;\n /** The initial sort descriptor. */\n initialSortDescriptor?: SortDescriptor;\n /** The initial filter text. */\n initialFilterText?: string;\n /** A function that returns a unique key for an item object. */\n getKey?: (item: T) => Key;\n /** A function that loads the data for the items in the list. */\n load: AsyncListLoadFunction<T, C>;\n /** An optional function that performs sorting. */\n sort?: AsyncListLoadFunction<T, C>;\n}\n\nexport interface AsyncListData<T> {\n /** The items in the list. */\n readonly items: T[];\n /** The keys of the currently selected items in the list. */\n readonly selectedKeys: Selection;\n /** The current sort descriptor for the list. */\n readonly sortDescriptor: SortDescriptor | undefined;\n /** Whether data is currently being loaded. */\n readonly isLoading: boolean;\n /** If loading data failed, then this contains the error that occurred. */\n readonly error: Error | undefined;\n /** The current filter text. */\n readonly filterText: string;\n /** The current loading state for the list. */\n readonly loadingState: LoadingState;\n\n /** Reloads the data in the list. */\n reload(): void;\n /** Loads the next page of data in the list. */\n loadMore(): void;\n /** Triggers sorting for the list. */\n sort(descriptor: SortDescriptor): void;\n\n /** Sets the selected keys. */\n setSelectedKeys(keys: Selection): void;\n /** Sets the filter text. */\n setFilterText(filterText: string): void;\n\n /** Gets an item from the list by key. */\n getItem(key: Key): T | undefined;\n /** Inserts items into the list at the given index. */\n insert(index: number, ...values: T[]): void;\n /** Inserts items before a given key. */\n insertBefore(key: Key, ...values: T[]): void;\n /** Inserts items after a given key. */\n insertAfter(key: Key, ...values: T[]): void;\n /** Appends items to the list. */\n append(...values: T[]): void;\n /** Prepends items to the list. */\n prepend(...values: T[]): void;\n /** Removes items from the list by their keys. */\n remove(...keys: Key[]): void;\n /** Removes all items from the list that are currently in the set of selected items. */\n removeSelectedItems(): void;\n /** Moves an item within the list. */\n move(key: Key, toIndex: number): void;\n /** Updates an item in the list. */\n update(key: Key, newValue: T): void;\n}\n\ninterface InternalState<T, C> {\n loadingState: LoadingState;\n items: T[];\n selectedKeys: Selection;\n sortDescriptor?: SortDescriptor;\n error?: Error;\n cursor?: C;\n filterText: string;\n abortController?: AbortController;\n}\n\n/**\n * Manages state for an immutable async loaded list data structure, and provides\n * convenience methods to update the data over time. Manages loading and error\n * states, pagination, and sorting.\n */\nexport function createAsyncList<T, C = string>(options: AsyncListOptions<T, C>): AsyncListData<T> {\n const defaultGetKey = (item: T): Key => {\n const candidate = item as { id?: Key; key?: Key };\n return candidate.id ?? candidate.key ?? String(item);\n };\n\n const {\n load,\n sort: sortFn,\n initialSelectedKeys,\n initialSortDescriptor,\n getKey = defaultGetKey,\n initialFilterText = \"\",\n } = options;\n\n const [state, setState] = createSignal<InternalState<T, C>>({\n loadingState: \"idle\",\n items: [],\n selectedKeys: initialSelectedKeys === \"all\" ? \"all\" : new Set(initialSelectedKeys || []),\n sortDescriptor: initialSortDescriptor,\n filterText: initialFilterText,\n });\n\n async function dispatchFetch(\n type: \"loading\" | \"loadingMore\" | \"sorting\" | \"filtering\",\n fn: AsyncListLoadFunction<T, C>,\n opts?: { sortDescriptor?: SortDescriptor; filterText?: string },\n ) {\n const abortController = new AbortController();\n const currentState = untrack(state);\n\n // Update to loading state\n setState((s) => {\n // Abort previous request if one is in progress\n if (s.abortController) {\n s.abortController.abort();\n }\n return {\n ...s,\n loadingState: type,\n items: type === \"loading\" ? [] : s.items,\n sortDescriptor: opts?.sortDescriptor ?? s.sortDescriptor,\n filterText: opts?.filterText ?? s.filterText,\n abortController,\n };\n });\n\n try {\n const previousFilterText = opts?.filterText ?? currentState.filterText;\n const response = await fn({\n items: currentState.items.slice(),\n selectedKeys: currentState.selectedKeys,\n sortDescriptor: opts?.sortDescriptor ?? currentState.sortDescriptor,\n signal: abortController.signal,\n cursor: type === \"loadingMore\" ? currentState.cursor : undefined,\n filterText: previousFilterText,\n loadingState: currentState.loadingState,\n });\n\n setState((s) => {\n // Ignore stale response\n if (s.abortController !== abortController) return s;\n\n const newItems = [...(response.items ?? [])];\n const items = type === \"loadingMore\" ? [...s.items, ...newItems] : newItems;\n\n let selectedKeys: Selection;\n if (type === \"loadingMore\") {\n selectedKeys =\n s.selectedKeys === \"all\" || response.selectedKeys === \"all\"\n ? \"all\"\n : new Set([...(s.selectedKeys as Set<Key>), ...(response.selectedKeys ?? [])]);\n } else {\n selectedKeys = response.selectedKeys\n ? response.selectedKeys === \"all\"\n ? \"all\"\n : new Set(response.selectedKeys)\n : s.selectedKeys;\n }\n\n return {\n ...s,\n loadingState: \"idle\",\n items,\n selectedKeys,\n sortDescriptor: response.sortDescriptor ?? s.sortDescriptor,\n cursor: response.cursor as C | undefined,\n filterText: response.filterText ?? s.filterText,\n error: undefined,\n abortController: undefined,\n };\n });\n\n // Trigger another filter if filterText changed in the response\n const responseFilterText = response.filterText ?? previousFilterText;\n if (\n responseFilterText &&\n responseFilterText !== previousFilterText &&\n !abortController.signal.aborted\n ) {\n dispatchFetch(\"filtering\", load, { filterText: responseFilterText });\n }\n } catch (e) {\n setState((s) => {\n if (s.abortController !== abortController) return s;\n return {\n ...s,\n loadingState: \"error\",\n error: e as Error,\n abortController: undefined,\n };\n });\n }\n }\n\n // Trigger initial load immediately\n dispatchFetch(\"loading\", load);\n\n return {\n get items() {\n return state().items;\n },\n get selectedKeys() {\n return state().selectedKeys;\n },\n get sortDescriptor() {\n return state().sortDescriptor;\n },\n get isLoading() {\n const ls = state().loadingState;\n return ls === \"loading\" || ls === \"loadingMore\" || ls === \"sorting\" || ls === \"filtering\";\n },\n get error() {\n return state().error;\n },\n get filterText() {\n return state().filterText;\n },\n get loadingState() {\n return state().loadingState;\n },\n\n reload() {\n dispatchFetch(\"loading\", load);\n },\n\n loadMore() {\n const s = state();\n if (\n s.loadingState === \"loading\" ||\n s.loadingState === \"loadingMore\" ||\n s.loadingState === \"filtering\" ||\n s.cursor == null\n ) {\n return;\n }\n dispatchFetch(\"loadingMore\", load);\n },\n\n sort(descriptor: SortDescriptor) {\n dispatchFetch(\"sorting\", (sortFn || load) as AsyncListLoadFunction<T, C>, {\n sortDescriptor: descriptor,\n });\n },\n\n setSelectedKeys(keys: Selection) {\n setState((s) => ({ ...s, selectedKeys: keys }));\n },\n\n setFilterText(filterText: string) {\n dispatchFetch(\"filtering\", load, { filterText });\n },\n\n getItem(key: Key) {\n return state().items.find((item) => getKey(item) === key);\n },\n\n insert(index: number, ...values: T[]) {\n setState((s) => ({\n ...s,\n items: [...s.items.slice(0, index), ...values, ...s.items.slice(index)],\n }));\n },\n\n insertBefore(key: Key, ...values: T[]) {\n setState((s) => {\n const index = s.items.findIndex((item) => getKey(item) === key);\n if (index === -1) return s;\n return {\n ...s,\n items: [...s.items.slice(0, index), ...values, ...s.items.slice(index)],\n };\n });\n },\n\n insertAfter(key: Key, ...values: T[]) {\n setState((s) => {\n const index = s.items.findIndex((item) => getKey(item) === key);\n if (index === -1) return s;\n return {\n ...s,\n items: [...s.items.slice(0, index + 1), ...values, ...s.items.slice(index + 1)],\n };\n });\n },\n\n append(...values: T[]) {\n setState((s) => ({ ...s, items: [...s.items, ...values] }));\n },\n\n prepend(...values: T[]) {\n setState((s) => ({ ...s, items: [...values, ...s.items] }));\n },\n\n remove(...keys: Key[]) {\n setState((s) => {\n const keySet = new Set(keys);\n const items = s.items.filter((item) => !keySet.has(getKey(item)));\n let selectedKeys = s.selectedKeys;\n if (selectedKeys !== \"all\") {\n const newSelection = new Set(selectedKeys);\n for (const key of keys) {\n newSelection.delete(key);\n }\n selectedKeys = newSelection;\n }\n return { ...s, items, selectedKeys };\n });\n },\n\n removeSelectedItems() {\n setState((s) => {\n if (s.selectedKeys === \"all\") {\n return { ...s, items: [], selectedKeys: new Set() };\n }\n const sel = s.selectedKeys;\n return {\n ...s,\n items: s.items.filter((item) => !sel.has(getKey(item))),\n selectedKeys: new Set(),\n };\n });\n },\n\n move(key: Key, toIndex: number) {\n setState((s) => {\n const index = s.items.findIndex((item) => getKey(item) === key);\n if (index === -1) return s;\n const copy = s.items.slice();\n const [item] = copy.splice(index, 1);\n copy.splice(toIndex, 0, item);\n return { ...s, items: copy };\n });\n },\n\n update(key: Key, newValue: T) {\n setState((s) => {\n const index = s.items.findIndex((item) => getKey(item) === key);\n if (index === -1) return s;\n return {\n ...s,\n items: [...s.items.slice(0, index), newValue, ...s.items.slice(index + 1)],\n };\n });\n },\n };\n}\n","/**\n * getColorChannels - Standalone function to get color channels for a color space.\n *\n * Returns the three channels for a given color space.\n */\n\nimport type { ColorChannel, ColorSpace } from \"./types\";\n\nconst COLOR_SPACE_CHANNELS: Record<ColorSpace, [ColorChannel, ColorChannel, ColorChannel]> = {\n rgb: [\"red\", \"green\", \"blue\"],\n hsl: [\"hue\", \"saturation\", \"lightness\"],\n hsb: [\"hue\", \"saturation\", \"brightness\"],\n};\n\n/**\n * Returns the color channels for a given color space.\n *\n * @param colorSpace - The color space to get channels for.\n * @returns A tuple of three color channels.\n *\n * @example\n * ```ts\n * getColorChannels('rgb') // ['red', 'green', 'blue']\n * getColorChannels('hsl') // ['hue', 'saturation', 'lightness']\n * getColorChannels('hsb') // ['hue', 'saturation', 'brightness']\n * ```\n */\nexport function getColorChannels(\n colorSpace: ColorSpace,\n): [ColorChannel, ColorChannel, ColorChannel] {\n const channels = COLOR_SPACE_CHANNELS[colorSpace];\n if (!channels) {\n throw new Error(`Unknown color space: ${colorSpace}`);\n }\n return channels;\n}\n","/**\n * State management for step list components.\n * Tracks selected step, completion status, and selectability.\n */\n\nimport { createEffect, createMemo, createSignal, type Accessor } from \"solid-js\";\nimport type { Key } from \"../collections/types\";\n\nexport interface StepListStateProps {\n /** The currently selected step key (controlled). */\n selectedKey?: Key;\n /** The default selected step key (uncontrolled). */\n defaultSelectedKey?: Key;\n /** Called when the selected step changes. */\n onSelectionChange?: (key: Key) => void;\n /** The last completed step key (controlled). */\n lastCompletedStep?: Key;\n /** The default last completed step key (uncontrolled). */\n defaultLastCompletedStep?: Key;\n /** Called when last completed step changes. */\n onLastCompletedStepChange?: (key: Key | null) => void;\n /** Whether all steps are disabled. */\n isDisabled?: boolean;\n /** Whether all steps are read-only. */\n isReadOnly?: boolean;\n /** Keys of individually disabled steps. */\n disabledKeys?: Iterable<Key>;\n /** The step items. */\n items: Array<{ key: Key; [key: string]: any }>;\n}\n\nexport interface StepListState {\n readonly selectedKey: Accessor<Key | null>;\n readonly lastCompletedStep: Accessor<Key | null>;\n readonly items: Accessor<Array<{ key: Key }>>;\n setSelectedKey(key: Key): void;\n setLastCompletedStep(key: Key): void;\n isCompleted(key: Key): boolean;\n isSelectable(key: Key): boolean;\n isDisabled: Accessor<boolean>;\n isReadOnly: Accessor<boolean>;\n}\n\n/**\n * Creates state for a step list component.\n */\nexport function createStepListState(props: StepListStateProps): StepListState {\n const items = () => props.items;\n\n // Build an index map: Key -> index\n const indexMap = createMemo(() => {\n const map = new Map<Key, number>();\n const currentItems = items();\n for (let i = 0; i < currentItems.length; i++) {\n map.set(currentItems[i].key, i);\n }\n return map;\n });\n\n // Disabled keys set\n const disabledKeysSet = createMemo(() => new Set<Key>(props.disabledKeys ?? []));\n\n const isDisabled: Accessor<boolean> = () => props.isDisabled ?? false;\n const isReadOnly: Accessor<boolean> = () => props.isReadOnly ?? false;\n\n // Last completed step signal (uncontrolled)\n const [lastCompletedStepInternal, setLastCompletedStepInternal] = createSignal<Key | null>(\n props.defaultLastCompletedStep ?? null,\n );\n\n const lastCompletedStep: Accessor<Key | null> = () => {\n if (props.lastCompletedStep !== undefined) {\n return props.lastCompletedStep;\n }\n return lastCompletedStepInternal();\n };\n\n const setLastCompletedStep = (key: Key) => {\n const currentIndex = indexMap().get(key);\n const prevIndex = lastCompletedStep() !== null ? indexMap().get(lastCompletedStep()!) : -1;\n\n // Only advance completion, never go back\n if (\n currentIndex !== undefined &&\n (prevIndex === undefined || currentIndex > (prevIndex ?? -1))\n ) {\n if (props.lastCompletedStep === undefined) {\n setLastCompletedStepInternal(key);\n }\n props.onLastCompletedStepChange?.(key);\n }\n };\n\n const isCompleted = (key: Key): boolean => {\n const completed = lastCompletedStep();\n if (completed === null) return false;\n const keyIndex = indexMap().get(key);\n const completedIndex = indexMap().get(completed);\n if (keyIndex === undefined || completedIndex === undefined) return false;\n return keyIndex <= completedIndex;\n };\n\n const isStepDisabled = (key: Key): boolean => {\n if (isDisabled()) return true;\n return disabledKeysSet().has(key);\n };\n\n const isSelectable = (key: Key): boolean => {\n if (isDisabled() || isReadOnly() || isStepDisabled(key)) return false;\n // Completed steps are always selectable\n if (isCompleted(key)) return true;\n // First step is always selectable\n const keyIndex = indexMap().get(key);\n if (keyIndex === 0) return true;\n // Otherwise a step is selectable only if the PREVIOUS step is completed —\n // mirrors react-stately `useStepListState.isSelectable`\n // (`isCompleted(prevStep) || step === firstKey`). There is no \"step after the\n // currently selected step\" clause upstream: a fresh list exposes only the\n // first step, and the immediate-next step becomes selectable when its\n // predecessor is *completed*, not merely selected.\n const currentItems = items();\n if (keyIndex !== undefined && keyIndex > 0) {\n const prevKey = currentItems[keyIndex - 1].key;\n if (isCompleted(prevKey)) return true;\n }\n return false;\n };\n\n // Find the first selectable non-completed step\n const findDefaultSelectedKey = (): Key | null => {\n const currentItems = items();\n for (const item of currentItems) {\n if (!isCompleted(item.key) && !isStepDisabled(item.key)) {\n return item.key;\n }\n }\n // All completed - select first non-disabled\n for (const item of currentItems) {\n if (!isStepDisabled(item.key)) {\n return item.key;\n }\n }\n return currentItems.length > 0 ? currentItems[0].key : null;\n };\n\n // Selected key signal (uncontrolled)\n const [selectedKeyInternal, setSelectedKeyInternal] = createSignal<Key | null>(\n props.defaultSelectedKey ?? findDefaultSelectedKey(),\n );\n\n const selectedKey: Accessor<Key | null> = () => {\n if (props.selectedKey !== undefined) {\n return props.selectedKey;\n }\n return selectedKeyInternal();\n };\n\n const setSelectedKey = (key: Key) => {\n if (isReadOnly() || isDisabled()) return;\n if (!isSelectable(key)) return;\n\n // Mark previous selected step as completed if advancing\n const currentSelected = selectedKey();\n if (currentSelected !== null) {\n const currentIndex = indexMap().get(currentSelected);\n const newIndex = indexMap().get(key);\n if (\n currentIndex !== undefined &&\n newIndex !== undefined &&\n newIndex > currentIndex &&\n !isCompleted(currentSelected)\n ) {\n setLastCompletedStep(currentSelected);\n }\n }\n\n if (props.selectedKey === undefined) {\n setSelectedKeyInternal(key);\n }\n props.onSelectionChange?.(key);\n };\n\n // Mirror react-stately `useStepListState`'s effect: whenever the selected step\n // sits more than one past the last completed step (e.g. mounted with a\n // `defaultSelectedKey` ahead of progress), auto-complete its immediate\n // predecessor. Because completion is cumulative (`isCompleted` = index ≤\n // lastCompleted index), advancing `lastCompletedStep` to `selectedIdx - 1`\n // marks every intermediate step complete. This runs regardless of\n // `isDisabled` / `isReadOnly`, exactly as upstream (the effect is ungated).\n createEffect(() => {\n const selKey = selectedKey();\n if (selKey === null) return;\n const selIdx = indexMap().get(selKey);\n if (selIdx === undefined || selIdx <= 0) return;\n const completed = lastCompletedStep();\n const lcs = completed !== null ? (indexMap().get(completed) ?? -1) : -1;\n if (selIdx > lcs + 1) {\n const prevKey = items()[selIdx - 1]?.key;\n if (prevKey !== undefined) setLastCompletedStep(prevKey);\n }\n });\n\n return {\n selectedKey,\n lastCompletedStep,\n items,\n setSelectedKey,\n setLastCompletedStep,\n isCompleted,\n isSelectable,\n isDisabled,\n isReadOnly,\n };\n}\n"],"mappings":";;;;;;;;;;;AAqBA,SAAgB,OAAU,OAA4B;CACpD,OAAO,OAAO,UAAU,aAAc,MAAsB,IAAI;AAClE;;;;AAUA,SAAgB,WAAc,OAA+C;CAC3E,OAAO,OAAO,UAAU;AAC1B;;;;;;;;;;;;;ACCA,SAAgB,kBAAkB,QAA2C,CAAC,GAAgB;CAC5F,MAAM,iBAAiB,OAAO,KAAK;CAEnC,MAAM,eAAe,SAAS;CAC9B,MAAM,kBAAkB,aAAa,cAAc,aAAa,mBAAmB;CAEnF,MAAM,CAAC,kBAAkB,uBAAuB,aAAa,eAAe;CAE5E,MAAM,qBAAqB,SAAS,CAAC,CAAC,eAAe,KAAA;CAErD,MAAM,mBAAsC;EAC1C,MAAM,IAAI,SAAS;EACnB,OAAO,aAAa,IAAK,EAAE,cAAc,QAAS,iBAAiB;CACrE;CAEA,SAAS,YAAY,OAAsB;EACzC,MAAM,IAAI,SAAS;EACnB,IAAI,EAAE,YACJ;EAGF,IAAI,CAAC,aAAa,GAChB,oBAAoB,KAAK;EAG3B,EAAE,WAAW,KAAK;CACpB;CAEA,SAAS,SAAe;EAEtB,IADU,SACN,CAAC,CAAC,YACJ;EAGF,YAAY,CAAC,WAAW,CAAC;CAC3B;CAEA,OAAO;EACL;EACA,iBAAiB,aAAa,mBAAmB;EACjD;EACA;CACF;AACF;;;;;;;;;;;ACjCA,SAAS,SAAS,MAAgC;CAChD,OAAO,IAAI,IAAI,OAAO,MAAM,KAAK,IAAI,IAAI,CAAC,CAAC;AAC7C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