"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.NetworkListenerAction=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");class NetworkListenerAction{static forward(targetGroups,options={}){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_elasticloadbalancingv2_NetworkForwardOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.forward),error}if(targetGroups.length===0)throw new Error("Need at least one targetGroup in a NetworkListenerAction.forward()");return targetGroups.length===1&&options.stickinessDuration===void 0?new TargetGroupListenerAction(targetGroups,{type:"forward",targetGroupArn:targetGroups[0].targetGroupArn}):new TargetGroupListenerAction(targetGroups,{type:"forward",forwardConfig:{targetGroups:targetGroups.map(g=>({targetGroupArn:g.targetGroupArn})),targetGroupStickinessConfig:options.stickinessDuration?{durationSeconds:options.stickinessDuration.toSeconds(),enabled:!0}:void 0}})}static weightedForward(targetGroups,options={}){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_elasticloadbalancingv2_NetworkForwardOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.weightedForward),error}if(targetGroups.length===0)throw new Error("Need at least one targetGroup in a NetworkListenerAction.weightedForward()");return new TargetGroupListenerAction(targetGroups.map(g=>g.targetGroup),{type:"forward",forwardConfig:{targetGroups:targetGroups.map(g=>({targetGroupArn:g.targetGroup.targetGroupArn,weight:g.weight})),targetGroupStickinessConfig:options.stickinessDuration?{durationSeconds:options.stickinessDuration.toSeconds(),enabled:!0}:void 0}})}constructor(defaultActionJson,next){this.defaultActionJson=defaultActionJson,this.next=next;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_elasticloadbalancingv2_CfnListener_ActionProperty(defaultActionJson),jsiiDeprecationWarnings().aws_cdk_lib_aws_elasticloadbalancingv2_NetworkListenerAction(next)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,NetworkListenerAction),error}}renderRuleActions(){const actionJson=this._actionJson??this.defaultActionJson;return this._renumber([actionJson,...this.next?.renderRuleActions()??[]])}renderActions(){return this._renumber([this.defaultActionJson,...this.next?.renderActions()??[]])}bind(scope,listener){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_elasticloadbalancingv2_INetworkListener(listener)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}Array.isArray(scope),Array.isArray(listener)}_renumber(actions){return actions.length<2?actions:actions.map((action,i)=>({...action,order:i+1}))}renumber(actions){return this._renumber(actions)}}exports.NetworkListenerAction=NetworkListenerAction,_a=JSII_RTTI_SYMBOL_1,NetworkListenerAction[_a]={fqn:"aws-cdk-lib.aws_elasticloadbalancingv2.NetworkListenerAction",version:"2.159.0"};class TargetGroupListenerAction extends NetworkListenerAction{constructor(targetGroups,defaultActionJson){super(defaultActionJson),this.targetGroups=targetGroups}bind(_scope,listener){for(const tg of this.targetGroups)tg.registerListener(listener)}}
