{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "components-calendar",
  "type": "registry:component",
  "title": "Calendar",
  "description": "A month grid for a day, several days, or a range",
  "author": "sudo-kw <https://github.com/sudo-kw>",
  "dependencies": [
    "@gpuix/native@0.11.0",
    "@gpuix/react@0.11.0",
    "effect@4.1.2",
    "react@^19.2.4"
  ],
  "registryDependencies": [
    "https://gpuixui.sudokw.com/gpuix-icons.json",
    "https://gpuixui.sudokw.com/gpuix-primitives.json",
    "https://gpuixui.sudokw.com/gpuix-tokens.json",
    "https://gpuixui.sudokw.com/gpuix-tw.json"
  ],
  "files": [
    {
      "path": "packages/components/src/calendar.tsx",
      "target": "@ui/gpuixui/components/calendar.tsx",
      "type": "registry:component",
      "content": "/** @jsxImportSource @gpuix/react */\nimport type { KeyEvent, StyleDesc } from \"@gpuix/react\";\nimport { useGpuix } from \"@gpuix/react\";\nimport { Select, type SelectOption } from \"../primitives/select.js\";\nimport {\n  CALENDAR_DAY,\n  CALENDAR_GRID,\n  CALENDAR_MONTH,\n  CALENDAR_MONTH_LABEL,\n  CALENDAR_ROOT,\n  CALENDAR_WEEKDAY,\n  cn,\n} from \"../tw/index.js\";\nimport { Match, pipe } from \"effect\";\nimport * as Arr from \"effect/Array\";\nimport * as DateTime from \"effect/DateTime\";\nimport * as Option from \"effect/Option\";\nimport { useLayoutEffect, useRef } from \"react\";\nimport {\n  addMonths,\n  boundsOfMatchers,\n  calendarLabel,\n  canBrowseMonth,\n  clampToBounds,\n  dayAriaLabel,\n  dayInMonth,\n  formatIsoDay,\n  formatMonthLabel,\n  isDayAvailable,\n  isPainted,\n  isSameDay,\n  moveDay,\n  moveKeyOf,\n  monthGrid,\n  monthShortName,\n  monthWindow,\n  nextDay,\n  nextRange,\n  paintOf,\n  parseIsoDay,\n  startOfMonth,\n  todayUtc,\n  toggleDay,\n  unbounded,\n  visibleMonth,\n  weekdayLabels,\n  yearRange,\n  type CalendarMode,\n  type CaptionLayout,\n  type DayMatchers,\n  type DayRange,\n  type MonthCount,\n  type Selection,\n  type WeekStart,\n} from \"./calendar/logic.js\";\nimport { makeCalendarStore } from \"./calendar/store.js\";\nimport { IconButton } from \"./internal/button.js\";\nimport { Icon } from \"../icons/index.js\";\nimport { isActivation, isDismiss, swallowsDefault } from \"./internal/key.js\";\nimport { send, useLocalState, useLocalStore } from \"./internal/local-state.js\";\nimport { recipeStyle } from \"./internal/recipe.js\";\nimport { mergeStyles } from \"@gpuix/react/floating\";\nimport {\n  controlRing,\n  disabledOpacity,\n  useTheme,\n  type Theme,\n} from \"./internal/theme.js\";\n\nconst CELL = 34;\n\nconst DEFAULT_FROM_YEAR = 1900;\n\nconst DEFAULT_YEARS_AHEAD = 100;\n\nexport interface CalendarBaseProps {\n  readonly numberOfMonths?: MonthCount;\n\n  readonly showOutsideDays?: boolean;\n\n  readonly captionLayout?: CaptionLayout;\n\n  readonly weekStartsOn?: WeekStart;\n\n  readonly fromYear?: number;\n\n  readonly toYear?: number;\n\n  readonly disabled?: DayMatchers;\n\n  readonly today?: string;\n\n  readonly defaultMonth?: string;\n\n  readonly autoFocus?: boolean;\n\n  readonly label?: string;\n\n  readonly onDismiss?: () => void;\n\n  readonly className?: string;\n}\n\nexport interface SingleCalendarProps extends CalendarBaseProps {\n  readonly mode?: \"single\";\n  readonly selected?: string | null;\n  readonly onSelect?: (day: string | null) => void;\n}\n\nexport interface MultipleCalendarProps extends CalendarBaseProps {\n  readonly mode: \"multiple\";\n  readonly selected?: ReadonlyArray<string>;\n  readonly onSelect?: (days: ReadonlyArray<string>) => void;\n}\n\nexport interface RangeCalendarProps extends CalendarBaseProps {\n  readonly mode: \"range\";\n  readonly selected?: DayRange | null;\n  readonly onSelect?: (range: DayRange | null) => void;\n}\n\nexport type CalendarProps =\n  | SingleCalendarProps\n  | MultipleCalendarProps\n  | RangeCalendarProps;\n\ninterface SelectionAdapter {\n  readonly selection: Selection;\n  readonly select: (day: string) => void;\n}\n\nconst adapterOf = (props: CalendarProps): SelectionAdapter => {\n  if (props.mode === \"range\") {\n    const range = props.selected ?? null;\n    return {\n      selection: { mode: \"range\", range },\n      select: (day) => props.onSelect?.(nextRange(range, day)),\n    };\n  }\n  if (props.mode === \"multiple\") {\n    const days = props.selected ?? [];\n    return {\n      selection: { mode: \"multiple\", days },\n      select: (day) => props.onSelect?.(toggleDay(days, day)),\n    };\n  }\n  const day = props.selected ?? null;\n  return {\n    selection: { mode: \"single\", day },\n    select: (next) => props.onSelect?.(nextDay(day, next)),\n  };\n};\n\nconst anchorOf = (selection: Selection, today: DateTime.Utc): DateTime.Utc =>\n  pipe(\n    Match.value(selection).pipe(\n      Match.when({ mode: \"single\" }, (current) =>\n        Option.flatMap(Option.fromNullishOr(current.day), parseIsoDay),\n      ),\n      Match.when({ mode: \"multiple\" }, (current) =>\n        Option.flatMap(Arr.head(current.days), parseIsoDay),\n      ),\n      Match.when({ mode: \"range\" }, (current) =>\n        Option.flatMap(Option.fromNullishOr(current.range?.from), parseIsoDay),\n      ),\n      Match.exhaustive,\n    ),\n    Option.getOrElse(() => today),\n  );\n\nconst monthIndexOf = (value: DateTime.Utc): string =>\n  String(DateTime.toPartsUtc(value).month);\n\nconst Caption = ({\n  month,\n  layout,\n  months,\n  years,\n  onMonth,\n  onYear,\n  testId,\n}: {\n  readonly month: DateTime.Utc;\n  readonly layout: CaptionLayout;\n  readonly months: ReadonlyArray<SelectOption>;\n  readonly years: ReadonlyArray<SelectOption>;\n  readonly onMonth: (month: number) => void;\n  readonly onYear: (year: number) => void;\n  readonly testId: string;\n}) => {\n  const theme = useTheme();\n  return (\n    <div\n      style={{\n        display: \"flex\",\n        flexDirection: \"row\",\n        alignItems: \"center\",\n        justifyContent: \"center\",\n        gap: theme.spacing.xs,\n        minHeight: CELL,\n      }}\n    >\n      {layout === \"dropdown\" ? (\n        <>\n          <Select\n            label=\"Month\"\n            options={months}\n            value={monthIndexOf(month)}\n            onValueChange={(next) => onMonth(Number(next))}\n            triggerTestId={`${testId}-select`}\n            itemTestId={(value) => `${testId}-month-${value}`}\n            size=\"sm\"\n          />\n          <Select\n            label=\"Year\"\n            options={years}\n            value={String(DateTime.toPartsUtc(month).year)}\n            onValueChange={(next) => onYear(Number(next))}\n            triggerTestId={`${testId}-year`}\n            itemTestId={(value) => `${testId}-year-${value}`}\n            size=\"sm\"\n          />\n        </>\n      ) : (\n        <text testId={testId} style={recipeStyle(CALENDAR_MONTH_LABEL, theme)}>\n          {formatMonthLabel(month)}\n        </text>\n      )}\n    </div>\n  );\n};\n\nconst cellStyle = (\n  theme: Theme,\n  paint: ReturnType<typeof paintOf>,\n  outside: boolean,\n  today: boolean,\n  available: boolean,\n): StyleDesc => ({\n  width: CELL,\n  height: CELL,\n  backgroundColor: isPainted(paint)\n    ? theme.colors.primary\n    : paint === \"range-middle\"\n      ? theme.colors.muted\n      : undefined,\n  color: isPainted(paint)\n    ? theme.colors.primaryForeground\n    : paint === \"range-middle\"\n      ? theme.colors.foreground\n      : available\n        ? outside\n          ? theme.colors.mutedForeground\n          : theme.colors.foreground\n        : theme.colors.mutedForeground,\n  borderWidth: today && !isPainted(paint) ? theme.borderWidth.thin : undefined,\n  borderColor: today ? theme.colors.primary : undefined,\n  cursor: available ? \"pointer\" : \"not-allowed\",\n  opacity: available ? undefined : disabledOpacity,\n  hover:\n    isPainted(paint) || !available\n      ? undefined\n      : { backgroundColor: theme.colors.hover },\n  ...controlRing(theme, { disabled: !available }),\n});\n\nexport const Calendar = (props: CalendarProps) => {\n  const theme = useTheme();\n  const renderer = useGpuix().renderer;\n  const {\n    numberOfMonths = 1,\n    showOutsideDays = true,\n    captionLayout = \"label\",\n    weekStartsOn = 1,\n    label = \"Calendar\",\n    autoFocus = false,\n    onDismiss,\n  } = props;\n  const today = pipe(\n    Option.flatMap(Option.fromNullishOr(props.today), parseIsoDay),\n    Option.getOrElse(() => todayUtc(DateTime.nowUnsafe())),\n  );\n  const bounds = Option.match(Option.fromNullishOr(props.disabled), {\n    onNone: () => unbounded,\n    onSome: boundsOfMatchers,\n  });\n  const adapter = adapterOf(props);\n  const { selection, select } = adapter;\n  const anchor = clampToBounds(anchorOf(selection, today), bounds);\n  const initialMonth = pipe(\n    Option.flatMap(Option.fromNullishOr(props.defaultMonth), parseIsoDay),\n    Option.getOrElse(() => startOfMonth(anchor)),\n  );\n  const store = useLocalStore(\n    makeCalendarStore({\n      month: visibleMonth(startOfMonth(initialMonth), numberOfMonths, anchor),\n      focus: anchor,\n      count: numberOfMonths,\n      pending: autoFocus,\n    }),\n  );\n  const view = useLocalState(store.local);\n  const cells = useRef<Record<string, number>>({});\n  const months = monthWindow(view.month, numberOfMonths);\n  const year = DateTime.toPartsUtc(today).year;\n\n  const fromYear =\n    props.fromYear ??\n    Math.max(\n      DEFAULT_FROM_YEAR,\n      Option.match(bounds.min, {\n        onNone: () => Number.NEGATIVE_INFINITY,\n        onSome: (min) => DateTime.toPartsUtc(min).year,\n      }),\n    );\n  const toYear =\n    props.toYear ??\n    Math.min(\n      year + DEFAULT_YEARS_AHEAD,\n      Option.match(bounds.max, {\n        onNone: () => Number.POSITIVE_INFINITY,\n        onSome: (max) => DateTime.toPartsUtc(max).year,\n      }),\n    );\n\n  const monthFocus = (month: DateTime.Utc): DateTime.Utc =>\n    clampToBounds(dayInMonth(view.focus, month), bounds);\n\n  useLayoutEffect(() => {\n    if (!view.pending) return;\n    send(store.settle);\n    const panel = Arr.findFirstIndex(months, (month) =>\n      isSameDay(startOfMonth(month), startOfMonth(view.focus)),\n    );\n    const key = `${Option.getOrElse(panel, () => 0)}-${formatIsoDay(view.focus)}`;\n    const id = cells.current[key];\n    if (id !== undefined) renderer?.focusElement?.(id);\n  }, [view, months, renderer, store]);\n\n  const movement = (event: KeyEvent): void => {\n    if (swallowsDefault(event, \"down\")) event.preventDefault();\n    if (isDismiss(event) && onDismiss !== undefined) {\n      onDismiss();\n      return;\n    }\n    pipe(\n      moveKeyOf(event.key ?? \"\"),\n      Option.match({\n        onNone: () => undefined,\n        onSome: (key) => {\n          event.preventDefault();\n          send(\n            store.focusDay(\n              clampToBounds(\n                moveDay(\n                  view.focus,\n                  { key, year: event.modifiers?.shift === true },\n                  {\n                    weekStartsOn,\n                    viewMonth: view.month,\n                    months: numberOfMonths,\n                    showOutsideDays,\n                    bounds,\n                    matchers: props.disabled,\n                    fromYear,\n                    toYear,\n                  },\n                ),\n                bounds,\n              ),\n            ),\n          );\n        },\n      }),\n    );\n  };\n\n  const page = (direction: -1 | 1): void => {\n    const next = addMonths(view.month, direction);\n    send(store.show(next, monthFocus(next)));\n  };\n\n  const monthOptions: ReadonlyArray<SelectOption> = Arr.map(\n    Arr.range(1, 12),\n    (index) => ({ value: String(index), label: monthShortName(index) }),\n  );\n  const yearOptions: ReadonlyArray<SelectOption> = Arr.map(\n    yearRange(fromYear, toYear),\n    (year) => ({ value: String(year), label: String(year) }),\n  );\n\n  return (\n    <div\n      data-calendar=\"\"\n      aria-label={calendarLabel(label, selection)}\n      role=\"group\"\n      onKeyDown={movement}\n      style={mergeStyles(\n        recipeStyle(cn(CALENDAR_ROOT, props.className), theme),\n        {\n          gap: theme.spacing.md,\n        },\n      )}\n    >\n      {Arr.map(months, (month, index) => {\n        const grid = monthGrid(month, weekStartsOn, showOutsideDays);\n        return (\n          <div\n            key={formatIsoDay(month)}\n            style={recipeStyle(CALENDAR_MONTH, theme)}\n          >\n            <div\n              style={{\n                display: \"flex\",\n                flexDirection: \"row\",\n                alignItems: \"center\",\n                justifyContent: \"space-between\",\n                gap: theme.spacing.xs,\n              }}\n            >\n              {index === 0 ? (\n                <IconButton\n                  label=\"Previous month\"\n                  size=\"sm\"\n                  testId=\"date-prev\"\n                  disabled={!canBrowseMonth(month, -1, bounds)}\n                  onClick={() => page(-1)}\n                >\n                  <Icon\n                    name=\"chevron-left\"\n                    size=\"md\"\n                    color={theme.colors.foreground}\n                  />\n                </IconButton>\n              ) : (\n                <div style={{ width: CELL }} />\n              )}\n              <Caption\n                month={month}\n                layout={captionLayout}\n                months={monthOptions}\n                years={yearOptions}\n                testId={index === 0 ? \"date-month\" : `date-month-${index}`}\n                onMonth={(next) => {\n                  const target = addMonths(\n                    startOfMonth(month),\n                    next - DateTime.toPartsUtc(month).month,\n                  );\n                  send(store.show(target, monthFocus(target)));\n                }}\n                onYear={(year) => {\n                  const target = addMonths(\n                    startOfMonth(month),\n                    (year - DateTime.toPartsUtc(month).year) * 12,\n                  );\n                  send(store.show(target, monthFocus(target)));\n                }}\n              />\n              {index === numberOfMonths - 1 ? (\n                <IconButton\n                  label=\"Next month\"\n                  size=\"sm\"\n                  testId=\"date-next\"\n                  disabled={!canBrowseMonth(month, 1, bounds)}\n                  onClick={() => page(1)}\n                >\n                  <Icon\n                    name=\"chevron-right\"\n                    size=\"md\"\n                    color={theme.colors.foreground}\n                  />\n                </IconButton>\n              ) : (\n                <div style={{ width: CELL }} />\n              )}\n            </div>\n            <div\n              role=\"grid\"\n              aria-label={calendarLabel(\n                `${label}, ${formatMonthLabel(month)}`,\n                selection,\n              )}\n              style={recipeStyle(CALENDAR_GRID, theme)}\n            >\n              <div role=\"row\" style={{ display: \"flex\", flexDirection: \"row\" }}>\n                {Arr.map(weekdayLabels(weekStartsOn), (name) => (\n                  <text\n                    key={name}\n                    role=\"columnheader\"\n                    aria-label={name}\n                    style={mergeStyles(recipeStyle(CALENDAR_WEEKDAY, theme), {\n                      width: CELL,\n                    })}\n                  >\n                    {name}\n                  </text>\n                ))}\n              </div>\n              {Arr.map(grid, (week, weekIndex) => (\n                <div\n                  key={weekIndex}\n                  role=\"row\"\n                  style={{ display: \"flex\", flexDirection: \"row\" }}\n                >\n                  {Arr.map(week, (cell, dayIndex) =>\n                    Option.match(cell, {\n                      onNone: () => (\n                        <div\n                          key={dayIndex}\n                          style={{ width: CELL, height: CELL }}\n                        />\n                      ),\n                      onSome: (day) => {\n                        const iso = formatIsoDay(day);\n                        const available = isDayAvailable(\n                          day,\n                          bounds,\n                          props.disabled,\n                        );\n                        const paint = paintOf(selection, iso);\n                        const focused = isSameDay(day, view.focus);\n                        const panel = Arr.findFirstIndex(months, (entry) =>\n                          isSameDay(startOfMonth(entry), startOfMonth(day)),\n                        );\n                        const tabbable =\n                          focused && Option.getOrElse(panel, () => 0) === index;\n                        return (\n                          <div\n                            key={`${index}-${iso}`}\n                            role=\"gridcell\"\n                            aria-label={dayAriaLabel(day, paint, available)}\n                            aria-selected={paint !== \"none\"}\n                            tabIndex={tabbable ? 0 : -1}\n                            ref={(instance) => {\n                              const key = `${index}-${iso}`;\n                              if (instance === null) delete cells.current[key];\n                              else cells.current[key] = instance.id;\n                            }}\n                            testId={`date-day-${iso}`}\n                            onClick={\n                              available\n                                ? () => {\n                                    select(iso);\n                                    send(store.visited(day));\n                                  }\n                                : undefined\n                            }\n                            onFocus={() => send(store.visited(day))}\n                            onKeyDown={(event: KeyEvent) => {\n                              if (swallowsDefault(event, \"down\"))\n                                event.preventDefault();\n                              if (available && isActivation(event, \"down\"))\n                                select(iso);\n                            }}\n                            onKeyUp={(event: KeyEvent) => {\n                              if (available && isActivation(event, \"up\"))\n                                select(iso);\n                            }}\n                            style={mergeStyles(\n                              recipeStyle(CALENDAR_DAY, theme),\n                              cellStyle(\n                                theme,\n                                paint,\n                                !isSameDay(startOfMonth(day), month),\n                                isSameDay(day, today),\n                                available,\n                              ),\n                            )}\n                          >\n                            {DateTime.toPartsUtc(day).day}\n                          </div>\n                        );\n                      },\n                    }),\n                  )}\n                </div>\n              ))}\n            </div>\n          </div>\n        );\n      })}\n    </div>\n  );\n};\n\nexport type { CalendarMode };\n\nexport const calendarMeta = {\n  name: \"Calendar\",\n  tier: 2,\n  status: \"done\",\n  gpuixSupport: \"partial\",\n  limitations: [\n    \"day, month and weekday labels are fixed English strings: the repo has no i18n layer\",\n    \"0.11.0 has no aria-current, so today is marked by a border only\",\n    \"0.11.0 has no aria-disabled and no live region: an unavailable day leaves the tab order, and a selection change is announced by the focused cell's name rather than a live region\",\n    \"no week numbers and no time of day: a time is the separate TimePicker\",\n  ],\n  docs: \"docs/calendar.mdx\",\n  example: \"examples/calendar.example.tsx\",\n  testFile: \"src/behaviour/calendar.test.tsx\",\n} as const;\n"
    },
    {
      "path": "packages/components/src/calendar/logic.ts",
      "target": "@ui/gpuixui/components/calendar/logic.ts",
      "type": "registry:lib",
      "content": "import { Match, pipe } from \"effect\";\nimport * as Arr from \"effect/Array\";\nimport * as DateTime from \"effect/DateTime\";\nimport * as Option from \"effect/Option\";\nimport * as P from \"effect/Predicate\";\n\nexport type WeekStart = 0 | 1;\n\nexport type DayOfWeek = 0 | 1 | 2 | 3 | 4 | 5 | 6;\n\nexport type CalendarMode = \"single\" | \"multiple\" | \"range\";\n\nexport type MonthCount = 1 | 2;\n\nexport type CaptionLayout = \"label\" | \"dropdown\";\n\nconst MONTHS: ReadonlyArray<string> = [\n  \"January\",\n  \"February\",\n  \"March\",\n  \"April\",\n  \"May\",\n  \"June\",\n  \"July\",\n  \"August\",\n  \"September\",\n  \"October\",\n  \"November\",\n  \"December\",\n];\n\nconst SHORT_MONTHS: ReadonlyArray<string> = [\n  \"Jan\",\n  \"Feb\",\n  \"Mar\",\n  \"Apr\",\n  \"May\",\n  \"Jun\",\n  \"Jul\",\n  \"Aug\",\n  \"Sep\",\n  \"Oct\",\n  \"Nov\",\n  \"Dec\",\n];\n\nconst WEEKDAYS: ReadonlyArray<string> = [\n  \"Sun\",\n  \"Mon\",\n  \"Tue\",\n  \"Wed\",\n  \"Thu\",\n  \"Fri\",\n  \"Sat\",\n];\n\nconst monthName = (parts: DateTime.DateTime.Parts): string =>\n  Option.getOrElse(Arr.get(MONTHS, parts.month - 1), () => String(parts.month));\n\nconst shortMonthName = (parts: DateTime.DateTime.Parts): string =>\n  Option.getOrElse(Arr.get(SHORT_MONTHS, parts.month - 1), () =>\n    String(parts.month),\n  );\n\nexport const weekdayLabels = (weekStartsOn: WeekStart): ReadonlyArray<string> =>\n  weekStartsOn === 1\n    ? [...Arr.drop(WEEKDAYS, 1), ...Arr.take(WEEKDAYS, 1)]\n    : WEEKDAYS;\n\nexport const formatMonthLabel = (value: DateTime.Utc): string => {\n  const parts = DateTime.toPartsUtc(value);\n  return `${monthName(parts)} ${parts.year}`;\n};\n\nexport const monthShortName = (month: number): string =>\n  Option.getOrElse(Arr.get(SHORT_MONTHS, month - 1), () => String(month));\n\nexport const formatDayLabel = (value: DateTime.Utc): string => {\n  const parts = DateTime.toPartsUtc(value);\n  return `${parts.day} ${formatMonthLabel(value)}`;\n};\n\nexport const formatShortDay = (value: DateTime.Utc): string => {\n  const parts = DateTime.toPartsUtc(value);\n  return `${shortMonthName(parts)} ${parts.day}, ${parts.year}`;\n};\n\nexport interface DayRange {\n  readonly from: string;\n  readonly to: string | null;\n}\n\nexport const formatRangeLabel = (range: DayRange): string => {\n  const from = parseIsoDay(range.from);\n  const to = Option.flatMap(Option.fromNullishOr(range.to), parseIsoDay);\n  return Option.match(to, {\n    onNone: () =>\n      Option.match(from, {\n        onNone: () => range.from,\n        onSome: formatShortDay,\n      }),\n    onSome: (end) => {\n      const start = Option.getOrNull(from);\n      if (start === null) return formatShortDay(end);\n      const startParts = DateTime.toPartsUtc(start);\n      const endParts = DateTime.toPartsUtc(end);\n      return startParts.year === endParts.year\n        ? `${shortMonthName(startParts)} ${startParts.day} – ${shortMonthName(endParts)} ${endParts.day}, ${endParts.year}`\n        : `${formatShortDay(start)} – ${formatShortDay(end)}`;\n    },\n  });\n};\n\nexport const startOfMonth = (value: DateTime.Utc): DateTime.Utc =>\n  DateTime.startOf(\"month\")(value);\n\nexport const addMonths = (value: DateTime.Utc, amount: number): DateTime.Utc =>\n  DateTime.add({ months: amount })(startOfMonth(value));\n\nexport const addDays = (value: DateTime.Utc, amount: number): DateTime.Utc =>\n  DateTime.add({ days: amount })(value);\n\nexport const lastDayOfMonth = (value: DateTime.Utc): DateTime.Utc =>\n  DateTime.add({ days: -1 })(addMonths(value, 1));\n\nexport const isSameDay = (left: DateTime.Utc, right: DateTime.Utc): boolean => {\n  const a = DateTime.toPartsUtc(left);\n  const b = DateTime.toPartsUtc(right);\n  return a.year === b.year && a.month === b.month && a.day === b.day;\n};\n\nexport const formatIsoDay = (value: DateTime.Utc): string =>\n  DateTime.formatIsoDateUtc(value);\n\nconst ISO_DAY = /^\\d{4}-\\d{2}-\\d{2}$/;\n\nexport const parseIsoDay = (value: string): Option.Option<DateTime.Utc> =>\n  pipe(\n    ISO_DAY.test(value) ? Option.some(value) : Option.none(),\n    Option.flatMap((day) => DateTime.make(`${day}T00:00:00.000Z`)),\n    Option.filter((parsed) => DateTime.formatIsoDateUtc(parsed) === value),\n    Option.map((parsed) => DateTime.startOf(\"day\")(parsed)),\n  );\n\nexport const todayUtc = (now: DateTime.Utc): DateTime.Utc =>\n  DateTime.startOf(\"day\")(now);\n\nexport const monthGrid = (\n  month: DateTime.Utc,\n  weekStartsOn: WeekStart,\n  showOutsideDays = true,\n): ReadonlyArray<ReadonlyArray<Option.Option<DateTime.Utc>>> => {\n  const start = startOfMonth(month);\n  const monthParts = DateTime.toPartsUtc(start);\n  const offset = (monthParts.weekDay - weekStartsOn + 7) % 7;\n  const firstCell = addDays(start, -offset);\n\n  const cell = (index: number): Option.Option<DateTime.Utc> => {\n    const day = addDays(firstCell, index);\n    const parts = DateTime.toPartsUtc(day);\n    const own =\n      parts.year === monthParts.year && parts.month === monthParts.month;\n    return own || showOutsideDays ? Option.some(day) : Option.none();\n  };\n\n  return Arr.map(Arr.range(0, 5), (week) =>\n    Arr.map(Arr.range(0, 6), (day) => cell(week * 7 + day)),\n  );\n};\n\nexport const monthWindow = (\n  viewMonth: DateTime.Utc,\n  count: MonthCount,\n): ReadonlyArray<DateTime.Utc> =>\n  Arr.map(Arr.range(0, count - 1), (index) => addMonths(viewMonth, index));\n\nexport const windowStart = (viewMonth: DateTime.Utc): DateTime.Utc =>\n  startOfMonth(viewMonth);\n\nexport const windowEnd = (\n  viewMonth: DateTime.Utc,\n  count: MonthCount,\n): DateTime.Utc => lastDayOfMonth(addMonths(viewMonth, count - 1));\n\nexport const visibleMonth = (\n  viewMonth: DateTime.Utc,\n  count: MonthCount,\n  day: DateTime.Utc,\n): DateTime.Utc => {\n  const millis = DateTime.toEpochMillis(day);\n  if (millis < DateTime.toEpochMillis(windowStart(viewMonth)))\n    return startOfMonth(day);\n  if (millis > DateTime.toEpochMillis(windowEnd(viewMonth, count)))\n    return addMonths(startOfMonth(day), -(count - 1));\n  return startOfMonth(viewMonth);\n};\n\nconst gridStart = (\n  month: DateTime.Utc,\n  weekStartsOn: WeekStart,\n): DateTime.Utc => {\n  const start = startOfMonth(month);\n  const offset = (DateTime.toPartsUtc(start).weekDay - weekStartsOn + 7) % 7;\n  return addDays(start, -offset);\n};\n\nconst gridEnd = (month: DateTime.Utc, weekStartsOn: WeekStart): DateTime.Utc =>\n  addDays(gridStart(month, weekStartsOn), 41);\n\nexport interface DayBounds {\n  readonly min: Option.Option<DateTime.Utc>;\n  readonly max: Option.Option<DateTime.Utc>;\n}\n\nexport const unbounded: DayBounds = {\n  min: Option.none(),\n  max: Option.none(),\n};\n\nexport const boundsOf = (\n  min?: string | null,\n  max?: string | null,\n): DayBounds => ({\n  min: Option.flatMap(Option.fromNullishOr(min), parseIsoDay),\n  max: Option.flatMap(Option.fromNullishOr(max), parseIsoDay),\n});\n\nexport interface DayMatchers {\n  readonly before?: string;\n\n  readonly after?: string;\n\n  readonly range?: {\n    readonly from?: string;\n    readonly to?: string;\n  };\n\n  readonly weekdays?: ReadonlyArray<DayOfWeek>;\n\n  readonly filter?: (day: string) => boolean;\n}\n\nexport const boundsOfMatchers = (\n  matchers: DayMatchers | undefined,\n): DayBounds => {\n  const shift = (end: \"before\" | \"after\") =>\n    Option.flatMap(\n      Option.fromNullishOr(\n        end === \"before\" ? matchers?.before : matchers?.after,\n      ),\n      (iso) =>\n        Option.map(parseIsoDay(iso), (day) =>\n          addDays(day, end === \"before\" ? 1 : -1),\n        ),\n    );\n  return { min: shift(\"before\"), max: shift(\"after\") };\n};\n\nexport const isAvailable = (day: DateTime.Utc, bounds: DayBounds): boolean => {\n  const millis = DateTime.toEpochMillis(day);\n  return (\n    Option.match(bounds.min, {\n      onNone: () => true,\n      onSome: (min) => millis >= DateTime.toEpochMillis(min),\n    }) &&\n    Option.match(bounds.max, {\n      onNone: () => true,\n      onSome: (max) => millis <= DateTime.toEpochMillis(max),\n    })\n  );\n};\n\nexport const isDisabled = (\n  day: DateTime.Utc,\n  matchers: DayMatchers | undefined,\n): boolean => {\n  if (matchers === undefined) return false;\n  const iso = formatIsoDay(day);\n  const millis = DateTime.toEpochMillis(day);\n  const edge = (value: string | undefined): Option.Option<number> =>\n    Option.map(\n      Option.flatMap(Option.fromNullishOr(value), parseIsoDay),\n      DateTime.toEpochMillis,\n    );\n  const atOrAfter = (bound: Option.Option<number>): boolean =>\n    Option.match(bound, {\n      onNone: () => true,\n      onSome: (value) => millis >= value,\n    });\n  const atOrBefore = (bound: Option.Option<number>): boolean =>\n    Option.match(bound, {\n      onNone: () => true,\n      onSome: (value) => millis <= value,\n    });\n  const inSpan =\n    matchers.range !== undefined &&\n    atOrAfter(edge(matchers.range.from)) &&\n    atOrBefore(edge(matchers.range.to));\n  return (\n    Option.exists(edge(matchers.before), (before) => millis < before) ||\n    Option.exists(edge(matchers.after), (after) => millis > after) ||\n    inSpan ||\n    Arr.contains(DateTime.toPartsUtc(day).weekDay as DayOfWeek)(\n      matchers.weekdays ?? [],\n    ) ||\n    (matchers.filter !== undefined && matchers.filter(iso))\n  );\n};\n\nexport const isDayAvailable = (\n  day: DateTime.Utc,\n  bounds: DayBounds,\n  matchers: DayMatchers | undefined,\n): boolean => isAvailable(day, bounds) && !isDisabled(day, matchers);\n\nexport const clampToBounds = (\n  day: DateTime.Utc,\n  bounds: DayBounds,\n): DateTime.Utc => {\n  const millis = DateTime.toEpochMillis(day);\n  const lower = Option.match(bounds.min, {\n    onNone: () => day,\n    onSome: (min) => (millis < DateTime.toEpochMillis(min) ? min : day),\n  });\n  return Option.match(bounds.max, {\n    onNone: () => lower,\n    onSome: (max) =>\n      DateTime.toEpochMillis(lower) > DateTime.toEpochMillis(max) ? max : lower,\n  });\n};\n\nexport const canBrowseMonth = (\n  viewMonth: DateTime.Utc,\n  direction: -1 | 1,\n  bounds: DayBounds,\n): boolean => {\n  const current = DateTime.toEpochMillis(startOfMonth(viewMonth));\n  return Match.value(direction).pipe(\n    Match.when(-1, () =>\n      Option.match(bounds.min, {\n        onNone: () => true,\n        onSome: (min) => current > DateTime.toEpochMillis(startOfMonth(min)),\n      }),\n    ),\n    Match.when(1, () =>\n      Option.match(bounds.max, {\n        onNone: () => true,\n        onSome: (max) => current < DateTime.toEpochMillis(startOfMonth(max)),\n      }),\n    ),\n    Match.exhaustive,\n  );\n};\n\nexport type MoveKey =\n  | \"left\"\n  | \"right\"\n  | \"up\"\n  | \"down\"\n  | \"home\"\n  | \"end\"\n  | \"page-up\"\n  | \"page-down\";\n\nexport interface Move {\n  readonly key: MoveKey;\n  readonly year?: boolean;\n}\n\nexport interface MoveOptions {\n  readonly weekStartsOn: WeekStart;\n  readonly viewMonth: DateTime.Utc;\n  readonly months: MonthCount;\n  readonly showOutsideDays: boolean;\n  readonly bounds: DayBounds;\n  readonly matchers: DayMatchers | undefined;\n  readonly fromYear: number;\n  readonly toYear: number;\n}\n\nconst stepOf = (\n  from: DateTime.Utc,\n  move: Move,\n  options: MoveOptions,\n): DateTime.Utc => {\n  const parts = DateTime.toPartsUtc(from);\n  const offset = (parts.weekDay - options.weekStartsOn + 7) % 7;\n  const inMonth = (amount: number): DateTime.Utc => {\n    const target = addMonths(from, amount);\n    const last = DateTime.toPartsUtc(lastDayOfMonth(target)).day;\n    return addDays(startOfMonth(target), Math.min(parts.day, last) - 1);\n  };\n  return Match.value(move.key).pipe(\n    Match.when(\"left\", () => addDays(from, -1)),\n    Match.when(\"right\", () => addDays(from, 1)),\n    Match.when(\"up\", () => addDays(from, -7)),\n    Match.when(\"down\", () => addDays(from, 7)),\n    Match.when(\"home\", () => addDays(from, -offset)),\n    Match.when(\"end\", () => addDays(from, 6 - offset)),\n    Match.when(\"page-up\", () => inMonth(move.year === true ? -12 : -1)),\n    Match.when(\"page-down\", () => inMonth(move.year === true ? 12 : 1)),\n    Match.exhaustive,\n  );\n};\n\nconst clampYear = (\n  day: DateTime.Utc,\n  fromYear: number,\n  toYear: number,\n): DateTime.Utc => {\n  const parts = DateTime.toPartsUtc(day);\n  const year = Math.min(Math.max(parts.year, fromYear), toYear);\n  if (year === parts.year) return day;\n  const first = DateTime.make(\n    `${String(year).padStart(4, \"0\")}-${String(parts.month).padStart(2, \"0\")}-01T00:00:00.000Z`,\n  );\n  return Option.match(first, {\n    onNone: () => day,\n    onSome: (month) =>\n      addDays(\n        month,\n        Math.min(parts.day, DateTime.toPartsUtc(lastDayOfMonth(month)).day) - 1,\n      ),\n  });\n};\n\nexport const moveDay = (\n  from: DateTime.Utc,\n  move: Move,\n  options: MoveOptions,\n): DateTime.Utc => {\n  const raw =\n    move.year === true\n      ? clampYear(stepOf(from, move, options), options.fromYear, options.toYear)\n      : stepOf(from, move, options);\n\n  const bounded = clampToBounds(raw, options.bounds);\n  const paging = move.key === \"page-up\" || move.key === \"page-down\";\n  const windowFirst = paging ? startOfMonth(bounded) : options.viewMonth;\n  const windowLast = paging\n    ? startOfMonth(bounded)\n    : addMonths(options.viewMonth, options.months - 1);\n  const ownFirst = paging ? startOfMonth(bounded) : startOfMonth(from);\n  const ownLast = paging ? lastDayOfMonth(bounded) : lastDayOfMonth(from);\n  const lower = options.showOutsideDays\n    ? gridStart(windowFirst, options.weekStartsOn)\n    : ownFirst;\n  const upper = options.showOutsideDays\n    ? gridEnd(windowLast, options.weekStartsOn)\n    : ownLast;\n  const clamp = (day: DateTime.Utc): DateTime.Utc => {\n    const millis = DateTime.toEpochMillis(day);\n    if (millis < DateTime.toEpochMillis(lower)) return lower;\n    if (millis > DateTime.toEpochMillis(upper)) return upper;\n    return day;\n  };\n  const target = clamp(bounded);\n  const direction =\n    DateTime.toEpochMillis(target) < DateTime.toEpochMillis(from) ? -1 : 1;\n  const inside = (day: DateTime.Utc): boolean => {\n    const millis = DateTime.toEpochMillis(day);\n    return (\n      millis >= DateTime.toEpochMillis(lower) &&\n      millis <= DateTime.toEpochMillis(upper)\n    );\n  };\n  const search = (steps: number): DateTime.Utc => {\n    const candidate = addDays(target, steps * direction);\n    return steps > 84 || !inside(candidate)\n      ? from\n      : isDayAvailable(candidate, options.bounds, options.matchers)\n        ? candidate\n        : search(steps + 1);\n  };\n  return isDayAvailable(target, options.bounds, options.matchers)\n    ? target\n    : search(0);\n};\n\nexport const yearRange = (\n  fromYear: number,\n  toYear: number,\n): ReadonlyArray<number> =>\n  fromYear <= toYear ? Arr.range(fromYear, toYear) : Arr.empty();\n\nexport type Selection =\n  | { readonly mode: \"single\"; readonly day: string | null }\n  | { readonly mode: \"multiple\"; readonly days: ReadonlyArray<string> }\n  | { readonly mode: \"range\"; readonly range: DayRange | null };\n\nexport const singleSelection = (day: string | null): Selection => ({\n  mode: \"single\",\n  day,\n});\n\nexport const multipleSelection = (days: ReadonlyArray<string>): Selection => ({\n  mode: \"multiple\",\n  days,\n});\n\nexport const rangeSelection = (range: DayRange | null): Selection => ({\n  mode: \"range\",\n  range,\n});\n\nexport const rangeOf = (value: unknown): DayRange | null => {\n  if (typeof value !== \"object\" || value === null) return null;\n  const source = value as { readonly from?: unknown; readonly to?: unknown };\n  if (!P.isString(source.from) || Option.isNone(parseIsoDay(source.from)))\n    return null;\n  return {\n    from: source.from,\n    to:\n      P.isString(source.to) && Option.isSome(parseIsoDay(source.to))\n        ? source.to\n        : null,\n  };\n};\n\nexport const rangeContains = (range: DayRange | null, day: string): boolean => {\n  if (range === null) return false;\n  const millis = Option.match(parseIsoDay(day), {\n    onNone: () => null,\n    onSome: DateTime.toEpochMillis,\n  });\n  const start = Option.match(parseIsoDay(range.from), {\n    onNone: () => null,\n    onSome: DateTime.toEpochMillis,\n  });\n  const end = Option.match(Option.fromNullishOr(range.to), {\n    onNone: () => start,\n    onSome: (iso) =>\n      Option.match(parseIsoDay(iso), {\n        onNone: () => start,\n        onSome: DateTime.toEpochMillis,\n      }),\n  });\n  return millis !== null && start !== null && end !== null\n    ? millis >= start && millis <= end\n    : false;\n};\n\nexport const nextRange = (range: DayRange | null, day: string): DayRange =>\n  range === null || range.to !== null || day < range.from\n    ? { from: day, to: null }\n    : { from: range.from, to: day };\n\nexport const nextDay = (current: string | null, day: string): string | null =>\n  current === day ? null : day;\n\nexport const toggleDay = (\n  days: ReadonlyArray<string>,\n  day: string,\n): ReadonlyArray<string> =>\n  Arr.contains(day)(days)\n    ? Arr.filter(days, (held) => held !== day)\n    : [...days, day];\n\nexport const dayInMonth = (\n  value: DateTime.Utc,\n  month: DateTime.Utc,\n): DateTime.Utc => {\n  const parts = DateTime.toPartsUtc(value);\n  const target = startOfMonth(month);\n  const last = DateTime.toPartsUtc(lastDayOfMonth(target)).day;\n  return addDays(target, Math.min(parts.day, last) - 1);\n};\n\nexport type DayPaint =\n  | \"none\"\n  | \"selected\"\n  | \"range-start\"\n  | \"range-middle\"\n  | \"range-end\";\n\nexport const paintOf = (selection: Selection, day: string): DayPaint => {\n  if (selection.mode === \"single\")\n    return selection.day === day ? \"selected\" : \"none\";\n  if (selection.mode === \"multiple\")\n    return Arr.contains(day)(selection.days) ? \"selected\" : \"none\";\n  const range = selection.range;\n  if (range === null) return \"none\";\n  if (range.from === day) return \"range-start\";\n  if (range.to === day) return \"range-end\";\n  return rangeContains(range, day) ? \"range-middle\" : \"none\";\n};\n\nexport const isPainted = (paint: DayPaint): boolean =>\n  paint === \"selected\" || paint === \"range-start\" || paint === \"range-end\";\n\nexport const dayAriaLabel = (\n  day: DateTime.Utc,\n  paint: DayPaint,\n  available: boolean,\n): string => {\n  const name = formatDayLabel(day);\n  const state = Match.value(paint).pipe(\n    Match.when(\"selected\", () => \", selected\"),\n    Match.when(\"range-start\", () => \", range start\"),\n    Match.when(\"range-middle\", () => \", in range\"),\n    Match.when(\"range-end\", () => \", range end\"),\n    Match.orElse(() => \"\"),\n  );\n  return `${name}${state}${available ? \"\" : \", unavailable\"}`;\n};\n\nexport const describeSelection = (selection: Selection): string => {\n  if (selection.mode === \"single\")\n    return Option.match(\n      Option.flatMap(Option.fromNullishOr(selection.day), parseIsoDay),\n      {\n        onNone: () => \"no day selected\",\n        onSome: (day) => `${formatDayLabel(day)} selected`,\n      },\n    );\n  if (selection.mode === \"multiple\")\n    return selection.days.length === 0\n      ? \"no days selected\"\n      : `${selection.days.length} selected`;\n  return selection.range === null\n    ? \"no range selected\"\n    : `range ${formatRangeLabel(selection.range)}`;\n};\n\nexport const calendarLabel = (label: string, selection: Selection): string =>\n  `${label}, ${describeSelection(selection)}`;\n\nexport const hasSelection = (selection: Selection): boolean =>\n  Match.value(selection).pipe(\n    Match.when({ mode: \"single\" }, (current) => current.day !== null),\n    Match.when({ mode: \"multiple\" }, (current) => current.days.length > 0),\n    Match.when({ mode: \"range\" }, (current) => current.range !== null),\n    Match.exhaustive,\n  );\n\nexport const formatSelectionLabel = (\n  selection: Selection,\n  placeholder: string,\n): string => {\n  if (!hasSelection(selection)) return placeholder;\n  return Match.value(selection).pipe(\n    Match.when({ mode: \"single\" }, (current) =>\n      Option.match(\n        Option.flatMap(Option.fromNullishOr(current.day), parseIsoDay),\n        { onNone: () => placeholder, onSome: formatShortDay },\n      ),\n    ),\n    Match.when({ mode: \"multiple\" }, (current) =>\n      current.days.length === 1\n        ? formatSelectionLabel(\n            singleSelection(current.days[0] ?? null),\n            placeholder,\n          )\n        : `${current.days.length} days`,\n    ),\n    Match.when({ mode: \"range\" }, (current) =>\n      current.range === null ? placeholder : formatRangeLabel(current.range),\n    ),\n    Match.exhaustive,\n  );\n};\n\nexport const isOutsideMonth = (\n  day: DateTime.Utc,\n  month: DateTime.Utc,\n): boolean => !isSameDay(startOfMonth(day), startOfMonth(month));\n\nexport const moveKeyOf = (key: string): Option.Option<MoveKey> =>\n  Match.value(key).pipe(\n    Match.when(\"left\", () => Option.some(\"left\" as const)),\n    Match.when(\"right\", () => Option.some(\"right\" as const)),\n    Match.when(\"up\", () => Option.some(\"up\" as const)),\n    Match.when(\"down\", () => Option.some(\"down\" as const)),\n    Match.when(\"home\", () => Option.some(\"home\" as const)),\n    Match.when(\"end\", () => Option.some(\"end\" as const)),\n    Match.when(\"pageup\", () => Option.some(\"page-up\" as const)),\n    Match.when(\"pagedown\", () => Option.some(\"page-down\" as const)),\n    Match.orElse(() => Option.none()),\n  );\n"
    },
    {
      "path": "packages/components/src/calendar/store.ts",
      "target": "@ui/gpuixui/components/calendar/store.ts",
      "type": "registry:lib",
      "content": "import { Effect } from \"effect\";\nimport * as DateTime from \"effect/DateTime\";\nimport * as SubscriptionRef from \"effect/SubscriptionRef\";\nimport { makeLocalState, type LocalState } from \"../internal/local-state.js\";\nimport { visibleMonth, type MonthCount } from \"./logic.js\";\n\nexport interface CalendarViewState {\n  readonly month: DateTime.Utc;\n\n  readonly focus: DateTime.Utc;\n\n  readonly pending: boolean;\n}\n\nexport interface CalendarStore {\n  readonly local: LocalState<CalendarViewState>;\n\n  readonly count: MonthCount;\n\n  readonly focusDay: (day: DateTime.Utc) => Effect.Effect<void>;\n\n  readonly show: (\n    month: DateTime.Utc,\n    day: DateTime.Utc,\n  ) => Effect.Effect<void>;\n\n  readonly visited: (day: DateTime.Utc) => Effect.Effect<void>;\n\n  readonly settle: Effect.Effect<void>;\n}\n\nexport const makeCalendarStore = (initial: {\n  readonly month: DateTime.Utc;\n  readonly focus: DateTime.Utc;\n  readonly count: MonthCount;\n  readonly pending?: boolean;\n}): Effect.Effect<CalendarStore> =>\n  Effect.gen(function* () {\n    const count = initial.count;\n    const local = yield* makeLocalState<CalendarViewState>({\n      month: initial.month,\n      focus: initial.focus,\n      pending: initial.pending ?? false,\n    });\n\n    const focusDay = Effect.fnUntraced(function* (day: DateTime.Utc) {\n      const current = yield* SubscriptionRef.get(local.state);\n      yield* local.write({\n        month: visibleMonth(current.month, count, day),\n        focus: day,\n        pending: true,\n      });\n    });\n\n    const show = Effect.fnUntraced(function* (\n      month: DateTime.Utc,\n      day: DateTime.Utc,\n    ) {\n      yield* local.write({ month, focus: day, pending: true });\n    });\n\n    const visited = Effect.fnUntraced(function* (day: DateTime.Utc) {\n      const current = yield* SubscriptionRef.get(local.state);\n      if (DateTime.toEpochMillis(current.focus) === DateTime.toEpochMillis(day))\n        return;\n      yield* local.write({\n        month: visibleMonth(current.month, count, day),\n        focus: day,\n        pending: false,\n      });\n    });\n\n    const settle = Effect.flatMap(SubscriptionRef.get(local.state), (current) =>\n      current.pending\n        ? local.write({ ...current, pending: false })\n        : Effect.void,\n    );\n\n    return { local, count, focusDay, show, visited, settle };\n  });\n"
    },
    {
      "path": "packages/components/src/internal/button.tsx",
      "target": "@ui/gpuixui/components/internal/button.tsx",
      "type": "registry:component",
      "content": "/** @jsxImportSource @gpuix/react */\nimport type { Props } from \"@gpuix/react\";\nimport type { ReactNode } from \"react\";\nimport {\n  Button as PrimitiveButton,\n  IconButton as PrimitiveIconButton,\n  actionOnColor as primitiveActionOnColor,\n  type ButtonVariant as PrimitiveVariant,\n} from \"../../primitives/button.js\";\nimport { cn } from \"../../tw/index.js\";\nimport * as Schema from \"effect/Schema\";\nimport type { Theme } from \"./theme.js\";\n\nconst ButtonVariants = Schema.Literals([\n  \"primary\",\n  \"secondary\",\n  \"ghost\",\n  \"danger\",\n  \"link\",\n]);\n\nexport type ButtonVariant = typeof ButtonVariants.Type;\n\nexport type ButtonSize = \"sm\" | \"md\" | \"lg\";\n\nexport interface ButtonProps extends Props {\n  readonly variant?: ButtonVariant;\n\n  readonly size?: ButtonSize;\n\n  readonly disabled?: boolean;\n\n  readonly loading?: boolean;\n\n  readonly loadingLabel?: string;\n\n  readonly reducedMotion?: boolean;\n\n  readonly leading?: ReactNode;\n\n  readonly trailing?: ReactNode;\n}\n\nexport interface IconButtonProps extends Props {\n  readonly label: string;\n\n  readonly size?: ButtonSize;\n  readonly disabled?: boolean;\n}\n\ninterface Look {\n  readonly variant: PrimitiveVariant;\n  readonly className: string;\n}\n\nconst LOOKS: Readonly<Record<ButtonVariant, Look>> = {\n  primary: { variant: \"primary\", className: \"\" },\n  secondary: { variant: \"secondary\", className: \"border border-strong\" },\n  ghost: { variant: \"ghost\", className: \"\" },\n  danger: { variant: \"destructive\", className: \"\" },\n\n  link: { variant: \"link\", className: \"underline underline-offset-4\" },\n};\n\nconst lookOf = (variant: unknown): Look =>\n  LOOKS[Schema.is(ButtonVariants)(variant) ? variant : \"secondary\"];\n\nexport const actionOnColor = (theme: Theme, variant: ButtonVariant): string =>\n  primitiveActionOnColor(theme, lookOf(variant).variant);\n\nexport const Button = ({\n  variant = \"secondary\",\n  size = \"md\",\n  disabled = false,\n  onClick,\n  style,\n  \"aria-label\": ariaLabel,\n  ...rest\n}: ButtonProps) => {\n  const look = lookOf(variant);\n  return (\n    <PrimitiveButton\n      {...rest}\n      variant={look.variant}\n      size={size}\n      disabled={disabled}\n      label={ariaLabel}\n      className={cn(look.className)}\n      onActivate={onClick}\n      style={style}\n    />\n  );\n};\n\nexport const IconButton = ({\n  label,\n  size = \"md\",\n  disabled = false,\n  onClick,\n  style,\n  children,\n  ...rest\n}: IconButtonProps) => (\n  <PrimitiveIconButton\n    {...rest}\n    icon={children}\n    variant=\"ghost\"\n    size={size}\n    disabled={disabled}\n    label={label}\n    className=\"text-muted-foreground hover:text-foreground\"\n    onActivate={onClick}\n    style={style}\n  />\n);\n"
    },
    {
      "path": "packages/components/src/internal/key.ts",
      "target": "@ui/gpuixui/components/internal/key.ts",
      "type": "registry:lib",
      "content": "import type { EventPayload, KeyEvent, Props } from \"@gpuix/react\";\nimport * as Option from \"effect/Option\";\n\nexport type KeyPhase = \"down\" | \"up\";\n\nexport const isActivation = (event: EventPayload, phase: KeyPhase): boolean => {\n  if (event.isHeld === true) return false;\n  if (event.key === \"enter\") return phase === \"down\";\n  return event.key === \"space\" && phase === \"up\";\n};\n\nexport const swallowsDefault = (\n  event: EventPayload,\n  phase: KeyPhase,\n): boolean => event.key === \"space\" && phase === \"down\";\n\nexport const activationHandlers = (\n  activate: (event: KeyEvent) => void,\n  observe: Pick<Props, \"onKeyDown\" | \"onKeyUp\"> = {},\n): Pick<Props, \"onKeyDown\" | \"onKeyUp\"> => ({\n  onKeyDown: (event: KeyEvent) => {\n    if (swallowsDefault(event, \"down\")) event.preventDefault();\n    if (isActivation(event, \"down\")) activate(event);\n    observe.onKeyDown?.(event);\n  },\n  onKeyUp: (event: KeyEvent) => {\n    if (isActivation(event, \"up\")) activate(event);\n    observe.onKeyUp?.(event);\n  },\n});\n\nexport const isEnter = (event: EventPayload): boolean => event.key === \"enter\";\n\nexport const isDown = (event: EventPayload): boolean =>\n  event.key === \"down\" || (event.key === \"n\" && event.modifiers?.ctrl === true);\n\nexport const isUp = (event: EventPayload): boolean =>\n  event.key === \"up\" || (event.key === \"p\" && event.modifiers?.ctrl === true);\n\nexport const isRight = (event: EventPayload): boolean => event.key === \"right\";\n\nexport const isLeft = (event: EventPayload): boolean => event.key === \"left\";\n\nexport const isFirst = (event: EventPayload): boolean => event.key === \"home\";\n\nexport const isLast = (event: EventPayload): boolean => event.key === \"end\";\n\nexport const isPageUp = (event: EventPayload): boolean =>\n  event.key === \"pageup\";\n\nexport const isPageDown = (event: EventPayload): boolean =>\n  event.key === \"pagedown\";\n\nexport const isDismiss = (event: EventPayload): boolean =>\n  event.key === \"escape\";\n\nexport const isTab = (event: EventPayload): boolean => event.key === \"tab\";\n\nexport const isSelectAll = (event: EventPayload): boolean =>\n  event.key === \"a\" &&\n  (event.modifiers?.cmd === true || event.modifiers?.ctrl === true);\n\nexport const isMenuKey = (event: EventPayload): boolean =>\n  (event.key === \"f10\" && event.modifiers?.shift === true) ||\n  event.key === \"contextmenu\";\n\nexport const axisDirection = (\n  event: EventPayload,\n  orientation: \"horizontal\" | \"vertical\",\n): Option.Option<1 | -1> => {\n  if (event.key === \"right\") return Option.some(1);\n  if (event.key === \"left\") return Option.some(-1);\n  if (orientation === \"vertical\") {\n    if (isDown(event)) return Option.some(1);\n    if (isUp(event)) return Option.some(-1);\n  }\n  return Option.none();\n};\n"
    },
    {
      "path": "packages/components/src/internal/local-state.ts",
      "target": "@ui/gpuixui/components/internal/local-state.ts",
      "type": "registry:lib",
      "content": "import { Effect } from \"effect\";\nimport * as Arr from \"effect/Array\";\nimport * as Duration from \"effect/Duration\";\nimport * as Fiber from \"effect/Fiber\";\nimport * as Option from \"effect/Option\";\nimport * as Ref from \"effect/Ref\";\nimport * as SubscriptionRef from \"effect/SubscriptionRef\";\nimport { useEffect, useState, useSyncExternalStore } from \"react\";\n\nexport interface LocalState<A> {\n  readonly state: SubscriptionRef.SubscriptionRef<A>;\n\n  readonly read: () => A;\n\n  readonly subscribe: (listener: () => void) => () => void;\n\n  readonly write: (next: A) => Effect.Effect<void>;\n\n  readonly after: (\n    millis: number,\n    effect: Effect.Effect<void>,\n  ) => Effect.Effect<void>;\n\n  readonly cancel: Effect.Effect<void>;\n\n  readonly running: () => boolean;\n}\n\nexport const makeLocalState = <A>(initial: A): Effect.Effect<LocalState<A>> =>\n  Effect.gen(function* () {\n    const state = yield* SubscriptionRef.make(initial);\n    const timer = yield* Ref.make(Option.none<Fiber.Fiber<void>>());\n    const listeners = yield* Ref.make<ReadonlyArray<() => void>>(Arr.empty());\n\n    const write = Effect.fnUntraced(function* (next: A) {\n      yield* SubscriptionRef.set(state, next);\n      const subscribers = yield* Ref.get(listeners);\n      yield* Effect.sync(() => {\n        Arr.forEach(subscribers, (listener) => listener());\n      });\n    });\n\n    const cancel = Effect.gen(function* () {\n      const held = yield* Ref.getAndSet(timer, Option.none());\n      yield* Option.match(held, {\n        onNone: () => Effect.void,\n        onSome: Fiber.interrupt,\n      });\n    });\n\n    const after = Effect.fnUntraced(function* (\n      millis: number,\n      effect: Effect.Effect<void>,\n    ) {\n      yield* cancel;\n      const fiber = yield* Effect.forkDetach(\n        Effect.sleep(Duration.millis(millis)).pipe(Effect.andThen(effect)),\n      );\n      yield* Ref.set(timer, Option.some(fiber));\n    });\n\n    const running = (): boolean =>\n      Option.exists(\n        Ref.getUnsafe(timer),\n        (fiber) => fiber.pollUnsafe() === undefined,\n      );\n\n    const subscribe = (listener: () => void): (() => void) => {\n      Effect.runSync(\n        Ref.update(listeners, (current) => Arr.append(current, listener)),\n      );\n      return () => {\n        Effect.runSync(\n          Ref.update(listeners, (current) =>\n            Arr.filter(current, (held) => held !== listener),\n          ),\n        );\n      };\n    };\n\n    return {\n      state,\n\n      read: () => SubscriptionRef.getUnsafe(state),\n      subscribe,\n      write,\n      after,\n      cancel,\n      running,\n    };\n  });\n\ninterface Teardown {\n  readonly local: { readonly cancel: Effect.Effect<void> };\n}\n\nexport const useLocalStore = <Store extends Teardown>(\n  make: Effect.Effect<Store>,\n): Store => {\n  const [store] = useState(() => Effect.runSync(make));\n  useEffect(() => () => send(store.local.cancel), [store]);\n  return store;\n};\n\nexport const send = (command: Effect.Effect<void>): void => {\n  Effect.runFork(command);\n};\n\nexport const useLocalState = <A>(local: LocalState<A>): A =>\n  useSyncExternalStore(local.subscribe, local.read, local.read);\n\nexport const useLocalSlice = <A, B>(\n  local: LocalState<A>,\n  select: (state: A) => B,\n): B =>\n  useSyncExternalStore(\n    local.subscribe,\n    () => select(local.read()),\n    () => select(local.read()),\n  );\n"
    },
    {
      "path": "packages/components/src/internal/recipe.ts",
      "target": "@ui/gpuixui/components/internal/recipe.ts",
      "type": "registry:lib",
      "content": "import type { StyleDesc } from \"@gpuix/react\";\nimport { createRecipeCache } from \"../../tw/index.js\";\nimport type { Theme } from \"./theme.js\";\n\nexport const recipeStyle: (recipe: string, theme: Theme) => StyleDesc =\n  createRecipeCache(512);\n"
    },
    {
      "path": "packages/components/src/internal/theme.ts",
      "target": "@ui/gpuixui/components/internal/theme.ts",
      "type": "registry:lib",
      "content": "import type { StyleDesc } from \"@gpuix/react\";\nimport * as Schema from \"effect/Schema\";\nimport {\n  alpha,\n  avatarPixels,\n  avatarSize,\n  brandTextOn,\n  controlFocusRing,\n  controlHeight,\n  controlPaddingX,\n  currentPlatform,\n  darkTheme,\n  disabledAction,\n  disabledOpacity,\n  elevationShadow,\n  filledHover,\n  filledPressed,\n  findHighlight,\n  focusRing,\n  keyboardFocusRing,\n  lightTheme,\n  nativeTextTheme,\n  pointerWash,\n  selectionOn,\n  statusTone,\n  syntaxColors,\n  targetSize,\n  textStyle,\n  type BoxShadow,\n  type ElevationLevel,\n  type FindHighlightSource,\n  type NativeTextFill,\n  type PlatformName,\n  type PointerWashSurface,\n  type StatusTone,\n  type SyntaxColors,\n  type SyntaxRole,\n  type TextRole,\n  type Theme,\n  type ThemeColors,\n} from \"../../tokens/index.js\";\n\nexport {\n  alpha,\n  avatarPixels,\n  avatarSize,\n  controlFocusRing,\n  controlHeight,\n  controlPaddingX,\n  currentPlatform,\n  darkTheme,\n  disabledAction,\n  disabledOpacity,\n  elevationShadow,\n  filledHover,\n  filledPressed,\n  findHighlight,\n  focusRing,\n  keyboardFocusRing,\n  lightTheme,\n  nativeTextTheme,\n  statusTone,\n  syntaxColors,\n  targetSize,\n  textStyle,\n};\nexport type {\n  BoxShadow,\n  ElevationLevel,\n  FindHighlightSource,\n  NativeTextFill,\n  PlatformName,\n  StatusTone,\n  SyntaxColors,\n  SyntaxRole,\n  TextRole,\n  Theme,\n};\nexport { ThemeProvider, useTheme } from \"../../tokens/react.js\";\n\nexport const keyboardRing = (theme: Theme, invalid = false): StyleDesc =>\n  controlFocusRing(theme, { invalid }) ?? {};\n\nexport interface ControlRingState {\n  readonly disabled?: boolean;\n\n  readonly invalid?: boolean;\n}\n\nexport const controlRing = (\n  theme: Theme,\n  state: ControlRingState = {},\n): StyleDesc => controlFocusRing(theme, state) ?? {};\n\nexport const pressWash = (theme: Theme, replaced: PointerWashSurface): string =>\n  pointerWash(theme, \"active\", replaced) ?? theme.colors.active;\n\nexport const selectionWash = (theme: Theme): StyleDesc => ({\n  selectionColor: theme.colors.selection,\n});\n\nexport const keepContent: StyleDesc = { keyboardFocusDim: false };\n\nexport const disabledFade = (\n  disabled: boolean,\n): { readonly opacity: number } | undefined =>\n  disabled ? { opacity: disabledOpacity } : undefined;\n\nconst Tones = Schema.Literals([\"info\", \"success\", \"warning\", \"danger\"]);\n\nexport type Tone = typeof Tones.Type;\n\nexport const toneOf = (value: unknown): Tone =>\n  Schema.is(Tones)(value) ? value : \"info\";\n\nexport interface ToneStyle {\n  readonly fg: string;\n  readonly bg: string;\n  readonly border: string;\n}\n\nconst TOKEN_TONE: Readonly<Record<Tone, StatusTone>> = {\n  info: \"info\",\n  success: \"success\",\n  warning: \"warning\",\n  danger: \"destructive\",\n};\n\nexport const tone = (theme: Theme, value: Tone): ToneStyle => {\n  const { background, border, foreground } = statusTone(\n    theme,\n    TOKEN_TONE[value],\n  );\n  return { bg: background, border, fg: foreground };\n};\n\nconst softRoles: Readonly<Record<Tone, keyof ThemeColors>> = {\n  info: \"infoSoft\",\n  success: \"successSoft\",\n  warning: \"warningSoft\",\n  danger: \"destructiveSoft\",\n};\n\nexport const messageLink = (theme: Theme, value: Tone): string =>\n  brandTextOn(theme, softRoles[value]);\n\nexport const messageSelection = (theme: Theme, value: Tone): string =>\n  selectionOn(theme, softRoles[value]);\n\nexport const toneSurface = (theme: Theme, value: Tone): StyleDesc => {\n  const { bg, border, fg } = tone(theme, value);\n  return {\n    backgroundColor: bg,\n    color: fg,\n    borderWidth: theme.borderWidth.thin,\n    borderColor: border,\n  };\n};\n"
    }
  ],
  "docs": "[Calendar](https://gpuixui.sudokw.com/components/calendar) — These are GPUix native components: the files render through GPUix's reconciler against `@gpuix/react`, not the DOM, and need the per-platform `@gpuix/native` binding. The CLI installs the `@gpuixui/*` runtime the components import as registry items, so the copied tree resolves on its own; wrap it in `ThemeProvider` before it renders.",
  "meta": {
    "url": "/components/calendar",
    "kind": "component",
    "runtime": "gpuix",
    "registry": "gpuixui"
  }
}