"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.DomainName=exports.SecurityPolicy=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),core_1=require("../../core"),apigateway_generated_1=require("./apigateway.generated"),base_path_mapping_1=require("./base-path-mapping"),restapi_1=require("./restapi");var SecurityPolicy;(function(SecurityPolicy2){SecurityPolicy2.TLS_1_0="TLS_1_0",SecurityPolicy2.TLS_1_2="TLS_1_2"})(SecurityPolicy=exports.SecurityPolicy||(exports.SecurityPolicy={}));class DomainName extends core_1.Resource{constructor(scope,id,props){super(scope,id);this.basePaths=new Set,jsiiDeprecationWarnings.aws_cdk_lib_aws_apigateway_DomainNameProps(props);const endpointType=props.endpointType||restapi_1.EndpointType.REGIONAL,edge=endpointType===restapi_1.EndpointType.EDGE;if(!core_1.Token.isUnresolved(props.domainName)&&/[A-Z]/.test(props.domainName))throw new Error(`Domain name does not support uppercase letters. Got: ${props.domainName}`);const mtlsConfig=this.configureMTLS(props.mtls),resource=new apigateway_generated_1.CfnDomainName(this,"Resource",{domainName:props.domainName,certificateArn:edge?props.certificate.certificateArn:void 0,regionalCertificateArn:edge?void 0:props.certificate.certificateArn,endpointConfiguration:{types:[endpointType]},mutualTlsAuthentication:mtlsConfig,securityPolicy:props.securityPolicy});this.domainName=resource.ref,this.domainNameAliasDomainName=edge?resource.attrDistributionDomainName:resource.attrRegionalDomainName,this.domainNameAliasHostedZoneId=edge?resource.attrDistributionHostedZoneId:resource.attrRegionalHostedZoneId,props.mapping&&this.addBasePathMapping(props.mapping,{basePath:props.basePath})}static fromDomainNameAttributes(scope,id,attrs){jsiiDeprecationWarnings.aws_cdk_lib_aws_apigateway_DomainNameAttributes(attrs);class Import extends core_1.Resource{constructor(){super(...arguments);this.domainName=attrs.domainName,this.domainNameAliasDomainName=attrs.domainNameAliasTarget,this.domainNameAliasHostedZoneId=attrs.domainNameAliasHostedZoneId}}return new Import(scope,id)}addBasePathMapping(targetApi,options={}){if(jsiiDeprecationWarnings.aws_cdk_lib_aws_apigateway_IRestApi(targetApi),jsiiDeprecationWarnings.aws_cdk_lib_aws_apigateway_BasePathMappingOptions(options),this.basePaths.has(void 0))throw new Error("This domain name already has an empty base path. No additional base paths are allowed.");this.basePaths.add(options.basePath);const id=`Map:${options.basePath||"/"}=>${core_1.Names.nodeUniqueId(targetApi.node)}`;return new base_path_mapping_1.BasePathMapping(this,id,{domainName:this,restApi:targetApi,...options})}configureMTLS(mtlsConfig){if(!!mtlsConfig)return{truststoreUri:mtlsConfig.bucket.s3UrlForObject(mtlsConfig.key),truststoreVersion:mtlsConfig.version}}}exports.DomainName=DomainName,_a=JSII_RTTI_SYMBOL_1,DomainName[_a]={fqn:"aws-cdk-lib.aws_apigateway.DomainName",version:"2.13.0"};
//# sourceMappingURL=domain-name.js.map
