{"ast":null,"code":"import _classCallCheck from \"@babel/runtime/helpers/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/createClass\";\nimport _assertThisInitialized from \"@babel/runtime/helpers/assertThisInitialized\";\nimport _inherits from \"@babel/runtime/helpers/inherits\";\nimport _possibleConstructorReturn from \"@babel/runtime/helpers/possibleConstructorReturn\";\nimport _getPrototypeOf from \"@babel/runtime/helpers/getPrototypeOf\";\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction _extends() {\n  _extends = Object.assign || function (target) {\n    for (var i = 1; i < arguments.length; i++) {\n      var source = arguments[i];\n      for (var key in source) {\n        if (Object.prototype.hasOwnProperty.call(source, key)) {\n          target[key] = source[key];\n        }\n      }\n    }\n    return target;\n  };\n  return _extends.apply(this, arguments);\n}\nfunction _defineProperty(obj, key, value) {\n  if (key in obj) {\n    Object.defineProperty(obj, key, {\n      value: value,\n      enumerable: true,\n      configurable: true,\n      writable: true\n    });\n  } else {\n    obj[key] = value;\n  }\n  return obj;\n}\nimport * as React from 'react';\nimport { Component } from 'react';\nimport Animated from \"react-native-web/dist/exports/Animated\";\nimport Platform from \"react-native-web/dist/exports/Platform\";\nimport { State } from \"../../State\";\nimport { BaseButton } from \"../GestureButtons\";\nexport var TOUCHABLE_STATE = {\n  UNDETERMINED: 0,\n  BEGAN: 1,\n  MOVED_OUTSIDE: 2\n};\nvar GenericTouchable = function (_Component) {\n  _inherits(GenericTouchable, _Component);\n  var _super = _createSuper(GenericTouchable);\n  function GenericTouchable() {\n    var _this;\n    _classCallCheck(this, GenericTouchable);\n    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n      args[_key] = arguments[_key];\n    }\n    _this = _super.call.apply(_super, [this].concat(args));\n    _defineProperty(_assertThisInitialized(_this), \"pressInTimeout\", void 0);\n    _defineProperty(_assertThisInitialized(_this), \"pressOutTimeout\", void 0);\n    _defineProperty(_assertThisInitialized(_this), \"longPressTimeout\", void 0);\n    _defineProperty(_assertThisInitialized(_this), \"longPressDetected\", false);\n    _defineProperty(_assertThisInitialized(_this), \"pointerInside\", true);\n    _defineProperty(_assertThisInitialized(_this), \"STATE\", TOUCHABLE_STATE.UNDETERMINED);\n    _defineProperty(_assertThisInitialized(_this), \"onGestureEvent\", function (_ref2) {\n      var pointerInside = _ref2.nativeEvent.pointerInside;\n      if (_this.pointerInside !== pointerInside) {\n        if (pointerInside) {\n          _this.onMoveIn();\n        } else {\n          _this.onMoveOut();\n        }\n      }\n      _this.pointerInside = pointerInside;\n    });\n    _defineProperty(_assertThisInitialized(_this), \"onHandlerStateChange\", function (_ref3) {\n      var nativeEvent = _ref3.nativeEvent;\n      var state = nativeEvent.state;\n      if (state === State.CANCELLED || state === State.FAILED) {\n        _this.moveToState(TOUCHABLE_STATE.UNDETERMINED);\n      } else if (state === (Platform.OS !== 'android' ? State.ACTIVE : State.BEGAN) && _this.STATE === TOUCHABLE_STATE.UNDETERMINED) {\n        _this.handlePressIn();\n      } else if (state === State.END) {\n        var shouldCallOnPress = !_this.longPressDetected && _this.STATE !== TOUCHABLE_STATE.MOVED_OUTSIDE && _this.pressOutTimeout === null;\n        _this.handleGoToUndetermined();\n        if (shouldCallOnPress) {\n          var _this$props$onPress, _this$props;\n          (_this$props$onPress = (_this$props = _this.props).onPress) === null || _this$props$onPress === void 0 ? void 0 : _this$props$onPress.call(_this$props);\n        }\n      }\n    });\n    _defineProperty(_assertThisInitialized(_this), \"onLongPressDetected\", function () {\n      var _this$props$onLongPre, _this$props2;\n      _this.longPressDetected = true;\n      (_this$props$onLongPre = (_this$props2 = _this.props).onLongPress) === null || _this$props$onLongPre === void 0 ? void 0 : _this$props$onLongPre.call(_this$props2);\n    });\n    return _this;\n  }\n  _createClass(GenericTouchable, [{\n    key: \"handlePressIn\",\n    value: function handlePressIn() {\n      var _this2 = this;\n      if (this.props.delayPressIn) {\n        this.pressInTimeout = setTimeout(function () {\n          _this2.moveToState(TOUCHABLE_STATE.BEGAN);\n          _this2.pressInTimeout = null;\n        }, this.props.delayPressIn);\n      } else {\n        this.moveToState(TOUCHABLE_STATE.BEGAN);\n      }\n      if (this.props.onLongPress) {\n        var time = (this.props.delayPressIn || 0) + (this.props.delayLongPress || 0);\n        this.longPressTimeout = setTimeout(this.onLongPressDetected, time);\n      }\n    }\n  }, {\n    key: \"handleMoveOutside\",\n    value: function handleMoveOutside() {\n      var _this3 = this;\n      if (this.props.delayPressOut) {\n        this.pressOutTimeout = this.pressOutTimeout || setTimeout(function () {\n          _this3.moveToState(TOUCHABLE_STATE.MOVED_OUTSIDE);\n          _this3.pressOutTimeout = null;\n        }, this.props.delayPressOut);\n      } else {\n        this.moveToState(TOUCHABLE_STATE.MOVED_OUTSIDE);\n      }\n    }\n  }, {\n    key: \"handleGoToUndetermined\",\n    value: function handleGoToUndetermined() {\n      var _this4 = this;\n      clearTimeout(this.pressOutTimeout);\n      if (this.props.delayPressOut) {\n        this.pressOutTimeout = setTimeout(function () {\n          if (_this4.STATE === TOUCHABLE_STATE.UNDETERMINED) {\n            _this4.moveToState(TOUCHABLE_STATE.BEGAN);\n          }\n          _this4.moveToState(TOUCHABLE_STATE.UNDETERMINED);\n          _this4.pressOutTimeout = null;\n        }, this.props.delayPressOut);\n      } else {\n        if (this.STATE === TOUCHABLE_STATE.UNDETERMINED) {\n          this.moveToState(TOUCHABLE_STATE.BEGAN);\n        }\n        this.moveToState(TOUCHABLE_STATE.UNDETERMINED);\n      }\n    }\n  }, {\n    key: \"componentDidMount\",\n    value: function componentDidMount() {\n      this.reset();\n    }\n  }, {\n    key: \"reset\",\n    value: function reset() {\n      this.longPressDetected = false;\n      this.pointerInside = true;\n      clearTimeout(this.pressInTimeout);\n      clearTimeout(this.pressOutTimeout);\n      clearTimeout(this.longPressTimeout);\n      this.pressOutTimeout = null;\n      this.longPressTimeout = null;\n      this.pressInTimeout = null;\n    }\n  }, {\n    key: \"moveToState\",\n    value: function moveToState(newState) {\n      var _this$props$onStateCh, _this$props6;\n      if (newState === this.STATE) {\n        return;\n      }\n      if (newState === TOUCHABLE_STATE.BEGAN) {\n        var _this$props$onPressIn, _this$props3;\n        (_this$props$onPressIn = (_this$props3 = this.props).onPressIn) === null || _this$props$onPressIn === void 0 ? void 0 : _this$props$onPressIn.call(_this$props3);\n      } else if (newState === TOUCHABLE_STATE.MOVED_OUTSIDE) {\n        var _this$props$onPressOu, _this$props4;\n        (_this$props$onPressOu = (_this$props4 = this.props).onPressOut) === null || _this$props$onPressOu === void 0 ? void 0 : _this$props$onPressOu.call(_this$props4);\n      } else if (newState === TOUCHABLE_STATE.UNDETERMINED) {\n        this.reset();\n        if (this.STATE === TOUCHABLE_STATE.BEGAN) {\n          var _this$props$onPressOu2, _this$props5;\n          (_this$props$onPressOu2 = (_this$props5 = this.props).onPressOut) === null || _this$props$onPressOu2 === void 0 ? void 0 : _this$props$onPressOu2.call(_this$props5);\n        }\n      }\n      (_this$props$onStateCh = (_this$props6 = this.props).onStateChange) === null || _this$props$onStateCh === void 0 ? void 0 : _this$props$onStateCh.call(_this$props6, this.STATE, newState);\n      this.STATE = newState;\n    }\n  }, {\n    key: \"componentWillUnmount\",\n    value: function componentWillUnmount() {\n      this.reset();\n    }\n  }, {\n    key: \"onMoveIn\",\n    value: function onMoveIn() {\n      if (this.STATE === TOUCHABLE_STATE.MOVED_OUTSIDE) {\n        this.moveToState(TOUCHABLE_STATE.BEGAN);\n      }\n    }\n  }, {\n    key: \"onMoveOut\",\n    value: function onMoveOut() {\n      clearTimeout(this.longPressTimeout);\n      this.longPressTimeout = null;\n      if (this.STATE === TOUCHABLE_STATE.BEGAN) {\n        this.handleMoveOutside();\n      }\n    }\n  }, {\n    key: \"render\",\n    value: function render() {\n      var _ref, _this$props$touchSoun;\n      var hitSlop = (_ref = typeof this.props.hitSlop === 'number' ? {\n        top: this.props.hitSlop,\n        left: this.props.hitSlop,\n        bottom: this.props.hitSlop,\n        right: this.props.hitSlop\n      } : this.props.hitSlop) !== null && _ref !== void 0 ? _ref : undefined;\n      var coreProps = {\n        accessible: this.props.accessible !== false,\n        accessibilityLabel: this.props.accessibilityLabel,\n        accessibilityHint: this.props.accessibilityHint,\n        accessibilityRole: this.props.accessibilityRole,\n        accessibilityState: this.props.accessibilityState,\n        accessibilityActions: this.props.accessibilityActions,\n        onAccessibilityAction: this.props.onAccessibilityAction,\n        nativeID: this.props.nativeID,\n        onLayout: this.props.onLayout,\n        hitSlop: hitSlop\n      };\n      return React.createElement(BaseButton, _extends({\n        style: this.props.containerStyle,\n        onHandlerStateChange: this.props.disabled ? undefined : this.onHandlerStateChange,\n        onGestureEvent: this.onGestureEvent,\n        hitSlop: hitSlop,\n        shouldActivateOnStart: this.props.shouldActivateOnStart,\n        disallowInterruption: this.props.disallowInterruption,\n        testID: this.props.testID,\n        touchSoundDisabled: (_this$props$touchSoun = this.props.touchSoundDisabled) !== null && _this$props$touchSoun !== void 0 ? _this$props$touchSoun : false,\n        enabled: !this.props.disabled\n      }, this.props.extraButtonProps), React.createElement(Animated.View, _extends({}, coreProps, {\n        style: this.props.style\n      }), this.props.children));\n    }\n  }]);\n  return GenericTouchable;\n}(Component);\nexport { GenericTouchable as default };\n_defineProperty(GenericTouchable, \"defaultProps\", {\n  delayLongPress: 600,\n  extraButtonProps: {\n    rippleColor: 'transparent',\n    exclusive: true\n  }\n});","map":{"version":3,"sources":["GenericTouchable.tsx"],"names":["React","Component","State","BaseButton","TOUCHABLE_STATE","UNDETERMINED","BEGAN","MOVED_OUTSIDE","GenericTouchable","delayLongPress","extraButtonProps","rippleColor","exclusive","handlePressIn","props","delayPressIn","pressInTimeout","setTimeout","moveToState","onLongPress","time","longPressTimeout","onLongPressDetected","handleMoveOutside","delayPressOut","pressOutTimeout","handleGoToUndetermined","clearTimeout","STATE","componentDidMount","reset","longPressDetected","pointerInside","newState","onPressIn","onPressOut","onStateChange","nativeEvent","onMoveIn","onMoveOut","state","CANCELLED","FAILED","Platform","OS","ACTIVE","END","shouldCallOnPress","onPress","componentWillUnmount","render","hitSlop","top","left","bottom","right","undefined","coreProps","accessible","accessibilityLabel","accessibilityHint","accessibilityRole","accessibilityState","accessibilityActions","onAccessibilityAction","nativeID","onLayout","containerStyle","disabled","onHandlerStateChange","onGestureEvent","shouldActivateOnStart","disallowInterruption","testID","touchSoundDisabled","style","children"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,SAAT,QAA0B,OAA1B;AAAA,OAAA,QAAA;AAAA,OAAA,QAAA;AASA,SAASC,KAAT;AACA,SAASC,UAAT;AAgBA,OAAO,IAAMC,eAAe,GAAG;EAC7BC,YAAY,EAAE,CADe;EAE7BC,KAAK,EAAE,CAFsB;EAG7BC,aAAa,EAAE;AAHc,CAAxB;AAAA,IAuCcC,gBAAN,aAAA,UAAA;EAAA,SAAA,CAAA,gBAAA,EAAA,UAAA;EAAA,IAAA,MAAA,GAAA,YAAA,CAAA,gBAAA;EAEb,SAAA,iBAAA,EAAA;IAAA,IAAA,KAAA;IAAA,eAAA,OAAA,gBAAA;IAAA,SAAA,IAAA,GAAA,SAAA,CAAA,MAAA,EAAA,IAAA,OAAA,KAAA,CAAA,IAAA,GAAA,IAAA,MAAA,IAAA,GAAA,IAAA,EAAA,IAAA;MAAA,IAAA,CAAA,IAAA,IAAA,SAAA,CAAA,IAAA;IAAA;IAAA,KAAA,GAAA,MAAA,CAAA,IAAA,CAAA,KAAA,CAA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C,KAAL,CAAW6D;MAAhD,CAAA,CAAA,EACG,IAAA,CAAK7D,KAAL,CAAW8D,QADd,CAdF,CADF;IAoBD;EAAA;EAAA,OAAA,gBAAA;AAAA,EAzO2C3E,SAA/B;AAAA,SAAMO,gBAAN,IAAA,OAAA;gBAAMA,gB,kBAGG;EACpBC,cAAc,EAAE,GADI;EAEpBC,gBAAgB,EAAE;IAChBC,WAAW,EAAE,aADG;IAEhBC,SAAS,EAAE;EAFK;AAFE,C","sourcesContent":["import * as React from 'react';\nimport { Component } from 'react';\nimport {\n  Animated,\n  Platform,\n  StyleProp,\n  ViewStyle,\n  TouchableWithoutFeedbackProps,\n} from 'react-native';\n\nimport { State } from '../../State';\nimport { BaseButton } from '../GestureButtons';\n\nimport {\n  GestureEvent,\n  HandlerStateChangeEvent,\n} from '../../handlers/gestureHandlerCommon';\nimport { NativeViewGestureHandlerPayload } from '../../handlers/NativeViewGestureHandler';\nimport { TouchableNativeFeedbackExtraProps } from './TouchableNativeFeedback.android';\n\n/**\n * Each touchable is a states' machine which preforms transitions.\n * On very beginning (and on the very end or recognition) touchable is\n * UNDETERMINED. Then it moves to BEGAN. If touchable recognizes that finger\n * travel outside it transits to special MOVED_OUTSIDE state. Gesture recognition\n * finishes in UNDETERMINED state.\n */\nexport const TOUCHABLE_STATE = {\n  UNDETERMINED: 0,\n  BEGAN: 1,\n  MOVED_OUTSIDE: 2,\n} as const;\n\ntype TouchableState = typeof TOUCHABLE_STATE[keyof typeof TOUCHABLE_STATE];\n\nexport interface GenericTouchableProps extends TouchableWithoutFeedbackProps {\n  // Decided to drop not used fields from RN's implementation.\n  // e.g. onBlur and onFocus as well as deprecated props. - TODO: this comment may be unuseful in this moment\n\n  // TODO: in RN these events get native event parameter, which prolly could be used in our implementation too\n  onPress?: () => void;\n  onPressIn?: () => void;\n  onPressOut?: () => void;\n  onLongPress?: () => void;\n\n  nativeID?: string;\n  shouldActivateOnStart?: boolean;\n  disallowInterruption?: boolean;\n\n  containerStyle?: StyleProp<ViewStyle>;\n}\n\ninterface InternalProps {\n  extraButtonProps: TouchableNativeFeedbackExtraProps;\n  onStateChange?: (oldState: TouchableState, newState: TouchableState) => void;\n}\n\n// TODO: maybe can be better\n// TODO: all clearTimeout have ! added, maybe they shouldn't ?\ntype Timeout = ReturnType<typeof setTimeout> | null | undefined;\n\n/**\n * GenericTouchable is not intented to be used as it is.\n * Should be treated as a source for the rest of touchables\n */\n\nexport default class GenericTouchable extends Component<\n  GenericTouchableProps & InternalProps\n> {\n  static defaultProps = {\n    delayLongPress: 600,\n    extraButtonProps: {\n      rippleColor: 'transparent',\n      exclusive: true,\n    },\n  };\n\n  // timeout handlers\n  pressInTimeout: Timeout;\n  pressOutTimeout: Timeout;\n  longPressTimeout: Timeout;\n\n  // This flag is required since recognition of longPress implies not-invoking onPress\n  longPressDetected = false;\n\n  pointerInside = true;\n\n  // State of touchable\n  STATE: TouchableState = TOUCHABLE_STATE.UNDETERMINED;\n\n  // handlePressIn in called on first touch on traveling inside component.\n  // Handles state transition with delay.\n  handlePressIn() {\n    if (this.props.delayPressIn) {\n      this.pressInTimeout = setTimeout(() => {\n        this.moveToState(TOUCHABLE_STATE.BEGAN);\n        this.pressInTimeout = null;\n      }, this.props.delayPressIn);\n    } else {\n      this.moveToState(TOUCHABLE_STATE.BEGAN);\n    }\n    if (this.props.onLongPress) {\n      const time =\n        (this.props.delayPressIn || 0) + (this.props.delayLongPress || 0);\n      this.longPressTimeout = setTimeout(this.onLongPressDetected, time);\n    }\n  }\n  // handleMoveOutside in called on traveling outside component.\n  // Handles state transition with delay.\n  handleMoveOutside() {\n    if (this.props.delayPressOut) {\n      this.pressOutTimeout =\n        this.pressOutTimeout ||\n        setTimeout(() => {\n          this.moveToState(TOUCHABLE_STATE.MOVED_OUTSIDE);\n          this.pressOutTimeout = null;\n        }, this.props.delayPressOut);\n    } else {\n      this.moveToState(TOUCHABLE_STATE.MOVED_OUTSIDE);\n    }\n  }\n\n  // handleGoToUndetermined transits to UNDETERMINED state with proper delay\n  handleGoToUndetermined() {\n    clearTimeout(this.pressOutTimeout!); // TODO: maybe it can be undefined\n    if (this.props.delayPressOut) {\n      this.pressOutTimeout = setTimeout(() => {\n        if (this.STATE === TOUCHABLE_STATE.UNDETERMINED) {\n          this.moveToState(TOUCHABLE_STATE.BEGAN);\n        }\n        this.moveToState(TOUCHABLE_STATE.UNDETERMINED);\n        this.pressOutTimeout = null;\n      }, this.props.delayPressOut);\n    } else {\n      if (this.STATE === TOUCHABLE_STATE.UNDETERMINED) {\n        this.moveToState(TOUCHABLE_STATE.BEGAN);\n      }\n      this.moveToState(TOUCHABLE_STATE.UNDETERMINED);\n    }\n  }\n\n  componentDidMount() {\n    this.reset();\n  }\n  // reset timeout to prevent memory leaks.\n  reset() {\n    this.longPressDetected = false;\n    this.pointerInside = true;\n    clearTimeout(this.pressInTimeout!);\n    clearTimeout(this.pressOutTimeout!);\n    clearTimeout(this.longPressTimeout!);\n    this.pressOutTimeout = null;\n    this.longPressTimeout = null;\n    this.pressInTimeout = null;\n  }\n\n  // All states' transitions are defined here.\n  moveToState(newState: TouchableState) {\n    if (newState === this.STATE) {\n      // Ignore dummy transitions\n      return;\n    }\n    if (newState === TOUCHABLE_STATE.BEGAN) {\n      // First touch and moving inside\n      this.props.onPressIn?.();\n    } else if (newState === TOUCHABLE_STATE.MOVED_OUTSIDE) {\n      // Moving outside\n      this.props.onPressOut?.();\n    } else if (newState === TOUCHABLE_STATE.UNDETERMINED) {\n      // Need to reset each time on transition to UNDETERMINED\n      this.reset();\n      if (this.STATE === TOUCHABLE_STATE.BEGAN) {\n        // ... and if it happens inside button.\n        this.props.onPressOut?.();\n      }\n    }\n    // Finally call lister (used by subclasses)\n    this.props.onStateChange?.(this.STATE, newState);\n    // ... and make transition.\n    this.STATE = newState;\n  }\n\n  onGestureEvent = ({\n    nativeEvent: { pointerInside },\n  }: GestureEvent<NativeViewGestureHandlerPayload>) => {\n    if (this.pointerInside !== pointerInside) {\n      if (pointerInside) {\n        this.onMoveIn();\n      } else {\n        this.onMoveOut();\n      }\n    }\n    this.pointerInside = pointerInside;\n  };\n\n  onHandlerStateChange = ({\n    nativeEvent,\n  }: HandlerStateChangeEvent<NativeViewGestureHandlerPayload>) => {\n    const { state } = nativeEvent;\n    if (state === State.CANCELLED || state === State.FAILED) {\n      // Need to handle case with external cancellation (e.g. by ScrollView)\n      this.moveToState(TOUCHABLE_STATE.UNDETERMINED);\n    } else if (\n      // This platform check is an implication of slightly different behavior of handlers on different platform.\n      // And Android \"Active\" state is achieving on first move of a finger, not on press in.\n      // On iOS event on \"Began\" is not delivered.\n      state === (Platform.OS !== 'android' ? State.ACTIVE : State.BEGAN) &&\n      this.STATE === TOUCHABLE_STATE.UNDETERMINED\n    ) {\n      // Moving inside requires\n      this.handlePressIn();\n    } else if (state === State.END) {\n      const shouldCallOnPress =\n        !this.longPressDetected &&\n        this.STATE !== TOUCHABLE_STATE.MOVED_OUTSIDE &&\n        this.pressOutTimeout === null;\n      this.handleGoToUndetermined();\n      if (shouldCallOnPress) {\n        // Calls only inside component whether no long press was called previously\n        this.props.onPress?.();\n      }\n    }\n  };\n\n  onLongPressDetected = () => {\n    this.longPressDetected = true;\n    // checked for in the caller of `onLongPressDetected`, but better to check twice\n    this.props.onLongPress?.();\n  };\n\n  componentWillUnmount() {\n    // to prevent memory leaks\n    this.reset();\n  }\n\n  onMoveIn() {\n    if (this.STATE === TOUCHABLE_STATE.MOVED_OUTSIDE) {\n      // This call is not throttled with delays (like in RN's implementation).\n      this.moveToState(TOUCHABLE_STATE.BEGAN);\n    }\n  }\n\n  onMoveOut() {\n    // long press should no longer be detected\n    clearTimeout(this.longPressTimeout!);\n    this.longPressTimeout = null;\n    if (this.STATE === TOUCHABLE_STATE.BEGAN) {\n      this.handleMoveOutside();\n    }\n  }\n\n  render() {\n    const hitSlop =\n      (typeof this.props.hitSlop === 'number'\n        ? {\n            top: this.props.hitSlop,\n            left: this.props.hitSlop,\n            bottom: this.props.hitSlop,\n            right: this.props.hitSlop,\n          }\n        : this.props.hitSlop) ?? undefined;\n\n    const coreProps = {\n      accessible: this.props.accessible !== false,\n      accessibilityLabel: this.props.accessibilityLabel,\n      accessibilityHint: this.props.accessibilityHint,\n      accessibilityRole: this.props.accessibilityRole,\n      // TODO: check if changed to no 's' correctly, also removed 2 props that are no longer available: `accessibilityComponentType` and `accessibilityTraits`,\n      // would be good to check if it is ok for sure, see: https://github.com/facebook/react-native/issues/24016\n      accessibilityState: this.props.accessibilityState,\n      accessibilityActions: this.props.accessibilityActions,\n      onAccessibilityAction: this.props.onAccessibilityAction,\n      nativeID: this.props.nativeID,\n      onLayout: this.props.onLayout,\n      hitSlop: hitSlop as\n        | Animated.WithAnimatedObject<typeof hitSlop>\n        | undefined,\n    };\n\n    return (\n      <BaseButton\n        style={this.props.containerStyle}\n        onHandlerStateChange={\n          // TODO: not sure if it can be undefined instead of null\n          this.props.disabled ? undefined : this.onHandlerStateChange\n        }\n        onGestureEvent={this.onGestureEvent}\n        hitSlop={hitSlop}\n        shouldActivateOnStart={this.props.shouldActivateOnStart}\n        disallowInterruption={this.props.disallowInterruption}\n        testID={this.props.testID}\n        touchSoundDisabled={this.props.touchSoundDisabled ?? false}\n        enabled={!this.props.disabled}\n        {...this.props.extraButtonProps}>\n        <Animated.View {...coreProps} style={this.props.style}>\n          {this.props.children}\n        </Animated.View>\n      </BaseButton>\n    );\n  }\n}\n"]},"metadata":{},"sourceType":"module"}