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

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var VueCompositionAPI = require('@vue/composition-api');
var hooks_useConfig = require('../../hooks/useConfig.js');
var components_timeline_utils = require('./utils.js');
var components_timeline_timelineItem = require('./timeline-item.js');
var components_timeline_props = require('./props.js');
require('../config-provider/useConfig.js');
require('../config-provider/context.js');
require('lodash/merge');
require('lodash/mergeWith');
require('../../chunks/zh_CN.js');
require('../../chunks/log.js');
require('../../chunks/_commonjsHelpers-fe796db6.js');
require('../loading/index.js');
require('../../utils/withInstall.js');
require('vue');
require('lodash/capitalize');
require('../../config.js');
require('../loading/loading.js');
require('../../utils/dom.js');
require('raf');
require('lodash/isString');
require('../../utils/easing.js');
require('../../utils/render-node.js');
require('lodash');
require('../../utils/transfer-dom.js');
require('../config-provider/config-receiver.js');
require('../../utils/mixins.js');
require('../loading/props.js');
require('../loading/icon/gradient.js');
require('../../chunks/defineProperty-19da3d4c.js');
require('../../chunks/set-style.js');
require('../../chunks/helper2.js');
require('../loading/plugin.js');

var _Timeline = VueCompositionAPI.defineComponent({
  name: "LTimeline",
  components: {
    TimelineItem: components_timeline_timelineItem["default"]
  },
  props: {
    ...components_timeline_props.TimeLineProps
  },
  setup(props) {
    const {
      theme,
      labelAlign,
      reverse,
      layout,
      mode
    } = VueCompositionAPI.toRefs(props);
    const instance = VueCompositionAPI.getCurrentInstance();
    const classPrefix = hooks_useConfig.usePrefixClass();
    const uidArr = VueCompositionAPI.ref([]);
    VueCompositionAPI.nextTick(() => {
      const defaultSlots = instance.slots.default ? instance.slots.default : [null];
      uidArr.value = defaultSlots.map(item => item?.componentInstance?._uid);
    });
    const hasLabelItem = VueCompositionAPI.computed(() => {
      const defaultSlots = instance.slots.default ? instance.slots.default : [null];
      return defaultSlots.some(item => !!item?.componentOptions?.propsData?.label);
    });
    const timelineClassName = VueCompositionAPI.computed(() => {
      const renderAlign = components_timeline_utils["default"](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(" ");
    });
    VueCompositionAPI.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]);
  }
});

exports["default"] = _Timeline;
//# sourceMappingURL=timeline.js.map
