/**
 * ldesign v0.2.22
 * (c) 2022/12/7 16:21 built by swimly
 * @license MIT
 */

import { defineComponent, toRefs, getCurrentInstance, ref, nextTick, computed, provide } from '@vue/composition-api';
import { usePrefixClass } from '../../hooks/useConfig.js';
import getRenderAlign from './utils.js';
import _TimelineItem from './timeline-item.js';
import { TimeLineProps } from './props.js';
import '../config-provider/useConfig.js';
import '../config-provider/context.js';
import 'lodash/merge';
import 'lodash/mergeWith';
import '../../chunks/zh_CN.js';
import '../config-provider/type.js';
import '../../chunks/index.js';
import '../../chunks/log.js';
import '../../chunks/_commonjsHelpers-fe796db6.js';
import '../loading/index.js';
import '../../utils/withInstall.js';
import 'vue';
import 'lodash/capitalize';
import '../../config.js';
import '../loading/loading.js';
import '../../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../../utils/easing.js';
import '../../utils/render-node.js';
import 'lodash';
import '../../utils/transfer-dom.js';
import '../config-provider/config-receiver.js';
import '../../utils/mixins.js';
import '../loading/props.js';
import '../loading/icon/gradient.js';
import '../../chunks/defineProperty-19da3d4c.js';
import '../../chunks/set-style.js';
import '../../chunks/helper2.js';
import '../loading/style/css.js';
import '../loading/type.js';
import '../loading/plugin.js';

var _Timeline = defineComponent({
  name: "LTimeline",
  components: {
    TimelineItem: _TimelineItem
  },
  props: {
    ...TimeLineProps
  },
  setup(props) {
    const {
      theme,
      labelAlign,
      reverse,
      layout,
      mode
    } = toRefs(props);
    const instance = getCurrentInstance();
    const classPrefix = usePrefixClass();
    const uidArr = ref([]);
    nextTick(() => {
      const defaultSlots = instance.slots.default ? instance.slots.default : [null];
      uidArr.value = defaultSlots.map(item => item?.componentInstance?._uid);
    });
    const hasLabelItem = computed(() => {
      const defaultSlots = instance.slots.default ? instance.slots.default : [null];
      return defaultSlots.some(item => !!item?.componentOptions?.propsData?.label);
    });
    const timelineClassName = computed(() => {
      const renderAlign = getRenderAlign(labelAlign?.value, layout?.value);
      const classNames = [`${classPrefix.value}-timeline`, `${classPrefix.value}-timeline-${renderAlign}`, `${classPrefix.value}-timeline-${layout?.value}`, `${classPrefix.value}-timeline-label--${mode?.value}`];
      if (reverse?.value) classNames.push(`${classPrefix.value}-timeline-reverse`);
      if (hasLabelItem?.value) classNames.push(`${classPrefix.value}-timeline-label`);
      return classNames.join(" ");
    });
    provide("TTimeline", {
      uidArr,
      theme,
      labelAlign,
      reverse,
      layout,
      mode,
      timelineClassName: timelineClassName.value
    });
    return {
      timelineClassName
    };
  },
  render() {
    const h = arguments[0];
    const {
      reverse
    } = this;
    const defaultSlot = this.$scopedSlots.default ? this.$scopedSlots.default(null) : [null];
    if (reverse) defaultSlot.reverse();
    const {
      timelineClassName,
      style
    } = this;
    return h("ul", {
      "class": timelineClassName,
      "style": style
    }, [defaultSlot]);
  }
});

export { _Timeline as default };
//# sourceMappingURL=timeline.js.map
