importState(state) {
        if (!state || typeof state !== 'object') {
            throw new Error('Invalid state object');
        }

        try {
            this.undoStack = state.undoStack.map(cmd => this.deserializeCommand(cmd));
            this.redoStack = state.redoStack.map(cmd => this.deserializeCommand(cmd));
            this.maxStackSize = state.maxStackSize || this.maxStackSize;
            this.snapshotInterval = state.snapshotInterval || this.snapshotInterval;
            this.compressThreshold = state.compressThreshold || this.compressThreshold;
            this.mergeWindow = state.mergeWindow || this.mergeWindow;

            // Reset other internal state
            this.isExecuting = false;
            this.lastExecutionTime = 0;
            this.transactionStack = [];
            this.snapshots.clear();

            this.notifyListeners();
        } catch (error) {
            throw new Error('Failed to import state: ' + error.message);
        }
    }
Imports a previously exported state into the undo/redo manager.

@param {Object} state - The state object to import.
@throws {Error} If the state object is invalid or commands can't be deserialized.

@description
This method takes a state object (typically created by exportState)
and restores the undo/redo manager to that state. It deserializes
the undo and redo stacks and restores configuration settings.

@example
// Assuming jsonState is retrieved from storage
const state = JSON.parse(jsonState);
undoRedoManager.importState(state);