<?php

use Dev4Press\v54\Core\Quick\KSES;
use function Dev4Press\v54\Functions\panel;

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

$_panel     = panel()->a()->panel_object();
$_subpanel  = panel()->a()->subpanel;
$_subpanels = panel()->subpanels();

?>
<div class="d4p-sidebar">
    <div class="d4p-panel-scroller d4p-scroll-active">
        <div class="d4p-panel-title">
            <div class="_icon">
				<?php echo KSES::strong( panel()->r()->icon( $_panel->icon ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
            </div>
            <h3><?php echo KSES::strong( $_panel->title ); ?></h3>
			<?php

			echo '<h4>' . panel()->r()->icon( $_subpanels[ $_subpanel ]['icon'] ) . esc_html__( 'All Settings', 'd4plib' ) . '</h4>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped

			?>
            <div class="_info">
				<?php

				echo esc_html( $_subpanels[ $_subpanel ]['info'] );

				if ( isset( $_subpanels[ $_subpanel ]['kb'] ) ) {
					$url   = $_subpanels[ $_subpanel ]['kb']['url'];
					$label = $_subpanels[ $_subpanel ]['kb']['label'] ?? __( 'Knowledge Base', 'd4plib' );

					?>

                    <div class="_kb">
                        <a href="<?php echo esc_url( $url ); ?>" target="_blank" rel="noopener"><?php echo esc_html( $label ); ?></a>
                    </div>

					<?php
				}

				?>
            </div>
        </div>
        <div class="d4p-panel-mark">
            <p><?php esc_html_e( 'Search through settings by typing what you need to find in this field.', 'd4plib' ); ?></p>
            <input type="text" class="widefat" id="d4p-settings-mark" aria-label="<?php esc_attr_e( 'Search Settings', 'd4plib' ); ?>"/>
            <button type="button">
                <i class="d4p-icon d4p-ui-clear" title="<?php esc_attr_e( 'Clear Search', 'd4plib' ); ?>"></i>
            </button>
        </div>
        <div class="d4p-panel-buttons">
            <input type="submit" value="<?php esc_attr_e( 'Save Settings', 'd4plib' ); ?>" class="button-primary"/>
        </div>
        <div class="d4p-return-to-top">
            <a href="#wpwrap"><?php esc_html_e( 'Return to top', 'd4plib' ); ?></a>
        </div>
    </div>
</div>
