"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EventBridgePutEvents=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var iam=()=>{var tmp=require("../../../aws-iam");return iam=()=>tmp,tmp},sfn=()=>{var tmp=require("../../../aws-stepfunctions");return sfn=()=>tmp,tmp},cdk=()=>{var tmp=require("../../../core");return cdk=()=>tmp,tmp},literal_string_1=()=>{var tmp=require("../../../core/lib/private/literal-string");return literal_string_1=()=>tmp,tmp},task_utils_1=()=>{var tmp=require("../private/task-utils");return task_utils_1=()=>tmp,tmp};class EventBridgePutEvents extends sfn().TaskStateBase{props;static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_stepfunctions_tasks.EventBridgePutEvents",version:"2.256.1"};static jsonPath(scope,id,props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_stepfunctions_tasks_EventBridgePutEventsJsonPathProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.jsonPath),error}return new EventBridgePutEvents(scope,id,props)}static jsonata(scope,id,props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_stepfunctions_tasks_EventBridgePutEventsJsonataProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.jsonata),error}return new EventBridgePutEvents(scope,id,{...props,queryLanguage:sfn().QueryLanguage.JSONATA})}static SUPPORTED_INTEGRATION_PATTERNS=[sfn().IntegrationPattern.REQUEST_RESPONSE,sfn().IntegrationPattern.WAIT_FOR_TASK_TOKEN];taskMetrics;taskPolicies;integrationPattern;constructor(scope,id,props){super(scope,id,props),this.props=props;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_stepfunctions_tasks_EventBridgePutEventsProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,EventBridgePutEvents),error}if(this.integrationPattern=props.integrationPattern??sfn().IntegrationPattern.REQUEST_RESPONSE,(0,task_utils_1().validatePatternSupported)(this.integrationPattern,EventBridgePutEvents.SUPPORTED_INTEGRATION_PATTERNS),this.integrationPattern===sfn().IntegrationPattern.WAIT_FOR_TASK_TOKEN&&!sfn().FieldUtils.containsTaskToken(props.entries.map(entry=>entry.detail)))throw new(cdk()).ValidationError((0,literal_string_1().lit)`TaskTokenRequired`,"Task Token is required in `entries`. Use JsonPath.taskToken to set the token.",this);this.validateEntries(),this.taskPolicies=[new(iam()).PolicyStatement({actions:["events:PutEvents"],resources:this.eventBusArns})]}get eventBusArns(){return this.props.entries.map(entry=>entry.eventBus?entry.eventBus.eventBusRef.eventBusArn:cdk().Stack.of(this).formatArn({resource:"event-bus",resourceName:"default",arnFormat:cdk().ArnFormat.SLASH_RESOURCE_NAME,service:"events"}))}_renderTask(topLevelQueryLanguage){const queryLanguage=sfn()._getActualQueryLanguage(topLevelQueryLanguage,this.props.queryLanguage);return{Resource:(0,task_utils_1().integrationResourceArn)("events","putEvents",this.integrationPattern),...this._renderParametersOrArguments({Entries:this.renderEntries()},queryLanguage)}}renderEntries(){return this.props.entries.map(entry=>({Detail:entry.detail?.value,DetailType:entry.detailType,EventBusName:entry.eventBus?.eventBusRef.eventBusArn,Source:entry.source}))}validateEntries(){if(this.props.entries.length<=0)throw new(cdk()).ValidationError((0,literal_string_1().lit)`EntriesMustBeNonEmptyArray`,"Value for property `entries` must be a non-empty array.",this);if(this.props.entries.some(e=>e.source.startsWith("aws.")))throw new(cdk()).ValidationError((0,literal_string_1().lit)`EventSourceCannotStartWithAws`,'Event source cannot start with "aws."',this)}}exports.EventBridgePutEvents=EventBridgePutEvents;
