<commit_before>import '../../react.dart';

enum EventType {
  SyntheticEvent,
  SyntheticClipboardEvent,
  SyntheticKeyboardEvent,
  SyntheticCompositionEvent,
  SyntheticFocusEvent,
  SyntheticFormEvent,
  SyntheticMouseEvent,
  SyntheticPointerEvent,
  SyntheticTouchEvent,
  SyntheticTransitionEvent,
  SyntheticAnimationEvent,
  SyntheticUIEvent,
  SyntheticWheelEvent,
}


SyntheticEvent getEmptyEventOfType(EventType type) {
  switch(type) {
    case EventType.SyntheticEvent:
      return SyntheticEventHelper.getEmptyEvent();
    case EventType.SyntheticClipboardEvent:
      return SyntheticEventHelper.getEmptyClipboardEvent();
    case EventType.SyntheticKeyboardEvent:
      return SyntheticEventHelper.getEmptyKeyboardEvent();
    case EventType.SyntheticCompositionEvent:
      return SyntheticEventHelper.getEmptyCompositionEvent();
    case EventType.SyntheticFocusEvent:
      return SyntheticEventHelper.getEmptyFocusEvent();
    case EventType.SyntheticFormEvent:
      return SyntheticEventHelper.getEmptyFormEvent();
    case EventType.SyntheticMouseEvent:
      return SyntheticEventHelper.getEmptyMouseEvent();
    case EventType.SyntheticPointerEvent:
      return SyntheticEventHelper.getEmptyPointerEvent();
    case EventType.SyntheticTouchEvent:
      return SyntheticEventHelper.getEmptyTouchEvent();
    case EventType.SyntheticTransitionEvent:
      return SyntheticEventHelper.getEmptyTransitionEvent();
    case EventType.SyntheticAnimationEvent:
      return SyntheticEventHelper.getEmptyAnimationEvent();
    case EventType.SyntheticUIEvent:
      return SyntheticEventHelper.getEmptyUIEvent();
    case EventType.SyntheticWheelEvent:
      return SyntheticEventHelper.getEmptyWheelEvent();
  }

  return null;
}

extension SyntheticEventTypeHelpers on SyntheticEvent {
  bool get isClipboardEvent => this.tryCast<SyntheticClipboardEvent>() != null;
  bool get isKeyboardEvent => this.tryCast<SyntheticKeyboardEvent>() != null;
  bool get isCompositionEvent => this.tryCast<SyntheticCompositionEvent>() != null;
  bool get isFocusEvent => this.tryCast<SyntheticFocusEvent>() != null;
  bool get isFormEvent => this.tryCast<SyntheticFormEvent>() != null;
  bool get isMouseEvent => this.tryCast<SyntheticMouseEvent>() != null;
  bool get isPointerEvent => this.tryCast<SyntheticPointerEvent>() != null;
  bool get isTouchEvent => this.tryCast<SyntheticTouchEvent>() != null;
  bool get isTransitionEvent => this.tryCast<SyntheticTransitionEvent>() != null;
  bool get isAnimationEvent => this.tryCast<SyntheticAnimationEvent>() != null;
  bool get isUiEvent => this.tryCast<SyntheticUIEvent>() != null;
  bool get isWheelEvent => this.tryCast<SyntheticWheelEvent>() != null;
}


