{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pay-card-form",
  "type": "registry:component",
  "title": "Pay Card Form",
  "description": "A card entry form with grouped number formatting, a Luhn check, brand detection, expiry validation and a live card preview. It never sends data anywhere.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "payments",
    "card",
    "form",
    "payment",
    "luhn",
    "validation",
    "checkout"
  ],
  "docs": "https://hyperblur.dev/effects/pay-card-form",
  "files": [
    {
      "path": "registry/hyperblur/pay-card-form.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/pay-card-form.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type PayCardFormTheme = \"midnight\" | \"aurora\" | \"ember\" | \"graphite\" | \"lagoon\";\nexport type PayCardBrandId = \"arc\" | \"twin\" | \"tri\" | \"ring\" | \"none\";\n\nexport interface PayCardFormValues {\n  number: string;\n  name: string;\n  expiry: string;\n  cvc: string;\n  brand: PayCardBrandId;\n}\n\nexport interface PayCardFormProps\n  extends Omit<React.FormHTMLAttributes<HTMLFormElement>, \"onSubmit\" | \"onChange\" | \"defaultValue\"> {\n  onSubmit?: (values: PayCardFormValues) => void;\n  onChange?: (values: PayCardFormValues) => void;\n  defaultValues?: Partial<Pick<PayCardFormValues, \"number\" | \"name\" | \"expiry\" | \"cvc\">>;\n  showPreview?: boolean;\n  submitLabel?: string;\n  successLabel?: string;\n  theme?: PayCardFormTheme;\n  bank?: string;\n  accent?: string;\n}\n\ntype FieldName = \"number\" | \"name\" | \"expiry\" | \"cvc\";\n\ninterface Brand {\n  id: PayCardBrandId;\n  label: string;\n  lengths: number[];\n  cvc: number;\n}\n\nconst css = `\n.hb-qf2 {\n  box-sizing: border-box;\n  container-type: inline-size;\n  width: 100%;\n  color: #ededed;\n  font-family: inherit;\n  font-size: 14px;\n  line-height: 1.4;\n}\n.hb-qf2 *, .hb-qf2 *::before, .hb-qf2 *::after { box-sizing: border-box; }\n.hb-qf2-grid { display: grid; gap: 22px; }\n@container (min-width: 520px) {\n  .hb-qf2-grid { grid-template-columns: minmax(0, 0.92fr) minmax(0, 1fr); align-items: center; gap: 28px; }\n}\n.hb-qf2-stage { min-width: 0; width: 100%; max-width: 340px; margin: 0 auto; perspective: 1100px; container-type: inline-size; }\n.hb-qf2-card {\n  position: relative;\n  width: 100%;\n  aspect-ratio: 1.586;\n  transform-style: preserve-3d;\n  transition: transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);\n}\n.hb-qf2[data-flip=\"true\"] .hb-qf2-card { transform: rotateY(180deg); }\n.hb-qf2-face {\n  position: absolute;\n  inset: 0;\n  overflow: hidden;\n  color: #fff;\n  border-radius: 5.2cqw;\n  background:\n    radial-gradient(120% 90% at 0% 0%, var(--hb-qf2-a), transparent 62%),\n    linear-gradient(135deg, var(--hb-qf2-b), var(--hb-qf2-c));\n  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset, 0 3cqw 7cqw -2cqw rgba(0, 0, 0, 0.65);\n  backface-visibility: hidden;\n  -webkit-backface-visibility: hidden;\n}\n.hb-qf2[data-theme=\"midnight\"] { --hb-qf2-a: #3b6dff; --hb-qf2-b: #14214f; --hb-qf2-c: #070b1c; }\n.hb-qf2[data-theme=\"aurora\"] { --hb-qf2-a: #2dd4a8; --hb-qf2-b: #3b2f8f; --hb-qf2-c: #0e0a2a; }\n.hb-qf2[data-theme=\"ember\"] { --hb-qf2-a: #ff8a4c; --hb-qf2-b: #8a1f3d; --hb-qf2-c: #1c0810; }\n.hb-qf2[data-theme=\"graphite\"] { --hb-qf2-a: #8a8f9c; --hb-qf2-b: #2b2e36; --hb-qf2-c: #0d0e12; }\n.hb-qf2[data-theme=\"lagoon\"] { --hb-qf2-a: #35d0ff; --hb-qf2-b: #0b5d8a; --hb-qf2-c: #04202e; }\n.hb-qf2-front {\n  display: flex;\n  flex-direction: column;\n  justify-content: space-between;\n  padding: 6.4cqw 7cqw 6cqw;\n}\n.hb-qf2-top { display: flex; align-items: center; justify-content: space-between; }\n.hb-qf2-bank { font-size: 4.2cqw; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.92; }\n.hb-qf2-nfc { width: 6.4cqw; height: 6.4cqw; fill: none; stroke: #fff; stroke-width: 1.7; stroke-linecap: round; opacity: 0.85; }\n.hb-qf2-chip {\n  display: block;\n  width: 12.6cqw;\n  height: 9.6cqw;\n  border-radius: 1.8cqw;\n  background:\n    linear-gradient(90deg, transparent 32%, rgba(80, 55, 10, 0.5) 32% 34%, transparent 34% 66%, rgba(80, 55, 10, 0.5) 66% 68%, transparent 68%),\n    linear-gradient(0deg, transparent 46%, rgba(80, 55, 10, 0.5) 46% 54%, transparent 54%),\n    linear-gradient(135deg, #f5dc9a, #c8a24e 55%, #efd58f);\n}\n.hb-qf2-cf { border-radius: 1.6cqw; margin: -1cqw -1.4cqw; padding: 1cqw 1.4cqw; min-width: 0; transition: background-color 0.3s ease, box-shadow 0.3s ease; }\n.hb-qf2-cf[data-on=\"true\"] { background: rgba(255, 255, 255, 0.14); box-shadow: 0 0 0 0.45cqw rgba(255, 255, 255, 0.6); }\n.hb-qf2-cf[data-empty=\"true\"] > * { opacity: 0.45; }\n.hb-qf2-cnum {\n  display: flex;\n  gap: 3cqw;\n  font-family: ui-monospace, \"SF Mono\", Menlo, Consolas, monospace;\n  font-size: 6.2cqw;\n  letter-spacing: 0.04em;\n  line-height: 1.1;\n  white-space: nowrap;\n  transition: opacity 0.3s ease;\n}\n.hb-qf2-bot { display: flex; align-items: flex-end; justify-content: space-between; gap: 3cqw; }\n.hb-qf2-meta { display: flex; min-width: 0; flex: 1; align-items: flex-end; gap: 5cqw; }\n.hb-qf2-clab { display: block; margin-bottom: 0.6cqw; font-size: 2.5cqw; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.6; }\n.hb-qf2-cv {\n  display: block;\n  overflow: hidden;\n  font-size: 4cqw;\n  font-weight: 500;\n  letter-spacing: 0.08em;\n  line-height: 1.2;\n  text-overflow: ellipsis;\n  text-transform: uppercase;\n  white-space: nowrap;\n  transition: opacity 0.3s ease;\n}\n.hb-qf2-cmark { width: 14cqw; height: 9.6cqw; flex: none; }\n.hb-qf2-back { transform: rotateY(180deg); }\n.hb-qf2-stripe { position: absolute; left: 0; right: 0; top: 10cqw; height: 14cqw; background: #08080a; }\n.hb-qf2-sign {\n  position: absolute;\n  left: 7cqw;\n  right: 7cqw;\n  top: 31cqw;\n  display: flex;\n  align-items: center;\n  height: 10cqw;\n  overflow: hidden;\n  background: repeating-linear-gradient(135deg, #f1efe8 0 1.4cqw, #dcd9cf 1.4cqw 2.8cqw);\n  border-radius: 1.2cqw;\n}\n.hb-qf2-code {\n  min-width: 14cqw;\n  margin-left: auto;\n  padding: 1cqw 2.4cqw;\n  background: #fff;\n  color: #14151a;\n  font-family: ui-monospace, \"SF Mono\", Menlo, Consolas, monospace;\n  font-size: 5cqw;\n    font-weight: 600;\n  letter-spacing: 0.1em;\n  text-align: right;\n}\n.hb-qf2-fields { display: flex; min-width: 0; flex-direction: column; gap: 12px; }\n.hb-qf2-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }\n.hb-qf2-field { min-width: 0; }\n.hb-qf2-lab { display: block; margin-bottom: 6px; color: #a1a1a1; font-size: 12px; font-weight: 500; letter-spacing: 0.01em; }\n.hb-qf2-ctl { position: relative; display: flex; align-items: center; }\n.hb-qf2-in {\n  width: 100%;\n  height: 42px;\n  margin: 0;\n  padding: 0 12px;\n  color: #ededed;\n  font: inherit;\n  font-size: 15px;\n  font-variant-numeric: tabular-nums;\n  background: #111111;\n  border: 1px solid #2a2a2a;\n  border-radius: 10px;\n  outline: none;\n  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;\n}\n.hb-qf2-in::placeholder { color: #5f5f5f; }\n.hb-qf2-in:hover { border-color: #3a3a3a; }\n.hb-qf2-in:focus-visible { border-color: var(--hb-qf2-x); box-shadow: 0 0 0 3px color-mix(in srgb, var(--hb-qf2-x) 28%, transparent); }\n.hb-qf2-field[data-bad=\"true\"] .hb-qf2-in { border-color: #ff5d6c; box-shadow: 0 0 0 3px rgba(255, 93, 108, 0.16); }\n.hb-qf2-field[data-ok=\"true\"] .hb-qf2-in { padding-right: 70px; }\n.hb-qf2-tail { position: absolute; right: 10px; display: flex; align-items: center; gap: 8px; pointer-events: none; }\n.hb-qf2-mini { width: 26px; height: 18px; }\n.hb-qf2-tick { width: 16px; height: 16px; fill: none; stroke: #3ddc97; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }\n.hb-qf2-err {\n  display: grid;\n  grid-template-rows: 0fr;\n  margin: 0;\n  color: #ff7a86;\n  font-size: 12px;\n  opacity: 0;\n  transition: grid-template-rows 0.25s ease, opacity 0.25s ease, margin 0.25s ease;\n}\n.hb-qf2-err > span { min-height: 0; overflow: hidden; }\n.hb-qf2-field[data-bad=\"true\"] .hb-qf2-err { grid-template-rows: 1fr; margin-top: 5px; opacity: 1; }\n.hb-qf2-field[data-bad=\"true\"] .hb-qf2-ctl { animation: hb-qf2-shake 0.35s ease; }\n.hb-qf2-go {\n  position: relative;\n  display: grid;\n  place-items: center;\n  width: 100%;\n  height: 44px;\n  margin: 2px 0 0;\n  padding: 0 16px;\n  overflow: hidden;\n  color: #fff;\n  font: inherit;\n  font-size: 15px;\n  font-weight: 600;\n  background: var(--hb-qf2-x);\n  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0));\n  border: 0;\n  border-radius: 10px;\n  cursor: pointer;\n  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.3s ease;\n}\n.hb-qf2-go:hover { transform: translateY(-1px); }\n.hb-qf2-go:active { transform: scale(0.98); }\n.hb-qf2-go:focus-visible { outline: 2px solid var(--hb-qf2-x); outline-offset: 3px; }\n.hb-qf2-go[data-done=\"true\"] { background-color: #15803d; }\n.hb-qf2-go > span { grid-area: 1 / 1; display: inline-flex; align-items: center; gap: 8px; transition: opacity 0.25s ease, transform 0.3s ease; }\n.hb-qf2-go > span:last-child { opacity: 0; transform: translateY(60%); }\n.hb-qf2-go[data-done=\"true\"] > span:first-child { opacity: 0; transform: translateY(-60%); }\n.hb-qf2-go[data-done=\"true\"] > span:last-child { opacity: 1; transform: none; }\n@keyframes hb-qf2-shake {\n  0%, 100% { transform: translateX(0); }\n  25% { transform: translateX(-4px); }\n  75% { transform: translateX(4px); }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-qf2-card, .hb-qf2-in, .hb-qf2-err, .hb-qf2-go, .hb-qf2-go > span { transition: none; }\n  .hb-qf2-field[data-bad=\"true\"] .hb-qf2-ctl { animation: none; }\n}\n`;\n\nexport function detectPayCardBrand(digits: string): Brand {\n  if (/^4/.test(digits)) return { id: \"arc\", label: \"Arc\", lengths: [16], cvc: 3 };\n  if (/^(5[1-5]|2(2[2-9]|[3-6]|7[01]|720))/.test(digits)) return { id: \"twin\", label: \"Twin\", lengths: [16], cvc: 3 };\n  if (/^3[47]/.test(digits)) return { id: \"tri\", label: \"Tri\", lengths: [15], cvc: 4 };\n  if (/^6/.test(digits)) return { id: \"ring\", label: \"Ring\", lengths: [16, 17, 18, 19], cvc: 3 };\n  return { id: \"none\", label: \"Card\", lengths: [13, 14, 15, 16, 17, 18, 19], cvc: 3 };\n}\n\nexport function isLuhnValid(digits: string) {\n  let sum = 0;\n  let flip = false;\n  for (let i = digits.length - 1; i >= 0; i -= 1) {\n    let n = digits.charCodeAt(i) - 48;\n    if (flip) {\n      n *= 2;\n      if (n > 9) n -= 9;\n    }\n    sum += n;\n    flip = !flip;\n  }\n  return digits.length > 0 && sum % 10 === 0;\n}\n\nfunction formatNumber(raw: string) {\n  const digits = raw.replace(/\\D/g, \"\").slice(0, 19);\n  if (/^3[47]/.test(digits)) {\n    return [digits.slice(0, 4), digits.slice(4, 10), digits.slice(10, 15)].filter(Boolean).join(\" \");\n  }\n  return (digits.match(/.{1,4}/g) ?? []).join(\" \");\n}\n\nfunction formatExpiry(raw: string, prev: string) {\n  let digits = raw.replace(/\\D/g, \"\").slice(0, 4);\n  if (digits.length === 1 && digits > \"1\") digits = `0${digits}`;\n  if (digits.length < 2) return digits;\n  if (digits.length === 2) return raw.length < prev.length ? digits : `${digits}/`;\n  return `${digits.slice(0, 2)}/${digits.slice(2)}`;\n}\n\nfunction checkNumber(value: string) {\n  const digits = value.replace(/\\D/g, \"\");\n  if (!digits) return \"Enter your card number\";\n  const brand = detectPayCardBrand(digits);\n  if (digits.length < Math.min(...brand.lengths)) return \"Card number looks incomplete\";\n  if (!brand.lengths.includes(digits.length)) return \"Check the number of digits\";\n  if (!isLuhnValid(digits)) return \"This card number is not valid\";\n  return \"\";\n}\n\nfunction checkExpiry(value: string) {\n  const digits = value.replace(/\\D/g, \"\");\n  if (digits.length < 4) return \"Use the MM/YY format\";\n  const month = Number(digits.slice(0, 2));\n  const year = 2000 + Number(digits.slice(2));\n  if (month < 1 || month > 12) return \"Month must be 01 to 12\";\n  const now = new Date();\n  const thisYear = now.getFullYear();\n  const thisMonth = now.getMonth() + 1;\n  if (year < thisYear || (year === thisYear && month < thisMonth)) return \"This card has expired\";\n  if (year > thisYear + 20) return \"Check the expiry year\";\n  return \"\";\n}\n\nfunction checkCvc(value: string, brand: Brand) {\n  const digits = value.replace(/\\D/g, \"\");\n  if (digits.length !== brand.cvc) return `Enter the ${brand.cvc}-digit code`;\n  return \"\";\n}\n\nfunction checkName(value: string) {\n  return value.trim().length < 2 ? \"Enter the name on the card\" : \"\";\n}\n\nfunction Mark({ kind, className }: { kind: PayCardBrandId; className: string }) {\n  if (kind === \"none\") return null;\n  return (\n    <svg className={className} viewBox=\"0 0 56 38\" aria-hidden=\"true\">\n      {kind === \"twin\" && (\n        <>\n          <circle cx=\"20\" cy=\"19\" r=\"14\" fill=\"#fff\" fillOpacity=\"0.7\" />\n          <circle cx=\"36\" cy=\"19\" r=\"14\" fill=\"#fff\" fillOpacity=\"0.38\" />\n        </>\n      )}\n      {kind === \"tri\" && (\n        <>\n          <path d=\"M6 33 L16 5 H24 L14 33 Z\" fill=\"#fff\" fillOpacity=\"0.4\" />\n          <path d=\"M20 33 L30 5 H38 L28 33 Z\" fill=\"#fff\" fillOpacity=\"0.62\" />\n          <path d=\"M34 33 L44 5 H52 L42 33 Z\" fill=\"#fff\" fillOpacity=\"0.85\" />\n        </>\n      )}\n      {kind === \"arc\" && (\n        <>\n          <path d=\"M8 31 A22 22 0 0 1 48 31\" fill=\"none\" stroke=\"#fff\" strokeOpacity=\"0.45\" strokeWidth=\"5\" strokeLinecap=\"round\" />\n          <path d=\"M16 31 A14 14 0 0 1 40 31\" fill=\"none\" stroke=\"#fff\" strokeOpacity=\"0.85\" strokeWidth=\"5\" strokeLinecap=\"round\" />\n        </>\n      )}\n      {kind === \"ring\" && (\n        <>\n          <circle cx=\"28\" cy=\"19\" r=\"14\" fill=\"none\" stroke=\"#fff\" strokeOpacity=\"0.45\" strokeWidth=\"5\" />\n          <circle cx=\"28\" cy=\"19\" r=\"5\" fill=\"#fff\" fillOpacity=\"0.85\" />\n        </>\n      )}\n    </svg>\n  );\n}\n\ninterface CardFieldProps {\n  name: FieldName;\n  uid: string;\n  label: string;\n  error: string;\n  value: string;\n  ok?: boolean;\n  tail?: React.ReactNode;\n  inputRef: (el: HTMLInputElement | null) => void;\n  inputProps: React.InputHTMLAttributes<HTMLInputElement>;\n  format?: (raw: string) => string;\n  onValue: (name: FieldName, value: string) => void;\n  onFocus: (name: FieldName) => void;\n  onBlur: (name: FieldName) => void;\n}\n\nfunction CardField({ name, uid, label, error, value, ok, tail, inputRef, inputProps, format, onValue, onFocus, onBlur }: CardFieldProps) {\n  const id = `${uid}-${name}`;\n  const errorId = `${id}-e`;\n  return (\n    <div className=\"hb-qf2-field\" data-bad={Boolean(error)} data-ok={Boolean(ok)}>\n      <label className=\"hb-qf2-lab\" htmlFor={id}>\n        {label}\n      </label>\n      <div className=\"hb-qf2-ctl\">\n        <input\n          ref={inputRef}\n          id={id}\n          className=\"hb-qf2-in\"\n          aria-invalid={Boolean(error)}\n          aria-describedby={errorId}\n          value={value}\n          onChange={(e) => onValue(name, format ? format(e.target.value) : e.target.value)}\n          onFocus={() => onFocus(name)}\n          onBlur={() => onBlur(name)}\n          {...inputProps}\n        />\n        {tail}\n      </div>\n      <p id={errorId} className=\"hb-qf2-err\" aria-live=\"polite\">\n        <span>{error}</span>\n      </p>\n    </div>\n  );\n}\n\nexport function PayCardForm({\n  onSubmit,\n  onChange,\n  defaultValues,\n  showPreview = true,\n  submitLabel = \"Pay now\",\n  successLabel = \"Card accepted\",\n  theme = \"midnight\",\n  bank = \"Northvale\",\n  accent = \"#2f7bff\",\n  className = \"\",\n  style,\n  ...rest\n}: PayCardFormProps) {\n  const uid = React.useId();\n  const inputs = React.useRef<Record<FieldName, HTMLInputElement | null>>({ number: null, expiry: null, cvc: null, name: null });\n  const timer = React.useRef(0);\n  const [values, setValues] = React.useState({\n    number: formatNumber(defaultValues?.number ?? \"\"),\n    name: defaultValues?.name ?? \"\",\n    expiry: formatExpiry(defaultValues?.expiry ?? \"\", \"\"),\n    cvc: (defaultValues?.cvc ?? \"\").replace(/\\D/g, \"\").slice(0, 4),\n  });\n  const [errors, setErrors] = React.useState<Record<FieldName, string>>({ number: \"\", name: \"\", expiry: \"\", cvc: \"\" });\n  const [touched, setTouched] = React.useState<Record<FieldName, boolean>>({ number: false, name: false, expiry: false, cvc: false });\n  const [focused, setFocused] = React.useState<FieldName | null>(null);\n  const [done, setDone] = React.useState(false);\n\n  React.useEffect(() => () => window.clearTimeout(timer.current), []);\n\n  const digits = values.number.replace(/\\D/g, \"\");\n  const brand = detectPayCardBrand(digits);\n  const numberOk = brand.lengths.includes(digits.length) && isLuhnValid(digits);\n\n  function validate(field: FieldName, next: typeof values) {\n    const nextBrand = detectPayCardBrand(next.number.replace(/\\D/g, \"\"));\n    if (field === \"number\") return checkNumber(next.number);\n    if (field === \"expiry\") return checkExpiry(next.expiry);\n    if (field === \"cvc\") return checkCvc(next.cvc, nextBrand);\n    return checkName(next.name);\n  }\n\n  function emit(next: typeof values) {\n    const nextBrand = detectPayCardBrand(next.number.replace(/\\D/g, \"\"));\n    onChange?.({ ...next, number: next.number.replace(/\\D/g, \"\"), brand: nextBrand.id });\n  }\n\n  function update(field: FieldName, value: string) {\n    const next = { ...values, [field]: value };\n    setValues(next);\n    setDone(false);\n    if (touched[field] || errors[field]) setErrors((e) => ({ ...e, [field]: validate(field, next) }));\n    emit(next);\n    if (field === \"number\") {\n      const nextDigits = value.replace(/\\D/g, \"\");\n      const nextBrand = detectPayCardBrand(nextDigits);\n      if (nextBrand.id !== \"none\" && nextDigits.length === Math.max(...nextBrand.lengths) && isLuhnValid(nextDigits)) {\n        inputs.current.expiry?.focus();\n      }\n    }\n    if (field === \"expiry\" && value.replace(/\\D/g, \"\").length === 4 && !checkExpiry(value)) inputs.current.cvc?.focus();\n  }\n\n  function blur(field: FieldName) {\n    setFocused((f) => (f === field ? null : f));\n    setTouched((t) => ({ ...t, [field]: true }));\n    if (values[field]) setErrors((e) => ({ ...e, [field]: validate(field, values) }));\n  }\n\n  function submit(event: React.FormEvent<HTMLFormElement>) {\n    event.preventDefault();\n    const order: FieldName[] = [\"number\", \"expiry\", \"cvc\", \"name\"];\n    const next = { number: \"\", name: \"\", expiry: \"\", cvc: \"\" };\n    for (const f of order) next[f] = validate(f, values);\n    setErrors(next);\n    setTouched({ number: true, name: true, expiry: true, cvc: true });\n    const first = order.find((f) => next[f]);\n    if (first) {\n      inputs.current[first]?.focus();\n      return;\n    }\n    onSubmit?.({ ...values, number: digits, brand: brand.id });\n    setDone(true);\n    window.clearTimeout(timer.current);\n    timer.current = window.setTimeout(() => setDone(false), 2400);\n  }\n\n  const groups = (() => {\n    const len = brand.id === \"tri\" ? 15 : Math.max(16, digits.length);\n    const padded = digits.padEnd(len, \"•\");\n    if (brand.id === \"tri\") return [padded.slice(0, 4), padded.slice(4, 10), padded.slice(10, 15)];\n    return padded.match(/.{1,4}/g) ?? [];\n  })();\n  const cardName = values.name.trim().slice(0, 26);\n  const expiryDigits = values.expiry.replace(/\\D/g, \"\");\n  const slots = \"MM/YY\".split(\"\");\n  [0, 1, 3, 4].forEach((at, i) => {\n    if (i < expiryDigits.length) slots[at] = expiryDigits[i];\n  });\n\n  const vars = { \"--hb-qf2-x\": accent, ...style } as React.CSSProperties;\n\n  return (\n    <form\n      noValidate\n      className={`hb-qf2 ${className}`}\n      style={vars}\n      data-theme={theme}\n      data-flip={focused === \"cvc\"}\n      onSubmit={submit}\n      {...rest}\n    >\n      <style href=\"hb-pay-card-form\" precedence=\"default\">{css}</style>\n      <div className=\"hb-qf2-grid\">\n        {showPreview && (\n          <div className=\"hb-qf2-stage\" aria-hidden=\"true\">\n            <div className=\"hb-qf2-card\">\n              <div className=\"hb-qf2-face hb-qf2-front\">\n                <div className=\"hb-qf2-top\">\n                  <span className=\"hb-qf2-bank\">{bank}</span>\n                  <svg className=\"hb-qf2-nfc\" viewBox=\"0 0 24 24\">\n                    <path d=\"M6 9.5a4 4 0 0 1 0 5M9.5 7a8 8 0 0 1 0 10M13 4.5a12 12 0 0 1 0 15M16.5 2a16 16 0 0 1 0 20\" />\n                  </svg>\n                </div>\n                <span className=\"hb-qf2-chip\" />\n                <div className=\"hb-qf2-cf\" data-on={focused === \"number\"} data-empty={digits.length === 0}>\n                  <div className=\"hb-qf2-cnum\">\n                    {groups.map((g, i) => (\n                      <span key={i}>{g}</span>\n                    ))}\n                  </div>\n                </div>\n                <div className=\"hb-qf2-bot\">\n                  <div className=\"hb-qf2-meta\">\n                    <div className=\"hb-qf2-cf\" data-on={focused === \"name\"} data-empty={cardName.length === 0} style={{ flex: 1 }}>\n                      <span className=\"hb-qf2-clab\">Card holder</span>\n                      <span className=\"hb-qf2-cv\">{cardName || \"Full name\"}</span>\n                    </div>\n                    <div className=\"hb-qf2-cf\" data-on={focused === \"expiry\"} data-empty={expiryDigits.length === 0}>\n                      <span className=\"hb-qf2-clab\">Expires</span>\n                      <span className=\"hb-qf2-cv\">{slots.join(\"\")}</span>\n                    </div>\n                  </div>\n                  <Mark kind={brand.id === \"none\" ? \"arc\" : brand.id} className=\"hb-qf2-cmark\" />\n                </div>\n              </div>\n              <div className=\"hb-qf2-face hb-qf2-back\">\n                <div className=\"hb-qf2-stripe\" />\n                <div className=\"hb-qf2-sign\">\n                  <span className=\"hb-qf2-code\">{values.cvc || \"•\".repeat(brand.cvc)}</span>\n                </div>\n              </div>\n            </div>\n          </div>\n        )}\n        <div className=\"hb-qf2-fields\">\n          <CardField\n            name=\"number\"\n            uid={uid}\n            error={errors.number}\n            value={values.number}\n            onValue={update}\n            onFocus={setFocused}\n            onBlur={blur}\n            label=\"Card number\"\n            inputRef={(el) => { inputs.current.number = el; }}\n            ok={numberOk}\n            inputProps={{ type: \"text\", inputMode: \"numeric\", autoComplete: \"cc-number\", placeholder: \"4242 4242 4242 4242\", maxLength: 23 }}\n            format={formatNumber}\n            tail={\n              <span className=\"hb-qf2-tail\">\n                {numberOk && (\n                  <svg className=\"hb-qf2-tick\" viewBox=\"0 0 16 16\" aria-label=\"Valid number\">\n                    <path d=\"M3 8.5l3.2 3.2L13 4.8\" />\n                  </svg>\n                )}\n                {brand.id !== \"none\" && (\n                  <span style={{ display: \"inline-flex\" }} title={brand.label}>\n                    <Mark kind={brand.id} className=\"hb-qf2-mini\" />\n                  </span>\n                )}\n              </span>\n            }\n          />\n          <div className=\"hb-qf2-row\">\n            <CardField\n              name=\"expiry\"\n            uid={uid}\n            error={errors.expiry}\n            value={values.expiry}\n            onValue={update}\n            onFocus={setFocused}\n            onBlur={blur}\n              label=\"Expiry\"\n              inputRef={(el) => { inputs.current.expiry = el; }}\n              inputProps={{ type: \"text\", inputMode: \"numeric\", autoComplete: \"cc-exp\", placeholder: \"MM/YY\", maxLength: 5 }}\n              format={(v) => formatExpiry(v, values.expiry)}\n            />\n            <CardField\n              name=\"cvc\"\n            uid={uid}\n            error={errors.cvc}\n            value={values.cvc}\n            onValue={update}\n            onFocus={setFocused}\n            onBlur={blur}\n              label=\"CVC\"\n              inputRef={(el) => { inputs.current.cvc = el; }}\n              inputProps={{ type: \"text\", inputMode: \"numeric\", autoComplete: \"cc-csc\", placeholder: brand.cvc === 4 ? \"1234\" : \"123\", maxLength: 4 }}\n              format={(v) => v.replace(/\\D/g, \"\").slice(0, brand.cvc)}\n            />\n          </div>\n          <CardField\n            name=\"name\"\n            uid={uid}\n            error={errors.name}\n            value={values.name}\n            onValue={update}\n            onFocus={setFocused}\n            onBlur={blur}\n            label=\"Name on card\"\n            inputRef={(el) => { inputs.current.name = el; }}\n            inputProps={{ type: \"text\", autoComplete: \"cc-name\", placeholder: \"Alex Morgan\", maxLength: 40 }}\n          />\n          <button type=\"submit\" className=\"hb-qf2-go\" data-done={done}>\n            <span>{submitLabel}</span>\n            <span aria-live=\"polite\">{done ? successLabel : \"\"}</span>\n          </button>\n        </div>\n      </div>\n    </form>\n  );\n}\n"
    }
  ]
}