{"version":3,"file":"vue2-teleport-BsPi9ICC.js","sources":["../../../node_modules/vue2-teleport/dist/teleport.esm.js"],"sourcesContent":["//\n//\n//\n//\n//\n//\n\nvar script = {\n name: 'teleport',\n props: {\n to: {\n type: String,\n required: true,\n },\n where: {\n type: String,\n default: 'after',\n },\n disabled: Boolean,\n },\n data: function data() {\n return {\n nodes: [],\n waiting: false,\n observer: null,\n parent: null,\n };\n },\n watch: {\n to: 'maybeMove',\n where: 'maybeMove',\n disabled: function disabled(value) {\n var this$1 = this;\n\n if (value) {\n this.disable();\n // Ensure all event done.\n this.$nextTick(function () {\n this$1.teardownObserver();\n });\n } else {\n this.bootObserver();\n this.move();\n }\n },\n },\n mounted: function mounted() {\n // Store a reference to the nodes\n this.nodes = Array.from(this.$el.childNodes);\n\n if (!this.disabled) {\n this.bootObserver();\n }\n\n // Move slot content to target\n this.maybeMove();\n },\n beforeDestroy: function beforeDestroy() {\n // Fix nodes reference\n this.nodes = this.getComponentChildrenNode();\n\n // Move back\n this.disable();\n\n // Stop observing\n this.teardownObserver();\n },\n computed: {\n classes: function classes() {\n if (this.disabled) {\n return ['teleporter'];\n }\n\n return ['teleporter', 'hidden'];\n },\n },\n methods: {\n maybeMove: function maybeMove() {\n if (!this.disabled) {\n this.move();\n }\n },\n move: function move() {\n this.waiting = false;\n\n this.parent = document.querySelector(this.to);\n\n if (!this.parent) {\n this.disable();\n\n this.waiting = true;\n\n return;\n }\n\n if (this.where === 'before') {\n this.parent.prepend(this.getFragment());\n } else {\n this.parent.appendChild(this.getFragment());\n }\n },\n disable: function disable() {\n this.$el.appendChild(this.getFragment());\n this.parent = null;\n },\n // Using a fragment is faster because it'll trigger only a single reflow\n // See https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment\n getFragment: function getFragment() {\n var fragment = document.createDocumentFragment();\n\n this.nodes.forEach(function (node) { return fragment.appendChild(node); });\n\n return fragment;\n },\n onMutations: function onMutations(mutations) {\n var this$1 = this;\n\n // Makes sure the move operation is only done once\n var shouldMove = false;\n\n for (var i = 0; i < mutations.length; i++) {\n var mutation = mutations[i];\n var filteredAddedNodes = Array.from(mutation.addedNodes).filter(function (node) { return !this$1.nodes.includes(node); });\n\n if (Array.from(mutation.removedNodes).includes(this.parent)) {\n this.disable();\n this.waiting = !this.disabled;\n } else if (this.waiting && filteredAddedNodes.length > 0) {\n shouldMove = true;\n }\n }\n\n if (shouldMove) {\n this.move();\n }\n },\n bootObserver: function bootObserver() {\n var this$1 = this;\n\n if (this.observer) {\n return;\n }\n\n this.observer = new MutationObserver(function (mutations) { return this$1.onMutations(mutations); });\n\n this.observer.observe(document.body, {\n childList: true,\n subtree: true,\n attributes: false,\n characterData: false,\n });\n\n if (this.childObserver) {\n return;\n }\n // watch childNodes change\n this.childObserver = new MutationObserver(function (mutations) {\n var childChangeRecord = mutations.find(function (i) { return i.target === this$1.$el; });\n if (childChangeRecord) {\n // Remove old nodes before update position.\n this$1.nodes.forEach(function (node) { return node.parentNode && node.parentNode.removeChild(node); });\n this$1.nodes = this$1.getComponentChildrenNode();\n this$1.maybeMove();\n }\n });\n\n this.childObserver.observe(this.$el, {\n childList: true,\n subtree: false,\n attributes: false,\n characterData: false,\n });\n },\n teardownObserver: function teardownObserver() {\n if (this.observer) {\n this.observer.disconnect();\n this.observer = null;\n }\n if (this.childObserver) {\n this.childObserver.disconnect();\n this.childObserver = null;\n }\n },\n getComponentChildrenNode: function getComponentChildrenNode() {\n return this.$vnode.componentOptions.children\n .map(function (i) { return i.elm; })\n .filter(function (i) { return i; });\n },\n },\n};\n\nfunction normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {\r\n if (typeof shadowMode !== 'boolean') {\r\n createInjectorSSR = createInjector;\r\n createInjector = shadowMode;\r\n shadowMode = false;\r\n }\r\n // Vue.extend constructor export interop.\r\n var options = typeof script === 'function' ? script.options : script;\r\n // render functions\r\n if (template && template.render) {\r\n options.render = template.render;\r\n options.staticRenderFns = template.staticRenderFns;\r\n options._compiled = true;\r\n // functional template\r\n if (isFunctionalTemplate) {\r\n options.functional = true;\r\n }\r\n }\r\n // scopedId\r\n if (scopeId) {\r\n options._scopeId = scopeId;\r\n }\r\n var hook;\r\n if (moduleIdentifier) {\r\n // server build\r\n hook = function (context) {\r\n // 2.3 injection\r\n context =\r\n context || // cached call\r\n (this.$vnode && this.$vnode.ssrContext) || // stateful\r\n (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional\r\n // 2.2 with runInNewContext: true\r\n if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {\r\n context = __VUE_SSR_CONTEXT__;\r\n }\r\n // inject component styles\r\n if (style) {\r\n style.call(this, createInjectorSSR(context));\r\n }\r\n // register component module identifier for async chunk inference\r\n if (context && context._registeredComponents) {\r\n context._registeredComponents.add(moduleIdentifier);\r\n }\r\n };\r\n // used by ssr in case component is cached and beforeCreate\r\n // never gets called\r\n options._ssrRegister = hook;\r\n }\r\n else if (style) {\r\n hook = shadowMode\r\n ? function (context) {\r\n style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot));\r\n }\r\n : function (context) {\r\n style.call(this, createInjector(context));\r\n };\r\n }\r\n if (hook) {\r\n if (options.functional) {\r\n // register for functional component in vue file\r\n var originalRender = options.render;\r\n options.render = function renderWithStyleInjection(h, context) {\r\n hook.call(context);\r\n return originalRender(h, context);\r\n };\r\n }\r\n else {\r\n // inject component registration as beforeCreate hook\r\n var existing = options.beforeCreate;\r\n options.beforeCreate = existing ? [].concat(existing, hook) : [hook];\r\n }\r\n }\r\n return script;\r\n}\n\nvar isOldIE = typeof navigator !== 'undefined' &&\r\n /msie [6-9]\\\\b/.test(navigator.userAgent.toLowerCase());\r\nfunction createInjector(context) {\r\n return function (id, style) { return addStyle(id, style); };\r\n}\r\nvar HEAD;\r\nvar styles = {};\r\nfunction addStyle(id, css) {\r\n var group = isOldIE ? css.media || 'default' : id;\r\n var style = styles[group] || (styles[group] = { ids: new Set(), styles: [] });\r\n if (!style.ids.has(id)) {\r\n style.ids.add(id);\r\n var code = css.source;\r\n if (css.map) {\r\n // https://developer.chrome.com/devtools/docs/javascript-debugging\r\n // this makes source maps inside style tags work properly in Chrome\r\n code += '\\n/*# sourceURL=' + css.map.sources[0] + ' */';\r\n // http://stackoverflow.com/a/26603875\r\n code +=\r\n '\\n/*# sourceMappingURL=data:application/json;base64,' +\r\n btoa(unescape(encodeURIComponent(JSON.stringify(css.map)))) +\r\n ' */';\r\n }\r\n if (!style.element) {\r\n style.element = document.createElement('style');\r\n style.element.type = 'text/css';\r\n if (css.media)\r\n { style.element.setAttribute('media', css.media); }\r\n if (HEAD === undefined) {\r\n HEAD = document.head || document.getElementsByTagName('head')[0];\r\n }\r\n HEAD.appendChild(style.element);\r\n }\r\n if ('styleSheet' in style.element) {\r\n style.styles.push(code);\r\n style.element.styleSheet.cssText = style.styles\r\n .filter(Boolean)\r\n .join('\\n');\r\n }\r\n else {\r\n var index = style.ids.size - 1;\r\n var textNode = document.createTextNode(code);\r\n var nodes = style.element.childNodes;\r\n if (nodes[index])\r\n { style.element.removeChild(nodes[index]); }\r\n if (nodes.length)\r\n { style.element.insertBefore(textNode, nodes[index]); }\r\n else\r\n { style.element.appendChild(textNode); }\r\n }\r\n }\r\n}\n\n/* script */\nvar __vue_script__ = script;\n\n/* template */\nvar __vue_render__ = function() {\n var _vm = this;\n var _h = _vm.$createElement;\n var _c = _vm._self._c || _h;\n return _c(\"div\", { class: _vm.classes }, [_vm._t(\"default\")], 2)\n};\nvar __vue_staticRenderFns__ = [];\n__vue_render__._withStripped = true;\n\n /* style */\n var __vue_inject_styles__ = function (inject) {\n if (!inject) { return }\n inject(\"data-v-50f4b45b_0\", { source: \".hidden[data-v-50f4b45b] {\\n visibility: hidden;\\n display: none;\\n}\\n\\n/*# sourceMappingURL=Teleport.vue.map */\", map: {\"version\":3,\"sources\":[\"/home/shodan/Projects/vue2-teleport/src/Teleport.vue\",\"Teleport.vue\"],\"names\":[],\"mappings\":\"AA2LA;EACA,kBAAA;EACA,aAAA;AC1LA;;AAEA,uCAAuC\",\"file\":\"Teleport.vue\",\"sourcesContent\":[\"\\n\\n\\n\\n\\n\",\".hidden {\\n visibility: hidden;\\n display: none;\\n}\\n\\n/*# sourceMappingURL=Teleport.vue.map */\"]}, media: undefined });\n\n };\n /* scoped */\n var __vue_scope_id__ = \"data-v-50f4b45b\";\n /* module identifier */\n var __vue_module_identifier__ = undefined;\n /* functional template */\n var __vue_is_functional_template__ = false;\n /* style inject SSR */\n \n /* style inject shadow dom */\n \n\n \n var __vue_component__ = /*#__PURE__*/normalizeComponent(\n { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },\n __vue_inject_styles__,\n __vue_script__,\n __vue_scope_id__,\n __vue_is_functional_template__,\n __vue_module_identifier__,\n false,\n createInjector,\n undefined,\n undefined\n );\n\n// Taken from https://vuejs.org/v2/cookbook/packaging-sfc-for-npm.html\n\n// Declare install function executed by Vue.use()\nfunction install (Vue) {\n if (install.installed) { return; }\n\n install.installed = true;\n Vue.component('Teleport', __vue_component__);\n}\n\n// Create module definition for Vue.use()\nvar plugin = {\n install: install,\n};\n\n// Auto-install when vue is found (eg. in browser via