import "../../../CodeInput-C-igR77V.js";
import "../../../DataTableInput-yaU5g-kP.js";
import "../../../SectionFilter-hrtoRLwj.js";
import { t as RequestSection_default } from "../../../RequestSection-HhdJj9hW.js";
import "../../../RequestAuth-BzBfIysT.js";
//#region src/views/Request/RequestSection/helpers/filter-security-requirements.ts
/**
* Takes in selected security and filters it with the requirements
*/
var filterSecurityRequirements = (securityRequirements, selectedSecuritySchemeUids = [], securitySchemes = {}) => {
	if (!securityRequirements || securityRequirements.length === 0) return [];
	const nonOptionalRequirements = securityRequirements.filter((requirement) => Object.keys(requirement).length > 0);
	if (nonOptionalRequirements.length === 0) return [];
	if (selectedSecuritySchemeUids.length === 0) {
		const firstRequirement = nonOptionalRequirements[0];
		const firstSchemeNameKey = firstRequirement ? Object.keys(firstRequirement)[0] : void 0;
		const matchingScheme = Object.values(securitySchemes).find((scheme) => scheme.nameKey === firstSchemeNameKey);
		return matchingScheme ? [matchingScheme] : [];
	}
	const requiredCombinations = new Set(nonOptionalRequirements.map((requirement) => Object.keys(requirement).sort().join(",")));
	const result = [];
	for (const uids of selectedSecuritySchemeUids) {
		const schemeUids = Array.isArray(uids) ? uids : [uids];
		const validSchemes = [];
		const nameKeys = [];
		for (const uid of schemeUids) {
			const scheme = securitySchemes[uid];
			if (scheme?.nameKey) {
				validSchemes.push(scheme);
				nameKeys.push(scheme.nameKey);
			}
		}
		if (nameKeys.length > 0) {
			const key = nameKeys.sort().join(",");
			if (requiredCombinations.has(key)) result.push(...validSchemes);
		}
	}
	return result;
};
//#endregion
export { RequestSection_default as RequestSection, filterSecurityRequirements };

//# sourceMappingURL=index.js.map