{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "layers-01",
  "title": "layers-01",
  "description": "Animated layers icon",
  "dependencies": [
    "motion"
  ],
  "files": [
    {
      "path": "icons/layers-01.tsx",
      "content": "'use client';\n\nimport type { Easing, 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 Layers01IconHandle {\n  startAnimation: () => void;\n  stopAnimation: () => void;\n}\n\ninterface Layers01IconProps extends HTMLAttributes<HTMLDivElement> {\n  size?: number;\n}\n\nconst TOP =\n  'M8.64298 3.14559L6.93816 3.93362C4.31272 5.14719 3 5.75397 3 6.75C3 7.74603 4.31272 8.35281 6.93817 9.56638L8.64298 10.3544C10.2952 11.1181 11.1214 11.5 12 11.5C12.8786 11.5 13.7048 11.1181 15.357 10.3544L17.0618 9.56638C19.6873 8.35281 21 7.74603 21 6.75C21 5.75397 19.6873 5.14719 17.0618 3.93362L15.357 3.14559C13.7048 2.38186 12.8786 2 12 2C11.1214 2 10.2952 2.38186 8.64298 3.14559Z';\nconst MIDDLE =\n  'M20.788 11.0972C20.9293 11.2959 21 11.5031 21 11.7309C21 12.7127 19.6873 13.3109 17.0618 14.5072L15.357 15.284C13.7048 16.0368 12.8786 16.4133 12 16.4133C11.1214 16.4133 10.2952 16.0368 8.64298 15.284L6.93817 14.5072C4.31272 13.3109 3 12.7127 3 11.7309C3 11.5031 3.07067 11.2959 3.212 11.0972';\nconst BOTTOM =\n  'M20.3767 16.2661C20.7922 16.5971 21 16.927 21 17.3176C21 18.2995 19.6873 18.8976 17.0618 20.0939L15.357 20.8707C13.7048 21.6236 12.8786 22 12 22C11.1214 22 10.2952 21.6236 8.64298 20.8707L6.93817 20.0939C4.31272 18.8976 3 18.2995 3 17.3176C3 16.927 3.20778 16.5971 3.62334 16.2661';\n\n// A new sheet falls in from the top like a solid sheet (a mask that moves\n// with it hides whatever it covers) and, on landing, pushes the stack down one\n// slot: the old top sheet becomes the middle layer (a clip trims it to the\n// middle-layer shape), the middle sheet becomes the bottom one, and the bottom\n// sheet slides out. The stack then bounces like jelly. At the end each sheet\n// sits on a rest shape, so the swap back to rest is invisible.\nconst LAYER_DURATION = 1.15;\nconst LAYER_TIMES = [0, 0.26, 0.42, 0.56, 0.7, 0.84, 0.999, 1];\nconst LAYER_EASE: Easing[] = [\n  'easeIn',\n  [0.23, 1, 0.32, 1],\n  'easeInOut',\n  'easeInOut',\n  'easeInOut',\n  'linear',\n  'linear',\n];\nconst DROP_FROM = -13;\nconst SLOT = 4.95;\n// Damped bounce after the push lands.\nconst BOUNCE = [1.2, -0.45, 0.18, 0];\nconst settle = (base: number, k = 1) => BOUNCE.map((o) => base + o * k);\n\n// The clip's top edge follows the falling sheet, then stays 5.75 below the\n// old top sheet's own origin, which is where the middle layer's ends sit.\nconst CLIP_BOTTOM = 70;\nconst CLIP_HEIGHT = 110;\nconst CLIP_REST_TOP = CLIP_BOTTOM - CLIP_HEIGHT;\nconst CLIP_TOPS = [-0.35, 6.49, ...settle(SLOT + 5.75), 10.7, CLIP_REST_TOP];\n\nconst newSheetVariants: Variants = {\n  normal: { translateY: DROP_FROM },\n  animate: {\n    translateY: [DROP_FROM, -SLOT, ...settle(0), 0, DROP_FROM],\n    transition: { duration: LAYER_DURATION, ease: LAYER_EASE, times: LAYER_TIMES },\n  },\n};\n\nconst topVariants: Variants = {\n  normal: { translateY: 0 },\n  animate: {\n    translateY: [0, 0, ...settle(SLOT), SLOT, 0],\n    transition: { duration: LAYER_DURATION, ease: LAYER_EASE, times: LAYER_TIMES },\n  },\n};\n\nconst clipVariants: Variants = {\n  normal: { attrY: CLIP_REST_TOP, height: CLIP_HEIGHT },\n  animate: {\n    attrY: CLIP_TOPS,\n    height: CLIP_TOPS.map((top) => CLIP_BOTTOM - top),\n    transition: { duration: LAYER_DURATION, ease: LAYER_EASE, times: LAYER_TIMES },\n  },\n};\n\nconst middleVariants: Variants = {\n  normal: { d: MIDDLE, translateY: 0 },\n  animate: {\n    d: [MIDDLE, MIDDLE, BOTTOM, BOTTOM, BOTTOM, BOTTOM, BOTTOM, MIDDLE],\n    translateY: [0, 0, ...settle(0, 0.7), 0, 0],\n    transition: { duration: LAYER_DURATION, ease: LAYER_EASE, times: LAYER_TIMES },\n  },\n};\n\nconst bottomVariants: Variants = {\n  normal: { translateY: 0 },\n  animate: {\n    translateY: [0, 0, 9, 9, 9, 9, 9, 0],\n    transition: { duration: LAYER_DURATION, ease: LAYER_EASE, times: LAYER_TIMES },\n  },\n};\n\nconst generatedGeometryVariants: Variants = {\n  normal: { visibility: 'hidden', transition: { duration: 0 } },\n  animate: {\n    visibility: ['visible', 'visible', 'hidden'],\n    transition: { duration: LAYER_DURATION, times: [0, 0.999, 1] },\n  },\n};\n\nconst Layers01Icon = forwardRef<Layers01IconHandle, Layers01IconProps>(\n  ({ onMouseEnter, onMouseLeave, className, size = 28, ...props }, ref) => {\n    const controls = useAnimation();\n    const maskId = useId();\n    const clipId = 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            <mask id={maskId} maskUnits=\"userSpaceOnUse\" x=\"-5\" y=\"-20\" width=\"34\" height=\"50\">\n              <rect x=\"-5\" y=\"-20\" width=\"34\" height=\"50\" fill=\"white\" />\n              <motion.path\n                d={TOP}\n                fill=\"black\"\n                stroke=\"black\"\n                strokeWidth=\"3.5\"\n                strokeLinejoin=\"round\"\n                variants={newSheetVariants}\n                animate={controls}\n                initial=\"normal\"\n              />\n            </mask>\n            <clipPath id={clipId} clipPathUnits=\"userSpaceOnUse\">\n              <motion.rect\n                x=\"-5\"\n                y={CLIP_REST_TOP}\n                width=\"34\"\n                height={CLIP_HEIGHT}\n                variants={clipVariants}\n                animate={controls}\n                initial=\"normal\"\n              />\n            </clipPath>\n          </defs>\n          <g mask={`url(#${maskId})`} clipPath={`url(#${clipId})`}>\n            <motion.path\n              d={TOP}\n              stroke=\"currentColor\"\n              strokeLinecap=\"round\"\n              strokeLinejoin=\"round\"\n              strokeWidth=\"1.5\"\n              variants={topVariants}\n              animate={controls}\n              initial=\"normal\"\n            />\n          </g>\n          <motion.path\n            d={MIDDLE}\n            stroke=\"currentColor\"\n            strokeLinecap=\"round\"\n            strokeLinejoin=\"round\"\n            strokeWidth=\"1.5\"\n            variants={middleVariants}\n            animate={controls}\n            initial=\"normal\"\n          />\n          <motion.path\n            d={BOTTOM}\n            stroke=\"currentColor\"\n            strokeLinecap=\"round\"\n            strokeLinejoin=\"round\"\n            strokeWidth=\"1.5\"\n            variants={bottomVariants}\n            animate={controls}\n            initial=\"normal\"\n          />\n          <motion.g\n            variants={generatedGeometryVariants}\n            animate={controls}\n            initial=\"normal\"\n          >\n            <motion.path\n              d={TOP}\n              stroke=\"currentColor\"\n              strokeLinecap=\"round\"\n              strokeLinejoin=\"round\"\n              strokeWidth=\"1.5\"\n              variants={newSheetVariants}\n              animate={controls}\n              initial=\"normal\"\n            />\n          </motion.g>\n        </svg>\n      </div>\n    );\n  }\n);\n\nLayers01Icon.displayName = 'Layers01Icon';\n\nexport { Layers01Icon };\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"
}