import { o as p } from "./rolldown-runtime.js";
import { i as a, n as l } from "./vendor/react.js";
import { t as h } from "./FileTypeIcon.js";
var d = /* @__PURE__ */ p(a(), 1), f = l(), i = {
  extension: "string",
  fileType: "string",
  variant: "string",
  size: "string",
  className: "string"
};
function n(t, e) {
  if (t !== null)
    switch (e) {
      case "number":
        return Number(t);
      case "boolean":
        return t !== "false" && t !== "0";
      case "json":
        try {
          return JSON.parse(t);
        } catch {
          return t;
        }
      default:
        return t;
    }
}
var s = class extends HTMLElement {
  _root = null;
  _childrenContainer = null;
  _props = {};
  _initialized = !1;
  connectedCallback() {
    setTimeout(() => this._initialize(), 0);
  }
  _initialize() {
    if (this._initialized) return;
    this._initialized = !0;
    const t = [];
    for (const r of Array.from(this.childNodes))
      r.nodeType === Node.TEXT_NODE && !r.textContent?.trim() || t.push(r);
    const e = document.createElement("div");
    for (e.style.display = "contents", this._childrenContainer = document.createElement("div"), this._childrenContainer.style.display = "contents", t.forEach((r) => this._childrenContainer.appendChild(r)); this.firstChild; ) this.removeChild(this.firstChild);
    this.appendChild(e), this._root = (0, f.createRoot)(e), this._render();
  }
  disconnectedCallback() {
    this._root?.unmount(), this._root = null;
  }
  attributeChangedCallback(t, e, r) {
    this._render();
  }
  static get observedAttributes() {
    return Object.keys(i).map((t) => t.replace(/([A-Z])/g, "-$1").toLowerCase());
  }
  _setProp(t, e) {
    const r = i[t] || "string";
    this._props[t] = this._parseValue(e, r), this._render();
  }
  _parseValue(t, e) {
    if (e === "boolean" && typeof t == "boolean" || e === "number" && typeof t == "number" || e === "string" && typeof t == "string") return t;
    if (typeof t == "string") switch (e) {
      case "boolean":
        return t !== "false" && t !== "0" && t !== "";
      case "number":
        return Number(t);
      case "json":
        try {
          return JSON.parse(t);
        } catch {
          return t;
        }
      default:
        return t;
    }
    return t;
  }
  _getProp(t) {
    if (t in this._props) return this._props[t];
    const e = t.replace(/([A-Z])/g, "-$1").toLowerCase(), r = i[t] || "string";
    return n(this.getAttribute(e), r);
  }
  _render() {
    if (!this._root) return;
    const t = {};
    for (const [r, o] of Object.entries(i)) if (r in this._props) t[r] = this._props[r];
    else {
      const c = r.replace(/([A-Z])/g, "-$1").toLowerCase();
      t[r] = n(this.getAttribute(c), o);
    }
    const e = d.createElement(h, {
      ...t,
      _hostElement: this
    });
    this._root.render(e);
  }
};
for (const t of Object.keys(i)) Object.defineProperty(s.prototype, t, {
  get() {
    return this._getProp(t);
  },
  set(e) {
    this._setProp(t, e);
  },
  enumerable: !0,
  configurable: !0
});
typeof customElements < "u" && !customElements.get("hf-file-type-icon") && customElements.define("hf-file-type-icon", s);
export {
  s as FileTypeIconWC,
  s as default
};

//# sourceMappingURL=hf-file-type-icon.js.map