<?php
/**
 * Main plugin orchestrator.
 *
 * @package AccessLens
 */

declare(strict_types=1);

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

/**
 * AccessLens_Plugin — singleton entry point.
 */
final class AccessLens_Plugin {

	/** @var AccessLens_Plugin|null */
	private static ?AccessLens_Plugin $instance = null;

	/** @var AccessLens_Admin */
	private AccessLens_Admin $admin;

	/** @var AccessLens_Ajax */
	private AccessLens_Ajax $ajax;

	private function __construct() {
		AccessLens_Options::maybe_set_installed_at();

		$this->admin = new AccessLens_Admin();
		$this->ajax  = new AccessLens_Ajax( new AccessLens_Engine_Client() );

		$this->admin->register();
		$this->ajax->register();
		// Note: load_plugin_textdomain() is called separately on 'init' in the
		// main plugin file (accesslens.php), not here.
	}

	/**
	 * Get or create singleton instance.
	 */
	public static function get_instance(): self {
		if ( null === self::$instance ) {
			self::$instance = new self();
		}
		return self::$instance;
	}

}
