{
  "version": 3,
  "sources": ["../src/portal.tsx"],
  "sourcesContent": ["import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\n\n/* -------------------------------------------------------------------------------------------------\n * Portal\n * -----------------------------------------------------------------------------------------------*/\n\ntype PortalElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface PortalProps extends PrimitiveDivProps {\n  /**\n   * An optional container where the portaled content should be appended.\n   */\n  container?: Element | DocumentFragment | null;\n}\n\nconst Portal = /* @__PURE__ */ React.forwardRef<PortalElement, PortalProps>(\n  function Portal(props, forwardedRef) {\n    const { container: containerProp, ...portalProps } = props;\n    const [mounted, setMounted] = React.useState(false);\n    useLayoutEffect(() => setMounted(true), []);\n    const container = containerProp || (mounted && globalThis?.document?.body);\n    return container\n      ? ReactDOM.createPortal(<Primitive.div {...portalProps} ref={forwardedRef} />, container)\n      : null;\n  },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Root = Portal;\n\nexport {\n  Portal,\n  //\n  Root,\n};\nexport type { PortalProps };\n"],
  "mappings": ";;;;;AAAA,YAAY,WAAW;AACvB,YAAY,cAAc;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAsBF;AAP9B,IAAM,SAAyB,gBAAM;AAAA,EACnC,gCAASA,QAAO,OAAO,cAAc;AACnC,UAAM,EAAE,WAAW,eAAe,GAAG,YAAY,IAAI;AACrD,UAAM,CAAC,SAAS,UAAU,IAAU,eAAS,KAAK;AAClD,oBAAgB,MAAM,WAAW,IAAI,GAAG,CAAC,CAAC;AAC1C,UAAM,YAAY,iBAAkB,WAAW,YAAY,UAAU;AACrE,WAAO,YACM,sBAAa,oBAAC,UAAU,KAAV,EAAe,GAAG,aAAa,KAAK,cAAc,GAAI,SAAS,IACtF;AAAA,EACN,GARA;AASF;AAIA,IAAM,OAAO;",
  "names": ["Portal"]
}
