"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "handleMutable", { enumerable: true, get: function() { return handleMutable; } }); const _computechangedpath = require("./compute-changed-path"); function handleMutable(state, mutable) { var _mutable_canonicalUrl; var _mutable_shouldScroll; // shouldScroll is true by default, can override to false. const shouldScroll = (_mutable_shouldScroll = mutable.shouldScroll) != null ? _mutable_shouldScroll : true; var _mutable_scrollableSegments, _computeChangedPath; return { buildId: state.buildId, // Set href. canonicalUrl: mutable.canonicalUrl != null ? mutable.canonicalUrl === state.canonicalUrl ? state.canonicalUrl : mutable.canonicalUrl : state.canonicalUrl, pushRef: { pendingPush: mutable.pendingPush != null ? mutable.pendingPush : state.pushRef.pendingPush, mpaNavigation: mutable.mpaNavigation != null ? mutable.mpaNavigation : state.pushRef.mpaNavigation }, // All navigation requires scroll and focus management to trigger. focusAndScrollRef: { apply: shouldScroll ? (mutable == null ? void 0 : mutable.scrollableSegments) !== undefined ? true : state.focusAndScrollRef.apply : false, onlyHashChange: !!mutable.hashFragment && state.canonicalUrl.split("#")[0] === ((_mutable_canonicalUrl = mutable.canonicalUrl) == null ? void 0 : _mutable_canonicalUrl.split("#")[0]), hashFragment: shouldScroll ? // #top is handled in layout-router. mutable.hashFragment && mutable.hashFragment !== "" ? decodeURIComponent(mutable.hashFragment.slice(1)) : state.focusAndScrollRef.hashFragment : null, segmentPaths: shouldScroll ? (_mutable_scrollableSegments = mutable == null ? void 0 : mutable.scrollableSegments) != null ? _mutable_scrollableSegments : state.focusAndScrollRef.segmentPaths : [] }, // Apply cache. cache: mutable.cache ? mutable.cache : state.cache, prefetchCache: mutable.prefetchCache ? mutable.prefetchCache : state.prefetchCache, // Apply patched router state. tree: mutable.patchedTree !== undefined ? mutable.patchedTree : state.tree, nextUrl: mutable.patchedTree !== undefined ? (_computeChangedPath = (0, _computechangedpath.computeChangedPath)(state.tree, mutable.patchedTree)) != null ? _computeChangedPath : state.canonicalUrl : state.nextUrl }; } if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') { Object.defineProperty(exports.default, '__esModule', { value: true }); Object.assign(exports.default, exports); module.exports = exports.default; } //# sourceMappingURL=handle-mutable.js.map