function normalizeUrl(url = '') { return String(url || '').trim() } export function isBookingEntryUrl(url = '') { return /^\/pkgBooking\/(book_viewing\/book_viewing|book\/book)(?:\?|$)/.test(normalizeUrl(url)) } export function resolveExistingBookingNavigationTarget(stayState = {}) { const source = stayState || {} const currentBooking = source.currentBooking || null const hasCheckedIn = source.hasCheckedIn === true if (currentBooking) { return '/pages/index/index?pageId=stay-service' } if (hasCheckedIn) { return '/pages/index/index?pageId=stay-service' } return '' } export function resolveBookingRedirectAfterLogin(targetUrl = '', stayState = {}) { const normalizedTargetUrl = normalizeUrl(targetUrl) if (!isBookingEntryUrl(normalizedTargetUrl)) { return normalizedTargetUrl } return resolveExistingBookingNavigationTarget(stayState) || normalizedTargetUrl }