"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.toEmit = void 0;
// ets_tracing: off
const CS = __importStar(require("../../../../../Cause"));
const CK = __importStar(require("../../../../../Collections/Immutable/Chunk"));
const T = __importStar(require("../../../../../Effect"));
const Ex = __importStar(require("../../../../../Exit"));
const O = __importStar(require("../../../../../Option"));
function toEmit(fn) {
    const ops = {
        chunk(as) {
            return this(T.succeed(as));
        },
        die(err) {
            return this(T.die(err));
        },
        dieMessage(message) {
            return this(T.dieMessage(message));
        },
        done(exit) {
            return this(T.done(Ex.mapBoth_(exit, (e) => O.some(e), (a) => CK.single(a))));
        },
        end() {
            return this(T.fail(O.none));
        },
        fail(e) {
            return this(T.fail(O.some(e)));
        },
        fromEffect(io) {
            return this(T.mapBoth_(io, (e) => O.some(e), (a) => CK.single(a)));
        },
        fromEffectChunk(io) {
            return this(T.mapError_(io, (e) => O.some(e)));
        },
        halt(cause) {
            return this(T.halt(CS.map_(cause, (e) => O.some(e))));
        },
        single(a) {
            return this(T.succeed(CK.single(a)));
        }
    };
    return Object.assign(fn, ops);
}
exports.toEmit = toEmit;
//# sourceMappingURL=Emit.js.map