{"version":3,"sources":["../src/utils/getCoordinates.ts"],"sourcesContent":["import { clamp } from '@fluentui/react-utilities';\n\n/**\n * Calculates the normalized coordinates of a mouse event relative to a given HTML element.\n *\n * @param element - The HTML element to calculate the coordinates relative to.\n * @param event - The mouse event containing the clientX and clientY properties.\n * @returns An object containing the normalized x and y coordinates, clamped between 0 and 1.\n */\nexport function getCoordinates(element: HTMLElement, event: PointerEvent): { x: number; y: number } {\n  const rect = element.getBoundingClientRect();\n\n  const newX = roundTwoDecimal((event.clientX - rect.left) / rect.width);\n  const newY = roundTwoDecimal(1 - (event.clientY - rect.top) / rect.height);\n\n  return {\n    x: clamp(newX, 0, 1),\n    y: clamp(newY, 0, 1),\n  };\n}\n\n/**\n * Rounds a given number to two decimal places.\n *\n * @param num - The number to be rounded.\n * @returns The number rounded to two decimal places.\n */\nexport function roundTwoDecimal(num: number): number {\n  return Math.round(num * 100) / 100;\n}\n"],"names":["clamp","getCoordinates","element","event","rect","getBoundingClientRect","newX","roundTwoDecimal","clientX","left","width","newY","clientY","top","height","x","y","num","Math","round"],"mappings":";;;;;;;;;;;IASgBC,cAAAA;;;mBAkBAM;;;;gCA3BM,4BAA4B;AAS3C,wBAAwBL,OAAoB,EAAEC,KAAmB;IACtE,MAAMC,OAAOF,QAAQG,qBAAqB;IAE1C,MAAMC,OAAOC,gBAAiBJ,CAAAA,MAAMK,OAAO,GAAGJ,KAAKK,IAAG,AAAHA,IAAQL,KAAKM,KAAK;IACrE,MAAMC,OAAOJ,gBAAgB,IAAKJ,CAAAA,MAAMS,OAAO,GAAGR,KAAKS,GAAAA,AAAE,IAAKT,KAAKU,MAAM;IAEzE,OAAO;QACLC,OAAGf,qBAAAA,EAAMM,MAAM,GAAG;QAClBU,OAAGhB,qBAAAA,EAAMW,MAAM,GAAG;IACpB;AACF;AAQO,SAASJ,gBAAgBU,GAAW;IACzC,OAAOC,KAAKC,KAAK,CAACF,MAAM,OAAO;AACjC"}