class I {
  constructor(t) {
    this.cache = {
      node: t
    };
  }
  isUINode() {
    return !0;
  }
  get node() {
    return this.cache.node;
  }
}
function z(e) {
  const t = {};
  return e.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (n) => {
    const [s, i] = n.split("=");
    t[s] = i;
  }), t;
}
function U(e) {
  Object.defineProperties(e, {
    QueryParams: {
      get: function() {
        return z(globalThis.location.search.substring(1));
      },
      configurable: !1,
      enumerable: !0
    },
    HashParams: {
      get: function() {
        return globalThis.location.hash.substring(1).split("#");
      },
      configurable: !1,
      enumerable: !0
    }
  });
}
class S extends Array {
  constructor(...t) {
    super(...t);
  }
  clear() {
    return this.length = 0, this;
  }
  getItemById(t) {
    return this.find((n) => n.element.id === t);
  }
  getItemsByTagName(t) {
    return this.filter((n) => n.element.tagName.toLowerCase() === t.toLowerCase());
  }
  getElementsByClassName(t) {
    return this.filter((n) => n.element.classList?.contains(t));
  }
  querySelector(t) {
    const n = globalThis?.document?.querySelector(t);
    return n && this.find((s) => s.element === n) || null;
  }
  querySelectorAll(t) {
    const n = globalThis?.document?.querySelectorAll(t);
    return Array.from(n).map((s) => this.find((i) => i.element === s)).filter(Boolean);
  }
}
const N = new S(), G = {
  default: {
    target: null,
    render: !0,
    math: {
      mode: "deg"
    }
  },
  setDefault: function(e) {
    const t = Object.keys(e), n = Object.values(e);
    for (let s = 0; s < t.length; s++) this.default[t[s]] = n[s];
  },
  init: () => {
  },
  renderingMode: "spa",
  isSSC: !1
}, Z = {
  store: /* @__PURE__ */ new Map(),
  index: 0,
  register: function(e) {
    this.store.set(this.index++, e);
  },
  reset() {
    this.index = 0, this.store.clear();
  }
}, V = {
  ui_index: 0,
  get_ui_index: function() {
    return this.ui_index++;
  },
  register_ui: function(e) {
  }
};
var F = {
  store: /* @__PURE__ */ new Map(),
  index: 0,
  session_storage: null,
  register: function(e) {
    this.store.set(this.index++, e);
  },
  update: function(e, t) {
  }
};
function j() {
  globalThis?.__Ziko__ || (globalThis.__Ziko__ = {
    __UI__: N,
    __HYDRATION__: Z,
    __State__: F,
    __Config__: G,
    __CACHE__: V,
    __PROVIDERS__: {}
  }, U(__Ziko__));
}
j();
class H extends I {
  constructor() {
    super();
  }
  init(t, n, s, i) {
    if (this.target = globalThis.__Ziko__.__Config__.default.target || globalThis?.document?.body, typeof t == "string")
      switch (s) {
        case "html":
          t = globalThis?.document?.createElement(t);
          break;
        case "svg":
          t = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", t);
          break;
        default:
          throw Error("Not supported");
      }
    else this.target = t?.parentElement;
    Object.assign(this.cache, {
      name: n,
      isInteractive: !1,
      parent: null,
      isBody: !1,
      isRoot: !1,
      isHidden: !1,
      isFrozzen: !1,
      attributes: {},
      filters: {},
      temp: {}
    }), this.events = {
      ptr: null,
      mouse: null,
      wheel: null,
      key: null,
      drag: null,
      drop: null,
      click: null,
      clipboard: null,
      focus: null,
      swipe: null,
      custom: null
    }, this.observer = {
      resize: null,
      intersection: null
    }, t && Object.assign(this.cache, { element: t }), this.items = new S(), globalThis.__Ziko__.__UI__[this.cache.name] ? globalThis.__Ziko__.__UI__[this.cache.name]?.push(this) : globalThis.__Ziko__.__UI__[this.cache.name] = [this], t && i && this?.render?.(), globalThis.__Ziko__.__UI__.push(this);
  }
  get element() {
    return this.cache.element;
  }
  [Symbol.iterator]() {
    return this.items[Symbol.iterator]();
  }
  maintain() {
    for (let t = 0; t < this.items.length; t++)
      Object.defineProperty(this, t, {
        value: this.items[t],
        writable: !0,
        configurable: !0,
        enumerable: !1
      });
  }
  isInteractive() {
    return this.cache.isInteractive;
  }
  isUIElement() {
    return !0;
  }
}
function Y(e, ...t) {
  t.forEach((n) => $(e, n));
}
function $(e, t) {
  const n = Object.getOwnPropertyDescriptors(t);
  for (const s of Reflect.ownKeys(n)) {
    const i = n[s];
    "get" in i || "set" in i || typeof i.value != "function" ? Object.defineProperty(Object.getPrototypeOf(e), s, i) : typeof i.value == "function" && (Object.getPrototypeOf(e).hasOwnProperty(s) || Object.defineProperty(Object.getPrototypeOf(e), s, i));
  }
}
function q(e = this.target, t = 0) {
  return t > 0 ? (setTimeout(() => this.mount(e, 0), t), this) : this.isBody ? this : (e?.isUIElement && (e = e.element), this.target = e, this.target?.appendChild(this.element), this);
}
function K(e = 0) {
  return e > 0 ? (setTimeout(() => this.unmount(0), e), this) : (this.cache.parent ? this.cache.parent.remove(this) : this.target?.children?.length && [...this.target.children].includes(this.element) && this.target.removeChild(this.element), this);
}
const W = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  mount: q,
  unmount: K
}, Symbol.toStringTag, { value: "Module" }));
globalThis.__Ziko__ || j();
const P = (e) => typeof e == "function" && e?.()?.isStateGetter?.(), M = (e = "") => e.replace(/[A-Z]/g, (t) => "-" + t.toLowerCase()), L = (e = "") => e.length === 0 ? !1 : /^[a-z][a-zA-Z0-9]*$/.test(e);
function Q(e, t) {
  if (e instanceof Object) {
    const [n, s] = [Object.keys(e), Object.values(e)];
    for (let i = 0; i < n.length; i++)
      s[i] instanceof Array && (t[i] = s[i].join(" ")), E.call(this, n[i], s[i]);
  } else
    t instanceof Array && (t = t.join(" ")), E.call(this, e, t);
  return this;
}
function X(...e) {
  for (let t = 0; t < e.length; t++) this.element?.removeAttribute(e[t]);
  return this;
}
function J(e) {
  return e = L(e) ? M(e) : e, this.element.attributes[e].value;
}
function ee(e = !0) {
  return this.setAttr("contenteditable", e), this;
}
function E(e, t) {
  globalThis.SVGAElement && this.element instanceof globalThis.SVGAElement && (e = L(e) ? M(e) : e), !(this?.attr[e] && this?.attr[e] === t) && (P(t) ? t()._subscribe(
    (s) => this.element?.setAttribute(e, s),
    this
  ) : this.element?.setAttribute(e, t), Object.assign(this.cache.attributes, { [e]: t }));
}
const te = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  _set_attrs_: E,
  getAttr: J,
  removeAttr: X,
  setAttr: Q,
  setContentEditable: ee
}, Symbol.toStringTag, { value: "Module" }));
class ne extends I {
  constructor(...t) {
    super("span", "text", !1, ...t), this.element = globalThis?.document?.createTextNode(...t);
  }
  isText() {
    return !0;
  }
}
const k = (...e) => new ne(...e);
function se(...e) {
  return R.call(this, "append", "push", ...e), this;
}
function ie(...e) {
  return this.__addItem__.call(this, "prepend", "unshift", ...e), this;
}
function re(e, ...t) {
  if (e >= this.element.children.length) this.append(...t);
  else
    for (let n = 0; n < t.length; n++)
      ["number", "string"].includes(typeof t[n]) && (t[n] = k(t[n])), this.element?.insertBefore(t[n].element, this.items[e].element), this.items.splice(e, 0, t[n]);
  return this;
}
function oe(...e) {
  const t = (n) => {
    typeof n == "number" && (n = this.items[n]), n?.isUIElement && this.element?.removeChild(n.element), this.items = this.items.filter((s) => s !== n);
  };
  for (let n = 0; n < e.length; n++) t(e[n]);
  for (let n = 0; n < this.items.length; n++)
    Object.assign(this, { [[n]]: this.items[n] });
  return this;
}
function le() {
  return this?.items?.forEach((e) => e.unmount()), this.element.innerHTML = "", this;
}
function ce(e) {
  return this.cache.element.replaceWith(e), this.cache.element = e, this;
}
function ae(e) {
  return e?.isUIElement && (e = e.element), this.element?.after(e), this;
}
function he(e) {
  return e?.isUIElement && (e = e.element), this.element?.before(e), this;
}
async function R(e, t, ...n) {
  if (this.cache.isFrozzen)
    return console.warn("You can't append new item to frozzen element"), this;
  for (let s = 0; s < n.length; s++) {
    if (["number", "string"].includes(typeof n[s]) && (n[s] = k(n[s])), n[s] instanceof Function) {
      const i = n[s]();
      i.isStateGetter && (n[s] = k(i.value), i._subscribe(
        (r) => n[s].element.textContent = r,
        n[s]
      ));
    }
    if (typeof globalThis?.Node == "function" && n[s] instanceof globalThis?.Node && (n[s] = new this.constructor(n[s])), n[s]?.isUINode)
      n[s].cache.parent = this, this.element?.[e](n[s].element), n[s].target = this.element, this.items[t](n[s]);
    else if (n[s] instanceof Promise) {
      const i = await n[s];
      i.cache.parent = this, this.element?.[e](i.element), i.target = this.element, this.items[t](i);
    } else n[s] instanceof Object && (n[s]?.style && this.style(n[s]?.style), n[s]?.attr && Object.entries(n[s].attr).forEach(
      (i) => this.setAttr("" + i[0], i[1])
    ));
  }
  return this.maintain(), this;
}
const ue = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  __addItem__: R,
  after: ae,
  append: se,
  before: he,
  clear: le,
  insertAt: re,
  prepend: ie,
  remove: oe,
  replaceElementWith: ce
}, Symbol.toStringTag, { value: "Module" }));
function fe(e) {
  return this.items.at(e);
}
function de(e) {
  return this.items.forEach(e), this;
}
function me(e) {
  return this.items.map(e);
}
function ge(e) {
  return this.items.filter(e);
}
const pe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  at: fe,
  find: ge,
  forEach: de,
  map: me
}, Symbol.toStringTag, { value: "Module" }));
function be(e) {
  if (!this.element?.style) return this;
  for (let t in e) {
    const n = e[t];
    if (P(n)) {
      const s = n();
      Object.assign(this.element.style, { [t]: s.value }), s._subscribe(
        (i) => {
          console.log({ newValue: i }), Object.assign(this.element.style, { [t]: i });
        }
        // this 
      );
    } else Object.assign(this.element.style, { [t]: n });
  }
  return this;
}
function _e(e, t) {
  return this.style({ width: e, height: t });
}
function ye() {
}
function ve() {
}
function we(e, { duration: t = 1e3, iterations: n = 1, easing: s = "ease" } = {}) {
  return this.element?.animate(e, { duration: t, iterations: n, easing: s }), this;
}
const Ee = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  animate: we,
  hide: ye,
  show: ve,
  size: _e,
  style: be
}, Symbol.toStringTag, { value: "Module" }));
class ke {
  constructor(t, n) {
    this.cache = {
      category: n,
      target: t,
      listeners: {},
      currentEvent: null,
      event: null,
      customEvents: /* @__PURE__ */ new Set()
    };
  }
  get event() {
    return this.cache.event;
  }
  get target() {
    return this.cache.target;
  }
  get element() {
    return this.cache.target.element;
  }
  get currentEvent() {
    return this.cache.currentEvent;
  }
  addListener(t, n, { preventDefault: s = !1, paused: i = !1 } = {}) {
    return this.cache.listeners[t] = {
      callback: (r) => {
        this.cache.event = r, this.cache.listeners[t].preventDefault && r.preventDefault(), this.cache.listeners[t].paused || (this.cache.currentEvent = t, n.call(this, this));
      },
      preventDefault: s,
      paused: i
    }, this.element.addEventListener(t, this.cache.listeners[t].callback), this;
  }
  removeListener(t) {
    return this.element.removeEventListener(t, this.cache.listeners[t].callback), this;
  }
  pause(t) {
    return this.cache.listeners[t].paused = !0, this;
  }
  resume(t) {
    return this.cache.listeners[t].paused = !1, this;
  }
  preventDefault(t) {
    return this.cache.listeners[t].preventDefault = !0, this;
  }
  useDefault(t) {
    return this.cache.listeners[t].preventDefault = !1, this;
  }
}
class Te extends Event {
  constructor(t, n) {
    super("clickaway", { bubbles: !0, cancelable: !0 }), this.originalEvent = t, this.targetElement = n;
  }
}
function Oe(e) {
  function t(n) {
    if (!e.contains(n.target)) {
      const s = new Te(n, e);
      e.dispatchEvent(s);
    }
  }
  return globalThis?.document?.addEventListener("click", t), () => globalThis?.document?.removeEventListener("click", t);
}
const b = (e, t = !1) => {
  const n = e.element.getBoundingClientRect(), s = e.event;
  let i = s?.clientX - n.left | 0, r = s?.clientY - n.top | 0;
  if (t) {
    const o = e.element.clientWidth, l = e.element.clientHeight;
    i = +(i / o * 2 - 1).toFixed(8), r = +(r / l * -2 + 1).toFixed(8);
  }
  return { x: i, y: r };
}, Ce = (e, t, n) => e.exp.events?.[t]?.cache?.customEvents?.has(n), m = "click", xe = {
  onClick(e) {
    return this.on(
      "click",
      e,
      { category: m }
    );
  },
  onDblClick(e) {
    return this.on(
      "dblclick",
      e,
      { category: m }
    );
  },
  onClickAway(e) {
    return Ce(this, m, "clickaway") || Oe(this.element), this.on(
      "clickaway",
      e,
      { category: m, isCustom: !0 }
    );
  }
}, _ = "ptr", Ae = {
  onPtrDown(e, t = !1) {
    return this.on(
      "pointerdown",
      e,
      { category: _, details_setter: (n) => {
        const { x: s, y: i } = b(n, t);
        n.dx = s, n.dy = i, n.isDown = !0, n.isDragging = n.isMoving ?? !1;
      } }
    );
  },
  onPtrMove(e, t = !1) {
    return this.on(
      "pointermove",
      e,
      { category: _, details_setter: (n) => {
        const { x: s, y: i } = b(n, t);
        n.mx = s, n.my = i, n.isMoving = !0, n.isDragging = n.isDown ?? !1;
      } }
    );
  },
  onPtrUp(e, t = !1) {
    return this.on(
      "pointerup",
      e,
      { category: _, details_setter: (n) => {
        const { x: s, y: i } = b(n, t);
        n.ux = s, n.uy = i, n.isDown = !1, n.isMoving = !1, n.isDragging = !1;
      } }
    );
  }
}, y = "key", Ie = {
  onKeyDown(e) {
    return this.on(
      "keydown",
      e,
      {
        category: y,
        details_setter: (t) => {
          t.kd = t.event.key;
        }
      }
    );
  },
  onKeyPress(e) {
    return this.on(
      "keypress",
      e,
      {
        category: y,
        details_setter: (t) => {
          t.kp = t.event.key;
        }
      }
    );
  },
  onKeyUp(e) {
    return this.on(
      "keydown",
      e,
      {
        category: y,
        details_setter: (t) => {
          t.ku = t.event.key;
        }
      }
    );
  }
}, T = (e, t) => {
  let n = 0;
  return (...s) => {
    const i = (/* @__PURE__ */ new Date()).getTime();
    i - n < t || (n = i, e(...s));
  };
};
class C extends CustomEvent {
  constructor(t, n, { bubbles: s = !0, cancelable: i = !0 } = {}) {
    super(t, { detail: n, bubbles: s, cancelable: i });
  }
}
function v(e, {
  intersection: t = !0,
  resize: n = !0,
  threshold: s = 0,
  throttleResize: i = 100,
  throttleEnterExit: r = 0
} = {}) {
  let o, l;
  const c = (g) => {
    for (let d of g) {
      const { width: p, height: B } = d.contentRect;
      e.dispatchEvent(
        new C("resizeview", {
          width: p,
          height: B,
          entry: d
        })
      );
    }
  }, a = i > 0 ? T(c, i) : c, f = (g) => {
    for (let d of g) {
      const p = d.isIntersecting ? "enterview" : "exitview";
      e.dispatchEvent(new C(p, d));
    }
  }, O = r > 0 ? T(f, r) : f;
  return t && (o = new IntersectionObserver(O, { threshold: s }), o.observe(e)), n && (l = new ResizeObserver(a), l.observe(e)), () => {
    o && (o.unobserve(e), o.disconnect()), l && (l.unobserve(e), l.disconnect());
  };
}
const h = "view", Se = {
  onEnterView(e) {
    return this.exp.events?.[h] || v(this.element), this.on(
      "enterview",
      e,
      { category: h, isCustom: !0 }
    );
  },
  onExitView(e) {
    return this.exp.events?.[h] || v(this.element), this.on(
      "exitview",
      e,
      { category: h, isCustom: !0 }
    );
  },
  onResizeView(e) {
    return this.exp.events?.[h] || v(this.element), this.on(
      "resizeview",
      e,
      { category: h, isCustom: !0 }
    );
  }
};
class u extends H {
  constructor({ element: t, name: n = "", type: s = "html", render: i = __Ziko__.__Config__.default.render } = {}) {
    super(), this.exp = {
      events: {}
    }, Y(
      this,
      W,
      te,
      ue,
      Ee,
      pe,
      Ae,
      xe,
      Ie,
      Se
    ), t && this.init(t, n, s, i);
  }
  on(t, n, { details_setter: s, category: i = "global", isCustom: r = !1, preventDefault: o = !1 } = {}) {
    i && !this.exp.events.hasOwnProperty(i) && (this.exp.events[i] = new ke(this, i)), r && this.exp.events[i].cache.customEvents.add(t);
    const l = this.exp.events[i];
    return l.addListener(t, (c) => {
      s && s(l), n(c);
    }, {
      preventDefault: o
    }), this;
  }
  _off(t, n = "global") {
    this.exp.events[n].removeListener(t);
  }
  get element() {
    return this.cache.element;
  }
  isInteractive() {
    return this.cache.isInteractive;
  }
  useClient(t) {
    return this.cache.isInteractive || (this.element.setAttribute("data-hydration-index", globalThis.__Ziko__.__HYDRATION__.index), globalThis.__Ziko__.__HYDRATION__.register(() => this), this.cache.isInteractive = !0), t && this.element.setAttribute("data-hydration-directive", t), this;
  }
  get st() {
    return this.cache.style;
  }
  get attr() {
    return this.cache.attributes;
  }
  get evt() {
    return this.events;
  }
  get html() {
    return this.element.innerHTML;
  }
  get text() {
    return this.element.textContent;
  }
  get isBody() {
    return this.element === globalThis?.document.body;
  }
  get parent() {
    return this.cache.parent;
  }
  get width() {
    return this.element.getBoundingClientRect().width;
  }
  get height() {
    return this.element.getBoundingClientRect().height;
  }
  get top() {
    return this.element.getBoundingClientRect().top;
  }
  get right() {
    return this.element.getBoundingClientRect().right;
  }
  get bottom() {
    return this.element.getBoundingClientRect().bottom;
  }
  get left() {
    return this.element.getBoundingClientRect().left;
  }
}
const je = (e) => (...t) => {
  const n = t[0];
  return n?.isUIElement?.() || Pe(n) ? new e({}, ...t) : new e(n, ...t.slice(1));
};
function Pe(e) {
  return typeof e != "object" && typeof e != "function" || e === null;
}
const Me = [
  "a",
  "abb",
  "address",
  "area",
  "article",
  "aside",
  "audio",
  "b",
  "base",
  "bdi",
  "bdo",
  "blockquote",
  "br",
  "button",
  "canvas",
  "caption",
  "cite",
  "code",
  "col",
  "colgroup",
  "data",
  "datalist",
  "dd",
  "del",
  "details",
  "dfn",
  "dialog",
  "div",
  "dl",
  "dt",
  "em",
  "embed",
  "fieldset",
  "figcaption",
  "figure",
  "footer",
  "form",
  "h1",
  "h2",
  "h3",
  "h4",
  "h5",
  "h6",
  "header",
  "hgroup",
  "hr",
  "i",
  "iframe",
  "img",
  "ipnut",
  "ins",
  "kbd",
  "label",
  "legend",
  "li",
  "main",
  "map",
  "mark",
  "menu",
  "meter",
  "nav",
  "object",
  "ol",
  "optgroup",
  "option",
  "output",
  "p",
  "param",
  "picture",
  "pre",
  "progress",
  "q",
  "rp",
  "rt",
  "ruby",
  "s",
  "samp",
  "search",
  "section",
  "select",
  "small",
  "source",
  "span",
  "strong",
  "sub",
  "summary",
  "sup",
  "table",
  "tbody",
  "td",
  "template",
  "textarea",
  "tfoot",
  "th",
  "thead",
  "time",
  "title",
  "tr",
  "track",
  "u",
  "ul",
  "var",
  "video",
  "wbr"
], Le = [
  "svg",
  "g",
  "defs",
  "symbol",
  "use",
  "image",
  "switch",
  "rect",
  "circle",
  "ellipse",
  "line",
  "polyline",
  "polygon",
  "path",
  "text",
  "tspan",
  "textPath",
  "altGlyph",
  "altGlyphDef",
  "altGlyphItem",
  "glyph",
  "glyphRef",
  "linearGradient",
  "radialGradient",
  "pattern",
  "solidColor",
  "filter",
  "feBlend",
  "feColorMatrix",
  "feComponentTransfer",
  "feComposite",
  "feConvolveMatrix",
  "feDiffuseLighting",
  "feDisplacementMap",
  "feDropShadow",
  "feFlood",
  "feFuncA",
  "feFuncR",
  "feFuncG",
  "feFuncB",
  "feGaussianBlur",
  "feImage",
  "feMerge",
  "feMergeNode",
  "feMorphology",
  "feOffset",
  "feSpecularLighting",
  "feTile",
  "feTurbulence",
  "animate",
  "animateMotion",
  "animateTransform",
  "set",
  "script",
  "desc",
  "title",
  "metadata",
  "foreignObject"
], Re = [
  "math",
  "annotation",
  "merror",
  "mfrac",
  "mi",
  "mprescripts",
  "mn",
  "mo",
  "mover",
  "mpadded",
  "mphantom",
  "mprescripts",
  "mroot",
  "mrow",
  "ms",
  "semantics",
  "mspace",
  "msqrt",
  "mstyle",
  "msub",
  "msup",
  "msubsup",
  "mtable",
  "mtd",
  "mtext",
  "mtr",
  "munder",
  "munderover"
], D = new Proxy({}, {
  get(e, t) {
    if (typeof t != "string") return;
    let n = t.replaceAll("_", "-").toLowerCase(), s;
    return Me.includes(n) && (s = "html"), Le.includes(n) && (s = "svg"), Re.includes(n) && (s = "mathml"), (...i) => i.length === 0 ? new u({ element: n, name: n, type: s }) : ["string", "number"].includes(typeof i[0]) || i[0] instanceof u || typeof i[0] == "function" && i[0]().isStateGetter() ? new u({ element: n, name: n, type: s }).append(...i) : new u({ element: n, type: s }).setAttr(i.shift()).append(...i);
  }
}), { svg: $e } = D, De = {
  m: "margin",
  mx: "marginInline",
  my: "marginBlock",
  mt: "marginTop",
  mb: "marginBottom",
  ml: "marginLeft",
  mr: "marginRight",
  p: "padding",
  px: "paddingInline",
  py: "paddingBlock",
  pt: "paddingTop",
  pb: "paddingBottom",
  pl: "paddingLeft",
  pr: "paddingRight",
  bg: "background",
  bgColor: "backgroundColor",
  w: "width",
  h: "height",
  f: "font"
}, w = ["xs", "sm", "md", "lg", "xl", "xxl"], x = {
  xs: 300,
  sm: 600,
  md: 960,
  lg: 1280,
  xl: 1920,
  xxl: 1 / 0
}, Be = () => /* @__PURE__ */ Object.create({
  xs: {},
  sm: {},
  md: {},
  lg: {},
  xl: {},
  xxl: {}
});
function ze(e) {
  return e.startsWith("margin") || e.startsWith("padding") || ["gap"].includes(e);
}
function A(e, t) {
  return typeof t == "number" && ze(e) ? `calc(var(--zextra-base-spacing) * ${t})` : t;
}
function Ue(e) {
  return typeof e == "object" && e !== null && !Array.isArray(e);
}
class Ne extends u {
  sx(t = {}) {
    const n = {}, s = {};
    for (let r in t) {
      const o = De[r] ?? r, l = t[r];
      if (Ue(l)) {
        const c = {};
        for (let a in l)
          c[a] = A(o, l[a]);
        s[o] = c;
      } else n[o] = A(o, l);
    }
    this.style(n);
    const i = Be();
    for (let r in s)
      for (let o of w)
        i[o][r] = s[r][o] ?? s[r].base ?? "";
    this.onResizeView(
      T(() => {
        const r = this.width;
        for (let o of w)
          if (i[o] && r < x[o])
            return this.style(i[o]);
      }, 30)
    ), console.log({ BREAKPOINTS: w, BREAKPOINTS_MAP: x, BREAKPOINTS_STYLES_MAP: i });
  }
}
const { ul: Ge, li: Ze, a: Ve } = D;
class Fe extends Ne {
  constructor({ content: t = document.body, depth: n = 6, labelFn: s } = {}) {
    super({ element: "nav" }), this.setAttr({
      class: "zextra-toc"
    }), this.content = t instanceof u ? t.element : t, this.toc_list = Ge(), this.depth = n, this.labelFn = s, this.observer = null, this.append(this.toc_list), this.#n();
  }
  #t() {
    if (Array.isArray(this.depth)) return this.depth.map((n) => `h${n}`).join(", ");
    const t = Math.min(Math.max(this.depth, 1), 6);
    return Array.from({ length: t }, (n, s) => `h${s + 1}`).join(", ");
  }
  #e() {
    const t = this.content ?? document.body;
    if (!t) return !1;
    const n = this.#t(), s = t.querySelectorAll(n);
    if (s.length === 0) return !1;
    this.toc_list.element.replaceChildren();
    const i = Array.isArray(this.depth) ? [...this.depth].sort((r, o) => r - o) : Array.from({ length: this.depth }, (r, o) => o + 1);
    return s.forEach((r, o) => {
      r.id || (r.id = `heading-${o + 1}`);
      const l = parseInt(r.tagName[1]), c = i.indexOf(l), a = this.labelFn ? this.labelFn(r, l) : r.textContent;
      Ze(
        {},
        Ve({ href: `#${r.id}` }, a)
      ).style({
        marginLeft: `${c * 15}px`
      }).mount(this.toc_list);
    }), !0;
  }
  #n() {
    this.#e() || (this.observer = new MutationObserver(() => {
      this.#e() && (this.observer?.disconnect(), this.observer = null);
    }), (() => {
      const s = this.content ?? document.body;
      s ? this.observer.observe(s, {
        childList: !0,
        subtree: !0
      }) : document.addEventListener("DOMContentLoaded", () => {
        const i = this.content ?? document.body;
        i && this.observer?.observe(i, {
          childList: !0,
          subtree: !0
        });
      }, { once: !0 });
    })());
  }
  destroy() {
    this.observer && (this.observer.disconnect(), this.observer = null);
  }
  refresh() {
    this.#e();
  }
}
const He = je(Fe), Ye = /* @__PURE__ */ new WeakMap(), qe = (e) => {
  const t = He(), { parentElement: n, data: s, setStateValue: i } = e;
  console.log({ args: e });
  const r = n.querySelector("[data-engine='zikojs']");
  if (!r)
    throw new Error("Unexpected: root element not found");
  return r.innerHTML = "", t.mount(r), t.toc_list.element.querySelectorAll("a").forEach((l) => {
    l.addEventListener("click", (c) => {
      c.preventDefault();
      const f = (l.getAttribute("href") || "").replace("#", "");
      document.getElementById(f)?.scrollIntoView({ behavior: "smooth" }), history.replaceState(null, "", `#${f}`);
    });
  }), () => {
    Ye.delete(n);
  };
};
export {
  qe as default
};
