{"version":3,"file":"dlr-eoc-utils-browser.mjs","sources":["../../../projects/utils-browser/src/lib/download/download.ts","../../../projects/utils-browser/src/lib/layout/layout.ts","../../../projects/utils-browser/src/public-api.ts","../../../projects/utils-browser/src/dlr-eoc-utils-browser.ts"],"sourcesContent":["\n\nexport function downloadJson(data: object, fileName: string) {\n    const jsonData = JSON.stringify(data);\n    const blob = new Blob([jsonData], { type: 'text/json;charset=utf-8;' });\n    return downloadBlob(blob, fileName);\n}\n\n\nexport function downloadBlob(blob: Blob, fileName: string) {\n    const url = window.URL.createObjectURL(blob);\n    downloadUrl(url, fileName);\n}\n\n\nexport function downloadUrl(url: string, fileName: string) {\n    // window.open(url) doesn't work here. Instead, we create a temporary link item and simulate a click on it.\n    const a = document.createElement('a');\n    document.body.appendChild(a);\n    a.style.display = 'none';\n    a.href = url;\n    a.download = fileName;\n    a.click();\n\n    window.URL.revokeObjectURL(url);\n    document.body.removeChild(a);\n}","\nexport type PaperFormat = 'A0' | 'A1' | 'A2' | 'A3' | 'A4' | 'A5' | 'A6';\nexport type Orientation = 'landscape' | 'portrait';\nexport type Resolution = number;\n\nconst PaperSizeTable = {\n    A6: {\n        longCm: 14.8,\n        shortCm: 10.5\n    },\n    A5: {\n        longCm: 21.0,\n        shortCm: 14.8\n    },\n    A4: {\n        longCm: 29.7,\n        shortCm: 21.0\n    },\n    A3: {\n        longCm: 42.0,\n        shortCm: 29.7\n    },\n    A2: {\n        longCm: 59.4,\n        shortCm: 42.0\n    },\n    A1: {\n        longCm: 84.1,\n        shortCm: 59.4\n    },\n    A0: {\n        longCm: 118.9,\n        shortCm: 84.1\n    },\n};\n\nconst inchPerCm = 0.393701;\n\n\n/**\n * A utility class intended to help with getting the dimensions of a paper.\n * Especially useful for preparing html that needs to be printed.\n */\nexport class Paper {\n\n    readonly widthCm: number;\n    readonly heightCm: number;\n    readonly widthPx: number;\n    readonly heightPx: number;\n    constructor(\n        readonly format: PaperFormat,\n        readonly resolution: Resolution,\n        readonly orientation: Orientation) {\n\n        const shortCm = PaperSizeTable[format].shortCm;\n        const longCm = PaperSizeTable[format].longCm;\n        const shortPx = Math.floor(shortCm * inchPerCm * resolution);\n        const longPx = Math.floor(longCm * inchPerCm * resolution);\n\n        if (orientation === 'portrait') {\n            this.widthCm = shortCm;\n            this.heightCm = longCm;\n            this.widthPx = shortPx;\n            this.heightPx = longPx;\n        } else {\n            this.widthCm = longCm;\n            this.heightCm = shortCm;\n            this.widthPx = longPx;\n            this.heightPx = shortPx;\n        }\n    }\n\n    updateFormat(format: PaperFormat): Paper {\n        return new Paper(format, this.resolution, this.orientation);\n    }\n\n    updateResolution(resolution: Resolution): Paper {\n        return new Paper(this.format, resolution, this.orientation);\n    }\n\n    updateOrientation(orientation: Orientation): Paper {\n        return new Paper(this.format, this.resolution, orientation);\n    }\n\n}\n","/*\n * Public API Surface of utils-browser\n */\n\nexport * from './lib/download/download';\nexport * from './lib/layout/layout';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAEM,SAAU,YAAY,CAAC,IAAY,EAAE,QAAgB,EAAA;IACvD,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;AACrC,IAAA,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,0BAA0B,EAAE,CAAC;AACvE,IAAA,OAAO,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC;AACvC;AAGM,SAAU,YAAY,CAAC,IAAU,EAAE,QAAgB,EAAA;IACrD,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC;AAC5C,IAAA,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC;AAC9B;AAGM,SAAU,WAAW,CAAC,GAAW,EAAE,QAAgB,EAAA;;IAErD,MAAM,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC;AACrC,IAAA,QAAQ,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