<?php
/**
 * Built-in JJ\'s Post Scheduler module catalog.
 *
 * @package ScheduledChanges
 */

namespace ScheduledChanges\Extension;

use ScheduledChanges\Audit\AuditDiagnosticsModule;
use ScheduledChanges\Execution\ExecutionModule;
use ScheduledChanges\Provider\ProviderDiscoveryModule;
use ScheduledChanges\Recording\RecordingModule;
use ScheduledChanges\Rollback\RollbackModule;
use ScheduledChanges\Scheduler\SchedulingModule;
use ScheduledChanges\Taxonomy\TaxonomyModule;
use ScheduledChanges\Taxonomy\WordPressCategoryModule;
use ScheduledChanges\Taxonomy\WordPressTagModule;
use ScheduledChanges\Templates\LaunchTemplatesModule;
use ScheduledChanges\Validation\ValidationModule;
use ScheduledChanges\WordPressContent\NativeContentModule;
use ScheduledChanges\WordPressContent\RegisteredMetaModule;

/**
 * Declares the bundled modules that ship inside core.
 */
final class BundledModuleCatalog {
	/**
	 * Returns bundled module manifests.
	 *
	 * @return ModuleDefinition[]
	 */
	public function definitions(): array {
		$definitions = array(
			$this->definition(
				ProviderDiscoveryModule::MODULE_ID,
				'Provider and Field Discovery Module',
				array( AuditDiagnosticsModule::MODULE_ID ),
				array( 'providers.discovery', 'fields.discovery', 'fields.registry' ),
				ModuleDefinition::VISIBILITY_DEVELOPMENT,
				'foundation',
				'Discovers field providers, builds the field registry, and resolves ownership for schedulable target data.'
			),
			$this->definition(
				ValidationModule::MODULE_ID,
				'Launch Planning and Validation Module',
				array( ProviderDiscoveryModule::MODULE_ID ),
				array( 'launch.validation', 'operations.graph', 'permissions.validation' ),
				ModuleDefinition::VISIBILITY_PUBLIC,
				'lifecycle',
				'Builds operation plans, validates schedules and permissions, and blocks unsafe changes before they are queued.'
			),
			$this->definition(
				SchedulingModule::MODULE_ID,
				'Scheduling and Queue Module',
				array( ValidationModule::MODULE_ID, ExecutionModule::MODULE_ID ),
				array( 'launch.scheduling', 'queue.actions', 'recurrence' ),
				ModuleDefinition::VISIBILITY_PUBLIC,
				'lifecycle',
				'Schedules launches, manages Action Scheduler jobs, recurrence safety, and queue status.'
			),
			$this->definition(
				ExecutionModule::MODULE_ID,
				'Execution and Locks Module',
				array( ValidationModule::MODULE_ID, RollbackModule::MODULE_ID ),
				array( 'launch.execution', 'locks', 'provider.operations' ),
				ModuleDefinition::VISIBILITY_PUBLIC,
				'lifecycle',
				'Runs queued changes with target locks, provider operation dispatch, conflict checks, retries, and readback.'
			),
			$this->definition(
				RecordingModule::MODULE_ID,
				'Record Changes Module',
				array( ValidationModule::MODULE_ID, ExecutionModule::MODULE_ID ),
				array( 'recording.workspace', 'recording.diff', 'recording.finalize' ),
				ModuleDefinition::VISIBILITY_PUBLIC,
				'recording',
				'Creates safe recording workspaces, captures edits, builds diffs, and finalizes recordings into scheduled launches.'
			),
			$this->definition(
				RollbackModule::MODULE_ID,
				'Snapshots and Rollback Module',
				array( ProviderDiscoveryModule::MODULE_ID ),
				array( 'snapshots', 'rollback' ),
				ModuleDefinition::VISIBILITY_PUBLIC,
				'safety',
				'Captures before/apply snapshots and restores supported changes through verified rollback workflows.'
			),
			$this->definition(
				AuditDiagnosticsModule::MODULE_ID,
				'Audit and Diagnostics Module',
				array(),
				array( 'audit.events', 'runs.history', 'diagnostics.system-status', 'support.report' ),
				ModuleDefinition::VISIBILITY_PUBLIC,
				'diagnostics',
				'Owns redacted audit events and durable execution history used by System Status, support reports, and operational consumers.'
			),
			$this->definition(
				NativeContentModule::MODULE_ID,
				'Native WordPress Content Module',
				array( ProviderDiscoveryModule::MODULE_ID ),
				array( 'wordpress.content.fields', 'wordpress.content.operations' ),
				ModuleDefinition::VISIBILITY_PUBLIC,
				'native-wordpress',
				'Schedules supported native post and page fields such as title, content, status, author, dates, media, and hierarchy.'
			),
			$this->definition(
				TaxonomyModule::MODULE_ID,
				'Taxonomies Module',
				array( NativeContentModule::MODULE_ID ),
				array( 'wordpress.taxonomies' ),
				ModuleDefinition::VISIBILITY_GROUPED_PUBLIC,
				'native-wordpress',
				'Provides the shared taxonomy scheduling layer used by category, tag, and custom taxonomy assignments.'
			),
			$this->definition(
				WordPressCategoryModule::MODULE_ID,
				'Categories Module',
				array( TaxonomyModule::MODULE_ID ),
				array( 'wordpress.categories' ),
				ModuleDefinition::VISIBILITY_GROUPED_PUBLIC,
				'native-wordpress',
				'Schedules category assignments for WordPress posts through the shared taxonomy engine.'
			),
			$this->definition(
				WordPressTagModule::MODULE_ID,
				'Tags Module',
				array( TaxonomyModule::MODULE_ID ),
				array( 'wordpress.tags' ),
				ModuleDefinition::VISIBILITY_GROUPED_PUBLIC,
				'native-wordpress',
				'Schedules WordPress post tags through the shared taxonomy engine.'
			),
			$this->definition(
				RegisteredMetaModule::MODULE_ID,
				'Registered Custom Meta Module',
				array( NativeContentModule::MODULE_ID ),
				array( 'wordpress.meta.registered' ),
				ModuleDefinition::VISIBILITY_GROUPED_PUBLIC,
				'native-wordpress',
				'Schedules explicitly registered WordPress custom meta that has a safe schema and write contract.'
			),
			$this->definition(
				LaunchTemplatesModule::MODULE_ID,
				'Launch Templates Module',
				array( NativeContentModule::MODULE_ID ),
				array( 'portability.templates' ),
				ModuleDefinition::VISIBILITY_PUBLIC,
				'portability',
				'Provides reusable, versioned launch blueprints and accepts template contributions from selected provider modules.'
			),
			$this->definition(
				BundledModuleIds::REST_API,
				'REST Delivery Module',
				array( AuditDiagnosticsModule::MODULE_ID ),
				array( 'delivery.rest' ),
				ModuleDefinition::VISIBILITY_PUBLIC,
				'delivery',
				'Provides centralized REST authentication, capability policy, route registration, and the module-contributed System Status route.'
			),
			$this->definition(
				BundledModuleIds::REST_LAUNCHES,
				'Launch REST Routes Module',
				array( BundledModuleIds::REST_API, SchedulingModule::MODULE_ID ),
				array( 'delivery.rest.launches' ),
				ModuleDefinition::VISIBILITY_GROUPED_PUBLIC,
				'delivery',
				'Contributes permission-checked launch, target, provider, validation, scheduling, execution, and cancellation routes and schemas.'
			),
			$this->definition(
				BundledModuleIds::REST_ROLLBACK,
				'Rollback REST Route Module',
				array( BundledModuleIds::REST_LAUNCHES, RollbackModule::MODULE_ID ),
				array( 'delivery.rest.rollback' ),
				ModuleDefinition::VISIBILITY_GROUPED_PUBLIC,
				'delivery',
				'Contributes the permission-checked rollback REST route for supported scheduled changes.'
			),
			$this->definition(
				BundledModuleIds::REST_RECORDINGS,
				'Record Changes REST Routes Module',
				array( BundledModuleIds::REST_API, RecordingModule::MODULE_ID ),
				array( 'delivery.rest.recordings' ),
				ModuleDefinition::VISIBILITY_GROUPED_PUBLIC,
				'delivery',
				'Contributes permission-checked recording collection, capture, finalize, and cancellation routes and schemas.'
			),
			$this->definition(
				BundledModuleIds::WP_CLI,
				'WP-CLI Delivery Module',
				array( AuditDiagnosticsModule::MODULE_ID ),
				array( 'delivery.wp-cli' ),
				ModuleDefinition::VISIBILITY_PUBLIC,
				'delivery',
				'Provides explicit WP-CLI command registration and shared actor, capability, confirmation, and output policy.'
			),
			$this->definition(
				BundledModuleIds::CLI_SCHEDULING,
				'Scheduling WP-CLI Commands Module',
				array( BundledModuleIds::WP_CLI, SchedulingModule::MODULE_ID ),
				array( 'delivery.wp-cli.scheduling' ),
				ModuleDefinition::VISIBILITY_GROUPED_PUBLIC,
				'delivery',
				'Contributes launch lifecycle and queue inspection commands backed by scheduling and execution application services.'
			),
			$this->definition(
				BundledModuleIds::CLI_RECORDING,
				'Record Changes WP-CLI Commands Module',
				array( BundledModuleIds::WP_CLI, RecordingModule::MODULE_ID ),
				array( 'delivery.wp-cli.recording' ),
				ModuleDefinition::VISIBILITY_GROUPED_PUBLIC,
				'delivery',
				'Contributes recording list, start, capture, finalize, cancellation, and cleanup commands.'
			),
			$this->definition(
				BundledModuleIds::CLI_PROVIDERS,
				'Provider WP-CLI Commands Module',
				array( BundledModuleIds::WP_CLI, ProviderDiscoveryModule::MODULE_ID ),
				array( 'delivery.wp-cli.providers' ),
				ModuleDefinition::VISIBILITY_GROUPED_PUBLIC,
				'delivery',
				'Contributes provider inventory and canonical field discovery commands from the active provider registry.'
			),
			$this->definition(
				BundledModuleIds::CLI_DIAGNOSTICS,
				'Diagnostics WP-CLI Commands Module',
				array( BundledModuleIds::WP_CLI, AuditDiagnosticsModule::MODULE_ID ),
				array( 'delivery.wp-cli.diagnostics' ),
				ModuleDefinition::VISIBILITY_GROUPED_PUBLIC,
				'delivery',
				'Contributes redacted logs, conflict summaries, migration status, and doctor diagnostics commands.'
			),
			$this->definition(
				BundledModuleIds::ADMIN_SHELL,
				'Admin Shell Module',
				array( AuditDiagnosticsModule::MODULE_ID ),
				array( 'delivery.admin', 'admin.navigation', 'admin.assets' ),
				ModuleDefinition::VISIBILITY_PUBLIC,
				'admin',
				'Provides the neutral WordPress admin shell, navigation transport, localized data transport, assets, and fallback host.'
			),
			$this->definition(
				BundledModuleIds::ADMIN_READ_ONLY,
				'Read-only Admin Discovery Module',
				array( BundledModuleIds::ADMIN_SHELL, ProviderDiscoveryModule::MODULE_ID, LaunchTemplatesModule::MODULE_ID ),
				array( 'admin.read-only', 'admin.launch-previews', 'admin.targets' ),
				ModuleDefinition::VISIBILITY_GROUPED_PUBLIC,
				'admin',
				'Adds dashboard summaries and launch preview data without registering mutating admin actions.'
			),
			$this->definition(
				BundledModuleIds::ADMIN_SCHEDULE,
				'Schedule Center and Calendar Admin Module',
				array( BundledModuleIds::ADMIN_SHELL, SchedulingModule::MODULE_ID ),
				array( 'admin.schedule-center', 'admin.calendar', 'admin.targets' ),
				ModuleDefinition::VISIBILITY_GROUPED_PUBLIC,
				'admin',
				'Adds the Schedule Center and Calendar screens for reviewing scheduled changes.'
			),
			$this->definition(
				BundledModuleIds::ADMIN_RECORDING,
				'Record Changes Admin Module',
				array( BundledModuleIds::ADMIN_SHELL, RecordingModule::MODULE_ID ),
				array( 'admin.record-changes' ),
				ModuleDefinition::VISIBILITY_GROUPED_PUBLIC,
				'admin',
				'Adds editor-driven recording start and cancel actions plus recording notices.'
			),
			$this->definition(
				BundledModuleIds::ADMIN_RUN_HISTORY,
				'Run History and Rollback Admin Module',
				array( BundledModuleIds::ADMIN_SHELL, AuditDiagnosticsModule::MODULE_ID ),
				array( 'admin.run-history', 'admin.rollback' ),
				ModuleDefinition::VISIBILITY_GROUPED_PUBLIC,
				'admin',
				'Adds redacted run history and audit details without registering restore mutations.'
			),
			$this->definition(
				BundledModuleIds::ADMIN_MODULES,
				'Addons Page Module',
				array( BundledModuleIds::ADMIN_SHELL ),
				array( 'admin.addons-page', 'modules.catalog' ),
				ModuleDefinition::VISIBILITY_PUBLIC,
				'admin',
				'Displays high-level addon availability from the resolved extension and module catalog.'
			),
		);

		return PublicHooks::bundledModuleDefinitions( $definitions );
	}

