11cb0ef41Sopenharmony_ci// Copyright 2020 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciclass AppEvent extends CustomEvent {
61cb0ef41Sopenharmony_ci  constructor(name) {
71cb0ef41Sopenharmony_ci    super(name, {bubbles: true, composed: true});
81cb0ef41Sopenharmony_ci  }
91cb0ef41Sopenharmony_ci}
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciexport class SelectionEvent extends AppEvent {
121cb0ef41Sopenharmony_ci  // TODO: turn into static class fields once Safari supports it.
131cb0ef41Sopenharmony_ci  static get name() {
141cb0ef41Sopenharmony_ci    return 'select';
151cb0ef41Sopenharmony_ci  }
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci  constructor(entries) {
181cb0ef41Sopenharmony_ci    super(SelectionEvent.name);
191cb0ef41Sopenharmony_ci    if (!Array.isArray(entries) || entries.length == 0) {
201cb0ef41Sopenharmony_ci      throw new Error('No valid entries selected!');
211cb0ef41Sopenharmony_ci    }
221cb0ef41Sopenharmony_ci    this.entries = entries;
231cb0ef41Sopenharmony_ci  }
241cb0ef41Sopenharmony_ci}
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ciexport class SelectRelatedEvent extends AppEvent {
271cb0ef41Sopenharmony_ci  static get name() {
281cb0ef41Sopenharmony_ci    return 'selectrelated';
291cb0ef41Sopenharmony_ci  }
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_ci  constructor(entry) {
321cb0ef41Sopenharmony_ci    super(SelectRelatedEvent.name);
331cb0ef41Sopenharmony_ci    this.entry = entry;
341cb0ef41Sopenharmony_ci  }
351cb0ef41Sopenharmony_ci}
361cb0ef41Sopenharmony_ci
371cb0ef41Sopenharmony_ciexport class FocusEvent extends AppEvent {
381cb0ef41Sopenharmony_ci  static get name() {
391cb0ef41Sopenharmony_ci    return 'showentrydetail';
401cb0ef41Sopenharmony_ci  }
411cb0ef41Sopenharmony_ci
421cb0ef41Sopenharmony_ci  constructor(entry) {
431cb0ef41Sopenharmony_ci    super(FocusEvent.name);
441cb0ef41Sopenharmony_ci    this.entry = entry;
451cb0ef41Sopenharmony_ci  }
461cb0ef41Sopenharmony_ci}
471cb0ef41Sopenharmony_ci
481cb0ef41Sopenharmony_ciexport class SelectTimeEvent extends AppEvent {
491cb0ef41Sopenharmony_ci  static get name() {
501cb0ef41Sopenharmony_ci    return 'timerangeselect';
511cb0ef41Sopenharmony_ci  }
521cb0ef41Sopenharmony_ci
531cb0ef41Sopenharmony_ci  constructor(start = 0, end = Infinity, focus = false, zoom = false) {
541cb0ef41Sopenharmony_ci    super(SelectTimeEvent.name);
551cb0ef41Sopenharmony_ci    this.start = start;
561cb0ef41Sopenharmony_ci    this.end = end;
571cb0ef41Sopenharmony_ci    this.focus = focus;
581cb0ef41Sopenharmony_ci    this.zoom = zoom;
591cb0ef41Sopenharmony_ci  }
601cb0ef41Sopenharmony_ci}
611cb0ef41Sopenharmony_ci
621cb0ef41Sopenharmony_ciexport class SynchronizeSelectionEvent extends AppEvent {
631cb0ef41Sopenharmony_ci  static get name() {
641cb0ef41Sopenharmony_ci    return 'syncselection';
651cb0ef41Sopenharmony_ci  }
661cb0ef41Sopenharmony_ci
671cb0ef41Sopenharmony_ci  constructor(start, end) {
681cb0ef41Sopenharmony_ci    super(SynchronizeSelectionEvent.name);
691cb0ef41Sopenharmony_ci    this.start = start;
701cb0ef41Sopenharmony_ci    this.end = end;
711cb0ef41Sopenharmony_ci  }
721cb0ef41Sopenharmony_ci}
731cb0ef41Sopenharmony_ci
741cb0ef41Sopenharmony_ciexport class ToolTipEvent extends AppEvent {
751cb0ef41Sopenharmony_ci  static get name() {
761cb0ef41Sopenharmony_ci    return 'showtooltip';
771cb0ef41Sopenharmony_ci  }
781cb0ef41Sopenharmony_ci
791cb0ef41Sopenharmony_ci  constructor(content, positionOrTargetNode) {
801cb0ef41Sopenharmony_ci    super(ToolTipEvent.name);
811cb0ef41Sopenharmony_ci    if (!positionOrTargetNode) {
821cb0ef41Sopenharmony_ci      throw Error('Either provide a valid position or targetNode');
831cb0ef41Sopenharmony_ci    }
841cb0ef41Sopenharmony_ci    this._content = content;
851cb0ef41Sopenharmony_ci    this._positionOrTargetNode = positionOrTargetNode;
861cb0ef41Sopenharmony_ci  }
871cb0ef41Sopenharmony_ci
881cb0ef41Sopenharmony_ci  get content() {
891cb0ef41Sopenharmony_ci    return this._content;
901cb0ef41Sopenharmony_ci  }
911cb0ef41Sopenharmony_ci
921cb0ef41Sopenharmony_ci  get positionOrTargetNode() {
931cb0ef41Sopenharmony_ci    return this._positionOrTargetNode;
941cb0ef41Sopenharmony_ci  }
951cb0ef41Sopenharmony_ci}
96