
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
import { Disposable, MutableDisposable } from '../../../../base/common/lifecycle.js';
import { localize } from '../../../../nls.js';
import { IMeteredConnectionService } from '../../../../platform/meteredConnection/common/meteredConnection.service.js';
import { StatusbarAlignment } from '../../../services/statusbar/browser/statusbar.js';
import { IStatusbarService } from '../../../services/statusbar/browser/statusbar.service.js';

var MeteredConnectionStatusContribution_1;
let MeteredConnectionStatusContribution = class MeteredConnectionStatusContribution extends Disposable {
    static {
        MeteredConnectionStatusContribution_1 = this;
    }
    static {
        this.ID = "workbench.contrib.meteredConnectionStatus";
    }
    constructor(meteredConnectionService, statusbarService) {
        super();
        this.meteredConnectionService = meteredConnectionService;
        this.statusbarService = statusbarService;
        this.statusBarEntry = this._register(( new MutableDisposable()));
        this.updateStatusBarEntry(this.meteredConnectionService.isConnectionMetered);
        this._register(
            this.meteredConnectionService.onDidChangeIsConnectionMetered(isMetered => {
                this.updateStatusBarEntry(isMetered);
            })
        );
    }
    updateStatusBarEntry(isMetered) {
        if (isMetered) {
            if (!this.statusBarEntry.value) {
                this.statusBarEntry.value = this.statusbarService.addEntry(
                    this.getStatusBarEntry(),
                    MeteredConnectionStatusContribution_1.ID,
                    StatusbarAlignment.RIGHT,
                    -Number.MAX_VALUE
                );
            }
        } else {
            this.statusBarEntry.clear();
        }
    }
    getStatusBarEntry() {
        return {
            name: ( localize(10874, "Metered Connection")),
            text: "$(radio-tower)",
            ariaLabel: ( localize(10875, "Metered Connection Enabled")),
            tooltip: ( localize(
                10876,
                "Metered connection enabled. Some automatic features like extension updates, Settings Sync, and automatic Git operations are paused to reduce data usage."
            )),
            command: {
                id: "workbench.action.configureMeteredConnection",
                title: ( localize(10877, "Configure"))
            },
            showInAllWindows: true
        };
    }
};
MeteredConnectionStatusContribution = MeteredConnectionStatusContribution_1 = ( __decorate([( __param(0, IMeteredConnectionService)), ( __param(1, IStatusbarService))], MeteredConnectionStatusContribution));

export { MeteredConnectionStatusContribution };
