/**
 * Copyright 2019 The Pennsylvania State University
 * @license Apache-2.0, see License.md for full text.
 */
class PortalLauncher extends HTMLElement{static get tag(){return"portal-launcher"}constructor(t=!1){super(),this.tag=PortalLauncher.tag,this.querySelectorAll("a")&&this.querySelectorAll("a").forEach((t=>{t.addEventListener("click",this.click.bind(this))}))}normalizeEventPath(t){return t.composed&&t.composedPath?t.composedPath():t.path?t.path:t.originalTarget?[t.originalTarget]:[t.target]}click(t){let e=t.target;var a=this.normalizeEventPath(t);if("A"!==e.tagName&&a.forEach((t=>{"A"===t.tagName&&(e=t)})),e&&null!=e.getAttribute("href")&&"HTMLPortalElement"in window){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation();const a=globalThis.document.createElement("style"),n=.2;a.innerHTML=`\n          portal {\n            position:fixed;\n            width: 100%;\n            height: 100%;\n            opacity: 0;\n            box-shadow: 0 0 20px 10px #999;\n            transform: scale(${n});\n            bottom: calc(20px + 50% * ${n} - 50%);\n            right: calc(20px + 50% * ${n} - 50%);\n            z-index: 10000;\n          }\n          .portal-transition {\n            transition:\n              transform 0.4s,\n              bottom 0.7s,\n              left 0.7s,\n              opacity 1.0s;\n          }\n          @media (prefers-reduced-motion: reduce) {\n            .portal-transition {\n              transition: all 0.001s;\n            }\n          }\n          .portal-reveal {\n            transform: scale(1.0);\n            bottom: 0px;\n            left: 0px;\n          }\n          .fade-in {\n            opacity: 1.0;\n          }\n        `;const o=globalThis.document.createElement("portal");o.src=e.getAttribute("href"),o.classList.add("portal-transition"),o.addEventListener("transitionend",(t=>{"bottom"==t.propertyName&&o.activate()})),globalThis.document.body.appendChild(a,o),setTimeout((t=>o.classList.add("fade-in")),250),setTimeout((t=>o.classList.add("portal-reveal")),500)}}}customElements.define(PortalLauncher.tag,PortalLauncher);export{PortalLauncher};