import { cx } from '@linaria/core';
import Link from '../Link/index.js';
import Tag from '../Tag/index.js';
import { Typo } from '../Typo/index.js';
import OverflowTooltip from '../../coreX/OverflowTooltip/index.js';
import { splitMap } from '../../utils/constants.js';
import { Flex } from 'antd5';
import cs from 'classnames';
import React__default from 'react';
import { InfoTextWrapper, SubInfoTextWrapper } from './Timeline.style.js';
import { Show } from '../../coreX/Show/index.js';

var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __objRest = (source, exclude) => {
  var target = {};
  for (var prop in source)
    if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
      target[prop] = source[prop];
  if (source != null && __getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(source)) {
      if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
        target[prop] = source[prop];
    }
  return target;
};
const TimelineBasicText = ({
  children,
  className,
  multiLines
}) => {
  return /* @__PURE__ */ React__default.createElement(
    OverflowTooltip,
    {
      className,
      multiLines: multiLines != null ? multiLines : 2,
      content: children
    }
  );
};
const TimelineArea = ({ items, gap = 1, split, suffix, className, compact }) => {
  const splitNode = typeof split === "string" ? splitMap[split] || split : split;
  const rendetItem = (category, props, compact2) => {
    const _a = props, { className: className2 } = _a, restProps = __objRest(_a, ["className"]);
    switch (category) {
      case "subinfo_label":
        return /* @__PURE__ */ React__default.createElement(
          TimelineBasicText,
          __spreadValues({
            className: cx(SubInfoTextWrapper, Typo.Label.l4_regular, className2)
          }, restProps)
        );
      case "info":
        return /* @__PURE__ */ React__default.createElement(
          TimelineBasicText,
          __spreadValues({
            className: cs(
              InfoTextWrapper,
              {
                [Typo.Label.l4_regular]: compact2,
                [Typo.Label.l2_regular]: !compact2
              },
              className2
            )
          }, restProps)
        );
      case "info_bold":
        return /* @__PURE__ */ React__default.createElement(
          TimelineBasicText,
          __spreadValues({
            className: cs(
              InfoTextWrapper,
              {
                [Typo.Label.l4_bold]: compact2,
                [Typo.Label.l2_bold]: !compact2
              },
              className2
            )
          }, restProps)
        );
      case "link":
        return /* @__PURE__ */ React__default.createElement(Link, __spreadValues({}, props));
      case "tag":
        return /* @__PURE__ */ React__default.createElement(Tag, __spreadValues({}, props));
    }
  };
  return /* @__PURE__ */ React__default.createElement(Flex, { justify: "space-between", align: "center", className }, /* @__PURE__ */ React__default.createElement(Flex, { align: "center", gap }, items.map((item, idx) => {
    const { category } = item;
    return /* @__PURE__ */ React__default.createElement(React__default.Fragment, { key: idx }, rendetItem(category, item, compact), /* @__PURE__ */ React__default.createElement(Show, { condition: Boolean(split) }, /* @__PURE__ */ React__default.createElement(Show, { condition: idx < items.length - 1 }, splitNode)));
  })), /* @__PURE__ */ React__default.createElement(Show, { condition: Boolean(suffix) }, /* @__PURE__ */ React__default.createElement(Show, { condition: Boolean(split) }, splitNode), suffix));
};

export { TimelineArea };
