license import { DetectableImage } from '../../defs/detected-image.js' ; import { flat } from '../utils/flat.js' ; import { ArtifactStore , PerceptionResult , PerceptionState } from './stores/artifact-store.js' ; export interface ProbableTargets { detectableImages : DetectableImage [ ] ; } export class ArtifactDealer { private readonly artstores : ArtifactStore [ ] = [ ] ; async addArtifactStore ( artstore ) { this . artstores . push ( artstore ) ; } async predictPerceptionTargets ( request ) { const allStoreResults = await Promise . all ( this . artstores . map ( ( artstore ) => { if ( ! artstore . getDetectableImages ) { return [ ] ; } return artstore . getDetectableImages ( request ) ; } ) ) ; return { detectableImages : flat ( allStoreResults ) } ; } async getPerceptionResults ( context ) { context = { markers : [ ] , geo : [ ] , images : [ ] , ... context } ; const allStoreResults = await Promise . all ( this . artstores . map ( ( artstore ) => { if ( ! artstore . findRelevantArtifacts ) { return [ ] ; } return artstore . findRelevantArtifacts ( context ) ; } ) ) ; return flat ( allStoreResults ) ; } }