<?php
declare( strict_types=1 );

use FiboFilters\Config\Env;

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

$fibofilters_debug_tabs = [
	[
		'slug'  => 'filters',
		'title' => 'Filters',
	],
	[
		'slug'  => 'indexer',
		'title' => 'Indexer',
	],
	[
		'slug'  => 'maintenance',
		'title' => 'Maintenance',
	],
	[
		'slug'  => 'integrations',
		'title' => 'Integrations',
	],
];
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$fibofilters_current_tab = isset( $_GET['tab'] ) ? sanitize_key( $_GET['tab'] ) : $fibofilters_debug_tabs[0]['slug'];
?>
	<script>
		window.fiboFiltersNotications = [];
	</script>
	<div id="fibofilters-debug-notifications" class="fibofilters"></div>
	<div class="content-wrapper">
		<div id="fibofilters-debug" class="fibofilters fibofilters-debug">
			<div class="interface-interface-skeleton">
				<div class="interface-interface-skeleton__editor">
					<div class="interface-navigable-region interface-interface-skeleton__header" aria-label="Header" role="region" tabindex="-1">
						<div class="fibofilters-header">
							<div class="fibofilters-header__navigable-toolbar-wrapper">
								<h1 class="fibofilters-header__title">
									<img class="fibofilters-header__title_logo" src="<?php echo esc_url( Env::$build_url ); ?>/admin/images/fibofilters-logo.a09f81b8.png" alt="FiboFilters">
								</h1>
								<span class="fibofilters-header__title_subtitle">Debug page</span>
							</div>
						</div>
					</div>
					<div class="interface-interface-skeleton__body">
						<div class="interface-navigable-region interface-interface-skeleton__content" aria-label="Content" role="region" tabindex="-1">
							<div class="fibofilters-settings-tab">
								<div role="tablist" aria-orientation="horizontal" class="components-tab-panel__tabs">
									<?php
									foreach ( $fibofilters_debug_tabs as $fibofilters_debug_tab ) {
										?>
										<a href="
										<?php
										echo esc_url(
											add_query_arg(
												[
													'page' => 'fibofilters-debug',
													'tab'  => $fibofilters_debug_tab['slug'],
												],
												admin_url( 'admin.php' )
											)
										);
										?>
									" class="components-button components-tab-panel__tabs-item <?php echo $fibofilters_current_tab === $fibofilters_debug_tab['slug'] ? 'is-active' : ''; ?>">
											<?php echo esc_html( $fibofilters_debug_tab['title'] ); ?>
										</a>
										<?php
									}
									?>
								</div>
								<div role="tabpanel" class="components-tab-panel__tab-content">
										<?php
										$fibofilters_tab_file = sprintf( Env::$path . '/partials/views/admin/debug/%s.php', $fibofilters_current_tab );
										if ( file_exists( $fibofilters_tab_file ) ) {
											require_once $fibofilters_tab_file;
										}
										?>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
<?php
