import {
  Icon
} from "./chunk-TKIP5Q5H.js";
import {
  Flex
} from "./chunk-TRY7VZOM.js";

// src/components/Accordion/AccordionLink.tsx
import classNames from "classnames/dedupe";
import { chevronDown } from "@simplybusiness/icons";
import { jsx, jsxs } from "react/jsx-runtime";
var AccordionLink = ({
  text,
  elementType: LinkElement = "span",
  toggle,
  onClick,
  headerChildren,
  ariaExpanded,
  accordionId,
  contentId
}) => {
  const linkClasses = classNames("mobius-accordion__link", {
    "--is-open": ariaExpanded
  });
  const iconClasses = classNames("mobius-accordion__link-icon", {
    "--is-open": ariaExpanded
  });
  const handleOnClick = (e) => {
    if (onClick) {
      onClick(e);
    }
    toggle();
  };
  const handleKeyDown = (e) => {
    if (e.key === " " || e.key === "Enter") {
      toggle();
    }
  };
  if (headerChildren) {
    return /* @__PURE__ */ jsxs(
      Flex,
      {
        justifyContent: "space-between",
        alignItems: "center",
        className: "mobius-accordion__header",
        children: [
          /* @__PURE__ */ jsxs(
            "div",
            {
              id: accordionId,
              className: linkClasses,
              onClick: handleOnClick,
              onKeyDown: handleKeyDown,
              role: "button",
              tabIndex: 0,
              "aria-expanded": !!ariaExpanded,
              "aria-controls": contentId,
              children: [
                /* @__PURE__ */ jsx(LinkElement, { className: "mobius-accordion__link-text", children: text }),
                /* @__PURE__ */ jsx(Icon, { icon: chevronDown, className: iconClasses })
              ]
            }
          ),
          headerChildren
        ]
      }
    );
  }
  return /* @__PURE__ */ jsxs(
    "div",
    {
      id: accordionId,
      className: linkClasses,
      onClick: handleOnClick,
      onKeyDown: handleKeyDown,
      role: "button",
      tabIndex: 0,
      "aria-expanded": !!ariaExpanded,
      "aria-controls": contentId,
      children: [
        /* @__PURE__ */ jsx(LinkElement, { className: "mobius-accordion__link-text", children: text }),
        /* @__PURE__ */ jsx(Icon, { icon: chevronDown, className: iconClasses })
      ]
    }
  );
};

export {
  AccordionLink
};
//# sourceMappingURL=chunk-6GGDGE7D.js.map
