/**
 * ldesign v0.4.6
 * (c) 2023 ldesign
 * @license MIT
 */

'use strict';

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

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var VueCompositionAPI = require('@vue/composition-api');
var hooks_useConfig = require('../hooks/useConfig.js');
var timeline_utils = require('./utils.js');
var timeline_timelineItem = require('./timeline-item.js');
var timeline_props = require('./props.js');
require('../config-provider/useConfig.js');
require('../config-provider/context.js');
require('lodash/merge');
require('lodash/mergeWith');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('@babel/runtime/helpers/typeof');
require('../_chunks/dep-7c884501.js');
require('dayjs');
require('../_common/js/log/log.js');
require('../loading/index.js');
require('../utils/withInstall.js');
require('vue');
require('lodash/capitalize');
require('../loading/directive.js');
require('lodash/isObject');
require('lodash/mapKeys');
require('lodash/isEqual');
require('../loading/plugin.js');
require('../config.js');
require('../utils/dom.js');
require('raf');
require('lodash/isString');
require('../utils/easing.js');
require('../loading/loading.js');
require('../utils/render-tnode.js');
require('lodash/camelCase');
require('lodash/kebabCase');
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('../_common/js/loading/circle-adapter.js');
require('../_common/js/utils/set-style.js');
require('../_common/js/utils/helper.js');
require('@babel/runtime/helpers/toConsumableArray');
require('@babel/runtime/helpers/objectWithoutProperties');
require('@babel/runtime/helpers/slicedToArray');
require('lodash/isNull');
require('lodash/isUndefined');
require('lodash/isNumber');
require('lodash/isArray');
require('./timeline-item-props.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var _Timeline = VueCompositionAPI.defineComponent({
  name: "TTimeline",
  components: {
    TimelineItem: timeline_timelineItem["default"]
  },
  props: _objectSpread({}, timeline_props["default"]),
  setup: function setup(props) {
    var _toRefs = VueCompositionAPI.toRefs(props),
      theme = _toRefs.theme,
      labelAlign = _toRefs.labelAlign,
      reverse = _toRefs.reverse,
      layout = _toRefs.layout,
      mode = _toRefs.mode;
    var instance = VueCompositionAPI.getCurrentInstance();
    var classPrefix = hooks_useConfig.usePrefixClass();
    var uidArr = VueCompositionAPI.ref([]);
    VueCompositionAPI.nextTick(function () {
      var defaultSlots = instance.slots["default"] ? instance.slots["default"] : [null];
      uidArr.value = defaultSlots.map(function (item) {
        var _item$componentInstan;
        return item === null || item === void 0 ? void 0 : (_item$componentInstan = item.componentInstance) === null || _item$componentInstan === void 0 ? void 0 : _item$componentInstan._uid;
      });
    });
    var hasLabelItem = VueCompositionAPI.computed(function () {
      var defaultSlots = instance.slots["default"] ? instance.slots["default"] : [null];
      return defaultSlots.some(function (item) {
        var _item$componentOption, _item$componentOption2;
        return !!(item !== null && item !== void 0 && (_item$componentOption = item.componentOptions) !== null && _item$componentOption !== void 0 && (_item$componentOption2 = _item$componentOption.propsData) !== null && _item$componentOption2 !== void 0 && _item$componentOption2.label);
      });
    });
    var timelineClassName = VueCompositionAPI.computed(function () {
      var renderAlign = timeline_utils["default"](labelAlign === null || labelAlign === void 0 ? void 0 : labelAlign.value, layout === null || layout === void 0 ? void 0 : layout.value);
      var classNames = ["".concat(classPrefix.value, "-timeline"), "".concat(classPrefix.value, "-timeline-").concat(renderAlign), "".concat(classPrefix.value, "-timeline-").concat(layout === null || layout === void 0 ? void 0 : layout.value), "".concat(classPrefix.value, "-timeline-label--").concat(mode === null || mode === void 0 ? void 0 : mode.value)];
      if (reverse !== null && reverse !== void 0 && reverse.value) classNames.push("".concat(classPrefix.value, "-timeline-reverse"));
      if (hasLabelItem !== null && hasLabelItem !== void 0 && hasLabelItem.value) classNames.push("".concat(classPrefix.value, "-timeline-label"));
      return classNames.join(" ");
    });
    VueCompositionAPI.provide("TTimeline", {
      uidArr: uidArr,
      theme: theme,
      labelAlign: labelAlign,
      reverse: reverse,
      layout: layout,
      mode: mode,
      timelineClassName: timelineClassName.value
    });
    return {
      timelineClassName: timelineClassName
    };
  },
  render: function render() {
    var h = arguments[0];
    var reverse = this.reverse;
    var defaultSlot = this.$scopedSlots["default"] ? this.$scopedSlots["default"](null) : [null];
    if (reverse) defaultSlot.reverse();
    var timelineClassName = this.timelineClassName,
      style = this.style;
    return h("ul", {
      "class": timelineClassName,
      "style": style
    }, [defaultSlot]);
  }
});

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