{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "polar-license-key",
  "title": "Polar License Key",
  "description": "Styled license key display with masking, copy functionality, and status indicators.",
  "dependencies": [
    "@polar-sh/sdk"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/default/blocks/polar/polar-license-key/components/elements/polar-license-key.tsx",
      "content": "\"use client\";\n\nimport { useCallback, useState } from \"react\";\n\nfunction cn(...classes: (string | boolean | undefined)[]) {\n  return classes.filter(Boolean).join(\" \");\n}\n\nexport interface PolarLicenseKeyProps {\n  licenseKey: string;\n  productName?: string;\n  status?: \"active\" | \"expired\" | \"revoked\" | \"pending\";\n  activations?: { current: number; limit: number };\n  expiresAt?: Date | string;\n  masked?: boolean;\n  showCopyButton?: boolean;\n  showStatus?: boolean;\n  size?: \"sm\" | \"md\" | \"lg\";\n  className?: string;\n  onCopy?: (key: string) => void;\n}\n\nfunction CopyIcon({ className }: { className?: string }) {\n  return (\n    <svg\n      className={className}\n      xmlns=\"http://www.w3.org/2000/svg\"\n      width=\"16\"\n      height=\"16\"\n      viewBox=\"0 0 24 24\"\n      fill=\"none\"\n      stroke=\"currentColor\"\n      strokeWidth=\"2\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n    >\n      <rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\" />\n      <path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\" />\n    </svg>\n  );\n}\n\nfunction CheckIcon({ className }: { className?: string }) {\n  return (\n    <svg\n      className={className}\n      xmlns=\"http://www.w3.org/2000/svg\"\n      width=\"16\"\n      height=\"16\"\n      viewBox=\"0 0 24 24\"\n      fill=\"none\"\n      stroke=\"currentColor\"\n      strokeWidth=\"2\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n    >\n      <polyline points=\"20 6 9 17 4 12\" />\n    </svg>\n  );\n}\n\nfunction KeyIcon({ className }: { className?: string }) {\n  return (\n    <svg\n      className={className}\n      xmlns=\"http://www.w3.org/2000/svg\"\n      width=\"16\"\n      height=\"16\"\n      viewBox=\"0 0 24 24\"\n      fill=\"none\"\n      stroke=\"currentColor\"\n      strokeWidth=\"2\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n    >\n      <path d=\"m21 2-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0 3 3L22 7l-3-3m-3.5 3.5L19 4\" />\n    </svg>\n  );\n}\n\nfunction EyeIcon({ className }: { className?: string }) {\n  return (\n    <svg\n      className={className}\n      xmlns=\"http://www.w3.org/2000/svg\"\n      width=\"16\"\n      height=\"16\"\n      viewBox=\"0 0 24 24\"\n      fill=\"none\"\n      stroke=\"currentColor\"\n      strokeWidth=\"2\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n    >\n      <path d=\"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z\" />\n      <circle cx=\"12\" cy=\"12\" r=\"3\" />\n    </svg>\n  );\n}\n\nfunction EyeOffIcon({ className }: { className?: string }) {\n  return (\n    <svg\n      className={className}\n      xmlns=\"http://www.w3.org/2000/svg\"\n      width=\"16\"\n      height=\"16\"\n      viewBox=\"0 0 24 24\"\n      fill=\"none\"\n      stroke=\"currentColor\"\n      strokeWidth=\"2\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n    >\n      <path d=\"M9.88 9.88a3 3 0 1 0 4.24 4.24\" />\n      <path d=\"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68\" />\n      <path d=\"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61\" />\n      <line x1=\"2\" x2=\"22\" y1=\"2\" y2=\"22\" />\n    </svg>\n  );\n}\n\nconst STATUS_STYLES: Record<string, { bg: string; text: string; dot: string }> = {\n  active: {\n    bg: \"bg-green-100 dark:bg-green-900/30\",\n    text: \"text-green-700 dark:text-green-300\",\n    dot: \"bg-green-500\",\n  },\n  expired: {\n    bg: \"bg-amber-100 dark:bg-amber-900/30\",\n    text: \"text-amber-700 dark:text-amber-300\",\n    dot: \"bg-amber-500\",\n  },\n  revoked: {\n    bg: \"bg-red-100 dark:bg-red-900/30\",\n    text: \"text-red-700 dark:text-red-300\",\n    dot: \"bg-red-500\",\n  },\n  pending: {\n    bg: \"bg-gray-100 dark:bg-gray-800\",\n    text: \"text-gray-700 dark:text-gray-300\",\n    dot: \"bg-gray-400\",\n  },\n};\n\nconst SIZE_CLASSES = {\n  sm: {\n    container: \"p-3\",\n    key: \"text-xs\",\n    icon: \"h-3.5 w-3.5\",\n    button: \"h-6 w-6\",\n  },\n  md: {\n    container: \"p-4\",\n    key: \"text-sm\",\n    icon: \"h-4 w-4\",\n    button: \"h-7 w-7\",\n  },\n  lg: {\n    container: \"p-5\",\n    key: \"text-base\",\n    icon: \"h-5 w-5\",\n    button: \"h-8 w-8\",\n  },\n};\n\nexport function PolarLicenseKey({\n  licenseKey,\n  productName,\n  status = \"active\",\n  activations,\n  expiresAt,\n  masked: initialMasked = true,\n  showCopyButton = true,\n  showStatus = true,\n  size = \"md\",\n  className,\n  onCopy,\n}: PolarLicenseKeyProps) {\n  const [copied, setCopied] = useState(false);\n  const [masked, setMasked] = useState(initialMasked);\n  const sizes = SIZE_CLASSES[size];\n  const statusStyle = STATUS_STYLES[status];\n\n  const displayKey = masked\n    ? licenseKey.replace(/(.{4})(.*)(.{4})/, \"$1-****-****-$3\")\n    : licenseKey;\n\n  const handleCopy = useCallback(async () => {\n    try {\n      await navigator.clipboard.writeText(licenseKey);\n      setCopied(true);\n      onCopy?.(licenseKey);\n      setTimeout(() => setCopied(false), 2000);\n    } catch (err) {\n      console.error(\"Failed to copy:\", err);\n    }\n  }, [licenseKey, onCopy]);\n\n  const formatDate = (date: Date | string) => {\n    const d = typeof date === \"string\" ? new Date(date) : date;\n    return d.toLocaleDateString(undefined, {\n      year: \"numeric\",\n      month: \"short\",\n      day: \"numeric\",\n    });\n  };\n\n  return (\n    <div\n      data-slot=\"polar-license-key\"\n      className={cn(\n        \"rounded-xl border border-border bg-card\",\n        sizes.container,\n        className\n      )}\n    >\n      {(productName || showStatus) && (\n        <div className=\"flex items-center justify-between mb-3\">\n          {productName && (\n            <div className=\"flex items-center gap-2\">\n              <KeyIcon className={cn(\"text-muted-foreground\", sizes.icon)} />\n              <span className=\"font-medium text-foreground text-sm\">\n                {productName}\n              </span>\n            </div>\n          )}\n          {showStatus && (\n            <span\n              data-slot=\"status\"\n              className={cn(\n                \"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium\",\n                statusStyle.bg,\n                statusStyle.text\n              )}\n            >\n              <span className={cn(\"h-1.5 w-1.5 rounded-full\", statusStyle.dot)} />\n              {status.charAt(0).toUpperCase() + status.slice(1)}\n            </span>\n          )}\n        </div>\n      )}\n\n      <div\n        data-slot=\"key-display\"\n        className=\"flex items-center gap-2 rounded-lg bg-muted/50 p-2\"\n      >\n        <code\n          data-slot=\"key-value\"\n          className={cn(\n            \"flex-1 font-mono text-foreground select-all\",\n            sizes.key\n          )}\n        >\n          {displayKey}\n        </code>\n        <div className=\"flex items-center gap-1\">\n          <button\n            type=\"button\"\n            onClick={() => setMasked(!masked)}\n            className={cn(\n              \"inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors\",\n              sizes.button\n            )}\n            title={masked ? \"Show license key\" : \"Hide license key\"}\n          >\n            {masked ? (\n              <EyeIcon className={sizes.icon} />\n            ) : (\n              <EyeOffIcon className={sizes.icon} />\n            )}\n          </button>\n          {showCopyButton && (\n            <button\n              type=\"button\"\n              onClick={handleCopy}\n              className={cn(\n                \"inline-flex items-center justify-center rounded-md transition-colors\",\n                sizes.button,\n                copied\n                  ? \"text-green-600 dark:text-green-400\"\n                  : \"text-muted-foreground hover:text-foreground hover:bg-muted\"\n              )}\n              title={copied ? \"Copied!\" : \"Copy license key\"}\n            >\n              {copied ? (\n                <CheckIcon className={sizes.icon} />\n              ) : (\n                <CopyIcon className={sizes.icon} />\n              )}\n            </button>\n          )}\n        </div>\n      </div>\n\n      {(activations || expiresAt) && (\n        <div className=\"flex items-center gap-4 mt-3 text-xs text-muted-foreground\">\n          {activations && (\n            <span data-slot=\"activations\">\n              Activations: {activations.current}/{activations.limit}\n            </span>\n          )}\n          {expiresAt && (\n            <span data-slot=\"expires\">\n              Expires: {formatDate(expiresAt)}\n            </span>\n          )}\n        </div>\n      )}\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "docs": "Secure license key display with toggle visibility, copy-to-clipboard, activation count, and expiration date.",
  "categories": [
    "polar"
  ],
  "type": "registry:block"
}