{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "budget-overview",
  "title": "Budget Overview",
  "type": "registry:block",
  "files": [
    {
      "path": "packages/registry-native/blocks/budget-overview/BudgetOverview.tsx",
      "content": "import * as React from 'react'\nimport { FlatList, I18nManager, View, type ViewProps } from 'react-native'\nimport { ChevronLeft, ChevronRight } from 'lucide-react-native'\nimport { Icon } from '@/components/ui/icon'\nimport { ListItem, ListItemContent, ListItemDescription, ListItemTitle, ListSeparator } from '@/components/ui/list'\nimport { Progress } from '@/components/ui/progress'\nimport { Text } from '@/components/ui/text'\nimport { cn } from '@/lib/utils'\n\nexport interface BudgetOverviewCategory {\n  id: string\n  name: string\n  /** Non-negative safe integer in minor currency units (such as cents). */\n  allocated: number\n  /** Non-negative safe integer in the same units as allocated. */\n  spent: number\n}\n\nconst defaultLabels = {\n  categories: 'Categories',\n  noCategories: 'No budget categories yet',\n  noAllocation: 'No allocation',\n  fullySpent: 'Fully spent',\n  unavailable: 'Budget summary unavailable',\n  spentOf: (spent: string, allocated: string) => `${spent} of ${allocated} spent`,\n  remaining: (amount: string) => `${amount} remaining`,\n  exceeded: (amount: string) => `${amount} over budget`,\n}\n\nexport interface BudgetOverviewProps extends ViewProps {\n  className?: string\n  /** Omit to show the sample. An empty array renders the empty state. */\n  categories?: readonly BudgetOverviewCategory[]\n  /** ISO 4217 code shared by every category in this period. */\n  currency?: string\n  locale?: string\n  header?: React.ReactNode\n  labels?: Partial<typeof defaultLabels>\n  onCategoryPress?: (category: BudgetOverviewCategory) => void\n}\n\nconst sample: readonly BudgetOverviewCategory[] = [\n  { id: 'workspace', name: 'Studio supplies', allocated: 15_000, spent: 10_234 },\n  { id: 'transport', name: 'Transport', allocated: 8_000, spent: 9_200 },\n]\n\nfunction validAmount(value: number) {\n  return Number.isSafeInteger(value) && value >= 0\n}\n\nfunction amountFormatter(locale: string | undefined, currency: string) {\n  const code = currency.trim().toUpperCase()\n  if (!/^[A-Z]{3}$/.test(code)) return undefined\n  const format = new Intl.NumberFormat(locale, { style: 'currency', currency: code })\n  const { maximumFractionDigits: precision = 2, numberingSystem } = format.resolvedOptions()\n  if (precision === 0) return (minor: number) => format.format(minor)\n  const divisor = 10 ** precision\n  const digits = new Intl.NumberFormat(locale, {\n    minimumIntegerDigits: precision,\n    maximumFractionDigits: 0,\n    numberingSystem,\n    useGrouping: false,\n  })\n  const zeroFraction = digits.format(0)\n  const halfFraction = digits.format(divisor / 2)\n  const sample = format.format(0.5)\n  const sampleStart = sample.lastIndexOf(halfFraction)\n  if (sampleStart < 0) return undefined\n  const suffixLength = sample.length - sampleStart - halfFraction.length\n\n  return (minor: number) => {\n    const remainder = minor % divisor\n    const whole = format.format((minor - remainder) / divisor)\n    if (!remainder) return whole\n    // Replace only the fractional digits to preserve the locale's monetary\n    // separators and affixes without relying on Hermes formatToParts.\n    const fractionEnd = whole.length - suffixLength\n    return whole.slice(0, fractionEnd - zeroFraction.length) + digits.format(remainder) + whole.slice(fractionEnd)\n  }\n}\n\nexport function BudgetOverview({\n  className,\n  categories = sample,\n  currency = 'USD',\n  locale,\n  header,\n  labels,\n  onCategoryPress,\n  ...props\n}: BudgetOverviewProps) {\n  const copy = { ...defaultLabels, ...labels }\n  const formatter = React.useMemo(() => amountFormatter(locale, currency), [locale, currency])\n  const validCategories = React.useMemo(\n    () => categories.filter((category) => validAmount(category.allocated) && validAmount(category.spent)),\n    [categories],\n  )\n  const totals = React.useMemo(\n    () =>\n      validCategories.reduce(\n        (sum, category) => ({\n          allocated: sum.allocated + category.allocated,\n          spent: sum.spent + category.spent,\n        }),\n        { allocated: 0, spent: 0 },\n      ),\n    [validCategories],\n  )\n  const showTotal =\n    !!formatter &&\n    validCategories.length > 0 &&\n    validCategories.length === categories.length &&\n    validAmount(totals.allocated) &&\n    validAmount(totals.spent)\n  const Chevron = I18nManager.isRTL ? ChevronLeft : ChevronRight\n\n  function amount(minor: number) {\n    return formatter?.(minor) ?? ''\n  }\n\n  function balance(allocated: number, spent: number) {\n    if (!allocated && !spent) return copy.noAllocation\n    if (spent > allocated) return copy.exceeded(amount(spent - allocated))\n    if (spent === allocated) return copy.fullySpent\n    return copy.remaining(amount(allocated - spent))\n  }\n\n  return (\n    <View {...props} className={cn('min-h-0 flex-1 bg-background', className)}>\n      <FlatList\n        data={formatter ? validCategories : []}\n        keyExtractor={(category) => category.id}\n        contentContainerStyle={{ paddingBottom: 16 }}\n        ListHeaderComponent={\n          <View className=\"gap-4 pb-3\">\n            {header}\n            {showTotal ? (\n              <View className=\"gap-3 rounded-2xl border border-border bg-card p-5\">\n                <View className=\"gap-1\">\n                  <Text\n                    size=\"title\"\n                    className={totals.spent > totals.allocated ? 'text-destructive' : undefined}\n                    style={{ fontVariant: ['tabular-nums'] }}\n                  >\n                    {balance(totals.allocated, totals.spent)}\n                  </Text>\n                  <Text size=\"sm\" variant=\"muted\" style={{ fontVariant: ['tabular-nums'] }}>\n                    {copy.spentOf(amount(totals.spent), amount(totals.allocated))}\n                  </Text>\n                </View>\n                {totals.allocated > 0 ? (\n                  <Progress\n                    aria-hidden\n                    value={totals.spent}\n                    max={totals.allocated}\n                    indicatorClassName={totals.spent > totals.allocated ? 'bg-destructive' : undefined}\n                  />\n                ) : null}\n              </View>\n            ) : formatter && validCategories.length > 0 ? (\n              <Text size=\"sm\" variant=\"muted\">\n                {copy.unavailable}\n              </Text>\n            ) : null}\n            {validCategories.length > 0 && formatter ? (\n              <Text accessibilityRole=\"header\" className=\"font-semibold\">\n                {copy.categories}\n              </Text>\n            ) : null}\n          </View>\n        }\n        ListEmptyComponent={\n          <View className=\"items-center rounded-xl border border-border px-4 py-8\">\n            <Text className=\"text-center font-medium\">\n              {categories.length > 0 ? copy.unavailable : copy.noCategories}\n            </Text>\n          </View>\n        }\n        ItemSeparatorComponent={ListSeparator}\n        renderItem={({ item }) => {\n          const over = item.spent > item.allocated\n          const categoryBalance = balance(item.allocated, item.spent)\n          const categorySpending = copy.spentOf(amount(item.spent), amount(item.allocated))\n          return (\n            <ListItem\n              accessible\n              accessibilityLabel={[item.name, categorySpending, categoryBalance].join(', ')}\n              onPress={onCategoryPress ? () => onCategoryPress(item) : undefined}\n              className=\"px-0\"\n            >\n              <ListItemContent className=\"gap-2\">\n                <View className=\"flex-row flex-wrap items-baseline justify-between gap-x-3 gap-y-1\">\n                  <ListItemTitle className=\"min-w-0 shrink\">{item.name}</ListItemTitle>\n                  <Text\n                    size=\"sm\"\n                    className={cn('font-medium', over && 'text-destructive')}\n                    style={{ fontVariant: ['tabular-nums'] }}\n                  >\n                    {categoryBalance}\n                  </Text>\n                </View>\n                <ListItemDescription style={{ fontVariant: ['tabular-nums'] }}>{categorySpending}</ListItemDescription>\n                {item.allocated > 0 ? (\n                  <Progress\n                    aria-hidden\n                    value={item.spent}\n                    max={item.allocated}\n                    indicatorClassName={over ? 'bg-destructive' : undefined}\n                  />\n                ) : null}\n              </ListItemContent>\n              {onCategoryPress ? <Icon icon={Chevron} size={18} className=\"text-muted-foreground\" /> : null}\n            </ListItem>\n          )\n        }}\n      />\n    </View>\n  )\n}\n",
      "type": "registry:block",
      "target": "~/components/blocks/budget-overview/BudgetOverview.tsx"
    },
    {
      "path": "packages/registry-native/blocks/budget-overview/index.ts",
      "content": "export { BudgetOverview, type BudgetOverviewCategory, type BudgetOverviewProps } from './BudgetOverview'\n",
      "type": "registry:block",
      "target": "~/components/blocks/budget-overview/index.ts"
    }
  ],
  "dependencies": [
    "lucide-react-native"
  ],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/icon.json",
    "https://native.uipkge.dev/r/native/list.json",
    "https://native.uipkge.dev/r/native/progress.json",
    "https://native.uipkge.dev/r/native/text.json"
  ],
  "description": "A native budget summary with category allocations, actual spending, progress, and clear remaining or overspent balances.",
  "categories": [
    "finance"
  ]
}