import { E as l } from "./lit-element.jLBm65_O.js";
import { f as $ } from "./directive-helpers.Dm4rc594.js";
import { i as f, t as a, e as _ } from "./directive.oAbCiebi.js";
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */
const h = (t, s) => {
  const e = t._$AN;
  if (e === void 0) return !1;
  for (const i of e) i._$AO?.(s, !1), h(i, s);
  return !0;
}, n = (t) => {
  let s, e;
  do {
    if ((s = t._$AM) === void 0) break;
    e = s._$AN, e.delete(t), t = s;
  } while (e?.size === 0);
}, d = (t) => {
  for (let s; s = t._$AM; t = s) {
    let e = s._$AN;
    if (e === void 0) s._$AN = e = /* @__PURE__ */ new Set();
    else if (e.has(t)) break;
    e.add(t), v(s);
  }
};
function A(t) {
  this._$AN !== void 0 ? (n(this), this._$AM = t, d(this)) : this._$AM = t;
}
function u(t, s = !1, e = 0) {
  const i = this._$AH, c = this._$AN;
  if (c !== void 0 && c.size !== 0) if (s) if (Array.isArray(i)) for (let o = e; o < i.length; o++) h(i[o], !1), n(i[o]);
  else i != null && (h(i, !1), n(i));
  else h(this, t);
}
const v = (t) => {
  t.type == a.CHILD && (t._$AP ??= u, t._$AQ ??= A);
};
class p extends f {
  constructor() {
    super(...arguments), this._$AN = void 0;
  }
  _$AT(s, e, i) {
    super._$AT(s, e, i), d(this), this.isConnected = s._$AU;
  }
  _$AO(s, e = !0) {
    s !== this.isConnected && (this.isConnected = s, s ? this.reconnected?.() : this.disconnected?.()), e && (h(this, s), n(this));
  }
  setValue(s) {
    if ($(this._$Ct)) this._$Ct._$AI(s, this);
    else {
      const e = [...this._$Ct._$AH];
      e[this._$Ci] = s, this._$Ct._$AI(e, this, 0);
    }
  }
  disconnected() {
  }
  reconnected() {
  }
}
/**
 * @license
 * Copyright 2020 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */
const N = () => new G();
class G {
}
const r = /* @__PURE__ */ new WeakMap(), M = _(class extends p {
  render(t) {
    return l;
  }
  update(t, [s]) {
    const e = s !== this.G;
    return e && this.G !== void 0 && this.rt(void 0), (e || this.lt !== this.ct) && (this.G = s, this.ht = t.options?.host, this.rt(this.ct = t.element)), l;
  }
  rt(t) {
    if (this.isConnected || (t = void 0), typeof this.G == "function") {
      const s = this.ht ?? globalThis;
      let e = r.get(s);
      e === void 0 && (e = /* @__PURE__ */ new WeakMap(), r.set(s, e)), e.get(this.G) !== void 0 && this.G.call(this.ht, void 0), e.set(this.G, t), t !== void 0 && this.G.call(this.ht, t);
    } else this.G.value = t;
  }
  get lt() {
    return typeof this.G == "function" ? r.get(this.ht ?? globalThis)?.get(this.G) : this.G?.value;
  }
  disconnected() {
    this.lt === this.ct && this.rt(void 0);
  }
  reconnected() {
    this.rt(this.ct);
  }
});
export {
  N as e,
  p as f,
  M as n
};
