// Terminal Adapter - Bridges game engine to existing TerminalShell
class TerminalAdapter {
  constructor(terminal) {
    this.terminal = terminal;
    this.inputCallback = null;
  }

  // Output methods - delegate to terminal
  print(text, className = "") {
    this.terminal.print(text, className);
    this.scrollToBottom();
  }

  printHTML(html, className = "") {
    this.terminal.printHTML(html, className);
    this.scrollToBottom();
  }

  printError(text) {
    this.terminal.printError(text);
    this.scrollToBottom();
  }

  printSuccess(text) {
    this.terminal.printSuccess(text);
    this.scrollToBottom();
  }

  printInfo(text) {
    this.terminal.printInfo(text);
    this.scrollToBottom();
  }

  printWarning(text) {
    this.terminal.printWarning(text);
    this.scrollToBottom();
  }

  clear() {
    this.terminal.clear();
  }

  scrollToBottom() {
    this.terminal.scrollToBottom();
  }

  // Input capture - allows game to intercept terminal input
  captureInput(callback) {
    this.inputCallback = callback;
  }

  releaseInput() {
    this.inputCallback = null;
  }

  // Called by game engine when input is received
  handleInput(value) {
    if (this.inputCallback) {
      this.inputCallback(value);
      return true;
    }
    return false;
  }

  // Get the input element for focus management
  getInputElement() {
    return this.terminal.input;
  }

  // Focus the input
  focusInput() {
    if (this.terminal.input) {
      this.terminal.input.focus();
    }
  }
}
