<script>
import theme from "#build/b24ui/dashboard-group";
</script>

<script setup>
import { ref, computed, useId } from "vue";
import { Primitive } from "reka-ui";
import { useNuxtApp, useAppConfig } from "#imports";
import { provideDashboardContext } from "../utils/dashboard";
import { tv } from "../utils/tv";
const props = defineProps({
  as: { type: null, required: false },
  class: { type: null, required: false },
  id: { type: String, required: false },
  storage: { type: String, required: false, default: "cookie" },
  storageKey: { type: String, required: false, default: "dashboard" }
});
defineSlots();
const nuxtApp = useNuxtApp();
const appConfig = useAppConfig();
const b24ui = computed(() => tv({ extend: tv(theme), ...appConfig.b24ui?.dashboardGroup || {} }));
const sidebarOpen = ref(false);
const isLoading = ref(false);
const contextId = `${props.storage}-sidebar-group-${props.id || useId()}`;
provideDashboardContext({
  contextId,
  storage: props.storage,
  storageKey: props.storageKey,
  sidebarOpen,
  toggleSidebar: () => {
    nuxtApp.hooks.callHook("dashboard:sidebar:toggle");
  },
  toggleSearch: () => {
    nuxtApp.hooks.callHook("dashboard:search:toggle");
  },
  isLoading,
  load: (load, contextId2) => {
    nuxtApp.hooks.callHook("dashboard:content:load", load, contextId2);
  }
});
</script>

<template>
  <Primitive :as="as" :class="b24ui({ class: props.class })">
    <slot />
  </Primitive>
</template>
