import type { Selection } from '../Selection' ; export type List < T > = Set < T > | Array < T > ; export function toSetIfNeeded < T > ( list ) { return Array . isArray ( list ) ? new Set ( list ) : list ; } export function isSelectionIncluded ( selection , selectionList ) { const setSelectionList = toSetIfNeeded ( selectionList ) ; if ( setSelectionList . has ( selection ) ) return true ; for ( const listValue of selectionList ) { if ( setSelectionList . has ( listValue ) ) return true ; } return false ; } export function isAnySelectionIncluded ( selectionsToCheck , selectionsList ) { const setSelectionList = toSetIfNeeded ( selectionsList ) ; for ( const selection of selectionsToCheck ) { if ( isSelectionIncluded ( selection , setSelectionList ) ) return true ; } return false ; } export function isAnySelectionIncludedInMatrix ( selectionsToCheck , selectionsMatrix ) { const selectionsToCheckSet = toSetIfNeeded ( selectionsToCheck ) ; for ( const group of selectionsMatrix ) { if ( isAnySelectionIncluded ( selectionsToCheckSet , group ) ) return true ; } return false ; }