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AAa;gBAAA;aAAE;YAC9G;gBAAC,CAAA,GAAA,wCAAyB;gBAAG;aAAM;SACpC;OACA,YAAY,QAAQ;AAK/B;AAWA,SAAS,mCAAa,KAAwB;IAC5C,IAAI,cAAC,UAAU,YAAE,QAAQ,aAAE,SAAS,iBAAE,aAAa,EAAC,GAAG,CAAA,GAAA,iBAAS,EAAE;IAClE,IAAI,QAAQ,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,wCAAyB;IAChD,IAAI,aAAa,CAAA,GAAA,cAAM,EAAE,IAAM,CAAA,GAAA,gBAAQ,EAAE,MAAM,QAAQ,EAAE,WAAW;QAAC,MAAM,QAAQ;QAAE;KAAS;IAE9F,IAAI,MAAM,CAAA,GAAA,mBAAW,EAAE;IACvB,IAAI,WAAW,CAAA,GAAA,wBAAgB,EAAE;IACjC,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,kBAAkB;QAClB,QAAQ;YACN,YAAY;uBACZ;mBACA;QACF;IACF;IAEA,qBACE,gCAAC,CAAA,GAAA,yCAAE,EAAE,GAAG;QACL,GAAG,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,qBAAa,EAAE,OAAO;YAAC,QAAQ;QAAI,IAAI,WAAW;QAChE,GAAG,WAAW;QACf,KAAK;QACL,iBAAe,YAAY;QAC3B,gBAAc,aAAa;OAC1B,+BACC,gCAAC,CAAA,GAAA,oBAAY;QAAE,WAAW,MAAM,KAAK;QAEtC,YAAY,QAAQ;AAG3B","sources":["packages/react-aria-components/src/Modal.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaModalOverlayProps, useModalOverlay} from 'react-aria/useModalOverlay';\n\nimport {\n  ClassNameOrFunction,\n  ContextValue,\n  dom,\n  Provider,\n  RenderProps,\n  SlotProps,\n  useContextProps,\n  useRenderProps\n} from './utils';\nimport {DismissButton, Overlay} from 'react-aria/Overlay';\nimport {DOMAttributes, forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {isScrollable} from 'react-aria/private/utils/isScrollable';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport {OverlayTriggerProps, OverlayTriggerState, useOverlayTriggerState} from 'react-stately/useOverlayTriggerState';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport React, {createContext, ForwardedRef, forwardRef, useContext, useMemo, useRef} from 'react';\nimport {useEnterAnimation, useExitAnimation} from 'react-aria/private/utils/animation';\nimport {useIsSSR} from 'react-aria/SSRProvider';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {useViewportSize} from 'react-aria/private/utils/useViewportSize';\n\nexport interface ModalOverlayProps extends AriaModalOverlayProps, OverlayTriggerProps, RenderProps<ModalRenderProps>, SlotProps, GlobalDOMAttributes<HTMLDivElement> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n   * @default 'react-aria-ModalOverlay'\n   */\n  className?: ClassNameOrFunction<ModalRenderProps>,\n  /**\n   * Whether the modal is currently performing an entry animation.\n   */\n  isEntering?: boolean,\n  /**\n   * Whether the modal is currently performing an exit animation.\n   */\n  isExiting?: boolean,\n  /**\n   * The container element in which the overlay portal will be placed. This may have unknown behavior depending on where it is portalled to.\n   * @default document.body\n   * @deprecated - Use a parent UNSAFE_PortalProvider to set your portal container instead.\n   */\n  UNSTABLE_portalContainer?: Element\n}\n\ninterface InternalModalContextValue {\n  modalProps: DOMAttributes,\n  modalRef: RefObject<HTMLDivElement | null>,\n  isExiting: boolean,\n  isDismissable?: boolean\n}\n\nexport const ModalContext = createContext<ContextValue<ModalOverlayProps, HTMLDivElement>>(null);\nconst InternalModalContext = createContext<InternalModalContextValue | null>(null);\n\nexport interface ModalRenderProps {\n  /**\n   * Whether the modal is currently entering. Use this to apply animations.\n   * @selector [data-entering]\n   */\n  isEntering: boolean,\n  /**\n   * Whether the modal is currently exiting. Use this to apply animations.\n   * @selector [data-exiting]\n   */\n  isExiting: boolean,\n  /**\n   * State of the modal.\n   */\n  state: OverlayTriggerState\n}\n\n/**\n * A modal is an overlay element which blocks interaction with elements outside it.\n */\nexport const Modal = /*#__PURE__*/ (forwardRef as forwardRefType)(function Modal(props: ModalOverlayProps, ref: ForwardedRef<HTMLDivElement>) {\n  let ctx = useContext(InternalModalContext);\n\n  if (ctx) {\n    if (process.env.NODE_ENV !== 'production' && (props.onOpenChange || props.defaultOpen !== undefined || props.isOpen !== undefined)) {\n      // create a list of props that are passed in but not allowed when using an external ModalOverlay\n      const invalidSet = new Set(['isDismissable', 'isKeyboardDismissDisabled', 'isOpen', 'defaultOpen', 'onOpenChange', 'isEntering', 'isExiting', 'UNSTABLE_portalContainer', 'shouldCloseOnInteractOutside']);\n      const invalidProps = Object.keys(props).filter(key => invalidSet.has(key));\n      console.warn(`This modal is already wrapped in a ModalOverlay, props [${invalidProps.join(', ')}] should be placed on the ModalOverlay instead.`);\n    }\n    return <ModalContent {...props} modalRef={ref}>{props.children}</ModalContent>;\n  }\n\n  let {\n    isDismissable,\n    isKeyboardDismissDisabled,\n    isOpen,\n    defaultOpen,\n    onOpenChange,\n    children,\n    isEntering,\n    isExiting,\n    UNSTABLE_portalContainer,\n    shouldCloseOnInteractOutside,\n    ...otherProps\n  } = props;\n\n  return (\n    <ModalOverlay\n      isDismissable={isDismissable}\n      isKeyboardDismissDisabled={isKeyboardDismissDisabled}\n      isOpen={isOpen}\n      defaultOpen={defaultOpen}\n      onOpenChange={onOpenChange}\n      isEntering={isEntering}\n      isExiting={isExiting}\n      UNSTABLE_portalContainer={UNSTABLE_portalContainer}\n      shouldCloseOnInteractOutside={shouldCloseOnInteractOutside}>\n      <ModalContent {...otherProps} modalRef={ref}>\n        {children}\n      </ModalContent>\n    </ModalOverlay>\n  );\n});\n\ninterface ModalOverlayInnerProps extends ModalOverlayProps {\n  overlayRef: RefObject<HTMLDivElement | null>,\n  modalRef: RefObject<HTMLDivElement | null>,\n  state: OverlayTriggerState,\n  isExiting: boolean\n}\n\nfunction ModalOverlayWithForwardRef(props: ModalOverlayProps, ref: ForwardedRef<HTMLDivElement>) {\n  [props, ref] = useContextProps(props, ref, ModalContext);\n  let contextState = useContext(OverlayTriggerStateContext);\n  let localState = useOverlayTriggerState(props);\n  let state = props.isOpen != null || props.defaultOpen != null || !contextState ? localState : contextState;\n  if (state === contextState) {\n    if (process.env.NODE_ENV !== 'production' && (props.onOpenChange || props.defaultOpen !== undefined || props.isOpen !== undefined)) {\n      console.warn('This modals state is controlled by a trigger, place onOpenChange on the trigger instead.');\n    }\n  }\n\n  let objectRef = useObjectRef(ref);\n  let modalRef = useRef<HTMLDivElement>(null);\n  let isOverlayExiting = useExitAnimation(objectRef, state.isOpen);\n  let isModalExiting = useExitAnimation(modalRef, state.isOpen);\n  let isExiting = isOverlayExiting || isModalExiting || props.isExiting || false;\n  let isSSR = useIsSSR();\n\n  if ((!state.isOpen && !isExiting) || isSSR) {\n    return null;\n  }\n\n  return (\n    <ModalOverlayInner\n      {...props}\n      state={state}\n      isExiting={isExiting}\n      overlayRef={objectRef}\n      modalRef={modalRef} />\n  );\n}\n\n/**\n * A ModalOverlay is a wrapper for a Modal which allows customizing the backdrop element.\n */\nexport const ModalOverlay = /*#__PURE__*/ (forwardRef as forwardRefType)(ModalOverlayWithForwardRef);\n\nfunction ModalOverlayInner({UNSTABLE_portalContainer, ...props}: ModalOverlayInnerProps) {\n  let modalRef = props.modalRef;\n  let {state} = props;\n  let {modalProps, underlayProps} = useModalOverlay(props, state, modalRef);\n\n  let entering = useEnterAnimation(props.overlayRef) || props.isEntering || false;\n  let renderProps = useRenderProps({\n    ...props,\n    defaultClassName: 'react-aria-ModalOverlay',\n    values: {\n      isEntering: entering,\n      isExiting: props.isExiting,\n      state\n    }\n  });\n\n  let viewport = useViewportSize();\n  let pageWidth: number | undefined = undefined;\n  let pageHeight: number | undefined = undefined;\n  if (typeof document !== 'undefined') {\n    let scrollingElement = isScrollable(document.body) ? document.body : document.scrollingElement || document.documentElement;\n    // Prevent Firefox from adding scrollbars when the page has a fractional width/height.\n    let fractionalWidthDifference = scrollingElement.getBoundingClientRect().width % 1;\n    let fractionalHeightDifference = scrollingElement.getBoundingClientRect().height % 1;\n    pageWidth = scrollingElement.scrollWidth - fractionalWidthDifference;\n    pageHeight = scrollingElement.scrollHeight - fractionalHeightDifference;\n  }\n\n  let style = {\n    ...renderProps.style,\n    '--visual-viewport-width': viewport.width + 'px',\n    '--visual-viewport-height': viewport.height + 'px',\n    '--page-width': pageWidth !== undefined ? pageWidth + 'px' : undefined,\n    '--page-height': pageHeight !== undefined ? pageHeight + 'px' : undefined\n  };\n\n  return (\n    <Overlay isExiting={props.isExiting} portalContainer={UNSTABLE_portalContainer}>\n      <dom.div\n        {...mergeProps(filterDOMProps(props, {global: true}), underlayProps)}\n        {...renderProps}\n        style={style}\n        ref={props.overlayRef}\n        data-entering={entering || undefined}\n        data-exiting={props.isExiting || undefined}>\n        <Provider\n          values={[\n            [InternalModalContext, {modalProps, modalRef, isExiting: props.isExiting, isDismissable: props.isDismissable}],\n            [OverlayTriggerStateContext, state]\n          ]}>\n          {renderProps.children}\n        </Provider>\n      </dom.div>\n    </Overlay>\n  );\n}\n\ninterface ModalContentProps extends RenderProps<ModalRenderProps>, GlobalDOMAttributes<HTMLDivElement> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n   * @default 'react-aria-ModalContent'\n   */\n  className?: ClassNameOrFunction<ModalRenderProps>,\n  modalRef: ForwardedRef<HTMLDivElement>\n}\n\nfunction ModalContent(props: ModalContentProps) {\n  let {modalProps, modalRef, isExiting, isDismissable} = useContext(InternalModalContext)!;\n  let state = useContext(OverlayTriggerStateContext)!;\n  let mergedRefs = useMemo(() => mergeRefs(props.modalRef, modalRef), [props.modalRef, modalRef]);\n\n  let ref = useObjectRef(mergedRefs);\n  let entering = useEnterAnimation(ref);\n  let renderProps = useRenderProps({\n    ...props,\n    defaultClassName: 'react-aria-Modal',\n    values: {\n      isEntering: entering,\n      isExiting,\n      state\n    }\n  });\n\n  return (\n    <dom.div\n      {...mergeProps(filterDOMProps(props, {global: true}), modalProps)}\n      {...renderProps}\n      ref={ref}\n      data-entering={entering || undefined}\n      data-exiting={isExiting || undefined}>\n      {isDismissable &&\n        <DismissButton onDismiss={state.close} />\n      }\n      {renderProps.children}\n    </dom.div>\n  );\n}\n"],"names":[],"version":3,"file":"Modal.mjs.map"}