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

const klevuModalCss = ":host{display:block}dialog{border:none !important;border-radius:var(--klevu-border-radius-m);padding:var(--klevu-spacing-04);box-shadow:var(--klevu-elevation-1)}main{padding:var(--klevu-spacing-04)}header{display:flex;justify-content:flex-end}button{border:none;background-color:transparent;appearance:none;border-radius:100%;height:30px;width:30px}";

var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
  if (kind === "a" && !f)
    throw new TypeError("Private accessor was defined without a getter");
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
    throw new TypeError("Cannot read private member from an object whose class did not declare it");
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
  if (kind === "m")
    throw new TypeError("Private method is not writable");
  if (kind === "a" && !f)
    throw new TypeError("Private accessor was defined without a setter");
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
    throw new TypeError("Cannot write private member to an object whose class did not declare it");
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var _KlevuModal_dialogRef;
const KlevuModal = /*@__PURE__*/ proxyCustomElement(class KlevuModal extends HTMLElement {
  constructor() {
    super();
    this.__registerHost();
    this.__attachShadow();
    _KlevuModal_dialogRef.set(this, void 0);
    this.startOpen = false;
  }
  componentDidLoad() {
    if (this.startOpen) {
      this.openModal();
    }
  }
  async openModal() {
    var _a;
    (_a = __classPrivateFieldGet(this, _KlevuModal_dialogRef, "f")) === null || _a === void 0 ? void 0 : _a.showModal();
  }
  async closeModal() {
    var _a;
    (_a = __classPrivateFieldGet(this, _KlevuModal_dialogRef, "f")) === null || _a === void 0 ? void 0 : _a.close();
  }
  render() {
    return (h(Host, null, h("dialog", { ref: (el) => (__classPrivateFieldSet(this, _KlevuModal_dialogRef, el, "f")) }, h("header", null, h("form", { method: "dialog" }, h("button", null, h("span", { part: "material-icon" }, "close")))), h("main", null, h("slot", null)))));
  }
  static get style() { return klevuModalCss; }
}, [1, "klevu-modal", {
    "startOpen": [4, "start-open"],
    "openModal": [64],
    "closeModal": [64]
  }]);
_KlevuModal_dialogRef = new WeakMap();
function defineCustomElement() {
  if (typeof customElements === "undefined") {
    return;
  }
  const components = ["klevu-modal"];
  components.forEach(tagName => { switch (tagName) {
    case "klevu-modal":
      if (!customElements.get(tagName)) {
        customElements.define(tagName, KlevuModal);
      }
      break;
  } });
}
defineCustomElement();

export { KlevuModal as K, defineCustomElement as d };

//# sourceMappingURL=klevu-modal2.js.map