<?php

/**
 * Asset enquer.
 *
 * @package northmill-online-shared
 */
declare (strict_types=1);
namespace Northmill_Online_Shared_Checkout\Northmill_Online_Shared\Modules\Assets;

use Closure;
use Northmill_Online_Shared_Checkout\Northmill_Online_Shared\Modules\Abstract_Module;
use Northmill_Online_Shared_Checkout\Northmill_Online_Shared\Modules\Assets\Models\Script_Asset_Model;
use Northmill_Online_Shared_Checkout\Northmill_Online_Shared\Modules\Assets\Models\Style_Asset_Model;
defined('ABSPATH') || exit;
/**
 * Class Enquer
 */
class Enquer extends Abstract_Module
{
    /**
     * Registered scripts.
     *
     * @var array
     */
    private array $scripts = array('frontend' => array(), 'admin' => array(), 'both' => array());
    /**
     * Registered styles.
     *
     * @var array
     */
    private array $styles = array('frontend' => array(), 'admin' => array(), 'both' => array());
    /**
     * Register scripts.
     *
     * @param string              $filename            Filename.
     * @param Asset_Location_Enum $location            Where asset should be enqueued.
     * @param array               $asset_dependencies  Asset dependencies.
     * @param array|Closure|null  $plugin_localization Plugin localization.
     * @param bool|array|Closure  $should_enqueue      Whether the asset should be enqueued. Defaults to true.
     */
    public function register_script(string $filename, Asset_Location_Enum $location, array $asset_dependencies = array(), array|Closure|null $plugin_localization = null, array|Closure|bool $should_enqueue = \true, bool $is_dependency = \false): void
    {
        $this->scripts[$location->to_string()][$filename] = new Script_Asset_Model($filename, $location, $asset_dependencies, $plugin_localization, $should_enqueue, $is_dependency);
    }
    /**
     * Register styles.
     *
     * @param string              $filename           Filename.
     * @param Asset_Location_Enum $location           Where asset should be enqueued.
     * @param array               $asset_dependencies Asset dependencies.
     * @param bool|array|Closure  $should_enqueue     Whether the asset should be enqueued. Defaults to true.
     */
    public function register_style(string $filename, Asset_Location_Enum $location, array $asset_dependencies = array(), bool|array|Closure $should_enqueue = \true): void
    {
        $this->styles[$location->to_string()][$filename] = new Style_Asset_Model($filename, $location, $asset_dependencies, $should_enqueue);
    }
}
