{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "policy-delivery-panel",
  "type": "registry:component",
  "title": "Policy Delivery Panel",
  "description": "Right-dock panel listing policies / guardrails active for the route or run.",
  "dependencies": [
    "@vllnt/ui@^0.2.1"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/default/policy-delivery-panel/policy-delivery-panel.tsx",
      "content": "\"use client\";\n\nimport {\n  type ComponentPropsWithoutRef,\n  forwardRef,\n  type ReactNode,\n} from \"react\";\n\nimport { cn } from \"@vllnt/ui\";\n\n/**\n * Enforcement status for a policy.\n *\n * @public\n */\nexport type PolicyStatus = \"advisory\" | \"disabled\" | \"enforced\";\n\nconst STATUS_LABEL: Record<PolicyStatus, string> = {\n  advisory: \"Advisory\",\n  disabled: \"Disabled\",\n  enforced: \"Enforced\",\n};\n\nconst STATUS_TONE: Record<PolicyStatus, string> = {\n  advisory:\n    \"border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300\",\n  disabled: \"border-border bg-muted/40 text-muted-foreground\",\n  enforced:\n    \"border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300\",\n};\n\n/**\n * One policy row.\n *\n * @public\n */\nexport type PolicyEntry = {\n  /** Optional secondary line (rationale, owner, last-updated). */\n  description?: ReactNode;\n  /** Stable identifier — used as the React key. */\n  id: string;\n  /** Display name (e.g. `\"PII redaction\"`). */\n  name: ReactNode;\n  /** Optional toggle handler — when provided, the row becomes a button. */\n  onToggle?: () => void;\n  /** Enforcement status. */\n  status: PolicyStatus;\n};\n\n/**\n * Localizable strings.\n *\n * @public\n */\nexport type PolicyDeliveryPanelLabels = {\n  /** Empty-state copy. Defaults to `\"No policies\"`. */\n  empty?: string;\n  /** Aria-label for the panel. Defaults to `\"Policy delivery\"`. */\n  region?: string;\n};\n\nconst DEFAULT_LABELS = {\n  empty: \"No policies\",\n  region: \"Policy delivery\",\n} as const satisfies Required<PolicyDeliveryPanelLabels>;\n\n/**\n * Props for {@link PolicyDeliveryPanel}.\n *\n * @public\n */\nexport type PolicyDeliveryPanelProps = {\n  /** Localizable strings. */\n  labels?: PolicyDeliveryPanelLabels;\n  /** Policy entries in render order. */\n  policies: PolicyEntry[];\n  /** Panel title. Defaults to `\"Policies\"`. */\n  title?: ReactNode;\n} & ComponentPropsWithoutRef<\"section\">;\n\nconst RowBody = (props: { policy: PolicyEntry }): React.ReactElement => {\n  const { policy } = props;\n  return (\n    <span className=\"flex flex-1 flex-col gap-0.5 text-left\">\n      <span className=\"flex items-center justify-between gap-2\">\n        <span className=\"truncate text-xs font-medium text-foreground\">\n          {policy.name}\n        </span>\n        <span\n          className={cn(\n            \"rounded-full border px-1.5 py-0.5 text-[10px] uppercase tracking-wide\",\n            STATUS_TONE[policy.status],\n          )}\n        >\n          {STATUS_LABEL[policy.status]}\n        </span>\n      </span>\n      {policy.description ? (\n        <span className=\"truncate text-[10px] text-muted-foreground\">\n          {policy.description}\n        </span>\n      ) : null}\n    </span>\n  );\n};\n\nconst Row = (props: { policy: PolicyEntry }): React.ReactElement => {\n  const { policy } = props;\n  if (policy.onToggle) {\n    const handleClick = (): void => {\n      policy.onToggle?.();\n    };\n    return (\n      <button\n        className=\"flex w-full items-center gap-2 rounded-md border border-transparent px-2 py-1.5 text-left transition-colors hover:border-border hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n        data-policy-row={policy.id}\n        data-policy-status={policy.status}\n        onClick={handleClick}\n        type=\"button\"\n      >\n        <RowBody policy={policy} />\n      </button>\n    );\n  }\n  return (\n    <div\n      className=\"flex w-full items-center gap-2 rounded-md px-2 py-1.5\"\n      data-policy-row={policy.id}\n      data-policy-status={policy.status}\n    >\n      <RowBody policy={policy} />\n    </div>\n  );\n};\n\n/**\n * Right-dock panel listing the policies / guardrails that apply to the\n * active route or run. Each row shows the policy name, enforcement\n * status chip, and optional rationale. Pure presentation; the host\n * computes the policy list from the live config and supplies an\n * optional toggle handler for admin views.\n *\n * @example\n * ```tsx\n * <PolicyDeliveryPanel\n *   policies={[\n *     { id: \"pii\",  name: \"PII redaction\", status: \"enforced\" },\n *     { id: \"rate\", name: \"Rate limiting\", status: \"advisory\", description: \"60 / s soft cap\" },\n *     { id: \"exp\",  name: \"Experiment B\",  status: \"disabled\" },\n *   ]}\n * />\n * ```\n *\n * @public\n */\nexport const PolicyDeliveryPanel = forwardRef<\n  HTMLElement,\n  PolicyDeliveryPanelProps\n>((props, ref) => {\n  const { className, labels, policies, title = \"Policies\", ...rest } = props;\n  const resolvedLabels = { ...DEFAULT_LABELS, ...labels };\n  return (\n    <section\n      aria-label={resolvedLabels.region}\n      className={cn(\n        \"flex w-full flex-col gap-2 rounded-lg border bg-background p-3 text-foreground\",\n        className,\n      )}\n      data-policy-delivery-panel\n      ref={ref}\n      {...rest}\n    >\n      <header>\n        <h3 className=\"text-xs font-semibold uppercase tracking-wide text-muted-foreground\">\n          {title}\n        </h3>\n      </header>\n      {policies.length === 0 ? (\n        <p\n          className=\"px-2 py-3 text-center text-xs text-muted-foreground\"\n          data-policy-state=\"empty\"\n        >\n          {resolvedLabels.empty}\n        </p>\n      ) : (\n        <ul className=\"space-y-0.5\">\n          {policies.map((policy) => (\n            <li key={policy.id}>\n              <Row policy={policy} />\n            </li>\n          ))}\n        </ul>\n      )}\n    </section>\n  );\n});\nPolicyDeliveryPanel.displayName = \"PolicyDeliveryPanel\";\n",
      "type": "registry:component"
    }
  ],
  "version": "0.2.1",
  "stability": "stable"
}
