<?php
/**
 * REST bucket loader: require_once for services, router, handlers, Rest class.
 * Loaded on rest_api_init via fotogenic_ai_load_rest_bucket() so routes register reliably.
 *
 * @package Fotogenic_AI
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

$fotogenic_ai_path = FOTOGENIC_AI_PATH;

/*
 * WordPress can overwrite an active plugin before the update request ends.
 * Public 1.0.5 may leave its earlier interfaces and callbacks in memory, so
 * loading current REST services in that request would mix incompatible PHP
 * contracts. Install a no-op REST boundary for only that request. The next
 * request starts from the complete current plugin and loads this bucket below.
 */
$fotogenic_ai_legacy_product_contract = interface_exists( 'Fotogenic_AI\\ProductQueryAdapter', false )
	&& ! method_exists( 'Fotogenic_AI\\ProductQueryAdapter', 'scan_products' );
if ( $fotogenic_ai_legacy_product_contract ) {
	require_once $fotogenic_ai_path . 'includes/rest/class-rest-update-bridge.php';
	unset( $fotogenic_ai_legacy_product_contract );
	return;
}
unset( $fotogenic_ai_legacy_product_contract );

require_once $fotogenic_ai_path . 'includes/core/services/class-service-configuration.php';
require_once $fotogenic_ai_path . 'includes/core/services/class-service-credits.php';
require_once $fotogenic_ai_path . 'includes/core/services/class-service-experiences.php';
require_once $fotogenic_ai_path . 'includes/core/services/class-service-presets.php';
require_once $fotogenic_ai_path . 'includes/core/services/class-service-library.php';
require_once $fotogenic_ai_path . 'includes/core/services/class-service-history.php';
require_once $fotogenic_ai_path . 'includes/core/services/class-service-bulk.php';
require_once $fotogenic_ai_path . 'includes/core/services/generate/class-generate-image-builder.php';
require_once $fotogenic_ai_path . 'includes/core/services/generate/class-generate-terminal-reconciler.php';
require_once $fotogenic_ai_path . 'includes/core/services/generate/class-service-generate-start.php';
require_once $fotogenic_ai_path . 'includes/core/services/generate/class-service-generate-poll.php';
require_once $fotogenic_ai_path . 'includes/core/services/generate/class-service-generate-active.php';
require_once $fotogenic_ai_path . 'includes/core/services/generate/class-service-generate-configuration.php';
require_once $fotogenic_ai_path . 'includes/core/services/generate/class-service-generate-save.php';
require_once $fotogenic_ai_path . 'includes/core/services/generate/class-service-generate-remove.php';
require_once $fotogenic_ai_path . 'includes/core/services/workflows/class-campaign-set-recipe.php';
require_once $fotogenic_ai_path . 'includes/core/services/workflows/class-generate-images-multipart-builder.php';
require_once $fotogenic_ai_path . 'includes/core/services/workflows/class-campaign-set-multipart-builder.php';
require_once $fotogenic_ai_path . 'includes/core/services/workflows/class-increase-resolution-multipart-builder.php';
require_once $fotogenic_ai_path . 'includes/core/services/workflows/class-workflow-draft-normalizer.php';
require_once $fotogenic_ai_path . 'includes/core/services/workflows/class-workflow-source-preflight.php';
require_once $fotogenic_ai_path . 'includes/core/services/workflows/class-workflow-configuration-authority.php';
require_once $fotogenic_ai_path . 'includes/core/services/workflows/class-workflow-accepted-authority.php';
require_once $fotogenic_ai_path . 'includes/core/services/workflows/class-workflow-preflight.php';
require_once $fotogenic_ai_path . 'includes/core/services/workflows/class-workflow-start-coordinator.php';
require_once $fotogenic_ai_path . 'includes/core/services/workflows/class-universal-start-service.php';
require_once $fotogenic_ai_path . 'includes/core/services/workflows/class-service-campaign-set-start.php';
require_once $fotogenic_ai_path . 'includes/core/services/workflows/class-service-increase-resolution-start.php';
require_once $fotogenic_ai_path . 'includes/rest/class-rest-router.php';
require_once $fotogenic_ai_path . 'includes/rest/class-rest-result-request-decoder.php';
require_once $fotogenic_ai_path . 'includes/rest/handlers/class-rest-studio-run.php';
require_once $fotogenic_ai_path . 'includes/rest/handlers/class-rest-studio-results.php';
require_once $fotogenic_ai_path . 'includes/rest/handlers/class-rest-configuration.php';
require_once $fotogenic_ai_path . 'includes/rest/handlers/class-rest-credits.php';
require_once $fotogenic_ai_path . 'includes/rest/handlers/class-rest-experiences.php';
require_once $fotogenic_ai_path . 'includes/rest/handlers/class-rest-auth.php';
require_once $fotogenic_ai_path . 'includes/rest/handlers/class-rest-library.php';
require_once $fotogenic_ai_path . 'includes/rest/handlers/class-rest-history.php';
require_once $fotogenic_ai_path . 'includes/rest/handlers/class-rest-studio-bulk.php';
require_once $fotogenic_ai_path . 'includes/rest/handlers/class-rest-studio-store-queue.php';
require_once $fotogenic_ai_path . 'includes/rest/handlers/class-rest-admin.php';
require_once $fotogenic_ai_path . 'includes/rest/handlers/class-rest-studio.php';
require_once $fotogenic_ai_path . 'includes/rest/handlers/class-rest-studio-media.php';
require_once $fotogenic_ai_path . 'includes/rest/handlers/class-rest-studio-post.php';
require_once $fotogenic_ai_path . 'includes/rest/handlers/class-rest-studio-page.php';
require_once $fotogenic_ai_path . 'includes/rest/handlers/workflows/class-rest-universal-studio.php';
require_once $fotogenic_ai_path . 'includes/rest/handlers/class-studio-cache-invalidator.php';
require_once $fotogenic_ai_path . 'includes/rest/class-rest.php';
