<?php

namespace WPSN\Domain;

defined('ABSPATH') || exit;

final class SeoMeta
{
    public string $title;

    public string $description;

    /**
     * Canonical URL (absolute). Empty string means: do not output.
     */
    public string $canonical;

    /**
     * Robots directives in a normalized form.
     *
     * Supported keys (Stage 2):
     *  - noindex (bool)
     *  - nofollow (bool)
     *  - max-image-preview (string)
     *  - max-snippet (string)
     *  - max-video-preview (string)
     *  - noarchive (bool)
     *  - nosnippet (bool)
     *
     * @var array<string, string|bool>
     */
    public array $robots;

    /**
     * OpenGraph (and Twitter fallback) title.
     */
    public string $ogTitle;

    /**
     * OpenGraph (and Twitter fallback) description.
     */
    public string $ogDescription;

    /**
     * OpenGraph (and Twitter fallback) image URL (absolute). Empty string means: do not output.
     */
    public string $ogImage;

    /**
     * Twitter title (falls back to OpenGraph title).
     */
    public string $twitterTitle;

    /**
     * Twitter description (falls back to OpenGraph description).
     */
    public string $twitterDescription;

    /**
     * Twitter image URL (absolute). Falls back to OpenGraph image. Empty string means: do not output.
     */
    public string $twitterImage;

    /**
     * @param array<string, string|bool> $robots
     */
    public function __construct(
        string $title = '',
        string $description = '',
        string $canonical = '',
        array $robots = [],
        string $ogTitle = '',
        string $ogDescription = '',
        string $ogImage = '',
        string $twitterTitle = '',
        string $twitterDescription = '',
        string $twitterImage = ''
    ) {
        $this->title       = $title;
        $this->description = $description;
        $this->canonical   = $canonical;

        $this->robots = array_merge([
            'noindex'           => false,
            'nofollow'          => false,
            'max-image-preview' => 'large',
            'max-snippet'       => '-1',
            'max-video-preview' => '-1',
            'noarchive'         => false,
            'nosnippet'         => false,
        ], $robots);

        $this->ogTitle = $ogTitle;
        $this->ogDescription = $ogDescription;
        $this->ogImage = $ogImage;

        $this->twitterTitle = $twitterTitle;
        $this->twitterDescription = $twitterDescription;
        $this->twitterImage = $twitterImage;
    }
}
