"use strict";var _a,_b,_c;Object.defineProperty(exports,"__esModule",{value:!0}),exports.withResolved=exports.isResolvableObject=exports.Tokenization=exports.Token=exports.TokenComparison=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),lazy_1=require("./lazy"),encoding_1=require("./private/encoding"),intrinsic_1=require("./private/intrinsic"),resolve_1=require("./private/resolve"),token_map_1=require("./private/token-map");class TokenComparison{constructor(){}}exports.TokenComparison=TokenComparison,_a=JSII_RTTI_SYMBOL_1,TokenComparison[_a]={fqn:"aws-cdk-lib.TokenComparison",version:"2.13.0"},TokenComparison.SAME=new TokenComparison,TokenComparison.DIFFERENT=new TokenComparison,TokenComparison.ONE_UNRESOLVED=new TokenComparison,TokenComparison.BOTH_UNRESOLVED=new TokenComparison;class Token{constructor(){}static isUnresolved(obj){return encoding_1.unresolved(obj)}static asString(value,options={}){return jsiiDeprecationWarnings.aws_cdk_lib_EncodingOptions(options),typeof value=="string"?value:token_map_1.TokenMap.instance().registerString(Token.asAny(value),options.displayHint)}static asNumber(value){return typeof value=="number"?value:token_map_1.TokenMap.instance().registerNumber(Token.asAny(value))}static asList(value,options={}){return jsiiDeprecationWarnings.aws_cdk_lib_EncodingOptions(options),Array.isArray(value)&&value.every(x=>typeof x=="string")?value:token_map_1.TokenMap.instance().registerList(Token.asAny(value),options.displayHint)}static asAny(value){return isResolvableObject(value)?value:new intrinsic_1.Intrinsic(value)}static compareStrings(possibleToken1,possibleToken2){const firstIsUnresolved=Token.isUnresolved(possibleToken1),secondIsUnresolved=Token.isUnresolved(possibleToken2);return firstIsUnresolved&&secondIsUnresolved?TokenComparison.BOTH_UNRESOLVED:firstIsUnresolved||secondIsUnresolved?TokenComparison.ONE_UNRESOLVED:possibleToken1===possibleToken2?TokenComparison.SAME:TokenComparison.DIFFERENT}}exports.Token=Token,_b=JSII_RTTI_SYMBOL_1,Token[_b]={fqn:"aws-cdk-lib.Token",version:"2.13.0"};class Tokenization{constructor(){}static reverseString(s){return token_map_1.TokenMap.instance().splitString(s)}static reverseCompleteString(s){const fragments=Tokenization.reverseString(s);if(fragments.length!==1)throw new Error(`Tokenzation.reverseCompleteString: argument must not be a concatentation, got '${s}'`);return fragments.firstToken}static reverseNumber(n){return token_map_1.TokenMap.instance().lookupNumberToken(n)}static reverseList(l){return token_map_1.TokenMap.instance().lookupList(l)}static reverse(x,options={}){if(jsiiDeprecationWarnings.aws_cdk_lib_ReverseOptions(options),Tokenization.isResolvable(x))return x;if(typeof x=="string"){if(options.failConcat===!1){const fragments=Tokenization.reverseString(x);return fragments.length===1?fragments.firstToken:void 0}return Tokenization.reverseCompleteString(x)}if(Array.isArray(x))return Tokenization.reverseList(x);if(typeof x=="number")return Tokenization.reverseNumber(x)}static resolve(obj,options){var _d;return jsiiDeprecationWarnings.aws_cdk_lib_ResolveOptions(options),resolve_1.resolve(obj,{scope:options.scope,resolver:options.resolver,preparing:(_d=options.preparing)!==null&&_d!==void 0?_d:!1,removeEmpty:options.removeEmpty})}static isResolvable(obj){return isResolvableObject(obj)}static stringifyNumber(x){return Token.isUnresolved(x)?lazy_1.Lazy.uncachedString({produce:context=>{const resolved=context.resolve(x);return typeof resolved!="number"?resolved:`${resolved}`}}):typeof x!="number"?x:`${x}`}}exports.Tokenization=Tokenization,_c=JSII_RTTI_SYMBOL_1,Tokenization[_c]={fqn:"aws-cdk-lib.Tokenization",version:"2.13.0"};function isResolvableObject(x){return typeof x=="object"&&x!==null&&typeof x.resolve=="function"}exports.isResolvableObject=isResolvableObject;function withResolved(...args){if(args.length<2)return;const argArray=args.slice(0,args.length-1);argArray.some(Token.isUnresolved)||args[args.length-1].apply(arguments,argArray)}exports.withResolved=withResolved;
//# sourceMappingURL=token.js.map
