<?php

namespace KupShop\ArticlesBundle\Twig\Components\Articles;

use KupShop\ArticlesBundle\Twig\Components\Articles\Utils\ArticleTrait;
use KupShop\ComponentsBundle\Attributes\Component;
use KupShop\ComponentsBundle\Attributes\Version;
use KupShop\ComponentsBundle\Twig\BaseComponent;
use KupShop\KupShopBundle\Context\DomainContext;
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;

#[AsTwigComponent(template: '@Articles/components/Articles/ShareVertical/ShareVertical.1.html.twig')]
#[Component(1, [
    new Version(1, newJs: null),
])]
class ShareVertical extends BaseComponent
{
    use ArticleTrait {
        getUrl as getBaseUrl;
    }
    public int $id;
    public ?array $image = null;
    public string $title;
    public bool $hideFacebook = false;
    public bool $hideX = false;
    public bool $hidePinterest = false;

    public function __construct(private readonly DomainContext $domainContext)
    {
    }

    public function getUrl(): string
    {
        return $this->getBaseUrl($this->id, null, 'article', 'IDa', 1);
    }

    public function getShareImage()
    {
        if (!$this->image) {
            return '';
        }

        return "{$this->domainContext->getActiveId()}{$this->image['src']}";
    }
}
