{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "contact-section",
  "title": "Contact Section",
  "description": "A contact section with a heading and your email, phone and address on the left, and a validated message form on the right: topic chips, a loading state driven by your onSubmit promise, inline errors and a thank-you screen.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/contact-section/contact-section.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, AnimatePresence, useReducedMotion } 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 ContactSubmitData {\n  name: string;\n  email: string;\n  /** The chosen topic, or \"\" when topics are hidden. */\n  topic: string;\n  message: string;\n}\n\nexport interface ContactChannel {\n  kind: \"email\" | \"phone\" | \"address\" | \"chat\";\n  label: string;\n  value: string;\n  href?: string;\n}\n\nexport interface ContactSectionProps {\n  eyebrow?: string;\n  title?: string;\n  description?: string;\n  /** Ways to reach you, listed under the description. Pass [] to hide them. */\n  channels?: ContactChannel[];\n  /** Topic chips above the message. Pass [] to hide them. */\n  topics?: string[];\n  /**\n   * Called with the form data. Return a promise: the button shows a spinner while it runs, a\n   * rejection (or a resolved string) is shown as an error, and success shows the thank-you screen.\n   */\n  onSubmit?: (data: ContactSubmitData) => void | string | Promise<void | string>;\n  submitLabel?: string;\n  successTitle?: string;\n  successText?: string;\n  minMessageLength?: number;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst DEFAULT_CHANNELS: ContactChannel[] = [\n  { kind: \"email\", label: \"Email\", value: \"hello@acme.com\", href: \"mailto:hello@acme.com\" },\n  { kind: \"phone\", label: \"Phone\", value: \"+1 (555) 010-2030\", href: \"tel:+15550102030\" },\n  { kind: \"address\", label: \"Office\", value: \"500 Market St, San Francisco, CA\" },\n];\n\nconst DEFAULT_TOPICS = [\"Sales\", \"Support\", \"Partnership\", \"Other\"];\n\nconst PALETTES = {\n  dark: {\n    text: \"#F5F4F1\",\n    muted: \"rgba(245,244,241,0.6)\",\n    faint: \"rgba(245,244,241,0.35)\",\n    panel: \"#0E0E0E\",\n    border: \"rgba(255,255,255,0.1)\",\n    field: \"rgba(255,255,255,0.03)\",\n    fieldBorder: \"rgba(255,255,255,0.12)\",\n    fieldHover: \"rgba(255,255,255,0.24)\",\n    focus: \"rgba(245,244,241,0.85)\",\n    chip: \"rgba(255,255,255,0.05)\",\n    chipOn: \"#F5F4F1\",\n    onChipOn: \"#0A0A0A\",\n    icon: \"rgba(255,255,255,0.06)\",\n    primary: \"#F5F4F1\",\n    onPrimary: \"#0A0A0A\",\n    error: \"#FF7A6B\",\n    ok: \"#3FBF7F\",\n  },\n  light: {\n    text: \"#0A0A0A\",\n    muted: \"rgba(10,10,10,0.6)\",\n    faint: \"rgba(10,10,10,0.35)\",\n    panel: \"#FFFFFF\",\n    border: \"rgba(10,10,10,0.1)\",\n    field: \"#FFFFFF\",\n    fieldBorder: \"rgba(10,10,10,0.16)\",\n    fieldHover: \"rgba(10,10,10,0.3)\",\n    focus: \"rgba(10,10,10,0.85)\",\n    chip: \"rgba(10,10,10,0.05)\",\n    chipOn: \"#0A0A0A\",\n    onChipOn: \"#FFFFFF\",\n    icon: \"rgba(10,10,10,0.05)\",\n    primary: \"#0A0A0A\",\n    onPrimary: \"#FFFFFF\",\n    error: \"#E5484D\",\n    ok: \"#1F9D5C\",\n  },\n};\n\ntype Palette = (typeof PALETTES)[\"dark\"];\n\nconst EMAIL_RE = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\nfunction ChannelIcon({ kind, color }: { kind: ContactChannel[\"kind\"]; color: string }) {\n  const common = { width: 18, height: 18, viewBox: \"0 0 24 24\", fill: \"none\", stroke: color, strokeWidth: 1.8, strokeLinecap: \"round\" as const, strokeLinejoin: \"round\" as const, \"aria-hidden\": true as const };\n  if (kind === \"email\")\n    return (\n      <svg {...common}>\n        <rect x=\"3\" y=\"5\" width=\"18\" height=\"14\" rx=\"2.5\" />\n        <path d=\"m3.8 7.2 7.1 5a1.9 1.9 0 0 0 2.2 0l7.1-5\" />\n      </svg>\n    );\n  if (kind === \"phone\")\n    return (\n      <svg {...common}>\n        <path d=\"M5 4h3l1.5 4-2 1.5a11 11 0 0 0 5 5l1.5-2 4 1.5v3a2 2 0 0 1-2 2A16 16 0 0 1 3 6a2 2 0 0 1 2-2Z\" />\n      </svg>\n    );\n  if (kind === \"chat\")\n    return (\n      <svg {...common}>\n        <path d=\"M4 5.5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-9l-4.5 3.5v-3.5H4a1 1 0 0 1-1-1v-10a1 1 0 0 1 1-1Z\" />\n      </svg>\n    );\n  return (\n    <svg {...common}>\n      <path d=\"M12 21s-7-6-7-11.5a7 7 0 0 1 14 0C19 15 12 21 12 21Z\" />\n      <circle cx=\"12\" cy=\"9.5\" r=\"2.5\" />\n    </svg>\n  );\n}\n\nfunction Spinner({ color }: { color: string }) {\n  return (\n    <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" aria-hidden=\"true\" style={{ animation: \"contact-section-spin 0.7s linear infinite\" }}>\n      <circle cx=\"12\" cy=\"12\" r=\"9\" stroke={color} strokeOpacity=\"0.25\" strokeWidth=\"2.5\" />\n      <path d=\"M21 12a9 9 0 0 0-9-9\" stroke={color} strokeWidth=\"2.5\" strokeLinecap=\"round\" />\n      <style>{\"@keyframes contact-section-spin { to { transform: rotate(360deg); } }\"}</style>\n    </svg>\n  );\n}\n\ninterface FieldProps {\n  id: string;\n  label: string;\n  error?: string;\n  p: Palette;\n  children: (props: { \"aria-invalid\": boolean; \"aria-describedby\"?: string; style: React.CSSProperties; className: string }) => React.ReactNode;\n}\n\nfunction Field({ id, label, error, p, children }: FieldProps) {\n  const [hover, setHover] = React.useState(false);\n  return (\n    <div className=\"flex flex-col gap-1.5\" onMouseEnter={() => setHover(true)} onMouseLeave={() => setHover(false)}>\n      <label htmlFor={id} className=\"text-sm font-medium\" style={{ color: p.text }}>\n        {label}\n      </label>\n      {children({\n        \"aria-invalid\": !!error,\n        \"aria-describedby\": error ? `${id}-error` : undefined,\n        className: \"w-full rounded-xl px-3.5 text-[15px] outline-none transition-[border-color,box-shadow] duration-150 focus:shadow-[0_0_0_3px_rgba(127,127,127,0.18)]\",\n        style: { background: p.field, color: p.text, border: `1px solid ${error ? p.error : hover ? p.fieldHover : p.fieldBorder}` },\n      })}\n      <AnimatePresence initial={false}>\n        {error && (\n          <motion.p id={`${id}-error`} initial={{ opacity: 0, height: 0 }} animate={{ opacity: 1, height: \"auto\" }} exit={{ opacity: 0, height: 0 }} className=\"text-xs\" style={{ color: p.error }}>\n            {error}\n          </motion.p>\n        )}\n      </AnimatePresence>\n    </div>\n  );\n}\n\nexport function ContactSection({\n  eyebrow = \"Contact\",\n  title = \"Let's talk\",\n  description = \"Questions about pricing, a partnership or anything else? Send us a message and we'll get back to you within one business day.\",\n  channels = DEFAULT_CHANNELS,\n  topics = DEFAULT_TOPICS,\n  onSubmit,\n  submitLabel = \"Send message\",\n  successTitle = \"Message sent\",\n  successText = \"Thanks for reaching out. We'll reply to your email within one business day.\",\n  minMessageLength = 10,\n  theme = \"dark\",\n  className,\n}: ContactSectionProps) {\n  const p = PALETTES[theme];\n  const reduce = useReducedMotion();\n  const uid = React.useId();\n\n  const [name, setName] = React.useState(\"\");\n  const [email, setEmail] = React.useState(\"\");\n  const [topic, setTopic] = React.useState(topics[0] ?? \"\");\n  const [message, setMessage] = React.useState(\"\");\n  const [touched, setTouched] = React.useState<Record<string, boolean>>({});\n  const [submitted, setSubmitted] = React.useState(false);\n  const [loading, setLoading] = React.useState(false);\n  const [formError, setFormError] = React.useState(\"\");\n  const [done, setDone] = React.useState(false);\n\n  const errors: Record<string, string> = {};\n  if (!name.trim()) errors.name = \"Please enter your name.\";\n  if (!email.trim()) errors.email = \"Please enter your email.\";\n  else if (!EMAIL_RE.test(email.trim())) errors.email = \"That email doesn't look right.\";\n  if (message.trim().length < minMessageLength) errors.message = message.trim() ? `Please write at least ${minMessageLength} characters.` : \"Please write a message.\";\n  const shown = (k: string) => (submitted || touched[k] ? errors[k] : undefined);\n  const blur = (k: string) => () => setTouched((t) => ({ ...t, [k]: true }));\n\n  const submit = async (e: React.FormEvent) => {\n    e.preventDefault();\n    setSubmitted(true);\n    setFormError(\"\");\n    if (Object.keys(errors).length) return;\n    setLoading(true);\n    try {\n      const res = await onSubmit?.({ name: name.trim(), email: email.trim(), topic, message: message.trim() });\n      if (typeof res === \"string\" && res) setFormError(res);\n      else setDone(true);\n    } catch (err) {\n      setFormError(err instanceof Error ? err.message : \"Something went wrong. Please try again.\");\n    } finally {\n      setLoading(false);\n    }\n  };\n\n  const reset = () => {\n    setName(\"\");\n    setEmail(\"\");\n    setMessage(\"\");\n    setTopic(topics[0] ?? \"\");\n    setTouched({});\n    setSubmitted(false);\n    setDone(false);\n  };\n\n  const fade = reduce ? { duration: 0 } : { duration: 0.3, ease: [0.22, 1, 0.36, 1] as const };\n\n  return (\n    <section className={cn(\"w-full\", className)} style={{ color: p.text }}>\n      <div className=\"grid grid-cols-1 gap-10 lg:grid-cols-[minmax(0,1fr)_minmax(0,1.2fr)] lg:gap-16\">\n        <div>\n          {eyebrow && (\n            <span className=\"text-xs font-semibold uppercase tracking-[0.14em]\" style={{ color: p.faint }}>\n              {eyebrow}\n            </span>\n          )}\n          <h2 className=\"mt-3 text-3xl font-semibold leading-tight tracking-tight sm:text-4xl\">{title}</h2>\n          {description && (\n            <p className=\"mt-4 max-w-md text-[15px] leading-6\" style={{ color: p.muted }}>\n              {description}\n            </p>\n          )}\n          {channels.length > 0 && (\n            <ul className=\"mt-8 flex flex-col gap-4\">\n              {channels.map((c) => {\n                const body = (\n                  <>\n                    <span className=\"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl\" style={{ background: p.icon }}>\n                      <ChannelIcon kind={c.kind} color={p.text} />\n                    </span>\n                    <span className=\"flex min-w-0 flex-col\">\n                      <span className=\"text-xs\" style={{ color: p.faint }}>\n                        {c.label}\n                      </span>\n                      <span className=\"truncate text-[15px] font-medium\">{c.value}</span>\n                    </span>\n                  </>\n                );\n                return (\n                  <li key={c.label}>\n                    {c.href ? (\n                      <a href={c.href} className=\"flex items-center gap-3 rounded-xl outline-none transition-opacity hover:opacity-80 focus-visible:ring-2\">\n                        {body}\n                      </a>\n                    ) : (\n                      <div className=\"flex items-center gap-3\">{body}</div>\n                    )}\n                  </li>\n                );\n              })}\n            </ul>\n          )}\n        </div>\n\n        <div className=\"relative rounded-2xl p-6 sm:p-8\" style={{ background: p.panel, border: `1px solid ${p.border}` }}>\n          <AnimatePresence mode=\"wait\" initial={false}>\n            {done ? (\n              <motion.div key=\"done\" initial={{ opacity: 0, y: 8 }} animate={{ opacity: 1, y: 0 }} exit={{ opacity: 0, y: -8 }} transition={fade} className=\"flex min-h-[420px] flex-col items-center justify-center text-center\" role=\"status\">\n                <motion.span\n                  initial={reduce ? false : { scale: 0.6, opacity: 0 }}\n                  animate={{ scale: 1, opacity: 1 }}\n                  transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 300, damping: 18, delay: 0.05 }}\n                  className=\"flex h-14 w-14 items-center justify-center rounded-full\"\n                  style={{ background: p.icon }}\n                >\n                  <svg width=\"26\" height=\"26\" viewBox=\"0 0 24 24\" fill=\"none\" stroke={p.ok} strokeWidth={2.4} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                    <path d=\"m5 12.5 4.5 4.5L19 7.5\" />\n                  </svg>\n                </motion.span>\n                <h3 className=\"mt-5 text-xl font-semibold\">{successTitle}</h3>\n                <p className=\"mt-2 max-w-xs text-sm leading-6\" style={{ color: p.muted }}>\n                  {successText}\n                </p>\n                <button type=\"button\" onClick={reset} className=\"mt-6 text-sm font-medium underline-offset-4 outline-none hover:underline focus-visible:ring-2\" style={{ color: p.text }}>\n                  Send another message\n                </button>\n              </motion.div>\n            ) : (\n              <motion.form key=\"form\" noValidate onSubmit={submit} initial={{ opacity: 0, y: 8 }} animate={{ opacity: 1, y: 0 }} exit={{ opacity: 0, y: -8 }} transition={fade} className=\"flex flex-col gap-5\">\n                <div className=\"grid grid-cols-1 gap-5 sm:grid-cols-2\">\n                  <Field id={`${uid}-name`} label=\"Name\" error={shown(\"name\")} p={p}>\n                    {(f) => <input id={`${uid}-name`} type=\"text\" autoComplete=\"name\" placeholder=\"Ada Lovelace\" value={name} onChange={(e) => setName(e.target.value)} onBlur={blur(\"name\")} disabled={loading} {...f} className={cn(f.className, \"h-11\")} />}\n                  </Field>\n                  <Field id={`${uid}-email`} label=\"Email\" error={shown(\"email\")} p={p}>\n                    {(f) => <input id={`${uid}-email`} type=\"email\" autoComplete=\"email\" placeholder=\"you@company.com\" value={email} onChange={(e) => setEmail(e.target.value)} onBlur={blur(\"email\")} disabled={loading} {...f} className={cn(f.className, \"h-11\")} />}\n                  </Field>\n                </div>\n\n                {topics.length > 0 && (\n                  <fieldset className=\"flex flex-col gap-2\">\n                    <legend className=\"mb-2 text-sm font-medium\">What can we help with?</legend>\n                    <div className=\"flex flex-wrap gap-2\">\n                      {topics.map((t) => {\n                        const on = topic === t;\n                        return (\n                          <label key={t} className=\"relative cursor-pointer\">\n                            <input type=\"radio\" name={`${uid}-topic`} value={t} checked={on} onChange={() => setTopic(t)} disabled={loading} className=\"peer sr-only\" />\n                            <span\n                              className=\"inline-flex h-9 items-center rounded-full px-4 text-sm font-medium transition-colors peer-focus-visible:ring-2\"\n                              style={{ background: on ? p.chipOn : p.chip, color: on ? p.onChipOn : p.muted }}\n                            >\n                              {t}\n                            </span>\n                          </label>\n                        );\n                      })}\n                    </div>\n                  </fieldset>\n                )}\n\n                <Field id={`${uid}-message`} label=\"Message\" error={shown(\"message\")} p={p}>\n                  {(f) => (\n                    <textarea\n                      id={`${uid}-message`}\n                      rows={5}\n                      placeholder=\"Tell us a little about what you need...\"\n                      value={message}\n                      onChange={(e) => setMessage(e.target.value)}\n                      onBlur={blur(\"message\")}\n                      disabled={loading}\n                      {...f}\n                      className={cn(f.className, \"resize-none py-3 leading-6\")}\n                    />\n                  )}\n                </Field>\n\n                <AnimatePresence initial={false}>\n                  {formError && (\n                    <motion.div\n                      role=\"alert\"\n                      initial={{ opacity: 0, height: 0 }}\n                      animate={{ opacity: 1, height: \"auto\" }}\n                      exit={{ opacity: 0, height: 0 }}\n                      className=\"overflow-hidden rounded-xl px-3.5 py-2.5 text-sm\"\n                      style={{ color: p.error, background: theme === \"dark\" ? \"rgba(255,122,107,0.08)\" : \"rgba(229,72,77,0.07)\", border: `1px solid ${p.error}33` }}\n                    >\n                      {formError}\n                    </motion.div>\n                  )}\n                </AnimatePresence>\n\n                <button\n                  type=\"submit\"\n                  disabled={loading}\n                  className=\"flex h-11 items-center justify-center gap-2 rounded-xl text-sm font-semibold outline-none transition-[filter,opacity] hover:brightness-110 focus-visible:ring-2 disabled:opacity-80\"\n                  style={{ background: p.primary, color: p.onPrimary }}\n                >\n                  {loading && <Spinner color={p.onPrimary} />}\n                  {loading ? \"Sending...\" : submitLabel}\n                </button>\n              </motion.form>\n            )}\n          </AnimatePresence>\n        </div>\n      </div>\n    </section>\n  );\n}\n\nexport default ContactSection;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}