{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "author": "Lopifi (https://lopifi.com)",
  "categories": [
    "statements",
    "finance",
    "accounting"
  ],
  "dependencies": [],
  "description": "Operating / investing / financing.",
  "files": [
    {
      "content": "\"use client\";\n\nimport { cn } from \"@/lib/ledger/cn\";\nimport { CheckIcon, ExclamationTriangleIcon } from \"@/components/ledger/icons\";\nimport { Money } from \"@/components/ledger/money\";\nimport { type StatementHeader, type StatementLine, StatementTable } from \"@/components/ledger/statement-table\";\n\nexport interface CashFlowStatementProps {\n  className?: string;\n  /** Offer the period columns to hide. See `StatementTable`. */\n  columnManager?: boolean;\n  header: Omit<StatementHeader, \"statement\">;\n  lines: StatementLine[];\n  /** Caps the scroller so the column headers freeze. See `StatementTable`. */\n  maxHeight?: number;\n  method?: \"indirect\" | \"direct\";\n  periods: string[];\n  /** Beginning + net change = ending, and ending must equal the balance\n      sheet cash line. Asserted and displayed. */\n  tieOut: {\n    beginningCash: number[];\n    netChange: number[];\n    endingCash: number[];\n    balanceSheetCash: number[];\n  };\n}\n\n/**\n * The working-capital sign convention is inverted and it confuses everyone:\n * an *increase* in AR is a *use* of cash. The lines are labelled\n * \"(Increase) / decrease in …\" exactly so, because the parenthetical is\n * what makes the sign readable.\n */\nexport function CashFlowStatement({\n  header,\n  periods,\n  method = \"indirect\",\n  lines,\n  tieOut,\n  maxHeight,\n  columnManager,\n  className,\n}: CashFlowStatementProps) {\n  return (\n    <div className={cn(\"w-full\", className)}>\n      <StatementTable\n        columnManager={columnManager}\n        header={{\n          ...header,\n          statement: `Statement of cash flows (${method} method)`,\n        }}\n        lines={lines}\n        maxHeight={maxHeight}\n        periods={periods}\n      />\n\n      <div className=\"mt-4 space-y-2\">\n        {periods.map((p, i) => {\n          const computed = tieOut.beginningCash[i] + tieOut.netChange[i];\n          const tiesInternally = computed === tieOut.endingCash[i];\n          const tiesToBalanceSheet = tieOut.endingCash[i] === tieOut.balanceSheetCash[i];\n          const ok = tiesInternally && tiesToBalanceSheet;\n\n          return (\n            <div\n              className={cn(\n                \"flex flex-wrap items-center gap-2 rounded-md border px-4 py-3\",\n                ok ? \"border-positive bg-positive-subtle\" : \"border-negative bg-negative-subtle\",\n              )}\n              key={p}\n              role={ok ? undefined : \"alert\"}\n            >\n              {ok ? (\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\">{p}:</span>\n              <span className=\"flex flex-wrap items-baseline gap-1 text-body\">\n                Beginning{\" \"}\n                <Money accounting value={{ amount: tieOut.beginningCash[i], currency: header.currency }} />\n                <span aria-hidden=\"true\">+</span>\n                Net change{\" \"}\n                <Money accounting value={{ amount: tieOut.netChange[i], currency: header.currency }} />\n                <span aria-hidden=\"true\">=</span>\n                Ending{\" \"}\n                <Money accounting value={{ amount: tieOut.endingCash[i], currency: header.currency }} />\n              </span>\n              <span className={cn(\"text-body font-medium\", ok ? \"text-positive\" : \"text-negative\")}>\n                {ok\n                  ? \"Ties to the balance sheet cash line.\"\n                  : tiesInternally\n                    ? \"Does not tie to the balance sheet cash line.\"\n                    : \"Beginning plus net change does not equal ending cash.\"}\n              </span>\n            </div>\n          );\n        })}\n      </div>\n    </div>\n  );\n}\n",
      "path": "components/ledger/cash-flow-statement.tsx",
      "target": "components/ledger/cash-flow-statement.tsx",
      "type": "registry:component"
    }
  ],
  "name": "cash-flow-statement",
  "registryDependencies": [
    "@lopifi/theme",
    "@lopifi/cn",
    "@lopifi/icons",
    "@lopifi/money",
    "@lopifi/statement-table"
  ],
  "title": "CashFlowStatement",
  "type": "registry:component"
}
