{"version":3,"sources":["jsdelivr-header.js","/npm/@instructure/ui-portal@10.18.1/es/Portal/props.js","/npm/@instructure/ui-portal@10.18.1/es/Portal/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,+hBC0BA,MAAM,EAAY,CAChB,KAAM,EAAU,KAChB,OAAQ,EAAU,KAClB,QAAS,EAAU,KACnB,UAAW,EAAU,UAAU,CAAC,EAAS,EAAU,OACnD,SAAU,EAAU,MAAM,CAAC,SAAU,QACrC,SAAU,EAAU,KACpB,WAAY,EAAU,KACtB,IAAK,EAAU,MAAM,OAAO,OAAO,EAA6B,aCvC5D,EAAY,CAAC,OAAQ,WAAY,SAAU,UAAW,YAAa,WAAY,aAAc,OACnG,IAAU,EAAQ,EAqCf,IAAC,EAAiB,GAAgC,GAAe,EAAU,cAAqB,EACjG,WAAA,CAAY,GACV,MAAM,GACN,KAAK,QAAU,KACf,KAAK,IAAM,KACX,KAAK,UAAY,IACf,MAAM,EAAa,KAAK,MAAM,WAC9B,KAAK,IAAM,EACX,KAAK,QAAU,EACW,mBAAf,GACT,EAAW,EACnB,EAES,IAGL,KAAK,MAAQ,CACX,UAAW,KAAK,cAAc,IAEpC,CACE,iBAAA,GACO,GAKD,KAAK,MAAM,MAAQ,EAAS,MAAM,KAAK,MAAM,UAAY,GAC3D,KAAK,aAAY,KACX,KAAK,MAAM,MAAqC,mBAAtB,KAAK,MAAM,QACvC,KAAK,MAAM,OAAO,KAAK,QACjC,GAGA,CACE,kBAAA,CAAmB,GACjB,IAAK,EACH,OAEF,MAAM,EAAY,KAAK,cAAc,KAAK,OACtC,IAAc,KAAK,MAAM,WAE3B,KAAK,SAAS,CACZ,cAKA,KAAK,MAAM,OAAS,EAAU,MAAqC,mBAAtB,KAAK,MAAM,QAC1D,KAAK,MAAM,OAAO,KAAK,UAIpB,KAAK,MAAM,MAAQ,EAAU,MAAsC,mBAAvB,KAAK,MAAM,SAC1D,KAAK,MAAM,SAEjB,CACE,oBAAA,GAC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Ae,CAC5H,MAAM,EACN,SAAU,SACV,OAAQ,OACR,QAAS,OACT,UAAW,KACX,SAAU,KACV,WAAY,QA3I4C,EA4IvD,KAAa,S","file":"/npm/@instructure/ui-portal@10.18.1/es/index.js/+esm","sourceRoot":"","sourcesContent":["/**\n * Bundled by jsDelivr using Rollup v2.79.2 and Terser v5.39.0.\n * Original file: /npm/@instructure/ui-portal@10.18.1/es/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 - present Instructure, Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport PropTypes from 'prop-types';\nimport { element } from '@instructure/ui-prop-types';\nimport { textDirectionContextConsumer } from '@instructure/ui-i18n';\n\n/**\n * The DOM Node of the Portal. It is created as a `span` element.\n */\n\nconst propTypes = {\n  open: PropTypes.bool,\n  onOpen: PropTypes.func,\n  onClose: PropTypes.func,\n  mountNode: PropTypes.oneOfType([element, PropTypes.func]),\n  insertAt: PropTypes.oneOf(['bottom', 'top']),\n  children: PropTypes.node,\n  elementRef: PropTypes.func,\n  dir: PropTypes.oneOf(Object.values(textDirectionContextConsumer.DIRECTION))\n};\nconst allowedProps = ['open', 'onOpen', 'onClose', 'mountNode', 'insertAt', 'children', 'elementRef', 'dir'];\nexport { propTypes, allowedProps };","import _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nconst _excluded = [\"open\", \"insertAt\", \"onOpen\", \"onClose\", \"mountNode\", \"children\", \"elementRef\", \"dir\"];\nvar _dec, _class, _Portal;\n/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 - present Instructure, Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Children, Component } from 'react';\nimport ReactDOM from 'react-dom';\nimport { passthroughProps } from '@instructure/ui-react-utils';\nimport { textDirectionContextConsumer } from '@instructure/ui-i18n';\nimport { canUseDOM } from '@instructure/ui-dom-utils';\nimport { propTypes, allowedProps } from './props';\n/**\n---\ncategory: components/utilities\n---\n@module Portal\n**/\nlet Portal = (_dec = textDirectionContextConsumer(), _dec(_class = (_Portal = class Portal extends Component {\n  constructor(props) {\n    super(props);\n    this.DOMNode = null;\n    this.ref = null;\n    this.handleRef = el => {\n      const elementRef = this.props.elementRef;\n      this.ref = el;\n      this.DOMNode = el;\n      if (typeof elementRef === 'function') {\n        elementRef(el);\n      }\n    };\n    if (!canUseDOM) {\n      return;\n    }\n    this.state = {\n      mountNode: this.findMountNode(props)\n    };\n  }\n  componentDidMount() {\n    if (!canUseDOM) {\n      return;\n    }\n\n    // If Portal is mounting in an open condition fire onOpen handler\n    if (this.props.open && Children.count(this.props.children) > 0) {\n      this.forceUpdate(() => {\n        if (this.props.open && typeof this.props.onOpen === 'function') {\n          this.props.onOpen(this.DOMNode);\n        }\n      });\n    }\n  }\n  componentDidUpdate(prevProps) {\n    if (!canUseDOM) {\n      return;\n    }\n    const mountNode = this.findMountNode(this.props);\n    if (mountNode !== this.state.mountNode) {\n      // set state here to make the component re-render\n      this.setState({\n        mountNode\n      });\n    }\n\n    // If Portal was closed but is now open fire onOpen handler\n    if (this.props.open && !prevProps.open && typeof this.props.onOpen === 'function') {\n      this.props.onOpen(this.DOMNode);\n    }\n\n    // If Portal was open but is now closed fire onClose handler\n    if (!this.props.open && prevProps.open && typeof this.props.onClose === 'function') {\n      this.props.onClose();\n    }\n  }\n  componentWillUnmount() {\n    if (!canUseDOM) {\n      return;\n    }\n    this.removeNode();\n\n    // If Portal was open fire onClose handler\n    if (this.props.open && typeof this.props.onClose === 'function') {\n      this.props.onClose();\n    }\n  }\n  removeNode() {\n    if (this.DOMNode && this.DOMNode.parentNode && typeof this.DOMNode.parentNode.removeChild === 'function') {\n      this.DOMNode.parentNode.removeChild(this.DOMNode);\n      this.handleRef(null);\n    }\n  }\n  insertNode() {\n    const _this$props = this.props,\n      open = _this$props.open,\n      insertAt = _this$props.insertAt,\n      onOpen = _this$props.onOpen,\n      onClose = _this$props.onClose,\n      mountNode = _this$props.mountNode,\n      children = _this$props.children,\n      elementRef = _this$props.elementRef,\n      dir = _this$props.dir,\n      props = _objectWithoutProperties(_this$props, _excluded);\n\n    // Create node if it doesn't already exist\n    if (!this.DOMNode) {\n      const node = document.createElement('span');\n      const attributes = {\n        ...passthroughProps(props),\n        dir\n      };\n      Object.keys(attributes).forEach(name => {\n        node.setAttribute(name, attributes[name]);\n      });\n      this.handleRef(node);\n    }\n\n    // Append node to container if it isn't already\n    if (this.DOMNode && this.DOMNode.parentNode !== this.state.mountNode) {\n      if (insertAt === 'bottom') {\n        this.state.mountNode.appendChild(this.DOMNode);\n      } else {\n        this.state.mountNode.insertBefore(this.DOMNode, this.state.mountNode.firstChild);\n      }\n    }\n    return this.DOMNode;\n  }\n  findMountNode(props) {\n    let mountNode;\n    if (typeof props.mountNode === 'function') {\n      mountNode = props.mountNode();\n    } else if (props.mountNode) {\n      mountNode = props.mountNode;\n    }\n    if (!mountNode || !mountNode.nodeName) {\n      mountNode = document.body;\n    }\n    return mountNode;\n  }\n  get node() {\n    return this.DOMNode;\n  }\n  render() {\n    const _this$props2 = this.props,\n      children = _this$props2.children,\n      open = _this$props2.open;\n    if (!canUseDOM && open) {\n      return children;\n    }\n    return open && Children.count(children) > 0 ? /*#__PURE__*/ReactDOM.createPortal(children, this.insertNode()) : null;\n  }\n}, _Portal.displayName = \"Portal\", _Portal.propTypes = propTypes, _Portal.allowedProps = allowedProps, _Portal.defaultProps = {\n  open: false,\n  insertAt: 'bottom',\n  onOpen: () => {},\n  onClose: () => {},\n  mountNode: null,\n  children: null,\n  elementRef: () => {}\n}, _Portal)) || _class);\nexport default Portal;\nexport { Portal };"]}