"use strict";

import React, { useCallback } from 'react';
import { SendIcon } from '../../assets/icons';
import Button from '../styled/Button';
import { MessageInput } from '../styled/StyledInputComponents/StyledInputComponents';
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
const TextInput = ({
  message,
  setMessage,
  handleSendClick,
  config,
  isLoading,
  onFocus,
  onBlur
}) => {
  const handleInputChange = useCallback(text => {
    setMessage(text);
  }, [setMessage]);
  const handleKeyDown = useCallback(event => {
    if (event.nativeEvent.key === 'Enter' && message) {
      handleSendClick();
    }
  }, [handleSendClick, message]);
  return /*#__PURE__*/_jsxs(_Fragment, {
    children: [/*#__PURE__*/_jsx(MessageInput
    // Stable testIDs so Maestro / Detox / Appium can drive the
    // chat-send flow reliably. accessibilityLabel mirrors the
    // testID so iOS accessibility-id lookups also work.
    , {
      testID: "chat-message-input",
      accessibilityLabel: "chat-message-input",
      color: config?.colors?.primary,
      placeholder: "Type message",
      value: message,
      onChangeText: handleInputChange,
      onSubmitEditing: handleSendClick,
      onFocus: onFocus,
      onBlur: onBlur,
      editable: !isLoading
    }), /*#__PURE__*/_jsx(Button, {
      testID: "chat-send-button",
      accessibilityLabel: "chat-send-button",
      onPress: handleSendClick,
      EndIcon: /*#__PURE__*/_jsx(SendIcon, {
        color: !message ? '#D4D4D8' : '#fff'
      }),
      style: {
        borderRadius: 100,
        backgroundColor: !message ? 'transparent' : config?.colors?.primary
      }
    })]
  });
};
export default TextInput;
//# sourceMappingURL=TextInput.js.map