"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.Stage=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var constructs_1=()=>{var tmp=require("constructs");return constructs_1=()=>tmp,tmp},synthesis_1=()=>{var tmp=require("./private/synthesis");return synthesis_1=()=>tmp,tmp},cxapi=()=>{var tmp=require("../../cx-api");return cxapi=()=>tmp,tmp};const STAGE_SYMBOL=Symbol.for("@aws-cdk/core.Stage");class Stage extends constructs_1().Construct{static of(construct){return constructs_1().Node.of(construct).scopes.reverse().slice(1).find(Stage.isStage)}static isStage(x){return x!==null&&typeof x=="object"&&STAGE_SYMBOL in x}constructor(scope,id,props={}){super(scope,id),this.policyValidationBeta1=[];try{jsiiDeprecationWarnings().aws_cdk_lib_StageProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,Stage),error}if(id!==""&&!/^[a-z][a-z0-9\-\_\.]+$/i.test(id))throw new Error(`invalid stage name "${id}". Stage name must start with a letter and contain only alphanumeric characters, hypens ('-'), underscores ('_') and periods ('.')`);Object.defineProperty(this,STAGE_SYMBOL,{value:!0}),this.parentStage=Stage.of(this),this.region=props.env?.region??this.parentStage?.region,this.account=props.env?.account??this.parentStage?.account,props.permissionsBoundary?._bind(this),this._assemblyBuilder=this.createBuilder(props.outdir),this.stageName=[this.parentStage?.stageName,props.stageName??id].filter(x=>x).join("-"),props.policyValidationBeta1&&(this.policyValidationBeta1=props.policyValidationBeta1)}get outdir(){return this._assemblyBuilder.outdir}get assetOutdir(){return this._assemblyBuilder.assetOutdir}get artifactId(){return this.node.path?`assembly-${this.node.path.replace(/\//g,"-").replace(/^-+|-+$/g,"")}`:""}synth(options={}){try{jsiiDeprecationWarnings().aws_cdk_lib_StageSynthesisOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.synth),error}return(!this.assembly||options.force)&&(this.assembly=(0,synthesis_1().synthesize)(this,{skipValidation:options.skipValidation,validateOnSynthesis:options.validateOnSynthesis})),this.assembly}createBuilder(outdir){if(this.parentStage&&outdir)throw new Error('"outdir" cannot be specified for nested stages');return this.parentStage?this.parentStage._assemblyBuilder.createNestedAssembly(this.artifactId,this.node.path):new(cxapi()).CloudAssemblyBuilder(outdir)}}exports.Stage=Stage,_a=JSII_RTTI_SYMBOL_1,Stage[_a]={fqn:"aws-cdk-lib.Stage",version:"2.148.1"};
