import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';

const klevuUtilPortalCss = ":host{display:block}";

const KlevuUtilPortal = /*@__PURE__*/ proxyCustomElement(class KlevuUtilPortal extends HTMLElement {
  constructor() {
    super();
    this.__registerHost();
    this.__attachShadow();
  }
  connectedCallback() {
    this.createRoot();
  }
  createRoot() {
    if (this.root) {
      return;
    }
    this.root = document.createElement("div");
    const assignedContent = [];
    this.el.querySelectorAll("slot").forEach((slot) => {
      assignedContent.push(...slot.assignedElements());
    });
    this.root.appendChild(this.el);
    for (const element of assignedContent) {
      this.el.childNodes[0].appendChild(element);
    }
    this.root.setAttribute("data-name", "klevu-portal");
    document.body.appendChild(this.root);
  }
  disconnectedCallback() {
    if (!this.root) {
      return;
    }
    this.root.remove();
  }
  render() {
    return (h(Host, null, h("slot", null)));
  }
  get el() { return this; }
  static get style() { return klevuUtilPortalCss; }
}, [1, "klevu-util-portal"]);
function defineCustomElement() {
  if (typeof customElements === "undefined") {
    return;
  }
  const components = ["klevu-util-portal"];
  components.forEach(tagName => { switch (tagName) {
    case "klevu-util-portal":
      if (!customElements.get(tagName)) {
        customElements.define(tagName, KlevuUtilPortal);
      }
      break;
  } });
}
defineCustomElement();

export { KlevuUtilPortal as K, defineCustomElement as d };

//# sourceMappingURL=klevu-util-portal2.js.map