"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.TokenizedStringFragments=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var token_1=()=>{var tmp=require("./token");return token_1=()=>tmp,tmp};class TokenizedStringFragments{constructor(){this.fragments=new Array}get firstToken(){const first=this.fragments[0];if(first.type==="token")return first.token}get firstValue(){return fragmentValue(this.fragments[0])}get length(){return this.fragments.length}addLiteral(lit){this.fragments.push({type:"literal",lit})}addToken(token){try{jsiiDeprecationWarnings().aws_cdk_lib_IResolvable(token)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addToken),error}this.fragments.push({type:"token",token})}addIntrinsic(value){this.fragments.push({type:"intrinsic",value})}get tokens(){const ret=new Array;for(const f of this.fragments)f.type==="token"&&ret.push(f.token);return ret}mapTokens(mapper){try{jsiiDeprecationWarnings().aws_cdk_lib_ITokenMapper(mapper)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.mapTokens),error}const ret=new TokenizedStringFragments;for(const f of this.fragments)switch(f.type){case"literal":ret.addLiteral(f.lit);break;case"token":const mapped=mapper.mapToken(f.token);(0,token_1().isResolvableObject)(mapped)?ret.addToken(mapped):token_1().Token.isUnresolved(mapped)?ret.addIntrinsic(mapped):ret.addLiteral(mapped);break;case"intrinsic":ret.addIntrinsic(f.value);break}return ret}join(concat){try{jsiiDeprecationWarnings().aws_cdk_lib_IFragmentConcatenator(concat)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.join),error}if(this.fragments.length===0)return concat.join(void 0,void 0);if(this.fragments.length===1)return this.firstValue;const values=this.fragments.map(fragmentValue);for(;values.length>1;){const prefix=values.splice(0,2);values.splice(0,0,concat.join(prefix[0],prefix[1]))}return values[0]}}exports.TokenizedStringFragments=TokenizedStringFragments,_a=JSII_RTTI_SYMBOL_1,TokenizedStringFragments[_a]={fqn:"aws-cdk-lib.TokenizedStringFragments",version:"2.159.0"};function fragmentValue(fragment){switch(fragment.type){case"literal":return fragment.lit;case"token":return fragment.token.toString();case"intrinsic":return fragment.value}}
