<?php

declare(strict_types=1);

namespace App\Entity;

use App\Repository\IngestProfileRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;

#[ORM\Entity(repositoryClass: IngestProfileRepository::class)]
#[ORM\Table(name: 'ingest_profile')]
class IngestProfile
{
    #[ORM\Id]
    #[ORM\Column(type: 'uuid', unique: true)]
    private Uuid $id;

    #[ORM\Column(type: 'integer')]
    private int $version;

    #[ORM\Column(type: 'integer')]
    private int $chunkSize;

    #[ORM\Column(type: 'integer')]
    private int $chunkOverlap;

    #[ORM\Column(type: 'string', length: 255)]
    private string $embeddingModel;

    #[ORM\Column(type: 'integer')]
    private int $embeddingDimension;

    #[ORM\Column(type: 'integer')]
    private int $scoringVersion;

    #[ORM\Column(type: 'boolean')]
    private bool $active = false;

    #[ORM\Column(type: 'boolean')]
    private bool $reindexRequired = true;

    #[ORM\Column(type: 'datetime_immutable')]
    private \DateTimeImmutable $createdAt;

    public function __construct(
        int $version,
        int $chunkSize,
        int $chunkOverlap,
        string $embeddingModel,
        int $embeddingDimension,
        int $scoringVersion
    ) {
        $this->id = Uuid::v4();
        $this->version = $version;
        $this->chunkSize = $chunkSize;
        $this->chunkOverlap = $chunkOverlap;
        $this->embeddingModel = $embeddingModel;
        $this->embeddingDimension = $embeddingDimension;
        $this->scoringVersion = $scoringVersion;
        $this->createdAt = new \DateTimeImmutable();
    }

    public function getId(): Uuid { return $this->id; }
    public function getVersion(): int { return $this->version; }
    public function getChunkSize(): int { return $this->chunkSize; }
    public function getChunkOverlap(): int { return $this->chunkOverlap; }
    public function getEmbeddingModel(): string { return $this->embeddingModel; }
    public function getEmbeddingDimension(): int { return $this->embeddingDimension; }
    public function getScoringVersion(): int { return $this->scoringVersion; }
    public function isActive(): bool { return $this->active; }
    public function isReindexRequired(): bool { return $this->reindexRequired; }
    public function getCreatedAt(): \DateTimeImmutable { return $this->createdAt; }

    public function activate(): void
    {
        $this->active = true;
        $this->reindexRequired = true;
    }

    public function deactivate(): void
    {
        $this->active = false;
    }

    public function markReindexDone(): void
    {
        $this->reindexRequired = false;
    }
}
