"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Vue = require("vue");
const index = require("../swipe/index.js");
const useExpose = require("../composables/use-expose.js");
const props = require("../utils/props.js");
const create = require("../utils/create.js");
const [name, bem] = create.createNamespace("tabs");
var stdin_default = Vue.defineComponent({
  name,
  props: {
    count: props.makeRequiredProp(Number),
    inited: Boolean,
    animated: Boolean,
    duration: props.makeRequiredProp(props.numericProp),
    swipeable: Boolean,
    lazyRender: Boolean,
    currentIndex: props.makeRequiredProp(Number)
  },
  emits: ["change"],
  setup(props2, {
    emit,
    slots
  }) {
    const swipeRef = Vue.ref();
    const onChange = (index2) => emit("change", index2);
    const renderChildren = () => {
      var _a;
      const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
      if (props2.animated || props2.swipeable) {
        return Vue.createVNode(index.Swipe, {
          "ref": swipeRef,
          "loop": false,
          "class": bem("track"),
          "duration": +props2.duration * 1e3,
          "touchable": props2.swipeable,
          "lazyRender": props2.lazyRender,
          "showIndicators": false,
          "onChange": onChange
        }, {
          default: () => [Content]
        });
      }
      return Content;
    };
    const swipeToCurrentTab = (index2) => {
      const swipe = swipeRef.value;
      if (swipe && swipe.state.active !== index2) {
        swipe.swipeTo(index2, {
          immediate: !props2.inited
        });
      }
    };
    Vue.watch(() => props2.currentIndex, swipeToCurrentTab);
    Vue.onMounted(() => {
      swipeToCurrentTab(props2.currentIndex);
    });
    useExpose.useExpose({
      swipeRef
    });
    return () => Vue.createVNode("div", {
      "class": bem("content", {
        animated: props2.animated || props2.swipeable
      })
    }, [renderChildren()]);
  }
});
exports.default = stdin_default;
