"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Writer = void 0;
const text_1 = require("./text");
class Writer {
    #indent = 0;
    #lines = [];
    get indent() {
        return ' '.repeat(this.#indent * 2);
    }
    inIndent = (handler) => {
        this.#indent++;
        handler();
        this.#indent--;
    };
    append(src = '') {
        this.#lines.push(this.indent + src);
    }
    write(src) {
        let lines = (0, text_1.trimIndent)(src).split('\n');
        for (let l of lines) {
            this.append(l);
        }
    }
    end() {
        return this.#lines.join('\n');
    }
}
exports.Writer = Writer;
