import { AmfNamespace } from '@api-client/core/amf/definitions/Namespace.js';
import ApiSecurityDocumentElement from './ApiSecurityDocument.element.js';
export default class ApiParametrizedSecurityScheme extends ApiSecurityDocumentElement {
    settingsValue;
    get settings() {
        return this.settingsValue;
    }
    set settings(value) {
        const old = this.settingsValue;
        if (old === value) {
            return;
        }
        this.settingsValue = value;
        this.requestUpdate();
    }
    /**
     * @returns The template for the security settings, when required.
     */
    settingsTemplate(scheme) {
        const appliedSettings = this.settingsValue;
        if (!appliedSettings) {
            return super.settingsTemplate(scheme);
        }
        const { settings } = scheme;
        if (!settings) {
            return '';
        }
        const { types } = settings;
        const mergedSettings = this.mergeSettings(appliedSettings, settings);
        if (types.includes(AmfNamespace.aml.vocabularies.security.ApiKeySettings)) {
            return this.apiKeySettingsTemplate(mergedSettings);
        }
        if (types.includes(AmfNamespace.aml.vocabularies.security.OpenIdConnectSettings)) {
            return this.openIdConnectSettingsTemplate(mergedSettings);
        }
        if (types.includes(AmfNamespace.aml.vocabularies.security.OAuth2Settings)) {
            return this.oAuth2SettingsTemplate(mergedSettings);
        }
        return '';
    }
    /**
     * @param applied The settings applied to the current object
     * @param scheme The settings defined in the scheme
     * @returns The merged settings to render.
     */
    mergeSettings(applied, scheme) {
        const result = { ...scheme };
        Object.keys(applied).forEach((key) => {
            if (['id', 'types', 'additionalProperties'].includes(key)) {
                return;
            }
            // eslint-disable-next-line @typescript-eslint/no-explicit-any
            result[key] = applied[key];
        });
        return result;
    }
}
//# sourceMappingURL=ApiParametrizedSecurityScheme.element.js.map