{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "profile-settings",
  "type": "registry:block",
  "title": "Profile Settings",
  "description": "Edit your profile: crop a generated photo in a small dialog, claim a username with a live availability check and suggestions, see your local time on a tiny clock, and save from a bar that springs up when something changes.",
  "categories": [
    "screen",
    "Settings"
  ],
  "dependencies": [
    "lucide-react",
    "motion"
  ],
  "registryDependencies": [
    "utils",
    "https://coss.com/ui/r/badge.json",
    "https://coss.com/ui/r/button.json",
    "https://coss.com/ui/r/dialog.json",
    "https://coss.com/ui/r/input.json",
    "https://coss.com/ui/r/input-group.json",
    "https://coss.com/ui/r/select.json",
    "https://coss.com/ui/r/slider.json",
    "https://coss.com/ui/r/spinner.json",
    "https://coss.com/ui/r/textarea.json"
  ],
  "files": [
    {
      "path": "registry/devl/profile-settings.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport {\n  ArrowLeftIcon,\n  BellIcon,\n  CheckIcon,\n  CreditCardIcon,\n  KeyRoundIcon,\n  MoveIcon,\n  PaletteIcon,\n  RotateCcwIcon,\n  SettingsIcon,\n  ShieldIcon,\n  UploadIcon,\n  UserIcon,\n  UsersIcon,\n  XIcon,\n  ZoomInIcon,\n  ZoomOutIcon,\n} from \"lucide-react\";\nimport { AnimatePresence, animate, motion, useMotionValue, useReducedMotion } from \"motion/react\";\nimport {\n  type ComponentType,\n  type KeyboardEvent,\n  type PointerEvent,\n  type ReactNode,\n  useEffect,\n  useId,\n  useMemo,\n  useRef,\n  useState,\n} from \"react\";\nimport { cn } from \"@/lib/utils\";\nimport { Badge } from \"@/components/ui/badge\";\nimport { Button } from \"@/components/ui/button\";\nimport {\n  Dialog,\n  DialogDescription,\n  DialogFooter,\n  DialogHeader,\n  DialogPanel,\n  DialogPopup,\n  DialogTitle,\n} from \"@/components/ui/dialog\";\nimport { Input } from \"@/components/ui/input\";\nimport { InputGroup, InputGroupAddon, InputGroupInput, InputGroupText } from \"@/components/ui/input-group\";\nimport { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from \"@/components/ui/select\";\nimport { Slider } from \"@/components/ui/slider\";\nimport { Spinner } from \"@/components/ui/spinner\";\nimport { Textarea } from \"@/components/ui/textarea\";\n\nexport type AvatarPalette = \"dusk\" | \"tide\" | \"ember\" | \"moss\";\n\nexport interface AvatarCrop {\n  palette: AvatarPalette;\n  x: number;\n  y: number;\n  zoom: number;\n}\n\nexport interface ProfileDraft {\n  fullName: string;\n  publicName: string;\n  username: string;\n  email: string;\n  bio: string;\n  timeZone: string;\n  avatar: AvatarCrop | null;\n}\n\nexport interface ProfileZone {\n  id: string;\n  city: string;\n}\n\nexport interface ProfileSettingsProps {\n  className?: string;\n  profile?: ProfileDraft;\n  domain?: string;\n  takenUsernames?: string[];\n  bioLimit?: number;\n  zones?: ProfileZone[];\n  onSave?: (profile: ProfileDraft) => void | Promise<void>;\n  onNavigate?: (section: string) => void;\n}\n\ntype UsernameStatus = \"current\" | \"checking\" | \"available\" | \"taken\" | \"invalid\";\n\nconst easeOut = [0.23, 1, 0.32, 1] as const;\nconst spring = { type: \"spring\", stiffness: 520, damping: 42 } as const;\nconst press = \"transition-[background-color,color,box-shadow,scale] duration-150 ease-out motion-safe:active:scale-[0.97]\";\nconst stageSpan = 136;\nconst zoomRange = [1, 2.4] as const;\nconst artBleed = 1.3;\n\nconst palettes: Record<AvatarPalette, { label: string; stops: [string, string, string]; swatch: string }> = {\n  dusk: {\n    label: \"Dusk\",\n    stops: [\"text-indigo-600\", \"text-fuchsia-500\", \"text-amber-300\"],\n    swatch: \"from-indigo-600 via-fuchsia-500 to-amber-300\",\n  },\n  tide: {\n    label: \"Tide\",\n    stops: [\"text-blue-700\", \"text-teal-400\", \"text-lime-200\"],\n    swatch: \"from-blue-700 via-teal-400 to-lime-200\",\n  },\n  ember: {\n    label: \"Ember\",\n    stops: [\"text-rose-700\", \"text-orange-500\", \"text-yellow-300\"],\n    swatch: \"from-rose-700 via-orange-500 to-yellow-300\",\n  },\n  moss: {\n    label: \"Moss\",\n    stops: [\"text-emerald-800\", \"text-emerald-500\", \"text-lime-300\"],\n    swatch: \"from-emerald-800 via-emerald-500 to-lime-300\",\n  },\n};\n\nconst navGroups: { label: string; items: { id: string; label: string; icon: ComponentType<{ className?: string }> }[] }[] = [\n  {\n    label: \"Account\",\n    items: [\n      { id: \"profile\", label: \"Profile\", icon: UserIcon },\n      { id: \"appearance\", label: \"Appearance\", icon: PaletteIcon },\n      { id: \"notifications\", label: \"Notifications\", icon: BellIcon },\n      { id: \"security\", label: \"Security\", icon: ShieldIcon },\n    ],\n  },\n  {\n    label: \"Workspace\",\n    items: [\n      { id: \"general\", label: \"General\", icon: SettingsIcon },\n      { id: \"members\", label: \"Members & roles\", icon: UsersIcon },\n      { id: \"billing\", label: \"Billing\", icon: CreditCardIcon },\n    ],\n  },\n  {\n    label: \"Developer\",\n    items: [{ id: \"api\", label: \"API keys & webhooks\", icon: KeyRoundIcon }],\n  },\n];\n\nconst defaultZones: ProfileZone[] = [\n  { id: \"Pacific/Honolulu\", city: \"Honolulu\" },\n  { id: \"America/Los_Angeles\", city: \"Los Angeles\" },\n  { id: \"America/Denver\", city: \"Denver\" },\n  { id: \"America/Chicago\", city: \"Chicago\" },\n  { id: \"America/New_York\", city: \"New York\" },\n  { id: \"America/Sao_Paulo\", city: \"São Paulo\" },\n  { id: \"Europe/London\", city: \"London\" },\n  { id: \"Europe/Lisbon\", city: \"Lisbon\" },\n  { id: \"Europe/Stockholm\", city: \"Stockholm\" },\n  { id: \"Europe/Berlin\", city: \"Berlin\" },\n  { id: \"Africa/Lagos\", city: \"Lagos\" },\n  { id: \"Africa/Nairobi\", city: \"Nairobi\" },\n  { id: \"Asia/Dubai\", city: \"Dubai\" },\n  { id: \"Asia/Kolkata\", city: \"Mumbai\" },\n  { id: \"Asia/Singapore\", city: \"Singapore\" },\n  { id: \"Asia/Tokyo\", city: \"Tokyo\" },\n  { id: \"Australia/Sydney\", city: \"Sydney\" },\n  { id: \"Pacific/Auckland\", city: \"Auckland\" },\n];\n\nconst defaultProfile: ProfileDraft = {\n  fullName: \"Ada Lindqvist\",\n  publicName: \"Ada\",\n  username: \"adalindqvist\",\n  email: \"ada@ridgeline.app\",\n  bio: \"Design engineer on the platform team. I care about fast tools, tidy changelogs and good coffee.\",\n  timeZone: \"Europe/Stockholm\",\n  avatar: { palette: \"dusk\", x: 0, y: 0, zoom: 1 },\n};\n\nconst defaultTaken = [\"ada\", \"adal\", \"lindqvist\", \"admin\", \"support\", \"hello\", \"team\", \"ridgeline\", \"design\"];\n\nfunction useReducedMotionSafe() {\n  const prefers = useReducedMotion();\n  const [mounted, setMounted] = useState(false);\n  useEffect(() => setMounted(true), []);\n  return mounted && Boolean(prefers);\n}\n\nfunction useSafeId() {\n  return useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n}\n\nfunction initialsOf(name: string) {\n  const parts = name.trim().split(/\\s+/).filter(Boolean);\n  if (parts.length === 0) return \"?\";\n  return (parts.length > 1 ? parts[0][0] + parts[parts.length - 1][0] : parts[0][0]).toUpperCase();\n}\n\nfunction clampCrop(crop: AvatarCrop): AvatarCrop {\n  const zoom = Math.max(zoomRange[0], Math.min(zoomRange[1], crop.zoom));\n  const limit = 50 * (zoom * artBleed - 1);\n  const clamp = (v: number) => Math.max(-limit, Math.min(limit, v));\n  return { ...crop, zoom, x: clamp(crop.x), y: clamp(crop.y) };\n}\n\nfunction artTransform(crop: AvatarCrop) {\n  return `translate(${50 + crop.x} ${50 + crop.y}) scale(${crop.zoom * artBleed}) translate(-50 -50)`;\n}\n\nfunction sameCrop(a: AvatarCrop | null, b: AvatarCrop | null) {\n  if (!a || !b) return a === b;\n  return a.palette === b.palette && a.x === b.x && a.y === b.y && a.zoom === b.zoom;\n}\n\nfunction validateUsername(value: string): string | null {\n  if (value.length < 3) return \"Use at least 3 characters.\";\n  if (value.length > 24) return \"Keep it to 24 characters or fewer.\";\n  if (!/^[a-z0-9-]+$/.test(value)) return \"Use lowercase letters, numbers and hyphens.\";\n  if (/^-|-$/.test(value)) return \"Start and end with a letter or number.\";\n  return null;\n}\n\nfunction suggestionsFor(value: string, fullName: string, taken: Set<string>) {\n  const base = value.replace(/[^a-z0-9]/g, \"\").slice(0, 16) || \"ada\";\n  const last = fullName.trim().split(/\\s+/).slice(1).join(\"\").toLowerCase().replace(/[^a-z]/g, \"\");\n  return [last ? `${base}-${last[0]}` : `${base}-hq`, `${base}${base.length + 21}`, `hey-${base}`, `${base}-studio`]\n    .filter((s) => !taken.has(s) && !validateUsername(s) && s !== value)\n    .slice(0, 3);\n}\n\nfunction offsetMinutes(timeZone: string, date: Date) {\n  const part = new Intl.DateTimeFormat(\"en-US\", { timeZone, timeZoneName: \"shortOffset\" })\n    .formatToParts(date)\n    .find((p) => p.type === \"timeZoneName\")?.value;\n  const match = part?.match(/GMT([+-])(\\d{1,2})(?::(\\d{2}))?/);\n  if (!match) return 0;\n  const sign = match[1] === \"-\" ? -1 : 1;\n  return sign * (Number(match[2]) * 60 + Number(match[3] ?? 0));\n}\n\nfunction formatOffset(minutes: number) {\n  if (minutes === 0) return \"UTC\";\n  const abs = Math.abs(minutes);\n  const m = abs % 60;\n  return `UTC${minutes > 0 ? \"+\" : \"−\"}${Math.floor(abs / 60)}${m ? `:${String(m).padStart(2, \"0\")}` : \"\"}`;\n}\n\nfunction formatDiff(minutes: number) {\n  if (minutes === 0) return \"same as your browser\";\n  const abs = Math.abs(minutes);\n  const m = abs % 60;\n  return `${Math.floor(abs / 60)}h${m ? ` ${m}m` : \"\"} ${minutes > 0 ? \"ahead of\" : \"behind\"} your browser`;\n}\n\nfunction AvatarArt({ palette, initials, uid }: { palette: AvatarPalette; initials: string; uid: string }) {\n  const p = palettes[palette];\n  return (\n    <>\n      <defs>\n        <linearGradient id={`${uid}-bg`} x1=\"0\" x2=\"1\" y1=\"0\" y2=\"1\">\n          <stop className={p.stops[0]} offset=\"0\" stopColor=\"currentColor\" />\n          <stop className={p.stops[1]} offset=\"1\" stopColor=\"currentColor\" />\n        </linearGradient>\n        <radialGradient id={`${uid}-glow`}>\n          <stop className={p.stops[2]} offset=\"0\" stopColor=\"currentColor\" stopOpacity=\"0.9\" />\n          <stop className={p.stops[2]} offset=\"1\" stopColor=\"currentColor\" stopOpacity=\"0\" />\n        </radialGradient>\n      </defs>\n      <rect fill={`url(#${uid}-bg)`} height=\"100\" width=\"100\" />\n      <circle cx=\"68\" cy=\"30\" fill={`url(#${uid}-glow)`} r=\"30\" />\n      <circle className={p.stops[2]} cx=\"68\" cy=\"30\" fill=\"currentColor\" r=\"8\" />\n      <path d=\"M0 66 Q 20 54 42 63 T 100 56 V100 H0Z\" fill=\"black\" fillOpacity=\"0.14\" />\n      <path d=\"M0 80 Q 28 68 56 78 T 100 72 V100 H0Z\" fill=\"black\" fillOpacity=\"0.2\" />\n      <text\n        dominantBaseline=\"central\"\n        fill=\"white\"\n        fontSize=\"22\"\n        fontWeight=\"600\"\n        letterSpacing=\"-0.4\"\n        textAnchor=\"middle\"\n        x=\"50\"\n        y=\"50\"\n      >\n        {initials}\n      </text>\n    </>\n  );\n}\n\nfunction ProfileAvatar({ crop, initials, className }: { crop: AvatarCrop | null; initials: string; className?: string }) {\n  const uid = useSafeId();\n  if (!crop) {\n    return (\n      <span\n        aria-hidden\n        className={cn(\n          \"flex shrink-0 items-center justify-center rounded-full border bg-muted font-medium text-muted-foreground [container-type:size]\",\n          className,\n        )}\n      >\n        <span className=\"text-[38cqh] leading-none\">{initials}</span>\n      </span>\n    );\n  }\n  return (\n    <svg aria-hidden className={cn(\"shrink-0\", className)} viewBox=\"0 0 100 100\">\n      <clipPath id={`${uid}-clip`}>\n        <circle cx=\"50\" cy=\"50\" r=\"50\" />\n      </clipPath>\n      <g clipPath={`url(#${uid}-clip)`}>\n        <g transform={artTransform(crop)}>\n          <AvatarArt initials={initials} palette={crop.palette} uid={uid} />\n        </g>\n      </g>\n      <circle cx=\"50\" cy=\"50\" fill=\"none\" r=\"49.5\" stroke=\"black\" strokeOpacity=\"0.08\" />\n    </svg>\n  );\n}\n\nfunction CropStage({\n  crop,\n  initials,\n  onChange,\n}: {\n  crop: AvatarCrop;\n  initials: string;\n  onChange: (crop: AvatarCrop) => void;\n}) {\n  const uid = useSafeId();\n  const ref = useRef<HTMLDivElement>(null);\n  const drag = useRef<{ px: number; py: number; x: number; y: number } | null>(null);\n  const [dragging, setDragging] = useState(false);\n  const thirds = [100 / 3, 200 / 3];\n\n  const onPointerDown = (e: PointerEvent<HTMLDivElement>) => {\n    e.currentTarget.setPointerCapture(e.pointerId);\n    drag.current = { px: e.clientX, py: e.clientY, x: crop.x, y: crop.y };\n    setDragging(true);\n  };\n  const onPointerMove = (e: PointerEvent<HTMLDivElement>) => {\n    const start = drag.current;\n    const el = ref.current;\n    if (!start || !el) return;\n    const k = stageSpan / el.clientWidth;\n    onChange(clampCrop({ ...crop, x: start.x + (e.clientX - start.px) * k, y: start.y + (e.clientY - start.py) * k }));\n  };\n  const endDrag = () => {\n    drag.current = null;\n    setDragging(false);\n  };\n  const onKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n    const step = e.shiftKey ? 8 : 2;\n    const moves: Record<string, [number, number, number]> = {\n      ArrowLeft: [-step, 0, 0],\n      ArrowRight: [step, 0, 0],\n      ArrowUp: [0, -step, 0],\n      ArrowDown: [0, step, 0],\n      \"+\": [0, 0, 0.1],\n      \"=\": [0, 0, 0.1],\n      \"-\": [0, 0, -0.1],\n    };\n    const move = moves[e.key];\n    if (!move) return;\n    e.preventDefault();\n    onChange(clampCrop({ ...crop, x: crop.x + move[0], y: crop.y + move[1], zoom: crop.zoom + move[2] }));\n  };\n\n  return (\n    <div\n      aria-label=\"Photo framing. Drag or use the arrow keys to move, plus and minus to zoom.\"\n      className=\"relative aspect-square w-full cursor-grab touch-none select-none overflow-hidden rounded-xl bg-muted outline-none ring-ring/24 focus-visible:ring-[3px] active:cursor-grabbing\"\n      onKeyDown={onKeyDown}\n      onLostPointerCapture={endDrag}\n      onPointerCancel={endDrag}\n      onPointerDown={onPointerDown}\n      onPointerMove={onPointerMove}\n      onPointerUp={endDrag}\n      ref={ref}\n      role=\"group\"\n      tabIndex={0}\n    >\n      <svg aria-hidden className=\"size-full\" viewBox=\"-18 -18 136 136\">\n        <clipPath id={`${uid}-circle`}>\n          <circle cx=\"50\" cy=\"50\" r=\"50\" />\n        </clipPath>\n        <g transform={artTransform(crop)}>\n          <AvatarArt initials={initials} palette={crop.palette} uid={uid} />\n        </g>\n        <path\n          className=\"fill-popover/72\"\n          d=\"M-18 -18 H118 V118 H-18Z M50 0 A50 50 0 1 0 50 100 A50 50 0 1 0 50 0Z\"\n          fillRule=\"evenodd\"\n        />\n        <g\n          className=\"transition-opacity duration-150 ease-out\"\n          clipPath={`url(#${uid}-circle)`}\n          opacity={dragging ? 1 : 0}\n          stroke=\"white\"\n          strokeOpacity=\"0.55\"\n          strokeWidth=\"0.35\"\n        >\n          {thirds.map((t) => (\n            <g key={t}>\n              <line x1={t} x2={t} y1=\"0\" y2=\"100\" />\n              <line x1=\"0\" x2=\"100\" y1={t} y2={t} />\n            </g>\n          ))}\n        </g>\n        <circle cx=\"50\" cy=\"50\" fill=\"none\" r=\"50\" stroke=\"white\" strokeOpacity=\"0.9\" strokeWidth=\"0.6\" />\n      </svg>\n      <span\n        className={cn(\n          \"pointer-events-none absolute bottom-2.5 left-1/2 inline-flex -translate-x-1/2 items-center gap-1.5 whitespace-nowrap rounded-full bg-popover/88 px-2.5 py-1 font-medium text-foreground text-xs shadow-xs/5 backdrop-blur-sm transition-opacity duration-150\",\n          dragging ? \"opacity-0\" : \"opacity-100\",\n        )}\n      >\n        <MoveIcon className=\"size-3\" />\n        Drag to reposition\n      </span>\n    </div>\n  );\n}\n\nfunction CropDialog({\n  open,\n  initial,\n  initials,\n  onOpenChange,\n  onApply,\n}: {\n  open: boolean;\n  initial: AvatarCrop;\n  initials: string;\n  onOpenChange: (open: boolean) => void;\n  onApply: (crop: AvatarCrop) => void;\n}) {\n  const [crop, setCrop] = useState(initial);\n  const initialRef = useRef(initial);\n  initialRef.current = initial;\n  useEffect(() => {\n    if (open) setCrop(initialRef.current);\n  }, [open]);\n\n  return (\n    <Dialog onOpenChange={onOpenChange} open={open}>\n      <DialogPopup className=\"sm:max-w-sm\">\n        <DialogHeader>\n          <DialogTitle className=\"font-semibold text-lg\">Adjust photo</DialogTitle>\n          <DialogDescription>Drag to reposition, then zoom to frame it.</DialogDescription>\n        </DialogHeader>\n        <DialogPanel className=\"flex flex-col gap-5\">\n          <div className=\"mx-auto w-full max-w-64\">\n            <CropStage crop={crop} initials={initials} onChange={setCrop} />\n          </div>\n          <div className=\"flex items-center gap-2\">\n            <Button\n              aria-label=\"Zoom out\"\n              className={press}\n              disabled={crop.zoom <= zoomRange[0]}\n              onClick={() => setCrop((c) => clampCrop({ ...c, zoom: c.zoom - 0.2 }))}\n              size=\"icon-sm\"\n              variant=\"ghost\"\n            >\n              <ZoomOutIcon />\n            </Button>\n            <Slider\n              getAriaLabel={() => \"Zoom\"}\n              max={zoomRange[1]}\n              min={zoomRange[0]}\n              onValueChange={(v) => setCrop((c) => clampCrop({ ...c, zoom: Array.isArray(v) ? v[0] : v }))}\n              step={0.01}\n              value={crop.zoom}\n            />\n            <Button\n              aria-label=\"Zoom in\"\n              className={press}\n              disabled={crop.zoom >= zoomRange[1]}\n              onClick={() => setCrop((c) => clampCrop({ ...c, zoom: c.zoom + 0.2 }))}\n              size=\"icon-sm\"\n              variant=\"ghost\"\n            >\n              <ZoomInIcon />\n            </Button>\n          </div>\n          <div className=\"flex flex-col gap-2\">\n            <span className=\"font-medium text-sm\">Image</span>\n            <div aria-label=\"Image\" className=\"flex gap-2\" role=\"radiogroup\">\n              {(Object.keys(palettes) as AvatarPalette[]).map((key) => {\n                const active = crop.palette === key;\n                return (\n                  <button\n                    aria-checked={active}\n                    aria-label={palettes[key].label}\n                    className={cn(\n                      \"relative size-10 rounded-lg bg-gradient-to-br outline-none ring-offset-2 ring-offset-popover focus-visible:ring-2 focus-visible:ring-ring\",\n                      press,\n                      palettes[key].swatch,\n                      active && \"ring-2 ring-foreground\",\n                    )}\n                    key={key}\n                    onClick={() => setCrop((c) => ({ ...c, palette: key }))}\n                    role=\"radio\"\n                    type=\"button\"\n                  >\n                    {active && (\n                      <span className=\"absolute inset-0 flex items-center justify-center text-white\">\n                        <CheckIcon className=\"size-4\" strokeWidth={2.5} />\n                      </span>\n                    )}\n                  </button>\n                );\n              })}\n            </div>\n          </div>\n        </DialogPanel>\n        <DialogFooter>\n          <Button\n            className={cn(press, \"sm:me-auto\")}\n            disabled={crop.zoom === 1 && crop.x === 0 && crop.y === 0}\n            onClick={() => setCrop((c) => ({ ...c, x: 0, y: 0, zoom: 1 }))}\n            variant=\"ghost\"\n          >\n            <RotateCcwIcon />\n            Reset\n          </Button>\n          <Button className={press} onClick={() => onOpenChange(false)} variant=\"outline\">\n            Cancel\n          </Button>\n          <Button\n            className={press}\n            onClick={() => {\n              onApply(crop);\n              onOpenChange(false);\n            }}\n          >\n            Apply\n          </Button>\n        </DialogFooter>\n      </DialogPopup>\n    </Dialog>\n  );\n}\n\nfunction useUnwrappedAngle(angle: number | null) {\n  const reduce = useReducedMotionSafe();\n  const mv = useMotionValue(0);\n  const last = useRef<number | null>(null);\n  useEffect(() => {\n    if (angle === null) return;\n    if (last.current === null || reduce) {\n      last.current = angle;\n      mv.set(angle);\n      return;\n    }\n    const delta = ((((angle - last.current) % 360) + 540) % 360) - 180;\n    last.current += delta;\n    const controls = animate(mv, last.current, { type: \"spring\", stiffness: 140, damping: 18 });\n    return () => controls.stop();\n  }, [angle, reduce, mv]);\n  return mv;\n}\n\nfunction MiniClock({ hours, minutes }: { hours: number | null; minutes: number | null }) {\n  const ready = hours !== null && minutes !== null;\n  const hour = useUnwrappedAngle(ready ? (hours % 12) * 30 + minutes * 0.5 : null);\n  const minute = useUnwrappedAngle(ready ? minutes * 6 : null);\n  const night = ready && (hours < 7 || hours >= 19);\n  return (\n    <span\n      aria-hidden\n      className={cn(\n        \"relative flex size-8 shrink-0 items-center justify-center rounded-full border shadow-xs/5 transition-colors duration-300\",\n        night ? \"border-indigo-900 bg-indigo-950 text-indigo-100\" : \"bg-background text-foreground\",\n      )}\n    >\n      <motion.span\n        className={cn(\n          \"absolute bottom-1/2 left-[calc(50%-1px)] h-2 w-0.5 origin-bottom rounded-full bg-current transition-opacity\",\n          ready ? \"opacity-100\" : \"opacity-0\",\n        )}\n        style={{ rotate: hour }}\n      />\n      <motion.span\n        className={cn(\n          \"absolute bottom-1/2 left-[calc(50%-0.75px)] h-3 w-[1.5px] origin-bottom rounded-full bg-current transition-opacity\",\n          ready ? \"opacity-100\" : \"opacity-0\",\n        )}\n        style={{ rotate: minute }}\n      />\n      <span className=\"absolute size-1 rounded-full bg-current\" />\n    </span>\n  );\n}\n\nfunction DirtyDot({ show }: { show: boolean }) {\n  return (\n    <AnimatePresence initial={false}>\n      {show && (\n        <motion.span\n          animate={{ opacity: 1, scale: 1 }}\n          aria-label=\"Edited\"\n          className=\"size-1.5 rounded-full bg-warning\"\n          exit={{ opacity: 0, scale: 0.5 }}\n          initial={{ opacity: 0, scale: 0.5 }}\n          role=\"img\"\n          transition={{ duration: 0.16, ease: easeOut }}\n        />\n      )}\n    </AnimatePresence>\n  );\n}\n\nfunction Field({\n  label,\n  help,\n  htmlFor,\n  dirty,\n  aside,\n  children,\n}: {\n  label: string;\n  help?: string;\n  htmlFor?: string;\n  dirty?: boolean;\n  aside?: ReactNode;\n  children: ReactNode;\n}) {\n  return (\n    <div className=\"flex min-w-0 flex-col gap-2\">\n      <div className=\"flex items-end justify-between gap-3\">\n        <div className=\"flex min-w-0 flex-col gap-0.5\">\n          <span className=\"flex items-center gap-2\">\n            <label className=\"font-medium text-sm\" htmlFor={htmlFor}>\n              {label}\n            </label>\n            <DirtyDot show={Boolean(dirty)} />\n          </span>\n          {help && <span className=\"text-pretty text-muted-foreground text-xs\">{help}</span>}\n        </div>\n        {aside}\n      </div>\n      {children}\n    </div>\n  );\n}\n\nfunction Section({ title, description, children }: { title: string; description?: string; children: ReactNode }) {\n  return (\n    <section className=\"mt-10\">\n      <h2 className=\"font-medium text-sm\">{title}</h2>\n      {description && <p className=\"text-pretty text-muted-foreground text-sm\">{description}</p>}\n      {children}\n    </section>\n  );\n}\n\nfunction SettingsShell({\n  active,\n  account,\n  onNavigate,\n  overlay,\n  children,\n}: {\n  active: string;\n  account: ReactNode;\n  onNavigate?: (section: string) => void;\n  overlay?: ReactNode;\n  children: ReactNode;\n}) {\n  const items = navGroups.flatMap((g) => g.items);\n  return (\n    <>\n      <aside className=\"hidden w-60 shrink-0 flex-col border-r bg-muted/30 px-3 py-4 md:flex\">\n        <button\n          className=\"flex h-8 items-center gap-2 rounded-md px-2 text-muted-foreground text-sm outline-none ring-ring/24 transition-colors hover:bg-accent/60 hover:text-foreground focus-visible:ring-[3px]\"\n          type=\"button\"\n        >\n          <ArrowLeftIcon className=\"size-4\" />\n          Back to Ridgeline\n        </button>\n        <nav aria-label=\"Settings\">\n          {navGroups.map((group) => (\n            <div key={group.label}>\n              <div className=\"px-2 pt-5 pb-1.5 font-medium text-muted-foreground text-xs\">{group.label}</div>\n              <div className=\"flex flex-col gap-0.5\">\n                {group.items.map((item) => {\n                  const current = item.id === active;\n                  const Icon = item.icon;\n                  return (\n                    <button\n                      aria-current={current ? \"page\" : undefined}\n                      className={cn(\n                        \"flex h-8 w-full items-center gap-2 rounded-md px-2 text-left text-sm outline-none ring-ring/24 transition-colors focus-visible:ring-[3px]\",\n                        current ? \"bg-accent font-medium text-foreground\" : \"text-foreground/80 hover:bg-accent/60\",\n                      )}\n                      key={item.id}\n                      onClick={() => onNavigate?.(item.id)}\n                      type=\"button\"\n                    >\n                      <Icon className=\"size-4 shrink-0 text-muted-foreground\" />\n                      <span className=\"truncate\">{item.label}</span>\n                    </button>\n                  );\n                })}\n              </div>\n            </div>\n          ))}\n        </nav>\n        <div className=\"mt-auto flex items-center gap-2.5 px-2 pt-4\">{account}</div>\n      </aside>\n      <div className=\"relative flex min-w-0 flex-1 flex-col\">\n        <div className=\"md:hidden\">\n          <div className=\"flex h-12 items-center gap-2 border-b px-4\">\n            <button\n              aria-label=\"Back to Ridgeline\"\n              className=\"-ms-1.5 flex size-8 items-center justify-center rounded-md text-muted-foreground outline-none ring-ring/24 hover:bg-accent/60 hover:text-foreground focus-visible:ring-[3px]\"\n              type=\"button\"\n            >\n              <ArrowLeftIcon className=\"size-4\" />\n            </button>\n            <span className=\"font-medium text-sm\">Settings</span>\n          </div>\n          <nav\n            aria-label=\"Settings\"\n            className=\"flex gap-1.5 overflow-x-auto border-b px-4 py-2.5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden\"\n          >\n            {items.map((item) => {\n              const current = item.id === active;\n              return (\n                <button\n                  aria-current={current ? \"page\" : undefined}\n                  className={cn(\n                    \"h-7 shrink-0 rounded-full px-3 text-xs outline-none ring-ring/24 transition-colors focus-visible:ring-[3px]\",\n                    current ? \"bg-foreground font-medium text-background\" : \"bg-muted text-muted-foreground hover:text-foreground\",\n                  )}\n                  key={item.id}\n                  onClick={() => onNavigate?.(item.id)}\n                  type=\"button\"\n                >\n                  {item.label}\n                </button>\n              );\n            })}\n          </nav>\n        </div>\n        <div className=\"min-h-0 flex-1 overflow-y-auto\">\n          <div className=\"mx-auto w-full max-w-2xl px-6 py-10 md:px-10\">{children}</div>\n        </div>\n        {overlay}\n      </div>\n    </>\n  );\n}\n\nfunction UsernameStatusLine({\n  status,\n  message,\n  suggestions,\n  onPick,\n  id,\n}: {\n  status: UsernameStatus;\n  message: string | null;\n  suggestions: string[];\n  onPick: (value: string) => void;\n  id: string;\n}) {\n  const reduce = useReducedMotionSafe();\n  const content: Record<UsernameStatus, ReactNode> = {\n    current: <span className=\"text-muted-foreground\">This is your current username.</span>,\n    checking: <span className=\"text-muted-foreground\">Checking availability…</span>,\n    available: (\n      <span className=\"flex items-center gap-1 text-success-foreground\">\n        <CheckIcon className=\"size-3.5\" />\n        Available\n      </span>\n    ),\n    taken: (\n      <span className=\"flex flex-wrap items-center gap-x-1.5 gap-y-1 text-destructive-foreground\">\n        <span>Taken, try</span>\n        {suggestions.map((s, i) => (\n          <motion.button\n            animate={{ opacity: 1, y: 0 }}\n            className={cn(\n              \"inline-flex h-6 items-center rounded-md border bg-background px-1.5 font-mono text-foreground text-xs outline-none ring-ring/24 hover:bg-accent focus-visible:ring-[3px]\",\n              press,\n            )}\n            initial={{ opacity: 0, y: reduce ? 0 : 3 }}\n            key={s}\n            onClick={() => onPick(s)}\n            transition={{ duration: 0.18, ease: easeOut, delay: reduce ? 0 : 0.03 + i * 0.03 }}\n            type=\"button\"\n          >\n            {s}\n          </motion.button>\n        ))}\n      </span>\n    ),\n    invalid: <span className=\"text-destructive-foreground\">{message}</span>,\n  };\n  return (\n    <div aria-live=\"polite\" className=\"relative min-h-6 text-xs\" id={id}>\n      <AnimatePresence initial={false} mode=\"popLayout\">\n        <motion.div\n          animate={{ opacity: 1, y: 0 }}\n          className=\"flex min-h-6 items-center\"\n          exit={{ opacity: 0, y: reduce ? 0 : -3 }}\n          initial={{ opacity: 0, y: reduce ? 0 : 3 }}\n          key={status === \"invalid\" ? `invalid-${message}` : status}\n          transition={{ duration: 0.16, ease: easeOut }}\n        >\n          {content[status]}\n        </motion.div>\n      </AnimatePresence>\n    </div>\n  );\n}\n\nexport function ProfileSettings({\n  className,\n  profile = defaultProfile,\n  domain = \"ridgeline.app\",\n  takenUsernames = defaultTaken,\n  bioLimit = 160,\n  zones = defaultZones,\n  onSave,\n  onNavigate,\n}: ProfileSettingsProps) {\n  const uid = useSafeId();\n  const reduce = useReducedMotionSafe();\n  const [baseline, setBaseline] = useState(profile);\n  const [draft, setDraft] = useState(profile);\n  const [cropOpen, setCropOpen] = useState(false);\n  const [editingEmail, setEditingEmail] = useState(false);\n  const [checked, setChecked] = useState<{ value: string; taken: boolean } | null>(null);\n  const [offsets, setOffsets] = useState<Record<string, number> | null>(null);\n  const [localOffset, setLocalOffset] = useState<number | null>(null);\n  const [clock, setClock] = useState<{ time: string; day: string; hours: number; minutes: number } | null>(null);\n  const [saving, setSaving] = useState(false);\n  const [saved, setSaved] = useState(false);\n  const savedTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n  const alive = useRef(true);\n  const emailRef = useRef<HTMLInputElement>(null);\n\n  const taken = useMemo(() => new Set(takenUsernames.map((h) => h.toLowerCase())), [takenUsernames]);\n  const usernameError = draft.username === baseline.username ? null : validateUsername(draft.username);\n\n  useEffect(() => {\n    if (draft.username === baseline.username || validateUsername(draft.username)) return;\n    if (checked?.value === draft.username) return;\n    const value = draft.username;\n    const timer = setTimeout(() => setChecked({ value, taken: taken.has(value) }), 650);\n    return () => clearTimeout(timer);\n  }, [draft.username, baseline.username, checked, taken]);\n\n  useEffect(() => {\n    const now = new Date();\n    setOffsets(Object.fromEntries(zones.map((z) => [z.id, offsetMinutes(z.id, now)])));\n    setLocalOffset(-now.getTimezoneOffset());\n  }, [zones]);\n\n  useEffect(() => {\n    const tick = () => {\n      const now = new Date();\n      const parts = new Intl.DateTimeFormat(\"en-GB\", {\n        timeZone: draft.timeZone,\n        hour: \"2-digit\",\n        minute: \"2-digit\",\n        weekday: \"short\",\n        hourCycle: \"h23\",\n      }).formatToParts(now);\n      const get = (type: string) => parts.find((p) => p.type === type)?.value ?? \"\";\n      const hours = Number(get(\"hour\")) % 24;\n      const minutes = Number(get(\"minute\"));\n      setClock({ time: `${get(\"hour\")}:${get(\"minute\")}`, day: get(\"weekday\"), hours, minutes });\n    };\n    tick();\n    const interval = setInterval(tick, 15000);\n    return () => clearInterval(interval);\n  }, [draft.timeZone]);\n\n  useEffect(() => {\n    alive.current = true;\n    return () => {\n      alive.current = false;\n      if (savedTimer.current) clearTimeout(savedTimer.current);\n    };\n  }, []);\n\n  useEffect(() => {\n    if (editingEmail) emailRef.current?.focus();\n  }, [editingEmail]);\n\n  const usernameStatus: UsernameStatus =\n    draft.username === baseline.username\n      ? \"current\"\n      : usernameError\n        ? \"invalid\"\n        : checked?.value === draft.username\n          ? checked.taken\n            ? \"taken\"\n            : \"available\"\n          : \"checking\";\n\n  const dirty = {\n    avatar: !sameCrop(draft.avatar, baseline.avatar),\n    fullName: draft.fullName !== baseline.fullName,\n    publicName: draft.publicName !== baseline.publicName,\n    username: draft.username !== baseline.username,\n    email: draft.email !== baseline.email,\n    bio: draft.bio !== baseline.bio,\n    timeZone: draft.timeZone !== baseline.timeZone,\n  };\n  const dirtyCount = Object.values(dirty).filter(Boolean).length;\n  const emailValid = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(draft.email);\n  const blocker = !draft.fullName.trim()\n    ? \"Add your full name\"\n    : usernameStatus === \"invalid\"\n      ? \"Fix your username\"\n      : usernameStatus === \"taken\"\n        ? \"That username is taken\"\n        : usernameStatus === \"checking\"\n          ? \"Checking username…\"\n          : !emailValid\n            ? \"Enter a valid email\"\n            : draft.bio.length > bioLimit\n              ? \"Bio is too long\"\n              : null;\n\n  const zone = zones.find((z) => z.id === draft.timeZone) ?? zones[0];\n  const zoneOffset = offsets?.[zone.id] ?? null;\n  const suggestions = usernameStatus === \"taken\" ? suggestionsFor(draft.username, draft.fullName, taken) : [];\n  const initials = initialsOf(draft.fullName || baseline.fullName);\n  const set = <K extends keyof ProfileDraft>(key: K, value: ProfileDraft[K]) => setDraft((d) => ({ ...d, [key]: value }));\n  const bioLeft = bioLimit - draft.bio.length;\n\n  const discard = () => {\n    setDraft(baseline);\n    setEditingEmail(false);\n  };\n\n  const save = async () => {\n    if (blocker || saving) return;\n    setSaving(true);\n    const snapshot = draft;\n    await Promise.all([onSave?.(snapshot), new Promise((r) => setTimeout(r, 900))]);\n    if (!alive.current) return;\n    setSaving(false);\n    setBaseline(snapshot);\n    setEditingEmail(false);\n    setChecked(null);\n    setSaved(true);\n    if (savedTimer.current) clearTimeout(savedTimer.current);\n    savedTimer.current = setTimeout(() => setSaved(false), 1600);\n  };\n\n  const ids = {\n    fullName: `${uid}-full`,\n    publicName: `${uid}-public`,\n    username: `${uid}-username`,\n    email: `${uid}-email`,\n    bio: `${uid}-bio`,\n    zone: `${uid}-zone`,\n  };\n  const barVisible = dirtyCount > 0 || saved;\n\n  return (\n    <div className={cn(\"flex h-[760px] w-full bg-background text-foreground\", className)}>\n      <SettingsShell\n        account={\n          <>\n            <ProfileAvatar className=\"size-7\" crop={draft.avatar} initials={initials} />\n            <div className=\"flex min-w-0 flex-col\">\n              <span className=\"truncate font-medium text-sm\">{draft.fullName.trim() || baseline.fullName}</span>\n              <span className=\"truncate text-muted-foreground text-xs\">{baseline.email}</span>\n            </div>\n          </>\n        }\n        active=\"profile\"\n        onNavigate={onNavigate}\n        overlay={\n          <AnimatePresence>\n            {barVisible && (\n              <motion.div\n                animate={{ opacity: 1, y: 0 }}\n                className=\"pointer-events-none absolute inset-x-0 bottom-4 z-20 flex justify-center px-4 md:px-6\"\n                exit={{ opacity: 0, y: reduce ? 0 : 16 }}\n                initial={{ opacity: 0, y: reduce ? 0 : 24 }}\n                transition={reduce ? { duration: 0.15 } : { type: \"spring\", stiffness: 480, damping: 34 }}\n              >\n                <div className=\"pointer-events-auto flex w-full max-w-xl items-center gap-2 rounded-xl border bg-popover py-2 ps-4 pe-2 shadow-lg/5\">\n                  <AnimatePresence initial={false} mode=\"popLayout\">\n                    {saved && dirtyCount === 0 ? (\n                      <motion.span\n                        animate={{ opacity: 1, y: 0 }}\n                        aria-live=\"polite\"\n                        className=\"flex min-h-8 flex-1 items-center gap-2 font-medium text-sm\"\n                        exit={{ opacity: 0, y: reduce ? 0 : -6 }}\n                        initial={{ opacity: 0, y: reduce ? 0 : 6 }}\n                        key=\"saved\"\n                        transition={{ duration: 0.18, ease: easeOut }}\n                      >\n                        <CheckIcon className=\"size-4 text-success-foreground\" />\n                        Profile saved\n                      </motion.span>\n                    ) : (\n                      <motion.div\n                        animate={{ opacity: 1, y: 0 }}\n                        className=\"flex min-w-0 flex-1 items-center gap-2\"\n                        exit={{ opacity: 0, y: reduce ? 0 : -6 }}\n                        initial={{ opacity: 0, y: reduce ? 0 : 6 }}\n                        key=\"dirty\"\n                        transition={{ duration: 0.18, ease: easeOut }}\n                      >\n                        <span aria-live=\"polite\" className=\"flex min-w-0 flex-1 flex-col\">\n                          <span className=\"truncate font-medium text-sm\">\n                            <span className=\"sm:hidden\">Unsaved changes</span>\n                            <span className=\"hidden sm:inline\">You have unsaved changes</span>\n                          </span>\n                          {blocker && !saving && <span className=\"truncate text-warning-foreground text-xs\">{blocker}</span>}\n                        </span>\n                        <Button className={press} disabled={saving} onClick={discard} size=\"sm\" variant=\"ghost\">\n                          Discard\n                        </Button>\n                        <Button className={cn(press, \"min-w-14\")} disabled={Boolean(blocker)} loading={saving} onClick={save} size=\"sm\">\n                          Save\n                        </Button>\n                      </motion.div>\n                    )}\n                  </AnimatePresence>\n                </div>\n              </motion.div>\n            )}\n          </AnimatePresence>\n        }\n      >\n        <h1 className=\"font-semibold text-2xl tracking-tight\">Profile</h1>\n        <p className=\"mt-1 text-muted-foreground text-sm\">Manage how you appear to your team across Ridgeline.</p>\n\n        <section className=\"mt-10 flex items-center gap-4\">\n          <ProfileAvatar className=\"size-16\" crop={draft.avatar} initials={initials} />\n          <div className=\"flex min-w-0 flex-col gap-2\">\n            <span className=\"flex items-center gap-2\">\n              <span className=\"font-medium text-sm\">Profile picture</span>\n              <DirtyDot show={dirty.avatar} />\n            </span>\n            <div className=\"flex flex-wrap items-center gap-2\">\n              <Button className={press} onClick={() => setCropOpen(true)} size=\"sm\" variant=\"outline\">\n                <UploadIcon />\n                Upload\n              </Button>\n              <Button className={press} disabled={!draft.avatar} onClick={() => set(\"avatar\", null)} size=\"sm\" variant=\"ghost\">\n                Remove\n              </Button>\n            </div>\n            <span className=\"text-muted-foreground text-xs\">PNG or JPG, up to 2 MB.</span>\n          </div>\n        </section>\n\n        <div className=\"mt-10 flex flex-col gap-6\">\n          <div className=\"grid gap-6 sm:grid-cols-2\">\n            <Field dirty={dirty.fullName} help=\"Visible to your team.\" htmlFor={ids.fullName} label=\"Full name\">\n              <Input\n                aria-invalid={!draft.fullName.trim() || undefined}\n                autoComplete=\"name\"\n                id={ids.fullName}\n                maxLength={48}\n                onChange={(e) => set(\"fullName\", e.target.value)}\n                value={draft.fullName}\n              />\n            </Field>\n            <Field dirty={dirty.publicName} help=\"Shown on comments and mentions.\" htmlFor={ids.publicName} label=\"Public name\">\n              <Input\n                autoComplete=\"nickname\"\n                id={ids.publicName}\n                maxLength={32}\n                onChange={(e) => set(\"publicName\", e.target.value)}\n                placeholder={draft.fullName.split(\" \")[0]}\n                value={draft.publicName}\n              />\n            </Field>\n          </div>\n\n          <Field dirty={dirty.username} help=\"Your profile link and @mention handle.\" htmlFor={ids.username} label=\"Username\">\n            <div className=\"flex flex-col gap-1\">\n              <InputGroup>\n                <InputGroupAddon>\n                  <InputGroupText>{domain}/</InputGroupText>\n                </InputGroupAddon>\n                <InputGroupInput\n                  aria-describedby={`${ids.username}-status`}\n                  aria-invalid={usernameStatus === \"taken\" || usernameStatus === \"invalid\" || undefined}\n                  autoCapitalize=\"none\"\n                  autoComplete=\"off\"\n                  className=\"[&_input]:ps-0.5!\"\n                  id={ids.username}\n                  maxLength={28}\n                  onChange={(e) => set(\"username\", e.target.value.toLowerCase().replace(/\\s+/g, \"-\"))}\n                  spellCheck={false}\n                  value={draft.username}\n                />\n                <InputGroupAddon align=\"inline-end\">\n                  <span className=\"relative flex size-4 items-center justify-center\">\n                    <AnimatePresence initial={false} mode=\"popLayout\">\n                      <motion.span\n                        animate={{ opacity: 1, scale: 1 }}\n                        className=\"absolute inset-0 flex items-center justify-center\"\n                        exit={{ opacity: 0, scale: 0.8 }}\n                        initial={{ opacity: 0, scale: 0.8 }}\n                        key={usernameStatus}\n                        transition={{ duration: 0.15, ease: easeOut }}\n                      >\n                        {usernameStatus === \"checking\" && <Spinner className=\"size-4 text-muted-foreground\" />}\n                        {usernameStatus === \"available\" && <CheckIcon className=\"size-4 text-success-foreground\" />}\n                        {(usernameStatus === \"taken\" || usernameStatus === \"invalid\") && (\n                          <XIcon className=\"size-4 text-destructive-foreground\" />\n                        )}\n                      </motion.span>\n                    </AnimatePresence>\n                  </span>\n                </InputGroupAddon>\n              </InputGroup>\n              <UsernameStatusLine\n                id={`${ids.username}-status`}\n                message={usernameError}\n                onPick={(value) => {\n                  setChecked({ value, taken: false });\n                  set(\"username\", value);\n                }}\n                status={usernameStatus}\n                suggestions={suggestions}\n              />\n            </div>\n          </Field>\n\n          <Field\n            aside={\n              !editingEmail && (\n                <Button className={cn(press, \"-me-2\")} onClick={() => setEditingEmail(true)} size=\"xs\" variant=\"ghost\">\n                  Change\n                </Button>\n              )\n            }\n            dirty={dirty.email}\n            help={dirty.email ? \"We’ll send a link to confirm the new address.\" : \"Used for sign-in and notifications.\"}\n            htmlFor={ids.email}\n            label=\"Email\"\n          >\n            <InputGroup>\n              <InputGroupInput\n                aria-invalid={!emailValid || undefined}\n                autoComplete=\"email\"\n                id={ids.email}\n                onChange={(e) => set(\"email\", e.target.value.trim())}\n                readOnly={!editingEmail}\n                ref={emailRef}\n                type=\"email\"\n                value={draft.email}\n              />\n              <InputGroupAddon align=\"inline-end\">\n                <AnimatePresence initial={false} mode=\"popLayout\">\n                  {dirty.email ? (\n                    <motion.span\n                      animate={{ opacity: 1, scale: 1 }}\n                      exit={{ opacity: 0, scale: 0.9 }}\n                      initial={{ opacity: 0, scale: 0.9 }}\n                      key=\"pending\"\n                      transition={{ duration: 0.15, ease: easeOut }}\n                    >\n                      <Badge variant=\"warning\">Unverified</Badge>\n                    </motion.span>\n                  ) : (\n                    <motion.span\n                      animate={{ opacity: 1, scale: 1 }}\n                      exit={{ opacity: 0, scale: 0.9 }}\n                      initial={{ opacity: 0, scale: 0.9 }}\n                      key=\"verified\"\n                      transition={{ duration: 0.15, ease: easeOut }}\n                    >\n                      <Badge variant=\"success\">\n                        <CheckIcon />\n                        Verified\n                      </Badge>\n                    </motion.span>\n                  )}\n                </AnimatePresence>\n              </InputGroupAddon>\n            </InputGroup>\n          </Field>\n\n          <Field\n            aside={\n              <span\n                className={cn(\n                  \"text-xs tabular-nums transition-colors\",\n                  bioLeft < 0 ? \"text-destructive-foreground\" : bioLeft <= 20 ? \"text-warning-foreground\" : \"text-muted-foreground\",\n                )}\n                id={`${ids.bio}-count`}\n              >\n                {draft.bio.length}/{bioLimit}\n              </span>\n            }\n            dirty={dirty.bio}\n            help=\"A sentence or two about what you work on.\"\n            htmlFor={ids.bio}\n            label=\"Bio\"\n          >\n            <Textarea\n              aria-describedby={`${ids.bio}-count`}\n              aria-invalid={bioLeft < 0 || undefined}\n              className=\"**:[textarea]:resize-none\"\n              id={ids.bio}\n              onChange={(e) => set(\"bio\", e.target.value)}\n              placeholder=\"What you work on, what you’re into.\"\n              value={draft.bio}\n            />\n          </Field>\n        </div>\n\n        <Section description=\"Teammates see your local time on your profile and in mentions.\" title=\"Time zone\">\n          <div className=\"mt-3 rounded-xl border bg-card\">\n            <div className=\"flex flex-col gap-3 px-4 py-3.5 sm:flex-row sm:items-center sm:gap-4\">\n              <div className=\"flex min-w-0 flex-1 items-center gap-3\">\n                <MiniClock hours={clock?.hours ?? null} minutes={clock?.minutes ?? null} />\n                <div className=\"flex min-w-0 flex-col\">\n                  <span className=\"flex items-center gap-2 text-sm\">\n                    <span>\n                      It’s <span className=\"font-medium tabular-nums\">{clock?.time ?? \"––:––\"}</span> for you\n                    </span>\n                    <DirtyDot show={dirty.timeZone} />\n                  </span>\n                  <span className=\"truncate text-muted-foreground text-xs tabular-nums\">\n                    {clock?.day ?? \"\"}\n                    {zoneOffset !== null && ` · ${formatOffset(zoneOffset)}`}\n                    {zoneOffset !== null && localOffset !== null && ` · ${formatDiff(zoneOffset - localOffset)}`}\n                  </span>\n                </div>\n              </div>\n              <Select\n                items={zones.map((z) => ({ value: z.id, label: z.city }))}\n                onValueChange={(value) => value && set(\"timeZone\", value as string)}\n                value={draft.timeZone}\n              >\n                <SelectTrigger aria-label=\"Time zone\" className=\"sm:w-48\" id={ids.zone} size=\"sm\">\n                  <SelectValue />\n                </SelectTrigger>\n                <SelectPopup>\n                  {zones.map((z) => (\n                    <SelectItem key={z.id} value={z.id}>\n                      <span className=\"flex w-full items-center justify-between gap-4\">\n                        {z.city}\n                        <span className=\"font-mono text-muted-foreground text-xs tabular-nums\">\n                          {offsets ? formatOffset(offsets[z.id] ?? 0) : \"\"}\n                        </span>\n                      </span>\n                    </SelectItem>\n                  ))}\n                </SelectPopup>\n              </Select>\n            </div>\n          </div>\n        </Section>\n        <div className=\"h-20\" />\n      </SettingsShell>\n\n      <CropDialog\n        initial={draft.avatar ?? { palette: \"dusk\", x: 0, y: 0, zoom: 1 }}\n        initials={initials}\n        onApply={(crop) => set(\"avatar\", crop)}\n        onOpenChange={setCropOpen}\n        open={cropOpen}\n      />\n    </div>\n  );\n}\n"
    }
  ]
}