"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Validations=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var annotations_1=()=>{var tmp=require("../annotations");return annotations_1=()=>tmp,tmp},errors_1=()=>{var tmp=require("../errors");return errors_1=()=>tmp,tmp},literal_string_1=()=>{var tmp=require("../private/literal-string");return literal_string_1=()=>tmp,tmp},stage_1=()=>{var tmp=require("../stage");return stage_1=()=>tmp,tmp};class Validations{scope;static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.Validations",version:"2.256.1"};static ACKNOWLEDGED_RULES_METADATA_KEY="aws:cdk:acknowledged-rules";static of(scope){return new Validations(scope)}static ANNOTATION_PREFIX="annotation";constructor(scope){this.scope=scope}addPlugins(...plugins){try{jsiiDeprecationWarnings().aws_cdk_lib_IPolicyValidationPlugin(plugins)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addPlugins),error}const stage=stage_1().Stage.isStage(this.scope)?this.scope:stage_1().Stage.of(this.scope);if(!stage)throw new(errors_1()).UnscopedValidationError((0,literal_string_1().lit)`NoStageForValidationPlugins`,"Cannot add validation plugins on a construct without an enclosing Stage");stage._addValidationPlugins(...plugins)}addWarning(id,message){annotations_1().Annotations.of(this.scope).addWarningV2(this.qualifyId(id),message)}addError(id,message){annotations_1().Annotations.of(this.scope).addError(`${message} (${this.qualifyId(id)})`)}acknowledge(...rules){try{jsiiDeprecationWarnings().aws_cdk_lib_Acknowledgment(rules)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.acknowledge),error}for(const rule of rules){const qualifiedId=this.qualifyId(rule.id);this.recordAcknowledgment(qualifiedId,rule.reason),annotations_1().Annotations.of(this.scope).acknowledgeWarning(qualifiedId)}}recordAcknowledgment(id,reason){const matches=this.scope.node.metadata.filter(m=>m.type===Validations.ACKNOWLEDGED_RULES_METADATA_KEY),acknowledged=(matches.length>0?matches[matches.length-1]:void 0)?.data??{};acknowledged[id]=reason,this.scope.node.addMetadata(Validations.ACKNOWLEDGED_RULES_METADATA_KEY,acknowledged)}qualifyId(id){const parts=id.split("::");if(parts.length>2||parts.length===2&&parts[0].length===0)throw new(errors_1()).UnscopedValidationError((0,literal_string_1().lit)`InvalidValidationId`,`Invalid validation rule ID '${id}'. The '::' delimiter is reserved for separating the prefix from the rule name (e.g. 'prefix::RuleName').`);return parts.length===2?id:`${Validations.ANNOTATION_PREFIX}::${id}`}}exports.Validations=Validations;
