{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dice-roll-discount-popup",
  "title": "Dice Roll Discount Popup",
  "description": "A gamified discount-capture widget where visitors roll two 3D dice for a reward tier, with a themed reveal modal and code copy, rendered inline or as a corner-launched popup with manual/delay/scroll triggers.",
  "dependencies": [
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/dice-roll-discount-popup/dice-roll-discount-popup.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, AnimatePresence } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\ninterface RewardTier {\n  max: number;\n  label: string;\n  code: string;\n}\n\ninterface Reward {\n  label: string;\n  code: string;\n}\n\ninterface ThemeConfig {\n  name: string;\n  title: string;\n  subtitle: string;\n  buttonText: string;\n  triggerText: string;\n  glow: string;\n  background: string;\n  lightBackground: string;\n  rewards: RewardTier[];\n  doublesReward: Reward;\n}\n\nconst THEMES: { [key: string]: ThemeConfig } = {\n  ecommerce: {\n    name: \"E-Commerce\",\n    title: \"Roll for a Discount\",\n    subtitle: \"3 free rolls, real savings\",\n    buttonText: \"Roll Dice\",\n    triggerText: \"Roll for a Discount\",\n    glow: \"rgba(255,255,255,0.16)\",\n    background: \"#080808\",\n    lightBackground: \"linear-gradient(160deg, #f4f6fa 0%, #dfe6f0 100%)\",\n    rewards: [\n      { max: 4, label: \"5% off\", code: \"DICE5\" },\n      { max: 6, label: \"10% off\", code: \"DICE10\" },\n      { max: 8, label: \"15% off\", code: \"DICE15\" },\n      { max: 10, label: \"20% off\", code: \"DICE20\" },\n      { max: 12, label: \"25% off\", code: \"DICE25\" },\n    ],\n    doublesReward: { label: \"Free Shipping\", code: \"DOUBLES\" },\n  },\n  campaign: {\n    name: \"Campaign / Sale\",\n    title: \"Roll Before It's Gone\",\n    subtitle: \"Limited-time drop, roll now\",\n    buttonText: \"Roll for Deal\",\n    triggerText: \"Roll for a Deal\",\n    glow: \"rgba(248,113,113,0.22)\",\n    background: \"#080808\",\n    lightBackground: \"linear-gradient(160deg, #fff1f0 0%, #fecdd3 100%)\",\n    rewards: [\n      { max: 4, label: \"10% off\", code: \"SALE10\" },\n      { max: 6, label: \"20% off\", code: \"SALE20\" },\n      { max: 8, label: \"30% off\", code: \"SALE30\" },\n      { max: 10, label: \"40% off\", code: \"SALE40\" },\n      { max: 12, label: \"50% off\", code: \"SALE50\" },\n    ],\n    doublesReward: { label: \"Stack Extra 10%\", code: \"SALEDOUBLE\" },\n  },\n  restaurant: {\n    name: \"Restaurant / Cafe\",\n    title: \"Today's Lucky Roll\",\n    subtitle: \"Scan, roll, treat yourself\",\n    buttonText: \"Roll for Treat\",\n    triggerText: \"Roll for a Treat\",\n    glow: \"rgba(251,191,36,0.20)\",\n    background: \"#080808\",\n    lightBackground: \"linear-gradient(160deg, #fff7ed 0%, #fde8cf 100%)\",\n    rewards: [\n      { max: 4, label: \"Free Coffee\", code: \"CAFE-COFFEE\" },\n      { max: 6, label: \"10% off Bill\", code: \"CAFE10\" },\n      { max: 8, label: \"Free Dessert\", code: \"CAFE-DESSERT\" },\n      { max: 10, label: \"20% off Bill\", code: \"CAFE20\" },\n      { max: 12, label: \"Free Appetizer\", code: \"CAFE-APP\" },\n    ],\n    doublesReward: { label: \"Meal On Us\", code: \"CAFE-FREE\" },\n  },\n  saas: {\n    name: \"SaaS / Freemium\",\n    title: \"Roll for a Plan Discount\",\n    subtitle: \"One roll per new account\",\n    buttonText: \"Roll Dice\",\n    triggerText: \"Roll for a Discount\",\n    glow: \"rgba(129,140,248,0.22)\",\n    background: \"#080808\",\n    lightBackground: \"linear-gradient(160deg, #eef2ff 0%, #e0e7ff 100%)\",\n    rewards: [\n      { max: 4, label: \"10% off\", code: \"SAAS10\" },\n      { max: 6, label: \"20% off\", code: \"SAAS20\" },\n      { max: 8, label: \"1 Month Free\", code: \"SAAS-MONTH\" },\n      { max: 10, label: \"30% off\", code: \"SAAS30\" },\n      { max: 12, label: \"50% off\", code: \"SAAS50\" },\n    ],\n    doublesReward: { label: \"3 Months Free\", code: \"SAAS-3MO\" },\n  },\n  event: {\n    name: \"Event / Tickets\",\n    title: \"Roll for an Early Bird Deal\",\n    subtitle: \"Before you check out\",\n    buttonText: \"Roll for Bonus\",\n    triggerText: \"Roll for a Bonus\",\n    glow: \"rgba(45,212,191,0.20)\",\n    background: \"#080808\",\n    lightBackground: \"linear-gradient(160deg, #ecfeff 0%, #cffafe 100%)\",\n    rewards: [\n      { max: 4, label: \"5% off\", code: \"EVT5\" },\n      { max: 6, label: \"10% off\", code: \"EVT10\" },\n      { max: 8, label: \"Free Drink Ticket\", code: \"EVT-DRINK\" },\n      { max: 10, label: \"15% off\", code: \"EVT15\" },\n      { max: 12, label: \"VIP Upgrade\", code: \"EVT-VIP\" },\n    ],\n    doublesReward: { label: \"Free +1 Ticket\", code: \"EVT-PLUSONE\" },\n  },\n};\n\nconst faceRotations: { [key: number]: { rotateX: number; rotateY: number } } = {\n  1: { rotateX: 0, rotateY: 0 },\n  2: { rotateX: 0, rotateY: 180 },\n  3: { rotateX: 0, rotateY: -90 },\n  4: { rotateX: 0, rotateY: 90 },\n  5: { rotateX: -90, rotateY: 0 },\n  6: { rotateX: 90, rotateY: 0 },\n};\n\nconst PIP_LAYOUTS: { [key: number]: number[] } = {\n  1: [5],\n  2: [1, 9],\n  3: [1, 5, 9],\n  4: [1, 3, 7, 9],\n  5: [1, 3, 5, 7, 9],\n  6: [1, 3, 4, 6, 7, 9],\n};\n\nfunction Pips({ number }: { number: number }) {\n  const active = PIP_LAYOUTS[number] || [];\n  return (\n    <div className=\"grid h-[65%] w-[65%] grid-cols-3 grid-rows-3\">\n      {Array.from({ length: 9 }).map((_, i) => (\n        <div key={i} className=\"flex items-center justify-center\">\n          {active.includes(i + 1) && (\n            <div\n              className=\"h-[11px] w-[11px] rounded-full\"\n              style={{\n                background: \"radial-gradient(circle at 32% 28%, #4b4b52 0%, #16161a 55%, #000000 100%)\",\n                boxShadow: \"inset 0 1px 1.5px rgba(255,255,255,0.25), 0 1px 2px rgba(0,0,0,0.5)\",\n              }}\n            />\n          )}\n        </div>\n      ))}\n    </div>\n  );\n}\n\nfunction GiftIcon() {\n  return (\n    <svg width=\"28\" height=\"28\" viewBox=\"0 0 24 24\" fill=\"none\" aria-hidden=\"true\" focusable=\"false\" className=\"relative\">\n      <rect x=\"3.5\" y=\"10\" width=\"17\" height=\"9.5\" rx=\"1.5\" fill=\"#0a0a0f\" />\n      <rect x=\"2.5\" y=\"7\" width=\"19\" height=\"4\" rx=\"1\" fill=\"#0a0a0f\" />\n      <rect x=\"10.4\" y=\"7\" width=\"3.2\" height=\"12.5\" fill=\"#ffffff\" />\n      <path\n        d=\"M12 7c-1.6 0-3-1-3.6-2.1C7.6 3.2 8.5 2 9.8 2c1.3 0 2.2 1.4 2.2 3 0-1.6.9-3 2.2-3 1.3 0 2.2 1.2 1.4 2.9C15 6 13.6 7 12 7z\"\n        fill=\"#0a0a0f\"\n      />\n    </svg>\n  );\n}\n\nconst DICE_FACES = [\n  { face: 1, transform: \"rotateY(0deg) translateZ(42px) scale(1.08)\" },\n  { face: 2, transform: \"rotateY(180deg) translateZ(42px) scale(1.08)\" },\n  { face: 3, transform: \"rotateY(90deg) translateZ(42px) scale(1.08)\" },\n  { face: 4, transform: \"rotateY(-90deg) translateZ(42px) scale(1.08)\" },\n  { face: 5, transform: \"rotateX(90deg) translateZ(42px) scale(1.08)\" },\n  { face: 6, transform: \"rotateX(-90deg) translateZ(42px) scale(1.08)\" },\n];\n\nfunction Dice3D({ value, delay = 0, isRolling }: { value: number; delay?: number; isRolling: boolean }) {\n  const final = faceRotations[value];\n  return (\n    <div style={{ width: 84, height: 84, perspective: 700 }}>\n      <motion.div\n        animate={\n          isRolling\n            ? {\n                rotateX: [0, 480, 960, 1440, final.rotateX],\n                rotateY: [0, -360, 720, -1080, final.rotateY],\n                rotateZ: [0, 180, 360, 540, 0],\n                y: [0, -45, -10, 6, 0],\n              }\n            : { rotateX: final.rotateX, rotateY: final.rotateY, rotateZ: 0, y: 0 }\n        }\n        transition={isRolling ? { duration: 1.7, ease: [0.22, 0.8, 0.2, 1], delay } : { duration: 0.45, ease: \"easeOut\", delay: delay * 0.5 }}\n        className=\"relative h-full w-full\"\n        style={{ transformStyle: \"preserve-3d\" }}\n      >\n        {DICE_FACES.map((item) => (\n          <div\n            key={item.face}\n            className=\"absolute flex items-center justify-center rounded-[9px] border border-black/5\"\n            style={{\n              width: 84,\n              height: 84,\n              background: \"linear-gradient(150deg, #ffffff 0%, #f4f5f7 55%, #e3e5e9 100%)\",\n              backfaceVisibility: \"hidden\",\n              transform: item.transform,\n              boxShadow: \"inset 0 1.5px 2px rgba(255,255,255,0.9), inset 0 -4px 8px rgba(0,0,0,0.08), 0 10px 22px rgba(0,0,0,0.35)\",\n            }}\n          >\n            <Pips number={item.face} />\n          </div>\n        ))}\n      </motion.div>\n    </div>\n  );\n}\n\nexport interface DiceRollDiscountPopupProps extends Omit<React.ComponentPropsWithoutRef<\"div\">, \"children\"> {\n  accentColor?: string;\n  theme?: keyof typeof THEMES;\n  lightMode?: boolean;\n  asPopup?: boolean;\n  /** Only used when asPopup is true — starts the popup open instead of showing the launcher widget. */\n  defaultOpen?: boolean;\n  trigger?: \"manual\" | \"delay\" | \"scroll\";\n  delaySeconds?: number;\n  widgetPosition?: \"bottom-right\" | \"bottom-left\";\n  widgetIcon?: string;\n  freeRolls?: number;\n  storageKey?: string;\n}\n\n/**\n * DiceRollDiscountPopup — a gamified discount-capture widget: roll two dice\n * (3D, CSS-transform based) for a reward tier, with a themed reward reveal\n * modal and code copy. Renders inline, or as a corner-launched popup with\n * manual / delay / scroll-into-view triggers.\n */\nexport function DiceRollDiscountPopup({\n  className,\n  accentColor = \"#ffffff\",\n  theme = \"ecommerce\",\n  lightMode = false,\n  asPopup = false,\n  defaultOpen = false,\n  trigger = \"manual\",\n  delaySeconds = 4,\n  widgetPosition = \"bottom-right\",\n  widgetIcon,\n  freeRolls = 3,\n  storageKey = \"\",\n  ...props\n}: DiceRollDiscountPopupProps) {\n  const uid = React.useId();\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const popupCardRef = React.useRef<HTMLDivElement>(null);\n  const rewardModalRef = React.useRef<HTMLDivElement>(null);\n  const widgetTriggerRef = React.useRef<HTMLButtonElement>(null);\n  const cardRef = React.useRef<HTMLDivElement>(null);\n  const rollTimerRef = React.useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n  const settleTimerRef = React.useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n  const copyTimerRef = React.useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n  const [dice1, setDice1] = React.useState(1);\n  const [dice2, setDice2] = React.useState(1);\n  const [isRolling, setIsRolling] = React.useState(false);\n  const [total, setTotal] = React.useState<number | null>(null);\n  const [currentReward, setCurrentReward] = React.useState<Reward | null>(null);\n  const [showPopup, setShowPopup] = React.useState(false);\n  const [rewards, setRewards] = React.useState<Reward[]>([]);\n  const [rollsLeft, setRollsLeft] = React.useState(freeRolls);\n  const [message, setMessage] = React.useState(`You have ${freeRolls} free roll${freeRolls === 1 ? \"\" : \"s\"}`);\n  const [copiedCode, setCopiedCode] = React.useState<string | null>(null);\n\n  const [popupOpen, setPopupOpen] = React.useState(!asPopup || defaultOpen);\n  const [scrollTriggered, setScrollTriggered] = React.useState(false);\n  const [widgetHover, setWidgetHover] = React.useState(false);\n  const [widgetVisible, setWidgetVisible] = React.useState(true);\n  const [prevAsPopup, setPrevAsPopup] = React.useState(asPopup);\n\n  if (asPopup !== prevAsPopup) {\n    setPrevAsPopup(asPopup);\n    setPopupOpen(!asPopup || defaultOpen);\n  }\n\n  const activeTheme = THEMES[theme] || THEMES.ecommerce;\n  const widgetContainerRef = React.useRef<HTMLDivElement>(null);\n\n  const mode = lightMode\n    ? {\n        ink: \"#171a21\",\n        inkSoft: \"rgba(23,26,33,0.7)\",\n        inkMuted: \"rgba(23,26,33,0.5)\",\n        inkFaint: \"rgba(23,26,33,0.4)\",\n        divider: \"rgba(23,26,33,0.18)\",\n        surface: \"rgba(255,255,255,0.65)\",\n        surfaceBorder: \"rgba(23,26,33,0.1)\",\n        cardBorder: \"rgba(23,26,33,0.08)\",\n        overlayBg: \"rgba(255,255,255,0.9)\",\n        modalBg: \"rgba(255,255,255,0.75)\",\n        modalBorder: \"rgba(23,26,33,0.12)\",\n        codeBoxBg: \"rgba(23,26,33,0.03)\",\n        codeBoxBorder: \"rgba(23,26,33,0.25)\",\n        chromeBg: \"#ffffff\",\n        chromeBorder: \"rgba(23,26,33,0.1)\",\n        iconStroke: \"rgba(23,26,33,0.55)\",\n      }\n    : {\n        ink: \"#ffffff\",\n        inkSoft: \"rgba(255,255,255,0.7)\",\n        inkMuted: \"rgba(255,255,255,0.45)\",\n        inkFaint: \"rgba(255,255,255,0.4)\",\n        divider: \"rgba(255,255,255,0.3)\",\n        surface: \"rgba(255,255,255,0.06)\",\n        surfaceBorder: \"rgba(255,255,255,0.12)\",\n        cardBorder: \"rgba(255,255,255,0.08)\",\n        overlayBg: \"rgba(4,4,6,0.86)\",\n        modalBg: \"rgba(255,255,255,0.06)\",\n        modalBorder: \"rgba(255,255,255,0.16)\",\n        codeBoxBg: \"rgba(255,255,255,0.04)\",\n        codeBoxBorder: \"rgba(255,255,255,0.3)\",\n        chromeBg: \"rgba(10,10,15,0.92)\",\n        chromeBorder: \"rgba(255,255,255,0.16)\",\n        iconStroke: \"rgba(255,255,255,0.6)\",\n      };\n\n  const suffix = storageKey.trim() ? `-${storageKey.trim()}` : \"\";\n  const rollsKey = `dice-roll-rolls-left${suffix}`;\n  const rewardsKey = `dice-roll-rewards${suffix}`;\n\n  React.useEffect(() => {\n    const savedRolls = localStorage.getItem(rollsKey);\n    const savedRewards = localStorage.getItem(rewardsKey);\n    // Restored after mount on purpose: reading storage during render would not match the\n    // server-rendered HTML.\n    // eslint-disable-next-line react-hooks/set-state-in-effect\n    if (savedRolls !== null) setRollsLeft(parseInt(savedRolls, 10));\n    if (savedRewards) {\n      try {\n        setRewards(JSON.parse(savedRewards));\n      } catch {\n        setRewards([]);\n      }\n    }\n    if (savedRolls === \"0\") setMessage(\"All rolls used\");\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, []);\n\n  React.useEffect(() => {\n    return () => {\n      clearTimeout(rollTimerRef.current);\n      clearTimeout(settleTimerRef.current);\n      clearTimeout(copyTimerRef.current);\n    };\n  }, []);\n\n  React.useEffect(() => {\n    if (!asPopup || trigger !== \"delay\") return;\n    const t = setTimeout(() => setPopupOpen(true), delaySeconds * 1000);\n    return () => clearTimeout(t);\n  }, [asPopup, trigger, delaySeconds]);\n\n  React.useEffect(() => {\n    if (!asPopup || trigger !== \"scroll\" || !rootRef.current) return;\n    const observer = new IntersectionObserver(\n      ([entry]) => {\n        if (entry.isIntersecting && !scrollTriggered) {\n          setScrollTriggered(true);\n          setPopupOpen(true);\n        }\n      },\n      { threshold: 0.4 }\n    );\n    observer.observe(rootRef.current);\n    return () => observer.disconnect();\n  }, [asPopup, trigger, scrollTriggered]);\n\n  React.useEffect(() => {\n    if (!asPopup || !widgetContainerRef.current) return;\n    const el = widgetContainerRef.current;\n    const observer = new IntersectionObserver(([entry]) => setWidgetVisible(entry.isIntersecting), { threshold: 0 });\n    observer.observe(el);\n    return () => observer.disconnect();\n  }, [asPopup]);\n\n  const wasPopupOpenRef = React.useRef(false);\n  React.useEffect(() => {\n    if (!asPopup) return;\n    if (popupOpen) {\n      popupCardRef.current?.focus();\n    } else if (wasPopupOpenRef.current) {\n      widgetTriggerRef.current?.focus();\n    }\n    wasPopupOpenRef.current = popupOpen;\n  }, [asPopup, popupOpen]);\n\n  React.useEffect(() => {\n    if (!showPopup) return;\n    rewardModalRef.current?.focus();\n  }, [showPopup]);\n\n  const getReward = React.useCallback(\n    (sum: number, isDoubles: boolean): Reward => {\n      if (isDoubles) return activeTheme.doublesReward;\n      const tier = activeTheme.rewards.find((t) => sum <= t.max);\n      return tier || activeTheme.rewards[activeTheme.rewards.length - 1];\n    },\n    [activeTheme]\n  );\n\n  const rollDice = () => {\n    if (rollsLeft <= 0 || isRolling) return;\n    setIsRolling(true);\n    setTotal(null);\n    setMessage(\"Rolling...\");\n    clearTimeout(rollTimerRef.current);\n    clearTimeout(settleTimerRef.current);\n\n    rollTimerRef.current = setTimeout(() => {\n      const side1 = Math.floor(Math.random() * 6) + 1;\n      const side2 = Math.floor(Math.random() * 6) + 1;\n      const sum = side1 + side2;\n      const isDoubles = side1 === side2;\n      const won = getReward(sum, isDoubles);\n\n      setDice1(side1);\n      setDice2(side2);\n      setTotal(sum);\n      setCurrentReward(won);\n      setIsRolling(false);\n\n      const newRewards = [...rewards, won];\n      const newRollsLeft = rollsLeft - 1;\n      setRewards(newRewards);\n      setRollsLeft(newRollsLeft);\n      localStorage.setItem(rewardsKey, JSON.stringify(newRewards));\n      localStorage.setItem(rollsKey, newRollsLeft.toString());\n\n      setMessage(newRollsLeft === 0 ? \"All rolls used\" : `${newRollsLeft} roll${newRollsLeft > 1 ? \"s\" : \"\"} left`);\n\n      settleTimerRef.current = setTimeout(() => setShowPopup(true), 600);\n    }, 1800);\n  };\n\n  const copyCode = (code: string) => {\n    navigator.clipboard.writeText(code).catch(() => {});\n    setCopiedCode(code);\n    clearTimeout(copyTimerRef.current);\n    copyTimerRef.current = setTimeout(() => setCopiedCode(null), 1500);\n  };\n\n  const widgetOnRight = widgetPosition !== \"bottom-left\";\n\n  const gameCard = (\n    <div\n      ref={cardRef}\n      className=\"relative box-border flex w-full min-w-0 flex-col items-center justify-start overflow-hidden rounded-[22px] px-[26px] py-8 font-sans select-none\"\n      style={{\n        background: lightMode ? activeTheme.lightBackground : activeTheme.background,\n        border: `1px solid ${mode.cardBorder}`,\n        ...(asPopup ? { height: \"auto\", minHeight: 0, maxHeight: \"90vh\", overflowY: \"auto\" } : {}),\n      }}\n    >\n      <div className=\"relative z-[1] mb-[22px] text-center\">\n        <h2 id={`${uid}-title`} className=\"m-0 font-serif text-[25px] font-normal leading-[1.15] tracking-[-0.02em]\" style={{ color: mode.ink }}>\n          {activeTheme.title}\n        </h2>\n        <div className=\"mx-auto my-3 h-px w-8\" style={{ background: mode.divider }} />\n        <div className=\"text-[10px] font-semibold uppercase tracking-[0.18em]\" style={{ color: mode.inkFaint }}>\n          {activeTheme.subtitle}\n        </div>\n      </div>\n\n      <div className=\"relative z-[1] mb-[22px] flex justify-center gap-6\" style={{ perspective: 800 }} aria-hidden=\"true\">\n        <Dice3D value={dice1} delay={0} isRolling={isRolling} />\n        <Dice3D value={dice2} delay={0.1} isRolling={isRolling} />\n      </div>\n\n      <div\n        className=\"relative z-[1] mb-2.5 w-full max-w-[260px] rounded-[14px] px-4 py-3 text-center backdrop-blur-[8px]\"\n        style={{ background: mode.surface, border: `1px solid ${mode.surfaceBorder}` }}\n      >\n        <div className=\"text-[10px] font-bold uppercase tracking-[0.2em]\" style={{ color: mode.inkFaint }}>\n          Result\n        </div>\n        <div className=\"font-serif text-[34px] font-normal\" style={{ color: mode.ink }} aria-live=\"polite\">\n          {total !== null ? total : \"-\"}\n        </div>\n      </div>\n\n      <div className=\"relative z-[1] mb-[18px] text-center text-xs font-semibold uppercase tracking-[0.08em]\" style={{ color: mode.inkMuted }} aria-live=\"polite\">\n        {message}\n      </div>\n\n      <motion.button\n        onClick={rollDice}\n        whileHover={{ scale: rollsLeft <= 0 || isRolling ? 1 : 1.03 }}\n        whileTap={{ scale: rollsLeft <= 0 || isRolling ? 1 : 0.97 }}\n        disabled={rollsLeft <= 0 || isRolling}\n        className=\"relative z-[1] mb-[26px] rounded-[40px] border-none px-[30px] py-3.5 text-xs font-bold uppercase tracking-[0.1em] text-[#0a0a0f]\"\n        style={{\n          background: accentColor,\n          opacity: rollsLeft <= 0 || isRolling ? 0.4 : 1,\n          cursor: rollsLeft <= 0 || isRolling ? \"not-allowed\" : \"pointer\",\n        }}\n      >\n        {isRolling ? \"Rolling...\" : rollsLeft <= 0 ? \"No Rolls Left\" : `${activeTheme.buttonText} · ${rollsLeft} left`}\n      </motion.button>\n\n      {rewards.length > 0 && (\n        <div className=\"relative z-[1] mt-1.5 w-full max-w-[340px]\">\n          <div className=\"mb-3 text-center text-[10px] font-bold uppercase tracking-[0.2em]\" style={{ color: mode.inkFaint }}>\n            Your Rewards\n          </div>\n          <div className=\"flex flex-col gap-2\">\n            {rewards.map((r, i) => {\n              const isCopied = copiedCode === r.code;\n              return (\n                <div\n                  key={i}\n                  className=\"flex items-center justify-between rounded-xl px-4 py-3 backdrop-blur-[8px]\"\n                  style={{ background: mode.surface, border: `1px solid ${mode.surfaceBorder}` }}\n                >\n                  <div>\n                    <div className=\"text-sm font-semibold\" style={{ color: mode.ink }}>\n                      {r.label}\n                    </div>\n                    <div className=\"mt-0.5 text-[11px] font-semibold tracking-[0.06em]\" style={{ color: mode.inkFaint }}>\n                      {r.code}\n                    </div>\n                  </div>\n                  <button\n                    onClick={() => copyCode(r.code)}\n                    className=\"flex items-center justify-center rounded-lg border-none bg-transparent p-1.5\"\n                    title=\"Copy code\"\n                    aria-label=\"Copy code\"\n                  >\n                    {isCopied ? (\n                      <span style={{ color: mode.ink, fontSize: 14, fontWeight: 700 }}>✓</span>\n                    ) : (\n                      <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke={mode.iconStroke} strokeWidth=\"2\">\n                        <rect x=\"9\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\" ry=\"2\" />\n                        <path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\" />\n                      </svg>\n                    )}\n                  </button>\n                </div>\n              );\n            })}\n          </div>\n        </div>\n      )}\n\n      <AnimatePresence>\n        {showPopup && currentReward && (\n          <motion.div\n            initial={{ opacity: 0 }}\n            animate={{ opacity: 1 }}\n            exit={{ opacity: 0, transition: { duration: 0.12 } }}\n            className=\"absolute inset-0 z-50 flex items-center justify-center rounded-[22px] p-4 backdrop-blur-[6px]\"\n            style={{ background: mode.overlayBg }}\n          >\n            <motion.div\n              ref={rewardModalRef}\n              initial={{ opacity: 0, scale: 0.96 }}\n              animate={{ opacity: 1, scale: 1 }}\n              exit={{ opacity: 0, scale: 0.98 }}\n              transition={{ duration: 0.35, ease: [0.16, 1, 0.3, 1] }}\n              role=\"dialog\"\n              aria-modal=\"true\"\n              aria-labelledby={`${uid}-reward-title`}\n              tabIndex={-1}\n              onKeyDown={(e) => {\n                if (e.key === \"Escape\") setShowPopup(false);\n              }}\n              className=\"w-full max-w-[300px] rounded-[18px] px-[26px] py-[30px] text-center backdrop-blur-[20px]\"\n              style={{ background: mode.modalBg, border: `1px solid ${mode.modalBorder}`, boxShadow: \"0 20px 50px rgba(0,0,0,0.5)\" }}\n            >\n              <motion.h3\n                id={`${uid}-reward-title`}\n                initial={{ opacity: 0, y: 14 }}\n                animate={{ opacity: 1, y: 0 }}\n                transition={{ delay: 0.15, duration: 0.4 }}\n                className=\"m-0 font-serif text-2xl font-normal\"\n                style={{ color: mode.ink }}\n              >\n                You won\n              </motion.h3>\n              <motion.div\n                initial={{ scaleX: 0 }}\n                animate={{ scaleX: 1 }}\n                transition={{ delay: 0.25, duration: 0.4 }}\n                className=\"mx-auto my-3 mb-3.5 h-px w-7 origin-center\"\n                style={{ background: mode.divider }}\n              />\n              <motion.p\n                initial={{ opacity: 0, y: 10 }}\n                animate={{ opacity: 1, y: 0 }}\n                transition={{ delay: 0.3, duration: 0.4 }}\n                className=\"m-0 mb-[18px] text-[15px]\"\n                style={{ color: mode.inkSoft }}\n              >\n                {currentReward.label}\n              </motion.p>\n              <motion.div\n                initial={{ opacity: 0, y: 10 }}\n                animate={{ opacity: 1, y: 0 }}\n                transition={{ delay: 0.35, duration: 0.4 }}\n                className=\"mb-5 rounded-[10px] border border-dashed p-3\"\n                style={{ background: mode.codeBoxBg, borderColor: mode.codeBoxBorder }}\n              >\n                <span className=\"text-base font-bold tracking-[0.06em]\" style={{ color: mode.ink }}>\n                  {currentReward.code}\n                </span>\n              </motion.div>\n              <motion.button\n                initial={{ opacity: 0, y: 10 }}\n                animate={{ opacity: 1, y: 0 }}\n                transition={{ delay: 0.4, duration: 0.4 }}\n                onClick={() => setShowPopup(false)}\n                className=\"w-full cursor-pointer rounded-[40px] border-none px-[13px] py-[13px] text-xs font-bold uppercase tracking-[0.1em] text-[#0a0a0f]\"\n                style={{ background: accentColor }}\n              >\n                Continue\n              </motion.button>\n            </motion.div>\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </div>\n  );\n\n  if (!asPopup) {\n    return (\n      <div ref={rootRef} className={cn(\"w-full\", className)} {...props}>\n        {gameCard}\n      </div>\n    );\n  }\n\n  return (\n    <div ref={rootRef} className={cn(\"relative\", className)} {...props}>\n      <div\n        ref={widgetContainerRef}\n        className=\"fixed bottom-6 z-[9998] flex items-center gap-2.5\"\n        style={{ flexDirection: widgetOnRight ? \"row-reverse\" : \"row\", ...(widgetOnRight ? { right: 24 } : { left: 24 }) }}\n      >\n        <motion.button\n          ref={widgetTriggerRef}\n          onClick={() => setPopupOpen(true)}\n          onHoverStart={() => setWidgetHover(true)}\n          onHoverEnd={() => setWidgetHover(false)}\n          whileHover={{ scale: 1.06 }}\n          whileTap={{ scale: 0.94 }}\n          aria-label={activeTheme.triggerText}\n          className=\"relative flex h-14 w-14 shrink-0 cursor-pointer items-center justify-center rounded-full backdrop-blur-[10px]\"\n          style={{ background: \"#ffffff\", border: \"1px solid rgba(0,0,0,0.08)\", boxShadow: `0 8px 28px ${activeTheme.glow}, 0 4px 14px rgba(0,0,0,0.5)` }}\n        >\n          <motion.span\n            className=\"pointer-events-none absolute inset-0 rounded-full\"\n            style={{ background: \"rgba(0,0,0,0.12)\" }}\n            animate={!widgetVisible ? undefined : { scale: [1, 1.7, 1.7], opacity: [0.4, 0, 0] }}\n            transition={!widgetVisible ? { duration: 0 } : { duration: 2.2, repeat: Infinity, ease: \"easeOut\" }}\n          />\n          {widgetIcon ? (\n            <img src={widgetIcon} alt=\"\" className=\"relative h-7 w-7 rounded-full object-cover\" />\n          ) : (\n            <GiftIcon />\n          )}\n        </motion.button>\n\n        <AnimatePresence>\n          {widgetHover && (\n            <motion.div\n              initial={{ opacity: 0, x: widgetOnRight ? 10 : -10 }}\n              animate={{ opacity: 1, x: 0 }}\n              exit={{ opacity: 0, x: widgetOnRight ? 10 : -10 }}\n              transition={{ duration: 0.18 }}\n              className=\"whitespace-nowrap rounded-[10px] px-4 py-2.5 text-[11px] font-semibold uppercase tracking-[0.06em] backdrop-blur-[10px]\"\n              style={{ background: mode.chromeBg, border: `1px solid ${mode.chromeBorder}`, color: mode.ink }}\n            >\n              {activeTheme.triggerText}\n            </motion.div>\n          )}\n        </AnimatePresence>\n      </div>\n\n      <AnimatePresence>\n        {popupOpen && (\n          <motion.div\n            initial={{ opacity: 0 }}\n            animate={{ opacity: 1 }}\n            exit={{ opacity: 0 }}\n            className=\"fixed inset-0 z-[9999] flex items-center justify-center p-5 backdrop-blur-[4px]\"\n            style={{ background: \"rgba(0,0,0,0.7)\" }}\n          >\n            <motion.div\n              ref={popupCardRef}\n              initial={{ scale: 0.94, y: 16 }}\n              animate={{ scale: 1, y: 0 }}\n              exit={{ scale: 0.96, opacity: 0 }}\n              transition={{ duration: 0.35, ease: [0.16, 1, 0.3, 1] }}\n              role=\"dialog\"\n              aria-modal=\"true\"\n              aria-labelledby={`${uid}-title`}\n              tabIndex={-1}\n              onKeyDown={(e) => {\n                if (e.key === \"Escape\") setPopupOpen(false);\n              }}\n              className=\"relative w-full max-w-[420px]\"\n              style={{ maxHeight: \"90vh\" }}\n            >\n              {gameCard}\n              <button\n                onClick={() => setPopupOpen(false)}\n                aria-label=\"Close\"\n                className=\"absolute -right-3.5 -top-3.5 z-[100] flex h-8 w-8 cursor-pointer items-center justify-center rounded-full p-0 text-[17px] leading-[30px]\"\n                style={{ background: mode.chromeBg, border: `1px solid ${mode.chromeBorder}`, color: mode.ink, boxShadow: \"0 4px 16px rgba(0,0,0,0.5)\" }}\n              >\n                ×\n              </button>\n            </motion.div>\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </div>\n  );\n}\n\nexport default DiceRollDiscountPopup;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}