"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const dom = require("../../../browser/dom.js");
const keyboardEvent = require("../../../browser/keyboardEvent.js");
const mouseEvent = require("../../../browser/mouseEvent.js");
const inputBox = require("../../../browser/ui/inputbox/inputBox.js");
const lifecycle = require("../../../common/lifecycle.js");
const severity = require("../../../common/severity.js");
require("./media/quickInput.css.js");
const $ = dom.$;
class QuickInputBox extends lifecycle.Disposable {
  constructor(parent) {
    super();
    this.parent = parent;
    this.onKeyDown = (handler) => {
      return dom.addDisposableListener(this.inputBox.inputElement, dom.EventType.KEY_DOWN, (e) => {
        handler(new keyboardEvent.StandardKeyboardEvent(e));
      });
    };
    this.onMouseDown = (handler) => {
      return dom.addDisposableListener(this.inputBox.inputElement, dom.EventType.MOUSE_DOWN, (e) => {
        handler(new mouseEvent.StandardMouseEvent(e));
      });
    };
    this.onDidChange = (handler) => {
      return this.inputBox.onDidChange(handler);
    };
    this.container = dom.append(this.parent, $(".quick-input-box"));
    this.inputBox = this._register(new inputBox.InputBox(this.container, void 0));
  }
  get value() {
    return this.inputBox.value;
  }
  set value(value) {
    this.inputBox.value = value;
  }
  select(range = null) {
    this.inputBox.select(range);
  }
  isSelectionAtEnd() {
    return this.inputBox.isSelectionAtEnd();
  }
  get placeholder() {
    return this.inputBox.inputElement.getAttribute("placeholder") || "";
  }
  set placeholder(placeholder) {
    this.inputBox.setPlaceHolder(placeholder);
  }
  get ariaLabel() {
    return this.inputBox.getAriaLabel();
  }
  set ariaLabel(ariaLabel) {
    this.inputBox.setAriaLabel(ariaLabel);
  }
  get password() {
    return this.inputBox.inputElement.type === "password";
  }
  set password(password) {
    this.inputBox.inputElement.type = password ? "password" : "text";
  }
  setAttribute(name, value) {
    this.inputBox.inputElement.setAttribute(name, value);
  }
  removeAttribute(name) {
    this.inputBox.inputElement.removeAttribute(name);
  }
  showDecoration(decoration) {
    if (decoration === severity.default.Ignore) {
      this.inputBox.hideMessage();
    } else {
      this.inputBox.showMessage({ type: decoration === severity.default.Info ? 1 : decoration === severity.default.Warning ? 2 : 3, content: "" });
    }
  }
  stylesForType(decoration) {
    return this.inputBox.stylesForType(
      decoration === severity.default.Info ? 1 : decoration === severity.default.Warning ? 2 : 3
      /* ERROR */
    );
  }
  setFocus() {
    this.inputBox.focus();
  }
  layout() {
    this.inputBox.layout();
  }
  style(styles) {
    this.inputBox.style(styles);
  }
}
exports.QuickInputBox = QuickInputBox;
