"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const arrays = require("../../../base/common/arrays.js");
const lifecycle = require("../../../base/common/lifecycle.js");
const platform = require("../../registry/common/platform.js");
exports.DefaultQuickAccessFilterValue = void 0;
(function(DefaultQuickAccessFilterValue) {
  DefaultQuickAccessFilterValue[DefaultQuickAccessFilterValue["PRESERVE"] = 0] = "PRESERVE";
  DefaultQuickAccessFilterValue[DefaultQuickAccessFilterValue["LAST"] = 1] = "LAST";
})(exports.DefaultQuickAccessFilterValue || (exports.DefaultQuickAccessFilterValue = {}));
const Extensions = {
  Quickaccess: "workbench.contributions.quickaccess"
};
class QuickAccessRegistry {
  constructor() {
    this.providers = [];
    this.defaultProvider = void 0;
  }
  registerQuickAccessProvider(provider) {
    if (provider.prefix.length === 0) {
      this.defaultProvider = provider;
    } else {
      this.providers.push(provider);
    }
    this.providers.sort((providerA, providerB) => providerB.prefix.length - providerA.prefix.length);
    return lifecycle.toDisposable(() => {
      this.providers.splice(this.providers.indexOf(provider), 1);
      if (this.defaultProvider === provider) {
        this.defaultProvider = void 0;
      }
    });
  }
  getQuickAccessProviders() {
    return arrays.coalesce([this.defaultProvider, ...this.providers]);
  }
  getQuickAccessProvider(prefix) {
    const result = prefix ? this.providers.find((provider) => prefix.startsWith(provider.prefix)) || void 0 : void 0;
    return result || this.defaultProvider;
  }
}
platform.Registry.add(Extensions.Quickaccess, new QuickAccessRegistry());
exports.Extensions = Extensions;
exports.QuickAccessRegistry = QuickAccessRegistry;
