'use strict';

var clsx = require('clsx');
var React = require('react');
var Body = require('../../body/Body.js');
var Chevron = require('../../chevron/Chevron.js');
require('../../common/theme.js');
require('../../common/direction.js');
require('../../common/propsValues/control.js');
require('../../common/propsValues/breakpoint.js');
var size = require('../../common/propsValues/size.js');
var typography = require('../../common/propsValues/typography.js');
require('../../common/propsValues/width.js');
require('../../common/propsValues/type.js');
require('../../common/propsValues/dateMode.js');
require('../../common/propsValues/monthFormat.js');
var position = require('../../common/propsValues/position.js');
require('../../common/propsValues/layouts.js');
require('../../common/propsValues/status.js');
require('../../common/propsValues/sentiment.js');
require('../../common/propsValues/profileType.js');
require('../../common/propsValues/variant.js');
require('../../common/propsValues/scroll.js');
require('../../common/propsValues/markdownNodeType.js');
require('../../common/fileType.js');
require('@transferwise/icons');
require('react-intl');
require('../../common/closeButton/CloseButton.messages.js');
var jsxRuntime = require('react/jsx-runtime');
var Option = require('../../common/Option/Option.js');

const AccordionItem = ({
  'aria-label': ariaLabel,
  id,
  title,
  subtitle,
  content,
  onClick,
  open,
  icon,
  theme = 'light'
}) => {
  const iconElement = icon ? /*#__PURE__*/React.cloneElement(icon, {
    size: 24
  }) : null;
  const fallbackId = React.useId();
  const accordionId = id ?? fallbackId;
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
    id: accordionId,
    className: clsx.clsx('np-accordion-item', iconElement ? 'np-accordion-item--with-icon' : null, {
      'np-accordion-item--open': open
    }),
    children: [/*#__PURE__*/jsxRuntime.jsx(Option, {
      "aria-label": ariaLabel,
      as: "button",
      media: iconElement,
      title: title,
      content: subtitle,
      button: /*#__PURE__*/jsxRuntime.jsx(Chevron, {
        orientation: open ? position.Position.TOP : position.Position.BOTTOM,
        size: size.Size.MEDIUM
      }),
      inverseMediaCircle: false,
      "aria-expanded": open,
      "aria-controls": `${accordionId}-section`,
      id: `${accordionId}-control`,
      onClick: onClick
    }), open && /*#__PURE__*/jsxRuntime.jsx("div", {
      id: `${accordionId}-section`,
      role: "region",
      "aria-labelledby": `${accordionId}-control`,
      children: /*#__PURE__*/jsxRuntime.jsx(Body, {
        as: "span",
        type: typography.Typography.BODY_LARGE,
        className: clsx.clsx('np-accordion-item__content', 'd-block', {
          'has-icon': icon
        }),
        children: content
      })
    })]
  });
};

module.exports = AccordionItem;
//# sourceMappingURL=AccordionItem.js.map
