/*
 * Copyright (c) 2018, 2025, Oracle and/or its affiliates.
 * Licensed under The Universal Permissive License (UPL), Version 1.0
 * as shown at https://oss.oracle.com/licenses/upl/
 */
const standardRemappings=[{oldType:"Object",newType:"object"},{oldType:"Void",newType:"void"},{oldType:"String",newType:"string"},{oldType:"Number",newType:"number"},{oldType:"Boolean",newType:"boolean"}];function applyCustomMappings(overrideMappings){let allMappings=[...standardRemappings];if(overrideMappings){for(const[key,value]of Object.entries(overrideMappings)){if(value&&value.length>0){if(Array.isArray(value)){const addMappings=value.map(newTarget=>{return{oldType:key,newType:newTarget}});allMappings=allMappings.concat(addMappings)}else if(typeof value==="string"){allMappings.push({oldType:key,newType:value})}}}}return allMappings}function fuzzyTypeMatch(oldType,newType,fuzzyMappings){let match=false;if(oldType==newType){match=true}else{let alternatives=fuzzyMappings.filter(fm=>{return fm.oldType===oldType&&fm.newType===newType});match=alternatives.length>0}return match}function generateFuzzyHistorical(oldTypeArray,fuzzyMappings){const expandedOldTypes=[...oldTypeArray];oldTypeArray.forEach(historicalType=>{const foundFuzzyMatches=fuzzyMappings.filter(ft=>ft.oldType===historicalType);foundFuzzyMatches.forEach(match=>{expandedOldTypes.push(match.newType)})});return expandedOldTypes}function generateFuzzyCurrent(newTypeArray,fuzzyMappings){const expandedNewTypes=[...newTypeArray];newTypeArray.forEach(newType=>{const foundFuzzyMatches=fuzzyMappings.filter(ft=>ft.newType===newType);foundFuzzyMatches.forEach(match=>{expandedNewTypes.push(match.oldType)})});return expandedNewTypes}module.exports={applyCustomMappings,fuzzyTypeMatch,generateFuzzyHistorical,generateFuzzyCurrent};