

const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.js');
const require_jwa = require('../jwk/jwa.js');
const require_octJwk = require('../jwk/kty/oct/octJwk.js');
const require_common = require('./common.js');
const require_KmsKeyAgreementDecryptOptions = require('./KmsKeyAgreementDecryptOptions.js');
let zod = require("zod");
zod = require_rolldown_runtime.__toESM(zod);

//#region src/modules/kms/options/KmsDecryptOptions.ts
const zKmsDecryptDataDecryptionAesGcm = zod.z.object({
	algorithm: zod.z.enum([
		require_jwa.KnownJwaContentEncryptionAlgorithms.A128GCM,
		require_jwa.KnownJwaContentEncryptionAlgorithms.A192GCM,
		require_jwa.KnownJwaContentEncryptionAlgorithms.A256GCM
	]),
	iv: zod.z.instanceof(Uint8Array).refine((iv) => iv.length === 12, "iv must be 12 bytes for AES GCM"),
	aad: zod.z.optional(zod.z.instanceof(Uint8Array)),
	tag: zod.z.instanceof(Uint8Array)
});
const zKmsDecryptDataDecryptionAesCbc = zod.z.object({
	algorithm: zod.z.enum([require_jwa.KnownJwaContentEncryptionAlgorithms.A128CBC, require_jwa.KnownJwaContentEncryptionAlgorithms.A256CBC]),
	iv: zod.z.instanceof(Uint8Array).refine((iv) => iv.length === 16, "iv must be 16 bytes for AES CBC")
});
const zKmsDecryptDataDecryptionAesCbcHmac = zod.z.object({
	algorithm: zod.z.enum([
		require_jwa.KnownJwaContentEncryptionAlgorithms.A128CBC_HS256,
		require_jwa.KnownJwaContentEncryptionAlgorithms.A192CBC_HS384,
		require_jwa.KnownJwaContentEncryptionAlgorithms.A256CBC_HS512
	]),
	iv: zod.z.instanceof(Uint8Array).refine((iv) => iv.length === 16, "iv must be 16 bytes for AES CBC with HMAC"),
	aad: zod.z.optional(zod.z.instanceof(Uint8Array)),
	tag: zod.z.instanceof(Uint8Array)
});
const zKmsDecryptDataDecryptionSalsa = zod.z.object({
	algorithm: zod.z.enum([require_jwa.KnownJwaContentEncryptionAlgorithms["XSALSA20-POLY1305"]]),
	iv: zod.z.instanceof(Uint8Array).optional()
});
const zKmsDecryptDataDecryptionC20p = zod.z.object({
	algorithm: zod.z.enum([require_jwa.KnownJwaContentEncryptionAlgorithms.C20P, require_jwa.KnownJwaContentEncryptionAlgorithms.XC20P]),
	iv: zod.z.instanceof(Uint8Array),
	aad: zod.z.optional(zod.z.instanceof(Uint8Array)),
	tag: zod.z.instanceof(Uint8Array)
});
const zKmsDecryptDataDecryption = zod.z.discriminatedUnion("algorithm", [
	zKmsDecryptDataDecryptionAesCbc,
	zKmsDecryptDataDecryptionAesCbcHmac,
	zKmsDecryptDataDecryptionAesGcm,
	zKmsDecryptDataDecryptionC20p,
	zKmsDecryptDataDecryptionSalsa
]);
const zKmsDecryptOptions = zod.z.object({
	key: zod.z.union([
		zod.z.object({
			keyId: require_common.zKmsKeyId,
			privateJwk: zod.z.never().optional(),
			keyAgreement: zod.z.never().optional()
		}),
		zod.z.object({
			privateJwk: require_octJwk.zKmsJwkPrivateOct.describe("A private oct (symmetric) jwk"),
			keyId: zod.z.never().optional(),
			keyAgreement: zod.z.never().optional()
		}),
		zod.z.object({
			keyAgreement: require_KmsKeyAgreementDecryptOptions.zKmsKeyAgreementDecryptOptions,
			keyId: zod.z.never().optional(),
			privateJwk: zod.z.never().optional()
		})
	]),
	decryption: zKmsDecryptDataDecryption.describe("Options related to the decryption algorithm to use for decrypting the data"),
	encrypted: zod.z.instanceof(Uint8Array).describe("The encrypted data to decrypt")
});

//#endregion
exports.zKmsDecryptOptions = zKmsDecryptOptions;