/*
 * Copyright (c) 2018, 2026, 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 CaccHelpers=require("./jetwco-cacc-helpers");function controlCallback(controlRuleName,controlRuleDef,semver,cacheManager,metadata,compareMetadata,componentVersionDiff,baselines,componentType,componentName,errorMsgContext,overrideTypeMappings){if(componentType==="composite"){let errorConditions=[];const{add:addConstraint,remove:removeConstraint,mutate:mutateConstraint}=controlRuleDef;const removeControlMetadata=CaccHelpers.deriveConstraintMetadata(baselines,removeConstraint);if(metadata.hasOwnProperty("styleClasses")||compareMetadata.hasOwnProperty("styleClasses")){const styleClasses=CaccHelpers.flattenArrayByAttr(metadata.styleClasses,"name");const historicalStyleClasses=CaccHelpers.flattenArrayByAttr(compareMetadata.styleClasses,"name");const diffs=CaccHelpers.stringArrayDiff(styleClasses,historicalStyleClasses);if(CaccHelpers.checkConstraintPatchMajor(diffs.add,addConstraint,componentVersionDiff)){errorConditions.push(`Style class(es) ${diffs.add.join(", ")} added to${errorMsgContext}'${addConstraint}'`)}const removeErrors=CaccHelpers.checkConstraintMajorWithDeprecation(diffs.remove,removeConstraint,componentVersionDiff,cacheManager,componentName,removeControlMetadata,diff=>{return["styleClasses",`[name:${diff}]`]});if(removeErrors.length>0){errorConditions.push(`Class(es) ${removeErrors.join(", ")} removed from styleClasses of${errorMsgContext}'${removeConstraint}'`)}}if(errorConditions.length>0){return errorConditions.join("\n")}}return};module.exports=controlCallback;