using System.Text.RegularExpressions;
using Tiku.Application.Content;
using Tiku.Application.QuestionBanks;
using Tiku.Application.Security;
using Tiku.Infrastructure.Persistence;

namespace Tiku.Infrastructure.Content;

public sealed partial class DirectContentService(
    TikuDbContext dbContext,
    IQuestionReferenceService questionReferenceService,
    ICurrentAccessContext currentAccessContext,
    IFeatureAccessService featureAccessService) : IDirectContentService
{
    private const int DefaultLimit = 100;
    private const int MaxLimit = 1000;

    private static readonly string[] ContentPermissions =
    [
        BackendPermissions.TenantContentManage,
        BackendPermissions.TenantVocabularyManage,
        BackendPermissions.TenantHandbookManage,
        BackendPermissions.TenantVideoManage,
        BackendPermissions.TenantScorelineManage,
        BackendPermissions.TenantSiteContentManage,
        BackendPermissions.TenantJobManage
    ];

    private static readonly Regex ScorelineFieldKeyRegex = new("^[A-Za-z][A-Za-z0-9_]{0,63}$", RegexOptions.Compiled);

    private static readonly HashSet<string> SupportedImportTypes = new(StringComparer.OrdinalIgnoreCase)
    {
        "questions",
        "vocabulary",
        "handbook",
        "scoreline",
        "videos"
    };
}