const s = (h, c, t = { x: 0, y: 0 }) => {
  const e = c * (Math.PI / 180);
  return {
    x: (h.x - t.x) * Math.cos(e) - (h.y - t.y) * Math.sin(e) + t.x,
    y: (h.x - t.x) * Math.sin(e) + (h.y - t.y) * Math.cos(e) + t.y
  };
}, O = (h, c, t, e, n) => {
  const y = t.height * e, a = t.width * e, f = t.top * e, M = t.left * e, { y: d } = s(
    { x: h.width, y: h.height },
    n % 180 === 0 ? 0 : 90
  ), p = M, g = Math.abs(d) - f, o = { x: h.width / 2, y: h.height / 2 }, { x: r, y: u } = s(
    {
      x: c.left + Math.abs(a) / 2,
      y: c.top + Math.abs(y) / 2
    },
    n,
    o
  ), { x: I, y: b } = s({ x: p, y: g }, n, o), x = {
    left: I,
    top: b
  }, H = x.left - r, L = x.top - u;
  return { leftInPage: H, topInPage: L };
};
export {
  O as getWordPositionInPage
};
