{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "motion",
  "title": "Motion",
  "description": "Shared motion tokens — hover language, presence helpers, timeline reveal (Family Values easings, no springs/blur).",
  "files": [
    {
      "path": "registry/default/lib/motion.ts",
      "content": "/**\n * Shared motion tokens — Family Values fluidity + Zajno × Motion.dev taste.\n *\n * ## Taste brief (locked)\n *\n * Sources (principles as tokens/comments — not copy):\n * - https://motion.zajno.com/ — easing, offset/delay, fade, transform/morph\n * - https://motion.dev/docs/react-layout-animations — `layout` / `layoutId` / `LayoutGroup`\n * - https://motion.dev/docs/react-animate-presence — exit; `mode=\"wait\"` | `\"popLayout\"`\n * - https://motion.dev/docs/react-transitions — tween duration/ease (no spring bounce on chrome)\n * - https://motion.dev/examples?category=base-ui — Base UI presence patterns\n *\n * Zajno → AtroUI:\n * 1. **Easing** — UI settle is ease-out, never linear chrome. `easeOutExpo` for arrive /\n *    focus moments; `easeOutSoft` for panels / drawers / page chrome.\n * 2. **Offset & delay** — `staggerChildren` / `delayChildren` for hierarchy; keep ≤40–50ms\n *    (`stagger()` / `STAGGER_MAX`). Prefer Motion's `stagger()` from `motion/react` with\n *    our clamped seconds: `delayChildren: motionStagger(stagger(0.04))`.\n * 3. **Fade-in/out** — always pair opacity with subtle y or scale on popups (not opacity\n *    alone). Backdrop fades are the opacity-only exception.\n * 4. **Transform & morph** — shared elements travel via `layout` / `layoutId` +\n *    `LayoutGroup`; remounts feel like teleport.\n * 5. **Skip fireworks on primitives** — no parallax / zoom / blur-orb soup on catalog chrome.\n *\n * Motion.dev notes:\n * - Tweens only on chrome (`type: \"tween\"`). No spring overshoot (Family Values).\n * - AnimatePresence: default crossfade when heights differ; `mode=\"wait\"` only when the\n *    outgoing must finish first; `popLayout` when exiting siblings should free layout space.\n * - `MotionConfig` defaults: pass `{...atroMotionDefaults}` (docs playground).\n *\n * Rules:\n * - Opacity always present on exit so Base UI `getAnimations()` can await leave.\n * - `useReducedMotion` → duration 0 / skip scale (call sites pass `reduce`).\n * - Chrome ≤300ms; press ≤100ms. Exit can run slightly faster than enter.\n */\n\n/** Sharp settle for dialogs / focus / arrive moments (Zajno ease-out arrive) */\nexport const easeOutExpo = [0.16, 1, 0.3, 1] as const\n\n/** Soft settle for panels / drawers / page chrome (Zajno ease-out soft) */\nexport const easeOutSoft = [0.32, 0.72, 0, 1] as const\n\n/**\n * Enter / exit ease pairing (Zajno: correct easing on both legs).\n * Enter = arrive (expo); exit = soft settle out, slightly quicker via `exitTween`.\n */\nexport const enterEase = easeOutExpo\nexport const exitEase = easeOutSoft\n\n/** Exit durations ≈ 80% of enter (Zajno: leave a beat faster than arrive). */\nexport const EXIT_DURATION_SCALE = 0.8\n\n/** Default / max stagger between children (seconds). Hierarchy soft — ≤40–50ms. */\nexport const STAGGER_DEFAULT = 0.04\nexport const STAGGER_MAX = 0.05\n\n/**\n * Clamp a stagger delay (seconds) for `staggerChildren` or Motion's `stagger()`.\n * Caps at {@link STAGGER_MAX} so list hierarchy stays subtle.\n *\n * ```ts\n * import { stagger as motionStagger } from \"motion/react\"\n * import { stagger } from \"atroui\"\n * // variants: { show: { transition: { staggerChildren: stagger(0.04) } } }\n * // or:      { show: { transition: { delayChildren: motionStagger(stagger()) } } }\n * ```\n */\nexport function stagger(delay: number = STAGGER_DEFAULT): number {\n  if (!Number.isFinite(delay) || delay < 0) return 0\n  return Math.min(delay, STAGGER_MAX)\n}\n\n/** @deprecated Prefer {@link stagger} — same clamp. */\nexport const staggerDelay = stagger\n\n/** Build an enter tween (ease-out arrive). */\nexport function enterTween(\n  duration: number,\n  ease: readonly [number, number, number, number] | \"easeOut\" = enterEase\n) {\n  return { type: \"tween\" as const, duration, ease }\n}\n\n/** Build an exit tween — slightly faster than the matching enter. */\nexport function exitTween(\n  enterDuration: number,\n  ease: readonly [number, number, number, number] | \"easeOut\" = exitEase\n) {\n  return {\n    type: \"tween\" as const,\n    duration: enterDuration * EXIT_DURATION_SCALE,\n    ease,\n  }\n}\n\n/** Pair enter + exit tweens from one enter duration (presence helpers). */\nexport function presenceTweens(\n  enterDuration: number,\n  ease: readonly [number, number, number, number] | \"easeOut\" = enterEase,\n  exitEaseOverride: readonly [number, number, number, number] | \"easeOut\" = exitEase\n) {\n  return {\n    enter: enterTween(enterDuration, ease),\n    exit: exitTween(enterDuration, exitEaseOverride),\n  }\n}\n\n/**\n * Defaults for `<MotionConfig {...atroMotionDefaults}>` (docs playground).\n * Tween-only chrome — consumers override per-surface with dialog/popup/panel tokens.\n */\nexport const atroMotionDefaults = {\n  transition: {\n    type: \"tween\" as const,\n    duration: 0.2,\n    ease: easeOutSoft,\n  },\n  reducedMotion: \"user\" as const,\n} as const\n\n/** Overlay / drawer panel slide */\nexport const panelTween = {\n  type: \"tween\" as const,\n  duration: 0.28,\n  ease: easeOutSoft,\n} as const\n\n/** Backdrop fade */\nexport const fadeTween = {\n  type: \"tween\" as const,\n  duration: 0.2,\n  ease: \"easeOut\" as const,\n} as const\n\n/** Dialog / command panel appear */\nexport const dialogTween = {\n  type: \"tween\" as const,\n  duration: 0.22,\n  ease: easeOutExpo,\n} as const\n\n/** Anchored popup (menu / popover) settle */\nexport const popupTween = {\n  type: \"tween\" as const,\n  duration: 0.2,\n  ease: easeOutSoft,\n} as const\n\n/** Collapsible height (sidebar sections, accordion) */\nexport const revealTween = {\n  type: \"tween\" as const,\n  duration: 0.24,\n  ease: easeOutSoft,\n} as const\n\n/** Docs / blog page content continuity */\nexport const pageFade = {\n  type: \"tween\" as const,\n  duration: 0.18,\n  ease: easeOutSoft,\n} as const\n\n/**\n * Route enter — full continuity beat for page-level content.\n * Opacity + y + blur settle (expo). Chrome (sidebar/TOC/header) stays\n * mounted; only the measure column re-enters. Reduced motion → duration 0.\n */\nexport const pageEnterTween = {\n  type: \"tween\" as const,\n  duration: 0.4,\n  ease: easeOutExpo,\n} as const\n\n/** Route enter travel in px — one step above the scroll-reveal beat. */\nexport const PAGE_ENTER_Y = 12\n\n/** Route enter blur in px — paired with y + opacity, never alone. */\nexport const PAGE_ENTER_BLUR = 4\n\n/**\n * Marketing chrome hide-on-scroll (Motion scroll-direction pattern).\n * Docs book headers stay fixed — never pass this tween there.\n * Call sites: `useReducedMotion` → skip hide (stay visible, no travel).\n */\nexport const SCROLL_HIDE_OFFSET = 150\n\nexport const scrollHideTween = {\n  type: \"tween\" as const,\n  duration: 0.28,\n  ease: easeOutSoft,\n} as const\n\n/** Button / control press feedback (scale / translate) — ≤100ms */\nexport const pressTween = {\n  type: \"tween\" as const,\n  duration: 0.1,\n  ease: easeOutExpo,\n} as const\n\n/**\n * Signature hover language (soft-rect Mira chrome):\n * Material brightens (CSS); geometry barely lifts; ink travels; never grow.\n * Hover ≤1px y; press into surface; focus mirrors hover.\n */\nexport const hoverLift = { y: -1 } as const\nexport const pressInto = { scale: 0.98, y: 1 } as const\n/** Alias — keyboard focus uses the same target as hover. */\nexport const focusAsHover = hoverLift\n\n/** Hover / focus settle — slightly longer Soft than press. */\nexport const hoverTween = {\n  type: \"tween\" as const,\n  duration: 0.14,\n  ease: easeOutSoft,\n} as const\n\n/**\n * Gesture targets for soft-rect controls.\n * Prefer per-gesture transitions so press stays ≤100ms Expo while hover Soft.\n */\nexport function controlGestures(reduce?: boolean | null) {\n  if (reduce) {\n    return {\n      whileHover: undefined,\n      whileFocus: undefined,\n      whileTap: undefined,\n    }\n  }\n  return {\n    whileHover: { ...hoverLift, transition: hoverTween },\n    whileFocus: { ...focusAsHover, transition: hoverTween },\n    whileTap: { ...pressInto, transition: pressTween },\n  }\n}\n\n/**\n * Scroll / timeline sequence reveal — opacity + y only (never blur).\n * Delay step is landing-scale (~120ms), not list {@link stagger} (≤50ms).\n */\nexport const LANDING_STAGGER = 0.12\n\nexport const timelineRevealVariants = {\n  visible: (i: number) => ({\n    y: 0,\n    opacity: 1,\n    transition: {\n      delay: i * LANDING_STAGGER,\n      ...enterTween(0.28, easeOutExpo),\n    },\n  }),\n  hidden: { y: 12, opacity: 0 },\n} as const\n\n/**\n * In-view / section reveal enter (FadeIn).\n * Longer expo settle — premium scroll reveals run 400–550ms,\n * not the 280ms chrome beat. Accordion/collapsible keep `revealTween`.\n */\nexport const inViewTween = {\n  type: \"tween\" as const,\n  duration: 0.45,\n  ease: easeOutExpo,\n} as const\n\n/**\n * Opt-in scroll-reveal blur in px — pass to FadeIn `blur`.\n * Off by default (Family Values: blur-in alone reads as AI-slop atmosphere).\n */\nexport const SCROLL_REVEAL_BLUR = 4\n\n/** Tooltip appear / dismiss */\nexport const tooltipTween = {\n  type: \"tween\" as const,\n  duration: 0.12,\n  ease: easeOutExpo,\n} as const\n\n/** Toast edge enter / exit (opacity + y) — keep ≤220ms; stack via CSS vars */\nexport const toastTween = {\n  type: \"tween\" as const,\n  duration: 0.2,\n  ease: easeOutSoft,\n} as const\n\n/**\n * Progress / meter fill width tween.\n * Never use on a slider while `dragging` — drag must stay 1:1.\n */\nexport const fillTween = {\n  type: \"tween\" as const,\n  duration: 0.24,\n  ease: easeOutSoft,\n} as const\n\n/** Avatar image / fallback crossfade */\nexport const avatarTween = {\n  type: \"tween\" as const,\n  duration: 0.18,\n  ease: easeOutSoft,\n} as const\n\n/**\n * Shared-element / layoutId morph (tabs pill, toolbar expand, TextMorph chrome).\n * ~0.2–0.24s easeOutSoft — never spring bounce on chrome.\n * Wrap siblings in `LayoutGroup` when multiple layoutIds share a tree.\n */\nexport const layoutTween = {\n  type: \"tween\" as const,\n  duration: 0.22,\n  ease: easeOutSoft,\n} as const\n\n/**\n * Switch thumb / track via Motion `layout` + flex justify flip\n * (Motion.dev Base UI Switch pattern). Slightly snappier than layoutTween.\n */\nexport const switchLayoutTween = {\n  type: \"tween\" as const,\n  duration: 0.16,\n  ease: easeOutExpo,\n} as const\n\n/**\n * AnimatedGroup-style list container variants.\n * Use: `<motion.ul variants={staggerContainer} initial=\"hidden\" animate=\"show\">`\n * Pair with `staggerItem` children. Cap subtle — {@link stagger} ≤50ms.\n */\nexport const staggerContainer = {\n  hidden: {},\n  show: {\n    transition: {\n      staggerChildren: stagger(),\n    },\n  },\n} as const\n\n/** AnimatedGroup-style list item — opacity + y (never opacity alone). */\nexport const staggerItem = {\n  hidden: { opacity: 0, y: 4 },\n  show: {\n    opacity: 1,\n    y: 0,\n    transition: enterTween(0.16, easeOutSoft),\n  },\n} as const\n\n/**\n * Menu popup variants — popup settle + staggerChildren ≤40ms.\n * Pair with `menuItemVariants` on MenuItem / SubTrigger / check/radio rows.\n * Closed path keeps opacity + scale for AnimatePresence exit.\n */\nexport const menuPopupVariants = {\n  closed: {\n    opacity: 0,\n    scale: 0.98,\n    transition: exitTween(popupTween.duration, popupTween.ease),\n  },\n  open: {\n    opacity: 1,\n    scale: 1,\n    transition: {\n      ...enterTween(popupTween.duration, popupTween.ease),\n      staggerChildren: stagger(),\n      delayChildren: 0.02,\n    },\n  },\n} as const\n\n/** Menu row enter — matches menuPopupVariants open/closed names. */\nexport const menuItemVariants = {\n  closed: {\n    opacity: 0,\n    y: 4,\n    transition: exitTween(0.16, easeOutSoft),\n  },\n  open: {\n    opacity: 1,\n    y: 0,\n    transition: enterTween(0.16, easeOutSoft),\n  },\n} as const\n\n/**\n * Menu / Select item highlight (Motion.dev origin settle + layoutId morph):\n * Prefer a single shared `layoutId` highlight sibling that morphs between\n * active items (LayoutGroup), not remounting per-row backgrounds.\n * Transition: `layoutTween`. Reduced motion → no layout animation / duration 0.\n * Do not spring-overshoot the highlight — easeOutSoft only.\n */\n\nconst instant = { type: \"tween\" as const, duration: 0 } as const\n\n/** Backdrop fade for Dialog / Alert Dialog overlays (opacity-only exception). */\nexport function backdropMotion(reduce?: boolean | null) {\n  const { enter, exit } = presenceTweens(fadeTween.duration, fadeTween.ease)\n  return {\n    initial: { opacity: 0 },\n    animate: {\n      opacity: 1,\n      transition: reduce ? instant : enter,\n    },\n    exit: {\n      opacity: 0,\n      transition: reduce ? instant : exit,\n    },\n  }\n}\n\n/**\n * Centered dialog / alert popup.\n * Keeps translate(-50%, -50%) so Motion `transform` does not fight centering.\n * Opacity + y/scale settle (Zajno fade paired with travel). Exit slightly faster.\n */\nexport function dialogContentMotion(reduce?: boolean | null) {\n  const closed = reduce\n    ? \"translate(-50%, -50%) scale(1)\"\n    : \"translate(-50%, calc(-50% + 8px)) scale(0.98)\"\n  const open = \"translate(-50%, -50%) scale(1)\"\n  const { enter, exit } = presenceTweens(dialogTween.duration, dialogTween.ease)\n  return {\n    initial: { opacity: 0, transform: closed },\n    animate: {\n      opacity: 1,\n      transform: open,\n      transition: reduce ? instant : enter,\n    },\n    exit: {\n      opacity: 0,\n      transform: closed,\n      transition: reduce ? instant : exit,\n    },\n  }\n}\n\n/**\n * Anchored menu / popover popup (Positioner owns placement; origin CSS var).\n * Opacity + scale — never opacity alone on popups.\n */\nexport function popupMotion(reduce?: boolean | null) {\n  const scale = reduce ? 1 : 0.96\n  const { enter, exit } = presenceTweens(\n    popupTween.duration,\n    popupTween.ease,\n    popupTween.ease\n  )\n  return {\n    initial: { opacity: 0, scale },\n    animate: {\n      opacity: 1,\n      scale: 1,\n      transition: reduce ? instant : enter,\n    },\n    exit: {\n      opacity: 0,\n      scale,\n      transition: reduce ? instant : exit,\n    },\n  }\n}\n\n/**\n * Menu surface — opacity + scale settle with staggerChildren for rows.\n * Reduced motion → flat fade, no stagger / scale.\n */\nexport function menuPopupMotion(reduce?: boolean | null) {\n  if (reduce) {\n    return {\n      initial: { opacity: 0 },\n      animate: { opacity: 1 },\n      exit: { opacity: 0 },\n      transition: instant,\n    }\n  }\n  return {\n    initial: \"closed\" as const,\n    animate: \"open\" as const,\n    exit: \"closed\" as const,\n    variants: menuPopupVariants,\n  }\n}\n\n/**\n * Tooltip — opacity + y from the side (Motion.dev Base UI Tooltip).\n * Skip scale; reduced motion → duration 0 / no y travel.\n */\nexport function tooltipMotion(reduce?: boolean | null) {\n  const y = reduce ? 0 : 4\n  const { enter, exit } = presenceTweens(tooltipTween.duration, tooltipTween.ease)\n  return {\n    initial: { opacity: 0, y },\n    animate: {\n      opacity: 1,\n      y: 0,\n      transition: reduce ? instant : enter,\n    },\n    exit: {\n      opacity: 0,\n      y,\n      transition: reduce ? instant : exit,\n    },\n  }\n}\n\nexport type DrawerPanelSide = \"top\" | \"right\" | \"bottom\" | \"left\"\n\n/**\n * Drawer / sheet panel — slide from edge via `panelTween` (easeOutSoft).\n * Opacity stays 1 so Base UI `getAnimations()` still awaits leave.\n * Reduced motion → duration 0 / no travel.\n */\nexport function drawerPanelMotion(\n  side: DrawerPanelSide = \"right\",\n  reduce?: boolean | null\n) {\n  const closed =\n    reduce\n      ? { x: 0, y: 0 }\n      : side === \"right\"\n        ? { x: \"100%\", y: 0 }\n        : side === \"left\"\n          ? { x: \"-100%\", y: 0 }\n          : side === \"bottom\"\n            ? { x: 0, y: \"100%\" }\n            : { x: 0, y: \"-100%\" }\n  const { enter, exit } = presenceTweens(\n    panelTween.duration,\n    panelTween.ease,\n    panelTween.ease\n  )\n  return {\n    initial: { opacity: 1, ...closed },\n    animate: {\n      opacity: 1,\n      x: 0,\n      y: 0,\n      transition: reduce ? instant : enter,\n    },\n    exit: {\n      opacity: 1,\n      ...closed,\n      transition: reduce ? instant : exit,\n    },\n  }\n}\n\n/**\n * Toast root — edge enter/exit opacity + y.\n * Stack offset / scale stay on CSS vars (`--toast-offset-y`, `--toast-index`)\n * so Motion transform does not fight the stack. Ending keeps opacity on the\n * exit path for Base UI `getAnimations()`.\n */\nexport function toastMotion(\n  reduce?: boolean | null,\n  ending?: boolean\n) {\n  const y = reduce ? 0 : 10\n  const visible = { opacity: 1, y: 0 }\n  const hidden = { opacity: 0, y }\n  const { enter, exit } = presenceTweens(\n    toastTween.duration,\n    toastTween.ease,\n    toastTween.ease\n  )\n  return {\n    initial: hidden,\n    animate: ending\n      ? { ...hidden, transition: reduce ? instant : exit }\n      : { ...visible, transition: reduce ? instant : enter },\n  }\n}\n\n/** Avatar image fade-in once loaded (opacity + scale — Zajno fade+transform). */\nexport function avatarImageMotion(reduce?: boolean | null) {\n  const { enter, exit } = presenceTweens(\n    avatarTween.duration,\n    avatarTween.ease,\n    avatarTween.ease\n  )\n  const scaleIn = reduce ? 1 : 0.96\n  const scaleOut = reduce ? 1 : 0.98\n  return {\n    initial: { opacity: 0, scale: scaleIn },\n    animate: {\n      opacity: 1,\n      scale: 1,\n      transition: reduce ? instant : enter,\n    },\n    exit: {\n      opacity: 0,\n      scale: scaleOut,\n      transition: reduce ? instant : exit,\n    },\n  }\n}\n\n/** Avatar fallback — crossfades under / over the image (opacity + scale). */\nexport function avatarFallbackMotion(reduce?: boolean | null) {\n  const { enter, exit } = presenceTweens(\n    avatarTween.duration,\n    avatarTween.ease,\n    avatarTween.ease\n  )\n  const scaleIn = reduce ? 1 : 0.96\n  const scaleOut = reduce ? 1 : 0.98\n  return {\n    initial: { opacity: 0, scale: scaleIn },\n    animate: {\n      opacity: 1,\n      scale: 1,\n      transition: reduce ? instant : enter,\n    },\n    exit: {\n      opacity: 0,\n      scale: scaleOut,\n      transition: reduce ? instant : exit,\n    },\n  }\n}\n",
      "type": "registry:lib",
      "target": "lib/motion.ts"
    }
  ],
  "type": "registry:lib"
}