using TornadoAce_CJOnStyle.Domain;

namespace TornadoAce_CJOnStyle.Services
{
    public sealed class AutomationWorkspace
    {
        private AutomationWorkspace(
            IReadOnlyList<CueSheetRecord> cueSheets,
            SceneTemplateDefinition activeTemplate,
            SceneDataSnapshot activeScene,
            IReadOnlyList<InspectionResult> inspectionResults)
        {
            CueSheets = cueSheets;
            ActiveTemplate = activeTemplate;
            ActiveScene = activeScene;
            InspectionResults = inspectionResults;
        }

        public IReadOnlyList<CueSheetRecord> CueSheets { get; }

        public SceneTemplateDefinition ActiveTemplate { get; }

        public SceneDataSnapshot ActiveScene { get; }

        public IReadOnlyList<InspectionResult> InspectionResults { get; }

        public static AutomationWorkspace CreateDemo()
        {
            var cueSheets = new[]
            {
                new CueSheetRecord("CJ-20260817-001", DateTime.Today.AddHours(9), "최화정쇼", "비비안 컴포트 패키지", "79,900원", "브라 4종 + 팬티 4종", "ARS 10% 할인"),
                new CueSheetRecord("CJ-20260817-002", DateTime.Today.AddHours(11), "동가게", "프리미엄 한우 세트", "69,900원", "1등급 등심 1.2kg", "무이자 5개월"),
                new CueSheetRecord("CJ-20260817-003", DateTime.Today.AddHours(14), "스타일 라이브", "썸머 린넨 셋업", "59,900원", "자켓 + 팬츠", "앱 주문 추가 적립")
            };

            var mappings = new[]
            {
                new FieldMappingDefinition("programTitle", "TXT_PROGRAM", "Text", "trim"),
                new FieldMappingDefinition("productName", "TXT_PRODUCT", "Text", "normalize-space"),
                new FieldMappingDefinition("priceText", "TXT_PRICE", "Text", "currency-text"),
                new FieldMappingDefinition("compositionText", "TXT_COMPOSITION", "Text", "line-break-safe"),
                new FieldMappingDefinition("promotionText", "TXT_PROMOTION", "Text", "special-char-exception")
            };

            var template = new SceneTemplateDefinition("CJ_PRICE_LOWER_01", "가격형 하단 자막 / Tornado Scene", "Tornado2 primary, Tornado3 ready", mappings);

            var scene = new SceneDataSnapshot(
                "CJ_PRICE_LOWER_01_0900.tscn",
                template.TemplateId,
                new Dictionary<string, string>
                {
                    ["TXT_PROGRAM"] = "최화정쇼",
                    ["TXT_PRODUCT"] = "비비안 컴포트 패키지",
                    ["TXT_PRICE"] = "79,900원",
                    ["TXT_COMPOSITION"] = "브라 4종 + 팬티 4종",
                    ["TXT_PROMOTION"] = "ARS 10% 할인"
                },
                new[] { @"D:\CJOnStyle\Products\VIVIEN\main.png" });

            var inspections = new[]
            {
                new InspectionResult("CJ-20260817-001", "최화정쇼", "CJ_PRICE_LOWER_01_0900.tscn", 100, "Low", "1차 통과"),
                new InspectionResult("CJ-20260817-002", "동가게", "CJ_PRICE_LOWER_01_1100.tscn", 96.4, "High", "가격 불일치 확인"),
                new InspectionResult("CJ-20260817-003", "스타일 라이브", "CJ_PRICE_LOWER_01_1400.tscn", 98.1, "Medium", "특수문자 예외 후보")
            };

            return new AutomationWorkspace(cueSheets, template, scene, inspections);
        }
    }
}
