<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 BaseSidebarPanel from './BaseSidebarPanel.vue';

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