	/**
	 * Creates a bundled module definition.
	 *
	 * @param string[] $dependencies Dependency module slugs.
	 * @param string[] $capabilities Capability IDs.
	 */
	private function definition(
		string $slug,
		string $name,
		array $dependencies,
		array $capabilities,
		string $visibility,
		string $group,
		string $description
	): ModuleDefinition {
		return new ModuleDefinition(
			$slug,
			$name,
			defined( 'SCHEDULED_CHANGES_VERSION' ) ? SCHEDULED_CHANGES_VERSION : '0.0.0',
			$slug,
			'scheduled-changes-core',
			'',
			array(),
			ModuleDefinition::LIFECYCLE_COMPLETE,
			'Bundled with JJ\'s Post Scheduler core.',
			array(),
			array(
				'dependencies'       => $dependencies,
				'capabilities'       => $capabilities,
				'package_form'       => ModuleDefinition::PACKAGE_BUNDLED_CORE,
				'visibility'         => $visibility,
				'source_package'     => 'scheduled-changes-core',
				'group'              => $group,
				'description'        => $description,
				'resources'          => $this->resourcesForSlug( $slug ),
				'registration_phase' => $this->phaseForGroup( $group, $slug ),
			)
		);
	}

	/**
	 * Returns runtime resources owned by a bundled module.
	 *
	 * @return array<string,string[]>
	 */
	private function resourcesForSlug( string $slug ): array {
		switch ( $slug ) {
			case ProviderDiscoveryModule::MODULE_ID:
				return array(
					ModuleDefinition::RESOURCE_OPTION => array( 'scheduled_changes_provider_cache_generation' ),
					ModuleDefinition::RESOURCE_WORDPRESS_HOOK => array(
						'scheduled_changes_core_services_ready',
						'scheduled_changes_field_ownership_collision',
						'scheduled_changes_field_providers',
						'scheduled_changes_provider_diagnostic_contexts',
					),
				);

			case ValidationModule::MODULE_ID:
				return array(
					ModuleDefinition::RESOURCE_TABLE => array( 'operations' ),
					ModuleDefinition::RESOURCE_WORDPRESS_HOOK => array(
						'scheduled_changes_before_validate_launch',
						'scheduled_changes_operation_types',
						'scheduled_changes_validate_external_operation',
						'scheduled_changes_validation_target_exists',
						'scheduled_changes_validation_target_subtype',
					),
				);

			case SchedulingModule::MODULE_ID:
				return array(
					ModuleDefinition::RESOURCE_ACTION_HOOK => array( 'scheduled_changes_execute_launch' ),
					ModuleDefinition::RESOURCE_UNINSTALL   => array( 'scheduled-actions' ),
					ModuleDefinition::RESOURCE_OPTION      => array( 'scheduled_changes_last_queue_activity_utc' ),
					ModuleDefinition::RESOURCE_TABLE       => array( 'launch_versions', 'launch_targets', 'launches' ),
					ModuleDefinition::RESOURCE_WORDPRESS_HOOK => array(
						'action_scheduler_before_process_queue',
					),
				);

			case ExecutionModule::MODULE_ID:
				return array(
					ModuleDefinition::RESOURCE_TABLE => array( 'locks' ),
					ModuleDefinition::RESOURCE_WORDPRESS_HOOK => array(
						'action_scheduler_after_execute',
						'action_scheduler_before_execute',
						'action_scheduler_execution_ignored',
						'action_scheduler_failed_execution',
						'scheduled_changes_after_execute_launch',
						'scheduled_changes_before_execute_launch',
						'scheduled_changes_execute_provider_operation',
						'scheduled_changes_provider_operation_handlers',
					),
				);

			case RecordingModule::MODULE_ID:
				return array(
					ModuleDefinition::RESOURCE_META      => array(
						'_scheduled_changes_creation_operation_uuid',
						'_scheduled_changes_creation_request_hash',
						'_scheduled_changes_recording_session_uuid',
						'_scheduled_changes_recording_desired_status',
						'_scheduled_changes_recording_owner_id',
						'_scheduled_changes_recording_source_id',
						'_scheduled_changes_recording_workspace_marker',
					),
					ModuleDefinition::RESOURCE_TABLE     => array( 'recording_sessions' ),
					ModuleDefinition::RESOURCE_UNINSTALL => array( 'recording-workspaces' ),
					ModuleDefinition::RESOURCE_WORDPRESS_HOOK => array(
						'scheduled_changes_recordable_targets',
						'scheduled_changes_recording_clone_strategies',
						'scheduled_changes_recording_context_ended',
						'scheduled_changes_recording_context_started',
						'scheduled_changes_recording_launch_compiler',
						'scheduled_changes_recording_workspace_adapter',
					),
				);

			case RollbackModule::MODULE_ID:
				return array(
					ModuleDefinition::RESOURCE_TABLE => array( 'snapshots' ),
					ModuleDefinition::RESOURCE_WORDPRESS_HOOK => array(
						'scheduled_changes_after_rollback_launch',
						'scheduled_changes_created_target_rollback_handlers',
					),
				);

			case AuditDiagnosticsModule::MODULE_ID:
				return array(
					ModuleDefinition::RESOURCE_MIGRATION => array(
						'initial-schema',
					),
					ModuleDefinition::RESOURCE_OPTION    => array(
						'scheduled_changes_migration_lock',
						'scheduled_changes_migration_status',
						'scheduled_changes_schema_version',
						'scheduled_changes_version',
					),
					ModuleDefinition::RESOURCE_TABLE     => array( 'audit_events', 'run_operations', 'runs' ),
					ModuleDefinition::RESOURCE_WORDPRESS_HOOK => array(
						'scheduled_changes_admin_system_rows',
						'scheduled_changes_cli_doctor_payload',
						'scheduled_changes_system_compatibility',
						'scheduled_changes_system_status_payload',
						'scheduled_changes_system_status_schema',
					),
				);

			case NativeContentModule::MODULE_ID:
				return array(
					ModuleDefinition::RESOURCE_FIELD => array( 'wordpress.content.fields' ),
					ModuleDefinition::RESOURCE_WORDPRESS_HOOK => array( 'scheduled_changes_target_reference_context' ),
				);

			case TaxonomyModule::MODULE_ID:
				return array(
					ModuleDefinition::RESOURCE_FIELD => array( 'wordpress.taxonomies' ),
					ModuleDefinition::RESOURCE_META  => array(
						'_scheduled_changes_recording_pending_term_assignments',
						'_scheduled_changes_recording_pending_terms',
					),
					ModuleDefinition::RESOURCE_WORDPRESS_HOOK => array( 'scheduled_changes_taxonomy_registrations' ),
				);

			case WordPressCategoryModule::MODULE_ID:
				return array( ModuleDefinition::RESOURCE_FIELD => array( 'wordpress.categories' ) );

			case WordPressTagModule::MODULE_ID:
				return array( ModuleDefinition::RESOURCE_FIELD => array( 'wordpress.tags' ) );

			case RegisteredMetaModule::MODULE_ID:
				return array(
					ModuleDefinition::RESOURCE_FIELD => array( 'wordpress.meta.registered' ),
					ModuleDefinition::RESOURCE_WORDPRESS_HOOK => array( 'scheduled_changes_wordpress_meta_fields' ),
				);

			case LaunchTemplatesModule::MODULE_ID:
				return array(
					ModuleDefinition::RESOURCE_CLI_COMMAND => array( 'scheduled-changes templates' ),
					ModuleDefinition::RESOURCE_WORDPRESS_HOOK => array( 'scheduled_changes_launch_templates' ),
				);

			case BundledModuleIds::REST_API:
				return array( ModuleDefinition::RESOURCE_REST_ROUTE => array( 'scheduled-changes/v1/system-status' ) );

			case BundledModuleIds::REST_LAUNCHES:
				return array(
					ModuleDefinition::RESOURCE_REST_ROUTE => array(
						'scheduled-changes/v1/launches',
						'scheduled-changes/v1/launches/(?p<uuid>[0-9a-fa-f-]{36})',
						'scheduled-changes/v1/launches/(?p<uuid>[0-9a-fa-f-]{36})/cancel',
						'scheduled-changes/v1/launches/(?p<uuid>[0-9a-fa-f-]{36})/run',
						'scheduled-changes/v1/launches/(?p<uuid>[0-9a-fa-f-]{36})/schedule',
						'scheduled-changes/v1/launches/(?p<uuid>[0-9a-fa-f-]{36})/validate',
						'scheduled-changes/v1/providers',
						'scheduled-changes/v1/targets',
					),
					ModuleDefinition::RESOURCE_WORDPRESS_HOOK => array(
						'scheduled_changes_rest_launch_row',
						'scheduled_changes_rest_launch_schema',
					),
				);

			case BundledModuleIds::REST_ROLLBACK:
				return array(
					ModuleDefinition::RESOURCE_REST_ROUTE => array( 'scheduled-changes/v1/launches/(?p<uuid>[0-9a-fa-f-]{36})/rollback' ),
				);

			case BundledModuleIds::REST_RECORDINGS:
				return array(
					ModuleDefinition::RESOURCE_REST_ROUTE => array(
						'scheduled-changes/v1/recordings',
						'scheduled-changes/v1/recordings/(?p<uuid>[0-9a-fa-f-]{36})/cancel',
						'scheduled-changes/v1/recordings/(?p<uuid>[0-9a-fa-f-]{36})/capture',
						'scheduled-changes/v1/recordings/(?p<uuid>[0-9a-fa-f-]{36})/finalize',
					),
				);

			case BundledModuleIds::WP_CLI:
				return array(
					ModuleDefinition::RESOURCE_WORDPRESS_HOOK => array( 'scheduled_changes_cli_field_scan_context' ),
				);

			case BundledModuleIds::CLI_SCHEDULING:
				return array( ModuleDefinition::RESOURCE_CLI_COMMAND => array( 'scheduled-changes launch', 'scheduled-changes queue' ) );

			case BundledModuleIds::CLI_RECORDING:
				return array( ModuleDefinition::RESOURCE_CLI_COMMAND => array( 'scheduled-changes recording' ) );

			case BundledModuleIds::CLI_PROVIDERS:
				return array( ModuleDefinition::RESOURCE_CLI_COMMAND => array( 'scheduled-changes fields', 'scheduled-changes providers' ) );

			case BundledModuleIds::CLI_DIAGNOSTICS:
				return array( ModuleDefinition::RESOURCE_CLI_COMMAND => array( 'scheduled-changes conflicts', 'scheduled-changes doctor', 'scheduled-changes logs', 'scheduled-changes migrations' ) );

			case BundledModuleIds::ADMIN_SHELL:
				return array(
					ModuleDefinition::RESOURCE_ASSET     => array( 'scheduled-changes-admin' ),
					ModuleDefinition::RESOURCE_OPTION    => array( 'scheduled_changes_activated_at', 'scheduled_changes_delete_data_on_uninstall' ),
					ModuleDefinition::RESOURCE_UNINSTALL => array( 'roles-and-capabilities', 'transient-admin-notices' ),
					ModuleDefinition::RESOURCE_WORDPRESS_HOOK => array(
						'admin_enqueue_scripts',
						'admin_menu',
						'scheduled_changes_admin_target_row',
					),
				);

			case BundledModuleIds::ADMIN_READ_ONLY:
				return array(
					ModuleDefinition::RESOURCE_WORDPRESS_HOOK => array( 'scheduled_changes_read_only_admin_screens', 'scheduled_changes_read_only_admin_screen_data_keys' ),
				);

			case BundledModuleIds::ADMIN_SCHEDULE:
				return array(
					ModuleDefinition::RESOURCE_WORDPRESS_HOOK => array(
						'scheduled_changes_admin_screens:schedule-center',
						'scheduled_changes_admin_screens:all-changes',
						'scheduled_changes_admin_screens:calendar',
						'scheduled_changes_admin_data_keys:launches',
						'scheduled_changes_admin_data_keys:calendar',
					),
				);

			case BundledModuleIds::ADMIN_RECORDING:
				return array( ModuleDefinition::RESOURCE_WORDPRESS_HOOK => array( 'admin_post_scheduled_changes_cancel_recording', 'admin_post_scheduled_changes_start_dashboard_recording' ) );

			case BundledModuleIds::ADMIN_RUN_HISTORY:
				return array( ModuleDefinition::RESOURCE_WORDPRESS_HOOK => array( 'scheduled_changes_run_history_admin_screens', 'scheduled_changes_run_history_admin_screen_data_keys' ) );

			case BundledModuleIds::ADMIN_MODULES:
				return array(
					ModuleDefinition::RESOURCE_WORDPRESS_HOOK => array(
						'scheduled_changes_admin_screens:modules',
						'scheduled_changes_admin_data_keys:adapters',
						'scheduled_changes_admin_data_keys:system',
					),
				);

			}

		return array();
	}

	private function phaseForGroup( string $group, string $slug ): string {
		if ( AuditDiagnosticsModule::MODULE_ID === $slug ) {
			return ModuleDefinition::PHASE_FOUNDATION;
		}

		if ( 'foundation' === $group ) {
			return ModuleDefinition::PHASE_FOUNDATION;
		}

		if ( 'native-wordpress' === $group ) {
			return ModuleDefinition::PHASE_PROVIDERS;
		}

		if ( 'admin' === $group || 'delivery' === $group ) {
			return ModuleDefinition::PHASE_DELIVERY;
		}

		return ModuleDefinition::PHASE_APPLICATION;
	}
}
