<?php
/**
 * WeCodeArt Framework
 *
 * WARNING: This file is part of the core WeCodeArt Framework. DO NOT edit this file under any circumstances.
 * Please do all modifications in the form of a child theme.
 *
 * @package		WeCodeArt Framework
 * @subpackage  Gutenberg CSS Frontend
 * @copyright   Copyright (c) 2025, WeCodeArt Framework
 * @since		5.0.0
 * @version		6.6.1
 */

namespace WeCodeArt\Gutenberg\Styles\Blocks;

defined( 'ABSPATH' ) || exit;

use WeCodeArt\Singleton;
use WeCodeArt\Gutenberg\Styles\Processor;
use function WeCodeArt\Functions\get_prop;

/**
 * Block CSS Processor
 */
class Media extends Processor {
	/**
	 * Parses an output and creates the styles array for it.
	 *
	 * @return 	void
	 */
	protected function process_style(): void {
		$selector 		= $this->get_selector( '> .wp-block-media-text__media' );
		$declarations 	= [];
		
		// Handle width
		if ( $value = get_prop( $this->attrs, 'mediaWidth' ) ) {
			$this->add_declarations( [
				'grid-template-columns' => get_prop( $this->attrs, 'mediaPosition', 'left' ) === 'right' ? "auto {$value}%" : "{$value}% auto",
			] );
		}

		if( ! empty( $declarations ) ) {
			$this->add_declarations( $declarations, $selector );
		}

		parent::process_style();
	}
}