"use strict";var _a,_b;Object.defineProperty(exports,"__esModule",{value:!0}),exports.VirtualServiceProvider=exports.VirtualService=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),appmesh_generated_1=require("./appmesh.generated"),mesh_1=require("./mesh"),utils_1=require("./private/utils"),cdk=require("../../core");class VirtualService extends cdk.Resource{static fromVirtualServiceArn(scope,id,virtualServiceArn){return new class extends cdk.Resource{constructor(){super(...arguments),this.virtualServiceArn=virtualServiceArn,this.parsedArn=cdk.Fn.split("/",cdk.Stack.of(scope).splitArn(virtualServiceArn,cdk.ArnFormat.SLASH_RESOURCE_NAME).resourceName),this.virtualServiceName=cdk.Fn.select(2,this.parsedArn),this.mesh=mesh_1.Mesh.fromMeshName(this,"Mesh",cdk.Fn.select(0,this.parsedArn))}}(scope,id)}static fromVirtualServiceAttributes(scope,id,attrs){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_appmesh_VirtualServiceAttributes(attrs)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromVirtualServiceAttributes),error}return new class extends cdk.Resource{constructor(){super(...arguments),this.virtualServiceName=attrs.virtualServiceName,this.mesh=attrs.mesh,this.virtualServiceArn=cdk.Stack.of(this).formatArn({service:"appmesh",resource:`mesh/${attrs.mesh.meshName}/virtualService`,resourceName:this.virtualServiceName})}}(scope,id)}constructor(scope,id,props){super(scope,id,{physicalName:props.virtualServiceName||cdk.Lazy.string({produce:()=>cdk.Names.uniqueId(this)})});try{jsiiDeprecationWarnings.aws_cdk_lib_aws_appmesh_VirtualServiceProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,VirtualService),error}const providerConfig=props.virtualServiceProvider.bind(this);this.mesh=providerConfig.mesh;const svc=new appmesh_generated_1.CfnVirtualService(this,"Resource",{meshName:this.mesh.meshName,meshOwner:(0,utils_1.renderMeshOwner)(this.env.account,this.mesh.env.account),virtualServiceName:this.physicalName,spec:{provider:providerConfig.virtualNodeProvider||providerConfig.virtualRouterProvider?{virtualNode:providerConfig.virtualNodeProvider,virtualRouter:providerConfig.virtualRouterProvider}:void 0}});this.virtualServiceName=this.getResourceNameAttribute(svc.attrVirtualServiceName),this.virtualServiceArn=this.getResourceArnAttribute(svc.ref,{service:"appmesh",resource:`mesh/${this.mesh.meshName}/virtualService`,resourceName:this.physicalName})}}exports.VirtualService=VirtualService,_a=JSII_RTTI_SYMBOL_1,VirtualService[_a]={fqn:"aws-cdk-lib.aws_appmesh.VirtualService",version:"2.96.1"};class VirtualServiceProvider{static virtualNode(virtualNode){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_appmesh_IVirtualNode(virtualNode)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.virtualNode),error}return new VirtualServiceProviderImpl(virtualNode,void 0)}static virtualRouter(virtualRouter){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_appmesh_IVirtualRouter(virtualRouter)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.virtualRouter),error}return new VirtualServiceProviderImpl(void 0,virtualRouter)}static none(mesh){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_appmesh_IMesh(mesh)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.none),error}return new VirtualServiceProviderImpl(void 0,void 0,mesh)}}exports.VirtualServiceProvider=VirtualServiceProvider,_b=JSII_RTTI_SYMBOL_1,VirtualServiceProvider[_b]={fqn:"aws-cdk-lib.aws_appmesh.VirtualServiceProvider",version:"2.96.1"};class VirtualServiceProviderImpl extends VirtualServiceProvider{constructor(virtualNode,virtualRouter,mesh){super(),this.virtualNode=virtualNode,this.virtualRouter=virtualRouter;const providedMesh=this.virtualNode?.mesh??this.virtualRouter?.mesh??mesh;this.mesh=providedMesh}bind(_construct){return{mesh:this.mesh,virtualNodeProvider:this.virtualNode?{virtualNodeName:this.virtualNode.virtualNodeName}:void 0,virtualRouterProvider:this.virtualRouter?{virtualRouterName:this.virtualRouter.virtualRouterName}:void 0}}}
