"use client";
function m(c) {
  const l = String(c), e = [];
  return { toOffset: s, toPoint: i };
  function i(n) {
    if (typeof n == "number" && n > -1 && n <= l.length) {
      let t = 0;
      for (; ; ) {
        let r = e[t];
        if (r === void 0) {
          const u = f(l, e[t - 1]);
          r = u === -1 ? l.length + 1 : u + 1, e[t] = r;
        }
        if (r > n)
          return {
            line: t + 1,
            column: n - (t > 0 ? e[t - 1] : 0) + 1,
            offset: n
          };
        t++;
      }
    }
  }
  function s(n) {
    if (n && typeof n.line == "number" && typeof n.column == "number" && !Number.isNaN(n.line) && !Number.isNaN(n.column)) {
      for (; e.length < n.line; ) {
        const r = e[e.length - 1], u = f(l, r), o = u === -1 ? l.length + 1 : u + 1;
        if (r === o) break;
        e.push(o);
      }
      const t = (n.line > 1 ? e[n.line - 2] : 0) + n.column - 1;
      if (t < e[n.line - 1]) return t;
    }
  }
}
function f(c, l) {
  const e = c.indexOf("\r", l), i = c.indexOf(`
`, l);
  return i === -1 ? e : e === -1 || e + 1 === i ? i : e < i ? e : i;
}
export {
  m as location
};
