import { parseLine as v, createLineData as T } from "./parser.js"; function y(h, p = " ") { let r = 0; const t = T("", p); async function s() { r === 0 && (r = 1); const e = await h.next(); return e === null ? (r = 2, !0) : (t.line = e, v(t), !1); } const a = () => t.level, o = () => t.line.slice(t.offsetHead), u = () => t.line.slice(t.offsetHead, t.offsetTail), l = () => t.line.slice(t.offsetTail), w = (e) => e === u(); async function d(e) { const n = r === 0 ? -1 : a(); for (; !(await s() || a() <= n || await e()); ) ; } async function f(e = -1, n = [o()]) { var i; return e === -1 && (e = t.level + 1), await s() || t.level < e ? n : (n.push(((i = t.line) == null ? void 0 : i.slice(e)) || ""), f(e, n)); } async function x(e = [], n) { const c = {}; return await d(async () => { const i = u(); if (!!i) { if (!e.length || e.includes(i)) { c[i] = n ? await n() : l().trim(); return; } if (e && !e.includes(i) && e.includes("#text")) { c["#text"] = await f(a()); return; } } }), c; } async function b() { const e = [["root", []]]; for (; !await s(); ) { const n = a(), c = n + 1, i = e[n]; if (!i) continue; e.length = c; const m = e[c] = [o(), []]; i[1].push(m); } return e[0]; } return { state: r, next: s, line: o, head: u, tail: l, level: a, match: w, each: d, blockAsText: f, buildObject: x, toArrays: b }; } export { y as useDocument };