{"version":3,"file":"units-rOMQqXh2.mjs","names":[],"sources":["../src/utils/units.ts"],"sourcesContent":["// DrawingML / SpreadsheetDrawing length unit conversions. EMUs (English Metric\n// Units) are OOXML's universal length type — 1 inch = 914400 EMU, 1 cm = 360000\n// EMU, 1 px @ 96 DPI = 9525 EMU.\n//\n// Mirrors openpyxl/openpyxl/utils/units.py. These helpers are on the hot path\n// for the drawing / chart writers.\n\nexport const EMU_PER_INCH = 914_400;\nexport const EMU_PER_CM = 360_000;\nexport const EMU_PER_PIXEL = 9_525;\nexport const EMU_PER_POINT = 12_700;\n\n/** DPI assumed by Excel when converting between pixels and other units. */\nconst DEFAULT_PIXEL_DPI = 96;\n\n// ---- pixel <-> EMU ---------------------------------------------------------\n\nexport function emuFromPx(px: number): number {\n  return Math.round(px * EMU_PER_PIXEL);\n}\nexport function pxFromEmu(emu: number): number {\n  return emu / EMU_PER_PIXEL;\n}\n\n// ---- centimetre <-> EMU ----------------------------------------------------\n\nexport function emuFromCm(cm: number): number {\n  return Math.round(cm * EMU_PER_CM);\n}\nexport function cmFromEmu(emu: number): number {\n  return emu / EMU_PER_CM;\n}\n\n// ---- inch <-> EMU ----------------------------------------------------------\n\nexport function emuFromInch(inch: number): number {\n  return Math.round(inch * EMU_PER_INCH);\n}\nexport function inchFromEmu(emu: number): number {\n  return emu / EMU_PER_INCH;\n}\n\n// ---- point <-> EMU ---------------------------------------------------------\n\nexport function emuFromPoint(pt: number): number {\n  return Math.round(pt * EMU_PER_POINT);\n}\nexport function pointFromEmu(emu: number): number {\n  return emu / EMU_PER_POINT;\n}\n\n// ---- pixel <-> point (DPI) ------------------------------------------------\n\nexport function pointToPixel(pt: number, dpi = DEFAULT_PIXEL_DPI): number {\n  return (pt * dpi) / 72;\n}\nexport function pixelToPoint(px: number, dpi = DEFAULT_PIXEL_DPI): number {\n  return (px * 72) / dpi;\n}\n"],"mappings":";AAOA,MAAa,eAAe;AAC5B,MAAa,aAAa;AAC1B,MAAa,gBAAgB;AAC7B,MAAa,gBAAgB;;AAG7B,MAAM,oBAAoB;AAI1B,SAAgB,UAAU,IAAoB;CAC5C,OAAO,KAAK,MAAM,KAAK,aAAa;AACtC;AACA,SAAgB,UAAU,KAAqB;CAC7C,OAAO,MAAM;AACf;AAIA,SAAgB,UAAU,IAAoB;CAC5C,OAAO,KAAK,MAAM,KAAK,UAAU;AACnC;AACA,SAAgB,UAAU,KAAqB;CAC7C,OAAO,MAAM;AACf;AAIA,SAAgB,YAAY,MAAsB;CAChD,OAAO,KAAK,MAAM,OAAO,YAAY;AACvC;AACA,SAAgB,YAAY,KAAqB;CAC/C,OAAO,MAAM;AACf;AAIA,SAAgB,aAAa,IAAoB;CAC/C,OAAO,KAAK,MAAM,KAAK,aAAa;AACtC;AACA,SAAgB,aAAa,KAAqB;CAChD,OAAO,MAAM;AACf;AAIA,SAAgB,aAAa,IAAY,MAAM,mBAA2B;CACxE,OAAQ,KAAK,MAAO;AACtB;AACA,SAAgB,aAAa,IAAY,MAAM,mBAA2B;CACxE,OAAQ,KAAK,KAAM;AACrB"}