namespace NATS.Server.Protocol;

public sealed class ClientCommandMatrix
{
    public bool IsAllowed(global::NATS.Server.ClientKind kind, string? op)
    {
        if (string.IsNullOrWhiteSpace(op))
            return true;

        return (kind, op.ToUpperInvariant()) switch
        {
            (global::NATS.Server.ClientKind.Router, "RS+") => true,
            (global::NATS.Server.ClientKind.Router, "RS-") => true,
            (global::NATS.Server.ClientKind.Router, "RMSG") => true,
            (global::NATS.Server.ClientKind.Gateway, "A+") => true,
            (global::NATS.Server.ClientKind.Gateway, "A-") => true,
            (global::NATS.Server.ClientKind.Leaf, "LS+") => true,
            (global::NATS.Server.ClientKind.Leaf, "LS-") => true,
            (global::NATS.Server.ClientKind.Leaf, "LMSG") => true,
            (_, "RS+") => false,
            (_, "RS-") => false,
            (_, "RMSG") => false,
            (_, "A+") => false,
            (_, "A-") => false,
            (_, "LS+") => false,
            (_, "LS-") => false,
            (_, "LMSG") => false,
            _ => true,
        };
    }
}
