using System.Collections.Generic;

namespace ZB.MOM.WW.MxGateway.Worker.Conversion;

internal static class MxStatusDetailText
{
    private static readonly IReadOnlyDictionary<int, string> KnownDetails = new Dictionary<int, string>
    {
        [16] = "Request timed out",
        [17] = "Platform communication error",
        [18] = "Invalid platform ID",
        [19] = "Invalid engine ID",
        [20] = "Engine communication error",
        [21] = "Invalid reference",
        [22] = "No Galaxy Repository",
        [23] = "Invalid object ID",
        [24] = "Object signature mismatch",
        [25] = "Invalid primitive ID",
        [26] = "Invalid attribute ID",
        [27] = "Invalid property ID",
        [28] = "Index out of range",
        [29] = "Data out of range",
        [30] = "Incorrect data type",
        [31] = "Attribute not readable",
        [32] = "Attribute not writeable",
        [33] = "Write access denied",
        [34] = "Unknown error",
        [36] = "Wrong data type",
        [37] = "Wrong number of dimensions",
        [38] = "Invalid index",
        [39] = "Index out of order",
        [40] = "Dimension does not exist",
        [41] = "Conversion not supported",
        [42] = "Unable to convert string",
        [43] = "Overflow",
        [44] = "Attribute signature mismatch",
        [47] = "Nmx version mismatch",
        [48] = "Nmx command not valid",
        [49] = "Lmx version mismatch",
        [50] = "Lmx command not valid",
        [56] = "Secured Write",
        [57] = "Verified Write",
        [60] = "User did not have the necessary permissions to write",
        [61] = "Verifier did not have the necessary permissions to verify",
        [541] = "Conversion to intended data type is not supported",
        [542] = "Unable to convert the input string to intended data type",
        [8017] = "Object must be offscan to modify attributes that have an MxSecurityConfigure security classification",
    };

    /// <summary>Looks up the text description for an MXAccess status detail code.</summary>
    /// <param name="detail">Status detail code.</param>
    /// <returns>Description text if found; otherwise empty string.</returns>
    public static string Lookup(int detail)
    {
        return KnownDetails.TryGetValue(detail, out string text) ? text : string.Empty;
    }
}
