using Tiku.Application.Growth;
using Tiku.Application.Security;
using Tiku.Infrastructure.Persistence;
namespace Tiku.Infrastructure.Growth;

internal sealed record ReferralServiceDependencies(
    IGrowthPersistence GrowthPersistence,
    ICommercePersistence CommercePersistence,
    IIdentityPersistence IdentityPersistence,
    IReferralQrcodeGenerator QrcodeGenerator,
    ICurrentAccessContext CurrentAccessContext);

internal abstract partial class ReferralServiceBase(ReferralServiceDependencies dependencies)
{
    protected IGrowthPersistence growthPersistence { get; } = dependencies.GrowthPersistence;
    protected ICommercePersistence commercePersistence { get; } = dependencies.CommercePersistence;
    protected IIdentityPersistence identityPersistence { get; } = dependencies.IdentityPersistence;
    protected IReferralQrcodeGenerator qrcodeGenerator { get; } = dependencies.QrcodeGenerator;
    protected ICurrentAccessContext currentAccessContext { get; } = dependencies.CurrentAccessContext;
    protected static readonly HashSet<string> AllowedEventTypes = new(StringComparer.OrdinalIgnoreCase)
    {
        "enter",
        "register",
        "purchase",
        "share",
        "scan",
        "manual_bind"
    };

    protected static readonly HashSet<string> AllowedSources = new(StringComparer.OrdinalIgnoreCase)
    {
        "share",
        "qrcode",
        "timeline",
        "miniapp",
        "h5",
        "manual",
        "unknown"
    };
}
