{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "glyph-match",
  "title": "Glyph match",
  "description": "Turn over cards and find four matching pairs in a shuffled deck.",
  "dependencies": [
    "lucide-react@1.73.0"
  ],
  "registryDependencies": [
    "https://www.cyberspec.dev/r/recipe-layout.json",
    "https://www.cyberspec.dev/r/badge.json",
    "https://www.cyberspec.dev/r/button.json"
  ],
  "files": [
    {
      "path": "registry/cyber/recipes/glyph-match.tsx",
      "content": "\"use client\"\n\nimport { useState } from \"react\"\nimport { Asterisk, Diamond, Hexagon, Triangle, Waypoints } from \"lucide-react\"\nimport { Button } from \"@/registry/cyber/ui/button\"\nimport { Badge } from \"@/registry/cyber/ui/badge\"\nimport \"./recipe-layout.css\"\n\nconst shapes = [Diamond, Hexagon, Triangle, Waypoints]\nconst names = [\"Diamond\", \"Hexagon\", \"Triangle\", \"Constellation\"]\nfunction shuffle() {\n  const deck = [0, 1, 2, 3, 0, 1, 2, 3]\n  for (let i = deck.length - 1; i > 0; i--) {\n    const j = Math.floor(Math.random() * (i + 1))\n    ;[deck[i], deck[j]] = [deck[j], deck[i]]\n  }\n  return deck\n}\n\nexport default function GlyphMatch() {\n  const [cards, setCards] = useState(shuffle)\n  const [flipped, setFlipped] = useState<number[]>([])\n  const [matched, setMatched] = useState<number[]>([])\n  const [turns, setTurns] = useState(0)\n  function reveal(index: number) {\n    const previous = flipped.length === 1 ? flipped[0] : undefined\n    if (previous === undefined) { setFlipped([index]); return }\n    setTurns(turns + 1)\n    if (cards[previous] === cards[index]) {\n      setMatched([...matched, previous, index])\n      setFlipped([])\n    } else setFlipped([previous, index])\n  }\n  return (\n    <div className=\"sink-stack\">\n      <div className=\"sink-between\"><span className=\"sink-label\">Memory deck</span><Badge tone=\"signal\">{matched.length / 2} / 4 pairs</Badge></div>\n      <div style={{display: \"grid\", gridTemplateColumns: \"repeat(4, minmax(0, 1fr))\", gap: 5}}>\n        {cards.map((shape, index) => {\n          const known = matched.includes(index)\n          const visible = known || flipped.includes(index)\n          const Icon = visible ? shapes[shape] : Asterisk\n          return <Button key={index} tone={known ? \"signal\" : visible ? \"flag\" : \"secondary\"}\n            disabled={known || (flipped.length === 1 && flipped[0] === index)} style={{height: 56}}\n            aria-label={`Card ${index + 1}, ${visible ? names[shape] : \"face down\"}${known ? \", matched\" : \"\"}`}\n            onClick={() => reveal(index)}><Icon aria-hidden /></Button>\n        })}\n      </div>\n      <div className=\"sink-between\">\n        <span className=\"sink-note\" role=\"status\">{matched.length === 8 ? `All pairs in ${turns} turns` : flipped.length === 2 ? \"No match. Pick another card.\" : flipped.length ? \"Find its partner.\" : \"Turn over two cards.\"}</span>\n        <Button size=\"sm\" onClick={() => { setCards(shuffle()); setMatched([]); setFlipped([]); setTurns(0) }}>Shuffle</Button>\n      </div>\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/recipes/glyph-match.tsx"
    }
  ],
  "categories": [
    "recipe",
    "arcade"
  ],
  "type": "registry:component"
}
