"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (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 () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CfnLoadBalancerPropsMixin = void 0;
const jsiiDeprecationWarnings = require("../../../.warnings.jsii.js");
const JSII_RTTI_SYMBOL_1 = Symbol.for("jsii.rtti");
/* eslint-disable @stylistic/max-len, eol-last */
const cdk = __importStar(require("aws-cdk-lib/core"));
const service = __importStar(require("aws-cdk-lib/aws-elasticloadbalancing"));
/**
 * Specifies a Classic Load Balancer.
 *
 * If this resource has a public IP address and is also in a VPC that is defined in the same template, you must use the [DependsOn attribute](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-dependson.html) to declare a dependency on the VPC-gateway attachment.
 *
 * @cloudformationResource AWS::ElasticLoadBalancing::LoadBalancer
 * @mixin true
 * @stability external
 * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticloadbalancing-loadbalancer.html
 */
class CfnLoadBalancerPropsMixin extends cdk.Mixin {
    static [JSII_RTTI_SYMBOL_1] = { fqn: "@aws-cdk/cfn-property-mixins.aws_elasticloadbalancing.CfnLoadBalancerPropsMixin", version: "2.258.1" };
    static CFN_PROPERTY_KEYS = ["accessLoggingPolicy", "appCookieStickinessPolicy", "availabilityZones", "connectionDrainingPolicy", "connectionSettings", "crossZone", "healthCheck", "instances", "lbCookieStickinessPolicy", "listeners", "loadBalancerName", "policies", "scheme", "securityGroups", "subnets", "tags"];
    props;
    strategy;
    /**
     * Create a mixin to apply properties to `AWS::ElasticLoadBalancing::LoadBalancer`.
     *
     * @param props L1 properties to apply
     * @param options Mixin options
     */
    constructor(props, options = {}) {
        super();
        try {
            jsiiDeprecationWarnings._aws_cdk_cfn_property_mixins_aws_elasticloadbalancing_CfnLoadBalancerMixinProps(props);
            jsiiDeprecationWarnings._aws_cdk_cfn_property_mixins_CfnPropertyMixinOptions(options);
        }
        catch (error) {
            if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
                Error.captureStackTrace(error, CfnLoadBalancerPropsMixin);
            }
            throw error;
        }
        this.props = {
            ...props,
            ...flattenCfnLoadBalancerMixinProps(props)
        };
        this.strategy = (options.strategy ?? cdk.PropertyMergeStrategy.combine());
    }
    /**
     * Check if this mixin supports the given construct
     */
    supports(construct) {
        return (cdk.CfnResource.isCfnResource(construct) && service.CfnLoadBalancer.isCfnLoadBalancer(construct));
    }
    /**
     * Apply the mixin properties to the construct
     */
    applyTo(construct) {
        if (this.supports(construct)) {
            this.strategy.apply(construct, this.props, CfnLoadBalancerPropsMixin.CFN_PROPERTY_KEYS);
        }
    }
}
exports.CfnLoadBalancerPropsMixin = CfnLoadBalancerPropsMixin;
// @ts-ignore TS6133
function flattenCfnLoadBalancerPropsMixinAccessLoggingPolicyProperty(props) {
    if (cdk.isResolvableObject(props))
        return props;
    return {
        emitInterval: (!props.emitInterval ? undefined : props.emitInterval),
        enabled: (!props.enabled ? undefined : props.enabled),
        s3BucketName: (!props.s3BucketName ? undefined : cdk.getRefProperty(props.s3BucketName?.bucketRef, 'bucketName') ?? cdk.ensureStringOrUndefined(props.s3BucketName, "s3BucketName", "s3.IBucketRef | string")),
        s3BucketPrefix: (!props.s3BucketPrefix ? undefined : props.s3BucketPrefix)
    };
}
// @ts-ignore TS6133
function flattenCfnLoadBalancerMixinProps(props) {
    const ret = {};
    if ((props.accessLoggingPolicy !== undefined))
        ret.accessLoggingPolicy = flattenCfnLoadBalancerPropsMixinAccessLoggingPolicyProperty(props.accessLoggingPolicy);
    if ((props.instances !== undefined))
        ret.instances = cdk.mapArrayInPlace(props.instances, (item) => cdk.getRefProperty(item?.instanceRef, 'instanceId') ?? cdk.ensureStringOrUndefined(item, "instances", "ec2.IInstanceRef | string"));
    if ((props.securityGroups !== undefined))
        ret.securityGroups = cdk.mapArrayInPlace(props.securityGroups, (item) => cdk.getRefProperty(item?.securityGroupRef, 'securityGroupId') ?? cdk.ensureStringOrUndefined(item, "securityGroups", "ec2.ISecurityGroupRef | string"));
    if ((props.subnets !== undefined))
        ret.subnets = cdk.mapArrayInPlace(props.subnets, (item) => cdk.getRefProperty(item?.subnetRef, 'subnetId') ?? cdk.ensureStringOrUndefined(item, "subnets", "ec2.ISubnetRef | string"));
    return ret;
}
