"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.Dashboard=exports.PeriodOverride=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),core_1=require("../../core"),cloudwatch_generated_1=require("./cloudwatch.generated"),layout_1=require("./layout");var PeriodOverride;(function(PeriodOverride2){PeriodOverride2.AUTO="auto",PeriodOverride2.INHERIT="inherit"})(PeriodOverride=exports.PeriodOverride||(exports.PeriodOverride={}));class Dashboard extends core_1.Resource{constructor(scope,id,props={}){super(scope,id,{physicalName:props.dashboardName}),this.rows=[];try{jsiiDeprecationWarnings.aws_cdk_lib_aws_cloudwatch_DashboardProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.constructor),error}{const{dashboardName}=props;if(dashboardName&&!core_1.Token.isUnresolved(dashboardName)&&!dashboardName.match(/^[\w-]+$/))throw new Error([`The value ${dashboardName} for field dashboardName contains invalid characters.`,"It can only contain alphanumerics, dash (-) and underscore (_)."].join(" "))}const dashboard=new cloudwatch_generated_1.CfnDashboard(this,"Resource",{dashboardName:this.physicalName,dashboardBody:core_1.Lazy.string({produce:()=>{const column=new layout_1.Column(...this.rows);return column.position(0,0),core_1.Stack.of(this).toJsonString({start:props.start,end:props.end,periodOverride:props.periodOverride,widgets:column.toJson()})}})});this.dashboardName=this.getResourceNameAttribute(dashboard.ref),(props.widgets||[]).forEach(row=>{this.addWidgets(...row)}),this.dashboardArn=core_1.Stack.of(this).formatArn({service:"cloudwatch",resource:"dashboard",resourceName:this.physicalName})}addWidgets(...widgets){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_cloudwatch_IWidget(widgets)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addWidgets),error}if(widgets.length===0)return;const warnings=allWidgetsDeep(widgets).flatMap(w2=>{var _b;return(_b=w2.warnings)!==null&&_b!==void 0?_b:[]});for(const w2 of warnings)core_1.Annotations.of(this).addWarning(w2);const w=widgets.length>1?new layout_1.Row(...widgets):widgets[0];this.rows.push(w)}}exports.Dashboard=Dashboard,_a=JSII_RTTI_SYMBOL_1,Dashboard[_a]={fqn:"aws-cdk-lib.aws_cloudwatch.Dashboard",version:"2.24.1"};function allWidgetsDeep(ws){const ret=new Array;return ws.forEach(recurse),ret;function recurse(w){ret.push(w),hasSubWidgets(w)&&w.widgets.forEach(recurse)}}function hasSubWidgets(w){return"widgets"in w}
//# sourceMappingURL=dashboard.js.map
