<?php

declare(strict_types=1);

namespace App\Services\WebStories;

use App\Models\WorldWebStory;
use App\Support\Seo\SeoFactory;

final class WorldWebStorySeoService
{
    public function __construct(private readonly SeoFactory $seo)
    {
    }

    public function indexSeo(): array
    {
        return $this->seo->collectionListing(
            'Skinbase Web Stories',
            'Explore Skinbase Web Stories featuring digital art Worlds, wallpapers, creator highlights, seasonal collections, and visual stories from the Skinbase community.',
            route('web-stories.index'),
        )->toArray();
    }

    /**
     * @return array<string, string>
     */
    public function storyMeta(WorldWebStory $story): array
    {
        $title = $story->seoTitle();
        $description = $story->seoDescription();

        return [
            'title' => $title,
            'description' => $description,
            'canonical' => $story->publicUrl(),
            'robots' => $story->noindex ? 'noindex,follow' : 'index,follow,max-image-preview:large',
            'og_title' => $title,
            'og_description' => $description,
            'og_url' => $story->publicUrl(),
            'og_image' => (string) $story->posterPortraitUrl(),
            'twitter_title' => $title,
            'twitter_description' => $description,
            'twitter_image' => (string) $story->posterPortraitUrl(),
        ];
    }
}