'use strict';

var core = require('@linaria/core');
var index$2 = require('../Link/index.js');
var index$1 = require('../Tag/index.js');
var index$3 = require('../Typo/index.js');
var index$4 = require('../../coreX/OverflowTooltip/index.js');
var constants = require('../../utils/constants.js');
var antd5 = require('antd5');
var cs = require('classnames');
var React = require('react');
var Timeline_style = require('./Timeline.style.js');
var index = require('../../coreX/Show/index.js');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var cs__default = /*#__PURE__*/_interopDefault(cs);
var React__default = /*#__PURE__*/_interopDefault(React);

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.default.createElement(
    index$4,
    {
      className,
      multiLines: multiLines != null ? multiLines : 2,
      content: children
    }
  );
};
const TimelineArea = ({ items, gap = 1, split, suffix, className, compact }) => {
  const splitNode = typeof split === "string" ? constants.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.default.createElement(
          TimelineBasicText,
          __spreadValues({
            className: core.cx(Timeline_style.SubInfoTextWrapper, index$3.Typo.Label.l4_regular, className2)
          }, restProps)
        );
      case "info":
        return /* @__PURE__ */ React__default.default.createElement(
          TimelineBasicText,
          __spreadValues({
            className: cs__default.default(
              Timeline_style.InfoTextWrapper,
              {
                [index$3.Typo.Label.l4_regular]: compact2,
                [index$3.Typo.Label.l2_regular]: !compact2
              },
              className2
            )
          }, restProps)
        );
      case "info_bold":
        return /* @__PURE__ */ React__default.default.createElement(
          TimelineBasicText,
          __spreadValues({
            className: cs__default.default(
              Timeline_style.InfoTextWrapper,
              {
                [index$3.Typo.Label.l4_bold]: compact2,
                [index$3.Typo.Label.l2_bold]: !compact2
              },
              className2
            )
          }, restProps)
        );
      case "link":
        return /* @__PURE__ */ React__default.default.createElement(index$2, __spreadValues({}, props));
      case "tag":
        return /* @__PURE__ */ React__default.default.createElement(index$1.default, __spreadValues({}, props));
    }
  };
  return /* @__PURE__ */ React__default.default.createElement(antd5.Flex, { justify: "space-between", align: "center", className }, /* @__PURE__ */ React__default.default.createElement(antd5.Flex, { align: "center", gap }, items.map((item, idx) => {
    const { category } = item;
    return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, { key: idx }, rendetItem(category, item, compact), /* @__PURE__ */ React__default.default.createElement(index.Show, { condition: Boolean(split) }, /* @__PURE__ */ React__default.default.createElement(index.Show, { condition: idx < items.length - 1 }, splitNode)));
  })), /* @__PURE__ */ React__default.default.createElement(index.Show, { condition: Boolean(suffix) }, /* @__PURE__ */ React__default.default.createElement(index.Show, { condition: Boolean(split) }, splitNode), suffix));
};

exports.TimelineArea = TimelineArea;
