{"version":3,"sources":["webpack:///./node_modules/aurelia-shop/dist/native-modules/helpers/pdf.helper.js","webpack:///./node_modules/aurelia-shop/dist/native-modules/helpers/pdf.test.js"],"names":["doc","currentPageNb","this","currentPageTop","marginLeft","marginRight","marginTop","marginBottom","mainTextSize","mainTextColor","mainTextStyle","fontName","secondaryTextSize","secondaryTextColor","secondaryTextStyle","headerHeight","footerHeight","productPositionMargin","productQuantityMargin","productUnitPriceRight","productTextWidth","currentTableAlt","currentTableAltRowIndexes","currentTableTopBorderIndexes","currentTableBottomBorderIndexes","currentTableDisplayQ","currentTableDisplayP","currentTableTotalStarted","currentTablePaymentStarted","text","objects","parseTemplate","callback","callItNow","headerCallback","call","footerCallback","rgb","setTextColor","setFont","setFontSize","params","addPage","lineHeightFactor","getLineHeightFactor","getFontSize","width","prepareForMainText","lineHeight","getTextHeight","textWidth","internal","pageSize","getWidth","splitTextToSize","length","autoSetCurrentPageTop","newPageFor","textLeft","lines","originalTop","addMultilineBoldText","lenghts","prepareForSecondaryText","totalHeight","docHeight","getHeight","isbold","line","currentX","parts","split","part","getTextWidth","company","name","address","extraLines","x","options","boldLines","companyBold","push","nameBold","street","zip","city","country","boldStyle","boldColor","normalStyle","normalColor","filter","company1","name1","address1","extraLines1","company2","name2","address2","extraLines2","originalCurrentPageTop","addAddress","currentPageTop1","pageWidth","currentPageTop2","Math","max","leftStrings","rightStrings","options1","options2","addAddress2","nbBoldLines","slice","normalLines","removeEmptyLines","leftText","rightText","leftWidth","rightWidth","leftSecondary","addSecondaryText","addMainText","rightSecondary","head","currentTableHead","currentTableBody","currentTableFoot","row","toggleAlt","foot","finishSettings","_a","settings","theme","lineWidth","lineColor","foreground","background","alternateForeground","alternateBackground","headForeground","headBackground","colStyles","rowBorders","top","bottom","borderTopIndex","color","thickLineColor","thickLineWidth","borderBottomIndex","newAltRowIndexes","index","includes","parseInt","cellIndex","cell","content","styles","fillColor","textColor","addTable","pText","itemText","qText","unitText","totalText","displayP","displayQ","tableStart","position","mainText","secondaryText","quantity","price","fontSize","valign","numString","tableAddBodyRow","colSpan","halign","total","highlight","highlightColor","fontStyle","undefined","amount","console","log","leftContent","rightContent","nbRows","i","createCell","tableFinish","Object","assign","isBold","matches","trim","match","body","_b","_c","_d","tableOptions","margin","left","right","startY","headStyles","headStyle","footStyles","footForeground","footBackground","footStyle","alternateRowStyles","didParseCell","data","section","column","rawStyles","raw","cellWidth","didDrawCell","table","rowBordersTop","borderTop","rowBordersBottom","borderBottom","nbCols","keys","cells","w","height","setLineWidth","setDrawColor","cursor","y","h","userOptions","lastAutoTable","finalY","orientation","unit","format","compress"],"mappings":"sLAEO,MAAM,EACT,YAAYA,EAAKC,EAAgB,GAC7BC,KAAKD,cAAgB,EACrBC,KAAKC,eAAiB,EACtBD,KAAKE,WAAa,GAClBF,KAAKG,YAAc,GACnBH,KAAKI,UAAY,GACjBJ,KAAKK,aAAe,GACpBL,KAAKM,aAAe,GACpBN,KAAKO,cAAgB,UACrBP,KAAKQ,cAAgB,SACrBR,KAAKS,SAAW,YAChBT,KAAKU,kBAAoB,GACzBV,KAAKW,mBAAqB,UAC1BX,KAAKY,mBAAqB,SAC1BZ,KAAKa,aAAe,EACpBb,KAAKc,aAAe,EACpBd,KAAKe,sBAAwB,EAC7Bf,KAAKgB,sBAAwB,GAC7BhB,KAAKiB,sBAAwB,GAC7BjB,KAAKkB,iBAAmB,IACxBlB,KAAKmB,gBAAkB,EACvBnB,KAAKoB,0BAA4B,GACjCpB,KAAKqB,6BAA+B,GACpCrB,KAAKsB,gCAAkC,GACvCtB,KAAKuB,sBAAuB,EAC5BvB,KAAKwB,sBAAuB,EAC5BxB,KAAKyB,0BAA2B,EAChCzB,KAAK0B,4BAA6B,EAClC1B,KAAKF,IAAMA,EACXE,KAAKD,cAAgBA,EAEzB,cAAc4B,EAAMC,GAChB,OAAO,SAAOC,cAAcF,EAAMC,GAEtC,UAAUE,EAAUC,GAAY,GAC5B/B,KAAKgC,eAAiBF,EAClBC,GACA/B,KAA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0E,EAAcR,EAAKC,cAAWlC,EAClF2C,EAAsG,QAAlFzB,EAAKvE,aAA2C,EAASA,EAASW,kBAA+B,IAAP4D,OAAgB,EAASA,EAAG1D,OAC1IoF,EAAeD,EAAmBA,EAAiB5E,IAAU4E,EAAiBV,EAAKC,cAAWlC,EAC9F6C,EAASnC,OAAOoC,KAAKb,EAAK3F,IAAIyG,OAAOnL,OAC3C,GAAI8K,GAAaT,EAAKE,OAAOpE,OAAS8E,EAAS,EAAG,CAC9C,MAAMG,EAAIN,EAAUvL,MACV8K,EAAK9D,KAAK8E,OACpB5O,EAAI6O,aAAaF,GACjB3O,EAAI8O,aAAaT,EAAUhF,OAC3BrJ,EAAIoE,KAAK6I,EAAMW,EAAKmB,OAAOC,EAAG9B,EAAOU,EAAKmB,OAAOC,GAErD,GAAIT,GAAgBX,EAAKE,OAAOpE,OAAS8E,EAAS,EAAG,CACjD,MAAMG,EAAIJ,EAAazL,MACjBmM,EAAIrB,EAAK9D,KAAK8E,OACpB5O,EAAI6O,aAAaF,GACjB3O,EAAI8O,aAAaP,EAAalF,OAC9BrJ,EAAIoE,KAAK6I,EAAMW,EAAKmB,OAAOC,EAAIC,EAAG/B,EAAOU,EAAKmB,OAAOC,EAAIC,MAI/DC,EAAc7C,OAAOC,OAAO,GAAIhE,aAA2C,EAASA,EAASvD,QAASgI,GAC5G,IAAU7M,KAAKF,IAAKkP,GACpBhP,KAAKC,eAAiBD,KAAKF,IAAImP,cAAcC,Q,gDCnlBrD,MAAMpP,EAAM,I,UAAI,OAAM,CAClBqP,YAAa,WACbC,KAAM,KACNC,OAAQ,KACRC,UAAU,IAEF,IAAI,EAAUxP,EAAK","file":"vendors~ebf6f0d1.38da52be5dabed0c7410.chunk.js","sourcesContent":["import autoTable from 'jspdf-autotable';\nimport { NumberHelper, Parser } from 'aurelia-resources';\nexport class PDFHelper {\n    constructor(doc, currentPageNb = 1) {\n        this.currentPageNb = 1;\n        this.currentPageTop = 0;\n        this.marginLeft = 15;\n        this.marginRight = 15;\n        this.marginTop = 15;\n        this.marginBottom = 10;\n        this.mainTextSize = 12;\n        this.mainTextColor = '#000000';\n        this.mainTextStyle = 'normal';\n        this.fontName = 'Helvetica';\n        this.secondaryTextSize = 10;\n        this.secondaryTextColor = '#666666';\n        this.secondaryTextStyle = 'normal';\n        this.headerHeight = 0;\n        this.footerHeight = 0;\n        this.productPositionMargin = 5;\n        this.productQuantityMargin = 10;\n        this.productUnitPriceRight = 45;\n        this.productTextWidth = 100;\n        this.currentTableAlt = 0;\n        this.currentTableAltRowIndexes = [];\n        this.currentTableTopBorderIndexes = [];\n        this.currentTableBottomBorderIndexes = [];\n        this.currentTableDisplayQ = true;\n        this.currentTableDisplayP = true;\n        this.currentTableTotalStarted = false;\n        this.currentTablePaymentStarted = false;\n        this.doc = doc;\n        this.currentPageNb = currentPageNb;\n    }\n    parseTemplate(text, objects) {\n        return Parser.parseTemplate(text, objects);\n    }\n    setHeader(callback, callItNow = true) {\n        this.headerCallback = callback;\n        if (callItNow)\n            this.headerCallback.call(this, this.doc);\n    }\n    setFooter(callback, callItNow = true) {\n        this.footerCallback = callback;\n        if (callItNow)\n            this.footerCallback.call(this, this.doc);\n    }\n    setTextColor(rgb) {\n        this.doc.setTextColor(rgb);\n    }\n    prepareForMainText() {\n        this.setTextColor(this.mainTextColor);\n        this.doc.setFont(this.mainTextStyle);\n        this.doc.setFontSize(this.mainTextSize);\n    }\n    prepareForSecondaryText() {\n        this.setTextColor(this.secondaryTextColor);\n        this.doc.setFont(this.secondaryTextStyle);\n        this.doc.setFontSize(this.secondaryTextSize);\n    }\n    addPage(...params) {\n        this.currentPageNb += 1;\n        this.doc.addPage(...params);\n        if (this.headerCallback)\n            this.headerCallback.call(this, this.doc);\n        if (this.footerCallback)\n            this.footerCallback.call(this, this.doc);\n        this.currentPageTop = this.marginTop + this.headerHeight;\n    }\n    getTextHeight() {\n        let lineHeightFactor = this.doc.getLineHeightFactor();\n        let fontSize = this.doc.getFontSize();\n        let lineHeight = fontSize * 0.352778 * lineHeightFactor;\n        return lineHeight;\n    }\n    measureMainTextHeight(text, width) {\n        this.prepareForMainText();\n        const lineHeight = this.getTextHeight();\n        const textWidth = (typeof width === 'number') ? width : this.doc.internal.pageSize.getWidth() - this.marginLeft - this.marginRight;\n        const lines = this.doc.splitTextToSize(text, textWidth);\n        return lineHeight * lines.length;\n    }\n    addMainText(text, marginLeft, width, autoSetCurrentPageTop, newPageFor = 'block') {\n        if (typeof text !== 'string') {\n            text = '';\n        }\n        this.prepareForMainText();\n        let lineHeight = this.getTextHeight();\n        let textLeft = (typeof marginLeft === 'number') ? marginLeft : this.marginLeft;\n        let textWidth = (typeof width === 'number') ? width : this.doc.internal.pageSize.getWidth() - this.marginLeft - this.marginRight;\n        let lines = this.doc.splitTextToSize(text, textWidth);\n        const originalTop = this.currentPageTop;\n        this.addMultilineBoldText(lines, textLeft, newPageFor);\n        if (autoSetCurrentPageTop === false) {\n            this.currentPageTop = originalTop;\n        }\n        return lineHeight * lines.lenghts;\n    }\n    measureSecondaryTextHeight(text, width) {\n        this.prepareForSecondaryText();\n        const lineHeight = this.getTextHeight();\n        const textWidth = (typeof width === 'number') ? width : this.doc.internal.pageSize.getWidth() - this.marginLeft - this.marginRight;\n        const lines = this.doc.splitTextToSize(text, textWidth);\n        return lineHeight * lines.length;\n    }\n    addSecondaryText(text, marginLeft, width, autoSetCurrentPageTop, newPageFor = 'block') {\n        if (typeof text !== 'string') {\n            text = '';\n        }\n        this.prepareForSecondaryText();\n        let lineHeight = this.getTextHeight();\n        let textLeft = (typeof marginLeft === 'number') ? marginLeft : this.marginLeft;\n        let textWidth = (typeof width === 'number') ? width : this.doc.internal.pageSize.getWidth() - this.marginLeft - this.marginRight;\n        let lines = this.doc.splitTextToSize(text, textWidth);\n        const originalTop = this.currentPageTop;\n        this.addMultilineBoldText(lines, textLeft, newPageFor);\n        if (autoSetCurrentPageTop === false) {\n            this.currentPageTop = originalTop;\n        }\n        return lineHeight * lines.lenghts;\n    }\n    addMultilineBoldText(lines, textLeft, newPageFor = 'block') {\n        let lineHeight = this.getTextHeight();\n        const totalHeight = lineHeight * lines.length;\n        const docHeight = this.doc.internal.pageSize.getHeight();\n        if (newPageFor === 'block' && this.currentPageTop + totalHeight + this.footerHeight + this.marginBottom > docHeight) {\n            this.addPage();\n        }\n        let isbold = false;\n        for (let line of lines) {\n            if (newPageFor === 'line' && this.currentPageTop + lineHeight + this.footerHeight + this.marginBottom > docHeight) {\n                this.addPage();\n            }\n            isbold = !isbold;\n            let currentX = textLeft;\n            const parts = (line || '').split('**');\n            for (let part of parts) {\n                isbold = !isbold;\n                if (isbold) {\n                    this.doc.setFont(this.fontName, 'bold');\n                }\n                else {\n                    this.doc.setFont(this.fontName, 'normal');\n                }\n                this.doc.text(part, currentX, this.currentPageTop);\n                currentX += this.doc.getTextWidth(part);\n            }\n            this.currentPageTop += lineHeight;\n        }\n    }\n    addAddress(company, name, address, extraLines, x, options = {}) {\n        let lineHeight = this.getTextHeight();\n        let boldLines = [];\n        let lines = [];\n        if (company && !options.companyBold)\n            lines.push(company);\n        else if (company && options.companyBold)\n            boldLines.push(company);\n        if (name && !options.nameBold)\n            lines.push(name);\n        else if (name && options.nameBold)\n            boldLines.push(name);\n        if (address.street) {\n            lines.push(...address.street.split(\"\\n\"));\n        }\n        if (address.zip || address.city)\n            lines.push(`${address.zip || ''} ${address.city || ''}`);\n        if (address.country)\n            lines.push(address.country);\n        for (let line of extraLines) {\n            lines.push(line);\n        }\n        this.currentPageTop += lineHeight;\n        let boldStyle = options.boldStyle || 'bold';\n        let boldColor = options.boldColor || '#000000';\n        let normalStyle = options.normalStyle || 'normal';\n        let normalColor = options.normalColor || '#000000';\n        this.doc.setFont(this.fontName, boldStyle);\n        this.doc.setTextColor(boldColor);\n        if (boldLines.length) {\n            this.doc.text(boldLines, x, this.currentPageTop);\n            this.currentPageTop += boldLines.length * lineHeight;\n        }\n        this.doc.setFont(this.fontName, normalStyle);\n        this.doc.setTextColor(normalColor);\n        lines = lines.filter(line => line);\n        if (lines.length) {\n            this.doc.text(lines, x, this.currentPageTop);\n            this.currentPageTop += lines.length * lineHeight;\n        }\n        this.currentPageTop -= lineHeight;\n    }\n    addLeftAndRightAddresses(company1, name1, address1, extraLines1, company2, name2, address2, extraLines2, options = {}) {\n        let originalCurrentPageTop = this.currentPageTop;\n        this.addAddress(company1, name1, address1, extraLines1, this.marginLeft, options);\n        let currentPageTop1 = this.currentPageTop;\n        this.currentPageTop = originalCurrentPageTop;\n        let pageWidth = this.doc.internal.pageSize.getWidth();\n        this.addAddress(company2, name2, address2, extraLines2, pageWidth / 2, options);\n        let currentPageTop2 = this.currentPageTop;\n        this.currentPageTop = Math.max(currentPageTop1, currentPageTop2);\n    }\n    addLeftAndRightAddresses2(leftStrings, rightStrings, options1, options2) {\n        let originalCurrentPageTop = this.currentPageTop;\n        this.addAddress2(leftStrings, this.marginLeft, options1);\n        let currentPageTop1 = this.currentPageTop;\n        this.currentPageTop = originalCurrentPageTop;\n        let pageWidth = this.doc.internal.pageSize.getWidth();\n        this.addAddress2(rightStrings, pageWidth / 2, options2);\n        let currentPageTop2 = this.currentPageTop;\n        this.currentPageTop = Math.max(currentPageTop1, currentPageTop2);\n    }\n    addAddress2(lines, x, options) {\n        let lineHeight = this.getTextHeight();\n        this.currentPageTop += lineHeight;\n        let nbBoldLines = options.nbBoldLines || 0;\n        let boldStyle = options.boldStyle || 'bold';\n        let boldColor = options.boldColor || '#000000';\n        let normalStyle = options.normalStyle || 'normal';\n        let normalColor = options.normalColor || '#000000';\n        this.doc.setFont(this.fontName, boldStyle);\n        this.doc.setTextColor(boldColor);\n        const boldLines = lines.slice(0, nbBoldLines);\n        let normalLines = lines.slice(nbBoldLines);\n        if (boldLines.length) {\n            this.doc.text(boldLines, x, this.currentPageTop);\n            this.currentPageTop += boldLines.length * lineHeight;\n        }\n        this.doc.setFont(this.fontName, normalStyle);\n        this.doc.setTextColor(normalColor);\n        if (options.removeEmptyLines) {\n            normalLines = normalLines.filter(line => line);\n        }\n        if (normalLines.length) {\n            this.doc.text(normalLines, x, this.currentPageTop);\n            this.currentPageTop += normalLines.length * lineHeight;\n        }\n        this.currentPageTop -= lineHeight;\n    }\n    addLeftAndRight(leftText, rightText, options) {\n        const originalCurrentPageTop = this.currentPageTop;\n        const pageWidth = this.doc.internal.pageSize.getWidth();\n        const leftWidth = (pageWidth / 2) - this.marginLeft - 5;\n        const rightWidth = (pageWidth / 2) - this.marginRight;\n        if (!(options === null || options === void 0 ? void 0 : options.leftSecondary)) {\n            this.addMainText(leftText, this.marginLeft, leftWidth, true, 'block');\n        }\n        else {\n            this.addSecondaryText(leftText, this.marginLeft, leftWidth, true, 'block');\n        }\n        const currentPageTop1 = this.currentPageTop;\n        this.currentPageTop = originalCurrentPageTop;\n        if (!(options === null || options === void 0 ? void 0 : options.rightSecondary)) {\n            this.addMainText(rightText, pageWidth / 2, rightWidth, true, 'block');\n        }\n        else {\n            this.addSecondaryText(rightText, pageWidth / 2, rightWidth, true, 'block');\n        }\n        const currentPageTop2 = this.currentPageTop;\n        this.currentPageTop = Math.max(currentPageTop1, currentPageTop2);\n    }\n    tableStart(head) {\n        this.currentTableHead = head || [];\n        this.currentTableBody = [];\n        this.currentTableFoot = [];\n        this.currentTableAlt = 0;\n        this.currentTableAltRowIndexes = [];\n        if (head && head.length) {\n            this.currentTableTopBorderIndexes = ['head'];\n        }\n        else {\n            this.currentTableTopBorderIndexes = [];\n        }\n        this.currentTableBottomBorderIndexes = [];\n    }\n    tableAddBodyRow(row, toggleAlt = true) {\n        if (toggleAlt && this.currentTableBody.length > 0) {\n            this.currentTableAlt = (1 - this.currentTableAlt);\n        }\n        this.currentTableBody.push(row);\n        if (this.currentTableAlt === 1) {\n            this.currentTableAltRowIndexes.push(this.currentTableBody.length - 1);\n        }\n    }\n    tableFinish(foot, finishSettings) {\n        var _a;\n        this.currentTableFoot = foot || [];\n        if (((_a = this.currentTableBody) === null || _a === void 0 ? void 0 : _a.length) && (this.currentTableTopBorderIndexes.length || this.currentTableBottomBorderIndexes.length)) {\n            this.currentTableBottomBorderIndexes.push(`body${this.currentTableBody.length - 1}`);\n        }\n        const settings = {\n            theme: 'plain',\n            lineWidth: finishSettings.lineWidth,\n            lineColor: finishSettings.lineColor,\n            foreground: finishSettings.foreground,\n            background: finishSettings.background,\n            alternateForeground: finishSettings.foreground,\n            alternateBackground: finishSettings.background,\n            headForeground: finishSettings.headForeground,\n            headBackground: finishSettings.headBackground,\n            colStyles: finishSettings.colStyles,\n            rowBorders: { top: {}, bottom: {} },\n        };\n        for (const borderTopIndex of this.currentTableTopBorderIndexes) {\n            settings.rowBorders.top[borderTopIndex] = {\n                color: finishSettings.thickLineColor,\n                width: finishSettings.thickLineWidth\n            };\n        }\n        for (const borderBottomIndex of this.currentTableBottomBorderIndexes) {\n            settings.rowBorders.bottom[borderBottomIndex] = {\n                color: finishSettings.thickLineColor,\n                width: finishSettings.thickLineWidth\n            };\n        }\n        if (finishSettings.headBackground === finishSettings.background && finishSettings.headForeground === finishSettings.foreground) {\n            const newAltRowIndexes = [];\n            for (const index in this.currentTableBody) {\n                if (!this.currentTableAltRowIndexes.includes(parseInt(index, 10))) {\n                    newAltRowIndexes.push(parseInt(index, 10));\n                }\n            }\n            this.currentTableAltRowIndexes = newAltRowIndexes;\n        }\n        for (const index in this.currentTableBody) {\n            if (this.currentTableAltRowIndexes.includes(parseInt(index, 10))) {\n                for (const cellIndex in this.currentTableBody[index]) {\n                    const cell = this.currentTableBody[index][cellIndex];\n                    if (typeof cell !== 'object') {\n                        this.currentTableBody[index][cellIndex] = {\n                            content: cell,\n                            styles: {\n                                fillColor: finishSettings.alternateBackground,\n                                textColor: finishSettings.alternateForeground,\n                            }\n                        };\n                    }\n                    else {\n                        if (!this.currentTableBody[index][cellIndex].styles) {\n                            this.currentTableBody[index][cellIndex].styles = {};\n                        }\n                        this.currentTableBody[index][cellIndex].styles.fillColor = this.currentTableBody[index][cellIndex].styles.fillColor || finishSettings.alternateBackground;\n                        this.currentTableBody[index][cellIndex].styles.textColor = this.currentTableBody[index][cellIndex].styles.textColor || finishSettings.alternateForeground;\n                    }\n                }\n            }\n        }\n        this.addTable(this.currentTableHead, this.currentTableBody, this.currentTableFoot, settings);\n        this.currentTableHead = [];\n        this.currentTableBody = [];\n        this.currentTableFoot = [];\n    }\n    tableAddProductHeaders(pText, itemText, qText, unitText, totalText, displayP = true, displayQ = true) {\n        this.currentTableDisplayP = displayP;\n        this.currentTableDisplayQ = displayQ;\n        const head = [];\n        if (this.currentTableDisplayP) {\n            head.push(pText);\n        }\n        head.push(itemText);\n        if (this.currentTableDisplayQ) {\n            head.push(qText);\n        }\n        head.push(unitText, totalText);\n        this.tableStart([head]);\n    }\n    tableAddProduct(position, mainText, secondaryText, quantity, price) {\n        const row = [];\n        if (this.currentTableDisplayP) {\n            if ((typeof position === 'string' || typeof position === 'number') && `${position}`.length > 2) {\n                position = {\n                    content: position,\n                    styles: {\n                        fontSize: this.secondaryTextSize * 0.7,\n                        valign: 'middle'\n                    }\n                };\n            }\n            row.push(position);\n        }\n        const itemText = mainText + (secondaryText ? `\\n${secondaryText}` : '');\n        row.push(itemText, quantity, NumberHelper.numString(price), NumberHelper.numString(price * quantity));\n        this.tableAddBodyRow(row, true);\n    }\n    tableAddOption(mainText, secondaryText, quantity, price) {\n        const row = [];\n        if (this.currentTableDisplayP) {\n            row.push('');\n        }\n        const itemText = mainText + (secondaryText ? `\\n${secondaryText}` : '');\n        row.push(itemText, quantity, NumberHelper.numString(price), NumberHelper.numString(price * quantity));\n        this.tableAddBodyRow(row, false);\n    }\n    tableAddProductComment(mainText, secondaryText) {\n        const row = [];\n        if (this.currentTableDisplayP) {\n            row.push('');\n        }\n        const itemText = mainText + (secondaryText ? `\\n${secondaryText}` : '');\n        row.push({\n            content: itemText,\n            colSpan: 4,\n            styles: {\n                halign: 'left'\n            }\n        });\n        this.tableAddBodyRow(row, false);\n    }\n    tableAddTotal(mainText, secondaryText, total, highlight = false, highlightColor = '#369') {\n        const row = [];\n        const text = mainText + (secondaryText ? `\\n${secondaryText}` : '');\n        row.push({\n            content: text,\n            colSpan: this.currentTableDisplayP ? 4 : 3,\n            styles: {\n                halign: 'left',\n                fontStyle: highlight ? 'bold' : 'normal',\n                textColor: highlight ? highlightColor : undefined\n            }\n        });\n        row.push(NumberHelper.numString(total));\n        this.tableAddBodyRow(row);\n        if (!this.currentTableTotalStarted) {\n            this.currentTableTopBorderIndexes.push(`body${this.currentTableBody.length - 1}`);\n        }\n        else if (highlight) {\n            this.currentTableTopBorderIndexes.push(`body${this.currentTableBody.length - 1}`);\n            this.currentTableBottomBorderIndexes.push(`body${this.currentTableBody.length - 1}`);\n        }\n        this.currentTableTotalStarted = true;\n    }\n    tableAddPayment(mainText, secondaryText, amount, highlight = false, highlightColor = '#369') {\n        const row = [];\n        const text = mainText + (secondaryText ? `\\n${secondaryText}` : '');\n        let colSpan = 2;\n        if (this.currentTableDisplayP) {\n            colSpan += 1;\n        }\n        if (this.currentTableDisplayQ) {\n            colSpan += 1;\n        }\n        row.push({\n            content: text,\n            colSpan: colSpan,\n            styles: {\n                halign: 'left',\n                fontStyle: highlight ? 'bold' : 'normal',\n                textColor: highlight ? highlightColor : undefined\n            }\n        });\n        row.push(NumberHelper.numString(amount));\n        console.log('row', row);\n        this.tableAddBodyRow(row);\n        if (!this.currentTablePaymentStarted) {\n            this.currentTableTopBorderIndexes.push(`body${this.currentTableBody.length - 1}`);\n        }\n        else if (highlight) {\n            this.currentTableTopBorderIndexes.push(`body${this.currentTableBody.length - 1}`);\n            this.currentTableBottomBorderIndexes.push(`body${this.currentTableBody.length - 1}`);\n        }\n        this.currentTablePaymentStarted = true;\n    }\n    addDoubleColumnTable(leftContent, rightContent, settings) {\n        this.tableStart();\n        const leftStrings = (leftContent || '').split('\\n');\n        const rightStrings = (rightContent || '').split('\\n');\n        const nbRows = Math.max(leftStrings.length, rightStrings.length);\n        this.currentTableBody = [];\n        for (let i = 0; i < nbRows; i++) {\n            const row = [];\n            row.push(this.createCell(leftStrings[i] || ''), this.createCell(rightStrings[i] || ''));\n            this.tableAddBodyRow(row);\n        }\n        this.currentTableTopBorderIndexes.push(`body0`);\n        this.currentTableBottomBorderIndexes.push(`body${nbRows - 1}`);\n        this.tableFinish([], Object.assign({}, settings, {\n            colStyles: {\n                '0': { halign: 'left', valign: 'top' },\n                '2': { halign: 'left', valign: 'top' }\n            },\n        }));\n    }\n    createCell(content) {\n        let text = content;\n        let isBold = false;\n        const matches = text.trim().match(/^\\*\\*(.*)\\*\\*$/);\n        if (matches) {\n            text = matches[1];\n            isBold = true;\n        }\n        const cell = {\n            content: text,\n            styles: {\n                fontStyle: isBold ? 'bold' : 'normal'\n            }\n        };\n        return cell;\n    }\n    tableAddDeliveryHeaders(pText, itemText, qText, displayP = true) {\n        this.currentTableDisplayP = displayP;\n        const head = [];\n        if (this.currentTableDisplayP) {\n            head.push(pText);\n        }\n        head.push(itemText, qText);\n        this.tableStart([head]);\n    }\n    tableAddDeliveryItem(position, mainText, secondaryText, quantity) {\n        const row = [];\n        if (this.currentTableDisplayP) {\n            row.push(position);\n        }\n        const itemText = mainText + (secondaryText ? `\\n${secondaryText}` : '');\n        row.push(itemText, quantity);\n        this.tableAddBodyRow(row, true);\n    }\n    addTable(head, body, foot, settings) {\n        var _a, _b, _c, _d;\n        const tableOptions = {\n            theme: (settings === null || settings === void 0 ? void 0 : settings.theme) || 'plain',\n            margin: {\n                top: this.marginTop + this.headerHeight,\n                left: this.marginLeft,\n                right: this.marginRight,\n                bottom: this.marginBottom + this.footerHeight\n            },\n            head: head,\n            body: body,\n            foot: foot,\n            startY: this.currentPageTop,\n            styles: Object.assign({}, (_a = settings === null || settings === void 0 ? void 0 : settings.options) === null || _a === void 0 ? void 0 : _a.styles, {\n                textColor: settings === null || settings === void 0 ? void 0 : settings.foreground,\n                fillColor: settings === null || settings === void 0 ? void 0 : settings.background,\n                lineWidth: (settings === null || settings === void 0 ? void 0 : settings.lineWidth) ? settings.lineWidth : 0,\n                lineColor: (settings === null || settings === void 0 ? void 0 : settings.lineColor) ? settings.lineColor : 200,\n            }),\n            headStyles: Object.assign({}, (_b = settings === null || settings === void 0 ? void 0 : settings.options) === null || _b === void 0 ? void 0 : _b.headStyles, {\n                textColor: settings === null || settings === void 0 ? void 0 : settings.headForeground,\n                fillColor: settings === null || settings === void 0 ? void 0 : settings.headBackground,\n                fontStyle: settings === null || settings === void 0 ? void 0 : settings.headStyle,\n            }),\n            footStyles: Object.assign({}, (_c = settings === null || settings === void 0 ? void 0 : settings.options) === null || _c === void 0 ? void 0 : _c.footStyles, {\n                textColor: settings === null || settings === void 0 ? void 0 : settings.footForeground,\n                fillColor: settings === null || settings === void 0 ? void 0 : settings.footBackground,\n                fontStyle: settings === null || settings === void 0 ? void 0 : settings.footStyle,\n            }),\n            alternateRowStyles: Object.assign({}, (_d = settings === null || settings === void 0 ? void 0 : settings.options) === null || _d === void 0 ? void 0 : _d.alternateRowStyles, {\n                fillColor: settings === null || settings === void 0 ? void 0 : settings.alternateBackground,\n                textColor: settings === null || settings === void 0 ? void 0 : settings.alternateForeground\n            }),\n            didParseCell: (data) => {\n                var _a;\n                if ((_a = settings === null || settings === void 0 ? void 0 : settings.options) === null || _a === void 0 ? void 0 : _a.didParseCell) {\n                    settings.options.didParseCell.call(this, data);\n                }\n                const colStyles = settings === null || settings === void 0 ? void 0 : settings.colStyles;\n                const styles = colStyles ? colStyles[`${data.section}${data.column.index}`] || colStyles[`${data.column.index}`] : undefined;\n                if (styles) {\n                    const rawStyles = typeof data.cell.raw === 'object' ? data.cell.raw.styles || [] : {};\n                    data.cell.styles = Object.assign({}, data.cell.styles, styles, rawStyles);\n                    if (styles.cellWidth) {\n                        data.cell.width = styles.cellWidth;\n                    }\n                }\n            },\n            didDrawCell: (data) => {\n                var _a, _b, _c;\n                if ((_a = settings === null || settings === void 0 ? void 0 : settings.options) === null || _a === void 0 ? void 0 : _a.didDrawCell) {\n                    settings.options.didDrawCell.call(this, data);\n                }\n                const doc = data.doc;\n                const left = data.table.settings.margin.left;\n                const right = left + data.table.getWidth(doc.internal.pageSize.getWidth());\n                const index = `${data.section}${data.row.index}`;\n                const rowBordersTop = (_b = settings === null || settings === void 0 ? void 0 : settings.rowBorders) === null || _b === void 0 ? void 0 : _b.top;\n                const borderTop = rowBordersTop ? rowBordersTop[index] || rowBordersTop[data.section] : undefined;\n                const rowBordersBottom = (_c = settings === null || settings === void 0 ? void 0 : settings.rowBorders) === null || _c === void 0 ? void 0 : _c.bottom;\n                const borderBottom = rowBordersBottom ? rowBordersBottom[index] || rowBordersBottom[data.section] : undefined;\n                const nbCols = Object.keys(data.row.cells).length;\n                if (borderTop && data.column.index >= nbCols - 1) {\n                    const w = borderTop.width;\n                    const h = data.cell.height;\n                    doc.setLineWidth(w);\n                    doc.setDrawColor(borderTop.color);\n                    doc.line(left, data.cursor.y, right, data.cursor.y);\n                }\n                if (borderBottom && data.column.index >= nbCols - 1) {\n                    const w = borderBottom.width;\n                    const h = data.cell.height;\n                    doc.setLineWidth(w);\n                    doc.setDrawColor(borderBottom.color);\n                    doc.line(left, data.cursor.y + h, right, data.cursor.y + h);\n                }\n            }\n        };\n        const userOptions = Object.assign({}, settings === null || settings === void 0 ? void 0 : settings.options, tableOptions);\n        autoTable(this.doc, userOptions);\n        this.currentPageTop = this.doc.lastAutoTable.finalY;\n    }\n}\n\n//# sourceMappingURL=pdf.helper.js.map\n","import { jsPDF } from 'jspdf';\nimport { PDFHelper } from './pdf.helper';\nconst doc = new jsPDF({\n    orientation: 'portrait',\n    unit: 'mm',\n    format: 'a4',\n    compress: false\n});\nconst pdf = new PDFHelper(doc, 1);\nconst templateObjects = {\n    settings: {\n        companyName: 'SuperTech SA',\n        companyAddress: {\n            street: 'ZI de la Franche Région',\n            zip: '41348',\n            city: 'TONNERRE',\n            country: 'France'\n        }\n    },\n    order: {\n        deliveryAddress: {\n            street: 'Route des Deux-Communes 34',\n            zip: '1245',\n            city: 'Montagny Dessus',\n            country: 'Suisse'\n        },\n        billingAddress: {\n            street: 'Route des Deux-Communes 34',\n            zip: '1245',\n            city: 'Montagny Dessus',\n            country: 'Suisse'\n        },\n    },\n    customer: {\n        fullName: 'Routinex Services SA',\n        customerNb: '3180',\n        metadata: [\n            {\n                key: 'Ide européen',\n                value: 'FR28752126915'\n            }\n        ]\n    },\n    customerContact: {\n        fullName: 'Adrien Sanbonpoint'\n    }\n};\nconst senderAddressTemplate = `**!{settings:companyName}**\n!{settings:companyAddress.street}\n#{settings:companyAddress.zip} #{settings:companyAddress.city}\n!{settings:companyAddress.country}\n\n\n**Adresse de livraison**\n!{order:deliveryAddress.street}\n#{order:deliveryAddress.zip} #{order:deliveryAddress.city}\n!{order:deliveryAddress.country}\n`;\nconst receiverAddressTemplate = `**#{customer:fullName}**\n!{customerContact:fullName}\n!{order:billingAddress.street}\n#{order:billingAddress.zip} #{order:billingAddress.city}\n!{order:billingAddress.country}\n\nN° TVA intra-commu. : !{customer:metadata:Ide européen}\nN° client !{customer:customerNb}`;\nexport function pdfTest() {\n    pdf.doc.text('Here is a title', pdf.marginLeft, 22);\n    pdf.currentPageTop = 50;\n    pdf.addTable([['P', 'Article', 'Q', 'Prix unit.', 'Total']], [\n        ['1', 'Refroidisseur\\nSalut les amis', '2', '44.00', '88.00'],\n        ['2', 'Rechauffeur', '1', '54 480.00', '54 480.00'],\n        ['3', 'Ventilateur', '44', '50.00', '2200.00'],\n    ], [], {\n        theme: 'grid',\n        lineWidth: 0.2,\n        lineColor: 200,\n        foreground: '#000',\n        headStyle: 'normal',\n        headBackground: '#FFF',\n        headForeground: '#000',\n        alternateBackground: '#EFEFEF',\n        colStyles: {\n            '0': { halign: 'center', cellWidth: 8, valign: 'top' },\n            '2': { halign: 'center', cellWidth: 8, valign: 'top' },\n            '3': { halign: 'right', cellWidth: 24, valign: 'top' },\n            '4': { halign: 'right', cellWidth: 24, valign: 'top' },\n        },\n        rowBorders: {\n            bottom: {\n                body2: {\n                    width: 0.5,\n                    color: '#333333'\n                }\n            },\n            top: {\n                head: {\n                    width: 0.5,\n                    color: '#333333'\n                }\n            }\n        }\n    });\n    pdf.addTable([], [\n        ['Total en Euros hors TVA', '176 070.00'],\n        ['TVA à 20%', '35 214'],\n    ], [], {\n        theme: 'grid',\n        lineWidth: 0.2,\n        lineColor: 200,\n        foreground: '#000',\n        headStyle: 'normal',\n        headBackground: '#FFF',\n        headForeground: '#000',\n        alternateBackground: '#EFEFEF',\n        colStyles: {\n            '1': { halign: 'right', cellWidth: 24 }\n        },\n        rowBorders: {\n            top: {\n                body0: {\n                    width: 0.5,\n                    color: '#333333'\n                }\n            },\n            bottom: {\n                body1: {\n                    width: 0.5,\n                    color: '#333333'\n                }\n            }\n        }\n    });\n    pdf.addTable([], [\n        ['Acompte à réception de commande', '0.00'],\n    ], [], {\n        theme: 'grid',\n        lineWidth: 0.2,\n        lineColor: 200,\n        foreground: '#000',\n        headStyle: 'normal',\n        headBackground: '#FFF',\n        headForeground: '#000',\n        alternateBackground: '#EFEFEF',\n        colStyles: {\n            '1': { halign: 'right', cellWidth: 24 }\n        },\n        rowBorders: {\n            bottom: {\n                body0: {\n                    width: 0.5,\n                    color: '#333333'\n                }\n            }\n        }\n    });\n    doc.save(`Test.pdf`);\n}\n\n//# sourceMappingURL=pdf.test.js.map\n"],"sourceRoot":""}