import { computed, defineComponent, createVNode as _createVNode } from 'vue';
import '../Marks';
import { useInjectSlider } from '../context';
import Dot from './Dot';
const stepsProps = () => ({
  prefixCls: String,
  marks: Array,
  dots: {
    type: Boolean,
    default: undefined
  },
  style: [Object, Function],
  activeStyle: [Object, Function]
});
const Steps = defineComponent({
  name: 'ASteps',
  props: stepsProps(),
  setup(props) {
    const context = useInjectSlider();
    const stepDots = computed(() => {
      const {
        marks,
        dots
      } = props;
      const {
        step,
        min,
        max
      } = context.value;
      const dotSet = new Set();
      marks.forEach(mark => {
        dotSet.add(mark.value);
      });
      if (dots && step !== null) {
        let current = min;
        while (current <= max) {
          dotSet.add(current);
          current += step;
        }
      }
      return Array.from(dotSet);
    });
    return () => {
      const {
        prefixCls,
        style,
        activeStyle
      } = props;
      return _createVNode("div", {
        "class": `${prefixCls}-step`
      }, [stepDots.value.map(dotValue => _createVNode(Dot, {
        "prefixCls": prefixCls,
        "key": dotValue,
        "value": dotValue,
        "style": style,
        "activeStyle": activeStyle
      }, null))]);
    };
  }
});
export default Steps;