{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "phone-input",
  "title": "Phone Input",
  "description": "A phone number input with a searchable country menu: flags and calling codes, as-you-type formatting per country, paste detection for +codes, an E.164 value and a length check.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/phone-input/phone-input.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, AnimatePresence } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport interface PhoneCountry {\n  /** ISO 3166-1 alpha-2 code, e.g. \"US\". */\n  code: string;\n  name: string;\n  /** Calling code without the plus, e.g. \"1\". */\n  dial: string;\n  /** National number layout; each # is a digit. Its # count is the longest accepted number. */\n  mask: string;\n  /** Shortest accepted national number, for countries with variable lengths. Defaults to the mask length. */\n  min?: number;\n  /** Numbers here keep a leading 0 (Italian landlines); elsewhere a typed trunk 0 is dropped. */\n  keepLeadingZero?: boolean;\n}\n\nexport interface PhoneValueMeta {\n  country: string;\n  /** National significant number, digits only. */\n  nationalNumber: string;\n  /** True when the number has a valid length for the country. */\n  isValid: boolean;\n}\n\nexport type PhoneInputSize = \"sm\" | \"md\" | \"lg\";\n\nexport interface PhoneInputProps {\n  /** E.164 number, e.g. \"+14155550123\", or \"\" when empty. */\n  value?: string;\n  defaultValue?: string;\n  onValueChange?: (value: string, meta: PhoneValueMeta) => void;\n  /** Selected country (ISO code), controlled. */\n  country?: string;\n  defaultCountry?: string;\n  onCountryChange?: (country: string) => void;\n  /** Limit the menu to these ISO codes. */\n  countries?: string[];\n  /** Pinned to the top of the menu, in this order. */\n  preferredCountries?: string[];\n  label?: string;\n  placeholder?: string;\n  helperText?: string;\n  /** Forces an error state with this message. */\n  errorText?: string;\n  /** Shown after the field loses focus with an incomplete number; set to \"\" to turn the check off. */\n  invalidText?: string;\n  /** Name for a hidden input carrying the E.164 value, for plain form posts. */\n  name?: string;\n  size?: PhoneInputSize;\n  theme?: \"dark\" | \"light\";\n  width?: number | string;\n  disabled?: boolean;\n  className?: string;\n}\n\nexport const PHONE_COUNTRIES: PhoneCountry[] = [\n  { code: \"US\", name: \"United States\", dial: \"1\", mask: \"(###) ###-####\" },\n  { code: \"CA\", name: \"Canada\", dial: \"1\", mask: \"(###) ###-####\" },\n  { code: \"GB\", name: \"United Kingdom\", dial: \"44\", mask: \"#### ######\" },\n  { code: \"TR\", name: \"Türkiye\", dial: \"90\", mask: \"### ### ## ##\" },\n  { code: \"DE\", name: \"Germany\", dial: \"49\", mask: \"### ########\", min: 10 },\n  { code: \"FR\", name: \"France\", dial: \"33\", mask: \"# ## ## ## ##\" },\n  { code: \"ES\", name: \"Spain\", dial: \"34\", mask: \"### ## ## ##\" },\n  { code: \"IT\", name: \"Italy\", dial: \"39\", mask: \"### ### ####\", min: 9, keepLeadingZero: true },\n  { code: \"NL\", name: \"Netherlands\", dial: \"31\", mask: \"# ########\" },\n  { code: \"BE\", name: \"Belgium\", dial: \"32\", mask: \"### ## ## ##\", min: 8 },\n  { code: \"CH\", name: \"Switzerland\", dial: \"41\", mask: \"## ### ## ##\" },\n  { code: \"AT\", name: \"Austria\", dial: \"43\", mask: \"### ########\", min: 7 },\n  { code: \"SE\", name: \"Sweden\", dial: \"46\", mask: \"##-### ## ##\", min: 7 },\n  { code: \"NO\", name: \"Norway\", dial: \"47\", mask: \"### ## ###\" },\n  { code: \"DK\", name: \"Denmark\", dial: \"45\", mask: \"## ## ## ##\" },\n  { code: \"FI\", name: \"Finland\", dial: \"358\", mask: \"## ### #####\", min: 6 },\n  { code: \"IE\", name: \"Ireland\", dial: \"353\", mask: \"## ### ####\" },\n  { code: \"PT\", name: \"Portugal\", dial: \"351\", mask: \"### ### ###\" },\n  { code: \"PL\", name: \"Poland\", dial: \"48\", mask: \"### ### ###\" },\n  { code: \"CZ\", name: \"Czechia\", dial: \"420\", mask: \"### ### ###\" },\n  { code: \"GR\", name: \"Greece\", dial: \"30\", mask: \"### ### ####\" },\n  { code: \"RO\", name: \"Romania\", dial: \"40\", mask: \"### ### ###\" },\n  { code: \"HU\", name: \"Hungary\", dial: \"36\", mask: \"## ### ####\", min: 8 },\n  { code: \"UA\", name: \"Ukraine\", dial: \"380\", mask: \"## ### ## ##\" },\n  { code: \"RU\", name: \"Russia\", dial: \"7\", mask: \"(###) ###-##-##\" },\n  { code: \"IL\", name: \"Israel\", dial: \"972\", mask: \"##-###-####\", min: 8 },\n  { code: \"AE\", name: \"United Arab Emirates\", dial: \"971\", mask: \"## ### ####\", min: 8 },\n  { code: \"SA\", name: \"Saudi Arabia\", dial: \"966\", mask: \"## ### ####\" },\n  { code: \"EG\", name: \"Egypt\", dial: \"20\", mask: \"### ### ####\", min: 9 },\n  { code: \"ZA\", name: \"South Africa\", dial: \"27\", mask: \"## ### ####\" },\n  { code: \"NG\", name: \"Nigeria\", dial: \"234\", mask: \"### ### ####\" },\n  { code: \"KE\", name: \"Kenya\", dial: \"254\", mask: \"### ######\" },\n  { code: \"IN\", name: \"India\", dial: \"91\", mask: \"#####-#####\" },\n  { code: \"PK\", name: \"Pakistan\", dial: \"92\", mask: \"### #######\" },\n  { code: \"BD\", name: \"Bangladesh\", dial: \"880\", mask: \"####-######\" },\n  { code: \"CN\", name: \"China\", dial: \"86\", mask: \"### #### ####\" },\n  { code: \"JP\", name: \"Japan\", dial: \"81\", mask: \"##-####-####\", min: 9 },\n  { code: \"KR\", name: \"South Korea\", dial: \"82\", mask: \"##-####-####\", min: 9 },\n  { code: \"SG\", name: \"Singapore\", dial: \"65\", mask: \"#### ####\" },\n  { code: \"MY\", name: \"Malaysia\", dial: \"60\", mask: \"##-#### ####\", min: 9 },\n  { code: \"ID\", name: \"Indonesia\", dial: \"62\", mask: \"###-####-#####\", min: 9 },\n  { code: \"PH\", name: \"Philippines\", dial: \"63\", mask: \"### ### ####\" },\n  { code: \"TH\", name: \"Thailand\", dial: \"66\", mask: \"## ### ####\", min: 8 },\n  { code: \"VN\", name: \"Vietnam\", dial: \"84\", mask: \"## ### ## ##\" },\n  { code: \"AU\", name: \"Australia\", dial: \"61\", mask: \"### ### ###\" },\n  { code: \"NZ\", name: \"New Zealand\", dial: \"64\", mask: \"## ### ####\", min: 8 },\n  { code: \"BR\", name: \"Brazil\", dial: \"55\", mask: \"(##) #####-####\", min: 10 },\n  { code: \"MX\", name: \"Mexico\", dial: \"52\", mask: \"### ### ####\" },\n  { code: \"AR\", name: \"Argentina\", dial: \"54\", mask: \"## ####-####\" },\n  { code: \"CL\", name: \"Chile\", dial: \"56\", mask: \"# #### ####\" },\n  { code: \"CO\", name: \"Colombia\", dial: \"57\", mask: \"### ### ####\" },\n  { code: \"PE\", name: \"Peru\", dial: \"51\", mask: \"### ### ###\" },\n];\n\nconst PALETTES = {\n  dark: { text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.5)\", faint: \"rgba(245,244,241,0.28)\", bg: \"rgba(255,255,255,0.03)\", border: \"rgba(255,255,255,0.12)\", borderHover: \"rgba(255,255,255,0.24)\", focus: \"rgba(245,244,241,0.85)\", divider: \"rgba(255,255,255,0.1)\", menuBg: \"#0E0E0E\", menuBorder: \"rgba(255,255,255,0.08)\", highlight: \"rgba(255,255,255,0.07)\", hover: \"rgba(255,255,255,0.06)\", error: \"#FF7A6B\", shadow: \"0 24px 60px rgba(0,0,0,0.55)\" },\n  light: { text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.5)\", faint: \"rgba(10,10,10,0.28)\", bg: \"#FFFFFF\", border: \"rgba(10,10,10,0.16)\", borderHover: \"rgba(10,10,10,0.3)\", focus: \"rgba(10,10,10,0.85)\", divider: \"rgba(10,10,10,0.1)\", menuBg: \"#FFFFFF\", menuBorder: \"rgba(10,10,10,0.12)\", highlight: \"rgba(10,10,10,0.05)\", hover: \"rgba(10,10,10,0.04)\", error: \"#E5484D\", shadow: \"0 20px 50px rgba(0,0,0,0.16)\" },\n};\n\nconst SIZES: Record<PhoneInputSize, { font: number; height: number; padX: number; radius: number }> = {\n  sm: { font: 13, height: 36, padX: 12, radius: 11 },\n  md: { font: 14.5, height: 44, padX: 14, radius: 13 },\n  lg: { font: 16, height: 52, padX: 16, radius: 15 },\n};\n\nconst EXAMPLE_DIGITS = \"2015550123456\";\nconst digitsIn = (s: string) => s.replace(/\\D/g, \"\");\nconst maxLength = (c: PhoneCountry) => (c.mask.match(/#/g) ?? []).length;\nconst isValidLength = (c: PhoneCountry, digits: string) => digits.length >= (c.min ?? maxLength(c)) && digits.length <= maxLength(c);\n\n/** Lays digits into the mask and stops after the last one, so no trailing separators show. */\nfunction formatNational(c: PhoneCountry, digits: string) {\n  let out = \"\";\n  let i = 0;\n  for (const ch of c.mask) {\n    if (i >= digits.length) break;\n    if (ch === \"#\") out += digits[i++];\n    else out += ch;\n  }\n  return out;\n}\n\nconst flagOf = (code: string) => String.fromCodePoint(...[...code.toUpperCase()].map((ch) => 0x1f1a5 + ch.charCodeAt(0)));\n\n/** Longest calling-code match for an international number, preferring `current` when codes tie (US/CA). */\nfunction detectCountry(list: PhoneCountry[], digits: string, current: PhoneCountry) {\n  const matches = list.filter((c) => digits.startsWith(c.dial));\n  if (matches.length === 0) return null;\n  const longest = Math.max(...matches.map((c) => c.dial.length));\n  const best = matches.filter((c) => c.dial.length === longest);\n  return best.find((c) => c.code === current.code) ?? best[0];\n}\n\nfunction parseE164(list: PhoneCountry[], value: string | undefined, fallback: PhoneCountry) {\n  if (!value || !value.startsWith(\"+\")) return { country: fallback, national: digitsIn(value ?? \"\") };\n  const digits = digitsIn(value);\n  const c = detectCountry(list, digits, fallback) ?? fallback;\n  return { country: c, national: digits.slice(c.dial.length) };\n}\n\nfunction Chevron({ open, color }: { open: boolean; color: string }) {\n  return (\n    <motion.span aria-hidden=\"true\" className=\"flex shrink-0\" animate={{ rotate: open ? 180 : 0 }} transition={{ type: \"spring\", stiffness: 420, damping: 28 }} style={{ color }}>\n      <svg width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n        <path d=\"M4 6.2L8 10L12 6.2\" />\n      </svg>\n    </motion.span>\n  );\n}\n\nfunction Check({ color, size = 15 }: { color: string; size?: number }) {\n  return (\n    <svg width={size} height={size} viewBox=\"0 0 16 16\" fill=\"none\" className=\"shrink-0\" aria-hidden=\"true\">\n      <motion.path d=\"M3 8.2L6.4 11.6L13 4.4\" stroke={color} strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" initial={{ pathLength: 0 }} animate={{ pathLength: 1 }} transition={{ duration: 0.25, ease: \"easeOut\" }} />\n    </svg>\n  );\n}\n\nconst FLAG_FONT = '\"Apple Color Emoji\", \"Segoe UI Emoji\", \"Noto Color Emoji\", sans-serif';\n\nexport function PhoneInput({\n  value,\n  defaultValue = \"\",\n  onValueChange,\n  country: countryProp,\n  defaultCountry = \"US\",\n  onCountryChange,\n  countries,\n  preferredCountries = [],\n  label,\n  placeholder,\n  helperText,\n  errorText,\n  invalidText = \"Enter a valid phone number\",\n  name,\n  size = \"md\",\n  theme = \"dark\",\n  width = 320,\n  disabled = false,\n  className,\n}: PhoneInputProps) {\n  const p = PALETTES[theme];\n  const s = SIZES[size];\n  const uid = React.useId();\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const inputRef = React.useRef<HTMLInputElement>(null);\n  const searchRef = React.useRef<HTMLInputElement>(null);\n  const listRef = React.useRef<HTMLUListElement>(null);\n  const caretDigits = React.useRef<number | null>(null);\n\n  const list = React.useMemo(() => {\n    const base = countries ? PHONE_COUNTRIES.filter((c) => countries.includes(c.code)) : PHONE_COUNTRIES;\n    return base.length ? base : PHONE_COUNTRIES;\n  }, [countries]);\n  const byCode = (code?: string) => list.find((c) => c.code === code?.toUpperCase());\n  const fallback = byCode(defaultCountry) ?? list[0];\n\n  // The picked country is kept even when `value` is controlled, so choosing one on an empty field sticks.\n  const [initial] = React.useState(() => parseE164(list, defaultValue, fallback));\n  const [countryState, setCountryState] = React.useState(initial.country);\n  const [nationalState, setNationalState] = React.useState(initial.national);\n  const isControlled = value !== undefined;\n  const fromValue = isControlled && value ? parseE164(list, value, byCode(countryProp) ?? countryState) : null;\n  const country = byCode(countryProp) ?? fromValue?.country ?? byCode(countryState.code) ?? fallback;\n  const national = isControlled ? (fromValue?.national ?? \"\") : nationalState;\n\n  const [open, setOpen] = React.useState(false);\n  const [query, setQuery] = React.useState(\"\");\n  const [activeIndex, setActiveIndex] = React.useState(0);\n  const [focused, setFocused] = React.useState(false);\n  const [hovered, setHovered] = React.useState(false);\n  const [touched, setTouched] = React.useState(false);\n\n  const valid = isValidLength(country, national);\n  const e164 = national ? `+${country.dial}${national}` : \"\";\n\n  const emit = (c: PhoneCountry, digits: string) => {\n    const next = digits.slice(0, maxLength(c));\n    if (!countryProp) setCountryState(c);\n    if (!isControlled) setNationalState(next);\n    if (c.code !== country.code) onCountryChange?.(c.code);\n    onValueChange?.(next ? `+${c.dial}${next}` : \"\", { country: c.code, nationalNumber: next, isValid: isValidLength(c, next) });\n  };\n\n  const onInput = (raw: string, caret: number | null) => {\n    // \"+44 7911…\" (typed or pasted) switches country by its calling code.\n    if (raw.trim().startsWith(\"+\")) {\n      const all = digitsIn(raw);\n      const c = detectCountry(list, all, country);\n      if (c) {\n        caretDigits.current = null;\n        return emit(c, all.slice(c.dial.length));\n      }\n    }\n    let digits = digitsIn(raw);\n    let before = caret === null ? digits.length : digitsIn(raw.slice(0, caret)).length;\n    if (digits.startsWith(\"0\") && !country.keepLeadingZero) {\n      digits = digits.slice(1);\n      before = Math.max(0, before - 1);\n    }\n    caretDigits.current = before;\n    emit(country, digits);\n  };\n\n  // Put the caret back after the same number of digits once the text is reformatted.\n  const formatted = formatNational(country, national);\n  React.useLayoutEffect(() => {\n    const el = inputRef.current;\n    const n = caretDigits.current;\n    if (!el || n === null || document.activeElement !== el) return;\n    let pos = 0;\n    let seen = 0;\n    while (pos < formatted.length && seen < n) {\n      if (/\\d/.test(formatted[pos])) seen++;\n      pos++;\n    }\n    el.setSelectionRange(pos, pos);\n    caretDigits.current = null;\n  }, [formatted]);\n\n  const onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n    // Backspace right after a separator deletes the digit before it instead of doing nothing.\n    const el = e.currentTarget;\n    const start = el.selectionStart ?? 0;\n    if (e.key === \"Backspace\" && start === el.selectionEnd && start > 0 && !/\\d/.test(el.value[start - 1])) {\n      e.preventDefault();\n      const digitIndex = digitsIn(el.value.slice(0, start)).length - 1;\n      if (digitIndex < 0) return;\n      caretDigits.current = digitIndex;\n      emit(country, national.slice(0, digitIndex) + national.slice(digitIndex + 1));\n    }\n  };\n\n  const ordered = React.useMemo(() => {\n    const pinned = preferredCountries.map((code) => list.find((c) => c.code === code)).filter((c): c is PhoneCountry => Boolean(c));\n    return { pinned, rest: list.filter((c) => !pinned.includes(c)) };\n  }, [list, preferredCountries]);\n\n  const filtered = React.useMemo(() => {\n    const q = query.trim().toLowerCase().replace(/^\\+/, \"\");\n    if (!q) return [...ordered.pinned, ...ordered.rest];\n    return list.filter((c) => c.name.toLowerCase().includes(q) || c.code.toLowerCase() === q || c.dial.startsWith(q));\n  }, [query, ordered, list]);\n  const showPinnedDivider = !query.trim() && ordered.pinned.length > 0;\n\n  const openMenu = () => {\n    if (disabled) return;\n    setQuery(\"\");\n    const all = [...ordered.pinned, ...ordered.rest];\n    setActiveIndex(Math.max(0, all.findIndex((c) => c.code === country.code)));\n    setOpen(true);\n  };\n\n  const closeMenu = (focusInput = true) => {\n    setOpen(false);\n    if (focusInput) inputRef.current?.focus();\n  };\n\n  const pick = (c: PhoneCountry) => {\n    emit(c, national);\n    closeMenu();\n  };\n\n  const onSearchKey = (e: React.KeyboardEvent<HTMLInputElement>) => {\n    if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n      e.preventDefault();\n      if (filtered.length) setActiveIndex((i) => (i + (e.key === \"ArrowDown\" ? 1 : -1) + filtered.length) % filtered.length);\n    } else if (e.key === \"Home\" || e.key === \"End\") {\n      e.preventDefault();\n      setActiveIndex(e.key === \"Home\" ? 0 : filtered.length - 1);\n    } else if (e.key === \"Enter\") {\n      e.preventDefault();\n      if (filtered[activeIndex]) pick(filtered[activeIndex]);\n    } else if (e.key === \"Escape\") {\n      e.preventDefault();\n      closeMenu();\n    } else if (e.key === \"Tab\") {\n      setOpen(false);\n    }\n  };\n\n  React.useEffect(() => {\n    if (!open) return;\n    const onDown = (e: MouseEvent) => {\n      if (rootRef.current && !rootRef.current.contains(e.target as Node)) setOpen(false);\n    };\n    document.addEventListener(\"mousedown\", onDown);\n    const t = setTimeout(() => searchRef.current?.focus(), 30);\n    return () => {\n      document.removeEventListener(\"mousedown\", onDown);\n      clearTimeout(t);\n    };\n  }, [open]);\n\n  React.useEffect(() => {\n    if (!open) return;\n    listRef.current?.querySelector<HTMLElement>(`[data-index=\"${activeIndex}\"]`)?.scrollIntoView({ block: \"nearest\" });\n  }, [activeIndex, open]);\n\n  const showInvalid = Boolean(errorText) || (Boolean(invalidText) && touched && !focused && national.length > 0 && !valid);\n  const message = errorText || (showInvalid ? invalidText : helperText);\n  const active = focused || open;\n  const borderColor = showInvalid ? p.error : active ? p.focus : hovered ? p.borderHover : p.border;\n  const ringColor = showInvalid ? p.error : p.focus;\n  const shownPlaceholder = placeholder ?? formatNational(country, EXAMPLE_DIGITS.slice(0, maxLength(country)));\n\n  return (\n    <div ref={rootRef} className={cn(\"relative inline-flex flex-col gap-2\", className)} style={{ width, maxWidth: \"100%\", fontFamily: \"Inter, sans-serif\", opacity: disabled ? 0.5 : 1 }}>\n      {label && (\n        <label htmlFor={`${uid}-input`} className=\"font-semibold tracking-[-0.01em]\" style={{ color: p.text, fontSize: s.font }}>\n          {label}\n        </label>\n      )}\n      {name && <input type=\"hidden\" name={name} value={e164} />}\n\n      <div className=\"relative\">\n        <div\n          onMouseEnter={() => setHovered(true)}\n          onMouseLeave={() => setHovered(false)}\n          className=\"flex items-center\"\n          style={{ height: s.height, borderRadius: s.radius, background: p.bg, border: `1px solid ${borderColor}`, boxShadow: active || showInvalid ? `0 0 0 3px color-mix(in srgb, ${ringColor} 14%, transparent)` : \"0 0 0 0 transparent\", transition: \"border-color 0.18s ease, box-shadow 0.18s ease\" }}\n        >\n          <button\n            type=\"button\"\n            aria-haspopup=\"listbox\"\n            aria-expanded={open}\n            aria-label={`Country: ${country.name} +${country.dial}`}\n            disabled={disabled}\n            onClick={() => (open ? closeMenu() : openMenu())}\n            className=\"flex h-full shrink-0 cursor-pointer items-center border-none bg-transparent outline-none focus-visible:ring-2\"\n            style={{ gap: 6, padding: `0 8px 0 ${s.padX - 2}px`, borderRadius: `${s.radius}px 0 0 ${s.radius}px`, color: p.text, fontSize: s.font, fontWeight: 500, cursor: disabled ? \"default\" : \"pointer\", [\"--tw-ring-color\" as string]: p.focus }}\n          >\n            <span aria-hidden=\"true\" style={{ fontFamily: FLAG_FONT, fontSize: s.font + 3, lineHeight: 1 }}>\n              {flagOf(country.code)}\n            </span>\n            <span style={{ fontVariantNumeric: \"tabular-nums\" }}>+{country.dial}</span>\n            <Chevron open={open} color={open ? p.text : p.muted} />\n          </button>\n          <span aria-hidden=\"true\" className=\"shrink-0\" style={{ width: 1, height: s.height * 0.46, background: p.divider }} />\n          <input\n            ref={inputRef}\n            id={`${uid}-input`}\n            type=\"tel\"\n            inputMode=\"tel\"\n            autoComplete=\"tel-national\"\n            disabled={disabled}\n            value={formatted}\n            placeholder={shownPlaceholder}\n            aria-invalid={showInvalid || undefined}\n            aria-describedby={message ? `${uid}-msg` : undefined}\n            onChange={(e) => onInput(e.target.value, e.target.selectionStart)}\n            onKeyDown={onKeyDown}\n            onFocus={() => setFocused(true)}\n            onBlur={() => {\n              setFocused(false);\n              setTouched(true);\n            }}\n            className=\"h-full min-w-0 flex-1 border-none bg-transparent outline-none placeholder:text-[color:var(--pi-placeholder)]\"\n            style={{ padding: `0 ${valid ? 6 : s.padX}px 0 10px`, color: p.text, fontSize: s.font, fontWeight: 500, fontVariantNumeric: \"tabular-nums\", letterSpacing: \"0.01em\", [\"--pi-placeholder\" as string]: p.faint }}\n          />\n          <AnimatePresence>\n            {valid && (\n              <motion.span key=\"ok\" className=\"flex shrink-0\" style={{ paddingRight: s.padX }} initial={{ opacity: 0, scale: 0.6 }} animate={{ opacity: 1, scale: 1 }} exit={{ opacity: 0, scale: 0.6 }} transition={{ duration: 0.16 }} aria-hidden=\"true\">\n                <Check color={p.text} size={s.font + 1} />\n              </motion.span>\n            )}\n          </AnimatePresence>\n        </div>\n\n        <AnimatePresence>\n          {open && (\n            <motion.div\n              className=\"absolute left-0 z-50 w-full overflow-hidden\"\n              style={{ top: \"calc(100% + 8px)\", borderRadius: s.radius + 2, border: `1px solid ${p.menuBorder}`, background: p.menuBg, boxShadow: p.shadow, transformOrigin: \"top center\" }}\n              initial={{ opacity: 0, y: -6, scale: 0.98 }}\n              animate={{ opacity: 1, y: 0, scale: 1 }}\n              exit={{ opacity: 0, y: -6, scale: 0.98 }}\n              transition={{ duration: 0.16, ease: [0.16, 1, 0.3, 1] }}\n            >\n              <div className=\"flex items-center\" style={{ gap: 8, padding: `0 ${s.padX - 2}px`, height: s.height - 4, borderBottom: `1px solid ${p.menuBorder}` }}>\n                <svg width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" fill=\"none\" stroke={p.muted} strokeWidth=\"1.6\" strokeLinecap=\"round\" aria-hidden=\"true\">\n                  <circle cx=\"7\" cy=\"7\" r=\"4.5\" />\n                  <path d=\"M10.5 10.5L14 14\" />\n                </svg>\n                <input\n                  ref={searchRef}\n                  type=\"text\"\n                  role=\"combobox\"\n                  aria-expanded\n                  aria-controls={`${uid}-list`}\n                  aria-activedescendant={filtered[activeIndex] ? `${uid}-c-${filtered[activeIndex].code}` : undefined}\n                  aria-label=\"Search countries\"\n                  autoComplete=\"off\"\n                  spellCheck={false}\n                  value={query}\n                  placeholder=\"Search country or code\"\n                  onChange={(e) => {\n                    setQuery(e.target.value);\n                    setActiveIndex(0);\n                  }}\n                  onKeyDown={onSearchKey}\n                  className=\"min-w-0 flex-1 border-none bg-transparent p-0 outline-none placeholder:text-[color:var(--pi-placeholder)]\"\n                  style={{ color: p.text, fontSize: s.font - 1, fontWeight: 500, [\"--pi-placeholder\" as string]: p.muted }}\n                />\n              </div>\n              <ul ref={listRef} id={`${uid}-list`} role=\"listbox\" aria-label=\"Countries\" className=\"m-0 list-none overflow-auto p-1.5\" style={{ maxHeight: 264 }}>\n                {filtered.length === 0 ? (\n                  <li role=\"presentation\" className=\"text-center\" style={{ padding: \"18px 12px\", color: p.muted, fontSize: s.font - 0.5 }}>\n                    No countries found\n                  </li>\n                ) : (\n                  filtered.map((c, i) => {\n                    const isSelected = c.code === country.code;\n                    return (\n                      <React.Fragment key={c.code}>\n                        {showPinnedDivider && i === ordered.pinned.length && <li role=\"presentation\" aria-hidden=\"true\" style={{ height: 1, margin: \"6px 8px\", background: p.menuBorder }} />}\n                        <li\n                          id={`${uid}-c-${c.code}`}\n                          data-index={i}\n                          role=\"option\"\n                          aria-selected={isSelected}\n                          onMouseEnter={() => setActiveIndex(i)}\n                          onMouseDown={(e) => e.preventDefault()}\n                          onClick={() => pick(c)}\n                          className=\"flex cursor-pointer items-center\"\n                          style={{ gap: 10, padding: `${s.height * 0.18}px ${s.padX - 4}px`, borderRadius: s.radius - 4, background: i === activeIndex ? p.highlight : \"transparent\", color: p.text, transition: \"background 0.12s ease\" }}\n                        >\n                          <span aria-hidden=\"true\" style={{ fontFamily: FLAG_FONT, fontSize: s.font + 2, lineHeight: 1 }}>\n                            {flagOf(c.code)}\n                          </span>\n                          <span className=\"min-w-0 flex-1 truncate\" style={{ fontSize: s.font - 0.5, fontWeight: isSelected ? 700 : 500 }}>\n                            {c.name}\n                          </span>\n                          <span style={{ fontSize: s.font - 1.5, color: p.muted, fontVariantNumeric: \"tabular-nums\" }}>+{c.dial}</span>\n                          <span className=\"flex shrink-0 justify-end\" style={{ width: 15 }}>\n                            {isSelected && <Check color={p.text} size={14} />}\n                          </span>\n                        </li>\n                      </React.Fragment>\n                    );\n                  })\n                )}\n              </ul>\n            </motion.div>\n          )}\n        </AnimatePresence>\n      </div>\n\n      <AnimatePresence initial={false} mode=\"wait\">\n        {message && (\n          <motion.span key={showInvalid ? \"error\" : \"helper\"} id={`${uid}-msg`} role={showInvalid ? \"alert\" : undefined} initial={{ opacity: 0, y: -3 }} animate={{ opacity: 1, y: 0 }} exit={{ opacity: 0, y: -3 }} transition={{ duration: 0.16 }} style={{ color: showInvalid ? p.error : p.muted, fontSize: s.font - 1.5, lineHeight: 1.4, visibility: open ? \"hidden\" : \"visible\" }}>\n            {message}\n          </motion.span>\n        )}\n      </AnimatePresence>\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}