<script>

</script>

<script setup>
import { computed } from "vue";
import { reactiveOmit } from "@vueuse/core";
import { useColorMode } from "#imports";
import { useComponentProps } from "../../composables/useComponentProps";
import { useForwardProps } from "../../composables/useForwardProps";
import { useLocale } from "../../composables/useLocale";
import { usePrefix } from "../../composables/usePrefix";
import icons from "../../dictionary/icons";
import B24Button from "../Button.vue";
defineOptions({ inheritAttrs: false });
const _props = defineProps({
  color: { type: null, required: false, default: "air-tertiary-no-accent" },
  label: { type: String, required: false },
  activeColor: { type: null, required: false },
  depth: { type: null, required: false },
  activeDepth: { type: null, required: false },
  size: { type: null, required: false },
  rounded: { type: Boolean, required: false },
  block: { type: Boolean, required: false },
  loadingAuto: { type: Boolean, required: false },
  normalCase: { type: Boolean, required: false },
  useWait: { type: Boolean, required: false },
  useClock: { type: Boolean, required: false },
  useDropdown: { type: Boolean, required: false },
  onClick: { type: [Function, Array], required: false },
  class: { type: null, required: false },
  b24ui: { type: Object, required: false },
  icon: { type: [Function, Object], required: false },
  avatar: { type: Object, required: false },
  loading: { type: Boolean, required: false },
  as: { type: null, required: false },
  type: { type: null, required: false },
  disabled: { type: Boolean, required: false },
  isAction: { type: Boolean, required: false },
  exactActiveClass: { type: String, required: false },
  viewTransition: { type: Boolean, required: false }
});
const props = useComponentProps("button", _props);
const { t } = useLocale();
const colorMode = useColorMode();
const buttonProps = useForwardProps(reactiveOmit(props, "icon"));
const prefix = usePrefix();
const isDark = computed({
  get() {
    return colorMode.value === "dark";
  },
  set(_isDark) {
    colorMode.preference = _isDark ? "dark" : "light";
  }
});
</script>

<template>
  <B24Button
    v-bind="{
  ...buttonProps,
  'aria-label': isDark ? t('colorMode.switchToLight') : t('colorMode.switchToDark'),
  ...$attrs
}"
    @click="isDark = !isDark"
  >
    <template #leading="{ b24ui }">
      <Component :is="icons.dark" data-slot="leadingIcon" :class="b24ui.leadingIcon({ class: [props.b24ui?.leadingIcon, prefix('hidden dark:inline-block')] })" />
      <Component :is="icons.light" data-slot="leadingIcon" :class="b24ui.leadingIcon({ class: [props.b24ui?.leadingIcon, prefix('dark:hidden')] })" />
    </template>
  </B24Button>
</template>
