<?php

declare(strict_types=1);

namespace PpPhp\Core\Assets;

final class AssetPackage
{
    /**
     * @param string[] $dependencies
     */
    public function __construct(
        public readonly string $id,
        public readonly string $label,
        public readonly string $version,
        public readonly array $dependencies = [],
        public readonly AssetCollection $assets = new AssetCollection()
    ) {}

    public function addCss(string $path, array $attributes = [], int $priority = 100): self
    {
        $this->assets->add(Asset::css($path, $attributes, $priority));
        return $this;
    }

    public function addJs(
        string $path,
        string $location = 'footer',
        array $attributes = [],
        int $priority = 100
    ): self {
        $this->assets->add(Asset::js($path, $location, $attributes, $priority));
        return $this;
    }
}
