const CANCELED = Symbol("canceled");

export
class CancelableEvent {
  static type = "event";

  static cancelable = false;

  constructor(f) {
    this[CANCELED] = false,
      this.data = f
  }

  get type() {
    return this.constructor.type
  }

  get cancelable() {
    return this.constructor.cancelable
  }

  cancel() {
    this[CANCELED] = true
  }

  canceled() {
    return !!this[CANCELED]
  }

  clone(f) {
    return new this.constructor({
      ...this.data,
      ...f
    })
  }
}

export default
class DraggableEvent extends CancelableEvent {
  static type = "vue:drag:move";

  get sourceComponent() {
    return this.data.sourceComponent
  }

  get group() {
    return this.data.group
  }

  get item() {
    return this.data.item
  }

  get draggablePayload() {
    return this.data.draggablePayload
  }
}
