<?php

use ModernFields\Vendor\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

defined('ABSPATH') || exit;

return function (ContainerConfigurator $container): void {
  $services = $container->services()
    ->defaults()
    ->autowire()
    ->autoconfigure()
    ->public();

  # Main plugin class
  $services->set(\ModernFields\Plugin::class);

  # FieldGroups — explicit services (not picked up by Hooks load)
  $services->set(\ModernFields\FieldGroups\Services\FieldService::class);
  $services->set(\ModernFields\FieldGroups\Services\FieldGroupsService::class);

  # Load Hooks classes
  $services->load('ModernFields\\FieldGroups\\Hooks\\', '../includes/FieldGroups/Hooks/*');
  $services->load('ModernFields\\FieldGroups\\Locations\\Hooks\\', '../includes/FieldGroups/Locations/Hooks/*');
  $services->load('ModernFields\\Settings\\Hooks\\', '../includes/Settings/Hooks/*');
  $services->load('ModernFields\\WordPress\\Hooks\\', '../includes/WordPress/Hooks/*');
  $services->load('ModernFields\\WordPress\\Endpoints\\', '../includes/WordPress/Endpoints/*');
  $services->load('ModernFields\\PostTypes\\Hooks\\', '../includes/PostTypes/Hooks/*');
  $services->load('ModernFields\\Taxonomies\\Hooks\\', '../includes/Taxonomies/Hooks/*');
  $services->load('ModernFields\\ImportExport\\Hooks\\', '../includes/ImportExport/Hooks/*');
  $services->load('ModernFields\\ImportExport\\Services\\', '../includes/ImportExport/Services/*');
  if (defined('WP_CLI') && WP_CLI) {
    $services->load('ModernFields\\CLI\\Commands\\', '../includes/CLI/Commands/*');
    $services->load('ModernFields\\CLI\\Hooks\\', '../includes/CLI/Hooks/*');
  }
  $services->load('ModernFields\\Sync\\Hooks\\', '../includes/Sync/Hooks/*');
  $services->load('ModernFields\\Sync\\Services\\', '../includes/Sync/Services/*');
};
