/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
import { Disposable } from '../../../../base/common/lifecycle.js';
import { derivedWithStore, observableFromEvent, observableValue } from '../../../../base/common/observable.js';
export class MultiDiffEditorViewModel extends Disposable {
    constructor(_model, _diffEditorViewModelFactory) {
        super();
        this._model = _model;
        this._diffEditorViewModelFactory = _diffEditorViewModelFactory;
        this._documents = observableFromEvent(this._model.onDidChange, /** @description MultiDiffEditorViewModel.documents */ () => this._model.documents);
        this.items = derivedWithStore(this, (reader, store) => this._documents.read(reader).map(d => store.add(new DocumentDiffItemViewModel(d, this._diffEditorViewModelFactory)))).recomputeInitiallyAndOnChange(this._store);
        this.activeDiffItem = observableValue(this, undefined);
    }
}
export class DocumentDiffItemViewModel extends Disposable {
    constructor(entry, diffEditorViewModelFactory) {
        super();
        this.entry = entry;
        this.diffEditorViewModel = this._register(diffEditorViewModelFactory.createViewModel({
            original: entry.value.original,
            modified: entry.value.modified,
        }));
    }
}
