import { option_styles_default } from "./chunk.6R646567.js"; import { LocalizeController } from "./chunk.2SU6QBUU.js"; import { SlIcon } from "./chunk.AGWHFEOF.js"; import { e } from "./chunk.3RBSSBZT.js"; import { watch } from "./chunk.JMZM2TDT.js"; import { component_styles_default } from "./chunk.INZSKSLC.js"; import { ShoelaceElement, e as e2, n, r } from "./chunk.OGQ452CI.js"; import { x } from "./chunk.OOP2EFQH.js"; import { __decorateClass } from "./chunk.W27M6RDR.js"; // src/components/option/option.component.ts var SlOption = class extends ShoelaceElement { constructor() { super(...arguments); // @ts-expect-error - Controller is currently unused this.localize = new LocalizeController(this); this.isInitialized = false; this.current = false; this.selected = false; this.hasHover = false; this.value = ""; this.disabled = false; } connectedCallback() { super.connectedCallback(); this.setAttribute("role", "option"); this.setAttribute("aria-selected", "false"); } handleDefaultSlotChange() { if (this.isInitialized) { customElements.whenDefined("sl-select").then(() => { const controller = this.closest("sl-select"); if (controller) { controller.handleDefaultSlotChange(); } }); } else { this.isInitialized = true; } } handleMouseEnter() { this.hasHover = true; } handleMouseLeave() { this.hasHover = false; } handleDisabledChange() { this.setAttribute("aria-disabled", this.disabled ? "true" : "false"); } handleSelectedChange() { this.setAttribute("aria-selected", this.selected ? "true" : "false"); } handleValueChange() { if (typeof this.value !== "string") { this.value = String(this.value); } if (this.value.includes(" ")) { console.error(`Option values cannot include a space. All spaces have been replaced with underscores.`, this); this.value = this.value.replace(/ /g, "_"); } } /** Returns a plain text label based on the option's content. */ getTextLabel() { const nodes = this.childNodes; let label = ""; [...nodes].forEach((node) => { if (node.nodeType === Node.ELEMENT_NODE) { if (!node.hasAttribute("slot")) { label += node.textContent; } } if (node.nodeType === Node.TEXT_NODE) { label += node.textContent; } }); return label.trim(); } render() { return x`