{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "profile-settings-card",
  "type": "registry:component",
  "title": "Profile Settings Card",
  "description": "A light settings page with a section nav and a profile card: avatar color swatches tint the cover, fields validate inline, edited fields get a dot, and a footer tracks unsaved changes with reset, saving and saved states.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "profile",
    "profile",
    "settings",
    "form",
    "validation",
    "save state",
    "section"
  ],
  "docs": "https://hyperblur.dev/effects/profile-settings-card",
  "files": [
    {
      "path": "registry/hyperblur/profile-settings-card.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/profile-settings-card.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ProfileSettingsValues {\n  name: string;\n  username: string;\n  email: string;\n  bio: string;\n  location: string;\n  website: string;\n  color: string;\n}\n\nexport interface ProfileSettingsCardProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\" | \"defaultValue\"> {\n  title?: string;\n  subtitle?: string;\n  defaultValues?: Partial<ProfileSettingsValues>;\n  colors?: string[];\n  bioLimit?: number;\n  sections?: string[];\n  onSave?: (values: ProfileSettingsValues) => void | Promise<void>;\n  accent?: string;\n}\n\nconst baseValues: ProfileSettingsValues = {\n  name: \"Camille Durand\",\n  username: \"camille\",\n  email: \"camille@fieldnotes.app\",\n  bio: \"Product designer at Fieldnotes. Making research tools that feel like a good notebook.\",\n  location: \"Lyon, France\",\n  website: \"https://camille.design\",\n  color: \"#2f7bff\",\n};\n\nconst defaultColors = [\"#2f7bff\", \"#7c3aed\", \"#e11d74\", \"#f97316\", \"#10b981\", \"#0f172a\"];\n\nconst css = `\n@keyframes hb-yg9-bar {\n  from { opacity: 0; transform: translateY(16px); }\n  to { opacity: 1; transform: none; }\n}\n@keyframes hb-yg9-spin { to { transform: rotate(360deg); } }\n@keyframes hb-yg9-draw { to { stroke-dashoffset: 0; } }\n@keyframes hb-yg9-in {\n  from { opacity: 0; transform: translateY(14px); }\n  to { opacity: 1; transform: none; }\n}\n.hb-yg9 {\n  --hb-yg9-accent: #2f7bff;\n  --hb-yg9-ink: #14161b;\n  --hb-yg9-muted: #697080;\n  --hb-yg9-line: rgba(20, 22, 27, 0.1);\n  position: relative;\n  box-sizing: border-box;\n  width: 100%;\n  overflow: hidden;\n  container-type: inline-size;\n  background: #f7f5ef;\n  color: var(--hb-yg9-ink);\n  font-family: inherit;\n  -webkit-font-smoothing: antialiased;\n}\n.hb-yg9 *, .hb-yg9 *::before, .hb-yg9 *::after { box-sizing: border-box; }\n.hb-yg9-in {\n  display: grid;\n  gap: 28px;\n  max-width: 1120px;\n  margin: 0 auto;\n  padding: 72px 24px 88px;\n}\n@container (min-width: 860px) {\n  .hb-yg9-in { grid-template-columns: 240px 1fr; gap: 48px; }\n}\n.hb-yg9-title { margin: 0; font-size: 30px; font-weight: 650; letter-spacing: -0.035em; }\n.hb-yg9-sub { margin: 8px 0 0; color: var(--hb-yg9-muted); font-size: 14.5px; line-height: 1.55; }\n.hb-yg9-nav { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 22px; }\n@container (min-width: 860px) {\n  .hb-yg9-nav { flex-direction: column; }\n}\n.hb-yg9-tab {\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  height: 36px;\n  padding: 0 12px;\n  border: 0;\n  border-radius: 10px;\n  background: none;\n  color: var(--hb-yg9-muted);\n  font: inherit;\n  font-size: 14px;\n  font-weight: 500;\n  text-align: left;\n  cursor: pointer;\n  transition: background 0.2s ease, color 0.2s ease;\n}\n.hb-yg9-tab:hover { background: rgba(20, 22, 27, 0.05); color: var(--hb-yg9-ink); }\n.hb-yg9-tab[aria-current=\"page\"] { background: #fff; color: var(--hb-yg9-ink); box-shadow: 0 1px 2px rgba(20, 22, 27, 0.06), inset 0 0 0 1px var(--hb-yg9-line); }\n.hb-yg9-tab:focus-visible { outline: 2px solid var(--hb-yg9-accent); outline-offset: 2px; }\n.hb-yg9-card {\n  position: relative;\n  overflow: hidden;\n  border: 1px solid var(--hb-yg9-line);\n  border-radius: 20px;\n  background: #fff;\n  box-shadow: 0 1px 2px rgba(20, 22, 27, 0.04), 0 30px 60px -40px rgba(20, 22, 27, 0.3);\n  animation: hb-yg9-in 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;\n}\n.hb-yg9-cover {\n  height: 96px;\n  background:\n    radial-gradient(60% 120% at 20% 0%, color-mix(in srgb, var(--hb-yg9-c) 55%, #fff), transparent 70%),\n    radial-gradient(60% 120% at 90% 100%, color-mix(in srgb, var(--hb-yg9-c) 30%, #fff), transparent 70%),\n    color-mix(in srgb, var(--hb-yg9-c) 12%, #fff);\n  transition: background 0.4s ease;\n}\n.hb-yg9-head {\n  display: flex;\n  flex-wrap: wrap;\n  align-items: flex-end;\n  gap: 16px 20px;\n  margin-top: -40px;\n  padding: 0 28px;\n}\n.hb-yg9-avatar {\n  display: grid;\n  place-items: center;\n  width: 84px;\n  height: 84px;\n  border: 4px solid #fff;\n  border-radius: 50%;\n  background: linear-gradient(140deg, color-mix(in srgb, var(--hb-yg9-c) 70%, #fff), var(--hb-yg9-c));\n  box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--hb-yg9-c) 60%, transparent);\n  color: #fff;\n  font-size: 28px;\n  font-weight: 650;\n  letter-spacing: -0.03em;\n  transition: background 0.4s ease;\n}\n.hb-yg9-swatches { display: flex; gap: 8px; padding-bottom: 6px; }\n.hb-yg9-swatch {\n  width: 24px;\n  height: 24px;\n  padding: 0;\n  border: 2px solid #fff;\n  border-radius: 50%;\n  background: var(--hb-yg9-s);\n  box-shadow: 0 0 0 1px var(--hb-yg9-line);\n  cursor: pointer;\n  transition: transform 0.2s ease, box-shadow 0.2s ease;\n}\n.hb-yg9-swatch:hover { transform: scale(1.12); }\n.hb-yg9-swatch[aria-checked=\"true\"] { box-shadow: 0 0 0 2px var(--hb-yg9-s); }\n.hb-yg9-swatch:focus-visible { outline: 2px solid var(--hb-yg9-accent); outline-offset: 3px; }\n.hb-yg9-form { padding: 24px 28px 28px; }\n.hb-yg9-grid { display: grid; gap: 4px 16px; }\n@container (min-width: 620px) {\n  .hb-yg9-grid { grid-template-columns: 1fr 1fr; }\n  .hb-yg9-wide { grid-column: 1 / -1; }\n}\n.hb-yg9-field label {\n  display: flex;\n  align-items: center;\n  gap: 6px;\n  margin-bottom: 6px;\n  color: #3b3f4a;\n  font-size: 13px;\n  font-weight: 600;\n}\n.hb-yg9-dirty { width: 6px; height: 6px; border-radius: 50%; background: var(--hb-yg9-accent); }\n.hb-yg9-wrap {\n  display: flex;\n  align-items: center;\n  border: 1px solid rgba(20, 22, 27, 0.14);\n  border-radius: 11px;\n  background: #fff;\n  box-shadow: 0 1px 2px rgba(20, 22, 27, 0.04);\n  transition: border-color 0.2s ease, box-shadow 0.2s ease;\n}\n.hb-yg9-wrap:focus-within { border-color: var(--hb-yg9-accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--hb-yg9-accent) 14%, transparent); }\n.hb-yg9-wrap[data-invalid=\"true\"] { border-color: #e5484d; }\n.hb-yg9-prefix { padding-left: 12px; color: var(--hb-yg9-muted); font-size: 14px; }\n.hb-yg9-input {\n  flex: 1;\n  width: 100%;\n  min-width: 0;\n  height: 42px;\n  padding: 0 12px;\n  border: 0;\n  background: none;\n  color: var(--hb-yg9-ink);\n  font: inherit;\n  font-size: 14.5px;\n  outline: none;\n}\n.hb-yg9-prefix + .hb-yg9-input { padding-left: 2px; }\ntextarea.hb-yg9-input { height: 84px; padding: 10px 12px; line-height: 1.5; resize: vertical; }\n.hb-yg9-hint { display: flex; justify-content: space-between; gap: 8px; min-height: 18px; margin: 5px 0 6px; color: var(--hb-yg9-muted); font-size: 12px; }\n.hb-yg9-hint [data-error] { color: #d93036; }\n.hb-yg9-hint [data-over=\"true\"] { color: #d93036; font-weight: 600; }\n.hb-yg9-foot {\n  display: flex;\n  flex-wrap: wrap;\n  align-items: center;\n  justify-content: space-between;\n  gap: 12px;\n  margin-top: 12px;\n  padding-top: 18px;\n  border-top: 1px solid var(--hb-yg9-line);\n}\n.hb-yg9-state { display: inline-flex; align-items: center; gap: 8px; color: var(--hb-yg9-muted); font-size: 13.5px; }\n.hb-yg9-state[data-tone=\"dirty\"] { animation: hb-yg9-bar 0.35s ease both; color: var(--hb-yg9-ink); }\n.hb-yg9-state[data-tone=\"saved\"] { color: #15803d; animation: hb-yg9-bar 0.35s ease both; }\n.hb-yg9-state svg path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: hb-yg9-draw 0.4s 0.1s ease forwards; }\n.hb-yg9-actions { display: flex; gap: 8px; }\n.hb-yg9-btn {\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  gap: 8px;\n  height: 38px;\n  padding: 0 16px;\n  border: 1px solid rgba(20, 22, 27, 0.14);\n  border-radius: 10px;\n  background: #fff;\n  color: var(--hb-yg9-ink);\n  font: inherit;\n  font-size: 14px;\n  font-weight: 600;\n  cursor: pointer;\n  transition: background 0.2s ease, opacity 0.2s ease, transform 0.15s ease;\n}\n.hb-yg9-btn:hover:not(:disabled) { background: #f4f4f5; }\n.hb-yg9-btn:active:not(:disabled) { transform: scale(0.97); }\n.hb-yg9-btn:disabled { opacity: 0.45; cursor: default; }\n.hb-yg9-btn:focus-visible { outline: 2px solid var(--hb-yg9-accent); outline-offset: 2px; }\n.hb-yg9-primary { min-width: 120px; border-color: transparent; background: var(--hb-yg9-ink); color: #fff; }\n.hb-yg9-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--hb-yg9-accent) 35%, var(--hb-yg9-ink)); }\n.hb-yg9-spin { width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, 0.3); border-top-color: #fff; border-radius: 50%; animation: hb-yg9-spin 0.7s linear infinite; }\n@media (prefers-reduced-motion: reduce) {\n  .hb-yg9-card, .hb-yg9-state, .hb-yg9-state svg path, .hb-yg9-spin { animation: none; }\n  .hb-yg9-state svg path { stroke-dashoffset: 0; }\n  .hb-yg9-cover, .hb-yg9-avatar, .hb-yg9-swatch, .hb-yg9-wrap, .hb-yg9-btn, .hb-yg9-tab { transition: none; }\n}\n`;\n\ntype Errors = Partial<Record<keyof ProfileSettingsValues, string>>;\n\nfunction validate(v: ProfileSettingsValues, bioLimit: number): Errors {\n  const e: Errors = {};\n  if (v.name.trim().length < 2) e.name = \"Name is too short.\";\n  if (!/^[a-z0-9_]{3,20}$/.test(v.username)) e.username = \"3 to 20 lowercase letters, numbers or _.\";\n  if (!/^[^\\s@]+@[^\\s@]+\\.[^\\s@]{2,}$/.test(v.email.trim())) e.email = \"Enter a valid email.\";\n  if (v.bio.length > bioLimit) e.bio = \"Bio is too long.\";\n  if (v.website && !/^https?:\\/\\/[^\\s.]+\\.[^\\s]{2,}$/.test(v.website.trim())) e.website = \"Start with https:// and include a domain.\";\n  return e;\n}\n\nfunction initials(name: string) {\n  return name.trim().split(/\\s+/).map((p) => p[0] ?? \"\").slice(0, 2).join(\"\").toUpperCase() || \"?\";\n}\n\nexport function ProfileSettingsCard({\n  title = \"Settings\",\n  subtitle = \"Manage how you appear to teammates and on shared notebooks.\",\n  defaultValues,\n  colors = defaultColors,\n  bioLimit = 160,\n  sections = [\"Profile\", \"Account\", \"Notifications\", \"Billing\"],\n  onSave,\n  accent = \"#2f7bff\",\n  className = \"\",\n  style,\n  ...rest\n}: ProfileSettingsCardProps) {\n  const id = React.useId();\n  const initial = React.useMemo(() => ({ ...baseValues, ...defaultValues }), [defaultValues]);\n  const [saved, setSaved] = React.useState<ProfileSettingsValues>(initial);\n  const [values, setValues] = React.useState<ProfileSettingsValues>(initial);\n  const [errors, setErrors] = React.useState<Errors>({});\n  const [status, setStatus] = React.useState<\"idle\" | \"saving\" | \"saved\">(\"idle\");\n  const [section, setSection] = React.useState(sections[0] ?? \"Profile\");\n\n  const keys = Object.keys(values) as (keyof ProfileSettingsValues)[];\n  const dirtyKeys = keys.filter((k) => values[k] !== saved[k]);\n  const dirty = dirtyKeys.length > 0;\n\n  React.useEffect(() => {\n    if (status !== \"saved\") return;\n    const t = window.setTimeout(() => setStatus(\"idle\"), 2400);\n    return () => window.clearTimeout(t);\n  }, [status]);\n\n  const set = (k: keyof ProfileSettingsValues, v: string) => {\n    setValues((prev) => ({ ...prev, [k]: v }));\n    if (errors[k]) setErrors((prev) => ({ ...prev, [k]: undefined }));\n    if (status === \"saved\") setStatus(\"idle\");\n  };\n\n  const submit = async (e: React.FormEvent) => {\n    e.preventDefault();\n    const next = validate(values, bioLimit);\n    setErrors(next);\n    if (Object.keys(next).length) return;\n    setStatus(\"saving\");\n    const clean = { ...values, name: values.name.trim(), email: values.email.trim(), website: values.website.trim() };\n    try {\n      await Promise.all([onSave?.(clean), new Promise((r) => setTimeout(r, 900))]);\n      setSaved(clean);\n      setValues(clean);\n      setStatus(\"saved\");\n    } catch {\n      setStatus(\"idle\");\n    }\n  };\n\n  const reset = () => {\n    setValues(saved);\n    setErrors({});\n  };\n\n  const field = (k: keyof ProfileSettingsValues, label: string, opts: { type?: string; prefix?: string; wide?: boolean; auto?: string; placeholder?: string } = {}) => (\n    <div className={`hb-yg9-field ${opts.wide ? \"hb-yg9-wide\" : \"\"}`}>\n      <label htmlFor={`${id}-${k}`}>\n        {label}\n        {dirtyKeys.includes(k) && <span className=\"hb-yg9-dirty\" aria-label=\"edited\" />}\n      </label>\n      <div className=\"hb-yg9-wrap\" data-invalid={errors[k] ? \"true\" : undefined}>\n        {opts.prefix && <span className=\"hb-yg9-prefix\" aria-hidden=\"true\">{opts.prefix}</span>}\n        <input\n          id={`${id}-${k}`}\n          className=\"hb-yg9-input\"\n          type={opts.type ?? \"text\"}\n          autoComplete={opts.auto}\n          placeholder={opts.placeholder}\n          value={values[k]}\n          onChange={(e) => set(k, k === \"username\" ? e.target.value.toLowerCase() : e.target.value)}\n          aria-invalid={errors[k] ? true : undefined}\n          aria-describedby={`${id}-${k}-hint`}\n          disabled={status === \"saving\"}\n        />\n      </div>\n      <div className=\"hb-yg9-hint\" id={`${id}-${k}-hint`}>\n        {errors[k] ? <span data-error=\"\">{errors[k]}</span> : <span>{k === \"username\" ? `fieldnotes.app/@${values.username || \"you\"}` : \"\"}</span>}\n      </div>\n    </div>\n  );\n\n  return (\n    <section className={`hb-yg9 ${className}`} style={{ \"--hb-yg9-accent\": accent, \"--hb-yg9-c\": values.color, ...style } as React.CSSProperties} {...rest}>\n      <style href=\"hb-profile-settings-card\" precedence=\"default\">{css}</style>\n      <div className=\"hb-yg9-in\">\n        <div>\n          <h2 className=\"hb-yg9-title\">{title}</h2>\n          <p className=\"hb-yg9-sub\">{subtitle}</p>\n          <nav className=\"hb-yg9-nav\" aria-label=\"Settings sections\">\n            {sections.map((s) => (\n              <button key={s} type=\"button\" className=\"hb-yg9-tab\" aria-current={s === section ? \"page\" : undefined} onClick={() => setSection(s)}>\n                {s}\n              </button>\n            ))}\n          </nav>\n        </div>\n        <div className=\"hb-yg9-card\">\n          <div className=\"hb-yg9-cover\" aria-hidden=\"true\" />\n          <div className=\"hb-yg9-head\">\n            <span className=\"hb-yg9-avatar\" aria-hidden=\"true\">{initials(values.name)}</span>\n            <div className=\"hb-yg9-swatches\" role=\"radiogroup\" aria-label=\"Avatar color\">\n              {colors.map((c) => (\n                <button\n                  key={c}\n                  type=\"button\"\n                  role=\"radio\"\n                  className=\"hb-yg9-swatch\"\n                  aria-checked={values.color === c}\n                  aria-label={`Color ${c}`}\n                  style={{ \"--hb-yg9-s\": c } as React.CSSProperties}\n                  onClick={() => set(\"color\", c)}\n                />\n              ))}\n            </div>\n          </div>\n          <form className=\"hb-yg9-form\" onSubmit={submit} noValidate>\n            <div className=\"hb-yg9-grid\">\n              {field(\"name\", \"Full name\", { auto: \"name\" })}\n              {field(\"username\", \"Username\", { prefix: \"@\", auto: \"username\" })}\n              {field(\"email\", \"Email\", { type: \"email\", auto: \"email\" })}\n              {field(\"location\", \"Location\", { auto: \"address-level2\" })}\n              <div className=\"hb-yg9-field hb-yg9-wide\">\n                <label htmlFor={`${id}-bio`}>\n                  Bio\n                  {dirtyKeys.includes(\"bio\") && <span className=\"hb-yg9-dirty\" aria-label=\"edited\" />}\n                </label>\n                <div className=\"hb-yg9-wrap\" data-invalid={errors.bio || values.bio.length > bioLimit ? \"true\" : undefined}>\n                  <textarea\n                    id={`${id}-bio`}\n                    className=\"hb-yg9-input\"\n                    value={values.bio}\n                    onChange={(e) => set(\"bio\", e.target.value)}\n                    aria-invalid={errors.bio ? true : undefined}\n                    aria-describedby={`${id}-bio-hint`}\n                    disabled={status === \"saving\"}\n                  />\n                </div>\n                <div className=\"hb-yg9-hint\" id={`${id}-bio-hint`}>\n                  {errors.bio ? <span data-error=\"\">{errors.bio}</span> : <span>Shown on your public profile.</span>}\n                  <span data-over={values.bio.length > bioLimit}>{values.bio.length}/{bioLimit}</span>\n                </div>\n              </div>\n              {field(\"website\", \"Website\", { type: \"url\", wide: true, auto: \"url\", placeholder: \"https://\" })}\n            </div>\n            <div className=\"hb-yg9-foot\">\n              {status === \"saved\" ? (\n                <span className=\"hb-yg9-state\" data-tone=\"saved\" role=\"status\">\n                  <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path d=\"M5 12.5l4.5 4.5L19 7.5\" /></svg>\n                  Changes saved\n                </span>\n              ) : dirty ? (\n                <span className=\"hb-yg9-state\" data-tone=\"dirty\" role=\"status\">\n                  {dirtyKeys.length} unsaved {dirtyKeys.length === 1 ? \"change\" : \"changes\"}\n                </span>\n              ) : (\n                <span className=\"hb-yg9-state\">Last updated 3 days ago</span>\n              )}\n              <div className=\"hb-yg9-actions\">\n                <button type=\"button\" className=\"hb-yg9-btn\" onClick={reset} disabled={!dirty || status === \"saving\"}>Reset</button>\n                <button type=\"submit\" className=\"hb-yg9-btn hb-yg9-primary\" disabled={!dirty || status === \"saving\"}>\n                  {status === \"saving\" ? <><span className=\"hb-yg9-spin\" aria-hidden=\"true\" />Saving</> : \"Save changes\"}\n                </button>\n              </div>\n            </div>\n          </form>\n        </div>\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}