// / [VexFlow](http://vexflow.com) - Copyright (c) Mohit Muthanna 2010.
//
// ## Description
// This class implements varies types of ties between contiguous notes. The
// ties include: regular ties, hammer ons, pull offs, and slides.

import { Vex } from './vex';
import { StaveTie } from './stavetie';

export class TabTie extends StaveTie {
  static createHammeron(notes) {
    return new TabTie(notes, 'H');
  }

  static createPulloff(notes) {
    return new TabTie(notes, 'P');
  }

  constructor(notes, text) {
    /**
     * Notes is a struct that has:
     *
     *  {
     *    first_note: Note,
     *    last_note: Note,
     *    first_indices: [n1, n2, n3],
     *    last_indices: [n1, n2, n3]
     *  }
     *
     **/
    super(notes, text);
    this.render_options.cp1 = 9;
    this.render_options.cp2 = 11;
    this.render_options.y_shift = 3;

    this.setNotes(notes);
  }

  draw() {
    if (!this.context)
      throw new Vex.RERR('NoContext', 'No context to render tie.');
    const first_note = this.first_note;
    const last_note = this.last_note;
    let first_x_px, last_x_px, first_ys, last_ys;

    if (first_note) {
      first_x_px = first_note.getTieRightX() + this.render_options.tie_spacing;
      first_ys = first_note.getYs();
    } else {
      first_x_px = last_note.getStave().getTieStartX();
      first_ys = last_note.getYs();
      this.first_indices = this.last_indices;
    }

    if (last_note) {
      last_x_px = last_note.getTieLeftX() + this.render_options.tie_spacing;
      last_ys = last_note.getYs();
    } else {
      last_x_px = first_note.getStave().getTieEndX();
      last_ys = first_note.getYs();
      this.last_indices = this.first_indices;
    }

    this.renderTie({
      first_x_px,
      last_x_px,
      first_ys,
      last_ys,
      direction: -1,           // Tab tie's are always face up.
    });

    this.renderText(first_x_px, last_x_px);
    return true;
  }
}

// / [VexFlow](http://vexflow.com) - Copyright (c) Mohit Muthanna 2010.
//
// ## Description
// This class implements varies types of ties between contiguous notes. The
// ties include: regular ties, hammer ons, pull offs, and slides.

import { Vex } from './vex';
import { StaveTie } from './stavetie';

export class TabTie extends StaveTie {
  static createHammeron(notes) {
    return new TabTie(notes, 'H');
  }

  static createPulloff(notes) {
    return new TabTie(notes, 'P');
  }

  constructor(notes, text) {
    /**
     * Notes is a struct that has:
     *
     *  {
     *    first_note: Note,
     *    last_note: Note,
     *    first_indices: [n1, n2, n3],
     *    last_indices: [n1, n2, n3]
     *  }
     *
     **/
    super(notes, text);
    this.render_options.cp1 = 9;
    this.render_options.cp2 = 11;
    this.render_options.y_shift = 3;

    this.setNotes(notes);
  }

  draw() {
    if (!this.context) {
      throw new Vex.RERR('NoContext', 'No context to render tie.');
    }

    const first_note = this.first_note;
    const last_note = this.last_note;
    let first_x_px;
    let last_x_px;
    let first_ys;
    let last_ys;

    if (first_note) {
      first_x_px = first_note.getTieRightX() + this.render_options.tie_spacing;
      first_ys = first_note.getYs();
    } else {
      first_x_px = last_note.getStave().getTieStartX();
      first_ys = last_note.getYs();
      this.first_indices = this.last_indices;
    }

    if (last_note) {
      last_x_px = last_note.getTieLeftX() + this.render_options.tie_spacing;
      last_ys = last_note.getYs();
    } else {
      last_x_px = first_note.getStave().getTieEndX();
      last_ys = first_note.getYs();
      this.last_indices = this.first_indices;
    }

    this.renderTie({
      first_x_px,
      last_x_px,
      first_ys,
      last_ys,
      direction: -1, // Tab tie's are always face up.
    });

    this.renderText(first_x_px, last_x_px);
    return true;
  }
}

Fix remaining lint errors in tabtie.js