<?php
/**
 * WooCommerce recording workspace module.
 *
 * @package ScheduledChanges
 */

namespace ScheduledChangesWooCommerce\CoreCompat\Recording;

use ScheduledChanges\Field\FieldRegistry;
use ScheduledChanges\Provider\ProviderRegistry;
use ScheduledChanges\Repository\LaunchRepository;
use ScheduledChanges\Repository\LaunchVersionRepository;

/** Owns WooCommerce shadow workspaces, snapshots, diffs, compilation, and cleanup. */
final class WooCommerceRecordingModule {
	public const MODULE_ID = 'scheduled-changes-woocommerce-recording-workspace';

	/** Creates the source-protection guard for recording workspaces. */
	public function createAccessGuard(): ShadowProductAccessGuard {
		return new ShadowProductAccessGuard();
	}

	/** Creates the workspace adapter from active provider and field registries. */
	public function createWorkspaceAdapter( ProviderRegistry $providers, FieldRegistry $fields ): WooCommerceRecordingWorkspaceAdapter {
		return new WooCommerceRecordingWorkspaceAdapter(
			new ShadowProductCloner(),
			new RecordingSnapshotter( $providers ),
			new RecordingDiffBuilder( $fields )
		);
	}

	/** Creates the launch compiler from active provider and field registries. */
	public function createLaunchCompiler(
		ProviderRegistry $providers,
		FieldRegistry $fields,
		LaunchRepository $launches,
		LaunchVersionRepository $versions
	): RecordingLaunchCompiler {
		return new RecordingLaunchCompiler( $providers, $fields, $launches, $versions );
	}
}
