{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "identity-verification",
  "title": "Identity Verification",
  "description": "KYC-style ID front, back and selfie with a progress rail and submit gate.",
  "dependencies": [
    "@uploadcn/core@^0.1.0",
    "@uploadcn/react@^0.1.0",
    "cn"
  ],
  "registryDependencies": [
    "@uploadcn/upload"
  ],
  "files": [
    {
      "path": "registry/default/blocks/identity-verification.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport {\n  type UploadAdapter,\n  type Uploader,\n  type UploadItem as UploadItemData,\n} from \"@uploadcn/core\"\nimport {\n  useUploadContext,\n  useUploadSelector,\n  type UploadRootProps,\n} from \"@uploadcn/react\"\nimport { cn } from \"cn\"\n\nimport { IconPlaceholder } from \"@/components/icon-placeholder\"\nimport { NativeButton, Upload, UploadSlot } from \"@/registry/default/ui/upload\"\n\nexport interface VerificationStep {\n  name: string\n  label: string\n  description?: string\n  accept?: string\n  icon?: React.ReactNode\n}\n\nconst DEFAULT_STEPS: VerificationStep[] = [\n  {\n    name: \"id-front\",\n    label: \"ID, front\",\n    description: \"Passport, driver's license or national ID\",\n    accept: \"image/*,application/pdf\",\n    icon: (\n      <IconPlaceholder\n        lucide=\"IdCardIcon\"\n        tabler=\"IconId\"\n        hugeicons=\"IdIcon\"\n        phosphor=\"IdentificationCardIcon\"\n        remixicon=\"RiIdCardLine\"\n      />\n    ),\n  },\n  {\n    name: \"id-back\",\n    label: \"ID, back\",\n    description: \"Skip for passports\",\n    accept: \"image/*,application/pdf\",\n    icon: (\n      <IconPlaceholder\n        lucide=\"IdCardIcon\"\n        tabler=\"IconId\"\n        hugeicons=\"IdIcon\"\n        phosphor=\"IdentificationCardIcon\"\n        remixicon=\"RiIdCardLine\"\n      />\n    ),\n  },\n  {\n    name: \"selfie\",\n    label: \"Selfie\",\n    description: \"Face the camera in good light\",\n    accept: \"image/*\",\n    icon: (\n      <IconPlaceholder\n        lucide=\"ScanFaceIcon\"\n        tabler=\"IconFaceId\"\n        hugeicons=\"FaceIdIcon\"\n        phosphor=\"ScanIcon\"\n        remixicon=\"RiUserSmileLine\"\n      />\n    ),\n  },\n]\n\ninterface IdentityVerificationProps<TResult> {\n  adapter?: UploadAdapter<TResult>\n  /** Use an uploader you created with `useUploader` instead of options. */\n  uploader?: Uploader<TResult>\n  steps?: VerificationStep[]\n  /** Steps that may be skipped. Default `[\"id-back\"]`. */\n  optional?: string[]\n  /** Default 15 MB per file. */\n  maxSize?: number\n  /** Called with each step's uploaded file when the user submits. */\n  onSubmit?: (files: Record<string, UploadItemData<TResult>>) => void\n  className?: string\n}\n\n/**\n * KYC-style identity check: a slot per document, a progress rail, and a\n * submit button that unlocks once every required document is uploaded.\n */\nfunction IdentityVerification<TResult = unknown>({\n  adapter,\n  uploader,\n  steps = DEFAULT_STEPS,\n  optional = [\"id-back\"],\n  maxSize = 15 * 1000 * 1000,\n  onSubmit,\n  className,\n}: IdentityVerificationProps<TResult>) {\n  return (\n    <Upload\n      {...((uploader\n        ? { uploader }\n        : { adapter, maxSize }) as UploadRootProps<TResult>)}\n      className={className}\n    >\n      <Verification\n        steps={steps}\n        optional={optional}\n        onSubmit={\n          onSubmit as\n            ((files: Record<string, UploadItemData>) => void) | undefined\n        }\n      />\n    </Upload>\n  )\n}\n\nfunction Verification({\n  steps,\n  optional,\n  onSubmit,\n}: {\n  steps: VerificationStep[]\n  optional: string[]\n  onSubmit?: (files: Record<string, UploadItemData>) => void\n}) {\n  const { uploader } = useUploadContext()\n  const items = useUploadSelector(uploader, (state) => state.items)\n  const bySlot = (name: string) =>\n    items.find((item) => item.meta.slot === name && item.status !== \"cancelled\")\n  const done = steps.filter((step) => bySlot(step.name)?.status === \"success\")\n  const ready = steps.every(\n    (step) =>\n      optional.includes(step.name) || bySlot(step.name)?.status === \"success\"\n  )\n  const busy = steps.some((step) => {\n    const status = bySlot(step.name)?.status\n    return (\n      status &&\n      status !== \"success\" &&\n      status !== \"error\" &&\n      status !== \"rejected\"\n    )\n  })\n\n  return (\n    <div className=\"ring-foreground/10 bg-card text-card-foreground gap-(--card-spacing) rounded-xl text-sm ring-1 [--card-spacing:--spacing(4)] p-(--card-spacing) flex flex-col gap-4\">\n      <div className=\"flex flex-col gap-1\">\n        <h3 className=\"text-base leading-snug font-medium\">Verify your identity</h3>\n        <p className=\"text-muted-foreground text-sm text-muted-foreground\">\n          We need a photo ID and a selfie. It takes about two minutes.\n        </p>\n      </div>\n      <ol className=\"flex gap-1.5\" aria-label=\"Progress\">\n        {steps.map((step) => {\n          const status = bySlot(step.name)?.status\n          return (\n            <li\n              key={step.name}\n              aria-label={`${step.label}: ${status === \"success\" ? \"done\" : (status ?? \"not started\")}`}\n              className={cn(\n                \"h-1.5 flex-1 rounded-full bg-muted transition-colors\",\n                status === \"success\" && \"bg-primary\",\n                (status === \"uploading\" || status === \"queued\") &&\n                  \"animate-pulse bg-primary/50 motion-reduce:animate-none\",\n                (status === \"error\" || status === \"rejected\") &&\n                  \"bg-destructive\"\n              )}\n            />\n          )\n        })}\n      </ol>\n      <div className=\"flex flex-col gap-2\">\n        {steps.map((step) => (\n          <UploadSlot\n            key={step.name}\n            name={step.name}\n            label={step.label}\n            description={\n              optional.includes(step.name)\n                ? `${step.description ?? \"\"} · optional`.replace(/^ · /, \"\")\n                : step.description\n            }\n            accept={step.accept}\n            icon={\n              bySlot(step.name)?.status === \"success\" ? (\n                <IconPlaceholder\n                  lucide=\"CheckIcon\"\n                  tabler=\"IconCheck\"\n                  hugeicons=\"Tick02Icon\"\n                  phosphor=\"CheckIcon\"\n                  remixicon=\"RiCheckLine\"\n                />\n              ) : (\n                step.icon\n              )\n            }\n            required={!optional.includes(step.name)}\n          />\n        ))}\n      </div>\n      <div className=\"flex flex-col-reverse gap-3 border-t pt-4 sm:flex-row sm:items-center sm:justify-between\">\n        <p className=\"flex items-center gap-1.5 text-xs text-muted-foreground\">\n          <IconPlaceholder\n            lucide=\"LockIcon\"\n            tabler=\"IconLock\"\n            hugeicons=\"SquareLock02Icon\"\n            phosphor=\"LockKeyIcon\"\n            remixicon=\"RiLockLine\"\n            className=\"size-3.5 shrink-0\"\n          />\n          Encrypted in transit and only used for verification.\n        </p>\n        <NativeButton\n          disabled={!ready || busy}\n          onClick={() =>\n            onSubmit?.(\n              Object.fromEntries(\n                steps.flatMap((step) => {\n                  const item = bySlot(step.name)\n                  return item?.status === \"success\" ? [[step.name, item]] : []\n                })\n              )\n            )\n          }\n        >\n          {busy\n            ? \"Uploading…\"\n            : ready\n              ? \"Submit for review\"\n              : `${done.length} of ${steps.length - optional.length} required`}\n        </NativeButton>\n      </div>\n    </div>\n  )\n}\n\nexport { IdentityVerification, type IdentityVerificationProps }\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "upload",
    "fintech"
  ],
  "type": "registry:block"
}