import { defineComponent, createVNode, mergeProps } from "vue";
import { SIDEBAR_KEY } from "../sidebar/Sidebar.mjs";
import { useParent } from "../../../@vant/use/dist/index.esm.mjs";
import { useRoute, routeProps } from "../composables/use-route.mjs";
import { Badge } from "../badge/index.mjs";
import { extend } from "../utils/basic.mjs";
import { createNamespace } from "../utils/create.mjs";
import { numericProp } from "../utils/props.mjs";
const [name, bem] = createNamespace("sidebar-item");
const sidebarItemProps = extend({}, routeProps, {
  dot: Boolean,
  title: String,
  badge: numericProp,
  disabled: Boolean,
  badgeProps: Object
});
var stdin_default = defineComponent({
  name,
  props: sidebarItemProps,
  emits: ["click"],
  setup(props, {
    emit,
    slots
  }) {
    const route = useRoute();
    const {
      parent,
      index
    } = useParent(SIDEBAR_KEY);
    if (!parent) {
      return;
    }
    const onClick = () => {
      if (props.disabled) {
        return;
      }
      emit("click", index.value);
      parent.setActive(index.value);
      route();
    };
    return () => {
      const {
        dot,
        badge,
        title,
        disabled
      } = props;
      const selected = index.value === parent.getActive();
      return createVNode("div", {
        "role": "tab",
        "class": bem({
          select: selected,
          disabled
        }),
        "tabindex": disabled ? void 0 : 0,
        "aria-selected": selected,
        "onClick": onClick
      }, [createVNode(Badge, mergeProps({
        "dot": dot,
        "class": bem("text"),
        "content": badge
      }, props.badgeProps), {
        default: () => [slots.title ? slots.title() : title]
      })]);
    };
  }
});
export {
  stdin_default as default,
  sidebarItemProps
};
