import { addDisposableListener, EventType, append, $ as $$1 } from "../../../browser/dom.mjs";
import { StandardKeyboardEvent } from "../../../browser/keyboardEvent.mjs";
import { StandardMouseEvent } from "../../../browser/mouseEvent.mjs";
import { InputBox } from "../../../browser/ui/inputbox/inputBox.mjs";
import { Disposable } from "../../../common/lifecycle.mjs";
import Severity from "../../../common/severity.mjs";
import "./media/quickInput.css.mjs";
const $ = $$1;
class QuickInputBox extends Disposable {
  constructor(parent) {
    super();
    this.parent = parent;
    this.onKeyDown = (handler) => {
      return addDisposableListener(this.inputBox.inputElement, EventType.KEY_DOWN, (e) => {
        handler(new StandardKeyboardEvent(e));
      });
    };
    this.onMouseDown = (handler) => {
      return addDisposableListener(this.inputBox.inputElement, EventType.MOUSE_DOWN, (e) => {
        handler(new StandardMouseEvent(e));
      });
    };
    this.onDidChange = (handler) => {
      return this.inputBox.onDidChange(handler);
    };
    this.container = append(this.parent, $(".quick-input-box"));
    this.inputBox = this._register(new 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.Ignore) {
      this.inputBox.hideMessage();
    } else {
      this.inputBox.showMessage({ type: decoration === Severity.Info ? 1 : decoration === Severity.Warning ? 2 : 3, content: "" });
    }
  }
  stylesForType(decoration) {
    return this.inputBox.stylesForType(
      decoration === Severity.Info ? 1 : decoration === Severity.Warning ? 2 : 3
      /* ERROR */
    );
  }
  setFocus() {
    this.inputBox.focus();
  }
  layout() {
    this.inputBox.layout();
  }
  style(styles) {
    this.inputBox.style(styles);
  }
}
export {
  QuickInputBox
};
