// SPDX-License-Identifier: Apache-2.0
import { EnvironmentConfigSource } from './environment-config-source.js';
import { LayeredConfig } from './layered-config.js';
export class LayeredConfigBuilder {
    provider;
    mapper;
    prefix;
    sources;
    converters;
    mergeSourceValues = false;
    constructor(provider, mapper, prefix) {
        this.provider = provider;
        this.mapper = mapper;
        this.prefix = prefix;
        this.sources = [];
        this.converters = [];
    }
    withDefaultSources() {
        this.sources.push(new EnvironmentConfigSource(this.mapper, this.prefix));
        return this;
    }
    withConverter(cls, priority, converter) {
        this.converters.push(new ConverterEntry(cls, priority, converter));
        return this;
    }
    withDefaultConverters() {
        return this;
    }
    withSources(...sources) {
        this.sources.push(...sources);
        return this;
    }
    withMergeSourceValues(mergeSourceValues) {
        this.mergeSourceValues = mergeSourceValues;
        return this;
    }
    build() {
        const cfg = new LayeredConfig(this.sources, this.mergeSourceValues);
        this.provider.register(cfg);
        return cfg;
    }
}
class ConverterEntry {
    ctor;
    priority;
    converter;
    constructor(ctor, priority, converter) {
        this.ctor = ctor;
        this.priority = priority;
        this.converter = converter;
    }
}
//# sourceMappingURL=layered-config-builder.js.map