namespace NATS.Server.Auth;

public sealed class AccountConfig
{
    public int MaxConnections { get; init; }      // 0 = unlimited
    public int MaxSubscriptions { get; init; }    // 0 = unlimited
    public Permissions? DefaultPermissions { get; init; }

    /// <summary>Service and stream exports from this account.</summary>
    public List<ExportDefinition>? Exports { get; init; }

    /// <summary>Service and stream imports into this account.</summary>
    public List<ImportDefinition>? Imports { get; init; }
}

/// <summary>
/// Represents an export declaration in config: exports = [{ service: "sub" }] or [{ stream: "sub" }].
/// Go reference: server/opts.go — parseExportStreamMap / parseExportServiceMap.
/// </summary>
public sealed class ExportDefinition
{
    public string? Service { get; init; }
    public string? Stream { get; init; }

    /// <summary>Optional latency tracking subject (e.g. "latency.svc.echo").</summary>
    public string? LatencySubject { get; init; }

    /// <summary>Latency sampling percentage (1–100, default 100).</summary>
    public int LatencySampling { get; init; } = 100;
}

/// <summary>
/// Represents an import declaration in config:
/// imports = [{ service: { account: X, subject: "sub" }, to: "local" }].
/// Go reference: server/opts.go — parseImportStreamMap / parseImportServiceMap.
/// </summary>
public sealed class ImportDefinition
{
    public string? ServiceAccount { get; init; }
    public string? ServiceSubject { get; init; }
    public string? StreamAccount { get; init; }
    public string? StreamSubject { get; init; }
    public string? To { get; init; }
}
