import { __exports as lib } from '../../../_virtual/index4.js';
import { __require as requireKeymap_vim } from './cm/keymap_vim.js';
import { __require as requireStatusbar } from './statusbar.js';

var hasRequiredLib;

function requireLib () {
	if (hasRequiredLib) return lib;
	hasRequiredLib = 1;
	(function (exports) {

		Object.defineProperty(exports, "__esModule", {
		  value: true
		});
		Object.defineProperty(exports, "StatusBar", {
		  enumerable: true,
		  get: function get() {
		    return _statusbar["default"];
		  }
		});
		Object.defineProperty(exports, "VimMode", {
		  enumerable: true,
		  get: function get() {
		    return _keymap_vim["default"];
		  }
		});
		exports.initVimMode = initVimMode;
		var _keymap_vim = _interopRequireDefault(requireKeymap_vim());
		var _statusbar = _interopRequireDefault(requireStatusbar());
		function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
		function initVimMode(editor) {
		  var statusbarNode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
		  var StatusBarClass = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _statusbar["default"];
		  var sanitizer = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
		  var vimAdapter = new _keymap_vim["default"](editor);
		  if (!statusbarNode) {
		    vimAdapter.attach();
		    return vimAdapter;
		  }
		  var statusBar = new StatusBarClass(statusbarNode, editor, sanitizer);
		  var keyBuffer = "";
		  vimAdapter.on("vim-mode-change", function (mode) {
		    statusBar.setMode(mode);
		  });
		  vimAdapter.on("vim-keypress", function (key) {
		    if (key === ":") {
		      keyBuffer = "";
		    } else {
		      keyBuffer += key;
		    }
		    statusBar.setKeyBuffer(keyBuffer);
		  });
		  vimAdapter.on("vim-command-done", function () {
		    keyBuffer = "";
		    statusBar.setKeyBuffer(keyBuffer);
		  });
		  vimAdapter.on("dispose", function () {
		    statusBar.toggleVisibility(false);
		    statusBar.closeInput();
		    statusBar.clear();
		  });
		  statusBar.toggleVisibility(true);
		  vimAdapter.setStatusBar(statusBar);
		  vimAdapter.attach();
		  return vimAdapter;
		} 
	} (lib));
	return lib;
}

export { requireLib as __require };
