{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "mail-send-01",
  "title": "mail-send-01",
  "description": "Animated mail send icon",
  "dependencies": [
    "motion"
  ],
  "files": [
    {
      "path": "icons/mail-send-01.tsx",
      "content": "'use client';\n\nimport type { Variants } from 'motion/react';\nimport { motion, useAnimation } from 'motion/react';\nimport type { HTMLAttributes } from 'react';\nimport { forwardRef, useId } from 'react';\nimport { useIconAnimation } from '@/lib/use-icon-animation';\nimport { cn } from '@/lib/utils';\n\nexport interface MailSend01IconHandle {\n  startAnimation: () => void;\n  stopAnimation: () => void;\n}\n\ninterface MailSend01IconProps extends HTMLAttributes<HTMLDivElement> {\n  size?: number;\n}\n\nconst SEND_ARROW =\n  'M22 17.5L14 17.5M22 17.5C22 16.7998 20.0057 15.4915 19.5 15M22 17.5C22 18.2002 20.0057 19.5085 19.5 20';\n\nconst SEND_DURATION = 0.92;\nconst SEND_TIMES = [\n  0, 0.07, 0.14, 0.22, 0.32, 0.43, 0.5, 0.54, 0.62, 0.71, 0.8, 0.88,\n  0.95, 1,\n];\nconst BODY_TIMES = [0, 0.08, 0.16, 0.26, 0.38, 0.5, 0.62, 0.72, 0.82, 0.9, 0.96, 1];\n\n// The envelope recoils as the arrow launches and settles.\nconst bodyVariants: Variants = {\n  normal: { transform: 'translateY(0px) scaleX(1) scaleY(1)' },\n  animate: {\n    transform: [\n      'translateY(0px) scaleX(1) scaleY(1)',\n      'translateY(0px) scaleX(1) scaleY(1)',\n      'translateY(0.12px) scaleX(1.006) scaleY(0.994)',\n      'translateY(0.28px) scaleX(1.018) scaleY(0.982)',\n      'translateY(0.5px) scaleX(1.035) scaleY(0.958)',\n      'translateY(0.2px) scaleX(1.014) scaleY(0.986)',\n      'translateY(-0.36px) scaleX(0.985) scaleY(1.022)',\n      'translateY(0.14px) scaleX(1.008) scaleY(0.994)',\n      'translateY(0px) scaleX(1) scaleY(1)',\n      'translateY(0px) scaleX(1) scaleY(1)',\n      'translateY(0px) scaleX(1) scaleY(1)',\n      'translateY(0px) scaleX(1) scaleY(1)',\n    ],\n    transition: { duration: SEND_DURATION, ease: 'linear', times: BODY_TIMES },\n  },\n};\n\n// The arrow pulls back, tips, and accelerates beyond the right edge. A second\n// full arrow follows the same route out of the envelope's open side.\nconst departingArrowVariants: Variants = {\n  normal: { transform: 'translateX(0px) rotate(0deg)' },\n  animate: {\n    transform: [\n      'translateX(0px) rotate(0deg)',\n      'translateX(-0.6px) rotate(2.2deg)',\n      'translateX(-0.2px) rotate(1.2deg)',\n      'translateX(1.4px) rotate(-1deg)',\n      'translateX(4.3px) rotate(-3.2deg)',\n      'translateX(9.4px) rotate(-5.5deg)',\n      'translateX(16px) rotate(-5deg)',\n      'translateX(23px) rotate(-3.5deg)',\n      'translateX(28px) rotate(-2deg)',\n      'translateX(28px) rotate(-2deg)',\n      'translateX(28px) rotate(-2deg)',\n      'translateX(28px) rotate(-2deg)',\n      'translateX(28px) rotate(-2deg)',\n      'translateX(28px) rotate(-2deg)',\n    ],\n    transition: { duration: SEND_DURATION, ease: 'linear', times: SEND_TIMES },\n  },\n};\n\nconst arrivingArrowVariants: Variants = {\n  normal: { transform: 'translateX(-28px) rotate(-6deg)' },\n  animate: {\n    transform: [\n      'translateX(-28px) rotate(-6deg)',\n      'translateX(-28px) rotate(-6deg)',\n      'translateX(-28px) rotate(-6deg)',\n      'translateX(-28px) rotate(-6deg)',\n      'translateX(-28px) rotate(-6deg)',\n      'translateX(-28px) rotate(-6deg)',\n      'translateX(-28px) rotate(-6deg)',\n      'translateX(-23px) rotate(-6deg)',\n      'translateX(-16px) rotate(-5deg)',\n      'translateX(-9.8px) rotate(-4deg)',\n      'translateX(-4.7px) rotate(-2.5deg)',\n      'translateX(-1.4px) rotate(-0.8deg)',\n      'translateX(-0.2px) rotate(0.8deg)',\n      'translateX(0px) rotate(0deg)',\n    ],\n    transition: { duration: SEND_DURATION, ease: 'linear', times: SEND_TIMES },\n  },\n};\n\nconst generatedGeometryVariants: Variants = {\n  normal: { visibility: 'hidden', transition: { duration: 0 } },\n  animate: { visibility: 'visible', transition: { duration: 0 } },\n};\n\n// Temporary launch trails grow behind the arrow, move back to the left, and\n// clear before the replacement arrives.\nconst trailVariants: Variants = {\n  normal: { pathLength: 0, pathOffset: 0, visibility: 'hidden' },\n  animate: (i: number) => ({\n    pathLength: [0, 0.25, 1, 0.34, 0, 0],\n    pathOffset: [0, 0, 0, 0.66, 1, 1],\n    visibility: ['hidden', 'visible', 'visible', 'hidden'],\n    transition: {\n      duration: 0.38,\n      delay: 0.06 + i * 0.028,\n      ease: 'linear',\n      times: [0, 0.14, 0.34, 0.58, 0.8, 1],\n      // Hide the trail before it shrinks to a round-cap dot.\n      visibility: { duration: 0.38, delay: 0.06 + i * 0.028, ease: 'linear', times: [0, 0.14, 0.69, 0.7] },\n    },\n  }),\n};\n\nconst MailSend01Icon = forwardRef<MailSend01IconHandle, MailSend01IconProps>(\n  ({ onMouseEnter, onMouseLeave, className, size = 28, ...props }, ref) => {\n    const controls = useAnimation();\n    const arrowWindowId = useId();\n    const arrivalWindowId = useId();\n    const { handleMouseEnter, handleMouseLeave } = useIconAnimation({\n      controls,\n      loops: false,\n      onMouseEnter,\n      onMouseLeave,\n      ref,\n    });\n\n    return (\n      <div\n        className={cn(className)}\n        onMouseEnter={handleMouseEnter}\n        onMouseLeave={handleMouseLeave}\n        {...props}\n      >\n        <svg\n          xmlns=\"http://www.w3.org/2000/svg\"\n          width={size}\n          height={size}\n          viewBox=\"0 0 24 24\"\n          fill=\"none\"\n          overflow=\"hidden\"\n        >\n          <defs>\n            <clipPath id={arrowWindowId} clipPathUnits=\"userSpaceOnUse\">\n              <rect x=\"12.3\" y=\"13\" width=\"12\" height=\"9\" />\n            </clipPath>\n            <clipPath id={arrivalWindowId} clipPathUnits=\"userSpaceOnUse\">\n              <rect x=\"13\" y=\"13\" width=\"12\" height=\"9\" />\n            </clipPath>\n          </defs>\n          <motion.g\n            variants={generatedGeometryVariants}\n            animate={controls}\n            initial=\"normal\"\n          >\n            <motion.path\n              d=\"M11.2 17.5H6.2\"\n              stroke=\"currentColor\"\n              strokeLinecap=\"round\"\n              strokeWidth=\"1.5\"\n              variants={trailVariants}\n              custom={0}\n              animate={controls}\n              initial=\"normal\"\n            />\n            <motion.path\n              d=\"M10.8 15.2H7.4\"\n              stroke=\"currentColor\"\n              strokeLinecap=\"round\"\n              strokeWidth=\"1.5\"\n              variants={trailVariants}\n              custom={1}\n              animate={controls}\n              initial=\"normal\"\n            />\n            <motion.path\n              d=\"M10.6 13.3H8.4\"\n              stroke=\"currentColor\"\n              strokeLinecap=\"round\"\n              strokeWidth=\"1.5\"\n              variants={trailVariants}\n              custom={2}\n              animate={controls}\n              initial=\"normal\"\n            />\n          </motion.g>\n          <motion.g\n            variants={bodyVariants}\n            animate={controls}\n            initial=\"normal\"\n            style={{ transformBox: 'view-box', originX: 0.5, originY: 0.5 }}\n          >\n            <path\n              d=\"M22 12.5C22 12.0086 21.9947 11.0172 21.9842 10.5244C21.9189 7.45883 21.8862 5.92606 20.7551 4.79063C19.6239 3.6552 18.0497 3.61565 14.9012 3.53654C12.9607 3.48778 11.0393 3.48778 9.09882 3.53653C5.95033 3.61563 4.37608 3.65518 3.24495 4.79062C2.11382 5.92605 2.08114 7.45882 2.01576 10.5243C1.99474 11.51 1.99475 12.4899 2.01577 13.4756C2.08114 16.5411 2.11383 18.0739 3.24496 19.2093C4.37608 20.3448 5.95033 20.3843 9.09883 20.4634C9.90159 20.4836 10.7011 20.4954 11.5 20.4989\"\n              stroke=\"currentColor\"\n              strokeLinecap=\"round\"\n              strokeLinejoin=\"round\"\n              strokeWidth=\"1.5\"\n            />\n            <path\n              d=\"M2 6L8.91302 9.92462C11.4387 11.3585 12.5613 11.3585 15.087 9.92462L22 6\"\n              stroke=\"currentColor\"\n              strokeLinejoin=\"round\"\n              strokeWidth=\"1.5\"\n            />\n          </motion.g>\n          <g clipPath={`url(#${arrowWindowId})`}>\n            <motion.path\n              d={SEND_ARROW}\n              stroke=\"currentColor\"\n              strokeLinecap=\"round\"\n              strokeLinejoin=\"round\"\n              strokeWidth=\"1.5\"\n              variants={departingArrowVariants}\n              animate={controls}\n              initial=\"normal\"\n              style={{ transformBox: 'view-box', originX: 18 / 24, originY: 17.5 / 24 }}\n            />\n          </g>\n          <motion.g\n            clipPath={`url(#${arrivalWindowId})`}\n            variants={generatedGeometryVariants}\n            animate={controls}\n            initial=\"normal\"\n          >\n            <motion.path\n              d={SEND_ARROW}\n              stroke=\"currentColor\"\n              strokeLinecap=\"round\"\n              strokeLinejoin=\"round\"\n              strokeWidth=\"1.5\"\n              variants={arrivingArrowVariants}\n              animate={controls}\n              initial=\"normal\"\n              style={{ transformBox: 'view-box', originX: 18 / 24, originY: 17.5 / 24 }}\n            />\n          </motion.g>\n        </svg>\n      </div>\n    );\n  }\n);\n\nMailSend01Icon.displayName = 'MailSend01Icon';\n\nexport { MailSend01Icon };\n",
      "type": "registry:ui"
    },
    {
      "path": "lib/use-icon-animation.ts",
      "content": "'use client';\n\nimport type { LegacyAnimationControls } from 'motion/react';\nimport { spring, useReducedMotion } from 'motion/react';\nimport type {\n  ForwardedRef,\n  MouseEventHandler,\n} from 'react';\nimport { useCallback, useImperativeHandle, useRef } from 'react';\n\n/**\n * A damped spring as the easing of one keyframe segment: the value overshoots\n * its target and settles on it. Use it for landings so every icon shares the\n * same physical bounce. Higher `bounce` gives more oscillation.\n */\nexport function springEase(bounce = 0.45, visualDuration = 0.35) {\n  const generator = spring({ keyframes: [0, 1], bounce, visualDuration });\n  let settle = 0;\n  while (!generator.next(settle).done && settle < 5000) settle += 10;\n  return (progress: number) =>\n    progress >= 1 ? 1 : generator.next(progress * settle).value;\n}\n\nconst NUMBER = /-?\\d*\\.?\\d+/g;\n\n/**\n * The path at position `t` along a row of poses that share the same path\n * commands: `t = 1` is the second pose, `t = 1.5` is halfway to the third.\n * Waves use it to move along their own curvature instead of scaling, so the\n * stroke keeps its width.\n */\nexport function pathAt(poses: string[], t: number) {\n  const i = Math.min(Math.max(Math.floor(t), 0), poses.length - 2);\n  const to = poses[i + 1].match(NUMBER) ?? [];\n  let k = 0;\n  return poses[i].replace(NUMBER, (from) => {\n    const value = Number(from) + (Number(to[k++]) - Number(from)) * (t - i);\n    return String(Math.round(value * 10000) / 10000);\n  });\n}\n\nexport interface AnimatedIconHandle {\n  startAnimation: () => void;\n  stopAnimation: () => void;\n}\n\ninterface UseIconAnimationOptions {\n  controls: LegacyAnimationControls;\n  loops?: boolean;\n  onMouseEnter?: MouseEventHandler<HTMLDivElement>;\n  onMouseLeave?: MouseEventHandler<HTMLDivElement>;\n  ref: ForwardedRef<AnimatedIconHandle>;\n}\n\nexport function useIconAnimation({\n  controls,\n  loops = false,\n  onMouseEnter,\n  onMouseLeave,\n  ref,\n}: UseIconAnimationOptions) {\n  const shouldReduceMotion = useReducedMotion();\n  const isControlledRef = useRef(false);\n  const isPlayingRef = useRef(false);\n  const runRef = useRef(0);\n\n  const startAnimation = useCallback(() => {\n    if (shouldReduceMotion || isPlayingRef.current) return;\n\n    isPlayingRef.current = true;\n    const run = ++runRef.current;\n    controls.set('normal');\n    void controls.start('animate').then(() => {\n      if (runRef.current === run) isPlayingRef.current = false;\n    });\n  }, [controls, shouldReduceMotion]);\n\n  const stopAnimation = useCallback(() => {\n    if (!loops) return;\n\n    runRef.current++;\n    isPlayingRef.current = false;\n    void controls.start('normal');\n  }, [controls, loops]);\n\n  useImperativeHandle(\n    ref,\n    () => {\n      isControlledRef.current = true;\n      return { startAnimation, stopAnimation };\n    },\n    [startAnimation, stopAnimation]\n  );\n\n  const handleMouseEnter = useCallback<MouseEventHandler<HTMLDivElement>>(\n    (event) => {\n      onMouseEnter?.(event);\n      if (!isControlledRef.current) startAnimation();\n    },\n    [onMouseEnter, startAnimation]\n  );\n\n  const handleMouseLeave = useCallback<MouseEventHandler<HTMLDivElement>>(\n    (event) => {\n      onMouseLeave?.(event);\n      if (!isControlledRef.current) stopAnimation();\n    },\n    [onMouseLeave, stopAnimation]\n  );\n\n  return { handleMouseEnter, handleMouseLeave };\n}\n",
      "type": "registry:lib"
    }
  ],
  "type": "registry:ui"
}