"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mergeEnvironments = exports.replaceServiceIn_ = exports.replaceServiceIn = exports.tag = exports.service = void 0;
// ets_tracing: off
require("../Operator");
const Option_1 = require("../Option");
function service(x) {
    // @ts-expect-error
    return x;
}
exports.service = service;
/**
 * Extract the Has type from any augumented variant
 */
const makeTag = (key = Symbol()) => ({
    _tag: "Tag",
    _T: undefined,
    key,
    has: (t) => ({ [key]: t }),
    of: (t) => t,
    read: (r) => r[key],
    readOption: (r) => typeof r === "object" && r !== null ? (0, Option_1.fromNullable)(r[key]) : Option_1.none,
    refine: () => makeTag(key)
});
/**
 * Create a service entry Tag from a type and a URI
 */
function tag(key) {
    return makeTag(key);
}
exports.tag = tag;
/**
 * Replaces the service with the required Service Entry, in the specified environment
 */
const replaceServiceIn = (_, f) => (r) => ({
    ...r,
    [_.key]: f(r[_.key])
});
exports.replaceServiceIn = replaceServiceIn;
/**
 * Replaces the service with the required Service Entry, in the specified environment
 */
const replaceServiceIn_ = (r, _, f) => ({
    ...r,
    ..._.has(f(r[_.key]))
});
exports.replaceServiceIn_ = replaceServiceIn_;
function mergeEnvironments(_, r, t) {
    return {
        ...r,
        ..._.has(t)
    };
}
exports.mergeEnvironments = mergeEnvironments;
//# sourceMappingURL=index.js.map