{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "family-wallet",
  "type": "registry:component",
  "title": "Family Wallet",
  "description": "An animated wallet interface inspired by family account interactions with smooth card transitions.",
  "dependencies": [
    "lucide-react",
    "motion",
    "react-icons",
    "react-use-measure"
  ],
  "files": [
    {
      "path": "components/watermelon/family-wallet.tsx",
      "type": "registry:component",
      "content": "'use client';\n\nimport { useState, useEffect, type SVGProps } from 'react';\nimport useMeasure from 'react-use-measure';\nimport { motion, AnimatePresence } from 'motion/react';\n\nimport {\n  Drawer,\n  DrawerContent,\n  DrawerOverlay,\n  DrawerPortal,\n  DrawerClose,\n} from '@/components/ui/drawer';\n\nimport {\n  ChevronLeft,\n  X,\n  ArrowRight,\n  Fingerprint,\n  Github,\n  Chrome,\n  Twitter,\n} from 'lucide-react';\n\nimport { BsWallet2 } from 'react-icons/bs';\nimport { FaApple, FaDiscord } from 'react-icons/fa6';\n\n/* ---------------- ENUMS ---------------- */\n\nconst View = {\n  SIGN_IN: 'SIGN_IN',\n  PASSKEY: 'PASSKEY',\n  CONNECT_WALLET: 'CONNECT_WALLET',\n} as const;\n\ntype View = (typeof View)[keyof typeof View];\n\nconst TABS = [\n  { id: 'email', label: 'Email' },\n  { id: 'phone', label: 'Phone' },\n  { id: 'passkey', label: 'Passkey' },\n];\n\nconst MetaMask = (props: SVGProps<SVGSVGElement>) => (\n  <svg\n    {...props}\n    xmlSpace=\"preserve\"\n    id=\"metamask__Layer_1\"\n    x=\"0\"\n    y=\"0\"\n    version=\"1.1\"\n    viewBox=\"0 0 318.6 318.6\"\n  >\n    <path\n      fill=\"#e2761b\"\n      stroke=\"#e2761b\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n      d=\"m274.1 35.5-99.5 73.9L193 65.8z\"\n    />\n    <path d=\"m44.4 35.5 98.7 74.6-17.5-44.3zm193.9 171.3-26.5 40.6 56.7 15.6 16.3-55.3zm-204.4.9L50.1 263l56.7-15.6-26.5-40.6z\" />\n    <path d=\"m103.6 138.2-15.8 23.9 56.3 2.5-2-60.5zm111.3 0-39-34.8-1.3 61.2 56.2-2.5zM106.8 247.4l33.8-16.5-29.2-22.8zm71.1-16.5 33.9 16.5-4.7-39.3z\" />\n    <path\n      fill=\"#d7c1b3\"\n      stroke=\"#d7c1b3\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n      d=\"m211.8 247.4-33.9-16.5 2.7 22.1-.3 9.3zm-105 0 31.5 14.9-.2-9.3 2.5-22.1z\"\n    />\n    <path\n      fill=\"#233447\"\n      stroke=\"#233447\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n      d=\"m138.8 193.5-28.2-8.3 19.9-9.1zm40.9 0 8.3-17.4 20 9.1z\"\n    />\n    <path\n      fill=\"#cd6116\"\n      stroke=\"#cd6116\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n      d=\"m106.8 247.4 4.8-40.6-31.3.9zM207 206.8l4.8 40.6 26.5-39.7zm23.8-44.7-56.2 2.5 5.2 28.9 8.3-17.4 20 9.1zm-120.2 23.1 20-9.1 8.2 17.4 5.3-28.9-56.3-2.5z\"\n    />\n    <path\n      fill=\"#e4751f\"\n      stroke=\"#e4751f\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n      d=\"m87.8 162.1 23.6 46-.8-22.9zm120.3 23.1-1 22.9 23.7-46zm-64-20.6-5.3 28.9 6.6 34.1 1.5-44.9zm30.5 0-2.7 18 1.2 45 6.7-34.1z\"\n    />\n    <path d=\"m179.8 193.5-6.7 34.1 4.8 3.3 29.2-22.8 1-22.9zm-69.2-8.3.8 22.9 29.2 22.8 4.8-3.3-6.6-34.1z\" />\n    <path\n      fill=\"#c0ad9e\"\n      stroke=\"#c0ad9e\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n      d=\"m180.3 262.3.3-9.3-2.5-2.2h-37.7l-2.3 2.2.2 9.3-31.5-14.9 11 9 22.3 15.5h38.3l22.4-15.5 11-9z\"\n    />\n    <path\n      fill=\"#161616\"\n      stroke=\"#161616\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n      d=\"m177.9 230.9-4.8-3.3h-27.7l-4.8 3.3-2.5 22.1 2.3-2.2h37.7l2.5 2.2z\"\n    />\n    <path\n      fill=\"#763d16\"\n      stroke=\"#763d16\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n      d=\"m278.3 114.2 8.5-40.8-12.7-37.9-96.2 71.4 37 31.3 52.3 15.3 11.6-13.5-5-3.6 8-7.3-6.2-4.8 8-6.1zM31.8 73.4l8.5 40.8-5.4 4 8 6.1-6.1 4.8 8 7.3-5 3.6 11.5 13.5 52.3-15.3 37-31.3-96.2-71.4z\"\n    />\n    <path d=\"m267.2 153.5-52.3-15.3 15.9 23.9-23.7 46 31.2-.4h46.5zm-163.6-15.3-52.3 15.3-17.4 54.2h46.4l31.1.4-23.6-46zm71 26.4 3.3-57.7 15.2-41.1h-67.5l15 41.1 3.5 57.7 1.2 18.2.1 44.8h27.7l.2-44.8z\" />\n  </svg>\n);\n\nconst Coinbase = (props: SVGProps<SVGSVGElement>) => (\n  <svg {...props} viewBox=\"0 0 48 48\" fill=\"none\">\n    <g clipPath=\"url(#coinbase__clip0_2_2)\">\n      <path\n        d=\"M0 11.0769C0 4.95931 4.95931 0 11.0769 0H36.9231C43.0407 0 48 4.95931 48 11.0769V36.9231C48 43.0407 43.0407 48 36.9231 48H11.0769C4.95931 48 0 43.0407 0 36.9231V11.0769Z\"\n        fill=\"#0052FF\"\n      />\n      <path\n        d=\"M23.9573 32.5C22.3527 32.4676 20.7898 31.9838 19.4487 31.1044C18.1076 30.2249 17.0427 28.9855 16.3767 27.5289C15.7108 26.0724 15.4707 24.4578 15.6842 22.8711C15.8977 21.2843 16.5561 19.79 17.5835 18.5602C18.611 17.3303 19.9658 16.4149 21.4919 15.9193C23.018 15.4237 24.6534 15.3681 26.2098 15.7589C27.7663 16.1497 29.1804 16.9709 30.2894 18.1281C31.3985 19.2853 32.1574 20.7315 32.4787 22.3H41C40.5628 17.9606 38.4703 13.9546 35.1552 11.1109C31.8402 8.26711 27.5563 6.803 23.1895 7.02133C18.8226 7.23967 14.707 9.12377 11.6937 12.284C8.68042 15.4442 7 19.6386 7 24C7 28.3613 8.68042 32.5558 11.6937 35.716C14.707 38.8762 18.8226 40.7603 23.1895 40.9787C27.5563 41.197 31.8402 39.7329 35.1552 36.8891C38.4703 34.0454 40.5628 30.0394 41 25.7H32.4787C32.4787 29.1 27.3658 32.5 23.9573 32.5Z\"\n        fill=\"white\"\n      />\n    </g>\n    <defs>\n      <clipPath id=\"coinbase__clip0_2_2\">\n        <rect width=\"48\" height=\"48\" rx=\"24\" fill=\"white\" />\n      </clipPath>\n    </defs>\n  </svg>\n);\n\nconst Polygon = (props: SVGProps<SVGSVGElement>) => (\n  <svg {...props} viewBox=\"0 0 36 36\">\n    <g fill=\"none\">\n      <circle fill=\"#8247E5\" cx=\"18\" cy=\"18\" r=\"18\" />\n      <path\n        d=\"M24.172 13.954c-.438-.25-1.002-.25-1.504 0l-3.509 2.068-2.38 1.316-3.447 2.068c-.439.25-1.003.25-1.504 0l-2.695-1.63a1.527 1.527 0 0 1-.752-1.315v-3.133c0-.502.25-1.003.752-1.316l2.695-1.567c.438-.25 1.002-.25 1.504 0l2.694 1.63c.439.25.752.751.752 1.315v2.068l2.381-1.378v-2.13c0-.502-.25-1.004-.752-1.317l-5.013-2.945c-.438-.25-1.002-.25-1.504 0l-5.138 3.008c-.501.25-.752.752-.752 1.253v5.89c0 .502.25 1.003.752 1.316l5.076 2.946c.438.25 1.002.25 1.504 0l3.446-2.006 2.381-1.378 3.447-2.006c.438-.25 1.002-.25 1.504 0l2.694 1.567c.439.25.752.752.752 1.316v3.133c0 .501-.25 1.003-.752 1.316l-2.632 1.567c-.438.25-1.002.25-1.504 0l-2.694-1.567a1.527 1.527 0 0 1-.752-1.316v-2.005L16.84 22.1v2.067c0 .502.25 1.003.752 1.316l5.075 2.946c.439.25 1.003.25 1.504 0l5.076-2.946c.439-.25.752-.752.752-1.316v-5.953c0-.5-.25-1.002-.752-1.316l-5.076-2.945z\"\n        fill=\"#FFF\"\n      />\n    </g>\n  </svg>\n);\n\nconst TrustWallet = (props: SVGProps<SVGSVGElement>) => (\n  <svg {...props} viewBox=\"0 0 444 501\" fill=\"none\">\n    <path\n      d=\"M0.710022 72.41L222.16 0.109985V500.63C63.98 433.89 0.710022 305.98 0.710022 233.69V72.41Z\"\n      fill=\"#0500FF\"\n    />\n    <path\n      d=\"M443.62 72.41L222.17 0.109985V500.63C380.35 433.89 443.62 305.98 443.62 233.69V72.41Z\"\n      fill=\"url(#trust__paint0_linear_3_10)\"\n    />\n    <defs>\n      <linearGradient\n        id=\"trust__paint0_linear_3_10\"\n        x1=\"385.26\"\n        y1=\"-34.78\"\n        x2=\"216.61\"\n        y2=\"493.5\"\n        gradientUnits=\"userSpaceOnUse\"\n      >\n        <stop offset=\"0.02\" stopColor=\"#0000FF\" />\n        <stop offset=\"0.08\" stopColor=\"#0094FF\" />\n        <stop offset=\"0.16\" stopColor=\"#48FF91\" />\n        <stop offset=\"0.42\" stopColor=\"#0094FF\" />\n        <stop offset=\"0.68\" stopColor=\"#0038FF\" />\n        <stop offset=\"0.9\" stopColor=\"#0500FF\" />\n      </linearGradient>\n    </defs>\n  </svg>\n);\n\nexport default function FamilyWallet() {\n  const [open, setOpen] = useState(false);\n  const [view, setView] = useState<View>(View.SIGN_IN);\n  const [authType, setAuthType] = useState('email');\n  const [email, setEmail] = useState('');\n  const [phone, setPhone] = useState('');\n\n  const [ref, bounds] = useMeasure();\n\n  useEffect(() => {\n    if (!open) {\n      requestAnimationFrame(() => setView(View.SIGN_IN));\n    }\n  }, [open]);\n\n  const SignInView = () => (\n    <div className=\"flex flex-col gap-4\">\n      <div className=\"flex items-center justify-between\">\n        <h2 className=\"text-xl font-semibold text-zinc-900 dark:text-zinc-100\">\n          Sign In\n        </h2>\n\n        <DrawerClose asChild>\n          <button className=\"rounded-full bg-white p-2 dark:bg-zinc-800\">\n            <X className=\"h-5 w-5 text-zinc-400\" />\n          </button>\n        </DrawerClose>\n      </div>\n\n      {/* socials */}\n      <div className=\"flex flex-col gap-2\">\n        <div className=\"flex justify-between\">\n          {[Chrome, FaDiscord, Github, FaApple, Twitter].map((Icon, i) => (\n            <button\n              key={i}\n              className=\"flex items-center justify-center rounded-2xl bg-white px-4 py-3 dark:bg-zinc-800\"\n            >\n              <Icon className=\"h-6 w-6 text-black dark:text-white\" />\n            </button>\n          ))}\n        </div>\n\n        <div className=\"flex rounded-xl bg-white p-1 dark:bg-zinc-800\">\n          {TABS.map((tab) => (\n            <button\n              key={tab.id}\n              onClick={() => {\n                setAuthType(tab.id);\n              }}\n              className=\"relative flex-1 cursor-pointer rounded-lg py-2 text-sm font-medium\"\n            >\n              {tab.id === authType && (\n                <motion.div\n                  layoutId=\"active-tab\"\n                  className=\"absolute inset-0 z-0 rounded-lg bg-zinc-100 dark:bg-zinc-700/50\"\n                  transition={{\n                    type: 'spring',\n                    stiffness: 400,\n                    damping: 35,\n                  }}\n                />\n              )}\n\n              <span\n                className={`relative z-10 ${tab.id === authType\n                  ? 'text-zinc-900 dark:text-zinc-100'\n                  : 'text-zinc-500 dark:text-zinc-400'\n                  }`}\n              >\n                {tab.label}\n              </span>\n            </button>\n          ))}\n        </div>\n        <div>\n          <AnimatePresence mode=\"popLayout\">\n            {authType === 'email' && (\n              <motion.div className=\"relative flex w-full rounded-xl bg-white p-1.5 text-zinc-900 dark:bg-zinc-800 dark:text-white\">\n                <input\n                  value={email}\n                  onChange={(e) => setEmail(e.target.value)}\n                  placeholder=\"email@address.com\"\n                  className=\"text-md focus-visible:ring-none ml-2 flex-1 text-zinc-900 focus:border-0 focus:ring-0 focus:outline-none focus-visible:ring-0 focus-visible:outline-none dark:text-white\"\n                />\n                <motion.button className=\"flex items-center justify-center rounded-lg bg-zinc-100 px-4 py-2 dark:bg-zinc-700/50\">\n                  <ArrowRight className=\"size-6 text-black dark:text-white\" />\n                </motion.button>\n              </motion.div>\n            )}\n            {authType === 'phone' && (\n              <motion.div className=\"relative flex w-full rounded-xl bg-white p-1.5 text-zinc-900 dark:bg-zinc-800 dark:text-white\">\n                <input\n                  value={phone}\n                  onChange={(e) => setPhone(e.target.value)}\n                  placeholder=\"+1 234 567 8900\"\n                  className=\"text-md focus-visible:ring-none ml-2 flex-1 text-zinc-900 focus:border-0 focus:ring-0 focus:outline-none focus-visible:ring-0 focus-visible:outline-none dark:text-white\"\n                />\n                <motion.button className=\"flex items-center justify-center rounded-lg bg-zinc-100 px-4 py-2 dark:bg-zinc-700/50\">\n                  <ArrowRight className=\"size-6 text-black dark:text-white\" />\n                </motion.button>\n              </motion.div>\n            )}\n            {authType === 'passkey' && (\n              <motion.div className=\"relative flex w-full items-center justify-center gap-2 rounded-xl bg-white p-1.5 text-zinc-900 dark:bg-zinc-800 dark:text-white\">\n                <Fingerprint className=\"ml-1 size-6 text-zinc-900\" />\n                <input\n                  placeholder=\"Login with Passkey\"\n                  readOnly\n                  className=\"text-md focus-visible:ring-none ml-2 flex-1 text-zinc-900 focus:border-0 focus:ring-0 focus:outline-none focus-visible:ring-0 focus-visible:outline-none dark:text-white\"\n                />\n                <motion.button\n                  className=\"flex items-center justify-center rounded-lg bg-blue-500 px-4 py-2\"\n                  initial={{ opacity: 0 }}\n                  animate={{ opacity: 1 }}\n                  transition={{\n                    duration: 0.2,\n                  }}\n                  onClick={() => setView(View.PASSKEY)}\n                >\n                  <ArrowRight className=\"size-6 text-white\" />\n                </motion.button>\n              </motion.div>\n            )}\n          </AnimatePresence>\n        </div>\n      </div>\n      <div className=\"mt-2 mb-2 flex w-full items-center justify-center\">\n        <p>OR</p>\n      </div>\n\n      <button\n        onClick={() => setView(View.CONNECT_WALLET)}\n        className=\"flex w-full items-center justify-center gap-2 rounded-full bg-blue-500 py-3 text-white\"\n      >\n        <BsWallet2 />\n        Connect Wallet\n      </button>\n    </div>\n  );\n\n  const PasskeyView = () => (\n    <div className=\"flex flex-col items-center gap-6\">\n      <div className=\"flex w-full items-center justify-between\">\n        <button\n          onClick={() => setView(View.SIGN_IN)}\n          className=\"rounded-full bg-white p-2 dark:bg-zinc-800\"\n        >\n          <ChevronLeft className=\"size-6 text-zinc-400\" />\n        </button>\n\n        <h2 className=\"text-xl font-medium text-zinc-900\">Passkey</h2>\n\n        <DrawerClose asChild>\n          <button className=\"rounded-full bg-white p-2 dark:bg-zinc-800\">\n            <X className=\"size-6 text-zinc-400\" />\n          </button>\n        </DrawerClose>\n      </div>\n      <div className=\"relative flex items-center justify-center rounded-2xl bg-white dark:bg-zinc-800 p\">\n        <div className=\"pointer-events-none absolute inset-0\">\n          <svg\n            className=\"h-full w-full\"\n            viewBox=\"0 0 100 100\"\n            preserveAspectRatio=\"none\"\n          >\n            <rect\n              x=\"1\"\n              y=\"1\"\n              width=\"98\"\n              height=\"98\"\n              rx=\"16\"\n              ry=\"16\"\n              fill=\"none\"\n              stroke=\"none\"\n\n            />\n            =\n            <motion.rect\n              x=\"1\"\n              y=\"1\"\n              width=\"98\"\n              height=\"98\"\n              rx=\"16\"\n              ry=\"16\"\n              fill=\"none\"\n              stroke=\"url(#passkey-gradient)\"\n              strokeWidth=\"2\"\n              strokeDasharray=\"80 240\"\n              animate={{ strokeDashoffset: [0, -320] }}\n              transition={{\n                duration: 2,\n                repeat: Infinity,\n                ease: 'linear',\n              }}\n            />\n            <defs>\n              <linearGradient\n                id=\"passkey-gradient\"\n                gradientUnits=\"userSpaceOnUse\"\n                x1=\"0\"\n                y1=\"0\"\n                x2=\"100\"\n                y2=\"100\"\n              >\n                <stop offset=\"0%\" stopColor=\"#3b82f6\" stopOpacity=\"0\" />\n                <stop offset=\"50%\" stopColor=\"#3b82f6\" stopOpacity=\"1\" />\n                <stop offset=\"100%\" stopColor=\"#3b82f6\" stopOpacity=\"0\" />\n              </linearGradient>\n            </defs>\n          </svg>\n        </div>\n\n        <div className=\"relative flex items-center justify-center rounded-2xl p-4\">\n          <Fingerprint className=\"h-16 w-16 text-zinc-500\" />\n        </div>\n      </div>\n\n      <div className=\"flex flex-col items-center justify-center rounded-2xl p-2\">\n        <h2 className=\"text-lg font-medium text-zinc-900 dark:text-zinc-100\">\n          Waiting for passkey\n        </h2>\n        <p className=\"text-md text-center text-zinc-500 dark:text-zinc-400\">\n          Please follow prompts to verify your passkey\n        </p>\n      </div>\n\n      <button\n        onClick={() => setView(View.SIGN_IN)}\n        className=\"w-full rounded-xl bg-blue-500 py-3 text-white cursor-pointer\"\n      >\n        Continue\n      </button>\n    </div>\n  );\n\n  const WalletView = () => (\n    <div className=\"flex flex-col gap-4\">\n      <div className=\"flex items-center justify-between\">\n        <button\n          onClick={() => setView(View.SIGN_IN)}\n          className=\"rounded-full bg-white dark:bg-zinc-800 p-2\"\n        >\n          <ChevronLeft className=\"size-6 text-zinc-400\" />\n        </button>\n\n        <h2 className=\"text-lg font-medium text-zinc-900\">Connect Wallet</h2>\n\n        <DrawerClose asChild>\n          <button className=\"rounded-full bg-white dark:bg-zinc-800  p-2\">\n            <X className=\"size-6 text-zinc-400\" />\n          </button>\n        </DrawerClose>\n      </div>\n      <div className=\"flex flex-col items-center justify-center gap-2\">\n        {[\n          { name: 'Metamask', logo: MetaMask },\n          { name: 'Coinbase', logo: Coinbase },\n          { name: 'Polygon', logo: Polygon },\n          { name: 'Trust', logo: TrustWallet },\n        ].map((wallet, i) => (\n          <button\n            key={i}\n            className=\"flex w-full items-center justify-between rounded-xl bg-white dark:bg-zinc-800 p-4 cursor-pointer\"\n            onClick={() => setView(View.SIGN_IN)}\n          >\n            <span className=\"text-zinc-900 dark:text-zinc-100\">{wallet.name}</span>\n            <div className=\"\">\n              <wallet.logo className=\"size-6\" />\n            </div>\n          </button>\n        ))}\n        <button className=\"flex w-full items-center justify-between rounded-xl bg-white dark:bg-zinc-800 p-4\">\n          <div className=\"flex items-center gap-2\">\n            <span className=\"text-zinc-900 dark:text-zinc-100\">Other Wallets</span>\n            <div className=\"rounded-full border border-zinc-200 bg-zinc-100 dark:bg-zinc-800/50  dark:border-zinc-700 px-3 text-lg\">\n              350+\n            </div>\n          </div>\n\n          <BsWallet2 className=\"size-6\" />\n        </button>\n      </div>\n\n      <div className=\"mt-2 mb-2 flex items-center justify-center gap-2 cursor-pointer\"\n        onClick={() => setView(View.SIGN_IN)}\n      >\n        <BsWallet2 className=\"size-6\" />\n        <p> I don't have wallet</p>\n      </div>\n    </div>\n  );\n\n  const renderView = () => {\n    switch (view) {\n      case View.SIGN_IN:\n        return <SignInView />;\n\n      case View.PASSKEY:\n        return <PasskeyView />;\n\n      case View.CONNECT_WALLET:\n        return <WalletView />;\n    }\n  };\n\n  return (\n    <div className=\"relative flex  items-center justify-center \">\n      <button\n        onClick={() => setOpen(true)}\n        className=\"rounded-full bg-zinc-100 px-8 py-4 font-bold dark:text-white dark:bg-zinc-800\"\n      >\n        Open Wallet\n      </button>\n\n      <Drawer open={open} onOpenChange={setOpen}>\n        <DrawerPortal>\n          <DrawerOverlay className=\"fixed inset-0 bg-black/50\" />\n\n          <DrawerContent className=\"fixed bottom-10!  w-[360px] mx-auto overflow-hidden rounded-4xl! border border-zinc-100 bg-zinc-100 dark:border-zinc-800 dark:bg-zinc-900\">\n            <motion.div\n              animate={{ height: bounds.height }}\n              transition={{\n                type: 'spring',\n                stiffness: 400,\n                damping: 30,\n              }}\n            >\n              <div ref={ref} className=\"px-6 py-4\">\n                <AnimatePresence mode=\"popLayout\">\n                  <motion.div\n                    key={view}\n                    initial={{ opacity: 0, y: 10 }}\n                    animate={{ opacity: 1, y: 0 }}\n                    exit={{ opacity: 0, y: -10 }}\n                  >\n                    {renderView()}\n                  </motion.div>\n                </AnimatePresence>\n              </div>\n            </motion.div>\n          </DrawerContent>\n        </DrawerPortal>\n      </Drawer>\n    </div>\n  );\n}\n"
    }
  ]
}
