"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports.Breadcrumbs = void 0;

var _style = _interopRequireDefault(require("styled-jsx/style"));

var _react = _interopRequireDefault(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _useTheme = _interopRequireDefault(require("../../hooks/useTheme"));

var _Typography = require("../Typography");

var _Link = require("../Link");

var _jsxRuntime = require("react/jsx-runtime");

// Generated with util/create-component.js
const Breadcrumbs = props => {
  const theme = (0, _useTheme.default)();
  const {
    items = [],
    divider = "/",
    activeColor = "primary",
    inactiveColor = "subtext",
    weight = null,
    dividerWeight = "500",
    variant = "body1",
    dividerVariant = "body1",
    linkComponent = null,
    spacing = 1,
    children,
    className,
    ...otherProps
  } = props;
  const Component = linkComponent || _Link.Link;

  function handleValue(value) {
    return value ? typeof value === "number" ? `${value * theme.layout.spacingUnit}px` : value : "0px";
  }

  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
    "data-testid": "Wps-Breadcrumbs",
    ...otherProps,
    className: "jsx-4022366979" + " " + (otherProps && otherProps.className != null && otherProps.className || (0, _classnames.default)("Wps-Breadcrumbs", className) || ""),
    children: [items.map((item, index) => {
      return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Typography.Typography, {
        color: activeColor,
        weight: weight,
        variant: variant,
        children: [item.inactive ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Typography.Typography, {
          component: "span",
          color: inactiveColor,
          weight: weight,
          variant: variant,
          style: index === items.length - 1 ? {
            paddingRight: 0
          } : {
            paddingRight: handleValue(spacing)
          },
          children: [item.icon && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
            style: {
              paddingRight: 5
            },
            className: "jsx-4022366979",
            children: item.icon
          }), item.label]
        }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(Component, {
          href: item.href,
          color: activeColor,
          style: index === items.length - 1 ? {
            paddingRight: 0
          } : {
            paddingRight: handleValue(spacing)
          },
          children: [item.icon && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
            style: {
              paddingRight: 5
            },
            className: "jsx-4022366979",
            children: item.icon
          }), item.label]
        }), index !== items.length - 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.Typography, {
          component: "span",
          color: inactiveColor,
          weight: dividerWeight,
          variant: dividerVariant,
          style: index === items.length - 1 ? {
            paddingRight: 0
          } : {
            paddingRight: handleValue(spacing)
          },
          children: divider
        })]
      }, item.label);
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_style.default, {
      id: "4022366979",
      children: ".Wps-Breadcrumbs.jsx-4022366979{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;}"
    }), children]
  });
};

exports.Breadcrumbs = Breadcrumbs;