function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

import classNames from 'classnames';
import React, { createElement, forwardRef, Children, cloneElement, isValidElement } from "react";
import { ScrollView } from "@alifd/meet-react-component-one";
import { isStrictWechatMiniProgram } from '../utils';
import View from '../view';

var BreadCrumb = function BreadCrumb(props, ref) {
  var _props$className = props.className,
      className = _props$className === void 0 ? '' : _props$className,
      _props$prefix = props.prefix,
      prefix = _props$prefix === void 0 ? 'mt-' : _props$prefix,
      _props$size = props.size,
      size = _props$size === void 0 ? 'medium' : _props$size,
      _props$maxNode = props.maxNode,
      maxNode = _props$maxNode === void 0 ? 100 : _props$maxNode,
      _props$disabled = props.disabled,
      disabled = _props$disabled === void 0 ? false : _props$disabled,
      _props$onClick = props.onClick,
      onClick = _props$onClick === void 0 ? function () {} : _props$onClick,
      separator = props.separator,
      children = props.children;
  var count = Children.count(children);
  var clsPrefix = "".concat(prefix, "breadcrumb");
  return /*#__PURE__*/React.createElement(ScrollView, {
    ref: ref,
    className: classNames(className, clsPrefix, _defineProperty({}, "".concat(clsPrefix, "--").concat(size), isStrictWechatMiniProgram)),
    showsHorizontalScrollIndicator: false,
    horizontal: true
  }, /*#__PURE__*/React.createElement(View, {
    className: classNames("".concat(clsPrefix, "-container"), _defineProperty({}, "".concat(clsPrefix, "-container--").concat(size), isStrictWechatMiniProgram))
  }, Children.map(children, function (child, index) {
    if (!isValidElement(child)) {
      return null;
    }

    return cloneElement(child, {
      key: index,
      index: index,
      size: size,
      last: index === count - 1 && isValidElement(child),
      disabledAll: disabled,
      maxNode: maxNode,
      count: count,
      onClick: onClick,
      separator: separator
    });
  })));
};

export default /*#__PURE__*/forwardRef(BreadCrumb);