{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "slot",
  "title": "Slot",
  "description": "Slot component for motion animations.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "registryDependencies": [
    "https://optics.agusmayol.com.ar/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/optics/helpers/primitives/animate/slot.jsx",
      "content": "\"use client\";\nimport * as React from \"react\";\nimport { motion, isMotionComponent } from \"motion/react\";\nimport { cn } from \"@/registry/optics/lib/utils\";\n\nfunction mergeRefs(...refs) {\n\treturn (node) => {\n\t\trefs.forEach((ref) => {\n\t\t\tif (!ref) return;\n\t\t\tif (typeof ref === \"function\") {\n\t\t\t\tref(node);\n\t\t\t} else {\n\t\t\t\tref.current = node;\n\t\t\t}\n\t\t});\n\t};\n}\n\nfunction mergeProps(childProps, slotProps) {\n\tconst merged = { ...childProps, ...slotProps };\n\n\tif (childProps.className || slotProps.className) {\n\t\tmerged.className = cn(childProps.className, slotProps.className);\n\t}\n\n\tif (childProps.style || slotProps.style) {\n\t\tmerged.style = {\n\t\t\t...childProps.style,\n\t\t\t...slotProps.style,\n\t\t};\n\t}\n\n\treturn merged;\n}\n\nfunction Slot({ children, ref, ...props }) {\n\tconst isAlreadyMotion =\n\t\ttypeof children.type === \"object\" &&\n\t\tchildren.type !== null &&\n\t\tisMotionComponent(children.type);\n\n\tconst Base = React.useMemo(\n\t\t() => (isAlreadyMotion ? children.type : motion.create(children.type)),\n\t\t[isAlreadyMotion, children.type],\n\t);\n\n\tif (!React.isValidElement(children)) return null;\n\n\tconst { ref: childRef, ...childProps } = children.props;\n\n\tconst mergedProps = mergeProps(childProps, props);\n\n\treturn <Base {...mergedProps} ref={mergeRefs(childRef, ref)} />;\n}\n\nexport { Slot };\n",
      "type": "registry:component",
      "target": "components/optics/helpers/primitives/animate/slot.jsx"
    }
  ],
  "type": "registry:component"
}