"use strict";var _a,_b;Object.defineProperty(exports,"__esModule",{value:!0}),exports.StartingPosition=exports.EventSourceMapping=exports.SourceAccessConfigurationType=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),cdk=require("../../core"),lambda_generated_1=require("./lambda.generated");class SourceAccessConfigurationType{constructor(type){this.type=type}static of(name){return new SourceAccessConfigurationType(name)}}exports.SourceAccessConfigurationType=SourceAccessConfigurationType,_a=JSII_RTTI_SYMBOL_1,SourceAccessConfigurationType[_a]={fqn:"aws-cdk-lib.aws_lambda.SourceAccessConfigurationType",version:"2.21.0"},SourceAccessConfigurationType.BASIC_AUTH=new SourceAccessConfigurationType("BASIC_AUTH"),SourceAccessConfigurationType.VPC_SUBNET=new SourceAccessConfigurationType("VPC_SUBNET"),SourceAccessConfigurationType.VPC_SECURITY_GROUP=new SourceAccessConfigurationType("VPC_SECURITY_GROUP"),SourceAccessConfigurationType.SASL_SCRAM_256_AUTH=new SourceAccessConfigurationType("SASL_SCRAM_256_AUTH"),SourceAccessConfigurationType.SASL_SCRAM_512_AUTH=new SourceAccessConfigurationType("SASL_SCRAM_512_AUTH"),SourceAccessConfigurationType.CLIENT_CERTIFICATE_TLS_AUTH=new SourceAccessConfigurationType("CLIENT_CERTIFICATE_TLS_AUTH");class EventSourceMapping extends cdk.Resource{constructor(scope,id,props){var _c,_d,_e,_f,_g;super(scope,id);try{jsiiDeprecationWarnings.aws_cdk_lib_aws_lambda_EventSourceMappingProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.constructor),error}if(props.eventSourceArn==null&&props.kafkaBootstrapServers==null)throw new Error("Either eventSourceArn or kafkaBootstrapServers must be set");if(props.eventSourceArn!==void 0&&props.kafkaBootstrapServers!==void 0)throw new Error("eventSourceArn and kafkaBootstrapServers are mutually exclusive");if(props.kafkaBootstrapServers&&((_c=props.kafkaBootstrapServers)===null||_c===void 0?void 0:_c.length)<1)throw new Error("kafkaBootStrapServers must not be empty if set");if(props.maxBatchingWindow&&props.maxBatchingWindow.toSeconds()>300)throw new Error(`maxBatchingWindow cannot be over 300 seconds, got ${props.maxBatchingWindow.toSeconds()}`);if(props.maxRecordAge&&(props.maxRecordAge.toSeconds()<60||props.maxRecordAge.toDays({integral:!1})>7))throw new Error("maxRecordAge must be between 60 seconds and 7 days inclusive");if(props.retryAttempts!==void 0&&cdk.withResolved(props.retryAttempts,attempts=>{if(attempts<0||attempts>1e4)throw new Error(`retryAttempts must be between 0 and 10000 inclusive, got ${attempts}`)}),props.parallelizationFactor!==void 0&&cdk.withResolved(props.parallelizationFactor,factor=>{if(factor<1||factor>10)throw new Error(`parallelizationFactor must be between 1 and 10 inclusive, got ${factor}`)}),props.tumblingWindow&&!cdk.Token.isUnresolved(props.tumblingWindow)&&props.tumblingWindow.toSeconds()>900)throw new Error(`tumblingWindow cannot be over 900 seconds, got ${props.tumblingWindow.toSeconds()}`);let destinationConfig;props.onFailure&&(destinationConfig={onFailure:props.onFailure.bind(this,props.target)});let selfManagedEventSource;props.kafkaBootstrapServers&&(selfManagedEventSource={endpoints:{kafkaBootstrapServers:props.kafkaBootstrapServers}});const cfnEventSourceMapping=new lambda_generated_1.CfnEventSourceMapping(this,"Resource",{batchSize:props.batchSize,bisectBatchOnFunctionError:props.bisectBatchOnError,destinationConfig,enabled:props.enabled,eventSourceArn:props.eventSourceArn,functionName:props.target.functionName,startingPosition:props.startingPosition,functionResponseTypes:props.reportBatchItemFailures?["ReportBatchItemFailures"]:void 0,maximumBatchingWindowInSeconds:(_d=props.maxBatchingWindow)===null||_d===void 0?void 0:_d.toSeconds(),maximumRecordAgeInSeconds:(_e=props.maxRecordAge)===null||_e===void 0?void 0:_e.toSeconds(),maximumRetryAttempts:props.retryAttempts,parallelizationFactor:props.parallelizationFactor,topics:props.kafkaTopic!==void 0?[props.kafkaTopic]:void 0,tumblingWindowInSeconds:(_f=props.tumblingWindow)===null||_f===void 0?void 0:_f.toSeconds(),sourceAccessConfigurations:(_g=props.sourceAccessConfigurations)===null||_g===void 0?void 0:_g.map(o=>({type:o.type.type,uri:o.uri})),selfManagedEventSource});this.eventSourceMappingId=cfnEventSourceMapping.ref}static fromEventSourceMappingId(scope,id,eventSourceMappingId){class Import extends cdk.Resource{constructor(){super(...arguments),this.eventSourceMappingId=eventSourceMappingId}}return new Import(scope,id)}}exports.EventSourceMapping=EventSourceMapping,_b=JSII_RTTI_SYMBOL_1,EventSourceMapping[_b]={fqn:"aws-cdk-lib.aws_lambda.EventSourceMapping",version:"2.21.0"};var StartingPosition;(function(StartingPosition2){StartingPosition2.TRIM_HORIZON="TRIM_HORIZON",StartingPosition2.LATEST="LATEST"})(StartingPosition=exports.StartingPosition||(exports.StartingPosition={}));
//# sourceMappingURL=event-source-mapping.js.map
