{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "eye",
  "type": "registry:ui",
  "title": "eye",
  "description": "Animated eye icon for Vue",
  "dependencies": [
    "motion-v"
  ],
  "files": [
    {
      "path": "components/ui/eye.vue",
      "type": "registry:ui",
      "content": "<script setup lang=\"ts\">\nimport { motion, useAnimationControls } from 'motion-v'\nimport type { Variants } from 'motion-v'\nimport { useId } from 'vue'\nimport { useIconAnimation } from '../composables/useIconAnimation'\nimport type { AnimatedIconHandle } from '../types'\n\ndefineOptions({ inheritAttrs: false, name: 'EyeIcon' })\n\nwithDefaults(\n  defineProps<{\n    size?: number\n  }>(),\n  { size: 28 },\n)\n\nconst EYE_DURATION = 0.88;\nconst EYE_TIMES = [0, 0.18, 0.38, 0.58, 0.68, 0.74, 0.78, 0.88, 1];\nconst TOP_EYELID_OPEN =\n  'M2 14C2 13.6845 2.15201 13.4713 2.45604 13.045C3.8221 11.1294 7.31078 7 12 7C16.6892 7 20.1779 11.1294 21.544 13.045C21.848 13.4713 22 13.6845 22 14';\nconst TOP_EYELID_HALF =\n  'M2 14C2 13.85 2.15201 13.7 2.45604 13.55C5.2 11.2 8.5 10 12 10C15.5 10 18.8 11.2 21.544 13.55C21.848 13.7 22 13.85 22 14';\nconst EYELID_CLOSED =\n  'M2 14C2 14 2.15201 14 2.45604 14C3.8221 14 7.31078 14 12 14C16.6892 14 20.1779 14 21.544 14C21.848 14 22 14 22 14';\nconst BOTTOM_EYELID_OPEN =\n  'M2 14C2 14.3155 2.15201 14.5287 2.45604 14.955C3.8221 16.8706 7.31078 21 12 21C16.6892 21 20.1779 16.8706 21.544 14.955C21.848 14.5287 22 14.3155 22 14';\nconst BOTTOM_EYELID_HALF =\n  'M2 14C2 14.15 2.15201 14.3 2.45604 14.45C5.2 16.8 8.5 18 12 18C15.5 18 18.8 16.8 21.544 14.45C21.848 14.3 22 14.15 22 14';\n\n// The pupil darts first, then yields softly as the lids meet.\nconst pupilVariants: Variants = {\n  normal: { translateX: 0, scaleX: 1, scaleY: 1 },\n  animate: {\n    translateX: [0, -1.6, 1.5, 0, 0, 0, 0, 0, 0],\n    scaleX: [1, 1, 1, 1, 1.04, 1.08, 1.06, 0.98, 1],\n    scaleY: [1, 1, 1, 1, 0.92, 0.85, 0.88, 1.03, 1],\n    transition: {\n      duration: EYE_DURATION,\n      ease: 'easeInOut',\n      times: EYE_TIMES,\n    },\n  },\n};\n\nconst eyeOutlineVariants: Variants = {\n  normal: { scaleX: 1, scaleY: 1 },\n  animate: {\n    scaleX: [1, 1, 1, 1, 1.015, 1.03, 1.025, 0.99, 1],\n    scaleY: [1, 1, 1, 1, 0.91, 0.78, 0.83, 1.025, 1],\n    transition: { duration: EYE_DURATION, ease: 'easeInOut', times: EYE_TIMES },\n  },\n};\n\nconst browVariants: Variants = {\n  normal: { translateY: 0 },\n  animate: {\n    translateY: [0, 0, 0, 0, 0.25, 0.65, 0.55, -0.12, 0],\n    transition: { duration: EYE_DURATION, ease: 'easeInOut', times: EYE_TIMES },\n  },\n};\n\nconst topEyelidVariants: Variants = {\n  normal: { d: TOP_EYELID_OPEN, pathLength: 1 },\n  animate: {\n    d: [\n      TOP_EYELID_OPEN,\n      TOP_EYELID_OPEN,\n      TOP_EYELID_OPEN,\n      TOP_EYELID_OPEN,\n      TOP_EYELID_HALF,\n      EYELID_CLOSED,\n      EYELID_CLOSED,\n      TOP_EYELID_HALF,\n      TOP_EYELID_OPEN,\n    ],\n    transition: { duration: EYE_DURATION, ease: 'easeInOut', times: EYE_TIMES },\n  },\n};\n\nconst bottomEyelidVariants: Variants = {\n  normal: { d: BOTTOM_EYELID_OPEN, pathLength: 1 },\n  animate: {\n    d: [\n      BOTTOM_EYELID_OPEN,\n      BOTTOM_EYELID_OPEN,\n      BOTTOM_EYELID_OPEN,\n      BOTTOM_EYELID_OPEN,\n      BOTTOM_EYELID_HALF,\n      EYELID_CLOSED,\n      EYELID_CLOSED,\n      BOTTOM_EYELID_HALF,\n      BOTTOM_EYELID_OPEN,\n    ],\n    transition: { duration: EYE_DURATION, ease: 'easeInOut', times: EYE_TIMES },\n  },\n};\n\nconst pupilClipVariants: Variants = {\n  normal: { height: 14, y: 7 },\n  animate: {\n    height: [14, 14, 14, 14, 8, 0, 0, 8, 14],\n    y: [7, 7, 7, 7, 10, 14, 14, 10, 7],\n    transition: { duration: EYE_DURATION, ease: 'easeInOut', times: EYE_TIMES },\n  },\n};\n\nconst generatedGeometryVariants: Variants = {\n  normal: {\n    visibility: 'hidden',\n    transform: 'scaleX(1) scaleY(1)',\n    transition: { duration: 0 },\n  },\n  animate: {\n    visibility: [\n      'hidden',\n      'hidden',\n      'hidden',\n      'visible',\n      'visible',\n      'visible',\n      'visible',\n      'visible',\n      'hidden',\n    ],\n    transform: [\n      'scaleX(1) scaleY(1)',\n      'scaleX(1) scaleY(1)',\n      'scaleX(1) scaleY(1)',\n      'scaleX(1) scaleY(1)',\n      'scaleX(1.012) scaleY(0.93)',\n      'scaleX(1.025) scaleY(0.84)',\n      'scaleX(1.02) scaleY(0.88)',\n      'scaleX(0.995) scaleY(1.02)',\n      'scaleX(1) scaleY(1)',\n    ],\n    transition: { duration: EYE_DURATION, ease: 'easeInOut', times: EYE_TIMES },\n  },\n};\n\nconst controls = useAnimationControls()\nconst pupilClipId = useId();\nconst { onMouseEnter, onMouseLeave, startAnimation, stopAnimation } = useIconAnimation({\n  controls,\n  loops: false,\n})\n\ndefineExpose<AnimatedIconHandle>({ startAnimation, stopAnimation })\n</script>\n\n<template>\n  <div class=\"hia-icon\" @mouseenter=\"onMouseEnter\" @mouseleave=\"onMouseLeave\" v-bind=\"$attrs\">\n          <svg xmlns=\"http://www.w3.org/2000/svg\" :width=\"size\" :height=\"size\" viewBox=\"0 0 24 24\" fill=\"none\" overflow=\"visible\">\n            <defs>\n              <clipPath :id=\"pupilClipId\" clipPathUnits=\"userSpaceOnUse\">\n                <motion.rect x=\"0\" width=\"24\" fill=\"currentColor\" :variants=\"pupilClipVariants\" :animate=\"controls\" initial=\"normal\" />\n              </clipPath>\n            </defs>\n            <motion.path d=\"M2 8C2 8 6.47715 3 12 3C17.5228 3 22 8 22 8\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-width=\"1.5\" :variants=\"browVariants\" :animate=\"controls\" initial=\"normal\" />\n            <motion.path d=\"M21.544 13.045C21.848 13.4713 22 13.6845 22 14C22 14.3155 21.848 14.5287 21.544 14.955C20.1779 16.8706 16.6892 21 12 21C7.31078 21 3.8221 16.8706 2.45604 14.955C2.15201 14.5287 2 14.3155 2 14C2 13.6845 2.15201 13.4713 2.45604 13.045C3.8221 11.1294 7.31078 7 12 7C16.6892 7 20.1779 11.1294 21.544 13.045Z\" stroke=\"currentColor\" stroke-width=\"1.5\" :variants=\"eyeOutlineVariants\" :animate=\"controls\" initial=\"normal\" :style=\"{ transformOrigin: '12px 14px' }\" />\n            <motion.path d=\"M15 14C15 12.3431 13.6569 11 12 11C10.3431 11 9 12.3431 9 14C9 15.6569 10.3431 17 12 17C13.6569 17 15 15.6569 15 14Z\" stroke=\"currentColor\" stroke-width=\"1.5\" :variants=\"pupilVariants\" :animate=\"controls\" initial=\"normal\" :clip-path=\"`url(#${pupilClipId})`\" :style=\"{ transformOrigin: '12px 14px' }\" />\n            <motion.g :variants=\"generatedGeometryVariants\" :animate=\"controls\" initial=\"normal\" :style=\"{ transformOrigin: '12px 14px' }\">\n              <motion.path :d=\"TOP_EYELID_OPEN\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1.5\" :variants=\"topEyelidVariants\" :animate=\"controls\" initial=\"normal\" />\n              <motion.path :d=\"BOTTOM_EYELID_OPEN\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1.5\" :variants=\"bottomEyelidVariants\" :animate=\"controls\" initial=\"normal\" />\n            </motion.g>\n          </svg>\n        </div>\n</template>\n"
    },
    {
      "path": "composables/useIconAnimation.ts",
      "type": "registry:lib",
      "content": "import { ref, toValue, type MaybeRefOrGetter } from 'vue'\nimport type { AnimatedIconHandle } from '../types'\n\nexport type IconPose = 'normal' | 'animate'\n\ntype AnimationControls = {\n  set: (variant: IconPose | Record<string, unknown>) => void\n  start: (variant: IconPose | Record<string, unknown>) => Promise<unknown>\n}\n\nexport function useReducedMotionFlag(\n  reduced?: MaybeRefOrGetter<boolean | undefined>,\n) {\n  if (typeof window === 'undefined') return () => false\n  return () => {\n    const override = reduced === undefined ? undefined : toValue(reduced)\n    if (override !== undefined) return override\n    return window.matchMedia('(prefers-reduced-motion: reduce)').matches\n  }\n}\n\nexport function useIconAnimation(options: {\n  controls: AnimationControls\n  loops?: boolean\n}): AnimatedIconHandle & {\n  onMouseEnter: () => void\n  onMouseLeave: () => void\n} {\n  const { controls, loops = false } = options\n  const isPlaying = ref(false)\n  let run = 0\n\n  const prefersReduced = () =>\n    typeof window !== 'undefined' &&\n    window.matchMedia('(prefers-reduced-motion: reduce)').matches\n\n  async function startAnimation() {\n    if (prefersReduced() || isPlaying.value) return\n\n    isPlaying.value = true\n    const current = ++run\n    controls.set('normal')\n    await controls.start('animate')\n    if (run === current) isPlaying.value = false\n  }\n\n  function stopAnimation() {\n    if (!loops) return\n    run += 1\n    isPlaying.value = false\n    void controls.start('normal')\n  }\n\n  return {\n    startAnimation,\n    stopAnimation,\n    onMouseEnter: () => {\n      void startAnimation()\n    },\n    onMouseLeave: () => {\n      stopAnimation()\n    },\n  }\n}\n"
    },
    {
      "path": "types/animated-icon.ts",
      "type": "registry:lib",
      "content": "export interface AnimatedIconHandle {\n  startAnimation: () => void\n  stopAnimation: () => void\n}\n\nexport interface AnimatedIconProps {\n  size?: number\n}\n"
    }
  ]
}
