{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "calendar-app",
  "title": "Calendar App",
  "author": "vmnog <https://vmnog.com>",
  "description": "The live demo as one block: both sidebars, the header, day, week, month, year and agenda views, the ⌘K menu, settings, scheduling, the toasts, theme, .ics import and export, and keyboard shortcuts.",
  "dependencies": [
    "next-themes"
  ],
  "registryDependencies": [
    "@calendarcn/calendar-core",
    "@calendarcn/time-grid",
    "@calendarcn/month-view",
    "@calendarcn/agenda-view",
    "@calendarcn/year-view",
    "@calendarcn/calendar-header",
    "@calendarcn/command-menu",
    "@calendarcn/people-picker",
    "@calendarcn/calendar-toaster",
    "@calendarcn/calendar-settings",
    "@calendarcn/calendar-sidebar",
    "@calendarcn/details-sidebar",
    "@calendarcn/theme-toggle",
    "@calendarcn/ics",
    "@calendarcn/sample-data",
    "@calendarcn/conference-providers",
    "sidebar"
  ],
  "files": [
    {
      "path": "src/components/calendar-app.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { useTheme } from \"next-themes\";\n\nimport { cn } from \"@/lib/utils\";\nimport { useCalendarShortcuts } from \"@/hooks/use-calendar-shortcuts\";\nimport { useControllableState } from \"@/hooks/use-controllable-state\";\nimport { useMediaQuery } from \"@/hooks/use-media-query\";\nimport { AgendaView } from \"@/components/agenda-view\";\nimport { AvailabilityHint } from \"@/components/availability-panel\";\nimport { CalendarHeader } from \"@/components/calendar-header\";\nimport {\n  CalendarProvider,\n  useCalendar,\n  useCalendarConfig,\n} from \"@/components/calendar-provider\";\nimport { CalendarSettingsDialog } from \"@/components/calendar-settings\";\nimport { CalendarSidebar } from \"@/components/calendar-sidebar\";\nimport { CalendarToaster } from \"@/components/calendar-toaster\";\nimport { CommandMenu } from \"@/components/command-menu\";\nimport {\n  CONTEXT_PANEL_WIDTH,\n  DetailsSidebar,\n} from \"@/components/details-sidebar\";\nimport { MonthView } from \"@/components/month-view\";\nimport { PeoplePicker } from \"@/components/people-picker\";\nimport {\n  SchedulingProvider,\n  useScheduling,\n  useSchedulingShortcuts,\n} from \"@/components/scheduling-provider\";\nimport { TimeGrid } from \"@/components/time-grid\";\nimport { YearView } from \"@/components/year-view\";\nimport {\n  SidebarInset,\n  SidebarProvider,\n  useSidebar,\n} from \"@/components/ui/sidebar\";\nimport {\n  filterShownEvents,\n  getPeriodStart,\n  mergeShownEvents,\n} from \"@/lib/event-utils\";\nimport { parseIcs, toIcs, toIcsCalendar } from \"@/lib/ics\";\nimport {\n  KEYBOARD_SHORTCUT_GROUPS,\n  SHORTCUTS,\n  filterKeyboardShortcutGroups,\n} from \"@/lib/keyboard-shortcuts\";\nimport { toDisplayEvent } from \"@/lib/time-zones\";\nimport type {\n  CalendarInfo,\n  CalendarProviderProps,\n  CalendarTheme,\n  HourCycle,\n  PeoplePickerMode,\n} from \"@/components/calendar-types\";\nimport type {\n  CalendarAppProps,\n  CalendarSettingsSection,\n  CommandMenuPage,\n  DetailedCalendarEvent,\n  DetailsSidebarActions,\n  TimeZoneCommand,\n} from \"@/components/week-view-types\";\n\n/** Hour the time grid opens on unless `scrollToHour` says otherwise */\nconst DEFAULT_SCROLL_HOUR = 8;\n\n/** File types the command menu's .ics import offers */\nconst ICS_FILE_TYPES = \".ics,text/calendar\";\n\n/** Name of the file the command menu's .ics export downloads unless `exportFileName` says otherwise */\nconst DEFAULT_EXPORT_FILE_NAME = \"calendar.ics\";\n\n/**\n * Viewports at least this wide keep both sidebars inline (Tailwind `xl`).\n * Narrower ones show the context panel as an overlay: inline, it would leave\n * the calendar under ~500px at 1024px (240px left + 308px right).\n */\nconst WIDE_LAYOUT_QUERY = \"(min-width: 1280px)\";\n\n/** No events, for an app given neither `events` nor `defaultEvents` */\nconst NO_EVENTS: DetailedCalendarEvent[] = [];\n\n/** No hidden calendars: every calendar shows until its eye is clicked */\nconst NO_HIDDEN_CALENDARS: string[] = [];\n\n/** No calendars: an app given no `calendars` and before any is added */\nconst NO_CALENDARS: CalendarInfo[] = [];\n\n/** CalendarAppProps that configure the app's chrome rather than the provider */\ntype CalendarAppShellOptions = Pick<\n  CalendarAppProps,\n  | \"scrollToHour\"\n  | \"headerActions\"\n  | \"sidebarFooterActions\"\n  | \"exportFileName\"\n  | \"exportCalendarName\"\n  | \"onOpenSettings\"\n  | \"settingsDialog\"\n  | \"onSupport\"\n  | \"onAbout\"\n  | \"showComingSoon\"\n  | \"shortcuts\"\n>;\n\ninterface CalendarAppStateProps extends Omit<CalendarAppProps, \"className\"> {\n  /** Whether the context panel sits inline (true) or opens as an overlay */\n  isWideLayout: boolean;\n}\n\ninterface CalendarAppShellProps extends CalendarAppShellOptions {\n  /** Whether the context panel sits inline (true) or opens as an overlay */\n  isWideLayout: boolean;\n  /** Adds events read from an .ics file, replacing those with the same id */\n  onImportEvents: (events: DetailedCalendarEvent[]) => void;\n  /**\n   * Adds events read from an .ics file as a calendar named after the file,\n   * and returns them with its id\n   */\n  onImportCalendar: (\n    fileName: string,\n    events: DetailedCalendarEvent[],\n  ) => DetailedCalendarEvent[];\n  /** The app's \"Add calendar account\", with its helpers bound */\n  onAddCalendarAccount?: CalendarAppProps[\"onAddCalendarAccount\"];\n  /** Sets the clock the calendar shows (the settings' Time format) */\n  onHourCycleChange: (hourCycle: HourCycle) => void;\n  /** Every event the app holds, hidden calendars included: what \"Export .ics file\" writes */\n  allEvents: DetailedCalendarEvent[];\n  /** Ids of the calendars hidden from the sidebar's list */\n  hiddenCalendarIds: string[];\n  /** Called with the new hidden ids when a calendar is shown or hidden */\n  onHiddenCalendarIdsChange: (hiddenCalendarIds: string[]) => void;\n}\n\n/**\n * The live demo as one component: the calendar sidebar on the left, the\n * header and the day, week, month, year or agenda view in the middle, the details\n * sidebar on the right, the ⌘K command menu, the toasts after a delete,\n * cut or copy, theme cycling, .ics import and export, scheduling (marking\n * open times to copy, and links through `onCreateSchedulingLink`), and the\n * keyboard shortcuts. The settings dialog (`settingsDialog`) and the account\n * and app commands (`onAddCalendarAccount`, `onSupport`, `onAbout`) show when\n * you turn them on. Takes every `CalendarProvider` prop,\n * so events can be controlled or left to the app, and the calendars,\n * contacts, rooms and conferencing come from your data.\n *\n * It fills the viewport. On wide screens (1280px and up) both sidebars sit\n * inline; narrower, the details sidebar opens over the calendar, and on\n * phones the calendar sidebar does too. The eye beside a calendar in the\n * sidebar hides its events from every view.\n */\nexport function CalendarApp({ className, ...props }: CalendarAppProps) {\n  const isWideLayout = useMediaQuery(WIDE_LAYOUT_QUERY);\n\n  // The context panel starts open where it sits inline (wide screens) and\n  // closed where it would cover the calendar. Crossing the breakpoint resets it.\n  const [contextPanelOpen, setContextPanelOpen] = React.useState(isWideLayout);\n  const [prevIsWideLayout, setPrevIsWideLayout] = React.useState(isWideLayout);\n  if (isWideLayout !== prevIsWideLayout) {\n    setPrevIsWideLayout(isWideLayout);\n    setContextPanelOpen(isWideLayout);\n  }\n\n  return (\n    <SidebarProvider\n      className={cn(\"h-screen\", className)}\n      style={{ \"--sidebar-width\": CONTEXT_PANEL_WIDTH } as React.CSSProperties}\n      open={contextPanelOpen}\n      onOpenChange={setContextPanelOpen}\n    >\n      <CalendarAppState {...props} isWideLayout={isWideLayout} />\n    </SidebarProvider>\n  );\n}\n\n/**\n * The provider, with the app owning the events (so the command menu can\n * import an .ics file into them, controlled or not) and opening the phone\n * details sheet on select. Everything below reads the calendar state from\n * `useCalendar()`.\n */\nfunction CalendarAppState({\n  isWideLayout,\n  events: eventsProp,\n  defaultEvents,\n  onEventsChange,\n  onEventSelect,\n  onEventsImport,\n  scrollToHour,\n  headerActions,\n  sidebarFooterActions,\n  exportFileName,\n  exportCalendarName,\n  onOpenSettings,\n  onCreateSchedulingLink,\n  settingsDialog,\n  onAddCalendarAccount,\n  onSupport,\n  onAbout,\n  showComingSoon,\n  shortcuts,\n  children,\n  ...providerProps\n}: CalendarAppStateProps) {\n  const { isMobile, setOpenMobile: setContextPanelOpenMobile } = useSidebar();\n  const [events, setEvents] = useControllableState({\n    prop: eventsProp,\n    defaultProp: defaultEvents ?? NO_EVENTS,\n    onChange: onEventsChange,\n  });\n\n  /** Calendars hidden from the sidebar's list. Their events leave every view */\n  const [hiddenCalendarIds, setHiddenCalendarIds] =\n    React.useState(NO_HIDDEN_CALENDARS);\n  /** Calendars added from .ics files, after the app's `calendars` */\n  const [addedCalendars, setAddedCalendars] = React.useState(NO_CALENDARS);\n  /** Clock picked in the settings; until then, the app's `hourCycle` */\n  const [pickedHourCycle, setPickedHourCycle] =\n    React.useState<HourCycle | null>(null);\n\n  const calendarsProp = providerProps.calendars ?? NO_CALENDARS;\n  const calendars = React.useMemo(\n    () => [\n      ...calendarsProp,\n      ...addedCalendars.filter(\n        (added) => !calendarsProp.some((calendar) => calendar.id === added.id),\n      ),\n    ],\n    [calendarsProp, addedCalendars],\n  );\n\n  // The provider, and with it every view, the details and the search, gets\n  // the shown calendars' events only\n  const shownEvents = React.useMemo(\n    () => filterShownEvents(events, hiddenCalendarIds),\n    [events, hiddenCalendarIds],\n  );\n\n  // The provider's changes cover the shown events, so they are merged back\n  // into the full list. An event that lands on a hidden calendar (created\n  // there, or moved to it) shows that calendar again instead of vanishing.\n  const handleShownEventsChange = React.useCallback(\n    (shown: DetailedCalendarEvent[]) => {\n      const stillHidden = hiddenCalendarIds.filter(\n        (id) => !shown.some((event) => event.calendarId === id),\n      );\n      if (stillHidden.length !== hiddenCalendarIds.length) {\n        setHiddenCalendarIds(stillHidden);\n      }\n      setEvents((current) =>\n        mergeShownEvents(current, shown, hiddenCalendarIds),\n      );\n    },\n    [hiddenCalendarIds, setEvents],\n  );\n\n  // Phones show event details in the context panel sheet: the 320px popover\n  // doesn't fit beside an event on a ~390px screen\n  const handleEventSelect = React.useCallback(\n    (eventId: string) => {\n      onEventSelect?.(eventId);\n      if (isMobile) setContextPanelOpenMobile(true);\n    },\n    [onEventSelect, isMobile, setContextPanelOpenMobile],\n  );\n\n  // Importing the same file again updates its events instead of adding copies\n  const importEvents = React.useCallback(\n    (imported: DetailedCalendarEvent[]) => {\n      const importedIds = new Set(imported.map((event) => event.id));\n      setEvents((current) => [\n        ...current.filter((event) => !importedIds.has(event.id)),\n        ...imported,\n      ]);\n      onEventsImport?.(imported);\n    },\n    [setEvents, onEventsImport],\n  );\n\n  // An .ics file as a calendar of its own: added once, its events with it\n  const importCalendar = React.useCallback(\n    (fileName: string, imported: DetailedCalendarEvent[]) => {\n      const { calendar, events: calendarEvents } = toIcsCalendar(\n        fileName,\n        imported,\n        calendars,\n      );\n      setAddedCalendars((current) =>\n        current.some((added) => added.id === calendar.id)\n          ? current\n          : [...current, calendar],\n      );\n      setHiddenCalendarIds((current) =>\n        current.filter((id) => id !== calendar.id),\n      );\n      importEvents(calendarEvents);\n      return calendarEvents;\n    },\n    [calendars, importEvents],\n  );\n\n  // The provider reads only its own props. Its event type is erased here,\n  // as in the Calendar block, because TypeScript can't check JSX props\n  // against its generic conditional `createEvent` type.\n  const calendarProviderProps: CalendarProviderProps = {\n    ...(providerProps as CalendarProviderProps),\n    calendars,\n    hourCycle: pickedHourCycle ?? providerProps.hourCycle,\n    events: shownEvents,\n    onEventsChange:\n      handleShownEventsChange as CalendarProviderProps[\"onEventsChange\"],\n    onEventSelect: handleEventSelect,\n    children: (\n      <SchedulingProvider onCreateSchedulingLink={onCreateSchedulingLink}>\n        <CalendarAppShell\n          isWideLayout={isWideLayout}\n          onImportEvents={importEvents}\n          onImportCalendar={importCalendar}\n          onHourCycleChange={setPickedHourCycle}\n          allEvents={events}\n          hiddenCalendarIds={hiddenCalendarIds}\n          onHiddenCalendarIdsChange={setHiddenCalendarIds}\n          scrollToHour={scrollToHour}\n          headerActions={headerActions}\n          sidebarFooterActions={sidebarFooterActions}\n          exportFileName={exportFileName}\n          exportCalendarName={exportCalendarName}\n          onOpenSettings={onOpenSettings}\n          settingsDialog={settingsDialog}\n          onAddCalendarAccount={onAddCalendarAccount}\n          onSupport={onSupport}\n          onAbout={onAbout}\n          showComingSoon={showComingSoon}\n          shortcuts={shortcuts}\n        />\n        {children}\n      </SchedulingProvider>\n    ),\n  };\n\n  return <CalendarProvider {...calendarProviderProps} />;\n}\n\n/**\n * The chrome around the calendar: sidebars, header, command menu, theme\n * cycling, .ics import and export, and the app shortcuts.\n */\nfunction CalendarAppShell({\n  isWideLayout,\n  onImportEvents,\n  onImportCalendar,\n  onAddCalendarAccount,\n  onHourCycleChange,\n  allEvents,\n  hiddenCalendarIds,\n  onHiddenCalendarIdsChange,\n  scrollToHour = DEFAULT_SCROLL_HOUR,\n  headerActions,\n  sidebarFooterActions,\n  exportFileName = DEFAULT_EXPORT_FILE_NAME,\n  exportCalendarName,\n  onOpenSettings,\n  settingsDialog = false,\n  onSupport,\n  onAbout,\n  showComingSoon = false,\n  shortcuts = true,\n}: CalendarAppShellProps) {\n  const { theme, setTheme } = useTheme();\n  const {\n    toggleSidebar,\n    open: contextPanelOpen,\n    setOpen: setContextPanelOpen,\n    openMobile: contextPanelOpenMobile,\n    isMobile,\n  } = useSidebar();\n  const scheduling = useScheduling();\n  const isPicking = scheduling?.isPicking ?? false;\n  const { view, weekStartsOn, numberOfDays, goToDate } =\n    useCalendar<DetailedCalendarEvent>();\n  const { timeZone } = useCalendarConfig();\n  // shadcn tracks the panel's phone state separately; read whichever is active\n  const rightSidebarOpen = isMobile ? contextPanelOpenMobile : contextPanelOpen;\n  /** Inline calendar sidebar state (tablet and desktop) */\n  const [leftSidebarOpen, setLeftSidebarOpen] = React.useState(true);\n  /** Calendar sidebar overlay state (phones); starts closed */\n  const [leftOverlayOpen, setLeftOverlayOpen] = React.useState(false);\n  // Close the overlay when leaving the phone layout, so it doesn't pop back\n  // open the next time the viewport narrows\n  const [prevIsMobile, setPrevIsMobile] = React.useState(isMobile);\n  if (isMobile !== prevIsMobile) {\n    setPrevIsMobile(isMobile);\n    setLeftOverlayOpen(false);\n  }\n  const leftSidebarVisible = isMobile ? leftOverlayOpen : leftSidebarOpen;\n  const [commandMenuOpen, setCommandMenuOpen] = React.useState(false);\n  /** Page the command menu opens on: its commands, or Go to date's field (.) */\n  const [commandMenuPage, setCommandMenuPage] =\n    React.useState<CommandMenuPage>(\"commands\");\n  /** The time zone list the command menu opens on (Z), or none (Cmd+K) */\n  const [commandMenuZoneCommand, setCommandMenuZoneCommand] = React.useState<\n    TimeZoneCommand | undefined\n  >(undefined);\n  /** Whether the people picker F and P open is open */\n  const [peoplePickerOpen, setPeoplePickerOpen] = React.useState(false);\n  /** What picking someone does; kept while the picker closes, so its text stays */\n  const [peoplePickerMode, setPeoplePickerMode] =\n    React.useState<PeoplePickerMode>(\"meet-with\");\n  /** Hidden file picker behind the command menu's \"Import .ics file\" */\n  const icsInputRef = React.useRef<HTMLInputElement>(null);\n  /** Hidden file picker behind `importIcsCalendar()` (Add calendar account) */\n  const icsCalendarInputRef = React.useRef<HTMLInputElement>(null);\n  const [settingsOpen, setSettingsOpen] = React.useState(false);\n  /** Pane the settings dialog opens on */\n  const [settingsSection, setSettingsSection] =\n    React.useState<CalendarSettingsSection>(\"general\");\n  /** The details sidebar's event search and full shortcut list */\n  const detailsActionsRef = React.useRef<DetailsSidebarActions>(null);\n\n  // Phones show event details in the context panel sheet: the 320px popover\n  // doesn't fit beside an event on a ~390px screen\n  const showDetailsInPanel = isMobile || rightSidebarOpen;\n\n  const toggleCommandMenu = React.useCallback(() => {\n    setCommandMenuPage(\"commands\");\n    setCommandMenuZoneCommand(undefined);\n    setCommandMenuOpen((prev) => !prev);\n  }, []);\n\n  /** The . key: the command menu, on Go to date's field */\n  const openGoToDate = React.useCallback(() => {\n    setCommandMenuPage(\"go-to-date\");\n    setCommandMenuZoneCommand(undefined);\n    setCommandMenuOpen(true);\n  }, []);\n\n  /** Z: the command menu, on \"Travel to time zone...\"'s list */\n  const openTravelPicker = React.useCallback(() => {\n    setCommandMenuPage(\"commands\");\n    setCommandMenuZoneCommand(\"travel\");\n    setCommandMenuOpen(true);\n  }, []);\n\n  const openMeetWith = React.useCallback(() => {\n    setPeoplePickerMode(\"meet-with\");\n    setPeoplePickerOpen(true);\n  }, []);\n\n  const openTeammatePicker = React.useCallback(() => {\n    setPeoplePickerMode(\"teammate\");\n    setPeoplePickerOpen(true);\n  }, []);\n\n  const searchEvents = React.useCallback((query: string) => {\n    detailsActionsRef.current?.searchEvents(query);\n  }, []);\n\n  /** The ? key and \"Show keyboard shortcuts\": the full list, in the context panel */\n  const showAllShortcuts = React.useCallback(() => {\n    detailsActionsRef.current?.showAllShortcuts();\n  }, []);\n\n  const toggleLeftSidebar = React.useCallback(() => {\n    if (isMobile) {\n      setLeftOverlayOpen((prev) => !prev);\n      return;\n    }\n    setLeftSidebarOpen((prev) => !prev);\n  }, [isMobile]);\n\n  /** Shows the period of the earliest of the imported events */\n  const showImported = React.useCallback(\n    (imported: DetailedCalendarEvent[]) => {\n      const earliest = imported.reduce((first, event) =>\n        event.start < first.start ? event : first,\n      );\n      // The period of the day it falls on in the calendar's zone\n      goToDate(\n        getPeriodStart(\n          toDisplayEvent(earliest, timeZone).start,\n          view,\n          weekStartsOn,\n          numberOfDays,\n        ),\n      );\n    },\n    [goToDate, view, weekStartsOn, numberOfDays, timeZone],\n  );\n\n  /** Imports the picked .ics file and shows the period of its first event */\n  const handleIcsFileChange = React.useCallback(\n    async (e: React.ChangeEvent<HTMLInputElement>) => {\n      const file = e.target.files?.[0];\n      // Clear the input so picking the same file again imports it again\n      e.target.value = \"\";\n      if (!file) return;\n      const imported = parseIcs(await file.text());\n      if (imported.length === 0) return;\n      onImportEvents(imported);\n      showImported(imported);\n    },\n    [onImportEvents, showImported],\n  );\n\n  /** Adds the picked .ics file as a calendar named after it, and shows its first event */\n  const handleIcsCalendarFileChange = React.useCallback(\n    async (e: React.ChangeEvent<HTMLInputElement>) => {\n      const file = e.target.files?.[0];\n      e.target.value = \"\";\n      if (!file) return;\n      const imported = parseIcs(await file.text());\n      if (imported.length === 0) return;\n      showImported(onImportCalendar(file.name, imported));\n    },\n    [onImportCalendar, showImported],\n  );\n\n  /** \"Add calendar account\" in the sidebar, the command menu and the settings */\n  const addCalendarAccount = React.useMemo(() => {\n    if (!onAddCalendarAccount) return undefined;\n    return () =>\n      onAddCalendarAccount({\n        importIcsCalendar: () => icsCalendarInputRef.current?.click(),\n      });\n  }, [onAddCalendarAccount]);\n\n  /** Cmd+, and \"Go to settings\": the built-in dialog, else the app's own */\n  const openSettings = React.useMemo(() => {\n    if (!settingsDialog) return onOpenSettings;\n    return () => {\n      setSettingsSection(\"general\");\n      setSettingsOpen(true);\n    };\n  }, [settingsDialog, onOpenSettings]);\n\n  /** \"Manage calendar accounts\": the built-in dialog, on the calendars */\n  const manageCalendarAccounts = React.useMemo(() => {\n    if (!settingsDialog) return undefined;\n    return () => {\n      setSettingsSection(\"calendars\");\n      setSettingsOpen(true);\n    };\n  }, [settingsDialog]);\n\n  // The full list names only the keys this app handles: Cmd+, needs a\n  // settings action, the built-in dialog or the app's own\n  const shortcutGroups = React.useMemo(\n    () =>\n      openSettings\n        ? KEYBOARD_SHORTCUT_GROUPS\n        : filterKeyboardShortcutGroups(\n            KEYBOARD_SHORTCUT_GROUPS,\n            (shortcut) => shortcut !== SHORTCUTS.openSettings,\n          ),\n    [openSettings],\n  );\n\n  const exportIcs = React.useCallback(() => {\n    const url = URL.createObjectURL(\n      new Blob([toIcs(allEvents, { calendarName: exportCalendarName })], {\n        type: \"text/calendar;charset=utf-8\",\n      }),\n    );\n    const link = document.createElement(\"a\");\n    link.href = url;\n    link.download = exportFileName;\n    link.click();\n    setTimeout(() => URL.revokeObjectURL(url), 0);\n  }, [allEvents, exportCalendarName, exportFileName]);\n\n  /** Popover expand button: move the details into the context panel */\n  const expandEventPopover = React.useCallback(() => {\n    if (!rightSidebarOpen) toggleSidebar();\n  }, [rightSidebarOpen, toggleSidebar]);\n\n  const cycleTheme = React.useCallback(() => {\n    if (theme === \"system\") {\n      setTheme(\"light\");\n      return;\n    }\n    if (theme === \"light\") {\n      setTheme(\"dark\");\n      return;\n    }\n    setTheme(\"system\");\n  }, [theme, setTheme]);\n\n  // Marking open times opens the context panel where it sits inline, for\n  // the scheduling panel. Only when marking starts: closing it stays closed\n  const wasPickingRef = React.useRef(isPicking);\n  React.useEffect(() => {\n    const started = isPicking && !wasPickingRef.current;\n    wasPickingRef.current = isPicking;\n    if (started && isWideLayout && !contextPanelOpen) {\n      setContextPanelOpen(true);\n    }\n  }, [isPicking, isWideLayout, contextPanelOpen, setContextPanelOpen]);\n\n  // Scheduling's keys first: S, and Escape and Delete while times are\n  // marked, so the calendar's own Escape and Delete don't also run\n  useSchedulingShortcuts({ enabled: shortcuts });\n\n  // Calendar shortcuts: T, J/K, arrows, D/1, W/0, 2-9, M, A, C, Escape,\n  // Shift+Cmd+E for weekends, and the event keys: Delete/Backspace, Cmd+X,\n  // Cmd+C, Cmd+V, Cmd+D, Cmd+Z and Shift+Cmd+Z. Then the app's own, checked\n  // first: Cmd+K, Cmd+/, /, Shift+M, Cmd+, . ? Z, F and P\n  useCalendarShortcuts({\n    enabled: shortcuts,\n    onToggleCommandMenu: toggleCommandMenu,\n    onToggleSidebar: toggleLeftSidebar,\n    onToggleContextPanel: toggleSidebar,\n    onCycleTheme: cycleTheme,\n    onOpenSettings: openSettings,\n    onGoToDate: openGoToDate,\n    onShowShortcuts: showAllShortcuts,\n    onTravelToTimeZone: openTravelPicker,\n    onMeetWith: openMeetWith,\n    onShowTeammateCalendar: openTeammatePicker,\n  });\n\n  return (\n    <>\n      <CommandMenu\n        open={commandMenuOpen}\n        onOpenChange={setCommandMenuOpen}\n        onToggleSidebar={toggleLeftSidebar}\n        onToggleContextPanel={toggleSidebar}\n        onCycleTheme={cycleTheme}\n        onImportIcs={() => icsInputRef.current?.click()}\n        onExportIcs={exportIcs}\n        onShareAvailability={\n          scheduling ? () => scheduling.startPicking() : undefined\n        }\n        onCreateSchedulingLink={\n          scheduling?.canCreateLinks\n            ? scheduling.createSchedulingLink\n            : undefined\n        }\n        onOpenSettings={openSettings}\n        onSupport={onSupport}\n        onAddCalendarAccount={addCalendarAccount}\n        onManageCalendarAccounts={manageCalendarAccounts}\n        onAbout={onAbout}\n        onMeetWith={openMeetWith}\n        onShowTeammateCalendar={openTeammatePicker}\n        onSearchEvents={searchEvents}\n        onShowShortcuts={showAllShortcuts}\n        defaultPage={commandMenuPage}\n        showComingSoon={showComingSoon}\n        timeZoneCommand={commandMenuZoneCommand}\n      />\n      <PeoplePicker\n        open={peoplePickerOpen}\n        onOpenChange={setPeoplePickerOpen}\n        mode={peoplePickerMode}\n      />\n      <input\n        ref={icsInputRef}\n        type=\"file\"\n        accept={ICS_FILE_TYPES}\n        aria-label=\"Import .ics file\"\n        className=\"hidden\"\n        onChange={handleIcsFileChange}\n      />\n      {onAddCalendarAccount && (\n        <input\n          ref={icsCalendarInputRef}\n          type=\"file\"\n          accept={ICS_FILE_TYPES}\n          aria-label=\"Add an .ics file as a calendar\"\n          className=\"hidden\"\n          onChange={handleIcsCalendarFileChange}\n        />\n      )}\n      {settingsDialog && (\n        <CalendarSettingsDialog\n          open={settingsOpen}\n          onOpenChange={setSettingsOpen}\n          defaultSection={settingsSection}\n          theme={theme as CalendarTheme | undefined}\n          onThemeChange={setTheme}\n          onHourCycleChange={onHourCycleChange}\n          hiddenCalendarIds={hiddenCalendarIds}\n          onHiddenCalendarIdsChange={onHiddenCalendarIdsChange}\n          onAddCalendarAccount={addCalendarAccount}\n        />\n      )}\n      <CalendarSidebar\n        open={leftSidebarVisible}\n        onOpenChange={setLeftOverlayOpen}\n        overlay={isMobile}\n        footerActions={sidebarFooterActions}\n        hiddenCalendarIds={hiddenCalendarIds}\n        onHiddenCalendarIdsChange={onHiddenCalendarIdsChange}\n        onAddCalendarAccount={addCalendarAccount}\n      />\n      <SidebarInset className=\"flex flex-col overflow-hidden\">\n        <CalendarHeader\n          sidebarOpen={leftSidebarVisible}\n          onToggleSidebar={toggleLeftSidebar}\n          contextPanelOpen={rightSidebarOpen}\n          onToggleContextPanel={toggleSidebar}\n        >\n          {headerActions}\n        </CalendarHeader>\n        <div className=\"relative flex flex-1 flex-col overflow-hidden\">\n          {view === \"month\" && (\n            <MonthView\n              showEventPopover={!showDetailsInPanel}\n              onEventPopoverExpand={expandEventPopover}\n            />\n          )}\n          {view === \"agenda\" && (\n            <AgendaView\n              showEventPopover={!showDetailsInPanel}\n              onEventPopoverExpand={expandEventPopover}\n            />\n          )}\n          {view === \"year\" && <YearView />}\n          {/* One grid for day and week: switching re-lays it out instead of\n              remounting, so the vertical scroll position is kept */}\n          {(view === \"day\" || view === \"week\") && (\n            <TimeGrid\n              view={view}\n              scrollToHour={scrollToHour}\n              showEventPopover={!showDetailsInPanel}\n              onEventPopoverExpand={expandEventPopover}\n            />\n          )}\n          {/* \"Mark available times on your calendar\" while scheduling, with\n              Cancel and Copy when the scheduling panel isn't on screen */}\n          <AvailabilityHint showActions={!rightSidebarOpen} />\n          {/* Notion Calendar's toasts, at the bottom right over the view */}\n          <CalendarToaster />\n        </div>\n      </SidebarInset>\n      <DetailsSidebar\n        overlay={!isWideLayout}\n        actionsRef={detailsActionsRef}\n        shortcutGroups={shortcutGroups}\n      />\n    </>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "docs": "Calendar App: wrap your app in the ThemeProvider from @/components/theme-provider, then render <CalendarApp /> on a page of its own. https://calendarcn.xyz/docs/components/calendar-app#usage",
  "categories": [
    "calendar",
    "blocks"
  ],
  "type": "registry:block"
}