import { parseVersion as e } from "../internal/utils/objects.js";
import { attachInternals as t } from "../internal/utils/a11y.js";
import { useStyles as n } from "../internal/styles/index.js";
import { ICON_IMPORTS as r } from "./icons.js";
import i from "./icon.js";
import { __decorate as a } from "../_virtual/_@oxc-project_runtime@0.130.0/helpers/decorate.js";
import { LitElement as o, html as s, isServer as c } from "lit";
import { property as l } from "lit/decorators/property.js";
import { unsafeSVG as u } from "lit/directives/unsafe-svg.js";
import { state as d } from "lit/decorators/state.js";
//#region src/icon/icon.ts
var f = class e extends o {
	static {
		this.styles = n([i]);
	}
	static {
		this.metadata = {
			tag: "nve-icon",
			version: "0.2.3"
		};
	}
	static {
		this._icons = r;
	}
	static get _iconsRegistry() {
		return this.registeredIcon?._icons ?? e._icons;
	}
	static set _iconsRegistry(t) {
		this.registeredIcon._icons = {
			...e._iconsRegistry,
			...t
		};
	}
	static get registeredIcon() {
		return customElements.get(e.metadata.tag);
	}
	get #e() {
		return c && globalThis._NVE_SSR_ICON_REGISTRY ? globalThis._NVE_SSR_ICON_REGISTRY[this.name] : this.svg;
	}
	render() {
		return s`<div internal-host aria-hidden="true"><slot>${u(this.#e)}</slot></div>`;
	}
	connectedCallback() {
		super.connectedCallback(), t(this), this._internals.role = "img", globalThis?.document?.addEventListener(`${e.metadata.tag}-${this.name}`, this.#t.bind(this));
	}
	disconnectedCallback() {
		super.disconnectedCallback(), globalThis?.document?.removeEventListener(`${e.metadata.tag}-${this.name}`, this.#t.bind(this));
	}
	static async add(t) {
		globalThis.customElements?.whenDefined && (await globalThis.customElements.whenDefined(e.metadata.tag), e._iconsRegistry = t, Object.keys(t).forEach((n) => globalThis?.document?.dispatchEvent(new CustomEvent(`${e.metadata.tag}-${n}`, { detail: t[n] }))));
	}
	static alias(t) {
		globalThis.customElements?.whenDefined && globalThis.customElements.whenDefined(e.metadata.tag).then(() => {
			Object.keys(t).forEach((n) => {
				e._iconsRegistry[n] = e._iconsRegistry[t[n]], globalThis?.document?.dispatchEvent(new CustomEvent(`${e.metadata.tag}-${n}`, { detail: e._iconsRegistry[n] }));
			});
		});
	}
	async updated(e) {
		super.updated(e), await this.#n();
	}
	async #t(e) {
		this.isConnected && e.detail && this.svg !== await e.detail.svg() && this.#n();
	}
	async #n() {
		if (!this.name) return;
		let t = await (this.name.endsWith(".svg") ? fetch(this.name).then((e) => e.text()) : e._iconsRegistry[this.name]?.svg() ?? Promise.resolve(""));
		e._iconsRegistry[this.name] = {
			svg: () => t,
			...e._iconsRegistry[this.name]
		}, this.svg = t;
	}
};
a([l({
	type: String,
	reflect: !0
})], f.prototype, "status", void 0), a([l({
	type: String,
	reflect: !0
})], f.prototype, "size", void 0), a([l({
	type: String,
	reflect: !0
})], f.prototype, "direction", void 0), a([l({
	type: String,
	reflect: !0
})], f.prototype, "name", void 0), a([d()], f.prototype, "svg", void 0);
function p(t) {
	if (typeof globalThis.customElements?.get == "function") {
		let n = e(t.metadata.version), i = e("0.2.3");
		n.minor <= i.minor && n.major <= i.major && (t._icons = {
			...t._icons,
			...r
		});
	}
}
//#endregion
export { f as Icon, p as mergeIcons };

//# sourceMappingURL=icon2.js.map