"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const React = require("react");
const rem = require("../../core/utils/units-converters/rem.cjs");
const getSize = require("../../core/utils/get-size/get-size.cjs");
const createVarsResolver = require("../../core/styles-api/create-vars-resolver/create-vars-resolver.cjs");
require("clsx");
const getThemeColor = require("../../core/MantineProvider/color-functions/get-theme-color/get-theme-color.cjs");
const getContrastColor = require("../../core/MantineProvider/color-functions/get-contrast-color/get-contrast-color.cjs");
const getAutoContrastValue = require("../../core/MantineProvider/color-functions/get-auto-contrast-value/get-auto-contrast-value.cjs");
const useProps = require("../../core/MantineProvider/use-props/use-props.cjs");
const useStyles = require("../../core/styles-api/use-styles/use-styles.cjs");
const Box = require("../../core/Box/Box.cjs");
const factory = require("../../core/factory/factory.cjs");
const Timeline_context = require("./Timeline.context.cjs");
const TimelineItem = require("./TimelineItem/TimelineItem.cjs");
const Timeline_module_css = require("./Timeline.module.css.cjs");
const defaultProps = {
  active: -1,
  align: "left",
  reverseActive: false
};
const varsResolver = createVarsResolver.createVarsResolver(
  (theme, { bulletSize, lineWidth, radius, color, autoContrast }) => ({
    root: {
      "--tl-bullet-size": rem.rem(bulletSize),
      "--tl-line-width": rem.rem(lineWidth),
      "--tl-radius": radius === void 0 ? void 0 : getSize.getRadius(radius),
      "--tl-color": color ? getThemeColor.getThemeColor(color, theme) : void 0,
      "--tl-icon-color": getAutoContrastValue.getAutoContrastValue(autoContrast, theme) ? getContrastColor.getContrastColor({ color, theme, autoContrast }) : void 0
    }
  })
);
const Timeline = factory.factory((_props, ref) => {
  const props = useProps.useProps("Timeline", defaultProps, _props);
  const {
    classNames,
    className,
    style,
    styles,
    unstyled,
    vars,
    children,
    active,
    color,
    radius,
    bulletSize,
    align,
    lineWidth,
    reverseActive,
    mod,
    autoContrast,
    ...others
  } = props;
  const getStyles = useStyles.useStyles({
    name: "Timeline",
    classes: Timeline_module_css.default,
    props,
    className,
    style,
    classNames,
    styles,
    unstyled,
    vars,
    varsResolver
  });
  const _children = React.Children.toArray(children);
  const items = _children.map(
    (item, index) => {
      var _a, _b;
      return React.cloneElement(item, {
        unstyled,
        __align: align,
        __active: ((_a = item.props) == null ? void 0 : _a.active) || (reverseActive ? active >= _children.length - index - 1 : active >= index),
        __lineActive: ((_b = item.props) == null ? void 0 : _b.lineActive) || (reverseActive ? active >= _children.length - index - 1 : active - 1 >= index)
      });
    }
  );
  return /* @__PURE__ */ jsxRuntime.jsx(Timeline_context.TimelineProvider, { value: { getStyles }, children: /* @__PURE__ */ jsxRuntime.jsx(Box.Box, { ...getStyles("root"), mod: [{ align }, mod], ref, ...others, children: items }) });
});
Timeline.classes = Timeline_module_css.default;
Timeline.displayName = "@mantine/core/Timeline";
Timeline.Item = TimelineItem.TimelineItem;
exports.Timeline = Timeline;
