"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.CrossAccountDestination=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var logs_generated_1=()=>{var tmp=require("./logs.generated");return logs_generated_1=()=>tmp,tmp},iam=()=>{var tmp=require("../../aws-iam");return iam=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp},cdk=()=>{var tmp=require("../../core");return cdk=()=>tmp,tmp};class CrossAccountDestination extends cdk().Resource{constructor(scope,id,props){super(scope,id,{physicalName:props.destinationName||cdk().Lazy.string({produce:()=>this.generateUniqueName()})}),this.policyDocument=new(iam()).PolicyDocument;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_logs_CrossAccountDestinationProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,CrossAccountDestination),error}this.resource=new(logs_generated_1()).CfnDestination(this,"Resource",{destinationName:this.physicalName,destinationPolicy:this.lazyStringifiedPolicyDocument(),roleArn:props.role.roleArn,targetArn:props.targetArn}),this.destinationArn=this.getResourceArnAttribute(this.resource.attrArn,{service:"logs",resource:"destination",resourceName:this.physicalName,arnFormat:core_1().ArnFormat.COLON_RESOURCE_NAME}),this.destinationName=this.getResourceNameAttribute(this.resource.ref)}addToPolicy(statement){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_iam_PolicyStatement(statement)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addToPolicy),error}this.policyDocument.addStatements(statement)}bind(_scope,_sourceLogGroup){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_logs_ILogGroup(_sourceLogGroup)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}return{arn:this.destinationArn}}generateUniqueName(){return cdk().Stack.of(this).stackName+"-"+this.resource.logicalId}lazyStringifiedPolicyDocument(){return cdk().Lazy.string({produce:()=>this.policyDocument.isEmpty?"":cdk().Stack.of(this).toJsonString(this.policyDocument)})}}exports.CrossAccountDestination=CrossAccountDestination,_a=JSII_RTTI_SYMBOL_1,CrossAccountDestination[_a]={fqn:"aws-cdk-lib.aws_logs.CrossAccountDestination",version:"2.159.0"};
