'use client';

/** JSON block — thin chat wrapper around `JsonTree`. */

import { LazyJsonTree } from '../../../../data/JsonTree/lazy';
import type { JsonBlock } from '../../../types/block';
import type { BlockRendererProps } from './types';

export default function JsonBlockRenderer({ block, ctx }: BlockRendererProps<JsonBlock>) {
  // Compact appearance (block.mode === 'compact' or compact chat) → hide
  // the toolbar, collapse depth, drop the card frame. Full appearance →
  // hover-revealed toolbar + card.
  const mode = block.mode ?? (ctx.appearance === 'compact' ? 'compact' : 'full');
  const compact = mode !== 'full';
  return (
    <LazyJsonTree
      data={block.data}
      toolbar={compact ? 'never' : 'auto'}
      bordered={!compact}
      defaultExpandedDepth={compact ? 1 : 2}
    />
  );
}
