'use strict';

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

var vue = require('vue');
require('../../../utils/index.cjs');
var props = require('./props.cjs');
var InternalTabs = require('./InternalTabs.cjs');
var is = require('../../../utils/is.cjs');
var camelize = require('../../../utils/lang/camelize.cjs');
var initDefaultProps = require('../../../utils/vue/initDefaultProps.cjs');
var props$1 = require('../../../utils/vue/props.cjs');
var omit = require('../../../utils/lang/omit.cjs');

function parseTabList(children) {
  return children.map((node) => {
    if (is.isValidElement(node)) {
      const props = {
        ...node.props || {}
      };
      for (const [k, v] of Object.entries(props)) {
        delete props[k];
        props[camelize.camelize(k)] = v;
      }
      const slots = node.children || {};
      const key = node.key !== void 0 ? node.key : void 0;
      const {
        tab = slots.tab,
        disabled,
        forceRender,
        closable,
        animated,
        active,
        destroyInactiveTabPane
      } = props;
      return {
        key,
        ...props,
        node,
        closeIcon: slots.closeIcon,
        tab,
        disabled: disabled === "" || disabled,
        forceRender: forceRender === "" || forceRender,
        closable: closable === "" || closable,
        animated: animated === "" || animated,
        active: active === "" || active,
        destroyInactiveTabPane: destroyInactiveTabPane === "" || destroyInactiveTabPane
      };
    }
    return null;
  }).filter((tab) => tab);
}
var ATabs = /* @__PURE__ */ vue.defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "ATabs",
  inheritAttrs: false,
  props: initDefaultProps.initDefaultProps(props.tabsProps(), {
    tabPosition: "top",
    animated: {
      inkBar: true,
      tabPane: false
    }
  }),
  slots: Object,
  // emits: ['tabClick', 'tabScroll', 'change', 'update:activeKey'],
  setup(props, {
    attrs,
    slots,
    emit
  }) {
    const handleChange = (key) => {
      emit("update:activeKey", key);
      emit("change", key);
    };
    return () => {
      var _a;
      const tabs = parseTabList(props$1.flattenChildren((_a = slots.default) == null ? void 0 : _a.call(slots)));
      return vue.createVNode(InternalTabs.default, {
        ...omit.omit(props, ["onUpdate:activeKey", "onChange"]),
        ...attrs,
        "onChange": handleChange,
        "tabs": tabs
      }, slots);
    };
  }
});

exports.default = ATabs;
//# sourceMappingURL=Tabs.cjs.map
