<?php

declare(strict_types=1);

namespace TechnoArtisan\FilamentCms\Csp\Presets;

use Spatie\Csp\Directive;
use Spatie\Csp\Keyword;
use Spatie\Csp\Policy;
use Spatie\Csp\Preset;

class Matomo implements Preset
{
    public function configure(Policy $policy): void
    {
        $matomoUrl = 'http://mt.c75x.de'; // Matomo-Domain

        $policy
            ->add(Directive::BASE, Keyword::SELF)
            ->add(Directive::CONNECT, [$matomoUrl]) // for API-cals
            ->add(Directive::FONT, Keyword::SELF)
            ->add(Directive::IMG, [$matomoUrl, Keyword::SELF]) // for Tracking-Pixel
            ->add(Directive::SCRIPT, [$matomoUrl, Keyword::SELF]) // for matomo.js
            ->add(Directive::STYLE, Keyword::SELF);
    }
}
