{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ai-code-review-assistant",
  "title": "Ai Code Review Assistant",
  "type": "registry:block",
  "files": [
    {
      "path": "packages/registry-react/blocks/ai-code-review-assistant/AiCodeReviewAssistant.tsx",
      "content": "'use client'\n\nimport * as React from 'react'\nimport {\n  Bot,\n  Check,\n  CheckCircle2,\n  CheckCheck,\n  Code2,\n  Copy,\n  Cpu,\n  FileCode2,\n  GitBranch,\n  GitCommit,\n  GitPullRequest,\n  Layers,\n  MessageSquare,\n  RefreshCw,\n  RotateCcw,\n  Send,\n  ShieldCheck,\n  Sparkles,\n  TrendingDown,\n  TrendingUp,\n  X,\n  Zap,\n} from 'lucide-react'\nimport { cn } from '@/lib/utils'\nimport { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'\nimport { Badge } from '@/components/ui/badge'\nimport { Button } from '@/components/ui/button'\nimport { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'\nimport { Separator } from '@/components/ui/separator'\nimport { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'\n\nexport interface AiCodeReviewAssistantProps {\n  prNumber?: number\n  prTitle?: string\n  authorName?: string\n  authorHandle?: string\n  authorRole?: string\n  authorAvatar?: string\n  sourceBranch?: string\n  targetBranch?: string\n  className?: string\n}\n\nexport interface DiffLine {\n  id: string\n  oldNum?: number\n  newNum?: number\n  type: 'neutral' | 'deletion' | 'addition' | 'hunk'\n  text: string\n  annotationId?: string\n}\n\nexport interface ChatMessage {\n  id: string\n  sender: 'ai' | 'user'\n  author: string\n  timestamp: string\n  text: string\n  codeSnippet?: string\n}\n\nexport function AiCodeReviewAssistant({\n  prNumber = 412,\n  prTitle = 'refactor(tokens): migrate to OKLCH perceptual contrast engine',\n  authorName = 'Elena Rostova',\n  authorHandle = 'elena-rostova',\n  authorRole = 'Staff Design Systems Engineer',\n  authorAvatar = 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=96&h=96&fit=crop&crop=face',\n  sourceBranch = 'feature/oklch-engine',\n  targetBranch = 'main',\n  className,\n}: AiCodeReviewAssistantProps) {\n  const [activeTab, setActiveTab] = React.useState('diff')\n  const [isApplyingAll, setIsApplyingAll] = React.useState(false)\n  const [appliedPatches, setAppliedPatches] = React.useState<Set<string>>(new Set())\n  const [isChatOpen, setIsChatOpen] = React.useState(false)\n  const [chatInput, setChatInput] = React.useState('')\n  const [copiedDiff, setCopiedDiff] = React.useState(false)\n  const [copiedPatchId, setCopiedPatchId] = React.useState<string | null>(null)\n\n  const [chatMessages, setChatMessages] = React.useState<ChatMessage[]>([\n    {\n      id: 'msg-1',\n      sender: 'ai',\n      author: 'Glia AI Code Reviewer',\n      timestamp: '2 min ago',\n      text: \"I completed the AST review for PR #412. Migrating to OKLCH perceptual contrast is a massive win. I've pinpointed 2 optimization opportunities to maximize token efficiency and eliminate 20 DOM variables.\",\n    },\n    {\n      id: 'msg-2',\n      sender: 'user',\n      author: 'Elena Rostova',\n      timestamp: '1 min ago',\n      text: 'Why is `color-mix(in oklab, ... 10%, transparent)` better than declaring separate opacity custom properties?',\n    },\n    {\n      id: 'msg-3',\n      sender: 'ai',\n      author: 'Glia AI Code Reviewer',\n      timestamp: 'Just now',\n      text: 'Direct OKLab color-mix calculates the alpha composite on the GPU shader pipeline without registering 20 CSS custom properties in the browser style recalculation tree. This cuts ~1.8 KB from DOM memory while keeping luminance completely linear.',\n      codeSnippet: 'color-mix(in oklab, var(--primary) 10%, transparent)',\n    },\n  ])\n\n  const diffLines: DiffLine[] = React.useMemo(\n    () => [\n      {\n        id: 'hunk-1',\n        type: 'hunk',\n        text: '@@ -32,18 +32,24 @@ packages/shared/styles/tailwind.css',\n      },\n      {\n        id: 'line-32',\n        oldNum: 32,\n        newNum: 32,\n        type: 'neutral',\n        text: '@import \"tailwindcss\";',\n      },\n      {\n        id: 'line-33',\n        oldNum: 33,\n        newNum: 33,\n        type: 'neutral',\n        text: '@import \"tw-animate-css\";',\n      },\n      {\n        id: 'line-34',\n        oldNum: 34,\n        newNum: 34,\n        type: 'neutral',\n        text: '',\n      },\n      {\n        id: 'line-35',\n        oldNum: 35,\n        newNum: 35,\n        type: 'neutral',\n        text: '@theme inline {',\n      },\n      {\n        id: 'line-36',\n        oldNum: 36,\n        newNum: 36,\n        type: 'neutral',\n        text: '  --font-sans: \"Inter\", system-ui, sans-serif;',\n      },\n      {\n        id: 'line-37',\n        oldNum: 37,\n        newNum: 37,\n        type: 'neutral',\n        text: '  --font-mono: \"DM Mono\", monospace;',\n      },\n      {\n        id: 'line-38',\n        oldNum: 38,\n        type: 'deletion',\n        text: '-  --primary-10: color-mix(in srgb, var(--primary) 10%, #ffffff);',\n      },\n      {\n        id: 'line-39',\n        oldNum: 39,\n        type: 'deletion',\n        text: '-  --primary-20: color-mix(in srgb, var(--primary) 20%, #ffffff);',\n      },\n      {\n        id: 'line-40',\n        oldNum: 40,\n        type: 'deletion',\n        text: '-  --primary-hover: hsl(var(--primary-hsl) / 0.85);',\n      },\n      {\n        id: 'line-41',\n        newNum: 38,\n        type: 'addition',\n        text: '+  --primary-hover: oklch(from var(--primary) calc(l * 0.92) c h);',\n      },\n      {\n        id: 'line-42',\n        newNum: 39,\n        type: 'addition',\n        text: appliedPatches.has('patch-1')\n          ? '+  --primary-accent: color-mix(in oklab, var(--primary) 10%, transparent); /* [Glia AI Patch Applied] */'\n          : '+  --primary-accent: color-mix(in oklab, var(--primary) 15%, transparent);',\n        annotationId: 'patch-1',\n      },\n      {\n        id: 'line-43',\n        oldNum: 41,\n        newNum: 40,\n        type: 'neutral',\n        text: '  --color-background: var(--background);',\n      },\n      {\n        id: 'line-44',\n        oldNum: 42,\n        newNum: 41,\n        type: 'neutral',\n        text: '  --color-foreground: var(--foreground);',\n      },\n      {\n        id: 'line-45',\n        oldNum: 43,\n        type: 'deletion',\n        text: '-  --muted-border: rgb(229 231 235 / 0.6);',\n      },\n      {\n        id: 'line-46',\n        newNum: 42,\n        type: 'addition',\n        text: '+  --muted-border: oklch(0.92 0.005 240 / 0.8);',\n      },\n      {\n        id: 'line-47',\n        oldNum: 44,\n        newNum: 43,\n        type: 'neutral',\n        text: '  --color-border: var(--border);',\n      },\n      {\n        id: 'line-48',\n        oldNum: 45,\n        newNum: 44,\n        type: 'neutral',\n        text: '  --color-input: var(--input);',\n      },\n      {\n        id: 'line-49',\n        oldNum: 46,\n        type: 'deletion',\n        text: '-  --ring-offset-width: 2px;',\n      },\n      {\n        id: 'line-50',\n        newNum: 45,\n        type: 'addition',\n        text: '+  --color-ring: oklch(from var(--primary) l c h / 0.5);',\n      },\n      {\n        id: 'line-51',\n        newNum: 46,\n        type: 'addition',\n        text: appliedPatches.has('patch-2')\n          ? '+  --ring-focus-shadow: 0 0 0 2px var(--color-ring); /* [Glia AI Patch Applied] */'\n          : '+  --ring-focus-shadow: 0 0 0 2px var(--color-ring);',\n        annotationId: 'patch-2',\n      },\n      {\n        id: 'line-52',\n        oldNum: 47,\n        newNum: 47,\n        type: 'neutral',\n        text: '  --color-card: var(--card);',\n      },\n      {\n        id: 'line-53',\n        oldNum: 48,\n        newNum: 48,\n        type: 'neutral',\n        text: '  --color-card-foreground: var(--card-foreground);',\n      },\n      {\n        id: 'line-54',\n        oldNum: 49,\n        newNum: 49,\n        type: 'neutral',\n        text: '}',\n      },\n    ],\n    [appliedPatches],\n  )\n\n  const allPatchesApplied = appliedPatches.size === 2\n  const qualityScore = allPatchesApplied ? 99 : 96\n\n  const togglePatch = (patchId: string) => {\n    setAppliedPatches((prev) => {\n      const next = new Set(prev)\n      if (next.has(patchId)) {\n        next.delete(patchId)\n      } else {\n        next.add(patchId)\n      }\n      return next\n    })\n  }\n\n  const applyAllPatches = () => {\n    if (isApplyingAll) return\n    setIsApplyingAll(true)\n    setTimeout(() => {\n      setAppliedPatches(new Set(['patch-1', 'patch-2']))\n      setIsApplyingAll(false)\n    }, 600)\n  }\n\n  const resetPatches = () => {\n    setAppliedPatches(new Set())\n  }\n\n  const openChatWithTopic = (topicText?: string) => {\n    setIsChatOpen(true)\n    if (topicText) {\n      const userMsg: ChatMessage = {\n        id: `user-${Date.now()}`,\n        sender: 'user',\n        author: 'Elena Rostova',\n        timestamp: 'Just now',\n        text: topicText,\n      }\n      setChatMessages((prev) => [...prev, userMsg])\n      setTimeout(() => {\n        const aiMsg: ChatMessage = {\n          id: `ai-${Date.now()}`,\n          sender: 'ai',\n          author: 'Glia AI Code Reviewer',\n          timestamp: 'Just now',\n          text: `Regarding \"${topicText}\": Our AST lint engine verified that OKLCH relative color syntax produces 7:1 contrast on dark surfaces with zero gamut clipping on Apple Display P3 panels.`,\n        }\n        setChatMessages((prev) => [...prev, aiMsg])\n      }, 450)\n    }\n  }\n\n  const handleSendMessage = (e: React.FormEvent) => {\n    e.preventDefault()\n    const text = chatInput.trim()\n    if (!text) return\n    const userMsg: ChatMessage = {\n      id: `msg-${Date.now()}`,\n      sender: 'user',\n      author: 'Elena Rostova',\n      timestamp: 'Just now',\n      text,\n    }\n    setChatMessages((prev) => [...prev, userMsg])\n    setChatInput('')\n\n    setTimeout(() => {\n      const aiMsg: ChatMessage = {\n        id: `ai-${Date.now()}`,\n        sender: 'ai',\n        author: 'Glia AI Code Reviewer',\n        timestamp: 'Just now',\n        text: 'Validated against UIPKGE craft standards. The suggested AST refactor is fully backward-compatible with PostCSS fallback polyfills.',\n      }\n      setChatMessages((prev) => [...prev, aiMsg])\n    }, 500)\n  }\n\n  const copyRawDiff = () => {\n    const rawText = diffLines.map((l) => `${l.text}`).join('\\n')\n    navigator.clipboard?.writeText(rawText)\n    setCopiedDiff(true)\n    setTimeout(() => setCopiedDiff(false), 2000)\n  }\n\n  const copyPatchCode = (id: string, code: string) => {\n    navigator.clipboard?.writeText(code)\n    setCopiedPatchId(id)\n    setTimeout(() => setCopiedPatchId(null), 2000)\n  }\n\n  return (\n    <div data-uipkge data-slot=\"ai-code-review-assistant\" className={cn('w-full space-y-6', className)}>\n      {/* Header: Pull Request Info & AI Review Status */}\n      <Card className=\"border-border bg-card shadow-xs\">\n        <CardHeader className=\"pb-4\">\n          <div className=\"flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between\">\n            <div className=\"space-y-2\">\n              {/* PR Badge & Title */}\n              <div className=\"flex flex-wrap items-center gap-2\">\n                <Badge wrap variant=\"outline\" className=\"gap-1.5 font-mono text-xs\">\n                  <GitPullRequest className=\"text-primary size-3.5\" />\n                  <span>PR #{prNumber}</span>\n                </Badge>\n                <h2 className=\"text-foreground text-base font-bold tracking-tight sm:text-lg\">{prTitle}</h2>\n              </div>\n\n              {/* Meta: Author, Branches, Commit */}\n              <div className=\"text-muted-foreground flex flex-wrap items-center gap-2 text-xs sm:text-sm\">\n                <div className=\"flex items-center gap-1.5\">\n                  <Avatar className=\"size-5 border\">\n                    <AvatarImage src={authorAvatar} alt={authorName} />\n                    <AvatarFallback className=\"text-xs\">ER</AvatarFallback>\n                  </Avatar>\n                  <span className=\"text-foreground font-medium\">{authorName}</span>\n                  <span className=\"text-muted-foreground\">(@{authorHandle})</span>\n                </div>\n\n                <Separator orientation=\"vertical\" className=\"h-3.5\" />\n\n                <div className=\"flex items-center gap-1.5 font-mono text-xs\">\n                  <GitBranch className=\"text-primary size-3.5\" />\n                  <span className=\"text-foreground font-semibold\">{targetBranch}</span>\n                  <span className=\"text-muted-foreground\">←</span>\n                  <span className=\"text-foreground font-semibold\">{sourceBranch}</span>\n                </div>\n\n                <Separator orientation=\"vertical\" className=\"h-3.5\" />\n\n                <div className=\"flex items-center gap-1 font-mono text-xs\">\n                  <GitCommit className=\"text-muted-foreground size-3.5\" />\n                  <span>8f2a49b</span>\n                  <span>·</span>\n                  <span className=\"text-success font-medium\">+142</span>\n                  <span className=\"text-destructive font-medium\">-68</span>\n                </div>\n              </div>\n            </div>\n\n            {/* Actions & Review Status */}\n            <div className=\"flex flex-wrap items-center gap-2.5\">\n              {!allPatchesApplied ? (\n                <Badge\n                  wrap\n                  variant=\"success\"\n                  className=\"border-success/20 bg-success/10 text-success gap-1.5 px-3 py-1 text-xs font-semibold\"\n                >\n                  <Sparkles className=\"size-3.5 shrink-0\" />\n                  <span>Review Completed · 2 Suggestions · 0 Security Flaws</span>\n                </Badge>\n              ) : (\n                <Badge\n                  wrap\n                  variant=\"success\"\n                  className=\"border-success/30 bg-success/15 text-success gap-1.5 px-3 py-1 text-xs font-semibold\"\n                >\n                  <CheckCheck className=\"size-3.5 shrink-0\" />\n                  <span>All Patches Applied · Ready to Merge</span>\n                </Badge>\n              )}\n\n              {!allPatchesApplied ? (\n                <Button\n                  size=\"sm\"\n                  variant=\"default\"\n                  className=\"gap-1.5 text-xs font-medium shadow-xs\"\n                  disabled={isApplyingAll}\n                  onClick={applyAllPatches}\n                >\n                  {isApplyingAll ? <RefreshCw className=\"size-3.5 animate-spin\" /> : <Sparkles className=\"size-3.5\" />}\n                  <span>{isApplyingAll ? 'Applying Patches...' : 'Apply All AI Patches'}</span>\n                </Button>\n              ) : (\n                <Button\n                  size=\"sm\"\n                  variant=\"outline\"\n                  className=\"gap-1.5 text-xs font-medium shadow-xs\"\n                  onClick={resetPatches}\n                >\n                  <RotateCcw className=\"size-3.5\" />\n                  <span>Reset State</span>\n                </Button>\n              )}\n\n              <Button\n                size=\"sm\"\n                variant=\"outline\"\n                className=\"gap-1.5 text-xs font-medium shadow-xs\"\n                onClick={() => openChatWithTopic()}\n              >\n                <MessageSquare className=\"size-3.5\" />\n                <span>AI Chat (3)</span>\n              </Button>\n            </div>\n          </div>\n        </CardHeader>\n      </Card>\n\n      {/* 4 Code Review Health Cards */}\n      <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n        {/* Card 1: Quality Score */}\n        <Card className=\"border-border bg-card shadow-xs transition-colors\">\n          <CardContent className=\"p-4 sm:p-5\">\n            <div className=\"flex items-center justify-between\">\n              <span className=\"text-muted-foreground text-xs font-medium\">Code Quality Score</span>\n              <div className=\"bg-success/10 text-success flex size-8 items-center justify-center rounded-md\">\n                <CheckCircle2 className=\"size-4\" />\n              </div>\n            </div>\n            <div className=\"mt-3\">\n              <div className=\"text-foreground text-2xl font-bold tracking-tight\">{qualityScore} / 100</div>\n              <p className=\"text-muted-foreground mt-1 text-xs\">\n                Clean Architecture · <span className=\"text-success font-medium\">+14 pts</span> vs baseline\n              </p>\n            </div>\n            <div className=\"text-success mt-3 flex items-center gap-1.5 text-xs font-medium\">\n              <Check className=\"size-3.5\" />\n              <span>0 Anti-patterns · Clean CVA tokens</span>\n            </div>\n          </CardContent>\n        </Card>\n\n        {/* Card 2: Security & Vulnerability Check */}\n        <Card className=\"border-border bg-card shadow-xs\">\n          <CardContent className=\"p-4 sm:p-5\">\n            <div className=\"flex items-center justify-between\">\n              <span className=\"text-muted-foreground text-xs font-medium\">Security & SAST Check</span>\n              <div className=\"bg-success/10 text-success flex size-8 items-center justify-center rounded-md\">\n                <ShieldCheck className=\"size-4\" />\n              </div>\n            </div>\n            <div className=\"mt-3\">\n              <div className=\"text-foreground text-2xl font-bold tracking-tight\">0 Vulnerabilities</div>\n              <p className=\"text-muted-foreground mt-1 text-xs\">\n                0 Vulnerabilities Detected · <span className=\"text-success font-medium\">Pass</span>\n              </p>\n            </div>\n            <div className=\"text-success mt-3 flex items-center gap-1.5 text-xs font-medium\">\n              <Check className=\"size-3.5\" />\n              <span>OWASP Top 10 validated · Zero leaks</span>\n            </div>\n          </CardContent>\n        </Card>\n\n        {/* Card 3: Performance & Bundle Impact */}\n        <Card className=\"border-border bg-card shadow-xs\">\n          <CardContent className=\"p-4 sm:p-5\">\n            <div className=\"flex items-center justify-between\">\n              <span className=\"text-muted-foreground text-xs font-medium\">Performance & Bundle Impact</span>\n              <div className=\"bg-warning/10 text-warning flex size-8 items-center justify-center rounded-md\">\n                <Zap className=\"size-4\" />\n              </div>\n            </div>\n            <div className=\"mt-3\">\n              <div className=\"text-foreground text-2xl font-bold tracking-tight\">-4.2 KB (-18%)</div>\n              <p className=\"text-muted-foreground mt-1 text-xs\">Bundle Size Reduction · 14.8 KB → 10.6 KB</p>\n            </div>\n            <div className=\"text-warning mt-3 flex items-center gap-1.5 text-xs font-medium\">\n              <TrendingDown className=\"size-3.5\" />\n              <span>20 CSS variables eliminated from DOM</span>\n            </div>\n          </CardContent>\n        </Card>\n\n        {/* Card 4: Test Coverage Delta */}\n        <Card className=\"border-border bg-card shadow-xs\">\n          <CardContent className=\"p-4 sm:p-5\">\n            <div className=\"flex items-center justify-between\">\n              <span className=\"text-muted-foreground text-xs font-medium\">Test Coverage Delta</span>\n              <div className=\"bg-info/10 text-info flex size-8 items-center justify-center rounded-md\">\n                <Layers className=\"size-4\" />\n              </div>\n            </div>\n            <div className=\"mt-3\">\n              <div className=\"text-foreground text-2xl font-bold tracking-tight\">+2.4% Coverage</div>\n              <p className=\"text-muted-foreground mt-1 text-xs\">48 new tests · 94.8% total coverage</p>\n            </div>\n            <div className=\"text-success mt-3 flex items-center gap-1.5 text-xs font-medium\">\n              <TrendingUp className=\"size-3.5\" />\n              <span>100% token regression suites pass</span>\n            </div>\n          </CardContent>\n        </Card>\n      </div>\n\n      {/* Annotated Code Diff Reviewer Card */}\n      <Card className=\"border-border bg-card shadow-xs\">\n        <CardHeader className=\"border-border border-b pb-4\">\n          <div className=\"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between\">\n            <div className=\"space-y-1\">\n              <div className=\"flex flex-wrap items-center gap-2\">\n                <FileCode2 className=\"text-primary size-4 shrink-0\" />\n                <CardTitle className=\"text-foreground font-mono text-sm font-semibold sm:text-base\">\n                  packages/shared/styles/tailwind.css\n                </CardTitle>\n                <Badge wrap variant=\"outline\" className=\"font-mono text-xs\">\n                  CSS / Tailwind v4\n                </Badge>\n                <Badge wrap variant=\"secondary\" className=\"font-mono text-xs\">\n                  +24 -12 lines\n                </Badge>\n              </div>\n              <CardDescription className=\"text-muted-foreground text-xs\">\n                AST parser inspected 162 declarations · 2 optimization nodes annotated\n              </CardDescription>\n            </div>\n\n            <div className=\"flex items-center gap-2\">\n              <Button\n                variant=\"outline\"\n                size=\"sm\"\n                className=\"h-8 gap-1.5 text-xs font-medium shadow-xs\"\n                onClick={copyRawDiff}\n              >\n                {copiedDiff ? <Check className=\"text-success size-3.5\" /> : <Copy className=\"size-3.5\" />}\n                <span>{copiedDiff ? 'Copied Raw Diff' : 'Copy Raw Diff'}</span>\n              </Button>\n            </div>\n          </div>\n        </CardHeader>\n\n        <CardContent className=\"p-4 sm:p-6\">\n          <Tabs value={activeTab} onValueChange={setActiveTab} className=\"w-full space-y-4\">\n            <TabsList className=\"grid w-full grid-cols-3 sm:inline-flex sm:w-auto\">\n              <TabsTrigger value=\"diff\" className=\"gap-1.5 text-xs\">\n                <Code2 className=\"size-3.5\" />\n                <span>Unified Code Diff</span>\n              </TabsTrigger>\n              <TabsTrigger value=\"rules\" className=\"gap-1.5 text-xs\">\n                <ShieldCheck className=\"size-3.5\" />\n                <span>AST Rule Checks (4)</span>\n              </TabsTrigger>\n              <TabsTrigger value=\"impact\" className=\"gap-1.5 text-xs\">\n                <Cpu className=\"size-3.5\" />\n                <span>Token Matrix &amp; Gamut</span>\n              </TabsTrigger>\n            </TabsList>\n\n            {/* Tab 1: Visual Unified Code Diff with Inline AI Annotations */}\n            <TabsContent value=\"diff\" className=\"space-y-4 focus-visible:outline-none\">\n              <div className=\"border-border bg-muted/40 flex items-center justify-between rounded-t-md border-x border-t px-3 py-2 text-xs\">\n                <div className=\"text-muted-foreground flex items-center gap-2\">\n                  <span className=\"text-foreground font-medium\">Unified Diff View</span>\n                  <span>·</span>\n                  <span className=\"text-success font-medium\">+24 additions</span>\n                  <span>·</span>\n                  <span className=\"text-destructive font-medium\">-12 deletions</span>\n                </div>\n                <span className=\"text-muted-foreground font-mono\">AST Analyzed</span>\n              </div>\n\n              <div className=\"border-border bg-muted/20 overflow-x-auto rounded-b-md border font-mono text-xs leading-relaxed\">\n                <div className=\"max-w-[620px] min-w-full py-2\">\n                  {diffLines.map((line) => (\n                    <React.Fragment key={line.id}>\n                      {/* Hunk Line */}\n                      {line.type === 'hunk' ? (\n                        <div className=\"bg-muted/60 text-muted-foreground px-3 py-1 font-mono text-xs font-semibold select-none\">\n                          {line.text}\n                        </div>\n                      ) : (\n                        /* Diff Code Row */\n                        <div\n                          className={cn(\n                            'flex items-center px-3 py-0.5 transition-colors',\n                            line.type === 'addition' &&\n                              'border-success bg-success/10 text-success border-l-2 font-medium',\n                            line.type === 'deletion' &&\n                              'border-destructive bg-destructive/10 text-foreground dark:text-foreground border-l-2 font-medium line-through opacity-85',\n                            line.type === 'neutral' && 'text-muted-foreground border-l-2 border-transparent',\n                          )}\n                        >\n                          {/* Old Line Number */}\n                          <span className=\"text-muted-foreground/50 w-8 shrink-0 pr-2 text-right select-none\">\n                            {line.oldNum ?? ''}\n                          </span>\n                          {/* New Line Number */}\n                          <span className=\"text-muted-foreground/50 w-8 shrink-0 pr-3 text-right select-none\">\n                            {line.newNum ?? ''}\n                          </span>\n                          {/* Prefix */}\n                          <span\n                            className={cn(\n                              'w-4 shrink-0 text-center font-bold select-none',\n                              line.type === 'addition' && 'text-success',\n                              line.type === 'deletion' && 'text-destructive',\n                              line.type === 'neutral' && 'text-transparent',\n                            )}\n                          >\n                            {line.type === 'addition' ? '+' : line.type === 'deletion' ? '-' : ' '}\n                          </span>\n                          {/* Code Text */}\n                          <span className=\"pl-1 whitespace-pre\">{line.text}</span>\n                        </div>\n                      )}\n\n                      {/* Inline AI Review Annotation Card #1 (Pinned under line 42) */}\n                      {line.annotationId === 'patch-1' && (\n                        <div className=\"border-warning/40 bg-warning/[0.04] border-warning/30 dark:bg-warning/10] mx-4 my-3 rounded-lg border p-4 text-xs shadow-xs\">\n                          <div className=\"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between\">\n                            <div className=\"space-y-1.5\">\n                              <div className=\"flex flex-wrap items-center gap-2\">\n                                <div className=\"bg-warning/20 text-warning flex size-6 items-center justify-center rounded-md\">\n                                  <Bot className=\"size-3.5\" />\n                                </div>\n                                <span className=\"text-foreground font-semibold\">\n                                  Glia AI Code Review · AST Suggestion\n                                </span>\n                                <Badge wrap variant=\"warning\" className=\"gap-1 font-semibold\">\n                                  <Sparkles className=\"size-3\" />\n                                  <span>Performance Optimization · High Impact</span>\n                                </Badge>\n                                <span className=\"text-muted-foreground text-xs\">Confidence 99.4% · AST Node #42</span>\n                              </div>\n\n                              {/* Explanation */}\n                              <p className=\"text-foreground font-sans text-xs leading-relaxed font-medium\">\n                                Using{' '}\n                                <code className=\"bg-muted text-foreground rounded px-1.5 py-0.5 font-mono\">\n                                  color-mix(in oklab, var(--primary) 10%, transparent)\n                                </code>{' '}\n                                achieves identical contrast without injecting 20 additional CSS variables into the\n                                global DOM.\n                              </p>\n\n                              {/* Code Preview Replacement */}\n                              <div className=\"border-border/60 bg-muted/50 rounded-md border p-2.5 font-mono text-xs\">\n                                <div className=\"text-muted-foreground mb-1 text-xs select-none\">\n                                  Proposed AST Patch Replacement (Line 39):\n                                </div>\n                                <div className=\"text-success font-semibold\">\n                                  + --primary-accent: color-mix(in oklab, var(--primary) 10%, transparent);\n                                </div>\n                              </div>\n                            </div>\n\n                            {/* Action Buttons */}\n                            <div className=\"flex shrink-0 flex-wrap items-center gap-2 self-start sm:self-auto\">\n                              <Button\n                                size=\"xs\"\n                                variant=\"outline\"\n                                className=\"h-7 gap-1 text-xs\"\n                                onClick={() =>\n                                  copyPatchCode('patch-1', 'color-mix(in oklab, var(--primary) 10%, transparent)')\n                                }\n                              >\n                                {copiedPatchId === 'patch-1' ? (\n                                  <Check className=\"text-success size-3\" />\n                                ) : (\n                                  <Copy className=\"size-3\" />\n                                )}\n                                <span>{copiedPatchId === 'patch-1' ? 'Copied' : 'Copy Patch'}</span>\n                              </Button>\n\n                              <Button\n                                size=\"xs\"\n                                variant=\"outline\"\n                                className=\"h-7 gap-1 text-xs\"\n                                onClick={() =>\n                                  openChatWithTopic(\n                                    'Explain why OKLab color-mix avoids DOM stylesheet recalculation overhead',\n                                  )\n                                }\n                              >\n                                <MessageSquare className=\"size-3\" />\n                                <span>Explain in Chat</span>\n                              </Button>\n\n                              <Button\n                                size=\"xs\"\n                                variant={appliedPatches.has('patch-1') ? 'secondary' : 'default'}\n                                className={cn(\n                                  'h-7 gap-1 text-xs font-medium shadow-xs',\n                                  appliedPatches.has('patch-1') && 'border-success/30 text-success font-semibold',\n                                )}\n                                onClick={() => togglePatch('patch-1')}\n                              >\n                                {appliedPatches.has('patch-1') ? (\n                                  <Check className=\"text-success size-3\" />\n                                ) : (\n                                  <Zap className=\"size-3\" />\n                                )}\n                                <span>\n                                  {appliedPatches.has('patch-1') ? 'Patch Applied ✓' : 'Apply Suggestion (1-Click)'}\n                                </span>\n                              </Button>\n                            </div>\n                          </div>\n                        </div>\n                      )}\n\n                      {/* Inline AI Review Annotation Card #2 (Pinned under line 51) */}\n                      {line.annotationId === 'patch-2' && (\n                        <div className=\"border-success/40 bg-success/[0.04] border-success/30 dark:bg-success/10] mx-4 my-3 rounded-lg border p-4 text-xs shadow-xs\">\n                          <div className=\"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between\">\n                            <div className=\"space-y-1.5\">\n                              <div className=\"flex flex-wrap items-center gap-2\">\n                                <div className=\"bg-success/20 text-success flex size-6 items-center justify-center rounded-md\">\n                                  <ShieldCheck className=\"size-3.5\" />\n                                </div>\n                                <span className=\"text-foreground font-semibold\">\n                                  Glia AI Code Review · Gamut Engine\n                                </span>\n                                <Badge wrap variant=\"success\" className=\"gap-1 font-semibold\">\n                                  <CheckCircle2 className=\"size-3\" />\n                                  <span>Accessibility &amp; Gamut · WCAG AAA Verified</span>\n                                </Badge>\n                                <span className=\"text-muted-foreground text-xs\">Confidence 98.7% · AST Node #51</span>\n                              </div>\n\n                              {/* Explanation */}\n                              <p className=\"text-foreground font-sans text-xs leading-relaxed font-medium\">\n                                OKLCH relative gamut mapping guarantees 7:1 contrast ratio across both light and dark\n                                themes with zero perceptual hue shift on wide-gamut displays.\n                              </p>\n\n                              {/* Code Preview Replacement */}\n                              <div className=\"border-border/60 bg-muted/50 rounded-md border p-2.5 font-mono text-xs\">\n                                <div className=\"text-muted-foreground mb-1 text-xs select-none\">\n                                  Verified Relative Color Syntax:\n                                </div>\n                                <div className=\"text-success font-semibold\">\n                                  + --ring-focus-shadow: 0 0 0 2px var(--color-ring);\n                                </div>\n                              </div>\n                            </div>\n\n                            {/* Action Buttons */}\n                            <div className=\"flex shrink-0 flex-wrap items-center gap-2 self-start sm:self-auto\">\n                              <Button\n                                size=\"xs\"\n                                variant=\"outline\"\n                                className=\"h-7 gap-1 text-xs\"\n                                onClick={() =>\n                                  openChatWithTopic(\n                                    'How does OKLCH guarantee WCAG AAA contrast without shift on P3 monitors?',\n                                  )\n                                }\n                              >\n                                <MessageSquare className=\"size-3\" />\n                                <span>Explain in Chat</span>\n                              </Button>\n\n                              <Button\n                                size=\"xs\"\n                                variant={appliedPatches.has('patch-2') ? 'secondary' : 'default'}\n                                className={cn(\n                                  'h-7 gap-1 text-xs font-medium shadow-xs',\n                                  appliedPatches.has('patch-2') && 'border-success/30 text-success font-semibold',\n                                )}\n                                onClick={() => togglePatch('patch-2')}\n                              >\n                                {appliedPatches.has('patch-2') ? (\n                                  <Check className=\"text-success size-3\" />\n                                ) : (\n                                  <Zap className=\"size-3\" />\n                                )}\n                                <span>\n                                  {appliedPatches.has('patch-2') ? 'Patch Applied ✓' : 'Apply Suggestion (1-Click)'}\n                                </span>\n                              </Button>\n                            </div>\n                          </div>\n                        </div>\n                      )}\n                    </React.Fragment>\n                  ))}\n                </div>\n              </div>\n            </TabsContent>\n\n            {/* Tab 2: AST Rule Verification Suite */}\n            <TabsContent value=\"rules\" className=\"space-y-4 focus-visible:outline-none\">\n              <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-2\">\n                <div className=\"border-border bg-muted/20 space-y-2 rounded-lg border p-4\">\n                  <div className=\"flex items-center justify-between\">\n                    <div className=\"flex items-center gap-2 text-sm font-semibold\">\n                      <ShieldCheck className=\"text-success size-4\" />\n                      <span>Rule 1: Zero Global DOM Pollution</span>\n                    </div>\n                    <Badge wrap variant=\"success\" className=\"text-xs\">\n                      Pass · Verified\n                    </Badge>\n                  </div>\n                  <p className=\"text-muted-foreground text-xs leading-relaxed\">\n                    Eliminates 20 static opacity custom properties. All transparency channels are evaluated dynamically\n                    in OKLab color space.\n                  </p>\n                </div>\n\n                <div className=\"border-border bg-muted/20 space-y-2 rounded-lg border p-4\">\n                  <div className=\"flex items-center justify-between\">\n                    <div className=\"flex items-center gap-2 text-sm font-semibold\">\n                      <Zap className=\"text-success size-4\" />\n                      <span>Rule 2: Perceptual Uniformity (ΔE &lt; 0.8)</span>\n                    </div>\n                    <Badge wrap variant=\"success\" className=\"text-xs\">\n                      Pass · Verified\n                    </Badge>\n                  </div>\n                  <p className=\"text-muted-foreground text-xs leading-relaxed\">\n                    OKLCH lightness (L) scale provides mathematical linearity. Step changes in lightness feel uniform to\n                    human perception across all hues.\n                  </p>\n                </div>\n\n                <div className=\"border-border bg-muted/20 space-y-2 rounded-lg border p-4\">\n                  <div className=\"flex items-center justify-between\">\n                    <div className=\"flex items-center gap-2 text-sm font-semibold\">\n                      <Cpu className=\"text-success size-4\" />\n                      <span>Rule 3: PostCSS Lightning Fallbacks</span>\n                    </div>\n                    <Badge wrap variant=\"success\" className=\"text-xs\">\n                      Pass · Verified\n                    </Badge>\n                  </div>\n                  <p className=\"text-muted-foreground text-xs leading-relaxed\">\n                    Tailwind v4 engine generates automated sRGB fallback values for legacy web clients while streaming\n                    raw OKLCH to modern browsers.\n                  </p>\n                </div>\n\n                <div className=\"border-border bg-muted/20 space-y-2 rounded-lg border p-4\">\n                  <div className=\"flex items-center justify-between\">\n                    <div className=\"flex items-center gap-2 text-sm font-semibold\">\n                      <CheckCircle2 className=\"text-success size-4\" />\n                      <span>Rule 4: WCAG 2.2 AAA Contrast Ratios</span>\n                    </div>\n                    <Badge wrap variant=\"success\" className=\"text-xs\">\n                      Pass · 7.1:1 Ratio\n                    </Badge>\n                  </div>\n                  <p className=\"text-muted-foreground text-xs leading-relaxed\">\n                    Background to foreground contrast exceeds the 7:1 ratio threshold required for government and\n                    enterprise accessible software.\n                  </p>\n                </div>\n              </div>\n            </TabsContent>\n\n            {/* Tab 3: Token Matrix & Gamut Breakdown */}\n            <TabsContent value=\"impact\" className=\"space-y-4 focus-visible:outline-none\">\n              <div className=\"border-border overflow-x-auto rounded-lg border\">\n                <div className=\"bg-muted/40 border-border max-w-[480px] min-w-full border-b px-4 py-3 text-xs font-semibold\">\n                  Token Architecture Comparison: Legacy vs. OKLCH Engine\n                </div>\n                <div className=\"divide-border max-w-[480px] min-w-full divide-y text-xs\">\n                  <div className=\"grid grid-cols-3 p-3 font-medium\">\n                    <span className=\"text-muted-foreground\">Evaluation Metric</span>\n                    <span className=\"text-muted-foreground\">Legacy HSL / sRGB</span>\n                    <span className=\"text-success font-bold\">OKLCH Perceptual Engine</span>\n                  </div>\n                  <div className=\"grid grid-cols-3 p-3\">\n                    <span className=\"font-medium\">Total Token CSS Bundle</span>\n                    <span className=\"text-muted-foreground font-mono\">14.8 KB</span>\n                    <span className=\"text-success font-mono font-bold\">10.6 KB (-28.4%)</span>\n                  </div>\n                  <div className=\"grid grid-cols-3 p-3\">\n                    <span className=\"font-medium\">DOM Custom Properties</span>\n                    <span className=\"text-muted-foreground font-mono\">64 variables</span>\n                    <span className=\"text-success font-mono font-bold\">44 variables (-31.2%)</span>\n                  </div>\n                  <div className=\"grid grid-cols-3 p-3\">\n                    <span className=\"font-medium\">Display P3 Wide Gamut</span>\n                    <span className=\"text-destructive\">Clipping on 14 colors</span>\n                    <span className=\"text-success font-bold\">100% P3 Coverage</span>\n                  </div>\n                  <div className=\"grid grid-cols-3 p-3\">\n                    <span className=\"font-medium\">Perceptual Uniformity</span>\n                    <span className=\"text-muted-foreground\">Non-linear (HSL shift)</span>\n                    <span className=\"text-success font-bold\">Mathematically Uniform (LCH)</span>\n                  </div>\n                </div>\n              </div>\n            </TabsContent>\n          </Tabs>\n        </CardContent>\n      </Card>\n\n      {/* Interactive AI Review Assistant Chat Panel */}\n      {isChatOpen && (\n        <Card className=\"border-primary/30 bg-card shadow-md\">\n          <CardHeader className=\"border-border border-b pb-3\">\n            <div className=\"flex items-center justify-between\">\n              <div className=\"flex items-center gap-2.5\">\n                <div className=\"bg-primary/10 text-primary flex size-8 items-center justify-center rounded-md\">\n                  <Bot className=\"size-4\" />\n                </div>\n                <div>\n                  <CardTitle className=\"text-sm font-semibold\">\n                    Glia AI Assistant · PR #{prNumber} Review Thread\n                  </CardTitle>\n                  <CardDescription className=\"text-xs\">\n                    Contextual code review dialogue with active AST parser &amp; contrast engine\n                  </CardDescription>\n                </div>\n              </div>\n              <Button\n                variant=\"ghost\"\n                size=\"xs\"\n                className=\"size-7 p-0\"\n                aria-label=\"Close chat\"\n                onClick={() => setIsChatOpen(false)}\n              >\n                <X className=\"size-4\" />\n              </Button>\n            </div>\n          </CardHeader>\n\n          <CardContent className=\"space-y-4 p-4\">\n            {/* Message History */}\n            <div className=\"max-h-[320px] space-y-3 overflow-y-auto pr-1\">\n              {chatMessages.map((msg) => (\n                <div\n                  key={msg.id}\n                  className={cn(\n                    'flex flex-col gap-1 rounded-lg p-3 text-xs',\n                    msg.sender === 'ai'\n                      ? 'border-border/60 bg-muted/40 mr-8 border'\n                      : 'bg-primary/10 text-foreground border-primary/20 ml-8 border',\n                  )}\n                >\n                  <div className=\"flex items-center justify-between font-semibold\">\n                    <span className=\"flex items-center gap-1.5\">\n                      {msg.sender === 'ai' ? (\n                        <Bot className=\"text-primary size-3.5\" />\n                      ) : (\n                        <Avatar className=\"size-4 border\">\n                          <AvatarImage src={authorAvatar} />\n                          <AvatarFallback className=\"text-xs\">ER</AvatarFallback>\n                        </Avatar>\n                      )}\n                      <span>{msg.author}</span>\n                    </span>\n                    <span className=\"text-muted-foreground text-xs font-normal\">{msg.timestamp}</span>\n                  </div>\n                  <p className=\"mt-1 leading-relaxed\">{msg.text}</p>\n                  {msg.codeSnippet && (\n                    <div className=\"border-border/80 bg-muted/80 text-foreground mt-2 rounded p-2 font-mono text-xs select-all\">\n                      {msg.codeSnippet}\n                    </div>\n                  )}\n                </div>\n              ))}\n            </div>\n\n            {/* Preset Prompt Chips */}\n            <div className=\"flex flex-wrap items-center gap-1.5 pt-1\">\n              <span className=\"text-muted-foreground text-xs\">Quick ask:</span>\n              <button\n                type=\"button\"\n                className=\"border-border bg-muted/40 hover:bg-muted text-foreground cursor-pointer rounded-full border px-2.5 py-0.5 text-xs transition-colors\"\n                onClick={() => openChatWithTopic('Why is OKLab preferred over sRGB color space?')}\n              >\n                Why OKLab over sRGB?\n              </button>\n              <button\n                type=\"button\"\n                className=\"border-border bg-muted/40 hover:bg-muted text-foreground cursor-pointer rounded-full border px-2.5 py-0.5 text-xs transition-colors\"\n                onClick={() => openChatWithTopic('How does this affect browser performance?')}\n              >\n                Browser performance impact?\n              </button>\n            </div>\n\n            {/* Chat Input Field */}\n            <form className=\"flex items-center gap-2 pt-1\" onSubmit={handleSendMessage}>\n              <input\n                value={chatInput}\n                onChange={(e) => setChatInput(e.target.value)}\n                type=\"text\"\n                placeholder=\"Ask Glia AI about this code review or AST transformation...\"\n                className=\"border-input bg-background placeholder:text-muted-foreground focus-visible:ring-ring flex-1 rounded-md border px-3 py-2 text-xs focus-visible:ring-2 focus-visible:outline-none\"\n              />\n              <Button type=\"submit\" size=\"sm\" className=\"gap-1.5 text-xs\">\n                <Send className=\"size-3.5\" />\n                <span>Send</span>\n              </Button>\n            </form>\n          </CardContent>\n        </Card>\n      )}\n    </div>\n  )\n}\n\nexport default AiCodeReviewAssistant\n",
      "type": "registry:block",
      "target": "~/components/blocks/AiCodeReviewAssistant.tsx"
    }
  ],
  "dependencies": [
    "lucide-react"
  ],
  "devDependencies": [],
  "registryDependencies": [
    "https://uipkge.dev/r/react/avatar.json",
    "https://uipkge.dev/r/react/badge.json",
    "https://uipkge.dev/r/react/button.json",
    "https://uipkge.dev/r/react/card.json",
    "https://uipkge.dev/r/react/separator.json",
    "https://uipkge.dev/r/react/tabs.json"
  ],
  "description": "GitHub PR automated AI code review assistant with AST syntax diff annotations, performance suggestions, and 1-click patch application.",
  "categories": [
    "devops",
    "app",
    "ai"
  ]
}