<?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\Blocks
 * @copyright   Copyright (c) 2025, WeCodeArt Framework
 * @since		6.3.5
 * @version		6.3.7
 */

namespace WeCodeArt\Gutenberg\Blocks;

defined( 'ABSPATH' ) || exit;

use WeCodeArt\Singleton;
use WeCodeArt\Gutenberg\Blocks\Dynamic;
use function WeCodeArt\Functions\get_prop;

/**
 * Gutenberg Query Pagination block.
 */
class Query extends Dynamic {

	use Singleton;

    /**
	 * Block namespace.
	 *
	 * @var string
	 */
	protected $namespace = 'core';

	/**
	 * Block name.
	 *
	 * @var string
	 */
	protected $block_name = 'query';

    /**
	 * Block args.
	 *
	 * @param	array $current	Existing register args
	 *
	 * @return 	array
	 */
	public function block_type_args( array $current ): array {
		$supports 	= get_prop( $current, [ 'supports' ], [] );

		return [
			'supports'	=> wp_parse_args( [
				'spacing'	=> [
					'margin'	=> true,
					'padding'	=> true,
					'blockGap'	=> true,
					'__experimentalDefaultControls' => [
						'margin'	=> false,
						'padding'	=> false,
						'blockGap'	=> true,
					]
				],
			], $supports )
		];
	}

    /**
	 * Block styles
	 *
	 * @return 	string 	The block styles.
	 */
	public function styles() {
		return "
            *[class*='pagination-animation'] {
                position: fixed;
                top: 0;
                left: 0;
                height: 4px;
                width: 100vw;
                max-width: 100vw;
                margin: 0!important;
                padding: 0!important;
                opacity: 0;
            }
            *[class*='pagination-animation'].start-animation {
                animation: wp-pagination-start-animation 30s cubic-bezier(0.03, 0.5, 0, 1) forwards;
            }
            *[class*='pagination-animation'].finish-animation {
                animation: wp-pagination-finish-animation 0.3s ease-in;
            }
            :is(.wp-interactivity-router-loading-bar.wp-interactivity-router-loading-bar, *[class*='pagination-animation']) {
                background-color: var(--wp--preset--color--primary, #000);
                z-index: 1050;
            }

            @keyframes wp-pagination-start-animation {
                0% {
                    opacity: 1;
                    transform: scaleX(0);
                    transform-origin: 0 0;
                }
                to {
                    opacity: 1;
                    transform: scaleX(1);
                    transform-origin: 0 0;
                }
            }
            @keyframes wp-pagination-finish-animation {
                0% {
                    opacity: 1;
                }
                50% {
                    opacity: 1;
                }
                to {
                    opacity: 0;
                }
            }
		";
	}
}