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

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

export default {
    name: 'SidebarGroupLabel',
    extends: BaseSidebarGroupLabel,
    inheritAttrs: false,
    inject: {
        $pcSidebar: { default: null }
    },
    computed: {
        a11yAttrs() {
            return this.$pcSidebar?.getSectionAttrs('grouplabel') ?? {};
        },
        attrs() {
            return mergeProps(this.a11yAttrs, this.ptmi('root'));
        }
    }
};
</script>
