{"version":3,"file":"boundingBoxFromPoints.mjs","names":[],"sources":["../../../../src/util/misc/boundingBoxFromPoints.ts"],"sourcesContent":["import type { XY } from '../../Point';\nimport type { TBBox } from '../../typedefs';\n\n/**\n * Calculates bounding box (left, top, width, height) from given `points`\n * @param {XY[]} points\n * @return {Object} Object with left, top, width, height properties\n */\nexport const makeBoundingBoxFromPoints = (points: XY[]): TBBox => {\n  let left = 0,\n    top = 0,\n    width = 0,\n    height = 0;\n\n  for (let i = 0, len = points.length; i < len; i++) {\n    const { x, y } = points[i];\n    if (x > width || !i) width = x;\n    if (x < left || !i) left = x;\n    if (y > height || !i) height = y;\n    if (y < top || !i) top = y;\n  }\n\n  return {\n    left,\n    top,\n    width: width - left,\n    height: height - top,\n  };\n};\n"],"mappings":";;;;;;AAQA,MAAa,6BAA6B,WAAwB;CAChE,IAAI,OAAO,GACT,MAAM,GACN,QAAQ,GACR,SAAS;AAEX,MAAK,IAAI,IAAI,GAAG,MAAM,OAAO,QAAQ,IAAI,KAAK,KAAK;EACjD,MAAM,EAAE,GAAG,MAAM,OAAO;AACxB,MAAI,IAAI,SAAS,CAAC,EAAG,SAAQ;AAC7B,MAAI,IAAI,QAAQ,CAAC,EAAG,QAAO;AAC3B,MAAI,IAAI,UAAU,CAAC,EAAG,UAAS;AAC/B,MAAI,IAAI,OAAO,CAAC,EAAG,OAAM;;AAG3B,QAAO;EACL;EACA;EACA,OAAO,QAAQ;EACf,QAAQ,SAAS;EAClB"}