{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "hud-search-field",
  "type": "registry:component",
  "title": "HUD Search Field",
  "description": "A search input with a slash shortcut that focuses it from anywhere, a clear button, bracket corners that open on focus and a results readout.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "hud",
    "search",
    "input",
    "shortcut",
    "hud",
    "filter",
    "field"
  ],
  "docs": "https://hyperblur.dev/effects/hud-search-field",
  "files": [
    {
      "path": "registry/hyperblur/hud-search-field.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/hud-search-field.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface HudSearchFieldProps\n  extends Omit<React.InputHTMLAttributes<HTMLInputElement>, \"value\" | \"defaultValue\" | \"onChange\" | \"size\" | \"type\"> {\n  value?: string;\n  defaultValue?: string;\n  onChange?: (value: string) => void;\n  resultCount?: number;\n  total?: number;\n  shortcut?: string;\n  label?: string;\n  accent?: string;\n}\n\nconst css = `\n.hb-ua8 {\n  --hb-ua8-accent: #ff4d4d;\n  position: relative;\n  box-sizing: border-box;\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  width: 100%;\n  height: 40px;\n  padding: 0 10px 0 12px;\n  border: 1px solid rgba(255,255,255,.12);\n  background: rgba(255,255,255,.025);\n  color: #ededed;\n  font-family: inherit;\n  transition: border-color .2s ease, background-color .2s ease, box-shadow .25s ease;\n}\n.hb-ua8 *, .hb-ua8 *::before, .hb-ua8 *::after { box-sizing: border-box; }\n.hb-ua8:hover { border-color: rgba(255,255,255,.2); }\n.hb-ua8:focus-within {\n  border-color: color-mix(in srgb, var(--hb-ua8-accent) 45%, rgba(255,255,255,.12));\n  background: color-mix(in srgb, var(--hb-ua8-accent) 5%, rgba(255,255,255,.02));\n  box-shadow: 0 0 22px -10px var(--hb-ua8-accent);\n}\n.hb-ua8-k {\n  position: absolute;\n  width: 7px;\n  height: 7px;\n  border: 0 solid rgba(255,255,255,.5);\n  pointer-events: none;\n  transition: transform .3s cubic-bezier(.2, .8, .2, 1), width .3s cubic-bezier(.2, .8, .2, 1), height .3s cubic-bezier(.2, .8, .2, 1), border-color .2s ease;\n}\n.hb-ua8-k-tl { left: -1px; top: -1px; border-left-width: 1px; border-top-width: 1px; }\n.hb-ua8-k-tr { right: -1px; top: -1px; border-right-width: 1px; border-top-width: 1px; }\n.hb-ua8-k-bl { left: -1px; bottom: -1px; border-left-width: 1px; border-bottom-width: 1px; }\n.hb-ua8-k-br { right: -1px; bottom: -1px; border-right-width: 1px; border-bottom-width: 1px; }\n.hb-ua8:focus-within .hb-ua8-k { width: 12px; height: 12px; border-color: var(--hb-ua8-accent); }\n.hb-ua8:focus-within .hb-ua8-k-tl { transform: translate(-3px, -3px); }\n.hb-ua8:focus-within .hb-ua8-k-tr { transform: translate(3px, -3px); }\n.hb-ua8:focus-within .hb-ua8-k-bl { transform: translate(-3px, 3px); }\n.hb-ua8:focus-within .hb-ua8-k-br { transform: translate(3px, 3px); }\n.hb-ua8-icon { flex: 0 0 auto; width: 14px; height: 14px; color: #8f8f8f; transition: color .2s ease; }\n.hb-ua8:focus-within .hb-ua8-icon { color: var(--hb-ua8-accent); }\n.hb-ua8-input {\n  flex: 1 1 auto;\n  min-width: 0;\n  height: 100%;\n  margin: 0;\n  padding: 0;\n  border: 0;\n  outline: none;\n  background: transparent;\n  color: #ededed;\n  font: inherit;\n  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n  font-size: 12px;\n  letter-spacing: .06em;\n  caret-color: var(--hb-ua8-accent);\n}\n.hb-ua8-input::placeholder { color: #5f5f5f; text-transform: uppercase; letter-spacing: .14em; font-size: 10px; }\n.hb-ua8-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }\n.hb-ua8-mono {\n  flex: 0 0 auto;\n  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n  font-size: 9px;\n  letter-spacing: .14em;\n  text-transform: uppercase;\n  white-space: nowrap;\n}\n.hb-ua8-count { color: #8f8f8f; font-variant-numeric: tabular-nums; }\n.hb-ua8-count b { font-weight: 400; color: #ededed; }\n.hb-ua8-clear {\n  display: inline-grid;\n  place-items: center;\n  flex: 0 0 auto;\n  width: 20px;\n  height: 20px;\n  margin: 0;\n  padding: 0;\n  border: 1px solid rgba(255,255,255,.14);\n  background: transparent;\n  color: #a1a1a1;\n  cursor: pointer;\n  animation: hb-ua8-pop .2s ease-out;\n  transition: color .15s ease, border-color .15s ease;\n}\n.hb-ua8-clear:hover { color: #fff; border-color: var(--hb-ua8-accent); }\n.hb-ua8-clear:focus-visible { outline: 1px solid var(--hb-ua8-accent); outline-offset: 2px; }\n.hb-ua8-clear svg { width: 8px; height: 8px; }\n.hb-ua8-kbd {\n  display: inline-grid;\n  place-items: center;\n  min-width: 20px;\n  height: 20px;\n  padding: 0 5px;\n  border: 1px solid rgba(255,255,255,.18);\n  color: #a1a1a1;\n  letter-spacing: 0;\n}\n@keyframes hb-ua8-pop { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: none; } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-ua8, .hb-ua8-k, .hb-ua8-icon, .hb-ua8-clear { transition: none; animation: none; }\n}\n`;\n\nexport function HudSearchField({\n  value,\n  defaultValue = \"\",\n  onChange,\n  resultCount,\n  total,\n  shortcut = \"/\",\n  label = \"Search\",\n  accent = \"#ff4d4d\",\n  placeholder = \"Search experiments\",\n  className,\n  style,\n  onKeyDown,\n  onFocus,\n  onBlur,\n  ...rest\n}: HudSearchFieldProps) {\n  const [inner, setInner] = React.useState(defaultValue);\n  const [focused, setFocused] = React.useState(false);\n  const inputRef = React.useRef<HTMLInputElement>(null);\n  const current = value ?? inner;\n\n  const set = (next: string) => {\n    if (value === undefined) setInner(next);\n    onChange?.(next);\n  };\n\n  React.useEffect(() => {\n    if (!shortcut) return;\n    const onKey = (e: KeyboardEvent) => {\n      if (e.key !== shortcut || e.metaKey || e.ctrlKey || e.altKey) return;\n      const t = e.target as HTMLElement | null;\n      if (t && (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))) return;\n      e.preventDefault();\n      inputRef.current?.focus();\n      inputRef.current?.select();\n    };\n    window.addEventListener(\"keydown\", onKey);\n    return () => window.removeEventListener(\"keydown\", onKey);\n  }, [shortcut]);\n\n  return (\n    <div\n      className={[\"hb-ua8\", className].filter(Boolean).join(\" \")}\n      style={{ [\"--hb-ua8-accent\" as string]: accent, ...style }}\n      onPointerDown={(e) => {\n        if (e.target === e.currentTarget) {\n          e.preventDefault();\n          inputRef.current?.focus();\n        }\n      }}\n    >\n      <style href=\"hb-hud-search-field\" precedence=\"default\">{css}</style>\n      <span className=\"hb-ua8-k hb-ua8-k-tl\" aria-hidden=\"true\" />\n      <span className=\"hb-ua8-k hb-ua8-k-tr\" aria-hidden=\"true\" />\n      <span className=\"hb-ua8-k hb-ua8-k-bl\" aria-hidden=\"true\" />\n      <span className=\"hb-ua8-k hb-ua8-k-br\" aria-hidden=\"true\" />\n      <svg className=\"hb-ua8-icon\" viewBox=\"0 0 14 14\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.3\" aria-hidden=\"true\">\n        <circle cx=\"6\" cy=\"6\" r=\"4.2\" />\n        <path d=\"M9.2 9.2 12.5 12.5\" />\n      </svg>\n      <input\n        ref={inputRef}\n        type=\"search\"\n        className=\"hb-ua8-input\"\n        aria-label={label}\n        placeholder={placeholder}\n        autoComplete=\"off\"\n        spellCheck={false}\n        value={current}\n        onChange={(e) => set(e.target.value)}\n        onKeyDown={(e) => {\n          onKeyDown?.(e);\n          if (e.defaultPrevented) return;\n          if (e.key === \"Escape\") {\n            e.preventDefault();\n            if (current) set(\"\");\n            else e.currentTarget.blur();\n          }\n        }}\n        onFocus={(e) => {\n          setFocused(true);\n          onFocus?.(e);\n        }}\n        onBlur={(e) => {\n          setFocused(false);\n          onBlur?.(e);\n        }}\n        {...rest}\n      />\n      {current ? (\n        <button\n          type=\"button\"\n          className=\"hb-ua8-clear\"\n          aria-label=\"Clear search\"\n          onClick={() => {\n            set(\"\");\n            inputRef.current?.focus();\n          }}\n        >\n          <svg viewBox=\"0 0 8 8\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.2\" aria-hidden=\"true\">\n            <path d=\"M1 1l6 6M7 1 1 7\" />\n          </svg>\n        </button>\n      ) : null}\n      {resultCount !== undefined ? (\n        <span className=\"hb-ua8-mono hb-ua8-count\" aria-live=\"polite\">\n          <b>{String(resultCount).padStart(2, \"0\")}</b>\n          {total !== undefined ? ` / ${String(total).padStart(2, \"0\")}` : ` ${resultCount === 1 ? \"result\" : \"results\"}`}\n        </span>\n      ) : null}\n      {shortcut && !focused && !current ? (\n        <kbd className=\"hb-ua8-mono hb-ua8-kbd\" aria-hidden=\"true\">\n          {shortcut}\n        </kbd>\n      ) : null}\n    </div>\n  );\n}\n\nexport default HudSearchField;\n"
    }
  ]
}