{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "author": "Lopifi (https://lopifi.com)",
  "categories": [
    "statements",
    "finance",
    "accounting"
  ],
  "dependencies": [],
  "description": "Assets / liabilities / equity, with the balance check.",
  "files": [
    {
      "content": "\"use client\";\n\nimport { cn } from \"@/lib/ledger/cn\";\nimport { formatDate } from \"@/lib/ledger/fiscal-period\";\nimport { CheckIcon, ExclamationTriangleIcon } from \"@/components/ledger/icons\";\nimport { Money } from \"@/components/ledger/money\";\nimport {\n  type DrilldownTarget,\n  type StatementHeader,\n  type StatementLine,\n  StatementTable,\n} from \"@/components/ledger/statement-table\";\n\nexport interface BalanceSheetProps {\n  /** A balance sheet is a point in time. Taking a Date, not a range, makes\n      \"September 2026\" a category error the type system prevents. */\n  asOf: Date;\n  className?: string;\n  /** Offer the period columns to hide. See `StatementTable`. */\n  columnManager?: boolean;\n  comparativeDates?: Date[];\n  header: Omit<StatementHeader, \"statement\" | \"periodLabel\">;\n  lines: StatementLine[];\n  /** Caps the scroller so the column headers freeze. See `StatementTable`. */\n  maxHeight?: number;\n  onDrilldown?: (line: StatementLine, target: DrilldownTarget) => void;\n  /** Passed in, already computed, per column. */\n  totals: { assets: number[]; liabilities: number[]; equity: number[] };\n}\n\n/**\n * The accounting identity is a first-class UI element, not a footnote.\n * When it doesn't balance, that is a prominent error state with the\n * difference stated — never a silently wrong statement.\n */\nexport function BalanceSheet({\n  asOf,\n  comparativeDates = [],\n  header,\n  lines,\n  totals,\n  onDrilldown,\n  maxHeight,\n  columnManager,\n  className,\n}: BalanceSheetProps) {\n  const dates = [asOf, ...comparativeDates];\n  const periods = dates.map((d) => `As of ${formatDate(d)}`);\n\n  return (\n    <div className={cn(\"w-full\", className)}>\n      <StatementTable\n        columnManager={columnManager}\n        header={{\n          ...header,\n          periodLabel: `As of ${formatDate(asOf)}`,\n          statement: \"Balance sheet\",\n        }}\n        lines={lines}\n        maxHeight={maxHeight}\n        onDrilldown={onDrilldown}\n        periods={periods}\n      />\n\n      <div className=\"mt-4 space-y-2\">\n        {dates.map((d, i) => {\n          const assets = totals.assets[i];\n          const liabilities = totals.liabilities[i];\n          const equity = totals.equity[i];\n          const difference = assets - (liabilities + equity);\n          const balanced = difference === 0;\n\n          return (\n            <div\n              className={cn(\n                \"flex flex-wrap items-center gap-x-2 gap-y-1 rounded-md border px-4 py-3\",\n                balanced ? \"border-positive bg-positive-subtle\" : \"border-negative bg-negative-subtle\",\n              )}\n              key={d.toISOString()}\n              role={balanced ? undefined : \"alert\"}\n            >\n              {balanced ? (\n                <CheckIcon aria-hidden=\"true\" className=\"size-4 shrink-0 text-positive\" />\n              ) : (\n                <ExclamationTriangleIcon aria-hidden=\"true\" className=\"size-4 shrink-0 text-negative\" />\n              )}\n              <span className=\"text-caption text-text-secondary\">{formatDate(d)}:</span>\n              <span className=\"flex flex-wrap items-baseline gap-1 text-body\">\n                Assets <Money accounting value={{ amount: assets, currency: header.currency }} />\n                <span aria-hidden=\"true\">=</span>\n                Liabilities <Money accounting value={{ amount: liabilities, currency: header.currency }} />\n                <span aria-hidden=\"true\">+</span>\n                Equity <Money accounting value={{ amount: equity, currency: header.currency }} />\n              </span>\n              {balanced ? (\n                <span className=\"text-body font-medium text-positive\">Balanced</span>\n              ) : (\n                <span className=\"flex items-baseline gap-1 text-body font-medium text-negative\">\n                  Out by{\" \"}\n                  <Money\n                    accounting\n                    tone=\"inherit\"\n                    value={{ amount: difference, currency: header.currency }}\n                  />\n                </span>\n              )}\n            </div>\n          );\n        })}\n      </div>\n    </div>\n  );\n}\n",
      "path": "components/ledger/balance-sheet.tsx",
      "target": "components/ledger/balance-sheet.tsx",
      "type": "registry:component"
    }
  ],
  "name": "balance-sheet",
  "registryDependencies": [
    "@lopifi/theme",
    "@lopifi/cn",
    "@lopifi/fiscal-period",
    "@lopifi/icons",
    "@lopifi/money",
    "@lopifi/statement-table"
  ],
  "title": "BalanceSheet",
  "type": "registry:component"
}
