import { defineComponent, ref, useAttrs, useSlots, computed, resolveComponent, createBlock, openBlock, mergeProps, unref, createSlots, withCtx, renderSlot, createElementBlock, Fragment, renderList, createElementVNode, toDisplayString, normalizeStyle, normalizeClass, normalizeProps, guardReactiveProps } from 'vue';
import '../../../utils/index.mjs';
import { tabsLinePaddingEnum, tabsCardPaddingEnum, tabsProps } from './tabs.mjs';
import { createNamespace } from '../../../utils/create-namespace.mjs';

"use strict";
var _sfc_main = /* @__PURE__ */ defineComponent({
  ...{ name: "LlTabs" },
  __name: "tabs",
  props: tabsProps,
  setup(__props) {
    const props = __props;
    const bem = createNamespace("tabs");
    const tabsRef = ref();
    const attrs = useAttrs();
    const slots = useSlots();
    const filterSlots = computed(() => {
      const allSlotNames = Object.keys(slots || {});
      return allSlotNames.filter(
        (name) => name !== "leftExtra" && name !== "rightExtra" && name !== "default"
      );
    });
    const getStyle = computed(() => {
      const computedStyle = {};
      computedStyle["--tab-ink-bar-width"] = props.inkBarWidth;
      computedStyle["--tab-ink-bar-color"] = props.inkBarColor ? props.inkBarColor : props.type === "button" ? "#005ce5" : "#2e73ff";
      if (props.tabWidthMode === "fixed") {
        computedStyle["--tab-fixed-width"] = props.tabFixedWidth;
      }
      computedStyle["--tab-border-radius"] = props.tabBorderRadius;
      if (props.tabPadding && Object.keys(props.tabPadding).length > 0) {
        for (const key in props.tabPadding) {
          computedStyle[`--tab-${key}`] = props.tabPadding[key];
        }
      } else {
        if (props.type === "line") {
          if (props.tabPosition === "top" || props.tabPosition === "bottom") {
            for (const key in tabsLinePaddingEnum.horizontal[props.size]) {
              computedStyle[`--tab-${key}`] = tabsLinePaddingEnum.horizontal[props.size][key];
            }
          } else {
            for (const key in tabsLinePaddingEnum.vertical[props.size]) {
              computedStyle[`--tab-${key}`] = tabsLinePaddingEnum.vertical[props.size][key];
            }
          }
        } else {
          for (const key in tabsCardPaddingEnum[props.size]) {
            computedStyle[`--tab-${key}`] = tabsCardPaddingEnum[props.size][key];
          }
        }
      }
      return {
        width: props.width,
        height: props.height,
        ...computedStyle
      };
    });
    const getTabBarStyle = computed(() => {
      if (props.tabBarStyle) {
        return props.tabBarStyle;
      } else {
        switch (props.tabPosition) {
          case "top":
            return {
              marginBottom: "8px"
            };
          case "bottom":
            return {
              marginTop: "8px"
            };
          case "left":
            return {
              marginBottom: "8px"
            };
          case "right":
            return {
              marginTop: "8px"
            };
          default:
            return null;
        }
      }
    });
    const getLeftExtraStyle = computed(() => {
      return props.tabPosition === "top" || props.tabPosition === "bottom" ? { marginLeft: props.startIndent + "px" } : { marginTop: props.startIndent + "px" };
    });
    const getRightExtraStyle = computed(() => {
      return props.tabPosition === "top" || props.tabPosition === "bottom" ? { marginRight: props.endIndent + "px" } : { marginBottom: props.endIndent + "px" };
    });
    return (_ctx, _cache) => {
      const _component_a_tab_pane = resolveComponent("a-tab-pane");
      const _component_a_tabs = resolveComponent("a-tabs");
      return openBlock(), createBlock(_component_a_tabs, mergeProps({
        ref_key: "tabsRef",
        ref: tabsRef
      }, unref(attrs), {
        style: getStyle.value,
        class: [
          unref(bem).b(),
          unref(bem).is(_ctx.type === "button" ? "button" : ""),
          unref(bem).is(_ctx.tabWidthMode),
          unref(bem).is(_ctx.tabBorderRadius ? "set-border-radius" : "")
        ],
        size: _ctx.size,
        "hide-add": _ctx.hideAdd,
        "tab-position": _ctx.tabPosition,
        "tab-bar-style": getTabBarStyle.value,
        type: _ctx.type === "button" ? "card" : _ctx.type
      }), createSlots({
        leftExtra: withCtx(() => [
          createElementVNode(
            "div",
            {
              class: normalizeClass(unref(bem).e("leftExtra")),
              style: normalizeStyle(getLeftExtraStyle.value)
            },
            [
              renderSlot(_ctx.$slots, "leftExtra")
            ],
            6
            /* CLASS, STYLE */
          )
        ]),
        rightExtra: withCtx(() => [
          createElementVNode(
            "div",
            {
              class: normalizeClass(unref(bem).e("rightExtra")),
              style: normalizeStyle(getRightExtraStyle.value)
            },
            [
              renderSlot(_ctx.$slots, "rightExtra")
            ],
            6
            /* CLASS, STYLE */
          )
        ]),
        default: withCtx(() => [
          renderSlot(_ctx.$slots, "default", {}, () => [
            (openBlock(true), createElementBlock(
              Fragment,
              null,
              renderList(props.tabs, (tab, index) => {
                return openBlock(), createBlock(_component_a_tab_pane, {
                  key: tab.key,
                  disabled: tab.disabled,
                  closable: tab.closable
                }, {
                  tab: withCtx(() => [
                    renderSlot(_ctx.$slots, "tab", { tab }, () => [
                      createElementVNode(
                        "span",
                        null,
                        toDisplayString(tab.name),
                        1
                        /* TEXT */
                      )
                    ])
                  ]),
                  default: withCtx(() => [
                    renderSlot(_ctx.$slots, "tabPane", {
                      tab,
                      index
                    })
                  ]),
                  _: 2
                  /* DYNAMIC */
                }, 1032, ["disabled", "closable"]);
              }),
              128
              /* KEYED_FRAGMENT */
            ))
          ])
        ]),
        _: 2
        /* DYNAMIC */
      }, [
        renderList(filterSlots.value, (item) => {
          return {
            name: item,
            fn: withCtx((data) => [
              renderSlot(_ctx.$slots, item, normalizeProps(guardReactiveProps(data || {})))
            ])
          };
        })
      ]), 1040, ["style", "class", "size", "hide-add", "tab-position", "tab-bar-style", "type"]);
    };
  }
});

export { _sfc_main as default };
//# sourceMappingURL=tabs.vue2.mjs.map
