"use strict";var _a,_b;Object.defineProperty(exports,"__esModule",{value:!0}),exports.CodePipelineFileSet=exports.ArtifactMap=void 0;const jsiiDeprecationWarnings=require("../../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),crypto=require("crypto"),cp=require("../../../aws-codepipeline"),blueprint_1=require("../blueprint"),helpers_internal_1=require("../helpers-internal");class ArtifactMap{constructor(){this.artifacts=new Map,this.usedNames=new Set}toCodePipeline(x){if(jsiiDeprecationWarnings.aws_cdk_lib_pipelines_FileSet(x),x instanceof CodePipelineFileSet)return x._artifact;let ret=this.artifacts.get(x);if(!ret){const artifactName=this.makeUniqueName(`${x.producer.id}.${x.id}`);this.usedNames.add(artifactName),this.artifacts.set(x,ret=new cp.Artifact(artifactName))}return ret}makeUniqueName(baseName){let i=1;baseName=sanitizeArtifactName(baseName);let name=baseName;for(;this.usedNames.has(name);)name=`${baseName}${++i}`;return name}}exports.ArtifactMap=ArtifactMap,_a=JSII_RTTI_SYMBOL_1,ArtifactMap[_a]={fqn:"aws-cdk-lib.pipelines.ArtifactMap",version:"2.13.0"};function sanitizeArtifactName(x){let sani=x.replace(/[^A-Za-z0-9_]/g,"_");const maxLength=100;if(sani.length>maxLength){const fingerprint=crypto.createHash("sha256").update(sani).digest("hex").substr(0,8);sani=sani.substr(0,maxLength-fingerprint.length)+fingerprint}return sani}class CodePipelineFileSet extends blueprint_1.FileSet{constructor(artifact){var _c;super((_c=artifact.artifactName)!==null&&_c!==void 0?_c:"Imported",helpers_internal_1.PipelineGraph.NO_STEP);this._artifact=artifact}static fromArtifact(artifact){return jsiiDeprecationWarnings.aws_cdk_lib_aws_codepipeline_Artifact(artifact),new CodePipelineFileSet(artifact)}}exports.CodePipelineFileSet=CodePipelineFileSet,_b=JSII_RTTI_SYMBOL_1,CodePipelineFileSet[_b]={fqn:"aws-cdk-lib.pipelines.CodePipelineFileSet",version:"2.13.0"};
//# sourceMappingURL=artifact-map.js.map
