{"version":3,"sources":["../../../src/components/DatePicker/useDatePicker.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { ArrowDown, Enter, Escape, Space } from '@fluentui/keyboard-keys';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport {\n  getPartitionedNativeProps,\n  mergeCallbacks,\n  slot,\n  useControllableState,\n  useEventCallback,\n  useId,\n  useIsomorphicLayoutEffect,\n  useMergedRefs,\n} from '@fluentui/react-utilities';\nimport { resolvePositioningShorthand, usePositioning } from '../../hooks';\nimport { toDataAttributeValue } from '../../utils';\nimport { Calendar } from '../Calendar/Calendar';\nimport {\n  addDays,\n  calendarFormatters,\n  compareDatePart,\n  getMonthEnd,\n  getMonthStart,\n  isRestrictedDate,\n  setMonth,\n} from '../Calendar/utils';\nimport type { CalendarProps, CalendarViewChangeData } from '../Calendar/Calendar.types';\nimport type { CalendarDayHandle, CalendarDayProps } from '../Calendar/CalendarDay/CalendarDay.types';\nimport type { CalendarMonthHandle, CalendarMonthProps } from '../Calendar/CalendarMonth/CalendarMonth.types';\nimport type { CalendarFormatters } from '../Calendar/utils';\nimport { defaultFormatDate, defaultParseDate } from './datePickerFormatting';\nimport { useDatePickerDateState } from './useDatePickerDateState';\nimport type {\n  DatePickerCalendarProps,\n  DatePickerErrorMessageData,\n  DatePickerOpenChangeData,\n  DatePickerProps,\n  DatePickerState,\n} from './DatePicker.types';\n\ntype DatePickerEvent = React.SyntheticEvent | Event;\ntype OpenChangeReason = DatePickerOpenChangeData['reason'];\n\nconst isDefaultPrevented = (event: DatePickerEvent): boolean =>\n  'nativeEvent' in event ? event.isDefaultPrevented() : event.defaultPrevented;\n\nconst getActiveElement = (element: HTMLElement): Element | null => {\n  const root = element.getRootNode();\n  const ShadowRootConstructor = element.ownerDocument.defaultView?.ShadowRoot;\n  return ShadowRootConstructor && root instanceof ShadowRootConstructor\n    ? root.activeElement ?? element.ownerDocument.activeElement\n    : element.ownerDocument.activeElement;\n};\n\nconst mergeAriaDescribedBy = (...values: (string | undefined)[]): string | undefined => {\n  const ids = new Set(values.flatMap(value => value?.trim().split(/\\s+/).filter(Boolean) ?? []));\n  return ids.size ? [...ids].join(' ') : undefined;\n};\n\nconst defaultFormatErrorMessage = ({ error, minDate, maxDate, formatDate }: DatePickerErrorMessageData): string => {\n  if (error === 'required-input') {\n    return 'Enter a date.';\n  }\n\n  if (error === 'out-of-bounds') {\n    if (minDate && maxDate) {\n      return `Enter an available date between ${formatDate(minDate)} and ${formatDate(maxDate)}.`;\n    }\n    if (minDate) {\n      return `Enter an available date on or after ${formatDate(minDate)}.`;\n    }\n    if (maxDate) {\n      return `Enter an available date on or before ${formatDate(maxDate)}.`;\n    }\n    return 'Enter an available date.';\n  }\n\n  return 'Enter a date such as August 12, 2026, 2026-08-12 or 8/12/2026.';\n};\n\n// The day picker heading opens the year-range grid in the month-year picker.\nconst dayPickerHeaderLabel: CalendarFormatters['dayPickerHeaderLabel'] = data => `${data.formattedDate}, change year`;\n\n/**\n * Creates DatePicker state: the committed date, pending typed text and validation, the popup lifecycle and its focus\n * management, and the Calendar configuration.\n * @param props - Props from this instance of DatePicker.\n * @param ref - Reference to the field control: the input when `allowTextInput` is set, otherwise the trigger button.\n */\nexport const useDatePicker = (\n  props: DatePickerProps,\n  ref: React.Ref<HTMLInputElement | HTMLButtonElement>,\n): DatePickerState => {\n  const {\n    allowTextInput = false,\n    disabled = false,\n    formatDate = defaultFormatDate,\n    formatErrorMessage = defaultFormatErrorMessage,\n    maxDate,\n    minDate,\n    onOpenChange,\n    parseDate = defaultParseDate,\n    placeholder = 'Select a date',\n    positioning,\n    showGoToToday = false,\n    today: todayProp,\n  } = props;\n\n  const { targetDocument } = useFluent();\n  const today = React.useMemo(() => todayProp ?? new Date(), [todayProp]);\n\n  // A Field label's htmlFor would name the trigger button by the label alone, so the button uses aria-labelledby and\n  // appends the displayed date.\n  const fieldControlProps = useFieldControlProps_unstable(props, { supportsLabelFor: allowTextInput });\n  const nativeProps = getPartitionedNativeProps({\n    props: fieldControlProps,\n    primarySlotTagName: 'input',\n    excludedPropNames: ['defaultValue', 'disabled', 'placeholder', 'required', 'value'],\n  });\n  const required =\n    props.required === true ||\n    fieldControlProps['aria-required'] === true ||\n    fieldControlProps['aria-required'] === 'true';\n  const controlId = useId('datepicker-', fieldControlProps.id);\n\n  const calendarProps: DatePickerCalendarProps = slot.resolveShorthand(props.calendar) ?? {};\n  const restrictedDates = calendarProps.restrictedDates;\n  const isDateUnavailable = (date: Date) => isRestrictedDate(date, { minDate, maxDate, restrictedDates });\n\n  const dateState = useDatePickerDateState({\n    allowTextInput,\n    defaultValue: props.defaultValue,\n    disabled,\n    formatDate,\n    isDateUnavailable,\n    onDateChange: props.onDateChange,\n    onValidationResult: props.onValidationResult,\n    parseDate,\n    required,\n    value: props.value,\n  });\n  const { error } = dateState;\n\n  /**\n   * Opening shows the selected day, otherwise today, otherwise the first available day of today's month. Calendar\n   * falls back to an adjacent-month day or the Next month button when the shown month has no available day.\n   */\n  const getInitialDisplayedDate = (): Date => {\n    if (dateState.value && !isDateUnavailable(dateState.value)) {\n      return dateState.value;\n    }\n\n    let date = today;\n    if (minDate && compareDatePart(date, minDate) < 0) {\n      date = minDate;\n    } else if (maxDate && compareDatePart(date, maxDate) > 0) {\n      date = maxDate;\n    }\n    if (!isDateUnavailable(date)) {\n      return date;\n    }\n\n    const monthEnd = getMonthEnd(date);\n    for (let day = getMonthStart(date); compareDatePart(day, monthEnd) <= 0; day = addDays(day, 1)) {\n      if (!isDateUnavailable(day)) {\n        return day;\n      }\n    }\n    return date;\n  };\n\n  const [displayedDate, setDisplayedDate] = React.useState(getInitialDisplayedDate);\n\n  const [openState, setOpenState] = useControllableState({\n    state: props.open,\n    defaultState: props.defaultOpen,\n    initialState: false,\n  });\n  const open = openState && !disabled;\n\n  // Every opening shows the initial date, including defaultOpen and controlled `open` changes.\n  const [wasOpen, setWasOpen] = React.useState(open);\n  if (open !== wasOpen) {\n    setWasOpen(open);\n    if (open) {\n      setDisplayedDate(getInitialDisplayedDate());\n    }\n  }\n\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const controlRef = React.useRef<HTMLInputElement & HTMLButtonElement>(null);\n  const surfaceRef = React.useRef<HTMLDivElement>(null);\n  const dayPickerRef = React.useRef<CalendarDayHandle>(null);\n  const monthPickerRef = React.useRef<CalendarMonthHandle>(null);\n  // Set while a request runs, so the blur caused by returning focus to the field does not request a second change.\n  const isRequestingOpen = React.useRef(false);\n  const wasOpenOnLastEffect = React.useRef(false);\n  const focusWithinSurface = React.useRef(false);\n  // In the overlay layout the day heading first switches to the month view, which then opens the year-range grid.\n  const showYearPickerOnMount = React.useRef(false);\n\n  const isWithin = (element: HTMLElement | null, target: EventTarget | null) =>\n    !!element && !!target && element.contains(target as Node);\n\n  // Focuses the day picker, otherwise the month picker of a month-only calendar, otherwise the surface.\n  const focusCalendar = useEventCallback(() => {\n    if (dayPickerRef.current) {\n      dayPickerRef.current.focus({ preventScroll: true });\n    } else if (monthPickerRef.current) {\n      monthPickerRef.current.focus({ preventScroll: true });\n    } else {\n      surfaceRef.current?.focus({ preventScroll: true });\n    }\n  });\n\n  const requestOpen = useEventCallback((event: DatePickerEvent, nextOpen: boolean, reason: OpenChangeReason) => {\n    if (isRequestingOpen.current || open === nextOpen || (nextOpen && disabled)) {\n      return;\n    }\n    isRequestingOpen.current = true;\n\n    if (!nextOpen && reason !== 'focusOut' && reason !== 'outsideClick' && focusWithinSurface.current) {\n      const surfaceHasFocus = surfaceRef.current && isWithin(surfaceRef.current, getActiveElement(surfaceRef.current));\n      focusWithinSurface.current = false;\n      if (surfaceHasFocus) {\n        // Selection and Escape return focus to the field before the surface unmounts.\n        controlRef.current?.focus({ preventScroll: true });\n      }\n    }\n\n    isRequestingOpen.current = false;\n    setOpenState(nextOpen);\n    onOpenChange?.(event, { event, type: event.type, open: nextOpen, reason });\n  });\n\n  React.useEffect(() => {\n    const opened = open && !wasOpenOnLastEffect.current;\n    wasOpenOnLastEffect.current = open;\n    if (open) {\n      // Focus moves into the calendar on every opening, including defaultOpen and controlled `open` changes.\n      if (opened) {\n        focusCalendar();\n      }\n      return;\n    }\n\n    showYearPickerOnMount.current = false;\n    // A controlled close may remove the focused surface without a blur; restore focus from the surface tracker.\n    const root = rootRef.current;\n    const activeElement = root ? getActiveElement(root) : targetDocument?.activeElement;\n    const shadowRoot = root?.getRootNode();\n    const ShadowRootConstructor = root?.ownerDocument.defaultView?.ShadowRoot;\n    const focusWasLost =\n      !activeElement ||\n      activeElement === targetDocument?.body ||\n      (!!ShadowRootConstructor && shadowRoot instanceof ShadowRootConstructor && activeElement === shadowRoot.host);\n    if (\n      focusWithinSurface.current &&\n      (focusWasLost || (surfaceRef.current && isWithin(surfaceRef.current, activeElement)))\n    ) {\n      focusWithinSurface.current = false;\n      controlRef.current?.focus({ preventScroll: true });\n    }\n  }, [focusCalendar, open, targetDocument]);\n\n  const onOutsidePointerDown = useEventCallback((event: PointerEvent) => {\n    const path = event.composedPath();\n    if (\n      (rootRef.current && path.includes(rootRef.current)) ||\n      (surfaceRef.current && path.includes(surfaceRef.current))\n    ) {\n      return;\n    }\n    focusWithinSurface.current = false;\n    requestOpen(event, false, 'outsideClick');\n    dateState.validate(event);\n  });\n\n  React.useEffect(() => {\n    if (!open || !targetDocument) {\n      return;\n    }\n    targetDocument.addEventListener('pointerdown', onOutsidePointerDown, true);\n    return () => targetDocument.removeEventListener('pointerdown', onOutsidePointerDown, true);\n  }, [open, targetDocument, onOutsidePointerDown]);\n\n  const { targetRef, containerRef } = usePositioning({\n    position: 'below',\n    align: 'start',\n    ...resolvePositioningShorthand(positioning),\n  });\n\n  // Field control\n\n  const valueId = useId('datepicker-value-');\n  const surfaceId = useId('datepicker-popup-', slot.resolveShorthand(props.popupSurface)?.id);\n  const errorMessageSlot = slot.optional(props.errorMessage, { renderByDefault: true, elementType: 'div' });\n  const errorMessageId = useId('datepicker-error-', errorMessageSlot?.id);\n  const describedBy =\n    [fieldControlProps['aria-describedby'], error && errorMessageSlot ? errorMessageId : undefined]\n      .filter(Boolean)\n      .join(' ') || undefined;\n\n  const controlAriaProps = {\n    'aria-controls': open ? surfaceId : undefined,\n    'aria-describedby': describedBy,\n    'aria-expanded': open,\n    'aria-haspopup': 'dialog' as const,\n    'aria-invalid': error ? true : fieldControlProps['aria-invalid'],\n    'aria-required': required || undefined,\n  };\n\n  const onControlKeyDown = useEventCallback((event: React.KeyboardEvent<HTMLElement>) => {\n    if (event.isDefaultPrevented() || disabled) {\n      return;\n    }\n\n    if (event.key === ArrowDown && event.altKey) {\n      event.preventDefault();\n      if (open) {\n        focusCalendar();\n      } else {\n        requestOpen(event, true, 'keyboard');\n      }\n    } else if (event.key === Escape && open) {\n      // Keep the Escape that closes the calendar from also dismissing a surrounding dialog or popover.\n      event.preventDefault();\n      event.stopPropagation();\n      requestOpen(event, false, 'keyboard');\n    } else if (event.key === Enter && allowTextInput && !event.nativeEvent.isComposing) {\n      dateState.validate(event);\n    }\n  });\n\n  const onControlBlur = useEventCallback((event: React.FocusEvent<HTMLElement>) => {\n    // Moving between the field and the calendar does not submit pending text.\n    if (!isWithin(rootRef.current, event.relatedTarget) && !isWithin(surfaceRef.current, event.relatedTarget)) {\n      dateState.validate(event);\n    }\n  });\n\n  const formattedValue = dateState.value ? formatDate(dateState.value) : '';\n\n  const input = allowTextInput\n    ? slot.always(props.input, {\n        defaultProps: {\n          ...(nativeProps.primary as Omit<React.ComponentProps<'input'>, 'children'>),\n          autoComplete: 'off',\n          type: 'text',\n        },\n        elementType: 'input',\n      })\n    : undefined;\n  if (input) {\n    const inputDescribedBy = input['aria-describedby'];\n    const inputInvalid = input['aria-invalid'];\n    Object.assign(input, controlAriaProps);\n    input['aria-describedby'] = mergeAriaDescribedBy(describedBy, inputDescribedBy);\n    input['aria-invalid'] = error ? true : inputInvalid ?? fieldControlProps['aria-invalid'];\n    // aria-expanded is not supported on text inputs, and the popup is not a listbox, so the field is not a combobox.\n    // The calendar icon exposes the expanded state instead.\n    delete input['aria-expanded'];\n    input.id = controlId;\n    input.disabled = disabled;\n    input.placeholder = placeholder;\n    input.value = dateState.text;\n    input.onChange = mergeCallbacks(input.onChange, event => {\n      dateState.setText(event.target.value);\n    });\n    input.onKeyDown = mergeCallbacks(input.onKeyDown, onControlKeyDown);\n    input.onBlur = mergeCallbacks(input.onBlur, onControlBlur);\n  }\n\n  const displayValue = slot.always(props.displayValue, {\n    defaultProps: { children: formattedValue || placeholder },\n    elementType: 'span',\n  });\n  displayValue.id ??= valueId;\n\n  const trigger = allowTextInput\n    ? undefined\n    : slot.always(props.trigger, {\n        // Native props target the field control, which is a button when the field is not editable.\n        defaultProps: { ...(nativeProps.primary as React.ComponentProps<'button'>), type: 'button' },\n        elementType: 'button',\n      });\n  const control = input ?? trigger;\n  const mergedControlRef = useMergedRefs<HTMLInputElement & HTMLButtonElement>(\n    control?.ref as React.Ref<HTMLInputElement & HTMLButtonElement> | undefined,\n    ref as React.Ref<HTMLInputElement & HTMLButtonElement>,\n    controlRef,\n  );\n  if (control) {\n    control.ref = mergedControlRef;\n  }\n\n  if (trigger) {\n    const triggerDescribedBy = trigger['aria-describedby'];\n    const triggerInvalid = trigger['aria-invalid'];\n    Object.assign(trigger, controlAriaProps);\n    trigger['aria-describedby'] = mergeAriaDescribedBy(describedBy, triggerDescribedBy);\n    trigger['aria-invalid'] = error ? true : triggerInvalid ?? fieldControlProps['aria-invalid'];\n    // aria-required is not supported on buttons; a surrounding Field conveys that a date is required.\n    delete trigger['aria-required'];\n    // The accessible name combines the field's purpose with the displayed date or placeholder.\n    const labelledBy = trigger['aria-labelledby'] ?? (trigger['aria-label'] ? controlId : undefined);\n    trigger['aria-labelledby'] = labelledBy ? `${labelledBy} ${displayValue.id}` : undefined;\n    trigger.id = controlId;\n    trigger.disabled = disabled;\n    trigger.onClick = mergeCallbacks(trigger.onClick, event => {\n      if (!event.isDefaultPrevented() && !disabled) {\n        requestOpen(event, !open, 'trigger');\n      }\n    });\n    // Keep focus in the calendar while the trigger is pressed so the click closes rather than reopens it.\n    trigger.onMouseDown = mergeCallbacks(trigger.onMouseDown, event => {\n      if (open) {\n        event.preventDefault();\n      }\n    });\n    trigger.onKeyDown = mergeCallbacks(trigger.onKeyDown, onControlKeyDown);\n    trigger.onBlur = mergeCallbacks(trigger.onBlur, onControlBlur);\n  }\n\n  const icon = slot.optional(props.icon, { renderByDefault: true, elementType: 'span' });\n  if (icon) {\n    if (allowTextInput) {\n      // Not a tab stop: keyboard users open the calendar with Alt + Arrow Down from the input. It is still focusable\n      // and activatable with Enter or Space, so assistive technology that focuses the button can operate it.\n      icon.role ??= 'button';\n      icon.tabIndex ??= -1;\n      icon['aria-label'] ??= 'Choose date';\n      icon['aria-controls'] = open ? surfaceId : undefined;\n      icon['aria-disabled'] = disabled || undefined;\n      icon['aria-expanded'] = open;\n      icon.onMouseDown = mergeCallbacks(icon.onMouseDown, event => {\n        // Keep focus where it is, so pressing the icon neither validates pending text nor dismisses the calendar.\n        event.preventDefault();\n      });\n      icon.onClick = mergeCallbacks(icon.onClick, event => {\n        if (!event.isDefaultPrevented() && !disabled) {\n          requestOpen(event, !open, 'icon');\n        }\n      });\n      icon.onKeyDown = mergeCallbacks(icon.onKeyDown, event => {\n        if (event.isDefaultPrevented() || disabled || (event.key !== Enter && event.key !== Space)) {\n          return;\n        }\n        // Space would otherwise scroll the page.\n        event.preventDefault();\n        requestOpen(event, !open, 'icon');\n      });\n      icon.onBlur = mergeCallbacks(icon.onBlur, onControlBlur);\n    } else {\n      icon['aria-hidden'] = true;\n    }\n  }\n\n  const errorMessage = errorMessageSlot;\n  if (errorMessage) {\n    errorMessage.id = errorMessageId;\n    errorMessage['aria-live'] ??= 'polite';\n    errorMessage.children ??= error ? formatErrorMessage({ error, formatDate, maxDate, minDate }) : undefined;\n  }\n\n  const onDayPickerHeaderSelect = useEventCallback(() => monthPickerRef.current?.showYearPicker());\n  const onMonthPickerHandle = React.useCallback((handle: CalendarMonthHandle | null) => {\n    if (handle && showYearPickerOnMount.current) {\n      showYearPickerOnMount.current = false;\n      handle.showYearPicker();\n    }\n  }, []);\n  const onCalendarViewChange = useEventCallback((_event: DatePickerEvent, data: CalendarViewChangeData) => {\n    showYearPickerOnMount.current = data.view === 'month';\n  });\n  const onDisplayedDateChange = useEventCallback((_event: DatePickerEvent, data: { displayedDate: Date }) => {\n    setDisplayedDate(data.displayedDate);\n  });\n  const onCalendarSelectDate = useEventCallback((event: DatePickerEvent, data: { date: Date }) => {\n    if (!isDefaultPrevented(event) && !disabled) {\n      dateState.selectDate(event, data.date);\n      requestOpen(event, false, 'selection');\n    }\n  });\n  const onCalendarDismiss = useEventCallback((event: DatePickerEvent) => {\n    if (!isDefaultPrevented(event)) {\n      // Calendar stops propagation; cancelling the key also stops a native dialog or popover ancestor from closing.\n      event.preventDefault();\n      requestOpen(event, false, 'escape');\n    }\n  });\n  const onSurfaceFocus = useEventCallback(() => {\n    focusWithinSurface.current = true;\n  });\n  const onSurfaceBlur = useEventCallback((event: React.FocusEvent<HTMLDivElement>) => {\n    const nextTarget = event.relatedTarget;\n    if (isWithin(surfaceRef.current, nextTarget)) {\n      return;\n    }\n    focusWithinSurface.current = false;\n    // Focus leaving the window keeps the calendar open.\n    if (!nextTarget) {\n      return;\n    }\n    requestOpen(event, false, 'focusOut');\n    if (!isWithin(rootRef.current, nextTarget)) {\n      dateState.validate(event);\n    }\n  });\n  const onSurfaceKeyDown = useEventCallback((event: React.KeyboardEvent<HTMLDivElement>) => {\n    if (event.key === Escape && !event.isDefaultPrevented()) {\n      event.preventDefault();\n      event.stopPropagation();\n      requestOpen(event, false, 'escape');\n    }\n  });\n\n  // Calendar\n\n  const formatters: CalendarFormatters = { ...calendarFormatters, dayPickerHeaderLabel, ...calendarProps.formatters };\n\n  const calendar = slot.always<CalendarProps>(props.calendar, {\n    defaultProps: {\n      calendarMonthColumns: 3,\n      calendarYearColumns: 3,\n    },\n    elementType: Calendar,\n  });\n  // showGoToToday alone controls visibility, so styling the button through the calendar slot does not show it.\n  if (!showGoToToday) {\n    calendar.goToTodayButton = null;\n  }\n\n  const dayPickerProps: CalendarDayProps | null | undefined =\n    calendarProps.dayPicker === null ? null : slot.resolveShorthand(calendarProps.dayPicker);\n  const monthPickerProps: CalendarMonthProps | null | undefined =\n    calendarProps.monthPicker === null ? null : slot.resolveShorthand(calendarProps.monthPicker);\n  const mergedDayPickerRef = useMergedRefs(dayPickerProps?.imperativeRef, dayPickerRef);\n  const mergedMonthPickerRef = useMergedRefs(monthPickerProps?.imperativeRef, monthPickerRef, onMonthPickerHandle);\n  // The overlay layout mounts one picker at a time, so the day heading keeps Calendar's switch to the month view.\n  const isOverlay = calendarProps.layout === 'overlay' && dayPickerProps !== null && monthPickerProps !== null;\n\n  if (dayPickerProps !== null) {\n    calendar.dayPicker = {\n      ...(monthPickerProps === null || isOverlay ? undefined : { onHeaderSelect: onDayPickerHeaderSelect }),\n      ...dayPickerProps,\n      imperativeRef: mergedDayPickerRef,\n    };\n  }\n  if (monthPickerProps !== null) {\n    const getMonthCellProps = monthPickerProps?.getCellProps;\n    calendar.monthPicker = {\n      ...monthPickerProps,\n      imperativeRef: mergedMonthPickerRef,\n      getCellProps: month => {\n        const overrides = getMonthCellProps?.(month);\n        const date = setMonth(displayedDate, month.index);\n        // Name months with their year, such as \"August 2026\", rather than an abbreviation.\n        return {\n          ...overrides,\n          root: { 'aria-label': formatters.dateTime({ date, format: 'monthYear' }), ...overrides?.root },\n        };\n      },\n    };\n  }\n\n  calendar.formatters = formatters;\n  calendar.value = dateState.value;\n  calendar.today = today;\n  calendar.minDate = minDate;\n  calendar.maxDate = maxDate;\n  calendar.displayedDate = displayedDate;\n  calendar.onDisplayedDateChange = mergeCallbacks(calendar.onDisplayedDateChange, onDisplayedDateChange);\n  calendar.onSelectDate = mergeCallbacks(calendar.onSelectDate, onCalendarSelectDate);\n  calendar.onDismiss = mergeCallbacks(calendar.onDismiss, onCalendarDismiss);\n  calendar.onViewChange = mergeCallbacks(calendar.onViewChange, onCalendarViewChange);\n\n  // Popup surface\n\n  const popupSurface = slot.always(props.popupSurface, {\n    defaultProps: {\n      'aria-label': formatters.dateTime({ date: displayedDate, format: 'monthYear' }),\n      role: 'dialog',\n      // Pressing a non-focusable part of the surface focuses the surface instead of the body.\n      tabIndex: -1,\n    },\n    elementType: 'div',\n  });\n  Object.assign(popupSurface, { popover: 'manual' });\n  popupSurface.id = surfaceId;\n  popupSurface.ref = useMergedRefs(popupSurface.ref, surfaceRef, containerRef);\n  popupSurface.onFocus = mergeCallbacks(popupSurface.onFocus, onSurfaceFocus);\n  popupSurface.onBlur = mergeCallbacks(popupSurface.onBlur, onSurfaceBlur);\n  popupSurface.onKeyDown = mergeCallbacks(popupSurface.onKeyDown, onSurfaceKeyDown);\n\n  // Declared after the surface handlers, so focus moved while showing the popover reaches them.\n  useIsomorphicLayoutEffect(() => {\n    const surface = surfaceRef.current;\n    if (open && surface && typeof surface.showPopover === 'function' && !surface.matches(':popover-open')) {\n      surface.showPopover();\n    }\n  }, [open]);\n\n  // Root\n\n  const root = slot.always(props.root, { defaultProps: nativeProps.root, elementType: 'div' });\n  root.ref = useMergedRefs(root.ref, rootRef, targetRef);\n  // Applied after consumer props so reserved state cannot be misrepresented.\n  Object.assign(root, {\n    'data-open': toDataAttributeValue(open),\n    'data-disabled': toDataAttributeValue(disabled),\n    'data-invalid': toDataAttributeValue(!!error),\n    'data-editable': toDataAttributeValue(allowTextInput),\n    'data-placeholder': toDataAttributeValue(!dateState.value),\n  });\n\n  return {\n    allowTextInput,\n    disabled,\n    error,\n    open,\n    required,\n    value: dateState.value,\n    components: {\n      root: 'div',\n      input: 'input',\n      trigger: 'button',\n      displayValue: 'span',\n      icon: 'span',\n      errorMessage: 'div',\n      popupSurface: 'div',\n      calendar: Calendar,\n    },\n    root,\n    input,\n    trigger,\n    displayValue,\n    icon,\n    errorMessage,\n    popupSurface,\n    calendar,\n  };\n};\n"],"names":["useDatePicker","isDefaultPrevented","event","defaultPrevented","getActiveElement","element","root","getRootNode","ShadowRootConstructor","ownerDocument","defaultView","ShadowRoot","activeElement","mergeAriaDescribedBy","values","ids","Set","flatMap","value","trim","split","filter","Boolean","size","join","undefined","defaultFormatErrorMessage","error","minDate","maxDate","formatDate","dayPickerHeaderLabel","data","formattedDate","props","ref","allowTextInput","disabled","defaultFormatDate","formatErrorMessage","onOpenChange","parseDate","defaultParseDate","placeholder","positioning","showGoToToday","today","todayProp","targetDocument","useFluent","React","useMemo","Date","fieldControlProps","useFieldControlProps_unstable","supportsLabelFor","nativeProps","getPartitionedNativeProps","primarySlotTagName","excludedPropNames","required","controlId","useId","id","calendarProps","slot","resolveShorthand","calendar","restrictedDates","isDateUnavailable","date","isRestrictedDate","dateState","useDatePickerDateState","defaultValue","onDateChange","onValidationResult","getInitialDisplayedDate","compareDatePart","monthEnd","getMonthEnd","day","getMonthStart","addDays","displayedDate","setDisplayedDate","useState","openState","setOpenState","useControllableState","state","open","defaultState","defaultOpen","initialState","wasOpen","setWasOpen","rootRef","useRef","controlRef","surfaceRef","dayPickerRef","monthPickerRef","isRequestingOpen","wasOpenOnLastEffect","focusWithinSurface","showYearPickerOnMount","isWithin","target","contains","focusCalendar","useEventCallback","current","focus","preventScroll","requestOpen","nextOpen","reason","surfaceHasFocus","type","useEffect","opened","shadowRoot","focusWasLost","body","host","onOutsidePointerDown","path","composedPath","includes","validate","addEventListener","removeEventListener","targetRef","containerRef","usePositioning","position","align","resolvePositioningShorthand","valueId","surfaceId","popupSurface","errorMessageSlot","optional","errorMessage","renderByDefault","elementType","errorMessageId","describedBy","controlAriaProps","onControlKeyDown","key","ArrowDown","altKey","preventDefault","Escape","stopPropagation","Enter","nativeEvent","isComposing","onControlBlur","relatedTarget","formattedValue","input","always","defaultProps","primary","autoComplete","inputDescribedBy","inputInvalid","Object","assign","text","onChange","mergeCallbacks","setText","onKeyDown","onBlur","displayValue","children","trigger","control","mergedControlRef","useMergedRefs","triggerDescribedBy","triggerInvalid","labelledBy","onClick","onMouseDown","icon","role","tabIndex","Space","onDayPickerHeaderSelect","showYearPicker","onMonthPickerHandle","useCallback","handle","onCalendarViewChange","_event","view","onDisplayedDateChange","onCalendarSelectDate","selectDate","onCalendarDismiss","onSurfaceFocus","onSurfaceBlur","nextTarget","onSurfaceKeyDown","formatters","calendarFormatters","calendarMonthColumns","calendarYearColumns","Calendar","goToTodayButton","dayPickerProps","dayPicker","monthPickerProps","monthPicker","mergedDayPickerRef","imperativeRef","mergedMonthPickerRef","isOverlay","layout","onHeaderSelect","getMonthCellProps","getCellProps","month","overrides","setMonth","index","dateTime","format","onSelectDate","onDismiss","onViewChange","popover","onFocus","useIsomorphicLayoutEffect","surface","showPopover","matches","toDataAttributeValue","components"],"mappings":"AAAA;;;;;+BA2FaA;;;eAAAA;;;;iEAzFU;8BACyB;4BACF;qCACE;gCAUzC;uBACqD;uBACvB;0BACZ;wBASlB;sCAK6C;wCACb;AAYvC,MAAMC,qBAAqB,CAACC,QAC1B,iBAAiBA,QAAQA,MAAMD,kBAAkB,KAAKC,MAAMC,gBAAgB;AAE9E,MAAMC,mBAAmB,CAACC;IACxB,MAAMC,OAAOD,QAAQE,WAAW;IAChC,MAAMC,wBAAwBH,QAAQI,aAAa,CAACC,WAAW,EAAEC;IACjE,OAAOH,yBAAyBF,gBAAgBE,wBAC5CF,KAAKM,aAAa,IAAIP,QAAQI,aAAa,CAACG,aAAa,GACzDP,QAAQI,aAAa,CAACG,aAAa;AACzC;AAEA,MAAMC,uBAAuB,CAAC,GAAGC;IAC/B,MAAMC,MAAM,IAAIC,IAAIF,OAAOG,OAAO,CAACC,CAAAA,QAASA,OAAOC,OAAOC,MAAM,OAAOC,OAAOC,YAAY,EAAE;IAC5F,OAAOP,IAAIQ,IAAI,GAAG;WAAIR;KAAI,CAACS,IAAI,CAAC,OAAOC;AACzC;AAEA,MAAMC,4BAA4B,CAAC,EAAEC,KAAK,EAAEC,OAAO,EAAEC,OAAO,EAAEC,U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