namespace View_by_Distance.Shared.Models.Stateless.Methods;

public interface IId
{ // ...

    string TestStatic_GetIntelligentId(Properties.IPropertyConfiguration propertyConfiguration, long id, bool ignore) =>
        GetIntelligentId(propertyConfiguration, id, ignore);
    static string GetIntelligentId(Properties.IPropertyConfiguration propertyConfiguration, long id, bool ignore) =>
        Id.GetIntelligentId(propertyConfiguration, id, ignore);

    int TestStatic_GetId(Properties.IPropertyConfiguration propertyConfiguration, string intelligentId) =>
        GetId(propertyConfiguration, intelligentId);
    static int GetId(Properties.IPropertyConfiguration propertyConfiguration, string intelligentId) =>
        Id.GetId(propertyConfiguration, intelligentId);

    string TestStatic_GetPaddedId(Properties.IPropertyConfiguration propertyConfiguration, int index, int id) =>
        GetPaddedId(propertyConfiguration, index, id);
    static string GetPaddedId(Properties.IPropertyConfiguration propertyConfiguration, int index, int id) =>
        Id.GetPaddedId(propertyConfiguration, index, id);

    bool TestStatic_IsIgnore(FilePath filePath) =>
        IsIgnore(filePath);
    static bool IsIgnore(FilePath filePath) =>
        filePath.FileNameFirstSegment[^1] is '2' or '8';

    string TestStatic_GetIgnoreFullPath(FilePath filePath, Models.FileHolder fileHolder) =>
        GetIgnoreFullPath(filePath, fileHolder);
    static string GetIgnoreFullPath(FilePath filePath, Models.FileHolder fileHolder) =>
        fileHolder.DirectoryName is null ?
            throw new NotSupportedException() :
            filePath.Id > -1 ?
                fileHolder.NameWithoutExtension[^1] == '9' ?
                    Path.Combine(fileHolder.DirectoryName, $"{fileHolder.NameWithoutExtension[..^1]}8{fileHolder.ExtensionLowered}") :
                    throw new NotSupportedException("High") :
                fileHolder.NameWithoutExtension[^1] == '1' ?
                    Path.Combine(fileHolder.DirectoryName, $"{fileHolder.NameWithoutExtension[..^1]}2{fileHolder.ExtensionLowered}") :
                    throw new NotSupportedException("Low");

    bool TestStatic_NameWithoutExtensionIsIntelligentIdFormat(Properties.IPropertyConfiguration propertyConfiguration, string fileNameFirstSegment) =>
        NameWithoutExtensionIsIntelligentIdFormat(propertyConfiguration, fileNameFirstSegment);
    static bool NameWithoutExtensionIsIntelligentIdFormat(Properties.IPropertyConfiguration propertyConfiguration, string fileNameFirstSegment) =>
        fileNameFirstSegment.Length - 1 == propertyConfiguration.IntMinValueLength && fileNameFirstSegment[^1] is '1' or '2' or '8' or '9' && fileNameFirstSegment.All(char.IsNumber);

    bool TestStatic_NameWithoutExtensionIsPaddedIntelligentIdFormat(Properties.IPropertyConfiguration propertyConfiguration, int sortOrderOnlyLengthIndex, string fileNameFirstSegment) =>
        NameWithoutExtensionIsPaddedIntelligentIdFormat(propertyConfiguration, sortOrderOnlyLengthIndex, fileNameFirstSegment);
    static bool NameWithoutExtensionIsPaddedIntelligentIdFormat(Properties.IPropertyConfiguration propertyConfiguration, int sortOrderOnlyLengthIndex, string fileNameFirstSegment) =>
        fileNameFirstSegment.Length == propertyConfiguration.IntMinValueLength + sortOrderOnlyLengthIndex + 1
        && fileNameFirstSegment[^1] is '1' or '2' or '8' or '9'
        && fileNameFirstSegment.All(char.IsNumber);

    bool TestStatic_NameWithoutExtensionIsIdFormat(Properties.IPropertyConfiguration propertyConfiguration, Models.FileHolder fileHolder) =>
        NameWithoutExtensionIsIdFormat(propertyConfiguration, fileHolder);
    static bool NameWithoutExtensionIsIdFormat(Properties.IPropertyConfiguration propertyConfiguration, Models.FileHolder fileHolder) =>
        Id.NameWithoutExtensionIsIdFormat(propertyConfiguration, fileHolder.NameWithoutExtension.Split('.')[0]);

    int TestStatic_GetDeterministicHashCode(byte[] value) =>
        GetDeterministicHashCode(value);
    static int GetDeterministicHashCode(byte[] value) =>
        Id.GetDeterministicHashCode(value);

}