text: "use strict";
  /********************************************************************************
   * Copyright (C) 2018 Ericsson and others.
   *
   * This program and the accompanying materials are made available under the
   * terms of the Eclipse Public License v. 2.0 which is available at
   * http://www.eclipse.org/legal/epl-2.0.
   *
   * This Source Code may also be made available under the following Secondary
   * Licenses when the conditions for such availability set forth in the Eclipse
   * Public License v. 2.0 are satisfied: GNU General Public License, version 2
   * with the GNU Classpath Exception which is available at
   * https://www.gnu.org/software/classpath/license.html.
   *
   * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
   ********************************************************************************/
  var __read = (this && this.__read) || function (o, n) {
      var m = typeof Symbol === "function" && o[Symbol.iterator];
      if (!m) return o;
      var i = m.call(o), r, ar = [], e;
      try {
          while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
      }
      catch (error) { e = { error: error }; }
      finally {
          try {
              if (r && !r.done && (m = i["return"])) m.call(i);
          }
          finally { if (e) throw e.error; }
      }
      return ar;
  };
  var __spread = (this && this.__spread) || function () {
      for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
      return ar;
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  var browser_1 = require("@theia/core/lib/browser");
  var core_1 = require("@theia/core");
  var theming_1 = require("@theia/core/lib/browser/theming");
  var monaco_textmate_builtin_theme_provider_1 = require("./monaco-textmate-builtin-theme-provider");
  var monaco_builtin_theme_provider_1 = require("./monaco-builtin-theme-provider");
  var textmate_registry_1 = require("./textmate-registry");
  var textmate_contribution_1 = require("./textmate-contribution");
  var monaco_textmate_service_1 = require("./monaco-textmate-service");
  var onigasm_1 = require("onigasm");
  function fetchOnigasm() {
      return new Promise(function (resolve, reject) {
          var onigasmPath = require('onigasm/lib/onigasm.wasm'); // webpack doing its magic here
          var request = new XMLHttpRequest();
          request.onreadystatechange = function () {
              if (this.readyState === XMLHttpRequest.DONE) {
                  if (this.status === 200) {
                      resolve(this.response);
                  }
                  else {
                      reject(new Error('Could not fetch onigasm'));
                  }
              }
          };
          request.open('GET', onigasmPath, true);
          request.responseType = 'arraybuffer';
          request.send();
      });
  }
  exports.fetchOnigasm = fetchOnigasm;
  exports.default = (function (bind, unbind, isBound, rebind) {
      var onigasmPromise = browser_1.isBasicWasmSupported ? fetchOnigasm().then(function (buffer) { return onigasm_1.loadWASM(buffer); }) : Promise.reject(new Error('wasm not supported'));
      bind(monaco_textmate_service_1.OnigasmPromise).toConstantValue(onigasmPromise);
      bind(monaco_textmate_service_1.MonacoTextmateService).toSelf().inSingletonScope();
      bind(browser_1.FrontendApplicationContribution).toService(monaco_textmate_service_1.MonacoTextmateService);
      core_1.bindContributionProvider(bind, textmate_contribution_1.LanguageGrammarDefinitionContribution);
      bind(textmate_registry_1.TextmateRegistry).toSelf().inSingletonScope();
      var themeService = theming_1.ThemeService.get();
      monaco_builtin_theme_provider_1.BuiltinMonacoThemeProvider.compileMonacoThemes();
      themeService.register.apply(themeService, __spread(monaco_textmate_builtin_theme_provider_1.BuiltinTextmateThemeProvider.theiaTextmateThemes));
  });
  //# sourceMappingURL=monaco-textmate-frontend-bindings.js.map