{"version":3,"file":"vue-simple-portal.cjs","sources":["../../../../../node_modules/.pnpm/nanoid@3.3.7/node_modules/nanoid/non-secure/index.js","../../../../../node_modules/.pnpm/@linusborg+vue-simple-portal@0.1.5_vue@2.7.16/node_modules/@linusborg/vue-simple-portal/dist/index.esm.js"],"sourcesContent":["let urlAlphabet =\n  'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\nlet customAlphabet = (alphabet, defaultSize = 21) => {\n  return (size = defaultSize) => {\n    let id = ''\n    let i = size\n    while (i--) {\n      id += alphabet[(Math.random() * alphabet.length) | 0]\n    }\n    return id\n  }\n}\nlet nanoid = (size = 21) => {\n  let id = ''\n  let i = size\n  while (i--) {\n    id += urlAlphabet[(Math.random() * 64) | 0]\n  }\n  return id\n}\nexport { nanoid, customAlphabet }\n","\n/**\n * vue-simple-portal\n * version: 0.1.5,\n * (c) Thorsten Lünborg, 2021 - present\n * LICENCE: Apache-2.0\n * http://github.com/linusborg/vue-simple-portal\n*/\nimport Vue from 'vue';\nimport { nanoid } from 'nanoid/non-secure';\n\nfunction _typeof(obj) {\n  \"@babel/helpers - typeof\";\n\n  if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n    _typeof = function (obj) {\n      return typeof obj;\n    };\n  } else {\n    _typeof = function (obj) {\n      return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n    };\n  }\n\n  return _typeof(obj);\n}\n\nvar config = {\n  selector: \"vue-portal-target-\".concat(nanoid())\n};\nvar setSelector = function setSelector(selector) {\n  return config.selector = selector;\n};\nvar isBrowser = typeof window !== 'undefined' && (typeof document === \"undefined\" ? \"undefined\" : _typeof(document)) !== undefined;\n\nvar TargetContainer = Vue.extend({\n  // as an abstract component, it doesn't appear in\n  // the $parent chain of components.\n  // which means the next parent of any component rendered inside of this oen\n  // will be the parent from which is was sent\n  // @ts-expect-error\n  abstract: true,\n  name: 'PortalOutlet',\n  props: ['nodes', 'tag'],\n  data: function data(vm) {\n    return {\n      updatedNodes: vm.nodes\n    };\n  },\n  render: function render(h) {\n    var nodes = this.updatedNodes && this.updatedNodes();\n    if (!nodes) return h();\n    return nodes.length === 1 && !nodes[0].text ? nodes : h(this.tag || 'DIV', nodes);\n  },\n  destroyed: function destroyed() {\n    var el = this.$el;\n    el && el.parentNode.removeChild(el);\n  }\n});\n\nvar Portal = Vue.extend({\n  name: 'VueSimplePortal',\n  props: {\n    disabled: {\n      type: Boolean\n    },\n    prepend: {\n      type: Boolean\n    },\n    selector: {\n      type: String,\n      default: function _default() {\n        return \"#\".concat(config.selector);\n      }\n    },\n    tag: {\n      type: String,\n      default: 'DIV'\n    }\n  },\n  render: function render(h) {\n    if (this.disabled) {\n      var nodes = this.$scopedSlots && this.$scopedSlots.default();\n      if (!nodes) return h();\n      return nodes.length < 2 && !nodes[0].text ? nodes : h(this.tag, nodes);\n    }\n\n    return h();\n  },\n  created: function created() {\n    if (!this.getTargetEl()) {\n      this.insertTargetEl();\n    }\n  },\n  updated: function updated() {\n    var _this = this;\n\n    // We only update the target container component\n    // if the scoped slot function is a fresh one\n    // The new slot syntax (since Vue 2.6) can cache unchanged slot functions\n    // and we want to respect that here.\n    this.$nextTick(function () {\n      if (!_this.disabled && _this.slotFn !== _this.$scopedSlots.default) {\n        _this.container.updatedNodes = _this.$scopedSlots.default;\n      }\n\n      _this.slotFn = _this.$scopedSlots.default;\n    });\n  },\n  beforeDestroy: function beforeDestroy() {\n    this.unmount();\n  },\n  watch: {\n    disabled: {\n      immediate: true,\n      handler: function handler(disabled) {\n        disabled ? this.unmount() : this.$nextTick(this.mount);\n      }\n    }\n  },\n  methods: {\n    // This returns the element into which the content should be mounted.\n    getTargetEl: function getTargetEl() {\n      if (!isBrowser) return;\n      return document.querySelector(this.selector);\n    },\n    insertTargetEl: function insertTargetEl() {\n      if (!isBrowser) return;\n      var parent = document.querySelector('body');\n      var child = document.createElement(this.tag);\n      child.id = this.selector.substring(1);\n      parent.appendChild(child);\n    },\n    mount: function mount() {\n      if (!isBrowser) return;\n      var targetEl = this.getTargetEl();\n      var el = document.createElement('DIV');\n\n      if (this.prepend && targetEl.firstChild) {\n        targetEl.insertBefore(el, targetEl.firstChild);\n      } else {\n        targetEl.appendChild(el);\n      }\n\n      this.container = new TargetContainer({\n        el: el,\n        parent: this,\n        propsData: {\n          tag: this.tag,\n          nodes: this.$scopedSlots.default\n        }\n      });\n    },\n    unmount: function unmount() {\n      if (this.container) {\n        this.container.$destroy();\n        delete this.container;\n      }\n    }\n  }\n});\n\nfunction install(_Vue) {\n  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n  _Vue.component(options.name || 'portal', Portal);\n\n  if (options.defaultSelector) {\n    setSelector(options.defaultSelector);\n  }\n}\n\nif (typeof window !== 'undefined' && window.Vue && window.Vue === Vue) {\n  // plugin was inlcuded directly in a browser\n  Vue.use(install);\n}\n\nexport default install;\nexport { Portal, config, setSelector };\n"],"names":["urlAlphabet","nanoid","size","id","i","_typeof","obj","config","setSelector","selector","isBrowser","TargetContainer","Vue","vm","h","nodes","el","Portal","_this","disabled","parent","child","targetEl","install","_Vue","options"],"mappings":"mIAAA,IAAIA,EACF,mEAWEC,EAAS,CAACC,EAAO,KAAO,CAC1B,IAAIC,EAAK,GACLC,EAAIF,EACR,KAAOE,KACLD,GAAMH,EAAa,KAAK,OAAM,EAAK,GAAM,CAAC,EAE5C,OAAOG,CACT,ECRA,SAASE,EAAQC,EAAK,CACpB,0BAEA,OAAI,OAAO,QAAW,YAAc,OAAO,OAAO,UAAa,SAC7DD,EAAU,SAAUC,EAAK,CACvB,OAAO,OAAOA,CAChB,EAEAD,EAAU,SAAUC,EAAK,CACvB,OAAOA,GAAO,OAAO,QAAW,YAAcA,EAAI,cAAgB,QAAUA,IAAQ,OAAO,UAAY,SAAW,OAAOA,CAC3H,EAGKD,EAAQC,CAAG,CACpB,CAEG,IAACC,EAAS,CACX,SAAU,qBAAqB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