import { n as n2 } from "./chunk.EPTJRW4G.js"; import { getIconLibrary, unwatchIcon, watchIcon } from "./chunk.5ITCQEWZ.js"; import { requestIcon } from "./chunk.ARRH633M.js"; import { event, watch } from "./chunk.XX234VRK.js"; import { i } from "./chunk.VIWFLAGR.js"; import { T, e, h, n, r, r2 } from "./chunk.5PIDMFOE.js"; import { __decorateClass } from "./chunk.IHGPZX35.js"; // node_modules/lit-html/directives/unsafe-svg.js var t = class extends n2 { }; t.directiveName = "unsafeSVG", t.resultType = 2; var o = i(t); // _uyihdawu1:/Users/claviska/Projects/shoelace/src/components/icon/icon.scss var icon_default = ":host {\n position: relative;\n box-sizing: border-box;\n}\n:host *, :host *:before, :host *:after {\n box-sizing: inherit;\n}\n\n[hidden] {\n display: none !important;\n}\n\n:host {\n display: inline-block;\n width: 1em;\n height: 1em;\n contain: strict;\n box-sizing: content-box !important;\n}\n\n.icon,\nsvg {\n display: block;\n height: 100%;\n width: 100%;\n}"; // src/components/icon/icon.ts var parser = new DOMParser(); var SlIcon = class extends h { constructor() { super(...arguments); this.svg = ""; this.library = "default"; } connectedCallback() { super.connectedCallback(); watchIcon(this); } firstUpdated() { this.setIcon(); } disconnectedCallback() { super.disconnectedCallback(); unwatchIcon(this); } getLabel() { let label = ""; if (this.label) { label = this.label; } else if (this.name) { label = this.name.replace(/-/g, " "); } else if (this.src) { label = this.src.replace(/.*\//, "").replace(/-/g, " ").replace(/\.svg/i, ""); } return label; } getUrl() { const library = getIconLibrary(this.library); if (this.name && library) { return library.resolver(this.name); } else { return this.src; } } redraw() { this.setIcon(); } async setIcon() { const library = getIconLibrary(this.library); const url = this.getUrl(); if (url) { try { const file = await requestIcon(url); if (url !== this.getUrl()) { return; } else if (file.ok) { const doc = parser.parseFromString(file.svg, "text/html"); const svgEl = doc.body.querySelector("svg"); if (svgEl) { if (library && library.mutator) { library.mutator(svgEl); } this.svg = svgEl.outerHTML; this.slLoad.emit(); } else { this.svg = ""; this.slError.emit({ detail: { status: file.status } }); } } else { this.svg = ""; this.slError.emit({ detail: { status: file.status } }); } } catch (e2) { this.slError.emit({ detail: { status: -1 } }); } } else if (this.svg) { this.svg = ""; } } handleChange() { this.setIcon(); } render() { return T`