{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "exit-intent-survey",
  "title": "Exit Intent — Survey",
  "type": "registry:block",
  "files": [
    {
      "path": "packages/registry-react/blocks/exit-intent-survey/ExitIntentSurvey.tsx",
      "content": "'use client'\n\nimport { useEffect, useState } from 'react'\nimport { Check } from 'lucide-react'\nimport { Badge } from '@/components/ui/badge'\nimport { Button } from '@/components/ui/button'\nimport { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog'\nimport { Textarea } from '@/components/ui/textarea'\nimport { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group'\n\nconst options = [\n  'Pricing was unclear',\n  'Missing an integration',\n  'Just browsing',\n  'Security questions',\n  'Something else',\n]\n\nexport function ExitIntentSurvey({ storageKey = 'uipkge:exit-survey-seen' }: { storageKey?: string }) {\n  const [open, setOpen] = useState(false)\n  const [choice, setChoice] = useState('')\n  const [detail, setDetail] = useState('')\n  const [sent, setSent] = useState(false)\n\n  useEffect(() => {\n    const onPointerOut = (event: MouseEvent) => {\n      if (event.relatedTarget || event.clientY > 4) return\n      try {\n        if (window.sessionStorage.getItem(storageKey) === '1') return\n        window.sessionStorage.setItem(storageKey, '1')\n      } catch {\n        // Blocked storage: shows once more this page view, never in a loop.\n      }\n      setOpen(true)\n      document.removeEventListener('mouseout', onPointerOut)\n    }\n    document.addEventListener('mouseout', onPointerOut)\n    return () => document.removeEventListener('mouseout', onPointerOut)\n  }, [storageKey])\n\n  function submit() {\n    if (!choice) return\n    setSent(true)\n    // Close on its own rather than making someone dismiss a thank-you.\n    setTimeout(() => setOpen(false), 1400)\n  }\n\n  return (\n    <div data-slot=\"exit-intent-survey\">\n      <Dialog open={open} onOpenChange={setOpen}>\n        <DialogContent className=\"sm:max-w-md\">\n          {!sent ? (\n            <div>\n              <DialogHeader>\n                <Badge variant=\"secondary\" className=\"w-fit\">\n                  One question\n                </Badge>\n                <DialogTitle className=\"mt-3 text-xl leading-snug text-balance\">What were you looking for?</DialogTitle>\n                <DialogDescription>\n                  It goes to the people who build the page. No follow-up email unless you ask for one.\n                </DialogDescription>\n              </DialogHeader>\n\n              <ToggleGroup\n                value={choice}\n                type=\"single\"\n                variant=\"outline\"\n                size=\"sm\"\n                className=\"mt-5 flex-wrap justify-start\"\n                aria-label=\"Reason for leaving\"\n                onValueChange={(value: string) => setChoice(value ?? '')}\n              >\n                {options.map((option) => (\n                  <ToggleGroupItem key={option} value={option}>\n                    {option}\n                  </ToggleGroupItem>\n                ))}\n              </ToggleGroup>\n\n              <Textarea\n                value={detail}\n                onValueChange={setDetail}\n                className=\"mt-3\"\n                rows={3}\n                placeholder=\"Anything more (optional)\"\n                label=\"Anything more (optional)\"\n              />\n\n              <div className=\"mt-4 flex items-center gap-2\">\n                <Button disabled={!choice} onClick={submit}>\n                  Send\n                </Button>\n                <Button variant=\"ghost\" onClick={() => setOpen(false)}>\n                  Skip\n                </Button>\n              </div>\n            </div>\n          ) : (\n            <div className=\"py-6 text-center\" aria-live=\"polite\">\n              <span className=\"bg-success/10 mx-auto flex size-10 items-center justify-center rounded-full\">\n                <Check className=\"text-success size-5\" aria-hidden=\"true\" />\n              </span>\n              <p className=\"mt-3 text-sm font-medium\">Thanks — that is genuinely useful.</p>\n            </div>\n          )}\n        </DialogContent>\n      </Dialog>\n    </div>\n  )\n}\n",
      "type": "registry:block",
      "target": "~/components/blocks/ExitIntentSurvey.tsx"
    }
  ],
  "dependencies": [
    "lucide-react"
  ],
  "devDependencies": [],
  "registryDependencies": [
    "https://uipkge.dev/r/react/badge.json",
    "https://uipkge.dev/r/react/button.json",
    "https://uipkge.dev/r/react/dialog.json",
    "https://uipkge.dev/r/react/textarea.json",
    "https://uipkge.dev/r/react/toggle-group.json"
  ],
  "description": "One-question exit survey asking what the visitor did not find, with preset answers, an optional free-text field, and a thank-you state that closes itself.",
  "categories": [
    "marketing"
  ],
  "deprecated": true,
  "replacedBy": "exit-intent"
}