<?php

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

$wpcb_actions = carbon_get_post_meta( $wpcb_configuration_id, 'gallery_actions' ) ?: array();

$wpcb_action_classes = '';
if ( 'right' === get_post_meta( $wpcb_configuration_id, '_gallery_actions_position', true ) ) {
	$wpcb_action_classes .= ' wpcb-configurator-gallery-actions-right';
}
if ( wpcb_get_option( 'wpcb_border_style' ) ) {
	$wpcb_action_classes .= ' wpcb-border-' . wpcb_get_option( 'wpcb_border_style' );
}

if ( count( $wpcb_actions ) > 0 ) :
	?>
	<div class="wpcb-configurator-gallery-actions<?php echo esc_attr( $wpcb_action_classes ); ?>">
		<?php 
		$suffix = wpcb_get_i18n_suffix();

		if ( in_array( 'fullscreen', $wpcb_actions ) ) :
			$fullscreen_label = wpcb_get_option( 'wpcb_button_fullscreen_text', $suffix ) ?: __( 'Fullscreen', 'wcb-configurator-builder' );
			?>
			<button class="wpcb-configurator-gallery-action fullscreen">
				<div class="default">
					<?php echo wp_kses( wpcb_get_icon( 'fullscreen' ), wpcb_get_icon_kses_args() ); ?>
				</div>
				<div class="active">
					<?php echo wp_kses( wpcb_get_icon( 'fullscreen-exit' ), wpcb_get_icon_kses_args() ); ?>
				</div>
				<span class="wpcb-configurator-gallery-action-label">
					<?php echo esc_attr( $fullscreen_label ); ?>
				</span>
			</button>
			<?php
		endif;

		if ( in_array( 'capture', $wpcb_actions ) ) :
			$capture_label = wpcb_get_option( 'wpcb_button_capture_text', $suffix ) ?: __( 'Capture image', 'wcb-configurator-builder' );
			?>
			<button class="wpcb-configurator-gallery-action capture-image">
				<?php echo wp_kses( wpcb_get_icon( 'camera' ), wpcb_get_icon_kses_args() ); ?>
				<span class="wpcb-configurator-gallery-action-label">
					<?php echo esc_attr( $capture_label ); ?>
				</span>
			</button>
			<?php
		endif;

		if ( in_array( 'dimensions', $wpcb_actions ) ) :
			$dimensions_label = wpcb_get_option( 'wpcb_button_dimensions_text', $suffix ) ?: __( 'Show/hide dimensions', 'wcb-configurator-builder' );
			?>
			<button class="wpcb-configurator-gallery-action toggle-dims">
				<?php echo wp_kses( wpcb_get_icon( 'dimensions' ), wpcb_get_icon_kses_args() ); ?>
				<span class="wpcb-configurator-gallery-action-label">
					<?php echo esc_attr( $dimensions_label ); ?>
				</span>
			</button>
			<?php
		endif;

		if ( in_array( 'reset', $wpcb_actions ) ) :
			$reset_view_label = wpcb_get_option( 'wpcb_button_reset_view_text', $suffix ) ?: __( 'Reset camera view', 'wcb-configurator-builder' );
			?>
			<button class="wpcb-configurator-gallery-action reset-view">
				<?php echo wp_kses( wpcb_get_icon( 'reset-view' ), wpcb_get_icon_kses_args() ); ?>
				<span class="wpcb-configurator-gallery-action-label">
					<?php echo esc_attr( $reset_view_label ); ?>
				</span>
			</button>
			<?php
		endif;

		if ( in_array( 'info', $wpcb_actions ) && function_exists( 'wpcb_configurator_gallery_info_button' ) ) :
			wpcb_configurator_gallery_info_button();
		endif;

		if ( in_array( 'qr', $wpcb_actions ) && function_exists( 'wpcb_configurator_gallery_qr_button' ) ) :
			wpcb_configurator_gallery_qr_button();
		endif;
		?>
	</div>
	<?php
endif;
