import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import React from 'react';
import classNames from 'classnames';
import { ConfigContext } from '../config-provider/context';
var Divider = /*#__PURE__*/React.forwardRef(function (props, ref) {
  var customizePrefix = props.prefix,
      className = props.className,
      direction = props.direction,
      dashed = props.dashed,
      spacing = props.spacing,
      style = props.style;

  var _React$useContext = React.useContext(ConfigContext),
      getPrefixClassName = _React$useContext.getPrefixClassName;

  var dividerCls = getPrefixClassName('divider', customizePrefix);
  var cls = classNames(dividerCls, "".concat(dividerCls, "-").concat(direction), className, _defineProperty({}, "".concat(dividerCls, "-dashed"), dashed));
  var endPorps = {
    className: cls,
    style: style
  };
  var dividerStyle = {};

  if ('length' in props) {
    if (direction === 'row') {
      dividerStyle.width = props.length;
      dividerStyle.marginTop = props.spacing;
      dividerStyle.marginBottom = props.spacing;
    } else {
      dividerStyle.height = props.length;
      dividerStyle.marginLeft = props.spacing;
      dividerStyle.marginRight = props.spacing;
    }

    endPorps.style = _objectSpread(_objectSpread({}, dividerStyle), style);
  }

  return /*#__PURE__*/React.createElement("div", Object.assign({
    ref: ref
  }, endPorps));
});
Divider.defaultProps = {
  direction: 'row'
};
export default Divider;