You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
43 KiB

{"ast":null,"code":"import _toConsumableArray from \"@babel/runtime/helpers/toConsumableArray\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/objectWithoutProperties\";\nimport _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport _classCallCheck from \"@babel/runtime/helpers/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/createClass\";\nimport _inherits from \"@babel/runtime/helpers/inherits\";\nimport _possibleConstructorReturn from \"@babel/runtime/helpers/possibleConstructorReturn\";\nimport _getPrototypeOf from \"@babel/runtime/helpers/getPrototypeOf\";\nvar _excluded = [\"state\", \"descriptors\"];\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\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 ? Object.assign.bind() : 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}\nimport { HeaderShownContext, SafeAreaProviderCompat } from '@react-navigation/elements';\nimport { StackActions } from '@react-navigation/native';\nimport * as React from 'react';\nimport StyleSheet from \"react-native-web/dist/exports/StyleSheet\";\nimport View from \"react-native-web/dist/exports/View\";\nimport { SafeAreaInsetsContext } from 'react-native-safe-area-context';\nimport ModalPresentationContext from \"../../utils/ModalPresentationContext\";\nimport { GestureHandlerRootView } from \"../GestureHandler\";\nimport HeaderContainer from \"../Header/HeaderContainer\";\nimport CardStack from \"./CardStack\";\nvar GestureHandlerWrapper = GestureHandlerRootView != null ? GestureHandlerRootView : View;\nvar isArrayEqual = function isArrayEqual(a, b) {\n return a.length === b.length && a.every(function (it, index) {\n return it === b[index];\n });\n};\nvar StackView = function (_React$Component) {\n _inherits(StackView, _React$Component);\n var _super = _createSuper(StackView);\n function StackView() {\n var _this;\n _classCallCheck(this, StackView);\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 _this.state = {\n routes: [],\n previousRoutes: [],\n previousDescriptors: {},\n openingRouteKeys: [],\n closingRouteKeys: [],\n replacingRouteKeys: [],\n descriptors: {}\n };\n _this.getPreviousRoute = function (_ref2) {\n var route = _ref2.route;\n var _this$state = _this.state,\n closingRouteKeys = _this$state.closingRouteKeys,\n replacingRouteKeys = _this$state.replacingRouteKeys;\n var routes = _this.state.routes.filter(function (r) {\n return r.key === route.key || !closingRouteKeys.includes(r.key) && !replacingRouteKeys.includes(r.key);\n });\n var index = routes.findIndex(function (r) {\n return r.key === route.key;\n });\n return routes[index - 1];\n };\n _this.renderScene = function (_ref3) {\n var route = _ref3.route;\n var descriptor = _this.state.descriptors[route.key] || _this.props.descriptors[route.key];\n if (!descriptor) {\n return null;\n }\n return descriptor.render();\n };\n _this.renderHeader = function (props) {\n return React.createElement(HeaderContainer, props);\n };\n _this.handleOpenRoute = function (_ref4) {\n var route = _ref4.route;\n var _this$props = _this.props,\n state = _this$props.state,\n navigation = _this$props.navigation;\n var _this$state2 = _this.state,\n closingRouteKeys = _this$state2.closingRouteKeys,\n replacingRouteKeys = _this$state2.replacingRouteKeys;\n if (closingRouteKeys.some(function (key) {\n return key === route.key;\n }) && replacingRouteKeys.every(function (key) {\n return key !== route.key;\n }) && state.routeNames.includes(route.name) && !state.routes.some(function (r) {\n return r.key === route.key;\n })) {\n navigation.navigate(route);\n } else {\n _this.setState(function (state) {\n return {\n routes: state.replacingRouteKeys.length ? state.routes.filter(function (r) {\n return !state.replacingRouteKeys.includes(r.key);\n }) : state.routes,\n openingRouteKeys: state.openingRouteKeys.filter(function (key) {\n return key !== route.key;\n }),\n closingRouteKeys: state.closingRouteKeys.filter(function (key) {\n return key !== route.key;\n }),\n replacingRouteKeys: []\n };\n });\n }\n };\n _this.handleCloseRoute = function (_ref5) {\n var route = _ref5.route;\n var _this$props2 = _this.props,\n state = _this$props2.state,\n navigation = _this$props2.navigation;\n if (state.routes.some(function (r) {\n return r.key === route.key;\n })) {\n navigation.dispatch(_objectSpread(_objectSpread({}, StackActions.pop()), {}, {\n source: route.key,\n target: state.key\n }));\n } else {\n _this.setState(function (state) {\n return {\n routes: state.routes.filter(function (r) {\n return r.key !== route.key;\n }),\n openingRouteKeys: state.openingRouteKeys.filter(function (key) {\n return key !== route.key;\n }),\n closingRouteKeys: state.closingRouteKeys.filter(function (key) {\n return key !== route.key;\n })\n };\n });\n }\n };\n _this.handleTransitionStart = function (_ref6, closing) {\n var route = _ref6.route;\n return _this.props.navigation.emit({\n type: 'transitionStart',\n data: {\n closing: closing\n },\n target: route.key\n });\n };\n _this.handleTransitionEnd = function (_ref7, closing) {\n var route = _ref7.route;\n return _this.props.navigation.emit({\n type: 'transitionEnd',\n data: {\n closing: closing\n },\n target: route.key\n });\n };\n _this.handleGestureStart = function (_ref8) {\n var route = _ref8.route;\n _this.props.navigation.emit({\n type: 'gestureStart',\n target: route.key\n });\n };\n _this.handleGestureEnd = function (_ref9) {\n var route = _ref9.route;\n _this.props.navigation.emit({\n type: 'gestureEnd',\n target: route.key\n });\n };\n _this.handleGestureCancel = function (_ref10) {\n var route = _ref10.route;\n _this.props.navigation.emit({\n type: 'gestureCancel',\n target: route.key\n });\n };\n return _this;\n }\n _createClass(StackView, [{\n key: \"render\",\n value: function render() {\n var _this2 = this;\n var _this$props3 = this.props,\n state = _this$props3.state,\n _ = _this$props3.descriptors,\n rest = _objectWithoutProperties(_this$props3, _excluded);\n var _this$state3 = this.state,\n routes = _this$state3.routes,\n descriptors = _this$state3.descriptors,\n openingRouteKeys = _this$state3.openingRouteKeys,\n closingRouteKeys = _this$state3.closingRouteKeys;\n return React.createElement(GestureHandlerWrapper, {\n style: styles.container\n }, React.createElement(SafeAreaProviderCompat, null, React.createElement(SafeAreaInsetsContext.Consumer, null, function (insets) {\n return React.createElement(ModalPresentationContext.Consumer, null, function (isParentModal) {\n return React.createElement(HeaderShownContext.Consumer, null, function (isParentHeaderShown) {\n return React.createElement(CardStack, _extends({\n insets: insets,\n isParentHeaderShown: isParentHeaderShown,\n isParentModal: isParentModal,\n getPreviousRoute: _this2.getPreviousRoute,\n routes: routes,\n openingRouteKeys: openingRouteKeys,\n closingRouteKeys: closingRouteKeys,\n onOpenRoute: _this2.handleOpenRoute,\n onCloseRoute: _this2.handleCloseRoute,\n onTransitionStart: _this2.handleTransitionStart,\n onTransitionEnd: _this2.handleTransitionEnd,\n renderHeader: _this2.renderHeader,\n renderScene: _this2.renderScene,\n state: state,\n descriptors: descriptors,\n onGestureStart: _this2.handleGestureStart,\n onGestureEnd: _this2.handleGestureEnd,\n onGestureCancel: _this2.handleGestureCancel\n }, rest));\n });\n });\n })));\n }\n }], [{\n key: \"getDerivedStateFromProps\",\n value: function getDerivedStateFromProps(props, state) {\n if ((props.state.routes === state.previousRoutes || isArrayEqual(props.state.routes.map(function (r) {\n return r.key;\n }), state.previousRoutes.map(function (r) {\n return r.key;\n }))) && state.routes.length) {\n var _routes = state.routes;\n var _previousRoutes = state.previousRoutes;\n var _descriptors = props.descriptors;\n var previousDescriptors = state.previousDescriptors;\n if (props.descriptors !== state.previousDescriptors) {\n _descriptors = state.routes.reduce(function (acc, route) {\n acc[route.key] = props.descriptors[route.key] || state.descriptors[route.key];\n return acc;\n }, {});\n previousDescriptors = props.descriptors;\n }\n if (props.state.routes !== state.previousRoutes) {\n var map = props.state.routes.reduce(function (acc, route) {\n acc[route.key] = route;\n return acc;\n }, {});\n _routes = state.routes.map(function (route) {\n return map[route.key] || route;\n });\n _previousRoutes = props.state.routes;\n }\n return {\n routes: _routes,\n previousRoutes: _previousRoutes,\n descriptors: _descriptors,\n previousDescriptors: previousDescriptors\n };\n }\n var routes = props.state.index < props.state.routes.length - 1 ? props.state.routes.slice(0, props.state.index + 1) : props.state.routes;\n var openingRouteKeys = state.openingRouteKeys,\n closingRouteKeys = state.closingRouteKeys,\n replacingRouteKeys = state.replacingRouteKeys,\n previousRoutes = state.previousRoutes;\n var previousFocusedRoute = previousRoutes[previousRoutes.length - 1];\n var nextFocusedRoute = routes[routes.length - 1];\n var isAnimationEnabled = function isAnimationEnabled(key) {\n var descriptor = props.descriptors[key] || state.descriptors[key];\n return descriptor ? descriptor.options.animationEnabled !== false : true;\n };\n var getAnimationTypeForReplace = function getAnimationTypeForReplace(key) {\n var _descriptor$options$a;\n var descriptor = props.descriptors[key] || state.descriptors[key];\n return (_descriptor$options$a = descriptor.options.animationTypeForReplace) != null ? _descriptor$options$a : 'push';\n };\n if (previousFocusedRoute && previousFocusedRoute.key !== nextFocusedRoute.key) {\n if (!previousRoutes.some(function (r) {\n return r.key === nextFocusedRoute.key;\n })) {\n if (isAnimationEnabled(nextFocusedRoute.key) && !openingRouteKeys.includes(nextFocusedRoute.key)) {\n openingRouteKeys = [].concat(_toConsumableArray(openingRouteKeys), [nextFocusedRoute.key]);\n closingRouteKeys = closingRouteKeys.filter(function (key) {\n return key !== nextFocusedRoute.key;\n });\n replacingRouteKeys = replacingRouteKeys.filter(function (key) {\n return key !== nextFocusedRoute.key;\n });\n if (!routes.some(function (r) {\n return r.key === previousFocusedRoute.key;\n })) {\n openingRouteKeys = openingRouteKeys.filter(function (key) {\n return key !== previousFocusedRoute.key;\n });\n if (getAnimationTypeForReplace(nextFocusedRoute.key) === 'pop') {\n closingRouteKeys = [].concat(_toConsumableArray(closingRouteKeys), [previousFocusedRoute.key]);\n openingRouteKeys = openingRouteKeys.filter(function (key) {\n return key !== nextFocusedRoute.key;\n });\n routes = [].concat(_toConsumableArray(routes), [previousFocusedRoute]);\n } else {\n replacingRouteKeys = [].concat(_toConsumableArray(replacingRouteKeys), [previousFocusedRoute.key]);\n closingRouteKeys = closingRouteKeys.filter(function (key) {\n return key !== previousFocusedRoute.key;\n });\n routes = routes.slice();\n routes.splice(routes.length - 1, 0, previousFocusedRoute);\n }\n }\n }\n } else if (!routes.some(function (r) {\n return r.key === previousFocusedRoute.key;\n })) {\n if (isAnimationEnabled(previousFocusedRoute.key) && !closingRouteKeys.includes(previousFocusedRoute.key)) {\n closingRouteKeys = [].concat(_toConsumableArray(closingRouteKeys), [previousFocusedRoute.key]);\n openingRouteKeys = openingRouteKeys.filter(function (key) {\n return key !== previousFocusedRoute.key;\n });\n replacingRouteKeys = replacingRouteKeys.filter(function (key) {\n return key !== previousFocusedRoute.key;\n });\n routes = [].concat(_toConsumableArray(routes), [previousFocusedRoute]);\n }\n } else {}\n } else if (replacingRouteKeys.length || closingRouteKeys.length) {\n var _routes2;\n routes = routes.slice();\n (_routes2 = routes).splice.apply(_routes2, [routes.length - 1, 0].concat(_toConsumableArray(state.routes.filter(function (_ref) {\n var key = _ref.key;\n return isAnimationEnabled(key) ? replacingRouteKeys.includes(key) || closingRouteKeys.includes(key) : false;\n }))));\n }\n if (!routes.length) {\n throw new Error('There should always be at least one route in the navigation state.');\n }\n var descriptors = routes.reduce(function (acc, route) {\n acc[route.key] = props.descriptors[route.key] || state.descriptors[route.key];\n return acc;\n }, {});\n return {\n routes: routes,\n previousRoutes: props.state.routes,\n previousDescriptors: props.descriptors,\n openingRouteKeys: openingRouteKeys,\n closingRouteKeys: closingRouteKeys,\n replacingRouteKeys: replacingRouteKeys,\n descriptors: descriptors\n };\n }\n }]);\n return StackView;\n}(React.Component);\nexport { StackView as default };\nvar styles = StyleSheet.create({\n container: {\n flex: 1\n }\n});","map":{"version":3,"sources":["views/Stack/StackView.tsx"],"names":["HeaderShownContext","SafeAreaProviderCompat","StackActions","React","SafeAreaInsetsContext","ModalPresentationContext","GestureHandlerRootView","HeaderContainer","CardStack","GestureHandlerWrapper","View","isArrayEqual","a","b","length","every","it","index","StackView","Component","props","state","routes","previousRoutes","map","r","key","descriptors","previousDescriptors","reduce","acc","route","slice","openingRouteKeys","closingRouteKeys","replacingRouteKeys","previousFocusedRoute","nextFocusedRoute","isAnimationEnabled","descriptor","options","animationEnabled","getAnimationTypeForReplace","animationTypeForReplace","some","includes","filter","splice","Error","getPreviousRoute","findIndex","renderScene","render","renderHeader","handleOpenRoute","navigation","routeNames","name","navigate","setState","handleCloseRoute","dispatch","pop","source","target","handleTransitionStart","closing","emit","type","data","handleTransitionEnd","handleGestureStart","handleGestureEnd","handleGestureCancel","_","rest","styles","container","insets","isParentModal","isParentHeaderShown","StyleSheet","create","flex"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SACEA,kBAAkB,EAClBC,sBAAsB,QACjB,4BAA4B;AACnC,SAGEC,YAAY,QAEP,0BAA0B;AACjC,OAAO,KAAKC,KAAK,MAAM,OAAO;AAAA;AAAA;AAE9B,SAEEC,qBAAqB,QAChB,gCAAgC;AAOvC,OAAOC,wBAAwB;AAC/B,SAASC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C,EACjB,CAAC,4BACEO,KAAK,CAACC,MAAM,CAACwB,MAAM,CAAC,UAAA,IAAA,EAAA;UAAA,IAAGpB,GAAAA,GAAK,IAAA,CAALA,GAAAA;UAAK,OAC7BY,kBAAkB,CAACZ,GAAG,CAAC,GACnBS,kBAAkB,CAACU,QAAQ,CAACnB,GAAG,CAAC,IAAIQ,gBAAgB,CAACW,QAAQ,CAACnB,GAAG,CAAC,GAClE,KAAK;QAAA,CAAA,CACV,GACF;MACH;MAEA,IAAI,CAACJ,MAAM,CAACR,MAAM,EAAE;QAClB,MAAM,IAAIkC,KAAK,CACb,oEAAoE,CACrE;MACH;MAEA,IAAMrB,WAAW,GAAGL,MAAM,CAACO,MAAM,CAAqB,UAACC,GAAG,EAAEC,KAAK,EAAK;QACpED,GAAG,CAACC,KAAK,CAACL,GAAG,CAAC,GACZN,KAAK,CAACO,WAAW,CAACI,KAAK,CAACL,GAAG,CAAC,IAAIL,KAAK,CAACM,WAAW,CAACI,KAAK,CAACL,GAAG,CAAC;QAE9D,OAAOI,GAAG;MACZ,CAAC,EAAE,CAAC,CAAC,CAAC;MAEN,OAAO;QACLR,MAAM,EAANA,MAAM;QACNC,cAAc,EAAEH,KAAK,CAACC,KAAK,CAACC,MAAM;QAClCM,mBAAmB,EAAER,KAAK,CAACO,WAAW;QACtCM,gBAAgB,EAAhBA,gBAAgB;QAChBC,gBAAgB,EAAhBA,gBAAgB;QAChBC,kBAAkB,EAAlBA,kBAAkB;QAClBR,WAAAA,EAAAA;MACF,CAAC;IACH;EAAA;EAAA;AAAA,EAvNqCxB,KAAK,CAACgB,SAAS;AAAA,SAAjCD,SAAS;AAuZ9B,IAAM0D,MAAM,GAAGK,UAAU,CAACC,MAAM,CAAC;EAC/BL,SAAS,EAAE;IACTM,IAAI,EAAE;EACR;AACF,CAAC,CAAC","sourceRoot":"../../../../src","sourcesContent":["function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\nimport { HeaderShownContext, SafeAreaProviderCompat } from '@react-navigation/elements';\nimport { StackActions } from '@react-navigation/native';\nimport * as React from 'react';\nimport { StyleSheet, View } from 'react-native';\nimport { SafeAreaInsetsContext } from 'react-native-safe-area-context';\nimport ModalPresentationContext from '../../utils/ModalPresentationContext';\nimport { GestureHandlerRootView } from '../GestureHandler';\nimport HeaderContainer from '../Header/HeaderContainer';\nimport CardStack from './CardStack';\nconst GestureHandlerWrapper = GestureHandlerRootView ?? View;\n\n/**\n * Compare two arrays with primitive values as the content.\n * We need to make sure that both values and order match.\n */\nconst isArrayEqual = (a, b) => a.length === b.length && a.every((it, index) => it === b[index]);\nexport default class StackView extends React.Component {\n static getDerivedStateFromProps(props, state) {\n // If there was no change in routes, we don't need to compute anything\n if ((props.state.routes === state.previousRoutes || isArrayEqual(props.state.routes.map(r => r.key), state.previousRoutes.map(r => r.key))) && state.routes.length) {\n let routes = state.routes;\n let previousRoutes = state.previousRoutes;\n let descriptors = props.descriptors;\n let previousDescriptors = state.previousDescriptors;\n if (props.descriptors !== state.previousDescriptors) {\n descriptors = state.routes.reduce((acc, route) => {\n acc[route.key] = props.descriptors[route.key] || state.descriptors[route.key];\n return acc;\n }, {});\n previousDescriptors = props.descriptors;\n }\n if (props.state.routes !== state.previousRoutes) {\n // if any route objects have changed, we should update them\n const map = props.state.routes.reduce((acc, route) => {\n acc[route.key] = route;\n return acc;\n }, {});\n routes = state.routes.map(route => map[route.key] || route);\n previousRoutes = props.state.routes;\n }\n return {\n routes,\n previousRoutes,\n descriptors,\n previousDescriptors\n };\n }\n\n // Here we determine which routes were added or removed to animate them\n // We keep a copy of the route being removed in local state to be able to animate it\n\n let routes = props.state.index < props.state.routes.length - 1 ?\n // Remove any extra routes from the state\n // The last visible route should be the focused route, i.e. at current index\n props.state.routes.slice(0, props.state.index + 1) : props.state.routes;\n\n // Now we need to determine which routes were added and removed\n let {\n openingRouteKeys,\n closingRouteKeys,\n replacingRouteKeys,\n previousRoutes\n } = state;\n const previousFocusedRoute = previousRoutes[previousRoutes.length - 1];\n const nextFocusedRoute = routes[routes.length - 1];\n const isAnimationEnabled = key => {\n const descriptor = props.descriptors[key] || state.descriptors[key];\n return descriptor ? descriptor.options.animationEnabled !== false : true;\n };\n const getAnimationTypeForReplace = key => {\n const descriptor = props.descriptors[key] || state.descriptors[key];\n return descriptor.options.animationTypeForReplace ?? 'push';\n };\n if (previousFocusedRoute && previousFocusedRoute.key !== nextFocusedRoute.key) {\n // We only need to animate routes if the focused route changed\n // Animating previous routes won't be visible coz the focused route is on top of everything\n\n if (!previousRoutes.some(r => r.key === nextFocusedRoute.key)) {\n // A new route has come to the focus, we treat this as a push\n // A replace can also trigger this, the animation should look like push\n\n if (isAnimationEnabled(nextFocusedRoute.key) && !openingRouteKeys.includes(nextFocusedRoute.key)) {\n // In this case, we need to animate pushing the focused route\n // We don't care about animating any other added routes because they won't be visible\n openingRouteKeys = [...openingRouteKeys, nextFocusedRoute.key];\n closingRouteKeys = closingRouteKeys.filter(key => key !== nextFocusedRoute.key);\n replacingRouteKeys = replacingRouteKeys.filter(key => key !== nextFocusedRoute.key);\n if (!routes.some(r => r.key === previousFocusedRoute.key)) {\n // The previous focused route isn't present in state, we treat this as a replace\n\n openingRouteKeys = openingRouteKeys.filter(key => key !== previousFocusedRoute.key);\n if (getAnimationTypeForReplace(nextFocusedRoute.key) === 'pop') {\n closingRouteKeys = [...closingRouteKeys, previousFocusedRoute.key];\n\n // By default, new routes have a push animation, so we add it to `openingRouteKeys` before\n // But since user configured it to animate the old screen like a pop, we need to add this without animation\n // So remove it from `openingRouteKeys` which will remove the animation\n openingRouteKeys = openingRouteKeys.filter(key => key !== nextFocusedRoute.key);\n\n // Keep the route being removed at the end to animate it out\n routes = [...routes, previousFocusedRoute];\n } else {\n replacingRouteKeys = [...replacingRouteKeys, previousFocusedRoute.key];\n closingRouteKeys = closingRouteKeys.filter(key => key !== previousFocusedRoute.key);\n\n // Keep the old route in the state because it's visible under the new route, and removing it will feel abrupt\n // We need to insert it just before the focused one (the route being pushed)\n // After the push animation is completed, routes being replaced will be removed completely\n routes = routes.slice();\n routes.splice(routes.length - 1, 0, previousFocusedRoute);\n }\n }\n }\n } else if (!routes.some(r => r.key === previousFocusedRoute.key)) {\n // The previously focused route was removed, we treat this as a pop\n\n if (isAnimationEnabled(previousFocusedRoute.key) && !closingRouteKeys.includes(previousFocusedRoute.key)) {\n closingRouteKeys = [...closingRouteKeys, previousFocusedRoute.key];\n\n // Sometimes a route can be closed before the opening animation finishes\n // So we also need to remove it from the opening list\n openingRouteKeys = openingRouteKeys.filter(key => key !== previousFocusedRoute.key);\n replacingRouteKeys = replacingRouteKeys.filter(key => key !== previousFocusedRoute.key);\n\n // Keep a copy of route being removed in the state to be able to animate it\n routes = [...routes, previousFocusedRoute];\n }\n } else {\n // Looks like some routes were re-arranged and no focused routes were added/removed\n // i.e. the currently focused route already existed and the previously focused route still exists\n // We don't know how to animate this\n }\n } else if (replacingRouteKeys.length || closingRouteKeys.length) {\n // Keep the routes we are closing or replacing if animation is enabled for them\n routes = routes.slice();\n routes.splice(routes.length - 1, 0, ...state.routes.filter(_ref => {\n let {\n key\n } = _ref;\n return isAnimationEnabled(key) ? replacingRouteKeys.includes(key) || closingRouteKeys.includes(key) : false;\n }));\n }\n if (!routes.length) {\n throw new Error('There should always be at least one route in the navigation state.');\n }\n const descriptors = routes.reduce((acc, route) => {\n acc[route.key] = props.descriptors[route.key] || state.descriptors[route.key];\n return acc;\n }, {});\n return {\n routes,\n previousRoutes: props.state.routes,\n previousDescriptors: props.descriptors,\n openingRouteKeys,\n closingRouteKeys,\n replacingRouteKeys,\n descriptors\n };\n }\n state = {\n routes: [],\n previousRoutes: [],\n previousDescriptors: {},\n openingRouteKeys: [],\n closingRouteKeys: [],\n replacingRouteKeys: [],\n descriptors: {}\n };\n getPreviousRoute = _ref2 => {\n let {\n route\n } = _ref2;\n const {\n closingRouteKeys,\n replacingRouteKeys\n } = this.state;\n const routes = this.state.routes.filter(r => r.key === route.key || !closingRouteKeys.includes(r.key) && !replacingRouteKeys.includes(r.key));\n const index = routes.findIndex(r => r.key === route.key);\n return routes[index - 1];\n };\n renderScene = _ref3 => {\n let {\n route\n } = _ref3;\n const descriptor = this.state.descriptors[route.key] || this.props.descriptors[route.key];\n if (!descriptor) {\n return null;\n }\n return descriptor.render();\n };\n renderHeader = props => {\n return /*#__PURE__*/React.createElement(HeaderContainer, props);\n };\n handleOpenRoute = _ref4 => {\n let {\n route\n } = _ref4;\n const {\n state,\n navigation\n } = this.props;\n const {\n closingRouteKeys,\n replacingRouteKeys\n } = this.state;\n if (closingRouteKeys.some(key => key === route.key) && replacingRouteKeys.every(key => key !== route.key) && state.routeNames.includes(route.name) && !state.routes.some(r => r.key === route.key)) {\n // If route isn't present in current state, but was closing, assume that a close animation was cancelled\n // So we need to add this route back to the state\n navigation.navigate(route);\n } else {\n this.setState(state => ({\n routes: state.replacingRouteKeys.length ? state.routes.filter(r => !state.replacingRouteKeys.includes(r.key)) : state.routes,\n openingRouteKeys: state.openingRouteKeys.filter(key => key !== route.key),\n closingRouteKeys: state.closingRouteKeys.filter(key => key !== route.key),\n replacingRouteKeys: []\n }));\n }\n };\n handleCloseRoute = _ref5 => {\n let {\n route\n } = _ref5;\n const {\n state,\n navigation\n } = this.props;\n if (state.routes.some(r => r.key === route.key)) {\n // If a route exists in state, trigger a pop\n // This will happen in when the route was closed from the card component\n // e.g. When the close animation triggered from a gesture ends\n navigation.dispatch({\n ...StackActions.pop(),\n source: route.key,\n target: state.key\n });\n } else {\n // We need to clean up any state tracking the route and pop it immediately\n this.setState(state => ({\n routes: state.routes.filter(r => r.key !== route.key),\n openingRouteKeys: state.openingRouteKeys.filter(key => key !== route.key),\n closingRouteKeys: state.closingRouteKeys.filter(key => key !== route.key)\n }));\n }\n };\n handleTransitionStart = (_ref6, closing) => {\n let {\n route\n } = _ref6;\n return this.props.navigation.emit({\n type: 'transitionStart',\n data: {\n closing\n },\n target: route.key\n });\n };\n handleTransitionEnd = (_ref7, closing) => {\n let {\n route\n } = _ref7;\n return this.props.navigation.emit({\n type: 'transitionEnd',\n data: {\n closing\n },\n target: route.key\n });\n };\n handleGestureStart = _ref8 => {\n let {\n route\n } = _ref8;\n this.props.navigation.emit({\n type: 'gestureStart',\n target: route.key\n });\n };\n handleGestureEnd = _ref9 => {\n let {\n route\n } = _ref9;\n this.props.navigation.emit({\n type: 'gestureEnd',\n target: route.key\n });\n };\n handleGestureCancel = _ref10 => {\n let {\n route\n } = _ref10;\n this.props.navigation.emit({\n type: 'gestureCancel',\n target: route.key\n });\n };\n render() {\n const {\n state,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n descriptors: _,\n ...rest\n } = this.props;\n const {\n routes,\n descriptors,\n openingRouteKeys,\n closingRouteKeys\n } = this.state;\n return /*#__PURE__*/React.createElement(GestureHandlerWrapper, {\n style: styles.container\n }, /*#__PURE__*/React.createElement(SafeAreaProviderCompat, null, /*#__PURE__*/React.createElement(SafeAreaInsetsContext.Consumer, null, insets => /*#__PURE__*/React.createElement(ModalPresentationContext.Consumer, null, isParentModal => /*#__PURE__*/React.createElement(HeaderShownContext.Consumer, null, isParentHeaderShown => /*#__PURE__*/React.createElement(CardStack, _extends({\n insets: insets,\n isParentHeaderShown: isParentHeaderShown,\n isParentModal: isParentModal,\n getPreviousRoute: this.getPreviousRoute,\n routes: routes,\n openingRouteKeys: openingRouteKeys,\n closingRouteKeys: closingRouteKeys,\n onOpenRoute: this.handleOpenRoute,\n onCloseRoute: this.handleCloseRoute,\n onTransitionStart: this.handleTransitionStart,\n onTransitionEnd: this.handleTransitionEnd,\n renderHeader: this.renderHeader,\n renderScene: this.renderScene,\n state: state,\n descriptors: descriptors,\n onGestureStart: this.handleGestureStart,\n onGestureEnd: this.handleGestureEnd,\n onGestureCancel: this.handleGestureCancel\n }, rest)))))));\n }\n}\nconst styles = StyleSheet.create({\n container: {\n flex: 1\n }\n});\n//# sourceMappingURL=StackView.js.map"]},"metadata":{},"sourceType":"module"}