"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const designSystem = require("@choiceform/design-system");
const iconsReact = require("@choiceform/icons-react");
const React = require("react");
const index = require("../../../../i18n/index.cjs");
const tv = require("./tv.cjs");
const promptInputContext = require("../../context/prompt-input-context.cjs");
const PromptVoiceInput = React.memo(function PromptVoiceInput2(props) {
  const { className, ...rest } = props;
  const {
    isVoiceSupported,
    isVoiceListening,
    handleVoiceMouseDown,
    handleVoiceMouseUp,
    handleVoiceClick
  } = promptInputContext.usePromptInputContext();
  const recording = index.t("prompt-input", "recording");
  const voiceInput = index.t("prompt-input", "voice-input");
  const voiceNotSupported = index.t("prompt-input", "voice-not-supported");
  const tv$1 = tv.promptVoiceInputTv({ isVoiceListening });
  return /* @__PURE__ */ jsxRuntime.jsx(
    designSystem.IconButton,
    {
      ...rest,
      className: tv$1.button({ className }),
      onMouseDown: (e) => {
        e.preventDefault();
        if (!isVoiceSupported) return;
        handleVoiceMouseDown();
      },
      onMouseUp: (e) => {
        e.preventDefault();
        if (!isVoiceSupported) return;
        handleVoiceMouseUp();
      },
      onMouseLeave: () => {
        if (!isVoiceSupported) return;
        handleVoiceMouseUp();
      },
      onClick: (e) => {
        e.preventDefault();
        if (!isVoiceSupported) return;
        handleVoiceClick();
      },
      onTouchStart: () => {
        if (!isVoiceSupported) return;
        handleVoiceMouseDown();
      },
      onTouchEnd: () => {
        if (!isVoiceSupported) return;
        handleVoiceMouseUp();
      },
      onTouchCancel: () => {
        if (!isVoiceSupported) return;
        handleVoiceMouseUp();
      },
      disabled: !isVoiceSupported,
      tooltip: {
        content: isVoiceSupported ? isVoiceListening ? recording : voiceInput : voiceNotSupported
      },
      children: isVoiceListening ? /* @__PURE__ */ jsxRuntime.jsx(iconsReact.PromptToolbarAudioLines, {}) : /* @__PURE__ */ jsxRuntime.jsx(iconsReact.PromptToolbarMic, {})
    }
  );
});
exports.PromptVoiceInput = PromptVoiceInput;
//# sourceMappingURL=prompt-voice-input.cjs.map
