"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DefaultTokenResolver=exports.StringConcat=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var errors_1=()=>{var tmp=require("./errors");return errors_1=()=>tmp,tmp},encoding_1=()=>{var tmp=require("./private/encoding");return encoding_1=()=>tmp,tmp},literal_string_1=()=>{var tmp=require("./private/literal-string");return literal_string_1=()=>tmp,tmp},token_map_1=()=>{var tmp=require("./private/token-map");return token_map_1=()=>tmp,tmp};class StringConcat{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.StringConcat",version:"2.256.1"};join(left,right){return left===void 0?right!==void 0?`${right}`:void 0:right===void 0?`${left}`:`${left}${right}`}}exports.StringConcat=StringConcat;class DefaultTokenResolver{concat;static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.DefaultTokenResolver",version:"2.256.1"};constructor(concat){this.concat=concat;try{jsiiDeprecationWarnings().aws_cdk_lib_IFragmentConcatenator(concat)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,DefaultTokenResolver),error}}resolveToken(t,context,postProcessor){try{jsiiDeprecationWarnings().aws_cdk_lib_IResolvable(t),jsiiDeprecationWarnings().aws_cdk_lib_IResolveContext(context),jsiiDeprecationWarnings().aws_cdk_lib_IPostProcessor(postProcessor)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.resolveToken),error}try{let resolved=t.resolve(context);return resolved=context.resolve(resolved),resolved=postProcessor.postProcess(resolved,context),resolved}catch(e){let message=`Resolution error: ${e.message}.`;throw e.message=message,e}}resolveString(fragments,context){try{jsiiDeprecationWarnings().aws_cdk_lib_TokenizedStringFragments(fragments),jsiiDeprecationWarnings().aws_cdk_lib_IResolveContext(context)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.resolveString),error}return fragments.mapTokens({mapToken:x=>context.resolve(x)}).join(this.concat)}resolveList(xs,context){try{jsiiDeprecationWarnings().aws_cdk_lib_IResolveContext(context)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.resolveList),error}if(xs.length!==1)throw new(errors_1()).UnscopedValidationError((0,literal_string_1().lit)`CannotAddElementsListToken`,`Cannot add elements to list token, got: ${xs}`);const str=encoding_1().TokenString.forListToken(xs[0]),tokenMap=token_map_1().TokenMap.instance(),fragments=str.split(tokenMap.lookupToken.bind(tokenMap));if(fragments.length!==1)throw new(errors_1()).UnscopedValidationError((0,literal_string_1().lit)`CannotConcatenateStringsTokenizedString`,`Cannot concatenate strings in a tokenized string array, got: ${xs[0]}`);return fragments.mapTokens({mapToken:x=>context.resolve(x)}).firstValue}}exports.DefaultTokenResolver=DefaultTokenResolver;
