"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.attachCustomSynthesis=exports.App=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),cxapi=require("../../cx-api"),fs=require("fs-extra"),synthesis_1=require("./private/synthesis"),tree_metadata_1=require("./private/tree-metadata"),stage_1=require("./stage"),APP_SYMBOL=Symbol.for("@aws-cdk/core.App");class App extends stage_1.Stage{constructor(props={}){super(void 0,"",{outdir:props.outdir??process.env[cxapi.OUTDIR_ENV]});try{jsiiDeprecationWarnings.aws_cdk_lib_AppProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,App),error}Object.defineProperty(this,APP_SYMBOL,{value:!0}),this.loadContext(props.context,props.postCliContext),props.stackTraces===!1&&this.node.setContext(cxapi.DISABLE_METADATA_STACK_TRACE,!0);const analyticsReporting=props.analyticsReporting??props.runtimeInfo;analyticsReporting!==void 0&&this.node.setContext(cxapi.ANALYTICS_REPORTING_ENABLED_CONTEXT,analyticsReporting),(props.autoSynth??cxapi.OUTDIR_ENV in process.env)&&process.once("beforeExit",()=>this.synth()),(props.treeMetadata===void 0||props.treeMetadata)&&new tree_metadata_1.TreeMetadata(this)}static isApp(obj){return APP_SYMBOL in obj}loadContext(defaults={},final={}){for(const[k,v]of Object.entries(defaults))this.node.setContext(k,v);const context={...this.readContextFromEnvironment(),...this.readContextFromTempFile()};for(const[k,v]of Object.entries(context))this.node.setContext(k,v);for(const[k,v]of Object.entries(final))this.node.setContext(k,v)}readContextFromTempFile(){const location=process.env[cxapi.CONTEXT_OVERFLOW_LOCATION_ENV];return location?fs.readJSONSync(location):{}}readContextFromEnvironment(){const contextJson=process.env[cxapi.CONTEXT_ENV];return contextJson?JSON.parse(contextJson):{}}}exports.App=App,_a=JSII_RTTI_SYMBOL_1,App[_a]={fqn:"aws-cdk-lib.App",version:"2.46.0"};function attachCustomSynthesis(construct,synthesis){synthesis_1.addCustomSynthesis(construct,synthesis)}exports.attachCustomSynthesis=attachCustomSynthesis;
//# sourceMappingURL=app.js.map
