"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.SearchInput = void 0;
var _react = require("react");
var _reactNative = require("react-native");
var _useTheme = require("../theme/use-theme.js");
var _index = require("../styles/index.js");
var _index2 = require("../button/index.js");
var TextField = _interopRequireWildcard(require("../text-field/index.js"));
var _MagnifyingGlass = require("../icons/MagnifyingGlass.js");
var _Times = require("../icons/Times.js");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
const SearchInput = exports.SearchInput = /*#__PURE__*/(0, _react.forwardRef)(function SearchInput({
  value,
  label = 'Search',
  onClearText,
  ...rest
}, ref) {
  const theme = (0, _useTheme.useTheme)();
  const showClear = value != null && value.length > 0;
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
    style: [_index.atoms.w_full, _index.atoms.relative],
    children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(TextField.Root, {
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(TextField.Icon, {
        icon: _MagnifyingGlass.MagnifyingGlass_Stroke2_Corner0_Rounded
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)(TextField.Input, {
        inputRef: ref,
        label: label,
        value: value,
        placeholder: label,
        returnKeyType: "search",
        keyboardAppearance: theme.mode === 'light' ? 'light' : 'dark',
        selectTextOnFocus: _reactNative.Platform.OS !== 'web',
        autoFocus: false,
        accessibilityRole: "search",
        autoCorrect: false,
        autoComplete: "off",
        autoCapitalize: "none",
        style: showClear ? {
          paddingRight: 24
        } : undefined,
        ...rest
      })]
    }), showClear && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
      style: [_index.atoms.absolute, _index.atoms.z_20, _index.atoms.my_auto, _index.atoms.inset_0, _index.atoms.justify_center, _index.atoms.pr_sm, {
        left: 'auto'
      }],
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index2.Button, {
        testID: "searchTextInputClearBtn",
        onPress: onClearText,
        accessibilityLabel: "Clear search query",
        hitSlop: {
          top: 10,
          bottom: 10,
          left: 10,
          right: 10
        },
        variant: "ghost",
        size: "small",
        icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Times.TimesLarge_Stroke2_Corner0_Rounded, {
          fill: theme.colors.textSecondary,
          size: "xs"
        }),
        style: {
          padding: 4,
          minHeight: 0
        }
      })
    })]
  });
});
SearchInput.displayName = 'SearchInput';
//# sourceMappingURL=index.js.map