<template>
    <component v-if="!asChild" :is="as" :class="cx('root')" :type="as === 'BUTTON' || as === 'button' ? 'button' : undefined" v-bind="attrs">
        <slot />
    </component>
    <slot v-else :a11yAttrs="a11yAttrs" :class="cx('root')" />
</template>

<script>
import { mergeProps } from 'vue';
import BaseSidebarMenuSubButton from './BaseSidebarMenuSubButton.vue';

export default {
    name: 'SidebarMenuSubButton',
    extends: BaseSidebarMenuSubButton,
    inheritAttrs: false,
    inject: {
        $pcSidebar: { default: null }
    },
    computed: {
        a11yAttrs() {
            return {
                'data-pc-name': 'sidebarmenusubbutton',
                'data-pc-section': 'root',
                'data-active': this.isActive ? 'true' : undefined
            };
        },
        attrs() {
            return mergeProps(this.a11yAttrs, this.ptmi('root'));
        }
    }
};
</script>
