<script>
import theme from "#build/b24ui/chat-prompt-submit";
</script>

<script setup>
import { computed } from "vue";
import { useForwardProps } from "reka-ui";
import { reactiveOmit } from "@vueuse/core";
import { useAppConfig } from "#imports";
import { useComponentProps } from "../composables/useComponentProps";
import { useLocale } from "../composables/useLocale";
import { transformUI } from "../utils";
import { tv } from "../utils/tv";
import icons from "../dictionary/icons";
import B24Button from "./Button.vue";
defineOptions({ inheritAttrs: false });
const _props = defineProps({
  status: { type: String, required: false, default: "ready" },
  icon: { type: [Function, Object, Boolean], required: false },
  color: { type: null, required: false, default: "air-primary" },
  streamingIcon: { type: [Function, Object], required: false },
  streamingColor: { type: null, required: false, default: "air-secondary-accent-2" },
  submittedIcon: { type: [Function, Object], required: false },
  submittedColor: { type: null, required: false, default: "air-secondary-no-accent" },
  errorIcon: { type: [Function, Object], required: false },
  errorColor: { type: null, required: false, default: "air-primary-alert" },
  b24ui: { type: Object, required: false },
  class: { type: null, required: false },
  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 },
  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 emits = defineEmits(["stop", "reload"]);
const slots = defineSlots();
const props = useComponentProps("chatPromptSubmit", _props);
const { t } = useLocale();
const appConfig = useAppConfig();
const buttonProps = useForwardProps(reactiveOmit(props, "icon", "color", "status", "disabled", "streamingIcon", "streamingColor", "submittedIcon", "submittedColor", "errorIcon", "errorColor", "class", "b24ui"));
const disabled = computed(() => props.status === "ready" ? props.disabled : false);
const statusButtonProps = computed(() => ({
  ready: {
    icon: props.icon === false ? void 0 : props.icon ?? icons.imSend,
    color: props.color,
    type: "submit"
  },
  submitted: {
    icon: props.submittedIcon || icons.stop,
    color: props.submittedColor,
    onClick(e) {
      emits("stop", e);
    }
  },
  streaming: {
    icon: props.streamingIcon || icons.stop,
    color: props.streamingColor,
    onClick(e) {
      emits("stop", e);
    }
  },
  error: {
    icon: props.errorIcon || icons.reload,
    color: props.errorColor,
    onClick(e) {
      emits("reload", e);
    }
  }
})[props.status]);
const b24ui = computed(() => tv({ extend: theme, ...appConfig.b24ui?.chatPromptSubmit || {} })());
</script>

<template>
  <B24Button
    v-bind="{
  ...buttonProps,
  ...statusButtonProps,
  disabled,
  'aria-label': t('chatPromptSubmit.label'),
  'rounded': true,
  ...$attrs
}"
    :aria-label="t('chatPromptSubmit.label')"
    data-slot="base"
    :class="b24ui.base({ class: [props.b24ui?.base, props.class] })"
    :b24ui="transformUI(b24ui, props.b24ui)"
  >
    <template v-for="(_, name) in slots" #[name]="slotData">
      <slot :name="name" v-bind="slotData" />
    </template>
  </B24Button>
</template>
