"use strict";
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.StreamCopilotAnnotations = void 0;
class StreamCopilotAnnotations {
    constructor() {
        this.current = {};
    }
    update(annotations) {
        Object.entries(annotations).forEach(([namespace, annotations]) => {
            annotations.forEach(a => this.update_namespace(namespace, a));
        });
    }
    update_namespace(namespace, annotation) {
        if (!this.current[namespace]) {
            this.current[namespace] = [];
        }
        const annotationToUpdate = this.current[namespace];
        const index = annotationToUpdate.findIndex(a => a.id === annotation.id);
        if (index >= 0) {
            annotationToUpdate[index] = annotation;
        }
        else {
            annotationToUpdate.push(annotation);
        }
    }
    for(namespace) {
        return this.current[namespace] ?? [];
    }
}
exports.StreamCopilotAnnotations = StreamCopilotAnnotations;
//# sourceMappingURL=copilotAnnotations.js.map