"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.completeTestCode = void 0;
const utils_1 = require("@autobe/utils");
const getTestImportStatements_1 = require("./getTestImportStatements");
const completeTestCode = (ctx, artifacts, code) => __awaiter(void 0, void 0, void 0, function* () {
    const compiler = yield ctx.compiler();
    code = yield compiler.typescript.beautify(code);
    code = code
        .split("\r\n")
        .join("\n")
        .split("\n")
        .filter((str) => str.trim().startsWith("import") === false)
        .join("\n");
    return yield compiler.typescript.beautify(utils_1.StringUtil.trim `
    ${(0, getTestImportStatements_1.getTestImportStatements)(artifacts.document)}
    
    ${code}
  `);
});
exports.completeTestCode = completeTestCode;
//# sourceMappingURL=completeTestCode.js.map