import { c as _c } from "react-compiler-runtime";
import React from 'react';
import { Box, Text } from '../ink.js';
type Props = {
  query: string;
  placeholder?: string;
  isFocused: boolean;
  isTerminalFocused: boolean;
  prefix?: string;
  width?: number | string;
  cursorOffset?: number;
  borderless?: boolean;
};
export function SearchBox(t0) {
  const $ = _c(17);
  const {
    query,
    placeholder: t1,
    isFocused,
    isTerminalFocused,
    prefix: t2,
    width,
    cursorOffset,
    borderless: t3
  } = t0;
  const placeholder = t1 === undefined ? "Search\u2026" : t1;
  const prefix = t2 === undefined ? "\u2315" : t2;
  const borderless = t3 === undefined ? false : t3;
  const offset = cursorOffset ?? query.length;
  const t4 = borderless ? undefined : "round";
  const t5 = isFocused ? "suggestion" : undefined;
  const t6 = !isFocused;
  const t7 = borderless ? 0 : 1;
  const t8 = !isFocused;
  let t9;
  if ($[0] !== isFocused || $[1] !== isTerminalFocused || $[2] !== offset || $[3] !== placeholder || $[4] !== query) {
    t9 = isFocused ? <>{query ? isTerminalFocused ? <><Text>{query.slice(0, offset)}</Text><Text inverse={true}>{offset < query.length ? query[offset] : " "}</Text>{offset < query.length && <Text>{query.slice(offset + 1)}</Text>}</> : <Text>{query}</Text> : isTerminalFocused ? <><Text inverse={true}>{placeholder.charAt(0)}</Text><Text dimColor={true}>{placeholder.slice(1)}</Text></> : <Text dimColor={true}>{placeholder}</Text>}</> : query ? <Text>{query}</Text> : <Text>{placeholder}</Text>;
    $[0] = isFocused;
    $[1] = isTerminalFocused;
    $[2] = offset;
    $[3] = placeholder;
    $[4] = query;
    $[5] = t9;
  } else {
    t9 = $[5];
  }
  let t10;
  if ($[6] !== prefix || $[7] !== t8 || $[8] !== t9) {
    t10 = <Text dimColor={t8}>{prefix}{" "}{t9}</Text>;
    $[6] = prefix;
    $[7] = t8;
    $[8] = t9;
    $[9] = t10;
  } else {
    t10 = $[9];
  }
  let t11;
  if ($[10] !== t10 || $[11] !== t4 || $[12] !== t5 || $[13] !== t6 || $[14] !== t7 || $[15] !== width) {
    t11 = <Box flexShrink={0} borderStyle={t4} borderColor={t5} borderDimColor={t6} paddingX={t7} width={width}>{t10}</Box>;
    $[10] = t10;
    $[11] = t4;
    $[12] = t5;
    $[13] = t6;
    $[14] = t7;
    $[15] = width;
    $[16] = t11;
  } else {
    t11 = $[16];
  }
  return t11;
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJSZWFjdCIsIkJveCIsIlRleHQiLCJQcm9wcyIsInF1ZXJ5IiwicGxhY2Vob2xkZXIiLCJpc0ZvY3VzZWQiLCJpc1Rlcm1pbmFsRm9jdXNlZCIsInByZWZpeCIsIndpZHRoIiwiY3Vyc29yT2Zmc2V0IiwiYm9yZGVybGVzcyIsIlNlYXJjaEJveCIsInQwIiwiJCIsIl9jIiwidDEiLCJ0MiIsInQzIiwidW5kZWZpbmVkIiwib2Zmc2V0IiwibGVuZ3RoIiwidDQiLCJ0NSIsInQ2IiwidDciLCJ0OCIsInQ5Iiwic2xpY2UiLCJjaGFyQXQiLCJ0MTAiLCJ0MTEiXSwic291cmNlcyI6WyJTZWFyY2hCb3gudHN4Il0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBSZWFjdCBmcm9tICdyZWFjdCdcbmltcG9ydCB7IEJveCwgVGV4dCB9IGZyb20gJy4uL2luay5qcydcblxudHlwZSBQcm9wcyA9IHtcbiAgcXVlcnk6IHN0cmluZ1xuICBwbGFjZWhvbGRlcj86IHN0cmluZ1xuICBpc0ZvY3VzZWQ6IGJvb2xlYW5cbiAgaXNUZXJtaW5hbEZvY3VzZWQ6IGJvb2xlYW5cbiAgcHJlZml4Pzogc3RyaW5nXG4gIHdpZHRoPzogbnVtYmVyIHwgc3RyaW5nXG4gIGN1cnNvck9mZnNldD86IG51bWJlclxuICBib3JkZXJsZXNzPzogYm9vbGVhblxufVxuXG5leHBvcnQgZnVuY3Rpb24gU2VhcmNoQm94KHtcbiAgcXVlcnksXG4gIHBsYWNlaG9sZGVyID0g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vZmZzZXQgPCBxdWVyeS5sZW5ndGggJiYgKFxuICAgICAgICAgICAgICAgICAgICA8VGV4dD57cXVlcnkuc2xpY2Uob2Zmc2V0ICsgMSl9PC9UZXh0PlxuICAgICAgICAgICAgICAgICAgKX1cbiAgICAgICAgICAgICAgICA8Lz5cbiAgICAgICAgICAgICAgKSA6IChcbiAgICAgICAgICAgICAgICA8VGV4dD57cXVlcnl9PC9UZXh0PlxuICAgICAgICAgICAgICApXG4gICAgICAgICAgICApIDogaXNUZXJtaW5hbEZvY3VzZWQgPyAoXG4gICAgICAgICAgICAgIDw+XG4gICAgICAgICAgICAgICAgPFRleHQgaW52ZXJzZT57cGxhY2Vob2xkZXIuY2hhckF0KDApfTwvVGV4dD5cbiAgICAgICAgICAgICAgICA8VGV4dCBkaW1Db2xvcj57cGxhY2Vob2xkZXIuc2xpY2UoMSl9PC9UZXh0PlxuICAgICAgICAgICAgICA8Lz5cbiAgICAgICAgICAgICkgOiAoXG4gICAgICAgICAgICAgIDxUZXh0IGRpbUNvbG9yPntwbGFjZWhvbGRlcn08L1RleHQ+XG4gICAgICAgICAgICApfVxuICAgICAgICAgIDwvPlxuICAgICAgICApIDogcXVlcnkgPyAoXG4gICAgICAgICAgPFRleHQ+e3F1ZXJ5fTwvVGV4dD5cbiAgICAgICAgKSA6IChcbiAgICAgICAgICA8VGV4dD57cGxhY2Vob2xkZXJ9PC9UZXh0PlxuICAgICAgICApfVxuICAgICAgPC9UZXh0PlxuICAgIDwvQm94PlxuICApXG59XG4iXSwibWFwcGluZ3MiOiI7QUFBQSxPQUFPQSxLQUFLLE1BQU0sT0FBTztBQUN6QixTQUFTQyxHQUFHLEVBQUVDLElBQUksUUFBUSxXQUFXO0FBRXJDLEtBQUtDLEtBQUssR0FBRztFQUNYQyxLQUFLLEVBQUUsTUFBTTtFQUNiQyxXQUFXLENBQUMsRUFBRSxNQUFNO0VBQ3BCQyxTQUFTLEVBQUUsT0FBTztFQUNsQkMsaUJBQWlCLEVBQUUs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