Function restoreBlocks

Restores the blocks array using a two-pass approach to resolve circular dependencies.

Pass 1: Creates a "shallow" version of each block with all top-level properties but an empty elements array. This provides a complete reference list of all blocks.

Pass 2: Iterates over the shallow blocks, calling restoreElements for each one, providing the complete block list from Pass 1 as the necessary context.