class SyntheticEventHelper {
  static SyntheticEvent getEmptyEvent() => SyntheticEvent(null, null, null, null, null, () {}, null, null, null, null, 0, 'empty event');
  static SyntheticClipboardEvent getEmptyClipboardEvent() => SyntheticClipboardEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, 'empty event', null);
  static SyntheticKeyboardEvent getEmptyKeyboardEvent() => SyntheticKeyboardEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, null, null, null, null, null, null, null, null, null, null, null, null);
  static SyntheticCompositionEvent getEmptyCompositionEvent() => SyntheticCompositionEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, 'empty event', null);
  static SyntheticFocusEvent getEmptyFocusEvent() => SyntheticFocusEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, 'empty event', null);
  static SyntheticFormEvent getEmptyFormEvent() => SyntheticFormEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, 'empty event');
  static SyntheticMouseEvent getEmptyMouseEvent() => SyntheticMouseEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, 'empty event', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
  static SyntheticPointerEvent getEmptyPointerEvent() => SyntheticPointerEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, 'empty event', null, null, null, null, null, null, null, null, null, null);
  static SyntheticTouchEvent getEmptyTouchEvent() => SyntheticTouchEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, 'empty event', null, null, null, null, null, null, null);
  static SyntheticTransitionEvent getEmptyTransitionEvent() => SyntheticTransitionEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, 'empty event', null, null, null);
  static SyntheticAnimationEvent getEmptyAnimationEvent() => SyntheticAnimationEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, 'empty event', null, null, null);
  static SyntheticUIEvent getEmptyUIEvent() => SyntheticUIEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, 'empty event', null, null);
  static SyntheticWheelEvent getEmptyWheelEvent() => SyntheticWheelEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, 'empty event', null, null, null, null);





}



// A temporary measure that will be removed when Duck typing is added
// in the React 17 release branch.
extension <T> on T {
  S tryCast<S extends T>() => this is S ? this : null;
}<commit_msg>Add second iteration<commit_after>import '../../react.dart';

SyntheticEvent getEmptySyntheticEvent() => _SyntheticEventHelper.getEmptyEvent();
SyntheticClipboardEvent getEmptyClipboardEvent() => _SyntheticEventHelper.getEmptyClipboardEvent();
SyntheticKeyboardEvent getEmptyKeyboardEvent() => _SyntheticEventHelper.getEmptyKeyboardEvent();
SyntheticCompositionEvent getEmptyCompositionEvent() => _SyntheticEventHelper.getEmptyCompositionEvent();
SyntheticFocusEvent getEmptyFocusEvent() => _SyntheticEventHelper.getEmptyFocusEvent();
SyntheticFormEvent getEmptyFormEvent() => _SyntheticEventHelper.getEmptyFormEvent();
SyntheticMouseEvent getEmptyMouseEvent() => _SyntheticEventHelper.getEmptyMouseEvent();
SyntheticPointerEvent getEmptyPointerEvent() => _SyntheticEventHelper.getEmptyPointerEvent();
SyntheticTouchEvent getEmptyTouchEvent() => _SyntheticEventHelper.getEmptyTouchEvent();
SyntheticAnimationEvent getEmptyAnimationEvent() => _SyntheticEventHelper.getEmptyAnimationEvent();
SyntheticUIEvent getEmptyUIEvent() => _SyntheticEventHelper.getEmptyUIEvent();
SyntheticWheelEvent getEmptyWheelEvent() => _SyntheticEventHelper.getEmptyWheelEvent();

SyntheticEvent buildSyntheticEvent({SyntheticWheelEvent baseEvent, Map<String, dynamic> newEventProperties}) => _SyntheticEventHelper.buildEvent(baseEvent, newEventProperties);
SyntheticClipboardEvent buildClipboardEvent({SyntheticClipboardEvent baseEvent, Map<String, dynamic> newEventProperties}) => _SyntheticEventHelper.buildClipboardEvent(baseEvent, newEventProperties);
SyntheticKeyboardEvent buildKeyboardEvent({SyntheticKeyboardEvent baseEvent, Map<String, dynamic> newEventProperties}) => _SyntheticEventHelper.buildKeyboardEvent(baseEvent, newEventProperties);
SyntheticCompositionEvent buildCompositionEvent({SyntheticCompositionEvent baseEvent, Map<String, dynamic> newEventProperties}) => _SyntheticEventHelper.buildCompositionEvent(baseEvent, newEventProperties);
SyntheticFocusEvent buildFocusEvent({SyntheticFocusEvent baseEvent, Map<String, dynamic> newEventProperties}) => _SyntheticEventHelper.buildFocusEvent(baseEvent, newEventProperties);
SyntheticFormEvent buildFormEvent({SyntheticFormEvent baseEvent, Map<String, dynamic> newEventProperties}) => _SyntheticEventHelper.buildFormEvent(baseEvent, newEventProperties);
SyntheticMouseEvent buildMouseEvent({SyntheticMouseEvent baseEvent, Map<String, dynamic> newEventProperties}) => _SyntheticEventHelper.buildMouseEvent(baseEvent, newEventProperties);
SyntheticPointerEvent buildPointerEvent({SyntheticPointerEvent baseEvent, Map<String, dynamic> newEventProperties}) => _SyntheticEventHelper.buildPointerEvent(baseEvent, newEventProperties);
SyntheticTouchEvent buildTouchEvent({SyntheticTouchEvent baseEvent, Map<String, dynamic> newEventProperties}) => _SyntheticEventHelper.buildTouchEvent(baseEvent, newEventProperties);
SyntheticAnimationEvent buildAnimationEvent({SyntheticAnimationEvent baseEvent, Map<String, dynamic> newEventProperties}) => _SyntheticEventHelper.buildAnimationEvent(baseEvent, newEventProperties);
SyntheticUIEvent buildUIEvent({SyntheticUIEvent baseEvent, Map<String, dynamic> newEventProperties}) => _SyntheticEventHelper.buildUIEvent(baseEvent, newEventProperties);
SyntheticWheelEvent buildWheelEvent({SyntheticWheelEvent baseEvent, Map<String, dynamic> newEventProperties}) => _SyntheticEventHelper.buildWheelEvent(baseEvent, newEventProperties);

