"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultExecutor = void 0;
const tracing_1 = __importStar(require("../../Tracing"));
const fileName_1 = "(@effect-ts/system): _src/Testing/TestExecutor/index.ts";
const Cause = __importStar(require("../../Cause"));
const Tp = __importStar(require("../../Collections/Immutable/Tuple"));
const T = __importStar(require("../../Effect"));
const E = __importStar(require("../../Either"));
const Function_1 = require("../../Function");
const M = __importStar(require("../../Managed"));
const ES = __importStar(require("../ExecutedSpec"));
const Spec = __importStar(require("../Spec"));
const TAM = __importStar(require("../TestAnnotationMap"));
const TF = __importStar(require("../TestFailure"));
function defaultExecutor(env) {
    return {
        environment: env,
        run: (spec, defExec) => (M.use_(Spec.forEachExec(defExec, (e) => E.fold_(Cause.failureOrCause(e), ({ tuple: [failure, annotations] }) => T.succeed(Tp.tuple(E.left(failure), annotations), fileName_1 + ":39:26"), (cause) => T.succeed(Tp.tuple(E.left(TF.halt(cause)), TAM.TestAnnotationMap.empty), fileName_1 + ":41:26")), ({ tuple: [success, annotations] }) => T.succeed(Tp.tuple(E.right(success), annotations), fileName_1 + ":44:22"))(Spec.provideLayer(env)(Spec.annotated(spec))), (_) => (M.useNow(Spec.foldM(defExec)((_) => {
            Spec.concreteSpecCase(_);
            switch (_._tag) {
                case "SuiteCase": {
                    const v = _;
                    return (M.map_(v.specs, (specs) => new ES.ExecutedSpec(new ES.ExecutedSuiteCase(v.label, specs)), fileName_1 + ":57:28"));
                }
                case "TestCase": {
                    const v = _;
                    return (T.toManaged(T.map_(v.test, ({ tuple: [result, dynamicAnnotations] }) => new ES.ExecutedSpec(new ES.ExecutedTestCase(v.label, result, TAM.concat(v.annotations, dynamicAnnotations))), fileName_1 + ":67:28")));
                }
            }
        })(_), fileName_1 + ":83:21")), fileName_1 + ":46:14"))
    };
}
exports.defaultExecutor = defaultExecutor;
//# sourceMappingURL=index.js.map