

const require_ClaimFormat = require('../../vc/models/ClaimFormat.js');
require('../../vc/index.js');
require('../../mdoc/index.js');
require('../../sd-jwt-vc/index.js');

//#region src/modules/dcql/utils/DcqlPresentationsToCreate.ts
function dcqlGetPresentationsToCreate(credentialsForInputDescriptor) {
	const presentationsToCreate = {};
	for (const [credentialQueryId, matches] of Object.entries(credentialsForInputDescriptor)) for (const match of matches) {
		let presentationToCreate;
		switch (match.claimFormat) {
			case require_ClaimFormat.ClaimFormat.SdJwtDc:
				presentationToCreate = {
					claimFormat: require_ClaimFormat.ClaimFormat.SdJwtDc,
					subjectIds: [],
					credentialRecord: match.credentialRecord,
					disclosedPayload: match.disclosedPayload,
					additionalPayload: match.additionalPayload
				};
				break;
			case require_ClaimFormat.ClaimFormat.MsoMdoc:
				presentationToCreate = {
					claimFormat: require_ClaimFormat.ClaimFormat.MsoMdoc,
					subjectIds: [],
					credentialRecord: match.credentialRecord,
					disclosedPayload: match.disclosedPayload
				};
				break;
			case require_ClaimFormat.ClaimFormat.JwtW3cVc:
			case require_ClaimFormat.ClaimFormat.SdJwtW3cVc:
				presentationToCreate = {
					claimFormat: match.claimFormat === require_ClaimFormat.ClaimFormat.JwtW3cVc ? require_ClaimFormat.ClaimFormat.JwtW3cVp : require_ClaimFormat.ClaimFormat.SdJwtW3cVp,
					subjectIds: [],
					credentialRecord: match.credentialRecord,
					disclosedPayload: match.disclosedPayload
				};
				break;
			default:
				presentationToCreate = {
					claimFormat: match.claimFormat === require_ClaimFormat.ClaimFormat.LdpVc ? require_ClaimFormat.ClaimFormat.LdpVp : require_ClaimFormat.ClaimFormat.JwtVp,
					subjectIds: [match.credentialRecord.credential.credentialSubjectIds[0]],
					credentialRecord: match.credentialRecord,
					disclosedPayload: match.disclosedPayload
				};
				break;
		}
		if (!presentationsToCreate[credentialQueryId]) presentationsToCreate[credentialQueryId] = [presentationToCreate];
		else presentationsToCreate[credentialQueryId].push(presentationToCreate);
	}
	return presentationsToCreate;
}

//#endregion
exports.dcqlGetPresentationsToCreate = dcqlGetPresentationsToCreate;