{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "glass-sidebar",
  "title": "Glass Sidebar",
  "description": "A workspace sidebar with a continuous contour that opens around hovered links and flows back to your selection.",
  "dependencies": [
    "motion",
    "tailwindcss-concentric"
  ],
  "registryDependencies": [
    "utils",
    "@animate-ui/icons-chevron-right",
    "@animate-ui/icons-search",
    "@animate-ui/icons-x"
  ],
  "files": [
    {
      "path": "components/ui/glass-sidebar.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { AnimateIcon } from \"@/components/animate-ui/icons/icon\"\nimport { ChevronRight } from \"@/components/animate-ui/icons/chevron-right\"\nimport { motion, useMotionValue, useSpring, useTransform } from \"motion/react\"\nimport { cn } from \"@/lib/utils\"\nimport { LiquidSearch } from \"@/components/ui/liquid-search\"\n\ntype GlassSidebarItem = {\n  id: string\n  label: string\n  icon?: React.ReactNode\n  badge?: string\n  href?: string\n  /** Additional terms matched by the local search. */\n  keywords?: string\n}\ntype GlassSidebarHeading = { heading: string }\ntype GlassSidebarProps = Omit<React.ComponentProps<\"aside\">, \"children\" | \"defaultValue\" | \"onChange\"> & {\n  items: (GlassSidebarItem | GlassSidebarHeading)[]\n  value?: string\n  defaultValue?: string\n  onValueChange?: (id: string) => void\n  /** Replaces the brand row above search. */\n  header?: React.ReactNode\n  /** Account details or other content anchored below navigation. */\n  footer?: React.ReactNode\n  /** Shows a local filter for the navigation rows. */\n  searchable?: boolean\n  searchPlaceholder?: string\n}\n\nconst reducedMotionQuery = \"(prefers-reduced-motion: reduce)\"\nfunction subscribeReducedMotion(onChange: () => void) {\n  const media = window.matchMedia(reducedMotionQuery)\n  media.addEventListener(\"change\", onChange)\n  return () => media.removeEventListener(\"change\", onChange)\n}\nconst readReducedMotion = () => window.matchMedia(reducedMotionQuery).matches\nconst serverReducedMotion = () => true\n\nfunction GlassSidebar({ items, value, defaultValue, onValueChange, header, footer, searchable = true, searchPlaceholder = \"Find a page\", className, \"aria-label\": label = \"Sidebar\", ...props }: GlassSidebarProps) {\n  const [query, setQuery] = React.useState(\"\")\n  const [internal, setInternal] = React.useState(defaultValue ?? items.find(item => \"id\" in item)?.id)\n  const [hovered, setHovered] = React.useState<string | null>(null)\n  const [focused, setFocused] = React.useState<string | null>(null)\n  const uid = React.useId()\n  const reduceMotion = React.useSyncExternalStore(subscribeReducedMotion, readReducedMotion, serverReducedMotion)\n  const active = value ?? internal\n  const nav = React.useRef<HTMLElement>(null)\n  const [track, setTrack] = React.useState<{ top: number; bottom: number; width: number; rows: Record<string, number>; heights: Record<string, number> } | null>(null)\n  const lineStart = useMotionValue(0)\n  const lineEnd = useMotionValue(0)\n  const lineWidth = useMotionValue(240)\n  const rowHeight = useMotionValue(36)\n  const lineY = useSpring(0, { stiffness: 400, damping: 40, mass: 0.8 })\n  const ready = React.useRef(false)\n  // Keep the active outline square and open on the rail side, so the rail joins\n  // the row cleanly with a compact, squarish corner radius.\n  const contour = useTransform([lineY, lineWidth, rowHeight], ([y, width, height]: number[]) => {\n    const top = y - height / 2\n    const bottom = y + height / 2\n    const radius = Math.min(8, height / 3)\n    const right = Math.max(32, width - 6)\n    return `M 9 ${top - radius} Q 9 ${top} ${9 + radius} ${top} H ${right - radius} Q ${right} ${top} ${right} ${top + radius} V ${bottom - radius} Q ${right} ${bottom} ${right - radius} ${bottom} H ${9 + radius} Q 9 ${bottom} 9 ${bottom + radius}`\n  })\n  const seam = useTransform([lineStart, lineEnd, lineY, rowHeight], ([start, end, y, height]: number[]) => {\n    const top = y - height / 2\n    const bottom = y + height / 2\n    const radius = Math.min(8, height / 3)\n    return `M 9 ${start} V ${top - radius} M 9 ${bottom + radius} V ${end}`\n  })\n\n  function choose(id: string) {\n    if (value === undefined) setInternal(id)\n    onValueChange?.(id)\n  }\n\n  function onKeyDown(event: React.KeyboardEvent<HTMLElement>) {\n    const rows = [...(nav.current?.querySelectorAll<HTMLElement>(\"[data-sidebar-item]\") ?? [])]\n    const index = rows.indexOf(event.target as HTMLElement)\n    if (index < 0) return\n    const target = event.key === \"ArrowDown\" ? Math.min(index + 1, rows.length - 1)\n      : event.key === \"ArrowUp\" ? Math.max(index - 1, 0)\n      : event.key === \"Home\" ? 0 : event.key === \"End\" ? rows.length - 1 : null\n    if (target === null) return\n    event.preventDefault()\n    setHovered(null)\n    rows[target]?.focus()\n  }\n  const visible = React.useMemo(() => {\n    const q = query.trim().toLowerCase()\n    if (!q) return items\n    const result: (GlassSidebarItem | GlassSidebarHeading)[] = []\n    let heading: GlassSidebarHeading | undefined\n    for (const item of items) {\n      if (\"heading\" in item) heading = item\n      else if (`${item.label} ${item.keywords ?? \"\"}`.toLowerCase().includes(q)) {\n        if (heading) { result.push(heading); heading = undefined }\n        result.push(item)\n      }\n    }\n    return result\n  }, [items, query])\n  // A search can remove the hovered, focused, or selected row. Ignore stale\n  // targets so the seam stays visible until a matching row is highlighted.\n  const highlighted = [hovered, focused, active].find(id =>\n    id != null && visible.some(item => \"id\" in item && item.id === id)\n  )\n  const target = track?.rows[highlighted ?? \"\"]\n  // Measure only on layout changes; spring values move the SVG without React renders.\n  React.useLayoutEffect(() => {\n    const root = nav.current\n    if (!root) { ready.current = false; return }\n    const measure = () => {\n      const bounds = root.getBoundingClientRect()\n      const rows: Record<string, number> = {}\n      const heights: Record<string, number> = {}\n      root.querySelectorAll<HTMLElement>(\"[data-sidebar-item]\").forEach(row => {\n        const rect = row.getBoundingClientRect()\n        rows[row.dataset.sidebarItem!] = rect.top - bounds.top + rect.height / 2\n        heights[row.dataset.sidebarItem!] = rect.height\n      })\n      const positions = Object.values(rows)\n      if (!positions.length) { setTrack(null); return }\n      setTrack({ top: 0, bottom: bounds.height, width: bounds.width, rows, heights })\n    }\n    measure()\n    const observer = new ResizeObserver(measure)\n    observer.observe(root)\n    root.querySelectorAll(\"[data-sidebar-item]\").forEach(row => observer.observe(row))\n    return () => observer.disconnect()\n  }, [visible])\n\n  React.useLayoutEffect(() => {\n    if (!track) return\n    lineStart.set(track.top)\n    lineEnd.set(track.bottom)\n    lineWidth.set(track.width)\n    rowHeight.set(track.heights[highlighted ?? \"\"] ?? 36)\n    if (target === undefined) return\n    if (!ready.current || reduceMotion) lineY.jump(target)\n    else lineY.set(target)\n    ready.current = true\n  }, [highlighted, lineEnd, lineStart, lineWidth, lineY, reduceMotion, rowHeight, target, track])\n\n  return <aside data-slot=\"glass-sidebar\" aria-label={label} className={cn(\"relative flex min-h-96 w-full max-w-[264px] min-w-0 flex-col overflow-hidden rounded-[24px] border border-foreground/[0.09] bg-card/95 text-foreground antialiased shadow-[inset_0_1px_0_var(--gloss-highlight),0_16px_40px_-24px_var(--gloss-depth)] backdrop-blur-xl\", className)} {...props}>\n    <div data-slot=\"sidebar-header\" className=\"shrink-0 px-2 pb-1 pt-3\">\n      {header ?? <div className=\"flex items-center gap-3\">\n        <span className=\"grid size-8 shrink-0 place-items-center rounded-concentric border border-foreground/[0.08] bg-linear-to-b from-foreground/[0.055] to-foreground/[0.025] shadow-[inset_0_1px_0_var(--gloss-highlight)]\"><svg aria-hidden viewBox=\"0 0 24 24\" className=\"size-5 text-glow\"><path d=\"M5.5 14a6.5 6.5 0 0 1 13 0Z\" fill=\"currentColor\" /><path d=\"M3 17h18M7.5 20h9\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" /></svg></span>\n        <div className=\"min-w-0\"><p className=\"text-sm font-semibold tracking-tight\">Afterglow</p><p className=\"mt-0.5 text-[11px] text-muted-foreground\">Workspace</p></div>\n        <span className=\"ml-auto rounded-md border border-foreground/[0.08] px-1.5 py-0.5 text-[10px] tabular-nums text-foreground/40\">1.0</span>\n      </div>}\n      {searchable && <LiquidSearch className=\"mt-3\" aria-label={searchPlaceholder} placeholder={searchPlaceholder} value={query} onValueChange={setQuery} />}\n\n    </div>\n    <div data-slot=\"sidebar-scroll\" className=\"min-h-0 flex-1 overflow-y-auto px-2 pb-2 pt-1 [scrollbar-width:thin]\">\n      {visible.length ? <nav ref={nav} className=\"relative py-3\" aria-label={`${label} links`} onKeyDown={onKeyDown} onPointerLeave={() => setHovered(null)} onBlur={event => { if (!event.currentTarget.contains(event.relatedTarget)) setFocused(null) }}>\n        {track && <svg aria-hidden data-sidebar-line className=\"pointer-events-none absolute inset-0 h-full w-full overflow-visible\">\n          <defs><linearGradient id={`${uid}-line`} x1=\"0\" y1=\"0\" x2=\"1\" y2=\"0\"><stop stopColor=\"var(--glow)\" stopOpacity=\"0.2\" /><stop offset=\"0.5\" stopColor=\"var(--glow)\" stopOpacity=\"0.5\" /><stop offset=\"1\" stopColor=\"var(--glow)\" stopOpacity=\"0.3\" /></linearGradient></defs>\n          {target === undefined\n            ? <path data-sidebar-seam d={`M 9 ${track.top} V ${track.bottom}`} fill=\"none\" stroke=\"currentColor\" strokeOpacity=\"0.13\" strokeWidth=\"1\" strokeLinecap=\"round\" />\n            : <><motion.path data-sidebar-seam d={seam} fill=\"none\" stroke=\"currentColor\" strokeOpacity=\"0.13\" strokeWidth=\"1\" strokeLinecap=\"round\" /><motion.path data-sidebar-contour d={contour} fill=\"none\" stroke={`url(#${uid}-line)`} strokeWidth=\"1\" strokeLinecap=\"round\" /></>}\n        </svg>}\n        <ul className=\"space-y-0.5 pl-5\">\n          {visible.map((item, index) => {\n            if (\"heading\" in item) return <li key={`heading-${index}`} className={cn(\"flex items-center gap-3 px-3 pb-1.5 pt-3 text-[11px] font-medium text-foreground/45\", index === 0 && \"pt-0\")}><span>{item.heading}</span><span aria-hidden className=\"h-px flex-1 bg-foreground/[0.06]\" /></li>\n            const selected = active === item.id\n            const contents = <>\n              {/* concentric-ignore: mid-row, not in a corner of the panel */}\n              {item.icon && <span aria-hidden className={cn(\"relative grid size-7 shrink-0 place-items-center rounded-[8px] transition-colors duration-200 [&>svg]:size-[15px] [&>svg]:stroke-[1.65]\", selected || highlighted === item.id ? \"text-glow\" : \"text-foreground/50 group-hover:text-foreground/80\")}>{item.icon}</span>}\n              <span className=\"relative min-w-0 flex-1 truncate\">{item.label}</span>\n              {/* concentric-ignore: mid-row, not in a corner of the panel */}\n              {item.badge ? <span className={cn(\"relative min-w-5 shrink-0 rounded-md border border-foreground/[0.07] bg-foreground/[0.025] px-1.5 py-0.5 text-center text-[10px] leading-none tabular-nums transition-colors duration-150\", selected ? \"text-glow\" : \"text-foreground/45\")}>{item.badge}</span> : <ChevronRight aria-hidden size={13} className={cn(\"relative shrink-0 transition-[opacity,translate] duration-200 motion-reduce:transition-none\", highlighted === item.id ? \"translate-x-0 opacity-50\" : \"-translate-x-1 opacity-0\")} />}\n            </>\n            const common = {\n              \"data-sidebar-item\": item.id,\n              \"aria-current\": selected ? \"page\" as const : undefined,\n              className: cn(\"group relative flex min-h-9 scroll-my-3 w-full cursor-pointer items-center gap-2.5 rounded-[12px] px-2.5 py-1 text-left text-[13px] outline-none transition-colors duration-150 focus-visible:ring-2 focus-visible:ring-glow/60 motion-reduce:transition-none\", selected ? \"font-medium text-foreground\" : \"text-foreground/60 hover:text-foreground focus-visible:text-foreground\"),\n              onPointerEnter: (event: React.PointerEvent) => { if (event.pointerType !== \"touch\") setHovered(item.id) },\n              onFocus: () => setFocused(item.id),\n              onClick: (event: React.MouseEvent<HTMLElement>) => {\n                if (event.defaultPrevented || (item.href && (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey))) return\n                choose(item.id)\n              },\n            }\n            return <li key={item.id}><AnimateIcon animateOnHover asChild>{item.href ? <a {...common} href={item.href}>{contents}</a> : <button {...common} type=\"button\">{contents}</button>}</AnimateIcon></li>\n          })}\n        </ul>\n      </nav> : <p role=\"status\" className=\"px-3 text-xs text-muted-foreground\">No matching pages.</p>}\n    </div>\n    {footer && <div className=\"shrink-0 border-t border-foreground/[0.06] bg-foreground/[0.01] p-3\">{footer}</div>}\n  </aside>\n}\n\nexport { GlassSidebar, type GlassSidebarProps, type GlassSidebarItem, type GlassSidebarHeading }\n",
      "type": "registry:ui"
    },
    {
      "path": "components/ui/liquid-search.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { AnimateIcon } from \"@/components/animate-ui/icons/icon\"\nimport { Search } from \"@/components/animate-ui/icons/search\"\nimport { X } from \"@/components/animate-ui/icons/x\"\nimport { LiquidGlass } from \"@/components/ui/liquid-glass\"\nimport { cn } from \"@/lib/utils\"\n\ntype LiquidSearchProps = Omit<React.ComponentProps<\"input\">, \"type\" | \"size\" | \"value\" | \"defaultValue\" | \"onChange\"> & {\n  value?: string\n  defaultValue?: string\n  onValueChange?: (value: string) => void\n  /** Styles the input text separately from the glass capsule. */\n  inputClassName?: string\n}\n\nfunction LiquidSearch({ value, defaultValue = \"\", onValueChange, placeholder = \"Search anything\", className, inputClassName, disabled, readOnly, ref, onKeyDown, \"aria-label\": label, ...props }: LiquidSearchProps) {\n  const [internal, setInternal] = React.useState(defaultValue)\n  const input = React.useRef<HTMLInputElement>(null)\n  React.useImperativeHandle(ref, () => input.current!, [])\n  const text = value ?? internal\n  function update(next: string) {\n    if (value === undefined) setInternal(next)\n    onValueChange?.(next)\n  }\n  function clear() {\n    update(\"\")\n    input.current?.focus()\n  }\n  return <AnimateIcon animateOnHover asChild><div data-slot=\"liquid-search\" className={cn(\"group relative flex h-9 w-full min-w-0 items-center gap-2 rounded-[16px] p-1 text-foreground transition-shadow duration-200 focus-within:ring-2 focus-within:ring-glow/25\", disabled && \"pointer-events-none opacity-50\", className)}>\n    <LiquidGlass refraction={0} frost={6} tint=\"color-mix(in oklch, var(--card) 35%, transparent)\" className=\"pointer-events-none absolute inset-0 rounded-[inherit]\" />\n    <span aria-hidden className=\"relative grid size-7 shrink-0 place-items-center rounded-concentric bg-linear-to-b from-foreground/[0.065] to-foreground/[0.015] text-foreground/50 shadow-gloss transition-[color,scale] duration-200 group-focus-within:scale-[1.04] group-focus-within:text-glow motion-reduce:transition-none motion-reduce:group-focus-within:scale-100\"><Search aria-hidden size={14} strokeWidth={1.7} /></span>\n    <input {...props} ref={input} aria-label={label ?? placeholder} type=\"search\" disabled={disabled} readOnly={readOnly} placeholder={placeholder} value={text} onChange={event => update(event.target.value)} onKeyDown={event => {\n      onKeyDown?.(event)\n      if (!event.defaultPrevented && !event.nativeEvent.isComposing && event.key === \"Escape\" && text && !readOnly) {\n        event.preventDefault()\n        clear()\n      }\n    }} className={cn(\"relative h-full min-w-0 flex-1 appearance-none bg-transparent text-xs outline-none placeholder:text-foreground/40 [&::-webkit-search-cancel-button]:appearance-none\", inputClassName)} />\n    <AnimateIcon animateOnHover asChild><button type=\"button\" aria-label=\"Clear search\" disabled={disabled || readOnly || !text} tabIndex={text && !readOnly ? 0 : -1} onClick={clear} className={cn(\"relative grid size-6 shrink-0 cursor-pointer place-items-center rounded-concentric text-foreground/45 outline-none transition-[opacity,background-color] duration-150 hover:bg-foreground/[0.07] hover:text-foreground focus-visible:ring-2 focus-visible:ring-glow/50\", text && !readOnly ? \"opacity-100\" : \"pointer-events-none opacity-0\")}><X aria-hidden size={13} /></button></AnimateIcon>\n  </div></AnimateIcon>\n}\n\nexport { LiquidSearch, type LiquidSearchProps }\n",
      "type": "registry:ui"
    },
    {
      "path": "components/ui/liquid-glass.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport {\n  isMotionValue,\n  motion,\n  useMotionValue,\n  useTransform,\n  type MotionValue,\n} from \"motion/react\"\n\nimport { ringMask } from \"@/lib/afterglow\"\nimport { cn } from \"@/lib/utils\"\n\n/*\n * Liquid glass: a pane that bends whatever sits behind it, like Apple's\n * Liquid Glass. The rim is a curved lens, so content near the edges is\n * pulled inward, while the flat middle stays clear.\n *\n * Refraction is an SVG displacement map used as a backdrop-filter, which only\n * Chromium supports. Other browsers get a frosted fallback with the same rim.\n */\n\nconst SAMPLES = 128\nconst INDEX_OF_REFRACTION = 1.5\n\n// convex squircle: flat in the middle, rounding off toward the rim\nconst surface = (x: number) => Math.pow(1 - Math.pow(1 - x, 4), 0.25)\n\n// how far a straight-down ray is bent sideways at each point across the rim\nfunction rimProfile(bezel: number) {\n  const profile = new Float32Array(SAMPLES)\n  for (let i = 0; i < SAMPLES; i++) {\n    const x = i / (SAMPLES - 1)\n    const a = Math.max(x - 0.001, 0)\n    const b = Math.min(x + 0.001, 1)\n    const slope = (surface(b) - surface(a)) / (b - a)\n    const incident = Math.atan(slope)\n    const refracted = Math.asin(Math.sin(incident) / INDEX_OF_REFRACTION)\n    const thickness = bezel * (0.25 + surface(x))\n    profile[i] = thickness * Math.tan(incident - refracted)\n  }\n  return profile\n}\n\ntype DisplacementMap = { url: string; scale: number }\nconst maps = new Map<string, DisplacementMap>()\n\nfunction displacementMap(\n  width: number,\n  height: number,\n  radius: number,\n  bezel: number,\n  magnify: number\n): DisplacementMap {\n  const key = [width, height, radius, bezel, magnify].join(\":\")\n  const cached = maps.get(key)\n  if (cached) return cached\n\n  const profile = rimProfile(bezel)\n  const dx = new Float32Array(width * height)\n  const dy = new Float32Array(width * height)\n  let max = 0\n\n  for (let j = 0; j < height; j++) {\n    for (let i = 0; i < width; i++) {\n      // signed distance to a rounded rectangle, and the outward normal\n      const px = i + 0.5 - width / 2\n      const py = j + 0.5 - height / 2\n      const qx = Math.abs(px) - width / 2 + radius\n      const qy = Math.abs(py) - height / 2 + radius\n      const inside =\n        -(Math.hypot(Math.max(qx, 0), Math.max(qy, 0)) +\n          Math.min(Math.max(qx, qy), 0) -\n          radius)\n      let nx = 0\n      let ny = 0\n      if (qx > 0 && qy > 0) {\n        const length = Math.hypot(qx, qy) || 1\n        nx = (qx / length) * Math.sign(px)\n        ny = (qy / length) * Math.sign(py)\n      } else if (qx > qy) nx = Math.sign(px)\n      else ny = Math.sign(py)\n\n      let x = -px * magnify\n      let y = -py * magnify\n      if (inside >= 0 && inside < bezel) {\n        // sample inward, so the rim shows what's just inside the edge\n        const shift = profile[Math.round((inside / bezel) * (SAMPLES - 1))]\n        x -= nx * shift\n        y -= ny * shift\n      }\n      const k = j * width + i\n      dx[k] = x\n      dy[k] = y\n      max = Math.max(max, Math.abs(x), Math.abs(y))\n    }\n  }\n\n  const canvas = document.createElement(\"canvas\")\n  canvas.width = width\n  canvas.height = height\n  const context = canvas.getContext(\"2d\")\n  if (!context) return { url: \"\", scale: 0 }\n  const image = context.createImageData(width, height)\n  for (let k = 0; k < width * height; k++) {\n    // 128 is \"no shift\"; red moves along x, green along y\n    image.data[k * 4] = 128 + (dx[k] / (max || 1)) * 127\n    image.data[k * 4 + 1] = 128 + (dy[k] / (max || 1)) * 127\n    image.data[k * 4 + 2] = 128\n    image.data[k * 4 + 3] = 255\n  }\n  context.putImageData(image, 0, 0)\n\n  const map = { url: canvas.toDataURL(), scale: max * 2 }\n  if (maps.size > 48) maps.delete(maps.keys().next().value!)\n  maps.set(key, map)\n  return map\n}\n\n// only Chromium can use an SVG filter as a backdrop-filter\nfunction canRefract() {\n  const nav = navigator as Navigator & {\n    userAgentData?: { brands: { brand: string }[] }\n  }\n  if (nav.userAgentData) {\n    return nav.userAgentData.brands.some((b) => b.brand === \"Chromium\")\n  }\n  return /Chrome\\/\\d+/.test(nav.userAgent) && !/Firefox|FxiOS/.test(nav.userAgent)\n}\n\nconst noopSubscribe = () => () => {}\n\nfunction useCanRefract() {\n  return React.useSyncExternalStore(noopSubscribe, canRefract, () => false)\n}\n\ntype LiquidGlassProps = React.ComponentProps<\"div\"> & {\n  /** width of the curved rim in px, defaults to the corner radius (max 24) */\n  bezel?: number\n  /** 0 is flat glass, 1 is the full lens; pass a motion value to animate it */\n  refraction?: number | MotionValue<number>\n  /** zooms the middle like a magnifier, 0 to 0.3 */\n  magnify?: number\n  /** blur behind the glass in px */\n  frost?: number\n  /** a color mixed over the glass, e.g. for a tinted primary button */\n  tint?: string\n  /**\n   * fades the whole pane in and out. Never fade a parent of liquid glass\n   * instead: an ancestor with opacity cuts the glass off from what's behind it.\n   */\n  presence?: number | MotionValue<number>\n}\n\nfunction LiquidGlass({\n  bezel,\n  refraction = 1,\n  magnify = 0,\n  frost = 1,\n  tint,\n  presence = 1,\n  className,\n  children,\n  ...props\n}: LiquidGlassProps) {\n  const ref = React.useRef<HTMLDivElement>(null)\n  const displaceRef = React.useRef<SVGFEDisplacementMapElement>(null)\n  const id = `liquid-${React.useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`\n  const canRefractHere = useCanRefract()\n  // A fixed zero opts out of SVG backdrop sampling entirely. Native frosting avoids\n  // clipped-backdrop seams when flat panes overlap and change stacking order.\n  // Motion values still keep the map ready so they can animate away from zero.\n  const refract = canRefractHere && (typeof refraction !== \"number\" || refraction > 0)\n  const [shape, setShape] = React.useState<{ w: number; h: number; r: number }>()\n  // the scale last written to the filter, so a no-op resize can put it back\n  const applied = React.useRef(0)\n\n  React.useEffect(() => {\n    const node = ref.current\n    if (!node || !refract) return\n    const measure = () => {\n      const w = Math.round(node.offsetWidth)\n      const h = Math.round(node.offsetHeight)\n      const raw = getComputedStyle(node).borderTopLeftRadius\n      const value = parseFloat(raw) || 0\n      const r = Math.round(\n        Math.min(raw.endsWith(\"%\") ? (value / 100) * Math.min(w, h) : value, w / 2, h / 2)\n      )\n      setShape((prev) => {\n        if (prev?.w === w && prev.h === h && prev.r === r) {\n          displaceRef.current?.setAttribute(\"scale\", String(applied.current))\n          return prev\n        }\n        return { w, h, r }\n      })\n    }\n    // measure right away, then wait for resizing to settle before rebuilding the map\n    let first = true\n    let frame = 0\n    let timer = 0\n    const observer = new ResizeObserver(() => {\n      if (first) {\n        first = false\n        measure()\n        return\n      }\n      // until the new map is ready, the old one would bend the wrong pixels\n      displaceRef.current?.setAttribute(\"scale\", \"0\")\n      window.clearTimeout(timer)\n      timer = window.setTimeout(() => {\n        frame = requestAnimationFrame(measure)\n      }, 100)\n    })\n    observer.observe(node)\n    return () => {\n      observer.disconnect()\n      window.clearTimeout(timer)\n      cancelAnimationFrame(frame)\n    }\n  }, [refract])\n\n  const map = React.useMemo(() => {\n    if (!refract || !shape || shape.w < 2 || shape.h < 2) return undefined\n    const rim = Math.max(1, Math.min(bezel ?? Math.min(shape.r, 24), shape.w / 2, shape.h / 2))\n    return displacementMap(shape.w, shape.h, shape.r, Math.round(rim), magnify)\n  }, [bezel, magnify, refract, shape])\n\n  // animate refraction by scaling the filter, without rebuilding the map\n  React.useEffect(() => {\n    if (!map) return\n    const apply = (v: number) => {\n      applied.current = map.scale * v\n      displaceRef.current?.setAttribute(\"scale\", String(applied.current))\n    }\n    if (typeof refraction === \"number\") {\n      apply(refraction)\n      return\n    }\n    apply(refraction.get())\n    return refraction.on(\"change\", apply)\n  }, [map, refraction])\n\n  const ownPresence = useMotionValue(isMotionValue(presence) ? 1 : presence)\n  const visible = isMotionValue(presence) ? presence : ownPresence\n  React.useEffect(() => {\n    if (!isMotionValue(presence)) ownPresence.set(presence)\n  }, [ownPresence, presence])\n  const rimOpacity = useTransform(visible, (v) => v * 0.95)\n\n  const strength = isMotionValue(refraction) ? refraction.get() : refraction\n  const backdrop = map\n    ? `url(#${id})`\n    : `blur(${Math.max(frost, 10)}px) saturate(1.6)`\n\n  return (\n    <div\n      ref={ref}\n      data-slot=\"liquid-glass\"\n      // no isolation here: an isolated parent cuts the glass off from the scene\n      // behind it in Chrome. Layers stack in source order, and direct children\n      // are made relative so they sit on top (wrap an absolute child to keep it).\n      className={cn(\"relative [&>:where(:not([data-glass-layer]))]:relative\", className)}\n      {...props}\n    >\n      {map && (\n        <svg data-glass-layer aria-hidden width=\"0\" height=\"0\" className=\"pointer-events-none absolute\">\n          <filter id={id} colorInterpolationFilters=\"sRGB\">\n            <feGaussianBlur in=\"SourceGraphic\" stdDeviation={frost} result=\"frost\" />\n            <feImage\n              href={map.url}\n              x=\"0\"\n              y=\"0\"\n              width={shape?.w}\n              height={shape?.h}\n              preserveAspectRatio=\"none\"\n              result=\"map\"\n            />\n            <feDisplacementMap\n              ref={displaceRef}\n              in=\"frost\"\n              in2=\"map\"\n              scale={map.scale * strength}\n              xChannelSelector=\"R\"\n              yChannelSelector=\"G\"\n              result=\"bent\"\n            />\n            {/* glass makes what's behind it a little brighter and more vivid */}\n            <feColorMatrix in=\"bent\" type=\"saturate\" values=\"1.45\" result=\"vivid\" />\n            <feComponentTransfer in=\"vivid\">\n              <feFuncR type=\"linear\" slope=\"1.05\" />\n              <feFuncG type=\"linear\" slope=\"1.05\" />\n              <feFuncB type=\"linear\" slope=\"1.05\" />\n            </feComponentTransfer>\n          </filter>\n        </svg>\n      )}\n      <motion.div\n        data-glass-layer\n        aria-hidden\n        className=\"pointer-events-none absolute inset-0 rounded-[inherit] shadow-[0_10px_30px_-10px_var(--liquid-shadow),0_2px_8px_-2px_var(--liquid-shadow)]\"\n        style={{ opacity: visible }}\n      />\n      <motion.div\n        data-glass-layer\n        aria-hidden\n        className=\"pointer-events-none absolute inset-0 rounded-[inherit]\"\n        style={{\n          backdropFilter: backdrop,\n          WebkitBackdropFilter: backdrop,\n          opacity: visible,\n        }}\n      />\n      {/* tint, heavier when there's no refraction so text stays legible */}\n      <motion.div\n        data-glass-layer\n        aria-hidden\n        className={cn(\n          \"pointer-events-none absolute inset-0 rounded-[inherit] bg-(--liquid-tint)\",\n          !map && \"bg-(--liquid-fallback)\"\n        )}\n        style={tint ? { background: tint, opacity: visible } : { opacity: visible }}\n      />\n      {/* volume: light gathers inside the top edge, shade settles along the bottom */}\n      <motion.div\n        data-glass-layer\n        aria-hidden\n        className=\"pointer-events-none absolute inset-0 rounded-[inherit] shadow-[inset_0_1px_16px_-4px_var(--liquid-glow),inset_0_-12px_20px_-14px_var(--liquid-shade)]\"\n        style={{ opacity: visible }}\n      />\n      {/* rim light: bright where the light comes from (top left), softer opposite */}\n      <motion.div\n        data-glass-layer\n        aria-hidden\n        className=\"pointer-events-none absolute inset-0 rounded-[inherit] shadow-[inset_0_0_0_0.5px_var(--liquid-edge),inset_1px_1.5px_1px_-1px_var(--liquid-rim),inset_-1px_-1.5px_1px_-1px_color-mix(in_oklch,var(--liquid-rim)_45%,transparent)]\"\n        style={{ opacity: visible }}\n      />\n      <motion.div\n        data-glass-layer\n        aria-hidden\n        className=\"pointer-events-none absolute inset-0 rounded-[inherit] p-px\"\n        style={{\n          ...ringMask,\n          background:\n            \"conic-gradient(from 300deg, var(--liquid-rim), transparent 70deg, transparent 110deg, color-mix(in oklch, var(--liquid-rim) 55%, transparent) 180deg, transparent 250deg, transparent 290deg, var(--liquid-rim))\",\n          opacity: rimOpacity,\n        }}\n      />\n      {children}\n    </div>\n  )\n}\n\nexport { LiquidGlass, useCanRefract, type LiquidGlassProps }\n",
      "type": "registry:ui"
    },
    {
      "path": "lib/afterglow.ts",
      "content": "import type { CSSProperties } from \"react\"\nimport type { TargetAndTransition, Transition } from \"motion/react\"\n\n// shared spring presets, every component picks from these\nexport const springs = {\n  snappy: { stiffness: 520, damping: 34, mass: 0.6 },\n  soft: { stiffness: 260, damping: 26, mass: 0.8 },\n  glide: { stiffness: 120, damping: 20, mass: 1 },\n} as const\n\nexport type SpringName = keyof typeof springs\n\nexport function spring(name: SpringName): Transition {\n  return { type: \"spring\", ...springs[name] }\n}\n\n// how a glow fades once its source moves away: slow, with a long tail\nexport const afterglow = {\n  linger: 0.9,\n  ease: [0.22, 1, 0.36, 1],\n} as const satisfies { linger: number; ease: Transition[\"ease\"] }\n\n// paints only the padding ring of an element, used for glowing borders\nexport const ringMask: CSSProperties = {\n  WebkitMask:\n    \"linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)\",\n  WebkitMaskComposite: \"xor\",\n  mask: \"linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)\",\n  maskComposite: \"exclude\",\n}\n\n// small icon gestures, played when a control is pressed or selected\nexport const iconGestures = {\n  pop: { scale: [1, 1.2, 1] },\n  ring: { rotate: [0, -18, 14, -9, 4, 0], scale: [1, 1.12, 1] },\n  // a gear looks the same after half a turn, so it can rest there and snap back unseen\n  turn: { rotate: [0, 180], scale: [1, 1.12, 1] },\n  hop: { y: [0, -3, 0], scale: [1, 1.1, 1] },\n  nudge: { x: [0, 2.5, 0], scale: [1, 1.1, 1] },\n} satisfies Record<string, TargetAndTransition>\n\nexport type IconGesture = keyof typeof iconGestures\n\n// leaving a gesture is instant: every gesture already ends at, or looks like, its resting pose\nexport const iconRest: TargetAndTransition = { scale: 1, rotate: 0, x: 0, y: 0, transition: { duration: 0 } }\n",
      "type": "registry:lib"
    }
  ],
  "cssVars": {
    "theme": {
      "color-glow": "var(--glow)",
      "color-glow-foreground": "var(--glow-foreground)",
      "color-glow-2": "var(--glow-2)",
      "color-glow-3": "var(--glow-3)",
      "color-glass": "var(--glass)",
      "color-gloss-highlight": "var(--gloss-highlight)",
      "shadow-gloss": "inset 0 1px 0 0 var(--gloss-highlight), inset 0 -1px 0 0 var(--gloss-shade), 0 0 0 1px var(--gloss-edge), 0 1px 2px 0 var(--gloss-depth), 0 4px 12px -4px var(--gloss-depth)",
      "shadow-glass": "inset 0 1px 0 0 var(--gloss-highlight), inset 0 -10px 24px -18px var(--gloss-shade), inset 0 0 0 1px var(--gloss-edge), 0 2px 6px -1px var(--gloss-depth), 0 18px 40px -12px var(--gloss-depth)",
      "shadow-well": "inset 0 1px 3px 0 var(--gloss-depth), inset 0 0 0 1px var(--gloss-edge), 0 1px 0 0 var(--gloss-highlight)"
    },
    "light": {
      "glow": "oklch(0.7 0.19 45)",
      "glow-foreground": "oklch(0.22 0.05 40)",
      "glow-2": "oklch(0.64 0.22 12)",
      "glow-3": "oklch(0.56 0.21 300)",
      "glass": "oklch(1 0 0 / 55%)",
      "gloss-highlight": "oklch(1 0 0 / 95%)",
      "gloss-shade": "oklch(0.3 0.03 285 / 10%)",
      "gloss-depth": "oklch(0.32 0.03 285 / 20%)",
      "gloss-edge": "oklch(0.22 0.02 285 / 10%)",
      "liquid-tint": "oklch(1 0 0 / 18%)",
      "liquid-fallback": "oklch(1 0 0 / 55%)",
      "liquid-rim": "oklch(1 0 0 / 95%)",
      "liquid-edge": "oklch(0.2 0.02 285 / 10%)",
      "liquid-shadow": "oklch(0.22 0.02 285 / 26%)",
      "liquid-glow": "oklch(1 0 0 / 55%)",
      "liquid-shade": "oklch(0.25 0.03 285 / 14%)"
    },
    "dark": {
      "glow": "oklch(0.8 0.16 55)",
      "glow-foreground": "oklch(0.22 0.05 40)",
      "glow-2": "oklch(0.7 0.2 15)",
      "glow-3": "oklch(0.65 0.2 300)",
      "glass": "oklch(0.19 0 0 / 55%)",
      "gloss-highlight": "oklch(1 0 0 / 16%)",
      "gloss-shade": "oklch(0 0 0 / 30%)",
      "gloss-depth": "oklch(0.04 0 0 / 60%)",
      "gloss-edge": "oklch(1 0 0 / 9%)",
      "liquid-tint": "oklch(0.2 0 0 / 22%)",
      "liquid-fallback": "oklch(0.2 0 0 / 45%)",
      "liquid-rim": "oklch(1 0 0 / 60%)",
      "liquid-edge": "oklch(1 0 0 / 10%)",
      "liquid-shadow": "oklch(0 0 0 / 50%)",
      "liquid-glow": "oklch(1 0 0 / 24%)",
      "liquid-shade": "oklch(0 0 0 / 28%)"
    }
  },
  "css": {
    "@import \"tailwindcss-concentric\"": {}
  },
  "type": "registry:ui"
}