function exportPptFlag()
{
    var data=trends1Data;
            
    let pptx = new PptxGenJS();   
    let slide = pptx.addSlide();  // slide number - 1
    let slide2 = pptx.addSlide();  // slide number - 2
    let slide21 = pptx.addSlide();  // slide number - 3
	let slide3 = pptx.addSlide();  // slide number - 4
	let slide4 = pptx.addSlide();  // slide number - 5
	let slide5 = pptx.addSlide();  // slide number - 6
	let slide6 = pptx.addSlide();  // slide number - 7
	let slide7 = pptx.addSlide();  // slide number - 8
	let slide8 = pptx.addSlide();  // slide number - 9
	let slide9 = pptx.addSlide();  // slide number - 10
	let slide10 = pptx.addSlide();  // slide number - 11
	let slide11 = pptx.addSlide();  // slide number - 12
    let slide12 = pptx.addSlide();  // slide number - 13
    let slide22 = pptx.addSlide();  // slide number - 14
    let slide23 = pptx.addSlide();  // slide number - 15
    let slide13 = pptx.addSlide();  // slide number - 16
    let slide14 = pptx.addSlide();  // slide number - 17
    let slide15 = pptx.addSlide();  // slide number - 18
    let slide16 = pptx.addSlide();  // slide number - 19
    let slide17 = pptx.addSlide();  // slide number - 20
    let slide18 = pptx.addSlide();  // slide number - 21
    let slide19 = pptx.addSlide();  // slide number - 22
    let slide20 = pptx.addSlide();  // slide number - 23

	
	
	// Slide1 Consumption Funnel
    let topHead = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
    let subHead = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
    let leftHead = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let leftSubHead = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    let rightHead = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let rightSubHead = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    
    let country1 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country2 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country3 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country4 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country5 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country6 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country7 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
	
    let left_legend1 = { x: 0.01, y: 1.87, w: 1.10, h: 0.43, fontSize: 6, fontFace: "Arial", bold: false, color: '000000' };
    let left_legend2 = { x: 0.007, y: 2.41, w: 1.10, h: 0.43, fontSize: 6, fontFace: "Arial", bold: false, color: '000000' };
    let left_legend3 = { x: 0.007, y: 2.89, w: 1.10, h: 0.43, fontSize: 6, fontFace: "Arial", bold: false, color: '000000' };
    let left_legend4 = { x: 0.007, y: 3.41, w: 1.10, h: 0.43, fontSize: 6, fontFace: "Arial", bold: false, color: '000000' };
	
    let fTextOne = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 6, fontFace: "Arial", bold: false, italic: true, color: '969696' };
    let fTextTwo = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 6, italic: true, fontFace: "Arial", bold: false, color: '969696' };

    let rect1 = { x: 1.16, y: 1.87, w: 0.64, h: 0.39, fill: 'd6e6fd' };
    let rectText1 = { x: 1.16, y: 1.87, w: 0.64, h: 0.39, align: 'center', fontSize: 7, fontFace: "Arial", bold: true, color: '000000' };
	
    let rect2 = { x: 1.21, y: 2.38, w: 0.56, h: 0.39, fill: '71a7ff', line: { color: '71a7ff' } };
    let rectText2 = { x: 1.21, y: 2.38, w: 0.56, h: 0.39, align: 'center', fontSize: 7, fontFace: "Arial", bold: true, color: 'ffffff' };
	
    let rect3 = { x: 1.25, y: 2.86, w: 0.49, h: 0.39, fill: '156eff', line: { color: '156eff' } };
    let rectText3 = { x: 1.25, y: 2.86, w: 0.49, h: 0.39, align: 'center', fontSize: 7, bold: true, fontFace: "Arial", color: 'ffffff' };
	
    let rect4 = { x: 1.29, y: 3.37, w: 0.41, h: 0.39, fill: '0046b8', line: { color: '0046b8' } };
    let rectText4 = { x: 1.29, y: 3.37, w: 0.41, h: 0.39, align: 'center', fontSize: 7, bold: true, fontFace: "Arial", color: 'ffffff' };

    let countryBase = {x: 1.13,y: 3.74,w: 0.72,h: 0.30,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};
	
    let tableBase = {"x": 7.85,"y": 3.83,"w": 0.67,"h": 0.11,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};

    let logo1 = {"x": 8.00,"y": 5.21,"w": 0.54,"h": 0.28};
    let logo2 = {"x": 8.70,"y": 5.22,"w": 0.80,"h": 0.24};

    var DairycountryLevel = data['ConsumptionCountry'];
    var DairyquarterLevel = data['ConsumptionQuarter'];
                        
    var DairyfinalTrendData = [];
    var DairyfinalTrendDataX = [];

    var Q1 = DairyquarterLevel["Q1'25"];
    var Q2 = DairyquarterLevel["Q2'25"];
    
    var DairybaseData = [Q1.ever[0].bCount, Q2.ever[0].bCount];
    var DairyeverData = [Q1.ever[0].percentage, Q2.ever[0].percentage];
    var Dairyconsumed1YData = [Q1.consumed1Y[0].percentage, Q2.consumed1Y[0].percentage];
    var Dairyconsumed3MData = [Q1.consumed3M[0].percentage, Q2.consumed3M[0].percentage];
    var Dairyconsumed7DData = [Q1.consumed7D[0].percentage, Q2.consumed7D[0].percentage];
            
    DairyfinalTrendData.push(DairyeverData);
    DairyfinalTrendData.push(Dairyconsumed1YData);
    DairyfinalTrendData.push(Dairyconsumed3MData);
    DairyfinalTrendData.push(Dairyconsumed7DData);
    
    var DairyeverDataCountry = [];
    var Dairyconsumed1YDataCountry = [];
    var Dairyconsumed3MDataCountry = [];
    var Dairyconsumed7DDataCountry = [];

    const DairycountryData = {};

    countryLabel4.forEach(country => {
        if (DairycountryLevel[country]) {
            DairycountryData[country] = DairycountryLevel[country];
        }
    });

    for (let country in DairycountryData) {
        DairyeverDataCountry.push(DairycountryData[country].ever[0].percentage);
        Dairyconsumed1YDataCountry.push(DairycountryData[country].consumed1Y[0].percentage);
        Dairyconsumed3MDataCountry.push(DairycountryData[country].consumed3M[0].percentage);
        Dairyconsumed7DDataCountry.push(DairycountryData[country].consumed7D[0].percentage);
    }

    const DairybCounts = {};
    const Dairycountries = Object.keys(DairycountryData);

    Dairycountries.forEach((country, index) => {
        DairybCounts[index] = DairycountryLevel[country].ever[0].bCount;
    });

    const DairyflatArray = Object.values(DairybCounts);
    const ConsumptionFunnelArray = [{
        title: "Consumption Funnel",
        subtitle: "Dairy Milk (Flavored & Unflavored)",
        subtitle1: "Half Yearly (H1’25)",
        subtitle3: "Quarterly – SEA (Q1’25 & Q2’25)",
        countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: ["","https://keresearch.in/mdynata/assets/images/1.png","https://keresearch.in/mdynata/assets/images/2.png","https://keresearch.in/mdynata/assets/images/3.png","https://keresearch.in/mdynata/assets/images/4.png","https://keresearch.in/mdynata/assets/images/5.png","https://keresearch.in/mdynata/assets/images/6.png"],
        
        ever:DairyeverDataCountry,
        consumed1:Dairyconsumed1YDataCountry,
        consumed3:Dairyconsumed3MDataCountry,
        consumed7:Dairyconsumed7DDataCountry,
        
        funnel: ["","Ever Tried","Consumed in Past 12 Months","Consumed in Past 3 Months","Consumed in Past 7 Days"],
        sampleSizes:DairyflatArray,
        bottom1:"S11. In the past 7 days, have you personally consumed < CATEGORY > at home, at a restaurant, during travel or anywhere else?",
        bottom2:"S12. When was the last time you had < CATEGORY CODED ‘NO’ and ‘DON’T REMEMBER’ IN S11>? It could be at home, at a restaurant, during travel or anywhere else?",
        
        btm1:"Sig.", btm2:"High/", btm3:"Low", btm4:" vs.", btm5:"previous wave", btm6:" at 95% CI",
        tblB:[DairybaseData[0],DairybaseData[1]],
        table: [
        ["","Q1'25", "Q2'25"],
        [consumptionLabel[0],DairyeverData[0]+'%', DairyeverData[1]+'%'],
        [consumptionLabel[1],Dairyconsumed1YData[0]+'%',Dairyconsumed1YData[1]+'%'],
        [consumptionLabel[2],Dairyconsumed3MData[0]+'%', Dairyconsumed3MData[1]+'%'],
        [consumptionLabel[3],Dairyconsumed7DData[0]+'%', Dairyconsumed7DData[1]+'%'],
        ]
    }];

    ConsumptionFunnelArray.forEach(slideData => {
        slide.addText(slideData.title,topHead);
        slide.addText(slideData.subtitle,subHead);
        slide.addText(slideData.subtitle1, leftHead);
        slide.addText("Base – All Respondents",leftSubHead);
		slide.addText(slideData.subtitle3,rightHead);
        slide.addText("Base – All Respondents",rightSubHead);
        
        slide.addShape(pptx.ShapeType.line, { x:0.16,y:1.02,w:6.51,h:0,line:{color:'75b1bb',width:1.2} });
        slide.addShape(pptx.ShapeType.line, { x:6.83,y:1.02,w:2.46,h:0,line:{color:'75b1bb',width:1.2} });
		
        slide.addText(slideData.countries[0],country1);
        slide.addText(slideData.countries[1],country2);
        slide.addText(slideData.countries[2],country3);
        slide.addText(slideData.countries[3],country4);
        slide.addText(slideData.countries[4],country5);
        slide.addText(slideData.countries[5],country6);
        slide.addText(slideData.countries[6],country7);

        slide.addImage({ x: 2.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[1] });
        slide.addImage({ x: 2.94, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[2] });
        slide.addImage({ x: 3.73, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[3] });
        slide.addImage({ x: 4.54, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[4] });
        slide.addImage({ x: 5.33, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[5] });
        slide.addImage({ x: 6.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[6] });

        slide.addText(slideData.funnel[1],left_legend1);
        slide.addText(slideData.funnel[2],left_legend2);
        slide.addText(slideData.funnel[3],left_legend3);
        slide.addText(slideData.funnel[4],left_legend4);

        // Column 1
            var x1_c1 = 1.16;
            var w1_c1 = ((slideData.ever[0]/10)/3)/5;
            var w1_c2 = ((slideData.consumed1[0]/10)/3)/5;
            var w1_c3 = ((slideData.consumed3[0]/10)/3)/5;
            var w1_c4 = ((slideData.consumed7[0]/10)/3)/5;
            var center_c1 = x1_c1 + (w1_c1/2);

            var x1_c1 = center_c1-(w1_c1/2);
            var x1_c2 = center_c1-(w1_c2/2);
            var x1_c3 = center_c1-(w1_c3/2);
            var x1_c4 = center_c1-(w1_c4/2);
        // Column 1

        // Column 2
            var x2_c1 = 1.96;
            var w2_c1 = ((slideData.ever[1]/10)/3)/5;
            var w2_c2 = ((slideData.consumed1[1]/10)/3)/5;
            var w2_c3 = ((slideData.consumed3[1]/10)/3)/5;
            var w2_c4 = ((slideData.consumed7[1]/10)/3)/5;
            var center_c2 = x2_c1 + (w2_c1/2);

            var x2_c1 = center_c2-(w2_c1/2);
            var x2_c2 = center_c2-(w2_c2/2);
            var x2_c3 = center_c2-(w2_c3/2);
            var x2_c4 = center_c2-(w2_c4/2);
        // Column 2

        // Column 3
            var x3_c1 = 2.79;
            var w3_c1 = ((slideData.ever[2]/10)/3)/5;
            var w3_c2 = ((slideData.consumed1[2]/10)/3)/5;
            var w3_c3 = ((slideData.consumed3[2]/10)/3)/5;
            var w3_c4 = ((slideData.consumed7[2]/10)/3)/5;
            var center_c3 = x3_c1 + (w3_c1/2);

            var x3_c1 = center_c3-(w3_c1/2);
            var x3_c2 = center_c3-(w3_c2/2);
            var x3_c3 = center_c3-(w3_c3/2);
            var x3_c4 = center_c3-(w3_c4/2);
        // Column 3

        // Column 4
            var x4_c1 = 3.60;
            var w4_c1 = ((slideData.ever[3]/10)/3)/5;
            var w4_c2 = ((slideData.consumed1[3]/10)/3)/5;
            var w4_c3 = ((slideData.consumed3[3]/10)/3)/5;
            var w4_c4 = ((slideData.consumed7[3]/10)/3)/5;
            var center_c4 = x4_c1 + (w4_c1/2);

            var x4_c1 = center_c4-(w4_c1/2);
            var x4_c2 = center_c4-(w4_c2/2);
            var x4_c3 = center_c4-(w4_c3/2);
            var x4_c4 = center_c4-(w4_c4/2);
        // Column 4

        // Column 5
            var x5_c1 = 4.41;
            var w5_c1 = ((slideData.ever[4]/10)/3)/5;
            var w5_c2 = ((slideData.consumed1[4]/10)/3)/5;
            var w5_c3 = ((slideData.consumed3[4]/10)/3)/5;
            var w5_c4 = ((slideData.consumed7[4]/10)/3)/5;
            var center_c5 = x5_c1 + (w5_c1/2);

            var x5_c1 = center_c5-(w5_c1/2);
            var x5_c2 = center_c5-(w5_c2/2);
            var x5_c3 = center_c5-(w5_c3/2);
            var x5_c4 = center_c5-(w5_c4/2);
        // Column 5

        // Column 6
            var x6_c1 = 5.19;
            var w6_c1 = ((slideData.ever[5]/10)/3)/5;
            var w6_c2 = ((slideData.consumed1[5]/10)/3)/5;
            var w6_c3 = ((slideData.consumed3[5]/10)/3)/5;
            var w6_c4 = ((slideData.consumed7[5]/10)/3)/5;
            var center_c6 = x6_c1 + (w6_c1/2);

            var x6_c1 = center_c6-(w6_c1/2);
            var x6_c2 = center_c6-(w6_c2/2);
            var x6_c3 = center_c6-(w6_c3/2);
            var x6_c4 = center_c6-(w6_c4/2);
        // Column 6

        // Column 7
            var x7_c1 = 5.96;
            var w7_c1 = ((slideData.ever[6]/10)/3)/5;
            var w7_c2 = ((slideData.consumed1[6]/10)/3)/5;
            var w7_c3 = ((slideData.consumed3[6]/10)/3)/5;
            var w7_c4 = ((slideData.consumed7[6]/10)/3)/5;
            var center_c7 = x7_c1 + (w7_c1/2);

            var x7_c1 = center_c7-(w7_c1/2);
            var x7_c2 = center_c7-(w7_c2/2);
            var x7_c3 = center_c7-(w7_c3/2);
            var x7_c4 = center_c7-(w7_c4/2);
        // Column 7

        slide.addShape(pptx.ShapeType.rect,{...rect1,w: w1_c1,x: x1_c1});
        slide.addText(slideData.ever[0]+'%',{...rectText1,w: w1_c1,x: x1_c1});
        
        slide.addShape(pptx.ShapeType.rect,{...rect2,w: w1_c2,x: x1_c2});
        slide.addText(slideData.consumed1[0]+'%',{...rectText2,w: w1_c2,x: x1_c2});
        
        slide.addShape(pptx.ShapeType.rect,{...rect3,w: w1_c3,x: x1_c3});
        slide.addText(slideData.consumed3[0]+'%',{...rectText3,w: w1_c3,x: x1_c3});
        
        slide.addShape(pptx.ShapeType.rect,{...rect4,w: w1_c4,x: x1_c4});
        slide.addText(slideData.consumed7[0]+'%',{...rectText4,w: w1_c4,x: x1_c4});

        slide.addShape(pptx.ShapeType.rect,{...rect1,w: w2_c1,x: x2_c1});
        slide.addText(slideData.ever[1]+'%',{...rectText1,w: w2_c1,x: x2_c1});
        
        slide.addShape(pptx.ShapeType.rect,{...rect2,w: w2_c2,x: x2_c2});
        slide.addText(slideData.consumed1[1]+'%',{...rectText2,w: w2_c2,x: x2_c2});
        
        slide.addShape(pptx.ShapeType.rect,{...rect3,w: w2_c3,x: x2_c3});
        slide.addText(slideData.consumed3[1]+'%',{...rectText3,w: w2_c3,x: x2_c3});
        
        slide.addShape(pptx.ShapeType.rect,{...rect4,w: w2_c4,x: x2_c4});
        slide.addText(slideData.consumed7[1]+'%',{...rectText4,w: w2_c4,x: x2_c4});

        slide.addShape(pptx.ShapeType.rect,{...rect1,w: w3_c1,x: x3_c1});
        slide.addText(slideData.ever[2]+'%',{...rectText1,w: w3_c1,x: x3_c1});
        
        slide.addShape(pptx.ShapeType.rect,{...rect2,w: w3_c2,x: x3_c2});
        slide.addText(slideData.consumed1[2]+'%',{...rectText2,w: w3_c2,x: x3_c2});
        
        slide.addShape(pptx.ShapeType.rect,{...rect3,w: w3_c3,x: x3_c3});
        slide.addText(slideData.consumed3[2]+'%',{...rectText3,w: w3_c3,x: x3_c3});
        
        slide.addShape(pptx.ShapeType.rect,{...rect4,w: w3_c4,x: x3_c4});
        slide.addText(slideData.consumed7[2]+'%',{...rectText4,w: w3_c4,x: x3_c4});

        slide.addShape(pptx.ShapeType.rect,{...rect1,w: w4_c1,x: x4_c1});
        slide.addText(slideData.ever[3]+'%',{...rectText1,w: w4_c1,x: x4_c1});
        
        slide.addShape(pptx.ShapeType.rect,{...rect2,w: w4_c2,x: x4_c2});
        slide.addText(slideData.consumed1[3]+'%',{...rectText2,w: w4_c2,x: x4_c2});
        
        slide.addShape(pptx.ShapeType.rect,{...rect3,w: w4_c3,x: x4_c3});
        slide.addText(slideData.consumed3[3]+'%',{...rectText3,w: w4_c3,x: x4_c3});
        
        slide.addShape(pptx.ShapeType.rect,{...rect4,w: w4_c4,x: x4_c4});
        slide.addText(slideData.consumed7[3]+'%',{...rectText4,w: w4_c4,x: x4_c4});

        slide.addShape(pptx.ShapeType.rect,{...rect1,w: w5_c1,x: x5_c1});
        slide.addText(slideData.ever[4]+'%',{...rectText1,w: w5_c1,x: x5_c1});
        
        slide.addShape(pptx.ShapeType.rect,{...rect2,w: w5_c2,x: x5_c2});
        slide.addText(slideData.consumed1[4]+'%',{...rectText2,w: w5_c2,x: x5_c2});
        
        slide.addShape(pptx.ShapeType.rect,{...rect3,w: w5_c3,x: x5_c3});
        slide.addText(slideData.consumed3[4]+'%',{...rectText3,w: w5_c3,x: x5_c3});
        
        slide.addShape(pptx.ShapeType.rect,{...rect4,w: w5_c4,x: x5_c4});
        slide.addText(slideData.consumed7[4]+'%',{...rectText4,w: w5_c4,x: x5_c4});

        slide.addShape(pptx.ShapeType.rect,{...rect1,w: w6_c1,x: x6_c1});
        slide.addText(slideData.ever[5]+'%',{...rectText1,w: w6_c1,x: x6_c1});
        
        slide.addShape(pptx.ShapeType.rect,{...rect2,w: w6_c2,x: x6_c2});
        slide.addText(slideData.consumed1[5]+'%',{...rectText2,w: w6_c2,x: x6_c2});
        
        slide.addShape(pptx.ShapeType.rect,{...rect3,w: w6_c3,x: x6_c3});
        slide.addText(slideData.consumed3[5]+'%',{...rectText3,w: w6_c3,x: x6_c3});
        
        slide.addShape(pptx.ShapeType.rect,{...rect4,w: w6_c4,x: x6_c4});
        slide.addText(slideData.consumed7[5]+'%',{...rectText4,w: w6_c4,x: x6_c4});

        slide.addShape(pptx.ShapeType.rect,{...rect1,w: w7_c1,x: x7_c1});
        slide.addText(slideData.ever[6]+'%',{...rectText1,w: w7_c1,x: x7_c1});
        
        slide.addShape(pptx.ShapeType.rect,{...rect2,w: w7_c2,x: x7_c2});
        slide.addText(slideData.consumed1[6]+'%',{...rectText2,w: w7_c2,x: x7_c2});
        
        slide.addShape(pptx.ShapeType.rect,{...rect3,x: 6.05,w: w7_c3,x: x7_c3});
        slide.addText(slideData.consumed3[6]+'%',{...rectText3,x: 6.05,w: w7_c3,x: x7_c3});
        
        slide.addShape(pptx.ShapeType.rect,{...rect4,x: 6.08,w: w7_c4,x: x7_c4});
        slide.addText(slideData.consumed7[6]+'%',{...rectText4,x: 6.08,w: w7_c4,x: x7_c4});

        slide.addShape(pptx.ShapeType.line, {x: 0.28,y:2.31,w:6.38,h:0,line:{ color:'e0e0e0', width: 1 } });
        slide.addShape(pptx.ShapeType.line, {x: 0.28,y:2.82,w:6.38,h:0,line:{ color:'e0e0e0', width: 1 } });
        slide.addShape(pptx.ShapeType.line, {x: 0.28,y:3.31,w:6.38,h:0,line:{ color:'e0e0e0', width: 1 } });
        slide.addShape(pptx.ShapeType.line, {x: 0.28,y:3.80,w:6.38,h:0,line:{ color:'e0e0e0', width: 1 } });

        slide.addText("n-"+slideData.sampleSizes[0],countryBase);
        slide.addText("n-"+slideData.sampleSizes[1],{...countryBase,x: 1.91});
        slide.addText("n-"+slideData.sampleSizes[2],{...countryBase,x: 2.74});
        slide.addText("n-"+slideData.sampleSizes[3],{...countryBase,x: 3.55});
        slide.addText("n-"+slideData.sampleSizes[4],{...countryBase,x: 4.35});
        slide.addText("n-"+slideData.sampleSizes[5],{...countryBase,x: 5.14});
        slide.addText("n-"+slideData.sampleSizes[6],{...countryBase,x: 5.91});

        slide.addShape(pptx.ShapeType.line, { "x": 0.28,"y": 5.06,"w": 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });


        let tableRows = slideData.table.map((row, rowIndex, allRows) =>
            row.map(cell => ({
                text: cell,
                    options: {
                        border: (rowIndex === 0 || rowIndex === allRows.length - 1)
                        ? [false, false, false, false] // No border for first and last row
                        : [false, false, true, false], // Bottom border only
                        borderColor: 'e0e0e0',
                        borderSize: 0.5,
                        fontSize: 8,
                        align: 'center',
                        valign: 'middle',
                    }
            }))
        );

        slide.addTable(tableRows, {"x": 6.83,"y": 1.33,"w": 2.76,"h": 2.46});
		
        slide.addText("n-"+slideData.tblB[0],tableBase);
        slide.addText("n-"+slideData.tblB[1],{...tableBase,x: 8.82});

        slide.addText([
            { text: slideData.btm1, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
            { text: slideData.btm2, options: { color: '00b050',fontFace: "Arial", fontSize: 6, bold: false } },
            { text: slideData.btm3, options: { color: 'ff0000',fontFace: "Arial", fontSize: 6, bold: false } },
            { text: slideData.btm4, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
            { text: slideData.btm5, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: true } },
            { text: slideData.btm6, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } }
        ], {"x": 8.07,"y": 4.84,"w": 1.83,"h": 0.30});

        slide.addImage({...logo1,path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png"});
        slide.addImage({...logo2,path: "https://keresearch.in/mdynata/assets/images/strategic.png"});
        slide.addShape(pptx.ShapeType.line, {x: 6.74,y: 0.96,w: 0.00,h: 4.09,line: {color:'969696',width: 1,dashType: 'dash'}});

        slide.addText(slideData.bottom1,fTextOne);
        slide.addText(slideData.bottom2,fTextTwo);
    });	
        
   
   // Slide 2 Frequency of Consumption
	
    let topHead_2 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
    let subHead_2 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
    let leftHead_2 = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let leftSubHead_2 = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    let rightHead_2 = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let rightSubHead_2 = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    
    let country1_2 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country2_2 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country3_2 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country4_2 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country5_2 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country6_2 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country7_2 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
	
    let left_legend1_2 = { x: 0.01, y: 1.87, w: 1.34, h: 0.43, fontSize: 6, fontFace: "Arial", bold: false, color: '000000' };
    let left_legend2_2 = { x: 0.007, y: 2.41, w: 1.34, h: 0.43, fontSize: 6, fontFace: "Arial", bold: false, color: '000000' };
    let left_legend3_2 = { x: 0.007, y: 2.89, w: 1.34, h: 0.43, fontSize: 6, fontFace: "Arial", bold: false, color: '000000' };
    let left_legend4_2 = { x: 0.007, y: 3.41, w: 1.34, h: 0.43, fontSize: 6, fontFace: "Arial", bold: false, color: '000000' };
	
    let fTextOne_2 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 6, fontFace: "Arial", bold: false, italic: true, color: '969696' };
    let fTextTwo_2 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 6, italic: true, fontFace: "Arial", bold: false, color: '969696' };

    let tableBase_2 = {"x": 7.88,"y": 4.35,"w": 0.67,"h": 0.11,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};

    let logo1_2 = {"x": 8.00,"y": 5.21,"w": 0.54,"h": 0.28};
    let logo2_2 = {"x": 8.70,"y": 5.22,"w": 0.80,"h": 0.24};

	let opts12_2 = { x: 0.36, y: 2.22, w: 0.96, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts13_2 = { x: 0.34, y: 2.79, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts14_2 = { x: 0.32, y: 3.43, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts15_2 = { x: 0.33, y: 4.04, w: 0.99, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let fText1_2 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 6, fontFace: "Arial", bold: false, italic: true, color: '969696' };
    let fText2_2 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 6, italic: true, fontFace: "Arial", bold: false, color: '969696' };

	let stackChart = {x: 1.02,y: 1.4,w: 5.81,h: 3.20,barDir: "col",barGrouping: "stacked",barGapWidthPct: 110,dataLabelColor: "FFFFFF",dataLabelFontFace: "Arial",dataLabelFontSize: 9,dataLabelFontBold: true,showValue: true,dataLabelFormatCode: '0"%"', chartColors: ['F28C28','6D8A42','C6E48B','70A6FF','3A5A81'],lineDataSymbolSize: 15,catAxisLabelColor: "969696", catAxisLabelFontFace: "Arial",catAxisLabelFontSize: 8,catAxisOrientation: "minMax",showLegend: false,legendPos: 'l', legendFontSize: 9, showTitle: false,showValAxis: false,valAxisLabelPos: 'none',valAxisLineShow: false,valGridLine:{style: 'none'},};
	
	var frequencyconsumptioncountryLevel = data['S13_3Country'];
    var frequencyconsumptionquarterLevel = data['S13_3Quarter'];
    var frequencyconsumptionopt=["Everyday","2-3 times a week","Once a week","Once every 2 weeks/Once a month","Once every 2-3 months or Less often"];
    var Q1 = frequencyconsumptionquarterLevel["Q1'25"];
    var Q2 = frequencyconsumptionquarterLevel["Q2'25"];
    const frequencyconsumptionq1= Q1.map(item => item.percentage);
    const frequencyconsumptionq2= Q2.map(item => item.percentage);
    var frequencyconsumptionbaseData = [Q1[0].bCount, Q2[0].bCount];
    const frequencycountryData = {};
    const frequencyconsumption1 = [];
    const frequencyconsumption2 = [];
    const frequencyconsumption3 = [];
    const frequencyconsumption4 = [];
    const frequencyconsumption5 = [];
    const frequencyconsumptionbaseArray = [];

    countryLabel4.forEach(country => {
        if (frequencyconsumptioncountryLevel[country]) {
            frequencycountryData[country] = frequencyconsumptioncountryLevel[country];
        }
    });
            
    for (const country in frequencycountryData) {
        const countryData = frequencycountryData[country];
        frequencyconsumptionbaseArray.push(`n-${countryData[0].bCount}`);
        frequencyconsumption1.push(countryData[0].percentage);
        frequencyconsumption2.push(countryData[1].percentage);
        frequencyconsumption3.push(countryData[2].percentage);
        frequencyconsumption4.push(countryData[3].percentage);
        frequencyconsumption5.push(countryData[4].percentage);
    }

    const frequencyconsumptionArray = [{
        title: "Frequency of Consumption",
        subtitle: "Dairy Milk (Flavored & Unflavored)",
        subtitle1: "Half Yearly (H1’25)",
        subtitle3: "Quarterly – SEA (Q1’25 & Q2’25)",
        countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: ["","https://keresearch.in/mdynata/assets/images/1.png","https://keresearch.in/mdynata/assets/images/2.png","https://keresearch.in/mdynata/assets/images/3.png","https://keresearch.in/mdynata/assets/images/4.png","https://keresearch.in/mdynata/assets/images/5.png","https://keresearch.in/mdynata/assets/images/6.png"],
        funnel: frequencyconsumptionopt,
        f:[frequencyconsumption1,frequencyconsumption2,frequencyconsumption3,frequencyconsumption4,frequencyconsumption5],
        sampleSizes:frequencyconsumptionbaseArray,
        bottom1:"S13. You said you have had < CATEGORY >? recently. How often do you usually have?",
        bottom2:"",
        btm1:"Sig.", btm2:"High/", btm3:"Low", btm4:" vs.", btm5:"previous wave", btm6:" at 95% CI",
        tblB:[frequencyconsumptionbaseData[0],frequencyconsumptionbaseData[1]],
        table: [
            ["","Q1'25", "Q2'25"],
            [frequencyconsumptionopt[0],frequencyconsumptionq1[0]+'%', frequencyconsumptionq2[0]+'%'],
            [frequencyconsumptionopt[1],frequencyconsumptionq1[1]+'%',frequencyconsumptionq2[1]+'%'],
            [frequencyconsumptionopt[2],frequencyconsumptionq1[2]+'%',frequencyconsumptionq2[2]+'%'],
            [frequencyconsumptionopt[3],frequencyconsumptionq1[3]+'%',frequencyconsumptionq2[3]+'%'],
            [frequencyconsumptionopt[4],frequencyconsumptionq1[4]+'%',frequencyconsumptionq2[4]+'%'],
        ],
    }];

    frequencyconsumptionArray.forEach(slideData => {
        // Headings and Subheadings
        slide2.addText(slideData.title, topHead_2);
        slide2.addText(slideData.subtitle, subHead_2);
        slide2.addText(slideData.subtitle1, leftHead_2);
        slide2.addText("Base – Those who consumed in Past 3 months", leftSubHead_2);
        slide2.addText("Base – Those who consumed in Past 3 months", rightSubHead_2);
        slide2.addText(slideData.subtitle3, rightHead_2);

        // Horizontal top lines
        slide2.addShape(pptx.ShapeType.line, { x: 0.16, y: 1.02, w: 6.51, h: 0, line: { color: '75b1bb', width: 1.2 } });
        slide2.addShape(pptx.ShapeType.line, { x: 6.83, y: 1.02, w: 2.46, h: 0, line: { color: '75b1bb', width: 1.2 } });

        // Country labels
        slide2.addText(slideData.countries[0], country1);
        slide2.addText(slideData.countries[1], country2);
        slide2.addText(slideData.countries[2], country3);
        slide2.addText(slideData.countries[3], country4);
        slide2.addText(slideData.countries[4], country5);
        slide2.addText(slideData.countries[5], country6);
        slide2.addText(slideData.countries[6], country7);

        // Country flags (starting from index 1)
        slide2.addImage({ x: 2.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[1] });
        slide2.addImage({ x: 2.94, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[2] });
        slide2.addImage({ x: 3.73, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[3] });
        slide2.addImage({ x: 4.54, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[4] });
        slide2.addImage({ x: 5.33, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[5] });
        slide2.addImage({ x: 6.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[6] });

        // Chart data
        const colors = ['ffffff', 'ffffff','000000','ffffff','ffffff'];
        const chartData = slideData.f.slice().reverse().map((freq, i) => ({
            name: slideData.funnel[slideData.f.length - 1 - i],
            labels: slideData.sampleSizes,
            values: freq,
            dataLabelColor: colors[i]
        }));
        //console.log("chartData")
        //console.log(chartData)
        slide2.addChart(pptx.charts.BAR, chartData, stackChart);
        // Legends
        const legendItems = [
            { color: '3A5A81', text: 'Everyday' },
            { color: '70A6FF', text: '2-3 times a week' },
            { color: 'C6E48B', text: 'Once a week' },
            { color: '6D8A42', text: 'Once every 2 weeks/ once a month' },
            { color: 'F28C28', text: 'Once every 2-3 months or less often' }
        ];

        legendItems.forEach((item, index) => {
            slide2.addShape(pptx.ShapeType.rect, {
                x: 0.2,
                y: 2.2 + index * 0.5,
                w: 0.06,
                h: 0.06,
                fill: { color: item.color },
                line: { color: 'FFFFFF' }
            });

            slide2.addText(item.text, {
                x: 0.3,
                y: 2.2 + index * 0.5,
                fontSize: 6,
                w: 1,
                color: '000000',
                fontFace: 'Arial'
            });
        });

        // Line below chart
        slide2.addShape(pptx.ShapeType.line, {
            x: 0.28,
            y: 5.06,
            w: 9.72,
            h: 0,
            line: { color: '75b1bb', width: 1.2 }
        });

        // Table
        const tableRows2 = slideData.table.map((row, rowIndex, allRows) =>
            row.map(cell => ({
                text: cell,
                options: {
                    border: (rowIndex === 0 || rowIndex === allRows.length - 1)
                        ? [false, false, false, false]
                        : [false, false, true, false],
                    borderColor: 'e0e0e0',
                    borderSize: 0.5,
                    fontSize: 8,
                    align: 'center',
                    valign: 'middle'
                }
            }))
        );

        slide2.addTable(tableRows2, {
            "x": 6.83,"y": 1.46,"w": 2.76,"h": 2.83
        });

        // Table Base
        slide2.addText("n-" + slideData.tblB[0], tableBase_2);
        slide2.addText("n-" + slideData.tblB[1], { ...tableBase_2, x: 8.81 });

        // Bottom footer texts
        slide2.addText([
            { text: slideData.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6 } },
            { text: slideData.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6 } },
            { text: slideData.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6 } },
            { text: slideData.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6 } },
            { text: slideData.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
            { text: slideData.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6 } }
        ], {
            x: 8.07,
            y: 4.84,
            w: 1.83,
            h: 0.30
        });

        // Logo
        slide2.addImage({...logo1_2,path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png"});
        slide2.addImage({...logo2_2,path: "https://keresearch.in/mdynata/assets/images/strategic.png"});

        // Vertical separator line
        slide2.addShape(pptx.ShapeType.line, {
            x: 6.74,
            y: 0.96,
            w: 0.00,
            h: 4.09,
            line: { color: '969696', width: 1, dashType: 'dash' }
        });

        // Bottom right texts
        slide2.addText(slideData.bottom1, fText1_2);
        slide2.addText(slideData.bottom2, fText2_2);
    });
		
		
 // Slide 3 Sub-Categories
	
	let topHead_3 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
    let subHead_3 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
    let leftHead_3 = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let leftSubHead_3 = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    let rightHead_3 = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let  rightSubHead_3 = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };

    /* let country1_3 = { x: 1.31, y: 1.81, w: 0.94, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country2_3 = { x: 2.09, y: 1.76, w: 0.82, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country3_3 = { x: 2.94, y: 1.76, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country4_3 = { x: 3.79, y: 1.76, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country5_3 = { x: 4.57, y: 1.76, w: 0.85, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country6_3 = { x: 5.39, y: 1.76, w: 0.87, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country7_3 = { x: 6.22, y: 1.76, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' }; */
    let country1_3 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country2_3 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country3_3 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country4_3 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country5_3 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country6_3 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country7_3 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };


    let opts12_3 = { x: 0.36, y: 2.22, w: 0.96, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts13_3 = { x: 0.34, y: 2.79, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts14_3 = { x: 0.32, y: 3.43, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts15_3 = { x: 0.33, y: 4.04, w: 0.99, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let fText1_3 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
    let fText2_3 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
	
	let tableBase_3 = {"x": 7.95,"y": 4.21,"w": 0.67,"h": 0.30,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};

    let logo1_3 = {"x": 8.51,"y": 5.21,"w": 0.80,"h": 0.28};
    let logo2_3 = {"x": 9.36,"y": 5.18,"w": 0.54,"h": 0.35};
	
	let stackChart_3 = {x: 1.02,y: 1.4,w: 5.81,h: 3.20,barDir: "col",barGrouping: "stacked",barGapWidthPct: 110,dataLabelColor: "FFFFFF",dataLabelFontFace: "Arial",dataLabelFontSize: 9,dataLabelFontBold: true,showValue: true,dataLabelFormatCode: '0"%"', chartColors: ['F28C28','6D8A42','C6E48B','70A6FF','3A5A81'],lineDataSymbolSize: 15,catAxisLabelColor: "969696", catAxisLabelFontFace: "Arial",catAxisLabelFontSize: 8,catAxisOrientation: "minMax",showLegend: false,legendPos: 'l', legendFontSize: 9, showTitle: false,showValAxis: false,valAxisLabelPos: 'none',valAxisLineShow: false,valGridLine:{style: 'none'},};
	
		var SubCategoriescountryLevel = data['CM_C2Country'];
        var SubCategoriesquarterLevel = data['CM_C2Quarter'];
        var SubCategoriesopt=CMC2label;
        var Q1 = SubCategoriesquarterLevel["Q1'25"];
        var Q2 = SubCategoriesquarterLevel["Q2'25"];
        const SubCategoriesq1= Q1.map(item => item.percentage);
        const SubCategoriesq2= Q2.map(item => item.percentage);
        var SubCategoriesbaseData = [Q1[0].bCount, Q2[0].bCount];
        const SubCategoriescountryData = {};
        const SubCategories1 = [];
        const SubCategories2 = [];
        const SubCategories3 = [];
        const SubCategories4 = [];
        const SubCategories5 = [];
        const SubCategoriesbaseArray = [];

        countryLabel4.forEach(country => {
            if (SubCategoriescountryLevel[country]) {
                SubCategoriescountryData[country] = SubCategoriescountryLevel[country];
            }
        });
                
        for (const country in SubCategoriescountryData) {
            const countryData = SubCategoriescountryData[country];
            SubCategoriesbaseArray.push(`n-${countryData[0].bCount}`);
            SubCategories1.push(countryData[0].percentage);
            SubCategories2.push(countryData[1].percentage);
            SubCategories3.push(countryData[2].percentage);
            SubCategories4.push(countryData[3].percentage);
            SubCategories5.push(countryData[4].percentage);
        }

        const SubCategoriesArray = [{
            title: "Sub-Categories",
            subtitle: "Dairy Milk (Flavored & Unflavored)",
            subtitle1: "Half Yearly (H1’25)",
            subtitle3: "Quarterly – SEA (Q1’25 & Q2’25)",
            countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
            flags: ["","https://keresearch.in/mdynata/assets/images/1.png","https://keresearch.in/mdynata/assets/images/2.png","https://keresearch.in/mdynata/assets/images/3.png","https://keresearch.in/mdynata/assets/images/4.png","https://keresearch.in/mdynata/assets/images/5.png","https://keresearch.in/mdynata/assets/images/6.png"],
            funnel: SubCategoriesopt,
            f:[SubCategories1,SubCategories2,SubCategories3,SubCategories4,SubCategories5],
            sampleSizes:SubCategoriesbaseArray,
            bottom1:"C2. On this most recent occasion, please select the type of Dairy Milk (from Cows) you had?",
            bottom2:"",
            btm1:"Sig.", btm2:"High/", btm3:"Low", btm4:" vs.", btm5:"previous wave", btm6:" at 95% CI",
            tblB:[SubCategoriesbaseData[0],SubCategoriesbaseData[1]],
            table: [
                ["","Q1'25", "Q2'25"],
                [SubCategoriesopt[0],SubCategoriesq1[0]+'%', SubCategoriesq2[0]+'%'],
                [SubCategoriesopt[1],SubCategoriesq1[1]+'%',SubCategoriesq2[1]+'%'],
                [SubCategoriesopt[2],SubCategoriesq1[2]+'%',SubCategoriesq2[2]+'%'],
                [SubCategoriesopt[3],SubCategoriesq1[3]+'%',SubCategoriesq2[3]+'%'],
                [SubCategoriesopt[4],SubCategoriesq1[4]+'%',SubCategoriesq2[4]+'%'],
            ],
        }];

        SubCategoriesArray.forEach(slideData => {
            slide3.addText(slideData.title,topHead_3);
            slide3.addText(slideData.subtitle,subHead_3);
            slide3.addText(slideData.subtitle1,leftHead_3);
            slide3.addText("Base – Those who Consumed in Past 3 months",leftSubHead_3);
            slide3.addText("Base – Those who consumed in Past 3 months",rightSubHead_3);
            slide3.addText(slideData.subtitle3,rightHead_3);
            slide3.addShape(pptx.ShapeType.line, { x: 0.16,y: 1.02,w: 6.51, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide3.addShape(pptx.ShapeType.line, { "x": 6.83,"y": 1.02,"w": 2.46, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide3.addText(slideData.countries[0],{...country1_3,x: 1.01});
            slide3.addText(slideData.countries[1],{...country2_3,x: 1.87});
            slide3.addText(slideData.countries[2],{...country3_3,x: 2.74});
            slide3.addText(slideData.countries[3],{...country4_3,x: 3.55});
            slide3.addText(slideData.countries[4],{...country5_3,x: 4.32});
            slide3.addText(slideData.countries[5],{...country6_3,x: 5.10});
            slide3.addText(slideData.countries[6],{...country7_3,x: 5.91});
            slide3.addImage({ x: 2.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[1] });
            slide3.addImage({ x: 2.94, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[2] });
            slide3.addImage({ x: 3.73, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[3] });
            slide3.addImage({ x: 4.54, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[4] });
            slide3.addImage({ x: 5.33, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[5] });
            slide3.addImage({ x: 6.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[6] });

            const chartData = slideData.f.slice() .reverse().map((freq, i) => ({
					name: slideData.funnel[slideData.f.length - 1 - i], 
					labels: slideData.sampleSizes,
					values: freq,
             }));
             let tnpa=[];
             tnpa = [
                 {
                     type: pptx.charts.BAR,
                     data:chartData ,
                     options: {
                         barGrouping: "stacked",
                     },
                 },
             ];
             slide3.addChart(tnpa, stackChart_3);
             let legendItems = [
                 { color: '3A5A81', text: slideData.funnel[0] },
                 { color: '70A6FF', text: slideData.funnel[1] },
                 { color: 'C6E48B', text: slideData.funnel[2] },
                 { color: '6D8A42', text: slideData.funnel[3] },
                 { color: 'F28C28', text: slideData.funnel[4] },
             ];
             legendItems.forEach((item, index) => {
                 slide3.addShape(pptx.ShapeType.rect, {
                     x: 0.2,
                     y: 2.2 + index * 0.5,  
                     w: 0.060,
                     h: 0.060,
                     fill: { color: item.color },
                     line: { color: 'FFFFFF' }
                 });
                 slide3.addText(item.text, {
                     x: 0.2,
                     y: 2.24 + index * 0.5,
                     w:1,
                     fontSize: 7,
                     color: '000000',
                     fontFace: 'Arial'
                 });
             });

             slide3.addText(slideData.bottom1,fText1_3);
             slide3.addText(slideData.bottom2,fText2_3);
             slide3.addShape(pptx.ShapeType.line, { "x": 0.28,"y": 5.06,"w": 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });

             let tableRows = slideData.table.map((row, rowIndex, allRows) =>
                 row.map(cell => ({
                     text: cell,
                        options: {
                            border: (rowIndex === 0 || rowIndex === allRows.length - 1)
                                ? [false, false, false, false] //No border for first and last row
                                : [false, false, true, false], //Bottom border only
                            borderColor: 'e0e0e0',
                            borderSize: 0.5,
                            fontSize: 8,
                            align: 'center',
                            valign: 'middle'
                        }
                 }))
             );
             slide3.addTable(tableRows, {
                 "x": 6.83,
                 "y": 1.46,
                 "w": 2.89,
                 "h": 2.76
             });
             
			slide3.addText("n-"+slideData.tblB[0],tableBase_3);
			slide3.addText("n-"+slideData.tblB[1],{...tableBase_3,x: 9.0});
			
            slide3.addText([
                 { text: slideData.btm1, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm2, options: { color: '00b050',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm3, options: { color: 'ff0000',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm4, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm5, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: true } },
                 { text: slideData.btm6, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } }
             ], {"x": 8.07,"y": 4.84,"w": 1.83,"h": 0.30});

             slide3.addImage({...logo1_3,path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png"});
             slide3.addImage({...logo2_3,path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png"});

             slide3.addShape(pptx.ShapeType.line, {x: 6.74,y: 0.96,w: 0.00,h: 4.09,line: {color:'969696',width:1,dashType:'dash'}});
        });
		
	// Slide 4 How is it Consumed?
	
	let topHead_4 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
    let subHead_4 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
    let leftHead_4 = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let leftSubHead_4 = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    let rightHead_4 = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let  rightSubHead_4 = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };

    let country1_4 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country2_4 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country3_4 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country4_4 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country5_4 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country6_4 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country7_4 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

    let opts12_4 = { x: 0.36, y: 2.22, w: 0.96, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts13_4 = { x: 0.34, y: 2.79, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts14_4 = { x: 0.32, y: 3.43, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts15_4 = { x: 0.33, y: 4.04, w: 0.99, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let fText1_4 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
    let fText2_4 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
	
	let tableBase_4 = {"x": 7.95,"y": 4.21,"w": 0.67,"h": 0.30,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};

    let logo1_4 = {"x": 8.51,"y": 5.21,"w": 0.80,"h": 0.28};
    let logo2_4 = {"x": 9.36,"y": 5.18,"w": 0.54,"h": 0.35};
	
	let stackChart_4 = {x: 1.02,y: 1.4,w: 5.81,h: 3.20,barDir: "col",barGrouping: "stacked",barGapWidthPct: 110,dataLabelColor: "FFFFFF",dataLabelFontFace: "Arial",dataLabelFontSize: 9,dataLabelFontBold: true,showValue: true,dataLabelFormatCode: '0"%"', chartColors: ['6D8A42','C6E48B','70A6FF','3A5A81','F28C28'],lineDataSymbolSize: 15,catAxisLabelColor: "969696", catAxisLabelFontFace: "Arial",catAxisLabelFontSize: 8,catAxisOrientation: "minMax",showLegend: false,legendPos: 'l', legendFontSize: 9, showTitle: false,showValAxis: false,valAxisLabelPos: 'none',valAxisLineShow: false,valGridLine:{style: 'none'},};
	
		var ConsumedcountryLevel = data['CM_C5Country'];
        var ConsumedquarterLevel = data['CM_C5Quarter'];
        var Consumedopt=CMC5label2;
        var Q1 = ConsumedquarterLevel["Q1'25"];
        var Q2 = ConsumedquarterLevel["Q2'25"];
        const Consumedq1= Q1.map(item => item.percentage);
        const Consumedq2= Q2.map(item => item.percentage);
        var ConsumedbaseData = [Q1[0].bCount, Q2[0].bCount];
        const ConsumedcountryData = {};
        const Consumed1 = [];
        const Consumed2 = [];
        const Consumed3 = [];
        const Consumed4 = [];
        
        const ConsumedbaseArray = [];

        countryLabel4.forEach(country => {
            if (ConsumedcountryLevel[country]) {
                ConsumedcountryData[country] = ConsumedcountryLevel[country];
            }
        });
                
        for (const country in ConsumedcountryData) {
            const countryData = ConsumedcountryData[country];
            ConsumedbaseArray.push(`n-${countryData[0].bCount}`);
            Consumed1.push(countryData[0].percentage);
            Consumed2.push(countryData[1].percentage);  
            Consumed4.push(countryData[3].percentage);
            Consumed3.push(countryData[2].percentage);
            
        }

        const ConsumedArray = [{
            title: "How is it Consumed?",
            subtitle: "Dairy Milk (Flavored & Unflavored)",
            subtitle1: "Half Yearly (H1’25)",
            subtitle3: "Quarterly – SEA (Q1’25 & Q2’25)",
            countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
            flags: ["","https://keresearch.in/mdynata/assets/images/1.png","https://keresearch.in/mdynata/assets/images/2.png","https://keresearch.in/mdynata/assets/images/3.png","https://keresearch.in/mdynata/assets/images/4.png","https://keresearch.in/mdynata/assets/images/5.png","https://keresearch.in/mdynata/assets/images/6.png"],
            funnel: Consumedopt,
            f:[Consumed1,Consumed2,Consumed3,Consumed4],
            sampleSizes:ConsumedbaseArray,
            bottom1:"C5. How did you have it on this occasion?",
            bottom2:"",
            btm1:"Sig.", btm2:"High/", btm3:"Low", btm4:" vs.", btm5:"previous wave", btm6:" at 95% CI",
            tblB:[ConsumedbaseData[0],ConsumedbaseData[1]],
            table: [
                ["","Q1'25", "Q2'25"],
                [Consumedopt[0],Consumedq1[0]+'%', Consumedq2[0]+'%'],
                [Consumedopt[1],Consumedq1[1]+'%',Consumedq2[1]+'%'],
                [Consumedopt[3],Consumedq1[3]+'%',Consumedq2[3]+'%'],
                [Consumedopt[2],Consumedq1[2]+'%',Consumedq2[2]+'%'],
               
            ],
        }];

        ConsumedArray.forEach(slideData => {
            slide4.addText(slideData.title,topHead_4);
            slide4.addText(slideData.subtitle,subHead_4);
            slide4.addText(slideData.subtitle1,leftHead_4);
            slide4.addText("Base – Those who Consumed in Past 3 months",leftSubHead_4);
            slide4.addText("Base – Those who consumed in Past 3 months",rightSubHead_4);
            slide4.addText(slideData.subtitle3,rightHead_4);
            slide4.addShape(pptx.ShapeType.line, { x: 0.16,y: 1.02,w: 6.51, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide4.addShape(pptx.ShapeType.line, { "x": 6.83,"y": 1.02,"w": 2.46, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide4.addText(slideData.countries[0],{...country1_4,x: 1.01});
            slide4.addText(slideData.countries[1],{...country2_4,x: 1.87});
            slide4.addText(slideData.countries[2],{...country3_4,x: 2.74});
            slide4.addText(slideData.countries[3],{...country4_4,x: 3.55});
            slide4.addText(slideData.countries[4],{...country5_4,x: 4.32});
            slide4.addText(slideData.countries[5],{...country6_4,x: 5.10});
            slide4.addText(slideData.countries[6],{...country7_4,x: 5.91});
            slide4.addImage({ x: 2.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[1] });
            slide4.addImage({ x: 2.94, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[2] });
            slide4.addImage({ x: 3.73, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[3] });
            slide4.addImage({ x: 4.54, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[4] });
            slide4.addImage({ x: 5.33, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[5] });
            slide4.addImage({ x: 6.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[6] });

            [slideData.f[2], slideData.f[3]] = [slideData.f[3], slideData.f[2]];
            const chartData = slideData.f.slice() .reverse().map((freq, i) => ({
					name: slideData.funnel[slideData.f.length - 1 - i], 
					labels: slideData.sampleSizes,
					values: freq,
             }));
             let tnpa=[];
             tnpa = [
                 {
                     type: pptx.charts.BAR,
                     data:chartData ,
                     options: {
                         barGrouping: "stacked",
                     },
                 },
             ];
             slide4.addChart(tnpa, stackChart_4);
             let legendItems = [
                 { color: '3a5a81', text: slideData.funnel[0] },
                 { color: '70a6ff', text: slideData.funnel[1] },
                 { color: 'c6e48b', text: slideData.funnel[3] },
                 { color: '6d8a42', text: slideData.funnel[2] },
                 
             ];
             legendItems.forEach((item, index) => {
                 slide4.addShape(pptx.ShapeType.rect, {
                     x: 0.2,
                     y: 2.2 + index * 0.5,  
                     w: 0.060,
                     h: 0.060,
                     fill: { color: item.color },
                     line: { color: 'FFFFFF' }
                 });
                 slide4.addText(item.text, {
                     x: 0.2,
                     y: 2.24 + index * 0.5,
                     w: 1,
                     fontSize: 7,
                     color: '000000',
                     fontFace: 'Arial'
                 });
             });

             slide4.addText(slideData.bottom1,fText1_4);
             slide4.addText(slideData.bottom2,fText2_4);
             slide4.addShape(pptx.ShapeType.line, { "x": 0.28,"y": 5.06,"w": 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });

             let tableRows = slideData.table.map((row, rowIndex, allRows) =>
                 row.map(cell => ({
                     text: cell,
                     options: {
                         border: (rowIndex === 0 || rowIndex === allRows.length - 1)
                             ? [false, false, false, false] // No border for first and last row
                             : [false, false, true, false], // Bottom border only
                         borderColor: 'e0e0e0',
                         borderSize: 0.5,
                         fontSize: 8,
                         align: 'center',
                         valign: 'middle'
                     }
                 }))
             );
             slide4.addTable(tableRows, {
                 "x": 6.83,
                 "y": 1.46,
                 "w": 2.89,
                 "h": 2.76
             });
             
			slide4.addText("n-"+slideData.tblB[0],tableBase_4);
			slide4.addText("n-"+slideData.tblB[1],{...tableBase_4,x: 9.0});
			
            slide4.addText([
                 { text: slideData.btm1, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm2, options: { color: '00b050',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm3, options: { color: 'ff0000',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm4, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm5, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: true } },
                 { text: slideData.btm6, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } }
             ], {"x": 8.07,"y": 4.84,"w": 1.83,"h": 0.30});

             slide4.addImage({...logo1_4,path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png"});
             slide4.addImage({...logo2_4,path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png"});

             slide4.addShape(pptx.ShapeType.line, {x: 6.74,y: 0.96,w: 0.00,h: 4.09,line: {color:'969696',width:1,dashType:'dash'}});
        });
	
	
	 // Slide 5 Accompanied with…
	
	let topHead_5 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
    let subHead_5 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
    let leftHead_5 = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let leftSubHead_5 = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    let rightHead_5 = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let  rightSubHead_5 = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };

    let country1_5 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country2_5 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country3_5 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country4_5 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country5_5 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country6_5 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country7_5 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

    let opts12_5 = { x: 0.36, y: 2.22, w: 0.96, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts13_5 = { x: 0.34, y: 2.79, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts14_5 = { x: 0.32, y: 3.43, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts15_5 = { x: 0.33, y: 4.04, w: 0.99, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let fText1_5 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
    let fText2_5 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
	
	let tableBase_5 = {"x": 7.95,"y": 4.21,"w": 0.67,"h": 0.30,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};

    let logo1_5 = {"x": 8.51,"y": 5.21,"w": 0.80,"h": 0.28};
    let logo2_5 = {"x": 9.36,"y": 5.18,"w": 0.54,"h": 0.35};
	
	let stackChart_5 = {x: 1.02,y: 1.4,w: 5.81,h: 3.20,barDir: "col",barGrouping: "stacked",barGapWidthPct: 110,dataLabelColor: "FFFFFF",dataLabelFontFace: "Arial",dataLabelFontSize: 9,dataLabelFontBold: true,showValue: true,dataLabelFormatCode: '0"%"', chartColors: ['6D8A42','C6E48B','70A6FF','3A5A81','F28C28'],lineDataSymbolSize: 15,catAxisLabelColor: "969696", catAxisLabelFontFace: "Arial",catAxisLabelFontSize: 8,catAxisOrientation: "minMax",showLegend: false,legendPos: 'l', legendFontSize: 9, showTitle: false,showValAxis: false,valAxisLabelPos: 'none',valAxisLineShow: false,valGridLine:{style: 'none'},};
	
		var AccompanycountryLevel = data['CM_C10Country'];
        var AccompanyquarterLevel = data['CM_C10Quarter'];
        var Accompanyopt=CMC10label;
        var Q1 = AccompanyquarterLevel["Q1'25"];
        var Q2 = AccompanyquarterLevel["Q2'25"];
        const Accompanyq1= Q1.map(item => item.percentage);
        const Accompanyq2= Q2.map(item => item.percentage);
        var AccompanybaseData = [Q1[0].bCount, Q2[0].bCount];
        const AccompanycountryData = {};
        const Accompany1 = [];
        const Accompany2 = [];
        const Accompany3 = [];
        const Accompany4 = [];
        
        const AccompanybaseArray = [];

        countryLabel4.forEach(country => {
            if (AccompanycountryLevel[country]) {
                AccompanycountryData[country] = AccompanycountryLevel[country];
            }
        });
                
        for (const country in AccompanycountryData) {
            const countryData = AccompanycountryData[country];
            AccompanybaseArray.push(`n-${countryData[0].bCount}`);
            Accompany1.push(countryData[0].percentage);
            Accompany2.push(countryData[1].percentage);
            Accompany3.push(countryData[2].percentage);
            Accompany4.push(countryData[3].percentage);
            
        }

        const AccompanyArray = [{
            title: "Accompanied with…",
            subtitle: "Dairy Milk (Flavored & Unflavored)",
            subtitle1: "Half Yearly (H1’25)",
            subtitle3: "Quarterly – SEA (Q1’25 & Q2’25)",
            countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
            flags: ["","https://keresearch.in/mdynata/assets/images/1.png","https://keresearch.in/mdynata/assets/images/2.png","https://keresearch.in/mdynata/assets/images/3.png","https://keresearch.in/mdynata/assets/images/4.png","https://keresearch.in/mdynata/assets/images/5.png","https://keresearch.in/mdynata/assets/images/6.png"],
            funnel: Accompanyopt,
            f:[Accompany1,Accompany2,Accompany3,Accompany4],
            sampleSizes:AccompanybaseArray,
            bottom1:"C10. Did you have it along with anything else or by itself on this occasion?",
            bottom2:"",
            btm1:"Sig.", btm2:"High/", btm3:"Low", btm4:" vs.", btm5:"previous wave", btm6:" at 95% CI",
            tblB:[AccompanybaseData[0],AccompanybaseData[1]],
            table: [
                ["","Q1'25", "Q2'25"],
                [Accompanyopt[0],Accompanyq1[0]+'%', Accompanyq2[0]+'%'],
                [Accompanyopt[1],Accompanyq1[1]+'%',Accompanyq2[1]+'%'],
                [Accompanyopt[2],Accompanyq1[2]+'%',Accompanyq2[2]+'%'],
                [Accompanyopt[3],Accompanyq1[3]+'%',Accompanyq2[3]+'%'],
                
            ],
        }];

        AccompanyArray.forEach(slideData => {
            slide5.addText(slideData.title,topHead_5);
            slide5.addText(slideData.subtitle,subHead_5);
            slide5.addText(slideData.subtitle1,leftHead_5);
            slide5.addText("Base – Accompany in Past 3 months",leftSubHead_5);
            slide5.addText("Base – Those who consumed in Past 3 months",rightSubHead_5);
            slide5.addText(slideData.subtitle3,rightHead_5);
            slide5.addShape(pptx.ShapeType.line, { x: 0.16,y: 1.02,w: 6.51, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide5.addShape(pptx.ShapeType.line, { "x": 6.83,"y": 1.02,"w": 2.46, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide5.addText(slideData.countries[0],{...country1_5,x: 1.01});
            slide5.addText(slideData.countries[1],{...country2_5,x: 1.87});
            slide5.addText(slideData.countries[2],{...country3_5,x: 2.74});
            slide5.addText(slideData.countries[3],{...country4_5,x: 3.55});
            slide5.addText(slideData.countries[4],{...country5_5,x: 4.32});
            slide5.addText(slideData.countries[5],{...country6_5,x: 5.10});
            slide5.addText(slideData.countries[6],{...country7_5,x: 5.91});
            slide5.addImage({ x: 2.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[1] });
            slide5.addImage({ x: 2.94, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[2] });
            slide5.addImage({ x: 3.73, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[3] });
            slide5.addImage({ x: 4.54, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[4] });
            slide5.addImage({ x: 5.33, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[5] });
            slide5.addImage({ x: 6.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[6] });

            const chartData = slideData.f.slice() .reverse().map((freq, i) => ({
					name: slideData.funnel[slideData.f.length - 1 - i], 
					labels: slideData.sampleSizes,
					values: freq,
             }));
             let tnpa=[];
             tnpa = [
                 {
                     type: pptx.charts.BAR,
                     data:chartData ,
                     options: {
                         barGrouping: "stacked",
                     },
                 },
             ];
             slide5.addChart(tnpa, stackChart_5);
             let legendItems = [
                 { color: '3A5A81', text: slideData.funnel[0] },
                 { color: '70A6FF', text: slideData.funnel[1] },
                 { color: 'C6E48B', text: slideData.funnel[2] },
                 { color: '6D8A42', text: slideData.funnel[3] },
                 
             ];
             legendItems.forEach((item, index) => {
                 slide5.addShape(pptx.ShapeType.rect, {
                     x: 0.2,
                     y: 2.2 + index * 0.5,  
                     w: 0.060,
                     h: 0.060,
                     fill: { color: item.color },
                     line: { color: 'FFFFFF' }
                 });
                 slide5.addText(item.text, {
                     x: 0.2,
                     y: 2.24 + index * 0.5,
                     fontSize: 7,
                     color: '000000',
                     fontFace: 'Arial'
                 });
             });

             slide5.addText(slideData.bottom1,fText1_5);
             slide5.addText(slideData.bottom2,fText2_5);
             slide5.addShape(pptx.ShapeType.line, { "x": 0.28,"y": 5.06,"w": 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });

             let tableRows = slideData.table.map((row, rowIndex, allRows) =>
                 row.map(cell => ({
                     text: cell,
                     options: {
                         border: (rowIndex === 0 || rowIndex === allRows.length - 1)
                             ? [false, false, false, false] // No border for first and last row
                             : [false, false, true, false], // Bottom border only
                         borderColor: 'e0e0e0',
                         borderSize: 0.5,
                         fontSize: 8,
                         align: 'center',
                         valign: 'middle'
                     }
                 }))
             );
             slide5.addTable(tableRows, {
                 "x": 6.83,
                 "y": 1.46,
                 "w": 2.89,
                 "h": 2.76
             });
             
			slide5.addText("n-"+slideData.tblB[0],tableBase_5);
			slide5.addText("n-"+slideData.tblB[1],{...tableBase_5,x: 9.0});
			
            slide5.addText([
                 { text: slideData.btm1, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm2, options: { color: '00b050',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm3, options: { color: 'ff0000',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm4, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm5, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: true } },
                 { text: slideData.btm6, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } }
             ], {"x": 8.07,"y": 4.84,"w": 1.83,"h": 0.30});

             slide5.addImage({...logo1_5,path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png"});
             slide5.addImage({...logo2_5,path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png"});

             slide5.addShape(pptx.ShapeType.line, {x: 6.74,y: 0.96,w: 0.00,h: 4.09,line: {color:'969696',width:1,dashType:'dash'}});
        });
	
	 
	 // Slide 6 Temperature of Milk
	
	let topHead_6 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
    let subHead_6 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
     let leftHead_6 = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let leftSubHead_6 = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    let rightHead_6 = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let  rightSubHead_6 = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };

    let country1_6 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country2_6 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country3_6 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country4_6 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country5_6 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country6_6 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country7_6 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };


    let opts12_6 = { x: 0.36, y: 2.22, w: 0.96, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts13_6 = { x: 0.34, y: 2.79, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts14_6 = { x: 0.32, y: 3.43, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts15_6 = { x: 0.33, y: 4.04, w: 0.99, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let fText1_6 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
    let fText2_6 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
	
	let tableBase_6 = {"x": 7.95,"y": 4.21,"w": 0.67,"h": 0.30,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};

    let logo1_6 = {"x": 8.51,"y": 5.21,"w": 0.80,"h": 0.28};
    let logo2_6 = {"x": 9.36,"y": 5.18,"w": 0.54,"h": 0.35};
	
	let stackChart_6 = {x: 1.02,y: 1.4,w: 5.81,h: 3.20,barDir: "col",barGrouping: "stacked",barGapWidthPct: 110,dataLabelColor: "FFFFFF",dataLabelFontFace: "Arial",dataLabelFontSize: 9,dataLabelFontBold: true,showValue: true,dataLabelFormatCode: '0"%"', chartColors: ['70A6FF','3A5A81','F28C28','6D8A42','C6E48B'],lineDataSymbolSize: 15,catAxisLabelColor: "969696", catAxisLabelFontFace: "Arial",catAxisLabelFontSize: 8,catAxisOrientation: "minMax",showLegend: false,legendPos: 'l', legendFontSize: 9, showTitle: false,showValAxis: false,valAxisLabelPos: 'none',valAxisLineShow: false,valGridLine:{style: 'none'},};
	
		var TemperaturecountryLevel = data['CM_C4bCountry'];
        var TemperaturequarterLevel = data['CM_C4bQuarter'];
        var Temperatureopt=CMC4blabel;
        var Q1 = TemperaturequarterLevel["Q1'25"];
        var Q2 = TemperaturequarterLevel["Q2'25"];
        const Temperatureq1= Q1.map(item => item.percentage);
        const Temperatureq2= Q2.map(item => item.percentage);
        var TemperaturebaseData = [Q1[0].bCount, Q2[0].bCount];
        const TemperaturecountryData = {};
        const Temperature1 = [];
        const Temperature2 = [];
       
        
        const TemperaturebaseArray = [];

        countryLabel4.forEach(country => {
            if (TemperaturecountryLevel[country]) {
                TemperaturecountryData[country] = TemperaturecountryLevel[country];
            }
        });
                
        for (const country in TemperaturecountryData) {
            const countryData = TemperaturecountryData[country];
            TemperaturebaseArray.push(`n-${countryData[0].bCount}`);
            
            Temperature2.push(countryData[1].percentage);
            Temperature1.push(countryData[0].percentage);
           
            
        }

        const TemperatureArray = [{
            title: "Accompanied with…",
            subtitle: "Dairy Milk (Flavored & Unflavored)",
            subtitle1: "Half Yearly (H1’25)",
            subtitle3: "Quarterly – SEA (Q1’25 & Q2’25)",
            countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
            flags: ["","https://keresearch.in/mdynata/assets/images/1.png","https://keresearch.in/mdynata/assets/images/2.png","https://keresearch.in/mdynata/assets/images/3.png","https://keresearch.in/mdynata/assets/images/4.png","https://keresearch.in/mdynata/assets/images/5.png","https://keresearch.in/mdynata/assets/images/6.png"],
            funnel: Temperatureopt,
            f:[Temperature1,Temperature2],
            sampleSizes:TemperaturebaseArray,
            bottom1:"C4b. Did you have it…?",
            bottom2:"",
            btm1:"Sig.", btm2:"High/", btm3:"Low", btm4:" vs.", btm5:"previous wave", btm6:" at 95% CI",
            tblB:[TemperaturebaseData[0],TemperaturebaseData[1]],
            table: [
                ["","Q1'25", "Q2'25"],
                
                [Temperatureopt[1],Temperatureq1[1]+'%',Temperatureq2[1]+'%'],
                [Temperatureopt[0],Temperatureq1[0]+'%', Temperatureq2[0]+'%'],
                
                
            ],
        }];

        TemperatureArray.forEach(slideData => {
            slide6.addText(slideData.title,topHead_6);
            slide6.addText(slideData.subtitle,subHead_6);
            slide6.addText(slideData.subtitle1,leftHead_6);
            slide6.addText("Base – Temperature in Past 3 months",leftSubHead_6);
            slide6.addText("Base – Those who consumed in Past 3 months",rightSubHead_6);
            slide6.addText(slideData.subtitle3,rightHead_6);
            slide6.addShape(pptx.ShapeType.line, { x: 0.16,y: 1.02,w: 6.51, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide6.addShape(pptx.ShapeType.line, { "x": 6.83,"y": 1.02,"w": 2.46, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide6.addText(slideData.countries[0],{...country1_6,x: 1.01});
            slide6.addText(slideData.countries[1],{...country2_6,x: 1.87});
            slide6.addText(slideData.countries[2],{...country3_6,x: 2.74});
            slide6.addText(slideData.countries[3],{...country4_6,x: 3.55}); 
            slide6.addText(slideData.countries[4],{...country5_6,x: 4.32});
            slide6.addText(slideData.countries[5],{...country6_6,x: 5.10});
            slide6.addText(slideData.countries[6],{...country7_6,x: 5.91});
            slide6.addImage({ x: 2.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[1] });
            slide6.addImage({ x: 2.94, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[2] });
            slide6.addImage({ x: 3.73, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[3] });
            slide6.addImage({ x: 4.54, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[4] });
            slide6.addImage({ x: 5.33, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[5] });
            slide6.addImage({ x: 6.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[6] });

            
            [slideData.f[0], slideData.f[1]] = [slideData.f[1], slideData.f[0]];
            const chartData = slideData.f.slice() .reverse().map((freq, i) => ({
					name: slideData.funnel[slideData.f.length - 1 - i], 
					labels: slideData.sampleSizes,
					values: freq,
             }));
             let tnpa=[];
             tnpa = [
                 {
                     type: pptx.charts.BAR,
                     data:chartData ,
                     options: {
                         barGrouping: "stacked",
                     },
                 },
             ];
             slide6.addChart(tnpa, stackChart_6);
             let legendItems = [
                 { color: '3A5A81', text: slideData.funnel[1] },
                 { color: '70A6FF', text: slideData.funnel[0] },
             ];
             legendItems.forEach((item, index) => {
                 slide6.addShape(pptx.ShapeType.rect, {
                     x: 0.2,
                     y: 2.2 + index * 0.5,  
                     w: 0.060,
                     h: 0.060,
                     fill: { color: item.color },
                     line: { color: 'FFFFFF' }
                 });
                 slide6.addText(item.text, {
                     x: 0.2,
                     y: 2.24 + index * 0.5,
                     w: 1,
                     fontSize: 7,
                     color: '000000',
                     fontFace: 'Arial'
                 });
             });

             slide6.addText(slideData.bottom1,fText1_6);
             slide6.addText(slideData.bottom2,fText2_6);
             slide6.addShape(pptx.ShapeType.line, { "x": 0.28,"y": 5.06,"w": 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });

             let tableRows = slideData.table.map((row, rowIndex, allRows) =>
                 row.map(cell => ({
                     text: cell,
                     options: {
                         border: (rowIndex === 0 || rowIndex === allRows.length - 1)
                             ? [false, false, false, false] // No border for first and last row
                             : [false, false, true, false], // Bottom border only
                         borderColor: 'e0e0e0',
                         borderSize: 0.5,
                         fontSize: 8,
                         align: 'center',
                         valign: 'middle'
                     }
                 }))
             );
             slide6.addTable(tableRows, {
                 "x": 6.83,
                 "y": 1.46,
                 "w": 2.89,
                 "h": 2.76
             });
             
			slide6.addText("n-"+slideData.tblB[0],tableBase_6);
			slide6.addText("n-"+slideData.tblB[1],{...tableBase_6,x: 9.0});
			
            slide6.addText([
                 { text: slideData.btm1, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm2, options: { color: '00b050',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm3, options: { color: 'ff0000',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm4, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm5, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: true } },
                 { text: slideData.btm6, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } }
             ], {"x": 8.07,"y": 4.84,"w": 1.83,"h": 0.30});

             slide6.addImage({...logo1_6,path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png"});
             slide6.addImage({...logo2_6,path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png"});

             slide6.addShape(pptx.ShapeType.line, {x: 6.74,y: 0.96,w: 0.00,h: 4.09,line: {color:'969696',width:1,dashType:'dash'}});
        });
	
	
	  // Slide 7 Packaging Size
	
	let topHead_7 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
    let subHead_7 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
    let leftHead_7 = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let leftSubHead_7 = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    let rightHead_7 = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let  rightSubHead_7 = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };

    let country1_7 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country2_7 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country3_7 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country4_7 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country5_7 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country6_7 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country7_7 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

    let opts12_7 = { x: 0.36, y: 2.22, w: 0.96, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts13_7 = { x: 0.34, y: 2.79, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts14_7 = { x: 0.32, y: 3.43, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts15_7 = { x: 0.33, y: 4.04, w: 0.99, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let fText1_7 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
    let fText2_7 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
	
	let tableBase_7 = {"x": 7.95,"y": 4.21,"w": 0.67,"h": 0.30,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};

    let logo1_7 = {"x": 8.51,"y": 5.21,"w": 0.80,"h": 0.28};
    let logo2_7 = {"x": 9.36,"y": 5.18,"w": 0.54,"h": 0.35};
	
	let stackChart_7 = {x: 1.02,y: 1.4,w: 5.81,h: 3.20,barDir: "col",barGrouping: "stacked",barGapWidthPct: 110,dataLabelColor: "FFFFFF",dataLabelFontFace: "Arial",dataLabelFontSize: 9,dataLabelFontBold: true,showValue: true,dataLabelFormatCode: '0"%"', chartColors: ['70A6FF','3A5A81'],lineDataSymbolSize: 15,catAxisLabelColor: "969696", catAxisLabelFontFace: "Arial",catAxisLabelFontSize: 8,catAxisOrientation: "minMax",showLegend: false,legendPos: 'l', legendFontSize: 9, showTitle: false,showValAxis: false,valAxisLabelPos: 'none',valAxisLineShow: false,valGridLine:{style: 'none'},};
	
		var PackcountryLevel = data['CM_C7Country'];
        var PackquarterLevel = data['CM_C7Quarter'];
        var Packopt=CMC7label;
        var Q1 = PackquarterLevel["Q1'25"];
        var Q2 = PackquarterLevel["Q2'25"];
        const Packq1= Q1.map(item => item.percentage);
        const Packq2= Q2.map(item => item.percentage);
        var PackbaseData = [Q1[0].bCount, Q2[0].bCount];
        const PackcountryData = {};
        const Pack1 = [];
        const Pack2 = [];
       
        
        const PackbaseArray = [];

        countryLabel4.forEach(country => {
            if (PackcountryLevel[country]) {
                PackcountryData[country] = PackcountryLevel[country];
            }
        });
                
        for (const country in PackcountryData) {
            const countryData = PackcountryData[country];
            PackbaseArray.push(`n-${countryData[0].bCount}`);
            Pack2.push(countryData[1].percentage);
            Pack1.push(countryData[0].percentage);
           
            
        }

        const PackArray = [{
            title: "Packaging Size",
            subtitle: "Dairy Milk (Flavored & Unflavored)",
            subtitle1: "Half Yearly (H1’25)",
            subtitle3: "Quarterly – SEA (Q1’25 & Q2’25)",
            countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
            flags: ["","https://keresearch.in/mdynata/assets/images/1.png","https://keresearch.in/mdynata/assets/images/2.png","https://keresearch.in/mdynata/assets/images/3.png","https://keresearch.in/mdynata/assets/images/4.png","https://keresearch.in/mdynata/assets/images/5.png","https://keresearch.in/mdynata/assets/images/6.png"],
            funnel: Packopt,
            f:[Pack1,Pack2],
            sampleSizes:PackbaseArray,
            bottom1:"C7. Was it…?",
            bottom2:"",
            btm1:"Sig.", btm2:"High/", btm3:"Low", btm4:" vs.", btm5:"previous wave", btm6:" at 95% CI",
            tblB:[PackbaseData[0],PackbaseData[1]],
            table: [
                ["","Q1'25", "Q2'25"],
                [Packopt[1],Packq1[1]+'%',Packq2[1]+'%'],
                [Packopt[0],Packq1[0]+'%', Packq2[0]+'%'],
                
                
            ],
        }];

        PackArray.forEach(slideData => {
            slide7.addText(slideData.title,topHead_7);
            slide7.addText(slideData.subtitle,subHead_7);
            slide7.addText(slideData.subtitle1,leftHead_7);
            slide7.addText("Base – Pack in Past 3 months",leftSubHead_7);
            slide7.addText("Base – Those who consumed in Past 3 months",rightSubHead_7);
            slide7.addText(slideData.subtitle3,rightHead_7);
            slide7.addShape(pptx.ShapeType.line, { x: 0.16,y: 1.02,w: 6.51, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide7.addShape(pptx.ShapeType.line, { "x": 6.83,"y": 1.02,"w": 2.46, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide7.addText(slideData.countries[0],{...country1_7,x: 1.01});
            slide7.addText(slideData.countries[1],{...country2_7,x: 1.87});
            slide7.addText(slideData.countries[2],{...country3_7,x: 2.74});
            slide7.addText(slideData.countries[3],{...country4_7,x: 3.55});
            slide7.addText(slideData.countries[4],{...country5_7,x: 4.32});
            slide7.addText(slideData.countries[5],{...country6_7,x: 5.10});
            slide7.addText(slideData.countries[6],{...country7_7,x: 5.91});
            slide7.addImage({ x: 2.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[1] });
            slide7.addImage({ x: 2.94, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[2] });
            slide7.addImage({ x: 3.73, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[3] });
            slide7.addImage({ x: 4.54, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[4] });
            slide7.addImage({ x: 5.33, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[5] });
            slide7.addImage({ x: 6.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[6] });

            [slideData.f[0], slideData.f[1]] = [slideData.f[1], slideData.f[0]];
            const chartData = slideData.f.slice() .reverse().map((freq, i) => ({
					name: slideData.funnel[slideData.f.length - 1 - i], 
					labels: slideData.sampleSizes,
					values: freq,
             }));
             let tnpa=[];
             tnpa = [
                 {
                     type: pptx.charts.BAR,
                     data:chartData ,
                     options: {
                         barGrouping: "stacked",
                     },
                 },
             ];
             slide7.addChart(tnpa, stackChart_7);
             let legendItems = [
                 { color: '3A5A81', text: slideData.funnel[1] },
                 { color: '70A6FF', text: slideData.funnel[0] },
                 
                 
             ];
             legendItems.forEach((item, index) => {
                 slide7.addShape(pptx.ShapeType.rect, {
                     x: 0.2,
                     y: 2.2 + index * 0.5,  
                     w: 0.060,
                     h: 0.060,
                     fill: { color: item.color },
                     line: { color: 'FFFFFF' }
                 });
                 slide7.addText(item.text, {
                     x: 0.2,
                     y: 2.24 + index * 0.5,
                     w: 1,
                     fontSize: 7,
                     color: '000000',
                     fontFace: 'Arial'
                 });
             });

             slide7.addText(slideData.bottom1,fText1_7);
             slide7.addText(slideData.bottom2,fText2_7);
             slide7.addShape(pptx.ShapeType.line, { "x": 0.28,"y": 5.06,"w": 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });

             let tableRows = slideData.table.map((row, rowIndex, allRows) =>
                 row.map(cell => ({
                     text: cell,
                     options: {
                         border: (rowIndex === 0 || rowIndex === allRows.length - 1)
                             ? [false, false, false, false] // No border for first and last row
                             : [false, false, true, false], // Bottom border only
                         borderColor: 'e0e0e0',
                         borderSize: 0.5,
                         fontSize: 8,
                         align: 'center',
                         valign: 'middle'
                     }
                 }))
             );
             slide7.addTable(tableRows, {
                 "x": 6.83,
                 "y": 1.46,
                 "w": 2.89,
                 "h": 2.76
             });
             
			slide7.addText("n-"+slideData.tblB[0],tableBase_7);
			slide7.addText("n-"+slideData.tblB[1],{...tableBase_7,x: 9.13});
			
            slide7.addText([
                 { text: slideData.btm1, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm2, options: { color: '00b050',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm3, options: { color: 'ff0000',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm4, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm5, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: true } },
                 { text: slideData.btm6, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } }
             ], {"x": 8.07,"y": 4.84,"w": 1.83,"h": 0.30});

             slide7.addImage({...logo1_7,path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png"});
             slide7.addImage({...logo2_7,path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png"});

             slide7.addShape(pptx.ShapeType.line, {x: 6.74,y: 0.96,w: 0.00,h: 4.09,line: {color:'969696',width:1,dashType:'dash'}});
        });
		
		  // Slide 8 PackTaging Type
	
	let topHead_8 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
    let subHead_8 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
    let leftHead_8 = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let leftSubHead_8 = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    let rightHead_8 = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let  rightSubHead_8 = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };

    let country1_8 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country2_8 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country3_8 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country4_8 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country5_8 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country6_8 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country7_8 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

    let opts12_8 = { x: 0.36, y: 2.22, w: 0.96, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts13_8 = { x: 0.34, y: 2.79, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts14_8 = { x: 0.32, y: 3.43, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts15_8 = { x: 0.33, y: 4.04, w: 0.99, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let fText1_8 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
    let fText2_8 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
	
	let tableBase_8 = {"x": 7.95,"y": 4.21,"w": 0.67,"h": 0.30,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};

    let logo1_8 = {"x": 8.51,"y": 5.21,"w": 0.80,"h": 0.28};
    let logo2_8 = {"x": 9.36,"y": 5.18,"w": 0.54,"h": 0.35};
	
	let stackChart_8 = {x: 1.02,y: 1.4,w: 5.81,h: 3.20,barDir: "col",barGrouping: "stacked",barGapWidthPct: 110,dataLabelColor: "FFFFFF",dataLabelFontFace: "Arial",dataLabelFontSize: 9,dataLabelFontBold: true,showValue: true,dataLabelFormatCode: '0"%"', chartColors: ['F28C28','6D8A42','C6E48B','70A6FF','3A5A81'],lineDataSymbolSize: 15,catAxisLabelColor: "969696", catAxisLabelFontFace: "Arial",catAxisLabelFontSize: 8,catAxisOrientation: "minMax",showLegend: false,legendPos: 'l', legendFontSize: 9, showTitle: false,showValAxis: false,valAxisLabelPos: 'none',valAxisLineShow: false,valGridLine:{style: 'none'},};
	
		var PackTcountryLevel = data['CM_C6Country'];
        var PackTquarterLevel = data['CM_C6Quarter'];
        var PackTopt=CMC6label;
        var Q1 = PackTquarterLevel["Q1'25"];
        var Q2 = PackTquarterLevel["Q2'25"];
        const PackTq1= Q1.map(item => item.percentage);
        const PackTq2= Q2.map(item => item.percentage);
        var PackTbaseData = [Q1[0].bCount, Q2[0].bCount];
        const PackTcountryData = {};
        const PackT1 = [];
        const PackT2 = [];
		const PackT3 = [];
		const PackT4 = [];
		const PackT5 = [];
		// const PackT6 = [];
       
        
        const PackTbaseArray = [];

        countryLabel4.forEach(country => {
            if (PackTcountryLevel[country]) {
                PackTcountryData[country] = PackTcountryLevel[country];
            }
        });
                
        for (const country in PackTcountryData) {
            const countryData = PackTcountryData[country];
            PackTbaseArray.push(`n-${countryData[0].bCount}`);
			PackT4.push(countryData[3].percentage);
			PackT3.push(countryData[2].percentage);
            PackT1.push(countryData[0].percentage);
			PackT5.push(countryData[4].percentage);
            PackT2.push(countryData[1].percentage);
			// PackT6.push(countryData[5].percentage);
            
        }

        const PackTArray = [{
            title: "PackTaging Type",
            subtitle: "Dairy Milk (Flavored & Unflavored)",
            subtitle1: "Half Yearly (H1’25)",
            subtitle3: "Quarterly – SEA (Q1’25 & Q2’25)",
            countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
            flags: ["","https://keresearch.in/mdynata/assets/images/1.png","https://keresearch.in/mdynata/assets/images/2.png","https://keresearch.in/mdynata/assets/images/3.png","https://keresearch.in/mdynata/assets/images/4.png","https://keresearch.in/mdynata/assets/images/5.png","https://keresearch.in/mdynata/assets/images/6.png"],
            funnel: PackTopt,
            // f:[PackT1,PackT2,PackT3,PackT4,PackT5,PackT6],
            f:[PackT4, PackT3, PackT1, PackT5, PackT2],
            sampleSizes:PackTbaseArray,
            bottom1:"C6. What type of packaging did it come in?",
            bottom2:"",
            btm1:"Sig.", btm2:"High/", btm3:"Low", btm4:" vs.", btm5:"previous wave", btm6:" at 95% CI",
            tblB:[PackTbaseData[0],PackTbaseData[1]],
            table: [
                ["","Q1'25", "Q2'25"],
                [PackTopt[3],PackTq1[3]+'%',PackTq2[3]+'%'],
                [PackTopt[2],PackTq1[2]+'%',PackTq2[2]+'%'],
                [PackTopt[0],PackTq1[0]+'%', PackTq2[0]+'%'],
				[PackTopt[4],PackTq1[4]+'%',PackTq2[4]+'%'],
                [PackTopt[1],PackTq1[1]+'%',PackTq2[1]+'%'],
				// [PackTopt[5],PackTq1[5]+'%',PackTq2[5]+'%'],
            ],
        }];

        PackTArray.forEach(slideData => {
            slide8.addText(slideData.title,topHead_8);
            slide8.addText(slideData.subtitle,subHead_8);
            slide8.addText(slideData.subtitle1,leftHead_8);
            slide8.addText("Base – PackT in Past 3 months",leftSubHead_8);
            slide8.addText("Base – Those who consumed in Past 3 months",rightSubHead_8);
            slide8.addText(slideData.subtitle3,rightHead_8);
            slide8.addShape(pptx.ShapeType.line, { x: 0.16,y: 1.02,w: 6.51, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide8.addShape(pptx.ShapeType.line, { "x": 6.83,"y": 1.02,"w": 2.46, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide8.addText(slideData.countries[0],{...country1_8,x: 1.01});
            slide8.addText(slideData.countries[1],{...country2_8,x: 1.87});
            slide8.addText(slideData.countries[2],{...country3_8,x: 2.74});
            slide8.addText(slideData.countries[3],{...country4_8,x: 3.55});
            slide8.addText(slideData.countries[4],{...country5_8,x: 4.32});
            slide8.addText(slideData.countries[5],{...country6_8,x: 5.10});
            slide8.addText(slideData.countries[6],{...country7_8,x: 5.91});
            slide8.addImage({ x: 2.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[1] });
            slide8.addImage({ x: 2.94, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[2] });
            slide8.addImage({ x: 3.73, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[3] });
            slide8.addImage({ x: 4.54, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[4] });
            slide8.addImage({ x: 5.33, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[5] });
            slide8.addImage({ x: 6.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[6] });

            const chartData = slideData.f.slice() .reverse().map((freq, i) => ({
					name: slideData.funnel[slideData.f.length - 1 - i], 
					labels: slideData.sampleSizes,
					values: freq,
             }));
             let tnpa=[];
             tnpa = [
                 {
                     type: pptx.charts.BAR,
                     data:chartData ,
                     options: {
                         barGrouping: "stacked",
                     },
                 },
             ];
             slide8.addChart(tnpa, stackChart_8);
             let legendItems = [
                 { color: '3A5A81', text: slideData.funnel[3] },
                 { color: '70A6FF', text: slideData.funnel[2] },
                 { color: 'C6E48B', text: slideData.funnel[0] },
                 { color: '6D8A42', text: slideData.funnel[4] },
                 { color: 'F28C28', text: slideData.funnel[1] },
				//  { color: 'F7B267', text: slideData.funnel[5] },
                 
                 
             ];
             legendItems.forEach((item, index) => {
                 slide8.addShape(pptx.ShapeType.rect, {
                     x: 0.2,
                     y: 2.2 + index * 0.5,  
                     w: 0.060,
                     h: 0.060,
                     fill: { color: item.color },
                     line: { color: 'FFFFFF' }
                 });
                 slide8.addText(item.text, {
                     x: 0.2,
                     y: 2.24 + index * 0.5,
                     w: 1,
                     fontSize: 7,
                     color: '000000',
                     fontFace: 'Arial'
                 });
             });

             slide8.addText(slideData.bottom1,fText1_8);
             slide8.addText(slideData.bottom2,fText2_8);
             slide8.addShape(pptx.ShapeType.line, { "x": 0.28,"y": 5.06,"w": 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });

             let tableRows = slideData.table.map((row, rowIndex, allRows) =>
                 row.map(cell => ({
                     text: cell,
                     options: {
                         border: (rowIndex === 0 || rowIndex === allRows.length - 1)
                             ? [false, false, false, false] // No border for first and last row
                             : [false, false, true, false], // Bottom border only
                         borderColor: 'e0e0e0',
                         borderSize: 0.5,
                         fontSize: 8,
                         align: 'center',
                         valign: 'middle'
                     }
                 }))
             );
             slide8.addTable(tableRows, {
                 "x": 6.83,
                 "y": 1.46,
                 "w": 2.89,
                 "h": 2.76
             });
             
			slide8.addText("n-"+slideData.tblB[0],tableBase_8);
			slide8.addText("n-"+slideData.tblB[1],{...tableBase_8,x: 9.0});
			
            slide8.addText([
                 { text: slideData.btm1, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm2, options: { color: '00b050',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm3, options: { color: 'ff0000',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm4, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm5, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: true } },
                 //{ text: slideData.btm6, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } }
             ], {"x": 8.07,"y": 4.84,"w": 1.83,"h": 0.30});

             slide8.addImage({...logo1_8,path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png"});
             slide8.addImage({...logo2_8,path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png"});

             slide8.addShape(pptx.ShapeType.line, {x: 6.74,y: 0.96,w: 0.00,h: 4.09,line: {color:'969696',width:1,dashType:'dash'}});
        });


    // Slide 10 Place of consumption
	
	let topHead_10 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
    let subHead_10 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
    let leftHead_10 = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let leftSubHead_10 = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    let rightHead_10 = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let  rightSubHead_10 = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };

    
    let country1_10 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country2_10 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country3_10 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country4_10 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country5_10 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country6_10 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country7_10 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };


    let opts12_10 = { x: 0.36, y: 2.22, w: 0.96, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts13_10 = { x: 0.34, y: 2.79, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts14_10 = { x: 0.32, y: 3.43, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts15_10 = { x: 0.33, y: 4.04, w: 0.99, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let fText1_10 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
    let fText2_10 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
	
	let tableBase_10 = {"x": 7.95,"y": 4.21,"w": 0.67,"h": 0.30,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};

    let logo1_10 = {"x": 8.51,"y": 5.21,"w": 0.80,"h": 0.28};
    let logo2_10 = {"x": 9.36,"y": 5.18,"w": 0.54,"h": 0.35};
	
	let stackChart_10 = {x: 1.02,y: 1.4,w: 5.81,h: 3.20,barDir: "col",barGrouping: "stacked",barGapWidthPct: 110,dataLabelColor: "FFFFFF",dataLabelFontFace: "Arial",dataLabelFontSize: 9,dataLabelFontBold: true,showValue: true,dataLabelFormatCode: '0"%"', chartColors: ['7f7f7f','f2ad61','F28C28','6D8A42','C6E48B','70A6FF','3A5A81'],lineDataSymbolSize: 15,catAxisLabelColor: "969696", catAxisLabelFontFace: "Arial",catAxisLabelFontSize: 8,catAxisOrientation: "minMax",showLegend: false,legendPos: 'l', legendFontSize: 9, showTitle: false,showValAxis: false,valAxisLabelPos: 'none',valAxisLineShow: false,valGridLine:{style: 'none'},};
	
		var consumptionPlacecountryLevel = data['CM_C9Country'];
        var consumptionPlacequarterLevel = data['CM_C9Quarter'];
        var consumptionPlaceopt=CMC9label;
        var Q1 = consumptionPlacequarterLevel["Q1'25"];
        var Q2 = consumptionPlacequarterLevel["Q2'25"];
        const consumptionPlaceq1= Q1.map(item => item.percentage);
        const consumptionPlaceq2= Q2.map(item => item.percentage);
        var consumptionPlacebaseData = [Q1[0].bCount, Q2[0].bCount];
        const consumptionPlacecountryData = {};
        const consumptionPlace1 = [];
        const consumptionPlace2 = [];
        const consumptionPlace3 = [];
        const consumptionPlace4 = [];
        const consumptionPlace5 = [];
        const consumptionPlace6 = [];
        const consumptionPlace7 = [];
        const consumptionPlacebaseArray = [];

        countryLabel4.forEach(country => {
            if (consumptionPlacecountryLevel[country]) {
                consumptionPlacecountryData[country] = consumptionPlacecountryLevel[country];
            }
        });
                
        for (const country in consumptionPlacecountryData) {
            const countryData = consumptionPlacecountryData[country];
            consumptionPlacebaseArray.push(`n-${countryData[0].bCount}`);
            consumptionPlace1.push(countryData[0].percentage);
            consumptionPlace2.push(countryData[1].percentage);
            consumptionPlace3.push(countryData[2].percentage);
            consumptionPlace4.push(countryData[3].percentage);
            consumptionPlace5.push(countryData[4].percentage);
            consumptionPlace6.push(countryData[5].percentage);
            consumptionPlace7.push(countryData[6].percentage);
        }

        const consumptionPlaceArray = [{
            title: "Place of Consumption",
            subtitle: "Dairy Milk (Flavored & Unflavored)",
            subtitle1: "Half Yearly (H1’25)",
            subtitle3: "Quarterly – SEA (Q1’25 & Q2’25)",
            countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
            flags: ["","https://keresearch.in/mdynata/assets/images/1.png","https://keresearch.in/mdynata/assets/images/2.png","https://keresearch.in/mdynata/assets/images/3.png","https://keresearch.in/mdynata/assets/images/4.png","https://keresearch.in/mdynata/assets/images/5.png","https://keresearch.in/mdynata/assets/images/6.png"],
            funnel: consumptionPlaceopt,
            f:[consumptionPlace1,consumptionPlace2,consumptionPlace3,consumptionPlace4,consumptionPlace5, consumptionPlace6, consumptionPlace7],
            sampleSizes:consumptionPlacebaseArray,
            bottom1:"C2. Where did you have it?",
            bottom2:"",
            btm1:"Sig.", btm2:"High/", btm3:"Low", btm4:" vs.", btm5:"previous wave", btm6:" at 95% CI",
            tblB:[consumptionPlacebaseData[0],consumptionPlacebaseData[1]],
            table: [
                ["","Q1'25", "Q2'25"],
                [consumptionPlaceopt[0],consumptionPlaceq1[0]+'%', consumptionPlaceq2[0]+'%'],
                [consumptionPlaceopt[1],consumptionPlaceq1[1]+'%',consumptionPlaceq2[1]+'%'],
                [consumptionPlaceopt[2],consumptionPlaceq1[2]+'%',consumptionPlaceq2[2]+'%'],
                [consumptionPlaceopt[3],consumptionPlaceq1[3]+'%',consumptionPlaceq2[3]+'%'],
                [consumptionPlaceopt[4],consumptionPlaceq1[4]+'%',consumptionPlaceq2[4]+'%'],
                [consumptionPlaceopt[5],consumptionPlaceq1[5]+'%',consumptionPlaceq2[5]+'%'],
                [consumptionPlaceopt[6],consumptionPlaceq1[6]+'%',consumptionPlaceq2[6]+'%'],
            ],
        }];

        consumptionPlaceArray.forEach(slideData => {
            slide10.addText(slideData.title,topHead_10);
            slide10.addText(slideData.subtitle,subHead_10);
            slide10.addText(slideData.subtitle1,leftHead_10);
            slide10.addText("Base – Those who Consumed in Past 3 months",leftSubHead_10);
            slide10.addText("Base – Those who consumed in Past 3 months",rightSubHead_10);
            slide10.addText(slideData.subtitle3,rightHead_10);
            slide10.addShape(pptx.ShapeType.line, { x: 0.16,y: 1.02,w: 6.51, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide10.addShape(pptx.ShapeType.line, { "x": 6.83,"y": 1.02,"w": 2.46, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide10.addText(slideData.countries[0],{...country1_10,x: 1.01});
            slide10.addText(slideData.countries[1],{...country2_10,x: 1.87});
            slide10.addText(slideData.countries[2],{...country3_10,x: 2.74});
            slide10.addText(slideData.countries[3],{...country4_10,x: 3.55});
            slide10.addText(slideData.countries[4],{...country5_10,x: 4.32});
            slide10.addText(slideData.countries[5],{...country6_10,x: 5.10});
            slide10.addText(slideData.countries[6],{...country7_10,x: 5.91});
            slide10.addImage({ x: 2.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[1] });
            slide10.addImage({ x: 2.94, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[2] });
            slide10.addImage({ x: 3.73, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[3] });
            slide10.addImage({ x: 4.54, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[4] });
            slide10.addImage({ x: 5.33, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[5] });
            slide10.addImage({ x: 6.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[6] });

            const chartData = slideData.f.slice() .reverse().map((freq, i) => ({
					name: slideData.funnel[slideData.f.length - 1 - i], 
					labels: slideData.sampleSizes,
					values: freq,
             }));
             let tnpa=[];
             tnpa = [
                 {
                     type: pptx.charts.BAR,
                     data:chartData ,
                     options: {
                         barGrouping: "stacked",
                     },
                 },
             ];
             slide10.addChart(tnpa, stackChart_10);
             let legendItems = [
                 { color: '3A5A81', text: slideData.funnel[0] },
                 { color: '70A6FF', text: slideData.funnel[1] },
                 { color: 'C6E48B', text: slideData.funnel[2] },
                 { color: '6D8A42', text: slideData.funnel[3] },
                 { color: 'F28C28', text: slideData.funnel[4] },
                 { color: 'f2ad61', text: slideData.funnel[5] },
                 { color: '7f7f7f', text: slideData.funnel[6] },
             ];
             legendItems.forEach((item, index) => {
                 slide10.addShape(pptx.ShapeType.rect, {
                     x: 0.2,
                     y: 2.2 + index * 0.3,  
                     w: 0.060,
                     h: 0.060,
                     fill: { color: item.color },
                     line: { color: 'FFFFFF' }
                 });
                 slide10.addText(item.text, {
                     x: 0.2,
                     y: 2.24 + index * 0.3,
                     w: 1,
                     fontSize: 7,
                     color: '000000',
                     fontFace: 'Arial'
                 });
             });

             slide10.addText(slideData.bottom1,fText1_10);
             slide10.addText(slideData.bottom2,fText2_10);
             slide10.addShape(pptx.ShapeType.line, { "x": 0.28,"y": 5.06,"w": 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });

             let tableRows = slideData.table.map((row, rowIndex, allRows) =>
                 row.map(cell => ({
                     text: cell,
                     options: {
                         border: (rowIndex === 0 || rowIndex === allRows.length - 1)
                             ? [false, false, false, false] //No border for first and last row
                             : [false, false, true, false], //Bottom border only
                         borderColor: 'e0e0e0',
                         borderSize: 0.5,
                         fontSize: 8,
                         align: 'center',
                         valign: 'middle'
                     }
                 }))
             );
             slide10.addTable(tableRows, {
                 "x": 6.83,
                 "y": 1.46,
                 "w": 2.89,
                 "h": 2.76
             });
             
			slide10.addText("n-"+slideData.tblB[0],tableBase_10);
			slide10.addText("n-"+slideData.tblB[1],{...tableBase_10,x: 9.0});
			
            slide10.addText([
                 { text: slideData.btm1, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm2, options: { color: '00b050',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm3, options: { color: 'ff0000',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm4, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm5, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: true } },
                 { text: slideData.btm6, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } }
             ], {"x": 8.07,"y": 4.84,"w": 1.83,"h": 0.30});

             slide10.addImage({...logo1_10,path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png"});
             slide10.addImage({...logo2_10,path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png"});

             slide10.addShape(pptx.ShapeType.line, {x: 6.74,y: 0.96,w: 0.00,h: 4.09,line: {color:'969696',width:1,dashType:'dash'}});
        }); 


        // Slide 9: Time of Consumption — Circular Progress Bars (Donuts) for Each Combination

        // ---- TEXT AND SHAPE POSITION PRESETS ----
        let topHead_9 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
        let subHead_9 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
        let leftHead_9 = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
        let leftSubHead_9 = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
        let rightHead_9 = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
        let rightSubHead_9 = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
        let fText1_9 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
        let fText2_9 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
        let tableBase_9 = { x: 7.95, y: 4.21, w: 0.67, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, align: 'center', color: '969696' };
        let logo1_9 = { x: 8.51, y: 5.21, w: 0.80, h: 0.28 };
        let logo2_9 = { x: 9.36, y: 5.18, w: 0.54, h: 0.35 };

        // ---- DONUT STYLE PRESETS ----
        var donutConfig = {
            width: 0.65,
            height: 0.65,
            spacingX: 0.12,
            spacingY: 0.03,
            baseX: 1.00,
            baseY: 1.48,
            leftLabelWidth: 1,
            leftLabelFontSize: 6,
            percentFontSize: 5,
            percentColor: '000000',
            chartMainColor: '000000',
            chartBaseColor: '#e0e0e0'
        };

        // ---- DATA PREPARATION ----
        const countryLabels9 = ["SEA", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
        var consumptionTimecountryLevel = data['CM_C8Country'];
        var consumptionTimequarterLevel = data['CM_C8Quarter'];
        var consumptionTimeopt = CMC8label;
        var Q1 = consumptionTimequarterLevel["Q1'25"];
        var Q2 = consumptionTimequarterLevel["Q2'25"];
        const consumptionTimeq1 = Q1.map(item => item.percentage);
        const consumptionTimeq2 = Q2.map(item => item.percentage);
        var consumptionTimebaseData = [Q1[0].bCount, Q2[0].bCount];
        const consumptionTime1 = [], consumptionTime2 = [], consumptionTime3 = [], consumptionTime4 = [], consumptionTime5 = [], consumptionTimebaseArray = [];

        const baseArray9 = [];
        for (const country of countryLabels9) {
        const cData = consumptionTimecountryLevel[country];
        baseArray9.push(
            cData && cData[0] && typeof cData[0].bCount !== "undefined"
            ? `n-${cData[0].bCount}`
            : "n--"
        );
        }
        const bCountRow9 = [{ text: "", options: {} }];
        baseArray9.forEach(val => {
        bCountRow9.push({
            text: val,
            options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
        });
        });

        slide9.addTable([bCountRow9], {
        x: 0.23, y: 4.86, w: 6.04,
        colW: [1, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8],
        fontSize: 7,
        fontFace: 'Arial',
        align: 'center',
        border: [0]
        });

        countryLabel4.forEach(country => {
            if (consumptionTimecountryLevel[country]) {
                let countryData = consumptionTimecountryLevel[country];
                consumptionTimebaseArray.push(`n-${countryData[0].bCount}`);
                consumptionTime1.push(countryData[0].percentage);
                consumptionTime2.push(countryData[1].percentage);
                consumptionTime3.push(countryData[2].percentage);
                consumptionTime4.push(countryData[3].percentage);
                consumptionTime5.push(countryData[4].percentage);
            }
        });

        const consumptionTimeArray = [{
            title: "Time of Consumption",
            subtitle: "Dairy Milk (Flavored & Unflavored)",
            subtitle1: "Half Yearly (H1’25)",
            subtitle3: "Quarterly – SEA (Q1’25 & Q2’25)",
            countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
            flags: [
                "", 
                "https://keresearch.in/mdynata/assets/images/1.png",
                "https://keresearch.in/mdynata/assets/images/2.png",
                "https://keresearch.in/mdynata/assets/images/3.png",
                "https://keresearch.in/mdynata/assets/images/4.png",
                "https://keresearch.in/mdynata/assets/images/5.png",
                "https://keresearch.in/mdynata/assets/images/6.png"
            ],
            funnel: consumptionTimeopt,
            f: [consumptionTime1, consumptionTime2, consumptionTime3, consumptionTime4, consumptionTime5],
            sampleSizes: consumptionTimebaseArray,
            bottom1: "C2. When did you have it?",
            bottom2: "",
            btm1: "Sig.", btm2: "High/", btm3: "Low", btm4: " vs.", btm5: "previous wave", btm6: " at 95% CI",
            tblB: [consumptionTimebaseData[0], consumptionTimebaseData[1]],
            table: [
                ["", "Q1'25", "Q2'25"],
                [consumptionTimeopt[0], consumptionTimeq1[0] + '%', consumptionTimeq2[0] + '%'],
                [consumptionTimeopt[1], consumptionTimeq1[1] + '%', consumptionTimeq2[1] + '%'],
                [consumptionTimeopt[2], consumptionTimeq1[2] + '%', consumptionTimeq2[2] + '%'],
                [consumptionTimeopt[3], consumptionTimeq1[3] + '%', consumptionTimeq2[3] + '%'],
                [consumptionTimeopt[4], consumptionTimeq1[4] + '%', consumptionTimeq2[4] + '%']
            ]
        }];

        // ---- DRAW SLIDE ----
        consumptionTimeArray.forEach(slideData => {
            slide9.addText(slideData.title, topHead_9);
            slide9.addText(slideData.subtitle, subHead_9);
            slide9.addText(slideData.subtitle1, leftHead_9);
            slide9.addText("Base – Those who Consumed in Past 3 months", leftSubHead_9);
            slide9.addText("Base – Those who consumed in Past 3 months", rightSubHead_9);
            slide9.addText(slideData.subtitle3, rightHead_9);
            slide9.addShape(pptx.ShapeType.line, { x: 0.16, y: 1.02, w: 6.51, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide9.addShape(pptx.ShapeType.line, { x: 6.83, y: 1.02, w: 2.46, h: 0, line: { color: '75b1bb', width: 1.2 } });

            // ---- MAIN GRID: 5 Rows (labels) × 7 Columns (countries) ----
            for (let labelIdx = 0; labelIdx < 5; labelIdx++) {
                let label = slideData.funnel[labelIdx];
                slideData.countries.forEach((country, countryIdx) => {
                    let percent = slideData.f[labelIdx][countryIdx];
                    let x = donutConfig.baseX + countryIdx * (donutConfig.width + donutConfig.spacingX);
                    let y = donutConfig.baseY + labelIdx * (donutConfig.height + donutConfig.spacingY) + 0.1;

                    slide9.addChart(pptx.charts.DOUGHNUT, [{
                        name: `${country} - ${label}`,
                        labels: [label, ""],
                        values: [percent, 100 - percent]
                    }], {
                        x, y,
                        w: donutConfig.width,
                        h: donutConfig.height,
                        chartColors: [donutConfig.chartMainColor, donutConfig.chartBaseColor],
                        showLegend: false,
                        showValue: false,
                        dataLabelFontSize: 0
                    });

                    slide9.addText(`${percent}%`, {
                        x: x + 0.12 , y: y + 0.16, w: 0.4, h: 0.32,
                        fontSize: donutConfig.percentFontSize,
                        color: donutConfig.percentColor,
                        fontFace: 'Arial',
                        bold: true,
                        align: 'center',
                        valign: 'middle'
                    });

                    if (labelIdx === 0) {
                        slide9.addText(country, {
                        x: x - 0.05, y: y - 0.11, w: 0.80, h: 0.2,
                        align: 'center', fontSize: 8, bold: true,
                        fontFace: "Arial", color: "000000"
                    });
                        if (slideData.flags[countryIdx]) {
                            slide9.addImage({
                                x: x + (donutConfig.width - 0.30) / 2,
                                y: y - 0.38,
                                w: 0.35,
                                h: 0.33,
                                path: slideData.flags[countryIdx]
                            });
                        }
                    }

                    if (countryIdx === 0) {
                        slide9.addText(label, {
                            // x: x - (donutConfig.leftLabelWidth + 0.1),
                            x: x - (donutConfig.leftLabelWidth),
                            y: y + 0.23,
                            w: donutConfig.leftLabelWidth,
                            h: 0.2,
                            align: 'left',
                            fontSize: donutConfig.leftLabelFontSize,
                            bold: true,
                            fontFace: "Arial",
                            color: donutConfig.percentColor
                        });
                    }
                    if (labelIdx < 4) {  // Skip after last row
                        slide9.addShape(pptx.ShapeType.line, {
                            x: donutConfig.baseX - 0.75,
                            y: donutConfig.baseY + (labelIdx + 1) * (donutConfig.height + donutConfig.spacingY) + 0.07,
                            w: 6.5,
                            h: 0,
                            line: { color: 'e0e0e0', width: 0.75 }
                        });
                    }
                });
            }

    // Table
    let tableRows = slideData.table.map((row, rowIndex, allRows) =>
        row.map(cell => ({
            text: cell,
            options: {
                border: (rowIndex === 0 || rowIndex === allRows.length - 1) ? [false, false, false, false] : [false, false, true, false],
                borderColor: 'e0e0e0',
                borderSize: 0.5,
                fontSize: 8,
                align: 'center',
                valign: 'middle'
            }
        }))
    );
    slide9.addTable(tableRows, { x: 6.83, y: 1.46, w: 2.89, h: 2.76 });

    slide9.addText("n-" + slideData.tblB[0], tableBase_9);
    slide9.addText("n-" + slideData.tblB[1], { ...tableBase_9, x: 9.0 });

    slide9.addText([
        { text: slideData.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6 } },
        { text: slideData.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6 } },
        { text: slideData.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6 } },
        { text: slideData.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6 } },
        { text: slideData.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
        { text: slideData.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6 } }
    ], { x: 8.07, y: 4.84, w: 1.83, h: 0.30 });

    slide9.addText(slideData.bottom1, fText1_9);
    slide9.addText(slideData.bottom2, fText2_9);
    slide9.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });

    slide9.addImage({ ...logo1_9, path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png" });
    slide9.addImage({ ...logo2_9, path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png" });
    slide9.addShape(pptx.ShapeType.line, { x: 6.74, y: 0.96, w: 0.00, h: 4.09, line: { color: '969696', width: 1, dashType: 'dash' } });
});



// Slide 11:Consumed alone or with others

        // ---- TEXT AND SHAPE POSITION PRESETS ----
        let topHead_11 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
        let subHead_11 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
        let leftHead_11 = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
        let leftSubHead_11 = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
        let rightHead_11 = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
        let rightSubHead_11 = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
        let fText1_11 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
        let fText2_11 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
        let tableBase_11 = { x: 7.95, y: 4.21, w: 0.67, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, align: 'center', color: '969696' };
        let logo1_11 = { x: 8.51, y: 5.21, w: 0.80, h: 0.28 };
        let logo2_11 = { x: 9.36, y: 5.18, w: 0.54, h: 0.35 };

        // ---- DONUT STYLE PRESETS ----
        var donutConfig = {
            width: 0.65,
            height: 0.65,
            spacingX: 0.12,
            spacingY: 0.03,
            baseX: 1.00,
            baseY: 1.48,
            leftLabelWidth: 1,
            leftLabelFontSize: 6,
            percentFontSize: 5,
            percentColor: '000000',
            chartMainColor: '000000',
            chartBaseColor: '#e0e0e0'
        };

        // ---- DATA PREPARATION ----
        const countryLabels11 = ["SEA", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
        var consumptionWithcountryLevel = data['CM_C11Country'];
        var consumptionWithquarterLevel = data['CM_C11Quarter'];
        var consumptionWithopt = CMC11label;
        var Q1 = consumptionWithquarterLevel["Q1'25"];
        var Q2 = consumptionWithquarterLevel["Q2'25"];
        const consumptionWithq1 = Q1.map(item => item.percentage);
        const consumptionWithq2 = Q2.map(item => item.percentage);
        var consumptionWithbaseData = [Q1[0].bCount, Q2[0].bCount];
        const consumptionWith1 = [], consumptionWith2 = [], consumptionWith3 = [], consumptionWith4 = [], consumptionWith5 = [], consumptionWithbaseArray = [];


        const baseArray11 = [];
        for (const country of countryLabels11) {
        const cData = consumptionWithcountryLevel[country];
        baseArray11.push(
            cData && cData[0] && typeof cData[0].bCount !== "undefined"
            ? `n-${cData[0].bCount}`
            : "n--"
        );
        }
        const bCountRow11 = [{ text: "", options: {} }];
        baseArray11.forEach(val => {
        bCountRow11.push({
            text: val,
            options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
        });
        });

        slide11.addTable([bCountRow11], {
        x: 0.23, y: 4.86, w: 6.04,
        colW: [1, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8],
        fontSize: 7,
        fontFace: 'Arial',
        align: 'center',
        border: [0]
        });



        countryLabel4.forEach(country => {
            if (consumptionWithcountryLevel[country]) {
                let countryData = consumptionWithcountryLevel[country];
                consumptionWithbaseArray.push(`n-${countryData[0].bCount}`);
                consumptionWith1.push(countryData[0].percentage);
                consumptionWith2.push(countryData[1].percentage);
                consumptionWith3.push(countryData[2].percentage);
                consumptionWith4.push(countryData[3].percentage);
                consumptionWith5.push(countryData[4].percentage);
            }
        });

        const consumptionWithArray = [{
            title: "Consumed Alone vs. with others",
            subtitle: "Dairy Milk (Flavored & Unflavored)",
            subtitle1: "Half Yearly (H1’25)",
            subtitle3: "Quarterly – SEA (Q1’25 & Q2’25)",
            countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
            flags: [
                "", 
                "https://keresearch.in/mdynata/assets/images/1.png",
                "https://keresearch.in/mdynata/assets/images/2.png",
                "https://keresearch.in/mdynata/assets/images/3.png",
                "https://keresearch.in/mdynata/assets/images/4.png",
                "https://keresearch.in/mdynata/assets/images/5.png",
                "https://keresearch.in/mdynata/assets/images/6.png"
            ],
            funnel: consumptionWithopt,
            f: [consumptionWith1, consumptionWith2, consumptionWith3, consumptionWith4, consumptionWith5],
            sampleSizes: consumptionWithbaseArray,
            bottom1: "C10. Did you have it along with anything else or by itself on this occasion?",
            bottom2: "",
            btm1: "Sig.", btm2: "High/", btm3: "Low", btm4: " vs.", btm5: "previous wave", btm6: " at 95% CI",
            tblB: [consumptionWithbaseData[0], consumptionWithbaseData[1]],
            table: [
                ["", "Q1'25", "Q2'25"],
                [consumptionWithopt[0].replace(/<[^>]*>/g, '').trim(), consumptionWithq1[0] + '%', consumptionWithq2[0] + '%'],
                [consumptionWithopt[1].replace(/<[^>]*>/g, '').trim(), consumptionWithq1[1] + '%', consumptionWithq2[1] + '%'],
                [consumptionWithopt[2].replace(/<[^>]*>/g, '').trim(), consumptionWithq1[2] + '%', consumptionWithq2[2] + '%'],
                [consumptionWithopt[3].replace(/<[^>]*>/g, '').trim(), consumptionWithq1[3] + '%', consumptionWithq2[3] + '%'],
                [consumptionWithopt[4].replace(/<[^>]*>/g, '').trim(), consumptionWithq1[4] + '%', consumptionWithq2[4] + '%']
            ]
        }];

        // ---- DRAW SLIDE ----
        consumptionWithArray.forEach(slideData => {
            slide11.addText(slideData.title, topHead_11);
            slide11.addText(slideData.subtitle, subHead_11);
            slide11.addText(slideData.subtitle1, leftHead_11);
            slide11.addText("Base – Those who Consumed in Past 3 months", leftSubHead_11);
            slide11.addText("Base – Those who consumed in Past 3 months", rightSubHead_11);
            slide11.addText(slideData.subtitle3, rightHead_11);
            slide11.addShape(pptx.ShapeType.line, { x: 0.16, y: 1.02, w: 6.51, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide11.addShape(pptx.ShapeType.line, { x: 6.83, y: 1.02, w: 2.46, h: 0, line: { color: '75b1bb', width: 1.2 } });

            // ---- MAIN GRID: 5 Rows (labels) × 7 Columns (countries) ----
            for (let labelIdx = 0; labelIdx < 5; labelIdx++) {
                let label = slideData.funnel[labelIdx];
                slideData.countries.forEach((country, countryIdx) => {
                    let percent = slideData.f[labelIdx][countryIdx];
                    let x = donutConfig.baseX + countryIdx * (donutConfig.width + donutConfig.spacingX);
                    let y = donutConfig.baseY + labelIdx * (donutConfig.height + donutConfig.spacingY) + 0.1;

                    slide11.addChart(pptx.charts.DOUGHNUT, [{
                        name: `${country} - ${label}`,
                        labels: [label, ""],
                        values: [percent, 100 - percent]
                    }], {
                        x, y,
                        w: donutConfig.width,
                        h: donutConfig.height,
                        chartColors: [donutConfig.chartMainColor, donutConfig.chartBaseColor],
                        showLegend: false,
                        showValue: false,
                        dataLabelFontSize: 0
                    });

                    slide11.addText(`${percent}%`, {
                        x: x + 0.12 , y: y + 0.16, w: 0.4, h: 0.32,
                        fontSize: donutConfig.percentFontSize,
                        color: donutConfig.percentColor,
                        fontFace: 'Arial',
                        bold: true,
                        align: 'center',
                        valign: 'middle'
                    });

                    if (labelIdx === 0) {
                        slide11.addText(country, {
                        x: x - 0.05, y: y - 0.11, w: 0.80, h: 0.2,
                        align: 'center', fontSize: 8, bold: true,
                        fontFace: "Arial", color: "000000"
                    });
                        if (slideData.flags[countryIdx]) {
                            slide11.addImage({
                                x: x + (donutConfig.width - 0.30) / 2,
                                y: y - 0.38,
                                w: 0.35,
                                h: 0.33,
                                path: slideData.flags[countryIdx]
                            });
                        }
                    }

                    let cleanLabel = label.replace(/<[^>]*>/g, '').trim();
                    if (countryIdx === 0) {
                        slide11.addText(cleanLabel, {
                            // x: x - (donutConfig.leftLabelWidth + 0.1),
                            x: x - (donutConfig.leftLabelWidth),
                            y: y + 0.23,
                            w: donutConfig.leftLabelWidth,
                            h: 0.2,
                            align: 'left',
                            fontSize: donutConfig.leftLabelFontSize,
                            bold: true,
                            fontFace: "Arial",
                            color: donutConfig.percentColor
                        });
                    }
                    if (labelIdx < 4) {  // Skip after last row
                        slide11.addShape(pptx.ShapeType.line, {
                            x: donutConfig.baseX - 0.75,
                            y: donutConfig.baseY + (labelIdx + 1) * (donutConfig.height + donutConfig.spacingY) + 0.07,
                            w: 6.5,
                            h: 0,
                            line: { color: 'e0e0e0', width: 0.75 }
                        });
                    }
                });
            }

    // Table
    let tableRows = slideData.table.map((row, rowIndex, allRows) =>
        row.map(cell => ({
            text: cell,
            options: {
                border: (rowIndex === 0 || rowIndex === allRows.length - 1) ? [false, false, false, false] : [false, false, true, false],
                borderColor: 'e0e0e0',
                borderSize: 0.5,
                fontSize: 8,
                align: 'center',
                valign: 'middle'
            }
        }))
    );
    slide11.addTable(tableRows, { x: 6.83, y: 1.46, w: 2.89, h: 2.76 });

    slide11.addText("n-" + slideData.tblB[0], tableBase_11);
    slide11.addText("n-" + slideData.tblB[1], { ...tableBase_11, x: 9.0 });

    slide11.addText([
        { text: slideData.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6 } },
        { text: slideData.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6 } },
        { text: slideData.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6 } },
        { text: slideData.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6 } },
        { text: slideData.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
        { text: slideData.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6 } }
    ], { x: 8.07, y: 4.84, w: 1.83, h: 0.30 });

    slide11.addText(slideData.bottom1, fText1_11);
    slide11.addText(slideData.bottom2, fText2_11);
    slide11.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });

    slide11.addImage({ ...logo1_11, path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png" });
    slide11.addImage({ ...logo2_11, path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png" });
    slide11.addShape(pptx.ShapeType.line, { x: 6.74, y: 0.96, w: 0.00, h: 4.09, line: { color: '969696', width: 1, dashType: 'dash' } });
});



// Slide 13 Purchase Behaviour
	
	let topHead_13 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
    let subHead_13 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
    let leftHead_13 = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let leftSubHead_13 = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    let rightHead_13 = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let  rightSubHead_13 = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };

    let country1_13 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country2_13 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country3_13 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country4_13 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country5_13 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country6_13 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country7_13 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

    let opts12_13 = { x: 0.36, y: 2.22, w: 0.96, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts13_13 = { x: 0.34, y: 2.79, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts14_13 = { x: 0.32, y: 3.43, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts15_13 = { x: 0.33, y: 4.04, w: 0.99, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let fText1_13 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
    let fText2_13 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
	
	let tableBase_13 = {"x": 7.95,"y": 2.84,"w": 0.67,"h": 0.30,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};

    let logo1_13 = {"x": 8.51,"y": 5.21,"w": 0.80,"h": 0.28};
    let logo2_13 = {"x": 9.36,"y": 5.18,"w": 0.54,"h": 0.35};
	
	let stackChart_13 = {x: 1.02,y: 1.4,w: 5.81,h: 3.20,barDir: "col",barGrouping: "stacked",barGapWidthPct: 110,dataLabelColor: "FFFFFF",dataLabelFontFace: "Arial",dataLabelFontSize: 9,dataLabelFontBold: true,showValue: true,dataLabelFormatCode: '0"%"', chartColors: ['3A5A81'],lineDataSymbolSize: 15,catAxisLabelColor: "969696", catAxisLabelFontFace: "Arial",catAxisLabelFontSize: 8,catAxisOrientation: "minMax",showLegend: false,legendPos: 'l', legendFontSize: 9, showTitle: false,showValAxis: false,valAxisLabelPos: 'none',valAxisLineShow: false,valGridLine:{style: 'none'},};
	
		var purchaseBehaviourcountryLevel = data['CM_C17_1Country'];
        var purchaseBehaviourquarterLevel = data['CM_C17_1Quarter'];
        var purchaseBehaviouropt=CMC17_1label;
        var Q1 = purchaseBehaviourquarterLevel["Q1'25"];
        var Q2 = purchaseBehaviourquarterLevel["Q2'25"];
        const purchaseBehaviourq1= Q1.map(item => item.percentage);
        const purchaseBehaviourq2= Q2.map(item => item.percentage);
        var purchaseBehaviourbaseData = [Q1[0].bCount, Q2[0].bCount];
        const purchaseBehaviourcountryData = {};
        const purchaseBehaviour1 = [];
        
        const purchaseBehaviourbaseArray = [];

        countryLabel4.forEach(country => {
            if (purchaseBehaviourcountryLevel[country]) {
                purchaseBehaviourcountryData[country] = purchaseBehaviourcountryLevel[country];
            }
        });
                
        for (const country in purchaseBehaviourcountryData) {
            const countryData = purchaseBehaviourcountryData[country];
            purchaseBehaviourbaseArray.push(`n-${countryData[0].bCount}`);
            purchaseBehaviour1.push(countryData[0].percentage);
        }

        const purchaseBehaviourArray = [{
            title: "Purchase Behaviour",
            subtitle: "Dairy Milk (Flavored & Unflavored)",
            subtitle1: "Purchased in Household & Place of Purchase",
            subtitle3: "Quarterly – SEA (Q1’25 & Q2’25)",
            countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
            flags: ["","https://keresearch.in/mdynata/assets/images/1.png","https://keresearch.in/mdynata/assets/images/2.png","https://keresearch.in/mdynata/assets/images/3.png","https://keresearch.in/mdynata/assets/images/4.png","https://keresearch.in/mdynata/assets/images/5.png","https://keresearch.in/mdynata/assets/images/6.png"],
            funnel: purchaseBehaviouropt,
            f:[purchaseBehaviour1],
            sampleSizes:purchaseBehaviourbaseArray,
            bottom1:"C17_1. Do you or anyone else in the household purchase Category from a supermarket, retail shop, or online?",
            bottom2:"C19. Where do you or anyone in your household usually buy Category from?",
            btm1:"Sig.", btm2:"High/", btm3:"Low", btm4:" vs.", btm5:"previous wave", btm6:" at 95% CI",
            tblB:[purchaseBehaviourbaseData[0],purchaseBehaviourbaseData[1]],
            table: [
                ["","Q1'25", "Q2'25"],
                [purchaseBehaviouropt[0],purchaseBehaviourq1[0]+'%', purchaseBehaviourq2[0]+'%'],
                
                
            ],
        }];

        purchaseBehaviourArray.forEach(slideData => {
            slide13.addText(slideData.title,topHead_13);
            slide13.addText(slideData.subtitle,subHead_13);
            slide13.addText(slideData.subtitle1,leftHead_13);
            slide13.addText("Base – purchaseBehaviour in Past 3 months",leftSubHead_13);
            slide13.addText("Base – Those who consumed in Past 3 months",rightSubHead_13);
            slide13.addText(slideData.subtitle3,rightHead_13);
            slide13.addShape(pptx.ShapeType.line, { x: 0.16,y: 1.02,w: 6.51, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide13.addShape(pptx.ShapeType.line, { "x": 6.83,"y": 1.02,"w": 2.46, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide13.addText(slideData.countries[0],{...country1_13,x: 1.01});
            slide13.addText(slideData.countries[1],{...country2_13,x: 1.87});
            slide13.addText(slideData.countries[2],{...country3_13,x: 2.74});
            slide13.addText(slideData.countries[3],{...country4_13,x: 3.55});
            slide13.addText(slideData.countries[4],{...country5_13,x: 4.32});
            slide13.addText(slideData.countries[5],{...country6_13,x: 5.10});
            slide13.addText(slideData.countries[6],{...country7_13,x: 5.91});
            slide13.addImage({ x: 2.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[1] });
            slide13.addImage({ x: 2.94, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[2] });
            slide13.addImage({ x: 3.73, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[3] });
            slide13.addImage({ x: 4.54, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[4] });
            slide13.addImage({ x: 5.33, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[5] });
            slide13.addImage({ x: 6.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[6] });

            const chartData = slideData.f.slice() .reverse().map((freq, i) => ({
					name: slideData.funnel[slideData.f.length - 1 - i], 
					labels: slideData.sampleSizes,
					values: freq,
             }));
             let tnpa=[];
             tnpa = [
                 {
                     type: pptx.charts.BAR,
                     data:chartData ,
                     options: {
                         barGrouping: "stacked",
                     },
                 },
             ];
             slide13.addChart(tnpa, stackChart_13);
             let legendItems = [
                 { color: '3A5A81', text: slideData.funnel[0] },
                 
                 
             ];
             legendItems.forEach((item, index) => {
                 slide13.addShape(pptx.ShapeType.rect, {
                     x: 0.2,
                     y: 2.2 + index * 0.5,  
                     w: 0.060,
                     h: 0.060,
                     fill: { color: item.color },
                     line: { color: 'FFFFFF' }
                 });
                 slide13.addText(item.text, {
                     x: 0.2,
                     y: 2.24 + index * 0.5,
                     fontSize: 7,
                     color: '000000',
                     fontFace: 'Arial'
                 });
             });

             slide13.addText(slideData.bottom1,fText1_13);
             slide13.addText(slideData.bottom2,fText2_13);
             slide13.addShape(pptx.ShapeType.line, { "x": 0.28,"y": 5.06,"w": 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });

             let tableRows = slideData.table.map((row, rowIndex, allRows) =>
                 row.map(cell => ({
                     text: cell,
                     options: {
                         border: (rowIndex === 0 || rowIndex === allRows.length - 1)
                             ? [false, false, false, false] // No border for first and last row
                             : [false, false, true, false], // Bottom border only
                         borderColor: 'e0e0e0',
                         borderSize: 0.5,
                         fontSize: 8,
                         align: 'center',
                         valign: 'middle'
                     }
                 }))
             );
             slide13.addTable(tableRows, {
                 "x": 6.83,
                 "y": 1.46,
                 "w": 2.89,
                 "h": 1.35
             });
             
			slide13.addText("n-"+slideData.tblB[0],tableBase_13);
			slide13.addText("n-"+slideData.tblB[1],{...tableBase_13,x: 9.0});
			
            slide13.addText([
                 { text: slideData.btm1, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm2, options: { color: '00b050',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm3, options: { color: 'ff0000',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm4, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm5, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: true } },
                 { text: slideData.btm6, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } }
             ], {"x": 8.07,"y": 4.84,"w": 1.83,"h": 0.30});

             slide13.addImage({...logo1_13,path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png"});
             slide13.addImage({...logo2_13,path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png"});

             slide13.addShape(pptx.ShapeType.line, {x: 6.74,y: 0.96,w: 0.00,h: 4.09,line: {color:'969696',width:1,dashType:'dash'}});
        });


// ----------- PPT Slide 12: S -----------

// Slide essentials
let topHead_12 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
let subHead_12 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
// let subHead_12_2 = { x: 0.24, y: 2.79, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
let leftHead_12 = { x: 0.12, y: 0.75, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let leftHead_12_2 = { x: 0.12, y: 2.79, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let fText1_12 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
let fText2_12 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
let logo1_12 = { x: 8.51, y: 5.21, w: 0.80, h: 0.28 };
let logo2_12 = { x: 9.36, y: 5.18, w: 0.54, h: 0.35 };

let country1_12 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country2_12 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country3_12 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country4_12 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country5_12 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country6_12 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country7_12 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

// Slide titles/static text
const slideData = {
  title: "Change in Consumption",
  subtitle: "Dairy Milk (Flavored & Unflavored)",
  subtitle1: "Change in personal consumption over last 12 months",
  subtitle2: "Change in household consumption over last 12 months",
  countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: [
            "", // SEA; can be filled with an icon path if available
            "https://keresearch.in/mdynata/assets/images/1.png",
            "https://keresearch.in/mdynata/assets/images/2.png",
            "https://keresearch.in/mdynata/assets/images/3.png",
            "https://keresearch.in/mdynata/assets/images/4.png",
            "https://keresearch.in/mdynata/assets/images/5.png",
            "https://keresearch.in/mdynata/assets/images/6.png"
        ],
  bottom1: "C15/ C20. Compared to the last 1 year, how has your personal/ household consumption of Dairy Milk (from Cows) changed?",
  bottom2: "",
  btm1: "Sig.", btm2: "High/", btm3: "Low", btm4: " vs.", btm5: "previous year", btm6: " at 95% CI"
};

// ---- Draw headings and visuals ----
slide12.addText(slideData.title, topHead_12);
slide12.addText(slideData.subtitle, subHead_12);
slide12.addText(slideData.subtitle2, leftHead_12_2);
slide12.addText(slideData.subtitle1, leftHead_12);
slide12.addShape(pptx.ShapeType.line, { x: 0.16, y: 1.02, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });
slide12.addShape(pptx.ShapeType.line, { x: 0.16, y: 3.08, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });

slide12.addText(slideData.countries[0], { ...country1_12, x: 1.01 });
slide12.addText(slideData.countries[1], { ...country2_12, x: 1.87 });
slide12.addText(slideData.countries[2], { ...country3_12, x: 2.74 });
slide12.addText(slideData.countries[3], { ...country4_12, x: 3.55 });
slide12.addText(slideData.countries[4], { ...country5_12, x: 4.32 });
slide12.addText(slideData.countries[5], { ...country6_12, x: 5.10 });
slide12.addText(slideData.countries[6], { ...country7_12, x: 5.91 });

slide12.addImage({ x: 2.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[1] });
slide12.addImage({ x: 2.94, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[2] });
slide12.addImage({ x: 3.73, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[3] });
slide12.addImage({ x: 4.54, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[4] });
slide12.addImage({ x: 5.33, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[5] });
slide12.addImage({ x: 6.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[6] });

// ---- Prepare table arrays ----
const countryLabels = ["SEA", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
const quarterLabels = ["Q1'25", "Q2'25"];
const funnelLabels = CMC15label; // Example: ["Increased", "No Change", "Decreased"]
const countryData = data['CM_C15Country'];
const quarterData = data['CM_C15Quarter'];
const countryData2 = data['CM_C20Country'];
const quarterData2 = data['CM_C20Quarter'];


const baseArray12_1 = [];
for (const country of countryLabels) {
  const cData = countryData[country];
  baseArray12_1.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
}
const bCountRow12_1 = [{ text: "", options: {} }];
baseArray12_1.forEach(val => {
  bCountRow12_1.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});

const baseArray12_2 = [];
for (const country of countryLabels) {
  const cData = countryData2[country];
  baseArray12_2.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
}
const bCountRow12_2 = [{ text: "", options: {} }];
baseArray12_2.forEach(val => {
  bCountRow12_2.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});

const baseArray12_3 = [];
for (const quarter of quarterLabels) {
  const cData = quarterData[quarter];
  baseArray12_3.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
}
const bCountRow12_3 = [{ text: "", options: {} }];
baseArray12_3.forEach(val => {
  bCountRow12_3.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});

const baseArray12_4 = [];
for (const quarter of quarterLabels) {
  const cData = quarterData2[quarter];
  baseArray12_4.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
}
const bCountRow12_4 = [{ text: "", options: {} }];
baseArray12_4.forEach(val => {
  bCountRow12_4.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});

slide12.addTable([bCountRow12_1], {
  x: 0.23, y: 2.59, w: 6.5,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});
slide12.addTable([bCountRow12_2], {
  x: 0.23, y: 4.09, w: 6.5,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});
slide12.addTable([bCountRow12_3], {
  x: 7.35, y: 2.59, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});
slide12.addTable([bCountRow12_4], {
  x: 7.35, y: 4.09, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});


// Country table
let countryTable = [];
let countryTable2 = [];
for (let i = 0; i < funnelLabels.length; i++) {
//   let row = [funnelLabels[i]];
    let row = [];
  row.push({
    text: funnelLabels[i],
    options: {
        border: [{ pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" }]
    }
  });
  countryLabels.forEach(country => {
    const cell = countryData[country] && countryData[country][i] && typeof countryData[country][i].percentage !== 'undefined'
      ? countryData[country][i].percentage + "%"
      : "-";
    row.push({text: cell,
      options: {
        border: [{ pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" }]
      }
    });
  });
  countryTable.push(row);
}
for (let i = 0; i < funnelLabels.length; i++) {
  let row = [];
  row.push({
    text: funnelLabels[i],
    options: {
        border: [{ pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" }]
    }
  });
  countryLabels.forEach(country => {
    const cell = countryData2[country] && countryData2[country][i] && typeof countryData2[country][i].percentage !== 'undefined'
      ? countryData2[country][i].percentage + "%"
      : "-";
    row.push({text: cell,
      options: {
        border: [{ pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" }]
      }
    });
  });
  countryTable2.push(row);
}
// Quarter table
let quarterTable = [
  [
    { text: "", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } },
    { text: "Q1'25", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } },
    { text: "Q2'25", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } }
  ]
];
let quarterTable2 = [
  [
    { text: "", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } },
    { text: "Q1'25", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } },
    { text: "Q2'25", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } }
  ]
];
for (let i = 0; i < funnelLabels.length; i++) {
  quarterTable.push([
    { text: funnelLabels[i], options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } },
    { text: quarterData["Q1'25"][i].percentage + "%", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } },
    { text: quarterData["Q2'25"][i].percentage + "%", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } }
  ]);
}
for (let i = 0; i < funnelLabels.length; i++) {
  quarterTable2.push([
   { text: funnelLabels[i], options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } },
    { text: quarterData2["Q1'25"][i].percentage + "%", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } },
    { text: quarterData2["Q2'25"][i].percentage + "%", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } }
  ]);
}

// ---- Add side-by-side tables ----
slide12.addTable(countryTable, {
  x: 0.23, y: 1.86, w: 6.5,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  
});
slide12.addTable(countryTable2, {
  x: 0.23, y: 3.42, w: 6.5,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  
});
slide12.addTable(quarterTable, {
  x: 7.35, y: 1.65, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  
});
slide12.addTable(quarterTable2, {
  x: 7.35, y: 3.2, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  
});

// ---- Footnotes and Logos ----
slide12.addText(slideData.bottom1, fText1_12);
slide12.addText(slideData.bottom2, fText2_12);
slide12.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });
slide12.addText([
  { text: slideData.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
  { text: slideData.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } }
], { x: 8.07, y: 4.84, w: 1.83, h: 0.30 });
slide12.addImage({ ...logo1_12, path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png" });
slide12.addImage({ ...logo2_12, path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png" });

// ----------- End of Slide 12 Code -----------
	

// ----------- PPT Slide 14-----------
let topHead_14 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
let subHead_14 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
let leftHead_14 = { x: 0.12, y: 0.75, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let leftHead_14_2 = { x: 0.12, y: 2.79, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let fText1_14 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
let fText2_14 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
let logo1_14 = { x: 8.51, y: 5.21, w: 0.80, h: 0.28 };
let logo2_14 = { x: 9.36, y: 5.18, w: 0.54, h: 0.35 };

let country1_14 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country2_14 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country3_14 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country4_14 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country5_14 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country6_14 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country7_14 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

// Slide titles/static text
const slideData14 = {
  title: "Profile of Consumers",
//   subtitle: "Dairy Milk (Flavored & Unflavored)",
  subtitle1: "H1'25",
//   subtitle2: "Change in household consumption over last 12 months",
  countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: [
            "", // SEA; can be filled with an icon path if available
            "https://keresearch.in/mdynata/assets/images/1.png",
            "https://keresearch.in/mdynata/assets/images/2.png",
            "https://keresearch.in/mdynata/assets/images/3.png",
            "https://keresearch.in/mdynata/assets/images/4.png",
            "https://keresearch.in/mdynata/assets/images/5.png",
            "https://keresearch.in/mdynata/assets/images/6.png"
        ],
  bottom1: "S5. Indicate your age in completed years.",
  bottom2: "",
  bottom3: "",
  btm1: "Sig.", btm2: "High/", btm3: "Low", btm4: " vs.", btm5: "previous year", btm6: " at 95% CI"
};

// ---- Draw headings and visuals ----
slide14.addText(slideData14.title, topHead_14);
// slide14.addText(slideData14.subtitle, subHead_14);
// slide14.addText(slideData14.subtitle2, leftHead_14_2);
slide14.addText(slideData14.subtitle1, leftHead_14);
slide14.addShape(pptx.ShapeType.line, { x: 0.16, y: 1.02, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });

slide14.addText(slideData14.countries[0], { ...country1_14, x: 1.56 });
slide14.addText(slideData14.countries[1], { ...country2_14, x: 2.8 });
slide14.addText(slideData14.countries[2], { ...country3_14, x: 4.06 });
slide14.addText(slideData14.countries[3], { ...country4_14, x: 5.27 });
slide14.addText(slideData14.countries[4], { ...country5_14, x: 6.43 });
slide14.addText(slideData14.countries[5], { ...country6_14, x: 7.6 });
slide14.addText(slideData14.countries[6], { ...country7_14, x: 8.9 });

slide14.addImage({ x: 3.04, y: 1.22, w: 0.37, h: 0.38, path: slideData14.flags[1] });
slide14.addImage({ x: 4.28, y: 1.22, w: 0.37, h: 0.38, path: slideData14.flags[2] });
slide14.addImage({ x: 5.50, y: 1.22, w: 0.37, h: 0.38, path: slideData14.flags[3] });
slide14.addImage({ x: 6.69, y: 1.22, w: 0.37, h: 0.38, path: slideData14.flags[4] });
slide14.addImage({ x: 7.87, y: 1.22, w: 0.37, h: 0.38, path: slideData14.flags[5] });
slide14.addImage({ x: 9.13, y: 1.22, w: 0.37, h: 0.38, path: slideData14.flags[6] });

// ---- Prepare table arrays ----
const countryLabels14 = ["SEA", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
const funnelLabels14 = ageLabelXXX;
const countryData14 = data['HAGE'];
// const quarterData14 = data['CM_C15Quarter'];

const baseArray14 = [];
for (const country of countryLabels14) {
  const cData = countryData14[country];
  baseArray14.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
}
const bCountRow14 = [{ text: "", options: {} }];
baseArray14.forEach(val => {
  bCountRow14.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});

// Country table
let countryTable14 = [];
for (let i = 0; i < funnelLabels14.length; i++) {
  let row = [];
  row.push({
    text: funnelLabels14[i],
    options: {
        border: [{ pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" }]
    }
  });
  countryLabels14.forEach(country => {
    const cell = countryData14[country] && countryData14[country][i] && typeof countryData14[country][i].percentage !== 'undefined'
      ? countryData14[country][i].percentage + "%"
      : "-";
    row.push({text: cell,
      options: {
        border: [{ pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" }]
      }
    });
  });
  countryTable14.push(row);
}

slide14.addTable(countryTable14, {
  x: 0.23, y: 1.86, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  border: { type: "bottom", pt: '0.5', color: 'cccccc' }
});

slide14.addTable([bCountRow14], {
  x: 0.23, y: 2.96, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});

// ---- Footnotes and Logos ----
slide14.addText(slideData14.bottom1, fText1_14);
slide14.addText(slideData14.bottom2, fText2_14);
slide14.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });
slide14.addText([
  { text: slideData14.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData14.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData14.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData14.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData14.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
  { text: slideData14.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } }
], { x: 8.07, y: 4.84, w: 1.83, h: 0.30 });
slide14.addImage({ ...logo1_14, path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png" });
slide14.addImage({ ...logo2_14, path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png" });


// ----------- PPT Slide 15-----------
let topHead_15 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
let subHead_15 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
let leftHead_15 = { x: 0.12, y: 0.75, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let leftHead_15_2 = { x: 0.12, y: 2.79, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let fText1_15 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
let fText2_15 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
let logo1_15 = { x: 8.51, y: 5.21, w: 0.80, h: 0.28 };
let logo2_15 = { x: 9.36, y: 5.18, w: 0.54, h: 0.35 };

let country1_15 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country2_15 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country3_15 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country4_15 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country5_15 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country6_15 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country7_15 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

// Slide titles/static text
const slideData15 = {
  title: "Profile of Consumers",
//   subtitle: "Dairy Milk (Flavored & Unflavored)",
  subtitle1: "H1'25",
//   subtitle2: "Change in household consumption over last 12 months",
  countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: [
            "", // SEA; can be filled with an icon path if available
            "https://keresearch.in/mdynata/assets/images/1.png",
            "https://keresearch.in/mdynata/assets/images/2.png",
            "https://keresearch.in/mdynata/assets/images/3.png",
            "https://keresearch.in/mdynata/assets/images/4.png",
            "https://keresearch.in/mdynata/assets/images/5.png",
            "https://keresearch.in/mdynata/assets/images/6.png"
        ],
  bottom1: "P4. Please Indicate your Education.",
  bottom2: "",
  bottom3: "",
  btm1: "Sig.", btm2: "High/", btm3: "Low", btm4: " vs.", btm5: "previous year", btm6: " at 95% CI"
};

// ---- Draw headings and visuals ----
slide15.addText(slideData15.title, topHead_15);
// slide15.addText(slideData15.subtitle, subHead_15);
// slide15.addText(slideData15.subtitle2, leftHead_15_2);
slide15.addText(slideData15.subtitle1, leftHead_15);
slide15.addShape(pptx.ShapeType.line, { x: 0.16, y: 1.02, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });

slide15.addText(slideData15.countries[0], { ...country1_15, x: 1.56 });
slide15.addText(slideData15.countries[1], { ...country2_15, x: 2.8 });
slide15.addText(slideData15.countries[2], { ...country3_15, x: 4.06 });
slide15.addText(slideData15.countries[3], { ...country4_15, x: 5.27 });
slide15.addText(slideData15.countries[4], { ...country5_15, x: 6.43 });
slide15.addText(slideData15.countries[5], { ...country6_15, x: 7.6 });
slide15.addText(slideData15.countries[6], { ...country7_15, x: 8.9 });

slide15.addImage({ x: 3.04, y: 1.22, w: 0.37, h: 0.38, path: slideData15.flags[1] });
slide15.addImage({ x: 4.28, y: 1.22, w: 0.37, h: 0.38, path: slideData15.flags[2] });
slide15.addImage({ x: 5.50, y: 1.22, w: 0.37, h: 0.38, path: slideData15.flags[3] });
slide15.addImage({ x: 6.69, y: 1.22, w: 0.37, h: 0.38, path: slideData15.flags[4] });
slide15.addImage({ x: 7.87, y: 1.22, w: 0.37, h: 0.38, path: slideData15.flags[5] });
slide15.addImage({ x: 9.13, y: 1.22, w: 0.37, h: 0.38, path: slideData15.flags[6] });

// ---- Prepare table arrays ----
const countryLabels15 = ["SEA", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
const funnelLabels15 = educationXX;
const countryData15 = data['P4'];
// const quarterData15 = data['CM_C15Quarter'];

const baseArray15 = [];
for (const country of countryLabels15) {
  const cData = countryData15[country];
  baseArray15.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
}
const bCountRow15 = [{ text: "", options: {} }];
baseArray15.forEach(val => {
  bCountRow15.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});

// Country table
let countryTable15 = [];
for (let i = 0; i < funnelLabels15.length; i++) {
  let row = [];
  row.push({
    text: funnelLabels15[i],
    options: {
        border: [{ pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" }]
    }
  });
  countryLabels15.forEach(country => {
    const cell = countryData15[country] && countryData15[country][i] && typeof countryData15[country][i].percentage !== 'undefined'
      ? countryData15[country][i].percentage + "%"
      : "-";
    row.push({text: cell,
      options: {
        border: [{ pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" }]
      }
    });
  });
  countryTable15.push(row);
}

slide15.addTable(countryTable15, {
  x: 0.23, y: 1.86, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  border: { type: "bottom", pt: '0.5', color: 'cccccc' }
});

slide15.addTable([bCountRow15], {
  x: 0.23, y: 3.43, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});

// ---- Footnotes and Logos ----
slide15.addText(slideData15.bottom1, fText1_15);
slide15.addText(slideData15.bottom2, fText2_15);
slide15.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });
slide15.addText([
  { text: slideData15.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData15.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData15.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData15.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData15.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
  { text: slideData15.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } }
], { x: 8.07, y: 4.84, w: 1.83, h: 0.30 });
slide15.addImage({ ...logo1_15, path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png" });
slide15.addImage({ ...logo2_15, path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png" });



// ----------- PPT Slide 16-----------
let topHead_16 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
let subHead_16 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
let leftHead_16 = { x: 0.12, y: 0.75, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let leftHead_16_2 = { x: 0.12, y: 2.79, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let fText1_16 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
let fText2_16 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
let logo1_16 = { x: 8.51, y: 5.21, w: 0.80, h: 0.28 };
let logo2_16 = { x: 9.36, y: 5.18, w: 0.54, h: 0.35 };

let country1_16 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country2_16 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country3_16 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country4_16 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country5_16 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country6_16 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country7_16 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

// Slide titles/static text
const slideData16 = {
  title: "Profile of Consumers",
//   subtitle: "Dairy Milk (Flavored & Unflavored)",
  subtitle1: "H1'25",
//   subtitle2: "Change in household consumption over last 12 months",
  countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: [
            "", // SEA; can be filled with an icon path if available
            "https://keresearch.in/mdynata/assets/images/1.png",
            "https://keresearch.in/mdynata/assets/images/2.png",
            "https://keresearch.in/mdynata/assets/images/3.png",
            "https://keresearch.in/mdynata/assets/images/4.png",
            "https://keresearch.in/mdynata/assets/images/5.png",
            "https://keresearch.in/mdynata/assets/images/6.png"
        ],
  bottom1: "S10. Do you follow Halal dietary requirements.",
  bottom2: "",
  bottom3: "",
  btm1: "Sig.", btm2: "High/", btm3: "Low", btm4: " vs.", btm5: "previous year", btm6: " at 95% CI"
};

// ---- Draw headings and visuals ----
slide16.addText(slideData16.title, topHead_16);
// slide16.addText(slideData16.subtitle, subHead_16);
// slide16.addText(slideData16.subtitle2, leftHead_16_2);
slide16.addText(slideData16.subtitle1, leftHead_16);
slide16.addShape(pptx.ShapeType.line, { x: 0.16, y: 1.02, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });

slide16.addText(slideData16.countries[0], { ...country1_16, x: 1.56 });
slide16.addText(slideData16.countries[1], { ...country2_16, x: 2.8 });
slide16.addText(slideData16.countries[2], { ...country3_16, x: 4.06 });
slide16.addText(slideData16.countries[3], { ...country4_16, x: 5.27 });
slide16.addText(slideData16.countries[4], { ...country5_16, x: 6.43 });
slide16.addText(slideData16.countries[5], { ...country6_16, x: 7.6 });
slide16.addText(slideData16.countries[6], { ...country7_16, x: 8.9 });

slide16.addImage({ x: 3.04, y: 1.22, w: 0.37, h: 0.38, path: slideData16.flags[1] });
slide16.addImage({ x: 4.28, y: 1.22, w: 0.37, h: 0.38, path: slideData16.flags[2] });
slide16.addImage({ x: 5.50, y: 1.22, w: 0.37, h: 0.38, path: slideData16.flags[3] });
slide16.addImage({ x: 6.69, y: 1.22, w: 0.37, h: 0.38, path: slideData16.flags[4] });
slide16.addImage({ x: 7.87, y: 1.22, w: 0.37, h: 0.38, path: slideData16.flags[5] });
slide16.addImage({ x: 9.13, y: 1.22, w: 0.37, h: 0.38, path: slideData16.flags[6] });

// ---- Prepare table arrays ----
const countryLabels16 = ["SEA", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
const funnelLabels16 = halalLabel;
const countryData16 = data['S10'];
// const quarterData16 = data['CM_C16Quarter'];

const baseArray16 = [];
for (const country of countryLabels16) {
  const cData = countryData16[country];
  baseArray16.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
}
const bCountRow16 = [{ text: "", options: {} }];
baseArray16.forEach(val => {
  bCountRow16.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});

// Country table
let countryTable16 = [];
for (let i = 0; i < funnelLabels16.length; i++) {
  let row = [];
  row.push({
    text: funnelLabels16[i],
    options: {
        border: [{ pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" }]
    }
  });
  countryLabels16.forEach(country => {
    const cell = countryData16[country] && countryData16[country][i] && typeof countryData16[country][i].percentage !== 'undefined'
      ? countryData16[country][i].percentage + "%"
      : "-";
    row.push({text: cell,
      options: {
        border: [{ pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" }]
      }
    });
  });
  countryTable16.push(row);
}
/* let quarterTable16 = [
  ["", "Q1'25", "Q2'25"]
];
for (let i = 0; i < funnelLabels16.length; i++) {
  quarterTable16.push([
    funnelLabels16[i],
    quarterData16["Q1'25"][i].percentage + "%",
    quarterData16["Q2'25"][i].percentage + "%"
  ]);
} */

slide16.addTable(countryTable16, {
  x: 0.23, y: 1.86, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  border: { type: "bottom", pt: '0.5', color: 'cccccc' }
});
slide16.addTable([bCountRow16], {
  x: 0.23, y: 2.52, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});
/* 
slide16.addTable(quarterTable16, {
  x: 7.35, y: 1.65, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  border: { type: "bottom", pt: '0.5', color: 'cccccc' }
}); */

// ---- Footnotes and Logos ----
slide16.addText(slideData16.bottom1, fText1_16);
slide16.addText(slideData16.bottom2, fText2_16);
slide16.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });
slide16.addText([
  { text: slideData16.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData16.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData16.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData16.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData16.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
  { text: slideData16.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } }
], { x: 8.07, y: 4.84, w: 1.83, h: 0.30 });
slide16.addImage({ ...logo1_16, path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png" });
slide16.addImage({ ...logo2_16, path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png" });



// ----------- PPT Slide 17-----------
let topHead_17 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
let subHead_17 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
let leftHead_17 = { x: 0.12, y: 0.75, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let leftHead_17_2 = { x: 0.12, y: 2.79, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let fText1_17 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
let fText2_17 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
let logo1_17 = { x: 8.51, y: 5.21, w: 0.80, h: 0.28 };
let logo2_17 = { x: 9.36, y: 5.18, w: 0.54, h: 0.35 };

let country1_17 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country2_17 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country3_17 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country4_17 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country5_17 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country6_17 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country7_17 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

// Slide titles/static text
const slideData17 = {
  title: "Profile of Consumers",
//   subtitle: "Dairy Milk (Flavored & Unflavored)",
  subtitle1: "H1'25",
//   subtitle2: "Change in household consumption over last 12 months",
  countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: [
            "", // SEA; can be filled with an icon path if available
            "https://keresearch.in/mdynata/assets/images/1.png",
            "https://keresearch.in/mdynata/assets/images/2.png",
            "https://keresearch.in/mdynata/assets/images/3.png",
            "https://keresearch.in/mdynata/assets/images/4.png",
            "https://keresearch.in/mdynata/assets/images/5.png",
            "https://keresearch.in/mdynata/assets/images/6.png"
        ],
  bottom1: "P5. Please select your Occupation status.",
  bottom2: "",
  bottom3: "",
  btm1: "Sig.", btm2: "High/", btm3: "Low", btm4: " vs.", btm5: "previous year", btm6: " at 95% CI"
};

// ---- Draw headings and visuals ----
slide17.addText(slideData17.title, topHead_17);
// slide17.addText(slideData17.subtitle, subHead_17);
// slide17.addText(slideData17.subtitle2, leftHead_17_2);
slide17.addText(slideData17.subtitle1, leftHead_17);
slide17.addShape(pptx.ShapeType.line, { x: 0.17, y: 1.02, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });

slide17.addText(slideData17.countries[0], { ...country1_17, x: 1.56 });
slide17.addText(slideData17.countries[1], { ...country2_17, x: 2.8 });
slide17.addText(slideData17.countries[2], { ...country3_17, x: 4.06 });
slide17.addText(slideData17.countries[3], { ...country4_17, x: 5.27 });
slide17.addText(slideData17.countries[4], { ...country5_17, x: 6.43 });
slide17.addText(slideData17.countries[5], { ...country6_17, x: 7.6 });
slide17.addText(slideData17.countries[6], { ...country7_17, x: 8.9 });

slide17.addImage({ x: 3.04, y: 1.22, w: 0.37, h: 0.38, path: slideData17.flags[1] });
slide17.addImage({ x: 4.28, y: 1.22, w: 0.37, h: 0.38, path: slideData17.flags[2] });
slide17.addImage({ x: 5.50, y: 1.22, w: 0.37, h: 0.38, path: slideData17.flags[3] });
slide17.addImage({ x: 6.69, y: 1.22, w: 0.37, h: 0.38, path: slideData17.flags[4] });
slide17.addImage({ x: 7.87, y: 1.22, w: 0.37, h: 0.38, path: slideData17.flags[5] });
slide17.addImage({ x: 9.13, y: 1.22, w: 0.37, h: 0.38, path: slideData17.flags[6] });

// ---- Prepare table arrays ----
const countryLabels17 = ["SEA", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
const funnelLabels17 = occupationLabel;
const countryData17 = data['P5'];
// const quarterData17 = data['CM_C17Quarter'];

const baseArray17 = [];
for (const country of countryLabels17) {
  const cData = countryData17[country];
  baseArray17.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
}
const bCountRow17 = [{ text: "", options: {} }];
baseArray17.forEach(val => {
  bCountRow17.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});

// Country table
let countryTable17 = [];
for (let i = 0; i < funnelLabels17.length; i++) {
  let row = [];
  let cleanLabel = funnelLabels17[i];
  cleanLabel = cleanLabel.replace(/<[^>]*>/g, '').trim();
  row.push({
    text: cleanLabel,
    options: {
        border: [{ pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" }]
    }
  });
  countryLabels17.forEach(country => {
    const cell = countryData17[country] && countryData17[country][i] && typeof countryData17[country][i].percentage !== 'undefined'
      ? countryData17[country][i].percentage + "%"
      : "-";
    row.push({text: cell,
      options: {
        border: [{ pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" }]
      }
    });
  });
  countryTable17.push(row);
}


slide17.addTable(countryTable17, {
  x: 0.23, y: 1.86, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  border: { type: "bottom", pt: '0.5', color: 'cccccc' }
});
slide17.addTable([bCountRow17], {
  x: 0.23, y: 3.62, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});
/* 
slide17.addTable(quarterTable17, {
  x: 7.35, y: 1.65, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  border: { type: "bottom", pt: '0.5', color: 'cccccc' }
}); */

// ---- Footnotes and Logos ----
slide17.addText(slideData17.bottom1, fText1_17);
slide17.addText(slideData17.bottom2, fText2_17);
slide17.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });
slide17.addText([
  { text: slideData17.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData17.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData17.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData17.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData17.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
  { text: slideData17.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } }
], { x: 8.07, y: 4.84, w: 1.83, h: 0.30 });
slide17.addImage({ ...logo1_17, path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png" });
slide17.addImage({ ...logo2_17, path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png" });


// ----------- PPT Slide 18-----------
let topHead_18 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
let subHead_18 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
let leftHead_18 = { x: 0.12, y: 0.75, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let leftHead_18_2 = { x: 0.12, y: 2.79, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let fText1_18 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
let fText2_18 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
let logo1_18 = { x: 8.51, y: 5.21, w: 0.80, h: 0.28 };
let logo2_18 = { x: 9.36, y: 5.18, w: 0.54, h: 0.35 };

let country1_18 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country2_18 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country3_18 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country4_18 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country5_18 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country6_18 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country7_18 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

// Slide titles/static text
const slideData18 = {
  title: "Profile of Consumers",
//   subtitle: "Dairy Milk (Flavored & Unflavored)",
  subtitle1: "H1'25",
//   subtitle2: "Change in household consumption over last 12 months",
  countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: [
            "", // SEA; can be filled with an icon path if available
            "https://keresearch.in/mdynata/assets/images/1.png",
            "https://keresearch.in/mdynata/assets/images/2.png",
            "https://keresearch.in/mdynata/assets/images/3.png",
            "https://keresearch.in/mdynata/assets/images/4.png",
            "https://keresearch.in/mdynata/assets/images/5.png",
            "https://keresearch.in/mdynata/assets/images/6.png"
        ],
  bottom1: "",
  bottom2: "",
  bottom3: "",
  btm1: "Sig.", btm2: "High/", btm3: "Low", btm4: " vs.", btm5: "previous year", btm6: " at 95% CI"
};

// ---- Draw headings and visuals ----
slide18.addText(slideData18.title, topHead_18);
// slide18.addText(slideData18.subtitle, subHead_18);
// slide18.addText(slideData18.subtitle2, leftHead_18_2);
slide18.addText(slideData18.subtitle1, leftHead_18);
slide18.addShape(pptx.ShapeType.line, { x: 0.18, y: 1.02, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });

slide18.addText(slideData18.countries[0], { ...country1_18, x: 1.56 });
slide18.addText(slideData18.countries[1], { ...country2_18, x: 2.8 });
slide18.addText(slideData18.countries[2], { ...country3_18, x: 4.06 });
slide18.addText(slideData18.countries[3], { ...country4_18, x: 5.27 });
slide18.addText(slideData18.countries[4], { ...country5_18, x: 6.43 });
slide18.addText(slideData18.countries[5], { ...country6_18, x: 7.6 });
slide18.addText(slideData18.countries[6], { ...country7_18, x: 8.9 });

slide18.addImage({ x: 3.04, y: 1.22, w: 0.37, h: 0.38, path: slideData18.flags[1] });
slide18.addImage({ x: 4.28, y: 1.22, w: 0.37, h: 0.38, path: slideData18.flags[2] });
slide18.addImage({ x: 5.50, y: 1.22, w: 0.37, h: 0.38, path: slideData18.flags[3] });
slide18.addImage({ x: 6.69, y: 1.22, w: 0.37, h: 0.38, path: slideData18.flags[4] });
slide18.addImage({ x: 7.87, y: 1.22, w: 0.37, h: 0.38, path: slideData18.flags[5] });
slide18.addImage({ x: 9.13, y: 1.22, w: 0.37, h: 0.38, path: slideData18.flags[6] });

// ---- Prepare table arrays ----
const countryLabels18 = ["SEA", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
const funnelLabels18 = incomeLabel;
const countryData18 = data['S7'];
// const quarterData18 = data['CM_C18Quarter'];

const baseArray18 = [];
for (const country of countryLabels18) {
  const cData = countryData18[country];
  baseArray18.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
}
const bCountRow18 = [{ text: "", options: {} }];
baseArray18.forEach(val => {
  bCountRow18.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});

// Country table
let countryTable18 = [];
for (let i = 0; i < funnelLabels18.length; i++) {
  let row = [];
  row.push({
    text: funnelLabels18[i],
    options: {
        border: [{ pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" }]
    }
  });
  countryLabels18.forEach(country => {
    const cell = countryData18[country] && countryData18[country][i] && typeof countryData18[country][i].percentage !== 'undefined'
      ? countryData18[country][i].percentage + "%"
      : "-";
    row.push({text: cell,
      options: {
        border: [{ pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" }]
      }
    });
  });
  countryTable18.push(row);
}
/* let quarterTable18 = [
  ["", "Q1'25", "Q2'25"]
];
for (let i = 0; i < funnelLabels18.length; i++) {
  quarterTable18.push([
    funnelLabels18[i],
    quarterData18["Q1'25"][i].percentage + "%",
    quarterData18["Q2'25"][i].percentage + "%"
  ]);
} */

slide18.addTable(countryTable18, {
  x: 0.23, y: 1.86, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  border: { type: "bottom", pt: '0.5', color: 'cccccc' }
});
slide18.addTable([bCountRow18], {
  x: 0.23, y: 3.3, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});
/* 
slide18.addTable(quarterTable18, {
  x: 7.35, y: 1.65, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  border: { type: "bottom", pt: '0.5', color: 'cccccc' }
}); */

// ---- Footnotes and Logos ----
slide18.addText(slideData18.bottom1, fText1_18);
slide18.addText(slideData18.bottom2, fText2_18);
slide18.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });
slide18.addText([
  { text: slideData18.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData18.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData18.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData18.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData18.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
  { text: slideData18.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } }
], { x: 8.07, y: 4.84, w: 1.83, h: 0.30 });
slide18.addImage({ ...logo1_18, path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png" });
slide18.addImage({ ...logo2_18, path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png" });


// slide 19 -------------------------------

let topHead_19 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
let subHead_19 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
let leftHead_19 = { x: 0.12, y: 0.75, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let leftHead_19_2 = { x: 0.12, y: 2.79, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let fText1_19 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
let fText2_19 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
let logo1_19 = { x: 8.51, y: 5.21, w: 0.80, h: 0.28 };
let logo2_19 = { x: 9.36, y: 5.18, w: 0.54, h: 0.35 };

let country1_19 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country2_19 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country3_19 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country4_19 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country5_19 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country6_19 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country7_19 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

// Slide titles/static text
const slideData19 = {
  title: "Profile of Consumers",
//   subtitle: "Dairy Milk (Flavored & Unflavored)",
  subtitle1: "H1'25",
//   subtitle2: "Change in household consumption over last 12 months",
  countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: [
            "", // SEA; can be filled with an icon path if available
            "https://keresearch.in/mdynata/assets/images/1.png",
            "https://keresearch.in/mdynata/assets/images/2.png",
            "https://keresearch.in/mdynata/assets/images/3.png",
            "https://keresearch.in/mdynata/assets/images/4.png",
            "https://keresearch.in/mdynata/assets/images/5.png",
            "https://keresearch.in/mdynata/assets/images/6.png"
        ],
  bottom1: "P5. Please select your Occupation status.",
  bottom2: "",
  bottom3: "",
  btm1: "Sig.", btm2: "High/", btm3: "Low", btm4: " vs.", btm5: "previous year", btm6: " at 95% CI"
};

// ---- Draw headings and visuals ----
slide19.addText(slideData19.title, topHead_19);
// slide19.addText(slideData19.subtitle, subHead_19);
// slide19.addText(slideData19.subtitle2, leftHead_19_2);
slide19.addText(slideData19.subtitle1, leftHead_19);
slide19.addShape(pptx.ShapeType.line, { x: 0.19, y: 1.02, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });

slide19.addText(slideData19.countries[0], { ...country1_19, x: 1.56 });
slide19.addText(slideData19.countries[1], { ...country2_19, x: 2.8 });
slide19.addText(slideData19.countries[2], { ...country3_19, x: 4.06 });
slide19.addText(slideData19.countries[3], { ...country4_19, x: 5.27 });
slide19.addText(slideData19.countries[4], { ...country5_19, x: 6.43 });
slide19.addText(slideData19.countries[5], { ...country6_19, x: 7.6 });
slide19.addText(slideData19.countries[6], { ...country7_19, x: 8.9 });

slide19.addImage({ x: 3.04, y: 1.22, w: 0.37, h: 0.38, path: slideData19.flags[1] });
slide19.addImage({ x: 4.28, y: 1.22, w: 0.37, h: 0.38, path: slideData19.flags[2] });
slide19.addImage({ x: 5.50, y: 1.22, w: 0.37, h: 0.38, path: slideData19.flags[3] });
slide19.addImage({ x: 6.69, y: 1.22, w: 0.37, h: 0.38, path: slideData19.flags[4] });
slide19.addImage({ x: 7.87, y: 1.22, w: 0.37, h: 0.38, path: slideData19.flags[5] });
slide19.addImage({ x: 9.13, y: 1.22, w: 0.37, h: 0.38, path: slideData19.flags[6] });

// ---- Prepare table arrays ----
const countryLabels19 = ["SEA", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
const funnelLabels19 = relationXX;
const countryData19 = data['P1'];
// const quarterData19 = data['CM_C19Quarter'];

const baseArray19 = [];
for (const country of countryLabels19) {
  const cData = countryData19[country];
  baseArray19.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
}
const bCountRow19 = [{ text: "", options: {} }];
baseArray19.forEach(val => {
  bCountRow19.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});

// Country table
let countryTable19 = [];
for (let i = 0; i < funnelLabels19.length; i++) {
  let row = [];
  row.push({
    text: funnelLabels19[i],
    options: {
        border: [{ pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" }]
    }
  });
  countryLabels19.forEach(country => {
    const cell = countryData19[country] && countryData19[country][i] && typeof countryData19[country][i].percentage !== 'undefined'
      ? countryData19[country][i].percentage + "%"
      : "-";
    row.push({text: cell,
      options: {
        border: [{ pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" }]
      }
    });
  });
  countryTable19.push(row);
}


slide19.addTable(countryTable19, {
  x: 0.23, y: 1.86, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  border: { type: "bottom", pt: '0.5', color: 'cccccc' }
});
slide19.addTable([bCountRow19], {
  x: 0.23, y: 3.08, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});
/* 
slide19.addTable(quarterTable19, {
  x: 7.35, y: 1.65, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  border: { type: "bottom", pt: '0.5', color: 'cccccc' }
}); */

// ---- Footnotes and Logos ----
slide19.addText(slideData19.bottom1, fText1_19);
slide19.addText(slideData19.bottom2, fText2_19);
slide19.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });
slide19.addText([
  { text: slideData19.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData19.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData19.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData19.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData19.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
  { text: slideData19.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } }
], { x: 8.07, y: 4.84, w: 1.83, h: 0.30 });
slide19.addImage({ ...logo1_19, path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png" });
slide19.addImage({ ...logo2_19, path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png" });

	
// slide 20 ----------------------------
let topHead_20 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
let subHead_20 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
let leftHead_20 = { x: 0.12, y: 0.75, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let leftHead_20_2 = { x: 0.12, y: 2.79, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let fText1_20 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
let fText2_20 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
let logo1_20 = { x: 8.51, y: 5.21, w: 0.80, h: 0.28 };
let logo2_20 = { x: 9.36, y: 5.18, w: 0.54, h: 0.35 };

let country1_20 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country2_20 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country3_20 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country4_20 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country5_20 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country6_20 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country7_20 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

// Slide titles/static text
const slideData20 = {
  title: "Profile of Consumers",
//   subtitle: "Dairy Milk (Flavored & Unflavored)",
  subtitle1: "H1'25",
//   subtitle2: "Change in household consumption over last 12 months",
  countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: [
            "", // SEA; can be filled with an icon path if available
            "https://keresearch.in/mdynata/assets/images/1.png",
            "https://keresearch.in/mdynata/assets/images/2.png",
            "https://keresearch.in/mdynata/assets/images/3.png",
            "https://keresearch.in/mdynata/assets/images/4.png",
            "https://keresearch.in/mdynata/assets/images/5.png",
            "https://keresearch.in/mdynata/assets/images/6.png"
        ],
  bottom1: "P5. Please select your Occupation status.",
  bottom2: "",
  bottom3: "",
  btm1: "Sig.", btm2: "High/", btm3: "Low", btm4: " vs.", btm5: "previous year", btm6: " at 95% CI"
};

// ---- Draw headings and visuals ----
slide20.addText(slideData20.title, topHead_20);
// slide20.addText(slideData20.subtitle, subHead_20);
// slide20.addText(slideData20.subtitle2, leftHead_20_2);
slide20.addText(slideData20.subtitle1, leftHead_20);
slide20.addShape(pptx.ShapeType.line, { x: 0.20, y: 1.02, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });

slide20.addText(slideData20.countries[0], { ...country1_20, x: 1.56 });
slide20.addText(slideData20.countries[1], { ...country2_20, x: 2.8 });
slide20.addText(slideData20.countries[2], { ...country3_20, x: 4.06 });
slide20.addText(slideData20.countries[3], { ...country4_20, x: 5.27 });
slide20.addText(slideData20.countries[4], { ...country5_20, x: 6.43 });
slide20.addText(slideData20.countries[5], { ...country6_20, x: 7.6 });
slide20.addText(slideData20.countries[6], { ...country7_20, x: 8.9 });

slide20.addImage({ x: 3.04, y: 1.22, w: 0.37, h: 0.38, path: slideData20.flags[1] });
slide20.addImage({ x: 4.28, y: 1.22, w: 0.37, h: 0.38, path: slideData20.flags[2] });
slide20.addImage({ x: 5.50, y: 1.22, w: 0.37, h: 0.38, path: slideData20.flags[3] });
slide20.addImage({ x: 6.69, y: 1.22, w: 0.37, h: 0.38, path: slideData20.flags[4] });
slide20.addImage({ x: 7.87, y: 1.22, w: 0.37, h: 0.38, path: slideData20.flags[5] });
slide20.addImage({ x: 9.13, y: 1.22, w: 0.37, h: 0.38, path: slideData20.flags[6] });

// ---- Prepare table arrays ----
const countryLabels20 = ["SEA", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
const funnelLabels20 = CMC16label;
const countryData20 = data['CM_C16Country'];
// const quarterData20 = data['CM_C20Quarter'];

const baseArray20 = [];
for (const country of countryLabels20) {
  const cData = countryData20[country];
  baseArray20.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
}

const bCountRow20 = [{ text: "", options: {} }];
baseArray20.forEach(val => {
  bCountRow20.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});


// Country table
let countryTable20 = [];
for (let i = 0; i < funnelLabels20.length; i++) {
  let row = [];
  row.push({
    text: funnelLabels20[i],
    options: {
        border: [{ pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" }]
    }
  });
  countryLabels20.forEach(country => {
    const cell = countryData20[country] && countryData20[country][i] && typeof countryData20[country][i].percentage !== 'undefined'
      ? countryData20[country][i].percentage + "%"
      : "-";
    row.push({text: cell,
      options: {
        border: [{ pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" }]
      }
    });
  });
  countryTable20.push(row);
}


slide20.addTable(countryTable20, {
  x: 0.23, y: 1.86, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7, fontFace: 'Arial', align: 'center',
});

slide20.addTable([bCountRow20], {
  x: 0.23, y: 3.86, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});

/* 
slide20.addTable(quarterTable20, {
  x: 7.35, y: 1.65, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  border: { type: "bottom", pt: '0.5', color: 'cccccc' }
}); */

// ---- Footnotes and Logos ----
slide20.addText(slideData20.bottom1, fText1_20);
slide20.addText(slideData20.bottom2, fText2_20);
slide20.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });
slide20.addText([
  { text: slideData20.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData20.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData20.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData20.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData20.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
  { text: slideData20.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } }
], { x: 8.07, y: 4.84, w: 1.83, h: 0.30 });
slide20.addImage({ ...logo1_20, path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png" });
slide20.addImage({ ...logo2_20, path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png" });


// ----------- PPT Slide 23: S -----------

// Slide essentials
let topHead_23 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
let subHead_23 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
// let subHead_23_2 = { x: 0.24, y: 2.79, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
let leftHead_23 = { x: 0.12, y: 0.75, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let leftHead_23_2 = { x: 0.12, y: 2.79, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let fText1_23 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
let fText2_23 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
let logo1_23 = { x: 8.51, y: 5.21, w: 0.80, h: 0.28 };
let logo2_23 = { x: 9.36, y: 5.18, w: 0.54, h: 0.35 };

let country1_23 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country2_23 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country3_23 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country4_23 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country5_23 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country6_23 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country7_23 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

// Slide titles/static text
const slideData23 = {
  title: "Household Consumption",
  subtitle: "Dairy Milk (Flavored & Unflavored)",
  subtitle1: "Who else consumes at home, once a month",
//   subtitle2: "Quarterly – SEA (Q1’25 & Q2’25)",
  countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: [
            "", // SEA; can be filled with an icon path if available
            "https://keresearch.in/mdynata/assets/images/1.png",
            "https://keresearch.in/mdynata/assets/images/2.png",
            "https://keresearch.in/mdynata/assets/images/3.png",
            "https://keresearch.in/mdynata/assets/images/4.png",
            "https://keresearch.in/mdynata/assets/images/5.png",
            "https://keresearch.in/mdynata/assets/images/6.png"
        ],
  bottom1: "C16. Earlier, you mentioned that you have household members in the following age groups. Who else at home consumes Dairy Milk (from Cows) at least once a month besides you?",
  bottom2: "",
  btm1: "Sig.", btm2: "High/", btm3: "Low", btm4: " vs.", btm5: "previous year", btm6: " at 95% CI"
};

// ---- Draw headings and visuals ----
slide23.addText(slideData23.title, topHead_23);
slide23.addText(slideData23.subtitle, subHead_23);
// slide23.addText(slideData23.subtitle2, leftHead_23_2);
slide23.addText(slideData23.subtitle1, leftHead_23);
slide23.addShape(pptx.ShapeType.line, { x: 0.16, y: 1.02, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });
// slide23.addShape(pptx.ShapeType.line, { x: 0.16, y: 3.08, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });

slide23.addText(slideData23.countries[0], { ...country1_23, x: 1.01 });
slide23.addText(slideData23.countries[1], { ...country2_23, x: 1.87 });
slide23.addText(slideData23.countries[2], { ...country3_23, x: 2.74 });
slide23.addText(slideData23.countries[3], { ...country4_23, x: 3.55 });
slide23.addText(slideData23.countries[4], { ...country5_23, x: 4.32 });
slide23.addText(slideData23.countries[5], { ...country6_23, x: 5.10 });
slide23.addText(slideData23.countries[6], { ...country7_23, x: 5.91 });

slide23.addImage({ x: 2.09, y: 1.22, w: 0.37, h: 0.38, path: slideData23.flags[1] });
slide23.addImage({ x: 2.94, y: 1.22, w: 0.37, h: 0.38, path: slideData23.flags[2] });
slide23.addImage({ x: 3.73, y: 1.22, w: 0.37, h: 0.38, path: slideData23.flags[3] });
slide23.addImage({ x: 4.54, y: 1.22, w: 0.37, h: 0.38, path: slideData23.flags[4] });
slide23.addImage({ x: 5.33, y: 1.22, w: 0.37, h: 0.38, path: slideData23.flags[5] });
slide23.addImage({ x: 6.09, y: 1.22, w: 0.37, h: 0.38, path: slideData23.flags[6] });

// ---- Prepare table arrays ----
const countryLabels23 = ["SEA", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
const quarterLabels23 = ["Q1'25", "Q2'25"];
const funnelLabels23 = CMC16label; // Example: ["Increased", "No Change", "Decreased"]
const countryData23 = data['CM_C16Country'];
const quarterData23 = data['CM_C16Quarter'];

const baseArray23_1 = [];
for (const country of countryLabels23) {
  const cData = countryData23[country];
  baseArray23_1.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
}
const bCountRow23_1 = [{ text: "", options: {} }];
baseArray23_1.forEach(val => {
  bCountRow23_1.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});


const baseArray23_3 = [];
for (const quarter of quarterLabels23) {
  const cData = quarterData23[quarter];
  baseArray23_3.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
}
const bCountRow23_3 = [{ text: "", options: {} }];
baseArray23_3.forEach(val => {
  bCountRow23_3.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});

slide23.addTable([bCountRow23_1], {
  x: 0.23, y: 4.05, w: 6.5,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});
/* slide23.addTable([bCountRow12_2], {
  x: 0.23, y: 4.09, w: 6.5,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
}); */
slide23.addTable([bCountRow23_3], {
  x: 7.35, y: 4.05, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});
/* slide23.addTable([bCountRow12_4], {
  x: 7.35, y: 4.09, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});
 */

// Country table
let countryTable23 = [];
// let countryTable232 = [];
for (let i = 0; i < funnelLabels23.length; i++) {
//   let row = [funnelLabels23[i]];
    let row = [];
  row.push({
    text: funnelLabels23[i],
    options: {
        border: [{ pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" }]
    }
  });
  countryLabels23.forEach(country => {
    const cell = countryData23[country] && countryData23[country][i] && typeof countryData23[country][i].percentage !== 'undefined'
      ? countryData23[country][i].percentage + "%"
      : "-";
    row.push({text: cell,
      options: {
        border: [{ pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" }]
      }
    });
  });
  countryTable23.push(row);
}
/* for (let i = 0; i < funnelLabels23.length; i++) {
  let row = [];
  row.push({
    text: funnelLabels23[i],
    options: {
        border: [{ pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" }]
    }
  });
  countryLabels23.forEach(country => {
    const cell = countryData232[country] && countryData232[country][i] && typeof countryData232[country][i].percentage !== 'undefined'
      ? countryData232[country][i].percentage + "%"
      : "-";
    row.push({text: cell,
      options: {
        border: [{ pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" }]
      }
    });
  });
  countryTable232.push(row);
} */
// Quarter table
let quarterTable23 = [
  [
    { text: "", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } },
    { text: "Q1'25", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } },
    { text: "Q2'25", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } }
  ]
];
/* let quarterTable232 = [
  [
    { text: "", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } },
    { text: "Q1'25", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } },
    { text: "Q2'25", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } }
  ]
]; */
for (let i = 0; i < funnelLabels23.length; i++) {
  quarterTable23.push([
    { text: funnelLabels23[i], options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } },
    { text: quarterData23["Q1'25"][i].percentage + "%", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } },
    { text: quarterData23["Q2'25"][i].percentage + "%", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } }
  ]);
}
/* for (let i = 0; i < funnelLabels23.length; i++) {
  quarterTable232.push([
   { text: funnelLabels23[i], options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } },
    { text: quarterData232["Q1'25"][i].percentage + "%", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } },
    { text: quarterData232["Q2'25"][i].percentage + "%", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } }
  ]);
} */

// ---- Add side-by-side tables ----
slide23.addTable(countryTable23, {
  x: 0.23, y: 1.86, w: 6.5,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  
});
/* slide23.addTable(countryTable232, {
  x: 0.23, y: 3.42, w: 6.5,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  
}); */
slide23.addTable(quarterTable23, {
  x: 7.35, y: 1.65, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  
});
/* slide23.addTable(quarterTable232, {
  x: 7.35, y: 3.2, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  
}); */

// ---- Footnotes and Logos ----
slide23.addText(slideData23.bottom1, fText1_23);
slide23.addText(slideData23.bottom2, fText2_23);
slide23.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });
slide23.addText([
  { text: slideData23.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData23.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData23.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData23.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData23.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
  { text: slideData23.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } }
], { x: 8.07, y: 4.84, w: 1.83, h: 0.30 });
slide23.addImage({ ...logo1_23, path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png" });
slide23.addImage({ ...logo2_23, path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png" });

// ----------- End of Slide 23 Code -----------

// Slide 21 Reason for Consumption
	
	let topHead_21 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
    let subHead_21 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
    let leftHead_21 = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let leftSubHead_21 = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    let rightHead_21 = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let  rightSubHead_21 = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };

    let country1_21 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country2_21 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country3_21 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country4_21 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country5_21 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country6_21 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country7_21 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

    let opts12_21 = { x: 0.36, y: 2.22, w: 0.96, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts13_21 = { x: 0.34, y: 2.79, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts14_21 = { x: 0.32, y: 3.43, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts15_21 = { x: 0.33, y: 4.04, w: 0.99, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let fText1_21 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
    let fText2_21 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
	
	let tableBase_21 = {"x": 7.95,"y": 2.84,"w": 0.67,"h": 0.30,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};

    let logo1_21 = {"x": 8.51,"y": 5.21,"w": 0.80,"h": 0.28};
    let logo2_21 = {"x": 9.36,"y": 5.18,"w": 0.54,"h": 0.35};
	
	
let stackChart_21 = {
  x: 1.88,
  y: 1.71,
  w: 1.39,
  h: 2.87,
  barDir: "bar", // Horizontal bars
  barGrouping: "standard", // Not stacked
  barGapWidthPct: 50, // Reduce gap between bars
  showValue: true,
  dataLabelColor: "000000",
  dataLabelFontFace: "Arial",
  dataLabelFontSize: 7,
  dataLabelFontBold: false,
  dataLabelFormatCode: '0"%"',
 
  chartColors:["CFCFCF", "F29E1F", "F8A75B", "5C7146", "B8E986", "80B8FF", "365A8C", "E0E0E0", "7C7C7C", "F5A623", "C8B800", "70854A", "B5E3A6", "7FB2FF", "3A5A81"],
 
  showValAxis: false,
  valAxisLabelPos: 'none',
  valAxisLineShow: false,
  valGridLine: { style: 'none' },
valAxisMaxVal: 70,
  // Hide Y-axis title and legend
  showLegend: false,
  showTitle: false,

  // Optional: category axis (Y) label tweaks
  showCatAxis: true,
  catAxisLabelFontSize: 1,
  catAxisLabelColor: "ffffff",
  
  valGridLine: {
    style: 'none'
  }
};

let stackChart_21a = {
  x: 0.1,
  y: 1.71,
  w: 3.94,
  h: 2.87,
  barDir: "bar", // Horizontal bars
  barGrouping: "standard", // Not stacked
  barGapWidthPct: 50, // Reduce gap between bars
  showValue: true,
  dataLabelColor: "000000",
  dataLabelFontFace: "Arial",
  dataLabelFontSize: 7,
  dataLabelFontBold: false,
  dataLabelFormatCode: '0"%"',
 
  chartColors:["CFCFCF", "F29E1F", "F8A75B", "5C7146", "B8E986", "80B8FF", "365A8C", "E0E0E0", "7C7C7C", "F5A623", "C8B800", "70854A", "B5E3A6", "7FB2FF", "3A5A81"],
 
  showValAxis: false,
  valAxisLabelPos: 'none',
  valAxisLineShow: false,
  valGridLine: { style: 'none' },
valAxisMaxVal: 70,
  // Hide Y-axis title and legend
  showLegend: false,
  showTitle: false,

  // Optional: category axis (Y) label tweaks
  showCatAxis: true,
  catAxisLabelFontSize: 6,
  catAxisLabelColor: "000000",
  
  valGridLine: {
    style: 'none'
  }
};

	
		var ReasonforConsumptioncountryLevel = data['CM_C12Country'];
        var ReasonforConsumptionquarterLevel = data['CM_C12Quarter'];
        var Q1 = ReasonforConsumptionquarterLevel["Q1'25"];
        var Q2 = ReasonforConsumptionquarterLevel["Q2'25"];
        const ReasonforConsumptionq1= Q1.map(item => item.percentage);
        const ReasonforConsumptionq2= Q2.map(item => item.percentage);
        var ReasonforConsumptionbaseData = [Q1[0].bCount, Q2[0].bCount];
        const ReasonforConsumptioncountryData = {};
        const ReasonforConsumption1 = [];
        
        const ReasonforConsumptionbaseArray = [];

        countryLabel4.forEach(country => {
            if (ReasonforConsumptioncountryLevel[country]) {
                ReasonforConsumptioncountryData[country] = ReasonforConsumptioncountryLevel[country];
            }
        });
		
		const percentageMap = {};

		Object.keys(ReasonforConsumptioncountryData).forEach(country => {
			const entries = ReasonforConsumptioncountryData[country];
			if (Array.isArray(entries)) {
				percentageMap[country] = entries.map(item => item.percentage);
			} else {
				console.warn(`Skipping ${country} — not an array`);
			}
		});
		console.log("ddd");
		console.log(percentageMap);
                
        for (const country in ReasonforConsumptioncountryData) {
            const countryData = ReasonforConsumptioncountryData[country];
            ReasonforConsumptionbaseArray.push(`n-${countryData[0].bCount}`);
            ReasonforConsumption1.push(countryData[0].percentage);
        }

        const ReasonforConsumptionArray = [{
            title: "Reason for Consumption (SEA)",
            subtitle: "Dairy Milk (Flavored & Unflavored)",
            subtitle1: "",
            subtitle3: "",
            countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
            flags: ["","https://keresearch.in/mdynata/assets/images/1.png","https://keresearch.in/mdynata/assets/images/2.png","https://keresearch.in/mdynata/assets/images/3.png","https://keresearch.in/mdynata/assets/images/4.png","https://keresearch.in/mdynata/assets/images/5.png","https://keresearch.in/mdynata/assets/images/6.png"],
            funnel:["Supports overall good health","Good balance of taste and health","Has high-quality ingredients","It keeps me from feeling hungry until the next meal","Convenient to purchase, consume, or store","Good value for money","Something that I usually have","Something new and exciting","Improves physical performance/Provides energy","It helps me concentrate and focus","Helps reduce stress or overcome boredom","It is something I enjoy having","It is something to share with friends and family","It has a taste that I prefer","Sustainable and environmentally friendly choice"],
            f:[ReasonforConsumption1],
			f1:[percentageMap['SEA'],percentageMap['Singapore'],percentageMap['Thailand'],percentageMap['Malaysia'],percentageMap['Indonesia'],percentageMap['Philippines'],percentageMap['Vietnam']],
            sampleSizes:ReasonforConsumptionbaseArray,
            bottom1:"C12. Which of these BEST describes why you had it?",
            bottom2:"",
            btm1:"Sig.", btm2:"High/", btm3:"Low", btm4:" vs.", btm5:"previous wave", btm6:" at 95% CI",
            
            
        }];

        ReasonforConsumptionArray.forEach(slideData => {
            slide21.addText(slideData.title,topHead_21);
            slide21.addText(slideData.subtitle,subHead_21);
            slide21.addText(slideData.subtitle1,leftHead_21);
            slide21.addText(slideData.subtitle3,rightHead_21);
			
            /*slide21.addShape(pptx.ShapeType.line, { x: 0.16,y: 1.02,w: 6.51, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide21.addShape(pptx.ShapeType.line, { "x": 6.83,"y": 1.02,"w": 2.46, h: 0, line: { color: '75b1bb', width: 1.2 } });*/
            slide21.addText(slideData.countries[0],{...country1_21,x: 1.81});
            slide21.addText(slideData.countries[1],{...country2_21,x: 2.98});
            slide21.addText(slideData.countries[2],{...country3_21,x: 4.24});
            slide21.addText(slideData.countries[3],{...country4_21,x: 5.43});
            slide21.addText(slideData.countries[4],{...country5_21,x: 6.54});
            slide21.addText(slideData.countries[5],{...country6_21,x: 7.66});
            slide21.addText(slideData.countries[6],{...country7_21,x: 8.84});
            slide21.addImage({ x: 3.19, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[1] });
            slide21.addImage({ x: 4.40, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[2] });
            slide21.addImage({ x: 5.57, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[3] });
            slide21.addImage({ x: 6.73, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[4] });
            slide21.addImage({ x: 7.85, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[5] });
            slide21.addImage({ x: 8.97, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[6] });
			
			const xPositions = [1.88, 2.83, 4.09, 5.24, 6.42, 7.56, 8.66];
			console.log(slideData.f1);
			const chartData1 = {
				name: 'Reason for Consumption', 
				labels: slideData.funnel.slice().reverse(),
      
				values: slideData.f1[0].slice().reverse(),
			  };

			  
			  const tnpa1 = [
				{
				  type: pptx.charts.BAR,
				  data: [chartData1],
				  options: {
					barGrouping: "standard",
				  },
				},
			  ];

			  slide21.addChart(tnpa1, stackChart_21a);
			  
			for (let i = 1; i < 7; i++) {
			  const chartData = {
				name: 'Reason for Consumption', 
				labels: ["", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
				values: slideData.f1[i].slice().reverse(),
			  };

			  const chartOpts = JSON.parse(JSON.stringify(stackChart_21)); // Deep copy to avoid mutation
			  chartOpts.x = xPositions[i];

			  const tnpa = [
				{
				  type: pptx.charts.BAR,
				  data: [chartData],
				  options: {
					barGrouping: "standard",
				  },
				},
			  ];

			  slide21.addChart(tnpa, chartOpts);
			}
             
			
			
			
			slide21.addText("H1’25",{"x": 1.04,"y": 1.53,"w": 0.70, "h": 0.21,fontSize: 8,fontFace: 'Arial', align: 'center',color: '000000', bold: true, }); 
			
			slide21.addText('Base – Consumed in Past 7 days',{"x": 0.20,"y": 4.46,"w": 1.73, "h": 0.20,fontSize: 7,fontFace: 'Arial', align: 'center',color: '969696'}); 

			const xPositions1 = [1.57,2.91, 4.13, 5.31, 6.50, 7.64, 8.74];

			for (let i = 0; i < 7; i++) {
			slide21.addText(slideData.sampleSizes[i],{"x": xPositions1[i],"y": 4.46,"w": 1.04, h: 0.20,fontSize: 7,fontFace: 'Arial', align: 'center',color: '969696'});
			}
			
			
			const xPositions2 = [2.02, 2.19, 2.36, 2.52, 2.72, 2.87, 3.03, 3.23, 3.39, 3.54,3.74, 3.90, 4.09, 4.25];

			for (let i = 0; i < 14; i++) {
			slide21.addShape(pptx.ShapeType.line, { x: 0.24, y: xPositions2[i], w: 9.54, h: 0, line: { color: 'e0e0e0', width: 1 } });
			}

			 

             slide21.addText(slideData.bottom1,fText1_21);
             slide21.addText(slideData.bottom2,fText2_21);
             slide21.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });

             
			
            slide21.addText([
                 { text: slideData.btm1, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm2, options: { color: '00b050',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm3, options: { color: 'ff0000',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm4, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm5, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: true } },
                 { text: slideData.btm6, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } }
             ], {"x": 8.07,"y": 4.84,"w": 1.83,"h": 0.30});

             slide21.addImage({...logo1_21,path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png"});
             slide21.addImage({...logo2_21,path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png"});

             /*slide21.addShape(pptx.ShapeType.line, {x: 6.74,y: 0.96,w: 0.00,h: 4.09,line: {color:'969696',width:1,dashType:'dash'}});*/
        });


        // ----------- PPT Slide 22: S -----------

// Slide essentials
let topHead_22 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
let subHead_22 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
// let subHead_22_2 = { x: 0.24, y: 2.79, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
let leftHead_22 = { x: 0.12, y: 0.75, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let leftHead_22_2 = { x: 0.12, y: 2.79, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let fText1_22 = { x: 0.20, y: 5.06, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
let fText2_22 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
let logo1_22 = { x: 8.51, y: 5.21, w: 0.80, h: 0.28 };
let logo2_22 = { x: 9.36, y: 5.18, w: 0.54, h: 0.35 };

let country1_22 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country2_22 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country3_22 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country4_22 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country5_22 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country6_22 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country7_22 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

// Slide titles/static text
const slideData22 = {
  title: "Purchase Behaviour",
  subtitle: "Dairy Milk (Flavored & Unflavored)",
  subtitle1: "Purchased in Household & Place of Purchase",
//   subtitle2: "Quarterly – SEA (Q1’25 & Q2’25)",
  countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: [
            "", // SEA; can be filled with an icon path if available
            "https://keresearch.in/mdynata/assets/images/1.png",
            "https://keresearch.in/mdynata/assets/images/2.png",
            "https://keresearch.in/mdynata/assets/images/3.png",
            "https://keresearch.in/mdynata/assets/images/4.png",
            "https://keresearch.in/mdynata/assets/images/5.png",
            "https://keresearch.in/mdynata/assets/images/6.png"
        ],
  bottom1: "C16. Earlier, you mentioned that you have household members in the following age groups. Who else at home consumes Dairy Milk (from Cows) at least once a month besides you?",
  bottom2: "",
  btm1: "Sig.", btm2: "High/", btm3: "Low", btm4: " vs.", btm5: "previous year", btm6: " at 95% CI"
};

// ---- Draw headings and visuals ----
slide22.addText(slideData22.title, topHead_22);
slide22.addText(slideData22.subtitle, subHead_22);
// slide22.addText(slideData22.subtitle2, leftHead_22_2);
slide22.addText(slideData22.subtitle1, leftHead_22);
slide22.addShape(pptx.ShapeType.line, { x: 0.16, y: 1.02, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });
// slide22.addShape(pptx.ShapeType.line, { x: 0.16, y: 3.08, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });

slide22.addText(slideData22.countries[0], { ...country1_22, x: 2.37 });
slide22.addText(slideData22.countries[1], { ...country2_22, x: 3.18 });
slide22.addText(slideData22.countries[2], { ...country3_22, x: 3.95 });
slide22.addText(slideData22.countries[3], { ...country4_22, x: 4.71 });
slide22.addText(slideData22.countries[4], { ...country5_22, x: 5.41 });
slide22.addText(slideData22.countries[5], { ...country6_22, x: 6.16 });
slide22.addText(slideData22.countries[6], { ...country7_22, x: 6.96 });

slide22.addImage({ x: 3.40, y: 1.22, w: 0.37, h: 0.38, path: slideData22.flags[1] });
slide22.addImage({ x: 4.14, y: 1.22, w: 0.37, h: 0.38, path: slideData22.flags[2] });
slide22.addImage({ x: 4.89, y: 1.22, w: 0.37, h: 0.38, path: slideData22.flags[3] });
slide22.addImage({ x: 5.63, y: 1.22, w: 0.37, h: 0.38, path: slideData22.flags[4] });
slide22.addImage({ x: 6.37, y: 1.22, w: 0.37, h: 0.38, path: slideData22.flags[5] });
slide22.addImage({ x: 7.15, y: 1.22, w: 0.37, h: 0.38, path: slideData22.flags[6] });

slide22.addText("Q1'25", { x: 8.02, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' });
slide22.addText("Q2'25", { x: 9.00, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' });

// ---- Prepare table arrays ----
const countryLabels22 = ["SEA", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
const quarterLabels22 = ["Q1'25", "Q2'25"];
const funnelLabels22 = CMC19label2; 
const countryData22 = data['CM_C19Country'];
const quarterData22 = data['CM_C19Quarter'];

const countryBarData22 = data['CM_C17_1Country'];
const quarterBarData22 = data['CM_C17_1Quarter'];

// const lthcolor = ["f8696b","f8878a","f9a6a9","fac5c8","fbe4e7","f4f9f9","d4ecdd","b4dfc1","94d2a5","63be7b"];


const countryPercentages = countryLabels22.map(
  country => countryBarData22[country]?.[0]?.percentage ?? 0
);

const quarterPercentages = quarterLabels22.map(
    quarter => quarterBarData22[quarter]?.[0]?.percentage ?? 0
);
console.log("conPer", countryPercentages);
console.log("quaPer", quarterPercentages);
slide22.addChart(
    pptx.ChartType.bar,
    [
        {
        name: "Purchase %",
        labels: countryLabels22,
        values: countryPercentages,
        color: '#3A5A81'
        }
    ],
    {
        x: 2.30,
        y: 1.76,
        w: 5.57,
        h: 0.97,
        barDir: "col",
        fontFace: "Arial",
        fontSize: 5,
        showValue: true,
        dataLabelFormatCode: '0"%"',
        dataLabelPosition: 'center',
        dataLabelColor: '#000000',
        catAxisLabelFontFace: "Arial",
        catAxisLabelFontSize: 5,
        valAxisLabelFontFace: "Arial",
        valAxisLabelFontSize: 5,
        dataLabelFontSize: 6,
        chartColors:['3A5A81'],
        barGapWidth: 90, 
        valGridLine: { color: 'FFFFFF', width: 0 },
        catGridLine: { color: 'FFFFFF', width: 0 },
        valAxisLine: { color: 'FFFFFF', width: 0 },
        catAxisLine: { color: 'cccccc', width: 0.5 },
        valAxisHidden: true,
        catAxisHidden: true
    }
);

slide22.addChart(
    pptx.ChartType.bar,
    [
        {
        name: "Purchase %",
        labels: quarterLabels22,
        values: quarterPercentages,
        color: '#3A5A81'
        }
    ],
    {
        x: 7.79,
        y: 1.76,
        w: 2.23,
        h: 0.97,
        barDir: "col",
        fontFace: "Arial",
        fontSize: 5,
        showValue: true,
        dataLabelFormatCode: '0"%"',
        dataLabelPosition: 'center',
        dataLabelColor: '#000000',
        catAxisLabelFontFace: "Arial",
        catAxisLabelFontSize: 5,
        valAxisLabelFontFace: "Arial",
        valAxisLabelFontSize: 5,
        dataLabelFontSize: 6,
        chartColors:['3A5A81'],
        barGapWidth: 90, 
        valGridLine: { color: 'FFFFFF', width: 0 },
        catGridLine: { color: 'FFFFFF', width: 0 },
        valAxisLine: { color: 'FFFFFF', width: 0 },
        catAxisLine: { color: 'cccccc', width: 0.5 },
        valAxisHidden: true,
        catAxisHidden: true
    }
);
const baseArray22_1 = [];
for (const country of countryLabels22) {
  const cData = countryData22[country];
  baseArray22_1.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
}
const bCountRow22_1 = [];
bCountRow22_1.push({ text: "", options: {} }); // Ensure this is always present

while (bCountRow22_1.length <= 7) { // Ensure row has 7 cells for 7 columns
    const idx = bCountRow22_1.length - 1;
    const val = baseArray22_1[idx] || "n--";
    bCountRow22_1.push({
        text: val,
        options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
    });
}


const baseArray22_3 = [];
for (const quarter of quarterLabels22) {
  const cData = quarterData22[quarter];
  baseArray22_3.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
}
const bCountRow22_3 = [{ text: "", options: {} }];
baseArray22_3.forEach(val => {
  bCountRow22_3.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});

slide22.addTable([bCountRow22_1], {
  x: 0.22, y: 4.75, w: 7.5,
  colW: [2.25, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});

slide22.addTable([bCountRow22_3], {
  x: 7.67, y: 4.75, w: 2,
  colW: [0, 1, 1],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});

/* // Country table
let countryTable22 = [];
// let countryTable222 = [];
for (let i = 0; i < funnelLabels22.length; i++) {
//   let row = [funnelLabels22[i]];
    let row = [];
  row.push({
    text: funnelLabels22[i],
    options: {
        border: [{ pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" }]
    }   
  });
  
  
    const cPercentages2 = countryLabels22.map(country => {
        const val = countryData22[country]?.[i]?.percentage;
        return typeof val === 'number' ? val : null;
    });

    const validValues = cPercentages2.filter(val => val !== null);
    const minVal = Math.min(...validValues);
    const maxVal = Math.max(...validValues);

function getColorIndex(val) {
  if (minVal === maxVal) return Math.floor(lthcolor.length / 2); // uniform
  const scaled = Math.floor(((val - minVal) / (maxVal - minVal)) * (lthcolor.length - 1));
  return Math.min(Math.max(scaled, 0), lthcolor.length - 1);
}

countryLabels22.forEach((country, idx) => {
  const val = cPercentages2[idx];
  const text = val !== null ? `${val}%` : "-";
  const bgColor = val !== null ? lthcolor[getColorIndex(val)] : "FFFFFF";

  row.push({
    text,
    options: {
      fill: bgColor,
      color: '000000',
      border: [
        { pt: 0, color: "FFFFFF" },
        { pt: 0, color: "FFFFFF" },
        { pt: 0.5, color: "cccccc" },
        { pt: 0, color: "FFFFFF" }
      ]
    }
  });
});

  countryTable22.push(row);
}*/
const lthcolor = ["f8696b","f8878a","f9a6a9","fac5c8","fbe4e7","f4f9f9","d4ecdd","b4dfc1","94d2a5","63be7b"];

let countryTable22 = [];

// Step 1: Build color mapping per country based on RANK (highest = green, lowest = red)
const countryColorMap = {};
countryLabels22.forEach(country => {
  const colValues = funnelLabels22.map((_, i) => {
    const val = countryData22[country]?.[i]?.percentage;
    return typeof val === "number" ? val : null;
  });

  // Create rank-based mapping
  const indexed = colValues
    .map((val, i) => ({ val, i }))
    .filter(obj => obj.val !== null)
    .sort((a, b) => b.val - a.val); // Descending

  const colorMap = new Array(funnelLabels22.length).fill("FFFFFF"); // default fill

  indexed.forEach((obj, rank) => {
    const colorIdx = Math.min(rank, lthcolor.length - 1); // Clamp if more than 10
    colorMap[obj.i] = lthcolor[lthcolor.length - 1 - colorIdx]; // Reverse index
  });

  countryColorMap[country] = colorMap;
});

// Step 2: Create the table rows
for (let i = 0; i < funnelLabels22.length; i++) {
  const row = [];

  // First column: label
  row.push({
    text: funnelLabels22[i],
    options: {
      border: [
        { pt: 0, color: "FFFFFF" },
        { pt: 0, color: "FFFFFF" },
        { pt: 0.5, color: "cccccc" },
        { pt: 0, color: "FFFFFF" }
      ],
      align: 'left',
      fontFace: 'Arial',
      fontSize: 7,
    }
  });

  // Country columns
  countryLabels22.forEach(country => {
    const val = countryData22[country]?.[i]?.percentage;
    const text = typeof val === "number" ? `${val}%` : "-";
    const fill = countryColorMap[country][i] ?? "FFFFFF";

    row.push({
      text,
      options: {
        fill,
        color: '000000',
        fontFace: 'Arial',
        fontSize: 7,
        align: 'center',
        border: [
          { pt: 0, color: "FFFFFF" },
          { pt: 0.5, color: "cccccc" },
          { pt: 0.5, color: "cccccc" },
          { pt: 0, color: "FFFFFF" }
        ]
      }
    });
  });

  countryTable22.push(row);
}


console.log("q1", quarterData22["Q1'25"]);
console.log("q2", quarterData22["Q2'25"]);

// Quarter table
/* let quarterTable22 = [
  [
    { text: "", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } },
    { text: "Q1'25", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } },
    { text: "Q2'25", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } }
  ]
]; */
// const lthcolor = ["f8696b","f8878a","f9a6a9","fac5c8","fbe4e7","f4f9f9","d4ecdd","b4dfc1","94d2a5","63be7b"];


let quarterTable22 = [];

// Step 1: Build color mapping per quarter based on vertical ranks
const quarterColorMap = {}; // quarter → [color by row]

quarterLabels22.forEach(quarter => {
  const colValues = funnelLabels22.map((_, i) => {
    const val = quarterData22[quarter]?.[i]?.percentage;
    return typeof val === "number" ? val : null;
  });

  const indexed = colValues
    .map((val, i) => ({ val, i }))
    .filter(obj => obj.val !== null)
    .sort((a, b) => b.val - a.val); // Descending

  const colorMap = new Array(funnelLabels22.length).fill("FFFFFF");

  indexed.forEach((obj, rank) => {
    const colorIdx = Math.min(rank, lthcolor.length - 1);
    colorMap[obj.i] = lthcolor[lthcolor.length - 1 - colorIdx]; // reversed for highest = green
  });

  quarterColorMap[quarter] = colorMap;
});

// Step 2: Create the table rows (excluding row labels)
for (let i = 0; i < funnelLabels22.length; i++) {
  const row = [];

  quarterLabels22.forEach(quarter => {
    const val = quarterData22[quarter]?.[i]?.percentage;
    const text = typeof val === "number" ? `${val}%` : "-";
    const fill = quarterColorMap[quarter][i] ?? "FFFFFF";

    row.push({
      text,
      options: {
        fill,
        color: '000000',
        fontFace: 'Arial',
        fontSize: 7,
        align: 'center',
        border: [
          { pt: 0, color: "FFFFFF" },
          { pt: 0.5, color: "cccccc" },
          { pt: 0.5, color: "cccccc" },
          { pt: 0, color: "FFFFFF" }
        ]
      }
    });
  });

  quarterTable22.push(row);
}


// ---- Add side-by-side tables ----
slide22.addTable(countryTable22, {
  x: 0.22, y: 2.59, w: 7.5,
  colW: [2.25, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  
});

slide22.addTable(quarterTable22, {
  x: 7.9, y: 2.59, w: 2,
  colW: [1, 1],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  
});



// ---- Footnotes and Logos ----
slide22.addText(slideData22.bottom1, fText1_22);
slide22.addText(slideData22.bottom2, fText2_22);
slide22.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });
slide22.addText([
  { text: slideData22.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData22.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData22.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData22.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData22.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
  { text: slideData22.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } }
], { x: 8.07, y: 4.84, w: 1.83, h: 0.30 });
slide22.addImage({ ...logo1_22, path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png" });
slide22.addImage({ ...logo2_22, path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png" });

// ----------- End of Slide 22 Code -----------


	
        
    pptx.writeFile({ fileName: "Dynata Dashboard PPT Report.pptx" });
}