extension SyntheticEventTypeHelpers on SyntheticEvent {
  bool get isClipboardEvent => this.tryCast<SyntheticClipboardEvent>() != null;
  bool get isKeyboardEvent => this.tryCast<SyntheticKeyboardEvent>() != null;
  bool get isCompositionEvent => this.tryCast<SyntheticCompositionEvent>() != null;
  bool get isFocusEvent => this.tryCast<SyntheticFocusEvent>() != null;
  bool get isFormEvent => this.tryCast<SyntheticFormEvent>() != null;
  bool get isMouseEvent => this.tryCast<SyntheticMouseEvent>() != null;
  bool get isPointerEvent => this.tryCast<SyntheticPointerEvent>() != null;
  bool get isTouchEvent => this.tryCast<SyntheticTouchEvent>() != null;
  bool get isTransitionEvent => this.tryCast<SyntheticTransitionEvent>() != null;
  bool get isAnimationEvent => this.tryCast<SyntheticAnimationEvent>() != null;
  bool get isUiEvent => this.tryCast<SyntheticUIEvent>() != null;
  bool get isWheelEvent => this.tryCast<SyntheticWheelEvent>() != null;
}

class _SyntheticEventHelper {
  static SyntheticEvent getEmptyEvent() => SyntheticEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, 'empty event');
  static SyntheticClipboardEvent getEmptyClipboardEvent() => SyntheticClipboardEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, 'empty event', null);
  static SyntheticKeyboardEvent getEmptyKeyboardEvent() => SyntheticKeyboardEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, null, null, null, null, null, null, null, null, null, null, null, null);
  static SyntheticCompositionEvent getEmptyCompositionEvent() => SyntheticCompositionEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, 'empty event', null);
  static SyntheticFocusEvent getEmptyFocusEvent() => SyntheticFocusEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, 'empty event', null);
  static SyntheticFormEvent getEmptyFormEvent() => SyntheticFormEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, 'empty event');
  static SyntheticMouseEvent getEmptyMouseEvent() => SyntheticMouseEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, 'empty event', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
  static SyntheticPointerEvent getEmptyPointerEvent() => SyntheticPointerEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, 'empty event', null, null, null, null, null, null, null, null, null, null);
  static SyntheticTouchEvent getEmptyTouchEvent() => SyntheticTouchEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, 'empty event', null, null, null, null, null, null, null);
  static SyntheticTransitionEvent getEmptyTransitionEvent() => SyntheticTransitionEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, 'empty event', null, null, null);
  static SyntheticAnimationEvent getEmptyAnimationEvent() => SyntheticAnimationEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, 'empty event', null, null, null);
  static SyntheticUIEvent getEmptyUIEvent() => SyntheticUIEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, 'empty event', null, null);
  static SyntheticWheelEvent getEmptyWheelEvent() => SyntheticWheelEvent(null, null, null, null, () {}, () {}, null, null, null, null, 0, 'empty event', null, null, null, null);

  static SyntheticEvent buildEvent(SyntheticEvent event, Map<String, dynamic> newEventFields) {
    return SyntheticEvent(
      newEventFields['bubbles'] ?? event?.bubbles,
      newEventFields['cancelable'] ?? event?.cancelable,
      newEventFields['currentTarget'] ?? event?.currentTarget,
      newEventFields['defaultPrevented'] ?? event?.defaultPrevented,
      newEventFields['preventDefault'] ?? event?.preventDefault,
      newEventFields['stopPropagation'] ?? event?.stopPropagation,
      newEventFields['eventPhase'] ?? event?.eventPhase,
      newEventFields['isTrusted'] ?? event?.isTrusted,
      newEventFields['nativeEvent'] ?? event?.nativeEvent,
      newEventFields['target'] ?? event?.target,
      newEventFields['timeStamp'] ?? event?.timeStamp,
      newEventFields['type'] ?? event?.type,
    );
  }

  static SyntheticClipboardEvent buildClipboardEvent(SyntheticClipboardEvent event, Map<String, dynamic> newEventFields) {
    return SyntheticClipboardEvent(
      newEventFields['bubbles'] ?? event?.bubbles,
      newEventFields['cancelable'] ?? event?.cancelable,
      newEventFields['currentTarget'] ?? event?.currentTarget,
      newEventFields['defaultPrevented'] ?? event?.defaultPrevented,
      newEventFields['preventDefault'] ?? event?.preventDefault,
      newEventFields['stopPropagation'] ?? event?.stopPropagation,
      newEventFields['eventPhase'] ?? event?.eventPhase,
      newEventFields['isTrusted'] ?? event?.isTrusted,
      newEventFields['nativeEvent'] ?? event?.nativeEvent,
      newEventFields['target'] ?? event?.target,
      newEventFields['timeStamp'] ?? event?.timeStamp,
      newEventFields['type'] ?? event?.type,
      newEventFields['clipboardData'] ?? event?.clipboardData,
    );
  }

  static SyntheticKeyboardEvent buildKeyboardEvent(SyntheticKeyboardEvent event, Map<String, dynamic> newEventFields) {
    return SyntheticKeyboardEvent(
      newEventFields['bubbles'] ?? event?.bubbles,
      newEventFields['cancelable'] ?? event?.cancelable,
      newEventFields['currentTarget'] ?? event?.currentTarget,
      newEventFields['defaultPrevented'] ?? event?.defaultPrevented,
      newEventFields['preventDefault'] ?? event?.preventDefault,
      newEventFields['stopPropagation'] ?? event?.stopPropagation,
      newEventFields['eventPhase'] ?? event?.eventPhase,
      newEventFields['isTrusted'] ?? event?.isTrusted,
      newEventFields['nativeEvent'] ?? event?.nativeEvent,
      newEventFields['target'] ?? event?.target,
      newEventFields['timeStamp'] ?? event?.timeStamp,
      newEventFields['type'] ?? event?.type,
      newEventFields['altKey'] ?? event?.altKey,
      newEventFields['char'] ?? event?.char,
      newEventFields['ctrlKey'] ?? event?.ctrlKey,
      newEventFields['locale'] ?? event?.locale,
      newEventFields['location'] ?? event?.location,
      newEventFields['key'] ?? event?.key,
      newEventFields['metaKey'] ?? event?.metaKey,
      newEventFields['repeat'] ?? event?.repeat,
      newEventFields['shiftKey'] ?? event?.shiftKey,
      newEventFields['keyCode'] ?? event?.keyCode,
      newEventFields['charCode'] ?? event?.charCode,
    );
  }

  static SyntheticCompositionEvent buildCompositionEvent(SyntheticCompositionEvent event, Map<String, dynamic> newEventFields) {
    return SyntheticCompositionEvent(
      newEventFields['bubbles'] ?? event?.bubbles,
      newEventFields['cancelable'] ?? event?.cancelable,
      newEventFields['currentTarget'] ?? event?.currentTarget,
      newEventFields['defaultPrevented'] ?? event?.defaultPrevented,
      newEventFields['preventDefault'] ?? event?.preventDefault,
      newEventFields['stopPropagation'] ?? event?.stopPropagation,
      newEventFields['eventPhase'] ?? event?.eventPhase,
      newEventFields['isTrusted'] ?? event?.isTrusted,
      newEventFields['nativeEvent'] ?? event?.nativeEvent,
      newEventFields['target'] ?? event?.target,
      newEventFields['timeStamp'] ?? event?.timeStamp,
      newEventFields['type'] ?? event?.type,
      newEventFields['data'] ?? event?.data,
    );
  }

  static SyntheticFocusEvent buildFocusEvent(SyntheticFocusEvent event, Map<String, dynamic> newEventFields) {
    return SyntheticFocusEvent(
      newEventFields['bubbles'] ?? event?.bubbles,
      newEventFields['cancelable'] ?? event?.cancelable,
      newEventFields['currentTarget'] ?? event?.currentTarget,
      newEventFields['defaultPrevented'] ?? event?.defaultPrevented,
      newEventFields['preventDefault'] ?? event?.preventDefault,
      newEventFields['stopPropagation'] ?? event?.stopPropagation,
      newEventFields['eventPhase'] ?? event?.eventPhase,
      newEventFields['isTrusted'] ?? event?.isTrusted,
      newEventFields['nativeEvent'] ?? event?.nativeEvent,
      newEventFields['target'] ?? event?.target,
      newEventFields['timeStamp'] ?? event?.timeStamp,
      newEventFields['type'] ?? event?.type,
      newEventFields['relatedTarget'] ?? event?.relatedTarget,
    );
  }

  static SyntheticFormEvent buildFormEvent(SyntheticFormEvent event, Map<String, dynamic> newEventFields) {
    return SyntheticFormEvent(
      newEventFields['bubbles'] ?? event?.bubbles,
      newEventFields['cancelable'] ?? event?.cancelable,
      newEventFields['currentTarget'] ?? event?.currentTarget,
      newEventFields['defaultPrevented'] ?? event?.defaultPrevented,
      newEventFields['preventDefault'] ?? event?.preventDefault,
      newEventFields['stopPropagation'] ?? event?.stopPropagation,
      newEventFields['eventPhase'] ?? event?.eventPhase,
      newEventFields['isTrusted'] ?? event?.isTrusted,
      newEventFields['nativeEvent'] ?? event?.nativeEvent,
      newEventFields['target'] ?? event?.target,
      newEventFields['timeStamp'] ?? event?.timeStamp,
      newEventFields['type'] ?? event?.type,
    );
  }

  static SyntheticMouseEvent buildMouseEvent(SyntheticMouseEvent event, Map<String, dynamic> newEventFields) {
    return SyntheticMouseEvent(
      newEventFields['bubbles'] ?? event?.bubbles,
      newEventFields['cancelable'] ?? event?.cancelable,
      newEventFields['currentTarget'] ?? event?.currentTarget,
      newEventFields['defaultPrevented'] ?? event?.defaultPrevented,
      newEventFields['preventDefault'] ?? event?.preventDefault,
      newEventFields['stopPropagation'] ?? event?.stopPropagation,
      newEventFields['eventPhase'] ?? event?.eventPhase,
      newEventFields['isTrusted'] ?? event?.isTrusted,
      newEventFields['nativeEvent'] ?? event?.nativeEvent,
      newEventFields['target'] ?? event?.target,
      newEventFields['timeStamp'] ?? event?.timeStamp,
      newEventFields['type'] ?? event?.type,
      newEventFields['altKey'] ?? event?.altKey,
      newEventFields['button'] ?? event?.button,
      newEventFields['buttons'] ?? event?.buttons,
      newEventFields['clientX'] ?? event?.clientX,
      newEventFields['clientY'] ?? event?.clientY,
      newEventFields['ctrlKey'] ?? event?.ctrlKey,
      newEventFields['dataTransfer'] ?? event?.dataTransfer,
      newEventFields['metaKey'] ?? event?.metaKey,
      newEventFields['pageX'] ?? event?.pageX,
      newEventFields['pageY'] ?? event?.pageY,
      newEventFields['relatedTarget'] ?? event?.relatedTarget,
      newEventFields['screenX'] ?? event?.screenX,
      newEventFields['screenY'] ?? event?.screenY,
      newEventFields['shiftKey'] ?? event?.shiftKey,
    );
  }

  static SyntheticPointerEvent buildPointerEvent(SyntheticPointerEvent event, Map<String, dynamic> newEventFields) {
    return SyntheticPointerEvent(
      newEventFields['bubbles'] ?? event?.bubbles,
      newEventFields['cancelable'] ?? event?.cancelable,
      newEventFields['currentTarget'] ?? event?.currentTarget,
      newEventFields['defaultPrevented'] ?? event?.defaultPrevented,
      newEventFields['preventDefault'] ?? event?.preventDefault,
      newEventFields['stopPropagation'] ?? event?.stopPropagation,
      newEventFields['eventPhase'] ?? event?.eventPhase,
      newEventFields['isTrusted'] ?? event?.isTrusted,
      newEventFields['nativeEvent'] ?? event?.nativeEvent,
      newEventFields['target'] ?? event?.target,
      newEventFields['timeStamp'] ?? event?.timeStamp,
      newEventFields['type'] ?? event?.type,
      newEventFields['pointerId'] ?? event?.pointerId,
      newEventFields['width'] ?? event?.width,
      newEventFields['height'] ?? event?.height,
      newEventFields['pressure'] ?? event?.pressure,
      newEventFields['tangentialPressure'] ?? event?.tangentialPressure,
      newEventFields['tiltX'] ?? event?.tiltX,
      newEventFields['tiltY'] ?? event?.tiltY,
      newEventFields['twist'] ?? event?.twist,
      newEventFields['pointerType'] ?? event?.pointerType,
      newEventFields['isPrimary'] ?? event?.isPrimary,
    );
  }

  static SyntheticTouchEvent buildTouchEvent(SyntheticTouchEvent event, Map<String, dynamic> newEventFields) {
    return SyntheticTouchEvent(
      newEventFields['bubbles'] ?? event?.bubbles,
      newEventFields['cancelable'] ?? event?.cancelable,
      newEventFields['currentTarget'] ?? event?.currentTarget,
      newEventFields['defaultPrevented'] ?? event?.defaultPrevented,
      newEventFields['preventDefault'] ?? event?.preventDefault,
      newEventFields['stopPropagation'] ?? event?.stopPropagation,
      newEventFields['eventPhase'] ?? event?.eventPhase,
      newEventFields['isTrusted'] ?? event?.isTrusted,
      newEventFields['nativeEvent'] ?? event?.nativeEvent,
      newEventFields['target'] ?? event?.target,
      newEventFields['timeStamp'] ?? event?.timeStamp,
      newEventFields['type'] ?? event?.type,
      newEventFields['altKey'] ?? event?.altKey,
      newEventFields['changedTouches'] ?? event?.changedTouches,
      newEventFields['ctrlKey'] ?? event?.ctrlKey,
      newEventFields['metaKey'] ?? event?.metaKey,
      newEventFields['shiftKey'] ?? event?.shiftKey,
      newEventFields['targetTouches'] ?? event?.targetTouches,
      newEventFields['touches'] ?? event?.touches,
    );
  }

  static SyntheticTransitionEvent buildTransitionEvent(SyntheticTransitionEvent event, Map<String, dynamic> newEventFields) {
    return SyntheticTransitionEvent(
      newEventFields['bubbles'] ?? event?.bubbles,
      newEventFields['cancelable'] ?? event?.cancelable,
      newEventFields['currentTarget'] ?? event?.currentTarget,
      newEventFields['defaultPrevented'] ?? event?.defaultPrevented,
      newEventFields['preventDefault'] ?? event?.preventDefault,
      newEventFields['stopPropagation'] ?? event?.stopPropagation,
      newEventFields['eventPhase'] ?? event?.eventPhase,
      newEventFields['isTrusted'] ?? event?.isTrusted,
      newEventFields['nativeEvent'] ?? event?.nativeEvent,
      newEventFields['target'] ?? event?.target,
      newEventFields['timeStamp'] ?? event?.timeStamp,
      newEventFields['type'] ?? event?.type,
      newEventFields['propertyName'] ?? event?.propertyName,
      newEventFields['elapsedTime'] ?? event?.elapsedTime,
      newEventFields['pseudoElement'] ?? event?.pseudoElement,
    );
  }

  static SyntheticAnimationEvent buildAnimationEvent(SyntheticAnimationEvent event, Map<String, dynamic> newEventFields) {
    return SyntheticAnimationEvent(
      newEventFields['bubbles'] ?? event?.bubbles,
      newEventFields['cancelable'] ?? event?.cancelable,
      newEventFields['currentTarget'] ?? event?.currentTarget,
      newEventFields['defaultPrevented'] ?? event?.defaultPrevented,
      newEventFields['preventDefault'] ?? event?.preventDefault,
      newEventFields['stopPropagation'] ?? event?.stopPropagation,
      newEventFields['eventPhase'] ?? event?.eventPhase,
      newEventFields['isTrusted'] ?? event?.isTrusted,
      newEventFields['nativeEvent'] ?? event?.nativeEvent,
      newEventFields['target'] ?? event?.target,
      newEventFields['timeStamp'] ?? event?.timeStamp,
      newEventFields['type'] ?? event?.type,
      newEventFields['animationName'] ?? event?.animationName,
      newEventFields['elapsedTime'] ?? event?.elapsedTime,
      newEventFields['pseudoElement'] ?? event?.pseudoElement,
    );
  }

  static SyntheticUIEvent buildUIEvent(SyntheticUIEvent event, Map<String, dynamic> newEventFields) {
    return SyntheticUIEvent(
      newEventFields['bubbles'] ?? event?.bubbles,
      newEventFields['cancelable'] ?? event?.cancelable,
      newEventFields['currentTarget'] ?? event?.currentTarget,
      newEventFields['defaultPrevented'] ?? event?.defaultPrevented,
      newEventFields['preventDefault'] ?? event?.preventDefault,
      newEventFields['stopPropagation'] ?? event?.stopPropagation,
      newEventFields['eventPhase'] ?? event?.eventPhase,
      newEventFields['isTrusted'] ?? event?.isTrusted,
      newEventFields['nativeEvent'] ?? event?.nativeEvent,
      newEventFields['target'] ?? event?.target,
      newEventFields['timeStamp'] ?? event?.timeStamp,
      newEventFields['type'] ?? event?.type,
      newEventFields['detail'] ?? event?.detail,
      newEventFields['view'] ?? event?.view,
    );
  }

  static SyntheticWheelEvent buildWheelEvent(SyntheticWheelEvent event, Map<String, dynamic> newEventFields) {
    return SyntheticWheelEvent(
      newEventFields['bubbles'] ?? event?.bubbles,
      newEventFields['cancelable'] ?? event?.cancelable,
      newEventFields['currentTarget'] ?? event?.currentTarget,
      newEventFields['defaultPrevented'] ?? event?.defaultPrevented,
      newEventFields['preventDefault'] ?? event?.preventDefault,
      newEventFields['stopPropagation'] ?? event?.stopPropagation,
      newEventFields['eventPhase'] ?? event?.eventPhase,
      newEventFields['isTrusted'] ?? event?.isTrusted,
      newEventFields['nativeEvent'] ?? event?.nativeEvent,
      newEventFields['target'] ?? event?.target,
      newEventFields['timeStamp'] ?? event?.timeStamp,
      newEventFields['type'] ?? event?.type,
      newEventFields['deltaX'] ?? event?.deltaX,
      newEventFields['deltaMode'] ?? event?.deltaMode,
      newEventFields['deltaY'] ?? event?.deltaY,
      newEventFields['deltaZ'] ?? event?.deltaZ,
    );
  }
}

// A temporary measure that will be removed when Duck typing is added
// in the React 17 release branch.
extension <T> on T {
  S tryCast<S extends T>() => this is S ? this : null;
}
{'fraction_non_alphanumeric': 0.13575380883802016, 'fraction_numerical': 0.0011369665731827483, 'mean_word_length': 5.683637284701114, 'pattern_counts': {'":': 0, '<': 56, '<?xml version=': 0, '>': 132, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4809640', 'n_tokens_mistral': 7461, 'n_tokens_neox': 7260, 'n_words': 1425}