import _JSXStyle from "styled-jsx/style";
// Generated with util/create-component.js
import React from "react";
import classnames from "classnames";
import useTheme from "../../hooks/useTheme";
import { Typography } from "../Typography";
import { Link } from "../Link";
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
export const Breadcrumbs = props => {
  const theme = useTheme();
  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;

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

  return /*#__PURE__*/_jsxs("div", {
    "data-testid": "Wps-Breadcrumbs",
    ...otherProps,
    className: "jsx-4022366979" + " " + (otherProps && otherProps.className != null && otherProps.className || classnames("Wps-Breadcrumbs", className) || ""),
    children: [items.map((item, index) => {
      return /*#__PURE__*/_jsxs(Typography, {
        color: activeColor,
        weight: weight,
        variant: variant,
        children: [item.inactive ? /*#__PURE__*/_jsxs(Typography, {
          component: "span",
          color: inactiveColor,
          weight: weight,
          variant: variant,
          style: index === items.length - 1 ? {
            paddingRight: 0
          } : {
            paddingRight: handleValue(spacing)
          },
          children: [item.icon && /*#__PURE__*/_jsx("span", {
            style: {
              paddingRight: 5
            },
            className: "jsx-4022366979",
            children: item.icon
          }), item.label]
        }) : /*#__PURE__*/_jsxs(Component, {
          href: item.href,
          color: activeColor,
          style: index === items.length - 1 ? {
            paddingRight: 0
          } : {
            paddingRight: handleValue(spacing)
          },
          children: [item.icon && /*#__PURE__*/_jsx("span", {
            style: {
              paddingRight: 5
            },
            className: "jsx-4022366979",
            children: item.icon
          }), item.label]
        }), index !== items.length - 1 && /*#__PURE__*/_jsx(Typography, {
          component: "span",
          color: inactiveColor,
          weight: dividerWeight,
          variant: dividerVariant,
          style: index === items.length - 1 ? {
            paddingRight: 0
          } : {
            paddingRight: handleValue(spacing)
          },
          children: divider
        })]
      }, item.label);
    }), /*#__PURE__*/_jsx(_JSXStyle, {
      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]
  });
};