import { f, u as b, a as g } from "./lit-element.jLBm65_O.js";
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */
const y = { attribute: !0, type: String, converter: b, reflect: !1, hasChanged: f }, v = (s = y, e, t) => {
  const { kind: i, metadata: r } = t;
  let n = globalThis.litPropertyMetadata.get(r);
  if (n === void 0 && globalThis.litPropertyMetadata.set(r, n = /* @__PURE__ */ new Map()), i === "setter" && ((s = Object.create(s)).wrapped = !0), n.set(t.name, s), i === "accessor") {
    const { name: a } = t;
    return { set(o) {
      const p = e.get.call(this);
      e.set.call(this, o), this.requestUpdate(a, p, s);
    }, init(o) {
      return o !== void 0 && this.C(a, void 0, s, o), o;
    } };
  }
  if (i === "setter") {
    const { name: a } = t;
    return function(o) {
      const p = this[a];
      e.call(this, o), this.requestUpdate(a, p, s);
    };
  }
  throw Error("Unsupported decorator location: " + i);
};
function h(s) {
  return (e, t) => typeof t == "object" ? v(s, e, t) : ((i, r, n) => {
    const a = r.hasOwnProperty(n);
    return r.constructor.createProperty(n, i), a ? Object.getOwnPropertyDescriptor(r, n) : void 0;
  })(s, e, t);
}
var m = Object.defineProperty, l = (s, e, t, i) => {
  for (var r = void 0, n = s.length - 1, a; n >= 0; n--)
    (a = s[n]) && (r = a(e, t, r) || r);
  return r && m(e, t, r), r;
};
const d = class d extends g {
  constructor() {
    super(), this.theme = "light", this.preRender = !1, Object.entries(
      this.constructor.dependencies
    ).forEach(([e, t]) => {
      this.constructor.define(e, t);
    }), this.handleThemeChange = this.handleThemeChange.bind(this);
  }
  emit(e, t) {
    const i = new CustomEvent(e, {
      bubbles: !0,
      cancelable: !1,
      composed: !0,
      detail: {},
      ...t
    });
    return this.dispatchEvent(i), i;
  }
  static define(e, t = this, i = {}) {
    const r = customElements.get(e);
    if (!r) {
      try {
        customElements.define(e, t, i);
      } catch {
        customElements.define(
          e,
          class extends t {
          },
          i
        );
      }
      return;
    }
    let n = " (unknown version)", a = n;
    "version" in t && t.version && (n = " v" + t.version), "version" in r && r.version && (a = " v" + r.version), !(n && a && n === a) && console.warn(
      `Attempted to register <${e}>${n}, but <${e}>${a} has already been registered.`
    );
  }
  static createProperty(e, t) {
    super.createProperty(e, t), t?.attribute && typeof t.attribute == "string" && !Object.prototype.hasOwnProperty.call(
      this.prototype,
      t.attribute
    ) && Object.prototype.hasOwnProperty.call(this.prototype, e) && Object.defineProperty(this.prototype, t.attribute, {
      get() {
        return this[e];
      },
      set(i) {
        this[e] = i;
      }
    });
  }
  firstUpdated(e) {
    super.firstUpdated(e), !this.preRender && this.runFirstUpdated(e);
  }
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  runFirstUpdated(e) {
  }
  connectedUpdatedCallback() {
  }
  runConnectedCallback() {
  }
  adoptedCallback() {
    u(this);
  }
  connectedCallback() {
    super.connectedCallback(), "addEventListener" in globalThis && globalThis.addEventListener("cx-theme-change", this.handleThemeChange), !this.preRender && (this.runConnectedCallback(), this.updateComplete.then(() => {
      this.connectedUpdatedCallback();
    }));
  }
  disconnectedCallback() {
    super.disconnectedCallback(), "removeEventListener" in globalThis && globalThis.removeEventListener("cx-theme-change", this.handleThemeChange), u(this);
  }
  handleThemeChange(e) {
    this.theme = e.detail.theme;
  }
  getTheme() {
    return "getComputedStyle" in globalThis && getComputedStyle(
      globalThis.document.documentElement
    )?.colorScheme === "dark" ? "dark" : "light";
  }
  getState(e) {
    return this[e];
  }
};
d.version = "1", d.dependencies = {};
let c = d;
l([
  h()
], c.prototype, "dir");
l([
  h()
], c.prototype, "lang");
l([
  h()
], c.prototype, "theme");
l([
  h({ attribute: "pre-render", type: Boolean })
], c.prototype, "preRender");
function u(s) {
  if (s instanceof c)
    return;
  const e = s.localName || s.tagName, t = customElements.get(e.toLowerCase());
  t && Object.setPrototypeOf(s, t.prototype);
}
export {
  c as C,
  h as n
};
