using e_suite.API.Common.models;
using e_suite.Database.Audit;
using e_suite.Service.SigmaImporter.Extensions;
using eSuite.Core.CustomFields;

namespace e_suite.Service.SigmaImporter.PrintSpecifications;

public partial class PrintSpecificationImporter
{
    private readonly Guid _barcodeCommentsGuid = new("965030b7-6b67-4252-b0f2-be1775d11be6");
    private readonly Guid _bwrGuid = new("33603b50-22a3-4cd0-9c1c-d3fac9307bf0");
    private readonly Guid _colours = new("68b1b91c-3b28-47d5-a0a5-17cc72ddcf16");
    private readonly Guid _digitalSupplyMethodGuid = new("a226a708-9e34-422f-a6d7-17f052ef341e");
    private readonly Guid _digitalSupplyCommentsGuid = new("a485041e-49d7-4d51-9c03-572c4728bf2e");
    private readonly Guid _gmgProfileGuid = new("f31edd64-1c41-460c-b4fe-8c47368a782c");
    private readonly Guid _maxDotGuid = new("aa6d4458-2102-4908-ae8f-44dbb04dc6ce");
    private readonly Guid _minDotGuid = new("11015c9b-db6b-4463-9fe5-73ff4f4cce29");
    private readonly Guid _maxInkGuid = new("f5e9d90e-a92c-4765-aba5-23e960a2a73e");
    private readonly Guid _minMagGuid = new("bdef0f6d-fdb0-4cb3-9c66-875190158fa8");
    private readonly Guid _minMultiInkFontGuid = new("adb9ad71-e677-4885-8fd2-745ec56b00ea");
    private readonly Guid _minMultiInkLineGuid = new("2ff3ba40-bf9f-47d7-bcc3-7fde507cb530");
    private readonly Guid _minNegFontGuid = new("7728e67e-d773-4e09-8ec8-fde37d3257a9");
    private readonly Guid _minNegLineGuid = new("c6c47e29-04f1-4293-9540-13458b56fecf");
    private readonly Guid _minPosFontGuid = new("63121c46-92b3-4438-81f3-4efed67d6087");
    private readonly Guid _minPosLineGuid = new("d76f6284-aa9b-4d01-9d38-1a14c236e2f1");
    private readonly Guid _notesGuid = new("c644fce8-8a61-4283-883a-e076354dcbcb");
    private readonly Guid _printProcessGuid = new("1f2aeb33-da9c-4563-be88-177f485e789b");
    private readonly Guid _printProcessCommentsGuid = new("6be92302-b58e-4a6f-8eb4-a801ea844ea6");
    private readonly Guid _sequenceCGuid = new("be6a8649-c63d-4d6d-8a62-acbed7c0847a");
    private readonly Guid _sequenceMGuid = new("deabbe78-66c1-426c-8776-b5ac6ea0a3da");
    private readonly Guid _sequenceYGuid = new("cf312d4b-2e16-406d-9893-fd9844a4d020");
    private readonly Guid _sequenceKGuid = new("5220f156-58f0-4c7e-85b6-6c03d24fa80f");
    private readonly Guid _substrateCommentsGuid = new("eb30ae3f-0244-4582-b066-c43f28022dcf");
    private readonly Guid _techSpecCommentsGuid = new("7600e029-e837-4c0e-ba1d-b3d172d98fd9");
    private readonly Guid _trapGuid = new("cf998656-4003-44fe-b70e-cebae7315f1d");
    private readonly Guid _domainGuid = new("45821c2d-9d6e-4c82-ac57-965755960422");

