import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
import { localizeWithPath } from '../../../../nls.js';
import { basename } from '../../../../base/common/path.js';
import { Disposable } from '../../../../base/common/lifecycle.js';
import { registerEditorContribution, EditorContributionInstantiation } from '../../../../editor/browser/editorExtensions.js';
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.service.js';
import '../../../../platform/notification/common/notification.js';
import { INotificationService } from '../../../../platform/notification/common/notification.service.js';
import Severity$1 from '../../../../base/common/severity.js';
const _moduleId = "vs/workbench/contrib/codeEditor/browser/largeFileOptimizations";
let LargeFileOptimizationsWarner = class LargeFileOptimizationsWarner extends Disposable {
    static { this.ID = 'editor.contrib.largeFileOptimizationsWarner'; }
    constructor(_editor, _notificationService, _configurationService) {
        super();
        this._editor = _editor;
        this._notificationService = _notificationService;
        this._configurationService = _configurationService;
        this._register(this._editor.onDidChangeModel((e) => this._update()));
        this._update();
    }
    _update() {
        const model = this._editor.getModel();
        if (!model) {
            return;
        }
        if (model.isTooLargeForTokenization()) {
            const message = ( localizeWithPath(
                _moduleId,
                0,
                "{0}: tokenization, wrapping, folding, codelens, word highlighting and sticky scroll have been turned off for this large file in order to reduce memory usage and avoid freezing or crashing.",
                basename(model.uri.path)
            ));
            this._notificationService.prompt(Severity$1.Info, message, [
                {
                    label: ( localizeWithPath(_moduleId, 1, "Forcefully Enable Features")),
                    run: () => {
                        this._configurationService.updateValue(`editor.largeFileOptimizations`, false).then(() => {
                            this._notificationService.info(( localizeWithPath(
                                _moduleId,
                                2,
                                "Please reopen file in order for this setting to take effect."
                            )));
                        }, (err) => {
                            this._notificationService.error(err);
                        });
                    }
                }
            ], { neverShowAgain: { id: 'editor.contrib.largeFileOptimizationsWarner' } });
        }
    }
};
LargeFileOptimizationsWarner = ( (__decorate([
    ( (__param(1, INotificationService))),
    ( (__param(2, IConfigurationService)))
], LargeFileOptimizationsWarner)));
registerEditorContribution(LargeFileOptimizationsWarner.ID, LargeFileOptimizationsWarner, EditorContributionInstantiation.AfterFirstRender);
export { LargeFileOptimizationsWarner };
