<?php

namespace KupShop\LLMBundle\TextObjects;

use KupShop\LLMBundle\Dto\TextPromptInput;
use KupShop\LLMBundle\Enum\PromptPlaceholder;
use KupShop\LLMBundle\Enum\SystemPromptExtension;

class OrderCommentArea extends AbstractTextObject
{
    public const LABEL = 'order_comment';

    protected const DESCRIPTION = 'Objednávka / Komentář';

    protected array $SYSTEM_PROMPT_EXTENSIONS = [
        SystemPromptExtension::CKEDITOR_FORMATTING,
    ];

    public function providesPlaceholders(): array
    {
        return array_merge(parent::providesPlaceholders(), [
            PromptPlaceholder::ORDER_DATA,
            PromptPlaceholder::ORDER_HISTORY,
            PromptPlaceholder::ADMIN_INFO,
        ]);
    }

    protected function setPromptPlaceholders(TextPromptInput $prompt, ?string $entityType, ?int $entityId): void
    {
        if ($entityType == 'orders' && $entityId) {
            $order = new \Order();
            $order->createFromDB($entityId);
            $prompt->replacePlaceholder(PromptPlaceholder::ORDER_DATA, $this->placeholdersCreator->getOrderData($order));
            $prompt->replacePlaceholder(PromptPlaceholder::ORDER_HISTORY, $this->placeholdersCreator->getOrderHistory($order));
            $prompt->replacePlaceholder(PromptPlaceholder::ADMIN_INFO, $this->placeholdersCreator->getAdminUserInfo());
        }
    }
}
