@eschoolbase/client-ui 0.2.1 → 0.3.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/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["root","styles","button","sm","md","lg","primary","danger","spinner","styles","root","label","required","message","helper","error","styles","pad","today","root","header","title","footerButton","grid","selected","footer","chevron","getToday","styles","_Fragment","control","trigger","open","value","placeholder","sm","md","lg","icon","clear","invalid","disabled","panel","MENU_GAP","MENU_ESTIMATED_HEIGHT","FOCUSABLE","styles","_Fragment","root","list","option","selected","styles","footer","today","styles","chevron","getToday","styles","_Fragment","control","disabled","invalid","sm","md","lg","input","readOnly","styles","styles","search","icon","clear","styles","root","styles","backdrop","center","panel","FOCUSABLE","styles","header","heading","title","body","footer","_Fragment","styles","panel","sm","md","lg","xl","styles","panel","sm","md","lg","styles","_Fragment","styles","trigger","open","sm","md","lg","invalid","disabled","search","list","option","selected","check","empty","MENU_GAP","MENU_ESTIMATED_HEIGHT","styles","root","info","summary","button","icon","styles","_Fragment","caption","row","selected","styles","_Fragment","root","heading","title","subtitle","actions","styles","pill","label","dot","success","info","danger","warning","neutral","empty","TONES","styles","root","label","disabled","input","invalid","text","required","message","helper","error","styles","root","item","danger","label","icon","styles","root","circle","styles","root","actions","styles","root","actions","styles","styles","styles","title","circle","image","error","styles","_Fragment","root","disabled","invalid","tile","input","icon","list","styles","_Fragment","invalid","styles","root","label","input","styles","root","primary","danger","styles","root","icon","panel","styles","root","styles","root","styles","root","styles","_Fragment","root","styles","_Fragment","styles","cn","values","SALT","hashKey","text","key","h1","h2","i","ch","VALID_KEY_HASHES","globalKey","listeners","warned","LicenseContext","createContext","setLicenseKey","listener","isValidLicenseKey","subscribe","getSnapshot","useLicensed","providedKey","useContext","useSyncExternalStore","licensed","useEffect","UnlicensedNotice_module_default","UnlicensedNotice","Button_module_default","Button","forwardRef","rest","disabled","loading","variant","size","fullWidth","className","children","FormFieldContext","useFormFieldControl","context","generatedId","useId","id","options","required","invalid","describedBy","FormField_module_default","FormField","idProp","hasError","error","messageId","helperText","useMemo","label","pad$1","n","length","toISO","date","parseISO","value","today$1","now","addDays","days","addMonths","first","months","last","isSameDay","a","b","buildMonthGrid","month","offset","weekStartsOn","createDisabledPredicate","min","max","todayISO","dates","d","ranges","r","weekdays","iso","nearestEnabled","isDisabled","after","before","toMonthISO","parseMonth","createMonthDisabledPredicate","current","listed","m","toDateTimeISO","parseDateTime","match","day","hours","minutes","withTime","Calendar_module_default","chevron$2","direction","Calendar","todayDate","cursor","setCursor","useState","selected","view","setView","gridRef","useRef","focusCursor","monthName","locale","monthShort","base","dayLabel","year","yearStart","cursorISO","moveCursor","next","handleGridKeyDown","move","event","page","prevLabel","nextLabel","Fragment","outside","isSelected","onSelect","name","y","showFooter","allowClear","PickerField_module_default","MENU_GAP$2","MENU_ESTIMATED_HEIGHT$2","FOCUSABLE$2","PickerFieldControl","ariaDescribedBy","control","panelId","containerRef","triggerRef","panelRef","setTriggerRef","useCallback","node","ref","open","setOpen","style","setStyle","themeName","setThemeName","computePosition","container","rect","spaceBelow","above","panelWidth","openPicker","focusTick","setFocusTick","close","restoreFocus","tick","reposition","onPointerDown","target","handlePanelKeyDown","nodes","hasValue","displayText","showClear","clearable","onClick","onKeyDown","placeholder","clearLabel","onClear","icon","hiddenValue","createPortal","panelLabel","PickerShell","PickerField","DatePicker","isControlled","internal","setInternal","defaultValue","formatter","commit","onChange","TimeColumns_module_default","pad","TimeColumns","h","isPm","minuteValues","minuteStep","v","hourDisabled","isTimeDisabled","hour","hourOptions","use12Hours","minuteOptions","periodDisabled","start","periodOptions","Column","listRef","selectedIndex","option","list","el","items","index","DateTimePicker_module_default","parseBoundary","full","end","parseTime","DateTimePicker","earliest","disablePast","latest","disableFuture","isDayDisabled","isMomentDisabled","moment","fitTime","wanted","total","candidate","baseDay","defaultHours","defaultMinutes","defaultTime","nowDate","chevron$1","firstOfMonth","MonthCalendar","thisMonth","monthNames","monthLong","handleKeyDown","step","MonthPicker","PICKER_TYPES","isPickerType","type","PickerTypeInput","hiddenRef","setRef","common","input","dateOptions","Input_module_default","InputControl","readOnly","prefix","suffix","Input","props","PasswordInput_module_default","PasswordInput","visible","setVisible","autoComplete","hideLabel","showLabel","SearchInput_module_default","SearchInput","innerRef","DARK_QUERY","useSystemPrefersDark","query","storageListeners","readStorage","writeStoredTheme","theme","useStoredTheme","ThemeProvider_module_default","ThemeContext","ThemeProvider","controlledTheme","internalTheme","setInternalTheme","defaultTheme","storedTheme","storageKey","systemPrefersDark","resolvedTheme","setTheme","onThemeChange","inheritedKey","licenseKey","useTheme","useOptionalTheme","Overlay_module_default","FOCUSABLE$1","lockCount","previousOverflow","lockScroll","unlockScroll","Overlay","ariaLabel","baseId","titleId","descriptionId","pressedOnBackdrop","previous","panel","placement","closeOnBackdrop","onClose","panelClassName","closeOnEscape","active","OverlayContent_module_default","OverlayContent","title","description","hideCloseButton","closeLabel","footer","Modal_module_default","Modal","bare","Drawer_module_default","Drawer","ConfirmDialog_module_default","ConfirmDialog","typed","setTyped","confirmed","requireText","danger","tone","message","cancelLabel","onConfirm","confirmLabel","Select_module_default","MENU_GAP$1","MENU_ESTIMATED_HEIGHT$1","SEARCH_DEBOUNCE_MS","toArray","SelectControl","listId","valueId","optionId","popoverRef","searchRef","position","setPosition","search","setSearch","showSearch","setShowSearch","highlighted","setHighlighted","filtered","onSearch","multiple","firstEnabled","updatePosition","openMenu","firstSelected","o","closeMenu","selectOption","moveHighlight","onSearchRef","timer","handler","handleTriggerKeyDown","handleMenuKeyDown","isPrintable","selectedOptions","activeDescendant","labelledBy","listClassName","emptyMessage","Select","controlProps","getPageItems","pageCount","range","to","from","startPages","boundaryCount","endPages","siblingsStart","siblingCount","siblingsEnd","item","Pagination_module_default","icon$4","path","Pagination","showFirstLastProp","go","onPageChange","split","layout","showFirstLast","showSummary","pageSize","totalItems","showPageSize","pageSizeOptions","onPageSizeChange","summaryNode","pageSizeNode","pagesNode","Table_module_default","Table","bordered","containerClassName","scrollLabel","stickyHeader","TableHead","TableBody","TableFoot","TableRow","TableHeaderCell","ariaSort","sortable","sortDirection","align","onSort","TableCell","TableCaption","PageHeader_module_default","PageHeader","onBack","backLabel","subtitle","actions","StatusPill_module_default","TONES$1","StatusPill","status","resolved","pulse","Checkbox_module_default","Checkbox","indeterminate","hasMessage","DropdownMenu_module_default","MENU_GAP","MENU_WIDTH","MENU_ESTIMATED_HEIGHT","ITEM","DropdownMenu","menuId","menuRef","trigger","fitsRight","setOpenState","onOpenChange","focusItem","which","action","Skeleton_module_default","Skeleton","height","width","DataTable_module_default","SelectionBar","count","FilterValueControl","field","TableFilters_module_default","rowCounter","nextRowId","rowsFromValues","valuesFromRows","row","rows","DynamicFilterRows","used","available","fields","update","patch","f","choices","activeFilters","filterValueLabel","FiltersPanel","setRows","onApply","TableFilters","panelOpen","setPanelOpen","setText","lastExternal","activeFields","hasFields","onValuesChange","handleSearch","searchDelay","onSearchChange","searchPlaceholder","_removed","panelTitle","getValue","column","asText","searchRows","needle","columns","filterRows","filters","filterValue","c","collator","sortRows","sort","read","factor","aEmpty","bEmpty","result","entry","paginateRows","nextSort","DEFAULT_PAGE_SIZE_OPTIONS","defaultCallApi","url","init","buildRequestUrl","entries","params","parseResponse","data","response","meta","DataTableRequestError","fetchPage","callApi","fetchAllPages","pageNo","totalPages","queryFor","useDebouncedValue","debounced","setDebounced","delay","SKELETON_WIDTHS","alignOf","alertIcon","archiveIcon","DataTable","loadingProp","searchProp","filtersProp","sortProp","paginationProp","pageProp","pageSizeProp","remote","fetchUrl","pagination","searchState","setSearchState","defaultSearch","filtersState","setFiltersState","defaultFilters","sortState","setSortState","defaultSort","pageState","setPageState","defaultPage","pageSizeState","setPageSizeState","defaultPageSize","filterFields","goToFirstPage","changeSearch","changeFilters","onFiltersChange","changeSort","onSortChange","changePage","changePageSize","wait","debounceMs","debouncedSearch","debouncedFilters","requestKey","apiBaseUrl","additionalFilter","refreshTrigger","setResult","cancelled","loaded","registerApi","sourceRows","serverSide","manualFiltering","processed","manualSorting","serverPaging","manualPagination","currentPage","rowId","getRowId","visibleIds","selectedIds","selection","selectedVisible","allSelected","someSelected","toggleAll","toggleRow","s","hasActions","hasToolbar","searchable","isFiltered","columnCount","stop","emptyText","handleRowKeyDown","onRowClick","renderActions","isDanger","table","tableClassName","caption","actionsClassName","loadingRows","cellIndex","rowIndex","emptyState","bulkActions","belowToolbar","formatFileSize","bytes","mb","matchesAccept","tokens","accept","token","file","sameFile","fileKey","isImage","ImageCropper_module_default","FRAME","MAX_ZOOM","KEY_STEP","extensionFor","ImageCropper","dialogRef","setLoaded","failed","setFailed","zoom","setZoom","setOffset","saving","setSaving","drag","frameW","aspect","frameH","image","baseScale","scale","clamp","maxX","nextScale","maxY","x","changeZoom","dx","dy","handlePointerDown","handlePointerMove","endDrag","apply","outW","outputWidth","outH","canvas","sx","sy","blob","outputType","outputQuality","dialog","onCancel","shape","delta","FileInput_module_default","canPreview","createPreviewUrl","UploadIcon","ImageIcon","FileIcon","CloseIcon","FileInputControl","multipleProp","acceptProp","hintId","rejectedId","isImageVariant","inputRef","files","setFiles","rejected","setRejected","dragging","setDragging","cropping","setCropping","previews","setPreviews","previewsRef","syncInput","transfer","nextPreviews","existing","onFilesChange","addFiles","incoming","problems","accepted","maxSize","picked","crop","maxFiles","handleChange","handleDrop","removeFile","hint","t","openDialog","dropHandlers","frameAspect","aspectRatio","tileHeight","tileSize","croppedWidth","cropOutputWidth","state","names","thumb","fileList","preview","hintText","body","buttonLabel","cropOutputType","cropOutputQuality","cropTitle","cropped","FileInput","Textarea_module_default","TextareaControl","resize","Textarea","Switch_module_default","Switch","Badge_module_default","Badge","color","dot","Tabs_module_default","Tabs","tabRefs","activeIndex","activeItem","select","onValueChange","rtl","tabId","FormSection_module_default","FormSection","headingId","hasHeader","createElement","headingLevel","Avatar_module_default","TONES","getInitials","words","toneFor","hash","Avatar","failedSrc","setFailedSrc","showImage","src","initials","AccountPanel_module_default","GAP","EDGE","PANEL_WIDTH","FOCUSABLE","defaultRenderLink","tileTone","ExternalIcon","AccountPanel","sidebar","rootRef","openPanel","firstName","user","quickActions","dangerActions","runAction","greeting","content","renderLink","detail","apps","appsTitle","tile","app","collapsed","Typography_module_default","defaultElement","variantClass","Typography","as","weight","truncate","ThemeToggle_module_default","icons","labels","ThemeToggle","modes","mode","compact"],"sources":["../src/utils/cn.ts","../src/license/hash.ts","../src/license/keys.ts","../src/license/license.ts","../src/license/UnlicensedNotice.module.css","../src/license/UnlicensedNotice.tsx","../src/components/Button/Button.module.css","../src/components/Button/Button.tsx","../src/components/FormField/FormFieldContext.ts","../src/components/FormField/FormField.module.css","../src/components/FormField/FormField.tsx","../src/components/DatePicker/dateUtils.ts","../src/components/DatePicker/Calendar.module.css","../src/components/DatePicker/Calendar.tsx","../src/components/DatePicker/PickerField.module.css","../src/components/DatePicker/PickerField.tsx","../src/components/DatePicker/DatePicker.tsx","../src/components/DatePicker/TimeColumns.module.css","../src/components/DatePicker/TimeColumns.tsx","../src/components/DateTimePicker/DateTimePicker.module.css","../src/components/DateTimePicker/DateTimePicker.tsx","../src/components/DatePicker/MonthCalendar.tsx","../src/components/MonthPicker/MonthPicker.tsx","../src/components/Input/PickerTypeInput.tsx","../src/components/Input/Input.module.css","../src/components/Input/Input.tsx","../src/components/PasswordInput/PasswordInput.module.css","../src/components/PasswordInput/PasswordInput.tsx","../src/components/SearchInput/SearchInput.module.css","../src/components/SearchInput/SearchInput.tsx","../src/theme/themeStore.ts","../src/theme/ThemeProvider.module.css","../src/theme/ThemeProvider.tsx","../src/components/Overlay/Overlay.module.css","../src/components/Overlay/Overlay.tsx","../src/components/Overlay/OverlayContent.module.css","../src/components/Overlay/OverlayContent.tsx","../src/components/Modal/Modal.module.css","../src/components/Modal/Modal.tsx","../src/components/Drawer/Drawer.module.css","../src/components/Drawer/Drawer.tsx","../src/components/ConfirmDialog/ConfirmDialog.module.css","../src/components/ConfirmDialog/ConfirmDialog.tsx","../src/components/Select/Select.module.css","../src/components/Select/SelectControl.tsx","../src/components/Select/Select.tsx","../src/components/Pagination/paginationUtils.ts","../src/components/Pagination/Pagination.module.css","../src/components/Pagination/Pagination.tsx","../src/components/Table/Table.module.css","../src/components/Table/Table.tsx","../src/components/PageHeader/PageHeader.module.css","../src/components/PageHeader/PageHeader.tsx","../src/components/StatusPill/StatusPill.module.css","../src/components/StatusPill/StatusPill.tsx","../src/components/Checkbox/Checkbox.module.css","../src/components/Checkbox/Checkbox.tsx","../src/components/DropdownMenu/DropdownMenu.module.css","../src/components/DropdownMenu/DropdownMenu.tsx","../src/components/Skeleton/Skeleton.module.css","../src/components/Skeleton/Skeleton.tsx","../src/components/DataTable/DataTable.module.css","../src/components/DataTable/SelectionBar.tsx","../src/components/TableFilters/FilterValueControl.tsx","../src/components/TableFilters/TableFilters.module.css","../src/components/TableFilters/DynamicFilterRows.tsx","../src/components/TableFilters/filterUtils.ts","../src/components/TableFilters/TableFilters.tsx","../src/components/DataTable/dataTableUtils.ts","../src/components/DataTable/remote.ts","../src/components/DataTable/useDebouncedValue.ts","../src/components/DataTable/DataTable.tsx","../src/components/FileInput/fileUtils.ts","../src/components/FileInput/ImageCropper.module.css","../src/components/FileInput/ImageCropper.tsx","../src/components/FileInput/FileInput.module.css","../src/components/FileInput/FileInput.tsx","../src/components/Textarea/Textarea.module.css","../src/components/Textarea/Textarea.tsx","../src/components/Switch/Switch.module.css","../src/components/Switch/Switch.tsx","../src/components/Badge/Badge.module.css","../src/components/Badge/Badge.tsx","../src/components/Tabs/Tabs.module.css","../src/components/Tabs/Tabs.tsx","../src/components/FormSection/FormSection.module.css","../src/components/FormSection/FormSection.tsx","../src/components/Avatar/Avatar.module.css","../src/components/Avatar/Avatar.tsx","../src/components/AccountPanel/AccountPanel.module.css","../src/components/AccountPanel/AccountPanel.tsx","../src/components/Typography/Typography.module.css","../src/components/Typography/Typography.tsx","../src/components/ThemeToggle/ThemeToggle.module.css","../src/components/ThemeToggle/ThemeToggle.tsx"],"sourcesContent":["export type ClassValue = string | false | null | undefined;\n\n/** Join truthy class names into a single string. */\nexport function cn(...values: ClassValue[]): string {\n return values.filter(Boolean).join(' ');\n}\n","/**\n * Non-cryptographic 53-bit hash (cyrb53). Keys are stored as hashes so the\n * plain keys are not sitting in the bundle. This is a deterrent, not security:\n * anything shipped to the browser can be extracted. `scripts/license.mjs`\n * must use the same algorithm (a test keeps them in sync).\n */\nconst SALT = 'client-ui:';\n\nexport function hashKey(key: string): string {\n const text = SALT + key.trim();\n let h1 = 0xdeadbeef;\n let h2 = 0x41c6ce57;\n for (let i = 0; i < text.length; i++) {\n const ch = text.charCodeAt(i);\n h1 = Math.imul(h1 ^ ch, 2654435761);\n h2 = Math.imul(h2 ^ ch, 1597334677);\n }\n h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);\n h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909);\n h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);\n h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909);\n const value = 4294967296 * (2097151 & h2) + (h1 >>> 0);\n return value.toString(16).padStart(14, '0');\n}\n","/**\n * Hashes of the license keys this release accepts. Generate entries with\n * `node scripts/license.mjs generate <label>`; remove an entry to revoke a key\n * in the next release.\n */\nexport const VALID_KEY_HASHES: readonly string[] = [\n '1cd9d9bd20471f', // dev (Storybook / playground)\n];\n","import { createContext, useContext, useEffect, useSyncExternalStore } from 'react';\nimport { hashKey } from './hash';\nimport { VALID_KEY_HASHES } from './keys';\n\nlet globalKey = '';\nconst listeners = new Set<() => void>();\nlet warned = false;\n\n/** Context carrying the key given to `<ThemeProvider licenseKey>`. Takes priority over `setLicenseKey`. */\nexport const LicenseContext = createContext<string | null>(null);\n\n/** Set the license key once at app start. A `licenseKey` on `ThemeProvider` takes priority. */\nexport function setLicenseKey(key: string): void {\n globalKey = key;\n warned = false;\n listeners.forEach((listener) => listener());\n}\n\nexport function isValidLicenseKey(key: string | null | undefined): boolean {\n if (!key || !key.trim()) return false;\n return VALID_KEY_HASHES.includes(hashKey(key));\n}\n\nconst subscribe = (listener: () => void) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n};\nconst getSnapshot = () => globalKey;\n\n/** True when a valid license key is configured. Every component calls this. */\nexport function useLicensed(): boolean {\n const providedKey = useContext(LicenseContext);\n const key = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n const licensed = isValidLicenseKey(providedKey ?? key);\n\n useEffect(() => {\n if (licensed || warned) return;\n warned = true;\n console.error(\n '[client-ui] Missing or invalid license key. Components are disabled. ' +\n 'Pass licenseKey to <ThemeProvider> or call setLicenseKey() once at app start.',\n );\n }, [licensed]);\n\n return licensed;\n}\n",".root {\n display: inline-block;\n padding: var(--cui-space-1) var(--cui-space-2);\n border: 1px dashed var(--cui-color-danger);\n border-radius: var(--cui-radius-md);\n color: var(--cui-color-danger);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-xs);\n line-height: var(--cui-line-height);\n}\n","import styles from './UnlicensedNotice.module.css';\n\n/** Rendered in place of a component when no valid license key is configured. */\nexport function UnlicensedNotice() {\n return (\n <span role=\"alert\" className={styles.root}>\n client-ui: missing or invalid license key\n </span>\n );\n}\n",".button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: var(--cui-space-2);\n box-sizing: border-box;\n border: 1px solid transparent;\n border-radius: var(--cui-radius-md);\n font-family: var(--cui-font-family);\n font-weight: var(--cui-font-weight-medium);\n line-height: var(--cui-line-height);\n white-space: nowrap;\n cursor: pointer;\n user-select: none;\n transition:\n background-color var(--cui-transition-fast),\n border-color var(--cui-transition-fast),\n color var(--cui-transition-fast);\n}\n\n.button:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: var(--cui-focus-ring-offset);\n}\n\n.button:disabled {\n cursor: not-allowed;\n}\n\n.button[aria-busy='true'] {\n cursor: progress;\n}\n\n/* Sizes */\n.sm {\n height: var(--cui-control-height-sm);\n padding: 0 var(--cui-space-3);\n font-size: var(--cui-font-size-sm);\n}\n\n.md {\n height: var(--cui-control-height-md);\n padding: 0 var(--cui-space-4);\n font-size: var(--cui-font-size-md);\n}\n\n.lg {\n height: var(--cui-control-height-lg);\n padding: 0 var(--cui-space-6);\n font-size: var(--cui-font-size-lg);\n}\n\n.fullWidth {\n display: flex;\n width: 100%;\n}\n\n/* Variants */\n.primary {\n background-color: var(--cui-color-primary);\n color: var(--cui-color-on-primary);\n}\n.primary:hover:not(:disabled) {\n background-color: var(--cui-color-primary-hover);\n}\n.primary:active:not(:disabled) {\n background-color: var(--cui-color-primary-active);\n}\n\n.secondary {\n background-color: var(--cui-color-secondary);\n color: var(--cui-color-on-secondary);\n}\n.secondary:hover:not(:disabled) {\n background-color: var(--cui-color-secondary-hover);\n}\n\n.outline {\n background-color: transparent;\n border-color: var(--cui-color-border);\n color: var(--cui-color-text);\n}\n.outline:hover:not(:disabled) {\n background-color: var(--cui-color-surface-secondary);\n}\n\n.ghost {\n background-color: transparent;\n color: var(--cui-color-primary);\n}\n.ghost:hover:not(:disabled) {\n background-color: var(--cui-color-primary-subtle);\n}\n\n.danger {\n background-color: var(--cui-color-danger);\n color: var(--cui-color-on-danger);\n}\n.danger:hover:not(:disabled) {\n background-color: var(--cui-color-danger-hover);\n}\n.danger:active:not(:disabled) {\n background-color: var(--cui-color-danger-active);\n}\n\n.link {\n height: auto;\n padding: 0;\n background-color: transparent;\n color: var(--cui-color-primary);\n text-decoration: underline;\n text-underline-offset: 0.2em;\n}\n.link:hover:not(:disabled) {\n color: var(--cui-color-primary-hover);\n}\n\n/* Disabled (and loading, which is disabled) */\n.button:disabled:not([aria-busy='true']) {\n color: var(--cui-color-text-disabled);\n}\n.primary:disabled:not([aria-busy='true']),\n.secondary:disabled:not([aria-busy='true']),\n.danger:disabled:not([aria-busy='true']) {\n background-color: var(--cui-color-surface-secondary);\n}\n.outline:disabled {\n border-color: var(--cui-color-border);\n}\n.button[aria-busy='true'] {\n opacity: 0.85;\n}\n\n/* Spinner */\n.spinner {\n width: 1em;\n height: 1em;\n box-sizing: border-box;\n border: 2px solid currentColor;\n border-inline-end-color: transparent;\n border-radius: var(--cui-radius-full);\n animation: spin 0.7s linear infinite;\n}\n\n@keyframes spin {\n to {\n transform: rotate(360deg);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .spinner {\n animation-duration: 2s;\n }\n}\n","import { forwardRef } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport type { ButtonProps } from './Button.types';\nimport styles from './Button.module.css';\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n {\n variant = 'primary',\n size = 'md',\n loading = false,\n fullWidth = false,\n type = 'button',\n disabled,\n className,\n children,\n ...rest\n },\n ref,\n) {\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n return (\n <button\n {...rest}\n ref={ref}\n type={type}\n disabled={disabled || loading}\n aria-busy={loading || undefined}\n data-variant={variant}\n data-size={size}\n className={cn(\n styles.button,\n styles[variant],\n styles[size],\n fullWidth && styles.fullWidth,\n className,\n )}\n >\n {loading ? <span className={styles.spinner} aria-hidden=\"true\" /> : null}\n {children}\n </button>\n );\n});\n","import { createContext, useContext, useId } from 'react';\nimport type {\n FormFieldContextValue,\n FormFieldControlProps,\n UseFormFieldControlOptions,\n} from './FormField.types';\n\nexport const FormFieldContext = createContext<FormFieldContextValue | null>(null);\n\n/**\n * Connects a form control to the surrounding FormField (if any) and returns\n * the id / required / disabled / aria props it should apply to its native element.\n * Form controls (Input, Select, future Textarea...) should all use this hook.\n */\nexport function useFormFieldControl(options: UseFormFieldControlOptions): FormFieldControlProps {\n const context = useContext(FormFieldContext);\n const generatedId = useId();\n\n const id = context?.id ?? options.id ?? generatedId;\n const required = Boolean(options.required ?? context?.required);\n const disabled = Boolean(options.disabled ?? context?.disabled);\n const invalid = Boolean(options.error) || Boolean(context?.invalid);\n const describedBy =\n [options['aria-describedby'], context?.describedById].filter(Boolean).join(' ') || undefined;\n\n return {\n id,\n required,\n disabled,\n invalid,\n labelId: context?.labelId,\n 'aria-invalid': invalid ? true : undefined,\n 'aria-describedby': describedBy,\n };\n}\n",".root {\n display: flex;\n flex-direction: column;\n gap: var(--cui-space-1);\n min-width: 0;\n}\n\n.label {\n font-size: var(--cui-font-size-sm);\n font-weight: var(--cui-font-weight-semibold);\n color: var(--cui-color-text-secondary);\n margin-bottom: var(--cui-space-1);\n}\n\n.labelDisabled {\n color: var(--cui-color-text-disabled);\n}\n\n.required {\n margin-inline-start: var(--cui-space-1);\n color: var(--cui-color-danger);\n}\n\n.message {\n margin: 0;\n font-size: var(--cui-font-size-sm);\n}\n\n.helper {\n color: var(--cui-color-text-muted);\n}\n\n.error {\n color: var(--cui-color-danger);\n}\n","import { useId, useMemo } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { FormFieldContext } from './FormFieldContext';\nimport type { FormFieldContextValue, FormFieldProps } from './FormField.types';\nimport styles from './FormField.module.css';\n\nexport function FormField({\n children,\n label,\n required = false,\n helperText,\n error,\n disabled = false,\n id: idProp,\n className,\n ...rest\n}: FormFieldProps) {\n const generatedId = useId();\n const id = idProp ?? generatedId;\n const hasError = Boolean(error);\n const messageId = hasError ? `${id}-error` : helperText ? `${id}-helper` : undefined;\n\n const context = useMemo<FormFieldContextValue>(\n () => ({\n id,\n describedById: messageId,\n labelId: label ? `${id}-label` : undefined,\n required,\n disabled,\n invalid: hasError,\n }),\n [id, messageId, label, required, disabled, hasError],\n );\n\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n return (\n <FormFieldContext.Provider value={context}>\n <div {...rest} className={cn(styles.root, className)}>\n {label ? (\n <label\n id={`${id}-label`}\n htmlFor={id}\n className={cn(styles.label, disabled && styles.labelDisabled)}\n >\n {label}\n {required ? (\n <span className={styles.required} aria-hidden=\"true\">\n *\n </span>\n ) : null}\n </label>\n ) : null}\n {children}\n {hasError ? (\n <p id={messageId} className={cn(styles.message, styles.error)} role=\"alert\">\n {error}\n </p>\n ) : helperText ? (\n <p id={messageId} className={cn(styles.message, styles.helper)}>\n {helperText}\n </p>\n ) : null}\n </div>\n </FormFieldContext.Provider>\n );\n}\n","/**\n * Date helpers for the picker. Dates are handled as local calendar days and kept at\n * noon so daylight-saving shifts never move them to a neighbouring day.\n */\n\nconst pad = (n: number, length = 2) => String(n).padStart(length, '0');\n\n/** `2026-10-08` for a date, using its local year, month and day. */\nexport const toISO = (date: Date): string =>\n `${pad(date.getFullYear(), 4)}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;\n\n/** Parses `YYYY-MM-DD`. Returns null for anything else, including impossible dates like `2026-02-31`. */\nexport function parseISO(value: string | null | undefined): Date | null {\n if (!value || !/^\\d{4}-\\d{2}-\\d{2}$/.test(value)) return null;\n const date = new Date(`${value}T12:00:00`);\n return Number.isFinite(date.getTime()) && toISO(date) === value ? date : null;\n}\n\nexport const today = (): Date => {\n const now = new Date();\n return new Date(now.getFullYear(), now.getMonth(), now.getDate(), 12);\n};\n\nexport const addDays = (date: Date, days: number): Date =>\n new Date(date.getFullYear(), date.getMonth(), date.getDate() + days, 12);\n\n/** Moves by whole months, keeping the day of month when it exists (Jan 31 + 1 month = Feb 28/29). */\nexport function addMonths(date: Date, months: number): Date {\n const first = new Date(date.getFullYear(), date.getMonth() + months, 1, 12);\n const last = new Date(first.getFullYear(), first.getMonth() + 1, 0, 12).getDate();\n return new Date(first.getFullYear(), first.getMonth(), Math.min(date.getDate(), last), 12);\n}\n\nexport const isSameDay = (a: Date | null, b: Date | null): boolean =>\n Boolean(a && b && toISO(a) === toISO(b));\n\nexport function clampDate(date: Date, min: Date | null, max: Date | null): Date {\n if (min && date < min) return min;\n if (max && date > max) return max;\n return date;\n}\n\n/** The 42 days (6 weeks) shown for the month containing `month`, starting on `weekStartsOn` (0 = Sunday). */\nexport function buildMonthGrid(month: Date, weekStartsOn: 0 | 1): Date[] {\n const first = new Date(month.getFullYear(), month.getMonth(), 1, 12);\n const offset = (first.getDay() - weekStartsOn + 7) % 7;\n return Array.from({ length: 42 }, (_, i) => addDays(first, i - offset));\n}\n\nexport interface DateRange {\n /** First disabled day, `YYYY-MM-DD`. */\n from: string;\n /** Last disabled day, `YYYY-MM-DD`. */\n to: string;\n}\n\nexport interface DisabledDateOptions {\n /** Earliest selectable day, `YYYY-MM-DD`. Earlier days are disabled. */\n min?: string;\n /** Latest selectable day, `YYYY-MM-DD`. Later days are disabled. */\n max?: string;\n /** Disable every day before today. Today stays selectable. */\n disablePast?: boolean;\n /** Disable every day after today. Today stays selectable. */\n disableFuture?: boolean;\n /** Individual days to disable, as `YYYY-MM-DD` strings or Date objects (holidays, booked days). */\n disabledDates?: (string | Date)[];\n /** Ranges to disable, both ends included (e.g. a term break). */\n disabledRanges?: DateRange[];\n /** Weekdays to disable: 0 = Sunday ... 6 = Saturday (e.g. `[0, 6]` for weekends). */\n disabledDaysOfWeek?: number[];\n /** Your own rule. Return true to disable the day. Runs in addition to the options above. */\n isDateDisabled?: (date: Date) => boolean;\n}\n\n/** Combines every disabling option into one `(date) => boolean`. Invalid dates in the options are ignored. */\nexport function createDisabledPredicate(\n options: DisabledDateOptions,\n now: Date = today(),\n): (date: Date) => boolean {\n const min = parseISO(options.min);\n const max = parseISO(options.max);\n const todayISO = toISO(now);\n const dates = new Set(\n (options.disabledDates ?? [])\n .map((d) => (d instanceof Date ? toISO(d) : parseISO(d) ? d : null))\n .filter((d): d is string => d !== null),\n );\n const ranges = (options.disabledRanges ?? [])\n .map((r) => ({ from: parseISO(r.from), to: parseISO(r.to) }))\n .filter((r): r is { from: Date; to: Date } => r.from !== null && r.to !== null)\n .map((r) => ({ from: toISO(r.from), to: toISO(r.to) }));\n const weekdays = new Set(options.disabledDaysOfWeek ?? []);\n\n return (date) => {\n const iso = toISO(date);\n if (min && iso < toISO(min)) return true;\n if (max && iso > toISO(max)) return true;\n if (options.disablePast && iso < todayISO) return true;\n if (options.disableFuture && iso > todayISO) return true;\n if (dates.has(iso)) return true;\n if (weekdays.has(date.getDay())) return true;\n if (ranges.some((r) => iso >= r.from && iso <= r.to)) return true;\n return options.isDateDisabled?.(date) ?? false;\n };\n}\n\n/** `date` itself if it is enabled, otherwise the closest enabled day (searching up to a year either way). */\nexport function nearestEnabled(date: Date, isDisabled: (date: Date) => boolean): Date {\n if (!isDisabled(date)) return date;\n for (let offset = 1; offset <= 366; offset++) {\n const after = addDays(date, offset);\n if (!isDisabled(after)) return after;\n const before = addDays(date, -offset);\n if (!isDisabled(before)) return before;\n }\n return date;\n}\n\n/* ---------- Months (`YYYY-MM`) ---------- */\n\n/** `2026-10` for a date. */\nexport const toMonthISO = (date: Date): string =>\n `${pad(date.getFullYear(), 4)}-${pad(date.getMonth() + 1)}`;\n\n/** Parses `YYYY-MM` to the first day of that month. Returns null for anything else. */\nexport function parseMonth(value: string | null | undefined): Date | null {\n if (!value || !/^\\d{4}-\\d{2}$/.test(value)) return null;\n return parseISO(`${value}-01`);\n}\n\nexport interface DisabledMonthOptions {\n /** Earliest selectable month, `YYYY-MM`. */\n min?: string;\n /** Latest selectable month, `YYYY-MM`. */\n max?: string;\n /** Disable months before the current month. The current month stays selectable. */\n disablePast?: boolean;\n /** Disable months after the current month. The current month stays selectable. */\n disableFuture?: boolean;\n /** Individual months to disable, `YYYY-MM`. */\n disabledMonths?: string[];\n /** Your own rule, called with the first day of the month. Return true to disable it. */\n isMonthDisabled?: (month: Date) => boolean;\n}\n\n/** Combines every month-disabling option into one `(firstDayOfMonth) => boolean`. */\nexport function createMonthDisabledPredicate(\n options: DisabledMonthOptions,\n now: Date = today(),\n): (month: Date) => boolean {\n const min = options.min && parseMonth(options.min) ? options.min : null;\n const max = options.max && parseMonth(options.max) ? options.max : null;\n const current = toMonthISO(now);\n const listed = new Set((options.disabledMonths ?? []).filter((m) => parseMonth(m)));\n\n return (month) => {\n const iso = toMonthISO(month);\n if (min && iso < min) return true;\n if (max && iso > max) return true;\n if (options.disablePast && iso < current) return true;\n if (options.disableFuture && iso > current) return true;\n if (listed.has(iso)) return true;\n return options.isMonthDisabled?.(month) ?? false;\n };\n}\n\n/* ---------- Date and time (`YYYY-MM-DDTHH:mm`) ---------- */\n\n/** `2026-10-08T14:30` for a date, in local time. */\nexport const toDateTimeISO = (date: Date): string =>\n `${toISO(date)}T${pad(date.getHours())}:${pad(date.getMinutes())}`;\n\n/** Parses `YYYY-MM-DDTHH:mm` (seconds are ignored) to a local Date. Returns null for anything else. */\nexport function parseDateTime(value: string | null | undefined): Date | null {\n const match = /^(\\d{4}-\\d{2}-\\d{2})T(\\d{2}):(\\d{2})(?::\\d{2}(?:\\.\\d+)?)?$/.exec(value ?? '');\n if (!match) return null;\n const day = parseISO(match[1]);\n const hours = Number(match[2]);\n const minutes = Number(match[3]);\n if (!day || hours > 23 || minutes > 59) return null;\n return new Date(day.getFullYear(), day.getMonth(), day.getDate(), hours, minutes);\n}\n\n/** A date with its time replaced. */\nexport const withTime = (date: Date, hours: number, minutes: number): Date =>\n new Date(date.getFullYear(), date.getMonth(), date.getDate(), hours, minutes);\n",".root {\n padding: var(--cui-space-3);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-sm);\n color: var(--cui-color-text);\n}\n\n.header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--cui-space-1);\n margin-bottom: var(--cui-space-3);\n}\n\n.title {\n display: flex;\n align-items: center;\n gap: var(--cui-space-1);\n font-weight: var(--cui-font-weight-semibold);\n}\n\n.nav,\n.titleButton {\n background: transparent;\n border: 0;\n color: inherit;\n font: inherit;\n cursor: pointer;\n}\n\n.nav {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 2rem;\n height: 2rem;\n padding: 0;\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text-muted);\n}\n.nav svg {\n width: 1rem;\n height: 1rem;\n}\n.nav:hover {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-primary);\n}\n\n.titleButton {\n padding: var(--cui-space-1) var(--cui-space-2);\n border-radius: var(--cui-radius-lg);\n}\n.titleButton:hover {\n background-color: var(--cui-color-surface-secondary);\n}\n\n.nav:focus-visible,\n.titleButton:focus-visible,\n.day:focus-visible,\n.cell:focus-visible,\n.footerButton:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: -1px;\n}\n\n.weekdays,\n.grid {\n display: grid;\n grid-template-columns: repeat(7, 2.25rem);\n}\n\n.weekdays {\n margin-bottom: var(--cui-space-1);\n text-align: center;\n font-size: var(--cui-font-size-xs);\n font-weight: var(--cui-font-weight-medium);\n color: var(--cui-color-text-muted);\n}\n.weekdays span {\n padding: var(--cui-space-1) 0;\n}\n\n.grid {\n gap: 2px;\n}\n\n.day {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 2.25rem;\n padding: 0;\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text);\n font: inherit;\n font-size: var(--cui-font-size-xs);\n font-weight: var(--cui-font-weight-medium);\n cursor: pointer;\n}\n\n.day:hover:not([aria-disabled='true']):not(.selected) {\n background-color: var(--cui-color-primary-subtle);\n color: var(--cui-color-primary);\n}\n\n.outside {\n color: var(--cui-color-text-disabled);\n}\n\n.today:not(.selected) {\n box-shadow: inset 0 0 0 1px var(--cui-color-primary);\n color: var(--cui-color-primary);\n}\n\n.selected {\n background-color: var(--cui-color-primary);\n color: var(--cui-color-on-primary);\n}\n\n.day[aria-disabled='true'] {\n opacity: 0.35;\n text-decoration: line-through;\n cursor: not-allowed;\n}\n\n.cells {\n display: grid;\n grid-template-columns: repeat(3, 1fr);\n gap: var(--cui-space-2);\n width: calc(7 * 2.25rem + 6 * 2px);\n}\n\n.cell {\n padding: var(--cui-space-3) var(--cui-space-2);\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text-secondary);\n font: inherit;\n cursor: pointer;\n}\n.cell:hover {\n background-color: var(--cui-color-primary-subtle);\n color: var(--cui-color-primary);\n}\n.active {\n background-color: var(--cui-color-primary-subtle);\n color: var(--cui-color-primary);\n font-weight: var(--cui-font-weight-semibold);\n}\n\n.footer {\n display: flex;\n align-items: center;\n justify-content: space-between;\n margin-top: var(--cui-space-3);\n padding-top: var(--cui-space-2);\n border-top: 1px solid var(--cui-color-border);\n font-size: var(--cui-font-size-xs);\n font-weight: var(--cui-font-weight-semibold);\n}\n\n.footerButton {\n padding: 6px var(--cui-space-2);\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-md);\n color: var(--cui-color-text-muted);\n font: inherit;\n cursor: pointer;\n}\n.footerButton:hover:not(:disabled) {\n background-color: var(--cui-color-surface-secondary);\n}\n.footerPrimary {\n color: var(--cui-color-primary);\n}\n.footerButton:disabled {\n opacity: 0.35;\n cursor: not-allowed;\n}\n\n.cell[aria-disabled='true'] {\n opacity: 0.35;\n text-decoration: line-through;\n cursor: not-allowed;\n}\n.cell[aria-disabled='true']:hover {\n background: transparent;\n color: var(--cui-color-text-secondary);\n}\n\n.currentCell {\n box-shadow: inset 0 0 0 1px var(--cui-color-primary);\n color: var(--cui-color-primary);\n}\n","import { useEffect, useMemo, useRef, useState, type KeyboardEvent } from 'react';\nimport { cn } from '../../utils/cn';\nimport {\n addDays,\n addMonths,\n buildMonthGrid,\n nearestEnabled,\n isSameDay,\n today as getToday,\n toISO,\n} from './dateUtils';\nimport styles from './Calendar.module.css';\n\nexport interface CalendarProps {\n selected: Date | null;\n /** True for days that cannot be chosen. Disabled days stay focusable so keyboard navigation can pass over them. */\n isDisabled: (date: Date) => boolean;\n weekStartsOn: 0 | 1;\n locale?: string;\n /** Called with the chosen date, or null when \"Clear\" is pressed. */\n onSelect: (date: Date | null) => void;\n /** Hide the Clear button (when the picker is not clearable). */\n allowClear: boolean;\n /** Show the Clear / Today footer. Defaults to true. */\n showFooter?: boolean;\n}\n\ntype View = 'days' | 'months' | 'years';\n\nconst chevron = (direction: 'left' | 'right') => (\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d={direction === 'left' ? 'M12 5l-5 5 5 5' : 'M8 5l5 5-5 5'} />\n </svg>\n);\n\n/** The calendar shown inside the DatePicker popover: days, months and years views with full keyboard support. */\nexport function Calendar({\n selected,\n isDisabled,\n weekStartsOn,\n locale,\n onSelect,\n allowClear,\n showFooter = true,\n}: CalendarProps) {\n const todayDate = getToday();\n const [cursor, setCursor] = useState<Date>(() =>\n nearestEnabled(selected ?? todayDate, isDisabled),\n );\n const [view, setView] = useState<View>('days');\n const gridRef = useRef<HTMLDivElement>(null);\n const focusCursor = useRef(true);\n\n const monthName = useMemo(\n () => new Intl.DateTimeFormat(locale, { month: 'long' }).format(cursor),\n [cursor, locale],\n );\n const monthShort = useMemo(\n () =>\n Array.from({ length: 12 }, (_, m) =>\n new Intl.DateTimeFormat(locale, { month: 'short' }).format(new Date(2024, m, 1)),\n ),\n [locale],\n );\n const weekdays = useMemo(() => {\n const base = new Date(2024, 0, 7 + weekStartsOn); // 7 Jan 2024 is a Sunday\n return Array.from({ length: 7 }, (_, i) => {\n const day = addDays(base, i);\n return {\n short: new Intl.DateTimeFormat(locale, { weekday: 'short' }).format(day),\n long: new Intl.DateTimeFormat(locale, { weekday: 'long' }).format(day),\n };\n });\n }, [locale, weekStartsOn]);\n const dayLabel = useMemo(() => new Intl.DateTimeFormat(locale, { dateStyle: 'full' }), [locale]);\n\n const days = useMemo(() => buildMonthGrid(cursor, weekStartsOn), [cursor, weekStartsOn]);\n const year = cursor.getFullYear();\n const yearStart = Math.floor((year - 1) / 12) * 12 + 1;\n\n // Move focus to the active day after keyboard navigation (not on mouse paging).\n const cursorISO = toISO(cursor);\n useEffect(() => {\n if (view !== 'days' || !focusCursor.current) return;\n gridRef.current\n ?.querySelector<HTMLElement>(`[data-date=\"${cursorISO}\"]`)\n ?.focus({ preventScroll: true });\n }, [cursorISO, view]);\n\n const moveCursor = (next: Date) => {\n focusCursor.current = true;\n setCursor(next);\n };\n\n const handleGridKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const step: Record<string, () => Date> = {\n ArrowLeft: () => addDays(cursor, -1),\n ArrowRight: () => addDays(cursor, 1),\n ArrowUp: () => addDays(cursor, -7),\n ArrowDown: () => addDays(cursor, 7),\n PageUp: () => addMonths(cursor, event.shiftKey ? -12 : -1),\n PageDown: () => addMonths(cursor, event.shiftKey ? 12 : 1),\n Home: () => addDays(cursor, -((cursor.getDay() - weekStartsOn + 7) % 7)),\n End: () => addDays(cursor, 6 - ((cursor.getDay() - weekStartsOn + 7) % 7)),\n };\n const move = step[event.key];\n if (!move) return;\n event.preventDefault();\n moveCursor(move());\n };\n\n const page = (direction: 1 | -1) => {\n focusCursor.current = false;\n setCursor((current) =>\n addMonths(current, direction * (view === 'years' ? 144 : view === 'months' ? 12 : 1)),\n );\n };\n\n const prevLabel =\n view === 'years' ? 'Previous 12 years' : view === 'months' ? 'Previous year' : 'Previous month';\n const nextLabel =\n view === 'years' ? 'Next 12 years' : view === 'months' ? 'Next year' : 'Next month';\n\n return (\n <div className={styles.root}>\n <div className={styles.header}>\n <button\n type=\"button\"\n className={styles.nav}\n aria-label={prevLabel}\n onClick={() => page(-1)}\n >\n {chevron('left')}\n </button>\n <div className={styles.title} aria-live=\"polite\">\n {view === 'years' ? (\n <span>\n {yearStart} - {yearStart + 11}\n </span>\n ) : (\n <>\n {view === 'days' ? (\n <button\n type=\"button\"\n className={styles.titleButton}\n aria-label=\"Choose month\"\n onClick={() => setView('months')}\n >\n {monthName}\n </button>\n ) : null}\n <button\n type=\"button\"\n className={styles.titleButton}\n aria-label=\"Choose year\"\n onClick={() => setView('years')}\n >\n {year}\n </button>\n </>\n )}\n </div>\n <button type=\"button\" className={styles.nav} aria-label={nextLabel} onClick={() => page(1)}>\n {chevron('right')}\n </button>\n </div>\n\n {view === 'days' ? (\n <>\n <div className={styles.weekdays} aria-hidden=\"true\">\n {weekdays.map((day) => (\n <span key={day.long}>{day.short}</span>\n ))}\n </div>\n <div\n ref={gridRef}\n className={styles.grid}\n role=\"group\"\n aria-label={`${monthName} ${year}`}\n onKeyDown={handleGridKeyDown}\n >\n {days.map((day) => {\n const iso = toISO(day);\n const outside = day.getMonth() !== cursor.getMonth();\n const isSelected = isSameDay(day, selected);\n return (\n <button\n key={iso}\n type=\"button\"\n data-date={iso}\n tabIndex={isSameDay(day, cursor) ? 0 : -1}\n aria-disabled={isDisabled(day) || undefined}\n aria-label={dayLabel.format(day)}\n aria-pressed={isSelected}\n aria-current={isSameDay(day, todayDate) ? 'date' : undefined}\n className={cn(\n styles.day,\n outside && styles.outside,\n isSameDay(day, todayDate) && styles.today,\n isSelected && styles.selected,\n )}\n onClick={() => {\n if (!isDisabled(day)) onSelect(day);\n }}\n >\n {day.getDate()}\n </button>\n );\n })}\n </div>\n </>\n ) : view === 'months' ? (\n <div className={styles.cells}>\n {monthShort.map((name, month) => (\n <button\n key={name}\n type=\"button\"\n className={cn(styles.cell, month === cursor.getMonth() && styles.active)}\n onClick={() => {\n focusCursor.current = true;\n setCursor((current) => addMonths(current, month - current.getMonth()));\n setView('days');\n }}\n >\n {name}\n </button>\n ))}\n </div>\n ) : (\n <div className={styles.cells}>\n {Array.from({ length: 12 }, (_, i) => yearStart + i).map((y) => (\n <button\n key={y}\n type=\"button\"\n className={cn(styles.cell, y === year && styles.active)}\n onClick={() => {\n focusCursor.current = true;\n setCursor((current) => addMonths(current, (y - current.getFullYear()) * 12));\n setView('months');\n }}\n >\n {y}\n </button>\n ))}\n </div>\n )}\n\n {showFooter ? (\n <div className={styles.footer}>\n {allowClear ? (\n <button type=\"button\" className={styles.footerButton} onClick={() => onSelect(null)}>\n Clear\n </button>\n ) : (\n <span />\n )}\n <button\n type=\"button\"\n className={cn(styles.footerButton, styles.footerPrimary)}\n disabled={isDisabled(todayDate)}\n onClick={() => onSelect(todayDate)}\n >\n Today\n </button>\n </div>\n ) : null}\n </div>\n );\n}\n",".control {\n position: relative;\n display: flex;\n align-items: center;\n width: 100%;\n color: var(--cui-color-text);\n}\n\n.trigger {\n appearance: none;\n display: flex;\n align-items: center;\n box-sizing: border-box;\n width: 100%;\n padding: 0 var(--cui-space-10) 0 var(--cui-space-4);\n background-color: var(--cui-color-surface);\n border: var(--cui-control-border-width) solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n color: inherit;\n font-family: var(--cui-font-family);\n font-size: inherit;\n text-align: start;\n cursor: pointer;\n transition:\n border-color var(--cui-transition-fast),\n box-shadow var(--cui-transition-fast);\n}\n\n.trigger:hover:not(:disabled) {\n border-color: var(--cui-color-border-hover);\n}\n\n.trigger:focus-visible,\n.open .trigger {\n border-color: var(--cui-color-border-focus);\n outline: none;\n box-shadow: var(--cui-focus-ring);\n}\n\n.value {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.placeholder .value {\n color: var(--cui-color-placeholder);\n}\n\n.sm {\n font-size: var(--cui-font-size-sm);\n}\n.sm .trigger {\n height: var(--cui-control-height-sm);\n}\n.md {\n font-size: var(--cui-font-size-sm);\n}\n.md .trigger {\n height: var(--cui-control-height-md);\n}\n.lg {\n font-size: var(--cui-font-size-lg);\n}\n.lg .trigger {\n height: var(--cui-control-height-lg);\n}\n\n.icon {\n position: absolute;\n inset-inline-end: var(--cui-space-3);\n width: 1.25rem;\n height: 1.25rem;\n color: var(--cui-color-text-muted);\n pointer-events: none;\n}\n\n.clear {\n position: absolute;\n inset-inline-end: calc(var(--cui-space-3) + 1.5rem);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 1.25rem;\n height: 1.25rem;\n padding: 0;\n border: 0;\n border-radius: var(--cui-radius-full);\n background: transparent;\n color: var(--cui-color-text-muted);\n cursor: pointer;\n}\n.clear:hover {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text);\n}\n.clear:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n}\n.clear svg {\n width: 0.875rem;\n height: 0.875rem;\n}\n\n.invalid .trigger {\n border-color: var(--cui-color-danger-border);\n}\n.invalid .trigger:hover:not(:disabled) {\n border-color: var(--cui-color-danger-border-hover);\n}\n.invalid .trigger:focus-visible,\n.invalid.open .trigger {\n border-color: var(--cui-color-danger-border-hover);\n box-shadow: var(--cui-focus-ring-danger);\n}\n\n.disabled {\n color: var(--cui-color-text-disabled);\n}\n.disabled .trigger {\n background-color: var(--cui-color-surface-secondary);\n cursor: not-allowed;\n}\n.disabled .icon {\n color: var(--cui-color-text-disabled);\n}\n\n.panel {\n position: fixed;\n z-index: var(--cui-z-popover);\n box-sizing: border-box;\n background-color: var(--cui-color-surface);\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-xl);\n box-shadow: var(--cui-shadow-lg);\n animation: cui-datepicker-in 0.15s ease-out;\n}\n\n@keyframes cui-datepicker-in {\n from {\n opacity: 0;\n transform: translateY(-6px) scale(0.98);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .panel {\n animation: none;\n }\n}\n","import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n type ButtonHTMLAttributes,\n type CSSProperties,\n type KeyboardEvent,\n type ReactNode,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport type { ComponentSize } from '../../types';\nimport { FormField, useFormFieldControl } from '../FormField';\nimport styles from './PickerField.module.css';\n\nconst MENU_GAP = 4;\nconst MENU_ESTIMATED_HEIGHT = 420;\nconst FOCUSABLE = 'button:not([disabled]):not([tabindex=\"-1\"]), [tabindex=\"0\"]';\n\nexport interface PickerPanelContext {\n /** Close the popover. Focus returns to the field unless `restoreFocus` is false. */\n close: (restoreFocus?: boolean) => void;\n}\n\nexport interface PickerFieldProps extends Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n 'children' | 'placeholder' | 'value' | 'defaultValue' | 'onChange'\n> {\n required?: boolean;\n error?: ReactNode;\n size?: ComponentSize;\n /** Text for the chosen value, or null to show the placeholder. */\n displayText: string | null;\n placeholder: string;\n /** Submitted with a surrounding form under `name`. */\n name?: string;\n hiddenValue: string;\n /** Show the clear button (only while a value is chosen). */\n clearable: boolean;\n onClear: () => void;\n clearLabel: string;\n /** Accessible name of the popover. */\n panelLabel: string;\n /** Approximate width of the popover in px, used to keep it on screen. */\n panelWidth?: number;\n icon?: 'calendar' | 'clock';\n /** The popover content. */\n children: (context: PickerPanelContext) => ReactNode;\n}\n\n/**\n * Shared field for the date, month and date-time pickers: a trigger styled like the other form\n * controls, a clear button, and a popover rendered in <body> (so nothing can clip it) that keeps the\n * surrounding theme, closes on Escape or an outside click, and keeps Tab inside it.\n */\nconst PickerFieldControl = forwardRef<HTMLButtonElement, PickerFieldProps>(\n function PickerFieldControl(\n {\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n size = 'md',\n displayText,\n placeholder,\n name,\n hiddenValue,\n clearable,\n onClear,\n clearLabel,\n panelLabel,\n panelWidth = 300,\n icon = 'calendar',\n className,\n onClick,\n onKeyDown,\n children,\n ...rest\n },\n ref,\n ) {\n const control = useFormFieldControl({\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n });\n const panelId = `${useId()}-panel`;\n\n const containerRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n const panelRef = useRef<HTMLDivElement>(null);\n const setTriggerRef = useCallback(\n (node: HTMLButtonElement | null) => {\n triggerRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n },\n [ref],\n );\n\n const [open, setOpen] = useState(false);\n const [style, setStyle] = useState<CSSProperties | null>(null);\n const [themeName, setThemeName] = useState<string | undefined>();\n\n const computePosition = useCallback(() => {\n const container = containerRef.current;\n if (!container) return;\n const rect = container.getBoundingClientRect();\n const spaceBelow = window.innerHeight - rect.bottom;\n const above = spaceBelow < MENU_ESTIMATED_HEIGHT && rect.top > spaceBelow;\n const next: CSSProperties = {\n left: Math.max(8, Math.min(rect.left, window.innerWidth - panelWidth)),\n };\n if (above) next.bottom = window.innerHeight - rect.top + MENU_GAP;\n else next.top = rect.bottom + MENU_GAP;\n setStyle(next);\n }, [panelWidth]);\n\n const openPicker = () => {\n if (control.disabled) return;\n computePosition();\n // The popover lives in <body>; carry the surrounding theme over to it.\n setThemeName(\n containerRef.current?.closest('[data-theme]')?.getAttribute('data-theme') ?? undefined,\n );\n setOpen(true);\n };\n\n // `close` is handed to render code, so it must not touch refs; focus is restored by an effect.\n const [focusTick, setFocusTick] = useState(0);\n const close = (restoreFocus = true) => {\n setOpen(false);\n if (restoreFocus) setFocusTick((tick) => tick + 1);\n };\n useEffect(() => {\n if (focusTick > 0) triggerRef.current?.focus({ preventScroll: true });\n }, [focusTick]);\n\n useEffect(() => {\n if (!open) return;\n const reposition = () => requestAnimationFrame(computePosition);\n const onPointerDown = (event: MouseEvent) => {\n const target = event.target as Node;\n if (!containerRef.current?.contains(target) && !panelRef.current?.contains(target))\n setOpen(false);\n };\n window.addEventListener('scroll', reposition, true);\n window.addEventListener('resize', reposition);\n document.addEventListener('mousedown', onPointerDown, true);\n return () => {\n window.removeEventListener('scroll', reposition, true);\n window.removeEventListener('resize', reposition);\n document.removeEventListener('mousedown', onPointerDown, true);\n };\n }, [open, computePosition]);\n\n const handlePanelKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Escape') {\n event.preventDefault();\n event.stopPropagation();\n close();\n return;\n }\n if (event.key !== 'Tab') return;\n // The popover is portalled to <body>, so keep Tab cycling inside it.\n const nodes = Array.from(panelRef.current?.querySelectorAll<HTMLElement>(FOCUSABLE) ?? []);\n const first = nodes[0];\n const last = nodes[nodes.length - 1];\n if (!first || !last) return;\n if (event.shiftKey && document.activeElement === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n };\n\n const hasValue = displayText !== null;\n const showClear = clearable && hasValue && !control.disabled;\n\n return (\n <div\n ref={containerRef}\n className={cn(\n styles.control,\n styles[size],\n control.invalid && styles.invalid,\n control.disabled && styles.disabled,\n open && styles.open,\n className,\n )}\n >\n <button\n {...rest}\n ref={setTriggerRef}\n id={control.id}\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n aria-controls={open ? panelId : undefined}\n aria-invalid={control['aria-invalid']}\n aria-describedby={control['aria-describedby']}\n aria-required={control.required || undefined}\n disabled={control.disabled}\n className={cn(styles.trigger, !hasValue && styles.placeholder)}\n onClick={(event) => {\n onClick?.(event);\n if (event.defaultPrevented) return;\n if (open) close(false);\n else openPicker();\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n if (!open && event.key === 'ArrowDown') {\n event.preventDefault();\n openPicker();\n }\n }}\n >\n <span className={styles.value}>{displayText ?? placeholder}</span>\n </button>\n\n {showClear ? (\n <button\n type=\"button\"\n className={styles.clear}\n aria-label={clearLabel}\n onClick={() => {\n onClear();\n triggerRef.current?.focus({ preventScroll: true });\n }}\n >\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M6 6l8 8M14 6l-8 8\" />\n </svg>\n </button>\n ) : null}\n\n <svg\n className={styles.icon}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.8\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n {icon === 'clock' ? (\n <>\n <circle cx=\"12\" cy=\"12\" r=\"8\" />\n <path d=\"M12 7v5l3 2\" />\n </>\n ) : (\n <>\n <rect x=\"4\" y=\"5\" width=\"16\" height=\"15\" rx=\"2\" />\n <path d=\"M4 10h16M9 3v4M15 3v4\" />\n </>\n )}\n </svg>\n\n {name ? <input type=\"hidden\" name={name} value={hiddenValue} /> : null}\n\n {open && style\n ? createPortal(\n <div\n ref={panelRef}\n id={panelId}\n role=\"dialog\"\n aria-label={panelLabel}\n className={styles.panel}\n style={style}\n data-theme={themeName}\n onKeyDown={handlePanelKeyDown}\n >\n {children({ close })}\n </div>,\n document.body,\n )\n : null}\n </div>\n );\n },\n);\n\nexport interface PickerShellProps {\n label?: ReactNode;\n helperText?: ReactNode;\n error?: ReactNode;\n required?: boolean;\n disabled?: boolean;\n id?: string;\n children: ReactNode;\n}\n\n/** Adds the label, helper text and error around a picker, unless an enclosing FormField provides them. */\nexport function PickerShell({\n label,\n helperText,\n error,\n required,\n disabled,\n id,\n children,\n}: PickerShellProps) {\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n if (!label && !helperText && !error) return <>{children}</>;\n return (\n <FormField\n id={id}\n label={label}\n helperText={helperText}\n error={error}\n required={required}\n disabled={disabled}\n >\n {children}\n </FormField>\n );\n}\n\nexport const PickerField = PickerFieldControl;\n","import { forwardRef, useMemo, useState } from 'react';\nimport { Calendar } from './Calendar';\nimport { createDisabledPredicate, parseISO, toISO } from './dateUtils';\nimport { PickerField, PickerShell } from './PickerField';\nimport type { DatePickerProps } from './DatePicker.types';\n\n/** Date field with a calendar popover (days, months and years views, keyboard navigation). */\nexport const DatePicker = forwardRef<HTMLButtonElement, DatePickerProps>(function DatePicker(\n {\n label,\n helperText,\n error,\n required,\n disabled,\n id,\n value,\n defaultValue,\n onChange,\n min,\n max,\n disablePast,\n disableFuture,\n disabledDates,\n disabledRanges,\n disabledDaysOfWeek,\n isDateDisabled,\n placeholder = 'Select a date',\n name,\n clearable = true,\n weekStartsOn = 0,\n locale,\n ...rest\n },\n ref,\n) {\n const isControlled = value !== undefined;\n const [internal, setInternal] = useState(defaultValue ?? '');\n const current = isControlled ? value : internal;\n const selected = parseISO(current);\n const isDisabled = createDisabledPredicate({\n min,\n max,\n disablePast,\n disableFuture,\n disabledDates,\n disabledRanges,\n disabledDaysOfWeek,\n isDateDisabled,\n });\n\n const formatter = useMemo(\n () => new Intl.DateTimeFormat(locale, { day: '2-digit', month: 'short', year: 'numeric' }),\n [locale],\n );\n\n const commit = (next: string) => {\n if (!isControlled) setInternal(next);\n onChange?.(next);\n };\n\n return (\n <PickerShell\n label={label}\n helperText={helperText}\n error={error}\n required={required}\n disabled={disabled}\n id={id}\n >\n <PickerField\n {...rest}\n ref={ref}\n id={id}\n required={required}\n disabled={disabled}\n error={error}\n name={name}\n hiddenValue={selected ? toISO(selected) : ''}\n displayText={selected ? formatter.format(selected) : null}\n placeholder={placeholder}\n clearable={clearable}\n clearLabel=\"Clear date\"\n onClear={() => commit('')}\n panelLabel=\"Choose date\"\n >\n {({ close }) => (\n <Calendar\n selected={selected}\n isDisabled={isDisabled}\n weekStartsOn={weekStartsOn}\n locale={locale}\n allowClear={clearable}\n onSelect={(date) => {\n commit(date ? toISO(date) : '');\n close();\n }}\n />\n )}\n </PickerField>\n </PickerShell>\n );\n});\n",".root {\n display: flex;\n gap: var(--cui-space-2);\n padding: 0 var(--cui-space-3) var(--cui-space-3);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-sm);\n}\n\n.column {\n flex: 1;\n min-width: 0;\n}\n\n.list {\n display: flex;\n flex-direction: column;\n gap: 2px;\n max-height: 9.5rem;\n overflow-y: auto;\n padding: var(--cui-space-1);\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n background-color: var(--cui-color-surface);\n}\n\n.option {\n flex-shrink: 0;\n padding: 6px var(--cui-space-2);\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-md);\n color: var(--cui-color-text-secondary);\n font: inherit;\n text-align: center;\n cursor: pointer;\n}\n\n.option:hover:not([aria-disabled='true']):not(.selected) {\n background-color: var(--cui-color-primary-subtle);\n color: var(--cui-color-primary);\n}\n\n.option:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: -1px;\n}\n\n.selected {\n background-color: var(--cui-color-primary);\n color: var(--cui-color-on-primary);\n font-weight: var(--cui-font-weight-semibold);\n}\n\n.option[aria-disabled='true'] {\n opacity: 0.35;\n text-decoration: line-through;\n cursor: not-allowed;\n}\n","import { useEffect, useRef, type KeyboardEvent } from 'react';\nimport { cn } from '../../utils/cn';\nimport styles from './TimeColumns.module.css';\n\nexport interface TimeColumnsProps {\n /** Hour 0-23, or null while no time is chosen. */\n hours: number | null;\n minutes: number | null;\n onChange: (hours: number, minutes: number) => void;\n minuteStep: number;\n use12Hours: boolean;\n /** True for times that cannot be chosen. */\n isTimeDisabled: (hours: number, minutes: number) => boolean;\n}\n\ninterface Option {\n value: number;\n label: string;\n disabled: boolean;\n}\n\nconst pad = (n: number) => String(n).padStart(2, '0');\n\n/** Hour, minute (and AM/PM) lists used inside the DateTimePicker popover. */\nexport function TimeColumns({\n hours,\n minutes,\n onChange,\n minuteStep,\n use12Hours,\n isTimeDisabled,\n}: TimeColumnsProps) {\n const h = hours ?? 0;\n const m = minutes ?? 0;\n const isPm = h >= 12;\n\n // Multiples of the step, plus the current minute when it is not one (e.g. set programmatically).\n const minuteValues = Array.from(\n { length: Math.ceil(60 / minuteStep) },\n (_, i) => i * minuteStep,\n ).filter((v) => v < 60);\n if (minutes !== null && !minuteValues.includes(minutes)) minuteValues.push(minutes);\n minuteValues.sort((a, b) => a - b);\n\n // An hour is unavailable when none of its minutes can be chosen.\n const hourDisabled = (hour: number) => minuteValues.every((v) => isTimeDisabled(hour, v));\n\n // Hours as shown (1-12 with AM/PM, or 0-23); each maps back to a 24 hour value.\n const hourOptions: Option[] = use12Hours\n ? Array.from({ length: 12 }, (_, i) => {\n const value = i + (isPm ? 12 : 0);\n return { value, label: String(i === 0 ? 12 : i), disabled: hourDisabled(value) };\n })\n : Array.from({ length: 24 }, (_, i) => ({\n value: i,\n label: pad(i),\n disabled: hourDisabled(i),\n }));\n\n const minuteOptions: Option[] = minuteValues.map((value) => ({\n value,\n label: pad(value),\n disabled: isTimeDisabled(h, value),\n }));\n\n const periodDisabled = (start: number) =>\n Array.from({ length: 12 }, (_, i) => start + i).every(hourDisabled);\n const periodOptions: Option[] = [\n { value: 0, label: 'AM', disabled: periodDisabled(0) },\n { value: 12, label: 'PM', disabled: periodDisabled(12) },\n ];\n\n return (\n <div className={styles.root}>\n <Column\n label=\"Hours\"\n options={hourOptions}\n selected={hours}\n onSelect={(value) => onChange(value, m)}\n />\n <Column\n label=\"Minutes\"\n options={minuteOptions}\n selected={minutes}\n onSelect={(value) => onChange(h, value)}\n />\n {use12Hours ? (\n <Column\n label=\"AM or PM\"\n options={periodOptions}\n selected={hours === null ? null : isPm ? 12 : 0}\n onSelect={(value) => onChange((h % 12) + value, m)}\n />\n ) : null}\n </div>\n );\n}\n\nfunction Column({\n label,\n options,\n selected,\n onSelect,\n}: {\n label: string;\n options: Option[];\n selected: number | null;\n onSelect: (value: number) => void;\n}) {\n const listRef = useRef<HTMLDivElement>(null);\n const selectedIndex = options.findIndex((option) => option.value === selected);\n\n // Keep the chosen value visible inside the scrolling list.\n useEffect(() => {\n const list = listRef.current;\n const el = list?.querySelector<HTMLElement>('[aria-selected=\"true\"]');\n if (list && el)\n list.scrollTop = Math.max(0, el.offsetTop - list.clientHeight / 2 + el.offsetHeight / 2);\n }, [selected]);\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const items = Array.from(\n listRef.current?.querySelectorAll<HTMLElement>('[role=\"option\"]') ?? [],\n );\n const current = items.indexOf(document.activeElement as HTMLElement);\n let next = -1;\n if (event.key === 'ArrowDown') next = Math.min(current + 1, items.length - 1);\n else if (event.key === 'ArrowUp') next = Math.max(current - 1, 0);\n else if (event.key === 'Home') next = 0;\n else if (event.key === 'End') next = items.length - 1;\n if (next < 0) return;\n event.preventDefault();\n items[next]?.focus({ preventScroll: false });\n };\n\n return (\n <div className={styles.column}>\n <div\n ref={listRef}\n role=\"listbox\"\n aria-label={label}\n className={styles.list}\n onKeyDown={handleKeyDown}\n >\n {options.map((option, index) => {\n const isSelected = option.value === selected;\n return (\n <button\n key={option.value}\n type=\"button\"\n role=\"option\"\n aria-selected={isSelected}\n aria-disabled={option.disabled || undefined}\n tabIndex={isSelected || (selectedIndex === -1 && index === 0) ? 0 : -1}\n className={cn(styles.option, isSelected && styles.selected)}\n onClick={() => {\n if (!option.disabled) onSelect(option.value);\n }}\n >\n {option.label}\n </button>\n );\n })}\n </div>\n </div>\n );\n}\n",".timeHeading {\n padding: 0 var(--cui-space-3) var(--cui-space-1);\n border-top: 1px solid var(--cui-color-border);\n margin: 0 var(--cui-space-3) var(--cui-space-2);\n padding: var(--cui-space-2) 0 0;\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-xs);\n font-weight: var(--cui-font-weight-semibold);\n color: var(--cui-color-text-muted);\n}\n\n.footer {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: var(--cui-space-2) var(--cui-space-3) var(--cui-space-3);\n border-top: 1px solid var(--cui-color-border);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-xs);\n font-weight: var(--cui-font-weight-semibold);\n}\n\n.footerActions {\n display: flex;\n gap: var(--cui-space-1);\n}\n\n.footerButton {\n padding: 6px var(--cui-space-3);\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-md);\n color: var(--cui-color-text-muted);\n font: inherit;\n cursor: pointer;\n}\n.footerButton:hover:not(:disabled) {\n background-color: var(--cui-color-surface-secondary);\n}\n.footerButton:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: -1px;\n}\n.footerButton:disabled {\n opacity: 0.35;\n cursor: not-allowed;\n}\n\n.done {\n background-color: var(--cui-color-primary);\n color: var(--cui-color-on-primary);\n}\n.done:hover:not(:disabled) {\n background-color: var(--cui-color-primary-hover);\n}\n","import { forwardRef, useMemo, useState } from 'react';\nimport { Calendar } from '../DatePicker/Calendar';\nimport { PickerField, PickerShell } from '../DatePicker/PickerField';\nimport { TimeColumns } from '../DatePicker/TimeColumns';\nimport {\n addDays,\n createDisabledPredicate,\n nearestEnabled,\n parseDateTime,\n parseISO,\n toDateTimeISO,\n toISO,\n today,\n withTime,\n} from '../DatePicker/dateUtils';\nimport type { DateTimePickerProps } from './DateTimePicker.types';\nimport styles from './DateTimePicker.module.css';\n\n/** `YYYY-MM-DDTHH:mm` (or a bare date) as a moment; a bare date means the start or end of that day. */\nfunction parseBoundary(value: string | undefined, end: boolean): Date | null {\n if (!value) return null;\n const full = parseDateTime(value);\n if (full) return full;\n const day = parseISO(value);\n return day ? withTime(day, end ? 23 : 0, end ? 59 : 0) : null;\n}\n\nconst parseTime = (value: string): [number, number] => {\n const match = /^(\\d{2}):(\\d{2})$/.exec(value);\n const hours = match ? Number(match[1]) : 0;\n const minutes = match ? Number(match[2]) : 0;\n return hours > 23 || minutes > 59 ? [0, 0] : [hours, minutes];\n};\n\n/** Date and time field: a calendar plus hour and minute lists (value as `YYYY-MM-DDTHH:mm`). */\nexport const DateTimePicker = forwardRef<HTMLButtonElement, DateTimePickerProps>(\n function DateTimePicker(\n {\n label,\n helperText,\n error,\n required,\n disabled,\n id,\n value,\n defaultValue,\n onChange,\n min,\n max,\n disablePast,\n disableFuture,\n disabledDates,\n disabledRanges,\n disabledDaysOfWeek,\n isDateDisabled,\n minuteStep = 5,\n use12Hours = false,\n defaultTime = '00:00',\n placeholder = 'Select date and time',\n name,\n clearable = true,\n weekStartsOn = 0,\n locale,\n ...rest\n },\n ref,\n ) {\n const isControlled = value !== undefined;\n const [internal, setInternal] = useState(defaultValue ?? '');\n const current = isControlled ? value : internal;\n const selected = parseDateTime(current);\n\n // \"Past\" and \"future\" are measured from now, so they also limit the hours of today.\n const now = new Date();\n const earliest = [parseBoundary(min, false), disablePast ? now : null]\n .filter((d): d is Date => d !== null)\n .sort((a, b) => b.getTime() - a.getTime())[0];\n const latest = [parseBoundary(max, true), disableFuture ? now : null]\n .filter((d): d is Date => d !== null)\n .sort((a, b) => a.getTime() - b.getTime())[0];\n\n const isDayDisabled = createDisabledPredicate({\n min: earliest ? toISO(earliest) : undefined,\n max: latest ? toISO(latest) : undefined,\n disabledDates,\n disabledRanges,\n disabledDaysOfWeek,\n isDateDisabled,\n });\n const isMomentDisabled = (moment: Date) =>\n isDayDisabled(moment) ||\n (earliest !== undefined &&\n moment < withTime(earliest, earliest.getHours(), earliest.getMinutes())) ||\n (latest !== undefined && moment > withTime(latest, latest.getHours(), latest.getMinutes()));\n\n const formatter = useMemo(\n () =>\n new Intl.DateTimeFormat(locale, {\n day: '2-digit',\n month: 'short',\n year: 'numeric',\n hour: '2-digit',\n minute: '2-digit',\n hour12: use12Hours,\n }),\n [locale, use12Hours],\n );\n\n const commit = (next: Date | null) => {\n const text = next ? toDateTimeISO(next) : '';\n if (!isControlled) setInternal(text);\n onChange?.(text);\n };\n\n /** The first allowed time on `day` at or after the wanted one, or the wanted one when nothing fits. */\n const fitTime = (day: Date, hours: number, minutes: number): Date => {\n const wanted = withTime(day, hours, minutes);\n if (!isMomentDisabled(wanted)) return wanted;\n for (let total = 0; total < 24 * 60; total += minuteStep) {\n const candidate = withTime(day, Math.floor(total / 60), total % 60);\n if (!isMomentDisabled(candidate)) return candidate;\n }\n return wanted;\n };\n\n const baseDay = () => selected ?? nearestEnabled(today(), isDayDisabled);\n const [defaultHours, defaultMinutes] = parseTime(defaultTime);\n const nowDate = new Date();\n\n return (\n <PickerShell\n label={label}\n helperText={helperText}\n error={error}\n required={required}\n disabled={disabled}\n id={id}\n >\n <PickerField\n {...rest}\n ref={ref}\n id={id}\n required={required}\n disabled={disabled}\n error={error}\n name={name}\n hiddenValue={selected ? toDateTimeISO(selected) : ''}\n displayText={selected ? formatter.format(selected) : null}\n placeholder={placeholder}\n clearable={clearable}\n clearLabel=\"Clear date and time\"\n onClear={() => commit(null)}\n panelLabel=\"Choose date and time\"\n panelWidth={use12Hours ? 340 : 320}\n icon=\"clock\"\n >\n {({ close }) => (\n <div>\n <Calendar\n selected={selected}\n isDisabled={isDayDisabled}\n weekStartsOn={weekStartsOn}\n locale={locale}\n allowClear={clearable}\n showFooter={false}\n onSelect={(day) => {\n if (!day) return;\n commit(\n fitTime(\n day,\n selected?.getHours() ?? defaultHours,\n selected?.getMinutes() ?? defaultMinutes,\n ),\n );\n }}\n />\n <div className={styles.timeHeading}>Time</div>\n <TimeColumns\n hours={selected ? selected.getHours() : null}\n minutes={selected ? selected.getMinutes() : null}\n minuteStep={minuteStep}\n use12Hours={use12Hours}\n isTimeDisabled={(hours, minutes) =>\n isMomentDisabled(withTime(baseDay(), hours, minutes))\n }\n onChange={(hours, minutes) => commit(withTime(baseDay(), hours, minutes))}\n />\n <div className={styles.footer}>\n {clearable ? (\n <button\n type=\"button\"\n className={styles.footerButton}\n onClick={() => {\n commit(null);\n }}\n >\n Clear\n </button>\n ) : (\n <span />\n )}\n <span className={styles.footerActions}>\n <button\n type=\"button\"\n className={styles.footerButton}\n disabled={isMomentDisabled(nowDate)}\n onClick={() =>\n commit(\n withTime(addDays(nowDate, 0), nowDate.getHours(), nowDate.getMinutes()),\n )\n }\n >\n Now\n </button>\n <button\n type=\"button\"\n className={`${styles.footerButton} ${styles.done}`}\n onClick={() => close()}\n >\n Done\n </button>\n </span>\n </div>\n </div>\n )}\n </PickerField>\n </PickerShell>\n );\n },\n);\n","import { useEffect, useMemo, useRef, useState, type KeyboardEvent } from 'react';\nimport { cn } from '../../utils/cn';\nimport { addMonths, parseMonth, today as getToday, toMonthISO } from './dateUtils';\nimport styles from './Calendar.module.css';\n\nexport interface MonthCalendarProps {\n /** Selected month as the first day of that month. */\n selected: Date | null;\n /** True for months that cannot be chosen (called with the first day of the month). */\n isDisabled: (month: Date) => boolean;\n locale?: string;\n /** Called with the first day of the chosen month, or null when Clear is pressed. */\n onSelect: (month: Date | null) => void;\n allowClear: boolean;\n}\n\ntype View = 'months' | 'years';\n\nconst chevron = (direction: 'left' | 'right') => (\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d={direction === 'left' ? 'M12 5l-5 5 5 5' : 'M8 5l5 5-5 5'} />\n </svg>\n);\n\nconst firstOfMonth = (year: number, month: number) => new Date(year, month, 1, 12);\n\n/** Month and year chooser shown inside the MonthPicker popover. */\nexport function MonthCalendar({\n selected,\n isDisabled,\n locale,\n onSelect,\n allowClear,\n}: MonthCalendarProps) {\n const thisMonth = getToday();\n // `cursor` is the month with keyboard focus; its year is the page being shown.\n const [cursor, setCursor] = useState<Date>(() =>\n firstOfMonth((selected ?? thisMonth).getFullYear(), (selected ?? thisMonth).getMonth()),\n );\n const [view, setView] = useState<View>('months');\n const gridRef = useRef<HTMLDivElement>(null);\n const focusCursor = useRef(true);\n\n const year = cursor.getFullYear();\n const yearStart = Math.floor((year - 1) / 12) * 12 + 1;\n const monthNames = useMemo(\n () =>\n Array.from({ length: 12 }, (_, m) =>\n new Intl.DateTimeFormat(locale, { month: 'short' }).format(new Date(2024, m, 1)),\n ),\n [locale],\n );\n const monthLong = useMemo(\n () => new Intl.DateTimeFormat(locale, { month: 'long', year: 'numeric' }),\n [locale],\n );\n\n const cursorISO = toMonthISO(cursor);\n useEffect(() => {\n if (view !== 'months' || !focusCursor.current) return;\n gridRef.current\n ?.querySelector<HTMLElement>(`[data-month=\"${cursorISO}\"]`)\n ?.focus({ preventScroll: true });\n }, [cursorISO, view]);\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const steps: Record<string, number> = {\n ArrowLeft: -1,\n ArrowRight: 1,\n ArrowUp: -3,\n ArrowDown: 3,\n PageUp: -12,\n PageDown: 12,\n };\n const step = steps[event.key];\n if (step === undefined) return;\n event.preventDefault();\n focusCursor.current = true;\n setCursor((current) => addMonths(current, step));\n };\n\n const page = (direction: 1 | -1) => {\n focusCursor.current = false;\n setCursor((current) => addMonths(current, direction * (view === 'years' ? 144 : 12)));\n };\n\n return (\n <div className={styles.root}>\n <div className={styles.header}>\n <button\n type=\"button\"\n className={styles.nav}\n aria-label={view === 'years' ? 'Previous 12 years' : 'Previous year'}\n onClick={() => page(-1)}\n >\n {chevron('left')}\n </button>\n <div className={styles.title} aria-live=\"polite\">\n {view === 'years' ? (\n <span>\n {yearStart} - {yearStart + 11}\n </span>\n ) : (\n <button\n type=\"button\"\n className={styles.titleButton}\n aria-label=\"Choose year\"\n onClick={() => setView('years')}\n >\n {year}\n </button>\n )}\n </div>\n <button\n type=\"button\"\n className={styles.nav}\n aria-label={view === 'years' ? 'Next 12 years' : 'Next year'}\n onClick={() => page(1)}\n >\n {chevron('right')}\n </button>\n </div>\n\n {view === 'months' ? (\n <div\n ref={gridRef}\n className={styles.cells}\n role=\"group\"\n aria-label={`Months of ${year}`}\n onKeyDown={handleKeyDown}\n >\n {monthNames.map((name, month) => {\n const first = firstOfMonth(year, month);\n const iso = toMonthISO(first);\n const isSelected = selected !== null && toMonthISO(selected) === iso;\n return (\n <button\n key={iso}\n type=\"button\"\n data-month={iso}\n tabIndex={month === cursor.getMonth() ? 0 : -1}\n aria-label={monthLong.format(first)}\n aria-pressed={isSelected}\n aria-current={toMonthISO(thisMonth) === iso ? 'date' : undefined}\n aria-disabled={isDisabled(first) || undefined}\n className={cn(\n styles.cell,\n isSelected && styles.active,\n toMonthISO(thisMonth) === iso && !isSelected && styles.currentCell,\n )}\n onClick={() => {\n if (!isDisabled(first)) onSelect(first);\n }}\n >\n {name}\n </button>\n );\n })}\n </div>\n ) : (\n <div className={styles.cells}>\n {Array.from({ length: 12 }, (_, i) => yearStart + i).map((y) => (\n <button\n key={y}\n type=\"button\"\n className={cn(styles.cell, y === year && styles.active)}\n onClick={() => {\n focusCursor.current = true;\n setCursor((current) => addMonths(current, (y - current.getFullYear()) * 12));\n setView('months');\n }}\n >\n {y}\n </button>\n ))}\n </div>\n )}\n\n <div className={styles.footer}>\n {allowClear ? (\n <button type=\"button\" className={styles.footerButton} onClick={() => onSelect(null)}>\n Clear\n </button>\n ) : (\n <span />\n )}\n <button\n type=\"button\"\n className={cn(styles.footerButton, styles.footerPrimary)}\n disabled={isDisabled(firstOfMonth(thisMonth.getFullYear(), thisMonth.getMonth()))}\n onClick={() => onSelect(parseMonth(toMonthISO(thisMonth)))}\n >\n This month\n </button>\n </div>\n </div>\n );\n}\n","import { forwardRef, useMemo, useState } from 'react';\nimport { MonthCalendar } from '../DatePicker/MonthCalendar';\nimport { PickerField, PickerShell } from '../DatePicker/PickerField';\nimport { createMonthDisabledPredicate, parseMonth, toMonthISO } from '../DatePicker/dateUtils';\nimport type { MonthPickerProps } from './MonthPicker.types';\n\n/** Month and year field with a custom chooser (value as `YYYY-MM`). */\nexport const MonthPicker = forwardRef<HTMLButtonElement, MonthPickerProps>(function MonthPicker(\n {\n label,\n helperText,\n error,\n required,\n disabled,\n id,\n value,\n defaultValue,\n onChange,\n min,\n max,\n disablePast,\n disableFuture,\n disabledMonths,\n isMonthDisabled,\n placeholder = 'Select a month',\n name,\n clearable = true,\n locale,\n ...rest\n },\n ref,\n) {\n const isControlled = value !== undefined;\n const [internal, setInternal] = useState(defaultValue ?? '');\n const current = isControlled ? value : internal;\n const selected = parseMonth(current);\n const isDisabled = createMonthDisabledPredicate({\n min,\n max,\n disablePast,\n disableFuture,\n disabledMonths,\n isMonthDisabled,\n });\n\n const formatter = useMemo(\n () => new Intl.DateTimeFormat(locale, { month: 'long', year: 'numeric' }),\n [locale],\n );\n\n const commit = (next: string) => {\n if (!isControlled) setInternal(next);\n onChange?.(next);\n };\n\n return (\n <PickerShell\n label={label}\n helperText={helperText}\n error={error}\n required={required}\n disabled={disabled}\n id={id}\n >\n <PickerField\n {...rest}\n ref={ref}\n id={id}\n required={required}\n disabled={disabled}\n error={error}\n name={name}\n hiddenValue={selected ? toMonthISO(selected) : ''}\n displayText={selected ? formatter.format(selected) : null}\n placeholder={placeholder}\n clearable={clearable}\n clearLabel=\"Clear month\"\n onClear={() => commit('')}\n panelLabel=\"Choose month\"\n >\n {({ close }) => (\n <MonthCalendar\n selected={selected}\n isDisabled={isDisabled}\n locale={locale}\n allowClear={clearable}\n onSelect={(month) => {\n commit(month ? toMonthISO(month) : '');\n close();\n }}\n />\n )}\n </PickerField>\n </PickerShell>\n );\n});\n","import { forwardRef, useCallback, useRef, useState } from 'react';\nimport { DatePicker } from '../DatePicker';\nimport { DateTimePicker } from '../DateTimePicker';\nimport { MonthPicker } from '../MonthPicker';\nimport type { InputProps } from './Input.types';\n\n/** Input types that use the package's own pickers instead of the browser's. */\nexport const PICKER_TYPES = ['date', 'datetime-local', 'month'] as const;\nexport type PickerType = (typeof PICKER_TYPES)[number];\n\nexport const isPickerType = (type: string | undefined): type is PickerType =>\n PICKER_TYPES.includes(type as PickerType);\n\n/**\n * `Input type=\"date\" | \"datetime-local\" | \"month\"`: a themed picker behind the regular Input API.\n *\n * A hidden text input holds the value and receives a real `input` event when something is picked, so\n * `onChange` handlers, form libraries and the forwarded ref behave as they do with a native input.\n */\nexport const PickerTypeInput = forwardRef<HTMLInputElement, InputProps & { type: PickerType }>(\n function PickerTypeInput(\n {\n type,\n label,\n helperText,\n error,\n required,\n disabled,\n id,\n name,\n size,\n value,\n defaultValue,\n onChange,\n min,\n max,\n placeholder,\n className,\n dateOptions = {},\n },\n ref,\n ) {\n const hiddenRef = useRef<HTMLInputElement | null>(null);\n const setRef = useCallback(\n (node: HTMLInputElement | null) => {\n hiddenRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n },\n [ref],\n );\n\n const isControlled = value !== undefined;\n const [internal, setInternal] = useState(String(defaultValue ?? ''));\n const current = isControlled ? String(value) : internal;\n\n const pick = (next: string) => {\n const input = hiddenRef.current;\n if (!input) return;\n // Use the prototype's setter so React notices the change and runs onChange.\n Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set?.call(input, next);\n input.dispatchEvent(new Event('input', { bubbles: true }));\n };\n\n const common = {\n id,\n label,\n helperText,\n error,\n required,\n disabled,\n size,\n placeholder,\n className,\n value: current,\n onChange: pick,\n min: min === undefined ? undefined : String(min),\n max: max === undefined ? undefined : String(max),\n locale: dateOptions.locale,\n clearable: dateOptions.clearable,\n disablePast: dateOptions.disablePast,\n disableFuture: dateOptions.disableFuture,\n };\n\n return (\n <>\n {type === 'month' ? (\n <MonthPicker\n {...common}\n disabledMonths={dateOptions.disabledMonths}\n isMonthDisabled={dateOptions.isMonthDisabled}\n />\n ) : type === 'datetime-local' ? (\n <DateTimePicker\n {...common}\n disabledDates={dateOptions.disabledDates}\n disabledRanges={dateOptions.disabledRanges}\n disabledDaysOfWeek={dateOptions.disabledDaysOfWeek}\n isDateDisabled={dateOptions.isDateDisabled}\n weekStartsOn={dateOptions.weekStartsOn}\n minuteStep={dateOptions.minuteStep}\n use12Hours={dateOptions.use12Hours}\n defaultTime={dateOptions.defaultTime}\n />\n ) : (\n <DatePicker\n {...common}\n disabledDates={dateOptions.disabledDates}\n disabledRanges={dateOptions.disabledRanges}\n disabledDaysOfWeek={dateOptions.disabledDaysOfWeek}\n isDateDisabled={dateOptions.isDateDisabled}\n weekStartsOn={dateOptions.weekStartsOn}\n />\n )}\n <input\n ref={setRef}\n hidden\n readOnly\n tabIndex={-1}\n type=\"text\"\n name={name}\n value={current}\n onChange={(event) => {\n if (!isControlled) setInternal(event.target.value);\n onChange?.(event);\n }}\n />\n </>\n );\n },\n);\n",".control {\n display: flex;\n align-items: center;\n gap: var(--cui-space-2);\n box-sizing: border-box;\n width: 100%;\n padding: 0 var(--cui-space-4);\n background-color: var(--cui-color-surface);\n border: var(--cui-control-border-width) solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text);\n font-family: var(--cui-font-family);\n transition:\n border-color var(--cui-transition-fast),\n box-shadow var(--cui-transition-fast);\n}\n\n.control:hover:not(.disabled):not(.invalid) {\n border-color: var(--cui-color-border-hover);\n}\n\n.control:focus-within {\n border-color: var(--cui-color-border-focus);\n outline: none;\n box-shadow: var(--cui-focus-ring);\n}\n\n.sm {\n min-height: var(--cui-control-height-sm);\n font-size: var(--cui-font-size-sm);\n}\n.md {\n min-height: var(--cui-control-height-md);\n font-size: var(--cui-font-size-sm);\n}\n.lg {\n min-height: var(--cui-control-height-lg);\n font-size: var(--cui-font-size-lg);\n}\n\n.input {\n flex: 1;\n min-width: 0;\n align-self: stretch;\n padding: 0;\n border: 0;\n outline: 0;\n background: transparent;\n color: inherit;\n font: inherit;\n}\n\n.input[type='number'] {\n appearance: textfield;\n -moz-appearance: textfield;\n}\n.input[type='number']::-webkit-inner-spin-button,\n.input[type='number']::-webkit-outer-spin-button {\n -webkit-appearance: none;\n margin: 0;\n}\n\n.input::placeholder {\n color: var(--cui-color-placeholder);\n}\n\n.affix {\n display: inline-flex;\n align-items: center;\n flex-shrink: 0;\n color: var(--cui-color-text-secondary);\n}\n\n.invalid {\n border-color: var(--cui-color-danger-border);\n}\n.control.invalid:hover:not(.disabled) {\n border-color: var(--cui-color-danger-border-hover);\n}\n.invalid:focus-within {\n border-color: var(--cui-color-danger-border-hover);\n box-shadow: var(--cui-focus-ring-danger);\n}\n\n.readOnly {\n background-color: var(--cui-color-surface-secondary);\n}\n\n.disabled {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n.disabled .input,\n.disabled .affix {\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n","import { forwardRef } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { FormField, useFormFieldControl } from '../FormField';\nimport { PickerTypeInput, isPickerType } from './PickerTypeInput';\nimport type { InputProps } from './Input.types';\nimport styles from './Input.module.css';\n\nconst InputControl = forwardRef<HTMLInputElement, Omit<InputProps, 'label' | 'helperText'>>(\n function InputControl(\n {\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n prefix,\n suffix,\n size = 'md',\n readOnly,\n className,\n ...rest\n },\n ref,\n ) {\n const control = useFormFieldControl({\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n });\n\n return (\n <div\n className={cn(\n styles.control,\n styles[size],\n control.invalid && styles.invalid,\n control.disabled && styles.disabled,\n readOnly && styles.readOnly,\n className,\n )}\n >\n {prefix ? <span className={styles.affix}>{prefix}</span> : null}\n <input\n {...rest}\n ref={ref}\n id={control.id}\n required={control.required}\n disabled={control.disabled}\n readOnly={readOnly}\n aria-invalid={control['aria-invalid']}\n aria-describedby={control['aria-describedby']}\n className={styles.input}\n />\n {suffix ? <span className={styles.affix}>{suffix}</span> : null}\n </div>\n );\n },\n);\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(function Input(\n { label, helperText, ...props },\n ref,\n) {\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n // Browsers' own date pickers can't be themed, so date, date-time and month inputs use the package's pickers.\n if (isPickerType(props.type)) {\n return (\n <PickerTypeInput\n label={label}\n helperText={helperText}\n {...props}\n type={props.type}\n ref={ref}\n />\n );\n }\n\n // Without its own label/helper/error, Input defers to an enclosing <FormField>.\n if (!label && !helperText && !props.error) {\n return <InputControl {...props} ref={ref} />;\n }\n\n return (\n <FormField\n id={props.id}\n label={label}\n helperText={helperText}\n error={props.error}\n required={props.required}\n disabled={props.disabled}\n >\n <InputControl {...props} ref={ref} />\n </FormField>\n );\n});\n",".toggle {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 1.5rem;\n height: 1.5rem;\n padding: 0;\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-sm);\n color: var(--cui-color-text-muted);\n cursor: pointer;\n}\n\n.toggle:hover:not(:disabled) {\n color: var(--cui-color-text);\n}\n\n.toggle:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 1px;\n}\n\n.toggle:disabled {\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n\n.toggle svg {\n width: 1.125rem;\n height: 1.125rem;\n}\n","import { forwardRef, useState } from 'react';\nimport { Input } from '../Input';\nimport type { PasswordInputProps } from './PasswordInput.types';\nimport styles from './PasswordInput.module.css';\n\n/** `Input` for passwords, with a button to show or hide what is typed. */\nexport const PasswordInput = forwardRef<HTMLInputElement, PasswordInputProps>(\n function PasswordInput(\n { showLabel = 'Show password', hideLabel = 'Hide password', autoComplete, disabled, ...props },\n ref,\n ) {\n const [visible, setVisible] = useState(false);\n\n return (\n <Input\n {...props}\n ref={ref}\n type={visible ? 'text' : 'password'}\n autoComplete={autoComplete ?? 'current-password'}\n disabled={disabled}\n suffix={\n <button\n type=\"button\"\n className={styles.toggle}\n aria-label={visible ? hideLabel : showLabel}\n aria-pressed={visible}\n disabled={disabled}\n onClick={() => setVisible((current) => !current)}\n >\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.8\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12z\" />\n <circle cx=\"12\" cy=\"12\" r=\"3\" />\n {visible ? null : <path d=\"M4 4l16 16\" />}\n </svg>\n </button>\n }\n />\n );\n },\n);\n",".search input[type='search']::-webkit-search-cancel-button,\n.search input[type='search']::-webkit-search-decoration {\n appearance: none;\n -webkit-appearance: none;\n}\n\n.icon {\n width: 1.125rem;\n height: 1.125rem;\n color: var(--cui-color-text-muted);\n}\n\n.clear {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 1.25rem;\n height: 1.25rem;\n padding: 0;\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-full);\n color: var(--cui-color-text-muted);\n cursor: pointer;\n}\n\n.clear:hover {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text);\n}\n\n.clear:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n}\n\n.clear svg {\n width: 0.875rem;\n height: 0.875rem;\n}\n","import { forwardRef, useCallback, useRef, useState } from 'react';\nimport { Input } from '../Input';\nimport type { SearchInputProps } from './SearchInput.types';\nimport styles from './SearchInput.module.css';\n\n/** `Input` for searching: a search icon, and a clear button once something is typed. */\nexport const SearchInput = forwardRef<HTMLInputElement, SearchInputProps>(function SearchInput(\n {\n value,\n defaultValue,\n onChange,\n onClear,\n clearLabel = 'Clear search',\n disabled,\n readOnly,\n ...props\n },\n ref,\n) {\n const innerRef = useRef<HTMLInputElement | null>(null);\n const setRef = useCallback(\n (node: HTMLInputElement | null) => {\n innerRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n },\n [ref],\n );\n\n const isControlled = value !== undefined;\n const [internal, setInternal] = useState(String(defaultValue ?? ''));\n const current = isControlled ? String(value) : internal;\n const showClear = current.length > 0 && !disabled && !readOnly;\n\n return (\n <Input\n {...props}\n ref={setRef}\n type=\"search\"\n className={styles.search}\n value={current}\n disabled={disabled}\n readOnly={readOnly}\n onChange={(event) => {\n if (!isControlled) setInternal(event.target.value);\n onChange?.(event);\n }}\n prefix={\n <svg\n className={styles.icon}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.8\"\n strokeLinecap=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <circle cx=\"11\" cy=\"11\" r=\"6.5\" />\n <path d=\"M16 16l4.5 4.5\" />\n </svg>\n }\n suffix={\n showClear ? (\n <button\n type=\"button\"\n className={styles.clear}\n aria-label={clearLabel}\n onClick={() => {\n if (!isControlled) setInternal('');\n onClear?.();\n innerRef.current?.focus();\n }}\n >\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M6 6l8 8M14 6l-8 8\" />\n </svg>\n </button>\n ) : undefined\n }\n />\n );\n});\n","import { useSyncExternalStore } from 'react';\n\nconst DARK_QUERY = '(prefers-color-scheme: dark)';\n\n/** True when the OS prefers dark. Always false on the server and where matchMedia is missing. */\nexport function useSystemPrefersDark(): boolean {\n return useSyncExternalStore(\n (onChange) => {\n if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') {\n return () => {};\n }\n const query = window.matchMedia(DARK_QUERY);\n query.addEventListener('change', onChange);\n return () => query.removeEventListener('change', onChange);\n },\n () =>\n typeof window !== 'undefined' &&\n typeof window.matchMedia === 'function' &&\n window.matchMedia(DARK_QUERY).matches,\n () => false,\n );\n}\n\nconst storageListeners = new Set<() => void>();\n\nfunction readStorage(key: string): string | null {\n try {\n return window.localStorage.getItem(key);\n } catch {\n return null;\n }\n}\n\nexport function writeStoredTheme(key: string, theme: string): void {\n try {\n window.localStorage.setItem(key, theme);\n } catch {\n // Storage can be blocked (private mode); the choice then lasts for the session only.\n }\n storageListeners.forEach((listener) => listener());\n}\n\n/** The theme saved under `key`, or null. Null on the server and on the first client render. */\nexport function useStoredTheme(key: string | undefined): string | null {\n return useSyncExternalStore(\n (onChange) => {\n storageListeners.add(onChange);\n window.addEventListener('storage', onChange);\n return () => {\n storageListeners.delete(onChange);\n window.removeEventListener('storage', onChange);\n };\n },\n () => (key ? readStorage(key) : null),\n () => null,\n );\n}\n",".root {\n background-color: var(--cui-color-background);\n color: var(--cui-color-text);\n font-family: var(--cui-font-family);\n line-height: var(--cui-line-height);\n}\n","import { createContext, useCallback, useContext, useMemo, useState } from 'react';\nimport { LicenseContext } from '../license';\nimport { cn } from '../utils/cn';\nimport { useStoredTheme, useSystemPrefersDark, writeStoredTheme } from './themeStore';\nimport type { Theme, ThemeContextValue, ThemeProviderProps } from './ThemeProvider.types';\nimport styles from './ThemeProvider.module.css';\n\nconst ThemeContext = createContext<ThemeContextValue | null>(null);\n\nexport function ThemeProvider({\n children,\n theme: controlledTheme,\n defaultTheme = 'light',\n onThemeChange,\n storageKey,\n licenseKey,\n className,\n ...rest\n}: ThemeProviderProps) {\n const [internalTheme, setInternalTheme] = useState<Theme>(defaultTheme);\n const storedTheme = useStoredTheme(controlledTheme === undefined ? storageKey : undefined);\n const systemPrefersDark = useSystemPrefersDark();\n\n const theme = controlledTheme ?? storedTheme ?? internalTheme;\n const resolvedTheme = theme === 'system' ? (systemPrefersDark ? 'dark' : 'light') : theme;\n\n const setTheme = useCallback(\n (next: Theme) => {\n if (controlledTheme === undefined) {\n setInternalTheme(next);\n if (storageKey) writeStoredTheme(storageKey, next);\n }\n onThemeChange?.(next);\n },\n [controlledTheme, onThemeChange, storageKey],\n );\n\n const value = useMemo(\n () => ({ theme, resolvedTheme, setTheme }),\n [theme, resolvedTheme, setTheme],\n );\n // A nested provider without its own key inherits the outer one.\n const inheritedKey = useContext(LicenseContext);\n\n return (\n <ThemeContext.Provider value={value}>\n <LicenseContext.Provider value={licenseKey ?? inheritedKey}>\n <div {...rest} data-theme={resolvedTheme} className={cn(styles.root, className)}>\n {children}\n </div>\n </LicenseContext.Provider>\n </ThemeContext.Provider>\n );\n}\n\n/** Read or change the active theme. Must be used inside a `ThemeProvider`. */\nexport function useTheme(): ThemeContextValue {\n const context = useContext(ThemeContext);\n if (!context) throw new Error('useTheme must be used within a <ThemeProvider>.');\n return context;\n}\n\n/** Like `useTheme`, but returns null outside a ThemeProvider instead of throwing. Used by portalled components. */\nexport function useOptionalTheme(): ThemeContextValue | null {\n return useContext(ThemeContext);\n}\n",".backdrop {\n position: fixed;\n inset: 0;\n z-index: var(--cui-z-modal);\n display: flex;\n box-sizing: border-box;\n background-color: rgb(0 0 0 / 0.5);\n font-family: var(--cui-font-family);\n animation: cui-overlay-fade 0.15s ease-out;\n}\n\n.center {\n align-items: center;\n justify-content: center;\n padding: var(--cui-space-4);\n}\n\n.right {\n justify-content: flex-end;\n}\n.left {\n justify-content: flex-start;\n}\n\n.panel {\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n max-width: 100%;\n max-height: 100%;\n background-color: var(--cui-color-surface);\n color: var(--cui-color-text);\n box-shadow: var(--cui-shadow-lg);\n outline: none;\n}\n\n.center .panel {\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-xl);\n animation: cui-overlay-pop 0.18s ease-out;\n}\n\n.right .panel {\n height: 100%;\n border-inline-start: 1px solid var(--cui-color-border);\n animation: cui-overlay-slide-right 0.2s ease-out;\n}\n.left .panel {\n height: 100%;\n border-inline-end: 1px solid var(--cui-color-border);\n animation: cui-overlay-slide-left 0.2s ease-out;\n}\n\n@keyframes cui-overlay-fade {\n from {\n opacity: 0;\n }\n}\n@keyframes cui-overlay-pop {\n from {\n opacity: 0;\n transform: translateY(-12px) scale(0.97);\n }\n}\n@keyframes cui-overlay-slide-right {\n from {\n transform: translateX(100%);\n }\n}\n@keyframes cui-overlay-slide-left {\n from {\n transform: translateX(-100%);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .backdrop,\n .panel {\n animation: none;\n }\n}\n","import {\n useEffect,\n useId,\n useRef,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { cn } from '../../utils/cn';\nimport { useOptionalTheme } from '../../theme';\nimport styles from './Overlay.module.css';\n\nexport interface OverlayProps {\n open: boolean;\n onClose: () => void;\n /** Where the panel sits: centered (modal) or sliding in from a side (drawer). */\n placement: 'center' | 'right' | 'left';\n /** Width class of the panel, set by the caller's own CSS module. */\n panelClassName?: string;\n closeOnBackdrop?: boolean;\n closeOnEscape?: boolean;\n role?: 'dialog' | 'alertdialog';\n 'aria-label'?: string;\n /** Called with the ids to use for `aria-labelledby` / `aria-describedby`. */\n children: (ids: { titleId: string; descriptionId: string }) => ReactNode;\n className?: string;\n}\n\nconst FOCUSABLE =\n 'a[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n// Several overlays can be open at once; the page scrolls again only when the last one closes.\nlet lockCount = 0;\nlet previousOverflow = '';\nfunction lockScroll() {\n if (lockCount === 0) {\n previousOverflow = document.body.style.overflow;\n document.body.style.overflow = 'hidden';\n }\n lockCount += 1;\n}\nfunction unlockScroll() {\n lockCount = Math.max(0, lockCount - 1);\n if (lockCount === 0) document.body.style.overflow = previousOverflow;\n}\n\n/**\n * Shared base for Modal and Drawer: a backdrop and panel rendered in <body> that keeps the surrounding\n * theme, locks page scroll, traps focus, closes on Escape or a backdrop click, and gives focus back to\n * whatever had it before. Put `data-autofocus` on an element to focus it first; otherwise the panel gets focus.\n */\nexport function Overlay({\n open,\n onClose,\n placement,\n panelClassName,\n closeOnBackdrop = true,\n closeOnEscape = true,\n role = 'dialog',\n 'aria-label': ariaLabel,\n children,\n className,\n}: OverlayProps) {\n const baseId = useId();\n const titleId = `${baseId}-title`;\n const descriptionId = `${baseId}-description`;\n const panelRef = useRef<HTMLDivElement>(null);\n const pressedOnBackdrop = useRef(false);\n const theme = useOptionalTheme();\n\n useEffect(() => {\n if (!open) return;\n const previous = document.activeElement as HTMLElement | null;\n lockScroll();\n const panel = panelRef.current;\n (panel?.querySelector<HTMLElement>('[data-autofocus]') ?? panel)?.focus({\n preventScroll: true,\n });\n return () => {\n unlockScroll();\n previous?.focus?.({ preventScroll: true });\n };\n }, [open]);\n\n if (!open) return null;\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Escape' && closeOnEscape) {\n event.preventDefault();\n event.stopPropagation();\n onClose();\n return;\n }\n if (event.key !== 'Tab') return;\n const nodes = Array.from(panelRef.current?.querySelectorAll<HTMLElement>(FOCUSABLE) ?? []);\n const first = nodes[0];\n const last = nodes[nodes.length - 1];\n if (!first || !last) {\n event.preventDefault();\n return;\n }\n const active = document.activeElement;\n if (event.shiftKey && (active === first || active === panelRef.current)) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && active === last) {\n event.preventDefault();\n first.focus();\n }\n };\n\n // Only a press that starts on the backdrop closes it, so dragging a text selection out of the panel does not.\n const handleBackdropMouseDown = (event: MouseEvent<HTMLDivElement>) => {\n pressedOnBackdrop.current = event.target === event.currentTarget;\n };\n const handleBackdropClick = (event: MouseEvent<HTMLDivElement>) => {\n if (closeOnBackdrop && pressedOnBackdrop.current && event.target === event.currentTarget)\n onClose();\n pressedOnBackdrop.current = false;\n };\n\n return createPortal(\n <div\n className={cn(styles.backdrop, styles[placement])}\n data-theme={theme?.resolvedTheme}\n onMouseDown={handleBackdropMouseDown}\n onClick={handleBackdropClick}\n >\n <div\n ref={panelRef}\n role={role}\n aria-modal=\"true\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabel ? undefined : titleId}\n aria-describedby={descriptionId}\n tabIndex={-1}\n className={cn(styles.panel, panelClassName, className)}\n onKeyDown={handleKeyDown}\n >\n {children({ titleId, descriptionId })}\n </div>\n </div>,\n document.body,\n );\n}\n",".header {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n gap: var(--cui-space-4);\n padding: var(--cui-space-5) var(--cui-space-6) var(--cui-space-3);\n}\n\n.heading {\n min-width: 0;\n}\n\n.title {\n margin: 0;\n font-size: var(--cui-font-size-lg);\n font-weight: var(--cui-font-weight-semibold);\n line-height: 1.35;\n}\n\n.description {\n margin: var(--cui-space-1) 0 0;\n font-size: var(--cui-font-size-sm);\n color: var(--cui-color-text-muted);\n}\n\n.close {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n width: 2.25rem;\n height: 2.25rem;\n margin-inline-start: auto;\n padding: 0;\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-full);\n color: #94a3b8;\n cursor: pointer;\n transition:\n background-color var(--cui-transition-fast),\n color var(--cui-transition-fast),\n transform var(--cui-transition-fast);\n}\n.close:hover {\n background-color: #f1f5f9;\n color: #334155;\n}\n:global([data-theme='dark']) .close:hover {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text);\n}\n.close:active {\n transform: scale(0.95);\n}\n.close:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n}\n.close svg {\n width: 1.25rem;\n height: 1.25rem;\n}\n\n.body {\n flex: 1;\n min-height: 0;\n padding: var(--cui-space-2) var(--cui-space-6) var(--cui-space-5);\n overflow-y: auto;\n font-size: var(--cui-font-size-sm);\n line-height: var(--cui-line-height);\n}\n\n.footer {\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: var(--cui-space-2);\n padding: var(--cui-space-4) var(--cui-space-6);\n border-top: 1px solid var(--cui-color-border);\n}\n","import type { ReactNode } from 'react';\nimport styles from './OverlayContent.module.css';\n\nexport interface OverlayContentProps {\n titleId: string;\n descriptionId: string;\n title?: ReactNode;\n description?: ReactNode;\n footer?: ReactNode;\n hideCloseButton?: boolean;\n closeLabel?: string;\n onClose: () => void;\n children?: ReactNode;\n}\n\n/** Header (title, description, close button), scrolling body and footer shared by Modal and Drawer. */\nexport function OverlayContent({\n titleId,\n descriptionId,\n title,\n description,\n footer,\n hideCloseButton,\n closeLabel = 'Close',\n onClose,\n children,\n}: OverlayContentProps) {\n const hasHeader = Boolean(title || description || !hideCloseButton);\n return (\n <>\n {hasHeader ? (\n <header className={styles.header}>\n <div className={styles.heading}>\n {title ? (\n <h2 id={titleId} className={styles.title}>\n {title}\n </h2>\n ) : null}\n {description ? (\n <p id={descriptionId} className={styles.description}>\n {description}\n </p>\n ) : null}\n </div>\n {hideCloseButton ? null : (\n <button\n type=\"button\"\n className={styles.close}\n aria-label={closeLabel}\n onClick={onClose}\n >\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.2\"\n strokeLinecap=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M18 6 6 18M6 6l12 12\" />\n </svg>\n </button>\n )}\n </header>\n ) : null}\n <div className={styles.body}>{children}</div>\n {footer ? <footer className={styles.footer}>{footer}</footer> : null}\n </>\n );\n}\n",".panel {\n width: 100%;\n}\n\n.sm {\n max-width: 24rem;\n}\n.md {\n max-width: 32rem;\n}\n.lg {\n max-width: 42rem;\n}\n.xl {\n max-width: 56rem;\n}\n.full {\n max-width: none;\n width: calc(100vw - 2rem);\n height: calc(100vh - 2rem);\n}\n\n/* No padding or header of its own: the content brings them. */\n.bare {\n overflow: hidden;\n}\n","import { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { Overlay } from '../Overlay/Overlay';\nimport { OverlayContent } from '../Overlay/OverlayContent';\nimport type { ModalProps } from './Modal.types';\nimport styles from './Modal.module.css';\n\n/**\n * Dialog in the middle of the screen. Traps focus, locks page scroll, closes on Escape / backdrop /\n * the close button, and returns focus to what opened it. Put `data-autofocus` on an element to focus it first.\n */\nexport function Modal({\n open,\n onClose,\n title,\n description,\n children,\n footer,\n size = 'md',\n closeOnBackdrop,\n closeOnEscape,\n hideCloseButton,\n bare = false,\n role,\n 'aria-label': ariaLabel,\n className,\n}: ModalProps) {\n const licensed = useLicensed();\n if (!licensed) return open ? <UnlicensedNotice /> : null;\n\n return (\n <Overlay\n open={open}\n onClose={onClose}\n placement=\"center\"\n panelClassName={cn(styles.panel, styles[size], bare && styles.bare)}\n className={className}\n closeOnBackdrop={closeOnBackdrop}\n closeOnEscape={closeOnEscape}\n role={role}\n aria-label={ariaLabel}\n >\n {({ titleId, descriptionId }) =>\n bare ? (\n typeof children === 'function' ? (\n children({ titleId, descriptionId, onClose })\n ) : (\n children\n )\n ) : (\n <OverlayContent\n titleId={titleId}\n descriptionId={descriptionId}\n title={title}\n description={description}\n footer={footer}\n hideCloseButton={hideCloseButton}\n onClose={onClose}\n >\n {typeof children === 'function' ? null : children}\n </OverlayContent>\n )\n }\n </Overlay>\n );\n}\n",".panel {\n width: 100%;\n}\n\n.sm {\n max-width: 20rem;\n}\n.md {\n max-width: 28rem;\n}\n.lg {\n max-width: 40rem;\n}\n","import { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { Overlay } from '../Overlay/Overlay';\nimport { OverlayContent } from '../Overlay/OverlayContent';\nimport type { DrawerProps } from './Drawer.types';\nimport styles from './Drawer.module.css';\n\n/** Panel that slides in from the side, for forms and filters. Behaves like `Modal`. */\nexport function Drawer({\n open,\n onClose,\n title,\n description,\n children,\n footer,\n placement = 'right',\n size = 'md',\n closeOnBackdrop,\n closeOnEscape,\n hideCloseButton,\n role,\n 'aria-label': ariaLabel,\n className,\n}: DrawerProps) {\n const licensed = useLicensed();\n if (!licensed) return open ? <UnlicensedNotice /> : null;\n\n return (\n <Overlay\n open={open}\n onClose={onClose}\n placement={placement}\n panelClassName={cn(styles.panel, styles[size])}\n className={className}\n closeOnBackdrop={closeOnBackdrop}\n closeOnEscape={closeOnEscape}\n role={role}\n aria-label={ariaLabel}\n >\n {({ titleId, descriptionId }) => (\n <OverlayContent\n titleId={titleId}\n descriptionId={descriptionId}\n title={title}\n description={description}\n footer={footer}\n hideCloseButton={hideCloseButton}\n onClose={onClose}\n >\n {children}\n </OverlayContent>\n )}\n </Overlay>\n );\n}\n",".confirmText {\n padding-top: var(--cui-space-2);\n}\n","import { useState } from 'react';\nimport { Button } from '../Button';\nimport { Input } from '../Input';\nimport { Modal } from '../Modal';\nimport type { ConfirmDialogProps } from './ConfirmDialog.types';\nimport styles from './ConfirmDialog.module.css';\n\n/** \"Are you sure?\" dialog with Cancel and Confirm, a danger tone and an optional type-to-confirm field. */\nexport function ConfirmDialog({\n open,\n onClose,\n onConfirm,\n title,\n message,\n confirmLabel = 'Confirm',\n cancelLabel = 'Cancel',\n tone = 'default',\n loading = false,\n requireText,\n}: ConfirmDialogProps) {\n const [typed, setTyped] = useState('');\n const confirmed = requireText === undefined || typed === requireText;\n const danger = tone === 'danger';\n\n return (\n <Modal\n open={open}\n onClose={() => {\n if (loading) return;\n setTyped('');\n onClose();\n }}\n role=\"alertdialog\"\n size=\"sm\"\n title={title}\n description={message}\n closeOnBackdrop={!loading}\n closeOnEscape={!loading}\n hideCloseButton\n footer={\n <>\n <Button\n variant=\"outline\"\n disabled={loading}\n // For destructive actions the safe choice gets the focus.\n data-autofocus={danger ? '' : undefined}\n onClick={() => {\n setTyped('');\n onClose();\n }}\n >\n {cancelLabel}\n </Button>\n <Button\n variant={danger ? 'danger' : 'primary'}\n loading={loading}\n disabled={!confirmed}\n data-autofocus={danger ? undefined : ''}\n onClick={onConfirm}\n >\n {confirmLabel}\n </Button>\n </>\n }\n >\n {requireText !== undefined ? (\n <div className={styles.confirmText}>\n <Input\n label={`Type ${requireText} to confirm`}\n value={typed}\n disabled={loading}\n autoComplete=\"off\"\n placeholder={requireText}\n onChange={(event) => setTyped(event.target.value)}\n />\n </div>\n ) : null}\n </Modal>\n );\n}\n",".control {\n position: relative;\n display: flex;\n align-items: center;\n width: 100%;\n color: var(--cui-color-text);\n}\n\n.trigger {\n appearance: none;\n display: flex;\n align-items: center;\n box-sizing: border-box;\n width: 100%;\n padding: 0 var(--cui-space-10) 0 var(--cui-space-4);\n background-color: var(--cui-color-surface);\n border: var(--cui-control-border-width) solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n color: inherit;\n font-family: var(--cui-font-family);\n font-size: inherit;\n text-align: start;\n cursor: pointer;\n transition:\n border-color var(--cui-transition-fast),\n box-shadow var(--cui-transition-fast);\n}\n\n.trigger:hover:not(:disabled) {\n border-color: var(--cui-color-border-hover);\n}\n\n.trigger:focus-visible,\n.open .trigger {\n border-color: var(--cui-color-border-focus);\n outline: none;\n box-shadow: var(--cui-focus-ring);\n}\n\n.value {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.placeholder .value {\n color: var(--cui-color-placeholder);\n}\n\n.sm {\n font-size: var(--cui-font-size-sm);\n}\n.sm .trigger {\n height: var(--cui-control-height-sm);\n}\n.md {\n font-size: var(--cui-font-size-sm);\n}\n.md .trigger {\n height: var(--cui-control-height-md);\n}\n.lg {\n font-size: var(--cui-font-size-lg);\n}\n.lg .trigger {\n height: var(--cui-control-height-lg);\n}\n\n.chevron {\n position: absolute;\n inset-inline-end: var(--cui-space-3);\n width: 1.25rem;\n height: 1.25rem;\n color: var(--cui-color-text-muted);\n pointer-events: none;\n transition: transform 0.2s ease;\n}\n.open .chevron {\n transform: rotate(180deg);\n}\n\n.clear {\n position: absolute;\n inset-inline-end: calc(var(--cui-space-3) + 1.5rem);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 1.25rem;\n height: 1.25rem;\n padding: 0;\n border: 0;\n border-radius: var(--cui-radius-full);\n background: transparent;\n color: var(--cui-color-text-muted);\n cursor: pointer;\n}\n.clear:hover {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text);\n}\n.clear:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n}\n.clear svg {\n width: 0.875rem;\n height: 0.875rem;\n}\n\n.invalid .trigger {\n border-color: var(--cui-color-danger-border);\n}\n.invalid .trigger:hover:not(:disabled) {\n border-color: var(--cui-color-danger-border-hover);\n}\n.invalid .trigger:focus-visible,\n.invalid.open .trigger {\n border-color: var(--cui-color-danger-border-hover);\n box-shadow: var(--cui-focus-ring-danger);\n}\n\n.disabled {\n color: var(--cui-color-text-disabled);\n}\n.disabled .trigger {\n background-color: var(--cui-color-surface-secondary);\n cursor: not-allowed;\n}\n.disabled .chevron {\n color: var(--cui-color-text-disabled);\n}\n\n/* Popover (rendered in a portal, inside the nearest [data-theme] element) */\n.popover {\n position: fixed;\n z-index: var(--cui-z-popover);\n box-sizing: border-box;\n overflow: hidden;\n background-color: var(--cui-color-surface);\n color: var(--cui-color-text);\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n box-shadow: var(--cui-shadow-lg);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-sm);\n line-height: var(--cui-line-height);\n animation: cui-select-in 0.15s ease-out;\n}\n\n@keyframes cui-select-in {\n from {\n opacity: 0;\n transform: translateY(-8px) scale(0.98);\n }\n}\n\n.top {\n animation-name: cui-select-in-top;\n}\n\n@keyframes cui-select-in-top {\n from {\n opacity: 0;\n transform: translateY(8px) scale(0.98);\n }\n}\n\n.searchWrap {\n padding: var(--cui-space-2);\n border-bottom: 1px solid var(--cui-color-border);\n background-color: var(--cui-color-surface-secondary);\n}\n\n.search {\n box-sizing: border-box;\n width: 100%;\n height: var(--cui-control-height-sm);\n padding: 0 var(--cui-space-3);\n background-color: var(--cui-color-surface);\n border: var(--cui-control-border-width) solid var(--cui-color-border);\n border-radius: var(--cui-radius-md);\n color: inherit;\n font: inherit;\n outline: none;\n}\n.search::placeholder {\n color: var(--cui-color-placeholder);\n}\n.search:focus {\n border-color: var(--cui-color-border-focus);\n box-shadow: var(--cui-focus-ring);\n}\n\n.list {\n margin: 0;\n padding: var(--cui-space-2);\n max-height: 15rem;\n overflow-y: auto;\n list-style: none;\n outline: none;\n}\n\n.option {\n display: flex;\n align-items: center;\n justify-content: space-between;\n margin-bottom: 2px;\n padding: var(--cui-space-2) var(--cui-space-3);\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text-secondary);\n cursor: pointer;\n user-select: none;\n}\n\n.optionLabel {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.selected {\n background-color: var(--cui-color-primary-subtle);\n color: var(--cui-color-primary);\n font-weight: var(--cui-font-weight-semibold);\n}\n\n.highlighted {\n background-color: var(--cui-color-primary);\n color: var(--cui-color-on-primary);\n}\n\n.optionDisabled {\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n\n.check {\n flex-shrink: 0;\n width: 1rem;\n height: 1rem;\n margin-inline-start: var(--cui-space-2);\n}\n\n.empty {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: var(--cui-space-4);\n color: var(--cui-color-text-muted);\n}\n\n.spinner {\n width: 1.25rem;\n height: 1.25rem;\n box-sizing: border-box;\n border: 2px solid currentColor;\n border-inline-end-color: transparent;\n border-radius: var(--cui-radius-full);\n animation: cui-select-spin 0.7s linear infinite;\n}\n\n@keyframes cui-select-spin {\n to {\n transform: rotate(360deg);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .popover,\n .chevron {\n animation: none;\n transition: none;\n }\n .spinner {\n animation-duration: 2s;\n }\n}\n","import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type KeyboardEvent,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { cn } from '../../utils/cn';\nimport { useFormFieldControl } from '../FormField';\nimport type { SelectControlProps, SelectOption } from './Select.types';\nimport styles from './Select.module.css';\n\nconst MENU_GAP = 4;\nconst MENU_ESTIMATED_HEIGHT = 280;\nconst SEARCH_DEBOUNCE_MS = 500;\n\ninterface MenuPosition {\n style: CSSProperties;\n placement: 'top' | 'bottom';\n}\n\nconst toArray = (value: string | string[] | undefined): string[] =>\n Array.isArray(value) ? value : value ? [value] : [];\n\nexport const SelectControl = forwardRef<HTMLButtonElement, SelectControlProps>(\n function SelectControl(\n {\n options,\n placeholder = 'Select an option',\n size = 'md',\n multiple = false,\n clearable = true,\n onSearch,\n loading = false,\n emptyMessage = 'No options found.',\n listClassName,\n name,\n value,\n defaultValue,\n onChange,\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n className,\n onKeyDown,\n onClick,\n ...rest\n },\n ref,\n ) {\n const control = useFormFieldControl({\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n });\n\n const baseId = useId();\n const listId = `${baseId}-list`;\n const valueId = `${baseId}-value`;\n const optionId = (index: number) => `${baseId}-option-${index}`;\n\n const containerRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n const popoverRef = useRef<HTMLDivElement>(null);\n const listRef = useRef<HTMLUListElement>(null);\n const searchRef = useRef<HTMLInputElement>(null);\n\n const [open, setOpen] = useState(false);\n const [position, setPosition] = useState<MenuPosition | null>(null);\n const [search, setSearch] = useState('');\n // The search box stays hidden until the user starts typing.\n const [showSearch, setShowSearch] = useState(false);\n const [highlighted, setHighlighted] = useState(0);\n\n const isControlled = value !== undefined;\n const [internal, setInternal] = useState<string[]>(() => toArray(defaultValue));\n const selected = isControlled ? toArray(value) : internal;\n\n const setTriggerRef = useCallback(\n (node: HTMLButtonElement | null) => {\n triggerRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n },\n [ref],\n );\n\n const filtered = useMemo(() => {\n if (onSearch || !search) return options;\n const query = search.toLowerCase();\n return options.filter((option) => option.label.toLowerCase().includes(query));\n }, [options, search, onSearch]);\n\n const commit = (next: string[]) => {\n if (!isControlled) setInternal(next);\n onChange?.(multiple ? next : (next[0] ?? ''));\n };\n\n const firstEnabled = (list: SelectOption[]) => {\n const index = list.findIndex((option) => !option.disabled);\n return index === -1 ? 0 : index;\n };\n\n const updatePosition = useCallback(() => {\n const container = containerRef.current;\n if (!container) return;\n const rect = container.getBoundingClientRect();\n const spaceBelow = window.innerHeight - rect.bottom;\n const placement =\n spaceBelow < MENU_ESTIMATED_HEIGHT && rect.top > spaceBelow ? 'top' : 'bottom';\n const style: CSSProperties = { left: rect.left, width: rect.width };\n if (placement === 'bottom') style.top = rect.bottom + MENU_GAP;\n else style.bottom = window.innerHeight - rect.top + MENU_GAP;\n setPosition({ style, placement });\n }, []);\n\n const openMenu = () => {\n if (control.disabled) return;\n updatePosition();\n setSearch('');\n setShowSearch(false);\n const firstSelected = options.findIndex((o) => selected.includes(o.value));\n setHighlighted(firstSelected === -1 ? firstEnabled(options) : firstSelected);\n setOpen(true);\n };\n\n const closeMenu = (restoreFocus = true) => {\n setOpen(false);\n if (restoreFocus) triggerRef.current?.focus({ preventScroll: true });\n };\n\n const selectOption = (option: SelectOption) => {\n if (option.disabled) return;\n if (multiple) {\n commit(\n selected.includes(option.value)\n ? selected.filter((v) => v !== option.value)\n : [...selected, option.value],\n );\n } else {\n commit([option.value]);\n closeMenu();\n }\n setSearch('');\n setShowSearch(false);\n };\n\n const moveHighlight = (direction: 1 | -1) => {\n if (!filtered.length) return;\n let next = highlighted;\n for (let step = 0; step < filtered.length; step++) {\n next = (next + direction + filtered.length) % filtered.length;\n if (!filtered[next]?.disabled) break;\n }\n setHighlighted(next);\n };\n\n // Move focus into the list on open so arrow keys work immediately.\n useEffect(() => {\n if (open) listRef.current?.focus({ preventScroll: true });\n }, [open]);\n\n useEffect(() => {\n if (showSearch) searchRef.current?.focus({ preventScroll: true });\n }, [showSearch]);\n\n // Debounced server-side search.\n const onSearchRef = useRef(onSearch);\n useEffect(() => {\n onSearchRef.current = onSearch;\n }, [onSearch]);\n useEffect(() => {\n if (!open || !onSearchRef.current) return;\n const timer = setTimeout(() => onSearchRef.current?.(search), SEARCH_DEBOUNCE_MS);\n return () => clearTimeout(timer);\n }, [search, open]);\n\n // Keep the menu attached to the trigger.\n useEffect(() => {\n if (!open) return;\n const reposition = () => requestAnimationFrame(updatePosition);\n window.addEventListener('scroll', reposition, true);\n window.addEventListener('resize', reposition);\n return () => {\n window.removeEventListener('scroll', reposition, true);\n window.removeEventListener('resize', reposition);\n };\n }, [open, updatePosition]);\n\n // Close on outside press (capture, so ancestors that stop propagation can't block it).\n useEffect(() => {\n if (!open) return;\n const handler = (event: MouseEvent) => {\n const target = event.target as Node;\n if (!containerRef.current?.contains(target) && !popoverRef.current?.contains(target)) {\n setOpen(false);\n }\n };\n document.addEventListener('mousedown', handler, true);\n return () => document.removeEventListener('mousedown', handler, true);\n }, [open]);\n\n // Scroll the highlighted option into view without scrolling the page.\n useEffect(() => {\n if (!open) return;\n const list = listRef.current;\n const el = list?.children[highlighted] as HTMLElement | undefined;\n if (!list || !el) return;\n if (el.offsetTop < list.scrollTop) list.scrollTop = el.offsetTop;\n else if (el.offsetTop + el.offsetHeight > list.scrollTop + list.clientHeight)\n list.scrollTop = el.offsetTop + el.offsetHeight - list.clientHeight;\n }, [highlighted, open]);\n\n const handleTriggerKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n if (!open && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {\n event.preventDefault();\n openMenu();\n }\n };\n\n const handleMenuKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n switch (event.key) {\n case 'Escape':\n event.preventDefault();\n event.stopPropagation();\n closeMenu();\n return;\n case 'ArrowDown':\n event.preventDefault();\n moveHighlight(1);\n return;\n case 'ArrowUp':\n event.preventDefault();\n moveHighlight(-1);\n return;\n case 'Home':\n if (showSearch) return;\n event.preventDefault();\n setHighlighted(firstEnabled(filtered));\n return;\n case 'End':\n if (showSearch) return;\n event.preventDefault();\n setHighlighted(Math.max(filtered.length - 1, 0));\n return;\n case 'Enter':\n // Never submit a surrounding form from inside the menu.\n event.preventDefault();\n event.stopPropagation();\n if (filtered[highlighted]) selectOption(filtered[highlighted]);\n return;\n case 'Tab':\n // Hand focus back to the trigger so Tab continues from there.\n setOpen(false);\n triggerRef.current?.focus({ preventScroll: true });\n return;\n case ' ':\n if (showSearch) return;\n event.preventDefault();\n if (filtered[highlighted]) selectOption(filtered[highlighted]);\n return;\n default:\n break;\n }\n // The first printable key reveals the search box and seeds it.\n const isPrintable =\n event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey;\n if (!showSearch && isPrintable) {\n event.preventDefault();\n setSearch(event.key);\n setHighlighted(0);\n setShowSearch(true);\n }\n };\n\n const selectedOptions = options.filter((option) => selected.includes(option.value));\n const hasValue = selected.length > 0;\n const displayText =\n selected.length > 1\n ? `${selected.length} selected`\n : (selectedOptions[0]?.label ?? placeholder);\n const showClear = clearable && hasValue && !control.disabled;\n\n // Render in <body> so no ancestor (transform, overflow, filter) can detach or clip the\n // fixed-position menu; re-apply the active theme on the menu itself.\n const themeName = open\n ? containerRef.current?.closest('[data-theme]')?.getAttribute('data-theme')\n : undefined;\n const activeDescendant = open && filtered[highlighted] ? optionId(highlighted) : undefined;\n const labelledBy = control.labelId ? `${control.labelId} ${valueId}` : undefined;\n\n return (\n <div\n ref={containerRef}\n className={cn(\n styles.control,\n styles[size],\n control.invalid && styles.invalid,\n control.disabled && styles.disabled,\n open && styles.open,\n className,\n )}\n >\n <button\n {...rest}\n ref={setTriggerRef}\n id={control.id}\n type=\"button\"\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-controls={open ? listId : undefined}\n aria-labelledby={labelledBy}\n aria-invalid={control['aria-invalid']}\n aria-describedby={control['aria-describedby']}\n aria-required={control.required || undefined}\n disabled={control.disabled}\n className={cn(styles.trigger, !selectedOptions.length && styles.placeholder)}\n onClick={(event) => {\n onClick?.(event);\n if (event.defaultPrevented) return;\n if (open) closeMenu(false);\n else openMenu();\n }}\n onKeyDown={handleTriggerKeyDown}\n >\n <span id={valueId} className={styles.value}>\n {displayText}\n </span>\n </button>\n\n {showClear ? (\n <button\n type=\"button\"\n className={styles.clear}\n aria-label=\"Clear selection\"\n onClick={() => {\n commit([]);\n triggerRef.current?.focus({ preventScroll: true });\n }}\n >\n <svg viewBox=\"0 0 20 20\" aria-hidden=\"true\" focusable=\"false\">\n <path\n d=\"M6 6l8 8M14 6l-8 8\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n />\n </svg>\n </button>\n ) : null}\n\n <svg className={styles.chevron} viewBox=\"0 0 20 20\" aria-hidden=\"true\" focusable=\"false\">\n <path\n d=\"M5 7.5l5 5 5-5\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n\n {name\n ? selected.length > 0\n ? selected.map((v) => <input key={v} type=\"hidden\" name={name} value={v} />)\n : !multiple && <input type=\"hidden\" name={name} value=\"\" />\n : null}\n\n {open && position\n ? createPortal(\n <div\n ref={popoverRef}\n className={cn(styles.popover, styles[position.placement])}\n style={position.style}\n data-theme={themeName ?? undefined}\n onKeyDown={handleMenuKeyDown}\n >\n {showSearch ? (\n <div className={styles.searchWrap}>\n <input\n ref={searchRef}\n type=\"text\"\n className={styles.search}\n placeholder=\"Search options...\"\n aria-label=\"Search options\"\n aria-controls={listId}\n aria-activedescendant={activeDescendant}\n autoComplete=\"off\"\n value={search}\n onChange={(event) => {\n const next = event.target.value;\n setSearch(next);\n setHighlighted(0);\n if (next === '') {\n setShowSearch(false);\n listRef.current?.focus({ preventScroll: true });\n }\n }}\n />\n </div>\n ) : null}\n <ul\n ref={listRef}\n id={listId}\n role=\"listbox\"\n tabIndex={-1}\n aria-labelledby={labelledBy}\n aria-multiselectable={multiple || undefined}\n aria-activedescendant={showSearch ? undefined : activeDescendant}\n className={cn(styles.list, listClassName)}\n >\n {filtered.length > 0 ? (\n filtered.map((option, index) => {\n const isSelected = selected.includes(option.value);\n return (\n <li\n key={option.value}\n id={optionId(index)}\n role=\"option\"\n aria-selected={isSelected}\n aria-disabled={option.disabled || undefined}\n className={cn(\n styles.option,\n isSelected && styles.selected,\n index === highlighted && styles.highlighted,\n option.disabled && styles.optionDisabled,\n )}\n onMouseEnter={() => !option.disabled && setHighlighted(index)}\n onClick={() => selectOption(option)}\n >\n <span className={styles.optionLabel}>{option.label}</span>\n {isSelected ? (\n <svg\n className={styles.check}\n viewBox=\"0 0 20 20\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path\n d=\"M4.5 10.5l3.5 3.5 7.5-8\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n ) : null}\n </li>\n );\n })\n ) : (\n <li className={styles.empty} role=\"presentation\">\n {loading ? (\n <span className={styles.spinner} role=\"status\" aria-label=\"Loading\" />\n ) : (\n emptyMessage\n )}\n </li>\n )}\n </ul>\n </div>,\n document.body,\n )\n : null}\n </div>\n );\n },\n);\n","import { forwardRef } from 'react';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { FormField } from '../FormField';\nimport { SelectControl } from './SelectControl';\nimport type { SelectControlProps, SelectProps } from './Select.types';\n\n/**\n * Select with a popover list, type-to-search, optional multi-select, a clear\n * button and server-side search. Controlled (`value`) or uncontrolled\n * (`defaultValue`). The ref points at the trigger button.\n */\nexport const Select = forwardRef<HTMLButtonElement, SelectProps>(function Select(\n { label, helperText, ...props },\n ref,\n) {\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n // The single/multiple union is resolved inside SelectControl via `multiple`.\n const controlProps = props as SelectControlProps;\n\n // Without its own label/helper/error, Select defers to an enclosing <FormField>.\n if (!label && !helperText && !props.error) {\n return <SelectControl {...controlProps} ref={ref} />;\n }\n\n return (\n <FormField\n id={props.id}\n label={label}\n helperText={helperText}\n error={props.error}\n required={props.required}\n disabled={props.disabled}\n >\n <SelectControl {...controlProps} ref={ref} />\n </FormField>\n );\n});\n","export type PageItem = number | 'ellipsis-start' | 'ellipsis-end';\n\n/**\n * Which page buttons to show: the first and last `boundaryCount` pages, `siblingCount` pages either side of\n * the current one, and an ellipsis wherever pages are skipped. A gap of a single page is shown as that page\n * instead of an ellipsis, so the list never hides just one number.\n */\nexport function getPageItems(\n page: number,\n pageCount: number,\n siblingCount = 1,\n boundaryCount = 1,\n): PageItem[] {\n const total = Math.max(0, Math.floor(pageCount));\n if (total === 0) return [];\n const current = Math.min(Math.max(1, Math.floor(page)), total);\n\n const range = (from: number, to: number) =>\n Array.from({ length: Math.max(0, to - from + 1) }, (_, i) => from + i);\n\n const startPages = range(1, Math.min(boundaryCount, total));\n const endPages = range(Math.max(total - boundaryCount + 1, boundaryCount + 1), total);\n\n const siblingsStart = Math.max(\n Math.min(current - siblingCount, total - boundaryCount - siblingCount * 2 - 1),\n boundaryCount + 2,\n );\n const siblingsEnd = Math.min(\n Math.max(current + siblingCount, boundaryCount + siblingCount * 2 + 2),\n endPages.length > 0 ? (endPages[0] as number) - 2 : total - 1,\n );\n\n const items: PageItem[] = [...startPages];\n\n if (siblingsStart > boundaryCount + 2) items.push('ellipsis-start');\n else if (boundaryCount + 1 < total - boundaryCount) items.push(boundaryCount + 1);\n\n items.push(...range(siblingsStart, siblingsEnd));\n\n if (siblingsEnd < total - boundaryCount - 1) items.push('ellipsis-end');\n else if (total - boundaryCount > boundaryCount) items.push(total - boundaryCount);\n\n items.push(...endPages);\n\n // Drop duplicates the boundary arithmetic can produce on short lists, keeping order.\n return items.filter((item, index) => typeof item !== 'number' || items.indexOf(item) === index);\n}\n",".root {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: var(--cui-space-3) var(--cui-space-4);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-sm);\n color: var(--cui-color-text-secondary);\n}\n\n.info {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--cui-space-4);\n}\n\n.summary {\n color: var(--cui-color-text-muted);\n}\n\n.pageSize {\n display: flex;\n align-items: center;\n gap: var(--cui-space-2);\n}\n.pageSize > :last-child {\n width: 5rem;\n}\n\n.pages {\n display: flex;\n align-items: center;\n gap: var(--cui-space-1);\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n min-width: 2rem;\n height: 2rem;\n padding: 0 var(--cui-space-2);\n background-color: var(--cui-color-surface);\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-md);\n color: var(--cui-color-text-secondary);\n font: inherit;\n font-weight: var(--cui-font-weight-medium);\n cursor: pointer;\n transition:\n background-color var(--cui-transition-fast),\n border-color var(--cui-transition-fast),\n color var(--cui-transition-fast);\n}\n.button svg {\n width: 1rem;\n height: 1rem;\n}\n.button:hover:not(:disabled):not(.current) {\n background-color: var(--cui-color-surface-secondary);\n}\n.button:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 1px;\n}\n.button:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n\n.current {\n background-color: var(--cui-color-primary-subtle);\n border-color: color-mix(in srgb, var(--cui-color-primary) 40%, transparent);\n color: var(--cui-color-primary);\n font-weight: var(--cui-font-weight-semibold);\n cursor: default;\n}\n\n.ellipsis {\n min-width: 1.5rem;\n text-align: center;\n color: var(--cui-color-text-muted);\n}\n\n/* ---------- layout=\"split\" ---------- */\n.split {\n display: grid;\n grid-template-columns: 1fr auto 1fr;\n align-items: center;\n}\n.splitLeft {\n display: flex;\n justify-content: flex-start;\n}\n.splitCenter {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.splitRight {\n display: flex;\n justify-content: flex-end;\n}\n.split .summary,\n.split .pageSize {\n font-weight: var(--cui-font-weight-medium);\n color: var(--cui-color-text-muted);\n}\n\n.joined {\n gap: 0;\n}\n.joined li + li {\n margin-inline-start: -1px;\n}\n.joined .button {\n border-radius: 0;\n}\n.joined li:first-child .button {\n border-start-start-radius: var(--cui-radius-md);\n border-end-start-radius: var(--cui-radius-md);\n}\n.joined li:last-child .button {\n border-start-end-radius: var(--cui-radius-md);\n border-end-end-radius: var(--cui-radius-md);\n}\n.joined .current {\n position: relative;\n z-index: 1;\n}\n\n.pageOf {\n display: none;\n margin-inline: var(--cui-space-3);\n font-weight: var(--cui-font-weight-semibold);\n color: var(--cui-color-text-secondary);\n white-space: nowrap;\n}\n.pageOf strong {\n color: var(--cui-color-primary);\n}\n\n@media (max-width: 767px) {\n .split {\n grid-template-columns: 1fr auto;\n grid-template-areas:\n 'right left'\n 'center center';\n gap: var(--cui-space-3);\n }\n .splitLeft {\n grid-area: left;\n }\n .splitRight {\n grid-area: right;\n justify-content: flex-start;\n }\n .splitCenter {\n grid-area: center;\n justify-content: space-between;\n }\n .splitCenter .pages {\n display: contents;\n }\n /* On small screens: first, previous, \"Page x of y\", next, last. Numbers are hidden. */\n .split .pageNumber,\n .split .ellipsis {\n display: none;\n }\n .first {\n order: 1;\n }\n .prev {\n order: 2;\n }\n .pageOf {\n display: inline;\n order: 3;\n }\n .next {\n order: 4;\n }\n .last {\n order: 5;\n }\n}\n","import { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { Select } from '../Select';\nimport { getPageItems } from './paginationUtils';\nimport type { PaginationProps } from './Pagination.types';\nimport styles from './Pagination.module.css';\n\nconst icon = (path: string) => (\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d={path} />\n </svg>\n);\n\n/**\n * Page navigation: previous / next, numbered pages with ellipses, optional first / last, a\n * \"Showing 1-10 of 120\" summary and a rows-per-page select. Pages start at 1.\n */\nexport function Pagination({\n page,\n pageCount,\n onPageChange,\n siblingCount = 1,\n boundaryCount = 1,\n showFirstLast: showFirstLastProp = false,\n layout = 'default',\n pageSize,\n totalItems,\n pageSizeOptions,\n onPageSizeChange,\n disabled = false,\n 'aria-label': ariaLabel = 'Pagination',\n className,\n ...rest\n}: PaginationProps) {\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n const last = Math.max(1, pageCount);\n const current = Math.min(Math.max(1, page), last);\n const items = getPageItems(current, last, siblingCount, boundaryCount);\n const go = (next: number) => {\n if (!disabled && next >= 1 && next <= last && next !== current) onPageChange(next);\n };\n\n const split = layout === 'split';\n const showFirstLast = showFirstLastProp || split;\n const showSummary = pageSize !== undefined && totalItems !== undefined;\n const from = totalItems === 0 || !pageSize ? 0 : (current - 1) * pageSize + 1;\n const to = pageSize && totalItems !== undefined ? Math.min(current * pageSize, totalItems) : 0;\n const showPageSize = pageSizeOptions && pageSizeOptions.length > 0 && onPageSizeChange;\n\n const summaryNode = showSummary ? (\n <span className={styles.summary}>\n {split\n ? `Showing ${from}-${to} of ${totalItems} Rows`\n : `Showing ${from}-${to} of ${totalItems}`}\n </span>\n ) : null;\n\n const pageSizeNode = showPageSize ? (\n <div className={styles.pageSize}>\n <span aria-hidden=\"true\">{split ? 'Row Per Page' : 'Rows per page'}</span>\n <Select\n aria-label=\"Rows per page\"\n size=\"sm\"\n clearable={false}\n disabled={disabled}\n value={String(pageSize ?? pageSizeOptions[0])}\n options={pageSizeOptions.map((option) => ({\n label: String(option),\n value: String(option),\n }))}\n onChange={(value) => onPageSizeChange(Number(value))}\n />\n </div>\n ) : null;\n\n const pagesNode = (\n <>\n <ul className={cn(styles.pages, split && styles.joined)}>\n {showFirstLast ? (\n <li className={styles.first}>\n <button\n type=\"button\"\n className={styles.button}\n aria-label=\"First page\"\n disabled={disabled || current === 1}\n onClick={() => go(1)}\n >\n {icon('M11 5l-5 5 5 5M15 5v10')}\n </button>\n </li>\n ) : null}\n <li className={styles.prev}>\n <button\n type=\"button\"\n className={styles.button}\n aria-label=\"Previous page\"\n disabled={disabled || current === 1}\n onClick={() => go(current - 1)}\n >\n {icon('M12 5l-5 5 5 5')}\n </button>\n </li>\n {items.map((item) =>\n typeof item === 'number' ? (\n <li key={item} className={styles.pageNumber}>\n <button\n type=\"button\"\n className={cn(styles.button, item === current && styles.current)}\n aria-label={`Page ${item}`}\n aria-current={item === current ? 'page' : undefined}\n disabled={disabled}\n onClick={() => go(item)}\n >\n {item}\n </button>\n </li>\n ) : (\n <li key={item} className={cn(styles.ellipsis, styles.pageNumber)} aria-hidden=\"true\">\n …\n </li>\n ),\n )}\n <li className={styles.next}>\n <button\n type=\"button\"\n className={styles.button}\n aria-label=\"Next page\"\n disabled={disabled || current === last}\n onClick={() => go(current + 1)}\n >\n {icon('M8 5l5 5-5 5')}\n </button>\n </li>\n {showFirstLast ? (\n <li className={styles.last}>\n <button\n type=\"button\"\n className={styles.button}\n aria-label=\"Last page\"\n disabled={disabled || current === last}\n onClick={() => go(last)}\n >\n {icon('M9 5l5 5-5 5M5 5v10')}\n </button>\n </li>\n ) : null}\n </ul>\n {split ? (\n <span className={styles.pageOf} aria-hidden=\"true\">\n Page <strong>{current}</strong> of {last}\n </span>\n ) : null}\n </>\n );\n\n if (split) {\n return (\n <nav {...rest} aria-label={ariaLabel} className={cn(styles.root, styles.split, className)}>\n <div className={styles.splitLeft}>{pageSizeNode}</div>\n <div className={styles.splitCenter}>{pagesNode}</div>\n <div className={styles.splitRight}>{summaryNode}</div>\n </nav>\n );\n }\n\n return (\n <nav {...rest} aria-label={ariaLabel} className={cn(styles.root, className)}>\n <div className={styles.info}>\n {summaryNode}\n {pageSizeNode}\n </div>\n {pagesNode}\n </nav>\n );\n}\n",".container {\n position: relative;\n width: 100%;\n overflow: auto;\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-xl);\n background-color: var(--cui-color-surface);\n}\n.container:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: -2px;\n}\n\n.table {\n --table-px: var(--cui-space-6);\n width: 100%;\n border-collapse: separate;\n border-spacing: 0;\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-sm);\n line-height: var(--cui-line-height);\n color: var(--cui-color-text);\n}\n\n.caption {\n padding: var(--cui-space-3) var(--cui-space-4);\n text-align: start;\n caption-side: top;\n font-size: var(--cui-font-size-sm);\n color: var(--cui-color-text-muted);\n}\n\n/* Header: same values as the school app's DataTableHeader (Tailwind gray-50 / gray-500 / gray-100, shadow-sm). */\n.head {\n --head-bg: #f9fafb;\n --head-fg: #6b7280;\n --head-fg-hover: #374151;\n --head-border: #f3f4f6;\n --head-icon: #9ca3af;\n background-color: var(--head-bg);\n box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);\n white-space: nowrap;\n}\n:global([data-theme='dark']) .head {\n --head-bg: #374151;\n --head-fg: #9ca3af;\n --head-fg-hover: #e5e7eb;\n --head-border: #374151;\n --head-icon: #9ca3af;\n}\n\n/* Sorted column: label in the primary colour. The whole header cell is the click target. */\n.th.sorted {\n color: var(--cui-color-primary);\n}\n.th.sortable {\n padding: 0;\n}\n.sortable .sortButton {\n width: 100%;\n padding: 0.75rem var(--table-px);\n}\n.center .sortButton {\n justify-content: center;\n}\n.end .sortButton {\n justify-content: flex-end;\n}\n\n.sticky .head th {\n position: sticky;\n top: 0;\n z-index: 20;\n background-color: var(--head-bg);\n}\n\n.th {\n padding: 0.75rem var(--table-px);\n border-bottom: 1px solid var(--head-border);\n font-size: 0.75rem;\n line-height: 1rem;\n font-family: var(--cui-font-family);\n font-weight: 400; /* the app maps Tailwind's font-medium to 400 with Poppins */\n letter-spacing: 0.05em;\n text-transform: uppercase;\n color: var(--head-fg);\n white-space: nowrap;\n}\n\n.td {\n padding: var(--cui-space-3) var(--table-px);\n border-bottom: 1px solid var(--cui-color-border);\n vertical-align: middle;\n}\n\n.start {\n text-align: start;\n}\n.center {\n text-align: center;\n}\n.end {\n text-align: end;\n}\n\n.table tbody tr:last-child .td {\n border-bottom: 0;\n}\n\n.foot .td {\n background-color: var(--cui-color-surface-secondary);\n border-top: 1px solid var(--cui-color-border);\n font-weight: var(--cui-font-weight-medium);\n}\n\n.table tbody .row:hover {\n background-color: var(--cui-color-surface-secondary);\n}\n\n.row.selected,\n.table tbody .row.selected:hover {\n background-color: var(--cui-color-primary-subtle);\n}\n\n.clickable {\n cursor: pointer;\n}\n\n.sortButton {\n display: inline-flex;\n align-items: center;\n gap: 0.375rem;\n padding: 0;\n background: transparent;\n border: 0;\n color: inherit;\n font: inherit;\n letter-spacing: inherit;\n text-transform: inherit;\n cursor: pointer;\n}\n.sortButton:hover {\n color: var(--head-fg-hover);\n}\n.th.sorted .sortButton:hover {\n color: var(--cui-color-primary);\n}\n.sortButton:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 2px;\n border-radius: var(--cui-radius-sm);\n}\n\n.sortIcon {\n width: 0.875rem;\n height: 0.875rem;\n color: var(--head-icon);\n}\n.sortActive {\n width: 0.875rem;\n height: 0.875rem;\n flex-shrink: 0;\n color: var(--cui-color-primary);\n}\n\n/* Idle sort arrows only appear when the header is hovered or focused. */\n.sortIdle {\n opacity: 0;\n transition: opacity var(--cui-transition-fast);\n}\n.sortButton:hover .sortIdle,\n.sortButton:focus-visible .sortIdle {\n opacity: 1;\n}\n\n.flush {\n border: 0;\n border-radius: 0;\n background-color: transparent;\n}\n","import { forwardRef, type HTMLAttributes } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport type {\n TableCaptionProps,\n TableCellProps,\n TableHeaderCellProps,\n TableProps,\n TableRowProps,\n} from './Table.types';\nimport styles from './Table.module.css';\n\n/**\n * Styled semantic table. Compose it with `TableHead`, `TableBody`, `TableRow`, `TableHeaderCell`\n * and `TableCell`. For sorting, filtering, paging and selection use `DataTable`.\n */\nexport const Table = forwardRef<HTMLTableElement, TableProps>(function Table(\n { stickyHeader = false, bordered = true, containerClassName, scrollLabel, className, ...rest },\n ref,\n) {\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n return (\n <div\n className={cn(styles.container, !bordered && styles.flush, containerClassName)}\n // A scroll area must be reachable by keyboard so wide tables can be scrolled.\n tabIndex={0}\n role=\"region\"\n aria-label={scrollLabel}\n >\n <table\n {...rest}\n ref={ref}\n className={cn(styles.table, stickyHeader && styles.sticky, className)}\n />\n </div>\n );\n});\n\nexport const TableHead = forwardRef<\n HTMLTableSectionElement,\n HTMLAttributes<HTMLTableSectionElement>\n>(function TableHead({ className, ...rest }, ref) {\n return <thead {...rest} ref={ref} className={cn(styles.head, className)} />;\n});\n\nexport const TableBody = forwardRef<\n HTMLTableSectionElement,\n HTMLAttributes<HTMLTableSectionElement>\n>(function TableBody({ className, ...rest }, ref) {\n return <tbody {...rest} ref={ref} className={className} />;\n});\n\nexport const TableFoot = forwardRef<\n HTMLTableSectionElement,\n HTMLAttributes<HTMLTableSectionElement>\n>(function TableFoot({ className, ...rest }, ref) {\n return <tfoot {...rest} ref={ref} className={cn(styles.foot, className)} />;\n});\n\nexport const TableRow = forwardRef<HTMLTableRowElement, TableRowProps>(function TableRow(\n { selected = false, className, ...rest },\n ref,\n) {\n return (\n <tr\n {...rest}\n ref={ref}\n data-selected={selected || undefined}\n className={cn(\n styles.row,\n selected && styles.selected,\n rest.onClick && styles.clickable,\n className,\n )}\n />\n );\n});\n\nexport const TableHeaderCell = forwardRef<HTMLTableCellElement, TableHeaderCellProps>(\n function TableHeaderCell(\n {\n align = 'start',\n sortable = false,\n sortDirection = null,\n onSort,\n className,\n children,\n scope = 'col',\n ...rest\n },\n ref,\n ) {\n const ariaSort = !sortable\n ? undefined\n : sortDirection === 'asc'\n ? 'ascending'\n : sortDirection === 'desc'\n ? 'descending'\n : 'none';\n return (\n <th\n {...rest}\n ref={ref}\n scope={scope}\n aria-sort={ariaSort}\n className={cn(\n styles.th,\n styles[align],\n sortable && styles.sortable,\n sortable && sortDirection && styles.sorted,\n className,\n )}\n >\n {sortable ? (\n <button type=\"button\" className={styles.sortButton} onClick={onSort}>\n {children}\n <svg\n className={cn(styles.sortIcon, sortDirection ? styles.sortActive : styles.sortIdle)}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={sortDirection ? 3 : 2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n {sortDirection === 'asc' ? (\n <>\n <path d=\"m5 12 7-7 7 7\" />\n <path d=\"M12 19V5\" />\n </>\n ) : sortDirection === 'desc' ? (\n <>\n <path d=\"M12 5v14\" />\n <path d=\"m19 12-7 7-7-7\" />\n </>\n ) : (\n <>\n <path d=\"m21 16-4 4-4-4\" />\n <path d=\"M17 20V4\" />\n <path d=\"m3 8 4-4 4 4\" />\n <path d=\"M7 4v16\" />\n </>\n )}\n </svg>\n </button>\n ) : (\n children\n )}\n </th>\n );\n },\n);\n\nexport const TableCell = forwardRef<HTMLTableCellElement, TableCellProps>(function TableCell(\n { align = 'start', className, ...rest },\n ref,\n) {\n return <td {...rest} ref={ref} className={cn(styles.td, styles[align], className)} />;\n});\n\nexport const TableCaption = forwardRef<HTMLTableCaptionElement, TableCaptionProps>(\n function TableCaption({ className, ...rest }, ref) {\n return <caption {...rest} ref={ref} className={cn(styles.caption, className)} />;\n },\n);\n",".root {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: var(--cui-space-3);\n padding: var(--cui-space-4) 1.25rem;\n border-bottom: 1px solid var(--cui-color-border);\n font-family: var(--cui-font-family);\n}\n\n.main {\n display: flex;\n flex: 1;\n align-items: center;\n gap: var(--cui-space-3);\n min-width: 0;\n}\n\n/* Same circular button as the close button of Modal and Drawer. */\n.back {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n width: 2.25rem;\n height: 2.25rem;\n padding: 0;\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-full);\n color: #94a3b8;\n cursor: pointer;\n transition:\n background-color var(--cui-transition-fast),\n color var(--cui-transition-fast),\n transform var(--cui-transition-fast);\n}\n.back:hover {\n background-color: #f1f5f9;\n color: #334155;\n}\n:global([data-theme='dark']) .back:hover {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text);\n}\n.back:active {\n transform: scale(0.95);\n}\n.back:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n}\n.back svg {\n width: 1.25rem;\n height: 1.25rem;\n}\n\n.heading {\n min-width: 0;\n}\n\n.title {\n margin: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: 1.25rem;\n font-weight: var(--cui-font-weight-bold);\n line-height: 1.25;\n letter-spacing: -0.01em;\n color: var(--cui-color-text);\n}\n\n.subtitle {\n margin: 2px 0 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: var(--cui-font-size-sm);\n color: var(--cui-color-text-muted);\n}\n\n.actions {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--cui-space-2);\n}\n","import type { HTMLAttributes, ReactNode } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport styles from './PageHeader.module.css';\n\nexport interface PageHeaderProps extends Omit<HTMLAttributes<HTMLElement>, 'title'> {\n title: ReactNode;\n subtitle?: ReactNode;\n /** Shows the circular back button; it calls `onBack`. */\n onBack?: () => void;\n backLabel?: string;\n /** Buttons and other controls on the right. */\n actions?: ReactNode;\n}\n\n/** Page title bar like the school app's: optional circular back button, title, subtitle and actions. */\nexport function PageHeader({\n title,\n subtitle,\n onBack,\n backLabel = 'Go back',\n actions,\n className,\n ...rest\n}: PageHeaderProps) {\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n return (\n <header {...rest} className={cn(styles.root, className)}>\n <div className={styles.main}>\n {onBack ? (\n <button type=\"button\" className={styles.back} aria-label={backLabel} onClick={onBack}>\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"m12 19-7-7 7-7M19 12H5\" />\n </svg>\n </button>\n ) : null}\n <div className={styles.heading}>\n <h1 className={styles.title}>{title}</h1>\n {subtitle ? <p className={styles.subtitle}>{subtitle}</p> : null}\n </div>\n </div>\n {actions ? <div className={styles.actions}>{actions}</div> : null}\n </header>\n );\n}\n",".pill {\n display: inline-flex;\n align-items: center;\n gap: 0.375rem;\n padding: 0.125rem 0.625rem;\n border: 1px solid transparent;\n border-radius: var(--cui-radius-full);\n font-size: var(--cui-font-size-xs);\n font-weight: var(--cui-font-weight-medium);\n line-height: 1.25rem;\n white-space: nowrap;\n}\n\n.label {\n text-transform: capitalize;\n}\n\n.dot {\n width: 0.375rem;\n height: 0.375rem;\n border-radius: var(--cui-radius-full);\n background-color: currentColor;\n}\n\n.pulse {\n animation: cui-status-pulse 2s ease-in-out infinite;\n}\n\n@keyframes cui-status-pulse {\n 50% {\n opacity: 0.4;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .pulse {\n animation: none;\n }\n}\n\n.success {\n color: var(--cui-color-success);\n background-color: color-mix(in srgb, var(--cui-color-success) 10%, transparent);\n border-color: color-mix(in srgb, var(--cui-color-success) 25%, transparent);\n}\n.info {\n color: var(--cui-color-info);\n background-color: color-mix(in srgb, var(--cui-color-info) 10%, transparent);\n border-color: color-mix(in srgb, var(--cui-color-info) 25%, transparent);\n}\n.danger {\n color: var(--cui-color-danger);\n background-color: color-mix(in srgb, var(--cui-color-danger) 10%, transparent);\n border-color: color-mix(in srgb, var(--cui-color-danger) 25%, transparent);\n}\n.warning {\n color: var(--cui-color-warning);\n background-color: color-mix(in srgb, var(--cui-color-warning) 12%, transparent);\n border-color: color-mix(in srgb, var(--cui-color-warning) 30%, transparent);\n}\n.neutral {\n color: var(--cui-color-text-secondary);\n background-color: var(--cui-color-surface-muted, transparent);\n border-color: var(--cui-color-border);\n}\n\n.empty {\n color: var(--cui-color-text-muted);\n}\n","import type { HTMLAttributes } from 'react';\nimport { cn } from '../../utils/cn';\nimport styles from './StatusPill.module.css';\n\nexport type StatusPillTone = 'success' | 'info' | 'danger' | 'warning' | 'neutral';\n\nexport interface StatusPillProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'children'> {\n /** Status text, e.g. \"Active\". Shown capitalized; empty shows an em dash. */\n status?: string | null;\n /** Override the colour that is otherwise chosen from the status text. */\n tone?: StatusPillTone;\n}\n\nconst TONES: Record<string, StatusPillTone> = {\n active: 'success',\n completed: 'info',\n expired: 'danger',\n cancelled: 'danger',\n canceled: 'danger',\n pending: 'warning',\n};\n\n/** Small status badge with a dot, like the status column of the school app's tables. */\nexport function StatusPill({ status, tone, className, ...rest }: StatusPillProps) {\n if (!status) return <span className={styles.empty}>—</span>;\n const key = status.trim().toLowerCase();\n const resolved = tone ?? TONES[key] ?? 'neutral';\n const pulse = resolved === 'success' || key === 'completed';\n return (\n <span className={cn(styles.pill, styles[resolved], className)} {...rest}>\n <span className={cn(styles.dot, pulse && styles.pulse)} aria-hidden=\"true\" />\n <span className={styles.label}>{status}</span>\n </span>\n );\n}\n",".root {\n display: flex;\n flex-direction: column;\n gap: var(--cui-space-1);\n}\n\n.label {\n position: relative;\n display: inline-flex;\n align-items: flex-start;\n gap: var(--cui-space-3);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-sm);\n line-height: var(--cui-line-height);\n color: var(--cui-color-text);\n cursor: pointer;\n}\n\n.disabled {\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n\n/* The real input sits on top of the box so it stays focusable and clickable. */\n.input {\n position: absolute;\n top: 0;\n left: 0;\n width: 1.25rem;\n height: 1.25rem;\n margin: 0;\n opacity: 0;\n cursor: inherit;\n}\n\n.box {\n position: relative;\n display: inline-flex;\n flex-shrink: 0;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n width: 1.25rem;\n height: 1.25rem;\n background-color: var(--cui-color-surface);\n border: var(--cui-control-border-width) solid var(--cui-color-border-hover);\n border-radius: var(--cui-radius-sm);\n color: var(--cui-color-on-primary);\n transition:\n background-color var(--cui-transition-fast),\n border-color var(--cui-transition-fast),\n box-shadow var(--cui-transition-fast);\n}\n\n.check,\n.dash {\n position: absolute;\n inset: 0;\n margin: auto;\n width: 0.875rem;\n height: 0.875rem;\n opacity: 0;\n transform: scale(0.5);\n transition:\n opacity var(--cui-transition-fast),\n transform var(--cui-transition-fast);\n}\n\n.label:hover .input:not(:disabled) + .box {\n border-color: var(--cui-color-primary);\n}\n\n.input:checked + .box,\n.input:indeterminate + .box {\n background-color: var(--cui-color-primary);\n border-color: var(--cui-color-primary);\n}\n\n.input:checked + .box .check,\n.input:indeterminate + .box .dash {\n opacity: 1;\n transform: scale(1);\n}\n\n.input:indeterminate + .box .check {\n opacity: 0;\n}\n\n.input:focus-visible + .box {\n box-shadow: var(--cui-focus-ring);\n}\n\n.input.invalid + .box {\n border-color: var(--cui-color-danger-border);\n}\n.input.invalid:checked + .box {\n background-color: var(--cui-color-danger);\n border-color: var(--cui-color-danger);\n color: var(--cui-color-on-danger);\n}\n.input.invalid:focus-visible + .box {\n box-shadow: var(--cui-focus-ring-danger);\n}\n\n.input:disabled + .box {\n background-color: var(--cui-color-surface-secondary);\n border-color: var(--cui-color-border);\n color: var(--cui-color-text-disabled);\n}\n.input:disabled:checked + .box,\n.input:disabled:indeterminate + .box {\n background-color: var(--cui-color-text-disabled);\n border-color: var(--cui-color-text-disabled);\n color: var(--cui-color-surface);\n}\n\n.text {\n padding-top: 1px;\n}\n\n.required {\n margin-inline-start: var(--cui-space-1);\n color: var(--cui-color-danger);\n}\n\n.message {\n margin: 0;\n padding-inline-start: calc(1.25rem + var(--cui-space-3));\n font-size: var(--cui-font-size-sm);\n}\n.helper {\n color: var(--cui-color-text-muted);\n}\n.error {\n color: var(--cui-color-danger);\n}\n\n@media (prefers-reduced-motion: reduce) {\n .box,\n .check,\n .dash {\n transition: none;\n }\n}\n","import { forwardRef, useCallback, useEffect, useRef } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { useFormFieldControl } from '../FormField';\nimport type { CheckboxProps } from './Checkbox.types';\nimport styles from './Checkbox.module.css';\n\n/** Native checkbox with a themed box, optional label, helper text and error. */\nexport const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(function Checkbox(\n {\n label,\n helperText,\n error,\n indeterminate = false,\n id,\n required,\n disabled,\n 'aria-describedby': ariaDescribedBy,\n className,\n ...rest\n },\n ref,\n) {\n const innerRef = useRef<HTMLInputElement | null>(null);\n const setRef = useCallback(\n (node: HTMLInputElement | null) => {\n innerRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n },\n [ref],\n );\n\n useEffect(() => {\n if (innerRef.current) innerRef.current.indeterminate = indeterminate;\n }, [indeterminate]);\n\n const control = useFormFieldControl({\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n });\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n const messageId = `${control.id}-message`;\n const hasMessage = Boolean(error || helperText);\n const describedBy =\n [control['aria-describedby'], hasMessage ? messageId : undefined].filter(Boolean).join(' ') ||\n undefined;\n\n return (\n <div className={cn(styles.root, className)}>\n <label className={cn(styles.label, control.disabled && styles.disabled)}>\n <input\n {...rest}\n ref={setRef}\n id={control.id}\n type=\"checkbox\"\n required={control.required}\n disabled={control.disabled}\n aria-invalid={control['aria-invalid']}\n aria-describedby={describedBy}\n className={cn(styles.input, control.invalid && styles.invalid)}\n />\n <span className={styles.box} aria-hidden=\"true\">\n <svg className={styles.check} viewBox=\"0 0 20 20\" focusable=\"false\">\n <path\n d=\"M4.5 10.5l3.5 3.5 7.5-8\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n <svg className={styles.dash} viewBox=\"0 0 20 20\" focusable=\"false\">\n <path\n d=\"M5 10h10\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n />\n </svg>\n </span>\n {label ? (\n <span className={styles.text}>\n {label}\n {control.required ? (\n <span className={styles.required} aria-hidden=\"true\">\n *\n </span>\n ) : null}\n </span>\n ) : null}\n </label>\n {hasMessage ? (\n <p\n id={messageId}\n className={cn(styles.message, error ? styles.error : styles.helper)}\n role={error ? 'alert' : undefined}\n >\n {error || helperText}\n </p>\n ) : null}\n </div>\n );\n});\n",".root {\n display: inline-block;\n}\n\n.trigger {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n padding: var(--cui-space-2);\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text-secondary);\n cursor: pointer;\n transition:\n background-color var(--cui-transition-fast),\n color var(--cui-transition-fast);\n}\n.trigger svg {\n width: 1.25rem;\n height: 1.25rem;\n}\n.trigger:hover:not(:disabled) {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-primary);\n}\n.trigger:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 1px;\n}\n.trigger:disabled {\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n.open,\n.open:hover:not(:disabled) {\n background-color: var(--cui-color-primary-subtle);\n color: var(--cui-color-primary);\n}\n.custom {\n padding: var(--cui-space-1) var(--cui-space-3);\n font: inherit;\n font-size: var(--cui-font-size-sm);\n}\n\n.menu {\n position: fixed;\n z-index: var(--cui-z-popover);\n box-sizing: border-box;\n min-width: 12rem;\n width: max-content;\n max-width: 20rem;\n overflow: hidden;\n background-color: var(--cui-color-surface);\n color: var(--cui-color-text);\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-md);\n box-shadow: var(--cui-shadow-lg);\n font-family: var(--cui-font-family);\n animation: cui-dropdown-in 0.12s ease-out;\n}\n\n@keyframes cui-dropdown-in {\n from {\n opacity: 0;\n transform: translateY(-4px) scale(0.97);\n }\n}\n\n.item {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--cui-space-3);\n box-sizing: border-box;\n width: 100%;\n padding: var(--cui-space-3) var(--cui-space-4);\n background: transparent;\n border: 0;\n border-bottom: 1px solid var(--cui-color-border);\n color: var(--cui-color-text-secondary);\n font: inherit;\n font-size: var(--cui-font-size-sm);\n font-weight: var(--cui-font-weight-semibold);\n text-align: start;\n cursor: pointer;\n}\n.item:last-child {\n border-bottom: 0;\n}\n.item:hover:not([aria-disabled='true']),\n.item:focus-visible {\n background-color: var(--cui-color-surface-secondary);\n outline: none;\n}\n\n.danger {\n color: var(--cui-color-danger);\n}\n.danger:hover:not([aria-disabled='true']),\n.danger:focus-visible {\n background-color: color-mix(in srgb, var(--cui-color-danger) 10%, transparent);\n}\n\n.item[aria-disabled='true'] {\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n\n.label {\n white-space: nowrap;\n}\n\n.icon {\n display: inline-flex;\n flex-shrink: 0;\n width: 1.125rem;\n height: 1.125rem;\n}\n.icon > svg {\n width: 100%;\n height: 100%;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .menu {\n animation: none;\n }\n}\n","import {\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n type CSSProperties,\n type KeyboardEvent,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport type { DropdownMenuProps } from './DropdownMenu.types';\nimport styles from './DropdownMenu.module.css';\n\nconst MENU_GAP = 4;\nconst MENU_WIDTH = 192;\nconst MENU_ESTIMATED_HEIGHT = 200;\nconst ITEM = '[role=\"menuitem\"]:not([aria-disabled=\"true\"])';\n\n/**\n * A \"more actions\" button that opens a menu of actions. Arrow keys, Home and End move between items,\n * Enter or Space chooses one, Escape closes and returns focus to the button. The menu is rendered in\n * <body>, so tables and scroll areas can't clip it, and it keeps the surrounding theme.\n */\nexport function DropdownMenu({\n items,\n position = 'right',\n label = 'More actions',\n children,\n onOpenChange,\n disabled = false,\n className,\n}: DropdownMenuProps) {\n const licensed = useLicensed();\n const menuId = `${useId()}-menu`;\n const triggerRef = useRef<HTMLButtonElement>(null);\n const menuRef = useRef<HTMLDivElement>(null);\n const [open, setOpen] = useState(false);\n const [style, setStyle] = useState<CSSProperties | null>(null);\n const [themeName, setThemeName] = useState<string | undefined>();\n const [focusTick, setFocusTick] = useState(0);\n\n const computePosition = useCallback(() => {\n const trigger = triggerRef.current;\n if (!trigger) return;\n const rect = trigger.getBoundingClientRect();\n const spaceBelow = window.innerHeight - rect.bottom;\n const above = spaceBelow < MENU_ESTIMATED_HEIGHT && rect.top > spaceBelow;\n const next: CSSProperties = above\n ? { bottom: window.innerHeight - rect.top + MENU_GAP }\n : { top: rect.bottom + MENU_GAP };\n // `right`: the menu grows toward the right from the button's left edge, unless it would leave the screen.\n const fitsRight = rect.left + MENU_WIDTH <= window.innerWidth - 8;\n if (position === 'right' && fitsRight) next.left = rect.left;\n else next.right = Math.max(8, window.innerWidth - rect.right);\n setStyle(next);\n }, [position]);\n\n const setOpenState = (next: boolean) => {\n setOpen(next);\n onOpenChange?.(next);\n };\n\n const openMenu = () => {\n if (disabled) return;\n computePosition();\n setThemeName(\n triggerRef.current?.closest('[data-theme]')?.getAttribute('data-theme') ?? undefined,\n );\n setOpenState(true);\n };\n\n // `close` is used by render code, so it must not touch refs; focus returns through an effect.\n const close = (restoreFocus = true) => {\n setOpenState(false);\n if (restoreFocus) setFocusTick((tick) => tick + 1);\n };\n useEffect(() => {\n if (focusTick > 0) triggerRef.current?.focus({ preventScroll: true });\n }, [focusTick]);\n\n useEffect(() => {\n if (open) menuRef.current?.querySelector<HTMLElement>(ITEM)?.focus({ preventScroll: true });\n }, [open]);\n\n useEffect(() => {\n if (!open) return;\n const reposition = () => requestAnimationFrame(computePosition);\n const onPointerDown = (event: MouseEvent) => {\n const target = event.target as Node;\n if (!triggerRef.current?.contains(target) && !menuRef.current?.contains(target)) {\n setOpen(false);\n onOpenChange?.(false);\n }\n };\n window.addEventListener('scroll', reposition, true);\n window.addEventListener('resize', reposition);\n document.addEventListener('mousedown', onPointerDown, true);\n return () => {\n window.removeEventListener('scroll', reposition, true);\n window.removeEventListener('resize', reposition);\n document.removeEventListener('mousedown', onPointerDown, true);\n };\n }, [open, computePosition, onOpenChange]);\n\n if (!licensed) return <UnlicensedNotice />;\n\n const focusItem = (which: 'first' | 'last' | 1 | -1) => {\n const nodes = Array.from(menuRef.current?.querySelectorAll<HTMLElement>(ITEM) ?? []);\n if (nodes.length === 0) return;\n const current = nodes.indexOf(document.activeElement as HTMLElement);\n const next =\n which === 'first'\n ? 0\n : which === 'last'\n ? nodes.length - 1\n : (current + which + nodes.length) % nodes.length;\n nodes[next]?.focus({ preventScroll: true });\n };\n\n const handleMenuKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const actions: Record<string, () => void> = {\n ArrowDown: () => focusItem(1),\n ArrowUp: () => focusItem(-1),\n Home: () => focusItem('first'),\n End: () => focusItem('last'),\n Escape: () => close(),\n Tab: () => close(),\n };\n const action = actions[event.key];\n if (!action) return;\n if (event.key !== 'Tab') {\n event.preventDefault();\n event.stopPropagation();\n }\n action();\n };\n\n return (\n <span className={cn(styles.root, className)}>\n <button\n ref={triggerRef}\n type=\"button\"\n className={cn(styles.trigger, open && styles.open, children !== undefined && styles.custom)}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n aria-controls={open ? menuId : undefined}\n aria-label={label}\n title={label}\n disabled={disabled}\n onClick={() => (open ? close(false) : openMenu())}\n onKeyDown={(event) => {\n if (!open && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {\n event.preventDefault();\n openMenu();\n }\n }}\n >\n {children ?? (\n <svg viewBox=\"0 0 20 20\" fill=\"currentColor\" aria-hidden=\"true\" focusable=\"false\">\n <circle cx=\"10\" cy=\"4\" r=\"1.6\" />\n <circle cx=\"10\" cy=\"10\" r=\"1.6\" />\n <circle cx=\"10\" cy=\"16\" r=\"1.6\" />\n </svg>\n )}\n </button>\n\n {open && style\n ? createPortal(\n <div\n ref={menuRef}\n id={menuId}\n role=\"menu\"\n aria-label={label}\n className={styles.menu}\n style={style}\n data-theme={themeName}\n onKeyDown={handleMenuKeyDown}\n >\n {items.map((item, index) => (\n <button\n key={`${item.label}-${index}`}\n type=\"button\"\n role=\"menuitem\"\n tabIndex={-1}\n aria-disabled={item.disabled || undefined}\n className={cn(styles.item, item.variant === 'danger' && styles.danger)}\n onClick={() => {\n if (item.disabled) return;\n try {\n item.onClick();\n } finally {\n close();\n }\n }}\n >\n <span className={styles.label}>{item.label}</span>\n {item.icon ? (\n <span className={styles.icon} aria-hidden=\"true\">\n {item.icon}\n </span>\n ) : null}\n </button>\n ))}\n </div>,\n document.body,\n )\n : null}\n </span>\n );\n}\n",".root {\n display: block;\n background-color: var(--cui-color-surface-secondary);\n animation: cui-skeleton-pulse 1.5s ease-in-out infinite;\n}\n\n.rect {\n width: 100%;\n height: 1rem;\n border-radius: var(--cui-radius-md);\n}\n\n.text {\n width: 100%;\n height: 0.875rem;\n border-radius: var(--cui-radius-full);\n}\n\n.circle {\n width: 2.5rem;\n height: 2.5rem;\n border-radius: var(--cui-radius-full);\n}\n\n@keyframes cui-skeleton-pulse {\n 50% {\n opacity: 0.5;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .root {\n animation: none;\n }\n}\n","import { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport type { SkeletonProps } from './Skeleton.types';\nimport styles from './Skeleton.module.css';\n\n/** Pulsing placeholder shown while content loads. Hidden from assistive tech. */\nexport function Skeleton({\n variant = 'rect',\n width,\n height,\n className,\n style,\n ...rest\n}: SkeletonProps) {\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n // Dimensions are caller-supplied values, so they have to be inline styles.\n const size = { width, height: height ?? (variant === 'circle' ? width : undefined) };\n\n return (\n <span\n aria-hidden=\"true\"\n {...rest}\n className={cn(styles.root, styles[variant], className)}\n style={{ ...size, ...style }}\n />\n );\n}\n","/* The school app's look: fills its container, no outer border, pagination bar pinned to the bottom. */\n.root {\n display: flex;\n flex-direction: column;\n flex: 1;\n min-width: 0;\n min-height: 0;\n overflow: hidden;\n background-color: var(--cui-color-surface);\n}\n\n.toolbar {\n min-width: 0;\n padding: var(--cui-space-3);\n border-bottom: 1px solid var(--cui-color-border);\n background-color: var(--cui-color-surface);\n}\n@media (min-width: 768px) {\n .toolbar {\n padding: var(--cui-space-4);\n }\n}\n\n.tableArea {\n display: flex;\n flex-direction: column;\n flex: 1;\n min-height: 0;\n min-width: 0;\n overflow: hidden;\n}\n\n.scroll {\n flex: 1;\n min-height: 0;\n}\n\n.selectCell.selectCell {\n width: 1%;\n padding-inline: var(--cui-space-4);\n text-align: center;\n white-space: nowrap;\n}\n.selectCell > * {\n display: inline-flex;\n vertical-align: middle;\n}\n\n.actionsColumn {\n width: 1%;\n white-space: nowrap;\n}\n\n.actions {\n display: flex;\n justify-content: center;\n}\n\n.actionButton {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n padding: var(--cui-space-2);\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text-muted);\n cursor: pointer;\n transition:\n background-color var(--cui-transition-fast),\n color var(--cui-transition-fast),\n transform var(--cui-transition-fast);\n}\n.actionButton:hover {\n background-color: var(--cui-color-primary-subtle);\n color: var(--cui-color-primary);\n transform: scale(1.05);\n}\n.actionButton:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 1px;\n}\n.actionButton svg {\n width: 1.125rem;\n height: 1.125rem;\n}\n.actionDanger {\n color: var(--cui-color-danger);\n}\n.actionDanger:hover {\n background-color: color-mix(in srgb, var(--cui-color-danger) 10%, transparent);\n color: var(--cui-color-danger);\n}\n.actionText {\n font-size: var(--cui-font-size-xs);\n font-weight: var(--cui-font-weight-bold);\n}\n\n.cellText {\n font-size: 0.8125rem;\n font-weight: var(--cui-font-weight-medium);\n color: var(--cui-color-text-secondary);\n}\n\n.stateBox {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: var(--cui-space-3);\n}\n\n.empty {\n padding-block: var(--cui-space-12);\n text-align: center;\n color: var(--cui-color-text-muted);\n font-size: var(--cui-font-size-sm);\n}\n.emptyIcon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 3rem;\n height: 3rem;\n border-radius: var(--cui-radius-full);\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text-disabled);\n}\n.emptyIcon svg {\n width: 1.5rem;\n height: 1.5rem;\n}\n\n.errorCell {\n padding-block: var(--cui-space-12);\n text-align: center;\n background-color: color-mix(in srgb, var(--cui-color-danger) 6%, transparent);\n color: var(--cui-color-danger);\n}\n.errorIcon {\n display: inline-flex;\n}\n.errorIcon svg {\n width: 1.5rem;\n height: 1.5rem;\n}\n.errorText {\n font-weight: var(--cui-font-weight-medium);\n}\n\n.footer {\n min-width: 0;\n position: sticky;\n bottom: 0;\n z-index: 1;\n flex-shrink: 0;\n padding: var(--cui-space-3);\n background-color: var(--cui-color-surface);\n border-top: 1px solid var(--cui-color-border);\n box-shadow: 0 -2px 4px rgb(0 0 0 / 0.03);\n}\n@media (min-width: 768px) {\n .footer {\n padding: var(--cui-space-4);\n }\n}\n\n.srOnly {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n}\n\n/* Selection banner (shown while rows are selected). */\n.selectionBar {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--cui-space-2);\n padding: var(--cui-space-2) var(--cui-space-4);\n border-bottom: 1px solid color-mix(in srgb, var(--cui-color-primary) 20%, transparent);\n background-color: color-mix(in srgb, var(--cui-color-primary) 7%, transparent);\n font-size: var(--cui-font-size-sm);\n}\n\n.selectionCount {\n font-weight: var(--cui-font-weight-semibold);\n color: var(--cui-color-primary);\n}\n\n.selectionDivider {\n width: 1px;\n height: 1rem;\n margin: 0 var(--cui-space-1);\n background-color: var(--cui-color-border);\n}\n\n.bulkButton.bulkButton {\n height: 2rem;\n gap: var(--cui-space-1);\n padding: 0 var(--cui-space-3);\n font-size: var(--cui-font-size-xs);\n}\n.bulkButton svg {\n width: 0.875rem;\n height: 0.875rem;\n}\n.bulkDanger.bulkDanger {\n color: var(--cui-color-danger);\n}\n.bulkDanger.bulkDanger:hover:not(:disabled) {\n background-color: color-mix(in srgb, var(--cui-color-danger) 8%, transparent);\n border-color: color-mix(in srgb, var(--cui-color-danger) 40%, transparent);\n}\n\n.selectionClear {\n margin-inline-start: auto;\n padding: var(--cui-space-1) var(--cui-space-2);\n background: transparent;\n border: 0;\n color: var(--cui-color-primary);\n font: inherit;\n font-size: var(--cui-font-size-sm);\n text-decoration: underline;\n text-underline-offset: 3px;\n cursor: pointer;\n}\n.selectionClear:hover {\n opacity: 0.8;\n}\n.selectionClear:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 2px;\n}\n","import type { ReactNode } from 'react';\nimport { cn } from '../../utils/cn';\nimport { Button } from '../Button';\nimport styles from './DataTable.module.css';\n\nexport interface SelectionBarAction {\n label: string;\n icon?: ReactNode;\n onClick: () => void;\n disabled?: boolean;\n /** `danger` styles the button red. */\n variant?: 'default' | 'danger';\n}\n\nexport interface SelectionBarProps {\n /** Number of selected rows. Nothing is rendered for 0. */\n count: number;\n actions?: SelectionBarAction[];\n onClear: () => void;\n className?: string;\n}\n\n/** Banner shown above a table while rows are selected: \"N selected\", bulk actions and \"Clear selection\". */\nexport function SelectionBar({ count, actions = [], onClear, className }: SelectionBarProps) {\n if (count <= 0) return null;\n return (\n <div role=\"region\" aria-label=\"Selection\" className={cn(styles.selectionBar, className)}>\n <span className={styles.selectionCount} aria-live=\"polite\">\n {count} selected\n </span>\n {actions.length > 0 ? <span className={styles.selectionDivider} aria-hidden=\"true\" /> : null}\n {actions.map((action) => (\n <Button\n key={action.label}\n variant=\"outline\"\n size=\"sm\"\n className={cn(styles.bulkButton, action.variant === 'danger' && styles.bulkDanger)}\n disabled={action.disabled}\n onClick={action.onClick}\n >\n {action.icon}\n {action.label}\n </Button>\n ))}\n <button type=\"button\" className={styles.selectionClear} onClick={onClear}>\n Clear selection\n </button>\n </div>\n );\n}\n","import { DatePicker } from '../DatePicker';\nimport { Input } from '../Input';\nimport { Select } from '../Select';\nimport type { TableFilterField } from './TableFilters.types';\n\ninterface FilterValueControlProps {\n field: TableFilterField;\n value: string;\n onChange: (value: string) => void;\n /** Visible label above the control. Without it, `ariaLabel` names the control. */\n label?: string;\n ariaLabel?: string;\n size?: 'sm' | 'md';\n placeholder?: string;\n}\n\n/** The right input for a filter field: text, select or date. */\nexport function FilterValueControl({\n field,\n value,\n onChange,\n label,\n ariaLabel,\n size = 'md',\n placeholder,\n}: FilterValueControlProps) {\n const name = label ? { label } : { 'aria-label': ariaLabel ?? field.label };\n if (field.type === 'select') {\n return (\n <Select\n {...name}\n size={size}\n placeholder={placeholder ?? field.placeholder ?? `Any ${field.label.toLowerCase()}`}\n options={field.options ?? []}\n value={value}\n onChange={onChange}\n />\n );\n }\n if (field.type === 'date') {\n return (\n <DatePicker\n {...name}\n size={size}\n placeholder={placeholder ?? field.placeholder}\n value={value}\n onChange={onChange}\n />\n );\n }\n return (\n <Input\n {...name}\n size={size}\n placeholder={placeholder ?? field.placeholder}\n value={value}\n onChange={(event) => onChange(event.target.value)}\n />\n );\n}\n",".root {\n display: flex;\n flex-direction: column;\n gap: var(--cui-space-3);\n font-family: var(--cui-font-family);\n}\n\n.bar {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: var(--cui-space-3);\n}\n\n.barEnd {\n display: flex;\n align-items: center;\n gap: var(--cui-space-3);\n margin-inline-start: auto;\n}\n\n.search {\n flex: 1;\n min-width: 12rem;\n max-width: 24rem;\n}\n\n.actions {\n display: flex;\n align-items: center;\n gap: var(--cui-space-2);\n}\n\n.filtersIcon {\n width: 1rem;\n height: 1rem;\n}\n\n.panelFooter {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--cui-space-2);\n width: 100%;\n}\n\n.count {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 1rem;\n height: 1rem;\n padding: 0 var(--cui-space-1);\n border-radius: var(--cui-radius-full);\n background-color: var(--cui-color-primary);\n color: var(--cui-color-on-primary);\n font-size: 0.625rem;\n font-weight: var(--cui-font-weight-semibold);\n}\n\n.chips {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--cui-space-2);\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.chip {\n display: inline-flex;\n align-items: center;\n gap: 0.375rem;\n max-width: 100%;\n padding: var(--cui-space-1) var(--cui-space-1) var(--cui-space-1) 0.625rem;\n background-color: var(--cui-color-surface);\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-md);\n font-size: var(--cui-font-size-xs);\n}\n\n.chipLabel {\n color: var(--cui-color-text-muted);\n}\n\n.chipValue {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-weight: var(--cui-font-weight-medium);\n color: var(--cui-color-text);\n}\n\n.chipRemove {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n padding: 2px;\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-sm);\n color: var(--cui-color-text-disabled);\n cursor: pointer;\n}\n.chipRemove:hover {\n background-color: color-mix(in srgb, var(--cui-color-danger) 10%, transparent);\n color: var(--cui-color-danger);\n}\n.chipRemove:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n}\n.chipRemove svg {\n width: 0.75rem;\n height: 0.75rem;\n}\n\n.clearAll {\n display: inline-flex;\n align-items: center;\n gap: var(--cui-space-1);\n padding: var(--cui-space-1) 0.375rem;\n background: transparent;\n border: 0;\n color: var(--cui-color-text-muted);\n font: inherit;\n font-size: var(--cui-font-size-xs);\n font-weight: var(--cui-font-weight-medium);\n cursor: pointer;\n}\n.clearAll svg {\n width: 0.75rem;\n height: 0.75rem;\n}\n.clearAll:hover {\n color: var(--cui-color-danger);\n}\n.clearAll:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 2px;\n}\n\n/* Dynamic filter rows */\n.dynamic {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: var(--cui-space-4);\n}\n\n.noFilters {\n margin: 0;\n color: var(--cui-color-text-muted);\n font-size: var(--cui-font-size-sm);\n}\n\n.rows {\n display: flex;\n flex-direction: column;\n gap: var(--cui-space-3);\n width: 100%;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.row {\n display: grid;\n grid-template-columns: 1fr auto;\n grid-template-areas:\n 'field remove'\n 'value value';\n gap: var(--cui-space-2);\n padding: var(--cui-space-3);\n background-color: var(--cui-color-surface-secondary);\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n}\n\n.rowField {\n grid-area: field;\n min-width: 0;\n}\n.rowValue {\n grid-area: value;\n min-width: 0;\n}\n\n.rowRemove {\n grid-area: remove;\n align-self: center;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 2rem;\n height: 2rem;\n padding: 0;\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-md);\n color: var(--cui-color-text-muted);\n cursor: pointer;\n}\n.rowRemove:hover {\n background-color: color-mix(in srgb, var(--cui-color-danger) 10%, transparent);\n color: var(--cui-color-danger);\n}\n.rowRemove:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n}\n.rowRemove svg {\n width: 1rem;\n height: 1rem;\n}\n","import { Button } from '../Button';\nimport { Select } from '../Select';\nimport { FilterValueControl } from './FilterValueControl';\nimport type { TableFilterField } from './TableFilters.types';\nimport styles from './TableFilters.module.css';\n\nexport interface FilterRow {\n id: number;\n /** `key` of the chosen field, or '' while none is chosen. */\n key: string;\n value: string;\n}\n\nlet rowCounter = 0;\n/** A fresh, unique row id (only used as a React key). */\nexport const nextRowId = () => (rowCounter += 1);\n\n/** Turns the applied filter values into editable rows, one per active filter. */\nexport function rowsFromValues(values: Record<string, string>): FilterRow[] {\n return Object.entries(values).map(([key, value]) => ({ id: nextRowId(), key, value }));\n}\n\n/** The values the rows stand for: rows without a field or without a value filter nothing. */\nexport function valuesFromRows(rows: FilterRow[]): Record<string, string> {\n const values: Record<string, string> = {};\n for (const row of rows) {\n if (row.key && row.value.trim() !== '') values[row.key] = row.value;\n }\n return values;\n}\n\ninterface DynamicFilterRowsProps {\n fields: TableFilterField[];\n rows: FilterRow[];\n onChange: (rows: FilterRow[]) => void;\n}\n\n/**\n * The editable part of the filter panel: each row is a field choice plus a value, rows can be added and\n * removed, and a field can only be used once.\n */\nexport function DynamicFilterRows({ fields, rows, onChange }: DynamicFilterRowsProps) {\n const used = new Set(rows.map((row) => row.key).filter(Boolean));\n const available = fields.filter((field) => !used.has(field.key));\n\n const update = (id: number, patch: Partial<FilterRow>) =>\n onChange(rows.map((row) => (row.id === id ? { ...row, ...patch } : row)));\n\n const add = () => {\n const field = available[0];\n if (!field) return;\n onChange([...rows, { id: nextRowId(), key: field.key, value: '' }]);\n };\n\n return (\n <div className={styles.dynamic}>\n {rows.length === 0 ? (\n <p className={styles.noFilters}>No filters yet. Add one to narrow down the table.</p>\n ) : (\n <ul className={styles.rows}>\n {rows.map((row, index) => {\n const field = fields.find((f) => f.key === row.key);\n const choices = fields.filter((f) => f.key === row.key || !used.has(f.key));\n return (\n <li key={row.id} className={styles.row} aria-label={`Filter ${index + 1}`}>\n <div className={styles.rowField}>\n <Select\n aria-label={`Field for filter ${index + 1}`}\n size=\"sm\"\n clearable={false}\n value={row.key}\n options={choices.map((f) => ({ label: f.label, value: f.key }))}\n onChange={(next) => update(row.id, { key: next, value: '' })}\n />\n </div>\n <div className={styles.rowValue}>\n {field ? (\n <FilterValueControl\n key={field.key}\n field={field}\n value={row.value}\n size=\"sm\"\n ariaLabel={`Value for ${field.label}`}\n onChange={(next) => update(row.id, { value: next })}\n />\n ) : null}\n </div>\n <button\n type=\"button\"\n className={styles.rowRemove}\n aria-label={`Delete ${field?.label ?? 'empty'} filter`}\n onClick={() => onChange(rows.filter((r) => r.id !== row.id))}\n >\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M6 6l8 8M14 6l-8 8\" />\n </svg>\n </button>\n </li>\n );\n })}\n </ul>\n )}\n <Button variant=\"outline\" size=\"sm\" disabled={available.length === 0} onClick={add}>\n + Add filter\n </Button>\n </div>\n );\n}\n","import type { TableFilterField, TableFilterValues } from './TableFilters.types';\n\n/** Only the filters that actually filter something. */\nexport function activeFilters(values: TableFilterValues | undefined): TableFilterValues {\n return Object.fromEntries(\n Object.entries(values ?? {}).filter(([, value]) => value.trim() !== ''),\n );\n}\n\n/** Text to show for a filter's value: the option label for selects, the value itself otherwise. */\nexport function filterValueLabel(field: TableFilterField, value: string): string {\n if (field.type === 'select')\n return field.options?.find((option) => option.value === value)?.label ?? value;\n return value;\n}\n","import { useEffect, useRef, useState } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { Button } from '../Button';\nimport { Drawer } from '../Drawer';\nimport { SearchInput } from '../SearchInput';\nimport { DynamicFilterRows, rowsFromValues, valuesFromRows } from './DynamicFilterRows';\nimport type { FilterRow } from './DynamicFilterRows';\nimport { activeFilters, filterValueLabel } from './filterUtils';\nimport type { TableFilterField, TableFiltersProps, TableFilterValues } from './TableFilters.types';\nimport styles from './TableFilters.module.css';\n\n/** Mounted only while the panel is open, so its draft starts from the current values every time. */\nfunction FiltersPanel({\n fields,\n values,\n onApply,\n onClose,\n title,\n}: {\n fields: TableFilterField[];\n values: TableFilterValues;\n onApply: (values: TableFilterValues) => void;\n onClose: () => void;\n title: string;\n}) {\n const [rows, setRows] = useState<FilterRow[]>(() => rowsFromValues(values));\n\n return (\n <Drawer\n open\n onClose={onClose}\n title={title}\n description=\"Add the filters you want to use.\"\n size=\"sm\"\n footer={\n <div className={styles.panelFooter}>\n <Button variant=\"outline\" disabled={rows.length === 0} onClick={() => setRows([])}>\n Reset\n </Button>\n <Button\n onClick={() => {\n onApply(valuesFromRows(rows));\n onClose();\n }}\n >\n Apply Filters\n </Button>\n </div>\n }\n >\n <DynamicFilterRows fields={fields} rows={rows} onChange={setRows} />\n </Drawer>\n );\n}\n\n/**\n * Search box, a \"Filters\" button that opens a panel of fields (text, select, date) with Apply / Reset,\n * and removable chips for the active filters. State lives in your hands: pass values, react to changes.\n */\nexport function TableFilters({\n search = '',\n onSearchChange,\n searchPlaceholder = 'Search...',\n searchDelay = 0,\n fields,\n values,\n onValuesChange,\n panelTitle = 'Filters',\n className,\n}: TableFiltersProps) {\n const licensed = useLicensed();\n const [panelOpen, setPanelOpen] = useState(false);\n const [text, setText] = useState(search);\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n // Follow external changes to the search (e.g. a reset from outside).\n const lastExternal = useRef(search);\n if (lastExternal.current !== search) {\n lastExternal.current = search;\n if (search !== text) setText(search);\n }\n useEffect(() => () => clearTimeout(timer.current), []);\n\n if (!licensed) return <UnlicensedNotice />;\n\n const active = activeFilters(values);\n const activeFields = (fields ?? []).filter((field) => active[field.key] !== undefined);\n const hasFields = Boolean(fields && fields.length > 0 && onValuesChange);\n\n const handleSearch = (next: string) => {\n setText(next);\n clearTimeout(timer.current);\n if (searchDelay > 0) timer.current = setTimeout(() => onSearchChange?.(next), searchDelay);\n else onSearchChange?.(next);\n };\n\n return (\n <div className={cn(styles.root, className)}>\n <div className={styles.bar}>\n {onSearchChange ? (\n <div className={styles.search}>\n <SearchInput\n aria-label=\"Search\"\n placeholder={searchPlaceholder}\n value={text}\n onChange={(event) => handleSearch(event.target.value)}\n onClear={() => handleSearch('')}\n />\n </div>\n ) : null}\n <div className={styles.barEnd}>\n {hasFields ? (\n <Button\n variant=\"outline\"\n size=\"sm\"\n aria-haspopup=\"dialog\"\n onClick={() => setPanelOpen(true)}\n >\n <svg\n className={styles.filtersIcon}\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.8\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M3 5.5h14M5.5 10h9M8 14.5h4\" />\n </svg>\n Filters\n {activeFields.length > 0 ? (\n <span className={styles.count} aria-label={`${activeFields.length} active`}>\n {activeFields.length}\n </span>\n ) : null}\n </Button>\n ) : null}\n </div>\n </div>\n\n {activeFields.length > 0 ? (\n <ul className={styles.chips} aria-label=\"Active filters\">\n {activeFields.map((field) => (\n <li key={field.key} className={styles.chip}>\n <span className={styles.chipLabel}>{field.label}:</span>{' '}\n <strong className={styles.chipValue}>\n {filterValueLabel(field, active[field.key] as string)}\n </strong>\n <button\n type=\"button\"\n className={styles.chipRemove}\n aria-label={`Remove filter ${field.label}`}\n onClick={() => {\n const { [field.key]: _removed, ...rest } = active;\n void _removed;\n onValuesChange?.(rest);\n }}\n >\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M6 6l8 8M14 6l-8 8\" />\n </svg>\n </button>\n </li>\n ))}\n <li>\n <button type=\"button\" className={styles.clearAll} onClick={() => onValuesChange?.({})}>\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.8\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M4 10a6 6 0 106-6H7M7 1.5L4.5 4 7 6.5\" />\n </svg>\n Clear all\n </button>\n </li>\n </ul>\n ) : null}\n\n {panelOpen && hasFields ? (\n <FiltersPanel\n fields={fields ?? []}\n values={active}\n title={panelTitle}\n onApply={(next) => onValuesChange?.(next)}\n onClose={() => setPanelOpen(false)}\n />\n ) : null}\n </div>\n );\n}\n","import type { DataTableColumn, DataTableSort } from './DataTable.types';\n\n/** The value of a column for a row. */\nexport function getValue<T>(column: DataTableColumn<T>, row: T): unknown {\n if (column.accessor) return column.accessor(row);\n return (row as Record<string, unknown>)[String(column.accessorKey)];\n}\n\nconst asText = (value: unknown): string =>\n value === null || value === undefined\n ? ''\n : value instanceof Date\n ? value.toISOString()\n : String(value);\n\n/** Rows whose text contains `query` (case-insensitive) in any column. */\nexport function searchRows<T>(rows: T[], columns: DataTableColumn<T>[], query: string): T[] {\n const needle = query.trim().toLowerCase();\n if (!needle) return rows;\n return rows.filter((row) =>\n columns.some((column) => {\n const text = column.searchValue ? column.searchValue(row) : asText(getValue(column, row));\n return text.toLowerCase().includes(needle);\n }),\n );\n}\n\n/** Rows matching every column filter. Empty filter values are ignored. */\nexport function filterRows<T>(\n rows: T[],\n columns: DataTableColumn<T>[],\n filters: Record<string, string>,\n): T[] {\n const active = Object.entries(filters).filter(([, value]) => value.trim() !== '');\n if (active.length === 0) return rows;\n return rows.filter((row) =>\n active.every(([key, filterValue]) => {\n const column = columns.find((c) => String(c.accessorKey) === key);\n if (!column) return true;\n if (column.filterFn) return column.filterFn(row, filterValue);\n const text = asText(getValue(column, row));\n return column.filterType === 'select' || column.filterType === 'date'\n ? text === filterValue\n : text.toLowerCase().includes(filterValue.trim().toLowerCase());\n }),\n );\n}\n\nconst collator = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' });\n\n/** Rows sorted by a column. Empty values go last in either direction; the sort is stable. */\nexport function sortRows<T>(\n rows: T[],\n columns: DataTableColumn<T>[],\n sort: DataTableSort | null,\n): T[] {\n if (!sort) return rows;\n const column = columns.find((c) => String(c.accessorKey) === sort.key);\n if (!column) return rows;\n const read = (row: T) => (column.sortValue ? column.sortValue(row) : getValue(column, row));\n const factor = sort.direction === 'asc' ? 1 : -1;\n\n return rows\n .map((row, index) => ({ row, index, value: read(row) }))\n .sort((a, b) => {\n const aEmpty = a.value === null || a.value === undefined || a.value === '';\n const bEmpty = b.value === null || b.value === undefined || b.value === '';\n if (aEmpty || bEmpty) return aEmpty === bEmpty ? a.index - b.index : aEmpty ? 1 : -1;\n const result =\n typeof a.value === 'number' && typeof b.value === 'number'\n ? a.value - b.value\n : a.value instanceof Date && b.value instanceof Date\n ? a.value.getTime() - b.value.getTime()\n : collator.compare(asText(a.value), asText(b.value));\n return result === 0 ? a.index - b.index : result * factor;\n })\n .map((entry) => entry.row);\n}\n\n/** The rows of one page (pages start at 1). */\nexport function paginateRows<T>(rows: T[], page: number, pageSize: number): T[] {\n const start = (Math.max(1, page) - 1) * pageSize;\n return rows.slice(start, start + pageSize);\n}\n\n/** Next sort when a header is clicked: ascending, then descending, then none. */\nexport function nextSort(current: DataTableSort | null, key: string): DataTableSort | null {\n if (!current || current.key !== key) return { key, direction: 'asc' };\n return current.direction === 'asc' ? { key, direction: 'desc' } : null;\n}\n","import type { DataTableApiResponse, DataTableCallApi, DataTableSort } from './DataTable.types';\n\nexport const DEFAULT_PAGE_SIZE_OPTIONS = [10, 15, 20, 50, 100];\n\n/** Rows per request when `pagination` is off and every page is loaded. */\nexport const ALL_ROWS_PAGE_SIZE = 100;\n/** Never request more than this many pages when loading everything. */\nexport const MAX_PAGES = 100;\n\nexport const defaultCallApi: DataTableCallApi = async (url, init) => {\n const response = await fetch(url, init);\n return (await response.json()) as DataTableApiResponse;\n};\n\nexport interface RequestQuery {\n fetchUrl: string;\n apiBaseUrl?: string;\n pageNo: number;\n pageSize: number;\n search: string;\n additionalFilter?: string;\n sort: DataTableSort | null;\n /** Column filters by `accessorKey`. Empty values are left out. */\n filters: Record<string, string>;\n}\n\n/**\n * The request URL: `pageNo` and `pageSize`, plus one `filter` parameter that joins the search text, extra filter,\n * sort and column filters with `;` (`searchText:abc;orderByColumn:name;orderBy:asc;status:Active`).\n */\nexport function buildRequestUrl(query: RequestQuery): string {\n const base = /^https?:/i.test(query.fetchUrl)\n ? query.fetchUrl\n : `${query.apiBaseUrl ?? ''}${query.fetchUrl}`;\n\n const entries: string[] = [];\n if (query.search) entries.push(`searchText:${query.search}`);\n if (query.additionalFilter) entries.push(query.additionalFilter);\n if (query.sort) {\n entries.push(`orderByColumn:${query.sort.key}`);\n entries.push(`orderBy:${query.sort.direction}`);\n }\n for (const [key, value] of Object.entries(query.filters)) {\n if (value) entries.push(`${key}:${value}`);\n }\n\n const params = new URLSearchParams();\n params.append('pageNo', String(query.pageNo));\n params.append('pageSize', String(query.pageSize));\n if (entries.length > 0) params.append('filter', entries.join(';'));\n\n // Keep any query string already in the URL (e.g. `?type=Student`).\n return `${base}${base.includes('?') ? '&' : '?'}${params.toString()}`;\n}\n\nexport interface ParsedPage<T> {\n rows: T[];\n totalPages: number;\n totalItems: number;\n}\n\n/** Reads a response: `data.items` (or `data` itself) as rows, `data.totalPage` and `data.totalData` as the totals. */\nexport function parseResponse<T>(response: DataTableApiResponse): ParsedPage<T> {\n const data = response.data as\n { items?: unknown; totalPage?: number; totalData?: number } | unknown[] | undefined;\n const items = Array.isArray(data) ? data : (data?.items ?? data ?? []);\n const meta = Array.isArray(data) ? {} : (data ?? {});\n return {\n rows: Array.isArray(items) ? (items as T[]) : [],\n totalPages: (meta as { totalPage?: number }).totalPage ?? 0,\n totalItems: (meta as { totalData?: number }).totalData ?? 0,\n };\n}\n\nexport class DataTableRequestError extends Error {}\n\n/** One page, or an error: a response with `status: false` becomes an error carrying the server's message. */\nexport async function fetchPage<T>(url: string, callApi: DataTableCallApi): Promise<ParsedPage<T>> {\n const response = await callApi(url, { method: 'GET' });\n if (response.status === false) {\n throw new DataTableRequestError(response.message || 'Failed to fetch data');\n }\n return parseResponse<T>(response);\n}\n\n/** Every page of a query, 100 rows at a time (at most 100 pages). */\nexport async function fetchAllPages<T>(\n queryFor: (pageNo: number, pageSize: number) => string,\n callApi: DataTableCallApi,\n): Promise<T[]> {\n const rows: T[] = [];\n let pageNo = 1;\n let totalPages: number;\n do {\n const page = await fetchPage<T>(queryFor(pageNo, ALL_ROWS_PAGE_SIZE), callApi);\n rows.push(...page.rows);\n totalPages = page.totalPages || 1;\n pageNo += 1;\n } while (pageNo <= totalPages && pageNo <= MAX_PAGES);\n return rows;\n}\n","import { useEffect, useState } from 'react';\n\n/** The value, but only after it has stayed the same for `delay` ms. With a delay of 0 it is returned as is. */\nexport function useDebouncedValue<V>(value: V, delay: number): V {\n const [debounced, setDebounced] = useState(value);\n useEffect(() => {\n if (delay <= 0) return;\n const timer = setTimeout(() => setDebounced(value), delay);\n return () => clearTimeout(timer);\n }, [value, delay]);\n return delay <= 0 ? value : debounced;\n}\n","import { useEffect, useMemo, useState, type KeyboardEvent, type ReactNode } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { Button } from '../Button';\nimport { Checkbox } from '../Checkbox';\nimport { DropdownMenu } from '../DropdownMenu';\nimport { Pagination } from '../Pagination';\nimport { Skeleton } from '../Skeleton';\nimport {\n Table,\n TableBody,\n TableCaption,\n TableCell,\n TableHead,\n TableHeaderCell,\n TableRow,\n} from '../Table';\nimport type { TableAlign } from '../Table';\nimport { SelectionBar } from './SelectionBar';\nimport { TableFilters } from '../TableFilters';\nimport type { TableFilterField } from '../TableFilters';\nimport {\n filterRows,\n getValue,\n nextSort,\n paginateRows,\n searchRows,\n sortRows,\n} from './dataTableUtils';\nimport {\n DEFAULT_PAGE_SIZE_OPTIONS,\n buildRequestUrl,\n defaultCallApi,\n fetchAllPages,\n fetchPage,\n} from './remote';\nimport { useDebouncedValue } from './useDebouncedValue';\nimport type { DataTableAction, DataTableProps, DataTableSort } from './DataTable.types';\nimport styles from './DataTable.module.css';\n\nconst SKELETON_WIDTHS = [128, 80, 96];\n\nconst alignOf = (\n align: 'start' | 'center' | 'end' | 'left' | 'right' | undefined,\n): TableAlign | undefined => (align === 'left' ? 'start' : align === 'right' ? 'end' : align);\n\nconst alertIcon = (\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.8\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"9\" />\n <path d=\"M12 7.5v5M12 16h.01\" />\n </svg>\n);\n\nconst archiveIcon = (\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.6\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <rect x=\"3\" y=\"4\" width=\"18\" height=\"5\" rx=\"1\" />\n <path d=\"M5 9v9a1 1 0 001 1h12a1 1 0 001-1V9M10 13h4\" />\n </svg>\n);\n\ninterface RemoteResult<T> {\n key: string;\n rows: T[];\n totalPages: number;\n totalItems: number;\n error: string | null;\n}\n\n/**\n * Data table with search, column filters, sorting, row selection, row actions, loading / error / empty\n * states and pagination, in the look of the school app's tables.\n *\n * Give it rows with `data` (filtered, sorted and paged here), or a `fetchUrl` to load them from a server that\n * does the searching, sorting and paging (see `callApi`, `additionalFilter`, `refreshTrigger`, `registerApi`).\n * Each piece of state can be controlled (`search`, `filters`, `sort`, `page`, `pageSize`) or left to the table.\n */\nexport function DataTable<T>({\n columns,\n data,\n fetchUrl,\n apiBaseUrl,\n callApi = defaultCallApi,\n additionalFilter,\n refreshTrigger,\n debounceMs,\n registerApi,\n getRowId,\n loading: loadingProp = false,\n loadingRows = 5,\n emptyMessage,\n emptyState,\n searchable = true,\n searchPlaceholder,\n search: searchProp,\n defaultSearch = '',\n onSearchChange,\n filters: filtersProp,\n defaultFilters,\n onFiltersChange,\n manualFiltering = false,\n sort: sortProp,\n defaultSort = null,\n onSortChange,\n manualSorting = false,\n pagination: paginationProp,\n page: pageProp,\n defaultPage = 1,\n onPageChange,\n pageSize: pageSizeProp,\n defaultPageSize = 10,\n onPageSizeChange,\n pageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS,\n manualPagination = false,\n totalItems,\n selection,\n onRowClick,\n actions,\n actionsClassName,\n belowToolbar,\n bulkActions,\n caption,\n stickyHeader = true,\n className,\n tableClassName,\n containerClassName,\n 'aria-label': ariaLabel,\n}: DataTableProps<T>) {\n const licensed = useLicensed();\n const remote = fetchUrl !== undefined;\n const pagination = paginationProp ?? true;\n\n const [searchState, setSearchState] = useState(defaultSearch);\n const [filtersState, setFiltersState] = useState<Record<string, string>>(defaultFilters ?? {});\n const [sortState, setSortState] = useState<DataTableSort | null>(defaultSort);\n const [pageState, setPageState] = useState(defaultPage);\n const [pageSizeState, setPageSizeState] = useState(defaultPageSize);\n\n const search = searchProp ?? searchState;\n const filters = filtersProp ?? filtersState;\n const sort = sortProp === undefined ? sortState : sortProp;\n const pageSize = pageSizeProp ?? pageSizeState;\n const page = pageProp ?? pageState;\n\n const filterFields = useMemo<TableFilterField[]>(\n () =>\n columns\n .filter((column) => column.filterable)\n .map((column) => ({\n key: String(column.accessorKey),\n label: typeof column.header === 'string' ? column.header : String(column.accessorKey),\n type: column.filterType ?? 'text',\n options: column.filterOptions,\n })),\n [columns],\n );\n\n const goToFirstPage = () => {\n if (page === 1) return;\n if (pageProp === undefined) setPageState(1);\n onPageChange?.(1);\n };\n const changeSearch = (next: string) => {\n if (searchProp === undefined) setSearchState(next);\n onSearchChange?.(next);\n goToFirstPage();\n };\n const changeFilters = (next: Record<string, string>) => {\n if (filtersProp === undefined) setFiltersState(next);\n onFiltersChange?.(next);\n goToFirstPage();\n };\n const changeSort = (key: string) => {\n const next = nextSort(sort, key);\n if (sortProp === undefined) setSortState(next);\n onSortChange?.(next);\n };\n const changePage = (next: number) => {\n if (pageProp === undefined) setPageState(next);\n onPageChange?.(next);\n };\n const changePageSize = (next: number) => {\n if (pageSizeProp === undefined) setPageSizeState(next);\n onPageSizeChange?.(next);\n goToFirstPage();\n };\n\n // ---------- Rows from a server (fetchUrl) ----------\n const wait = debounceMs ?? (remote ? 500 : 0);\n const debouncedSearch = useDebouncedValue(search, wait);\n const debouncedFilters = useDebouncedValue(filters, wait);\n const requestKey = JSON.stringify([\n fetchUrl,\n apiBaseUrl,\n additionalFilter,\n refreshTrigger,\n pagination,\n page,\n pageSize,\n sort,\n debouncedSearch,\n debouncedFilters,\n ]);\n const [result, setResult] = useState<RemoteResult<T> | null>(null);\n\n useEffect(() => {\n if (!remote) return;\n let cancelled = false;\n const queryFor = (pageNo: number, size: number) =>\n buildRequestUrl({\n fetchUrl,\n apiBaseUrl,\n pageNo,\n pageSize: size,\n search: debouncedSearch,\n additionalFilter,\n sort,\n filters: debouncedFilters,\n });\n\n const load = async (): Promise<RemoteResult<T>> => {\n try {\n if (pagination) {\n const loaded = await fetchPage<T>(queryFor(page, pageSize), callApi);\n return { key: requestKey, error: null, ...loaded };\n }\n const rows = await fetchAllPages<T>(queryFor, callApi);\n return { key: requestKey, error: null, rows, totalPages: 0, totalItems: 0 };\n } catch (error) {\n const message =\n error instanceof Error && error.message ? error.message : 'An unexpected error occurred';\n return { key: requestKey, error: message, rows: [], totalPages: 0, totalItems: 0 };\n }\n };\n\n void load().then((loaded) => {\n if (!cancelled) setResult(loaded);\n });\n return () => {\n cancelled = true;\n };\n // `requestKey` covers every input of the request.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [requestKey]);\n\n useEffect(() => {\n registerApi?.({\n updateRow: (id, patch) =>\n setResult((previous) =>\n previous\n ? {\n ...previous,\n rows: previous.rows.map((row) =>\n (row as { id?: string | number }).id === id ? { ...row, ...patch } : row,\n ),\n }\n : previous,\n ),\n });\n }, [registerApi]);\n\n const loading = remote ? result?.key !== requestKey : loadingProp;\n const error = remote && !loading ? (result?.error ?? null) : null;\n const sourceRows = useMemo(\n () => (remote ? (result?.rows ?? []) : (data ?? [])),\n [remote, result, data],\n );\n const serverSide = remote || manualFiltering;\n\n const processed = useMemo(() => {\n let rows = sourceRows;\n if (!serverSide) rows = filterRows(searchRows(rows, columns, search), columns, filters);\n if (!(remote || manualSorting)) rows = sortRows(rows, columns, sort);\n return rows;\n }, [sourceRows, columns, search, filters, sort, serverSide, remote, manualSorting]);\n\n if (!licensed) return <UnlicensedNotice />;\n\n const serverPaging = remote || manualPagination;\n const total = remote\n ? (result?.totalItems ?? 0)\n : manualPagination\n ? (totalItems ?? sourceRows.length)\n : processed.length;\n const pageCount = remote\n ? Math.max(1, result?.totalPages ?? 1)\n : Math.max(1, Math.ceil(total / pageSize));\n const currentPage = Math.min(Math.max(1, page), pageCount);\n const rows =\n !pagination || serverPaging ? processed : paginateRows(processed, currentPage, pageSize);\n\n const rowId = (row: T, index: number) =>\n String(getRowId ? getRowId(row, index) : ((row as { id?: unknown }).id ?? index));\n const visibleIds = rows.map(rowId);\n const selectedIds = selection?.selected ?? [];\n const selectedVisible = visibleIds.filter((id) => selectedIds.includes(id));\n const allSelected = visibleIds.length > 0 && selectedVisible.length === visibleIds.length;\n const someSelected = selectedVisible.length > 0 && !allSelected;\n\n const toggleAll = () => {\n if (!selection) return;\n selection.onChange(\n allSelected\n ? selectedIds.filter((id) => !visibleIds.includes(id))\n : [...new Set([...selectedIds, ...visibleIds])],\n );\n };\n const toggleRow = (id: string) => {\n if (!selection) return;\n selection.onChange(\n selectedIds.includes(id) ? selectedIds.filter((s) => s !== id) : [...selectedIds, id],\n );\n };\n\n const hasActions = Boolean(actions && actions.length > 0);\n const hasToolbar = searchable || filterFields.length > 0;\n const isFiltered =\n search.trim() !== '' || Object.values(filters).some((value) => value.trim() !== '');\n const columnCount = columns.length + (selection ? 1 : 0) + (hasActions ? 1 : 0);\n const stop = { onClick: (event: { stopPropagation: () => void }) => event.stopPropagation() };\n const emptyText = emptyMessage ?? 'No data available';\n\n const handleRowKeyDown = (event: KeyboardEvent<HTMLTableRowElement>, row: T) => {\n if (event.target !== event.currentTarget) return;\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n onRowClick?.(row);\n }\n };\n\n const renderActions = (row: T): ReactNode => {\n const visible = (actions ?? []).filter((action) => !action.hidden?.(row));\n if (visible.length === 0) return null;\n const isDanger = (action: DataTableAction<T>) => action.variant === 'danger';\n if (visible.length === 1) {\n const action = visible[0] as DataTableAction<T>;\n return (\n <button\n type=\"button\"\n className={cn(styles.actionButton, isDanger(action) && styles.actionDanger)}\n title={action.label}\n aria-label={action.label}\n onClick={() => action.onClick(row)}\n >\n {action.icon ?? <span className={styles.actionText}>{action.label}</span>}\n </button>\n );\n }\n return (\n <DropdownMenu\n items={visible.map((action) => ({\n label: action.label,\n icon: action.icon,\n variant: isDanger(action) ? 'danger' : 'default',\n onClick: () => action.onClick(row),\n }))}\n />\n );\n };\n\n const table = (\n <div className={styles.tableArea} aria-busy={loading || undefined}>\n <Table\n aria-label={ariaLabel}\n scrollLabel={ariaLabel ? `${ariaLabel} (scrollable)` : undefined}\n stickyHeader={stickyHeader}\n bordered={false}\n className={tableClassName}\n containerClassName={cn(styles.scroll, containerClassName)}\n >\n {caption ? <TableCaption>{caption}</TableCaption> : null}\n <TableHead>\n <TableRow>\n {selection ? (\n <TableHeaderCell className={styles.selectCell}>\n <Checkbox\n aria-label=\"Select all rows\"\n checked={allSelected}\n indeterminate={someSelected}\n disabled={visibleIds.length === 0 || loading}\n onChange={toggleAll}\n />\n </TableHeaderCell>\n ) : null}\n {columns.map((column) => {\n const key = String(column.accessorKey);\n return (\n <TableHeaderCell\n key={key}\n align={alignOf(column.align)}\n sortable={column.sortable}\n sortDirection={sort?.key === key ? sort.direction : null}\n onSort={() => changeSort(key)}\n className={column.className}\n style={column.width !== undefined ? { width: column.width } : undefined}\n >\n {column.header}\n </TableHeaderCell>\n );\n })}\n {hasActions ? (\n <TableHeaderCell align=\"center\" className={actionsClassName ?? styles.actionsColumn}>\n Actions\n </TableHeaderCell>\n ) : null}\n </TableRow>\n </TableHead>\n <TableBody>\n {error ? (\n <TableRow>\n <TableCell colSpan={columnCount} className={styles.errorCell}>\n <div className={styles.stateBox} role=\"alert\">\n <span className={styles.errorIcon}>{alertIcon}</span>\n <span className={styles.errorText}>{error}</span>\n </div>\n </TableCell>\n </TableRow>\n ) : loading ? (\n Array.from({ length: loadingRows }, (_, rowIndex) => (\n <TableRow key={`loading-${rowIndex}`}>\n {Array.from({ length: columnCount }, (_, cellIndex) => (\n <TableCell\n key={cellIndex}\n align={hasActions && cellIndex === columnCount - 1 ? 'center' : undefined}\n >\n {hasActions && cellIndex === columnCount - 1 ? (\n <Skeleton\n width={32}\n height={32}\n style={{ borderRadius: 6, display: 'inline-block' }}\n />\n ) : (\n <Skeleton\n variant=\"text\"\n height={16}\n width={SKELETON_WIDTHS[cellIndex === 0 ? 0 : cellIndex % 2 === 0 ? 2 : 1]}\n style={{ borderRadius: 4 }}\n />\n )}\n </TableCell>\n ))}\n </TableRow>\n ))\n ) : rows.length === 0 ? (\n <TableRow>\n <TableCell colSpan={columnCount} className={styles.empty}>\n {emptyState ?? (\n <div className={styles.stateBox}>\n <span className={styles.emptyIcon}>{archiveIcon}</span>\n <span>\n {isFiltered ? 'No results match your search or filters.' : emptyText}\n </span>\n {isFiltered ? (\n <Button\n variant=\"link\"\n size=\"sm\"\n onClick={() => {\n changeSearch('');\n changeFilters({});\n }}\n >\n Clear search and filters\n </Button>\n ) : null}\n </div>\n )}\n </TableCell>\n </TableRow>\n ) : (\n rows.map((row, index) => {\n const id = rowId(row, index);\n const selected = selectedIds.includes(id);\n return (\n <TableRow\n key={id}\n selected={selected}\n onClick={onRowClick ? () => onRowClick(row) : undefined}\n onKeyDown={onRowClick ? (event) => handleRowKeyDown(event, row) : undefined}\n tabIndex={onRowClick ? 0 : undefined}\n >\n {selection ? (\n <TableCell className={styles.selectCell} {...stop}>\n <Checkbox\n aria-label=\"Select row\"\n checked={selected}\n onChange={() => toggleRow(id)}\n />\n </TableCell>\n ) : null}\n {columns.map((column) => {\n const value = getValue(column, row);\n return (\n <TableCell\n key={String(column.accessorKey)}\n align={alignOf(column.align)}\n className={column.className}\n style={column.width !== undefined ? { width: column.width } : undefined}\n >\n {column.render ? (\n column.render(value, row)\n ) : (\n <span className={styles.cellText}>\n {value !== undefined && value !== null ? String(value) : '-'}\n </span>\n )}\n </TableCell>\n );\n })}\n {hasActions ? (\n <TableCell\n align=\"center\"\n className={actionsClassName ?? styles.actionsColumn}\n {...stop}\n >\n <div className={styles.actions}>{renderActions(row)}</div>\n </TableCell>\n ) : null}\n </TableRow>\n );\n })\n )}\n </TableBody>\n </Table>\n </div>\n );\n\n return (\n <div className={cn(styles.root, className)}>\n {hasToolbar ? (\n <div className={styles.toolbar}>\n <TableFilters\n search={searchable ? search : undefined}\n onSearchChange={searchable ? changeSearch : undefined}\n searchPlaceholder={searchPlaceholder ?? 'Search...'}\n fields={filterFields}\n values={filters}\n onValuesChange={filterFields.length > 0 ? changeFilters : undefined}\n />\n </div>\n ) : null}\n {selection && selectedIds.length > 0 ? (\n <SelectionBar\n count={selectedIds.length}\n actions={bulkActions?.map((a) => ({ ...a, onClick: () => a.onClick(selectedIds) }))}\n onClear={() => selection.onChange([])}\n />\n ) : null}\n {belowToolbar}\n\n {table}\n\n <div role=\"status\" className={styles.srOnly}>\n {loading ? 'Loading' : error ? 'Error' : `${total} ${total === 1 ? 'result' : 'results'}`}\n </div>\n\n {pagination ? (\n <div className={styles.footer}>\n <Pagination\n layout=\"split\"\n page={currentPage}\n pageCount={pageCount}\n onPageChange={changePage}\n pageSize={pageSize}\n totalItems={total}\n pageSizeOptions={pageSizeOptions}\n onPageSizeChange={changePageSize}\n disabled={loading}\n />\n </div>\n ) : null}\n </div>\n );\n}\n","/** \"1.5 MB\", \"820 KB\", \"12 B\". */\nexport function formatFileSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`;\n const mb = bytes / (1024 * 1024);\n return `${mb < 10 ? mb.toFixed(1) : Math.round(mb)} MB`;\n}\n\n/** Whether `file` matches a native `accept` string (`.pdf, image/*, application/pdf`). Empty accepts everything. */\nexport function matchesAccept(file: Pick<File, 'name' | 'type'>, accept?: string): boolean {\n const tokens = (accept ?? '')\n .split(',')\n .map((token) => token.trim().toLowerCase())\n .filter(Boolean);\n if (tokens.length === 0) return true;\n const name = file.name.toLowerCase();\n const type = file.type.toLowerCase();\n return tokens.some((token) => {\n if (token.startsWith('.')) return name.endsWith(token);\n if (token.endsWith('/*')) return type.startsWith(token.slice(0, -1));\n return type === token;\n });\n}\n\nexport const sameFile = (a: File, b: File) =>\n a.name === b.name && a.size === b.size && a.lastModified === b.lastModified;\n\n/** Stable key for a file: name, size and modified time. */\nexport const fileKey = (file: File) => `${file.name}-${file.size}-${file.lastModified}`;\n\nexport const isImage = (file: Pick<File, 'type'>) => file.type.startsWith('image/');\n",".backdrop {\n position: fixed;\n inset: 0;\n z-index: var(--cui-z-popover);\n display: flex;\n align-items: center;\n justify-content: center;\n padding: var(--cui-space-4);\n background-color: rgb(0 0 0 / 0.55);\n font-family: var(--cui-font-family);\n}\n\n.dialog {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: var(--cui-space-4);\n box-sizing: border-box;\n max-width: 100%;\n padding: var(--cui-space-5);\n background-color: var(--cui-color-surface);\n color: var(--cui-color-text);\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-xl);\n box-shadow: var(--cui-shadow-lg);\n outline: none;\n}\n\n.title {\n align-self: flex-start;\n margin: 0;\n font-size: var(--cui-font-size-lg);\n font-weight: var(--cui-font-weight-semibold);\n}\n\n.frame {\n position: relative;\n max-width: 100%;\n overflow: hidden;\n background-color: var(--cui-color-surface-secondary);\n border: 2px solid var(--cui-color-border);\n border-radius: var(--cui-radius-md);\n cursor: grab;\n touch-action: none;\n user-select: none;\n}\n.frame:active {\n cursor: grabbing;\n}\n.frame:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 2px;\n}\n\n.circle {\n border-radius: var(--cui-radius-full);\n}\n\n.image {\n position: absolute;\n top: 50%;\n left: 50%;\n max-width: none;\n pointer-events: none;\n will-change: transform;\n}\n\n.loading {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--cui-color-text-muted);\n font-size: var(--cui-font-size-sm);\n}\n\n.zoom {\n display: flex;\n align-items: center;\n gap: var(--cui-space-3);\n width: 100%;\n font-size: var(--cui-font-size-sm);\n color: var(--cui-color-text-secondary);\n}\n.zoom input {\n flex: 1;\n accent-color: var(--cui-color-primary);\n}\n\n.error {\n margin: 0;\n max-width: 20rem;\n font-size: var(--cui-font-size-sm);\n color: var(--cui-color-danger);\n}\n\n.actions {\n display: flex;\n align-self: flex-end;\n gap: var(--cui-space-2);\n}\n\n.cancel,\n.apply {\n height: var(--cui-control-height-md);\n padding: 0 var(--cui-space-4);\n border: var(--cui-control-border-width) solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n font: inherit;\n font-size: var(--cui-font-size-sm);\n font-weight: var(--cui-font-weight-medium);\n cursor: pointer;\n}\n\n.cancel {\n background-color: var(--cui-color-surface);\n color: var(--cui-color-text);\n}\n.cancel:hover {\n background-color: var(--cui-color-surface-secondary);\n}\n\n.apply {\n background-color: var(--cui-color-primary);\n border-color: var(--cui-color-primary);\n color: var(--cui-color-on-primary);\n}\n.apply:hover:not(:disabled) {\n background-color: var(--cui-color-primary-hover);\n border-color: var(--cui-color-primary-hover);\n}\n.apply:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.cancel:focus-visible,\n.apply:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 2px;\n}\n","import { useEffect, useId, useRef, useState, type KeyboardEvent, type PointerEvent } from 'react';\nimport { createPortal } from 'react-dom';\nimport { cn } from '../../utils/cn';\nimport styles from './ImageCropper.module.css';\n\nexport interface ImageCropperProps {\n file: File;\n /** Width divided by height of the crop frame. */\n aspect: number;\n /** `circle` shows a round frame; the saved image is still the full rectangle around it. */\n shape: 'circle' | 'rect';\n /** Width in px of the saved image. The height follows from `aspect`. */\n outputWidth: number;\n outputType: 'image/png' | 'image/jpeg' | 'image/webp';\n outputQuality?: number;\n title?: string;\n /** `data-theme` to apply to the dialog (it is rendered in <body>). */\n theme?: string;\n onApply: (file: File) => void;\n onCancel: () => void;\n}\n\nconst FRAME = 280; // length of the frame's longer side, in px\nconst MAX_ZOOM = 4;\nconst KEY_STEP = 12;\n\ninterface Loaded {\n image: HTMLImageElement;\n width: number;\n height: number;\n}\n\nconst extensionFor = (type: string) =>\n type === 'image/png' ? 'png' : type === 'image/webp' ? 'webp' : 'jpg';\n\n/**\n * Modal that lets the user move and zoom a picked image inside a fixed-ratio frame and saves the visible\n * part as a new file. Drag, arrow keys, the slider, or +/- keys adjust it; Enter applies, Escape cancels.\n */\nexport function ImageCropper({\n file,\n aspect,\n shape,\n outputWidth,\n outputType,\n outputQuality,\n title = 'Crop photo',\n theme,\n onApply,\n onCancel,\n}: ImageCropperProps) {\n const titleId = useId();\n const dialogRef = useRef<HTMLDivElement>(null);\n const [loaded, setLoaded] = useState<Loaded | null>(null);\n const [failed, setFailed] = useState(false);\n const [zoom, setZoom] = useState(1);\n const [offset, setOffset] = useState({ x: 0, y: 0 });\n const [saving, setSaving] = useState(false);\n const drag = useRef<{ x: number; y: number; ox: number; oy: number } | null>(null);\n\n // Frame size: the longer side is FRAME, the other follows the aspect ratio.\n const frameW = aspect >= 1 ? FRAME : Math.round(FRAME * aspect);\n const frameH = aspect >= 1 ? Math.round(FRAME / aspect) : FRAME;\n\n useEffect(() => {\n const previous = document.activeElement as HTMLElement | null;\n dialogRef.current?.focus({ preventScroll: true });\n return () => previous?.focus?.({ preventScroll: true });\n }, []);\n\n useEffect(() => {\n let url: string | undefined;\n const image = new Image();\n image.onload = () =>\n setLoaded({ image, width: image.naturalWidth, height: image.naturalHeight });\n image.onerror = () => setFailed(true);\n try {\n url = URL.createObjectURL(file);\n image.src = url;\n } catch {\n image.onerror?.(new Event('error'));\n }\n return () => {\n image.onload = null;\n image.onerror = null;\n if (url) URL.revokeObjectURL(url);\n };\n }, [file]);\n\n // Scale at which the image just covers the frame; zoom multiplies it.\n const baseScale = loaded ? Math.max(frameW / loaded.width, frameH / loaded.height) : 1;\n const scale = baseScale * zoom;\n\n const clamp = (x: number, y: number, nextScale: number) => {\n if (!loaded) return { x: 0, y: 0 };\n const maxX = Math.max(0, (loaded.width * nextScale - frameW) / 2);\n const maxY = Math.max(0, (loaded.height * nextScale - frameH) / 2);\n return { x: Math.min(maxX, Math.max(-maxX, x)), y: Math.min(maxY, Math.max(-maxY, y)) };\n };\n\n const changeZoom = (next: number) => {\n const value = Math.min(MAX_ZOOM, Math.max(1, next));\n setZoom(value);\n setOffset((current) => clamp(current.x, current.y, baseScale * value));\n };\n\n const move = (dx: number, dy: number) =>\n setOffset((current) => clamp(current.x + dx, current.y + dy, scale));\n\n const handlePointerDown = (event: PointerEvent<HTMLDivElement>) => {\n event.currentTarget.setPointerCapture?.(event.pointerId);\n drag.current = { x: event.clientX, y: event.clientY, ox: offset.x, oy: offset.y };\n };\n const handlePointerMove = (event: PointerEvent<HTMLDivElement>) => {\n const start = drag.current;\n if (!start) return;\n setOffset(clamp(start.ox + event.clientX - start.x, start.oy + event.clientY - start.y, scale));\n };\n const endDrag = () => {\n drag.current = null;\n };\n\n const apply = () => {\n if (!loaded || saving) return;\n setSaving(true);\n const outW = Math.round(outputWidth);\n const outH = Math.max(1, Math.round(outputWidth / aspect));\n const canvas = document.createElement('canvas');\n canvas.width = outW;\n canvas.height = outH;\n const context = canvas.getContext('2d');\n if (!context) {\n setSaving(false);\n setFailed(true);\n return;\n }\n // The frame's top-left corner, expressed in the image's own pixels.\n const sx = (loaded.width * scale - frameW) / 2 / scale - offset.x / scale;\n const sy = (loaded.height * scale - frameH) / 2 / scale - offset.y / scale;\n context.imageSmoothingQuality = 'high';\n context.drawImage(loaded.image, sx, sy, frameW / scale, frameH / scale, 0, 0, outW, outH);\n canvas.toBlob(\n (blob) => {\n if (!blob) {\n setSaving(false);\n setFailed(true);\n return;\n }\n const base = file.name.replace(/\\.[^.]+$/, '') || 'photo';\n const type = blob.type || outputType;\n onApply(\n new File([blob], `${base}.${extensionFor(type)}`, { type, lastModified: Date.now() }),\n );\n },\n outputType,\n outputQuality,\n );\n };\n\n const handleDialogKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Escape') {\n event.preventDefault();\n event.stopPropagation();\n onCancel();\n return;\n }\n if (event.key === 'Tab') {\n // Keep Tab inside the dialog.\n const nodes = Array.from(\n dialogRef.current?.querySelectorAll<HTMLElement>(\n 'button:not([disabled]), input, [tabindex=\"0\"]',\n ) ?? [],\n );\n const first = nodes[0];\n const last = nodes[nodes.length - 1];\n if (!first || !last) return;\n if (\n event.shiftKey &&\n (document.activeElement === first || document.activeElement === dialogRef.current)\n ) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n }\n };\n\n const handleStageKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const moves: Record<string, [number, number]> = {\n ArrowLeft: [KEY_STEP, 0],\n ArrowRight: [-KEY_STEP, 0],\n ArrowUp: [0, KEY_STEP],\n ArrowDown: [0, -KEY_STEP],\n };\n const delta = moves[event.key];\n if (delta) {\n event.preventDefault();\n move(delta[0], delta[1]);\n } else if (event.key === '+' || event.key === '=') {\n event.preventDefault();\n changeZoom(zoom + 0.1);\n } else if (event.key === '-') {\n event.preventDefault();\n changeZoom(zoom - 0.1);\n } else if (event.key === 'Enter') {\n event.preventDefault();\n apply();\n }\n };\n\n const dialog = (\n <div className={styles.backdrop} data-theme={theme}>\n <div\n ref={dialogRef}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={titleId}\n tabIndex={-1}\n className={styles.dialog}\n onKeyDown={handleDialogKeyDown}\n >\n <h2 id={titleId} className={styles.title}>\n {title}\n </h2>\n\n {failed ? (\n <p className={styles.error} role=\"alert\">\n This image could not be opened. Try a different file.\n </p>\n ) : (\n <>\n <div\n className={cn(styles.frame, shape === 'circle' && styles.circle)}\n style={{ width: frameW, height: frameH }}\n tabIndex={0}\n role=\"group\"\n aria-label=\"Crop area. Drag, or use the arrow keys to move the photo and plus and minus to zoom.\"\n onPointerDown={handlePointerDown}\n onPointerMove={handlePointerMove}\n onPointerUp={endDrag}\n onPointerCancel={endDrag}\n onKeyDown={handleStageKeyDown}\n >\n {loaded ? (\n <img\n src={loaded.image.src}\n alt=\"\"\n draggable={false}\n className={styles.image}\n style={{\n width: loaded.width * scale,\n height: loaded.height * scale,\n transform: `translate(calc(-50% + ${offset.x}px), calc(-50% + ${offset.y}px))`,\n }}\n />\n ) : (\n <span className={styles.loading}>Loading…</span>\n )}\n </div>\n\n <label className={styles.zoom}>\n <span>Zoom</span>\n <input\n type=\"range\"\n min={1}\n max={MAX_ZOOM}\n step={0.01}\n value={zoom}\n disabled={!loaded}\n aria-label=\"Zoom\"\n onChange={(event) => changeZoom(Number(event.target.value))}\n />\n </label>\n </>\n )}\n\n <div className={styles.actions}>\n <button type=\"button\" className={styles.cancel} onClick={onCancel}>\n Cancel\n </button>\n <button\n type=\"button\"\n className={styles.apply}\n disabled={!loaded || saving || failed}\n onClick={apply}\n >\n {saving ? 'Saving…' : 'Apply'}\n </button>\n </div>\n </div>\n </div>\n );\n\n return createPortal(dialog, document.body);\n}\n",".root {\n display: flex;\n flex-direction: column;\n gap: var(--cui-space-2);\n width: 100%;\n font-family: var(--cui-font-family);\n}\n\n/* ---------- Variant: dropzone ---------- */\n.zone {\n position: relative;\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: var(--cui-space-1);\n box-sizing: border-box;\n padding: var(--cui-space-6) var(--cui-space-4);\n background-color: var(--cui-color-surface);\n border: var(--cui-control-border-width) dashed var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text-secondary);\n font-size: var(--cui-font-size-sm);\n text-align: center;\n cursor: pointer;\n transition:\n background-color var(--cui-transition-fast),\n border-color var(--cui-transition-fast),\n box-shadow var(--cui-transition-fast);\n}\n\n.zone:hover:not(.disabled) {\n border-color: var(--cui-color-border-hover);\n}\n\n.zone:focus-within {\n border-color: var(--cui-color-border-focus);\n box-shadow: var(--cui-focus-ring);\n}\n\n.dragging {\n background-color: var(--cui-color-primary-subtle);\n border-color: var(--cui-color-primary);\n}\n\n/* Shared state classes (all variants) */\n.zone.invalid,\n.tile.invalid,\n.addTile.invalid,\n.fieldFace.invalid {\n border-color: var(--cui-color-danger-border);\n}\n.zone.invalid:focus-within {\n border-color: var(--cui-color-danger-border-hover);\n box-shadow: var(--cui-focus-ring-danger);\n}\n\n.zone.disabled {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n\n/* Visually hidden but focusable, so keyboard users and form submission still work. */\n.input {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip-path: inset(50%);\n border: 0;\n white-space: nowrap;\n}\n\n.icon {\n width: 1.75rem;\n height: 1.75rem;\n color: var(--cui-color-text-muted);\n}\n\n.browseLink {\n color: var(--cui-color-primary);\n font-weight: var(--cui-font-weight-medium);\n}\n\n.hint {\n font-size: var(--cui-font-size-xs);\n color: var(--cui-color-text-muted);\n}\n\n.hintText {\n font-size: var(--cui-font-size-xs);\n color: var(--cui-color-text-muted);\n}\n\n/* ---------- File list ---------- */\n.list {\n display: flex;\n flex-direction: column;\n gap: var(--cui-space-1);\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.item {\n display: flex;\n align-items: center;\n gap: var(--cui-space-3);\n padding: var(--cui-space-2) var(--cui-space-3);\n background-color: var(--cui-color-surface-secondary);\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-md);\n font-size: var(--cui-font-size-sm);\n color: var(--cui-color-text);\n}\n\n.itemThumb {\n width: 2rem;\n height: 2rem;\n flex-shrink: 0;\n border-radius: var(--cui-radius-sm);\n object-fit: cover;\n}\n\n.itemIcon {\n width: 1.25rem;\n height: 1.25rem;\n flex-shrink: 0;\n color: var(--cui-color-text-muted);\n}\n\n.name {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.size {\n flex-shrink: 0;\n font-size: var(--cui-font-size-xs);\n color: var(--cui-color-text-muted);\n}\n\n.remove {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n width: 1.25rem;\n height: 1.25rem;\n padding: 0;\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-full);\n color: var(--cui-color-text-muted);\n cursor: pointer;\n}\n.remove:hover:not(:disabled) {\n background-color: var(--cui-color-border);\n color: var(--cui-color-text);\n}\n.remove:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n}\n.remove svg {\n width: 0.875rem;\n height: 0.875rem;\n}\n\n.rejected {\n margin: 0;\n font-size: var(--cui-font-size-sm);\n color: var(--cui-color-danger);\n}\n\n/* ---------- Variant: button ---------- */\n.buttonRow {\n display: flex;\n align-items: center;\n gap: var(--cui-space-3);\n min-width: 0;\n}\n\n.buttonFace {\n position: relative;\n flex-shrink: 0;\n display: inline-flex;\n cursor: pointer;\n}\n\n.button {\n display: inline-flex;\n align-items: center;\n gap: var(--cui-space-2);\n box-sizing: border-box;\n height: var(--cui-control-height-md);\n padding: 0 var(--cui-space-4);\n background-color: var(--cui-color-surface);\n border: var(--cui-control-border-width) solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text);\n font-size: var(--cui-font-size-sm);\n font-weight: var(--cui-font-weight-medium);\n transition:\n background-color var(--cui-transition-fast),\n border-color var(--cui-transition-fast),\n box-shadow var(--cui-transition-fast);\n}\n.buttonFace:hover:not(.disabled) .button {\n background-color: var(--cui-color-surface-secondary);\n border-color: var(--cui-color-border-hover);\n}\n.buttonFace:focus-within .button {\n border-color: var(--cui-color-border-focus);\n box-shadow: var(--cui-focus-ring);\n}\n.buttonFace.invalid .button {\n border-color: var(--cui-color-danger-border);\n}\n.buttonFace.disabled {\n cursor: not-allowed;\n}\n.buttonFace.disabled .button {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text-disabled);\n}\n\n.buttonIcon {\n width: 1.125rem;\n height: 1.125rem;\n}\n\n.summary {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: var(--cui-font-size-sm);\n color: var(--cui-color-text-muted);\n}\n\n/* ---------- Variant: field ---------- */\n.fieldFace {\n position: relative;\n display: flex;\n align-items: center;\n gap: var(--cui-space-3);\n box-sizing: border-box;\n width: 100%;\n min-height: var(--cui-control-height-md);\n padding: 0 0 0 var(--cui-space-4);\n background-color: var(--cui-color-surface);\n border: var(--cui-control-border-width) solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n font-size: var(--cui-font-size-sm);\n color: var(--cui-color-text);\n cursor: pointer;\n overflow: hidden;\n transition:\n border-color var(--cui-transition-fast),\n box-shadow var(--cui-transition-fast);\n}\n.fieldFace:hover:not(.disabled) {\n border-color: var(--cui-color-border-hover);\n}\n.fieldFace:focus-within {\n border-color: var(--cui-color-border-focus);\n box-shadow: var(--cui-focus-ring);\n}\n.fieldFace.invalid:focus-within {\n border-color: var(--cui-color-danger-border-hover);\n box-shadow: var(--cui-focus-ring-danger);\n}\n.fieldFace.disabled {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n\n.fieldValue {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.fieldPlaceholder {\n color: var(--cui-color-placeholder);\n}\n\n.browse {\n align-self: stretch;\n display: inline-flex;\n align-items: center;\n flex-shrink: 0;\n padding: 0 var(--cui-space-4);\n background-color: var(--cui-color-surface-secondary);\n border-inline-start: 1px solid var(--cui-color-border);\n color: var(--cui-color-text-secondary);\n font-weight: var(--cui-font-weight-medium);\n}\n\n/* ---------- Variant: image ---------- */\n.imageRoot {\n display: flex;\n align-items: center;\n gap: var(--cui-space-4);\n}\n\n.tile {\n position: relative;\n display: flex;\n flex-shrink: 0;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n overflow: hidden;\n background-color: var(--cui-color-surface-secondary);\n border: var(--cui-control-border-width) dashed var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text-muted);\n font-size: var(--cui-font-size-xs);\n text-align: center;\n cursor: pointer;\n transition:\n border-color var(--cui-transition-fast),\n box-shadow var(--cui-transition-fast);\n}\n.circle {\n border-radius: var(--cui-radius-full);\n}\n.tile:hover:not(.disabled) {\n border-color: var(--cui-color-border-hover);\n}\n.tile:focus-within {\n border-color: var(--cui-color-border-focus);\n box-shadow: var(--cui-focus-ring);\n}\n.tile.disabled {\n cursor: not-allowed;\n opacity: 0.6;\n}\n\n.tileImage {\n width: 100%;\n height: 100%;\n object-fit: cover;\n}\n\n.tileEmpty {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: var(--cui-space-1);\n padding: var(--cui-space-2);\n overflow: hidden;\n}\n\n.overlay {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: rgb(0 0 0 / 0.5);\n color: var(--cui-color-white);\n font-weight: var(--cui-font-weight-medium);\n opacity: 0;\n transition: opacity var(--cui-transition-fast);\n}\n.tile:hover:not(.disabled) .overlay,\n.tile:focus-within .overlay {\n opacity: 1;\n}\n\n.imageSide {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: var(--cui-space-1);\n min-width: 0;\n font-size: var(--cui-font-size-sm);\n color: var(--cui-color-text);\n}\n\n.removeText {\n padding: 0;\n background: transparent;\n border: 0;\n color: var(--cui-color-danger);\n font: inherit;\n font-size: var(--cui-font-size-sm);\n cursor: pointer;\n}\n.removeText:hover:not(:disabled) {\n text-decoration: underline;\n}\n.removeText:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 2px;\n}\n.removeText:disabled {\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n\n/* ---------- Variant: gallery ---------- */\n.gallery {\n display: grid;\n grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));\n gap: var(--cui-space-3);\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.thumbItem,\n.addItem {\n position: relative;\n aspect-ratio: 1;\n}\n\n.thumbItem {\n overflow: hidden;\n background-color: var(--cui-color-surface-secondary);\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n}\n\n.thumbImage {\n width: 100%;\n height: 100%;\n object-fit: cover;\n}\n\n.thumbFallback {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: 100%;\n color: var(--cui-color-text-muted);\n}\n\n.thumbName {\n position: absolute;\n inset-inline: 0;\n bottom: 0;\n padding: 2px var(--cui-space-2);\n overflow: hidden;\n background-color: rgb(0 0 0 / 0.55);\n color: var(--cui-color-white);\n font-size: var(--cui-font-size-xs);\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.thumbRemove {\n position: absolute;\n top: var(--cui-space-1);\n inset-inline-end: var(--cui-space-1);\n background-color: rgb(0 0 0 / 0.6);\n color: var(--cui-color-white);\n}\n.thumbRemove:hover:not(:disabled) {\n background-color: rgb(0 0 0 / 0.8);\n color: var(--cui-color-white);\n}\n\n.addTile {\n position: relative;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: var(--cui-space-1);\n box-sizing: border-box;\n width: 100%;\n height: 100%;\n background-color: var(--cui-color-surface);\n border: var(--cui-control-border-width) dashed var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text-muted);\n font-size: var(--cui-font-size-xs);\n cursor: pointer;\n transition:\n border-color var(--cui-transition-fast),\n box-shadow var(--cui-transition-fast);\n}\n.addTile:hover:not(.disabled) {\n border-color: var(--cui-color-border-hover);\n}\n.addTile:focus-within {\n border-color: var(--cui-color-border-focus);\n box-shadow: var(--cui-focus-ring);\n}\n.addTile.disabled {\n cursor: not-allowed;\n opacity: 0.6;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .zone,\n .button,\n .fieldFace,\n .tile,\n .overlay,\n .addTile {\n transition: none;\n }\n}\n","import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n type ChangeEvent,\n type DragEvent,\n type ReactNode,\n} from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { FormField, useFormFieldControl } from '../FormField';\nimport { fileKey, formatFileSize, isImage, matchesAccept, sameFile } from './fileUtils';\nimport { ImageCropper } from './ImageCropper';\nimport type { FileInputProps } from './FileInput.types';\nimport styles from './FileInput.module.css';\n\nconst canPreview = () => typeof URL !== 'undefined' && typeof URL.createObjectURL === 'function';\n\n/** A preview URL for an image file, or undefined when the environment cannot make one. */\nfunction createPreviewUrl(file: File): string | undefined {\n try {\n return URL.createObjectURL(file);\n } catch {\n return undefined;\n }\n}\n\nconst UploadIcon = ({ className }: { className?: string }) => (\n <svg\n className={className}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.6\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M12 16V4M7 9l5-5 5 5M4 16v3a1 1 0 001 1h14a1 1 0 001-1v-3\" />\n </svg>\n);\n\nconst ImageIcon = ({ className }: { className?: string }) => (\n <svg\n className={className}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.6\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <rect x=\"3\" y=\"4\" width=\"18\" height=\"16\" rx=\"2\" />\n <circle cx=\"9\" cy=\"10\" r=\"1.5\" />\n <path d=\"M21 16l-5-5-8 8\" />\n </svg>\n);\n\nconst FileIcon = ({ className }: { className?: string }) => (\n <svg\n className={className}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.6\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M7 3h7l5 5v12a1 1 0 01-1 1H7a1 1 0 01-1-1V4a1 1 0 011-1z\" />\n <path d=\"M14 3v5h5\" />\n </svg>\n);\n\nconst CloseIcon = () => (\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M6 6l8 8M14 6l-8 8\" />\n </svg>\n);\n\nconst FileInputControl = forwardRef<HTMLInputElement, Omit<FileInputProps, 'label' | 'helperText'>>(\n function FileInputControl(\n {\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n variant = 'dropzone',\n multiple: multipleProp,\n accept: acceptProp,\n maxSize,\n maxFiles,\n preview = true,\n shape = 'square',\n aspectRatio = 4 / 3,\n tileSize = 128,\n crop = true,\n cropOutputWidth,\n cropOutputType,\n cropOutputQuality,\n cropTitle,\n buttonLabel,\n placeholder = 'No file chosen',\n onFilesChange,\n className,\n ...rest\n },\n ref,\n ) {\n const control = useFormFieldControl({\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n });\n const baseId = useId();\n const hintId = `${baseId}-hint`;\n const rejectedId = `${baseId}-rejected`;\n\n const isImageVariant = variant === 'image' || variant === 'gallery';\n const multiple =\n variant === 'gallery' ? true : variant === 'image' ? false : (multipleProp ?? false);\n const accept = acceptProp ?? (isImageVariant ? 'image/*' : undefined);\n\n const inputRef = useRef<HTMLInputElement | null>(null);\n const setRef = useCallback(\n (node: HTMLInputElement | null) => {\n inputRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n },\n [ref],\n );\n\n const [files, setFiles] = useState<File[]>([]);\n const [rejected, setRejected] = useState<string[]>([]);\n const [dragging, setDragging] = useState(false);\n // A picked image waiting in the cropper (image variant). `theme` is the surrounding data-theme.\n const [cropping, setCropping] = useState<{ file: File; theme?: string } | null>(null);\n\n // Object URLs for image previews are created when files are added and released when they go.\n const [previews, setPreviews] = useState<Record<string, string>>({});\n const previewsRef = useRef<Record<string, string>>({});\n useEffect(\n () => () => {\n Object.values(previewsRef.current).forEach((url) => URL.revokeObjectURL(url));\n },\n [],\n );\n\n // Keep the native input's own file list equal to ours, so forms submit what is shown.\n const syncInput = (next: File[]) => {\n try {\n const transfer = new DataTransfer();\n next.forEach((file) => transfer.items.add(file));\n if (inputRef.current) inputRef.current.files = transfer.files;\n } catch {\n // DataTransfer is not available everywhere; the native selection stays as is.\n }\n };\n\n const update = (next: File[]) => {\n const nextPreviews: Record<string, string> = {};\n if (canPreview()) {\n for (const file of next) {\n const key = fileKey(file);\n const existing = previewsRef.current[key];\n if (existing) nextPreviews[key] = existing;\n else if (isImage(file)) {\n const url = createPreviewUrl(file);\n if (url) nextPreviews[key] = url;\n }\n }\n for (const [key, url] of Object.entries(previewsRef.current)) {\n if (!nextPreviews[key]) URL.revokeObjectURL(url);\n }\n }\n previewsRef.current = nextPreviews;\n setPreviews(nextPreviews);\n setFiles(next);\n syncInput(next);\n onFilesChange?.(next);\n };\n\n const addFiles = (incoming: File[]) => {\n if (control.disabled || incoming.length === 0) return;\n const problems: string[] = [];\n const accepted: File[] = [];\n for (const file of incoming) {\n if (!matchesAccept(file, accept)) problems.push(`${file.name}: file type not accepted`);\n else if (maxSize !== undefined && file.size > maxSize)\n problems.push(`${file.name}: larger than ${formatFileSize(maxSize)}`);\n else accepted.push(file);\n }\n\n // Image variant with cropping: hand the picked image to the cropper instead of using it directly.\n const picked = accepted[0];\n if (variant === 'image' && crop && picked && picked.type !== 'image/svg+xml') {\n setRejected(problems);\n setCropping({\n file: picked,\n theme: inputRef.current?.closest('[data-theme]')?.getAttribute('data-theme') ?? undefined,\n });\n return;\n }\n\n let next: File[];\n if (!multiple) {\n next = accepted.length > 0 ? [accepted[0] as File] : files;\n } else {\n next = [...files];\n for (const file of accepted) {\n if (!next.some((existing) => sameFile(existing, file))) next.push(file);\n }\n if (maxFiles !== undefined && next.length > maxFiles) {\n problems.push(`You can add up to ${maxFiles} files`);\n next = next.slice(0, maxFiles);\n }\n }\n setRejected(problems);\n const changed = next.length !== files.length || next.some((file, i) => file !== files[i]);\n if (changed) update(next);\n else syncInput(files);\n };\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n addFiles(Array.from(event.target.files ?? []));\n };\n\n const handleDrop = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setDragging(false);\n addFiles(Array.from(event.dataTransfer.files));\n };\n\n const removeFile = (file: File) => {\n setRejected([]);\n update(files.filter((existing) => existing !== file));\n };\n\n const hint = [\n accept\n ? `Accepted: ${accept\n .split(',')\n .map((t) => t.trim())\n .join(', ')}`\n : null,\n maxSize !== undefined ? `Max ${formatFileSize(maxSize)} each` : null,\n ]\n .filter(Boolean)\n .join(' · ');\n\n const describedBy =\n [\n control['aria-describedby'],\n hint ? hintId : undefined,\n rejected.length ? rejectedId : undefined,\n ]\n .filter(Boolean)\n .join(' ') || undefined;\n const invalid = control.invalid || rejected.length > 0;\n\n const openDialog = () => {\n if (!control.disabled) inputRef.current?.click();\n };\n const dropHandlers = {\n onDragEnter: (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n if (!control.disabled) setDragging(true);\n },\n onDragOver: (event: DragEvent<HTMLElement>) => event.preventDefault(),\n onDragLeave: (event: DragEvent<HTMLElement>) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node | null)) setDragging(false);\n },\n onDrop: handleDrop,\n };\n\n // The real input stays in the page (visually hidden but focusable), so keyboards and forms work.\n const input = (\n <input\n {...rest}\n ref={setRef}\n id={control.id}\n type=\"file\"\n multiple={multiple}\n accept={accept}\n required={control.required && files.length === 0}\n disabled={control.disabled}\n aria-invalid={invalid ? true : undefined}\n aria-describedby={describedBy}\n className={styles.input}\n onChange={handleChange}\n // The visible face forwards its clicks to the input; stop the input's own click from looping back.\n onClick={(event) => event.stopPropagation()}\n />\n );\n\n // Frame of the image variant: circles and squares are 1:1, rectangles use `aspectRatio`.\n const frameAspect = shape === 'rectangle' ? Math.max(0.2, aspectRatio) : 1;\n const tileHeight = Math.round(tileSize / frameAspect);\n const croppedWidth = cropOutputWidth ?? (shape === 'rectangle' ? 800 : 512);\n\n const state = cn(invalid && styles.invalid, control.disabled && styles.disabled);\n const names = files.map((file) => file.name).join(', ');\n const thumb = (file: File, className: string): ReactNode => {\n const url = previews[fileKey(file)];\n return url ? <img src={url} alt=\"\" className={className} /> : null;\n };\n\n const fileList =\n files.length > 0 ? (\n <ul className={styles.list} aria-label=\"Selected files\">\n {files.map((file) => (\n <li key={fileKey(file)} className={styles.item}>\n {preview && previews[fileKey(file)] ? (\n thumb(file, styles.itemThumb ?? '')\n ) : (\n <FileIcon className={styles.itemIcon} />\n )}\n <span className={styles.name}>{file.name}</span>\n <span className={styles.size}>{formatFileSize(file.size)}</span>\n <button\n type=\"button\"\n className={styles.remove}\n aria-label={`Remove ${file.name}`}\n disabled={control.disabled}\n onClick={() => removeFile(file)}\n >\n <CloseIcon />\n </button>\n </li>\n ))}\n </ul>\n ) : null;\n\n const hintText =\n hint && variant !== 'dropzone' ? (\n <span id={hintId} className={styles.hintText}>\n {hint}\n </span>\n ) : null;\n\n let body: ReactNode;\n if (variant === 'button') {\n body = (\n <>\n <div className={styles.buttonRow}>\n <div className={cn(styles.buttonFace, state)} onClick={openDialog}>\n {input}\n <span className={styles.button}>\n <UploadIcon className={styles.buttonIcon} />\n {buttonLabel ?? (multiple ? 'Choose files' : 'Choose file')}\n </span>\n </div>\n <span className={styles.summary}>{names || placeholder}</span>\n </div>\n {hintText}\n {fileList}\n </>\n );\n } else if (variant === 'field') {\n body = (\n <>\n <div className={cn(styles.fieldFace, state)} onClick={openDialog}>\n {input}\n <span className={cn(styles.fieldValue, !names && styles.fieldPlaceholder)}>\n {names || placeholder}\n </span>\n <span className={styles.browse}>Browse</span>\n </div>\n {hintText}\n {fileList}\n </>\n );\n } else if (variant === 'image') {\n const file = files[0];\n const url = file ? previews[fileKey(file)] : undefined;\n body = (\n <div className={styles.imageRoot}>\n <div\n className={cn(\n styles.tile,\n shape === 'circle' && styles.circle,\n dragging && styles.dragging,\n state,\n )}\n style={{ width: tileSize, height: tileHeight }}\n onClick={openDialog}\n {...dropHandlers}\n >\n {input}\n {url ? (\n <img src={url} alt={file?.name ?? ''} className={styles.tileImage} />\n ) : (\n <span className={styles.tileEmpty}>\n <ImageIcon className={styles.icon} />\n <span>{file ? file.name : 'Upload photo'}</span>\n </span>\n )}\n <span className={styles.overlay}>{file ? 'Change' : 'Choose'}</span>\n </div>\n <div className={styles.imageSide}>\n {file ? (\n <>\n <span className={styles.name}>{file.name}</span>\n <span className={styles.size}>{formatFileSize(file.size)}</span>\n <button\n type=\"button\"\n className={styles.removeText}\n disabled={control.disabled}\n onClick={() => removeFile(file)}\n >\n Remove image\n </button>\n </>\n ) : null}\n {hintText}\n </div>\n </div>\n );\n } else if (variant === 'gallery') {\n const full = maxFiles !== undefined && files.length >= maxFiles;\n body = (\n <>\n <ul className={styles.gallery} aria-label=\"Selected images\">\n {files.map((file) => (\n <li key={fileKey(file)} className={styles.thumbItem}>\n {previews[fileKey(file)] ? (\n thumb(file, styles.thumbImage ?? '')\n ) : (\n <span className={styles.thumbFallback}>\n <FileIcon className={styles.icon} />\n </span>\n )}\n <span className={styles.thumbName}>{file.name}</span>\n <button\n type=\"button\"\n className={cn(styles.remove, styles.thumbRemove)}\n aria-label={`Remove ${file.name}`}\n disabled={control.disabled}\n onClick={() => removeFile(file)}\n >\n <CloseIcon />\n </button>\n </li>\n ))}\n {full ? null : (\n <li className={styles.addItem}>\n <div\n className={cn(styles.addTile, dragging && styles.dragging, state)}\n onClick={openDialog}\n {...dropHandlers}\n >\n {input}\n <ImageIcon className={styles.icon} />\n <span>Add images</span>\n </div>\n </li>\n )}\n </ul>\n {full ? input : null}\n {hintText}\n </>\n );\n } else {\n body = (\n <>\n <div\n className={cn(styles.zone, dragging && styles.dragging, state)}\n onClick={openDialog}\n {...dropHandlers}\n >\n {input}\n <UploadIcon className={styles.icon} />\n <span className={styles.prompt}>\n <span className={styles.browseLink}>\n {multiple ? 'Choose files' : 'Choose a file'}\n </span>{' '}\n or drag and drop\n </span>\n {hint ? (\n <span id={hintId} className={styles.hint}>\n {hint}\n </span>\n ) : null}\n </div>\n {fileList}\n </>\n );\n }\n\n return (\n <div className={cn(styles.root, className)}>\n {body}\n {cropping ? (\n <ImageCropper\n file={cropping.file}\n aspect={frameAspect}\n shape={shape === 'circle' ? 'circle' : 'rect'}\n outputWidth={croppedWidth}\n outputType={\n cropOutputType ??\n (['image/png', 'image/jpeg', 'image/webp'].includes(cropping.file.type)\n ? (cropping.file.type as 'image/png' | 'image/jpeg' | 'image/webp')\n : 'image/png')\n }\n outputQuality={cropOutputQuality}\n title={cropTitle}\n theme={cropping.theme}\n onApply={(cropped) => {\n setCropping(null);\n update([cropped]);\n inputRef.current?.focus({ preventScroll: true });\n }}\n onCancel={() => {\n setCropping(null);\n // The browser's own file list still holds the picked image; put ours back.\n syncInput(files);\n inputRef.current?.focus({ preventScroll: true });\n }}\n />\n ) : null}\n {rejected.length > 0 ? (\n <p id={rejectedId} className={styles.rejected} role=\"alert\">\n {rejected.join('. ')}\n </p>\n ) : null}\n </div>\n );\n },\n);\n\n/**\n * File picker in five looks (`variant`): drag-and-drop zone, button, input-like field, single image\n * tile and image gallery. Files are checked against `accept`, `maxSize` and `maxFiles`.\n */\nexport const FileInput = forwardRef<HTMLInputElement, FileInputProps>(function FileInput(\n { label, helperText, ...props },\n ref,\n) {\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n // Without its own label/helper/error, FileInput defers to an enclosing <FormField>.\n if (!label && !helperText && !props.error) {\n return <FileInputControl {...props} ref={ref} />;\n }\n\n return (\n <FormField\n id={props.id}\n label={label}\n helperText={helperText}\n error={props.error}\n required={props.required}\n disabled={props.disabled}\n >\n <FileInputControl {...props} ref={ref} />\n </FormField>\n );\n});\n",".textarea {\n display: block;\n box-sizing: border-box;\n width: 100%;\n min-height: var(--cui-control-height-md);\n padding: var(--cui-space-2) var(--cui-space-4);\n background-color: var(--cui-color-surface);\n border: var(--cui-control-border-width) solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-sm);\n line-height: var(--cui-line-height);\n transition:\n border-color var(--cui-transition-fast),\n box-shadow var(--cui-transition-fast);\n}\n\n.textarea::placeholder {\n color: var(--cui-color-placeholder);\n}\n\n.textarea:hover:not(:disabled):not(.invalid) {\n border-color: var(--cui-color-border-hover);\n}\n\n.textarea:focus {\n border-color: var(--cui-color-border-focus);\n outline: none;\n box-shadow: var(--cui-focus-ring);\n}\n\n.resize-none {\n resize: none;\n}\n.resize-vertical {\n resize: vertical;\n}\n.resize-horizontal {\n resize: horizontal;\n}\n.resize-both {\n resize: both;\n}\n\n.invalid {\n border-color: var(--cui-color-danger-border);\n}\n.invalid:hover:not(:disabled) {\n border-color: var(--cui-color-danger-border-hover);\n}\n.invalid:focus {\n border-color: var(--cui-color-danger-border-hover);\n box-shadow: var(--cui-focus-ring-danger);\n}\n\n.readOnly {\n background-color: var(--cui-color-surface-secondary);\n}\n\n.textarea:disabled {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n resize: none;\n}\n","import { forwardRef } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { FormField, useFormFieldControl } from '../FormField';\nimport type { TextareaProps } from './Textarea.types';\nimport styles from './Textarea.module.css';\n\nconst TextareaControl = forwardRef<\n HTMLTextAreaElement,\n Omit<TextareaProps, 'label' | 'helperText'>\n>(function TextareaControl(\n {\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n rows = 3,\n resize = 'vertical',\n readOnly,\n className,\n ...rest\n },\n ref,\n) {\n const control = useFormFieldControl({\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n });\n\n return (\n <textarea\n {...rest}\n ref={ref}\n id={control.id}\n rows={rows}\n required={control.required}\n disabled={control.disabled}\n readOnly={readOnly}\n aria-invalid={control['aria-invalid']}\n aria-describedby={control['aria-describedby']}\n className={cn(\n styles.textarea,\n styles[`resize-${resize}`],\n control.invalid && styles.invalid,\n readOnly && styles.readOnly,\n className,\n )}\n />\n );\n});\n\n/** Multi-line text input with the same label, helper and error handling as `Input`. */\nexport const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(function Textarea(\n { label, helperText, ...props },\n ref,\n) {\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n // Without its own label/helper/error, Textarea defers to an enclosing <FormField>.\n if (!label && !helperText && !props.error) {\n return <TextareaControl {...props} ref={ref} />;\n }\n\n return (\n <FormField\n id={props.id}\n label={label}\n helperText={helperText}\n error={props.error}\n required={props.required}\n disabled={props.disabled}\n >\n <TextareaControl {...props} ref={ref} />\n </FormField>\n );\n});\n",".root {\n display: flex;\n flex-direction: column;\n gap: var(--cui-space-1);\n}\n\n.label {\n position: relative;\n display: inline-flex;\n align-items: center;\n gap: var(--cui-space-3);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-sm);\n line-height: var(--cui-line-height);\n color: var(--cui-color-text);\n cursor: pointer;\n}\n\n.disabled {\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n\n.input {\n position: absolute;\n top: 0;\n left: 0;\n width: 2.75rem;\n height: 1.5rem;\n margin: 0;\n opacity: 0;\n cursor: inherit;\n}\n\n.track {\n position: relative;\n flex-shrink: 0;\n box-sizing: border-box;\n width: 2.75rem;\n height: 1.5rem;\n background-color: var(--cui-color-text-disabled);\n border-radius: var(--cui-radius-full);\n transition:\n background-color var(--cui-transition-fast),\n box-shadow var(--cui-transition-fast);\n}\n\n.thumb {\n position: absolute;\n top: 2px;\n inset-inline-start: 2px;\n width: 1.25rem;\n height: 1.25rem;\n background-color: var(--cui-color-white);\n border-radius: var(--cui-radius-full);\n box-shadow: var(--cui-shadow-sm);\n transition: transform var(--cui-transition-fast);\n}\n\n.input:checked + .track {\n background-color: var(--cui-color-primary);\n}\n.input:checked + .track .thumb {\n transform: translateX(1.25rem);\n}\n.input:checked + .track .thumb:dir(rtl) {\n transform: translateX(-1.25rem);\n}\n\n.input:focus-visible + .track {\n box-shadow: var(--cui-focus-ring);\n}\n\n.input.invalid + .track {\n box-shadow: 0 0 0 2px var(--cui-color-danger-border);\n}\n.input.invalid:focus-visible + .track {\n box-shadow: var(--cui-focus-ring-danger);\n}\n\n.input:disabled + .track {\n opacity: 0.5;\n}\n\n.required {\n margin-inline-start: var(--cui-space-1);\n color: var(--cui-color-danger);\n}\n\n.message {\n margin: 0;\n padding-inline-start: calc(2.75rem + var(--cui-space-3));\n font-size: var(--cui-font-size-sm);\n}\n.helper {\n color: var(--cui-color-text-muted);\n}\n.error {\n color: var(--cui-color-danger);\n}\n\n@media (prefers-reduced-motion: reduce) {\n .track,\n .thumb {\n transition: none;\n }\n}\n","import { forwardRef } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { useFormFieldControl } from '../FormField';\nimport type { SwitchProps } from './Switch.types';\nimport styles from './Switch.module.css';\n\n/** On/off toggle. A native checkbox with `role=\"switch\"`, so it works in forms and with keyboards. */\nexport const Switch = forwardRef<HTMLInputElement, SwitchProps>(function Switch(\n {\n label,\n helperText,\n error,\n id,\n required,\n disabled,\n 'aria-describedby': ariaDescribedBy,\n className,\n ...rest\n },\n ref,\n) {\n const control = useFormFieldControl({\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n });\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n const messageId = `${control.id}-message`;\n const hasMessage = Boolean(error || helperText);\n const describedBy =\n [control['aria-describedby'], hasMessage ? messageId : undefined].filter(Boolean).join(' ') ||\n undefined;\n\n return (\n <div className={cn(styles.root, className)}>\n <label className={cn(styles.label, control.disabled && styles.disabled)}>\n <input\n {...rest}\n ref={ref}\n id={control.id}\n type=\"checkbox\"\n role=\"switch\"\n required={control.required}\n disabled={control.disabled}\n aria-invalid={control['aria-invalid']}\n aria-describedby={describedBy}\n className={cn(styles.input, control.invalid && styles.invalid)}\n />\n <span className={styles.track} aria-hidden=\"true\">\n <span className={styles.thumb} />\n </span>\n {label ? (\n <span className={styles.text}>\n {label}\n {control.required ? (\n <span className={styles.required} aria-hidden=\"true\">\n *\n </span>\n ) : null}\n </span>\n ) : null}\n </label>\n {hasMessage ? (\n <p\n id={messageId}\n className={cn(styles.message, error ? styles.error : styles.helper)}\n role={error ? 'alert' : undefined}\n >\n {error || helperText}\n </p>\n ) : null}\n </div>\n );\n});\n",".root {\n --badge-color: var(--cui-color-text-secondary);\n display: inline-flex;\n align-items: center;\n gap: 0.375rem;\n box-sizing: border-box;\n padding: 2px 10px;\n border: 1px solid color-mix(in srgb, var(--badge-color) 25%, transparent);\n border-radius: var(--cui-radius-full);\n background-color: color-mix(in srgb, var(--badge-color) 10%, transparent);\n color: var(--badge-color);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-xs);\n font-weight: var(--cui-font-weight-semibold);\n line-height: var(--cui-line-height);\n white-space: nowrap;\n}\n\n.dot {\n width: 0.375rem;\n height: 0.375rem;\n border-radius: var(--cui-radius-full);\n background-color: var(--badge-color);\n}\n\n.neutral {\n --badge-color: var(--cui-color-text-secondary);\n}\n.primary {\n --badge-color: var(--cui-color-primary);\n}\n.success {\n --badge-color: var(--cui-color-success);\n}\n.warning {\n --badge-color: var(--cui-color-warning);\n}\n.danger {\n --badge-color: var(--cui-color-danger);\n}\n.info {\n --badge-color: var(--cui-color-info);\n}\n","import { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport type { BadgeProps } from './Badge.types';\nimport styles from './Badge.module.css';\n\n/** Small pill for statuses and counts. */\nexport function Badge({\n color = 'neutral',\n dot = false,\n className,\n children,\n ...rest\n}: BadgeProps) {\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n return (\n <span {...rest} className={cn(styles.root, styles[color], className)}>\n {dot ? <span className={styles.dot} aria-hidden=\"true\" /> : null}\n {children}\n </span>\n );\n}\n",".root {\n min-width: 0;\n}\n\n.list {\n display: flex;\n align-items: center;\n gap: var(--cui-space-6);\n overflow-x: auto;\n border-bottom: 1px solid var(--cui-color-border);\n}\n\n.tab {\n position: relative;\n display: inline-flex;\n align-items: center;\n gap: var(--cui-space-2);\n padding: 0 0 var(--cui-space-3);\n background: transparent;\n border: 0;\n color: var(--cui-color-text-muted);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-sm);\n font-weight: var(--cui-font-weight-medium);\n white-space: nowrap;\n cursor: pointer;\n transition: color var(--cui-transition-fast);\n}\n\n.tab::after {\n content: '';\n position: absolute;\n inset-inline: 0;\n bottom: -1px;\n height: 2px;\n background-color: transparent;\n transition: background-color var(--cui-transition-fast);\n}\n\n.tab:hover:not(:disabled) {\n color: var(--cui-color-text-secondary);\n}\n\n.selected,\n.selected:hover:not(:disabled) {\n color: var(--cui-color-primary);\n}\n.selected::after {\n background-color: var(--cui-color-primary);\n}\n\n.tab:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 2px;\n border-radius: var(--cui-radius-sm);\n}\n\n.tab:disabled {\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n\n.icon {\n display: inline-flex;\n width: 1rem;\n height: 1rem;\n}\n.icon > svg {\n width: 100%;\n height: 100%;\n}\n\n.panel {\n padding-top: var(--cui-space-4);\n outline: none;\n}\n.panel:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 2px;\n border-radius: var(--cui-radius-sm);\n}\n","import { useId, useRef, useState, type KeyboardEvent } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport type { TabsProps } from './Tabs.types';\nimport styles from './Tabs.module.css';\n\n/**\n * Underlined tabs following the WAI-ARIA tabs pattern: arrow keys, Home and End\n * move between tabs; the active tab's panel is shown below the list.\n */\nexport function Tabs<T extends string = string>({\n items,\n value,\n defaultValue,\n onValueChange,\n className,\n 'aria-label': ariaLabel,\n ...rest\n}: TabsProps<T>) {\n const baseId = useId();\n const tabRefs = useRef<(HTMLButtonElement | null)[]>([]);\n const firstEnabled = items.find((item) => !item.disabled)?.value;\n const [internal, setInternal] = useState<T | undefined>(defaultValue ?? firstEnabled);\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n const active = value ?? internal;\n const activeIndex = items.findIndex((item) => item.value === active);\n const activeItem = items[activeIndex];\n\n const select = (next: T) => {\n if (value === undefined) setInternal(next);\n onValueChange?.(next);\n };\n\n const move = (from: number, direction: 1 | -1 | 'first' | 'last') => {\n const count = items.length;\n let index = direction === 'first' ? -1 : direction === 'last' ? count : from;\n const step = direction === 'first' ? 1 : direction === 'last' ? -1 : direction;\n for (let i = 0; i < count; i++) {\n index = (index + step + count) % count;\n const item = items[index];\n if (item && !item.disabled) {\n select(item.value);\n tabRefs.current[index]?.focus();\n return;\n }\n }\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLButtonElement>, index: number) => {\n const rtl = getComputedStyle(event.currentTarget).direction === 'rtl';\n const next = rtl ? 'ArrowLeft' : 'ArrowRight';\n const previous = rtl ? 'ArrowRight' : 'ArrowLeft';\n if (event.key === next) move(index, 1);\n else if (event.key === previous) move(index, -1);\n else if (event.key === 'Home') move(index, 'first');\n else if (event.key === 'End') move(index, 'last');\n else return;\n event.preventDefault();\n };\n\n const tabId = (index: number) => `${baseId}-tab-${index}`;\n const panelId = (index: number) => `${baseId}-panel-${index}`;\n\n return (\n <div {...rest} className={cn(styles.root, className)}>\n <div role=\"tablist\" aria-label={ariaLabel} className={styles.list}>\n {items.map((item, index) => {\n const selected = index === activeIndex;\n return (\n <button\n key={item.value}\n ref={(node) => {\n tabRefs.current[index] = node;\n }}\n id={tabId(index)}\n type=\"button\"\n role=\"tab\"\n aria-selected={selected}\n aria-controls={selected && item.content !== undefined ? panelId(index) : undefined}\n tabIndex={selected ? 0 : -1}\n disabled={item.disabled}\n className={cn(styles.tab, selected && styles.selected)}\n onClick={() => select(item.value)}\n onKeyDown={(event) => handleKeyDown(event, index)}\n >\n {item.icon ? (\n <span className={styles.icon} aria-hidden=\"true\">\n {item.icon}\n </span>\n ) : null}\n {item.label}\n </button>\n );\n })}\n </div>\n {activeItem && activeItem.content !== undefined ? (\n <div\n role=\"tabpanel\"\n id={panelId(activeIndex)}\n aria-labelledby={tabId(activeIndex)}\n tabIndex={0}\n className={styles.panel}\n >\n {activeItem.content}\n </div>\n ) : null}\n </div>\n );\n}\n",".root {\n min-width: 0;\n}\n\n.header {\n display: flex;\n align-items: center;\n gap: var(--cui-space-4);\n margin-bottom: var(--cui-space-4);\n}\n\n.heading {\n flex-shrink: 0;\n}\n\n.title {\n margin: 0;\n font-size: var(--cui-font-size-sm);\n font-weight: var(--cui-font-weight-semibold);\n line-height: var(--cui-line-height);\n color: var(--cui-color-text);\n}\n\n.subtitle {\n margin: 2px 0 0;\n font-size: var(--cui-font-size-xs);\n color: var(--cui-color-text-muted);\n}\n\n.divider {\n flex: 1;\n height: 1px;\n background: linear-gradient(to right, var(--cui-color-border), transparent);\n}\n\n.fields {\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n gap: var(--cui-space-6);\n}\n\n@media (min-width: 768px) {\n .columns2 {\n grid-template-columns: repeat(2, minmax(0, 1fr));\n }\n .columns3 {\n grid-template-columns: repeat(3, minmax(0, 1fr));\n }\n}\n","import { createElement, useId } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport type { FormSectionProps } from './FormSection.types';\nimport styles from './FormSection.module.css';\n\n/**\n * A titled group of form fields: heading + optional subtitle, a divider line,\n * then the fields in a grid. Use it to split long forms into readable sections.\n */\nexport function FormSection({\n title,\n subtitle,\n children,\n columns = 1,\n headingLevel = 3,\n className,\n ...rest\n}: FormSectionProps) {\n const headingId = useId();\n const hasHeader = Boolean(title || subtitle);\n\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n return (\n <section\n {...rest}\n aria-labelledby={title ? headingId : rest['aria-labelledby']}\n className={cn(styles.root, className)}\n >\n {hasHeader ? (\n <div className={styles.header}>\n <div className={styles.heading}>\n {title\n ? createElement(`h${headingLevel}`, { id: headingId, className: styles.title }, title)\n : null}\n {subtitle ? <p className={styles.subtitle}>{subtitle}</p> : null}\n </div>\n <span className={styles.divider} aria-hidden=\"true\" />\n </div>\n ) : null}\n <div className={cn(styles.fields, styles[`columns${columns}`])}>{children}</div>\n </section>\n );\n}\n",".root {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n overflow: hidden;\n box-sizing: border-box;\n border-radius: var(--cui-radius-full);\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text-secondary);\n font-family: var(--cui-font-family);\n font-weight: var(--cui-font-weight-semibold);\n line-height: 1;\n user-select: none;\n}\n\n.xs {\n width: 1.75rem;\n height: 1.75rem;\n font-size: 0.6875rem;\n}\n.sm {\n width: 2rem;\n height: 2rem;\n font-size: var(--cui-font-size-xs);\n}\n.md {\n width: 2.5rem;\n height: 2.5rem;\n font-size: var(--cui-font-size-sm);\n}\n.lg {\n width: 3rem;\n height: 3rem;\n font-size: var(--cui-font-size-md);\n}\n.xl {\n width: 4rem;\n height: 4rem;\n font-size: var(--cui-font-size-xl);\n}\n\n.image {\n width: 100%;\n height: 100%;\n object-fit: cover;\n}\n\n.fallback {\n width: 60%;\n height: 60%;\n}\n\n/* Name-derived tones (translucent token colors work in light and dark) */\n.tone0 {\n background-color: color-mix(in srgb, var(--cui-color-primary) 16%, transparent);\n color: var(--cui-color-primary);\n}\n.tone1 {\n background-color: color-mix(in srgb, var(--cui-color-info) 16%, transparent);\n color: var(--cui-color-info);\n}\n.tone2 {\n background-color: color-mix(in srgb, var(--cui-color-success) 16%, transparent);\n color: var(--cui-color-success);\n}\n.tone3 {\n background-color: color-mix(in srgb, var(--cui-color-warning) 16%, transparent);\n color: var(--cui-color-warning);\n}\n.tone4 {\n background-color: color-mix(in srgb, var(--cui-color-danger) 16%, transparent);\n color: var(--cui-color-danger);\n}\n\n.primary {\n background: linear-gradient(\n to bottom right,\n var(--cui-color-primary),\n color-mix(in srgb, var(--cui-color-primary) 70%, transparent)\n );\n color: var(--cui-color-on-primary);\n}\n","import { useState } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport type { AvatarProps } from './Avatar.types';\nimport styles from './Avatar.module.css';\n\nconst TONES = [styles.tone0, styles.tone1, styles.tone2, styles.tone3, styles.tone4];\n\nexport function getInitials(name?: string | null): string {\n const words = (name ?? '').trim().split(/\\s+/).filter(Boolean);\n if (words.length === 0) return '';\n const first = words[0]?.[0] ?? '';\n const last = words.length > 1 ? (words[words.length - 1]?.[0] ?? '') : '';\n return (first + last).toUpperCase();\n}\n\n/** Stable pick of a tone from the name, so a person always gets the same color. */\nfunction toneFor(name?: string | null): string | undefined {\n const text = name ?? '';\n let hash = 0;\n for (let i = 0; i < text.length; i++) hash = (hash * 31 + text.charCodeAt(i)) >>> 0;\n return TONES[hash % TONES.length];\n}\n\n/** A photo when available, otherwise initials on a color derived from the name. */\nexport function Avatar({ name, src, size = 'md', tone = 'auto', className, ...rest }: AvatarProps) {\n const [failedSrc, setFailedSrc] = useState<string | null>(null);\n const showImage = Boolean(src) && src !== failedSrc;\n const initials = getInitials(name);\n\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n return (\n <span\n role={rest['aria-hidden'] ? undefined : 'img'}\n aria-label={rest['aria-hidden'] || !name ? undefined : name}\n {...rest}\n className={cn(\n styles.root,\n styles[size],\n !showImage && (tone === 'primary' ? styles.primary : toneFor(name)),\n className,\n )}\n >\n {showImage ? (\n <img\n className={styles.image}\n src={src ?? undefined}\n alt=\"\"\n onError={() => setFailedSrc(src ?? null)}\n />\n ) : initials ? (\n <span aria-hidden=\"true\">{initials}</span>\n ) : (\n <svg className={styles.fallback} viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\">\n <circle cx=\"12\" cy=\"8\" r=\"4\" fill=\"currentColor\" />\n <path d=\"M4 21c0-4.4 3.6-7 8-7s8 2.6 8 7z\" fill=\"currentColor\" />\n </svg>\n )}\n </span>\n );\n}\n",".root {\n position: relative;\n display: inline-block;\n}\n\n.rootSidebar {\n display: block;\n width: 100%;\n}\n\n.contents {\n display: contents;\n}\n\n/* Trigger: header (round avatar) */\n.triggerHeader {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 2.5rem;\n height: 2.5rem;\n padding: 0;\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-full);\n box-shadow: 0 0 0 2px transparent;\n cursor: pointer;\n transition: box-shadow var(--cui-transition-fast);\n}\n.triggerHeader:hover {\n box-shadow: 0 0 0 2px color-mix(in srgb, var(--cui-color-primary) 20%, transparent);\n}\n.triggerHeader.triggerOpen {\n box-shadow: 0 0 0 2px color-mix(in srgb, var(--cui-color-primary) 30%, transparent);\n}\n\n/* Trigger: sidebar row */\n.triggerSidebar {\n display: flex;\n align-items: center;\n gap: var(--cui-space-2);\n box-sizing: border-box;\n width: 100%;\n padding: var(--cui-space-1);\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-md);\n color: var(--cui-color-text);\n font-family: var(--cui-font-family);\n text-align: start;\n cursor: pointer;\n transition: background-color var(--cui-transition-fast);\n}\n.triggerSidebar:hover,\n.triggerSidebar.triggerOpen {\n background-color: var(--cui-color-surface-secondary);\n}\n.collapsed {\n justify-content: center;\n}\n\n.triggerHeader:focus-visible,\n.triggerSidebar:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: var(--cui-focus-ring-offset);\n}\n\n.identityText {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-width: 0;\n line-height: 1.25;\n}\n.triggerName {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: var(--cui-font-size-sm);\n font-weight: var(--cui-font-weight-medium);\n}\n.triggerRole {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: var(--cui-font-size-xs);\n color: var(--cui-color-text-muted);\n}\n\n/* Panel (rendered in <body>) */\n.panel {\n position: fixed;\n z-index: var(--cui-z-popover);\n box-sizing: border-box;\n width: 22rem;\n max-width: calc(100vw - 1.5rem);\n max-height: calc(100vh - 1.5rem);\n overflow-y: auto;\n padding: var(--cui-space-2);\n background-color: var(--cui-color-surface);\n color: var(--cui-color-text);\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-xl);\n box-shadow: var(--cui-shadow-lg);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-sm);\n line-height: var(--cui-line-height);\n outline: none;\n transform-origin: top right;\n animation: cui-account-in 0.2s ease-out;\n}\n.panelSidebar {\n transform-origin: bottom left;\n}\n\n@keyframes cui-account-in {\n from {\n opacity: 0;\n transform: scale(0.95);\n }\n}\n\n.identity {\n display: flex;\n flex-direction: column;\n align-items: center;\n padding: var(--cui-space-3) var(--cui-space-4) var(--cui-space-2);\n text-align: center;\n}\n\n.email {\n max-width: 100%;\n margin: 0 0 var(--cui-space-2);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: var(--cui-font-size-xs);\n font-weight: var(--cui-font-weight-medium);\n color: var(--cui-color-text-secondary);\n}\n\n.avatarRing {\n display: inline-flex;\n padding: 3px;\n border-radius: var(--cui-radius-full);\n background-color: color-mix(in srgb, var(--cui-color-primary) 15%, transparent);\n}\n.avatarInner {\n display: inline-flex;\n padding: 2px;\n border-radius: var(--cui-radius-full);\n background-color: var(--cui-color-surface);\n}\n\n.greeting {\n margin: var(--cui-space-2) 0 0;\n font-size: var(--cui-font-size-lg);\n font-weight: var(--cui-font-weight-normal);\n line-height: 1.25;\n color: var(--cui-color-text);\n}\n\n.role {\n margin-top: 6px;\n padding: 2px 10px;\n border: 1px solid color-mix(in srgb, var(--cui-color-primary) 20%, transparent);\n border-radius: var(--cui-radius-md);\n background-color: color-mix(in srgb, var(--cui-color-primary) 7%, transparent);\n font-size: 0.6875rem;\n font-weight: var(--cui-font-weight-semibold);\n color: var(--cui-color-primary);\n}\n\n.pills {\n display: flex;\n flex-wrap: wrap;\n justify-content: center;\n gap: var(--cui-space-2);\n margin-top: var(--cui-space-3);\n}\n\n.pill {\n display: inline-flex;\n align-items: center;\n gap: var(--cui-space-2);\n padding: 6px var(--cui-space-4);\n background-color: var(--cui-color-surface);\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-md);\n color: var(--cui-color-text-secondary);\n font: inherit;\n font-weight: var(--cui-font-weight-medium);\n text-decoration: none;\n cursor: pointer;\n transition:\n background-color var(--cui-transition-fast),\n border-color var(--cui-transition-fast),\n color var(--cui-transition-fast);\n}\n.pill:hover:not(:disabled) {\n background-color: color-mix(in srgb, var(--cui-color-primary) 4%, var(--cui-color-surface));\n border-color: color-mix(in srgb, var(--cui-color-primary) 30%, transparent);\n color: var(--cui-color-primary);\n}\n.pill:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.actionIcon {\n display: inline-flex;\n flex-shrink: 0;\n width: 1.125rem;\n height: 1.125rem;\n}\n.actionIcon > svg {\n width: 100%;\n height: 100%;\n}\n.externalIcon {\n width: 0.8125rem;\n height: 0.8125rem;\n color: var(--cui-color-text-disabled);\n}\n\n.details {\n margin: 0 0 var(--cui-space-2);\n padding: var(--cui-space-2) var(--cui-space-3);\n background-color: var(--cui-color-surface-secondary);\n border-radius: var(--cui-radius-lg);\n font-size: var(--cui-font-size-xs);\n}\n.detailRow {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: var(--cui-space-3);\n}\n.detailRow + .detailRow {\n margin-top: var(--cui-space-1);\n padding-top: var(--cui-space-1);\n border-top: 1px solid var(--cui-color-border);\n}\n.detailRow dt {\n color: var(--cui-color-text-muted);\n}\n.detailRow dd {\n margin: 0;\n text-align: end;\n font-weight: var(--cui-font-weight-medium);\n}\n\n/* App launcher */\n.apps {\n margin-bottom: var(--cui-space-2);\n padding: 10px 6px 6px;\n background-color: var(--cui-color-surface-secondary);\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n}\n.appsTitle {\n margin: 0;\n padding: 0 var(--cui-space-3) var(--cui-space-1);\n font-size: var(--cui-font-size-xs);\n font-weight: var(--cui-font-weight-medium);\n color: var(--cui-color-text-muted);\n}\n.grid {\n display: grid;\n grid-template-columns: repeat(3, minmax(0, 1fr));\n}\n\n.app {\n display: flex;\n flex-direction: column;\n align-items: center;\n padding: var(--cui-space-2) var(--cui-space-1) 6px;\n border: 1px solid transparent;\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text-secondary);\n text-decoration: none;\n transition:\n background-color var(--cui-transition-fast),\n border-color var(--cui-transition-fast),\n color var(--cui-transition-fast);\n}\n.app:hover {\n background-color: var(--cui-color-surface);\n border-color: color-mix(in srgb, var(--cui-color-primary) 25%, transparent);\n color: var(--cui-color-primary);\n}\n.app:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: -2px;\n}\n\n.tile {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 2.75rem;\n height: 2.75rem;\n border-radius: var(--cui-radius-lg);\n box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.05);\n}\n.tile > svg {\n width: 1.375rem;\n height: 1.375rem;\n transition: transform 0.2s ease-out;\n}\n.app:hover .tile > svg {\n transform: scale(1.18);\n}\n\n.tonePrimary {\n background-color: color-mix(in srgb, var(--cui-color-primary) 12%, transparent);\n color: var(--cui-color-primary);\n}\n.toneInfo {\n background-color: color-mix(in srgb, var(--cui-color-info) 14%, transparent);\n color: var(--cui-color-info);\n}\n.toneSuccess {\n background-color: color-mix(in srgb, var(--cui-color-success) 14%, transparent);\n color: var(--cui-color-success);\n}\n.toneWarning {\n background-color: color-mix(in srgb, var(--cui-color-warning) 14%, transparent);\n color: var(--cui-color-warning);\n}\n.toneDanger {\n background-color: color-mix(in srgb, var(--cui-color-danger) 14%, transparent);\n color: var(--cui-color-danger);\n}\n.toneNeutral {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text-secondary);\n}\n\n.appName {\n margin-top: 6px;\n text-align: center;\n font-size: var(--cui-font-size-xs);\n font-weight: var(--cui-font-weight-medium);\n line-height: 1.25;\n}\n\n/* Danger actions (log out) */\n.danger {\n padding-top: var(--cui-space-2);\n border-top: 1px solid var(--cui-color-border);\n}\n.dangerAction {\n display: flex;\n align-items: center;\n gap: var(--cui-space-3);\n box-sizing: border-box;\n width: 100%;\n padding: var(--cui-space-2) var(--cui-space-3);\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-md);\n color: var(--cui-color-danger);\n font: inherit;\n font-weight: var(--cui-font-weight-medium);\n text-align: start;\n cursor: pointer;\n transition: background-color var(--cui-transition-fast);\n}\n.dangerAction:hover:not(:disabled) {\n background-color: color-mix(in srgb, var(--cui-color-danger) 10%, transparent);\n}\n.dangerAction:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n.dangerAction:focus-visible,\n.pill:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 1px;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .panel {\n animation: none;\n }\n .tile > svg {\n transition: none;\n }\n}\n","import {\n useEffect,\n useId,\n useRef,\n useState,\n type CSSProperties,\n type KeyboardEvent,\n type ReactNode,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { Avatar } from '../Avatar';\nimport type {\n AccountPanelAction,\n AccountPanelApp,\n AccountPanelProps,\n RenderLinkArgs,\n} from './AccountPanel.types';\nimport styles from './AccountPanel.module.css';\n\nconst GAP = 8;\nconst EDGE = 12;\nconst PANEL_WIDTH = 352;\nconst FOCUSABLE = 'a[href], button:not([disabled])';\n\nconst defaultRenderLink = ({ href, className, title, onClick, children }: RenderLinkArgs) => (\n <a href={href} className={className} title={title} onClick={onClick}>\n {children}\n </a>\n);\n\nconst tileTone: Record<NonNullable<AccountPanelApp['tone']>, string | undefined> = {\n primary: styles.tonePrimary,\n info: styles.toneInfo,\n success: styles.toneSuccess,\n warning: styles.toneWarning,\n danger: styles.toneDanger,\n neutral: styles.toneNeutral,\n};\n\nfunction ExternalIcon() {\n return (\n <svg className={styles.externalIcon} viewBox=\"0 0 20 20\" aria-hidden=\"true\" focusable=\"false\">\n <path\n d=\"M8 5H5v10h10v-3M11 5h4v4M15 5l-7 7\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.8\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n );\n}\n\n/**\n * The logged-in user's button and account panel: greeting, role, detail rows,\n * quick actions, an app launcher and a log out action. It holds no auth or\n * routing logic; the app passes the user, the actions and (optionally) a\n * `renderLink` for its router.\n */\nexport function AccountPanel({\n user,\n apps = [],\n actions = [],\n placement = 'header',\n collapsed = false,\n appsTitle = 'All Apps',\n greeting = 'Hi',\n renderLink = defaultRenderLink,\n className,\n}: AccountPanelProps) {\n const sidebar = placement === 'sidebar';\n const panelId = useId();\n const rootRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const panelRef = useRef<HTMLDivElement>(null);\n const [open, setOpen] = useState(false);\n const [position, setPosition] = useState<CSSProperties | null>(null);\n const [themeName, setThemeName] = useState<string | undefined>();\n\n const computePosition = () => {\n const trigger = triggerRef.current;\n if (!trigger) return;\n const rect = trigger.getBoundingClientRect();\n if (sidebar) {\n const width = Math.min(PANEL_WIDTH, window.innerWidth - 2 * EDGE);\n setPosition({\n left: Math.max(EDGE, Math.min(rect.right + GAP, window.innerWidth - width - EDGE)),\n bottom: Math.max(EDGE, window.innerHeight - rect.bottom),\n });\n } else {\n setPosition({\n top: rect.bottom + GAP,\n right: Math.max(EDGE, window.innerWidth - rect.right),\n });\n }\n };\n\n const openPanel = () => {\n computePosition();\n // The panel is rendered in <body> (so no ancestor can clip or offset it); carry the theme over.\n setThemeName(rootRef.current?.closest('[data-theme]')?.getAttribute('data-theme') ?? undefined);\n setOpen(true);\n };\n\n const close = () => setOpen(false);\n\n useEffect(() => {\n if (open) panelRef.current?.focus({ preventScroll: true });\n }, [open]);\n\n useEffect(() => {\n if (!open) return;\n const reposition = () => requestAnimationFrame(computePosition);\n const onPointerDown = (event: MouseEvent) => {\n const target = event.target as Node;\n if (!rootRef.current?.contains(target) && !panelRef.current?.contains(target)) close();\n };\n window.addEventListener('scroll', reposition, true);\n window.addEventListener('resize', reposition);\n document.addEventListener('mousedown', onPointerDown, true);\n return () => {\n window.removeEventListener('scroll', reposition, true);\n window.removeEventListener('resize', reposition);\n document.removeEventListener('mousedown', onPointerDown, true);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open, sidebar]);\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Escape') {\n event.preventDefault();\n event.stopPropagation();\n close();\n triggerRef.current?.focus({ preventScroll: true });\n return;\n }\n if (event.key !== 'Tab') return;\n // The panel is portalled to <body>, so keep Tab cycling inside it.\n const nodes = Array.from(panelRef.current?.querySelectorAll<HTMLElement>(FOCUSABLE) ?? []);\n const first = nodes[0];\n const last = nodes[nodes.length - 1];\n if (!first || !last) return;\n if (\n event.shiftKey &&\n (document.activeElement === first || document.activeElement === panelRef.current)\n ) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n };\n\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n const firstName = user.name.trim().split(/\\s+/)[0] ?? user.name;\n const quickActions = actions.filter((a) => a.tone !== 'danger');\n const dangerActions = actions.filter((a) => a.tone === 'danger');\n\n const runAction = (action: AccountPanelAction) => {\n action.onClick?.();\n close();\n };\n\n const renderQuickAction = (action: AccountPanelAction): ReactNode => {\n const content = (\n <>\n {action.icon ? (\n <span className={styles.actionIcon} aria-hidden=\"true\">\n {action.icon}\n </span>\n ) : null}\n <span>{action.label}</span>\n {action.external ? <ExternalIcon /> : null}\n </>\n );\n if (action.href && !action.disabled) {\n if (action.external) {\n return (\n <a\n key={action.id}\n href={action.href}\n target=\"_blank\"\n rel=\"noreferrer\"\n title={action.title}\n className={styles.pill}\n onClick={() => close()}\n >\n {content}\n </a>\n );\n }\n return (\n <span key={action.id} className={styles.contents}>\n {renderLink({\n href: action.href,\n className: styles.pill ?? '',\n title: action.title,\n onClick: () => close(),\n children: content,\n })}\n </span>\n );\n }\n return (\n <button\n key={action.id}\n type=\"button\"\n disabled={action.disabled}\n title={action.title}\n className={styles.pill}\n onClick={() => runAction(action)}\n >\n {content}\n </button>\n );\n };\n\n const panel = (\n <div\n ref={panelRef}\n id={panelId}\n role=\"dialog\"\n aria-label=\"Account\"\n tabIndex={-1}\n className={cn(styles.panel, sidebar && styles.panelSidebar)}\n style={position ?? undefined}\n data-theme={themeName}\n onKeyDown={handleKeyDown}\n >\n <div className={styles.identity}>\n {user.email ? <p className={styles.email}>{user.email}</p> : null}\n <span className={styles.avatarRing}>\n <span className={styles.avatarInner}>\n <Avatar\n name={user.name}\n src={user.avatarUrl}\n size=\"xl\"\n tone=\"primary\"\n aria-hidden=\"true\"\n />\n </span>\n </span>\n <p className={styles.greeting}>\n {greeting}, {firstName}!\n </p>\n {user.role ? <span className={styles.role}>{user.role}</span> : null}\n {quickActions.length > 0 ? (\n <div className={styles.pills}>{quickActions.map(renderQuickAction)}</div>\n ) : null}\n </div>\n\n {user.details?.length ? (\n <dl className={styles.details}>\n {user.details.map((detail) => (\n <div key={detail.label} className={styles.detailRow}>\n <dt>{detail.label}</dt>\n <dd>{detail.value}</dd>\n </div>\n ))}\n </dl>\n ) : null}\n\n {apps.length > 0 ? (\n <section className={styles.apps} aria-label={appsTitle}>\n <p className={styles.appsTitle}>{appsTitle}</p>\n <div className={styles.grid}>\n {apps.map((app) => {\n const tile = (\n <>\n <span\n className={cn(styles.tile, tileTone[app.tone ?? 'primary'])}\n aria-hidden=\"true\"\n >\n {app.icon}\n </span>\n <span className={styles.appName}>{app.name}</span>\n </>\n );\n return app.current ? (\n <span key={app.id} className={styles.contents}>\n {renderLink({\n href: app.url,\n className: styles.app ?? '',\n title: app.description,\n onClick: () => close(),\n children: tile,\n })}\n </span>\n ) : (\n <a\n key={app.id}\n href={app.url}\n target=\"_blank\"\n rel=\"noreferrer\"\n title={app.description}\n className={styles.app}\n >\n {tile}\n </a>\n );\n })}\n </div>\n </section>\n ) : null}\n\n {dangerActions.length > 0 ? (\n <div className={styles.danger}>\n {dangerActions.map((action) => (\n <button\n key={action.id}\n type=\"button\"\n disabled={action.disabled}\n title={action.title}\n className={styles.dangerAction}\n onClick={() => runAction(action)}\n >\n {action.icon ? (\n <span className={styles.actionIcon} aria-hidden=\"true\">\n {action.icon}\n </span>\n ) : null}\n {action.label}\n </button>\n ))}\n </div>\n ) : null}\n </div>\n );\n\n return (\n <div ref={rootRef} className={cn(styles.root, sidebar && styles.rootSidebar, className)}>\n <button\n ref={triggerRef}\n type=\"button\"\n aria-label={`Account: ${user.name}`}\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n aria-controls={open ? panelId : undefined}\n className={cn(\n sidebar ? styles.triggerSidebar : styles.triggerHeader,\n sidebar && collapsed && styles.collapsed,\n open && styles.triggerOpen,\n )}\n onClick={() => (open ? close() : openPanel())}\n >\n <Avatar name={user.name} src={user.avatarUrl} size=\"sm\" tone=\"primary\" aria-hidden=\"true\" />\n {sidebar && !collapsed ? (\n <span className={styles.identityText}>\n <span className={styles.triggerName}>{user.name}</span>\n {user.role ? <span className={styles.triggerRole}>{user.role}</span> : null}\n </span>\n ) : null}\n </button>\n {open && position ? createPortal(panel, document.body) : null}\n </div>\n );\n}\n",".root {\n margin: 0;\n font-family: var(--cui-font-family);\n line-height: var(--cui-line-height);\n}\n\n/* Variants */\n.h1 {\n font-size: var(--cui-font-size-2xl);\n font-weight: var(--cui-font-weight-bold);\n line-height: 1.3;\n}\n.h2 {\n font-size: var(--cui-font-size-xl);\n font-weight: var(--cui-font-weight-semibold);\n line-height: 1.35;\n}\n.h3 {\n font-size: var(--cui-font-size-lg);\n font-weight: var(--cui-font-weight-semibold);\n line-height: 1.4;\n}\n.h4 {\n font-size: var(--cui-font-size-md);\n font-weight: var(--cui-font-weight-semibold);\n}\n.body {\n font-size: var(--cui-font-size-md);\n font-weight: var(--cui-font-weight-normal);\n}\n.bodySm {\n font-size: var(--cui-font-size-sm);\n font-weight: var(--cui-font-weight-normal);\n}\n.caption {\n font-size: var(--cui-font-size-xs);\n font-weight: var(--cui-font-weight-normal);\n}\n.label {\n font-size: var(--cui-font-size-sm);\n font-weight: var(--cui-font-weight-semibold);\n}\n\n/* Colors */\n.color-default {\n color: var(--cui-color-text);\n}\n.color-secondary {\n color: var(--cui-color-text-secondary);\n}\n.color-muted {\n color: var(--cui-color-text-muted);\n}\n.color-disabled {\n color: var(--cui-color-text-disabled);\n}\n.color-primary {\n color: var(--cui-color-primary);\n}\n.color-success {\n color: var(--cui-color-success);\n}\n.color-warning {\n color: var(--cui-color-warning);\n}\n.color-danger {\n color: var(--cui-color-danger);\n}\n.color-info {\n color: var(--cui-color-info);\n}\n\n/* Weight overrides (declared after variants so they win) */\n.weight-normal {\n font-weight: var(--cui-font-weight-normal);\n}\n.weight-medium {\n font-weight: var(--cui-font-weight-medium);\n}\n.weight-semibold {\n font-weight: var(--cui-font-weight-semibold);\n}\n.weight-bold {\n font-weight: var(--cui-font-weight-bold);\n}\n\n.align-start {\n text-align: start;\n}\n.align-center {\n text-align: center;\n}\n.align-end {\n text-align: end;\n}\n\n.truncate {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n","import { createElement } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport type { TypographyElement, TypographyProps, TypographyVariant } from './Typography.types';\nimport styles from './Typography.module.css';\n\nconst defaultElement: Record<TypographyVariant, TypographyElement> = {\n h1: 'h1',\n h2: 'h2',\n h3: 'h3',\n h4: 'h4',\n body: 'p',\n 'body-sm': 'p',\n caption: 'span',\n label: 'span',\n};\n\nconst variantClass: Record<TypographyVariant, string | undefined> = {\n h1: styles.h1,\n h2: styles.h2,\n h3: styles.h3,\n h4: styles.h4,\n body: styles.body,\n 'body-sm': styles.bodySm,\n caption: styles.caption,\n label: styles.label,\n};\n\n/** Themed text. Pick the look with `variant` and the HTML element with `as`. */\nexport function Typography({\n variant = 'body',\n as,\n color = 'default',\n weight,\n align,\n truncate = false,\n className,\n ...rest\n}: TypographyProps) {\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n return createElement(as ?? defaultElement[variant], {\n ...rest,\n className: cn(\n styles.root,\n variantClass[variant],\n styles[`color-${color}`],\n weight && styles[`weight-${weight}`],\n align && styles[`align-${align}`],\n truncate && styles.truncate,\n className,\n ),\n });\n}\n",".root {\n display: inline-flex;\n padding: 2px;\n gap: 2px;\n background-color: var(--cui-color-surface-secondary);\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n}\n\n.option {\n position: relative;\n display: inline-flex;\n}\n\n.input {\n position: absolute;\n inset: 0;\n margin: 0;\n opacity: 0;\n cursor: pointer;\n}\n\n.face {\n display: inline-flex;\n align-items: center;\n gap: var(--cui-space-2);\n padding: 6px var(--cui-space-3);\n border-radius: var(--cui-radius-md);\n color: var(--cui-color-text-muted);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-sm);\n font-weight: var(--cui-font-weight-medium);\n line-height: 1.25;\n white-space: nowrap;\n transition:\n background-color var(--cui-transition-fast),\n color var(--cui-transition-fast);\n}\n\n.option:hover .input:not(:checked) + .face {\n color: var(--cui-color-text);\n}\n\n.input:checked + .face {\n background-color: var(--cui-color-surface);\n color: var(--cui-color-primary);\n box-shadow: var(--cui-shadow-sm);\n}\n\n.input:focus-visible + .face {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 1px;\n}\n\n.icon {\n width: 1rem;\n height: 1rem;\n flex-shrink: 0;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .face {\n transition: none;\n }\n}\n","import { useId, type ReactNode } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { useTheme } from '../../theme';\nimport type { ThemeToggleProps } from './ThemeToggle.types';\nimport styles from './ThemeToggle.module.css';\n\nconst icons: Record<string, ReactNode> = {\n light: (\n <>\n <circle cx=\"12\" cy=\"12\" r=\"4\" />\n <path d=\"M12 3v2M12 19v2M3 12h2M19 12h2M5.6 5.6l1.4 1.4M17 17l1.4 1.4M5.6 18.4L7 17M17 7l1.4-1.4\" />\n </>\n ),\n dark: <path d=\"M20 14.5A8 8 0 019.5 4a8 8 0 1010.5 10.5z\" />,\n system: (\n <>\n <rect x=\"3\" y=\"4\" width=\"18\" height=\"12\" rx=\"2\" />\n <path d=\"M8 20h8M12 16v4\" />\n </>\n ),\n};\n\nconst labels: Record<string, string> = { light: 'Light', dark: 'Dark', system: 'System' };\n\n/**\n * Switch between themes (light / dark / system by default). Must be inside a\n * `ThemeProvider`. Built on radio inputs, so arrow keys and screen readers work natively.\n */\nexport function ThemeToggle({\n modes = ['light', 'dark', 'system'],\n compact = false,\n className,\n 'aria-label': ariaLabel = 'Theme',\n ...rest\n}: ThemeToggleProps) {\n const { theme, setTheme } = useTheme();\n const name = useId();\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n return (\n <div {...rest} role=\"radiogroup\" aria-label={ariaLabel} className={cn(styles.root, className)}>\n {modes.map((mode) => {\n const label = labels[mode] ?? mode;\n return (\n <label key={mode} className={styles.option} title={compact ? label : undefined}>\n <input\n type=\"radio\"\n name={name}\n value={mode}\n checked={theme === mode}\n onChange={() => setTheme(mode)}\n className={styles.input}\n aria-label={compact ? label : undefined}\n />\n <span className={styles.face}>\n {icons[mode] ? (\n <svg\n className={styles.icon}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.8\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n {icons[mode]}\n </svg>\n ) : null}\n {compact ? null : label}\n </span>\n </label>\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;AAGA,SAAg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;EAAK,GAAIW;EAAM,MAAK;EAAa,cAAYiS;EAAW,WAAWjU,EAAGD,GAAO,MAAMuC,CAAS;EACzF,UAAAgzB,EAAM,KAAK,MAAS;GACnB,IAAM5xB,IAAQ0xB,GAAOG,MAASA;GAC9B,OACE,kBAAC,SAAD;IAAkB,WAAWx1B,GAAO;IAAQ,OAAOy1B,IAAU9xB,IAAQ,KAAA;IAArE,UAAA,CACE,kBAAC,SAAD;KACE,MAAK;KACC;KACN,OAAO6xB;KACP,SAAShjB,MAAUgjB;KACnB,gBAAgBniB,EAASmiB,CAAI;KAC7B,WAAWx1B,GAAO;KAClB,cAAYy1B,IAAU9xB,IAAQ,KAAA;IAC/B,CAAA,GACD,kBAAC,QAAD;KAAM,WAAW3D,GAAO;KAAxB,UAAA,CACGo1B,GAAMI,KACL,kBAAC,OAAD;MACE,WAAWx1B,GAAO;MAClB,SAAQ;MACR,MAAK;MACL,QAAO;MACP,aAAY;MACZ,eAAc;MACd,gBAAe;MACf,eAAY;MACZ,WAAU;MAET,UAAAo1B,GAAMI;KACJ,CAAA,IACH,MACHC,IAAU,OAAO9xB,CACd;IACD,CAAA,CAAA;GA5BK,GAAA6xB,CA4BL;EAEX,CAAC;CACE,CAAA,IAtCe,kBAAC3zB,GAAD,CAAmB,CAAA;AAwC3C"}
1
+ {"version":3,"file":"index.js","names":["root","styles","button","sm","md","lg","primary","danger","spinner","styles","root","label","required","message","helper","error","styles","pad","today","root","header","title","footerButton","grid","selected","footer","chevron","getToday","styles","_Fragment","control","trigger","open","value","placeholder","sm","md","lg","icon","clear","invalid","disabled","panel","MENU_GAP","MENU_ESTIMATED_HEIGHT","FOCUSABLE","styles","_Fragment","root","list","option","selected","styles","footer","today","styles","chevron","getToday","styles","_Fragment","control","disabled","invalid","sm","md","lg","input","readOnly","styles","styles","search","icon","clear","styles","root","styles","backdrop","center","panel","FOCUSABLE","styles","header","heading","title","body","footer","_Fragment","styles","panel","sm","md","lg","xl","styles","panel","sm","md","lg","styles","_Fragment","styles","trigger","open","sm","md","lg","invalid","disabled","search","list","option","selected","check","empty","MENU_GAP","MENU_ESTIMATED_HEIGHT","styles","root","info","summary","button","icon","styles","_Fragment","caption","row","selected","styles","_Fragment","root","heading","title","subtitle","actions","styles","label","dot","success","info","danger","warning","neutral","empty","TONES","styles","root","label","disabled","input","invalid","text","required","message","helper","error","styles","root","menu","item","danger","label","icon","styles","root","circle","styles","root","toolbar","actions","srOnly","styles","root","actions","styles","styles","styles","title","circle","image","error","styles","_Fragment","root","disabled","invalid","tile","input","icon","list","styles","_Fragment","invalid","icon","styles","styles","root","label","input","styles","root","primary","danger","styles","root","icon","panel","styles","root","styles","root","styles","root","styles","_Fragment","root","styles","_Fragment","styles","cn","values","SALT","hashKey","text","key","h1","h2","i","ch","VALID_KEY_HASHES","globalKey","listeners","warned","LicenseContext","createContext","setLicenseKey","listener","isValidLicenseKey","subscribe","getSnapshot","useLicensed","providedKey","useContext","useSyncExternalStore","licensed","useEffect","UnlicensedNotice_module_default","UnlicensedNotice","Button_module_default","Button","forwardRef","rest","disabled","loading","variant","size","fullWidth","className","children","FormFieldContext","useFormFieldControl","context","generatedId","useId","id","options","required","invalid","describedBy","FormField_module_default","FormField","idProp","hasError","error","messageId","helperText","useMemo","label","pad$1","n","length","toISO","date","parseISO","value","today$1","now","addDays","days","addMonths","first","months","last","isSameDay","a","b","buildMonthGrid","month","offset","weekStartsOn","createDisabledPredicate","min","max","todayISO","dates","d","ranges","r","weekdays","iso","nearestEnabled","isDisabled","after","before","toMonthISO","parseMonth","createMonthDisabledPredicate","current","listed","m","toDateTimeISO","parseDateTime","match","day","hours","minutes","withTime","Calendar_module_default","chevron$2","direction","Calendar","todayDate","cursor","setCursor","useState","selected","view","setView","gridRef","useRef","focusCursor","monthName","locale","monthShort","base","dayLabel","year","yearStart","cursorISO","moveCursor","next","handleGridKeyDown","move","event","page","prevLabel","nextLabel","Fragment","outside","isSelected","onSelect","name","y","showFooter","allowClear","HOST_ID","getPortalHost","host","PickerField_module_default","MENU_GAP$2","MENU_ESTIMATED_HEIGHT$2","FOCUSABLE$2","PickerFieldControl","ariaDescribedBy","control","panelId","containerRef","triggerRef","panelRef","setTriggerRef","useCallback","node","ref","open","setOpen","style","setStyle","themeName","setThemeName","computePosition","container","rect","spaceBelow","above","panelWidth","openPicker","focusTick","setFocusTick","close","restoreFocus","tick","reposition","onPointerDown","target","handlePanelKeyDown","nodes","hasValue","displayText","showClear","clearable","onClick","onKeyDown","placeholder","clearLabel","onClear","icon","hiddenValue","createPortal","panelLabel","PickerShell","PickerField","DatePicker","isControlled","internal","setInternal","defaultValue","formatter","commit","onChange","TimeColumns_module_default","pad","TimeColumns","h","isPm","minuteValues","minuteStep","v","hourDisabled","isTimeDisabled","hour","hourOptions","use12Hours","minuteOptions","periodDisabled","start","periodOptions","Column","listRef","selectedIndex","option","list","el","items","index","DateTimePicker_module_default","parseBoundary","full","end","parseTime","DateTimePicker","earliest","disablePast","latest","disableFuture","isDayDisabled","isMomentDisabled","moment","fitTime","wanted","total","candidate","baseDay","defaultHours","defaultMinutes","defaultTime","nowDate","chevron$1","firstOfMonth","MonthCalendar","thisMonth","monthNames","monthLong","handleKeyDown","step","MonthPicker","PICKER_TYPES","isPickerType","type","PickerTypeInput","hiddenRef","setRef","common","input","dateOptions","Input_module_default","InputControl","readOnly","prefix","suffix","Input","props","PasswordInput_module_default","PasswordInput","visible","setVisible","autoComplete","hideLabel","showLabel","SearchInput_module_default","SearchInput","innerRef","DARK_QUERY","useSystemPrefersDark","query","storageListeners","readStorage","writeStoredTheme","theme","useStoredTheme","ThemeProvider_module_default","ThemeContext","ThemeProvider","controlledTheme","internalTheme","setInternalTheme","defaultTheme","storedTheme","storageKey","systemPrefersDark","resolvedTheme","setTheme","onThemeChange","inheritedKey","licenseKey","useTheme","useOptionalTheme","Overlay_module_default","FOCUSABLE$1","EXIT_MS","prefersReducedMotion","lockCount","previousOverflow","lockScroll","unlockScroll","Overlay","ariaLabel","baseId","titleId","descriptionId","pressedOnBackdrop","previous","panel","mounted","setMounted","timer","closing","placement","closeOnBackdrop","onClose","panelClassName","closeOnEscape","active","OverlayContent_module_default","OverlayContent","title","description","hideCloseButton","closeLabel","footer","Modal_module_default","Modal","bare","Drawer_module_default","Drawer","ConfirmDialog_module_default","ConfirmDialog","typed","setTyped","confirmed","requireText","danger","tone","message","cancelLabel","onConfirm","confirmLabel","Select_module_default","MENU_GAP$1","MENU_ESTIMATED_HEIGHT$1","SEARCH_DEBOUNCE_MS","toArray","SelectControl","listId","valueId","optionId","popoverRef","searchRef","position","setPosition","search","setSearch","showSearch","setShowSearch","highlighted","setHighlighted","filtered","onSearch","multiple","firstEnabled","updatePosition","openMenu","firstSelected","o","closeMenu","selectOption","moveHighlight","onSearchRef","handler","handleTriggerKeyDown","handleMenuKeyDown","isPrintable","selectedOptions","activeDescendant","labelledBy","listClassName","emptyMessage","Select","controlProps","getPageItems","pageCount","range","to","from","startPages","boundaryCount","endPages","siblingsStart","siblingCount","siblingsEnd","item","Pagination_module_default","icon$5","path","Pagination","showFirstLastProp","go","onPageChange","split","layout","showFirstLast","showSummary","pageSize","totalItems","showPageSize","pageSizeOptions","onPageSizeChange","summaryNode","pageSizeNode","pagesNode","Table_module_default","Table","bordered","containerClassName","scrollLabel","stickyHeader","TableHead","TableBody","TableFoot","TableRow","TableHeaderCell","ariaSort","sortable","sortDirection","align","onSort","TableCell","TableCaption","PageHeader_module_default","PageHeader","onBack","backLabel","subtitle","actions","StatusPill_module_default","TONES$1","StatusPill","status","resolved","pulse","Checkbox_module_default","Checkbox","indeterminate","hasMessage","DropdownMenu_module_default","MENU_GAP","MENU_WIDTH","MENU_ESTIMATED_HEIGHT","ITEM","DropdownMenu","menuId","menuRef","onOpenChangeRef","onOpenChange","trigger","fitsRight","prev","setOpenState","focusItem","which","action","Skeleton_module_default","Skeleton","height","width","DataTable_module_default","SelectionBar","count","FilterValueControl","field","TableFilters_module_default","rowCounter","nextRowId","rowsFromValues","valuesFromRows","row","rows","DynamicFilterRows","used","available","fields","update","patch","f","choices","activeFilters","filterValueLabel","FiltersPanel","setRows","onApply","TableFilters","panelOpen","setPanelOpen","setText","lastExternal","activeFields","hasFields","onValuesChange","handleSearch","searchDelay","onSearchChange","searchPlaceholder","_removed","panelTitle","getValue","column","asText","searchRows","needle","columns","filterRows","filters","filterValue","c","collator","sortRows","sort","read","factor","aEmpty","bEmpty","result","entry","paginateRows","nextSort","DEFAULT_PAGE_SIZE_OPTIONS","defaultCallApi","url","init","buildRequestUrl","entries","params","parseResponse","data","response","meta","DataTableRequestError","fetchPage","callApi","fetchAllPages","pageNo","totalPages","queryFor","useDebouncedValue","debounced","setDebounced","delay","SKELETON_WIDTHS","alignOf","alertIcon","archiveIcon","DataTable","loadingProp","searchProp","filtersProp","sortProp","paginationProp","pageProp","pageSizeProp","remote","fetchUrl","pagination","searchState","setSearchState","defaultSearch","filtersState","setFiltersState","defaultFilters","sortState","setSortState","defaultSort","pageState","setPageState","defaultPage","pageSizeState","setPageSizeState","defaultPageSize","filterFields","goToFirstPage","changeSearch","changeFilters","onFiltersChange","changeSort","onSortChange","changePage","changePageSize","wait","debounceMs","debouncedSearch","debouncedFilters","requestKey","apiBaseUrl","additionalFilter","refreshTrigger","setResult","cancelled","loaded","registerApi","sourceRows","serverSide","manualFiltering","processed","manualSorting","serverPaging","manualPagination","currentPage","rowId","getRowId","visibleIds","selectedIds","selection","selectedVisible","allSelected","someSelected","toggleAll","toggleRow","s","hasActions","hasToolbar","searchable","isFiltered","columnCount","stop","emptyText","handleRowKeyDown","onRowClick","renderActions","isDanger","table","tableClassName","caption","actionsClassName","loadingRows","cellIndex","rowIndex","emptyState","bulkActions","belowToolbar","formatFileSize","bytes","mb","matchesAccept","tokens","accept","token","file","sameFile","fileKey","isImage","ImageCropper_module_default","FRAME","MAX_ZOOM","KEY_STEP","extensionFor","ImageCropper","dialogRef","setLoaded","failed","setFailed","zoom","setZoom","setOffset","saving","setSaving","drag","frameW","aspect","frameH","image","baseScale","scale","clamp","maxX","nextScale","maxY","x","changeZoom","dx","dy","handlePointerDown","handlePointerMove","endDrag","apply","outW","outputWidth","outH","canvas","sx","sy","blob","outputType","outputQuality","dialog","onCancel","shape","delta","FileInput_module_default","canPreview","createPreviewUrl","UploadIcon","ImageIcon","FileIcon","CloseIcon","FileInputControl","multipleProp","acceptProp","hintId","rejectedId","isImageVariant","inputRef","files","setFiles","rejected","setRejected","dragging","setDragging","cropping","setCropping","previews","setPreviews","previewsRef","syncInput","transfer","nextPreviews","existing","onFilesChange","addFiles","incoming","problems","accepted","maxSize","picked","crop","maxFiles","handleChange","handleDrop","removeFile","hint","t","openDialog","dropHandlers","frameAspect","aspectRatio","tileHeight","tileSize","croppedWidth","cropOutputWidth","state","names","thumb","fileList","preview","hintText","body","buttonLabel","cropOutputType","cropOutputQuality","cropTitle","cropped","FileInput","ALLOWED","DROP","SAFE_HREF","unwrap","clean","child","tag","href","attr","sanitizeHtml","html","doc","isEmptyHtml","Textarea_module_default","icon$2","TOOLS","LINK_ICON","CLEAR_ICON","canExec","queryState","command","toHtml","normalize","RichTextControl","editorRef","lastHtml","setHtml","setActive","editable","emit","onValueChange","refreshActive","anchor","run","arg","addLink","keepSelection","tool","resize","TextareaControl","Textarea","Switch_module_default","Switch","Badge_module_default","Badge","color","dot","Tabs_module_default","Tabs","tabRefs","indicator","setIndicator","activeIndex","activeItem","useLayoutEffect","tab","measure","left","observer","select","rtl","tabId","FormSection_module_default","FormSection","headingId","hasHeader","createElement","headingLevel","Avatar_module_default","TONES","getInitials","words","toneFor","hash","Avatar","failedSrc","setFailedSrc","showImage","src","initials","AccountPanel_module_default","GAP","EDGE","PANEL_WIDTH","FOCUSABLE","defaultRenderLink","tileTone","ChevronIcon","ExternalIcon","AccountPanel","sidebar","rootRef","openPanel","firstName","user","quickActions","dangerActions","runAction","greeting","detail","content","renderLink","apps","appsTitle","tile","app","collapsed","Typography_module_default","defaultElement","variantClass","Typography","as","weight","truncate","ThemeToggle_module_default","icons","labels","ThemeToggle","modes","mode","compact"],"sources":["../src/utils/cn.ts","../src/license/hash.ts","../src/license/keys.ts","../src/license/license.ts","../src/license/UnlicensedNotice.module.css","../src/license/UnlicensedNotice.tsx","../src/components/Button/Button.module.css","../src/components/Button/Button.tsx","../src/components/FormField/FormFieldContext.ts","../src/components/FormField/FormField.module.css","../src/components/FormField/FormField.tsx","../src/components/DatePicker/dateUtils.ts","../src/components/DatePicker/Calendar.module.css","../src/components/DatePicker/Calendar.tsx","../src/utils/portalHost.ts","../src/components/DatePicker/PickerField.module.css","../src/components/DatePicker/PickerField.tsx","../src/components/DatePicker/DatePicker.tsx","../src/components/DatePicker/TimeColumns.module.css","../src/components/DatePicker/TimeColumns.tsx","../src/components/DateTimePicker/DateTimePicker.module.css","../src/components/DateTimePicker/DateTimePicker.tsx","../src/components/DatePicker/MonthCalendar.tsx","../src/components/MonthPicker/MonthPicker.tsx","../src/components/Input/PickerTypeInput.tsx","../src/components/Input/Input.module.css","../src/components/Input/Input.tsx","../src/components/PasswordInput/PasswordInput.module.css","../src/components/PasswordInput/PasswordInput.tsx","../src/components/SearchInput/SearchInput.module.css","../src/components/SearchInput/SearchInput.tsx","../src/theme/themeStore.ts","../src/theme/ThemeProvider.module.css","../src/theme/ThemeProvider.tsx","../src/components/Overlay/Overlay.module.css","../src/components/Overlay/Overlay.tsx","../src/components/Overlay/OverlayContent.module.css","../src/components/Overlay/OverlayContent.tsx","../src/components/Modal/Modal.module.css","../src/components/Modal/Modal.tsx","../src/components/Drawer/Drawer.module.css","../src/components/Drawer/Drawer.tsx","../src/components/ConfirmDialog/ConfirmDialog.module.css","../src/components/ConfirmDialog/ConfirmDialog.tsx","../src/components/Select/Select.module.css","../src/components/Select/SelectControl.tsx","../src/components/Select/Select.tsx","../src/components/Pagination/paginationUtils.ts","../src/components/Pagination/Pagination.module.css","../src/components/Pagination/Pagination.tsx","../src/components/Table/Table.module.css","../src/components/Table/Table.tsx","../src/components/PageHeader/PageHeader.module.css","../src/components/PageHeader/PageHeader.tsx","../src/components/StatusPill/StatusPill.module.css","../src/components/StatusPill/StatusPill.tsx","../src/components/Checkbox/Checkbox.module.css","../src/components/Checkbox/Checkbox.tsx","../src/components/DropdownMenu/DropdownMenu.module.css","../src/components/DropdownMenu/DropdownMenu.tsx","../src/components/Skeleton/Skeleton.module.css","../src/components/Skeleton/Skeleton.tsx","../src/components/DataTable/DataTable.module.css","../src/components/DataTable/SelectionBar.tsx","../src/components/TableFilters/FilterValueControl.tsx","../src/components/TableFilters/TableFilters.module.css","../src/components/TableFilters/DynamicFilterRows.tsx","../src/components/TableFilters/filterUtils.ts","../src/components/TableFilters/TableFilters.tsx","../src/components/DataTable/dataTableUtils.ts","../src/components/DataTable/remote.ts","../src/components/DataTable/useDebouncedValue.ts","../src/components/DataTable/DataTable.tsx","../src/components/FileInput/fileUtils.ts","../src/components/FileInput/ImageCropper.module.css","../src/components/FileInput/ImageCropper.tsx","../src/components/FileInput/FileInput.module.css","../src/components/FileInput/FileInput.tsx","../src/components/Textarea/sanitizeHtml.ts","../src/components/Textarea/Textarea.module.css","../src/components/Textarea/RichTextControl.tsx","../src/components/Textarea/Textarea.tsx","../src/components/Switch/Switch.module.css","../src/components/Switch/Switch.tsx","../src/components/Badge/Badge.module.css","../src/components/Badge/Badge.tsx","../src/components/Tabs/Tabs.module.css","../src/components/Tabs/Tabs.tsx","../src/components/FormSection/FormSection.module.css","../src/components/FormSection/FormSection.tsx","../src/components/Avatar/Avatar.module.css","../src/components/Avatar/Avatar.tsx","../src/components/AccountPanel/AccountPanel.module.css","../src/components/AccountPanel/AccountPanel.tsx","../src/components/Typography/Typography.module.css","../src/components/Typography/Typography.tsx","../src/components/ThemeToggle/ThemeToggle.module.css","../src/components/ThemeToggle/ThemeToggle.tsx"],"sourcesContent":["export type ClassValue = string | false | null | undefined;\n\n/** Join truthy class names into a single string. */\nexport function cn(...values: ClassValue[]): string {\n return values.filter(Boolean).join(' ');\n}\n","/**\n * Non-cryptographic 53-bit hash (cyrb53). Keys are stored as hashes so the\n * plain keys are not sitting in the bundle. This is a deterrent, not security:\n * anything shipped to the browser can be extracted. `scripts/license.mjs`\n * must use the same algorithm (a test keeps them in sync).\n */\nconst SALT = 'client-ui:';\n\nexport function hashKey(key: string): string {\n const text = SALT + key.trim();\n let h1 = 0xdeadbeef;\n let h2 = 0x41c6ce57;\n for (let i = 0; i < text.length; i++) {\n const ch = text.charCodeAt(i);\n h1 = Math.imul(h1 ^ ch, 2654435761);\n h2 = Math.imul(h2 ^ ch, 1597334677);\n }\n h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);\n h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909);\n h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);\n h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909);\n const value = 4294967296 * (2097151 & h2) + (h1 >>> 0);\n return value.toString(16).padStart(14, '0');\n}\n","/**\n * Hashes of the license keys this release accepts. Generate entries with\n * `node scripts/license.mjs generate <label>`; remove an entry to revoke a key\n * in the next release.\n */\nexport const VALID_KEY_HASHES: readonly string[] = [\n '1cd9d9bd20471f', // dev (Storybook / playground)\n];\n","import { createContext, useContext, useEffect, useSyncExternalStore } from 'react';\nimport { hashKey } from './hash';\nimport { VALID_KEY_HASHES } from './keys';\n\nlet globalKey = '';\nconst listeners = new Set<() => void>();\nlet warned = false;\n\n/** Context carrying the key given to `<ThemeProvider licenseKey>`. Takes priority over `setLicenseKey`. */\nexport const LicenseContext = createContext<string | null>(null);\n\n/** Set the license key once at app start. A `licenseKey` on `ThemeProvider` takes priority. */\nexport function setLicenseKey(key: string): void {\n globalKey = key;\n warned = false;\n listeners.forEach((listener) => listener());\n}\n\nexport function isValidLicenseKey(key: string | null | undefined): boolean {\n if (!key || !key.trim()) return false;\n return VALID_KEY_HASHES.includes(hashKey(key));\n}\n\nconst subscribe = (listener: () => void) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n};\nconst getSnapshot = () => globalKey;\n\n/** True when a valid license key is configured. Every component calls this. */\nexport function useLicensed(): boolean {\n const providedKey = useContext(LicenseContext);\n const key = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n const licensed = isValidLicenseKey(providedKey ?? key);\n\n useEffect(() => {\n if (licensed || warned) return;\n warned = true;\n console.error(\n '[client-ui] Missing or invalid license key. Components are disabled. ' +\n 'Pass licenseKey to <ThemeProvider> or call setLicenseKey() once at app start.',\n );\n }, [licensed]);\n\n return licensed;\n}\n",".root {\n display: inline-block;\n padding: var(--cui-space-1) var(--cui-space-2);\n border: 1px dashed var(--cui-color-danger);\n border-radius: var(--cui-radius-md);\n color: var(--cui-color-danger);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-xs);\n line-height: var(--cui-line-height);\n}\n","import styles from './UnlicensedNotice.module.css';\n\n/** Rendered in place of a component when no valid license key is configured. */\nexport function UnlicensedNotice() {\n return (\n <span role=\"alert\" className={styles.root}>\n client-ui: missing or invalid license key\n </span>\n );\n}\n",".button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: var(--cui-space-2);\n box-sizing: border-box;\n border: 1px solid transparent;\n border-radius: var(--cui-radius-md);\n font-family: var(--cui-font-family);\n font-weight: var(--cui-font-weight-normal);\n line-height: var(--cui-line-height);\n white-space: nowrap;\n cursor: pointer;\n user-select: none;\n transition:\n background-color var(--cui-transition-fast),\n border-color var(--cui-transition-fast),\n color var(--cui-transition-fast);\n}\n\n.button:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: var(--cui-focus-ring-offset);\n}\n\n.button:disabled {\n cursor: not-allowed;\n}\n\n.button[aria-busy='true'] {\n cursor: progress;\n}\n\n/* Sizes */\n.sm {\n height: var(--cui-control-height-sm);\n padding: 0 var(--cui-space-3);\n font-size: var(--cui-font-size-sm);\n}\n\n.md {\n height: var(--cui-control-height-md);\n padding: 0 var(--cui-space-4);\n font-size: var(--cui-font-size-md);\n}\n\n.lg {\n height: var(--cui-control-height-lg);\n padding: 0 var(--cui-space-6);\n font-size: var(--cui-font-size-lg);\n}\n\n.fullWidth {\n display: flex;\n width: 100%;\n}\n\n/* Variants */\n.primary {\n background-color: var(--cui-color-primary);\n color: var(--cui-color-on-primary);\n}\n.primary:hover:not(:disabled) {\n background-color: var(--cui-color-primary-hover);\n}\n.primary:active:not(:disabled) {\n background-color: var(--cui-color-primary-active);\n}\n\n.secondary {\n background-color: var(--cui-color-secondary);\n color: var(--cui-color-on-secondary);\n}\n.secondary:hover:not(:disabled) {\n background-color: var(--cui-color-secondary-hover);\n}\n\n.outline {\n background-color: transparent;\n border-color: var(--cui-color-border);\n color: var(--cui-color-text);\n}\n.outline:hover:not(:disabled) {\n background-color: var(--cui-color-surface-secondary);\n}\n\n.ghost {\n background-color: transparent;\n color: var(--cui-color-primary);\n}\n.ghost:hover:not(:disabled) {\n background-color: var(--cui-color-primary-subtle);\n}\n\n.danger {\n background-color: var(--cui-color-danger);\n color: var(--cui-color-on-danger);\n}\n.danger:hover:not(:disabled) {\n background-color: var(--cui-color-danger-hover);\n}\n.danger:active:not(:disabled) {\n background-color: var(--cui-color-danger-active);\n}\n\n.link {\n height: auto;\n padding: 0;\n background-color: transparent;\n color: var(--cui-color-primary);\n text-decoration: underline;\n text-underline-offset: 0.2em;\n}\n.link:hover:not(:disabled) {\n color: var(--cui-color-primary-hover);\n}\n\n/* Disabled (and loading, which is disabled) */\n.button:disabled:not([aria-busy='true']) {\n color: var(--cui-color-text-disabled);\n}\n.primary:disabled:not([aria-busy='true']),\n.secondary:disabled:not([aria-busy='true']),\n.danger:disabled:not([aria-busy='true']) {\n background-color: var(--cui-color-surface-secondary);\n}\n.outline:disabled {\n border-color: var(--cui-color-border);\n}\n.button[aria-busy='true'] {\n opacity: 0.85;\n}\n\n/* Spinner */\n.spinner {\n width: 1em;\n height: 1em;\n box-sizing: border-box;\n border: 2px solid currentColor;\n border-inline-end-color: transparent;\n border-radius: var(--cui-radius-full);\n animation: spin 0.7s linear infinite;\n}\n\n@keyframes spin {\n to {\n transform: rotate(360deg);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .spinner {\n animation-duration: 2s;\n }\n}\n","import { forwardRef } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport type { ButtonProps } from './Button.types';\nimport styles from './Button.module.css';\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n {\n variant = 'primary',\n size = 'md',\n loading = false,\n fullWidth = false,\n type = 'button',\n disabled,\n className,\n children,\n ...rest\n },\n ref,\n) {\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n return (\n <button\n {...rest}\n ref={ref}\n type={type}\n disabled={disabled || loading}\n aria-busy={loading || undefined}\n data-variant={variant}\n data-size={size}\n className={cn(\n styles.button,\n styles[variant],\n styles[size],\n fullWidth && styles.fullWidth,\n className,\n )}\n >\n {loading ? <span className={styles.spinner} aria-hidden=\"true\" /> : null}\n {children}\n </button>\n );\n});\n","import { createContext, useContext, useId } from 'react';\nimport type {\n FormFieldContextValue,\n FormFieldControlProps,\n UseFormFieldControlOptions,\n} from './FormField.types';\n\nexport const FormFieldContext = createContext<FormFieldContextValue | null>(null);\n\n/**\n * Connects a form control to the surrounding FormField (if any) and returns\n * the id / required / disabled / aria props it should apply to its native element.\n * Form controls (Input, Select, future Textarea...) should all use this hook.\n */\nexport function useFormFieldControl(options: UseFormFieldControlOptions): FormFieldControlProps {\n const context = useContext(FormFieldContext);\n const generatedId = useId();\n\n const id = context?.id ?? options.id ?? generatedId;\n const required = Boolean(options.required ?? context?.required);\n const disabled = Boolean(options.disabled ?? context?.disabled);\n const invalid = Boolean(options.error) || Boolean(context?.invalid);\n const describedBy =\n [options['aria-describedby'], context?.describedById].filter(Boolean).join(' ') || undefined;\n\n return {\n id,\n required,\n disabled,\n invalid,\n labelId: context?.labelId,\n 'aria-invalid': invalid ? true : undefined,\n 'aria-describedby': describedBy,\n };\n}\n",".root {\n display: flex;\n flex-direction: column;\n gap: var(--cui-space-1);\n min-width: 0;\n}\n\n.label {\n font-size: var(--cui-font-size-sm);\n font-weight: var(--cui-font-weight-semibold);\n color: var(--cui-color-text-secondary);\n margin-bottom: var(--cui-space-1);\n}\n\n.labelDisabled {\n color: var(--cui-color-text-disabled);\n}\n\n.required {\n margin-inline-start: var(--cui-space-1);\n color: var(--cui-color-danger);\n}\n\n.message {\n margin: 0;\n font-size: var(--cui-font-size-xs);\n}\n\n.helper {\n color: var(--cui-color-text-muted);\n}\n\n.error {\n color: var(--cui-color-danger);\n}\n","import { useId, useMemo } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { FormFieldContext } from './FormFieldContext';\nimport type { FormFieldContextValue, FormFieldProps } from './FormField.types';\nimport styles from './FormField.module.css';\n\nexport function FormField({\n children,\n label,\n required = false,\n helperText,\n error,\n disabled = false,\n id: idProp,\n className,\n ...rest\n}: FormFieldProps) {\n const generatedId = useId();\n const id = idProp ?? generatedId;\n const hasError = Boolean(error);\n const messageId = hasError ? `${id}-error` : helperText ? `${id}-helper` : undefined;\n\n const context = useMemo<FormFieldContextValue>(\n () => ({\n id,\n describedById: messageId,\n labelId: label ? `${id}-label` : undefined,\n required,\n disabled,\n invalid: hasError,\n }),\n [id, messageId, label, required, disabled, hasError],\n );\n\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n return (\n <FormFieldContext.Provider value={context}>\n <div {...rest} className={cn(styles.root, className)}>\n {label ? (\n <label\n id={`${id}-label`}\n htmlFor={id}\n className={cn(styles.label, disabled && styles.labelDisabled)}\n >\n {label}\n {required ? (\n <span className={styles.required} aria-hidden=\"true\">\n *\n </span>\n ) : null}\n </label>\n ) : null}\n {children}\n {hasError ? (\n <p id={messageId} className={cn(styles.message, styles.error)} role=\"alert\">\n {error}\n </p>\n ) : helperText ? (\n <p id={messageId} className={cn(styles.message, styles.helper)}>\n {helperText}\n </p>\n ) : null}\n </div>\n </FormFieldContext.Provider>\n );\n}\n","/**\n * Date helpers for the picker. Dates are handled as local calendar days and kept at\n * noon so daylight-saving shifts never move them to a neighbouring day.\n */\n\nconst pad = (n: number, length = 2) => String(n).padStart(length, '0');\n\n/** `2026-10-08` for a date, using its local year, month and day. */\nexport const toISO = (date: Date): string =>\n `${pad(date.getFullYear(), 4)}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;\n\n/** Parses `YYYY-MM-DD`. Returns null for anything else, including impossible dates like `2026-02-31`. */\nexport function parseISO(value: string | null | undefined): Date | null {\n if (!value || !/^\\d{4}-\\d{2}-\\d{2}$/.test(value)) return null;\n const date = new Date(`${value}T12:00:00`);\n return Number.isFinite(date.getTime()) && toISO(date) === value ? date : null;\n}\n\nexport const today = (): Date => {\n const now = new Date();\n return new Date(now.getFullYear(), now.getMonth(), now.getDate(), 12);\n};\n\nexport const addDays = (date: Date, days: number): Date =>\n new Date(date.getFullYear(), date.getMonth(), date.getDate() + days, 12);\n\n/** Moves by whole months, keeping the day of month when it exists (Jan 31 + 1 month = Feb 28/29). */\nexport function addMonths(date: Date, months: number): Date {\n const first = new Date(date.getFullYear(), date.getMonth() + months, 1, 12);\n const last = new Date(first.getFullYear(), first.getMonth() + 1, 0, 12).getDate();\n return new Date(first.getFullYear(), first.getMonth(), Math.min(date.getDate(), last), 12);\n}\n\nexport const isSameDay = (a: Date | null, b: Date | null): boolean =>\n Boolean(a && b && toISO(a) === toISO(b));\n\nexport function clampDate(date: Date, min: Date | null, max: Date | null): Date {\n if (min && date < min) return min;\n if (max && date > max) return max;\n return date;\n}\n\n/** The 42 days (6 weeks) shown for the month containing `month`, starting on `weekStartsOn` (0 = Sunday). */\nexport function buildMonthGrid(month: Date, weekStartsOn: 0 | 1): Date[] {\n const first = new Date(month.getFullYear(), month.getMonth(), 1, 12);\n const offset = (first.getDay() - weekStartsOn + 7) % 7;\n return Array.from({ length: 42 }, (_, i) => addDays(first, i - offset));\n}\n\nexport interface DateRange {\n /** First disabled day, `YYYY-MM-DD`. */\n from: string;\n /** Last disabled day, `YYYY-MM-DD`. */\n to: string;\n}\n\nexport interface DisabledDateOptions {\n /** Earliest selectable day, `YYYY-MM-DD`. Earlier days are disabled. */\n min?: string;\n /** Latest selectable day, `YYYY-MM-DD`. Later days are disabled. */\n max?: string;\n /** Disable every day before today. Today stays selectable. */\n disablePast?: boolean;\n /** Disable every day after today. Today stays selectable. */\n disableFuture?: boolean;\n /** Individual days to disable, as `YYYY-MM-DD` strings or Date objects (holidays, booked days). */\n disabledDates?: (string | Date)[];\n /** Ranges to disable, both ends included (e.g. a term break). */\n disabledRanges?: DateRange[];\n /** Weekdays to disable: 0 = Sunday ... 6 = Saturday (e.g. `[0, 6]` for weekends). */\n disabledDaysOfWeek?: number[];\n /** Your own rule. Return true to disable the day. Runs in addition to the options above. */\n isDateDisabled?: (date: Date) => boolean;\n}\n\n/** Combines every disabling option into one `(date) => boolean`. Invalid dates in the options are ignored. */\nexport function createDisabledPredicate(\n options: DisabledDateOptions,\n now: Date = today(),\n): (date: Date) => boolean {\n const min = parseISO(options.min);\n const max = parseISO(options.max);\n const todayISO = toISO(now);\n const dates = new Set(\n (options.disabledDates ?? [])\n .map((d) => (d instanceof Date ? toISO(d) : parseISO(d) ? d : null))\n .filter((d): d is string => d !== null),\n );\n const ranges = (options.disabledRanges ?? [])\n .map((r) => ({ from: parseISO(r.from), to: parseISO(r.to) }))\n .filter((r): r is { from: Date; to: Date } => r.from !== null && r.to !== null)\n .map((r) => ({ from: toISO(r.from), to: toISO(r.to) }));\n const weekdays = new Set(options.disabledDaysOfWeek ?? []);\n\n return (date) => {\n const iso = toISO(date);\n if (min && iso < toISO(min)) return true;\n if (max && iso > toISO(max)) return true;\n if (options.disablePast && iso < todayISO) return true;\n if (options.disableFuture && iso > todayISO) return true;\n if (dates.has(iso)) return true;\n if (weekdays.has(date.getDay())) return true;\n if (ranges.some((r) => iso >= r.from && iso <= r.to)) return true;\n return options.isDateDisabled?.(date) ?? false;\n };\n}\n\n/** `date` itself if it is enabled, otherwise the closest enabled day (searching up to a year either way). */\nexport function nearestEnabled(date: Date, isDisabled: (date: Date) => boolean): Date {\n if (!isDisabled(date)) return date;\n for (let offset = 1; offset <= 366; offset++) {\n const after = addDays(date, offset);\n if (!isDisabled(after)) return after;\n const before = addDays(date, -offset);\n if (!isDisabled(before)) return before;\n }\n return date;\n}\n\n/* ---------- Months (`YYYY-MM`) ---------- */\n\n/** `2026-10` for a date. */\nexport const toMonthISO = (date: Date): string =>\n `${pad(date.getFullYear(), 4)}-${pad(date.getMonth() + 1)}`;\n\n/** Parses `YYYY-MM` to the first day of that month. Returns null for anything else. */\nexport function parseMonth(value: string | null | undefined): Date | null {\n if (!value || !/^\\d{4}-\\d{2}$/.test(value)) return null;\n return parseISO(`${value}-01`);\n}\n\nexport interface DisabledMonthOptions {\n /** Earliest selectable month, `YYYY-MM`. */\n min?: string;\n /** Latest selectable month, `YYYY-MM`. */\n max?: string;\n /** Disable months before the current month. The current month stays selectable. */\n disablePast?: boolean;\n /** Disable months after the current month. The current month stays selectable. */\n disableFuture?: boolean;\n /** Individual months to disable, `YYYY-MM`. */\n disabledMonths?: string[];\n /** Your own rule, called with the first day of the month. Return true to disable it. */\n isMonthDisabled?: (month: Date) => boolean;\n}\n\n/** Combines every month-disabling option into one `(firstDayOfMonth) => boolean`. */\nexport function createMonthDisabledPredicate(\n options: DisabledMonthOptions,\n now: Date = today(),\n): (month: Date) => boolean {\n const min = options.min && parseMonth(options.min) ? options.min : null;\n const max = options.max && parseMonth(options.max) ? options.max : null;\n const current = toMonthISO(now);\n const listed = new Set((options.disabledMonths ?? []).filter((m) => parseMonth(m)));\n\n return (month) => {\n const iso = toMonthISO(month);\n if (min && iso < min) return true;\n if (max && iso > max) return true;\n if (options.disablePast && iso < current) return true;\n if (options.disableFuture && iso > current) return true;\n if (listed.has(iso)) return true;\n return options.isMonthDisabled?.(month) ?? false;\n };\n}\n\n/* ---------- Date and time (`YYYY-MM-DDTHH:mm`) ---------- */\n\n/** `2026-10-08T14:30` for a date, in local time. */\nexport const toDateTimeISO = (date: Date): string =>\n `${toISO(date)}T${pad(date.getHours())}:${pad(date.getMinutes())}`;\n\n/** Parses `YYYY-MM-DDTHH:mm` (seconds are ignored) to a local Date. Returns null for anything else. */\nexport function parseDateTime(value: string | null | undefined): Date | null {\n const match = /^(\\d{4}-\\d{2}-\\d{2})T(\\d{2}):(\\d{2})(?::\\d{2}(?:\\.\\d+)?)?$/.exec(value ?? '');\n if (!match) return null;\n const day = parseISO(match[1]);\n const hours = Number(match[2]);\n const minutes = Number(match[3]);\n if (!day || hours > 23 || minutes > 59) return null;\n return new Date(day.getFullYear(), day.getMonth(), day.getDate(), hours, minutes);\n}\n\n/** A date with its time replaced. */\nexport const withTime = (date: Date, hours: number, minutes: number): Date =>\n new Date(date.getFullYear(), date.getMonth(), date.getDate(), hours, minutes);\n",".root {\n padding: var(--cui-space-3);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-sm);\n color: var(--cui-color-text);\n}\n\n.header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--cui-space-1);\n margin-bottom: var(--cui-space-3);\n}\n\n.title {\n display: flex;\n align-items: center;\n gap: var(--cui-space-1);\n font-weight: var(--cui-font-weight-semibold);\n}\n\n.nav,\n.titleButton {\n background: transparent;\n border: 0;\n color: inherit;\n font: inherit;\n cursor: pointer;\n}\n\n.nav {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 2rem;\n height: 2rem;\n padding: 0;\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text-muted);\n}\n.nav svg {\n width: 1rem;\n height: 1rem;\n}\n.nav:hover {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-primary);\n}\n\n.titleButton {\n padding: var(--cui-space-1) var(--cui-space-2);\n border-radius: var(--cui-radius-lg);\n}\n.titleButton:hover {\n background-color: var(--cui-color-surface-secondary);\n}\n\n.nav:focus-visible,\n.titleButton:focus-visible,\n.day:focus-visible,\n.cell:focus-visible,\n.footerButton:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: -1px;\n}\n\n.weekdays,\n.grid {\n display: grid;\n grid-template-columns: repeat(7, 2.25rem);\n}\n\n.weekdays {\n margin-bottom: var(--cui-space-1);\n text-align: center;\n font-size: var(--cui-font-size-xs);\n font-weight: var(--cui-font-weight-medium);\n color: var(--cui-color-text-muted);\n}\n.weekdays span {\n padding: var(--cui-space-1) 0;\n}\n\n.grid {\n gap: 2px;\n}\n\n.day {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 2.25rem;\n padding: 0;\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text);\n font: inherit;\n font-size: var(--cui-font-size-xs);\n font-weight: var(--cui-font-weight-medium);\n cursor: pointer;\n}\n\n.day:hover:not([aria-disabled='true']):not(.selected) {\n background-color: var(--cui-color-primary-subtle);\n color: var(--cui-color-primary);\n}\n\n.outside {\n color: var(--cui-color-text-disabled);\n}\n\n.today:not(.selected) {\n box-shadow: inset 0 0 0 1px var(--cui-color-primary);\n color: var(--cui-color-primary);\n}\n\n.selected {\n background-color: var(--cui-color-primary);\n color: var(--cui-color-on-primary);\n}\n\n.day[aria-disabled='true'] {\n opacity: 0.35;\n text-decoration: line-through;\n cursor: not-allowed;\n}\n\n.cells {\n display: grid;\n grid-template-columns: repeat(3, 1fr);\n gap: var(--cui-space-2);\n width: calc(7 * 2.25rem + 6 * 2px);\n}\n\n.cell {\n padding: var(--cui-space-3) var(--cui-space-2);\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text-secondary);\n font: inherit;\n cursor: pointer;\n}\n.cell:hover {\n background-color: var(--cui-color-primary-subtle);\n color: var(--cui-color-primary);\n}\n.active {\n background-color: var(--cui-color-primary-subtle);\n color: var(--cui-color-primary);\n font-weight: var(--cui-font-weight-semibold);\n}\n\n.footer {\n display: flex;\n align-items: center;\n justify-content: space-between;\n margin-top: var(--cui-space-3);\n padding-top: var(--cui-space-2);\n border-top: 1px solid var(--cui-color-border);\n font-size: var(--cui-font-size-xs);\n font-weight: var(--cui-font-weight-semibold);\n}\n\n.footerButton {\n padding: 6px var(--cui-space-2);\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-md);\n color: var(--cui-color-text-muted);\n font: inherit;\n cursor: pointer;\n}\n.footerButton:hover:not(:disabled) {\n background-color: var(--cui-color-surface-secondary);\n}\n.footerPrimary {\n color: var(--cui-color-primary);\n}\n.footerButton:disabled {\n opacity: 0.35;\n cursor: not-allowed;\n}\n\n.cell[aria-disabled='true'] {\n opacity: 0.35;\n text-decoration: line-through;\n cursor: not-allowed;\n}\n.cell[aria-disabled='true']:hover {\n background: transparent;\n color: var(--cui-color-text-secondary);\n}\n\n.currentCell {\n box-shadow: inset 0 0 0 1px var(--cui-color-primary);\n color: var(--cui-color-primary);\n}\n","import { useEffect, useMemo, useRef, useState, type KeyboardEvent } from 'react';\nimport { cn } from '../../utils/cn';\nimport {\n addDays,\n addMonths,\n buildMonthGrid,\n nearestEnabled,\n isSameDay,\n today as getToday,\n toISO,\n} from './dateUtils';\nimport styles from './Calendar.module.css';\n\nexport interface CalendarProps {\n selected: Date | null;\n /** True for days that cannot be chosen. Disabled days stay focusable so keyboard navigation can pass over them. */\n isDisabled: (date: Date) => boolean;\n weekStartsOn: 0 | 1;\n locale?: string;\n /** Called with the chosen date, or null when \"Clear\" is pressed. */\n onSelect: (date: Date | null) => void;\n /** Hide the Clear button (when the picker is not clearable). */\n allowClear: boolean;\n /** Show the Clear / Today footer. Defaults to true. */\n showFooter?: boolean;\n}\n\ntype View = 'days' | 'months' | 'years';\n\nconst chevron = (direction: 'left' | 'right') => (\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d={direction === 'left' ? 'M12 5l-5 5 5 5' : 'M8 5l5 5-5 5'} />\n </svg>\n);\n\n/** The calendar shown inside the DatePicker popover: days, months and years views with full keyboard support. */\nexport function Calendar({\n selected,\n isDisabled,\n weekStartsOn,\n locale,\n onSelect,\n allowClear,\n showFooter = true,\n}: CalendarProps) {\n const todayDate = getToday();\n const [cursor, setCursor] = useState<Date>(() =>\n nearestEnabled(selected ?? todayDate, isDisabled),\n );\n const [view, setView] = useState<View>('days');\n const gridRef = useRef<HTMLDivElement>(null);\n const focusCursor = useRef(true);\n\n const monthName = useMemo(\n () => new Intl.DateTimeFormat(locale, { month: 'long' }).format(cursor),\n [cursor, locale],\n );\n const monthShort = useMemo(\n () =>\n Array.from({ length: 12 }, (_, m) =>\n new Intl.DateTimeFormat(locale, { month: 'short' }).format(new Date(2024, m, 1)),\n ),\n [locale],\n );\n const weekdays = useMemo(() => {\n const base = new Date(2024, 0, 7 + weekStartsOn); // 7 Jan 2024 is a Sunday\n return Array.from({ length: 7 }, (_, i) => {\n const day = addDays(base, i);\n return {\n short: new Intl.DateTimeFormat(locale, { weekday: 'short' }).format(day),\n long: new Intl.DateTimeFormat(locale, { weekday: 'long' }).format(day),\n };\n });\n }, [locale, weekStartsOn]);\n const dayLabel = useMemo(() => new Intl.DateTimeFormat(locale, { dateStyle: 'full' }), [locale]);\n\n const days = useMemo(() => buildMonthGrid(cursor, weekStartsOn), [cursor, weekStartsOn]);\n const year = cursor.getFullYear();\n const yearStart = Math.floor((year - 1) / 12) * 12 + 1;\n\n // Move focus to the active day after keyboard navigation (not on mouse paging).\n const cursorISO = toISO(cursor);\n useEffect(() => {\n if (view !== 'days' || !focusCursor.current) return;\n gridRef.current\n ?.querySelector<HTMLElement>(`[data-date=\"${cursorISO}\"]`)\n ?.focus({ preventScroll: true });\n }, [cursorISO, view]);\n\n const moveCursor = (next: Date) => {\n focusCursor.current = true;\n setCursor(next);\n };\n\n const handleGridKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const step: Record<string, () => Date> = {\n ArrowLeft: () => addDays(cursor, -1),\n ArrowRight: () => addDays(cursor, 1),\n ArrowUp: () => addDays(cursor, -7),\n ArrowDown: () => addDays(cursor, 7),\n PageUp: () => addMonths(cursor, event.shiftKey ? -12 : -1),\n PageDown: () => addMonths(cursor, event.shiftKey ? 12 : 1),\n Home: () => addDays(cursor, -((cursor.getDay() - weekStartsOn + 7) % 7)),\n End: () => addDays(cursor, 6 - ((cursor.getDay() - weekStartsOn + 7) % 7)),\n };\n const move = step[event.key];\n if (!move) return;\n event.preventDefault();\n moveCursor(move());\n };\n\n const page = (direction: 1 | -1) => {\n focusCursor.current = false;\n setCursor((current) =>\n addMonths(current, direction * (view === 'years' ? 144 : view === 'months' ? 12 : 1)),\n );\n };\n\n const prevLabel =\n view === 'years' ? 'Previous 12 years' : view === 'months' ? 'Previous year' : 'Previous month';\n const nextLabel =\n view === 'years' ? 'Next 12 years' : view === 'months' ? 'Next year' : 'Next month';\n\n return (\n <div className={styles.root}>\n <div className={styles.header}>\n <button\n type=\"button\"\n className={styles.nav}\n aria-label={prevLabel}\n onClick={() => page(-1)}\n >\n {chevron('left')}\n </button>\n <div className={styles.title} aria-live=\"polite\">\n {view === 'years' ? (\n <span>\n {yearStart} - {yearStart + 11}\n </span>\n ) : (\n <>\n {view === 'days' ? (\n <button\n type=\"button\"\n className={styles.titleButton}\n aria-label=\"Choose month\"\n onClick={() => setView('months')}\n >\n {monthName}\n </button>\n ) : null}\n <button\n type=\"button\"\n className={styles.titleButton}\n aria-label=\"Choose year\"\n onClick={() => setView('years')}\n >\n {year}\n </button>\n </>\n )}\n </div>\n <button type=\"button\" className={styles.nav} aria-label={nextLabel} onClick={() => page(1)}>\n {chevron('right')}\n </button>\n </div>\n\n {view === 'days' ? (\n <>\n <div className={styles.weekdays} aria-hidden=\"true\">\n {weekdays.map((day) => (\n <span key={day.long}>{day.short}</span>\n ))}\n </div>\n <div\n ref={gridRef}\n className={styles.grid}\n role=\"group\"\n aria-label={`${monthName} ${year}`}\n onKeyDown={handleGridKeyDown}\n >\n {days.map((day) => {\n const iso = toISO(day);\n const outside = day.getMonth() !== cursor.getMonth();\n const isSelected = isSameDay(day, selected);\n return (\n <button\n key={iso}\n type=\"button\"\n data-date={iso}\n tabIndex={isSameDay(day, cursor) ? 0 : -1}\n aria-disabled={isDisabled(day) || undefined}\n aria-label={dayLabel.format(day)}\n aria-pressed={isSelected}\n aria-current={isSameDay(day, todayDate) ? 'date' : undefined}\n className={cn(\n styles.day,\n outside && styles.outside,\n isSameDay(day, todayDate) && styles.today,\n isSelected && styles.selected,\n )}\n onClick={() => {\n if (!isDisabled(day)) onSelect(day);\n }}\n >\n {day.getDate()}\n </button>\n );\n })}\n </div>\n </>\n ) : view === 'months' ? (\n <div className={styles.cells}>\n {monthShort.map((name, month) => (\n <button\n key={name}\n type=\"button\"\n className={cn(styles.cell, month === cursor.getMonth() && styles.active)}\n onClick={() => {\n focusCursor.current = true;\n setCursor((current) => addMonths(current, month - current.getMonth()));\n setView('days');\n }}\n >\n {name}\n </button>\n ))}\n </div>\n ) : (\n <div className={styles.cells}>\n {Array.from({ length: 12 }, (_, i) => yearStart + i).map((y) => (\n <button\n key={y}\n type=\"button\"\n className={cn(styles.cell, y === year && styles.active)}\n onClick={() => {\n focusCursor.current = true;\n setCursor((current) => addMonths(current, (y - current.getFullYear()) * 12));\n setView('months');\n }}\n >\n {y}\n </button>\n ))}\n </div>\n )}\n\n {showFooter ? (\n <div className={styles.footer}>\n {allowClear ? (\n <button type=\"button\" className={styles.footerButton} onClick={() => onSelect(null)}>\n Clear\n </button>\n ) : (\n <span />\n )}\n <button\n type=\"button\"\n className={cn(styles.footerButton, styles.footerPrimary)}\n disabled={isDisabled(todayDate)}\n onClick={() => onSelect(todayDate)}\n >\n Today\n </button>\n </div>\n ) : null}\n </div>\n );\n}\n","/**\n * Shared container for portalled UI (menus, popovers, dialogs). Rendering into a dedicated element\n * rather than straight into <body> avoids a browser freeze seen when a portal into <body> opens\n * on a Storybook docs page.\n */\nconst HOST_ID = 'cui-portal-root';\n\nexport function getPortalHost(): HTMLElement {\n let host = document.getElementById(HOST_ID);\n if (!host) {\n host = document.createElement('div');\n host.id = HOST_ID;\n document.body.appendChild(host);\n }\n return host;\n}\n",".control {\n position: relative;\n display: flex;\n align-items: center;\n width: 100%;\n color: var(--cui-color-text);\n}\n\n.trigger {\n appearance: none;\n display: flex;\n align-items: center;\n box-sizing: border-box;\n width: 100%;\n padding: 0 var(--cui-space-10) 0 var(--cui-space-4);\n background-color: var(--cui-color-surface);\n border: var(--cui-control-border-width) solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n color: inherit;\n font-family: var(--cui-font-family);\n font-size: inherit;\n text-align: start;\n cursor: pointer;\n transition:\n border-color var(--cui-transition-fast),\n box-shadow var(--cui-transition-fast);\n}\n\n.control:not(.open) .trigger:hover:not(:disabled):not(:focus-visible) {\n border-color: var(--cui-color-border-hover);\n}\n\n.trigger:focus-visible,\n.open .trigger {\n border-color: var(--cui-color-border-focus);\n outline: none;\n box-shadow: var(--cui-focus-ring);\n}\n\n.value {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.placeholder .value {\n color: var(--cui-color-placeholder);\n}\n\n.sm {\n font-size: var(--cui-font-size-sm);\n}\n.sm .trigger {\n height: var(--cui-control-height-sm);\n}\n.md {\n font-size: var(--cui-font-size-sm);\n}\n.md .trigger {\n height: var(--cui-control-height-md);\n}\n.lg {\n font-size: var(--cui-font-size-lg);\n}\n.lg .trigger {\n height: var(--cui-control-height-lg);\n}\n\n.icon {\n position: absolute;\n inset-inline-end: var(--cui-space-3);\n width: 1.25rem;\n height: 1.25rem;\n color: var(--cui-color-text-muted);\n pointer-events: none;\n}\n\n.clear {\n position: absolute;\n inset-inline-end: calc(var(--cui-space-3) + 1.5rem);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 1.25rem;\n height: 1.25rem;\n padding: 0;\n border: 0;\n border-radius: var(--cui-radius-full);\n background: transparent;\n color: var(--cui-color-text-muted);\n cursor: pointer;\n}\n.clear:hover {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text);\n}\n.clear:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n}\n.clear svg {\n width: 0.875rem;\n height: 0.875rem;\n}\n\n.invalid .trigger {\n border-color: var(--cui-color-danger-border);\n}\n.invalid:not(.open) .trigger:hover:not(:disabled):not(:focus-visible) {\n border-color: var(--cui-color-danger-border-hover);\n}\n.invalid .trigger:focus-visible,\n.invalid.open .trigger {\n border-color: var(--cui-color-danger-border-hover);\n box-shadow: var(--cui-focus-ring-danger);\n}\n\n.disabled {\n color: var(--cui-color-text-disabled);\n}\n.disabled .trigger {\n background-color: var(--cui-color-surface-secondary);\n cursor: not-allowed;\n}\n.disabled .icon {\n color: var(--cui-color-text-disabled);\n}\n\n.panel {\n position: fixed;\n z-index: var(--cui-z-popover);\n box-sizing: border-box;\n background-color: var(--cui-color-surface);\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-xl);\n box-shadow: var(--cui-shadow-lg);\n animation: cui-datepicker-in 0.15s ease-out;\n}\n\n@keyframes cui-datepicker-in {\n from {\n opacity: 0;\n transform: translateY(-6px) scale(0.98);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .panel {\n animation: none;\n }\n}\n","import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n type ButtonHTMLAttributes,\n type CSSProperties,\n type KeyboardEvent,\n type ReactNode,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { cn } from '../../utils/cn';\nimport { getPortalHost } from '../../utils/portalHost';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport type { ComponentSize } from '../../types';\nimport { FormField, useFormFieldControl } from '../FormField';\nimport styles from './PickerField.module.css';\n\nconst MENU_GAP = 4;\nconst MENU_ESTIMATED_HEIGHT = 420;\nconst FOCUSABLE = 'button:not([disabled]):not([tabindex=\"-1\"]), [tabindex=\"0\"]';\n\nexport interface PickerPanelContext {\n /** Close the popover. Focus returns to the field unless `restoreFocus` is false. */\n close: (restoreFocus?: boolean) => void;\n}\n\nexport interface PickerFieldProps extends Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n 'children' | 'placeholder' | 'value' | 'defaultValue' | 'onChange'\n> {\n required?: boolean;\n error?: ReactNode;\n size?: ComponentSize;\n /** Text for the chosen value, or null to show the placeholder. */\n displayText: string | null;\n placeholder: string;\n /** Submitted with a surrounding form under `name`. */\n name?: string;\n hiddenValue: string;\n /** Show the clear button (only while a value is chosen). */\n clearable: boolean;\n onClear: () => void;\n clearLabel: string;\n /** Accessible name of the popover. */\n panelLabel: string;\n /** Approximate width of the popover in px, used to keep it on screen. */\n panelWidth?: number;\n icon?: 'calendar' | 'clock';\n /** The popover content. */\n children: (context: PickerPanelContext) => ReactNode;\n}\n\n/**\n * Shared field for the date, month and date-time pickers: a trigger styled like the other form\n * controls, a clear button, and a popover rendered in <body> (so nothing can clip it) that keeps the\n * surrounding theme, closes on Escape or an outside click, and keeps Tab inside it.\n */\nconst PickerFieldControl = forwardRef<HTMLButtonElement, PickerFieldProps>(\n function PickerFieldControl(\n {\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n size = 'md',\n displayText,\n placeholder,\n name,\n hiddenValue,\n clearable,\n onClear,\n clearLabel,\n panelLabel,\n panelWidth = 300,\n icon = 'calendar',\n className,\n onClick,\n onKeyDown,\n children,\n ...rest\n },\n ref,\n ) {\n const control = useFormFieldControl({\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n });\n const panelId = `${useId()}-panel`;\n\n const containerRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n const panelRef = useRef<HTMLDivElement>(null);\n const setTriggerRef = useCallback(\n (node: HTMLButtonElement | null) => {\n triggerRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n },\n [ref],\n );\n\n const [open, setOpen] = useState(false);\n const [style, setStyle] = useState<CSSProperties | null>(null);\n const [themeName, setThemeName] = useState<string | undefined>();\n\n const computePosition = useCallback(() => {\n const container = containerRef.current;\n if (!container) return;\n const rect = container.getBoundingClientRect();\n const spaceBelow = window.innerHeight - rect.bottom;\n const above = spaceBelow < MENU_ESTIMATED_HEIGHT && rect.top > spaceBelow;\n const next: CSSProperties = {\n left: Math.max(8, Math.min(rect.left, window.innerWidth - panelWidth)),\n };\n if (above) next.bottom = window.innerHeight - rect.top + MENU_GAP;\n else next.top = rect.bottom + MENU_GAP;\n setStyle(next);\n }, [panelWidth]);\n\n const openPicker = () => {\n if (control.disabled) return;\n computePosition();\n // The popover lives in <body>; carry the surrounding theme over to it.\n setThemeName(\n containerRef.current?.closest('[data-theme]')?.getAttribute('data-theme') ?? undefined,\n );\n setOpen(true);\n };\n\n // `close` is handed to render code, so it must not touch refs; focus is restored by an effect.\n const [focusTick, setFocusTick] = useState(0);\n const close = (restoreFocus = true) => {\n setOpen(false);\n if (restoreFocus) setFocusTick((tick) => tick + 1);\n };\n useEffect(() => {\n if (focusTick > 0) triggerRef.current?.focus({ preventScroll: true });\n }, [focusTick]);\n\n useEffect(() => {\n if (!open) return;\n const reposition = () => requestAnimationFrame(computePosition);\n const onPointerDown = (event: MouseEvent) => {\n const target = event.target as Node;\n if (!containerRef.current?.contains(target) && !panelRef.current?.contains(target))\n setOpen(false);\n };\n window.addEventListener('scroll', reposition, true);\n window.addEventListener('resize', reposition);\n document.addEventListener('mousedown', onPointerDown, true);\n return () => {\n window.removeEventListener('scroll', reposition, true);\n window.removeEventListener('resize', reposition);\n document.removeEventListener('mousedown', onPointerDown, true);\n };\n }, [open, computePosition]);\n\n const handlePanelKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Escape') {\n event.preventDefault();\n event.stopPropagation();\n close();\n return;\n }\n if (event.key !== 'Tab') return;\n // The popover is portalled to <body>, so keep Tab cycling inside it.\n const nodes = Array.from(panelRef.current?.querySelectorAll<HTMLElement>(FOCUSABLE) ?? []);\n const first = nodes[0];\n const last = nodes[nodes.length - 1];\n if (!first || !last) return;\n if (event.shiftKey && document.activeElement === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n };\n\n const hasValue = displayText !== null;\n const showClear = clearable && hasValue && !control.disabled;\n\n return (\n <div\n ref={containerRef}\n className={cn(\n styles.control,\n styles[size],\n control.invalid && styles.invalid,\n control.disabled && styles.disabled,\n open && styles.open,\n className,\n )}\n >\n <button\n {...rest}\n ref={setTriggerRef}\n id={control.id}\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n aria-controls={open ? panelId : undefined}\n aria-invalid={control['aria-invalid']}\n aria-describedby={control['aria-describedby']}\n aria-required={control.required || undefined}\n disabled={control.disabled}\n className={cn(styles.trigger, !hasValue && styles.placeholder)}\n onClick={(event) => {\n onClick?.(event);\n if (event.defaultPrevented) return;\n if (open) close(false);\n else openPicker();\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n if (!open && event.key === 'ArrowDown') {\n event.preventDefault();\n openPicker();\n }\n }}\n >\n <span className={styles.value}>{displayText ?? placeholder}</span>\n </button>\n\n {showClear ? (\n <button\n type=\"button\"\n className={styles.clear}\n aria-label={clearLabel}\n onClick={() => {\n onClear();\n triggerRef.current?.focus({ preventScroll: true });\n }}\n >\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M6 6l8 8M14 6l-8 8\" />\n </svg>\n </button>\n ) : null}\n\n <svg\n className={styles.icon}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.8\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n {icon === 'clock' ? (\n <>\n <circle cx=\"12\" cy=\"12\" r=\"8\" />\n <path d=\"M12 7v5l3 2\" />\n </>\n ) : (\n <>\n <rect x=\"4\" y=\"5\" width=\"16\" height=\"15\" rx=\"2\" />\n <path d=\"M4 10h16M9 3v4M15 3v4\" />\n </>\n )}\n </svg>\n\n {name ? <input type=\"hidden\" name={name} value={hiddenValue} /> : null}\n\n {open && style\n ? createPortal(\n <div\n ref={panelRef}\n id={panelId}\n role=\"dialog\"\n aria-label={panelLabel}\n className={styles.panel}\n style={style}\n data-theme={themeName}\n onKeyDown={handlePanelKeyDown}\n >\n {children({ close })}\n </div>,\n getPortalHost(),\n )\n : null}\n </div>\n );\n },\n);\n\nexport interface PickerShellProps {\n label?: ReactNode;\n helperText?: ReactNode;\n error?: ReactNode;\n required?: boolean;\n disabled?: boolean;\n id?: string;\n children: ReactNode;\n}\n\n/** Adds the label, helper text and error around a picker, unless an enclosing FormField provides them. */\nexport function PickerShell({\n label,\n helperText,\n error,\n required,\n disabled,\n id,\n children,\n}: PickerShellProps) {\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n if (!label && !helperText && !error) return <>{children}</>;\n return (\n <FormField\n id={id}\n label={label}\n helperText={helperText}\n error={error}\n required={required}\n disabled={disabled}\n >\n {children}\n </FormField>\n );\n}\n\nexport const PickerField = PickerFieldControl;\n","import { forwardRef, useMemo, useState } from 'react';\nimport { Calendar } from './Calendar';\nimport { createDisabledPredicate, parseISO, toISO } from './dateUtils';\nimport { PickerField, PickerShell } from './PickerField';\nimport type { DatePickerProps } from './DatePicker.types';\n\n/** Date field with a calendar popover (days, months and years views, keyboard navigation). */\nexport const DatePicker = forwardRef<HTMLButtonElement, DatePickerProps>(function DatePicker(\n {\n label,\n helperText,\n error,\n required,\n disabled,\n id,\n value,\n defaultValue,\n onChange,\n min,\n max,\n disablePast,\n disableFuture,\n disabledDates,\n disabledRanges,\n disabledDaysOfWeek,\n isDateDisabled,\n placeholder = 'Select a date',\n name,\n clearable = true,\n weekStartsOn = 0,\n locale,\n ...rest\n },\n ref,\n) {\n const isControlled = value !== undefined;\n const [internal, setInternal] = useState(defaultValue ?? '');\n const current = isControlled ? value : internal;\n const selected = parseISO(current);\n const isDisabled = createDisabledPredicate({\n min,\n max,\n disablePast,\n disableFuture,\n disabledDates,\n disabledRanges,\n disabledDaysOfWeek,\n isDateDisabled,\n });\n\n const formatter = useMemo(\n () => new Intl.DateTimeFormat(locale, { day: '2-digit', month: 'short', year: 'numeric' }),\n [locale],\n );\n\n const commit = (next: string) => {\n if (!isControlled) setInternal(next);\n onChange?.(next);\n };\n\n return (\n <PickerShell\n label={label}\n helperText={helperText}\n error={error}\n required={required}\n disabled={disabled}\n id={id}\n >\n <PickerField\n {...rest}\n ref={ref}\n id={id}\n required={required}\n disabled={disabled}\n error={error}\n name={name}\n hiddenValue={selected ? toISO(selected) : ''}\n displayText={selected ? formatter.format(selected) : null}\n placeholder={placeholder}\n clearable={clearable}\n clearLabel=\"Clear date\"\n onClear={() => commit('')}\n panelLabel=\"Choose date\"\n >\n {({ close }) => (\n <Calendar\n selected={selected}\n isDisabled={isDisabled}\n weekStartsOn={weekStartsOn}\n locale={locale}\n allowClear={clearable}\n onSelect={(date) => {\n commit(date ? toISO(date) : '');\n close();\n }}\n />\n )}\n </PickerField>\n </PickerShell>\n );\n});\n",".root {\n display: flex;\n gap: var(--cui-space-2);\n padding: 0 var(--cui-space-3) var(--cui-space-3);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-sm);\n}\n\n.column {\n flex: 1;\n min-width: 0;\n}\n\n.list {\n display: flex;\n flex-direction: column;\n gap: 2px;\n max-height: 9.5rem;\n overflow-y: auto;\n padding: var(--cui-space-1);\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n background-color: var(--cui-color-surface);\n}\n\n.option {\n flex-shrink: 0;\n padding: 6px var(--cui-space-2);\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-md);\n color: var(--cui-color-text-secondary);\n font: inherit;\n text-align: center;\n cursor: pointer;\n}\n\n.option:hover:not([aria-disabled='true']):not(.selected) {\n background-color: var(--cui-color-primary-subtle);\n color: var(--cui-color-primary);\n}\n\n.option:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: -1px;\n}\n\n.selected {\n background-color: var(--cui-color-primary);\n color: var(--cui-color-on-primary);\n font-weight: var(--cui-font-weight-semibold);\n}\n\n.option[aria-disabled='true'] {\n opacity: 0.35;\n text-decoration: line-through;\n cursor: not-allowed;\n}\n","import { useEffect, useRef, type KeyboardEvent } from 'react';\nimport { cn } from '../../utils/cn';\nimport styles from './TimeColumns.module.css';\n\nexport interface TimeColumnsProps {\n /** Hour 0-23, or null while no time is chosen. */\n hours: number | null;\n minutes: number | null;\n onChange: (hours: number, minutes: number) => void;\n minuteStep: number;\n use12Hours: boolean;\n /** True for times that cannot be chosen. */\n isTimeDisabled: (hours: number, minutes: number) => boolean;\n}\n\ninterface Option {\n value: number;\n label: string;\n disabled: boolean;\n}\n\nconst pad = (n: number) => String(n).padStart(2, '0');\n\n/** Hour, minute (and AM/PM) lists used inside the DateTimePicker popover. */\nexport function TimeColumns({\n hours,\n minutes,\n onChange,\n minuteStep,\n use12Hours,\n isTimeDisabled,\n}: TimeColumnsProps) {\n const h = hours ?? 0;\n const m = minutes ?? 0;\n const isPm = h >= 12;\n\n // Multiples of the step, plus the current minute when it is not one (e.g. set programmatically).\n const minuteValues = Array.from(\n { length: Math.ceil(60 / minuteStep) },\n (_, i) => i * minuteStep,\n ).filter((v) => v < 60);\n if (minutes !== null && !minuteValues.includes(minutes)) minuteValues.push(minutes);\n minuteValues.sort((a, b) => a - b);\n\n // An hour is unavailable when none of its minutes can be chosen.\n const hourDisabled = (hour: number) => minuteValues.every((v) => isTimeDisabled(hour, v));\n\n // Hours as shown (1-12 with AM/PM, or 0-23); each maps back to a 24 hour value.\n const hourOptions: Option[] = use12Hours\n ? Array.from({ length: 12 }, (_, i) => {\n const value = i + (isPm ? 12 : 0);\n return { value, label: String(i === 0 ? 12 : i), disabled: hourDisabled(value) };\n })\n : Array.from({ length: 24 }, (_, i) => ({\n value: i,\n label: pad(i),\n disabled: hourDisabled(i),\n }));\n\n const minuteOptions: Option[] = minuteValues.map((value) => ({\n value,\n label: pad(value),\n disabled: isTimeDisabled(h, value),\n }));\n\n const periodDisabled = (start: number) =>\n Array.from({ length: 12 }, (_, i) => start + i).every(hourDisabled);\n const periodOptions: Option[] = [\n { value: 0, label: 'AM', disabled: periodDisabled(0) },\n { value: 12, label: 'PM', disabled: periodDisabled(12) },\n ];\n\n return (\n <div className={styles.root}>\n <Column\n label=\"Hours\"\n options={hourOptions}\n selected={hours}\n onSelect={(value) => onChange(value, m)}\n />\n <Column\n label=\"Minutes\"\n options={minuteOptions}\n selected={minutes}\n onSelect={(value) => onChange(h, value)}\n />\n {use12Hours ? (\n <Column\n label=\"AM or PM\"\n options={periodOptions}\n selected={hours === null ? null : isPm ? 12 : 0}\n onSelect={(value) => onChange((h % 12) + value, m)}\n />\n ) : null}\n </div>\n );\n}\n\nfunction Column({\n label,\n options,\n selected,\n onSelect,\n}: {\n label: string;\n options: Option[];\n selected: number | null;\n onSelect: (value: number) => void;\n}) {\n const listRef = useRef<HTMLDivElement>(null);\n const selectedIndex = options.findIndex((option) => option.value === selected);\n\n // Keep the chosen value visible inside the scrolling list.\n useEffect(() => {\n const list = listRef.current;\n const el = list?.querySelector<HTMLElement>('[aria-selected=\"true\"]');\n if (list && el)\n list.scrollTop = Math.max(0, el.offsetTop - list.clientHeight / 2 + el.offsetHeight / 2);\n }, [selected]);\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const items = Array.from(\n listRef.current?.querySelectorAll<HTMLElement>('[role=\"option\"]') ?? [],\n );\n const current = items.indexOf(document.activeElement as HTMLElement);\n let next = -1;\n if (event.key === 'ArrowDown') next = Math.min(current + 1, items.length - 1);\n else if (event.key === 'ArrowUp') next = Math.max(current - 1, 0);\n else if (event.key === 'Home') next = 0;\n else if (event.key === 'End') next = items.length - 1;\n if (next < 0) return;\n event.preventDefault();\n items[next]?.focus({ preventScroll: false });\n };\n\n return (\n <div className={styles.column}>\n <div\n ref={listRef}\n role=\"listbox\"\n aria-label={label}\n className={styles.list}\n onKeyDown={handleKeyDown}\n >\n {options.map((option, index) => {\n const isSelected = option.value === selected;\n return (\n <button\n key={option.value}\n type=\"button\"\n role=\"option\"\n aria-selected={isSelected}\n aria-disabled={option.disabled || undefined}\n tabIndex={isSelected || (selectedIndex === -1 && index === 0) ? 0 : -1}\n className={cn(styles.option, isSelected && styles.selected)}\n onClick={() => {\n if (!option.disabled) onSelect(option.value);\n }}\n >\n {option.label}\n </button>\n );\n })}\n </div>\n </div>\n );\n}\n",".timeHeading {\n padding: 0 var(--cui-space-3) var(--cui-space-1);\n border-top: 1px solid var(--cui-color-border);\n margin: 0 var(--cui-space-3) var(--cui-space-2);\n padding: var(--cui-space-2) 0 0;\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-xs);\n font-weight: var(--cui-font-weight-semibold);\n color: var(--cui-color-text-muted);\n}\n\n.footer {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: var(--cui-space-2) var(--cui-space-3) var(--cui-space-3);\n border-top: 1px solid var(--cui-color-border);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-xs);\n font-weight: var(--cui-font-weight-semibold);\n}\n\n.footerActions {\n display: flex;\n gap: var(--cui-space-1);\n}\n\n.footerButton {\n padding: 6px var(--cui-space-3);\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-md);\n color: var(--cui-color-text-muted);\n font: inherit;\n cursor: pointer;\n}\n.footerButton:hover:not(:disabled) {\n background-color: var(--cui-color-surface-secondary);\n}\n.footerButton:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: -1px;\n}\n.footerButton:disabled {\n opacity: 0.35;\n cursor: not-allowed;\n}\n\n.done {\n background-color: var(--cui-color-primary);\n color: var(--cui-color-on-primary);\n}\n.done:hover:not(:disabled) {\n background-color: var(--cui-color-primary-hover);\n}\n","import { forwardRef, useMemo, useState } from 'react';\nimport { Calendar } from '../DatePicker/Calendar';\nimport { PickerField, PickerShell } from '../DatePicker/PickerField';\nimport { TimeColumns } from '../DatePicker/TimeColumns';\nimport {\n addDays,\n createDisabledPredicate,\n nearestEnabled,\n parseDateTime,\n parseISO,\n toDateTimeISO,\n toISO,\n today,\n withTime,\n} from '../DatePicker/dateUtils';\nimport type { DateTimePickerProps } from './DateTimePicker.types';\nimport styles from './DateTimePicker.module.css';\n\n/** `YYYY-MM-DDTHH:mm` (or a bare date) as a moment; a bare date means the start or end of that day. */\nfunction parseBoundary(value: string | undefined, end: boolean): Date | null {\n if (!value) return null;\n const full = parseDateTime(value);\n if (full) return full;\n const day = parseISO(value);\n return day ? withTime(day, end ? 23 : 0, end ? 59 : 0) : null;\n}\n\nconst parseTime = (value: string): [number, number] => {\n const match = /^(\\d{2}):(\\d{2})$/.exec(value);\n const hours = match ? Number(match[1]) : 0;\n const minutes = match ? Number(match[2]) : 0;\n return hours > 23 || minutes > 59 ? [0, 0] : [hours, minutes];\n};\n\n/** Date and time field: a calendar plus hour and minute lists (value as `YYYY-MM-DDTHH:mm`). */\nexport const DateTimePicker = forwardRef<HTMLButtonElement, DateTimePickerProps>(\n function DateTimePicker(\n {\n label,\n helperText,\n error,\n required,\n disabled,\n id,\n value,\n defaultValue,\n onChange,\n min,\n max,\n disablePast,\n disableFuture,\n disabledDates,\n disabledRanges,\n disabledDaysOfWeek,\n isDateDisabled,\n minuteStep = 5,\n use12Hours = false,\n defaultTime = '00:00',\n placeholder = 'Select date and time',\n name,\n clearable = true,\n weekStartsOn = 0,\n locale,\n ...rest\n },\n ref,\n ) {\n const isControlled = value !== undefined;\n const [internal, setInternal] = useState(defaultValue ?? '');\n const current = isControlled ? value : internal;\n const selected = parseDateTime(current);\n\n // \"Past\" and \"future\" are measured from now, so they also limit the hours of today.\n const now = new Date();\n const earliest = [parseBoundary(min, false), disablePast ? now : null]\n .filter((d): d is Date => d !== null)\n .sort((a, b) => b.getTime() - a.getTime())[0];\n const latest = [parseBoundary(max, true), disableFuture ? now : null]\n .filter((d): d is Date => d !== null)\n .sort((a, b) => a.getTime() - b.getTime())[0];\n\n const isDayDisabled = createDisabledPredicate({\n min: earliest ? toISO(earliest) : undefined,\n max: latest ? toISO(latest) : undefined,\n disabledDates,\n disabledRanges,\n disabledDaysOfWeek,\n isDateDisabled,\n });\n const isMomentDisabled = (moment: Date) =>\n isDayDisabled(moment) ||\n (earliest !== undefined &&\n moment < withTime(earliest, earliest.getHours(), earliest.getMinutes())) ||\n (latest !== undefined && moment > withTime(latest, latest.getHours(), latest.getMinutes()));\n\n const formatter = useMemo(\n () =>\n new Intl.DateTimeFormat(locale, {\n day: '2-digit',\n month: 'short',\n year: 'numeric',\n hour: '2-digit',\n minute: '2-digit',\n hour12: use12Hours,\n }),\n [locale, use12Hours],\n );\n\n const commit = (next: Date | null) => {\n const text = next ? toDateTimeISO(next) : '';\n if (!isControlled) setInternal(text);\n onChange?.(text);\n };\n\n /** The first allowed time on `day` at or after the wanted one, or the wanted one when nothing fits. */\n const fitTime = (day: Date, hours: number, minutes: number): Date => {\n const wanted = withTime(day, hours, minutes);\n if (!isMomentDisabled(wanted)) return wanted;\n for (let total = 0; total < 24 * 60; total += minuteStep) {\n const candidate = withTime(day, Math.floor(total / 60), total % 60);\n if (!isMomentDisabled(candidate)) return candidate;\n }\n return wanted;\n };\n\n const baseDay = () => selected ?? nearestEnabled(today(), isDayDisabled);\n const [defaultHours, defaultMinutes] = parseTime(defaultTime);\n const nowDate = new Date();\n\n return (\n <PickerShell\n label={label}\n helperText={helperText}\n error={error}\n required={required}\n disabled={disabled}\n id={id}\n >\n <PickerField\n {...rest}\n ref={ref}\n id={id}\n required={required}\n disabled={disabled}\n error={error}\n name={name}\n hiddenValue={selected ? toDateTimeISO(selected) : ''}\n displayText={selected ? formatter.format(selected) : null}\n placeholder={placeholder}\n clearable={clearable}\n clearLabel=\"Clear date and time\"\n onClear={() => commit(null)}\n panelLabel=\"Choose date and time\"\n panelWidth={use12Hours ? 340 : 320}\n icon=\"clock\"\n >\n {({ close }) => (\n <div>\n <Calendar\n selected={selected}\n isDisabled={isDayDisabled}\n weekStartsOn={weekStartsOn}\n locale={locale}\n allowClear={clearable}\n showFooter={false}\n onSelect={(day) => {\n if (!day) return;\n commit(\n fitTime(\n day,\n selected?.getHours() ?? defaultHours,\n selected?.getMinutes() ?? defaultMinutes,\n ),\n );\n }}\n />\n <div className={styles.timeHeading}>Time</div>\n <TimeColumns\n hours={selected ? selected.getHours() : null}\n minutes={selected ? selected.getMinutes() : null}\n minuteStep={minuteStep}\n use12Hours={use12Hours}\n isTimeDisabled={(hours, minutes) =>\n isMomentDisabled(withTime(baseDay(), hours, minutes))\n }\n onChange={(hours, minutes) => commit(withTime(baseDay(), hours, minutes))}\n />\n <div className={styles.footer}>\n {clearable ? (\n <button\n type=\"button\"\n className={styles.footerButton}\n onClick={() => {\n commit(null);\n }}\n >\n Clear\n </button>\n ) : (\n <span />\n )}\n <span className={styles.footerActions}>\n <button\n type=\"button\"\n className={styles.footerButton}\n disabled={isMomentDisabled(nowDate)}\n onClick={() =>\n commit(\n withTime(addDays(nowDate, 0), nowDate.getHours(), nowDate.getMinutes()),\n )\n }\n >\n Now\n </button>\n <button\n type=\"button\"\n className={`${styles.footerButton} ${styles.done}`}\n onClick={() => close()}\n >\n Done\n </button>\n </span>\n </div>\n </div>\n )}\n </PickerField>\n </PickerShell>\n );\n },\n);\n","import { useEffect, useMemo, useRef, useState, type KeyboardEvent } from 'react';\nimport { cn } from '../../utils/cn';\nimport { addMonths, parseMonth, today as getToday, toMonthISO } from './dateUtils';\nimport styles from './Calendar.module.css';\n\nexport interface MonthCalendarProps {\n /** Selected month as the first day of that month. */\n selected: Date | null;\n /** True for months that cannot be chosen (called with the first day of the month). */\n isDisabled: (month: Date) => boolean;\n locale?: string;\n /** Called with the first day of the chosen month, or null when Clear is pressed. */\n onSelect: (month: Date | null) => void;\n allowClear: boolean;\n}\n\ntype View = 'months' | 'years';\n\nconst chevron = (direction: 'left' | 'right') => (\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d={direction === 'left' ? 'M12 5l-5 5 5 5' : 'M8 5l5 5-5 5'} />\n </svg>\n);\n\nconst firstOfMonth = (year: number, month: number) => new Date(year, month, 1, 12);\n\n/** Month and year chooser shown inside the MonthPicker popover. */\nexport function MonthCalendar({\n selected,\n isDisabled,\n locale,\n onSelect,\n allowClear,\n}: MonthCalendarProps) {\n const thisMonth = getToday();\n // `cursor` is the month with keyboard focus; its year is the page being shown.\n const [cursor, setCursor] = useState<Date>(() =>\n firstOfMonth((selected ?? thisMonth).getFullYear(), (selected ?? thisMonth).getMonth()),\n );\n const [view, setView] = useState<View>('months');\n const gridRef = useRef<HTMLDivElement>(null);\n const focusCursor = useRef(true);\n\n const year = cursor.getFullYear();\n const yearStart = Math.floor((year - 1) / 12) * 12 + 1;\n const monthNames = useMemo(\n () =>\n Array.from({ length: 12 }, (_, m) =>\n new Intl.DateTimeFormat(locale, { month: 'short' }).format(new Date(2024, m, 1)),\n ),\n [locale],\n );\n const monthLong = useMemo(\n () => new Intl.DateTimeFormat(locale, { month: 'long', year: 'numeric' }),\n [locale],\n );\n\n const cursorISO = toMonthISO(cursor);\n useEffect(() => {\n if (view !== 'months' || !focusCursor.current) return;\n gridRef.current\n ?.querySelector<HTMLElement>(`[data-month=\"${cursorISO}\"]`)\n ?.focus({ preventScroll: true });\n }, [cursorISO, view]);\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const steps: Record<string, number> = {\n ArrowLeft: -1,\n ArrowRight: 1,\n ArrowUp: -3,\n ArrowDown: 3,\n PageUp: -12,\n PageDown: 12,\n };\n const step = steps[event.key];\n if (step === undefined) return;\n event.preventDefault();\n focusCursor.current = true;\n setCursor((current) => addMonths(current, step));\n };\n\n const page = (direction: 1 | -1) => {\n focusCursor.current = false;\n setCursor((current) => addMonths(current, direction * (view === 'years' ? 144 : 12)));\n };\n\n return (\n <div className={styles.root}>\n <div className={styles.header}>\n <button\n type=\"button\"\n className={styles.nav}\n aria-label={view === 'years' ? 'Previous 12 years' : 'Previous year'}\n onClick={() => page(-1)}\n >\n {chevron('left')}\n </button>\n <div className={styles.title} aria-live=\"polite\">\n {view === 'years' ? (\n <span>\n {yearStart} - {yearStart + 11}\n </span>\n ) : (\n <button\n type=\"button\"\n className={styles.titleButton}\n aria-label=\"Choose year\"\n onClick={() => setView('years')}\n >\n {year}\n </button>\n )}\n </div>\n <button\n type=\"button\"\n className={styles.nav}\n aria-label={view === 'years' ? 'Next 12 years' : 'Next year'}\n onClick={() => page(1)}\n >\n {chevron('right')}\n </button>\n </div>\n\n {view === 'months' ? (\n <div\n ref={gridRef}\n className={styles.cells}\n role=\"group\"\n aria-label={`Months of ${year}`}\n onKeyDown={handleKeyDown}\n >\n {monthNames.map((name, month) => {\n const first = firstOfMonth(year, month);\n const iso = toMonthISO(first);\n const isSelected = selected !== null && toMonthISO(selected) === iso;\n return (\n <button\n key={iso}\n type=\"button\"\n data-month={iso}\n tabIndex={month === cursor.getMonth() ? 0 : -1}\n aria-label={monthLong.format(first)}\n aria-pressed={isSelected}\n aria-current={toMonthISO(thisMonth) === iso ? 'date' : undefined}\n aria-disabled={isDisabled(first) || undefined}\n className={cn(\n styles.cell,\n isSelected && styles.active,\n toMonthISO(thisMonth) === iso && !isSelected && styles.currentCell,\n )}\n onClick={() => {\n if (!isDisabled(first)) onSelect(first);\n }}\n >\n {name}\n </button>\n );\n })}\n </div>\n ) : (\n <div className={styles.cells}>\n {Array.from({ length: 12 }, (_, i) => yearStart + i).map((y) => (\n <button\n key={y}\n type=\"button\"\n className={cn(styles.cell, y === year && styles.active)}\n onClick={() => {\n focusCursor.current = true;\n setCursor((current) => addMonths(current, (y - current.getFullYear()) * 12));\n setView('months');\n }}\n >\n {y}\n </button>\n ))}\n </div>\n )}\n\n <div className={styles.footer}>\n {allowClear ? (\n <button type=\"button\" className={styles.footerButton} onClick={() => onSelect(null)}>\n Clear\n </button>\n ) : (\n <span />\n )}\n <button\n type=\"button\"\n className={cn(styles.footerButton, styles.footerPrimary)}\n disabled={isDisabled(firstOfMonth(thisMonth.getFullYear(), thisMonth.getMonth()))}\n onClick={() => onSelect(parseMonth(toMonthISO(thisMonth)))}\n >\n This month\n </button>\n </div>\n </div>\n );\n}\n","import { forwardRef, useMemo, useState } from 'react';\nimport { MonthCalendar } from '../DatePicker/MonthCalendar';\nimport { PickerField, PickerShell } from '../DatePicker/PickerField';\nimport { createMonthDisabledPredicate, parseMonth, toMonthISO } from '../DatePicker/dateUtils';\nimport type { MonthPickerProps } from './MonthPicker.types';\n\n/** Month and year field with a custom chooser (value as `YYYY-MM`). */\nexport const MonthPicker = forwardRef<HTMLButtonElement, MonthPickerProps>(function MonthPicker(\n {\n label,\n helperText,\n error,\n required,\n disabled,\n id,\n value,\n defaultValue,\n onChange,\n min,\n max,\n disablePast,\n disableFuture,\n disabledMonths,\n isMonthDisabled,\n placeholder = 'Select a month',\n name,\n clearable = true,\n locale,\n ...rest\n },\n ref,\n) {\n const isControlled = value !== undefined;\n const [internal, setInternal] = useState(defaultValue ?? '');\n const current = isControlled ? value : internal;\n const selected = parseMonth(current);\n const isDisabled = createMonthDisabledPredicate({\n min,\n max,\n disablePast,\n disableFuture,\n disabledMonths,\n isMonthDisabled,\n });\n\n const formatter = useMemo(\n () => new Intl.DateTimeFormat(locale, { month: 'long', year: 'numeric' }),\n [locale],\n );\n\n const commit = (next: string) => {\n if (!isControlled) setInternal(next);\n onChange?.(next);\n };\n\n return (\n <PickerShell\n label={label}\n helperText={helperText}\n error={error}\n required={required}\n disabled={disabled}\n id={id}\n >\n <PickerField\n {...rest}\n ref={ref}\n id={id}\n required={required}\n disabled={disabled}\n error={error}\n name={name}\n hiddenValue={selected ? toMonthISO(selected) : ''}\n displayText={selected ? formatter.format(selected) : null}\n placeholder={placeholder}\n clearable={clearable}\n clearLabel=\"Clear month\"\n onClear={() => commit('')}\n panelLabel=\"Choose month\"\n >\n {({ close }) => (\n <MonthCalendar\n selected={selected}\n isDisabled={isDisabled}\n locale={locale}\n allowClear={clearable}\n onSelect={(month) => {\n commit(month ? toMonthISO(month) : '');\n close();\n }}\n />\n )}\n </PickerField>\n </PickerShell>\n );\n});\n","import { forwardRef, useCallback, useRef, useState } from 'react';\nimport { DatePicker } from '../DatePicker';\nimport { DateTimePicker } from '../DateTimePicker';\nimport { MonthPicker } from '../MonthPicker';\nimport type { InputProps } from './Input.types';\n\n/** Input types that use the package's own pickers instead of the browser's. */\nexport const PICKER_TYPES = ['date', 'datetime-local', 'month'] as const;\nexport type PickerType = (typeof PICKER_TYPES)[number];\n\nexport const isPickerType = (type: string | undefined): type is PickerType =>\n PICKER_TYPES.includes(type as PickerType);\n\n/**\n * `Input type=\"date\" | \"datetime-local\" | \"month\"`: a themed picker behind the regular Input API.\n *\n * A hidden text input holds the value and receives a real `input` event when something is picked, so\n * `onChange` handlers, form libraries and the forwarded ref behave as they do with a native input.\n */\nexport const PickerTypeInput = forwardRef<HTMLInputElement, InputProps & { type: PickerType }>(\n function PickerTypeInput(\n {\n type,\n label,\n helperText,\n error,\n required,\n disabled,\n id,\n name,\n size,\n value,\n defaultValue,\n onChange,\n min,\n max,\n placeholder,\n className,\n dateOptions = {},\n },\n ref,\n ) {\n const hiddenRef = useRef<HTMLInputElement | null>(null);\n const setRef = useCallback(\n (node: HTMLInputElement | null) => {\n hiddenRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n },\n [ref],\n );\n\n const isControlled = value !== undefined;\n const [internal, setInternal] = useState(String(defaultValue ?? ''));\n const current = isControlled ? String(value) : internal;\n\n const pick = (next: string) => {\n const input = hiddenRef.current;\n if (!input) return;\n // Use the prototype's setter so React notices the change and runs onChange.\n Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set?.call(input, next);\n input.dispatchEvent(new Event('input', { bubbles: true }));\n };\n\n const common = {\n id,\n label,\n helperText,\n error,\n required,\n disabled,\n size,\n placeholder,\n className,\n value: current,\n onChange: pick,\n min: min === undefined ? undefined : String(min),\n max: max === undefined ? undefined : String(max),\n locale: dateOptions.locale,\n clearable: dateOptions.clearable,\n disablePast: dateOptions.disablePast,\n disableFuture: dateOptions.disableFuture,\n };\n\n return (\n <>\n {type === 'month' ? (\n <MonthPicker\n {...common}\n disabledMonths={dateOptions.disabledMonths}\n isMonthDisabled={dateOptions.isMonthDisabled}\n />\n ) : type === 'datetime-local' ? (\n <DateTimePicker\n {...common}\n disabledDates={dateOptions.disabledDates}\n disabledRanges={dateOptions.disabledRanges}\n disabledDaysOfWeek={dateOptions.disabledDaysOfWeek}\n isDateDisabled={dateOptions.isDateDisabled}\n weekStartsOn={dateOptions.weekStartsOn}\n minuteStep={dateOptions.minuteStep}\n use12Hours={dateOptions.use12Hours}\n defaultTime={dateOptions.defaultTime}\n />\n ) : (\n <DatePicker\n {...common}\n disabledDates={dateOptions.disabledDates}\n disabledRanges={dateOptions.disabledRanges}\n disabledDaysOfWeek={dateOptions.disabledDaysOfWeek}\n isDateDisabled={dateOptions.isDateDisabled}\n weekStartsOn={dateOptions.weekStartsOn}\n />\n )}\n <input\n ref={setRef}\n hidden\n readOnly\n tabIndex={-1}\n type=\"text\"\n name={name}\n value={current}\n onChange={(event) => {\n if (!isControlled) setInternal(event.target.value);\n onChange?.(event);\n }}\n />\n </>\n );\n },\n);\n",".control {\n display: flex;\n align-items: center;\n gap: var(--cui-space-2);\n box-sizing: border-box;\n width: 100%;\n padding: 0 var(--cui-space-4);\n background-color: var(--cui-color-surface);\n border: var(--cui-control-border-width) solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text);\n font-family: var(--cui-font-family);\n transition:\n border-color var(--cui-transition-fast),\n box-shadow var(--cui-transition-fast);\n}\n\n.control:hover:not(.disabled):not(.invalid):not(:focus-within) {\n border-color: var(--cui-color-border-hover);\n}\n\n.control:focus-within {\n border-color: var(--cui-color-border-focus);\n outline: none;\n box-shadow: var(--cui-focus-ring);\n}\n\n.sm {\n min-height: var(--cui-control-height-sm);\n font-size: var(--cui-font-size-sm);\n}\n.md {\n min-height: var(--cui-control-height-md);\n font-size: var(--cui-font-size-sm);\n}\n.lg {\n min-height: var(--cui-control-height-lg);\n font-size: var(--cui-font-size-lg);\n}\n\n.input {\n flex: 1;\n min-width: 0;\n align-self: stretch;\n padding: 0;\n border: 0;\n outline: 0;\n background: transparent;\n color: inherit;\n font: inherit;\n}\n\n.input[type='number'] {\n appearance: textfield;\n -moz-appearance: textfield;\n}\n.input[type='number']::-webkit-inner-spin-button,\n.input[type='number']::-webkit-outer-spin-button {\n -webkit-appearance: none;\n margin: 0;\n}\n\n.input::placeholder {\n color: var(--cui-color-placeholder);\n}\n\n.affix {\n display: inline-flex;\n align-items: center;\n flex-shrink: 0;\n color: var(--cui-color-text-secondary);\n}\n\n.invalid {\n border-color: var(--cui-color-danger-border);\n}\n.control.invalid:hover:not(.disabled):not(:focus-within) {\n border-color: var(--cui-color-danger-border-hover);\n}\n.invalid:focus-within {\n border-color: var(--cui-color-danger-border-hover);\n box-shadow: var(--cui-focus-ring-danger);\n}\n\n.readOnly {\n background-color: var(--cui-color-surface-secondary);\n}\n\n.disabled {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n.disabled .input,\n.disabled .affix {\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n","import { forwardRef } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { FormField, useFormFieldControl } from '../FormField';\nimport { PickerTypeInput, isPickerType } from './PickerTypeInput';\nimport type { InputProps } from './Input.types';\nimport styles from './Input.module.css';\n\nconst InputControl = forwardRef<HTMLInputElement, Omit<InputProps, 'label' | 'helperText'>>(\n function InputControl(\n {\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n prefix,\n suffix,\n size = 'md',\n readOnly,\n className,\n ...rest\n },\n ref,\n ) {\n const control = useFormFieldControl({\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n });\n\n return (\n <div\n className={cn(\n styles.control,\n styles[size],\n control.invalid && styles.invalid,\n control.disabled && styles.disabled,\n readOnly && styles.readOnly,\n className,\n )}\n >\n {prefix ? <span className={styles.affix}>{prefix}</span> : null}\n <input\n {...rest}\n ref={ref}\n id={control.id}\n required={control.required}\n disabled={control.disabled}\n readOnly={readOnly}\n aria-invalid={control['aria-invalid']}\n aria-describedby={control['aria-describedby']}\n className={styles.input}\n />\n {suffix ? <span className={styles.affix}>{suffix}</span> : null}\n </div>\n );\n },\n);\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(function Input(\n { label, helperText, ...props },\n ref,\n) {\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n // Browsers' own date pickers can't be themed, so date, date-time and month inputs use the package's pickers.\n if (isPickerType(props.type)) {\n return (\n <PickerTypeInput\n label={label}\n helperText={helperText}\n {...props}\n type={props.type}\n ref={ref}\n />\n );\n }\n\n // Without its own label/helper/error, Input defers to an enclosing <FormField>.\n if (!label && !helperText && !props.error) {\n return <InputControl {...props} ref={ref} />;\n }\n\n return (\n <FormField\n id={props.id}\n label={label}\n helperText={helperText}\n error={props.error}\n required={props.required}\n disabled={props.disabled}\n >\n <InputControl {...props} ref={ref} />\n </FormField>\n );\n});\n",".toggle {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 1.5rem;\n height: 1.5rem;\n padding: 0;\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-sm);\n color: var(--cui-color-text-muted);\n cursor: pointer;\n}\n\n.toggle:hover:not(:disabled) {\n color: var(--cui-color-text);\n}\n\n.toggle:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 1px;\n}\n\n.toggle:disabled {\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n\n.toggle svg {\n width: 1.125rem;\n height: 1.125rem;\n}\n","import { forwardRef, useState } from 'react';\nimport { Input } from '../Input';\nimport type { PasswordInputProps } from './PasswordInput.types';\nimport styles from './PasswordInput.module.css';\n\n/** `Input` for passwords, with a button to show or hide what is typed. */\nexport const PasswordInput = forwardRef<HTMLInputElement, PasswordInputProps>(\n function PasswordInput(\n { showLabel = 'Show password', hideLabel = 'Hide password', autoComplete, disabled, ...props },\n ref,\n ) {\n const [visible, setVisible] = useState(false);\n\n return (\n <Input\n {...props}\n ref={ref}\n type={visible ? 'text' : 'password'}\n autoComplete={autoComplete ?? 'current-password'}\n disabled={disabled}\n suffix={\n <button\n type=\"button\"\n className={styles.toggle}\n aria-label={visible ? hideLabel : showLabel}\n aria-pressed={visible}\n disabled={disabled}\n onClick={() => setVisible((current) => !current)}\n >\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.8\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12z\" />\n <circle cx=\"12\" cy=\"12\" r=\"3\" />\n {visible ? null : <path d=\"M4 4l16 16\" />}\n </svg>\n </button>\n }\n />\n );\n },\n);\n",".search input[type='search']::-webkit-search-cancel-button,\n.search input[type='search']::-webkit-search-decoration {\n appearance: none;\n -webkit-appearance: none;\n}\n\n.icon {\n width: 1.125rem;\n height: 1.125rem;\n color: var(--cui-color-text-muted);\n}\n\n.clear {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 1.25rem;\n height: 1.25rem;\n padding: 0;\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-full);\n color: var(--cui-color-text-muted);\n cursor: pointer;\n}\n\n.clear:hover {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text);\n}\n\n.clear:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n}\n\n.clear svg {\n width: 0.875rem;\n height: 0.875rem;\n}\n","import { forwardRef, useCallback, useRef, useState } from 'react';\nimport { Input } from '../Input';\nimport type { SearchInputProps } from './SearchInput.types';\nimport styles from './SearchInput.module.css';\n\n/** `Input` for searching: a search icon, and a clear button once something is typed. */\nexport const SearchInput = forwardRef<HTMLInputElement, SearchInputProps>(function SearchInput(\n {\n value,\n defaultValue,\n onChange,\n onClear,\n clearLabel = 'Clear search',\n disabled,\n readOnly,\n ...props\n },\n ref,\n) {\n const innerRef = useRef<HTMLInputElement | null>(null);\n const setRef = useCallback(\n (node: HTMLInputElement | null) => {\n innerRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n },\n [ref],\n );\n\n const isControlled = value !== undefined;\n const [internal, setInternal] = useState(String(defaultValue ?? ''));\n const current = isControlled ? String(value) : internal;\n const showClear = current.length > 0 && !disabled && !readOnly;\n\n return (\n <Input\n {...props}\n ref={setRef}\n type=\"search\"\n className={styles.search}\n value={current}\n disabled={disabled}\n readOnly={readOnly}\n onChange={(event) => {\n if (!isControlled) setInternal(event.target.value);\n onChange?.(event);\n }}\n prefix={\n <svg\n className={styles.icon}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.8\"\n strokeLinecap=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <circle cx=\"11\" cy=\"11\" r=\"6.5\" />\n <path d=\"M16 16l4.5 4.5\" />\n </svg>\n }\n suffix={\n showClear ? (\n <button\n type=\"button\"\n className={styles.clear}\n aria-label={clearLabel}\n onClick={() => {\n if (!isControlled) setInternal('');\n onClear?.();\n innerRef.current?.focus();\n }}\n >\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M6 6l8 8M14 6l-8 8\" />\n </svg>\n </button>\n ) : undefined\n }\n />\n );\n});\n","import { useSyncExternalStore } from 'react';\n\nconst DARK_QUERY = '(prefers-color-scheme: dark)';\n\n/** True when the OS prefers dark. Always false on the server and where matchMedia is missing. */\nexport function useSystemPrefersDark(): boolean {\n return useSyncExternalStore(\n (onChange) => {\n if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') {\n return () => {};\n }\n const query = window.matchMedia(DARK_QUERY);\n query.addEventListener('change', onChange);\n return () => query.removeEventListener('change', onChange);\n },\n () =>\n typeof window !== 'undefined' &&\n typeof window.matchMedia === 'function' &&\n window.matchMedia(DARK_QUERY).matches,\n () => false,\n );\n}\n\nconst storageListeners = new Set<() => void>();\n\nfunction readStorage(key: string): string | null {\n try {\n return window.localStorage.getItem(key);\n } catch {\n return null;\n }\n}\n\nexport function writeStoredTheme(key: string, theme: string): void {\n try {\n window.localStorage.setItem(key, theme);\n } catch {\n // Storage can be blocked (private mode); the choice then lasts for the session only.\n }\n storageListeners.forEach((listener) => listener());\n}\n\n/** The theme saved under `key`, or null. Null on the server and on the first client render. */\nexport function useStoredTheme(key: string | undefined): string | null {\n return useSyncExternalStore(\n (onChange) => {\n storageListeners.add(onChange);\n window.addEventListener('storage', onChange);\n return () => {\n storageListeners.delete(onChange);\n window.removeEventListener('storage', onChange);\n };\n },\n () => (key ? readStorage(key) : null),\n () => null,\n );\n}\n",".root {\n background-color: var(--cui-color-background);\n color: var(--cui-color-text);\n font-family: var(--cui-font-family);\n line-height: var(--cui-line-height);\n}\n","import { createContext, useCallback, useContext, useMemo, useState } from 'react';\nimport { LicenseContext } from '../license';\nimport { cn } from '../utils/cn';\nimport { useStoredTheme, useSystemPrefersDark, writeStoredTheme } from './themeStore';\nimport type { Theme, ThemeContextValue, ThemeProviderProps } from './ThemeProvider.types';\nimport styles from './ThemeProvider.module.css';\n\nconst ThemeContext = createContext<ThemeContextValue | null>(null);\n\nexport function ThemeProvider({\n children,\n theme: controlledTheme,\n defaultTheme = 'light',\n onThemeChange,\n storageKey,\n licenseKey,\n className,\n ...rest\n}: ThemeProviderProps) {\n const [internalTheme, setInternalTheme] = useState<Theme>(defaultTheme);\n const storedTheme = useStoredTheme(controlledTheme === undefined ? storageKey : undefined);\n const systemPrefersDark = useSystemPrefersDark();\n\n const theme = controlledTheme ?? storedTheme ?? internalTheme;\n const resolvedTheme = theme === 'system' ? (systemPrefersDark ? 'dark' : 'light') : theme;\n\n const setTheme = useCallback(\n (next: Theme) => {\n if (controlledTheme === undefined) {\n setInternalTheme(next);\n if (storageKey) writeStoredTheme(storageKey, next);\n }\n onThemeChange?.(next);\n },\n [controlledTheme, onThemeChange, storageKey],\n );\n\n const value = useMemo(\n () => ({ theme, resolvedTheme, setTheme }),\n [theme, resolvedTheme, setTheme],\n );\n // A nested provider without its own key inherits the outer one.\n const inheritedKey = useContext(LicenseContext);\n\n return (\n <ThemeContext.Provider value={value}>\n <LicenseContext.Provider value={licenseKey ?? inheritedKey}>\n <div {...rest} data-theme={resolvedTheme} className={cn(styles.root, className)}>\n {children}\n </div>\n </LicenseContext.Provider>\n </ThemeContext.Provider>\n );\n}\n\n/** Read or change the active theme. Must be used inside a `ThemeProvider`. */\nexport function useTheme(): ThemeContextValue {\n const context = useContext(ThemeContext);\n if (!context) throw new Error('useTheme must be used within a <ThemeProvider>.');\n return context;\n}\n\n/** Like `useTheme`, but returns null outside a ThemeProvider instead of throwing. Used by portalled components. */\nexport function useOptionalTheme(): ThemeContextValue | null {\n return useContext(ThemeContext);\n}\n",".backdrop {\n position: fixed;\n inset: 0;\n z-index: var(--cui-z-modal);\n display: flex;\n box-sizing: border-box;\n font-family: var(--cui-font-family);\n /* Frosted-glass backdrop: light tint so the blurred page stays visible. Shared by modal and drawers. */\n background:\n radial-gradient(ellipse at 20% 15%, rgb(255 255 255 / 0.18), transparent 55%),\n radial-gradient(ellipse at 80% 85%, rgb(148 163 184 / 0.25), transparent 60%),\n rgb(100 116 139 / 0.18);\n -webkit-backdrop-filter: blur(3px) saturate(1.2);\n backdrop-filter: blur(3px) saturate(1.2);\n animation: cui-overlay-water 0.35s ease-out;\n}\n\n/* Ripples in like water: the blur deepens as the backdrop fades up. */\n@keyframes cui-overlay-water {\n from {\n opacity: 0;\n -webkit-backdrop-filter: blur(0);\n backdrop-filter: blur(0);\n }\n to {\n opacity: 1;\n }\n}\n\n.center {\n align-items: center;\n justify-content: center;\n padding: var(--cui-space-4);\n}\n\n.right {\n justify-content: flex-end;\n}\n.left {\n justify-content: flex-start;\n}\n\n.panel {\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n max-width: 100%;\n max-height: 100%;\n background-color: var(--cui-color-surface);\n color: var(--cui-color-text);\n box-shadow: var(--cui-shadow-lg);\n outline: none;\n}\n\n.center .panel {\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-xl);\n animation: cui-overlay-pop 0.18s ease-out;\n}\n\n.right .panel {\n height: 100%;\n border-inline-start: 1px solid var(--cui-color-border);\n animation: cui-overlay-slide-right 0.2s ease-out;\n}\n.left .panel {\n height: 100%;\n border-inline-end: 1px solid var(--cui-color-border);\n animation: cui-overlay-slide-left 0.2s ease-out;\n}\n\n/* Exit: reverse of the entrance, held at the end state until the component unmounts. */\n.closing {\n pointer-events: none;\n animation: cui-overlay-water-out 0.2s ease-in forwards;\n}\n.center.closing .panel {\n animation: cui-overlay-pop-out 0.2s ease-in forwards;\n}\n.right.closing .panel {\n animation: cui-overlay-slide-right-out 0.2s ease-in forwards;\n}\n.left.closing .panel {\n animation: cui-overlay-slide-left-out 0.2s ease-in forwards;\n}\n\n@keyframes cui-overlay-water-out {\n to {\n opacity: 0;\n -webkit-backdrop-filter: blur(0);\n backdrop-filter: blur(0);\n }\n}\n@keyframes cui-overlay-pop-out {\n to {\n opacity: 0;\n transform: translateY(-12px) scale(0.97);\n }\n}\n@keyframes cui-overlay-slide-right-out {\n to {\n transform: translateX(100%);\n }\n}\n@keyframes cui-overlay-slide-left-out {\n to {\n transform: translateX(-100%);\n }\n}\n\n@keyframes cui-overlay-fade {\n from {\n opacity: 0;\n }\n}\n@keyframes cui-overlay-pop {\n from {\n opacity: 0;\n transform: translateY(-12px) scale(0.97);\n }\n}\n@keyframes cui-overlay-slide-right {\n from {\n transform: translateX(100%);\n }\n}\n@keyframes cui-overlay-slide-left {\n from {\n transform: translateX(-100%);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .backdrop,\n .panel,\n .closing,\n .closing .panel {\n animation: none;\n }\n}\n","import {\n useEffect,\n useId,\n useRef,\n useState,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { cn } from '../../utils/cn';\nimport { getPortalHost } from '../../utils/portalHost';\nimport { useOptionalTheme } from '../../theme';\nimport styles from './Overlay.module.css';\n\nexport interface OverlayProps {\n open: boolean;\n onClose: () => void;\n /** Where the panel sits: centered (modal) or sliding in from a side (drawer). */\n placement: 'center' | 'right' | 'left';\n /** Width class of the panel, set by the caller's own CSS module. */\n panelClassName?: string;\n closeOnBackdrop?: boolean;\n closeOnEscape?: boolean;\n role?: 'dialog' | 'alertdialog';\n 'aria-label'?: string;\n /** Called with the ids to use for `aria-labelledby` / `aria-describedby`. */\n children: (ids: { titleId: string; descriptionId: string }) => ReactNode;\n className?: string;\n}\n\nconst FOCUSABLE =\n 'a[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n/** Matches the exit animation duration in Overlay.module.css. */\nconst EXIT_MS = 200;\n\nfunction prefersReducedMotion() {\n return (\n typeof window.matchMedia !== 'function' ||\n window.matchMedia('(prefers-reduced-motion: reduce)').matches\n );\n}\n\n// Several overlays can be open at once; the page scrolls again only when the last one closes.\nlet lockCount = 0;\nlet previousOverflow = '';\nfunction lockScroll() {\n if (lockCount === 0) {\n previousOverflow = document.body.style.overflow;\n document.body.style.overflow = 'hidden';\n }\n lockCount += 1;\n}\nfunction unlockScroll() {\n lockCount = Math.max(0, lockCount - 1);\n if (lockCount === 0) document.body.style.overflow = previousOverflow;\n}\n\n/**\n * Shared base for Modal and Drawer: a backdrop and panel rendered in <body> that keeps the surrounding\n * theme, locks page scroll, traps focus, closes on Escape or a backdrop click, and gives focus back to\n * whatever had it before. Put `data-autofocus` on an element to focus it first; otherwise the panel gets focus.\n */\nexport function Overlay({\n open,\n onClose,\n placement,\n panelClassName,\n closeOnBackdrop = true,\n closeOnEscape = true,\n role = 'dialog',\n 'aria-label': ariaLabel,\n children,\n className,\n}: OverlayProps) {\n const baseId = useId();\n const titleId = `${baseId}-title`;\n const descriptionId = `${baseId}-description`;\n const panelRef = useRef<HTMLDivElement>(null);\n const pressedOnBackdrop = useRef(false);\n const theme = useOptionalTheme();\n\n useEffect(() => {\n if (!open) return;\n const previous = document.activeElement as HTMLElement | null;\n lockScroll();\n const panel = panelRef.current;\n (panel?.querySelector<HTMLElement>('[data-autofocus]') ?? panel)?.focus({\n preventScroll: true,\n });\n return () => {\n unlockScroll();\n previous?.focus?.({ preventScroll: true });\n };\n }, [open]);\n\n // Stay mounted while the exit animation plays; skip it when motion is reduced or unsupported.\n const [mounted, setMounted] = useState(open);\n if (open && !mounted) setMounted(true);\n if (!open && mounted && prefersReducedMotion()) setMounted(false);\n\n useEffect(() => {\n if (open || !mounted) return;\n const timer = setTimeout(() => setMounted(false), EXIT_MS);\n return () => clearTimeout(timer);\n }, [open, mounted]);\n\n if (!open && !mounted) return null;\n const closing = !open;\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Escape' && closeOnEscape) {\n event.preventDefault();\n event.stopPropagation();\n onClose();\n return;\n }\n if (event.key !== 'Tab') return;\n const nodes = Array.from(panelRef.current?.querySelectorAll<HTMLElement>(FOCUSABLE) ?? []);\n const first = nodes[0];\n const last = nodes[nodes.length - 1];\n if (!first || !last) {\n event.preventDefault();\n return;\n }\n const active = document.activeElement;\n if (event.shiftKey && (active === first || active === panelRef.current)) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && active === last) {\n event.preventDefault();\n first.focus();\n }\n };\n\n // Only a press that starts on the backdrop closes it, so dragging a text selection out of the panel does not.\n const handleBackdropMouseDown = (event: MouseEvent<HTMLDivElement>) => {\n pressedOnBackdrop.current = event.target === event.currentTarget;\n };\n const handleBackdropClick = (event: MouseEvent<HTMLDivElement>) => {\n if (closeOnBackdrop && pressedOnBackdrop.current && event.target === event.currentTarget)\n onClose();\n pressedOnBackdrop.current = false;\n };\n\n return createPortal(\n <div\n className={cn(styles.backdrop, styles[placement], closing && styles.closing)}\n data-theme={theme?.resolvedTheme}\n onMouseDown={handleBackdropMouseDown}\n onClick={handleBackdropClick}\n >\n <div\n ref={panelRef}\n role={role}\n aria-modal=\"true\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabel ? undefined : titleId}\n aria-describedby={descriptionId}\n tabIndex={-1}\n className={cn(styles.panel, panelClassName, className)}\n onKeyDown={handleKeyDown}\n >\n {children({ titleId, descriptionId })}\n </div>\n </div>,\n getPortalHost(),\n );\n}\n",".header {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n gap: var(--cui-space-4);\n padding: var(--cui-space-5) var(--cui-space-6) var(--cui-space-3);\n}\n\n.heading {\n min-width: 0;\n}\n\n.title {\n margin: 0;\n font-size: var(--cui-font-size-lg);\n font-weight: var(--cui-font-weight-semibold);\n line-height: 1.35;\n}\n\n.description {\n margin: var(--cui-space-1) 0 0;\n font-size: var(--cui-font-size-sm);\n color: var(--cui-color-text-muted);\n}\n\n.close {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n width: 2.25rem;\n height: 2.25rem;\n margin-inline-start: auto;\n padding: 0;\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-full);\n color: #94a3b8;\n cursor: pointer;\n transition:\n background-color var(--cui-transition-fast),\n color var(--cui-transition-fast),\n transform var(--cui-transition-fast);\n}\n.close:hover {\n background-color: #f1f5f9;\n color: #334155;\n}\n:global([data-theme='dark']) .close:hover {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text);\n}\n.close:active {\n transform: scale(0.95);\n}\n.close:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n}\n.close svg {\n width: 1.25rem;\n height: 1.25rem;\n}\n\n.body {\n flex: 1;\n min-height: 0;\n padding: var(--cui-space-2) var(--cui-space-6) var(--cui-space-5);\n overflow-y: auto;\n font-size: var(--cui-font-size-sm);\n line-height: var(--cui-line-height);\n}\n\n.footer {\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: var(--cui-space-2);\n padding: var(--cui-space-4) var(--cui-space-6);\n border-top: 1px solid var(--cui-color-border);\n}\n","import type { ReactNode } from 'react';\nimport styles from './OverlayContent.module.css';\n\nexport interface OverlayContentProps {\n titleId: string;\n descriptionId: string;\n title?: ReactNode;\n description?: ReactNode;\n footer?: ReactNode;\n hideCloseButton?: boolean;\n closeLabel?: string;\n onClose: () => void;\n children?: ReactNode;\n}\n\n/** Header (title, description, close button), scrolling body and footer shared by Modal and Drawer. */\nexport function OverlayContent({\n titleId,\n descriptionId,\n title,\n description,\n footer,\n hideCloseButton,\n closeLabel = 'Close',\n onClose,\n children,\n}: OverlayContentProps) {\n const hasHeader = Boolean(title || description || !hideCloseButton);\n return (\n <>\n {hasHeader ? (\n <header className={styles.header}>\n <div className={styles.heading}>\n {title ? (\n <h2 id={titleId} className={styles.title}>\n {title}\n </h2>\n ) : null}\n {description ? (\n <p id={descriptionId} className={styles.description}>\n {description}\n </p>\n ) : null}\n </div>\n {hideCloseButton ? null : (\n <button\n type=\"button\"\n className={styles.close}\n aria-label={closeLabel}\n onClick={onClose}\n >\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.2\"\n strokeLinecap=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M18 6 6 18M6 6l12 12\" />\n </svg>\n </button>\n )}\n </header>\n ) : null}\n <div className={styles.body}>{children}</div>\n {footer ? <footer className={styles.footer}>{footer}</footer> : null}\n </>\n );\n}\n",".panel {\n width: 100%;\n}\n\n.sm {\n max-width: 24rem;\n}\n.md {\n max-width: 32rem;\n}\n.lg {\n max-width: 42rem;\n}\n.xl {\n max-width: 56rem;\n}\n.full {\n max-width: none;\n width: calc(100vw - 2rem);\n height: calc(100vh - 2rem);\n}\n\n/* No separator line above the footer in modals (drawers keep theirs). */\n.panel footer {\n border-top: 0;\n}\n\n/* No padding or header of its own: the content brings them. */\n.bare {\n overflow: hidden;\n}\n","import { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { Overlay } from '../Overlay/Overlay';\nimport { OverlayContent } from '../Overlay/OverlayContent';\nimport type { ModalProps } from './Modal.types';\nimport styles from './Modal.module.css';\n\n/**\n * Dialog in the middle of the screen. Traps focus, locks page scroll, closes on Escape / backdrop /\n * the close button, and returns focus to what opened it. Put `data-autofocus` on an element to focus it first.\n */\nexport function Modal({\n open,\n onClose,\n title,\n description,\n children,\n footer,\n size = 'md',\n closeOnBackdrop,\n closeOnEscape,\n hideCloseButton,\n bare = false,\n role,\n 'aria-label': ariaLabel,\n className,\n}: ModalProps) {\n const licensed = useLicensed();\n if (!licensed) return open ? <UnlicensedNotice /> : null;\n\n return (\n <Overlay\n open={open}\n onClose={onClose}\n placement=\"center\"\n panelClassName={cn(styles.panel, styles[size], bare && styles.bare)}\n className={className}\n closeOnBackdrop={closeOnBackdrop}\n closeOnEscape={closeOnEscape}\n role={role}\n aria-label={ariaLabel}\n >\n {({ titleId, descriptionId }) =>\n bare ? (\n typeof children === 'function' ? (\n children({ titleId, descriptionId, onClose })\n ) : (\n children\n )\n ) : (\n <OverlayContent\n titleId={titleId}\n descriptionId={descriptionId}\n title={title}\n description={description}\n footer={footer}\n hideCloseButton={hideCloseButton}\n onClose={onClose}\n >\n {typeof children === 'function' ? null : children}\n </OverlayContent>\n )\n }\n </Overlay>\n );\n}\n",".panel {\n width: 100%;\n}\n\n.sm {\n max-width: 20rem;\n}\n.md {\n max-width: 28rem;\n}\n.lg {\n max-width: 40rem;\n}\n","import { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { Overlay } from '../Overlay/Overlay';\nimport { OverlayContent } from '../Overlay/OverlayContent';\nimport type { DrawerProps } from './Drawer.types';\nimport styles from './Drawer.module.css';\n\n/** Panel that slides in from the side, for forms and filters. Behaves like `Modal`. */\nexport function Drawer({\n open,\n onClose,\n title,\n description,\n children,\n footer,\n placement = 'right',\n size = 'md',\n closeOnBackdrop,\n closeOnEscape,\n hideCloseButton,\n role,\n 'aria-label': ariaLabel,\n className,\n}: DrawerProps) {\n const licensed = useLicensed();\n if (!licensed) return open ? <UnlicensedNotice /> : null;\n\n return (\n <Overlay\n open={open}\n onClose={onClose}\n placement={placement}\n panelClassName={cn(styles.panel, styles[size])}\n className={className}\n closeOnBackdrop={closeOnBackdrop}\n closeOnEscape={closeOnEscape}\n role={role}\n aria-label={ariaLabel}\n >\n {({ titleId, descriptionId }) => (\n <OverlayContent\n titleId={titleId}\n descriptionId={descriptionId}\n title={title}\n description={description}\n footer={footer}\n hideCloseButton={hideCloseButton}\n onClose={onClose}\n >\n {children}\n </OverlayContent>\n )}\n </Overlay>\n );\n}\n",".confirmText {\n padding-top: var(--cui-space-2);\n}\n","import { useState } from 'react';\nimport { Button } from '../Button';\nimport { Input } from '../Input';\nimport { Modal } from '../Modal';\nimport type { ConfirmDialogProps } from './ConfirmDialog.types';\nimport styles from './ConfirmDialog.module.css';\n\n/** \"Are you sure?\" dialog with Cancel and Confirm, a danger tone and an optional type-to-confirm field. */\nexport function ConfirmDialog({\n open,\n onClose,\n onConfirm,\n title,\n message,\n confirmLabel = 'Confirm',\n cancelLabel = 'Cancel',\n tone = 'default',\n loading = false,\n requireText,\n}: ConfirmDialogProps) {\n const [typed, setTyped] = useState('');\n const confirmed = requireText === undefined || typed === requireText;\n const danger = tone === 'danger';\n\n return (\n <Modal\n open={open}\n onClose={() => {\n if (loading) return;\n setTyped('');\n onClose();\n }}\n role=\"alertdialog\"\n size=\"sm\"\n title={title}\n description={message}\n closeOnBackdrop={!loading}\n closeOnEscape={!loading}\n hideCloseButton\n footer={\n <>\n <Button\n variant=\"outline\"\n disabled={loading}\n // For destructive actions the safe choice gets the focus.\n data-autofocus={danger ? '' : undefined}\n onClick={() => {\n setTyped('');\n onClose();\n }}\n >\n {cancelLabel}\n </Button>\n <Button\n variant={danger ? 'danger' : 'primary'}\n loading={loading}\n disabled={!confirmed}\n data-autofocus={danger ? undefined : ''}\n onClick={onConfirm}\n >\n {confirmLabel}\n </Button>\n </>\n }\n >\n {requireText !== undefined ? (\n <div className={styles.confirmText}>\n <Input\n label={`Type ${requireText} to confirm`}\n value={typed}\n disabled={loading}\n autoComplete=\"off\"\n placeholder={requireText}\n onChange={(event) => setTyped(event.target.value)}\n />\n </div>\n ) : null}\n </Modal>\n );\n}\n",".control {\n position: relative;\n display: flex;\n align-items: center;\n width: 100%;\n color: var(--cui-color-text);\n}\n\n.trigger {\n appearance: none;\n display: flex;\n align-items: center;\n box-sizing: border-box;\n width: 100%;\n padding: 0 var(--cui-space-10) 0 var(--cui-space-4);\n background-color: var(--cui-color-surface);\n border: var(--cui-control-border-width) solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n color: inherit;\n font-family: var(--cui-font-family);\n font-size: inherit;\n text-align: start;\n cursor: pointer;\n transition:\n border-color var(--cui-transition-fast),\n box-shadow var(--cui-transition-fast);\n}\n\n.control:not(.open) .trigger:hover:not(:disabled):not(:focus-visible) {\n border-color: var(--cui-color-border-hover);\n}\n\n.trigger:focus-visible,\n.open .trigger {\n border-color: var(--cui-color-border-focus);\n outline: none;\n box-shadow: var(--cui-focus-ring);\n}\n\n.value {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.placeholder .value {\n color: var(--cui-color-placeholder);\n}\n\n.sm {\n font-size: var(--cui-font-size-sm);\n}\n.sm .trigger {\n height: var(--cui-control-height-sm);\n}\n.md {\n font-size: var(--cui-font-size-sm);\n}\n.md .trigger {\n height: var(--cui-control-height-md);\n}\n.lg {\n font-size: var(--cui-font-size-lg);\n}\n.lg .trigger {\n height: var(--cui-control-height-lg);\n}\n\n.chevron {\n position: absolute;\n inset-inline-end: var(--cui-space-3);\n width: 1.25rem;\n height: 1.25rem;\n color: var(--cui-color-text-muted);\n pointer-events: none;\n transition: transform 0.2s ease;\n}\n.open .chevron {\n transform: rotate(180deg);\n}\n\n.clear {\n position: absolute;\n inset-inline-end: calc(var(--cui-space-3) + 1.5rem);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 1.25rem;\n height: 1.25rem;\n padding: 0;\n border: 0;\n border-radius: var(--cui-radius-full);\n background: transparent;\n color: var(--cui-color-text-muted);\n cursor: pointer;\n}\n.clear:hover {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text);\n}\n.clear:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n}\n.clear svg {\n width: 0.875rem;\n height: 0.875rem;\n}\n\n.invalid .trigger {\n border-color: var(--cui-color-danger-border);\n}\n.invalid:not(.open) .trigger:hover:not(:disabled):not(:focus-visible) {\n border-color: var(--cui-color-danger-border-hover);\n}\n.invalid .trigger:focus-visible,\n.invalid.open .trigger {\n border-color: var(--cui-color-danger-border-hover);\n box-shadow: var(--cui-focus-ring-danger);\n}\n\n.disabled {\n color: var(--cui-color-text-disabled);\n}\n.disabled .trigger {\n background-color: var(--cui-color-surface-secondary);\n cursor: not-allowed;\n}\n.disabled .chevron {\n color: var(--cui-color-text-disabled);\n}\n\n/* Popover (rendered in a portal, inside the nearest [data-theme] element) */\n.popover {\n position: fixed;\n z-index: var(--cui-z-popover);\n box-sizing: border-box;\n overflow: hidden;\n background-color: var(--cui-color-surface);\n color: var(--cui-color-text);\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n box-shadow: var(--cui-shadow-lg);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-sm);\n line-height: var(--cui-line-height);\n animation: cui-select-in 0.15s ease-out;\n}\n\n@keyframes cui-select-in {\n from {\n opacity: 0;\n transform: translateY(-8px) scale(0.98);\n }\n}\n\n.top {\n animation-name: cui-select-in-top;\n}\n\n@keyframes cui-select-in-top {\n from {\n opacity: 0;\n transform: translateY(8px) scale(0.98);\n }\n}\n\n.searchWrap {\n padding: var(--cui-space-2);\n border-bottom: 1px solid var(--cui-color-border);\n background-color: var(--cui-color-surface-secondary);\n}\n\n.search {\n box-sizing: border-box;\n width: 100%;\n height: var(--cui-control-height-sm);\n padding: 0 var(--cui-space-3);\n background-color: var(--cui-color-surface);\n border: var(--cui-control-border-width) solid var(--cui-color-border);\n border-radius: var(--cui-radius-md);\n color: inherit;\n font: inherit;\n outline: none;\n}\n.search::placeholder {\n color: var(--cui-color-placeholder);\n}\n.search:focus {\n border-color: var(--cui-color-border-focus);\n box-shadow: var(--cui-focus-ring);\n}\n\n.list {\n margin: 0;\n padding: var(--cui-space-2);\n max-height: 15rem;\n overflow-y: auto;\n list-style: none;\n outline: none;\n}\n\n.option {\n display: flex;\n align-items: center;\n justify-content: space-between;\n margin-bottom: 2px;\n padding: var(--cui-space-2) var(--cui-space-3);\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text-secondary);\n cursor: pointer;\n user-select: none;\n}\n\n.optionLabel {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.selected {\n background-color: var(--cui-color-primary-subtle);\n color: var(--cui-color-primary);\n font-weight: var(--cui-font-weight-semibold);\n}\n\n.highlighted {\n background-color: var(--cui-color-primary);\n color: var(--cui-color-on-primary);\n}\n\n.optionDisabled {\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n\n.check {\n flex-shrink: 0;\n width: 1rem;\n height: 1rem;\n margin-inline-start: var(--cui-space-2);\n}\n\n.empty {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: var(--cui-space-4);\n color: var(--cui-color-text-muted);\n}\n\n.spinner {\n width: 1.25rem;\n height: 1.25rem;\n box-sizing: border-box;\n border: 2px solid currentColor;\n border-inline-end-color: transparent;\n border-radius: var(--cui-radius-full);\n animation: cui-select-spin 0.7s linear infinite;\n}\n\n@keyframes cui-select-spin {\n to {\n transform: rotate(360deg);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .popover,\n .chevron {\n animation: none;\n transition: none;\n }\n .spinner {\n animation-duration: 2s;\n }\n}\n","import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type KeyboardEvent,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { cn } from '../../utils/cn';\nimport { getPortalHost } from '../../utils/portalHost';\nimport { useFormFieldControl } from '../FormField';\nimport type { SelectControlProps, SelectOption } from './Select.types';\nimport styles from './Select.module.css';\n\nconst MENU_GAP = 4;\nconst MENU_ESTIMATED_HEIGHT = 280;\nconst SEARCH_DEBOUNCE_MS = 500;\n\ninterface MenuPosition {\n style: CSSProperties;\n placement: 'top' | 'bottom';\n}\n\nconst toArray = (value: string | string[] | undefined): string[] =>\n Array.isArray(value) ? value : value ? [value] : [];\n\nexport const SelectControl = forwardRef<HTMLButtonElement, SelectControlProps>(\n function SelectControl(\n {\n options,\n placeholder = 'Select an option',\n size = 'md',\n multiple = false,\n clearable = true,\n onSearch,\n loading = false,\n emptyMessage = 'No options found.',\n listClassName,\n name,\n value,\n defaultValue,\n onChange,\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n className,\n onKeyDown,\n onClick,\n ...rest\n },\n ref,\n ) {\n const control = useFormFieldControl({\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n });\n\n const baseId = useId();\n const listId = `${baseId}-list`;\n const valueId = `${baseId}-value`;\n const optionId = (index: number) => `${baseId}-option-${index}`;\n\n const containerRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n const popoverRef = useRef<HTMLDivElement>(null);\n const listRef = useRef<HTMLUListElement>(null);\n const searchRef = useRef<HTMLInputElement>(null);\n\n const [open, setOpen] = useState(false);\n const [position, setPosition] = useState<MenuPosition | null>(null);\n const [search, setSearch] = useState('');\n // The search box stays hidden until the user starts typing.\n const [showSearch, setShowSearch] = useState(false);\n const [highlighted, setHighlighted] = useState(0);\n\n const isControlled = value !== undefined;\n const [internal, setInternal] = useState<string[]>(() => toArray(defaultValue));\n const selected = isControlled ? toArray(value) : internal;\n\n const setTriggerRef = useCallback(\n (node: HTMLButtonElement | null) => {\n triggerRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n },\n [ref],\n );\n\n const filtered = useMemo(() => {\n if (onSearch || !search) return options;\n const query = search.toLowerCase();\n return options.filter((option) => option.label.toLowerCase().includes(query));\n }, [options, search, onSearch]);\n\n const commit = (next: string[]) => {\n if (!isControlled) setInternal(next);\n onChange?.(multiple ? next : (next[0] ?? ''));\n };\n\n const firstEnabled = (list: SelectOption[]) => {\n const index = list.findIndex((option) => !option.disabled);\n return index === -1 ? 0 : index;\n };\n\n const updatePosition = useCallback(() => {\n const container = containerRef.current;\n if (!container) return;\n const rect = container.getBoundingClientRect();\n const spaceBelow = window.innerHeight - rect.bottom;\n const placement =\n spaceBelow < MENU_ESTIMATED_HEIGHT && rect.top > spaceBelow ? 'top' : 'bottom';\n const style: CSSProperties = { left: rect.left, width: rect.width };\n if (placement === 'bottom') style.top = rect.bottom + MENU_GAP;\n else style.bottom = window.innerHeight - rect.top + MENU_GAP;\n setPosition({ style, placement });\n }, []);\n\n const openMenu = () => {\n if (control.disabled) return;\n updatePosition();\n setSearch('');\n setShowSearch(false);\n const firstSelected = options.findIndex((o) => selected.includes(o.value));\n setHighlighted(firstSelected === -1 ? firstEnabled(options) : firstSelected);\n setOpen(true);\n };\n\n const closeMenu = (restoreFocus = true) => {\n setOpen(false);\n if (restoreFocus) triggerRef.current?.focus({ preventScroll: true });\n };\n\n const selectOption = (option: SelectOption) => {\n if (option.disabled) return;\n if (multiple) {\n commit(\n selected.includes(option.value)\n ? selected.filter((v) => v !== option.value)\n : [...selected, option.value],\n );\n } else {\n commit([option.value]);\n closeMenu();\n }\n setSearch('');\n setShowSearch(false);\n };\n\n const moveHighlight = (direction: 1 | -1) => {\n if (!filtered.length) return;\n let next = highlighted;\n for (let step = 0; step < filtered.length; step++) {\n next = (next + direction + filtered.length) % filtered.length;\n if (!filtered[next]?.disabled) break;\n }\n setHighlighted(next);\n };\n\n // Move focus into the list on open so arrow keys work immediately.\n useEffect(() => {\n if (open) listRef.current?.focus({ preventScroll: true });\n }, [open]);\n\n useEffect(() => {\n if (showSearch) searchRef.current?.focus({ preventScroll: true });\n }, [showSearch]);\n\n // Debounced server-side search.\n const onSearchRef = useRef(onSearch);\n useEffect(() => {\n onSearchRef.current = onSearch;\n }, [onSearch]);\n useEffect(() => {\n if (!open || !onSearchRef.current) return;\n const timer = setTimeout(() => onSearchRef.current?.(search), SEARCH_DEBOUNCE_MS);\n return () => clearTimeout(timer);\n }, [search, open]);\n\n // Keep the menu attached to the trigger.\n useEffect(() => {\n if (!open) return;\n const reposition = () => requestAnimationFrame(updatePosition);\n window.addEventListener('scroll', reposition, true);\n window.addEventListener('resize', reposition);\n return () => {\n window.removeEventListener('scroll', reposition, true);\n window.removeEventListener('resize', reposition);\n };\n }, [open, updatePosition]);\n\n // Close on outside press (capture, so ancestors that stop propagation can't block it).\n useEffect(() => {\n if (!open) return;\n const handler = (event: MouseEvent) => {\n const target = event.target as Node;\n if (!containerRef.current?.contains(target) && !popoverRef.current?.contains(target)) {\n setOpen(false);\n }\n };\n document.addEventListener('mousedown', handler, true);\n return () => document.removeEventListener('mousedown', handler, true);\n }, [open]);\n\n // Scroll the highlighted option into view without scrolling the page.\n useEffect(() => {\n if (!open) return;\n const list = listRef.current;\n const el = list?.children[highlighted] as HTMLElement | undefined;\n if (!list || !el) return;\n if (el.offsetTop < list.scrollTop) list.scrollTop = el.offsetTop;\n else if (el.offsetTop + el.offsetHeight > list.scrollTop + list.clientHeight)\n list.scrollTop = el.offsetTop + el.offsetHeight - list.clientHeight;\n }, [highlighted, open]);\n\n const handleTriggerKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n if (!open && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {\n event.preventDefault();\n openMenu();\n }\n };\n\n const handleMenuKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n switch (event.key) {\n case 'Escape':\n event.preventDefault();\n event.stopPropagation();\n closeMenu();\n return;\n case 'ArrowDown':\n event.preventDefault();\n moveHighlight(1);\n return;\n case 'ArrowUp':\n event.preventDefault();\n moveHighlight(-1);\n return;\n case 'Home':\n if (showSearch) return;\n event.preventDefault();\n setHighlighted(firstEnabled(filtered));\n return;\n case 'End':\n if (showSearch) return;\n event.preventDefault();\n setHighlighted(Math.max(filtered.length - 1, 0));\n return;\n case 'Enter':\n // Never submit a surrounding form from inside the menu.\n event.preventDefault();\n event.stopPropagation();\n if (filtered[highlighted]) selectOption(filtered[highlighted]);\n return;\n case 'Tab':\n // Hand focus back to the trigger so Tab continues from there.\n setOpen(false);\n triggerRef.current?.focus({ preventScroll: true });\n return;\n case ' ':\n if (showSearch) return;\n event.preventDefault();\n if (filtered[highlighted]) selectOption(filtered[highlighted]);\n return;\n default:\n break;\n }\n // The first printable key reveals the search box and seeds it.\n const isPrintable =\n event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey;\n if (!showSearch && isPrintable) {\n event.preventDefault();\n setSearch(event.key);\n setHighlighted(0);\n setShowSearch(true);\n }\n };\n\n const selectedOptions = options.filter((option) => selected.includes(option.value));\n const hasValue = selected.length > 0;\n const displayText =\n selected.length > 1\n ? `${selected.length} selected`\n : (selectedOptions[0]?.label ?? placeholder);\n const showClear = clearable && hasValue && !control.disabled;\n\n // Render in <body> so no ancestor (transform, overflow, filter) can detach or clip the\n // fixed-position menu; re-apply the active theme on the menu itself.\n const themeName = open\n ? containerRef.current?.closest('[data-theme]')?.getAttribute('data-theme')\n : undefined;\n const activeDescendant = open && filtered[highlighted] ? optionId(highlighted) : undefined;\n const labelledBy = control.labelId ? `${control.labelId} ${valueId}` : undefined;\n\n return (\n <div\n ref={containerRef}\n className={cn(\n styles.control,\n styles[size],\n control.invalid && styles.invalid,\n control.disabled && styles.disabled,\n open && styles.open,\n className,\n )}\n >\n <button\n {...rest}\n ref={setTriggerRef}\n id={control.id}\n type=\"button\"\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-controls={open ? listId : undefined}\n aria-labelledby={labelledBy}\n aria-invalid={control['aria-invalid']}\n aria-describedby={control['aria-describedby']}\n aria-required={control.required || undefined}\n disabled={control.disabled}\n className={cn(styles.trigger, !selectedOptions.length && styles.placeholder)}\n onClick={(event) => {\n onClick?.(event);\n if (event.defaultPrevented) return;\n if (open) closeMenu(false);\n else openMenu();\n }}\n onKeyDown={handleTriggerKeyDown}\n >\n <span id={valueId} className={styles.value}>\n {displayText}\n </span>\n </button>\n\n {showClear ? (\n <button\n type=\"button\"\n className={styles.clear}\n aria-label=\"Clear selection\"\n onClick={() => {\n commit([]);\n triggerRef.current?.focus({ preventScroll: true });\n }}\n >\n <svg viewBox=\"0 0 20 20\" aria-hidden=\"true\" focusable=\"false\">\n <path\n d=\"M6 6l8 8M14 6l-8 8\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n />\n </svg>\n </button>\n ) : null}\n\n <svg className={styles.chevron} viewBox=\"0 0 20 20\" aria-hidden=\"true\" focusable=\"false\">\n <path\n d=\"M5 7.5l5 5 5-5\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n\n {name\n ? selected.length > 0\n ? selected.map((v) => <input key={v} type=\"hidden\" name={name} value={v} />)\n : !multiple && <input type=\"hidden\" name={name} value=\"\" />\n : null}\n\n {open && position\n ? createPortal(\n <div\n ref={popoverRef}\n className={cn(styles.popover, styles[position.placement])}\n style={position.style}\n data-theme={themeName ?? undefined}\n onKeyDown={handleMenuKeyDown}\n >\n {showSearch ? (\n <div className={styles.searchWrap}>\n <input\n ref={searchRef}\n type=\"text\"\n className={styles.search}\n placeholder=\"Search options...\"\n aria-label=\"Search options\"\n aria-controls={listId}\n aria-activedescendant={activeDescendant}\n autoComplete=\"off\"\n value={search}\n onChange={(event) => {\n const next = event.target.value;\n setSearch(next);\n setHighlighted(0);\n if (next === '') {\n setShowSearch(false);\n listRef.current?.focus({ preventScroll: true });\n }\n }}\n />\n </div>\n ) : null}\n <ul\n ref={listRef}\n id={listId}\n role=\"listbox\"\n tabIndex={-1}\n aria-labelledby={labelledBy}\n aria-multiselectable={multiple || undefined}\n aria-activedescendant={showSearch ? undefined : activeDescendant}\n className={cn(styles.list, listClassName)}\n >\n {filtered.length > 0 ? (\n filtered.map((option, index) => {\n const isSelected = selected.includes(option.value);\n return (\n <li\n key={option.value}\n id={optionId(index)}\n role=\"option\"\n aria-selected={isSelected}\n aria-disabled={option.disabled || undefined}\n className={cn(\n styles.option,\n isSelected && styles.selected,\n index === highlighted && styles.highlighted,\n option.disabled && styles.optionDisabled,\n )}\n onMouseEnter={() => !option.disabled && setHighlighted(index)}\n onClick={() => selectOption(option)}\n >\n <span className={styles.optionLabel}>{option.label}</span>\n {isSelected ? (\n <svg\n className={styles.check}\n viewBox=\"0 0 20 20\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path\n d=\"M4.5 10.5l3.5 3.5 7.5-8\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n ) : null}\n </li>\n );\n })\n ) : (\n <li className={styles.empty} role=\"presentation\">\n {loading ? (\n <span className={styles.spinner} role=\"status\" aria-label=\"Loading\" />\n ) : (\n emptyMessage\n )}\n </li>\n )}\n </ul>\n </div>,\n getPortalHost(),\n )\n : null}\n </div>\n );\n },\n);\n","import { forwardRef } from 'react';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { FormField } from '../FormField';\nimport { SelectControl } from './SelectControl';\nimport type { SelectControlProps, SelectProps } from './Select.types';\n\n/**\n * Select with a popover list, type-to-search, optional multi-select, a clear\n * button and server-side search. Controlled (`value`) or uncontrolled\n * (`defaultValue`). The ref points at the trigger button.\n */\nexport const Select = forwardRef<HTMLButtonElement, SelectProps>(function Select(\n { label, helperText, ...props },\n ref,\n) {\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n // The single/multiple union is resolved inside SelectControl via `multiple`.\n const controlProps = props as SelectControlProps;\n\n // Without its own label/helper/error, Select defers to an enclosing <FormField>.\n if (!label && !helperText && !props.error) {\n return <SelectControl {...controlProps} ref={ref} />;\n }\n\n return (\n <FormField\n id={props.id}\n label={label}\n helperText={helperText}\n error={props.error}\n required={props.required}\n disabled={props.disabled}\n >\n <SelectControl {...controlProps} ref={ref} />\n </FormField>\n );\n});\n","export type PageItem = number | 'ellipsis-start' | 'ellipsis-end';\n\n/**\n * Which page buttons to show: the first and last `boundaryCount` pages, `siblingCount` pages either side of\n * the current one, and an ellipsis wherever pages are skipped. A gap of a single page is shown as that page\n * instead of an ellipsis, so the list never hides just one number.\n */\nexport function getPageItems(\n page: number,\n pageCount: number,\n siblingCount = 1,\n boundaryCount = 1,\n): PageItem[] {\n const total = Math.max(0, Math.floor(pageCount));\n if (total === 0) return [];\n const current = Math.min(Math.max(1, Math.floor(page)), total);\n\n const range = (from: number, to: number) =>\n Array.from({ length: Math.max(0, to - from + 1) }, (_, i) => from + i);\n\n const startPages = range(1, Math.min(boundaryCount, total));\n const endPages = range(Math.max(total - boundaryCount + 1, boundaryCount + 1), total);\n\n const siblingsStart = Math.max(\n Math.min(current - siblingCount, total - boundaryCount - siblingCount * 2 - 1),\n boundaryCount + 2,\n );\n const siblingsEnd = Math.min(\n Math.max(current + siblingCount, boundaryCount + siblingCount * 2 + 2),\n endPages.length > 0 ? (endPages[0] as number) - 2 : total - 1,\n );\n\n const items: PageItem[] = [...startPages];\n\n if (siblingsStart > boundaryCount + 2) items.push('ellipsis-start');\n else if (boundaryCount + 1 < total - boundaryCount) items.push(boundaryCount + 1);\n\n items.push(...range(siblingsStart, siblingsEnd));\n\n if (siblingsEnd < total - boundaryCount - 1) items.push('ellipsis-end');\n else if (total - boundaryCount > boundaryCount) items.push(total - boundaryCount);\n\n items.push(...endPages);\n\n // Drop duplicates the boundary arithmetic can produce on short lists, keeping order.\n return items.filter((item, index) => typeof item !== 'number' || items.indexOf(item) === index);\n}\n",".root {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: var(--cui-space-3) var(--cui-space-4);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-sm);\n color: var(--cui-color-text-secondary);\n}\n\n.info {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--cui-space-4);\n}\n\n.summary {\n color: var(--cui-color-text-muted);\n}\n\n.pageSize {\n display: flex;\n align-items: center;\n gap: var(--cui-space-2);\n}\n.pageSize > :last-child {\n width: 5rem;\n}\n\n.pages {\n display: flex;\n align-items: center;\n gap: var(--cui-space-1);\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n min-width: var(--cui-control-height-sm);\n height: var(--cui-control-height-sm);\n padding: 0 var(--cui-space-2);\n background-color: var(--cui-color-surface);\n border: var(--cui-control-border-width) solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text-secondary);\n font: inherit;\n font-weight: var(--cui-font-weight-medium);\n cursor: pointer;\n transition:\n background-color var(--cui-transition-fast),\n border-color var(--cui-transition-fast),\n box-shadow var(--cui-transition-fast),\n color var(--cui-transition-fast);\n}\n.button svg {\n width: 1rem;\n height: 1rem;\n}\n.button:hover:not(:disabled):not(.current) {\n border-color: var(--cui-color-border-hover);\n}\n.button:focus-visible {\n border-color: var(--cui-color-border-focus);\n outline: none;\n box-shadow: var(--cui-focus-ring);\n}\n.button:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n\n.current {\n background-color: var(--cui-color-primary-subtle);\n border-color: color-mix(in srgb, var(--cui-color-primary) 40%, transparent);\n color: var(--cui-color-primary);\n font-weight: var(--cui-font-weight-semibold);\n cursor: default;\n}\n\n.ellipsis {\n min-width: 1.5rem;\n text-align: center;\n color: var(--cui-color-text-muted);\n}\n\n/* ---------- layout=\"split\" ---------- */\n.split {\n display: grid;\n grid-template-columns: 1fr auto 1fr;\n align-items: center;\n}\n.splitLeft {\n display: flex;\n justify-content: flex-start;\n}\n.splitCenter {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.splitRight {\n display: flex;\n justify-content: flex-end;\n}\n.split .summary,\n.split .pageSize {\n font-weight: var(--cui-font-weight-medium);\n color: var(--cui-color-text-muted);\n}\n\n.joined {\n gap: 0;\n}\n.joined li + li {\n margin-inline-start: calc(var(--cui-control-border-width) * -1);\n}\n.joined .button {\n position: relative;\n border-radius: 0;\n}\n.joined li:first-child .button {\n border-start-start-radius: var(--cui-radius-lg);\n border-end-start-radius: var(--cui-radius-lg);\n}\n.joined li:last-child .button {\n border-start-end-radius: var(--cui-radius-lg);\n border-end-end-radius: var(--cui-radius-lg);\n}\n/* Raise the hovered / focused / current button so its full border shows over its neighbours. */\n.joined .button:hover:not(:disabled),\n.joined .button:focus-visible {\n z-index: 1;\n}\n.joined .current {\n z-index: 2;\n}\n\n.pageOf {\n display: none;\n margin-inline: var(--cui-space-3);\n font-weight: var(--cui-font-weight-semibold);\n color: var(--cui-color-text-secondary);\n white-space: nowrap;\n}\n.pageOf strong {\n color: var(--cui-color-primary);\n}\n\n@media (max-width: 767px) {\n .split {\n grid-template-columns: 1fr auto;\n grid-template-areas:\n 'right left'\n 'center center';\n gap: var(--cui-space-3);\n }\n .splitLeft {\n grid-area: left;\n }\n .splitRight {\n grid-area: right;\n justify-content: flex-start;\n }\n .splitCenter {\n grid-area: center;\n justify-content: space-between;\n }\n .splitCenter .pages {\n display: contents;\n }\n /* On small screens: first, previous, \"Page x of y\", next, last. Numbers are hidden. */\n .split .pageNumber,\n .split .ellipsis {\n display: none;\n }\n .first {\n order: 1;\n }\n .prev {\n order: 2;\n }\n .pageOf {\n display: inline;\n order: 3;\n }\n .next {\n order: 4;\n }\n .last {\n order: 5;\n }\n}\n","import { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { Select } from '../Select';\nimport { getPageItems } from './paginationUtils';\nimport type { PaginationProps } from './Pagination.types';\nimport styles from './Pagination.module.css';\n\nconst icon = (path: string) => (\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d={path} />\n </svg>\n);\n\n/**\n * Page navigation: previous / next, numbered pages with ellipses, optional first / last, a\n * \"Showing 1-10 of 120\" summary and a rows-per-page select. Pages start at 1.\n */\nexport function Pagination({\n page,\n pageCount,\n onPageChange,\n siblingCount = 1,\n boundaryCount = 1,\n showFirstLast: showFirstLastProp = false,\n layout = 'default',\n pageSize,\n totalItems,\n pageSizeOptions,\n onPageSizeChange,\n disabled = false,\n 'aria-label': ariaLabel = 'Pagination',\n className,\n ...rest\n}: PaginationProps) {\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n const last = Math.max(1, pageCount);\n const current = Math.min(Math.max(1, page), last);\n const items = getPageItems(current, last, siblingCount, boundaryCount);\n const go = (next: number) => {\n if (!disabled && next >= 1 && next <= last && next !== current) onPageChange(next);\n };\n\n const split = layout === 'split';\n const showFirstLast = showFirstLastProp || split;\n const showSummary = pageSize !== undefined && totalItems !== undefined;\n const from = totalItems === 0 || !pageSize ? 0 : (current - 1) * pageSize + 1;\n const to = pageSize && totalItems !== undefined ? Math.min(current * pageSize, totalItems) : 0;\n const showPageSize = pageSizeOptions && pageSizeOptions.length > 0 && onPageSizeChange;\n\n const summaryNode = showSummary ? (\n <span className={styles.summary}>\n {split\n ? `Showing ${from}-${to} of ${totalItems} Rows`\n : `Showing ${from}-${to} of ${totalItems}`}\n </span>\n ) : null;\n\n const pageSizeNode = showPageSize ? (\n <div className={styles.pageSize}>\n <span aria-hidden=\"true\">{split ? 'Row Per Page' : 'Rows per page'}</span>\n <Select\n aria-label=\"Rows per page\"\n size=\"sm\"\n clearable={false}\n disabled={disabled}\n value={String(pageSize ?? pageSizeOptions[0])}\n options={pageSizeOptions.map((option) => ({\n label: String(option),\n value: String(option),\n }))}\n onChange={(value) => onPageSizeChange(Number(value))}\n />\n </div>\n ) : null;\n\n const pagesNode = (\n <>\n <ul className={cn(styles.pages, split && styles.joined)}>\n {showFirstLast ? (\n <li className={styles.first}>\n <button\n type=\"button\"\n className={styles.button}\n aria-label=\"First page\"\n disabled={disabled || current === 1}\n onClick={() => go(1)}\n >\n {icon('M11 5l-5 5 5 5M15 5v10')}\n </button>\n </li>\n ) : null}\n <li className={styles.prev}>\n <button\n type=\"button\"\n className={styles.button}\n aria-label=\"Previous page\"\n disabled={disabled || current === 1}\n onClick={() => go(current - 1)}\n >\n {icon('M12 5l-5 5 5 5')}\n </button>\n </li>\n {items.map((item) =>\n typeof item === 'number' ? (\n <li key={item} className={styles.pageNumber}>\n <button\n type=\"button\"\n className={cn(styles.button, item === current && styles.current)}\n aria-label={`Page ${item}`}\n aria-current={item === current ? 'page' : undefined}\n disabled={disabled}\n onClick={() => go(item)}\n >\n {item}\n </button>\n </li>\n ) : (\n <li key={item} className={cn(styles.ellipsis, styles.pageNumber)} aria-hidden=\"true\">\n …\n </li>\n ),\n )}\n <li className={styles.next}>\n <button\n type=\"button\"\n className={styles.button}\n aria-label=\"Next page\"\n disabled={disabled || current === last}\n onClick={() => go(current + 1)}\n >\n {icon('M8 5l5 5-5 5')}\n </button>\n </li>\n {showFirstLast ? (\n <li className={styles.last}>\n <button\n type=\"button\"\n className={styles.button}\n aria-label=\"Last page\"\n disabled={disabled || current === last}\n onClick={() => go(last)}\n >\n {icon('M9 5l5 5-5 5M5 5v10')}\n </button>\n </li>\n ) : null}\n </ul>\n {split ? (\n <span className={styles.pageOf} aria-hidden=\"true\">\n Page <strong>{current}</strong> of {last}\n </span>\n ) : null}\n </>\n );\n\n if (split) {\n return (\n <nav {...rest} aria-label={ariaLabel} className={cn(styles.root, styles.split, className)}>\n <div className={styles.splitLeft}>{pageSizeNode}</div>\n <div className={styles.splitCenter}>{pagesNode}</div>\n <div className={styles.splitRight}>{summaryNode}</div>\n </nav>\n );\n }\n\n return (\n <nav {...rest} aria-label={ariaLabel} className={cn(styles.root, className)}>\n <div className={styles.info}>\n {summaryNode}\n {pageSizeNode}\n </div>\n {pagesNode}\n </nav>\n );\n}\n",".container {\n position: relative;\n width: 100%;\n overflow: auto;\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-xl);\n background-color: var(--cui-color-surface);\n}\n.container:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: -2px;\n}\n\n.table {\n --table-px: var(--cui-space-6);\n width: 100%;\n border-collapse: separate;\n border-spacing: 0;\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-sm);\n line-height: var(--cui-line-height);\n color: var(--cui-color-text);\n}\n\n.caption {\n padding: var(--cui-space-3) var(--cui-space-4);\n text-align: start;\n caption-side: top;\n font-size: var(--cui-font-size-sm);\n color: var(--cui-color-text-muted);\n}\n\n/* Header: same values as the school app's DataTableHeader (Tailwind gray-50 / gray-500 / gray-100, shadow-sm). */\n.head {\n --head-bg: #f9fafb;\n --head-fg: #6b7280;\n --head-fg-hover: #374151;\n --head-border: #f3f4f6;\n --head-icon: #9ca3af;\n background-color: var(--head-bg);\n box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);\n white-space: nowrap;\n}\n:global([data-theme='dark']) .head {\n --head-bg: #374151;\n --head-fg: #9ca3af;\n --head-fg-hover: #e5e7eb;\n --head-border: #374151;\n --head-icon: #9ca3af;\n}\n\n/* Sorted column: label in the primary colour. The whole header cell is the click target. */\n.th.sorted {\n color: var(--cui-color-primary);\n}\n.th.sortable {\n padding: 0;\n}\n.sortable .sortButton {\n width: 100%;\n padding: 0.75rem var(--table-px);\n}\n.center .sortButton {\n justify-content: center;\n}\n.end .sortButton {\n justify-content: flex-end;\n}\n\n.sticky .head th {\n position: sticky;\n top: 0;\n z-index: 20;\n background-color: var(--head-bg);\n}\n\n.th {\n padding: 0.75rem var(--table-px);\n border-bottom: 1px solid var(--head-border);\n font-size: 0.75rem;\n line-height: 1rem;\n font-family: var(--cui-font-family);\n font-weight: 400; /* the app maps Tailwind's font-medium to 400 with Poppins */\n letter-spacing: 0.05em;\n text-transform: uppercase;\n color: var(--head-fg);\n white-space: nowrap;\n}\n\n.td {\n padding: var(--cui-space-3) var(--table-px);\n border-bottom: 1px solid var(--cui-color-border);\n vertical-align: middle;\n}\n\n.start {\n text-align: start;\n}\n.center {\n text-align: center;\n}\n.end {\n text-align: end;\n}\n\n.table tbody tr:last-child .td {\n border-bottom: 0;\n}\n\n.foot .td {\n background-color: var(--cui-color-surface-secondary);\n border-top: 1px solid var(--cui-color-border);\n font-weight: var(--cui-font-weight-medium);\n}\n\n.table tbody .row:hover {\n background-color: var(--cui-color-surface-secondary);\n}\n\n.row.selected,\n.table tbody .row.selected:hover {\n background-color: var(--cui-color-primary-subtle);\n}\n\n.clickable {\n cursor: pointer;\n}\n\n.sortButton {\n display: inline-flex;\n align-items: center;\n gap: 0.375rem;\n padding: 0;\n background: transparent;\n border: 0;\n color: inherit;\n font: inherit;\n letter-spacing: inherit;\n text-transform: inherit;\n cursor: pointer;\n}\n.sortButton:hover {\n color: var(--head-fg-hover);\n}\n.th.sorted .sortButton:hover {\n color: var(--cui-color-primary);\n}\n.sortButton:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 2px;\n border-radius: var(--cui-radius-sm);\n}\n\n.sortIcon {\n width: 0.875rem;\n height: 0.875rem;\n color: var(--head-icon);\n}\n.sortActive {\n width: 0.875rem;\n height: 0.875rem;\n flex-shrink: 0;\n color: var(--cui-color-primary);\n}\n\n/* Idle sort arrows only appear when the header is hovered or focused. */\n.sortIdle {\n opacity: 0;\n transition: opacity var(--cui-transition-fast);\n}\n.sortButton:hover .sortIdle,\n.sortButton:focus-visible .sortIdle {\n opacity: 1;\n}\n\n.flush {\n border: 0;\n border-radius: 0;\n background-color: transparent;\n}\n","import { forwardRef, type HTMLAttributes } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport type {\n TableCaptionProps,\n TableCellProps,\n TableHeaderCellProps,\n TableProps,\n TableRowProps,\n} from './Table.types';\nimport styles from './Table.module.css';\n\n/**\n * Styled semantic table. Compose it with `TableHead`, `TableBody`, `TableRow`, `TableHeaderCell`\n * and `TableCell`. For sorting, filtering, paging and selection use `DataTable`.\n */\nexport const Table = forwardRef<HTMLTableElement, TableProps>(function Table(\n { stickyHeader = false, bordered = true, containerClassName, scrollLabel, className, ...rest },\n ref,\n) {\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n return (\n <div\n className={cn(styles.container, !bordered && styles.flush, containerClassName)}\n // A scroll area must be reachable by keyboard so wide tables can be scrolled.\n tabIndex={0}\n role=\"region\"\n aria-label={scrollLabel}\n >\n <table\n {...rest}\n ref={ref}\n className={cn(styles.table, stickyHeader && styles.sticky, className)}\n />\n </div>\n );\n});\n\nexport const TableHead = forwardRef<\n HTMLTableSectionElement,\n HTMLAttributes<HTMLTableSectionElement>\n>(function TableHead({ className, ...rest }, ref) {\n return <thead {...rest} ref={ref} className={cn(styles.head, className)} />;\n});\n\nexport const TableBody = forwardRef<\n HTMLTableSectionElement,\n HTMLAttributes<HTMLTableSectionElement>\n>(function TableBody({ className, ...rest }, ref) {\n return <tbody {...rest} ref={ref} className={className} />;\n});\n\nexport const TableFoot = forwardRef<\n HTMLTableSectionElement,\n HTMLAttributes<HTMLTableSectionElement>\n>(function TableFoot({ className, ...rest }, ref) {\n return <tfoot {...rest} ref={ref} className={cn(styles.foot, className)} />;\n});\n\nexport const TableRow = forwardRef<HTMLTableRowElement, TableRowProps>(function TableRow(\n { selected = false, className, ...rest },\n ref,\n) {\n return (\n <tr\n {...rest}\n ref={ref}\n data-selected={selected || undefined}\n className={cn(\n styles.row,\n selected && styles.selected,\n rest.onClick && styles.clickable,\n className,\n )}\n />\n );\n});\n\nexport const TableHeaderCell = forwardRef<HTMLTableCellElement, TableHeaderCellProps>(\n function TableHeaderCell(\n {\n align = 'start',\n sortable = false,\n sortDirection = null,\n onSort,\n className,\n children,\n scope = 'col',\n ...rest\n },\n ref,\n ) {\n const ariaSort = !sortable\n ? undefined\n : sortDirection === 'asc'\n ? 'ascending'\n : sortDirection === 'desc'\n ? 'descending'\n : 'none';\n return (\n <th\n {...rest}\n ref={ref}\n scope={scope}\n aria-sort={ariaSort}\n className={cn(\n styles.th,\n styles[align],\n sortable && styles.sortable,\n sortable && sortDirection && styles.sorted,\n className,\n )}\n >\n {sortable ? (\n <button type=\"button\" className={styles.sortButton} onClick={onSort}>\n {children}\n <svg\n className={cn(styles.sortIcon, sortDirection ? styles.sortActive : styles.sortIdle)}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={sortDirection ? 3 : 2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n {sortDirection === 'asc' ? (\n <>\n <path d=\"m5 12 7-7 7 7\" />\n <path d=\"M12 19V5\" />\n </>\n ) : sortDirection === 'desc' ? (\n <>\n <path d=\"M12 5v14\" />\n <path d=\"m19 12-7 7-7-7\" />\n </>\n ) : (\n <>\n <path d=\"m21 16-4 4-4-4\" />\n <path d=\"M17 20V4\" />\n <path d=\"m3 8 4-4 4 4\" />\n <path d=\"M7 4v16\" />\n </>\n )}\n </svg>\n </button>\n ) : (\n children\n )}\n </th>\n );\n },\n);\n\nexport const TableCell = forwardRef<HTMLTableCellElement, TableCellProps>(function TableCell(\n { align = 'start', className, ...rest },\n ref,\n) {\n return <td {...rest} ref={ref} className={cn(styles.td, styles[align], className)} />;\n});\n\nexport const TableCaption = forwardRef<HTMLTableCaptionElement, TableCaptionProps>(\n function TableCaption({ className, ...rest }, ref) {\n return <caption {...rest} ref={ref} className={cn(styles.caption, className)} />;\n },\n);\n",".root {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: var(--cui-space-3);\n padding: var(--cui-space-4) 1.25rem;\n border-bottom: 1px solid var(--cui-color-border);\n font-family: var(--cui-font-family);\n}\n\n.main {\n display: flex;\n flex: 1;\n align-items: center;\n gap: var(--cui-space-3);\n min-width: 0;\n}\n\n/* Same circular button as the close button of Modal and Drawer. */\n.back {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n width: 2.25rem;\n height: 2.25rem;\n padding: 0;\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-full);\n color: #94a3b8;\n cursor: pointer;\n transition:\n background-color var(--cui-transition-fast),\n color var(--cui-transition-fast),\n transform var(--cui-transition-fast);\n}\n.back:hover {\n background-color: #f1f5f9;\n color: #334155;\n}\n:global([data-theme='dark']) .back:hover {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text);\n}\n.back:active {\n transform: scale(0.95);\n}\n.back:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n}\n.back svg {\n width: 1.25rem;\n height: 1.25rem;\n}\n\n.heading {\n min-width: 0;\n}\n\n.title {\n margin: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: 1.25rem;\n font-weight: var(--cui-font-weight-bold);\n line-height: 1.25;\n letter-spacing: -0.01em;\n color: var(--cui-color-text);\n}\n\n.subtitle {\n margin: 2px 0 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: var(--cui-font-size-sm);\n color: var(--cui-color-text-muted);\n}\n\n.actions {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--cui-space-2);\n}\n","import type { HTMLAttributes, ReactNode } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport styles from './PageHeader.module.css';\n\nexport interface PageHeaderProps extends Omit<HTMLAttributes<HTMLElement>, 'title'> {\n title: ReactNode;\n subtitle?: ReactNode;\n /** Shows the circular back button; it calls `onBack`. */\n onBack?: () => void;\n backLabel?: string;\n /** Buttons and other controls on the right. */\n actions?: ReactNode;\n}\n\n/** Page title bar like the school app's: optional circular back button, title, subtitle and actions. */\nexport function PageHeader({\n title,\n subtitle,\n onBack,\n backLabel = 'Go back',\n actions,\n className,\n ...rest\n}: PageHeaderProps) {\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n return (\n <header {...rest} className={cn(styles.root, className)}>\n <div className={styles.main}>\n {onBack ? (\n <button type=\"button\" className={styles.back} aria-label={backLabel} onClick={onBack}>\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"m12 19-7-7 7-7M19 12H5\" />\n </svg>\n </button>\n ) : null}\n <div className={styles.heading}>\n <h1 className={styles.title}>{title}</h1>\n {subtitle ? <p className={styles.subtitle}>{subtitle}</p> : null}\n </div>\n </div>\n {actions ? <div className={styles.actions}>{actions}</div> : null}\n </header>\n );\n}\n",".pill {\n display: inline-flex;\n align-items: center;\n gap: 0.375rem;\n padding: 0.125rem 0.625rem;\n border: 1px solid transparent;\n border-radius: var(--cui-radius-full);\n font-size: var(--cui-font-size-xs);\n font-weight: var(--cui-font-weight-medium);\n line-height: 1.25rem;\n white-space: nowrap;\n}\n\n.label {\n text-transform: capitalize;\n}\n\n.dot {\n width: 0.375rem;\n height: 0.375rem;\n border-radius: var(--cui-radius-full);\n background-color: currentColor;\n}\n\n.pulse {\n animation: cui-status-pulse 2s ease-in-out infinite;\n}\n\n@keyframes cui-status-pulse {\n 50% {\n opacity: 0.4;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .pulse {\n animation: none;\n }\n}\n\n.success {\n color: var(--cui-color-success);\n background-color: color-mix(in srgb, var(--cui-color-success) 10%, transparent);\n border-color: color-mix(in srgb, var(--cui-color-success) 25%, transparent);\n}\n.info {\n color: var(--cui-color-info);\n background-color: color-mix(in srgb, var(--cui-color-info) 10%, transparent);\n border-color: color-mix(in srgb, var(--cui-color-info) 25%, transparent);\n}\n.danger {\n color: var(--cui-color-danger);\n background-color: color-mix(in srgb, var(--cui-color-danger) 10%, transparent);\n border-color: color-mix(in srgb, var(--cui-color-danger) 25%, transparent);\n}\n.warning {\n color: var(--cui-color-warning);\n background-color: color-mix(in srgb, var(--cui-color-warning) 12%, transparent);\n border-color: color-mix(in srgb, var(--cui-color-warning) 30%, transparent);\n}\n.neutral {\n color: var(--cui-color-text-secondary);\n background-color: var(--cui-color-surface-muted, transparent);\n border-color: var(--cui-color-border);\n}\n\n.empty {\n color: var(--cui-color-text-muted);\n}\n","import type { HTMLAttributes } from 'react';\nimport { cn } from '../../utils/cn';\nimport styles from './StatusPill.module.css';\n\nexport type StatusPillTone = 'success' | 'info' | 'danger' | 'warning' | 'neutral';\n\nexport interface StatusPillProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'children'> {\n /** Status text, e.g. \"Active\". Shown capitalized; empty shows an em dash. */\n status?: string | null;\n /** Override the colour that is otherwise chosen from the status text. */\n tone?: StatusPillTone;\n}\n\nconst TONES: Record<string, StatusPillTone> = {\n active: 'success',\n completed: 'info',\n expired: 'danger',\n cancelled: 'danger',\n canceled: 'danger',\n pending: 'warning',\n};\n\n/** Small status badge with a dot, like the status column of the school app's tables. */\nexport function StatusPill({ status, tone, className, ...rest }: StatusPillProps) {\n if (!status) return <span className={styles.empty}>—</span>;\n const key = status.trim().toLowerCase();\n const resolved = tone ?? TONES[key] ?? 'neutral';\n const pulse = resolved === 'success' || key === 'completed';\n return (\n <span className={cn(styles.pill, styles[resolved], className)} {...rest}>\n <span className={cn(styles.dot, pulse && styles.pulse)} aria-hidden=\"true\" />\n <span className={styles.label}>{status}</span>\n </span>\n );\n}\n",".root {\n display: flex;\n flex-direction: column;\n gap: var(--cui-space-1);\n}\n\n.label {\n position: relative;\n display: inline-flex;\n align-items: flex-start;\n gap: var(--cui-space-3);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-sm);\n line-height: var(--cui-line-height);\n color: var(--cui-color-text);\n cursor: pointer;\n}\n\n.disabled {\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n\n/* The real input sits on top of the box so it stays focusable and clickable. */\n.input {\n position: absolute;\n top: 0;\n left: 0;\n width: 1.25rem;\n height: 1.25rem;\n margin: 0;\n opacity: 0;\n cursor: inherit;\n}\n\n.box {\n position: relative;\n display: inline-flex;\n flex-shrink: 0;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n width: 1.25rem;\n height: 1.25rem;\n background-color: var(--cui-color-surface);\n border: var(--cui-control-border-width) solid var(--cui-color-border-hover);\n border-radius: var(--cui-radius-sm);\n color: var(--cui-color-on-primary);\n transition:\n background-color var(--cui-transition-fast),\n border-color var(--cui-transition-fast),\n box-shadow var(--cui-transition-fast);\n}\n\n.check,\n.dash {\n position: absolute;\n inset: 0;\n margin: auto;\n width: 0.875rem;\n height: 0.875rem;\n opacity: 0;\n transform: scale(0.5);\n transition:\n opacity var(--cui-transition-fast),\n transform var(--cui-transition-fast);\n}\n\n.label:hover .input:not(:disabled) + .box {\n border-color: var(--cui-color-primary);\n}\n\n.input:checked + .box,\n.input:indeterminate + .box {\n background-color: var(--cui-color-primary);\n border-color: var(--cui-color-primary);\n}\n\n.input:checked + .box .check,\n.input:indeterminate + .box .dash {\n opacity: 1;\n transform: scale(1);\n}\n\n.input:indeterminate + .box .check {\n opacity: 0;\n}\n\n.input:focus-visible + .box {\n box-shadow: var(--cui-focus-ring);\n}\n\n.input.invalid + .box {\n border-color: var(--cui-color-danger-border);\n}\n.input.invalid:checked + .box {\n background-color: var(--cui-color-danger);\n border-color: var(--cui-color-danger);\n color: var(--cui-color-on-danger);\n}\n.input.invalid:focus-visible + .box {\n box-shadow: var(--cui-focus-ring-danger);\n}\n\n.input:disabled + .box {\n background-color: var(--cui-color-surface-secondary);\n border-color: var(--cui-color-border);\n color: var(--cui-color-text-disabled);\n}\n.input:disabled:checked + .box,\n.input:disabled:indeterminate + .box {\n background-color: var(--cui-color-text-disabled);\n border-color: var(--cui-color-text-disabled);\n color: var(--cui-color-surface);\n}\n\n.text {\n padding-top: 1px;\n}\n\n.required {\n margin-inline-start: var(--cui-space-1);\n color: var(--cui-color-danger);\n}\n\n.message {\n margin: 0;\n padding-inline-start: calc(1.25rem + var(--cui-space-3));\n font-size: var(--cui-font-size-xs);\n}\n.helper {\n color: var(--cui-color-text-muted);\n}\n.error {\n color: var(--cui-color-danger);\n}\n\n@media (prefers-reduced-motion: reduce) {\n .box,\n .check,\n .dash {\n transition: none;\n }\n}\n","import { forwardRef, useCallback, useEffect, useRef } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { useFormFieldControl } from '../FormField';\nimport type { CheckboxProps } from './Checkbox.types';\nimport styles from './Checkbox.module.css';\n\n/** Native checkbox with a themed box, optional label, helper text and error. */\nexport const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(function Checkbox(\n {\n label,\n helperText,\n error,\n indeterminate = false,\n id,\n required,\n disabled,\n 'aria-describedby': ariaDescribedBy,\n className,\n ...rest\n },\n ref,\n) {\n const innerRef = useRef<HTMLInputElement | null>(null);\n const setRef = useCallback(\n (node: HTMLInputElement | null) => {\n innerRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n },\n [ref],\n );\n\n useEffect(() => {\n if (innerRef.current) innerRef.current.indeterminate = indeterminate;\n }, [indeterminate]);\n\n const control = useFormFieldControl({\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n });\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n const messageId = `${control.id}-message`;\n const hasMessage = Boolean(error || helperText);\n const describedBy =\n [control['aria-describedby'], hasMessage ? messageId : undefined].filter(Boolean).join(' ') ||\n undefined;\n\n return (\n <div className={cn(styles.root, className)}>\n <label className={cn(styles.label, control.disabled && styles.disabled)}>\n <input\n {...rest}\n ref={setRef}\n id={control.id}\n type=\"checkbox\"\n required={control.required}\n disabled={control.disabled}\n aria-invalid={control['aria-invalid']}\n aria-describedby={describedBy}\n className={cn(styles.input, control.invalid && styles.invalid)}\n />\n <span className={styles.box} aria-hidden=\"true\">\n <svg className={styles.check} viewBox=\"0 0 20 20\" focusable=\"false\">\n <path\n d=\"M4.5 10.5l3.5 3.5 7.5-8\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n <svg className={styles.dash} viewBox=\"0 0 20 20\" focusable=\"false\">\n <path\n d=\"M5 10h10\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n />\n </svg>\n </span>\n {label ? (\n <span className={styles.text}>\n {label}\n {control.required ? (\n <span className={styles.required} aria-hidden=\"true\">\n *\n </span>\n ) : null}\n </span>\n ) : null}\n </label>\n {hasMessage ? (\n <p\n id={messageId}\n className={cn(styles.message, error ? styles.error : styles.helper)}\n role={error ? 'alert' : undefined}\n >\n {error || helperText}\n </p>\n ) : null}\n </div>\n );\n});\n",".root {\n display: inline-block;\n}\n\n.trigger {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n padding: var(--cui-space-2);\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text-secondary);\n cursor: pointer;\n transition:\n background-color var(--cui-transition-fast),\n color var(--cui-transition-fast);\n}\n.trigger svg {\n width: 1.25rem;\n height: 1.25rem;\n}\n.trigger:hover:not(:disabled) {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-primary);\n}\n.trigger:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 1px;\n}\n.trigger:disabled {\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n.open,\n.open:hover:not(:disabled) {\n background-color: var(--cui-color-primary-subtle);\n color: var(--cui-color-primary);\n}\n.custom {\n padding: var(--cui-space-1) var(--cui-space-3);\n font: inherit;\n font-size: var(--cui-font-size-sm);\n}\n\n.menu {\n position: fixed;\n z-index: var(--cui-z-popover);\n box-sizing: border-box;\n min-width: 12rem;\n width: max-content;\n max-width: 20rem;\n overflow: hidden;\n background-color: var(--cui-color-surface);\n color: var(--cui-color-text);\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-md);\n box-shadow: var(--cui-shadow-lg);\n font-family: var(--cui-font-family);\n animation: cui-dropdown-in 0.12s ease-out;\n}\n\n@keyframes cui-dropdown-in {\n from {\n opacity: 0;\n transform: translateY(-4px) scale(0.97);\n }\n}\n\n.item {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--cui-space-3);\n box-sizing: border-box;\n width: 100%;\n padding: var(--cui-space-3) var(--cui-space-4);\n background: transparent;\n border: 0;\n border-bottom: 1px solid var(--cui-color-border);\n color: var(--cui-color-text-secondary);\n font: inherit;\n font-size: var(--cui-font-size-sm);\n font-weight: var(--cui-font-weight-semibold);\n text-align: start;\n cursor: pointer;\n}\n.item:last-child {\n border-bottom: 0;\n}\n.item:hover:not([aria-disabled='true']),\n.item:focus-visible {\n background-color: var(--cui-color-surface-secondary);\n outline: none;\n}\n\n.danger {\n color: var(--cui-color-danger);\n}\n.danger:hover:not([aria-disabled='true']),\n.danger:focus-visible {\n background-color: color-mix(in srgb, var(--cui-color-danger) 10%, transparent);\n}\n\n.item[aria-disabled='true'] {\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n\n.label {\n white-space: nowrap;\n}\n\n.icon {\n display: inline-flex;\n flex-shrink: 0;\n width: 1.125rem;\n height: 1.125rem;\n}\n.icon > svg {\n width: 100%;\n height: 100%;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .menu {\n animation: none;\n }\n}\n","import {\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n type CSSProperties,\n type KeyboardEvent,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { cn } from '../../utils/cn';\nimport { getPortalHost } from '../../utils/portalHost';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport type { DropdownMenuProps } from './DropdownMenu.types';\nimport styles from './DropdownMenu.module.css';\n\nconst MENU_GAP = 4;\nconst MENU_WIDTH = 192;\nconst MENU_ESTIMATED_HEIGHT = 200;\nconst ITEM = '[role=\"menuitem\"]:not([aria-disabled=\"true\"])';\n\n/**\n * A \"more actions\" button that opens a menu of actions. Arrow keys, Home and End move between items,\n * Enter or Space chooses one, Escape closes and returns focus to the button. The menu is rendered in\n * <body>, so tables and scroll areas can't clip it, and it keeps the surrounding theme.\n */\nexport function DropdownMenu({\n items,\n position = 'right',\n label = 'More actions',\n children,\n onOpenChange,\n disabled = false,\n className,\n}: DropdownMenuProps) {\n const licensed = useLicensed();\n const menuId = `${useId()}-menu`;\n const triggerRef = useRef<HTMLButtonElement>(null);\n const menuRef = useRef<HTMLDivElement>(null);\n const [open, setOpen] = useState(false);\n const [style, setStyle] = useState<CSSProperties | null>(null);\n const [themeName, setThemeName] = useState<string | undefined>();\n const [focusTick, setFocusTick] = useState(0);\n // Latest callback, so an inline `onOpenChange` doesn't re-subscribe the listeners on every render.\n const onOpenChangeRef = useRef(onOpenChange);\n useEffect(() => {\n onOpenChangeRef.current = onOpenChange;\n });\n\n const computePosition = useCallback(() => {\n const trigger = triggerRef.current;\n if (!trigger) return;\n const rect = trigger.getBoundingClientRect();\n const spaceBelow = window.innerHeight - rect.bottom;\n const above = spaceBelow < MENU_ESTIMATED_HEIGHT && rect.top > spaceBelow;\n const next: CSSProperties = above\n ? { bottom: window.innerHeight - rect.top + MENU_GAP }\n : { top: rect.bottom + MENU_GAP };\n // `right`: the menu grows toward the right from the button's left edge, unless it would leave the screen.\n const fitsRight = rect.left + MENU_WIDTH <= window.innerWidth - 8;\n if (position === 'right' && fitsRight) next.left = rect.left;\n else next.right = Math.max(8, window.innerWidth - rect.right);\n // Keep the same object when nothing moved, so scroll/resize events don't trigger needless re-renders.\n setStyle((prev) =>\n prev &&\n prev.top === next.top &&\n prev.bottom === next.bottom &&\n prev.left === next.left &&\n prev.right === next.right\n ? prev\n : next,\n );\n }, [position]);\n\n const setOpenState = (next: boolean) => {\n setOpen(next);\n onOpenChangeRef.current?.(next);\n };\n\n const openMenu = () => {\n if (disabled) return;\n computePosition();\n setThemeName(\n triggerRef.current?.closest('[data-theme]')?.getAttribute('data-theme') ?? undefined,\n );\n setOpenState(true);\n };\n\n // `close` is used by render code, so it must not touch refs; focus returns through an effect.\n const close = (restoreFocus = true) => {\n setOpenState(false);\n if (restoreFocus) setFocusTick((tick) => tick + 1);\n };\n useEffect(() => {\n if (focusTick > 0) triggerRef.current?.focus({ preventScroll: true });\n }, [focusTick]);\n\n useEffect(() => {\n if (open) menuRef.current?.querySelector<HTMLElement>(ITEM)?.focus({ preventScroll: true });\n }, [open]);\n\n useEffect(() => {\n if (!open) return;\n const reposition = () => requestAnimationFrame(computePosition);\n const onPointerDown = (event: MouseEvent) => {\n const target = event.target as Node;\n if (!triggerRef.current?.contains(target) && !menuRef.current?.contains(target)) {\n setOpen(false);\n onOpenChangeRef.current?.(false);\n }\n };\n window.addEventListener('scroll', reposition, true);\n window.addEventListener('resize', reposition);\n document.addEventListener('mousedown', onPointerDown, true);\n return () => {\n window.removeEventListener('scroll', reposition, true);\n window.removeEventListener('resize', reposition);\n document.removeEventListener('mousedown', onPointerDown, true);\n };\n }, [open, computePosition]);\n\n if (!licensed) return <UnlicensedNotice />;\n\n const focusItem = (which: 'first' | 'last' | 1 | -1) => {\n const nodes = Array.from(menuRef.current?.querySelectorAll<HTMLElement>(ITEM) ?? []);\n if (nodes.length === 0) return;\n const current = nodes.indexOf(document.activeElement as HTMLElement);\n const next =\n which === 'first'\n ? 0\n : which === 'last'\n ? nodes.length - 1\n : (current + which + nodes.length) % nodes.length;\n nodes[next]?.focus({ preventScroll: true });\n };\n\n const handleMenuKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const actions: Record<string, () => void> = {\n ArrowDown: () => focusItem(1),\n ArrowUp: () => focusItem(-1),\n Home: () => focusItem('first'),\n End: () => focusItem('last'),\n Escape: () => close(),\n Tab: () => close(),\n };\n const action = actions[event.key];\n if (!action) return;\n if (event.key !== 'Tab') {\n event.preventDefault();\n event.stopPropagation();\n }\n action();\n };\n\n return (\n <span className={cn(styles.root, className)}>\n <button\n ref={triggerRef}\n type=\"button\"\n className={cn(styles.trigger, open && styles.open, children !== undefined && styles.custom)}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n aria-controls={open ? menuId : undefined}\n aria-label={label}\n title={label}\n disabled={disabled}\n onClick={() => (open ? close(false) : openMenu())}\n onKeyDown={(event) => {\n if (!open && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {\n event.preventDefault();\n openMenu();\n }\n }}\n >\n {children ?? (\n <svg viewBox=\"0 0 20 20\" fill=\"currentColor\" aria-hidden=\"true\" focusable=\"false\">\n <circle cx=\"10\" cy=\"4\" r=\"1.6\" />\n <circle cx=\"10\" cy=\"10\" r=\"1.6\" />\n <circle cx=\"10\" cy=\"16\" r=\"1.6\" />\n </svg>\n )}\n </button>\n\n {open && style\n ? createPortal(\n <div\n ref={menuRef}\n id={menuId}\n role=\"menu\"\n aria-label={label}\n className={styles.menu}\n style={style}\n data-theme={themeName}\n onKeyDown={handleMenuKeyDown}\n >\n {items.map((item, index) => (\n <button\n key={`${item.label}-${index}`}\n type=\"button\"\n role=\"menuitem\"\n tabIndex={-1}\n aria-disabled={item.disabled || undefined}\n className={cn(styles.item, item.variant === 'danger' && styles.danger)}\n onClick={() => {\n if (item.disabled) return;\n try {\n item.onClick();\n } finally {\n close();\n }\n }}\n >\n <span className={styles.label}>{item.label}</span>\n {item.icon ? (\n <span className={styles.icon} aria-hidden=\"true\">\n {item.icon}\n </span>\n ) : null}\n </button>\n ))}\n </div>,\n getPortalHost(),\n )\n : null}\n </span>\n );\n}\n",".root {\n display: block;\n background-color: var(--cui-color-surface-secondary);\n animation: cui-skeleton-pulse 1.5s ease-in-out infinite;\n}\n\n.rect {\n width: 100%;\n height: 1rem;\n border-radius: var(--cui-radius-md);\n}\n\n.text {\n width: 100%;\n height: 0.875rem;\n border-radius: var(--cui-radius-full);\n}\n\n.circle {\n width: 2.5rem;\n height: 2.5rem;\n border-radius: var(--cui-radius-full);\n}\n\n@keyframes cui-skeleton-pulse {\n 50% {\n opacity: 0.5;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .root {\n animation: none;\n }\n}\n","import { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport type { SkeletonProps } from './Skeleton.types';\nimport styles from './Skeleton.module.css';\n\n/** Pulsing placeholder shown while content loads. Hidden from assistive tech. */\nexport function Skeleton({\n variant = 'rect',\n width,\n height,\n className,\n style,\n ...rest\n}: SkeletonProps) {\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n // Dimensions are caller-supplied values, so they have to be inline styles.\n const size = { width, height: height ?? (variant === 'circle' ? width : undefined) };\n\n return (\n <span\n aria-hidden=\"true\"\n {...rest}\n className={cn(styles.root, styles[variant], className)}\n style={{ ...size, ...style }}\n />\n );\n}\n","/* The school app's look: fills its container, no outer border, pagination bar pinned to the bottom. */\n.root {\n display: flex;\n flex-direction: column;\n flex: 1;\n min-width: 0;\n min-height: 0;\n overflow: hidden;\n background-color: var(--cui-color-surface);\n}\n\n.toolbar {\n --cui-toolbar-pad: var(--cui-space-3);\n min-width: 0;\n padding: var(--cui-toolbar-pad);\n border-bottom: 1px solid var(--cui-color-border);\n background-color: var(--cui-color-surface);\n}\n@media (min-width: 768px) {\n .toolbar {\n --cui-toolbar-pad: var(--cui-space-4);\n padding: var(--cui-toolbar-pad);\n }\n}\n\n.tableArea {\n display: flex;\n flex-direction: column;\n flex: 1;\n min-height: 0;\n min-width: 0;\n overflow: hidden;\n}\n\n.scroll {\n flex: 1;\n min-height: 0;\n}\n\n.selectCell.selectCell {\n width: 1%;\n padding-inline: var(--cui-space-4);\n text-align: center;\n white-space: nowrap;\n}\n.selectCell > * {\n display: inline-flex;\n vertical-align: middle;\n}\n\n.actionsColumn {\n width: 1%;\n white-space: nowrap;\n}\n\n.actions {\n display: flex;\n justify-content: center;\n}\n\n.actionButton {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n padding: var(--cui-space-2);\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text-muted);\n cursor: pointer;\n transition:\n background-color var(--cui-transition-fast),\n color var(--cui-transition-fast),\n transform var(--cui-transition-fast);\n}\n.actionButton:hover {\n background-color: var(--cui-color-primary-subtle);\n color: var(--cui-color-primary);\n transform: scale(1.05);\n}\n.actionButton:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 1px;\n}\n.actionButton svg {\n width: 1.125rem;\n height: 1.125rem;\n}\n.actionDanger {\n color: var(--cui-color-danger);\n}\n.actionDanger:hover {\n background-color: color-mix(in srgb, var(--cui-color-danger) 10%, transparent);\n color: var(--cui-color-danger);\n}\n.actionText {\n font-size: var(--cui-font-size-xs);\n font-weight: var(--cui-font-weight-bold);\n}\n\n.cellText {\n font-size: 0.8125rem;\n font-weight: var(--cui-font-weight-medium);\n color: var(--cui-color-text-secondary);\n}\n\n.stateBox {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: var(--cui-space-3);\n}\n\n.empty {\n padding-block: var(--cui-space-12);\n text-align: center;\n color: var(--cui-color-text-muted);\n font-size: var(--cui-font-size-sm);\n}\n.emptyIcon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 3rem;\n height: 3rem;\n border-radius: var(--cui-radius-full);\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text-disabled);\n}\n.emptyIcon svg {\n width: 1.5rem;\n height: 1.5rem;\n}\n\n.errorCell {\n padding-block: var(--cui-space-12);\n text-align: center;\n background-color: color-mix(in srgb, var(--cui-color-danger) 6%, transparent);\n color: var(--cui-color-danger);\n}\n.errorIcon {\n display: inline-flex;\n}\n.errorIcon svg {\n width: 1.5rem;\n height: 1.5rem;\n}\n.errorText {\n font-weight: var(--cui-font-weight-medium);\n}\n\n.footer {\n min-width: 0;\n position: sticky;\n bottom: 0;\n z-index: 1;\n flex-shrink: 0;\n padding: var(--cui-space-3);\n background-color: var(--cui-color-surface);\n border-top: 1px solid var(--cui-color-border);\n box-shadow: 0 -2px 4px rgb(0 0 0 / 0.03);\n}\n@media (min-width: 768px) {\n .footer {\n padding: var(--cui-space-4);\n }\n}\n\n.srOnly {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n}\n\n/* Selection banner (shown while rows are selected). */\n.selectionBar {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--cui-space-2);\n padding: var(--cui-space-2) var(--cui-space-4);\n border-bottom: 1px solid color-mix(in srgb, var(--cui-color-primary) 20%, transparent);\n background-color: color-mix(in srgb, var(--cui-color-primary) 7%, transparent);\n font-size: var(--cui-font-size-sm);\n}\n\n.selectionCount {\n font-weight: var(--cui-font-weight-semibold);\n color: var(--cui-color-primary);\n}\n\n.selectionDivider {\n width: 1px;\n height: 1rem;\n margin: 0 var(--cui-space-1);\n background-color: var(--cui-color-border);\n}\n\n.bulkButton.bulkButton {\n height: 2rem;\n gap: var(--cui-space-1);\n padding: 0 var(--cui-space-3);\n font-size: var(--cui-font-size-xs);\n}\n.bulkButton svg {\n width: 0.875rem;\n height: 0.875rem;\n}\n.bulkDanger.bulkDanger {\n color: var(--cui-color-danger);\n}\n.bulkDanger.bulkDanger:hover:not(:disabled) {\n background-color: color-mix(in srgb, var(--cui-color-danger) 8%, transparent);\n border-color: color-mix(in srgb, var(--cui-color-danger) 40%, transparent);\n}\n\n.selectionClear {\n margin-inline-start: auto;\n padding: var(--cui-space-1) var(--cui-space-2);\n background: transparent;\n border: 0;\n color: var(--cui-color-primary);\n font: inherit;\n font-size: var(--cui-font-size-sm);\n text-decoration: underline;\n text-underline-offset: 3px;\n cursor: pointer;\n}\n.selectionClear:hover {\n opacity: 0.8;\n}\n.selectionClear:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 2px;\n}\n","import type { ReactNode } from 'react';\nimport { cn } from '../../utils/cn';\nimport { Button } from '../Button';\nimport styles from './DataTable.module.css';\n\nexport interface SelectionBarAction {\n label: string;\n icon?: ReactNode;\n onClick: () => void;\n disabled?: boolean;\n /** `danger` styles the button red. */\n variant?: 'default' | 'danger';\n}\n\nexport interface SelectionBarProps {\n /** Number of selected rows. Nothing is rendered for 0. */\n count: number;\n actions?: SelectionBarAction[];\n onClear: () => void;\n className?: string;\n}\n\n/** Banner shown above a table while rows are selected: \"N selected\", bulk actions and \"Clear selection\". */\nexport function SelectionBar({ count, actions = [], onClear, className }: SelectionBarProps) {\n if (count <= 0) return null;\n return (\n <div role=\"region\" aria-label=\"Selection\" className={cn(styles.selectionBar, className)}>\n <span className={styles.selectionCount} aria-live=\"polite\">\n {count} selected\n </span>\n {actions.length > 0 ? <span className={styles.selectionDivider} aria-hidden=\"true\" /> : null}\n {actions.map((action) => (\n <Button\n key={action.label}\n variant=\"outline\"\n size=\"sm\"\n className={cn(styles.bulkButton, action.variant === 'danger' && styles.bulkDanger)}\n disabled={action.disabled}\n onClick={action.onClick}\n >\n {action.icon}\n {action.label}\n </Button>\n ))}\n <button type=\"button\" className={styles.selectionClear} onClick={onClear}>\n Clear selection\n </button>\n </div>\n );\n}\n","import { DatePicker } from '../DatePicker';\nimport { Input } from '../Input';\nimport { Select } from '../Select';\nimport type { TableFilterField } from './TableFilters.types';\n\ninterface FilterValueControlProps {\n field: TableFilterField;\n value: string;\n onChange: (value: string) => void;\n /** Visible label above the control. Without it, `ariaLabel` names the control. */\n label?: string;\n ariaLabel?: string;\n size?: 'sm' | 'md';\n placeholder?: string;\n}\n\n/** The right input for a filter field: text, select or date. */\nexport function FilterValueControl({\n field,\n value,\n onChange,\n label,\n ariaLabel,\n size = 'md',\n placeholder,\n}: FilterValueControlProps) {\n const name = label ? { label } : { 'aria-label': ariaLabel ?? field.label };\n if (field.type === 'select') {\n return (\n <Select\n {...name}\n size={size}\n placeholder={placeholder ?? field.placeholder ?? `Any ${field.label.toLowerCase()}`}\n options={field.options ?? []}\n value={value}\n onChange={onChange}\n />\n );\n }\n if (field.type === 'date') {\n return (\n <DatePicker\n {...name}\n size={size}\n placeholder={placeholder ?? field.placeholder}\n value={value}\n onChange={onChange}\n />\n );\n }\n return (\n <Input\n {...name}\n size={size}\n placeholder={placeholder ?? field.placeholder}\n value={value}\n onChange={(event) => onChange(event.target.value)}\n />\n );\n}\n",".root {\n display: flex;\n flex-direction: column;\n gap: var(--cui-space-3);\n font-family: var(--cui-font-family);\n}\n\n.bar {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: var(--cui-space-3);\n}\n\n.barEnd {\n display: flex;\n align-items: center;\n gap: var(--cui-space-3);\n margin-inline-start: auto;\n}\n\n.search {\n flex: 1;\n min-width: 10rem;\n max-width: 16rem;\n}\n\n.actions {\n display: flex;\n align-items: center;\n gap: var(--cui-space-2);\n}\n\n.filtersIcon {\n width: 1rem;\n height: 1rem;\n}\n\n.panelFooter {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--cui-space-2);\n width: 100%;\n}\n\n.count {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 1rem;\n height: 1rem;\n padding: 0 var(--cui-space-1);\n border-radius: var(--cui-radius-full);\n background-color: var(--cui-color-primary);\n color: var(--cui-color-on-primary);\n font-size: 0.625rem;\n font-weight: var(--cui-font-weight-semibold);\n}\n\n/* Applied-filters bar: same tinted look as the DataTable selection bar. */\n.chips {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--cui-space-2);\n /* Inside a DataTable toolbar this bleeds to the card edges, exactly like the selection bar. */\n margin: 0 calc(-1 * var(--cui-toolbar-pad, 0px)) calc(-1 * var(--cui-toolbar-pad, 0px));\n padding: var(--cui-space-2) var(--cui-space-4);\n list-style: none;\n border-top: 1px solid color-mix(in srgb, var(--cui-color-primary) 20%, transparent);\n background-color: color-mix(in srgb, var(--cui-color-primary) 7%, transparent);\n font-size: var(--cui-font-size-sm);\n}\n\n.chip {\n display: inline-flex;\n align-items: center;\n gap: 0.375rem;\n max-width: 100%;\n height: 2rem;\n box-sizing: border-box;\n padding: 0 var(--cui-space-1) 0 var(--cui-space-3);\n background-color: var(--cui-color-surface);\n border: 1px solid color-mix(in srgb, var(--cui-color-primary) 30%, var(--cui-color-border));\n border-radius: var(--cui-radius-full);\n font-size: var(--cui-font-size-xs);\n animation: cui-chip-in 0.18s ease-out;\n}\n\n@keyframes cui-chip-in {\n from {\n opacity: 0;\n transform: scale(0.85);\n }\n}\n\n.chipLabel {\n color: var(--cui-color-text-muted);\n}\n\n.chipValue {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-weight: var(--cui-font-weight-semibold);\n color: var(--cui-color-primary);\n}\n\n.chipRemove {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 1.25rem;\n height: 1.25rem;\n padding: 0;\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-full);\n color: var(--cui-color-text-muted);\n cursor: pointer;\n transition:\n background-color var(--cui-transition-fast),\n color var(--cui-transition-fast);\n}\n.chipRemove:hover {\n background-color: color-mix(in srgb, var(--cui-color-danger) 12%, transparent);\n color: var(--cui-color-danger);\n}\n.chipRemove:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n}\n.chipRemove svg {\n width: 0.75rem;\n height: 0.75rem;\n}\n\n/* Last item, pushed to the end like \"Clear selection\". */\n.chips > li:last-child {\n margin-inline-start: auto;\n}\n.clearAll {\n display: inline-flex;\n align-items: center;\n gap: var(--cui-space-1);\n padding: var(--cui-space-1) var(--cui-space-2);\n background: transparent;\n border: 0;\n color: var(--cui-color-primary);\n font: inherit;\n font-size: var(--cui-font-size-sm);\n text-decoration: underline;\n text-underline-offset: 3px;\n cursor: pointer;\n}\n.clearAll svg {\n display: none;\n}\n.clearAll:hover {\n opacity: 0.8;\n}\n.clearAll:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 2px;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .chip {\n animation: none;\n }\n .chipRemove {\n transition: none;\n }\n}\n\n/* Dynamic filter rows */\n.dynamic {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: var(--cui-space-4);\n}\n\n.noFilters {\n margin: 0;\n color: var(--cui-color-text-muted);\n font-size: var(--cui-font-size-sm);\n}\n\n.rows {\n display: flex;\n flex-direction: column;\n gap: var(--cui-space-3);\n width: 100%;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.row {\n display: grid;\n grid-template-columns: 1fr auto;\n grid-template-areas:\n 'field remove'\n 'value value';\n gap: var(--cui-space-2);\n padding: var(--cui-space-3);\n background-color: var(--cui-color-surface-secondary);\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n}\n\n.rowField {\n grid-area: field;\n min-width: 0;\n}\n.rowValue {\n grid-area: value;\n min-width: 0;\n}\n\n.rowRemove {\n grid-area: remove;\n align-self: center;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 2rem;\n height: 2rem;\n padding: 0;\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-md);\n color: var(--cui-color-text-muted);\n cursor: pointer;\n}\n.rowRemove:hover {\n background-color: color-mix(in srgb, var(--cui-color-danger) 10%, transparent);\n color: var(--cui-color-danger);\n}\n.rowRemove:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n}\n.rowRemove svg {\n width: 1rem;\n height: 1rem;\n}\n","import { Button } from '../Button';\nimport { Select } from '../Select';\nimport { FilterValueControl } from './FilterValueControl';\nimport type { TableFilterField } from './TableFilters.types';\nimport styles from './TableFilters.module.css';\n\nexport interface FilterRow {\n id: number;\n /** `key` of the chosen field, or '' while none is chosen. */\n key: string;\n value: string;\n}\n\nlet rowCounter = 0;\n/** A fresh, unique row id (only used as a React key). */\nexport const nextRowId = () => (rowCounter += 1);\n\n/** Turns the applied filter values into editable rows, one per active filter. */\nexport function rowsFromValues(values: Record<string, string>): FilterRow[] {\n return Object.entries(values).map(([key, value]) => ({ id: nextRowId(), key, value }));\n}\n\n/** The values the rows stand for: rows without a field or without a value filter nothing. */\nexport function valuesFromRows(rows: FilterRow[]): Record<string, string> {\n const values: Record<string, string> = {};\n for (const row of rows) {\n if (row.key && row.value.trim() !== '') values[row.key] = row.value;\n }\n return values;\n}\n\ninterface DynamicFilterRowsProps {\n fields: TableFilterField[];\n rows: FilterRow[];\n onChange: (rows: FilterRow[]) => void;\n}\n\n/**\n * The editable part of the filter panel: each row is a field choice plus a value, rows can be added and\n * removed, and a field can only be used once.\n */\nexport function DynamicFilterRows({ fields, rows, onChange }: DynamicFilterRowsProps) {\n const used = new Set(rows.map((row) => row.key).filter(Boolean));\n const available = fields.filter((field) => !used.has(field.key));\n\n const update = (id: number, patch: Partial<FilterRow>) =>\n onChange(rows.map((row) => (row.id === id ? { ...row, ...patch } : row)));\n\n const add = () => {\n const field = available[0];\n if (!field) return;\n onChange([...rows, { id: nextRowId(), key: field.key, value: '' }]);\n };\n\n return (\n <div className={styles.dynamic}>\n {rows.length === 0 ? (\n <p className={styles.noFilters}>No filters yet. Add one to narrow down the table.</p>\n ) : (\n <ul className={styles.rows}>\n {rows.map((row, index) => {\n const field = fields.find((f) => f.key === row.key);\n const choices = fields.filter((f) => f.key === row.key || !used.has(f.key));\n return (\n <li key={row.id} className={styles.row} aria-label={`Filter ${index + 1}`}>\n <div className={styles.rowField}>\n <Select\n aria-label={`Field for filter ${index + 1}`}\n size=\"sm\"\n clearable={false}\n value={row.key}\n options={choices.map((f) => ({ label: f.label, value: f.key }))}\n onChange={(next) => update(row.id, { key: next, value: '' })}\n />\n </div>\n <div className={styles.rowValue}>\n {field ? (\n <FilterValueControl\n key={field.key}\n field={field}\n value={row.value}\n size=\"sm\"\n ariaLabel={`Value for ${field.label}`}\n onChange={(next) => update(row.id, { value: next })}\n />\n ) : null}\n </div>\n <button\n type=\"button\"\n className={styles.rowRemove}\n aria-label={`Delete ${field?.label ?? 'empty'} filter`}\n onClick={() => onChange(rows.filter((r) => r.id !== row.id))}\n >\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M6 6l8 8M14 6l-8 8\" />\n </svg>\n </button>\n </li>\n );\n })}\n </ul>\n )}\n <Button variant=\"outline\" size=\"sm\" disabled={available.length === 0} onClick={add}>\n + Add filter\n </Button>\n </div>\n );\n}\n","import type { TableFilterField, TableFilterValues } from './TableFilters.types';\n\n/** Only the filters that actually filter something. */\nexport function activeFilters(values: TableFilterValues | undefined): TableFilterValues {\n return Object.fromEntries(\n Object.entries(values ?? {}).filter(([, value]) => value.trim() !== ''),\n );\n}\n\n/** Text to show for a filter's value: the option label for selects, the value itself otherwise. */\nexport function filterValueLabel(field: TableFilterField, value: string): string {\n if (field.type === 'select')\n return field.options?.find((option) => option.value === value)?.label ?? value;\n return value;\n}\n","import { useEffect, useRef, useState } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { Button } from '../Button';\nimport { Drawer } from '../Drawer';\nimport { SearchInput } from '../SearchInput';\nimport { DynamicFilterRows, rowsFromValues, valuesFromRows } from './DynamicFilterRows';\nimport type { FilterRow } from './DynamicFilterRows';\nimport { activeFilters, filterValueLabel } from './filterUtils';\nimport type { TableFilterField, TableFiltersProps, TableFilterValues } from './TableFilters.types';\nimport styles from './TableFilters.module.css';\n\n/** Mounted only while the panel is open, so its draft starts from the current values every time. */\nfunction FiltersPanel({\n fields,\n values,\n onApply,\n onClose,\n title,\n}: {\n fields: TableFilterField[];\n values: TableFilterValues;\n onApply: (values: TableFilterValues) => void;\n onClose: () => void;\n title: string;\n}) {\n const [rows, setRows] = useState<FilterRow[]>(() => rowsFromValues(values));\n\n return (\n <Drawer\n open\n onClose={onClose}\n title={title}\n description=\"Add the filters you want to use.\"\n size=\"sm\"\n footer={\n <div className={styles.panelFooter}>\n <Button variant=\"outline\" disabled={rows.length === 0} onClick={() => setRows([])}>\n Reset\n </Button>\n <Button\n onClick={() => {\n onApply(valuesFromRows(rows));\n onClose();\n }}\n >\n Apply Filters\n </Button>\n </div>\n }\n >\n <DynamicFilterRows fields={fields} rows={rows} onChange={setRows} />\n </Drawer>\n );\n}\n\n/**\n * Search box, a \"Filters\" button that opens a panel of fields (text, select, date) with Apply / Reset,\n * and removable chips for the active filters. State lives in your hands: pass values, react to changes.\n */\nexport function TableFilters({\n search = '',\n onSearchChange,\n searchPlaceholder = 'Search...',\n searchDelay = 0,\n fields,\n values,\n onValuesChange,\n panelTitle = 'Filters',\n className,\n}: TableFiltersProps) {\n const licensed = useLicensed();\n const [panelOpen, setPanelOpen] = useState(false);\n const [text, setText] = useState(search);\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n // Follow external changes to the search (e.g. a reset from outside).\n const lastExternal = useRef(search);\n if (lastExternal.current !== search) {\n lastExternal.current = search;\n if (search !== text) setText(search);\n }\n useEffect(() => () => clearTimeout(timer.current), []);\n\n if (!licensed) return <UnlicensedNotice />;\n\n const active = activeFilters(values);\n const activeFields = (fields ?? []).filter((field) => active[field.key] !== undefined);\n const hasFields = Boolean(fields && fields.length > 0 && onValuesChange);\n\n const handleSearch = (next: string) => {\n setText(next);\n clearTimeout(timer.current);\n if (searchDelay > 0) timer.current = setTimeout(() => onSearchChange?.(next), searchDelay);\n else onSearchChange?.(next);\n };\n\n return (\n <div className={cn(styles.root, className)}>\n <div className={styles.bar}>\n {onSearchChange ? (\n <div className={styles.search}>\n <SearchInput\n aria-label=\"Search\"\n size=\"sm\"\n placeholder={searchPlaceholder}\n value={text}\n onChange={(event) => handleSearch(event.target.value)}\n onClear={() => handleSearch('')}\n />\n </div>\n ) : null}\n <div className={styles.barEnd}>\n {hasFields ? (\n <Button\n variant=\"outline\"\n size=\"sm\"\n aria-haspopup=\"dialog\"\n onClick={() => setPanelOpen(true)}\n >\n <svg\n className={styles.filtersIcon}\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.8\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M3 5.5h14M5.5 10h9M8 14.5h4\" />\n </svg>\n Filters\n {activeFields.length > 0 ? (\n <span className={styles.count} aria-label={`${activeFields.length} active`}>\n {activeFields.length}\n </span>\n ) : null}\n </Button>\n ) : null}\n </div>\n </div>\n\n {activeFields.length > 0 ? (\n <ul className={styles.chips} aria-label=\"Active filters\">\n {activeFields.map((field) => (\n <li key={field.key} className={styles.chip}>\n <span className={styles.chipLabel}>{field.label}:</span>{' '}\n <strong className={styles.chipValue}>\n {filterValueLabel(field, active[field.key] as string)}\n </strong>\n <button\n type=\"button\"\n className={styles.chipRemove}\n aria-label={`Remove filter ${field.label}`}\n onClick={() => {\n const { [field.key]: _removed, ...rest } = active;\n void _removed;\n onValuesChange?.(rest);\n }}\n >\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M6 6l8 8M14 6l-8 8\" />\n </svg>\n </button>\n </li>\n ))}\n <li>\n <button type=\"button\" className={styles.clearAll} onClick={() => onValuesChange?.({})}>\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.8\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M4 10a6 6 0 106-6H7M7 1.5L4.5 4 7 6.5\" />\n </svg>\n Clear all\n </button>\n </li>\n </ul>\n ) : null}\n\n {panelOpen && hasFields ? (\n <FiltersPanel\n fields={fields ?? []}\n values={active}\n title={panelTitle}\n onApply={(next) => onValuesChange?.(next)}\n onClose={() => setPanelOpen(false)}\n />\n ) : null}\n </div>\n );\n}\n","import type { DataTableColumn, DataTableSort } from './DataTable.types';\n\n/** The value of a column for a row. */\nexport function getValue<T>(column: DataTableColumn<T>, row: T): unknown {\n if (column.accessor) return column.accessor(row);\n return (row as Record<string, unknown>)[String(column.accessorKey)];\n}\n\nconst asText = (value: unknown): string =>\n value === null || value === undefined\n ? ''\n : value instanceof Date\n ? value.toISOString()\n : String(value);\n\n/** Rows whose text contains `query` (case-insensitive) in any column. */\nexport function searchRows<T>(rows: T[], columns: DataTableColumn<T>[], query: string): T[] {\n const needle = query.trim().toLowerCase();\n if (!needle) return rows;\n return rows.filter((row) =>\n columns.some((column) => {\n const text = column.searchValue ? column.searchValue(row) : asText(getValue(column, row));\n return text.toLowerCase().includes(needle);\n }),\n );\n}\n\n/** Rows matching every column filter. Empty filter values are ignored. */\nexport function filterRows<T>(\n rows: T[],\n columns: DataTableColumn<T>[],\n filters: Record<string, string>,\n): T[] {\n const active = Object.entries(filters).filter(([, value]) => value.trim() !== '');\n if (active.length === 0) return rows;\n return rows.filter((row) =>\n active.every(([key, filterValue]) => {\n const column = columns.find((c) => String(c.accessorKey) === key);\n if (!column) return true;\n if (column.filterFn) return column.filterFn(row, filterValue);\n const text = asText(getValue(column, row));\n return column.filterType === 'select' || column.filterType === 'date'\n ? text === filterValue\n : text.toLowerCase().includes(filterValue.trim().toLowerCase());\n }),\n );\n}\n\nconst collator = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' });\n\n/** Rows sorted by a column. Empty values go last in either direction; the sort is stable. */\nexport function sortRows<T>(\n rows: T[],\n columns: DataTableColumn<T>[],\n sort: DataTableSort | null,\n): T[] {\n if (!sort) return rows;\n const column = columns.find((c) => String(c.accessorKey) === sort.key);\n if (!column) return rows;\n const read = (row: T) => (column.sortValue ? column.sortValue(row) : getValue(column, row));\n const factor = sort.direction === 'asc' ? 1 : -1;\n\n return rows\n .map((row, index) => ({ row, index, value: read(row) }))\n .sort((a, b) => {\n const aEmpty = a.value === null || a.value === undefined || a.value === '';\n const bEmpty = b.value === null || b.value === undefined || b.value === '';\n if (aEmpty || bEmpty) return aEmpty === bEmpty ? a.index - b.index : aEmpty ? 1 : -1;\n const result =\n typeof a.value === 'number' && typeof b.value === 'number'\n ? a.value - b.value\n : a.value instanceof Date && b.value instanceof Date\n ? a.value.getTime() - b.value.getTime()\n : collator.compare(asText(a.value), asText(b.value));\n return result === 0 ? a.index - b.index : result * factor;\n })\n .map((entry) => entry.row);\n}\n\n/** The rows of one page (pages start at 1). */\nexport function paginateRows<T>(rows: T[], page: number, pageSize: number): T[] {\n const start = (Math.max(1, page) - 1) * pageSize;\n return rows.slice(start, start + pageSize);\n}\n\n/** Next sort when a header is clicked: ascending, then descending, then none. */\nexport function nextSort(current: DataTableSort | null, key: string): DataTableSort | null {\n if (!current || current.key !== key) return { key, direction: 'asc' };\n return current.direction === 'asc' ? { key, direction: 'desc' } : null;\n}\n","import type { DataTableApiResponse, DataTableCallApi, DataTableSort } from './DataTable.types';\n\nexport const DEFAULT_PAGE_SIZE_OPTIONS = [10, 15, 20, 50, 100];\n\n/** Rows per request when `pagination` is off and every page is loaded. */\nexport const ALL_ROWS_PAGE_SIZE = 100;\n/** Never request more than this many pages when loading everything. */\nexport const MAX_PAGES = 100;\n\nexport const defaultCallApi: DataTableCallApi = async (url, init) => {\n const response = await fetch(url, init);\n return (await response.json()) as DataTableApiResponse;\n};\n\nexport interface RequestQuery {\n fetchUrl: string;\n apiBaseUrl?: string;\n pageNo: number;\n pageSize: number;\n search: string;\n additionalFilter?: string;\n sort: DataTableSort | null;\n /** Column filters by `accessorKey`. Empty values are left out. */\n filters: Record<string, string>;\n}\n\n/**\n * The request URL: `pageNo` and `pageSize`, plus one `filter` parameter that joins the search text, extra filter,\n * sort and column filters with `;` (`searchText:abc;orderByColumn:name;orderBy:asc;status:Active`).\n */\nexport function buildRequestUrl(query: RequestQuery): string {\n const base = /^https?:/i.test(query.fetchUrl)\n ? query.fetchUrl\n : `${query.apiBaseUrl ?? ''}${query.fetchUrl}`;\n\n const entries: string[] = [];\n if (query.search) entries.push(`searchText:${query.search}`);\n if (query.additionalFilter) entries.push(query.additionalFilter);\n if (query.sort) {\n entries.push(`orderByColumn:${query.sort.key}`);\n entries.push(`orderBy:${query.sort.direction}`);\n }\n for (const [key, value] of Object.entries(query.filters)) {\n if (value) entries.push(`${key}:${value}`);\n }\n\n const params = new URLSearchParams();\n params.append('pageNo', String(query.pageNo));\n params.append('pageSize', String(query.pageSize));\n if (entries.length > 0) params.append('filter', entries.join(';'));\n\n // Keep any query string already in the URL (e.g. `?type=Student`).\n return `${base}${base.includes('?') ? '&' : '?'}${params.toString()}`;\n}\n\nexport interface ParsedPage<T> {\n rows: T[];\n totalPages: number;\n totalItems: number;\n}\n\n/** Reads a response: `data.items` (or `data` itself) as rows, `data.totalPage` and `data.totalData` as the totals. */\nexport function parseResponse<T>(response: DataTableApiResponse): ParsedPage<T> {\n const data = response.data as\n { items?: unknown; totalPage?: number; totalData?: number } | unknown[] | undefined;\n const items = Array.isArray(data) ? data : (data?.items ?? data ?? []);\n const meta = Array.isArray(data) ? {} : (data ?? {});\n return {\n rows: Array.isArray(items) ? (items as T[]) : [],\n totalPages: (meta as { totalPage?: number }).totalPage ?? 0,\n totalItems: (meta as { totalData?: number }).totalData ?? 0,\n };\n}\n\nexport class DataTableRequestError extends Error {}\n\n/** One page, or an error: a response with `status: false` becomes an error carrying the server's message. */\nexport async function fetchPage<T>(url: string, callApi: DataTableCallApi): Promise<ParsedPage<T>> {\n const response = await callApi(url, { method: 'GET' });\n if (response.status === false) {\n throw new DataTableRequestError(response.message || 'Failed to fetch data');\n }\n return parseResponse<T>(response);\n}\n\n/** Every page of a query, 100 rows at a time (at most 100 pages). */\nexport async function fetchAllPages<T>(\n queryFor: (pageNo: number, pageSize: number) => string,\n callApi: DataTableCallApi,\n): Promise<T[]> {\n const rows: T[] = [];\n let pageNo = 1;\n let totalPages: number;\n do {\n const page = await fetchPage<T>(queryFor(pageNo, ALL_ROWS_PAGE_SIZE), callApi);\n rows.push(...page.rows);\n totalPages = page.totalPages || 1;\n pageNo += 1;\n } while (pageNo <= totalPages && pageNo <= MAX_PAGES);\n return rows;\n}\n","import { useEffect, useState } from 'react';\n\n/** The value, but only after it has stayed the same for `delay` ms. With a delay of 0 it is returned as is. */\nexport function useDebouncedValue<V>(value: V, delay: number): V {\n const [debounced, setDebounced] = useState(value);\n useEffect(() => {\n if (delay <= 0) return;\n const timer = setTimeout(() => setDebounced(value), delay);\n return () => clearTimeout(timer);\n }, [value, delay]);\n return delay <= 0 ? value : debounced;\n}\n","import { useEffect, useMemo, useState, type KeyboardEvent, type ReactNode } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { Button } from '../Button';\nimport { Checkbox } from '../Checkbox';\nimport { DropdownMenu } from '../DropdownMenu';\nimport { Pagination } from '../Pagination';\nimport { Skeleton } from '../Skeleton';\nimport {\n Table,\n TableBody,\n TableCaption,\n TableCell,\n TableHead,\n TableHeaderCell,\n TableRow,\n} from '../Table';\nimport type { TableAlign } from '../Table';\nimport { SelectionBar } from './SelectionBar';\nimport { TableFilters } from '../TableFilters';\nimport type { TableFilterField } from '../TableFilters';\nimport {\n filterRows,\n getValue,\n nextSort,\n paginateRows,\n searchRows,\n sortRows,\n} from './dataTableUtils';\nimport {\n DEFAULT_PAGE_SIZE_OPTIONS,\n buildRequestUrl,\n defaultCallApi,\n fetchAllPages,\n fetchPage,\n} from './remote';\nimport { useDebouncedValue } from './useDebouncedValue';\nimport type { DataTableAction, DataTableProps, DataTableSort } from './DataTable.types';\nimport styles from './DataTable.module.css';\n\nconst SKELETON_WIDTHS = [128, 80, 96];\n\nconst alignOf = (\n align: 'start' | 'center' | 'end' | 'left' | 'right' | undefined,\n): TableAlign | undefined => (align === 'left' ? 'start' : align === 'right' ? 'end' : align);\n\nconst alertIcon = (\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.8\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"9\" />\n <path d=\"M12 7.5v5M12 16h.01\" />\n </svg>\n);\n\nconst archiveIcon = (\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.6\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <rect x=\"3\" y=\"4\" width=\"18\" height=\"5\" rx=\"1\" />\n <path d=\"M5 9v9a1 1 0 001 1h12a1 1 0 001-1V9M10 13h4\" />\n </svg>\n);\n\ninterface RemoteResult<T> {\n key: string;\n rows: T[];\n totalPages: number;\n totalItems: number;\n error: string | null;\n}\n\n/**\n * Data table with search, column filters, sorting, row selection, row actions, loading / error / empty\n * states and pagination, in the look of the school app's tables.\n *\n * Give it rows with `data` (filtered, sorted and paged here), or a `fetchUrl` to load them from a server that\n * does the searching, sorting and paging (see `callApi`, `additionalFilter`, `refreshTrigger`, `registerApi`).\n * Each piece of state can be controlled (`search`, `filters`, `sort`, `page`, `pageSize`) or left to the table.\n */\nexport function DataTable<T>({\n columns,\n data,\n fetchUrl,\n apiBaseUrl,\n callApi = defaultCallApi,\n additionalFilter,\n refreshTrigger,\n debounceMs,\n registerApi,\n getRowId,\n loading: loadingProp = false,\n loadingRows = 5,\n emptyMessage,\n emptyState,\n searchable = true,\n searchPlaceholder,\n search: searchProp,\n defaultSearch = '',\n onSearchChange,\n filters: filtersProp,\n defaultFilters,\n onFiltersChange,\n manualFiltering = false,\n sort: sortProp,\n defaultSort = null,\n onSortChange,\n manualSorting = false,\n pagination: paginationProp,\n page: pageProp,\n defaultPage = 1,\n onPageChange,\n pageSize: pageSizeProp,\n defaultPageSize = 10,\n onPageSizeChange,\n pageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS,\n manualPagination = false,\n totalItems,\n selection,\n onRowClick,\n actions,\n actionsClassName,\n belowToolbar,\n bulkActions,\n caption,\n stickyHeader = true,\n className,\n tableClassName,\n containerClassName,\n 'aria-label': ariaLabel,\n}: DataTableProps<T>) {\n const licensed = useLicensed();\n const remote = fetchUrl !== undefined;\n const pagination = paginationProp ?? true;\n\n const [searchState, setSearchState] = useState(defaultSearch);\n const [filtersState, setFiltersState] = useState<Record<string, string>>(defaultFilters ?? {});\n const [sortState, setSortState] = useState<DataTableSort | null>(defaultSort);\n const [pageState, setPageState] = useState(defaultPage);\n const [pageSizeState, setPageSizeState] = useState(defaultPageSize);\n\n const search = searchProp ?? searchState;\n const filters = filtersProp ?? filtersState;\n const sort = sortProp === undefined ? sortState : sortProp;\n const pageSize = pageSizeProp ?? pageSizeState;\n const page = pageProp ?? pageState;\n\n const filterFields = useMemo<TableFilterField[]>(\n () =>\n columns\n .filter((column) => column.filterable)\n .map((column) => ({\n key: String(column.accessorKey),\n label: typeof column.header === 'string' ? column.header : String(column.accessorKey),\n type: column.filterType ?? 'text',\n options: column.filterOptions,\n })),\n [columns],\n );\n\n const goToFirstPage = () => {\n if (page === 1) return;\n if (pageProp === undefined) setPageState(1);\n onPageChange?.(1);\n };\n const changeSearch = (next: string) => {\n if (searchProp === undefined) setSearchState(next);\n onSearchChange?.(next);\n goToFirstPage();\n };\n const changeFilters = (next: Record<string, string>) => {\n if (filtersProp === undefined) setFiltersState(next);\n onFiltersChange?.(next);\n goToFirstPage();\n };\n const changeSort = (key: string) => {\n const next = nextSort(sort, key);\n if (sortProp === undefined) setSortState(next);\n onSortChange?.(next);\n };\n const changePage = (next: number) => {\n if (pageProp === undefined) setPageState(next);\n onPageChange?.(next);\n };\n const changePageSize = (next: number) => {\n if (pageSizeProp === undefined) setPageSizeState(next);\n onPageSizeChange?.(next);\n goToFirstPage();\n };\n\n // ---------- Rows from a server (fetchUrl) ----------\n const wait = debounceMs ?? (remote ? 500 : 0);\n const debouncedSearch = useDebouncedValue(search, wait);\n const debouncedFilters = useDebouncedValue(filters, wait);\n const requestKey = JSON.stringify([\n fetchUrl,\n apiBaseUrl,\n additionalFilter,\n refreshTrigger,\n pagination,\n page,\n pageSize,\n sort,\n debouncedSearch,\n debouncedFilters,\n ]);\n const [result, setResult] = useState<RemoteResult<T> | null>(null);\n\n useEffect(() => {\n if (!remote) return;\n let cancelled = false;\n const queryFor = (pageNo: number, size: number) =>\n buildRequestUrl({\n fetchUrl,\n apiBaseUrl,\n pageNo,\n pageSize: size,\n search: debouncedSearch,\n additionalFilter,\n sort,\n filters: debouncedFilters,\n });\n\n const load = async (): Promise<RemoteResult<T>> => {\n try {\n if (pagination) {\n const loaded = await fetchPage<T>(queryFor(page, pageSize), callApi);\n return { key: requestKey, error: null, ...loaded };\n }\n const rows = await fetchAllPages<T>(queryFor, callApi);\n return { key: requestKey, error: null, rows, totalPages: 0, totalItems: 0 };\n } catch (error) {\n const message =\n error instanceof Error && error.message ? error.message : 'An unexpected error occurred';\n return { key: requestKey, error: message, rows: [], totalPages: 0, totalItems: 0 };\n }\n };\n\n void load().then((loaded) => {\n if (!cancelled) setResult(loaded);\n });\n return () => {\n cancelled = true;\n };\n // `requestKey` covers every input of the request.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [requestKey]);\n\n useEffect(() => {\n registerApi?.({\n updateRow: (id, patch) =>\n setResult((previous) =>\n previous\n ? {\n ...previous,\n rows: previous.rows.map((row) =>\n (row as { id?: string | number }).id === id ? { ...row, ...patch } : row,\n ),\n }\n : previous,\n ),\n });\n }, [registerApi]);\n\n const loading = remote ? result?.key !== requestKey : loadingProp;\n const error = remote && !loading ? (result?.error ?? null) : null;\n const sourceRows = useMemo(\n () => (remote ? (result?.rows ?? []) : (data ?? [])),\n [remote, result, data],\n );\n const serverSide = remote || manualFiltering;\n\n const processed = useMemo(() => {\n let rows = sourceRows;\n if (!serverSide) rows = filterRows(searchRows(rows, columns, search), columns, filters);\n if (!(remote || manualSorting)) rows = sortRows(rows, columns, sort);\n return rows;\n }, [sourceRows, columns, search, filters, sort, serverSide, remote, manualSorting]);\n\n if (!licensed) return <UnlicensedNotice />;\n\n const serverPaging = remote || manualPagination;\n const total = remote\n ? (result?.totalItems ?? 0)\n : manualPagination\n ? (totalItems ?? sourceRows.length)\n : processed.length;\n const pageCount = remote\n ? Math.max(1, result?.totalPages ?? 1)\n : Math.max(1, Math.ceil(total / pageSize));\n const currentPage = Math.min(Math.max(1, page), pageCount);\n const rows =\n !pagination || serverPaging ? processed : paginateRows(processed, currentPage, pageSize);\n\n const rowId = (row: T, index: number) =>\n String(getRowId ? getRowId(row, index) : ((row as { id?: unknown }).id ?? index));\n const visibleIds = rows.map(rowId);\n const selectedIds = selection?.selected ?? [];\n const selectedVisible = visibleIds.filter((id) => selectedIds.includes(id));\n const allSelected = visibleIds.length > 0 && selectedVisible.length === visibleIds.length;\n const someSelected = selectedVisible.length > 0 && !allSelected;\n\n const toggleAll = () => {\n if (!selection) return;\n selection.onChange(\n allSelected\n ? selectedIds.filter((id) => !visibleIds.includes(id))\n : [...new Set([...selectedIds, ...visibleIds])],\n );\n };\n const toggleRow = (id: string) => {\n if (!selection) return;\n selection.onChange(\n selectedIds.includes(id) ? selectedIds.filter((s) => s !== id) : [...selectedIds, id],\n );\n };\n\n const hasActions = Boolean(actions && actions.length > 0);\n const hasToolbar = searchable || filterFields.length > 0;\n const isFiltered =\n search.trim() !== '' || Object.values(filters).some((value) => value.trim() !== '');\n const columnCount = columns.length + (selection ? 1 : 0) + (hasActions ? 1 : 0);\n const stop = { onClick: (event: { stopPropagation: () => void }) => event.stopPropagation() };\n const emptyText = emptyMessage ?? 'No data available';\n\n const handleRowKeyDown = (event: KeyboardEvent<HTMLTableRowElement>, row: T) => {\n if (event.target !== event.currentTarget) return;\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n onRowClick?.(row);\n }\n };\n\n const renderActions = (row: T): ReactNode => {\n const visible = (actions ?? []).filter((action) => !action.hidden?.(row));\n if (visible.length === 0) return null;\n const isDanger = (action: DataTableAction<T>) => action.variant === 'danger';\n if (visible.length === 1) {\n const action = visible[0] as DataTableAction<T>;\n return (\n <button\n type=\"button\"\n className={cn(styles.actionButton, isDanger(action) && styles.actionDanger)}\n title={action.label}\n aria-label={action.label}\n onClick={() => action.onClick(row)}\n >\n {action.icon ?? <span className={styles.actionText}>{action.label}</span>}\n </button>\n );\n }\n return (\n <DropdownMenu\n items={visible.map((action) => ({\n label: action.label,\n icon: action.icon,\n variant: isDanger(action) ? 'danger' : 'default',\n onClick: () => action.onClick(row),\n }))}\n />\n );\n };\n\n const table = (\n <div className={styles.tableArea} aria-busy={loading || undefined}>\n <Table\n aria-label={ariaLabel}\n scrollLabel={ariaLabel ? `${ariaLabel} (scrollable)` : undefined}\n stickyHeader={stickyHeader}\n bordered={false}\n className={tableClassName}\n containerClassName={cn(styles.scroll, containerClassName)}\n >\n {caption ? <TableCaption>{caption}</TableCaption> : null}\n <TableHead>\n <TableRow>\n {selection ? (\n <TableHeaderCell className={styles.selectCell}>\n <Checkbox\n aria-label=\"Select all rows\"\n checked={allSelected}\n indeterminate={someSelected}\n disabled={visibleIds.length === 0 || loading}\n onChange={toggleAll}\n />\n </TableHeaderCell>\n ) : null}\n {columns.map((column) => {\n const key = String(column.accessorKey);\n return (\n <TableHeaderCell\n key={key}\n align={alignOf(column.align)}\n sortable={column.sortable}\n sortDirection={sort?.key === key ? sort.direction : null}\n onSort={() => changeSort(key)}\n className={column.className}\n style={column.width !== undefined ? { width: column.width } : undefined}\n >\n {column.header}\n </TableHeaderCell>\n );\n })}\n {hasActions ? (\n <TableHeaderCell align=\"center\" className={actionsClassName ?? styles.actionsColumn}>\n Actions\n </TableHeaderCell>\n ) : null}\n </TableRow>\n </TableHead>\n <TableBody>\n {error ? (\n <TableRow>\n <TableCell colSpan={columnCount} className={styles.errorCell}>\n <div className={styles.stateBox} role=\"alert\">\n <span className={styles.errorIcon}>{alertIcon}</span>\n <span className={styles.errorText}>{error}</span>\n </div>\n </TableCell>\n </TableRow>\n ) : loading ? (\n Array.from({ length: loadingRows }, (_, rowIndex) => (\n <TableRow key={`loading-${rowIndex}`}>\n {Array.from({ length: columnCount }, (_, cellIndex) => (\n <TableCell\n key={cellIndex}\n align={hasActions && cellIndex === columnCount - 1 ? 'center' : undefined}\n >\n {hasActions && cellIndex === columnCount - 1 ? (\n <Skeleton\n width={32}\n height={32}\n style={{ borderRadius: 6, display: 'inline-block' }}\n />\n ) : (\n <Skeleton\n variant=\"text\"\n height={16}\n width={SKELETON_WIDTHS[cellIndex === 0 ? 0 : cellIndex % 2 === 0 ? 2 : 1]}\n style={{ borderRadius: 4 }}\n />\n )}\n </TableCell>\n ))}\n </TableRow>\n ))\n ) : rows.length === 0 ? (\n <TableRow>\n <TableCell colSpan={columnCount} className={styles.empty}>\n {emptyState ?? (\n <div className={styles.stateBox}>\n <span className={styles.emptyIcon}>{archiveIcon}</span>\n <span>\n {isFiltered ? 'No results match your search or filters.' : emptyText}\n </span>\n {isFiltered ? (\n <Button\n variant=\"link\"\n size=\"sm\"\n onClick={() => {\n changeSearch('');\n changeFilters({});\n }}\n >\n Clear search and filters\n </Button>\n ) : null}\n </div>\n )}\n </TableCell>\n </TableRow>\n ) : (\n rows.map((row, index) => {\n const id = rowId(row, index);\n const selected = selectedIds.includes(id);\n return (\n <TableRow\n key={id}\n selected={selected}\n onClick={onRowClick ? () => onRowClick(row) : undefined}\n onKeyDown={onRowClick ? (event) => handleRowKeyDown(event, row) : undefined}\n tabIndex={onRowClick ? 0 : undefined}\n >\n {selection ? (\n <TableCell className={styles.selectCell} {...stop}>\n <Checkbox\n aria-label=\"Select row\"\n checked={selected}\n onChange={() => toggleRow(id)}\n />\n </TableCell>\n ) : null}\n {columns.map((column) => {\n const value = getValue(column, row);\n return (\n <TableCell\n key={String(column.accessorKey)}\n align={alignOf(column.align)}\n className={column.className}\n style={column.width !== undefined ? { width: column.width } : undefined}\n >\n {column.render ? (\n column.render(value, row)\n ) : (\n <span className={styles.cellText}>\n {value !== undefined && value !== null ? String(value) : '-'}\n </span>\n )}\n </TableCell>\n );\n })}\n {hasActions ? (\n <TableCell\n align=\"center\"\n className={actionsClassName ?? styles.actionsColumn}\n {...stop}\n >\n <div className={styles.actions}>{renderActions(row)}</div>\n </TableCell>\n ) : null}\n </TableRow>\n );\n })\n )}\n </TableBody>\n </Table>\n </div>\n );\n\n return (\n <div className={cn(styles.root, className)}>\n {hasToolbar ? (\n <div className={styles.toolbar}>\n <TableFilters\n search={searchable ? search : undefined}\n onSearchChange={searchable ? changeSearch : undefined}\n searchPlaceholder={searchPlaceholder ?? 'Search...'}\n fields={filterFields}\n values={filters}\n onValuesChange={filterFields.length > 0 ? changeFilters : undefined}\n />\n </div>\n ) : null}\n {selection && selectedIds.length > 0 ? (\n <SelectionBar\n count={selectedIds.length}\n actions={bulkActions?.map((a) => ({ ...a, onClick: () => a.onClick(selectedIds) }))}\n onClear={() => selection.onChange([])}\n />\n ) : null}\n {belowToolbar}\n\n {table}\n\n <div role=\"status\" className={styles.srOnly}>\n {loading ? 'Loading' : error ? 'Error' : `${total} ${total === 1 ? 'result' : 'results'}`}\n </div>\n\n {pagination ? (\n <div className={styles.footer}>\n <Pagination\n layout=\"split\"\n page={currentPage}\n pageCount={pageCount}\n onPageChange={changePage}\n pageSize={pageSize}\n totalItems={total}\n pageSizeOptions={pageSizeOptions}\n onPageSizeChange={changePageSize}\n disabled={loading}\n />\n </div>\n ) : null}\n </div>\n );\n}\n","/** \"1.5 MB\", \"820 KB\", \"12 B\". */\nexport function formatFileSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`;\n const mb = bytes / (1024 * 1024);\n return `${mb < 10 ? mb.toFixed(1) : Math.round(mb)} MB`;\n}\n\n/** Whether `file` matches a native `accept` string (`.pdf, image/*, application/pdf`). Empty accepts everything. */\nexport function matchesAccept(file: Pick<File, 'name' | 'type'>, accept?: string): boolean {\n const tokens = (accept ?? '')\n .split(',')\n .map((token) => token.trim().toLowerCase())\n .filter(Boolean);\n if (tokens.length === 0) return true;\n const name = file.name.toLowerCase();\n const type = file.type.toLowerCase();\n return tokens.some((token) => {\n if (token.startsWith('.')) return name.endsWith(token);\n if (token.endsWith('/*')) return type.startsWith(token.slice(0, -1));\n return type === token;\n });\n}\n\nexport const sameFile = (a: File, b: File) =>\n a.name === b.name && a.size === b.size && a.lastModified === b.lastModified;\n\n/** Stable key for a file: name, size and modified time. */\nexport const fileKey = (file: File) => `${file.name}-${file.size}-${file.lastModified}`;\n\nexport const isImage = (file: Pick<File, 'type'>) => file.type.startsWith('image/');\n",".backdrop {\n position: fixed;\n inset: 0;\n z-index: var(--cui-z-popover);\n display: flex;\n align-items: center;\n justify-content: center;\n padding: var(--cui-space-4);\n background-color: rgb(0 0 0 / 0.55);\n font-family: var(--cui-font-family);\n}\n\n.dialog {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: var(--cui-space-4);\n box-sizing: border-box;\n max-width: 100%;\n padding: var(--cui-space-5);\n background-color: var(--cui-color-surface);\n color: var(--cui-color-text);\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-xl);\n box-shadow: var(--cui-shadow-lg);\n outline: none;\n}\n\n.title {\n align-self: flex-start;\n margin: 0;\n font-size: var(--cui-font-size-lg);\n font-weight: var(--cui-font-weight-semibold);\n}\n\n.frame {\n position: relative;\n max-width: 100%;\n overflow: hidden;\n background-color: var(--cui-color-surface-secondary);\n border: 2px solid var(--cui-color-border);\n border-radius: var(--cui-radius-md);\n cursor: grab;\n touch-action: none;\n user-select: none;\n}\n.frame:active {\n cursor: grabbing;\n}\n.frame:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 2px;\n}\n\n.circle {\n border-radius: var(--cui-radius-full);\n}\n\n.image {\n position: absolute;\n top: 50%;\n left: 50%;\n max-width: none;\n pointer-events: none;\n will-change: transform;\n}\n\n.loading {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--cui-color-text-muted);\n font-size: var(--cui-font-size-sm);\n}\n\n.zoom {\n display: flex;\n align-items: center;\n gap: var(--cui-space-3);\n width: 100%;\n font-size: var(--cui-font-size-sm);\n color: var(--cui-color-text-secondary);\n}\n.zoom input {\n flex: 1;\n accent-color: var(--cui-color-primary);\n}\n\n.error {\n margin: 0;\n max-width: 20rem;\n font-size: var(--cui-font-size-sm);\n color: var(--cui-color-danger);\n}\n\n.actions {\n display: flex;\n align-self: flex-end;\n gap: var(--cui-space-2);\n}\n\n.cancel,\n.apply {\n height: var(--cui-control-height-md);\n padding: 0 var(--cui-space-4);\n border: var(--cui-control-border-width) solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n font: inherit;\n font-size: var(--cui-font-size-sm);\n font-weight: var(--cui-font-weight-medium);\n cursor: pointer;\n}\n\n.cancel {\n background-color: var(--cui-color-surface);\n color: var(--cui-color-text);\n}\n.cancel:hover {\n background-color: var(--cui-color-surface-secondary);\n}\n\n.apply {\n background-color: var(--cui-color-primary);\n border-color: var(--cui-color-primary);\n color: var(--cui-color-on-primary);\n}\n.apply:hover:not(:disabled) {\n background-color: var(--cui-color-primary-hover);\n border-color: var(--cui-color-primary-hover);\n}\n.apply:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.cancel:focus-visible,\n.apply:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 2px;\n}\n","import { useEffect, useId, useRef, useState, type KeyboardEvent, type PointerEvent } from 'react';\nimport { createPortal } from 'react-dom';\nimport { cn } from '../../utils/cn';\nimport { getPortalHost } from '../../utils/portalHost';\nimport styles from './ImageCropper.module.css';\n\nexport interface ImageCropperProps {\n file: File;\n /** Width divided by height of the crop frame. */\n aspect: number;\n /** `circle` shows a round frame; the saved image is still the full rectangle around it. */\n shape: 'circle' | 'rect';\n /** Width in px of the saved image. The height follows from `aspect`. */\n outputWidth: number;\n outputType: 'image/png' | 'image/jpeg' | 'image/webp';\n outputQuality?: number;\n title?: string;\n /** `data-theme` to apply to the dialog (it is rendered in <body>). */\n theme?: string;\n onApply: (file: File) => void;\n onCancel: () => void;\n}\n\nconst FRAME = 280; // length of the frame's longer side, in px\nconst MAX_ZOOM = 4;\nconst KEY_STEP = 12;\n\ninterface Loaded {\n image: HTMLImageElement;\n width: number;\n height: number;\n}\n\nconst extensionFor = (type: string) =>\n type === 'image/png' ? 'png' : type === 'image/webp' ? 'webp' : 'jpg';\n\n/**\n * Modal that lets the user move and zoom a picked image inside a fixed-ratio frame and saves the visible\n * part as a new file. Drag, arrow keys, the slider, or +/- keys adjust it; Enter applies, Escape cancels.\n */\nexport function ImageCropper({\n file,\n aspect,\n shape,\n outputWidth,\n outputType,\n outputQuality,\n title = 'Crop photo',\n theme,\n onApply,\n onCancel,\n}: ImageCropperProps) {\n const titleId = useId();\n const dialogRef = useRef<HTMLDivElement>(null);\n const [loaded, setLoaded] = useState<Loaded | null>(null);\n const [failed, setFailed] = useState(false);\n const [zoom, setZoom] = useState(1);\n const [offset, setOffset] = useState({ x: 0, y: 0 });\n const [saving, setSaving] = useState(false);\n const drag = useRef<{ x: number; y: number; ox: number; oy: number } | null>(null);\n\n // Frame size: the longer side is FRAME, the other follows the aspect ratio.\n const frameW = aspect >= 1 ? FRAME : Math.round(FRAME * aspect);\n const frameH = aspect >= 1 ? Math.round(FRAME / aspect) : FRAME;\n\n useEffect(() => {\n const previous = document.activeElement as HTMLElement | null;\n dialogRef.current?.focus({ preventScroll: true });\n return () => previous?.focus?.({ preventScroll: true });\n }, []);\n\n useEffect(() => {\n let url: string | undefined;\n const image = new Image();\n image.onload = () =>\n setLoaded({ image, width: image.naturalWidth, height: image.naturalHeight });\n image.onerror = () => setFailed(true);\n try {\n url = URL.createObjectURL(file);\n image.src = url;\n } catch {\n image.onerror?.(new Event('error'));\n }\n return () => {\n image.onload = null;\n image.onerror = null;\n if (url) URL.revokeObjectURL(url);\n };\n }, [file]);\n\n // Scale at which the image just covers the frame; zoom multiplies it.\n const baseScale = loaded ? Math.max(frameW / loaded.width, frameH / loaded.height) : 1;\n const scale = baseScale * zoom;\n\n const clamp = (x: number, y: number, nextScale: number) => {\n if (!loaded) return { x: 0, y: 0 };\n const maxX = Math.max(0, (loaded.width * nextScale - frameW) / 2);\n const maxY = Math.max(0, (loaded.height * nextScale - frameH) / 2);\n return { x: Math.min(maxX, Math.max(-maxX, x)), y: Math.min(maxY, Math.max(-maxY, y)) };\n };\n\n const changeZoom = (next: number) => {\n const value = Math.min(MAX_ZOOM, Math.max(1, next));\n setZoom(value);\n setOffset((current) => clamp(current.x, current.y, baseScale * value));\n };\n\n const move = (dx: number, dy: number) =>\n setOffset((current) => clamp(current.x + dx, current.y + dy, scale));\n\n const handlePointerDown = (event: PointerEvent<HTMLDivElement>) => {\n event.currentTarget.setPointerCapture?.(event.pointerId);\n drag.current = { x: event.clientX, y: event.clientY, ox: offset.x, oy: offset.y };\n };\n const handlePointerMove = (event: PointerEvent<HTMLDivElement>) => {\n const start = drag.current;\n if (!start) return;\n setOffset(clamp(start.ox + event.clientX - start.x, start.oy + event.clientY - start.y, scale));\n };\n const endDrag = () => {\n drag.current = null;\n };\n\n const apply = () => {\n if (!loaded || saving) return;\n setSaving(true);\n const outW = Math.round(outputWidth);\n const outH = Math.max(1, Math.round(outputWidth / aspect));\n const canvas = document.createElement('canvas');\n canvas.width = outW;\n canvas.height = outH;\n const context = canvas.getContext('2d');\n if (!context) {\n setSaving(false);\n setFailed(true);\n return;\n }\n // The frame's top-left corner, expressed in the image's own pixels.\n const sx = (loaded.width * scale - frameW) / 2 / scale - offset.x / scale;\n const sy = (loaded.height * scale - frameH) / 2 / scale - offset.y / scale;\n context.imageSmoothingQuality = 'high';\n context.drawImage(loaded.image, sx, sy, frameW / scale, frameH / scale, 0, 0, outW, outH);\n canvas.toBlob(\n (blob) => {\n if (!blob) {\n setSaving(false);\n setFailed(true);\n return;\n }\n const base = file.name.replace(/\\.[^.]+$/, '') || 'photo';\n const type = blob.type || outputType;\n onApply(\n new File([blob], `${base}.${extensionFor(type)}`, { type, lastModified: Date.now() }),\n );\n },\n outputType,\n outputQuality,\n );\n };\n\n const handleDialogKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Escape') {\n event.preventDefault();\n event.stopPropagation();\n onCancel();\n return;\n }\n if (event.key === 'Tab') {\n // Keep Tab inside the dialog.\n const nodes = Array.from(\n dialogRef.current?.querySelectorAll<HTMLElement>(\n 'button:not([disabled]), input, [tabindex=\"0\"]',\n ) ?? [],\n );\n const first = nodes[0];\n const last = nodes[nodes.length - 1];\n if (!first || !last) return;\n if (\n event.shiftKey &&\n (document.activeElement === first || document.activeElement === dialogRef.current)\n ) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n }\n };\n\n const handleStageKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const moves: Record<string, [number, number]> = {\n ArrowLeft: [KEY_STEP, 0],\n ArrowRight: [-KEY_STEP, 0],\n ArrowUp: [0, KEY_STEP],\n ArrowDown: [0, -KEY_STEP],\n };\n const delta = moves[event.key];\n if (delta) {\n event.preventDefault();\n move(delta[0], delta[1]);\n } else if (event.key === '+' || event.key === '=') {\n event.preventDefault();\n changeZoom(zoom + 0.1);\n } else if (event.key === '-') {\n event.preventDefault();\n changeZoom(zoom - 0.1);\n } else if (event.key === 'Enter') {\n event.preventDefault();\n apply();\n }\n };\n\n const dialog = (\n <div className={styles.backdrop} data-theme={theme}>\n <div\n ref={dialogRef}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={titleId}\n tabIndex={-1}\n className={styles.dialog}\n onKeyDown={handleDialogKeyDown}\n >\n <h2 id={titleId} className={styles.title}>\n {title}\n </h2>\n\n {failed ? (\n <p className={styles.error} role=\"alert\">\n This image could not be opened. Try a different file.\n </p>\n ) : (\n <>\n <div\n className={cn(styles.frame, shape === 'circle' && styles.circle)}\n style={{ width: frameW, height: frameH }}\n tabIndex={0}\n role=\"group\"\n aria-label=\"Crop area. Drag, or use the arrow keys to move the photo and plus and minus to zoom.\"\n onPointerDown={handlePointerDown}\n onPointerMove={handlePointerMove}\n onPointerUp={endDrag}\n onPointerCancel={endDrag}\n onKeyDown={handleStageKeyDown}\n >\n {loaded ? (\n <img\n src={loaded.image.src}\n alt=\"\"\n draggable={false}\n className={styles.image}\n style={{\n width: loaded.width * scale,\n height: loaded.height * scale,\n transform: `translate(calc(-50% + ${offset.x}px), calc(-50% + ${offset.y}px))`,\n }}\n />\n ) : (\n <span className={styles.loading}>Loading…</span>\n )}\n </div>\n\n <label className={styles.zoom}>\n <span>Zoom</span>\n <input\n type=\"range\"\n min={1}\n max={MAX_ZOOM}\n step={0.01}\n value={zoom}\n disabled={!loaded}\n aria-label=\"Zoom\"\n onChange={(event) => changeZoom(Number(event.target.value))}\n />\n </label>\n </>\n )}\n\n <div className={styles.actions}>\n <button type=\"button\" className={styles.cancel} onClick={onCancel}>\n Cancel\n </button>\n <button\n type=\"button\"\n className={styles.apply}\n disabled={!loaded || saving || failed}\n onClick={apply}\n >\n {saving ? 'Saving…' : 'Apply'}\n </button>\n </div>\n </div>\n </div>\n );\n\n return createPortal(dialog, getPortalHost());\n}\n",".root {\n display: flex;\n flex-direction: column;\n gap: var(--cui-space-2);\n width: 100%;\n font-family: var(--cui-font-family);\n}\n\n/* ---------- Variant: dropzone ---------- */\n.zone {\n position: relative;\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: var(--cui-space-1);\n box-sizing: border-box;\n padding: var(--cui-space-6) var(--cui-space-4);\n background-color: var(--cui-color-surface);\n border: var(--cui-control-border-width) dashed var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text-secondary);\n font-size: var(--cui-font-size-sm);\n text-align: center;\n cursor: pointer;\n transition:\n background-color var(--cui-transition-fast),\n border-color var(--cui-transition-fast),\n box-shadow var(--cui-transition-fast);\n}\n\n.zone:hover:not(.disabled):not(:focus-within) {\n border-color: var(--cui-color-border-hover);\n}\n\n.zone:focus-within {\n border-color: var(--cui-color-border-focus);\n box-shadow: var(--cui-focus-ring);\n}\n\n.dragging {\n background-color: var(--cui-color-primary-subtle);\n border-color: var(--cui-color-primary);\n}\n\n/* Shared state classes (all variants) */\n.zone.invalid,\n.tile.invalid,\n.addTile.invalid,\n.fieldFace.invalid {\n border-color: var(--cui-color-danger-border);\n}\n.zone.invalid:focus-within {\n border-color: var(--cui-color-danger-border-hover);\n box-shadow: var(--cui-focus-ring-danger);\n}\n\n.zone.disabled {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n\n/* Visually hidden but focusable, so keyboard users and form submission still work. */\n.input {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip-path: inset(50%);\n border: 0;\n white-space: nowrap;\n}\n\n.icon {\n width: 1.75rem;\n height: 1.75rem;\n color: var(--cui-color-text-muted);\n}\n\n.browseLink {\n color: var(--cui-color-primary);\n font-weight: var(--cui-font-weight-medium);\n}\n\n.hint {\n font-size: var(--cui-font-size-xs);\n color: var(--cui-color-text-muted);\n}\n\n.hintText {\n font-size: var(--cui-font-size-xs);\n color: var(--cui-color-text-muted);\n}\n\n/* ---------- File list ---------- */\n.list {\n display: flex;\n flex-direction: column;\n gap: var(--cui-space-1);\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.item {\n display: flex;\n align-items: center;\n gap: var(--cui-space-3);\n padding: var(--cui-space-2) var(--cui-space-3);\n background-color: var(--cui-color-surface-secondary);\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-md);\n font-size: var(--cui-font-size-sm);\n color: var(--cui-color-text);\n}\n\n.itemThumb {\n width: 2rem;\n height: 2rem;\n flex-shrink: 0;\n border-radius: var(--cui-radius-sm);\n object-fit: cover;\n}\n\n.itemIcon {\n width: 1.25rem;\n height: 1.25rem;\n flex-shrink: 0;\n color: var(--cui-color-text-muted);\n}\n\n.name {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.size {\n flex-shrink: 0;\n font-size: var(--cui-font-size-xs);\n color: var(--cui-color-text-muted);\n}\n\n.remove {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n width: 1.25rem;\n height: 1.25rem;\n padding: 0;\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-full);\n color: var(--cui-color-text-muted);\n cursor: pointer;\n}\n.remove:hover:not(:disabled) {\n background-color: var(--cui-color-border);\n color: var(--cui-color-text);\n}\n.remove:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n}\n.remove svg {\n width: 0.875rem;\n height: 0.875rem;\n}\n\n.rejected {\n margin: 0;\n font-size: var(--cui-font-size-sm);\n color: var(--cui-color-danger);\n}\n\n/* ---------- Variant: button ---------- */\n.buttonRow {\n display: flex;\n align-items: center;\n gap: var(--cui-space-3);\n min-width: 0;\n}\n\n.buttonFace {\n position: relative;\n flex-shrink: 0;\n display: inline-flex;\n cursor: pointer;\n}\n\n.button {\n display: inline-flex;\n align-items: center;\n gap: var(--cui-space-2);\n box-sizing: border-box;\n height: var(--cui-control-height-md);\n padding: 0 var(--cui-space-4);\n background-color: var(--cui-color-surface);\n border: var(--cui-control-border-width) solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text);\n font-size: var(--cui-font-size-sm);\n font-weight: var(--cui-font-weight-medium);\n transition:\n background-color var(--cui-transition-fast),\n border-color var(--cui-transition-fast),\n box-shadow var(--cui-transition-fast);\n}\n.buttonFace:hover:not(.disabled):not(:focus-within) .button {\n background-color: var(--cui-color-surface-secondary);\n border-color: var(--cui-color-border-hover);\n}\n.buttonFace:focus-within .button {\n border-color: var(--cui-color-border-focus);\n box-shadow: var(--cui-focus-ring);\n}\n.buttonFace.invalid .button {\n border-color: var(--cui-color-danger-border);\n}\n.buttonFace.disabled {\n cursor: not-allowed;\n}\n.buttonFace.disabled .button {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text-disabled);\n}\n\n.buttonIcon {\n width: 1.125rem;\n height: 1.125rem;\n}\n\n.summary {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: var(--cui-font-size-sm);\n color: var(--cui-color-text-muted);\n}\n\n/* ---------- Variant: field ---------- */\n.fieldFace {\n position: relative;\n display: flex;\n align-items: center;\n gap: var(--cui-space-3);\n box-sizing: border-box;\n width: 100%;\n min-height: var(--cui-control-height-md);\n padding: 0 0 0 var(--cui-space-4);\n background-color: var(--cui-color-surface);\n border: var(--cui-control-border-width) solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n font-size: var(--cui-font-size-sm);\n color: var(--cui-color-text);\n cursor: pointer;\n overflow: hidden;\n transition:\n border-color var(--cui-transition-fast),\n box-shadow var(--cui-transition-fast);\n}\n.fieldFace:hover:not(.disabled):not(:focus-within) {\n border-color: var(--cui-color-border-hover);\n}\n.fieldFace:focus-within {\n border-color: var(--cui-color-border-focus);\n box-shadow: var(--cui-focus-ring);\n}\n.fieldFace.invalid:focus-within {\n border-color: var(--cui-color-danger-border-hover);\n box-shadow: var(--cui-focus-ring-danger);\n}\n.fieldFace.disabled {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n\n.fieldValue {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.fieldPlaceholder {\n color: var(--cui-color-placeholder);\n}\n\n.browse {\n align-self: stretch;\n display: inline-flex;\n align-items: center;\n flex-shrink: 0;\n padding: 0 var(--cui-space-4);\n background-color: var(--cui-color-surface-secondary);\n border-inline-start: 1px solid var(--cui-color-border);\n color: var(--cui-color-text-secondary);\n font-weight: var(--cui-font-weight-medium);\n}\n\n/* ---------- Variant: image ---------- */\n.imageRoot {\n display: flex;\n align-items: center;\n gap: var(--cui-space-4);\n}\n\n.tile {\n position: relative;\n display: flex;\n flex-shrink: 0;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n overflow: hidden;\n background-color: var(--cui-color-surface-secondary);\n border: var(--cui-control-border-width) dashed var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text-muted);\n font-size: var(--cui-font-size-xs);\n text-align: center;\n cursor: pointer;\n transition:\n border-color var(--cui-transition-fast),\n box-shadow var(--cui-transition-fast);\n}\n.circle {\n border-radius: var(--cui-radius-full);\n}\n.tile:hover:not(.disabled):not(:focus-within) {\n border-color: var(--cui-color-border-hover);\n}\n.tile:focus-within {\n border-color: var(--cui-color-border-focus);\n box-shadow: var(--cui-focus-ring);\n}\n.tile.disabled {\n cursor: not-allowed;\n opacity: 0.6;\n}\n\n.tileImage {\n width: 100%;\n height: 100%;\n object-fit: cover;\n}\n\n.tileEmpty {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: var(--cui-space-1);\n padding: var(--cui-space-2);\n overflow: hidden;\n}\n\n.overlay {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: rgb(0 0 0 / 0.5);\n color: var(--cui-color-white);\n font-weight: var(--cui-font-weight-medium);\n opacity: 0;\n transition: opacity var(--cui-transition-fast);\n}\n.tile:hover:not(.disabled) .overlay,\n.tile:focus-within .overlay {\n opacity: 1;\n}\n\n.imageSide {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: var(--cui-space-1);\n min-width: 0;\n font-size: var(--cui-font-size-sm);\n color: var(--cui-color-text);\n}\n\n.removeText {\n padding: 0;\n background: transparent;\n border: 0;\n color: var(--cui-color-danger);\n font: inherit;\n font-size: var(--cui-font-size-sm);\n cursor: pointer;\n}\n.removeText:hover:not(:disabled) {\n text-decoration: underline;\n}\n.removeText:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 2px;\n}\n.removeText:disabled {\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n\n/* ---------- Variant: gallery ---------- */\n.gallery {\n display: grid;\n grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));\n gap: var(--cui-space-3);\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.thumbItem,\n.addItem {\n position: relative;\n aspect-ratio: 1;\n}\n\n.thumbItem {\n overflow: hidden;\n background-color: var(--cui-color-surface-secondary);\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n}\n\n.thumbImage {\n width: 100%;\n height: 100%;\n object-fit: cover;\n}\n\n.thumbFallback {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: 100%;\n color: var(--cui-color-text-muted);\n}\n\n.thumbName {\n position: absolute;\n inset-inline: 0;\n bottom: 0;\n padding: 2px var(--cui-space-2);\n overflow: hidden;\n background-color: rgb(0 0 0 / 0.55);\n color: var(--cui-color-white);\n font-size: var(--cui-font-size-xs);\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.thumbRemove {\n position: absolute;\n top: var(--cui-space-1);\n inset-inline-end: var(--cui-space-1);\n background-color: rgb(0 0 0 / 0.6);\n color: var(--cui-color-white);\n}\n.thumbRemove:hover:not(:disabled) {\n background-color: rgb(0 0 0 / 0.8);\n color: var(--cui-color-white);\n}\n\n.addTile {\n position: relative;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: var(--cui-space-1);\n box-sizing: border-box;\n width: 100%;\n height: 100%;\n background-color: var(--cui-color-surface);\n border: var(--cui-control-border-width) dashed var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text-muted);\n font-size: var(--cui-font-size-xs);\n cursor: pointer;\n transition:\n border-color var(--cui-transition-fast),\n box-shadow var(--cui-transition-fast);\n}\n.addTile:hover:not(.disabled):not(:focus-within) {\n border-color: var(--cui-color-border-hover);\n}\n.addTile:focus-within {\n border-color: var(--cui-color-border-focus);\n box-shadow: var(--cui-focus-ring);\n}\n.addTile.disabled {\n cursor: not-allowed;\n opacity: 0.6;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .zone,\n .button,\n .fieldFace,\n .tile,\n .overlay,\n .addTile {\n transition: none;\n }\n}\n","import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n type ChangeEvent,\n type DragEvent,\n type ReactNode,\n} from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { FormField, useFormFieldControl } from '../FormField';\nimport { fileKey, formatFileSize, isImage, matchesAccept, sameFile } from './fileUtils';\nimport { ImageCropper } from './ImageCropper';\nimport type { FileInputProps } from './FileInput.types';\nimport styles from './FileInput.module.css';\n\nconst canPreview = () => typeof URL !== 'undefined' && typeof URL.createObjectURL === 'function';\n\n/** A preview URL for an image file, or undefined when the environment cannot make one. */\nfunction createPreviewUrl(file: File): string | undefined {\n try {\n return URL.createObjectURL(file);\n } catch {\n return undefined;\n }\n}\n\nconst UploadIcon = ({ className }: { className?: string }) => (\n <svg\n className={className}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.6\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M12 16V4M7 9l5-5 5 5M4 16v3a1 1 0 001 1h14a1 1 0 001-1v-3\" />\n </svg>\n);\n\nconst ImageIcon = ({ className }: { className?: string }) => (\n <svg\n className={className}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.6\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <rect x=\"3\" y=\"4\" width=\"18\" height=\"16\" rx=\"2\" />\n <circle cx=\"9\" cy=\"10\" r=\"1.5\" />\n <path d=\"M21 16l-5-5-8 8\" />\n </svg>\n);\n\nconst FileIcon = ({ className }: { className?: string }) => (\n <svg\n className={className}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.6\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M7 3h7l5 5v12a1 1 0 01-1 1H7a1 1 0 01-1-1V4a1 1 0 011-1z\" />\n <path d=\"M14 3v5h5\" />\n </svg>\n);\n\nconst CloseIcon = () => (\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M6 6l8 8M14 6l-8 8\" />\n </svg>\n);\n\nconst FileInputControl = forwardRef<HTMLInputElement, Omit<FileInputProps, 'label' | 'helperText'>>(\n function FileInputControl(\n {\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n variant = 'dropzone',\n multiple: multipleProp,\n accept: acceptProp,\n maxSize,\n maxFiles,\n preview = true,\n shape = 'square',\n aspectRatio = 4 / 3,\n tileSize = 128,\n crop = true,\n cropOutputWidth,\n cropOutputType,\n cropOutputQuality,\n cropTitle,\n buttonLabel,\n placeholder = 'No file chosen',\n onFilesChange,\n className,\n ...rest\n },\n ref,\n ) {\n const control = useFormFieldControl({\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n });\n const baseId = useId();\n const hintId = `${baseId}-hint`;\n const rejectedId = `${baseId}-rejected`;\n\n const isImageVariant = variant === 'image' || variant === 'gallery';\n const multiple =\n variant === 'gallery' ? true : variant === 'image' ? false : (multipleProp ?? false);\n const accept = acceptProp ?? (isImageVariant ? 'image/*' : undefined);\n\n const inputRef = useRef<HTMLInputElement | null>(null);\n const setRef = useCallback(\n (node: HTMLInputElement | null) => {\n inputRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n },\n [ref],\n );\n\n const [files, setFiles] = useState<File[]>([]);\n const [rejected, setRejected] = useState<string[]>([]);\n const [dragging, setDragging] = useState(false);\n // A picked image waiting in the cropper (image variant). `theme` is the surrounding data-theme.\n const [cropping, setCropping] = useState<{ file: File; theme?: string } | null>(null);\n\n // Object URLs for image previews are created when files are added and released when they go.\n const [previews, setPreviews] = useState<Record<string, string>>({});\n const previewsRef = useRef<Record<string, string>>({});\n useEffect(\n () => () => {\n Object.values(previewsRef.current).forEach((url) => URL.revokeObjectURL(url));\n },\n [],\n );\n\n // Keep the native input's own file list equal to ours, so forms submit what is shown.\n const syncInput = (next: File[]) => {\n try {\n const transfer = new DataTransfer();\n next.forEach((file) => transfer.items.add(file));\n if (inputRef.current) inputRef.current.files = transfer.files;\n } catch {\n // DataTransfer is not available everywhere; the native selection stays as is.\n }\n };\n\n const update = (next: File[]) => {\n const nextPreviews: Record<string, string> = {};\n if (canPreview()) {\n for (const file of next) {\n const key = fileKey(file);\n const existing = previewsRef.current[key];\n if (existing) nextPreviews[key] = existing;\n else if (isImage(file)) {\n const url = createPreviewUrl(file);\n if (url) nextPreviews[key] = url;\n }\n }\n for (const [key, url] of Object.entries(previewsRef.current)) {\n if (!nextPreviews[key]) URL.revokeObjectURL(url);\n }\n }\n previewsRef.current = nextPreviews;\n setPreviews(nextPreviews);\n setFiles(next);\n syncInput(next);\n onFilesChange?.(next);\n };\n\n const addFiles = (incoming: File[]) => {\n if (control.disabled || incoming.length === 0) return;\n const problems: string[] = [];\n const accepted: File[] = [];\n for (const file of incoming) {\n if (!matchesAccept(file, accept)) problems.push(`${file.name}: file type not accepted`);\n else if (maxSize !== undefined && file.size > maxSize)\n problems.push(`${file.name}: larger than ${formatFileSize(maxSize)}`);\n else accepted.push(file);\n }\n\n // Image variant with cropping: hand the picked image to the cropper instead of using it directly.\n const picked = accepted[0];\n if (variant === 'image' && crop && picked && picked.type !== 'image/svg+xml') {\n setRejected(problems);\n setCropping({\n file: picked,\n theme: inputRef.current?.closest('[data-theme]')?.getAttribute('data-theme') ?? undefined,\n });\n return;\n }\n\n let next: File[];\n if (!multiple) {\n next = accepted.length > 0 ? [accepted[0] as File] : files;\n } else {\n next = [...files];\n for (const file of accepted) {\n if (!next.some((existing) => sameFile(existing, file))) next.push(file);\n }\n if (maxFiles !== undefined && next.length > maxFiles) {\n problems.push(`You can add up to ${maxFiles} files`);\n next = next.slice(0, maxFiles);\n }\n }\n setRejected(problems);\n const changed = next.length !== files.length || next.some((file, i) => file !== files[i]);\n if (changed) update(next);\n else syncInput(files);\n };\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n addFiles(Array.from(event.target.files ?? []));\n };\n\n const handleDrop = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setDragging(false);\n addFiles(Array.from(event.dataTransfer.files));\n };\n\n const removeFile = (file: File) => {\n setRejected([]);\n update(files.filter((existing) => existing !== file));\n };\n\n const hint = [\n accept\n ? `Accepted: ${accept\n .split(',')\n .map((t) => t.trim())\n .join(', ')}`\n : null,\n maxSize !== undefined ? `Max ${formatFileSize(maxSize)} each` : null,\n ]\n .filter(Boolean)\n .join(' · ');\n\n const describedBy =\n [\n control['aria-describedby'],\n hint ? hintId : undefined,\n rejected.length ? rejectedId : undefined,\n ]\n .filter(Boolean)\n .join(' ') || undefined;\n const invalid = control.invalid || rejected.length > 0;\n\n const openDialog = () => {\n if (!control.disabled) inputRef.current?.click();\n };\n const dropHandlers = {\n onDragEnter: (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n if (!control.disabled) setDragging(true);\n },\n onDragOver: (event: DragEvent<HTMLElement>) => event.preventDefault(),\n onDragLeave: (event: DragEvent<HTMLElement>) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node | null)) setDragging(false);\n },\n onDrop: handleDrop,\n };\n\n // The real input stays in the page (visually hidden but focusable), so keyboards and forms work.\n const input = (\n <input\n {...rest}\n ref={setRef}\n id={control.id}\n type=\"file\"\n multiple={multiple}\n accept={accept}\n required={control.required && files.length === 0}\n disabled={control.disabled}\n aria-invalid={invalid ? true : undefined}\n aria-describedby={describedBy}\n className={styles.input}\n onChange={handleChange}\n // The visible face forwards its clicks to the input; stop the input's own click from looping back.\n onClick={(event) => event.stopPropagation()}\n />\n );\n\n // Frame of the image variant: circles and squares are 1:1, rectangles use `aspectRatio`.\n const frameAspect = shape === 'rectangle' ? Math.max(0.2, aspectRatio) : 1;\n const tileHeight = Math.round(tileSize / frameAspect);\n const croppedWidth = cropOutputWidth ?? (shape === 'rectangle' ? 800 : 512);\n\n const state = cn(invalid && styles.invalid, control.disabled && styles.disabled);\n const names = files.map((file) => file.name).join(', ');\n const thumb = (file: File, className: string): ReactNode => {\n const url = previews[fileKey(file)];\n return url ? <img src={url} alt=\"\" className={className} /> : null;\n };\n\n const fileList =\n files.length > 0 ? (\n <ul className={styles.list} aria-label=\"Selected files\">\n {files.map((file) => (\n <li key={fileKey(file)} className={styles.item}>\n {preview && previews[fileKey(file)] ? (\n thumb(file, styles.itemThumb ?? '')\n ) : (\n <FileIcon className={styles.itemIcon} />\n )}\n <span className={styles.name}>{file.name}</span>\n <span className={styles.size}>{formatFileSize(file.size)}</span>\n <button\n type=\"button\"\n className={styles.remove}\n aria-label={`Remove ${file.name}`}\n disabled={control.disabled}\n onClick={() => removeFile(file)}\n >\n <CloseIcon />\n </button>\n </li>\n ))}\n </ul>\n ) : null;\n\n const hintText =\n hint && variant !== 'dropzone' ? (\n <span id={hintId} className={styles.hintText}>\n {hint}\n </span>\n ) : null;\n\n let body: ReactNode;\n if (variant === 'button') {\n body = (\n <>\n <div className={styles.buttonRow}>\n <div className={cn(styles.buttonFace, state)} onClick={openDialog}>\n {input}\n <span className={styles.button}>\n <UploadIcon className={styles.buttonIcon} />\n {buttonLabel ?? (multiple ? 'Choose files' : 'Choose file')}\n </span>\n </div>\n <span className={styles.summary}>{names || placeholder}</span>\n </div>\n {hintText}\n {fileList}\n </>\n );\n } else if (variant === 'field') {\n body = (\n <>\n <div className={cn(styles.fieldFace, state)} onClick={openDialog}>\n {input}\n <span className={cn(styles.fieldValue, !names && styles.fieldPlaceholder)}>\n {names || placeholder}\n </span>\n <span className={styles.browse}>Browse</span>\n </div>\n {hintText}\n {fileList}\n </>\n );\n } else if (variant === 'image') {\n const file = files[0];\n const url = file ? previews[fileKey(file)] : undefined;\n body = (\n <div className={styles.imageRoot}>\n <div\n className={cn(\n styles.tile,\n shape === 'circle' && styles.circle,\n dragging && styles.dragging,\n state,\n )}\n style={{ width: tileSize, height: tileHeight }}\n onClick={openDialog}\n {...dropHandlers}\n >\n {input}\n {url ? (\n <img src={url} alt={file?.name ?? ''} className={styles.tileImage} />\n ) : (\n <span className={styles.tileEmpty}>\n <ImageIcon className={styles.icon} />\n <span>{file ? file.name : 'Upload photo'}</span>\n </span>\n )}\n <span className={styles.overlay}>{file ? 'Change' : 'Choose'}</span>\n </div>\n <div className={styles.imageSide}>\n {file ? (\n <>\n <span className={styles.name}>{file.name}</span>\n <span className={styles.size}>{formatFileSize(file.size)}</span>\n <button\n type=\"button\"\n className={styles.removeText}\n disabled={control.disabled}\n onClick={() => removeFile(file)}\n >\n Remove image\n </button>\n </>\n ) : null}\n {hintText}\n </div>\n </div>\n );\n } else if (variant === 'gallery') {\n const full = maxFiles !== undefined && files.length >= maxFiles;\n body = (\n <>\n <ul className={styles.gallery} aria-label=\"Selected images\">\n {files.map((file) => (\n <li key={fileKey(file)} className={styles.thumbItem}>\n {previews[fileKey(file)] ? (\n thumb(file, styles.thumbImage ?? '')\n ) : (\n <span className={styles.thumbFallback}>\n <FileIcon className={styles.icon} />\n </span>\n )}\n <span className={styles.thumbName}>{file.name}</span>\n <button\n type=\"button\"\n className={cn(styles.remove, styles.thumbRemove)}\n aria-label={`Remove ${file.name}`}\n disabled={control.disabled}\n onClick={() => removeFile(file)}\n >\n <CloseIcon />\n </button>\n </li>\n ))}\n {full ? null : (\n <li className={styles.addItem}>\n <div\n className={cn(styles.addTile, dragging && styles.dragging, state)}\n onClick={openDialog}\n {...dropHandlers}\n >\n {input}\n <ImageIcon className={styles.icon} />\n <span>Add images</span>\n </div>\n </li>\n )}\n </ul>\n {full ? input : null}\n {hintText}\n </>\n );\n } else {\n body = (\n <>\n <div\n className={cn(styles.zone, dragging && styles.dragging, state)}\n onClick={openDialog}\n {...dropHandlers}\n >\n {input}\n <UploadIcon className={styles.icon} />\n <span className={styles.prompt}>\n <span className={styles.browseLink}>\n {multiple ? 'Choose files' : 'Choose a file'}\n </span>{' '}\n or drag and drop\n </span>\n {hint ? (\n <span id={hintId} className={styles.hint}>\n {hint}\n </span>\n ) : null}\n </div>\n {fileList}\n </>\n );\n }\n\n return (\n <div className={cn(styles.root, className)}>\n {body}\n {cropping ? (\n <ImageCropper\n file={cropping.file}\n aspect={frameAspect}\n shape={shape === 'circle' ? 'circle' : 'rect'}\n outputWidth={croppedWidth}\n outputType={\n cropOutputType ??\n (['image/png', 'image/jpeg', 'image/webp'].includes(cropping.file.type)\n ? (cropping.file.type as 'image/png' | 'image/jpeg' | 'image/webp')\n : 'image/png')\n }\n outputQuality={cropOutputQuality}\n title={cropTitle}\n theme={cropping.theme}\n onApply={(cropped) => {\n setCropping(null);\n update([cropped]);\n inputRef.current?.focus({ preventScroll: true });\n }}\n onCancel={() => {\n setCropping(null);\n // The browser's own file list still holds the picked image; put ours back.\n syncInput(files);\n inputRef.current?.focus({ preventScroll: true });\n }}\n />\n ) : null}\n {rejected.length > 0 ? (\n <p id={rejectedId} className={styles.rejected} role=\"alert\">\n {rejected.join('. ')}\n </p>\n ) : null}\n </div>\n );\n },\n);\n\n/**\n * File picker in five looks (`variant`): drag-and-drop zone, button, input-like field, single image\n * tile and image gallery. Files are checked against `accept`, `maxSize` and `maxFiles`.\n */\nexport const FileInput = forwardRef<HTMLInputElement, FileInputProps>(function FileInput(\n { label, helperText, ...props },\n ref,\n) {\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n // Without its own label/helper/error, FileInput defers to an enclosing <FormField>.\n if (!label && !helperText && !props.error) {\n return <FileInputControl {...props} ref={ref} />;\n }\n\n return (\n <FormField\n id={props.id}\n label={label}\n helperText={helperText}\n error={props.error}\n required={props.required}\n disabled={props.disabled}\n >\n <FileInputControl {...props} ref={ref} />\n </FormField>\n );\n});\n","/** Tags kept as-is. Anything else is unwrapped (its text and children stay) unless it is in `DROP`. */\nconst ALLOWED = new Set([\n 'p',\n 'div',\n 'br',\n 'strong',\n 'b',\n 'em',\n 'i',\n 'u',\n 's',\n 'ul',\n 'ol',\n 'li',\n 'blockquote',\n 'a',\n]);\n/** Removed together with their content. */\nconst DROP = new Set(['script', 'style', 'iframe', 'object', 'embed', 'template', 'noscript']);\nconst SAFE_HREF = /^(https?:|mailto:|tel:|\\/|#)/i;\n\nfunction unwrap(parent: Node, el: Element) {\n while (el.firstChild) parent.insertBefore(el.firstChild, el);\n parent.removeChild(el);\n}\n\nfunction clean(node: Node): void {\n for (const child of Array.from(node.childNodes)) {\n if (child.nodeType === Node.COMMENT_NODE) {\n node.removeChild(child);\n } else if (child.nodeType === Node.ELEMENT_NODE) {\n const el = child as Element;\n const tag = el.tagName.toLowerCase();\n if (DROP.has(tag)) {\n node.removeChild(el);\n continue;\n }\n clean(el);\n if (!ALLOWED.has(tag)) {\n unwrap(node, el);\n continue;\n }\n const href = tag === 'a' ? (el.getAttribute('href') ?? '').trim() : '';\n for (const attr of Array.from(el.attributes)) el.removeAttribute(attr.name);\n if (tag === 'a') {\n if (SAFE_HREF.test(href)) {\n el.setAttribute('href', href);\n el.setAttribute('target', '_blank');\n el.setAttribute('rel', 'noopener noreferrer');\n } else {\n unwrap(node, el);\n }\n }\n }\n }\n}\n\n/** Reduces HTML to a small allowlist of formatting tags, with no attributes except safe links. */\nexport function sanitizeHtml(html: string): string {\n if (!html) return '';\n const doc = new DOMParser().parseFromString(html, 'text/html');\n clean(doc.body);\n return doc.body.innerHTML;\n}\n\n/** True when the HTML has no text and no list structure worth keeping. */\nexport function isEmptyHtml(html: string): boolean {\n if (!html) return true;\n const doc = new DOMParser().parseFromString(html, 'text/html');\n return (doc.body.textContent ?? '').trim() === '' && !doc.body.querySelector('li');\n}\n",".textarea {\n display: block;\n box-sizing: border-box;\n width: 100%;\n min-height: var(--cui-control-height-md);\n padding: var(--cui-space-2) var(--cui-space-4);\n background-color: var(--cui-color-surface);\n border: var(--cui-control-border-width) solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-sm);\n line-height: var(--cui-line-height);\n transition:\n border-color var(--cui-transition-fast),\n box-shadow var(--cui-transition-fast);\n}\n\n.textarea::placeholder {\n color: var(--cui-color-placeholder);\n}\n\n.textarea:hover:not(:disabled):not(.invalid):not(:focus) {\n border-color: var(--cui-color-border-hover);\n}\n\n.textarea:focus {\n border-color: var(--cui-color-border-focus);\n outline: none;\n box-shadow: var(--cui-focus-ring);\n}\n\n.resize-none {\n resize: none;\n}\n.resize-vertical {\n resize: vertical;\n}\n.resize-horizontal {\n resize: horizontal;\n}\n.resize-both {\n resize: both;\n}\n\n.invalid {\n border-color: var(--cui-color-danger-border);\n}\n.invalid:hover:not(:disabled):not(:focus) {\n border-color: var(--cui-color-danger-border-hover);\n}\n.invalid:focus {\n border-color: var(--cui-color-danger-border-hover);\n box-shadow: var(--cui-focus-ring-danger);\n}\n\n.readOnly {\n background-color: var(--cui-color-surface-secondary);\n}\n\n.textarea:disabled {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n resize: none;\n}\n\n/* ---------- type=\"rich\" ---------- */\n.rich {\n box-sizing: border-box;\n width: 100%;\n background-color: var(--cui-color-surface);\n border: var(--cui-control-border-width) solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-sm);\n line-height: var(--cui-line-height);\n transition:\n border-color var(--cui-transition-fast),\n box-shadow var(--cui-transition-fast);\n}\n.rich:hover:not(.invalid):not(.richDisabled):not(:focus-within) {\n border-color: var(--cui-color-border-hover);\n}\n.rich:focus-within {\n border-color: var(--cui-color-border-focus);\n box-shadow: var(--cui-focus-ring);\n}\n.rich.invalid:focus-within {\n border-color: var(--cui-color-danger-border-hover);\n box-shadow: var(--cui-focus-ring-danger);\n}\n.richDisabled {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n\n.toolbar {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--cui-space-1);\n padding: var(--cui-space-1) var(--cui-space-2);\n border-bottom: var(--cui-control-border-width) solid var(--cui-color-border);\n}\n.tool {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 1.75rem;\n height: 1.75rem;\n padding: 0;\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-md);\n color: var(--cui-color-text-secondary);\n cursor: pointer;\n transition:\n background-color var(--cui-transition-fast),\n color var(--cui-transition-fast);\n}\n.tool svg {\n width: 1rem;\n height: 1rem;\n}\n.tool:hover:not(:disabled) {\n background-color: var(--cui-color-surface-secondary);\n}\n.toolActive,\n.toolActive:hover:not(:disabled) {\n background-color: var(--cui-color-primary-subtle);\n color: var(--cui-color-primary);\n}\n.tool:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 1px;\n}\n.tool:disabled {\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n\n.editor {\n box-sizing: border-box;\n padding: var(--cui-space-2) var(--cui-space-4);\n overflow: auto;\n outline: none;\n overflow-wrap: anywhere;\n}\n.editor[data-empty='true']::before {\n content: attr(data-placeholder);\n color: var(--cui-color-placeholder);\n pointer-events: none;\n float: inline-start;\n height: 0;\n}\n.editor p,\n.editor div {\n margin: 0;\n}\n.editor ul,\n.editor ol {\n margin: var(--cui-space-1) 0;\n padding-inline-start: 1.5rem;\n}\n.editor blockquote {\n margin: var(--cui-space-1) 0;\n padding-inline-start: var(--cui-space-3);\n border-inline-start: 3px solid var(--cui-color-border);\n color: var(--cui-color-text-secondary);\n}\n.editor a {\n color: var(--cui-color-primary);\n text-decoration: underline;\n}\n","import { useCallback, useEffect, useLayoutEffect, useRef, useState, type ReactNode } from 'react';\nimport { cn } from '../../utils/cn';\nimport { useFormFieldControl } from '../FormField';\nimport { isEmptyHtml, sanitizeHtml } from './sanitizeHtml';\nimport type { TextareaProps } from './Textarea.types';\nimport styles from './Textarea.module.css';\n\ntype Command = 'bold' | 'italic' | 'underline' | 'insertUnorderedList' | 'insertOrderedList';\n\nconst icon = (path: ReactNode) => (\n <svg\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.8\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n {path}\n </svg>\n);\n\nconst TOOLS: { command: Command; label: string; icon: ReactNode }[] = [\n {\n command: 'bold',\n label: 'Bold',\n icon: icon(<path d=\"M6 4h5a3 3 0 010 6H6zM6 10h6a3 3 0 010 6H6z\" />),\n },\n { command: 'italic', label: 'Italic', icon: icon(<path d=\"M8 4h6M6 16h6M11 4l-2 12\" />) },\n {\n command: 'underline',\n label: 'Underline',\n icon: icon(<path d=\"M6 4v6a4 4 0 008 0V4M5 17h10\" />),\n },\n {\n command: 'insertUnorderedList',\n label: 'Bulleted list',\n icon: icon(<path d=\"M8 5h9M8 10h9M8 15h9M3.5 5h.01M3.5 10h.01M3.5 15h.01\" />),\n },\n {\n command: 'insertOrderedList',\n label: 'Numbered list',\n icon: icon(<path d=\"M9 5h8M9 10h8M9 15h8M3.5 4.5l1-.5v3M3 11.5h2L3 14h2\" />),\n },\n];\n\nconst LINK_ICON = icon(\n <path d=\"M8.5 11.5a3 3 0 004.2 0l2.3-2.3a3 3 0 00-4.2-4.2l-.8.8M11.5 8.5a3 3 0 00-4.2 0L5 10.8a3 3 0 004.2 4.2l.8-.8\" />,\n);\nconst CLEAR_ICON = icon(<path d=\"M5 5h10M10 5l-2 10M7 15h4M4 16l12-12\" />);\n\nfunction canExec() {\n return typeof document.execCommand === 'function';\n}\nfunction queryState(command: Command) {\n try {\n return typeof document.queryCommandState === 'function' && document.queryCommandState(command);\n } catch {\n return false;\n }\n}\n\nconst toHtml = (v: unknown) => sanitizeHtml(typeof v === 'string' ? v : '');\nconst normalize = (html: string) => (isEmptyHtml(html) ? '' : html);\n\n/** `Textarea type=\"rich\"`: a contenteditable editor with a small formatting toolbar. The value is sanitized HTML. */\nexport function RichTextControl({\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n 'aria-label': ariaLabel,\n rows = 3,\n resize = 'vertical',\n readOnly,\n className,\n name,\n placeholder,\n value,\n defaultValue,\n onValueChange,\n}: Omit<TextareaProps, 'label' | 'helperText' | 'type'>) {\n const control = useFormFieldControl({\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n });\n const editorRef = useRef<HTMLDivElement>(null);\n const lastHtml = useRef<string | null>(null);\n const [html, setHtml] = useState(() => normalize(toHtml(value ?? defaultValue)));\n const [active, setActive] = useState<Partial<Record<Command, boolean>>>({});\n const editable = !control.disabled && !readOnly;\n\n // Put the value into the editor on mount, and again whenever a controlled value changes from outside.\n useLayoutEffect(() => {\n const incoming = value ?? (lastHtml.current === null ? defaultValue : undefined);\n if (typeof incoming !== 'string') return;\n const next = toHtml(incoming);\n if (editorRef.current && next !== lastHtml.current) {\n editorRef.current.innerHTML = next;\n lastHtml.current = next;\n setHtml(normalize(next));\n }\n // `defaultValue` only matters on mount.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [value]);\n\n const emit = useCallback(() => {\n const el = editorRef.current;\n if (!el) return;\n const next = sanitizeHtml(el.innerHTML);\n lastHtml.current = next;\n setHtml(normalize(next));\n onValueChange?.(normalize(next));\n }, [onValueChange]);\n\n const refreshActive = useCallback(() => {\n const el = editorRef.current;\n const anchor = document.getSelection()?.anchorNode;\n if (!el || !anchor || !el.contains(anchor)) return;\n setActive({\n bold: queryState('bold'),\n italic: queryState('italic'),\n underline: queryState('underline'),\n insertUnorderedList: queryState('insertUnorderedList'),\n insertOrderedList: queryState('insertOrderedList'),\n });\n }, []);\n\n useEffect(() => {\n document.addEventListener('selectionchange', refreshActive);\n return () => document.removeEventListener('selectionchange', refreshActive);\n }, [refreshActive]);\n\n const run = (command: string, arg?: string) => {\n if (!editable || !canExec()) return;\n editorRef.current?.focus();\n document.execCommand(command, false, arg);\n emit();\n refreshActive();\n };\n\n const addLink = () => {\n if (!editable) return;\n const url = window.prompt('Link address (https://...)');\n if (url?.trim()) run('createLink', url.trim());\n };\n\n // Keep the toolbar from stealing the text selection when a button is pressed.\n const keepSelection = (event: { preventDefault: () => void }) => event.preventDefault();\n\n return (\n <div\n className={cn(\n styles.rich,\n control.invalid && styles.invalid,\n !editable && styles.richDisabled,\n className,\n )}\n >\n <div role=\"toolbar\" aria-label=\"Formatting\" className={styles.toolbar}>\n {TOOLS.map((tool) => (\n <button\n key={tool.command}\n type=\"button\"\n className={cn(styles.tool, active[tool.command] && styles.toolActive)}\n aria-label={tool.label}\n title={tool.label}\n aria-pressed={Boolean(active[tool.command])}\n disabled={!editable}\n onMouseDown={keepSelection}\n onClick={() => run(tool.command)}\n >\n {tool.icon}\n </button>\n ))}\n <button\n type=\"button\"\n className={styles.tool}\n aria-label=\"Link\"\n title=\"Link\"\n disabled={!editable}\n onMouseDown={keepSelection}\n onClick={addLink}\n >\n {LINK_ICON}\n </button>\n <button\n type=\"button\"\n className={styles.tool}\n aria-label=\"Clear formatting\"\n title=\"Clear formatting\"\n disabled={!editable}\n onMouseDown={keepSelection}\n onClick={() => run('removeFormat')}\n >\n {CLEAR_ICON}\n </button>\n </div>\n <div\n ref={editorRef}\n id={control.id}\n role=\"textbox\"\n aria-multiline=\"true\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabel ? undefined : control.labelId}\n aria-required={control.required || undefined}\n aria-invalid={control['aria-invalid']}\n aria-describedby={control['aria-describedby']}\n aria-disabled={control.disabled || undefined}\n aria-readonly={readOnly || undefined}\n contentEditable={editable}\n suppressContentEditableWarning\n tabIndex={control.disabled ? -1 : 0}\n data-placeholder={placeholder}\n data-empty={html === '' ? 'true' : undefined}\n className={cn(styles.editor, styles[`resize-${resize}`])}\n style={{ minHeight: `calc(${rows} * 1lh + var(--cui-space-4))` }}\n onInput={emit}\n onKeyUp={refreshActive}\n onMouseUp={refreshActive}\n onPaste={(event) => {\n // Paste as plain text so foreign styling and markup never get in.\n if (!editable || !canExec()) return;\n event.preventDefault();\n document.execCommand('insertText', false, event.clipboardData.getData('text/plain'));\n }}\n />\n {name ? <input type=\"hidden\" name={name} value={html} /> : null}\n </div>\n );\n}\n","import { forwardRef } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { FormField, useFormFieldControl } from '../FormField';\nimport { RichTextControl } from './RichTextControl';\nimport type { TextareaProps } from './Textarea.types';\nimport styles from './Textarea.module.css';\n\nconst TextareaControl = forwardRef<\n HTMLTextAreaElement,\n Omit<TextareaProps, 'label' | 'helperText'>\n>(function TextareaControl(\n {\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n rows = 3,\n resize = 'vertical',\n readOnly,\n className,\n ...rest\n },\n ref,\n) {\n const control = useFormFieldControl({\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n });\n\n return (\n <textarea\n {...rest}\n ref={ref}\n id={control.id}\n rows={rows}\n required={control.required}\n disabled={control.disabled}\n readOnly={readOnly}\n aria-invalid={control['aria-invalid']}\n aria-describedby={control['aria-describedby']}\n className={cn(\n styles.textarea,\n styles[`resize-${resize}`],\n control.invalid && styles.invalid,\n readOnly && styles.readOnly,\n className,\n )}\n />\n );\n});\n\n/**\n * Multi-line text input with the same label, helper and error handling as `Input`.\n * Use `type=\"rich\"` for a formatting editor that works with HTML.\n */\nexport const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(function Textarea(\n { label, helperText, ...props },\n ref,\n) {\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n const { type, onValueChange, ...controlProps } = props;\n const control =\n type === 'rich' ? (\n <RichTextControl {...controlProps} onValueChange={onValueChange} />\n ) : (\n <TextareaControl {...controlProps} ref={ref} />\n );\n\n // Without its own label/helper/error, Textarea defers to an enclosing <FormField>.\n if (!label && !helperText && !props.error) return control;\n\n return (\n <FormField\n id={props.id}\n label={label}\n helperText={helperText}\n error={props.error}\n required={props.required}\n disabled={props.disabled}\n >\n {control}\n </FormField>\n );\n});\n",".root {\n display: flex;\n flex-direction: column;\n gap: var(--cui-space-1);\n}\n\n.label {\n position: relative;\n display: inline-flex;\n align-items: center;\n gap: var(--cui-space-3);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-sm);\n line-height: var(--cui-line-height);\n color: var(--cui-color-text);\n cursor: pointer;\n}\n\n.disabled {\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n\n.input {\n position: absolute;\n top: 0;\n left: 0;\n width: 2.75rem;\n height: 1.5rem;\n margin: 0;\n opacity: 0;\n cursor: inherit;\n}\n\n.track {\n position: relative;\n flex-shrink: 0;\n box-sizing: border-box;\n width: 2.75rem;\n height: 1.5rem;\n background-color: var(--cui-color-text-disabled);\n border-radius: var(--cui-radius-full);\n transition:\n background-color var(--cui-transition-fast),\n box-shadow var(--cui-transition-fast);\n}\n\n.thumb {\n position: absolute;\n top: 2px;\n inset-inline-start: 2px;\n width: 1.25rem;\n height: 1.25rem;\n background-color: var(--cui-color-white);\n border-radius: var(--cui-radius-full);\n box-shadow: var(--cui-shadow-sm);\n transition: transform var(--cui-transition-fast);\n}\n\n.input:checked + .track {\n background-color: var(--cui-color-primary);\n}\n.input:checked + .track .thumb {\n transform: translateX(1.25rem);\n}\n.input:checked + .track .thumb:dir(rtl) {\n transform: translateX(-1.25rem);\n}\n\n.input:focus-visible + .track {\n box-shadow: var(--cui-focus-ring);\n}\n\n.input.invalid + .track {\n box-shadow: 0 0 0 2px var(--cui-color-danger-border);\n}\n.input.invalid:focus-visible + .track {\n box-shadow: var(--cui-focus-ring-danger);\n}\n\n.input:disabled + .track {\n opacity: 0.5;\n}\n\n.required {\n margin-inline-start: var(--cui-space-1);\n color: var(--cui-color-danger);\n}\n\n.message {\n margin: 0;\n padding-inline-start: calc(2.75rem + var(--cui-space-3));\n font-size: var(--cui-font-size-xs);\n}\n.helper {\n color: var(--cui-color-text-muted);\n}\n.error {\n color: var(--cui-color-danger);\n}\n\n@media (prefers-reduced-motion: reduce) {\n .track,\n .thumb {\n transition: none;\n }\n}\n","import { forwardRef } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { useFormFieldControl } from '../FormField';\nimport type { SwitchProps } from './Switch.types';\nimport styles from './Switch.module.css';\n\n/** On/off toggle. A native checkbox with `role=\"switch\"`, so it works in forms and with keyboards. */\nexport const Switch = forwardRef<HTMLInputElement, SwitchProps>(function Switch(\n {\n label,\n helperText,\n error,\n id,\n required,\n disabled,\n 'aria-describedby': ariaDescribedBy,\n className,\n ...rest\n },\n ref,\n) {\n const control = useFormFieldControl({\n id,\n required,\n disabled,\n error,\n 'aria-describedby': ariaDescribedBy,\n });\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n const messageId = `${control.id}-message`;\n const hasMessage = Boolean(error || helperText);\n const describedBy =\n [control['aria-describedby'], hasMessage ? messageId : undefined].filter(Boolean).join(' ') ||\n undefined;\n\n return (\n <div className={cn(styles.root, className)}>\n <label className={cn(styles.label, control.disabled && styles.disabled)}>\n <input\n {...rest}\n ref={ref}\n id={control.id}\n type=\"checkbox\"\n role=\"switch\"\n required={control.required}\n disabled={control.disabled}\n aria-invalid={control['aria-invalid']}\n aria-describedby={describedBy}\n className={cn(styles.input, control.invalid && styles.invalid)}\n />\n <span className={styles.track} aria-hidden=\"true\">\n <span className={styles.thumb} />\n </span>\n {label ? (\n <span className={styles.text}>\n {label}\n {control.required ? (\n <span className={styles.required} aria-hidden=\"true\">\n *\n </span>\n ) : null}\n </span>\n ) : null}\n </label>\n {hasMessage ? (\n <p\n id={messageId}\n className={cn(styles.message, error ? styles.error : styles.helper)}\n role={error ? 'alert' : undefined}\n >\n {error || helperText}\n </p>\n ) : null}\n </div>\n );\n});\n",".root {\n --badge-color: var(--cui-color-text-secondary);\n display: inline-flex;\n align-items: center;\n gap: 0.375rem;\n box-sizing: border-box;\n padding: 2px 10px;\n border: 1px solid color-mix(in srgb, var(--badge-color) 25%, transparent);\n border-radius: var(--cui-radius-full);\n background-color: color-mix(in srgb, var(--badge-color) 10%, transparent);\n color: var(--badge-color);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-xs);\n font-weight: var(--cui-font-weight-semibold);\n line-height: var(--cui-line-height);\n white-space: nowrap;\n}\n\n.dot {\n width: 0.375rem;\n height: 0.375rem;\n border-radius: var(--cui-radius-full);\n background-color: var(--badge-color);\n}\n\n.neutral {\n --badge-color: var(--cui-color-text-secondary);\n}\n.primary {\n --badge-color: var(--cui-color-primary);\n}\n.success {\n --badge-color: var(--cui-color-success);\n}\n.warning {\n --badge-color: var(--cui-color-warning);\n}\n.danger {\n --badge-color: var(--cui-color-danger);\n}\n.info {\n --badge-color: var(--cui-color-info);\n}\n","import { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport type { BadgeProps } from './Badge.types';\nimport styles from './Badge.module.css';\n\n/** Small pill for statuses and counts. */\nexport function Badge({\n color = 'neutral',\n dot = false,\n className,\n children,\n ...rest\n}: BadgeProps) {\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n return (\n <span {...rest} className={cn(styles.root, styles[color], className)}>\n {dot ? <span className={styles.dot} aria-hidden=\"true\" /> : null}\n {children}\n </span>\n );\n}\n",".root {\n min-width: 0;\n}\n\n.list {\n position: relative;\n display: flex;\n align-items: center;\n gap: var(--cui-space-6);\n overflow-x: auto;\n border-bottom: 1px solid var(--cui-color-border);\n}\n\n.tab {\n position: relative;\n display: inline-flex;\n align-items: center;\n gap: var(--cui-space-2);\n padding: var(--cui-space-1) var(--cui-space-2) var(--cui-space-3);\n margin-inline: calc(var(--cui-space-2) * -1);\n background: transparent;\n border: 0;\n color: var(--cui-color-text-muted);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-sm);\n font-weight: var(--cui-font-weight-medium);\n white-space: nowrap;\n cursor: pointer;\n border-radius: var(--cui-radius-sm) var(--cui-radius-sm) 0 0;\n transition:\n color var(--cui-transition-fast),\n background-color var(--cui-transition-fast),\n transform var(--cui-transition-fast);\n}\n\n.tab:active:not(:disabled) {\n transform: translateY(1px);\n}\n\n/* Sliding underline that follows the selected tab. */\n.indicator {\n position: absolute;\n bottom: -1px;\n height: 2px;\n border-radius: 2px 2px 0 0;\n background-color: var(--cui-color-primary);\n pointer-events: none;\n}\n.indicatorAnimated {\n transition:\n left 0.28s cubic-bezier(0.4, 0, 0.2, 1),\n width 0.28s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.tab:hover:not(:disabled) {\n color: var(--cui-color-text-secondary);\n background-color: rgb(100 116 139 / 0.08);\n}\n\n.selected,\n.selected:hover:not(:disabled) {\n color: var(--cui-color-primary);\n}\n\n.tab:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 2px;\n border-radius: var(--cui-radius-sm);\n}\n\n.tab:disabled {\n color: var(--cui-color-text-disabled);\n cursor: not-allowed;\n}\n\n.icon {\n display: inline-flex;\n width: 1rem;\n height: 1rem;\n}\n.icon > svg {\n width: 100%;\n height: 100%;\n}\n\n.panel {\n padding-top: var(--cui-space-4);\n outline: none;\n animation: cui-tabs-panel-in 0.25s ease-out;\n}\n\n@keyframes cui-tabs-panel-in {\n from {\n opacity: 0;\n transform: translateY(6px);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .tab,\n .indicatorAnimated {\n transition: none;\n }\n .tab:active:not(:disabled) {\n transform: none;\n }\n .panel {\n animation: none;\n }\n}\n.panel:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 2px;\n border-radius: var(--cui-radius-sm);\n}\n","import { useEffect, useId, useLayoutEffect, useRef, useState, type KeyboardEvent } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport type { TabsProps } from './Tabs.types';\nimport styles from './Tabs.module.css';\n\n/**\n * Underlined tabs following the WAI-ARIA tabs pattern: arrow keys, Home and End\n * move between tabs; the active tab's panel is shown below the list.\n */\nexport function Tabs<T extends string = string>({\n items,\n value,\n defaultValue,\n onValueChange,\n className,\n 'aria-label': ariaLabel,\n ...rest\n}: TabsProps<T>) {\n const baseId = useId();\n const tabRefs = useRef<(HTMLButtonElement | null)[]>([]);\n const firstEnabled = items.find((item) => !item.disabled)?.value;\n const [internal, setInternal] = useState<T | undefined>(defaultValue ?? firstEnabled);\n const listRef = useRef<HTMLDivElement>(null);\n const [indicator, setIndicator] = useState<{ left: number; width: number; animate: boolean }>();\n const licensed = useLicensed();\n\n const active = value ?? internal;\n const activeIndex = items.findIndex((item) => item.value === active);\n const activeItem = items[activeIndex];\n\n // Slide the underline to the selected tab. The first measurement is placed without animating.\n useLayoutEffect(() => {\n const tab = tabRefs.current[activeIndex];\n if (!tab) {\n setIndicator(undefined);\n return;\n }\n const measure = () =>\n setIndicator((prev) => {\n const left = tab.offsetLeft;\n const width = tab.offsetWidth;\n if (prev && prev.left === left && prev.width === width) return prev;\n return { left, width, animate: prev !== undefined };\n });\n measure();\n if (typeof ResizeObserver === 'undefined' || !listRef.current) return;\n const observer = new ResizeObserver(measure);\n observer.observe(listRef.current);\n observer.observe(tab);\n return () => observer.disconnect();\n }, [activeIndex, items.length, licensed]);\n\n // Keep the selected tab visible when the list scrolls horizontally.\n useEffect(() => {\n tabRefs.current[activeIndex]?.scrollIntoView?.({ block: 'nearest', inline: 'nearest' });\n }, [activeIndex]);\n\n if (!licensed) return <UnlicensedNotice />;\n\n const select = (next: T) => {\n if (value === undefined) setInternal(next);\n onValueChange?.(next);\n };\n\n const move = (from: number, direction: 1 | -1 | 'first' | 'last') => {\n const count = items.length;\n let index = direction === 'first' ? -1 : direction === 'last' ? count : from;\n const step = direction === 'first' ? 1 : direction === 'last' ? -1 : direction;\n for (let i = 0; i < count; i++) {\n index = (index + step + count) % count;\n const item = items[index];\n if (item && !item.disabled) {\n select(item.value);\n tabRefs.current[index]?.focus();\n return;\n }\n }\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLButtonElement>, index: number) => {\n const rtl = getComputedStyle(event.currentTarget).direction === 'rtl';\n const next = rtl ? 'ArrowLeft' : 'ArrowRight';\n const previous = rtl ? 'ArrowRight' : 'ArrowLeft';\n if (event.key === next) move(index, 1);\n else if (event.key === previous) move(index, -1);\n else if (event.key === 'Home') move(index, 'first');\n else if (event.key === 'End') move(index, 'last');\n else return;\n event.preventDefault();\n };\n\n const tabId = (index: number) => `${baseId}-tab-${index}`;\n const panelId = (index: number) => `${baseId}-panel-${index}`;\n\n return (\n <div {...rest} className={cn(styles.root, className)}>\n <div ref={listRef} role=\"tablist\" aria-label={ariaLabel} className={styles.list}>\n {items.map((item, index) => {\n const selected = index === activeIndex;\n return (\n <button\n key={item.value}\n ref={(node) => {\n tabRefs.current[index] = node;\n }}\n id={tabId(index)}\n type=\"button\"\n role=\"tab\"\n aria-selected={selected}\n aria-controls={selected && item.content !== undefined ? panelId(index) : undefined}\n tabIndex={selected ? 0 : -1}\n disabled={item.disabled}\n className={cn(styles.tab, selected && styles.selected)}\n onClick={() => select(item.value)}\n onKeyDown={(event) => handleKeyDown(event, index)}\n >\n {item.icon ? (\n <span className={styles.icon} aria-hidden=\"true\">\n {item.icon}\n </span>\n ) : null}\n {item.label}\n </button>\n );\n })}\n {indicator ? (\n <span\n aria-hidden=\"true\"\n className={cn(styles.indicator, indicator.animate && styles.indicatorAnimated)}\n style={{ left: indicator.left, width: indicator.width }}\n />\n ) : null}\n </div>\n {activeItem && activeItem.content !== undefined ? (\n <div\n key={activeItem.value}\n role=\"tabpanel\"\n id={panelId(activeIndex)}\n aria-labelledby={tabId(activeIndex)}\n tabIndex={0}\n className={styles.panel}\n >\n {activeItem.content}\n </div>\n ) : null}\n </div>\n );\n}\n",".root {\n min-width: 0;\n}\n\n.header {\n display: flex;\n align-items: center;\n gap: var(--cui-space-4);\n margin-bottom: var(--cui-space-4);\n}\n\n.heading {\n flex-shrink: 0;\n}\n\n.title {\n margin: 0;\n font-size: var(--cui-font-size-sm);\n font-weight: var(--cui-font-weight-semibold);\n line-height: var(--cui-line-height);\n color: var(--cui-color-text);\n}\n\n.subtitle {\n margin: 2px 0 0;\n font-size: var(--cui-font-size-xs);\n color: var(--cui-color-text-muted);\n}\n\n.divider {\n flex: 1;\n height: 1px;\n background: linear-gradient(to right, var(--cui-color-border), transparent);\n}\n\n.fields {\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n gap: var(--cui-space-6);\n}\n\n@media (min-width: 768px) {\n .columns2 {\n grid-template-columns: repeat(2, minmax(0, 1fr));\n }\n .columns3 {\n grid-template-columns: repeat(3, minmax(0, 1fr));\n }\n}\n","import { createElement, useId } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport type { FormSectionProps } from './FormSection.types';\nimport styles from './FormSection.module.css';\n\n/**\n * A titled group of form fields: heading + optional subtitle, a divider line,\n * then the fields in a grid. Use it to split long forms into readable sections.\n */\nexport function FormSection({\n title,\n subtitle,\n children,\n columns = 1,\n headingLevel = 3,\n className,\n ...rest\n}: FormSectionProps) {\n const headingId = useId();\n const hasHeader = Boolean(title || subtitle);\n\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n return (\n <section\n {...rest}\n aria-labelledby={title ? headingId : rest['aria-labelledby']}\n className={cn(styles.root, className)}\n >\n {hasHeader ? (\n <div className={styles.header}>\n <div className={styles.heading}>\n {title\n ? createElement(`h${headingLevel}`, { id: headingId, className: styles.title }, title)\n : null}\n {subtitle ? <p className={styles.subtitle}>{subtitle}</p> : null}\n </div>\n <span className={styles.divider} aria-hidden=\"true\" />\n </div>\n ) : null}\n <div className={cn(styles.fields, styles[`columns${columns}`])}>{children}</div>\n </section>\n );\n}\n",".root {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n overflow: hidden;\n box-sizing: border-box;\n border-radius: var(--cui-radius-full);\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text-secondary);\n font-family: var(--cui-font-family);\n font-weight: var(--cui-font-weight-semibold);\n line-height: 1;\n user-select: none;\n}\n\n.xs {\n width: 1.75rem;\n height: 1.75rem;\n font-size: 0.6875rem;\n}\n.sm {\n width: 2rem;\n height: 2rem;\n font-size: var(--cui-font-size-xs);\n}\n.md {\n width: 2.5rem;\n height: 2.5rem;\n font-size: var(--cui-font-size-sm);\n}\n.lg {\n width: 3rem;\n height: 3rem;\n font-size: var(--cui-font-size-md);\n}\n.xl {\n width: 4rem;\n height: 4rem;\n font-size: var(--cui-font-size-xl);\n}\n\n.image {\n width: 100%;\n height: 100%;\n object-fit: cover;\n}\n\n.fallback {\n width: 60%;\n height: 60%;\n}\n\n/* Name-derived tones (translucent token colors work in light and dark) */\n.tone0 {\n background-color: color-mix(in srgb, var(--cui-color-primary) 16%, transparent);\n color: var(--cui-color-primary);\n}\n.tone1 {\n background-color: color-mix(in srgb, var(--cui-color-info) 16%, transparent);\n color: var(--cui-color-info);\n}\n.tone2 {\n background-color: color-mix(in srgb, var(--cui-color-success) 16%, transparent);\n color: var(--cui-color-success);\n}\n.tone3 {\n background-color: color-mix(in srgb, var(--cui-color-warning) 16%, transparent);\n color: var(--cui-color-warning);\n}\n.tone4 {\n background-color: color-mix(in srgb, var(--cui-color-danger) 16%, transparent);\n color: var(--cui-color-danger);\n}\n\n.primary {\n background: linear-gradient(\n to bottom right,\n var(--cui-color-primary),\n color-mix(in srgb, var(--cui-color-primary) 70%, transparent)\n );\n color: var(--cui-color-on-primary);\n}\n","import { useState } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport type { AvatarProps } from './Avatar.types';\nimport styles from './Avatar.module.css';\n\nconst TONES = [styles.tone0, styles.tone1, styles.tone2, styles.tone3, styles.tone4];\n\nexport function getInitials(name?: string | null): string {\n const words = (name ?? '').trim().split(/\\s+/).filter(Boolean);\n if (words.length === 0) return '';\n const first = words[0]?.[0] ?? '';\n const last = words.length > 1 ? (words[words.length - 1]?.[0] ?? '') : '';\n return (first + last).toUpperCase();\n}\n\n/** Stable pick of a tone from the name, so a person always gets the same color. */\nfunction toneFor(name?: string | null): string | undefined {\n const text = name ?? '';\n let hash = 0;\n for (let i = 0; i < text.length; i++) hash = (hash * 31 + text.charCodeAt(i)) >>> 0;\n return TONES[hash % TONES.length];\n}\n\n/** A photo when available, otherwise initials on a color derived from the name. */\nexport function Avatar({ name, src, size = 'md', tone = 'auto', className, ...rest }: AvatarProps) {\n const [failedSrc, setFailedSrc] = useState<string | null>(null);\n const showImage = Boolean(src) && src !== failedSrc;\n const initials = getInitials(name);\n\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n return (\n <span\n role={rest['aria-hidden'] ? undefined : 'img'}\n aria-label={rest['aria-hidden'] || !name ? undefined : name}\n {...rest}\n className={cn(\n styles.root,\n styles[size],\n !showImage && (tone === 'primary' ? styles.primary : toneFor(name)),\n className,\n )}\n >\n {showImage ? (\n <img\n className={styles.image}\n src={src ?? undefined}\n alt=\"\"\n onError={() => setFailedSrc(src ?? null)}\n />\n ) : initials ? (\n <span aria-hidden=\"true\">{initials}</span>\n ) : (\n <svg className={styles.fallback} viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\">\n <circle cx=\"12\" cy=\"8\" r=\"4\" fill=\"currentColor\" />\n <path d=\"M4 21c0-4.4 3.6-7 8-7s8 2.6 8 7z\" fill=\"currentColor\" />\n </svg>\n )}\n </span>\n );\n}\n",".root {\n position: relative;\n display: inline-block;\n}\n\n.rootSidebar {\n display: block;\n width: 100%;\n}\n\n.contents {\n display: contents;\n}\n\n/* Trigger: header (round avatar) */\n.triggerHeader {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 2.5rem;\n height: 2.5rem;\n padding: 0;\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-full);\n box-shadow: 0 0 0 2px transparent;\n cursor: pointer;\n transition: box-shadow var(--cui-transition-fast);\n}\n.triggerHeader:hover {\n box-shadow: 0 0 0 2px color-mix(in srgb, var(--cui-color-primary) 20%, transparent);\n}\n.triggerHeader.triggerOpen {\n box-shadow: 0 0 0 2px color-mix(in srgb, var(--cui-color-primary) 30%, transparent);\n}\n\n/* Trigger: sidebar row */\n.triggerSidebar {\n display: flex;\n align-items: center;\n gap: 10px;\n box-sizing: border-box;\n width: 100%;\n padding: var(--cui-space-2);\n background: transparent;\n border: 1px solid transparent;\n border-radius: var(--cui-radius-lg);\n color: var(--cui-color-text);\n font-family: var(--cui-font-family);\n text-align: start;\n cursor: pointer;\n transition:\n background-color var(--cui-transition-fast),\n border-color var(--cui-transition-fast);\n}\n.triggerSidebar:hover {\n background-color: var(--cui-color-surface-secondary);\n}\n.triggerSidebar.triggerOpen {\n background-color: color-mix(in srgb, var(--cui-color-primary) 6%, var(--cui-color-surface));\n border-color: color-mix(in srgb, var(--cui-color-primary) 22%, transparent);\n}\n.collapsed {\n justify-content: center;\n padding: 6px;\n}\n\n.triggerHeader:focus-visible,\n.triggerSidebar:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: var(--cui-focus-ring-offset);\n}\n\n.identityText {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-width: 0;\n line-height: 1.25;\n}\n.triggerName {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: var(--cui-font-size-sm);\n font-weight: var(--cui-font-weight-medium);\n}\n.triggerRole {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: var(--cui-font-size-xs);\n color: var(--cui-color-text-muted);\n}\n\n/* Panel (rendered in <body>) */\n.panel {\n position: fixed;\n z-index: var(--cui-z-popover);\n box-sizing: border-box;\n width: 22rem;\n max-width: calc(100vw - 1.5rem);\n max-height: calc(100vh - 1.5rem);\n overflow-y: auto;\n padding: var(--cui-space-2);\n background-color: var(--cui-color-surface);\n color: var(--cui-color-text);\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-xl);\n box-shadow: var(--cui-shadow-lg);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-sm);\n line-height: var(--cui-line-height);\n outline: none;\n transform-origin: top right;\n animation: cui-account-in 0.2s ease-out;\n}\n.panelSidebar {\n transform-origin: bottom left;\n}\n\n@keyframes cui-account-in {\n from {\n opacity: 0;\n transform: scale(0.95);\n }\n}\n\n.srOnly {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip: rect(0 0 0 0);\n white-space: nowrap;\n}\n\n/* Profile: a soft tinted header, no border */\n.profile {\n padding: var(--cui-space-3);\n border-radius: var(--cui-radius-lg);\n background-color: color-mix(in srgb, var(--cui-color-primary) 6%, var(--cui-color-surface));\n}\n\n.profileTop {\n display: flex;\n align-items: center;\n gap: var(--cui-space-3);\n}\n.profileText {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n min-width: 0;\n}\n\n.greeting {\n margin: 0;\n font-size: var(--cui-font-size-md);\n font-weight: var(--cui-font-weight-semibold);\n line-height: 1.3;\n color: var(--cui-color-text);\n}\n\n.email {\n max-width: 100%;\n margin: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: var(--cui-font-size-xs);\n color: var(--cui-color-text-secondary);\n}\n\n.role {\n margin-top: 6px;\n padding: 0 8px;\n border-radius: var(--cui-radius-full);\n background-color: color-mix(in srgb, var(--cui-color-primary) 12%, transparent);\n font-size: 0.6875rem;\n font-weight: var(--cui-font-weight-semibold);\n line-height: 1.6;\n color: var(--cui-color-primary);\n}\n\n.details {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));\n gap: var(--cui-space-2) var(--cui-space-4);\n margin: var(--cui-space-3) 0 0;\n padding: var(--cui-space-2) var(--cui-space-3);\n border-radius: var(--cui-radius-md);\n background-color: var(--cui-color-surface);\n}\n.detail {\n min-width: 0;\n}\n.detail dt {\n font-size: 0.6875rem;\n color: var(--cui-color-text-muted);\n}\n.detail dd {\n margin: 0;\n overflow-wrap: anywhere;\n font-size: var(--cui-font-size-xs);\n font-weight: var(--cui-font-weight-medium);\n color: var(--cui-color-text);\n}\n\n/* Quick actions: menu rows */\n.menu {\n display: flex;\n flex-direction: column;\n gap: 2px;\n margin-top: var(--cui-space-2);\n}\n\n.menuItem {\n display: flex;\n align-items: center;\n gap: var(--cui-space-3);\n box-sizing: border-box;\n width: 100%;\n padding: 6px var(--cui-space-2);\n background: transparent;\n border: 0;\n border-radius: var(--cui-radius-md);\n color: var(--cui-color-text);\n font: inherit;\n text-align: start;\n text-decoration: none;\n cursor: pointer;\n transition: background-color var(--cui-transition-fast);\n}\n.menuItem:hover:not(:disabled) {\n background-color: var(--cui-color-surface-secondary);\n}\n.menuItem:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n.menuItem:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: -2px;\n}\n\n.menuIcon {\n display: inline-flex;\n flex-shrink: 0;\n align-items: center;\n justify-content: center;\n width: 1.75rem;\n height: 1.75rem;\n border-radius: var(--cui-radius-md);\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text-secondary);\n transition:\n background-color var(--cui-transition-fast),\n color var(--cui-transition-fast);\n}\n.menuIcon:empty {\n display: none;\n}\n.menuIcon > svg {\n width: 1rem;\n height: 1rem;\n}\n.menuItem:hover:not(:disabled) .menuIcon {\n background-color: color-mix(in srgb, var(--cui-color-primary) 12%, transparent);\n color: var(--cui-color-primary);\n}\n\n.menuLabel {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-weight: var(--cui-font-weight-medium);\n}\n\n.trailIcon {\n flex-shrink: 0;\n width: 0.875rem;\n height: 0.875rem;\n color: var(--cui-color-text-disabled);\n transition:\n transform var(--cui-transition-fast),\n color var(--cui-transition-fast),\n opacity var(--cui-transition-fast);\n}\n.menuItem:hover .trailIcon {\n color: var(--cui-color-text-secondary);\n transform: translateX(2px);\n}\n\n/* App launcher: borderless two-column rows */\n.apps {\n margin-top: var(--cui-space-2);\n padding-top: var(--cui-space-2);\n border-top: 1px solid var(--cui-color-border);\n}\n.sectionTitle {\n margin: 0;\n padding: var(--cui-space-1) var(--cui-space-2) 6px;\n font-size: 0.6875rem;\n font-weight: var(--cui-font-weight-semibold);\n letter-spacing: 0.04em;\n text-transform: uppercase;\n color: var(--cui-color-text-muted);\n}\n.grid {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 2px;\n}\n\n.app {\n display: flex;\n align-items: center;\n gap: 10px;\n min-width: 0;\n padding: 6px var(--cui-space-2);\n border-radius: var(--cui-radius-md);\n color: var(--cui-color-text);\n text-decoration: none;\n transition: background-color var(--cui-transition-fast);\n}\n.app:hover {\n background-color: var(--cui-color-surface-secondary);\n}\n.app:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: -2px;\n}\n/* The app the panel is open in */\n.appIsCurrent {\n background-color: color-mix(in srgb, var(--cui-color-primary) 7%, transparent);\n}\n.appIsCurrent:hover {\n background-color: color-mix(in srgb, var(--cui-color-primary) 11%, transparent);\n}\n\n.tile {\n display: flex;\n flex-shrink: 0;\n align-items: center;\n justify-content: center;\n width: 1.75rem;\n height: 1.75rem;\n border-radius: var(--cui-radius-md);\n}\n.tile > svg {\n width: 1rem;\n height: 1rem;\n transition: transform 0.2s ease-out;\n}\n.app:hover .tile > svg {\n transform: scale(1.12);\n}\n\n.tonePrimary {\n background-color: color-mix(in srgb, var(--cui-color-primary) 12%, transparent);\n color: var(--cui-color-primary);\n}\n.toneInfo {\n background-color: color-mix(in srgb, var(--cui-color-info) 14%, transparent);\n color: var(--cui-color-info);\n}\n.toneSuccess {\n background-color: color-mix(in srgb, var(--cui-color-success) 14%, transparent);\n color: var(--cui-color-success);\n}\n.toneWarning {\n background-color: color-mix(in srgb, var(--cui-color-warning) 14%, transparent);\n color: var(--cui-color-warning);\n}\n.toneDanger {\n background-color: color-mix(in srgb, var(--cui-color-danger) 14%, transparent);\n color: var(--cui-color-danger);\n}\n.toneNeutral {\n background-color: var(--cui-color-surface-secondary);\n color: var(--cui-color-text-secondary);\n}\n\n.appName {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-weight: var(--cui-font-weight-medium);\n}\n.currentDot {\n flex-shrink: 0;\n width: 6px;\n height: 6px;\n border-radius: var(--cui-radius-full);\n background-color: var(--cui-color-primary);\n}\n/* External apps: the open-in-new-tab mark appears on hover */\n.app .trailIcon {\n width: 0.75rem;\n height: 0.75rem;\n opacity: 0;\n}\n.app:hover .trailIcon,\n.app:focus-visible .trailIcon {\n opacity: 1;\n color: var(--cui-color-text-secondary);\n}\n\n/* Log out: a soft danger button closing the panel */\n.danger {\n display: flex;\n flex-direction: column;\n gap: var(--cui-space-1);\n margin-top: var(--cui-space-2);\n padding-top: var(--cui-space-2);\n border-top: 1px solid var(--cui-color-border);\n}\n.dangerAction {\n display: flex;\n align-items: center;\n justify-content: flex-start;\n gap: var(--cui-space-2);\n box-sizing: border-box;\n width: 100%;\n min-height: 2.25rem;\n padding: 6px var(--cui-space-3);\n background-color: color-mix(in srgb, var(--cui-color-danger) 8%, transparent);\n border: 0;\n border-radius: var(--cui-radius-md);\n color: var(--cui-color-danger);\n font: inherit;\n font-weight: var(--cui-font-weight-medium);\n cursor: pointer;\n transition: background-color var(--cui-transition-fast);\n}\n.dangerAction:hover:not(:disabled) {\n background-color: color-mix(in srgb, var(--cui-color-danger) 15%, transparent);\n}\n.dangerAction:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n.dangerAction:focus-visible {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 2px;\n}\n.dangerIcon {\n display: inline-flex;\n flex-shrink: 0;\n width: 1rem;\n height: 1rem;\n}\n.dangerIcon > svg {\n width: 100%;\n height: 100%;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .panel {\n animation: none;\n }\n .tile > svg,\n .trailIcon {\n transition: none;\n }\n .app:hover .tile > svg,\n .menuItem:hover .trailIcon {\n transform: none;\n }\n}\n","import {\n useEffect,\n useId,\n useRef,\n useState,\n type CSSProperties,\n type KeyboardEvent,\n type ReactNode,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { cn } from '../../utils/cn';\nimport { getPortalHost } from '../../utils/portalHost';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { Avatar } from '../Avatar';\nimport type {\n AccountPanelAction,\n AccountPanelApp,\n AccountPanelProps,\n RenderLinkArgs,\n} from './AccountPanel.types';\nimport styles from './AccountPanel.module.css';\n\nconst GAP = 8;\nconst EDGE = 12;\nconst PANEL_WIDTH = 352;\nconst FOCUSABLE = 'a[href], button:not([disabled])';\n\nconst defaultRenderLink = ({ href, className, title, onClick, children }: RenderLinkArgs) => (\n <a href={href} className={className} title={title} onClick={onClick}>\n {children}\n </a>\n);\n\nconst tileTone: Record<NonNullable<AccountPanelApp['tone']>, string | undefined> = {\n primary: styles.tonePrimary,\n info: styles.toneInfo,\n success: styles.toneSuccess,\n warning: styles.toneWarning,\n danger: styles.toneDanger,\n neutral: styles.toneNeutral,\n};\n\nfunction ChevronIcon() {\n return (\n <svg className={styles.trailIcon} viewBox=\"0 0 20 20\" aria-hidden=\"true\" focusable=\"false\">\n <path\n d=\"M8 5l5 5-5 5\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.8\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n );\n}\n\nfunction ExternalIcon() {\n return (\n <svg className={styles.trailIcon} viewBox=\"0 0 20 20\" aria-hidden=\"true\" focusable=\"false\">\n <path\n d=\"M8 5H5v10h10v-3M11 5h4v4M15 5l-7 7\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.8\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n );\n}\n\n/**\n * The logged-in user's button and account panel: greeting, role, detail rows,\n * quick actions, an app launcher and a log out action. It holds no auth or\n * routing logic; the app passes the user, the actions and (optionally) a\n * `renderLink` for its router.\n */\nexport function AccountPanel({\n user,\n apps = [],\n actions = [],\n placement = 'header',\n collapsed = false,\n appsTitle = 'All Apps',\n greeting = 'Hi',\n renderLink = defaultRenderLink,\n className,\n}: AccountPanelProps) {\n const sidebar = placement === 'sidebar';\n const panelId = useId();\n const rootRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const panelRef = useRef<HTMLDivElement>(null);\n const [open, setOpen] = useState(false);\n const [position, setPosition] = useState<CSSProperties | null>(null);\n const [themeName, setThemeName] = useState<string | undefined>();\n\n const computePosition = () => {\n const trigger = triggerRef.current;\n if (!trigger) return;\n const rect = trigger.getBoundingClientRect();\n if (sidebar) {\n const width = Math.min(PANEL_WIDTH, window.innerWidth - 2 * EDGE);\n setPosition({\n left: Math.max(EDGE, Math.min(rect.right + GAP, window.innerWidth - width - EDGE)),\n bottom: Math.max(EDGE, window.innerHeight - rect.bottom),\n });\n } else {\n setPosition({\n top: rect.bottom + GAP,\n right: Math.max(EDGE, window.innerWidth - rect.right),\n });\n }\n };\n\n const openPanel = () => {\n computePosition();\n // The panel is rendered in <body> (so no ancestor can clip or offset it); carry the theme over.\n setThemeName(rootRef.current?.closest('[data-theme]')?.getAttribute('data-theme') ?? undefined);\n setOpen(true);\n };\n\n const close = () => setOpen(false);\n\n useEffect(() => {\n if (open) panelRef.current?.focus({ preventScroll: true });\n }, [open]);\n\n useEffect(() => {\n if (!open) return;\n const reposition = () => requestAnimationFrame(computePosition);\n const onPointerDown = (event: MouseEvent) => {\n const target = event.target as Node;\n if (!rootRef.current?.contains(target) && !panelRef.current?.contains(target)) close();\n };\n window.addEventListener('scroll', reposition, true);\n window.addEventListener('resize', reposition);\n document.addEventListener('mousedown', onPointerDown, true);\n return () => {\n window.removeEventListener('scroll', reposition, true);\n window.removeEventListener('resize', reposition);\n document.removeEventListener('mousedown', onPointerDown, true);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open, sidebar]);\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Escape') {\n event.preventDefault();\n event.stopPropagation();\n close();\n triggerRef.current?.focus({ preventScroll: true });\n return;\n }\n if (event.key !== 'Tab') return;\n // The panel is portalled to <body>, so keep Tab cycling inside it.\n const nodes = Array.from(panelRef.current?.querySelectorAll<HTMLElement>(FOCUSABLE) ?? []);\n const first = nodes[0];\n const last = nodes[nodes.length - 1];\n if (!first || !last) return;\n if (\n event.shiftKey &&\n (document.activeElement === first || document.activeElement === panelRef.current)\n ) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n };\n\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n const firstName = user.name.trim().split(/\\s+/)[0] ?? user.name;\n const quickActions = actions.filter((a) => a.tone !== 'danger');\n const dangerActions = actions.filter((a) => a.tone === 'danger');\n\n const runAction = (action: AccountPanelAction) => {\n action.onClick?.();\n close();\n };\n\n const renderQuickAction = (action: AccountPanelAction): ReactNode => {\n const content = (\n <>\n <span className={styles.menuIcon} aria-hidden=\"true\">\n {action.icon ?? null}\n </span>\n <span className={styles.menuLabel}>{action.label}</span>\n {action.external ? <ExternalIcon /> : action.href ? <ChevronIcon /> : null}\n </>\n );\n if (action.href && !action.disabled) {\n if (action.external) {\n return (\n <a\n key={action.id}\n href={action.href}\n target=\"_blank\"\n rel=\"noreferrer\"\n title={action.title}\n className={styles.menuItem}\n onClick={() => close()}\n >\n {content}\n </a>\n );\n }\n return (\n <span key={action.id} className={styles.contents}>\n {renderLink({\n href: action.href,\n className: styles.menuItem ?? '',\n title: action.title,\n onClick: () => close(),\n children: content,\n })}\n </span>\n );\n }\n return (\n <button\n key={action.id}\n type=\"button\"\n disabled={action.disabled}\n title={action.title}\n className={styles.menuItem}\n onClick={() => runAction(action)}\n >\n {content}\n </button>\n );\n };\n\n const panel = (\n <div\n ref={panelRef}\n id={panelId}\n role=\"dialog\"\n aria-label=\"Account\"\n tabIndex={-1}\n className={cn(styles.panel, sidebar && styles.panelSidebar)}\n style={position ?? undefined}\n data-theme={themeName}\n onKeyDown={handleKeyDown}\n >\n {/* Profile: who is signed in, and the context they are working in */}\n <div className={styles.profile}>\n <div className={styles.profileTop}>\n <Avatar\n name={user.name}\n src={user.avatarUrl}\n size=\"lg\"\n tone=\"primary\"\n aria-hidden=\"true\"\n />\n <div className={styles.profileText}>\n <p className={styles.greeting}>\n {greeting}, {firstName}!\n </p>\n {user.email ? (\n <p className={styles.email} title={user.email}>\n {user.email}\n </p>\n ) : null}\n {user.role ? <span className={styles.role}>{user.role}</span> : null}\n </div>\n </div>\n\n {user.details?.length ? (\n <dl className={styles.details}>\n {user.details.map((detail) => (\n <div key={detail.label} className={styles.detail}>\n <dt>{detail.label}</dt>\n <dd title={detail.value}>{detail.value}</dd>\n </div>\n ))}\n </dl>\n ) : null}\n </div>\n\n {quickActions.length > 0 ? (\n <div className={styles.menu}>{quickActions.map(renderQuickAction)}</div>\n ) : null}\n\n {apps.length > 0 ? (\n <section className={styles.apps} aria-label={appsTitle}>\n <p className={styles.sectionTitle}>{appsTitle}</p>\n <div className={styles.grid}>\n {apps.map((app) => {\n const tile = (\n <>\n <span\n className={cn(styles.tile, tileTone[app.tone ?? 'primary'])}\n aria-hidden=\"true\"\n >\n {app.icon}\n </span>\n <span className={styles.appName}>{app.name}</span>\n {app.current ? (\n <span className={styles.currentDot}>\n <span className={styles.srOnly}>(current app)</span>\n </span>\n ) : (\n <ExternalIcon />\n )}\n </>\n );\n return app.current ? (\n <span key={app.id} className={styles.contents}>\n {renderLink({\n href: app.url,\n className: cn(styles.app, styles.appIsCurrent),\n title: app.description,\n onClick: () => close(),\n children: tile,\n })}\n </span>\n ) : (\n <a\n key={app.id}\n href={app.url}\n target=\"_blank\"\n rel=\"noreferrer\"\n title={app.description}\n className={styles.app}\n >\n {tile}\n </a>\n );\n })}\n </div>\n </section>\n ) : null}\n\n {dangerActions.length > 0 ? (\n <div className={styles.danger}>\n {dangerActions.map((action) => (\n <button\n key={action.id}\n type=\"button\"\n disabled={action.disabled}\n title={action.title}\n className={styles.dangerAction}\n onClick={() => runAction(action)}\n >\n {action.icon ? (\n <span className={styles.dangerIcon} aria-hidden=\"true\">\n {action.icon}\n </span>\n ) : null}\n {action.label}\n </button>\n ))}\n </div>\n ) : null}\n </div>\n );\n\n return (\n <div ref={rootRef} className={cn(styles.root, sidebar && styles.rootSidebar, className)}>\n <button\n ref={triggerRef}\n type=\"button\"\n aria-label={`Account: ${user.name}`}\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n aria-controls={open ? panelId : undefined}\n className={cn(\n sidebar ? styles.triggerSidebar : styles.triggerHeader,\n sidebar && collapsed && styles.collapsed,\n open && styles.triggerOpen,\n )}\n onClick={() => (open ? close() : openPanel())}\n >\n <Avatar name={user.name} src={user.avatarUrl} size=\"sm\" tone=\"primary\" aria-hidden=\"true\" />\n {sidebar && !collapsed ? (\n <span className={styles.identityText}>\n <span className={styles.triggerName}>{user.name}</span>\n {user.role ? <span className={styles.triggerRole}>{user.role}</span> : null}\n </span>\n ) : null}\n </button>\n {open && position ? createPortal(panel, getPortalHost()) : null}\n </div>\n );\n}\n",".root {\n margin: 0;\n font-family: var(--cui-font-family);\n line-height: var(--cui-line-height);\n}\n\n/* Variants */\n.h1 {\n font-size: var(--cui-font-size-2xl);\n font-weight: var(--cui-font-weight-bold);\n line-height: 1.3;\n}\n.h2 {\n font-size: var(--cui-font-size-xl);\n font-weight: var(--cui-font-weight-semibold);\n line-height: 1.35;\n}\n.h3 {\n font-size: var(--cui-font-size-lg);\n font-weight: var(--cui-font-weight-semibold);\n line-height: 1.4;\n}\n.h4 {\n font-size: var(--cui-font-size-md);\n font-weight: var(--cui-font-weight-semibold);\n}\n.body {\n font-size: var(--cui-font-size-md);\n font-weight: var(--cui-font-weight-normal);\n}\n.bodySm {\n font-size: var(--cui-font-size-sm);\n font-weight: var(--cui-font-weight-normal);\n}\n.caption {\n font-size: var(--cui-font-size-xs);\n font-weight: var(--cui-font-weight-normal);\n}\n.label {\n font-size: var(--cui-font-size-sm);\n font-weight: var(--cui-font-weight-semibold);\n}\n\n/* Colors */\n.color-default {\n color: var(--cui-color-text);\n}\n.color-secondary {\n color: var(--cui-color-text-secondary);\n}\n.color-muted {\n color: var(--cui-color-text-muted);\n}\n.color-disabled {\n color: var(--cui-color-text-disabled);\n}\n.color-primary {\n color: var(--cui-color-primary);\n}\n.color-success {\n color: var(--cui-color-success);\n}\n.color-warning {\n color: var(--cui-color-warning);\n}\n.color-danger {\n color: var(--cui-color-danger);\n}\n.color-info {\n color: var(--cui-color-info);\n}\n\n/* Weight overrides (declared after variants so they win) */\n.weight-normal {\n font-weight: var(--cui-font-weight-normal);\n}\n.weight-medium {\n font-weight: var(--cui-font-weight-medium);\n}\n.weight-semibold {\n font-weight: var(--cui-font-weight-semibold);\n}\n.weight-bold {\n font-weight: var(--cui-font-weight-bold);\n}\n\n.align-start {\n text-align: start;\n}\n.align-center {\n text-align: center;\n}\n.align-end {\n text-align: end;\n}\n\n.truncate {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n","import { createElement } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport type { TypographyElement, TypographyProps, TypographyVariant } from './Typography.types';\nimport styles from './Typography.module.css';\n\nconst defaultElement: Record<TypographyVariant, TypographyElement> = {\n h1: 'h1',\n h2: 'h2',\n h3: 'h3',\n h4: 'h4',\n body: 'p',\n 'body-sm': 'p',\n caption: 'span',\n label: 'span',\n};\n\nconst variantClass: Record<TypographyVariant, string | undefined> = {\n h1: styles.h1,\n h2: styles.h2,\n h3: styles.h3,\n h4: styles.h4,\n body: styles.body,\n 'body-sm': styles.bodySm,\n caption: styles.caption,\n label: styles.label,\n};\n\n/** Themed text. Pick the look with `variant` and the HTML element with `as`. */\nexport function Typography({\n variant = 'body',\n as,\n color = 'default',\n weight,\n align,\n truncate = false,\n className,\n ...rest\n}: TypographyProps) {\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n return createElement(as ?? defaultElement[variant], {\n ...rest,\n className: cn(\n styles.root,\n variantClass[variant],\n styles[`color-${color}`],\n weight && styles[`weight-${weight}`],\n align && styles[`align-${align}`],\n truncate && styles.truncate,\n className,\n ),\n });\n}\n",".root {\n display: inline-flex;\n padding: 2px;\n gap: 2px;\n background-color: var(--cui-color-surface-secondary);\n border: 1px solid var(--cui-color-border);\n border-radius: var(--cui-radius-lg);\n}\n\n.option {\n position: relative;\n display: inline-flex;\n}\n\n.input {\n position: absolute;\n inset: 0;\n margin: 0;\n opacity: 0;\n cursor: pointer;\n}\n\n.face {\n display: inline-flex;\n align-items: center;\n gap: var(--cui-space-2);\n padding: 6px var(--cui-space-3);\n border-radius: var(--cui-radius-md);\n color: var(--cui-color-text-muted);\n font-family: var(--cui-font-family);\n font-size: var(--cui-font-size-sm);\n font-weight: var(--cui-font-weight-medium);\n line-height: 1.25;\n white-space: nowrap;\n transition:\n background-color var(--cui-transition-fast),\n color var(--cui-transition-fast);\n}\n\n.option:hover .input:not(:checked) + .face {\n color: var(--cui-color-text);\n}\n\n.input:checked + .face {\n background-color: var(--cui-color-surface);\n color: var(--cui-color-primary);\n box-shadow: var(--cui-shadow-sm);\n}\n\n.input:focus-visible + .face {\n outline: var(--cui-focus-ring-width) solid var(--cui-color-border-focus);\n outline-offset: 1px;\n}\n\n.icon {\n width: 1rem;\n height: 1rem;\n flex-shrink: 0;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .face {\n transition: none;\n }\n}\n","import { useId, type ReactNode } from 'react';\nimport { cn } from '../../utils/cn';\nimport { UnlicensedNotice, useLicensed } from '../../license';\nimport { useTheme } from '../../theme';\nimport type { ThemeToggleProps } from './ThemeToggle.types';\nimport styles from './ThemeToggle.module.css';\n\nconst icons: Record<string, ReactNode> = {\n light: (\n <>\n <circle cx=\"12\" cy=\"12\" r=\"4\" />\n <path d=\"M12 3v2M12 19v2M3 12h2M19 12h2M5.6 5.6l1.4 1.4M17 17l1.4 1.4M5.6 18.4L7 17M17 7l1.4-1.4\" />\n </>\n ),\n dark: <path d=\"M20 14.5A8 8 0 019.5 4a8 8 0 1010.5 10.5z\" />,\n system: (\n <>\n <rect x=\"3\" y=\"4\" width=\"18\" height=\"12\" rx=\"2\" />\n <path d=\"M8 20h8M12 16v4\" />\n </>\n ),\n};\n\nconst labels: Record<string, string> = { light: 'Light', dark: 'Dark', system: 'System' };\n\n/**\n * Switch between themes (light / dark / system by default). Must be inside a\n * `ThemeProvider`. Built on radio inputs, so arrow keys and screen readers work natively.\n */\nexport function ThemeToggle({\n modes = ['light', 'dark', 'system'],\n compact = false,\n className,\n 'aria-label': ariaLabel = 'Theme',\n ...rest\n}: ThemeToggleProps) {\n const { theme, setTheme } = useTheme();\n const name = useId();\n const licensed = useLicensed();\n if (!licensed) return <UnlicensedNotice />;\n\n return (\n <div {...rest} role=\"radiogroup\" aria-label={ariaLabel} className={cn(styles.root, className)}>\n {modes.map((mode) => {\n const label = labels[mode] ?? mode;\n return (\n <label key={mode} className={styles.option} title={compact ? label : undefined}>\n <input\n type=\"radio\"\n name={name}\n value={mode}\n checked={theme === mode}\n onChange={() => setTheme(mode)}\n className={styles.input}\n aria-label={compact ? label : undefined}\n />\n <span className={styles.face}>\n {icons[mode] ? (\n <svg\n className={styles.icon}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.8\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\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