import { localize } from "../../../nls.mjs";
import { Emitter } from "../../../base/common/event.mjs";
import { LanguageConfigurationRegistry } from "./languageConfigurationRegistry.mjs";
import { Registry } from "../../../platform/registry/common/platform.mjs";
import { Mimes } from "../../../base/common/mime.mjs";
import { Extensions as Extensions$1 } from "../../../platform/configuration/common/configurationRegistry.mjs";
const Extensions = {
  ModesRegistry: "editor.modesRegistry"
};
class EditorModesRegistry {
  constructor() {
    this._onDidChangeLanguages = new Emitter();
    this.onDidChangeLanguages = this._onDidChangeLanguages.event;
    this._languages = [];
  }
  registerLanguage(def) {
    this._languages.push(def);
    this._onDidChangeLanguages.fire(void 0);
    return {
      dispose: () => {
        for (let i = 0, len = this._languages.length; i < len; i++) {
          if (this._languages[i] === def) {
            this._languages.splice(i, 1);
            return;
          }
        }
      }
    };
  }
  getLanguages() {
    return this._languages;
  }
}
const ModesRegistry = new EditorModesRegistry();
Registry.add(Extensions.ModesRegistry, ModesRegistry);
const PLAINTEXT_LANGUAGE_ID = "plaintext";
const PLAINTEXT_EXTENSION = ".txt";
ModesRegistry.registerLanguage({
  id: PLAINTEXT_LANGUAGE_ID,
  extensions: [PLAINTEXT_EXTENSION],
  aliases: [localize("plainText.alias", "Plain Text"), "text"],
  mimetypes: [Mimes.text]
});
LanguageConfigurationRegistry.register(PLAINTEXT_LANGUAGE_ID, {
  brackets: [
    ["(", ")"],
    ["[", "]"],
    ["{", "}"]
  ],
  surroundingPairs: [
    { open: "{", close: "}" },
    { open: "[", close: "]" },
    { open: "(", close: ")" },
    { open: "<", close: ">" },
    { open: '"', close: '"' },
    { open: "'", close: "'" },
    { open: "`", close: "`" }
  ],
  colorizedBracketPairs: [],
  folding: {
    offSide: true
  }
}, 0);
Registry.as(Extensions$1.Configuration).registerDefaultConfigurations([{
  overrides: {
    "[plaintext]": {
      "editor.unicodeHighlight.ambiguousCharacters": false,
      "editor.unicodeHighlight.invisibleCharacters": false
    }
  }
}]);
export {
  EditorModesRegistry,
  Extensions,
  ModesRegistry,
  PLAINTEXT_EXTENSION,
  PLAINTEXT_LANGUAGE_ID
};
