function m(n, o, f, r) {
  let e = "";
  if (n) {
    let t = !1, s = "";
    for (const c of n) {
      const { source: a, type: i } = c;
      switch (i) {
        case "space":
          t = !0;
          break;
        case "comment": {
          f && !t && r(c, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters");
          const l = a.substring(1) || " ";
          e ? e += s + l : e = l, s = "";
          break;
        }
        case "newline":
          e && (s += a), t = !0;
          break;
        default:
          r(c, "UNEXPECTED_TOKEN", `Unexpected ${i} at node end`);
      }
      o += a.length;
    }
  }
  return { comment: e, offset: o };
}
export {
  m as resolveEnd
};
