import React, { useContext, useMemo } from "react";
import classnames from "classnames";
import { AccordionContext } from "./Accordion";
import { StyledAccordionItem } from "./Styles";
export const ItemContext = /*#__PURE__*/React.createContext(null);
export const AccordionItem = _ref => {
  let {
    children,
    className,
    id
  } = _ref;
  const accordionContext = useContext(AccordionContext);
  const itemId = useMemo(() => {
    if (!id) {
      const randomString = Math.random().toString(36).slice(2);
      return "accordion-item-" + randomString;
    }
    return id;
  }, [id]);
  return /*#__PURE__*/React.createElement(ItemContext.Provider, {
    value: {
      isItemExpanded: accordionContext ? accordionContext.expandedItems.indexOf(itemId) > -1 : false,
      id: itemId
    }
  }, /*#__PURE__*/React.createElement(StyledAccordionItem, {
    className: classnames("accordionItem", className)
  }, children));
};
AccordionItem.displayName = "AccordionItem";
//# sourceMappingURL=AccordionItem.js.map