// ../src/components/radio-button/radio-button.tsx
import { Fragment } from "preact";

// ../src/helpers/formatClassString.ts
var formatClassString = (classesArray) => {
  return classesArray.filter((x) => !!x).join(" ");
};

// ../src/foundations/icons/sprite.svg
import { h } from "preact";
import { jsx, jsxs } from "preact/jsx-runtime";

// ../src/components/icon-sprite/icon-sprite.tsx
import { jsx as jsx2 } from "preact/jsx-runtime";
var IconUse = ({ iconName, classNames, attributes }) => {
  const componentClassName = "ds-icon";
  const classes = formatClassString([
    componentClassName,
    `${componentClassName}--sprite`,
    `${componentClassName}--${iconName}`,
    classNames
  ]);
  return /* @__PURE__ */ jsx2("i", { className: classes, ...attributes, children: /* @__PURE__ */ jsx2("svg", { children: /* @__PURE__ */ jsx2("use", { xlinkHref: `#ds-${iconName}` }) }) });
};

// ../src/assets/form-field/form-field.tsx
import { jsx as jsx3, jsxs as jsxs2 } from "preact/jsx-runtime";
var FormField = ({
  error,
  errorMessage,
  wrapperClasses,
  helpHtml,
  helpText,
  type,
  children
}) => {
  const classes = formatClassString([
    "ds-form-field",
    wrapperClasses,
    error && `ds-form-field__error`,
    type === "hidden" && "hidden"
  ]);
  const showHelp = helpHtml || helpText;
  return /* @__PURE__ */ jsxs2("div", { className: classes, children: [
    children,
    errorMessage && /* @__PURE__ */ jsxs2("div", { className: "ds-form-field__error-message js-field-error", children: [
      /* @__PURE__ */ jsx3(IconUse, { iconName: "info-filled" }),
      /* @__PURE__ */ jsx3("span", { children: errorMessage })
    ] }),
    showHelp && /* @__PURE__ */ jsx3("p", { className: "ds-form-field__help-text", children: helpHtml ? helpHtml : helpText })
  ] });
};
var form_field_default = FormField;

// ../src/components/radio-button/radio-button.tsx
import { jsx as jsx4, jsxs as jsxs3 } from "preact/jsx-runtime";
var RadioButton = ({
  buttons,
  error,
  name,
  errorMessage,
  required,
  stripLabel,
  disabled,
  forcePx,
  classNames
}) => {
  const componentClassName = "ds-radio-btn";
  const wrapperClasses = formatClassString([componentClassName, forcePx && "ds-force-px", classNames]);
  return /* @__PURE__ */ jsx4(form_field_default, { error, errorMessage, wrapperClasses, children: buttons?.map((button) => {
    const { id, selected, value, label, attributes } = button;
    return /* @__PURE__ */ jsxs3(Fragment, { children: [
      /* @__PURE__ */ jsx4(
        "input",
        {
          type: "radio",
          id,
          name,
          defaultChecked: selected,
          disabled,
          required,
          value,
          ...attributes
        }
      ),
      stripLabel ? /* @__PURE__ */ jsx4("div", { className: `${componentClassName}__inner`, children: /* @__PURE__ */ jsx4(RadioButtonIcons, { componentClassName }) }) : /* @__PURE__ */ jsxs3("label", { className: `${componentClassName}__inner`, htmlFor: id, children: [
        /* @__PURE__ */ jsx4(RadioButtonIcons, { componentClassName }),
        label && /* @__PURE__ */ jsx4("span", { className: `${componentClassName}__text`, children: label })
      ] })
    ] }, id);
  }) });
};
var RadioButtonIcons = ({ componentClassName }) => {
  return /* @__PURE__ */ jsxs3("span", { className: `${componentClassName}__icon`, children: [
    /* @__PURE__ */ jsx4(IconUse, { iconName: "radio_button_unchecked" }),
    /* @__PURE__ */ jsx4(IconUse, { iconName: "radio_button_checked" })
  ] });
};
export {
  RadioButton
};
//# sourceMappingURL=radio-button.js.map
