"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BucketBlockPublicAccess=exports.BucketVersioning=exports.BucketAutoDeleteObjects=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var iam=()=>{var tmp=require("../../../aws-iam");return iam=()=>tmp,tmp},core_1=()=>{var tmp=require("../../../core");return core_1=()=>tmp,tmp},helpers_internal_1=()=>{var tmp=require("../../../core/lib/helpers-internal");return helpers_internal_1=()=>tmp,tmp},mixins_1=()=>{var tmp=require("../../../core/lib/mixins");return mixins_1=()=>tmp,tmp},auto_delete_objects_provider_generated_1=()=>{var tmp=require("../../../custom-resource-handlers/dist/aws-s3/auto-delete-objects-provider.generated");return auto_delete_objects_provider_generated_1=()=>tmp,tmp},bucket_1=()=>{var tmp=require("../bucket");return bucket_1=()=>tmp,tmp},perms=()=>{var tmp=require("../perms");return perms=()=>tmp,tmp},s3_generated_1=()=>{var tmp=require("../s3.generated");return s3_generated_1=()=>tmp,tmp};class BucketAutoDeleteObjects extends mixins_1().Mixin{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_s3.mixins.BucketAutoDeleteObjects",version:"2.256.1"};static AUTO_DELETE_OBJECTS_RESOURCE_TYPE="Custom::S3AutoDeleteObjects";static AUTO_DELETE_OBJECTS_TAG="aws-cdk:auto-delete-objects";supports(construct){return s3_generated_1().CfnBucket.isCfnBucket(construct)}applyTo(construct){if(!this.supports(construct))return;construct.node.addValidation({validate:()=>{const errors=new Array;return construct.cfnOptions.deletionPolicy!==core_1().CfnDeletionPolicy.DELETE&&errors.push("Cannot use 'AutoDeleteObjects' on a Bucket without setting removal policy to 'DESTROY'."),errors}});const bucketRef=construct.bucketRef,scope=helpers_internal_1().ConstructReflection.of(construct).defaultChildOwner??construct,provider=auto_delete_objects_provider_generated_1().AutoDeleteObjectsProvider.getOrCreateProvider(scope,BucketAutoDeleteObjects.AUTO_DELETE_OBJECTS_RESOURCE_TYPE,{useCfnResponseWrapper:!1,description:`Lambda function for auto-deleting objects in ${bucketRef.bucketName} S3 bucket.`}),policyResult=iam().ResourceWithPolicies.of(construct)?.addToResourcePolicy(new(iam()).PolicyStatement({actions:[...perms().BUCKET_PUT_POLICY_ACTIONS,...perms().BUCKET_READ_METADATA_ACTIONS,...perms().BUCKET_DELETE_ACTIONS],resources:[bucketRef.bucketArn,perms().arnForObjects(bucketRef.bucketArn,"*")],principals:[new(iam()).ArnPrincipal(provider.roleArn)]})),customResource=new(core_1()).CustomResource(scope,"AutoDeleteObjectsCustomResource",{resourceType:BucketAutoDeleteObjects.AUTO_DELETE_OBJECTS_RESOURCE_TYPE,serviceToken:provider.serviceToken,properties:{BucketName:bucketRef.bucketName}});policyResult?.policyDependable&&customResource.node.addDependency(policyResult.policyDependable),core_1().Tags.of(construct).add(BucketAutoDeleteObjects.AUTO_DELETE_OBJECTS_TAG,"true")}}exports.BucketAutoDeleteObjects=BucketAutoDeleteObjects;class BucketVersioning extends mixins_1().Mixin{enabled;static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_s3.mixins.BucketVersioning",version:"2.256.1"};constructor(enabled=!0){super(),this.enabled=enabled}supports(construct){return s3_generated_1().CfnBucket.isCfnBucket(construct)}applyTo(construct){this.supports(construct)&&(construct.versioningConfiguration={status:this.enabled?"Enabled":"Suspended"})}}exports.BucketVersioning=BucketVersioning;class BucketBlockPublicAccess extends mixins_1().Mixin{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_s3.mixins.BucketBlockPublicAccess",version:"2.256.1"};configOptions;constructor(publicAccessConfig=bucket_1().BlockPublicAccess.BLOCK_ALL){super();try{jsiiDeprecationWarnings().aws_cdk_lib_aws_s3_BlockPublicAccess(publicAccessConfig)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,BucketBlockPublicAccess),error}this.configOptions={blockPublicAcls:publicAccessConfig.blockPublicAcls,blockPublicPolicy:publicAccessConfig.blockPublicPolicy,ignorePublicAcls:publicAccessConfig.ignorePublicAcls,restrictPublicBuckets:publicAccessConfig.restrictPublicBuckets}}supports(construct){return s3_generated_1().CfnBucket.isCfnBucket(construct)}applyTo(construct){this.supports(construct)&&(construct.publicAccessBlockConfiguration={blockPublicAcls:this.configOptions.blockPublicAcls??!0,blockPublicPolicy:this.configOptions.blockPublicPolicy??!0,ignorePublicAcls:this.configOptions.ignorePublicAcls??!0,restrictPublicBuckets:this.configOptions.restrictPublicBuckets??!0})}}exports.BucketBlockPublicAccess=BucketBlockPublicAccess;
