{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "profile-settings",
  "title": "Profile settings",
  "description": "Cover-art profile card with avatar upload, live handle availability check, time zone and locale pickers with a format preview, and a sticky unsaved-changes bar.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "https://goodui.dev/r/button.json",
    "https://goodui.dev/r/input.json",
    "https://goodui.dev/r/select.json",
    "label",
    "textarea"
  ],
  "files": [
    {
      "path": "registry/blocks/settings/profile-settings.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { AtSign, Camera, Check, Globe, Loader2, Trash2, X } from \"lucide-react\"\nimport { Label } from \"@/components/ui/label\"\nimport { Textarea } from \"@/components/ui/textarea\"\nimport { Button } from \"@/components/goodui/button\"\nimport { Input } from \"@/components/goodui/input\"\nimport { Select } from \"@/components/goodui/select\"\nimport { cn } from \"@/lib/utils\"\n\n/* ---------- Demo data ---------- */\n\nconst TIMEZONES = [\n  { value: \"Europe/London\", label: \"London\", description: \"GMT+0 · Europe/London\", group: \"Europe\" },\n  { value: \"Europe/Paris\", label: \"Paris\", description: \"GMT+1 · Europe/Paris\", group: \"Europe\" },\n  { value: \"Europe/Istanbul\", label: \"Istanbul\", description: \"GMT+3 · Europe/Istanbul\", group: \"Europe\" },\n  { value: \"America/New_York\", label: \"New York\", description: \"GMT-5 · America/New_York\", group: \"Americas\" },\n  { value: \"America/Chicago\", label: \"Chicago\", description: \"GMT-6 · America/Chicago\", group: \"Americas\" },\n  { value: \"America/Los_Angeles\", label: \"Los Angeles\", description: \"GMT-8 · America/Los_Angeles\", group: \"Americas\" },\n  { value: \"Asia/Dubai\", label: \"Dubai\", description: \"GMT+4 · Asia/Dubai\", group: \"Asia Pacific\" },\n  { value: \"Asia/Singapore\", label: \"Singapore\", description: \"GMT+8 · Asia/Singapore\", group: \"Asia Pacific\" },\n  { value: \"Australia/Sydney\", label: \"Sydney\", description: \"GMT+11 · Australia/Sydney\", group: \"Asia Pacific\" },\n]\n\nconst LOCALES = [\n  { value: \"en-US\", label: \"English (US)\", description: \"12-hour clock · MM/DD/YYYY\" },\n  { value: \"en-GB\", label: \"English (UK)\", description: \"24-hour clock · DD/MM/YYYY\" },\n  { value: \"de-DE\", label: \"Deutsch\", description: \"24-Stunden · TT.MM.JJJJ\" },\n  { value: \"fr-FR\", label: \"Français\", description: \"24 h · JJ/MM/AAAA\" },\n  { value: \"es-ES\", label: \"Español\", description: \"24 h · DD/MM/AAAA\" },\n  { value: \"tr-TR\", label: \"Türkçe\", description: \"24 saat · GG.AA.YYYY\" },\n]\n\nconst TAKEN = [\"mira\", \"alex\", \"studio\", \"nova\", \"admin\"]\n\ntype Profile = { first: string; last: string; handle: string; email: string; tz: string; locale: string; bio: string; photo: string | null }\n\nconst INITIAL: Profile = {\n  first: \"Mira\",\n  last: \"Castellano\",\n  handle: \"mira\",\n  email: \"mira@novasalon.co\",\n  tz: \"Europe/London\",\n  locale: \"en-GB\",\n  bio: \"Owner at Nova Salon. Balayage specialist, 12 years behind the chair.\",\n  photo: null,\n}\n\ntype HandleState = \"idle\" | \"checking\" | \"free\" | \"taken\" | \"invalid\"\n\n/* ---------- Pieces ---------- */\n\nfunction CoverArt() {\n  return (\n    <svg viewBox=\"0 0 800 200\" preserveAspectRatio=\"none\" className=\"absolute inset-0 size-full\" aria-hidden=\"true\">\n      <defs>\n        <linearGradient id=\"ps-g1\" x1=\"0\" x2=\"1\" y1=\"0\" y2=\"1\">\n          <stop offset=\"0\" stopColor=\"var(--chart-1)\" />\n          <stop offset=\"1\" stopColor=\"var(--chart-4)\" />\n        </linearGradient>\n        <radialGradient id=\"ps-g2\" cx=\"0.8\" cy=\"0.2\" r=\"0.7\">\n          <stop offset=\"0\" stopColor=\"var(--chart-2)\" stopOpacity=\"0.9\" />\n          <stop offset=\"1\" stopColor=\"var(--chart-2)\" stopOpacity=\"0\" />\n        </radialGradient>\n        <radialGradient id=\"ps-g3\" cx=\"0.15\" cy=\"0.9\" r=\"0.6\">\n          <stop offset=\"0\" stopColor=\"var(--chart-3)\" stopOpacity=\"0.8\" />\n          <stop offset=\"1\" stopColor=\"var(--chart-3)\" stopOpacity=\"0\" />\n        </radialGradient>\n      </defs>\n      <rect width=\"800\" height=\"200\" fill=\"url(#ps-g1)\" />\n      <rect width=\"800\" height=\"200\" fill=\"url(#ps-g2)\" />\n      <rect width=\"800\" height=\"200\" fill=\"url(#ps-g3)\" />\n      <g stroke=\"white\" strokeOpacity=\"0.18\" fill=\"none\">\n        {Array.from({ length: 9 }).map((_, i) => (\n          <circle key={i} cx=\"640\" cy=\"110\" r={30 + i * 34} />\n        ))}\n      </g>\n    </svg>\n  )\n}\n\nfunction Field({ label, htmlFor, hint, children }: { label: string; htmlFor?: string; hint?: string; children: React.ReactNode }) {\n  return (\n    <div className=\"grid gap-1.5\">\n      <Label htmlFor={htmlFor} className=\"text-sm font-medium\">\n        {label}\n      </Label>\n      {children}\n      {hint && <p className=\"text-xs text-muted-foreground\">{hint}</p>}\n    </div>\n  )\n}\n\n/* ---------- Block ---------- */\n\nexport default function ProfileSettings() {\n  const [saved, setSaved] = React.useState<Profile>(INITIAL)\n  const [form, setForm] = React.useState<Profile>(INITIAL)\n  const [handleState, setHandleState] = React.useState<HandleState>(\"idle\")\n  const [saving, setSaving] = React.useState(false)\n  const [savedFlash, setSavedFlash] = React.useState(false)\n  const [errors, setErrors] = React.useState<Partial<Record<keyof Profile, string>>>({})\n  const fileRef = React.useRef<HTMLInputElement>(null)\n\n  const dirty = JSON.stringify(form) !== JSON.stringify(saved)\n  const set = <K extends keyof Profile>(k: K, v: Profile[K]) => setForm((f) => ({ ...f, [k]: v }))\n\n  // Handle availability: debounced fake lookup.\n  React.useEffect(() => {\n    const h = form.handle\n    if (h === saved.handle) return setHandleState(\"idle\")\n    if (!/^[a-z0-9_]{3,20}$/.test(h)) return setHandleState(\"invalid\")\n    setHandleState(\"checking\")\n    const id = setTimeout(() => setHandleState(TAKEN.includes(h) ? \"taken\" : \"free\"), 650)\n    return () => clearTimeout(id)\n  }, [form.handle, saved.handle])\n\n  const pickPhoto = (e: React.ChangeEvent<HTMLInputElement>) => {\n    const file = e.target.files?.[0]\n    if (!file) return\n    set(\"photo\", URL.createObjectURL(file))\n    e.target.value = \"\"\n  }\n\n  const save = () => {\n    const next: typeof errors = {}\n    if (!form.first.trim()) next.first = \"First name is required\"\n    if (!form.last.trim()) next.last = \"Last name is required\"\n    if (handleState === \"invalid\") next.handle = \"3–20 characters: lowercase letters, numbers and _\"\n    if (handleState === \"taken\") next.handle = \"That handle is already taken\"\n    if (handleState === \"checking\") next.handle = \"Still checking availability…\"\n    if (form.bio.length > 160) next.bio = \"Keep the bio under 160 characters\"\n    setErrors(next)\n    if (Object.keys(next).length) return\n    setSaving(true)\n    setTimeout(() => {\n      setSaving(false)\n      setSaved(form)\n      setSavedFlash(true)\n      setTimeout(() => setSavedFlash(false), 2200)\n    }, 900)\n  }\n\n  const discard = () => {\n    setForm(saved)\n    setErrors({})\n  }\n\n  const initials = `${form.first[0] ?? \"\"}${form.last[0] ?? \"\"}`.toUpperCase()\n\n  return (\n    <div className=\"p-4 md:p-6\">\n      <div className=\"mx-auto max-w-4xl\">\n        {/* Cover + avatar */}\n        <div className=\"relative overflow-hidden rounded-2xl border bg-card shadow-sm\">\n          <div className=\"relative h-36 md:h-44\">\n            <CoverArt />\n          </div>\n          <div className=\"px-5 pb-5 md:px-8\">\n            <div className=\"-mt-12 flex flex-wrap items-end gap-4 md:-mt-14\">\n              <div className=\"relative\">\n                <div className=\"size-24 overflow-hidden rounded-2xl border-4 border-card bg-muted shadow-md md:size-28\">\n                  {form.photo ? (\n                    // eslint-disable-next-line @next/next/no-img-element\n                    <img src={form.photo} alt=\"\" className=\"size-full object-cover\" />\n                  ) : (\n                    <div className=\"flex size-full items-center justify-center bg-gradient-to-br from-[var(--chart-1)] to-[var(--chart-4)] font-heading text-3xl font-semibold text-white\">{initials}</div>\n                  )}\n                </div>\n                <button\n                  type=\"button\"\n                  onClick={() => fileRef.current?.click()}\n                  aria-label=\"Upload photo\"\n                  className=\"absolute -right-1 -bottom-1 flex size-9 items-center justify-center rounded-full border-2 border-card bg-foreground text-background shadow transition hover:scale-105 focus-visible:ring-3 focus-visible:ring-ring/50\"\n                >\n                  <Camera className=\"size-4\" />\n                </button>\n                <input ref={fileRef} type=\"file\" accept=\"image/*\" className=\"sr-only\" onChange={pickPhoto} aria-label=\"Choose a profile photo\" />\n              </div>\n              <div className=\"min-w-0 flex-1 basis-40 pb-1\">\n                <h2 className=\"truncate font-heading text-2xl font-semibold tracking-tight\">\n                  {form.first} {form.last}\n                </h2>\n                <p className=\"truncate text-sm text-muted-foreground\">\n                  @{form.handle} · {form.email}\n                </p>\n              </div>\n              <div className=\"flex w-full gap-2 pb-1 sm:w-auto\">\n                <Button size=\"sm\" variant=\"outline\" tone=\"neutral\" onClick={() => fileRef.current?.click()} iconLeft={<Camera />}>\n                  Change photo\n                </Button>\n                {form.photo && (\n                  <Button size=\"sm\" variant=\"ghost\" tone=\"danger\" onClick={() => set(\"photo\", null)} iconLeft={<Trash2 />} aria-label=\"Remove photo\">\n                    Remove\n                  </Button>\n                )}\n              </div>\n            </div>\n          </div>\n        </div>\n\n        {/* Form */}\n        <div className=\"mt-6 grid gap-6 md:grid-cols-[220px_1fr]\">\n          <div>\n            <h3 className=\"font-heading text-base font-semibold\">Personal details</h3>\n            <p className=\"mt-1 text-sm text-muted-foreground\">Shown on your public booking page and in emails to clients.</p>\n          </div>\n          <div className=\"grid gap-5 rounded-2xl border bg-card p-5 shadow-sm md:p-6\">\n            <div className=\"grid gap-5 sm:grid-cols-2\">\n              <Input id=\"ps-first\" label=\"First name\" value={form.first} onValueChange={(v) => set(\"first\", v)} state={errors.first ? \"error\" : \"default\"} message={errors.first} autoComplete=\"given-name\" />\n              <Input id=\"ps-last\" label=\"Last name\" value={form.last} onValueChange={(v) => set(\"last\", v)} state={errors.last ? \"error\" : \"default\"} message={errors.last} autoComplete=\"family-name\" />\n            </div>\n            <Input\n              id=\"ps-handle\"\n              label=\"Handle\"\n              value={form.handle}\n              onValueChange={(v) => set(\"handle\", v.toLowerCase())}\n              leading={<AtSign className=\"size-4\" />}\n              addonBefore=\"book.nova.co/\"\n              state={errors.handle || handleState === \"taken\" || handleState === \"invalid\" ? \"error\" : handleState === \"free\" ? \"success\" : \"default\"}\n              message={errors.handle ?? (handleState === \"taken\" ? \"That handle is already taken\" : handleState === \"free\" ? \"Nice, @\" + form.handle + \" is available\" : undefined)}\n              description=\"Lowercase letters, numbers and underscores\"\n              trailing={\n                handleState === \"checking\" ? (\n                  <Loader2 className=\"size-4 animate-spin text-muted-foreground\" aria-label=\"Checking availability\" />\n                ) : handleState === \"free\" ? (\n                  <Check className=\"size-4 text-emerald-600 dark:text-emerald-400\" />\n                ) : handleState === \"taken\" || handleState === \"invalid\" ? (\n                  <X className=\"size-4 text-rose-600 dark:text-rose-400\" />\n                ) : undefined\n              }\n              autoComplete=\"username\"\n            />\n            <Input id=\"ps-email\" label=\"Email\" type=\"email\" value={form.email} onValueChange={(v) => set(\"email\", v)} description=\"We send a confirmation link when this changes.\" autoComplete=\"email\" />\n            <Field label=\"Bio\" htmlFor=\"ps-bio\" hint={errors.bio}>\n              <Textarea id=\"ps-bio\" value={form.bio} onChange={(e) => set(\"bio\", e.target.value)} rows={3} aria-invalid={!!errors.bio} className={cn(errors.bio && \"border-destructive\")} />\n              <div className=\"flex justify-end text-xs tabular-nums text-muted-foreground\">\n                <span className={cn(form.bio.length > 160 && \"text-rose-600 dark:text-rose-400\")}>{form.bio.length}/160</span>\n              </div>\n            </Field>\n          </div>\n\n          <div>\n            <h3 className=\"font-heading text-base font-semibold\">Region</h3>\n            <p className=\"mt-1 text-sm text-muted-foreground\">Appointment times and dates follow these settings.</p>\n          </div>\n          <div className=\"grid gap-5 rounded-2xl border bg-card p-5 shadow-sm md:p-6\">\n            <div className=\"grid gap-5 sm:grid-cols-2\">\n              <Field label=\"Time zone\" htmlFor=\"ps-tz\">\n                <Select id=\"ps-tz\" options={TIMEZONES} value={form.tz} onValueChange={(v) => v && set(\"tz\", v)} searchable searchPlaceholder=\"Search cities\" icon={<Globe className=\"size-4\" />} className=\"w-full\" />\n              </Field>\n              <Field label=\"Language & format\" htmlFor=\"ps-locale\">\n                <Select id=\"ps-locale\" options={LOCALES} value={form.locale} onValueChange={(v) => v && set(\"locale\", v)} className=\"w-full\" />\n              </Field>\n            </div>\n            <div className=\"rounded-xl bg-muted/60 p-4 text-sm\">\n              <p className=\"text-muted-foreground\">Preview</p>\n              <p className=\"mt-1 font-medium\">\n                Next appointment: <span className=\"tabular-nums\">{form.locale === \"en-US\" ? \"Thu, Mar 14 · 2:30 PM\" : form.locale === \"de-DE\" ? \"Do., 14.03. · 14:30\" : form.locale === \"fr-FR\" ? \"jeu. 14/03 · 14:30\" : form.locale === \"tr-TR\" ? \"Per, 14.03 · 14:30\" : \"Thu 14/03 · 14:30\"}</span>{\" \"}\n                <span className=\"text-muted-foreground\">({TIMEZONES.find((t) => t.value === form.tz)?.label})</span>\n              </p>\n            </div>\n          </div>\n        </div>\n\n        {/* Unsaved changes bar */}\n        <div\n          className={cn(\n            \"sticky bottom-4 z-10 mt-6 flex items-center justify-between gap-3 rounded-2xl border bg-foreground px-4 py-3 text-background shadow-xl transition-all duration-300 motion-reduce:transition-none\",\n            dirty || saving || savedFlash ? \"translate-y-0 opacity-100\" : \"pointer-events-none translate-y-4 opacity-0\",\n          )}\n          role=\"status\"\n          aria-live=\"polite\"\n        >\n          <div className=\"flex items-center gap-3 text-sm\">\n            {savedFlash && !dirty ? (\n              <>\n                <span className=\"flex size-6 items-center justify-center rounded-full bg-emerald-500 text-white\">\n                  <Check className=\"size-3.5\" />\n                </span>\n                Profile saved\n              </>\n            ) : (\n              <>\n                <span className=\"relative flex size-2.5\">\n                  <span className=\"absolute inline-flex size-full animate-ping rounded-full bg-amber-400 opacity-75 motion-reduce:animate-none\" />\n                  <span className=\"relative inline-flex size-2.5 rounded-full bg-amber-400\" />\n                </span>\n                You have unsaved changes\n              </>\n            )}\n          </div>\n          <div className=\"flex gap-2\">\n            <Button size=\"sm\" variant=\"ghost\" tone=\"neutral\" className=\"text-background hover:bg-background/15\" onClick={discard} disabled={!dirty || saving}>\n              Discard\n            </Button>\n            <Button size=\"sm\" variant=\"solid\" tone=\"neutral\" className=\"bg-background text-foreground hover:bg-background/90\" onClick={save} loading={saving} disabled={!dirty}>\n              Save changes\n            </Button>\n          </div>\n        </div>\n      </div>\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/goodui/profile-settings.tsx"
    }
  ],
  "categories": [
    "settings"
  ],
  "type": "registry:block"
}
