'use strict';

var ExpandIcon = require('./ExpandIcon.js');
var RoundOrder = require('./RoundOrder.js');
var antd = require('antd');
var cs = require('classnames');
var React = require('react');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var cs__default = /*#__PURE__*/_interopDefault(cs);
var React__default = /*#__PURE__*/_interopDefault(React);

const CollapseStyle = "E_4100_0_7_ccrbeuz";
const CollapseDisabled = "E_4100_0_7_c1fljvag";
const ExpandableItem = props => {
  const {
    children,
    disableExpand = false,
    defaultActive = false,
    header,
    order
  } = props;
  const showExpandOnDisable = React.useMemo(() => {
    return disableExpand && defaultActive;
  }, [defaultActive, disableExpand]);
  const [activeKey, setActiveKey] = React.useState(showExpandOnDisable ? ["expandPanelKey"] : []);
  return /* @__PURE__ */React__default.default.createElement(antd.Collapse, {
    className: cs__default.default(CollapseStyle, {
      [CollapseDisabled]: disableExpand
    }),
    expandIcon: ExpandIcon,
    expandIconPosition: "right",
    defaultActiveKey: showExpandOnDisable ? ["expandPanelKey"] : [],
    bordered: false,
    activeKey,
    onChange: v => {
      if (disableExpand) {
        return;
      }
      setActiveKey(v);
    }
  }, /* @__PURE__ */React__default.default.createElement(antd.Collapse.Panel, {
    key: "expandPanelKey",
    header: /* @__PURE__ */React__default.default.createElement(RoundOrder, {
      order
    }, header),
    showArrow: !disableExpand
  }, children));
};
var ExpandableItem$1 = ExpandableItem;

module.exports = ExpandableItem$1;