    private async Task MakeSureCustomFieldsAreCreated(AuditUserDetails auditUserDetails)
    {
        
        var customFields = new List<CreateCustomField>
        {
            new()
            {
                FieldType = FieldType.Glossary,
                Name = "GMG Profile",
                RefElementId = _gmgProfileGlossaryGuid.ToGeneralIdRef(),
                Guid = _gmgProfileGuid,
                MaxEntries = 1
            },
            new()
            {
                FieldType = FieldType.Glossary,
                Name = "Digital Supply Method",
                RefElementId = _digitalSupplyFormatGlossaryGuid.ToGeneralIdRef(),
                Guid = _digitalSupplyMethodGuid,
                MaxEntries = 1

            },
            new()
            {
                FieldType = FieldType.Glossary,
                Name = "Print Process",
                RefElementId = _printProcessGlossaryGuid.ToGeneralIdRef(),
                Guid = _printProcessGuid,
                MaxEntries = 1
            },
            new()
            {
                FieldType = FieldType.Number,
                Name = "Sequence C",
                MinEntries = 1,
                Guid = _sequenceCGuid,
                Parameters = "{ \"step\":\"1\" }"
            },
            new()
            {
                FieldType = FieldType.Number,
                Name = "Sequence M",
                MinEntries = 1,
                Guid = _sequenceMGuid,
                Parameters = "{ \"step\":\"1\" }"
            },
            new()
            {
                FieldType = FieldType.Number,
                Name = "Sequence Y",
                MinEntries = 1,
                Guid = _sequenceYGuid,
                Parameters = "{ \"step\":\"1\" }"
            },
            new()
            {
                FieldType = FieldType.Number,
                Name = "Sequence K",
                MinEntries = 1,
                Guid = _sequenceKGuid,
                Parameters = "{ \"step\":\"1\" }"
            },
            new()
            {
                FieldType = FieldType.Number,
                Name = "Colours",
                MinEntries = 1,
                Guid = _colours,
                Parameters = "{ \"step\":\"1\" }"
            },
            new()
            {
                FieldType = FieldType.Number,
                Name = "Minimum Pos Line",
                MinEntries = 1,
                Guid = _minPosLineGuid,
                Parameters = "{ \"step\":\"0.001\" }"
            },
            new()
            {
                FieldType = FieldType.Number,
                Name = "Minimum Neg Line",
                MinEntries = 1,
                Guid = _minNegLineGuid,
                Parameters = "{ \"step\":\"0.001\" }"
            },
            new()
            {
                FieldType = FieldType.Number,
                Name = "Minimum Multi Ink Line",
                MinEntries = 1,
                Guid = _minMultiInkLineGuid,
                Parameters = "{ \"step\":\"0.001\" }"
            },
            new()
            {
                FieldType = FieldType.Number,
                Name = "Minimum Pos Font",
                MinEntries = 1,
                Guid = _minPosFontGuid,
                Parameters = "{ \"step\":\"0.001\" }"
            },
            new()
            {
                FieldType = FieldType.Number,
                Name = "Minimum Neg Font",
                MinEntries = 1,
                Guid = _minNegFontGuid,
                Parameters = "{ \"step\":\"0.001\" }"
            },
            new()
            {
                FieldType = FieldType.Number,
                Name = "Minimum Multi Ink Font",
                MinEntries = 1,
                Guid = _minMultiInkFontGuid,
                Parameters = "{ \"step\":\"0.001\" }"
            },
            new()
            {
                FieldType = FieldType.Number,
                Name = "Min Dot",
                MinEntries = 1,
                Guid = _minDotGuid,
                Parameters = "{ \"step\":\"0.001\" }"
            },
            new()
            {
                FieldType = FieldType.Number,
                Name = "Max Dot",
                MinEntries = 1,
                Guid = _maxDotGuid,
                Parameters = "{ \"step\":\"0.001\" }"
            },
            new()
            {
                FieldType = FieldType.Number,
                Name = "Trap",
                MinEntries = 1,
                Guid = _trapGuid,
                Parameters = "{ \"step\":\"0.001\" }"
            },
            new()
            {
                FieldType = FieldType.Number,
                Name = "Max Ink",
                MinEntries = 1,
                Guid = _maxInkGuid,
                Parameters = "{ \"step\":\"0.001\" }"
            },
            new()
            {
                FieldType = FieldType.Number,
                Name = "BWR",
                MinEntries = 1,
                Guid = _bwrGuid,
                Parameters = "{ \"step\":\"0.001\" }"
            },
            new()
            {
                FieldType = FieldType.Number,
                Name = "Min Mag",
                MinEntries = 1,
                Guid = _minMagGuid,
                Parameters = "{ \"step\":\"0.001\" }"
            },
            new()
            {
                FieldType = FieldType.Text,
                Name = "Tech Spec Comments",
                MinEntries = 1,
                Guid = _techSpecCommentsGuid,
                Parameters = "{ \"multiLine\":true }"
            },
            new()
            {
                FieldType = FieldType.Text,
                Name = "Print Process Comments",
                MinEntries = 1,
                Guid = _printProcessCommentsGuid,
                Parameters = "{ \"multiLine\":true }"
            },
            new()
            {
                FieldType = FieldType.Text,
                Name = "Digital Supply Comments",
                MinEntries = 1,
                Guid = _digitalSupplyCommentsGuid,
                Parameters = "{ \"multiLine\":true }"
            },
            new()
            {
                FieldType = FieldType.Text,
                Name = "Barcode Comments",
                MinEntries = 1,
                Guid = _barcodeCommentsGuid,
                Parameters = "{ \"multiLine\":true }"
            },
            new()
            {
                FieldType = FieldType.Text,
                Name = "Substrate Comments",
                MinEntries = 1,
                Guid = _substrateCommentsGuid,
                Parameters = "{ \"multiLine\":true }"
            },
            new()
            {
                FieldType = FieldType.Domain,
                Name = "Domain",
                MinEntries = 0,
                Guid = _domainGuid
            },
            new()
            {
                FieldType = FieldType.Text,
                Name = "Notes",
                MinEntries = 1,
                Guid = _notesGuid,
                Parameters = "{ \"multiLine\":true }"
            }

        };

        await _importCustomFieldHelper.EnsureCustomFieldsExist(auditUserDetails, customFields);
    }
}
