"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.IntegrationPattern=exports.TaskStateBase=void 0;const jsiiDeprecationWarnings=require("../../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),cloudwatch=require("../../../aws-cloudwatch"),chain_1=require("../chain"),state_1=require("./state");class TaskStateBase extends state_1.State{constructor(scope,id,props){super(scope,id,props);jsiiDeprecationWarnings.aws_cdk_lib_aws_stepfunctions_TaskStateBaseProps(props),this.endStates=[this],this.timeout=props.timeout,this.heartbeat=props.heartbeat}addRetry(props={}){return jsiiDeprecationWarnings.aws_cdk_lib_aws_stepfunctions_RetryProps(props),super._addRetry(props),this}addCatch(handler,props={}){return jsiiDeprecationWarnings.aws_cdk_lib_aws_stepfunctions_IChainable(handler),jsiiDeprecationWarnings.aws_cdk_lib_aws_stepfunctions_CatchProps(props),super._addCatch(handler.startState,props),this}next(next){return jsiiDeprecationWarnings.aws_cdk_lib_aws_stepfunctions_IChainable(next),super.makeNext(next.startState),chain_1.Chain.sequence(this,next)}toStateJson(){return{...this.renderNextEnd(),...this.renderRetryCatch(),...this.renderTaskBase(),...this._renderTask()}}metric(metricName,props){var _b;return jsiiDeprecationWarnings.aws_cdk_lib_aws_cloudwatch_MetricOptions(props),new cloudwatch.Metric({namespace:"AWS/States",metricName,dimensionsMap:(_b=this.taskMetrics)===null||_b===void 0?void 0:_b.metricDimensions,statistic:"sum",...props}).attachTo(this)}metricRunTime(props){var _b;return jsiiDeprecationWarnings.aws_cdk_lib_aws_cloudwatch_MetricOptions(props),this.taskMetric((_b=this.taskMetrics)===null||_b===void 0?void 0:_b.metricPrefixSingular,"RunTime",{statistic:"avg",...props})}metricScheduleTime(props){var _b;return jsiiDeprecationWarnings.aws_cdk_lib_aws_cloudwatch_MetricOptions(props),this.taskMetric((_b=this.taskMetrics)===null||_b===void 0?void 0:_b.metricPrefixSingular,"ScheduleTime",{statistic:"avg",...props})}metricTime(props){var _b;return jsiiDeprecationWarnings.aws_cdk_lib_aws_cloudwatch_MetricOptions(props),this.taskMetric((_b=this.taskMetrics)===null||_b===void 0?void 0:_b.metricPrefixSingular,"Time",{statistic:"avg",...props})}metricScheduled(props){var _b;return jsiiDeprecationWarnings.aws_cdk_lib_aws_cloudwatch_MetricOptions(props),this.taskMetric((_b=this.taskMetrics)===null||_b===void 0?void 0:_b.metricPrefixPlural,"Scheduled",props)}metricTimedOut(props){var _b;return jsiiDeprecationWarnings.aws_cdk_lib_aws_cloudwatch_MetricOptions(props),this.taskMetric((_b=this.taskMetrics)===null||_b===void 0?void 0:_b.metricPrefixPlural,"TimedOut",props)}metricStarted(props){var _b;return jsiiDeprecationWarnings.aws_cdk_lib_aws_cloudwatch_MetricOptions(props),this.taskMetric((_b=this.taskMetrics)===null||_b===void 0?void 0:_b.metricPrefixPlural,"Started",props)}metricSucceeded(props){var _b;return jsiiDeprecationWarnings.aws_cdk_lib_aws_cloudwatch_MetricOptions(props),this.taskMetric((_b=this.taskMetrics)===null||_b===void 0?void 0:_b.metricPrefixPlural,"Succeeded",props)}metricFailed(props){var _b;return jsiiDeprecationWarnings.aws_cdk_lib_aws_cloudwatch_MetricOptions(props),this.taskMetric((_b=this.taskMetrics)===null||_b===void 0?void 0:_b.metricPrefixPlural,"Failed",props)}metricHeartbeatTimedOut(props){var _b;return jsiiDeprecationWarnings.aws_cdk_lib_aws_cloudwatch_MetricOptions(props),this.taskMetric((_b=this.taskMetrics)===null||_b===void 0?void 0:_b.metricPrefixPlural,"HeartbeatTimedOut",props)}whenBoundToGraph(graph){jsiiDeprecationWarnings.aws_cdk_lib_aws_stepfunctions_StateGraph(graph),super.whenBoundToGraph(graph);for(const policyStatement of this.taskPolicies||[])graph.registerPolicyStatement(policyStatement)}taskMetric(prefix,suffix,props){if(prefix===void 0)throw new Error("Task does not expose metrics. Use the 'metric()' function to add metrics.");return this.metric(prefix+suffix,props)}renderTaskBase(){var _b,_c;return{Type:"Task",Comment:this.comment,TimeoutSeconds:(_b=this.timeout)===null||_b===void 0?void 0:_b.toSeconds(),HeartbeatSeconds:(_c=this.heartbeat)===null||_c===void 0?void 0:_c.toSeconds(),InputPath:state_1.renderJsonPath(this.inputPath),OutputPath:state_1.renderJsonPath(this.outputPath),ResultPath:state_1.renderJsonPath(this.resultPath),...this.renderResultSelector()}}}exports.TaskStateBase=TaskStateBase,_a=JSII_RTTI_SYMBOL_1,TaskStateBase[_a]={fqn:"aws-cdk-lib.aws_stepfunctions.TaskStateBase",version:"2.13.0"};var IntegrationPattern;(function(IntegrationPattern2){IntegrationPattern2.REQUEST_RESPONSE="REQUEST_RESPONSE",IntegrationPattern2.RUN_JOB="RUN_JOB",IntegrationPattern2.WAIT_FOR_TASK_TOKEN="WAIT_FOR_TASK_TOKEN"})(IntegrationPattern=exports.IntegrationPattern||(exports.IntegrationPattern={}));
//# sourceMappingURL=task-base.js.map
