'use strict';

var dimension = require('../../../design/dimension.js');
var Doc = require('../../util/Doc.js');

const Footer = ({ logo }) => async (doc) => {
    const defaultLogoWidth = 193 / 3;
    const defaultLogoHeight = 44 / 3;
    const logoWidth = 60;
    const logoHeight = 20;
    if (logo) {
        doc.image(`${__dirname}/../../../assets/image/footer_logo.png`, (Doc.Doc.width - defaultLogoWidth) / 2 - defaultLogoWidth / 2 - 6, Doc.Doc.height - defaultLogoHeight / 2 - dimension.Dimension.footerHeight / 2, {
            width: defaultLogoWidth,
            height: defaultLogoHeight,
        });
        doc.image(logo, (Doc.Doc.width - logoWidth) / 2 + logoWidth / 2 + 6, Doc.Doc.height - logoHeight / 2 - dimension.Dimension.footerHeight / 2, {
            width: logoWidth,
            height: logoHeight,
            fit: [logoWidth, logoHeight],
            align: 'center',
            valign: 'center',
        });
    }
    else {
        doc.image(`${__dirname}/../../../assets/image/footer_logo.png`, (Doc.Doc.width - defaultLogoWidth) / 2, Doc.Doc.height - defaultLogoHeight / 2 - dimension.Dimension.footerHeight / 2, {
            width: defaultLogoWidth,
            height: defaultLogoHeight,
        });
    }
};

exports.Footer = Footer;
