import {
  HasSlotController
} from "./chunk.IVMQWO2L.js";
import {
  watch
} from "./chunk.X2OQMWGY.js";
import {
  SolidElement,
  customElement
} from "./chunk.H53WQBDK.js";
import {
  __decorateClass
} from "./chunk.S3NI7NKU.js";

// src/components/radio-button/radio-button.ts
import { css, html } from "lit";
import { ifDefined } from "lit/directives/if-defined.js";
import { property, query, state } from "lit/decorators.js";
import cx from "classix";
var SdRadioButton = class extends SolidElement {
  constructor() {
    super(...arguments);
    this.hasSlotController = new HasSlotController(this, "[default]", "icon");
    this.hasFocus = false;
    this.size = "lg";
    this.disabled = false;
    this.visuallyDisabled = false;
    this.checked = false;
  }
  connectedCallback() {
    super.connectedCallback();
    this.setAttribute("role", "presentation");
  }
  handleBlur() {
    this.hasFocus = false;
    this.emit("sd-blur");
  }
  handleClick(e) {
    if (this.disabled || this.visuallyDisabled) {
      e.preventDefault();
      e.stopPropagation();
      return;
    }
    this.checked = true;
  }
  handleFocus() {
    this.hasFocus = true;
    this.emit("sd-focus");
  }
  handleDisabledChange() {
    const isDisabled = this.disabled || this.visuallyDisabled;
    this.setAttribute("aria-disabled", isDisabled ? "true" : "false");
  }
  /** Sets focus on the radio button. */
  focus(options) {
    this.input.focus(options);
  }
  /** Removes focus from the radio button. */
  blur() {
    this.input.blur();
  }
  render() {
    const hasDefaultSlot = this.hasSlotController.test("[default]");
    const hasIconSlot = this.hasSlotController.test("icon");
    const buttonSizeClass = `${this.size}-${hasDefaultSlot ? "label" : "no-label"}`;
    return html`<div part="base" role="presentation" class="relative"><button part="${`button${this.checked ? " button--checked" : ""}`}" role="radio" aria-checked="${this.checked}" class="${cx(
      "relative text-center sd-6-22-0-radio-button-border-radius transition-all ease-in-out duration-100 items-center justify-center focus-visible:focus-outline choice-control-font-weight",
      this.size === "sm" ? "text-sm" : "text-base",
      this.checked && !this.disabled && !this.visuallyDisabled ? "sd-6-22-0-button--primary--default-color-background sd-6-22-0-button--primary--default-color-text hover:sd-6-22-0-button--primary--hover-color-background hover:text-primary-100" : !this.checked && (this.disabled || this.visuallyDisabled) ? "text-neutral-500 hover:cursor-not-allowed" : this.checked && (this.disabled || this.visuallyDisabled) ? "bg-neutral-400 text-white hover:cursor-not-allowed " : "bg-transparent sd-6-22-0-radio-button-color-text border-primary cursor-pointer hover:sd-6-22-0-radio-button--hover-color-background hover:sd-6-22-0-radio-button--hover-color-text",
      hasDefaultSlot && {
        sm: "px-3",
        md: "px-4",
        lg: "px-5"
      }[this.size],
      this.hasFocus && "focused-class",
      hasDefaultSlot && "button--has-label",
      hasIconSlot && "button--has-icon flex gap-2",
      buttonSizeClass
    )}" aria-disabled="${this.disabled || this.visuallyDisabled}" type="button" value="${ifDefined(this.value)}" tabindex="${this.checked ? "0" : "-1"}" @blur="${this.handleBlur}" @focus="${this.handleFocus}" @click="${this.handleClick}"><slot name="icon" part="icon" class="${cx(
      hasIconSlot && "inline-flex relative items-center",
      {
        sm: "text-base",
        md: "text-lg",
        lg: "text-xl"
      }[this.size]
    )}" ?hidden="${!hasIconSlot}"></slot>${hasDefaultSlot ? html`<slot part="label" class="button__label inline-flex relative items-center whitespace-nowrap"></slot>` : null}</button></div>`;
  }
};
SdRadioButton.styles = [
  ...SolidElement.styles,
  css`/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */@layer properties;@layer theme,base,components,utilities;
:host{display:block;width:-moz-min-content;width:min-content}.hidden-input{all:unset;position:absolute;inset:calc(var(--sd-spacing-1) * 0);z-index:calc(10 * -1);opacity:var(--sd-opacity-0);outline-style:var(--tw-outline-style);outline-width:1px;outline-color:rgba(var(--sd-color-border-error,var(--sd-color-error)));--tw-outline-style:dotted;outline-style:dotted}.lg-label{height:46px}.lg-no-label{height:46px;padding-inline:calc(var(--sd-spacing-1) * 5)}.md-label{height:38px}.md-no-label{height:38px;padding-inline:var(--sd-spacing-4)}.sm-label{height:30px}.sm-no-label{height:30px;padding-inline:var(--sd-spacing-3)}:host([size=lg].sd-6-22-0-button-group__button:not(.sd-6-22-0-button-group__button--first)){margin-inline-start:calc(var(--sd-spacing-3) * -1)}:host([size=md].sd-6-22-0-button-group__button:not(.sd-6-22-0-button-group__button--first)){margin-inline-start:calc(var(--sd-spacing-2) * -1)}:host([size=sm].sd-6-22-0-button-group__button:not(.sd-6-22-0-button-group__button--first)){margin-inline-start:calc(var(--sd-spacing-1) * -1)}:host(.sd-6-22-0-button-group__button--hover){z-index:20}:host(.sd-6-22-0-button-group__button--focus){z-index:30}:host(.sd-6-22-0-button-group__button[checked]){z-index:40}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}`
];
__decorateClass([
  query(".button")
], SdRadioButton.prototype, "input", 2);
__decorateClass([
  query(".hidden-input")
], SdRadioButton.prototype, "hiddenInput", 2);
__decorateClass([
  state()
], SdRadioButton.prototype, "hasFocus", 2);
__decorateClass([
  property({ type: String, reflect: true })
], SdRadioButton.prototype, "size", 2);
__decorateClass([
  property({ type: Boolean, reflect: true })
], SdRadioButton.prototype, "disabled", 2);
__decorateClass([
  property({ type: Boolean, reflect: true, attribute: "visually-disabled" })
], SdRadioButton.prototype, "visuallyDisabled", 2);
__decorateClass([
  property({ type: Boolean, reflect: true })
], SdRadioButton.prototype, "checked", 2);
__decorateClass([
  property()
], SdRadioButton.prototype, "value", 2);
__decorateClass([
  watch(["disabled", "visually-disabled"], { waitUntilFirstUpdate: true })
], SdRadioButton.prototype, "handleDisabledChange", 1);
SdRadioButton = __decorateClass([
  customElement("sd-6-22-0-radio-button")
], SdRadioButton);

export {
  SdRadioButton
};
