const b = /\bmso-list:[^;]*ignore/i, g = /\bmso-list:[^;]*\bl(\d+)/i, p = /\bmso-list:[^;]*\blevel(\d+)/i, E = (s, a) => {
  const n = s.getAttribute("style"), r = n == null ? void 0 : n.match(g);
  if (!r)
    return null;
  const h = Number(r[1]), l = n == null ? void 0 : n.match(p), m = l ? Number(l[1]) : 1, u = new RegExp(`@list l${h}:level${m}\\s*\\{[^\\}]*mso-level-number-format:\\s*([\\w-]+)`, "i"), e = a.match(u), t = e && e[1] === "bullet" ? "bullet" : "ordered";
  return {
    id: h,
    indent: m,
    type: t,
    element: s
  };
}, x = (s) => {
  var m, u;
  const a = Array.from(s.querySelectorAll("[style*=mso-list]")), n = [], r = [];
  a.forEach((e) => {
    (e.getAttribute("style") || "").match(b) ? n.push(e) : r.push(e);
  }), n.forEach((e) => {
    var t;
    return (t = e.parentNode) == null ? void 0 : t.removeChild(e);
  });
  const h = s.documentElement.innerHTML, l = r.map((e) => E(e, h)).filter((e) => e);
  for (; l.length; ) {
    const e = [];
    let t = l.shift();
    for (; t; )
      e.push(t), t = l.length && ((m = l[0]) == null ? void 0 : m.element) === t.element.nextElementSibling && // Different id means the next item doesn't belong to this group.
      l[0].id === t.id ? l.shift() : null;
    const f = document.createElement("ul");
    e.forEach((o) => {
      const c = document.createElement("li");
      c.setAttribute("data-list", o.type), o.indent > 1 && c.setAttribute("class", `ql-indent-${o.indent - 1}`), c.innerHTML = o.element.innerHTML, f.appendChild(c);
    });
    const d = (u = e[0]) == null ? void 0 : u.element, {
      parentNode: i
    } = d ?? {};
    d && (i == null || i.replaceChild(f, d)), e.slice(1).forEach((o) => {
      let {
        element: c
      } = o;
      i == null || i.removeChild(c);
    });
  }
};
function A(s) {
  s.documentElement.getAttribute("xmlns:w") === "urn:schemas-microsoft-com:office:word" && x(s);
}
export {
  A as default
};
