{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "security",
  "title": "Security",
  "description": "Primitives for security: info, warning and critical audit severities and passing, attention and failing check results as coloured words, a desktop or phone device icon, and a weighted security score.",
  "registryDependencies": [
    "https://www.dashboardblocks.com/r/radix/status-label.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/security.tsx",
      "content": "'use client'\n\nimport {\n  StatusLabel,\n  type StatusTone,\n} from '@/registry/components/dashboardblocks/status-label'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\n\nimport { cn } from '@/lib/utils'\n\ntype AuditSeverity = 'info' | 'warning' | 'critical'\n\nconst auditSeverityConfig: Record<AuditSeverity, { label: string; tone: StatusTone }> = {\n  critical: { label: 'Critical', tone: 'bad' },\n  info: { label: 'Info', tone: 'neutral' },\n  warning: { label: 'Warning', tone: 'warning' },\n}\n\nfunction AuditSeverityLabel({\n  className,\n  label,\n  severity,\n}: {\n  className?: string\n  label?: string\n  severity: AuditSeverity\n}) {\n  const config = auditSeverityConfig[severity]\n  return (\n    <StatusLabel className={className} tone={config.tone}>\n      {label ?? config.label}\n    </StatusLabel>\n  )\n}\n\ntype DeviceKind = 'desktop' | 'mobile'\n\nfunction DeviceIcon({ className, kind }: { className?: string; kind: DeviceKind }) {\n  return (\n    <span\n      aria-hidden\n      data-slot='device-icon'\n      className={cn('text-muted-foreground flex shrink-0 [&_svg]:size-4', className)}\n    >\n      {kind === 'mobile' ? (\n        <IconPlaceholder\n          lucide='SmartphoneIcon'\n          tabler='IconDeviceMobile'\n          hugeicons='SmartPhone01Icon'\n          phosphor='DeviceMobileIcon'\n          remixicon='RiSmartphoneLine'\n        />\n      ) : (\n        <IconPlaceholder\n          lucide='MonitorIcon'\n          tabler='IconDeviceDesktop'\n          hugeicons='ComputerIcon'\n          phosphor='MonitorIcon'\n          remixicon='RiComputerLine'\n        />\n      )}\n    </span>\n  )\n}\n\ntype CheckResult = 'pass' | 'warn' | 'fail'\n\nconst checkResultConfig: Record<CheckResult, { label: string; tone: StatusTone }> = {\n  fail: { label: 'Failing', tone: 'bad' },\n  pass: { label: 'Passing', tone: 'good' },\n  warn: { label: 'Needs attention', tone: 'warning' },\n}\n\nfunction CheckResultLabel({\n  className,\n  label,\n  result,\n}: {\n  className?: string\n  label?: string\n  result: CheckResult\n}) {\n  const config = checkResultConfig[result]\n  return (\n    <StatusLabel className={className} tone={config.tone}>\n      {label ?? config.label}\n    </StatusLabel>\n  )\n}\n\nfunction getSecurityScore(checks: { result: CheckResult; weight?: number }[]) {\n  const total = checks.reduce((sum, check) => sum + (check.weight ?? 1), 0)\n  const earned = checks.reduce(\n    (sum, check) =>\n      sum +\n      (check.weight ?? 1) *\n        (check.result === 'pass' ? 1 : check.result === 'warn' ? 0.5 : 0),\n    0,\n  )\n  return total > 0 ? Math.round((earned / total) * 100) : 0\n}\n\nexport {\n  AuditSeverityLabel,\n  CheckResultLabel,\n  DeviceIcon,\n  auditSeverityConfig,\n  checkResultConfig,\n  getSecurityScore,\n}\n\nexport type { AuditSeverity, CheckResult, DeviceKind }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/security.tsx"
    }
  ],
  "type": "registry:component"
}
