"use strict";
//
//  Copyright (c) Microsoft Corporation. All rights reserved.
//
Object.defineProperty(exports, "__esModule", { value: true });
exports.findService = exports.serviceActivation = void 0;
/**
 * Decorator applied to suclasses of `SshService` that declares how the service gets activated.
 */
function serviceActivation(activation) {
    // eslint-disable-next-line @typescript-eslint/ban-types
    return (constructor) => {
        if (!constructor.activations) {
            constructor.activations = [];
        }
        constructor.activations.push(activation);
    };
}
exports.serviceActivation = serviceActivation;
/**
 * Locates a service type in configuration, using a predicate to check service activation
 * attributes.
 *
 * @param serviceConfigs Service configuration dictionary from `SshSessionConfiguration.services`.
 * @param predicate Function to test whether a service activation attribute matches some condition.
 * @returns Service type (constructor), or null if no service type satisfies the predicate.
 */
function findService(serviceConfigs, predicate) {
    for (const serviceType of serviceConfigs.keys()) {
        const activations = serviceType.activations;
        let foundActivation = false;
        for (const activation of activations) {
            foundActivation = true;
            if (predicate(activation)) {
                return serviceType;
            }
        }
        if (!foundActivation) {
            throw new Error(`SSH service type '${serviceType.name}' must have one or more ` +
                '\'serviceActivation\' decorators.');
        }
    }
    return null;
}
exports.findService = findService;
//# sourceMappingURL=https://github.com/VSCodium/sourcemaps/releases/download/stable-824c4c46a288b839f13b24022655329c2aeb9f81/node_modules-@microsoft-dev-tunnels-ssh-services-serviceActivation.js.map