{
  "name": "back-to-top",
  "type": "ui:component",
  "title": "BackToTop",
  "description": "Scroll-aware floating pill button that appears smoothly past a scroll threshold.",
  "dependencies": [
    "@lucide/icons"
  ],
  "registryDependencies": [
    "theme",
    "icon"
  ],
  "files": [
    {
      "path": "src/ui/back-to-top.tsx",
      "target": "src/ui/back-to-top.tsx",
      "sha256": "394447e2e989f3ffe6e0e7b68bafcedeaa25e2ae800ec22c2117a06a28853116",
      "content": "import './theme.css';\nimport { ArrowUp } from '@lucide/icons';\nimport { scope, type Ctx } from '@fierst/aster';\nimport { Icon } from './icon';\n\nconst bttScope = scope`\n  :scope {\n    position: fixed;\n    right: calc(1.25rem + var(--aster-safe-right));\n    bottom: calc(1.25rem + var(--aster-safe-bottom));\n    z-index: 40;\n    height: 38px;\n    padding: 0 0.85rem;\n    border-radius: 9999px;\n    border: 1px solid var(--aster-border);\n    background: var(--aster-surface);\n    color: var(--aster-on-surface);\n    box-shadow: var(--aster-shadow-md);\n    font-family: var(--aster-font-sans);\n    font-size: 0.8125rem;\n    font-weight: 500;\n    display: inline-flex;\n    align-items: center;\n    gap: 0.35rem;\n    cursor: pointer;\n    transition: transform var(--aster-dur-fast), background-color var(--aster-dur-fast);\n  }\n  :scope:hover { background: var(--aster-surface-muted); transform: translateY(-2px); }\n  :scope:focus-visible { outline: none; box-shadow: var(--aster-focus-ring), var(--aster-shadow-md); }\n`;\n\nexport function* BackToTop(\n  props: {\n    threshold?: number;\n    label?: string;\n    class?: string;\n  },\n  ctx: Ctx,\n) {\n  let visible = false;\n\n  if (typeof window !== 'undefined') {\n    const onScroll = () => {\n      const next = window.scrollY > (props.threshold ?? 320);\n      if (next !== visible) {\n        visible = next;\n        ctx.refresh();\n      }\n    };\n    window.addEventListener('scroll', onScroll, { passive: true, signal: ctx.signal });\n  }\n\n  for (props of ctx) {\n    if (!visible) {\n      yield null;\n      continue;\n    }\n    yield (\n      <button\n        type=\"button\"\n        class={[bttScope, props.class].filter(Boolean).join(' ')}\n        aria-label={props.label ?? 'Back to top'}\n        onClick={() =>\n          window.scrollTo({\n            top: 0,\n            behavior: window.matchMedia('(prefers-reduced-motion: reduce)').matches\n              ? 'instant'\n              : 'smooth',\n          })\n        }\n      >\n        <Icon icon={ArrowUp} size={14} />\n        <span>{props.label ?? 'Top'}</span>\n      </button>\n    );\n  }\n}\n"
    }
  ]
}
