@adminide-stack/yantra-mobile 12.0.195 → 12.0.196-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/CustomDrawer.js +17 -1
- package/lib/components/CustomDrawer.js.map +1 -1
- package/lib/compute.js +57 -1
- package/lib/compute.js.map +1 -1
- package/lib/config/env-config.js +11 -1
- package/lib/config/env-config.js.map +1 -1
- package/lib/features/agent-chat/NativeAgentChat.js +7 -0
- package/lib/features/agent-chat/NativeAgentChat.js.map +1 -1
- package/lib/features/canvas/extendVideo.js +5 -1
- package/lib/features/canvas/extendVideo.js.map +1 -1
- package/lib/features/canvas/workflow/StepSheet.js +18 -1
- package/lib/features/canvas/workflow/StepSheet.js.map +1 -1
- package/lib/features/canvas/workflow/workflowSteps.js +102 -31
- package/lib/features/canvas/workflow/workflowSteps.js.map +1 -1
- package/lib/features/chat/ComposerMicSend.js +35 -0
- package/lib/features/chat/ComposerMicSend.js.map +1 -0
- package/lib/features/chat/ComposerModeSwitch.js +64 -1
- package/lib/features/chat/ComposerModeSwitch.js.map +1 -1
- package/lib/features/chat/askUser.js +6 -1
- package/lib/features/chat/askUser.js.map +1 -1
- package/lib/features/connectors/ConnectorSheet.js +443 -0
- package/lib/features/connectors/ConnectorSheet.js.map +1 -0
- package/lib/features/connectors/ConnectorsPage.js +320 -0
- package/lib/features/connectors/ConnectorsPage.js.map +1 -0
- package/lib/features/connectors/connectConnector.js +278 -0
- package/lib/features/connectors/connectConnector.js.map +1 -0
- package/lib/features/connectors/connectorCatalog.js +222 -0
- package/lib/features/connectors/connectorCatalog.js.map +1 -0
- package/lib/features/connectors/useConnectorCatalog.js +153 -0
- package/lib/features/connectors/useConnectorCatalog.js.map +1 -0
- package/lib/features/home/needsYou/HomeNeedsYou.js +618 -0
- package/lib/features/home/needsYou/HomeNeedsYou.js.map +1 -0
- package/lib/features/home/needsYou/chatFollowUps.js +333 -0
- package/lib/features/home/needsYou/chatFollowUps.js.map +1 -0
- package/lib/features/home/needsYou/format.js +47 -0
- package/lib/features/home/needsYou/format.js.map +1 -0
- package/lib/features/home/needsYou/historyText.js +40 -0
- package/lib/features/home/needsYou/historyText.js.map +1 -0
- package/lib/features/home/needsYou/inboxHighlights.js +152 -0
- package/lib/features/home/needsYou/inboxHighlights.js.map +1 -0
- package/lib/features/home/needsYou/panelsSettings.js +71 -0
- package/lib/features/home/needsYou/panelsSettings.js.map +1 -0
- package/lib/features/home/needsYou/ported/commandConfirmProtocol.js +13 -0
- package/lib/features/home/needsYou/ported/commandConfirmProtocol.js.map +1 -0
- package/lib/features/home/needsYou/ported/paymentApprovalProtocol.js +91 -0
- package/lib/features/home/needsYou/ported/paymentApprovalProtocol.js.map +1 -0
- package/lib/features/home/needsYou/ported/resultCardModels.js +659 -0
- package/lib/features/home/needsYou/ported/resultCardModels.js.map +1 -0
- package/lib/features/home/needsYou/types.js +1 -0
- package/lib/features/home/needsYou/types.js.map +1 -0
- package/lib/features/home/needsYou/useChatFollowUps.js +149 -0
- package/lib/features/home/needsYou/useChatFollowUps.js.map +1 -0
- package/lib/features/home/needsYou/useHomeBriefing.js +68 -0
- package/lib/features/home/needsYou/useHomeBriefing.js.map +1 -0
- package/lib/features/home/needsYou/useInboxHighlights.js +173 -0
- package/lib/features/home/needsYou/useInboxHighlights.js.map +1 -0
- package/lib/features/home/needsYou/usePanelsSettings.js +105 -0
- package/lib/features/home/needsYou/usePanelsSettings.js.map +1 -0
- package/lib/features/shopping/DealCard.js +8 -1
- package/lib/features/shopping/DealCard.js.map +1 -1
- package/lib/features/shopping/DealRails.js +24 -7
- package/lib/features/shopping/DealRails.js.map +1 -1
- package/lib/features/shopping/DealsPanel.js +1 -1
- package/lib/features/shopping/DealsPanel.js.map +1 -1
- package/lib/features/shopping/HolidayDealsPanel.js +529 -0
- package/lib/features/shopping/HolidayDealsPanel.js.map +1 -0
- package/lib/features/shopping/HolidayDealsParts.js +954 -0
- package/lib/features/shopping/HolidayDealsParts.js.map +1 -0
- package/lib/features/shopping/HolidayOffers.js +351 -0
- package/lib/features/shopping/HolidayOffers.js.map +1 -0
- package/lib/features/shopping/ProductCard.js +80 -14
- package/lib/features/shopping/ProductCard.js.map +1 -1
- package/lib/features/shopping/ProductDetailSheet.js +22 -3
- package/lib/features/shopping/ProductDetailSheet.js.map +1 -1
- package/lib/features/shopping/SavedPanel.js +341 -5
- package/lib/features/shopping/SavedPanel.js.map +1 -1
- package/lib/features/shopping/SearchResults.js +8 -2
- package/lib/features/shopping/SearchResults.js.map +1 -1
- package/lib/features/shopping/ShoppingAgentChatPane.js +12 -0
- package/lib/features/shopping/ShoppingAgentChatPane.js.map +1 -1
- package/lib/features/shopping/ShoppingExperience.js +56 -19
- package/lib/features/shopping/ShoppingExperience.js.map +1 -1
- package/lib/features/shopping/TrendingSections.js +13 -4
- package/lib/features/shopping/TrendingSections.js.map +1 -1
- package/lib/features/shopping/WatchlistPanel.js +61 -5
- package/lib/features/shopping/WatchlistPanel.js.map +1 -1
- package/lib/features/shopping/catalog.js +41 -2
- package/lib/features/shopping/catalog.js.map +1 -1
- package/lib/features/shopping/chat/brainRouter.js +14 -0
- package/lib/features/shopping/chat/brainRouter.js.map +1 -1
- package/lib/features/shopping/chat/shoppingTurn.js +88 -16
- package/lib/features/shopping/chat/shoppingTurn.js.map +1 -1
- package/lib/features/shopping/hooks/useHolidayDeals.js +388 -0
- package/lib/features/shopping/hooks/useHolidayDeals.js.map +1 -0
- package/lib/features/shopping/hooks/useProductMedia.js +33 -6
- package/lib/features/shopping/hooks/useProductMedia.js.map +1 -1
- package/lib/features/shopping/hooks/useShoppingHistorySync.js +8 -4
- package/lib/features/shopping/hooks/useShoppingHistorySync.js.map +1 -1
- package/lib/features/shopping/hooks/useTrendingProducts.js +11 -3
- package/lib/features/shopping/hooks/useTrendingProducts.js.map +1 -1
- package/lib/features/shopping/savedProducts.js +76 -6
- package/lib/features/shopping/savedProducts.js.map +1 -1
- package/lib/features/shopping/services/aiRelevance.js +212 -0
- package/lib/features/shopping/services/aiRelevance.js.map +1 -0
- package/lib/features/shopping/services/blackFriday.js +301 -0
- package/lib/features/shopping/services/blackFriday.js.map +1 -0
- package/lib/features/shopping/services/blackFridayBrowserSites.js +137 -0
- package/lib/features/shopping/services/blackFridayBrowserSites.js.map +1 -0
- package/lib/features/shopping/services/catalogProductSearch.js +21 -3
- package/lib/features/shopping/services/catalogProductSearch.js.map +1 -1
- package/lib/features/shopping/services/holidayDeals.js +143 -0
- package/lib/features/shopping/services/holidayDeals.js.map +1 -0
- package/lib/features/shopping/services/mediaShape.js +7 -0
- package/lib/features/shopping/services/mediaShape.js.map +1 -0
- package/lib/features/shopping/services/modelStep.js +95 -0
- package/lib/features/shopping/services/modelStep.js.map +1 -0
- package/lib/features/shopping/services/modelWords.js +14 -0
- package/lib/features/shopping/services/modelWords.js.map +1 -0
- package/lib/features/shopping/services/productAvailability.js +5 -1
- package/lib/features/shopping/services/productAvailability.js.map +1 -1
- package/lib/features/shopping/services/productFilters.js +2 -2
- package/lib/features/shopping/services/productFilters.js.map +1 -1
- package/lib/features/shopping/services/productMedia.js +103 -18
- package/lib/features/shopping/services/productMedia.js.map +1 -1
- package/lib/features/shopping/services/retailerUrl.js +11 -8
- package/lib/features/shopping/services/retailerUrl.js.map +1 -1
- package/lib/features/shopping/services/salesDealsStore.js +3 -2
- package/lib/features/shopping/services/salesDealsStore.js.map +1 -1
- package/lib/features/shopping/services/savedReads.js +82 -0
- package/lib/features/shopping/services/savedReads.js.map +1 -0
- package/lib/features/shopping/services/searchCardFields.js +2 -0
- package/lib/features/shopping/services/searchCardFields.js.map +1 -1
- package/lib/features/shopping/services/searchRelevance.js +154 -24
- package/lib/features/shopping/services/searchRelevance.js.map +1 -1
- package/lib/features/shopping/services/secondHand.js +12 -0
- package/lib/features/shopping/services/secondHand.js.map +1 -0
- package/lib/features/shopping/services/shoppingProductSearch.js +82 -10
- package/lib/features/shopping/services/shoppingProductSearch.js.map +1 -1
- package/lib/features/shopping/services/shoppingSearchConnectorClient.js +14 -1
- package/lib/features/shopping/services/shoppingSearchConnectorClient.js.map +1 -1
- package/lib/features/shopping/services/shoppingSubgraph.js +2 -1
- package/lib/features/shopping/services/shoppingSubgraph.js.map +1 -1
- package/lib/features/shopping/services/storedGalleries.js +130 -0
- package/lib/features/shopping/services/storedGalleries.js.map +1 -0
- package/lib/features/shopping/services/usedSites.js +263 -0
- package/lib/features/shopping/services/usedSites.js.map +1 -0
- package/lib/features/shopping/services/verifyProducts.js +3 -3
- package/lib/features/shopping/services/verifyProducts.js.map +1 -1
- package/lib/features/shopping/services/watchDeal.js +61 -0
- package/lib/features/shopping/services/watchDeal.js.map +1 -0
- package/lib/features/shopping/shoppingRuntime.js +7 -2
- package/lib/features/shopping/shoppingRuntime.js.map +1 -1
- package/lib/features/shopping/state/accountCaches.js +20 -0
- package/lib/features/shopping/state/accountCaches.js.map +1 -0
- package/lib/features/shopping/state/holidayDealsRequest.js +22 -0
- package/lib/features/shopping/state/holidayDealsRequest.js.map +1 -0
- package/lib/features/shopping/tutorials/ShoppingTutorialDock.js +1 -1
- package/lib/features/shopping/tutorials/ShoppingTutorialDock.js.map +1 -1
- package/lib/features/shopping/tutorials/shoppingTutorials.js +2 -0
- package/lib/features/shopping/tutorials/shoppingTutorials.js.map +1 -1
- package/lib/features/shopping/useShoppingSearch.js +74 -18
- package/lib/features/shopping/useShoppingSearch.js.map +1 -1
- package/lib/features/team-chat/TeamChatExperience.js +474 -0
- package/lib/features/team-chat/TeamChatExperience.js.map +1 -0
- package/lib/features/team-chat/api/client.js +198 -0
- package/lib/features/team-chat/api/client.js.map +1 -0
- package/lib/features/team-chat/api/live.js +160 -0
- package/lib/features/team-chat/api/live.js.map +1 -0
- package/lib/features/team-chat/api/ops.js +241 -0
- package/lib/features/team-chat/api/ops.js.map +1 -0
- package/lib/features/team-chat/app.js +12 -0
- package/lib/features/team-chat/app.js.map +1 -0
- package/lib/features/team-chat/components/Avatar.js +107 -0
- package/lib/features/team-chat/components/Avatar.js.map +1 -0
- package/lib/features/team-chat/components/Composer.js +641 -0
- package/lib/features/team-chat/components/Composer.js.map +1 -0
- package/lib/features/team-chat/components/Dialogs.js +598 -0
- package/lib/features/team-chat/components/Dialogs.js.map +1 -0
- package/lib/features/team-chat/components/EmojiPicker.js +165 -0
- package/lib/features/team-chat/components/EmojiPicker.js.map +1 -0
- package/lib/features/team-chat/components/MessageItem.js +658 -0
- package/lib/features/team-chat/components/MessageItem.js.map +1 -0
- package/lib/features/team-chat/components/MessageList.js +248 -0
- package/lib/features/team-chat/components/MessageList.js.map +1 -0
- package/lib/features/team-chat/components/Mrkdwn.js +228 -0
- package/lib/features/team-chat/components/Mrkdwn.js.map +1 -0
- package/lib/features/team-chat/components/QuickSwitcher.js +215 -0
- package/lib/features/team-chat/components/QuickSwitcher.js.map +1 -0
- package/lib/features/team-chat/components/ui.js +662 -0
- package/lib/features/team-chat/components/ui.js.map +1 -0
- package/lib/features/team-chat/nativeTeamChatRegistry.js +15 -0
- package/lib/features/team-chat/nativeTeamChatRegistry.js.map +1 -0
- package/lib/features/team-chat/state/fetched.js +39 -0
- package/lib/features/team-chat/state/fetched.js.map +1 -0
- package/lib/features/team-chat/state/lists.js +230 -0
- package/lib/features/team-chat/state/lists.js.map +1 -0
- package/lib/features/team-chat/state/store.js +1108 -0
- package/lib/features/team-chat/state/store.js.map +1 -0
- package/lib/features/team-chat/state/useChannelDirectory.js +21 -0
- package/lib/features/team-chat/state/useChannelDirectory.js.map +1 -0
- package/lib/features/team-chat/theme.js +77 -0
- package/lib/features/team-chat/theme.js.map +1 -0
- package/lib/features/team-chat/utils/composeText.js +72 -0
- package/lib/features/team-chat/utils/composeText.js.map +1 -0
- package/lib/features/team-chat/utils/emoji.js +369 -0
- package/lib/features/team-chat/utils/emoji.js.map +1 -0
- package/lib/features/team-chat/utils/format.js +109 -0
- package/lib/features/team-chat/utils/format.js.map +1 -0
- package/lib/features/team-chat/utils/messageRows.js +24 -0
- package/lib/features/team-chat/utils/messageRows.js.map +1 -0
- package/lib/features/team-chat/utils/mrkdwn.js +222 -0
- package/lib/features/team-chat/utils/mrkdwn.js.map +1 -0
- package/lib/features/team-chat/utils/notify.js +47 -0
- package/lib/features/team-chat/utils/notify.js.map +1 -0
- package/lib/features/team-chat/utils/pickFiles.js +81 -0
- package/lib/features/team-chat/utils/pickFiles.js.map +1 -0
- package/lib/features/team-chat/views/ActivityView.js +235 -0
- package/lib/features/team-chat/views/ActivityView.js.map +1 -0
- package/lib/features/team-chat/views/BrowseView.js +179 -0
- package/lib/features/team-chat/views/BrowseView.js.map +1 -0
- package/lib/features/team-chat/views/ChannelView.js +475 -0
- package/lib/features/team-chat/views/ChannelView.js.map +1 -0
- package/lib/features/team-chat/views/DetailsPane.js +816 -0
- package/lib/features/team-chat/views/DetailsPane.js.map +1 -0
- package/lib/features/team-chat/views/DraftsView.js +212 -0
- package/lib/features/team-chat/views/DraftsView.js.map +1 -0
- package/lib/features/team-chat/views/FilesView.js +152 -0
- package/lib/features/team-chat/views/FilesView.js.map +1 -0
- package/lib/features/team-chat/views/NewMessageView.js +286 -0
- package/lib/features/team-chat/views/NewMessageView.js.map +1 -0
- package/lib/features/team-chat/views/PeopleView.js +118 -0
- package/lib/features/team-chat/views/PeopleView.js.map +1 -0
- package/lib/features/team-chat/views/ProfilePane.js +220 -0
- package/lib/features/team-chat/views/ProfilePane.js.map +1 -0
- package/lib/features/team-chat/views/SavedView.js +113 -0
- package/lib/features/team-chat/views/SavedView.js.map +1 -0
- package/lib/features/team-chat/views/SearchView.js +307 -0
- package/lib/features/team-chat/views/SearchView.js.map +1 -0
- package/lib/features/team-chat/views/Sidebar.js +368 -0
- package/lib/features/team-chat/views/Sidebar.js.map +1 -0
- package/lib/features/team-chat/views/ThreadPane.js +139 -0
- package/lib/features/team-chat/views/ThreadPane.js.map +1 -0
- package/lib/features/team-chat/views/ThreadsView.js +157 -0
- package/lib/features/team-chat/views/ThreadsView.js.map +1 -0
- package/lib/features/webbuilder/WebBuilderExperience.js +276 -42
- package/lib/features/webbuilder/WebBuilderExperience.js.map +1 -1
- package/lib/features/webbuilder/buildFragments.js +10 -4
- package/lib/features/webbuilder/buildFragments.js.map +1 -1
- package/lib/features/webbuilder/components/AssetChips.js +61 -0
- package/lib/features/webbuilder/components/AssetChips.js.map +1 -0
- package/lib/features/webbuilder/components/AssetSiteChooser.js +100 -0
- package/lib/features/webbuilder/components/AssetSiteChooser.js.map +1 -0
- package/lib/features/webbuilder/components/CommentsLayer.js +485 -0
- package/lib/features/webbuilder/components/CommentsLayer.js.map +1 -0
- package/lib/features/webbuilder/components/Composer.js +16 -2
- package/lib/features/webbuilder/components/Composer.js.map +1 -1
- package/lib/features/webbuilder/components/ComposerModeSwitch.js +71 -0
- package/lib/features/webbuilder/components/ComposerModeSwitch.js.map +1 -0
- package/lib/features/webbuilder/components/MyAssetsPicker.js +500 -0
- package/lib/features/webbuilder/components/MyAssetsPicker.js.map +1 -0
- package/lib/features/webbuilder/components/PlanDocument.js +165 -0
- package/lib/features/webbuilder/components/PlanDocument.js.map +1 -0
- package/lib/features/webbuilder/components/PlanDraftCard.js +205 -0
- package/lib/features/webbuilder/components/PlanDraftCard.js.map +1 -0
- package/lib/features/webbuilder/components/PlanView.js +788 -0
- package/lib/features/webbuilder/components/PlanView.js.map +1 -0
- package/lib/features/webbuilder/components/PreviewConsoleSheet.js +334 -0
- package/lib/features/webbuilder/components/PreviewConsoleSheet.js.map +1 -0
- package/lib/features/webbuilder/components/PreviewFrame.js +45 -3
- package/lib/features/webbuilder/components/PreviewFrame.js.map +1 -1
- package/lib/features/webbuilder/components/PreviewScreen.js +94 -10
- package/lib/features/webbuilder/components/PreviewScreen.js.map +1 -1
- package/lib/features/webbuilder/components/ProjectChat.js +84 -14
- package/lib/features/webbuilder/components/ProjectChat.js.map +1 -1
- package/lib/features/webbuilder/components/StudioHome.js +69 -6
- package/lib/features/webbuilder/components/StudioHome.js.map +1 -1
- package/lib/features/webbuilder/components/StyleDirectionsSheet.js +291 -0
- package/lib/features/webbuilder/components/StyleDirectionsSheet.js.map +1 -0
- package/lib/features/webbuilder/components/VersionChangesView.js +574 -0
- package/lib/features/webbuilder/components/VersionChangesView.js.map +1 -0
- package/lib/features/webbuilder/components/VersionPreviewView.js +186 -0
- package/lib/features/webbuilder/components/VersionPreviewView.js.map +1 -0
- package/lib/features/webbuilder/components/VersionsSheet.js +673 -16
- package/lib/features/webbuilder/components/VersionsSheet.js.map +1 -1
- package/lib/features/webbuilder/connectorTemplates.js +6 -1
- package/lib/features/webbuilder/connectorTemplates.js.map +1 -1
- package/lib/features/webbuilder/myAssets.js +101 -0
- package/lib/features/webbuilder/myAssets.js.map +1 -0
- package/lib/features/webbuilder/planChat.js +146 -0
- package/lib/features/webbuilder/planChat.js.map +1 -0
- package/lib/features/webbuilder/planDocument.js +89 -0
- package/lib/features/webbuilder/planDocument.js.map +1 -0
- package/lib/features/webbuilder/planStore.js +55 -0
- package/lib/features/webbuilder/planStore.js.map +1 -0
- package/lib/features/webbuilder/previewCommentsScript.js +218 -0
- package/lib/features/webbuilder/previewCommentsScript.js.map +1 -0
- package/lib/features/webbuilder/previewConsoleScript.js +39 -0
- package/lib/features/webbuilder/previewConsoleScript.js.map +1 -0
- package/lib/features/webbuilder/styleDirections.js +85 -0
- package/lib/features/webbuilder/styleDirections.js.map +1 -0
- package/lib/features/webbuilder/useCanvasComments.js +335 -0
- package/lib/features/webbuilder/useCanvasComments.js.map +1 -0
- package/lib/features/webbuilder/useCatalogTemplates.js +37 -0
- package/lib/features/webbuilder/useCatalogTemplates.js.map +1 -0
- package/lib/features/webbuilder/usePlanMode.js +145 -0
- package/lib/features/webbuilder/usePlanMode.js.map +1 -0
- package/lib/features/webbuilder/useStyleDirections.js +112 -0
- package/lib/features/webbuilder/useStyleDirections.js.map +1 -0
- package/lib/features/webbuilder/web/assets/assetsApi.js +174 -0
- package/lib/features/webbuilder/web/assets/assetsApi.js.map +1 -0
- package/lib/features/webbuilder/web/assets/assetsApi.ts +173 -0
- package/lib/features/webbuilder/web/assets/myAssets.js +341 -0
- package/lib/features/webbuilder/web/assets/myAssets.js.map +1 -0
- package/lib/features/webbuilder/web/assets/myAssets.ts +396 -0
- package/lib/features/webbuilder/web/canvas/elementName.js +46 -0
- package/lib/features/webbuilder/web/canvas/elementName.js.map +1 -0
- package/lib/features/webbuilder/web/canvas/visualEditorBridge.js +95 -0
- package/lib/features/webbuilder/web/canvas/visualEditorBridge.js.map +1 -0
- package/lib/features/webbuilder/web/chat/agentTurn.js +24 -0
- package/lib/features/webbuilder/web/chat/agentTurn.js.map +1 -0
- package/lib/features/webbuilder/web/chat/planMode.js +164 -0
- package/lib/features/webbuilder/web/chat/planMode.js.map +1 -0
- package/lib/features/webbuilder/web/chat/realPlans.js +66 -0
- package/lib/features/webbuilder/web/chat/realPlans.js.map +1 -0
- package/lib/features/webbuilder/web/comments/comments.js +336 -0
- package/lib/features/webbuilder/web/comments/comments.js.map +1 -0
- package/lib/features/webbuilder/web/comments/commentsApi.js +59 -0
- package/lib/features/webbuilder/web/comments/commentsApi.js.map +1 -0
- package/lib/features/webbuilder/web/components/planView.js +21 -0
- package/lib/features/webbuilder/web/components/planView.js.map +1 -0
- package/lib/features/webbuilder/web/console/consolePanel.js +43 -0
- package/lib/features/webbuilder/web/console/consolePanel.js.map +1 -0
- package/lib/features/webbuilder/web/console/previewConsole.js +256 -0
- package/lib/features/webbuilder/web/console/previewConsole.js.map +1 -0
- package/lib/features/webbuilder/web/console/usePreviewConsole.js +147 -0
- package/lib/features/webbuilder/web/console/usePreviewConsole.js.map +1 -0
- package/lib/features/webbuilder/web/design/directions.js +419 -1
- package/lib/features/webbuilder/web/design/directions.js.map +1 -1
- package/lib/features/webbuilder/web/history/diffActions.js +222 -0
- package/lib/features/webbuilder/web/history/diffActions.js.map +1 -0
- package/lib/features/webbuilder/web/history/diffHighlight.js +18 -0
- package/lib/features/webbuilder/web/history/diffHighlight.js.map +1 -0
- package/lib/features/webbuilder/web/history/versionActions.js +272 -0
- package/lib/features/webbuilder/web/history/versionActions.js.map +1 -0
- package/lib/features/webbuilder/web/history/versionDiff.js +338 -0
- package/lib/features/webbuilder/web/history/versionDiff.js.map +1 -0
- package/lib/features/webbuilder/web/history/versionPreview.js +83 -0
- package/lib/features/webbuilder/web/history/versionPreview.js.map +1 -0
- package/lib/features/webbuilder/web/history/versionPreviewMachine.js +150 -0
- package/lib/features/webbuilder/web/history/versionPreviewMachine.js.map +1 -0
- package/lib/features/webbuilder/web/history/versions.js +326 -1
- package/lib/features/webbuilder/web/history/versions.js.map +1 -1
- package/lib/features/webbuilder/web/hosted/hostedTurn.js +36 -0
- package/lib/features/webbuilder/web/hosted/hostedTurn.js.map +1 -0
- package/lib/features/webbuilder/web/studio/brandKit.js +25 -0
- package/lib/features/webbuilder/web/studio/brandKit.js.map +1 -0
- package/lib/features/webbuilder/web/utils/promptSafe.js +15 -0
- package/lib/features/webbuilder/web/utils/promptSafe.js.map +1 -0
- package/lib/features/webbuilder/web/webServices.js +3 -1
- package/lib/features/webbuilder/web/webServices.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/routes.json +55 -0
- package/lib/screens/Account/index.js +13 -5
- package/lib/screens/Account/index.js.map +1 -1
- package/lib/screens/Chat/index.js +16 -0
- package/lib/screens/Chat/index.js.map +1 -1
- package/lib/screens/Home/HomeScreen.js +202 -39
- package/lib/screens/Home/HomeScreen.js.map +1 -1
- package/lib/screens/Home/components/HomeHero.js +52 -38
- package/lib/screens/Home/components/HomeHero.js.map +1 -1
- package/lib/screens/Home/components/homeCatalog.js +8 -1
- package/lib/screens/Home/components/homeCatalog.js.map +1 -1
- package/lib/screens/TeamChat/index.js +41 -0
- package/lib/screens/TeamChat/index.js.map +1 -0
- package/lib/screens/WebBuilder/nativeWebBuilderRedirect.js +9 -2
- package/lib/screens/WebBuilder/nativeWebBuilderRedirect.js.map +1 -1
- package/lib/screens/WebBuilderNative/index.js +13 -3
- package/lib/screens/WebBuilderNative/index.js.map +1 -1
- package/lib/screens/WebBuilderNative/useConnectorTemplates.js +2 -2
- package/lib/screens/WebBuilderNative/useConnectorTemplates.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
import {modelWordRole,codeFamily}from'./modelWords.js';var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
1
17
|
function stem(word) {
|
|
2
18
|
if (word.length <= 3) return word;
|
|
3
19
|
if (/ies$/.test(word)) return `${word.slice(0, -3)}y`;
|
|
@@ -15,9 +31,9 @@ function toPhrase(value) {
|
|
|
15
31
|
function toPhrases(values) {
|
|
16
32
|
return (values != null ? values : []).map(toPhrase).filter((phrase) => phrase.length > 0);
|
|
17
33
|
}
|
|
18
|
-
function phraseIndex(stems, phrase) {
|
|
34
|
+
function phraseIndex(stems, phrase, from = 0) {
|
|
19
35
|
if (phrase.length === 0) return -1;
|
|
20
|
-
for (let i = 0; i + phrase.length <= stems.length; i++) {
|
|
36
|
+
for (let i = Math.max(0, from); i + phrase.length <= stems.length; i++) {
|
|
21
37
|
let hit = true;
|
|
22
38
|
for (let j = 0; j < phrase.length; j++) {
|
|
23
39
|
if (stems[i + j] !== phrase[j]) {
|
|
@@ -73,6 +89,7 @@ const ACCESSORY_TERMS = [
|
|
|
73
89
|
"strap",
|
|
74
90
|
"lanyard",
|
|
75
91
|
"replacement",
|
|
92
|
+
"power bank",
|
|
76
93
|
"mouse",
|
|
77
94
|
"mousepad",
|
|
78
95
|
// A book ABOUT the device ("MacBook For Seniors … (Paperback)") is not the device.
|
|
@@ -89,55 +106,168 @@ const ACCESSORY_TERMS = [
|
|
|
89
106
|
"mouse pad"
|
|
90
107
|
];
|
|
91
108
|
const DEVICE_DEPARTMENTS = /* @__PURE__ */ new Set(["high-tech", "gaming", "camera"]);
|
|
109
|
+
const FORMAT_TERMS = ["paperback", "hardcover"];
|
|
110
|
+
const ACCESSORY_NOUNS = new Set(ACCESSORY_TERMS.filter((term) => !term.includes(" ") && term !== "replacement" && !FORMAT_TERMS.includes(term)).map(stem));
|
|
111
|
+
const ENCLOSURE_NOUNS = new Set(["case", "cover", "shell", "sleeve", "pouch", "folio", "skin"].map(stem));
|
|
112
|
+
const PREPOSITIONS = /* @__PURE__ */ new Set(["for", "with", "without", "in", "on", "to", "from", "by", "of"]);
|
|
113
|
+
function headNoun(tokens) {
|
|
114
|
+
const cut = tokens.findIndex((token, i) => i > 0 && PREPOSITIONS.has(token));
|
|
115
|
+
const words = (cut > 0 ? tokens.slice(0, cut) : tokens).filter((token) => !FUNCTION_WORDS.has(token));
|
|
116
|
+
return words.length > 0 ? stem(words[words.length - 1]) : void 0;
|
|
117
|
+
}
|
|
118
|
+
function unorderedClassIndex(stems, phrase) {
|
|
119
|
+
const contiguous = phraseIndex(stems, phrase);
|
|
120
|
+
if (contiguous >= 0) return contiguous;
|
|
121
|
+
if (phrase.length < 2 || !phrase.every((word) => stems.includes(word))) return -1;
|
|
122
|
+
return stems.indexOf(phrase[phrase.length - 1]);
|
|
123
|
+
}
|
|
124
|
+
function earliest(a, b) {
|
|
125
|
+
if (a < 0) return b;
|
|
126
|
+
if (b < 0) return a;
|
|
127
|
+
return Math.min(a, b);
|
|
128
|
+
}
|
|
129
|
+
function filedAsBook(storeCategory) {
|
|
130
|
+
return tokenize(storeCategory != null ? storeCategory : "").some((token) => stem(token) === "book");
|
|
131
|
+
}
|
|
92
132
|
const FOR_MARKERS = [["for"], ["fit"], ["compatible"]];
|
|
93
133
|
const COMPATIBLE_MARKER = [["compatible"]];
|
|
94
134
|
function accessoryExcludePhrases(queryStemSet) {
|
|
95
135
|
return ACCESSORY_TERMS.map(toPhrase).filter((phrase) => phrase.length > 0 && !queryStemSet.has(phrase[phrase.length - 1]));
|
|
96
136
|
}
|
|
137
|
+
const FORMAT_STEMS = new Set(FORMAT_TERMS.map(stem));
|
|
138
|
+
const isFormat = (phrase) => phrase.length === 1 && FORMAT_STEMS.has(phrase[0]);
|
|
139
|
+
const WITH_MARKERS = /* @__PURE__ */ new Set(["with", "w", "include", "including", "built"]);
|
|
97
140
|
function excludeFollows(stems, phrase, anchor) {
|
|
141
|
+
const at = phraseIndex(stems, phrase, anchor - phrase.length + 2);
|
|
142
|
+
if (at < 0) return false;
|
|
143
|
+
return isFormat(phrase) || !withBetween(stems, anchor, at);
|
|
144
|
+
}
|
|
145
|
+
function withBetween(stems, from, to) {
|
|
146
|
+
for (let i = from + 1; i < to; i++) {
|
|
147
|
+
if (WITH_MARKERS.has(stems[i])) return true;
|
|
148
|
+
}
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
function namesTheItem(stems, phrase, anchor) {
|
|
98
152
|
const at = phraseIndex(stems, phrase);
|
|
99
|
-
return at >= 0 && at
|
|
153
|
+
return at >= 0 && (at < anchor || isFormat(phrase) || !withBetween(stems, anchor, at));
|
|
100
154
|
}
|
|
101
|
-
function
|
|
155
|
+
function titleSpellings(stems) {
|
|
156
|
+
const out = new Set(stems);
|
|
157
|
+
for (let i = 0; i + 1 < stems.length; i++) {
|
|
158
|
+
out.add(stems[i] + stems[i + 1]);
|
|
159
|
+
if (i + 2 < stems.length) out.add(stems[i] + stems[i + 1] + stems[i + 2]);
|
|
160
|
+
}
|
|
161
|
+
return out;
|
|
162
|
+
}
|
|
163
|
+
function queryWordsCarried(words, stems, spelled) {
|
|
164
|
+
const own = new Set(stems);
|
|
165
|
+
const carried = words.map((word) => own.has(word) || word.length >= 4 && spelled.has(word));
|
|
166
|
+
for (let i = 0; i < words.length; i++) {
|
|
167
|
+
for (const span of [2, 3]) {
|
|
168
|
+
if (i + span > words.length) continue;
|
|
169
|
+
if (own.has(words.slice(i, i + span).join(""))) {
|
|
170
|
+
for (let j = i; j < i + span; j++) carried[j] = true;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return carried;
|
|
175
|
+
}
|
|
176
|
+
function namesAnotherModel(stems, spelled, words, roles) {
|
|
177
|
+
return words.some((word, i) => {
|
|
178
|
+
if (spelled.has(word)) return false;
|
|
179
|
+
if (roles[i] === "code") {
|
|
180
|
+
const family = codeFamily(word);
|
|
181
|
+
return family !== null && [...spelled].some((t) => t !== word && codeFamily(t) === family);
|
|
182
|
+
}
|
|
183
|
+
if (roles[i] === "number" && i > 0 && roles[i - 1] === "name") {
|
|
184
|
+
const head = words[i - 1];
|
|
185
|
+
return stems.some((t, at) => t === head && at + 1 < stems.length && /^\d+$/.test(stems[at + 1]) && stems[at + 1].length === word.length && stems[at + 1] !== word);
|
|
186
|
+
}
|
|
187
|
+
return false;
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function relevanceJudge(relevance) {
|
|
102
191
|
var _a, _b, _c;
|
|
103
|
-
|
|
104
|
-
const targets = toPhrases([relevance.productType, ...(_a = relevance.synonyms) != null ? _a : []].filter(Boolean));
|
|
192
|
+
const brainTargets = toPhrases([relevance.productType, ...(_a = relevance.synonyms) != null ? _a : []].filter(Boolean));
|
|
105
193
|
const brainExcludes = toPhrases(relevance.excludes);
|
|
106
194
|
const queryTokens = tokenize((_b = relevance.query) != null ? _b : "");
|
|
107
195
|
const contentTokens = queryTokens.filter((token) => !FUNCTION_WORDS.has(token));
|
|
108
196
|
const queryWords = toPhrases(contentTokens.length > 0 ? contentTokens : queryTokens);
|
|
109
|
-
if (
|
|
197
|
+
if (brainTargets.length === 0 && queryWords.length === 0) return null;
|
|
198
|
+
const typePhrase = relevance.productType ? toPhrase(relevance.productType) : null;
|
|
199
|
+
const queryHead = headNoun(queryTokens);
|
|
200
|
+
const typeHead = typePhrase == null ? void 0 : typePhrase[typePhrase.length - 1];
|
|
201
|
+
const buysAccessory = [queryHead, typeHead].some((head) => head !== void 0 && ACCESSORY_NOUNS.has(head));
|
|
202
|
+
const buysEnclosure = [queryHead, typeHead].some((head) => head !== void 0 && ENCLOSURE_NOUNS.has(head));
|
|
203
|
+
const targets = buysEnclosure ? [...new Map(brainTargets.flatMap((target) => ENCLOSURE_NOUNS.has(target[target.length - 1]) ? [...ENCLOSURE_NOUNS].map((noun) => [...target.slice(0, -1), noun]) : [target]).map((target) => [target.join(" "), target])).values()] : brainTargets;
|
|
204
|
+
const accessoryNames = buysAccessory ? [.../* @__PURE__ */ new Set([queryHead, ...targets.map((target) => target[target.length - 1]), ...buysEnclosure ? ENCLOSURE_NOUNS : []])].filter((noun) => noun !== void 0 && ACCESSORY_NOUNS.has(noun)).map((noun) => [noun]) : [];
|
|
110
205
|
const queryStemSet = new Set(queryWords.flat());
|
|
111
|
-
const baseline = accessoryExcludePhrases(queryStemSet);
|
|
206
|
+
const baseline = buysAccessory ? toPhrases(FORMAT_TERMS) : accessoryExcludePhrases(queryStemSet);
|
|
112
207
|
const isDeviceSearch = DEVICE_DEPARTMENTS.has((_c = relevance.departmentId) != null ? _c : "");
|
|
113
|
-
const excludes = brainExcludes.length === 0 ? baseline : isDeviceSearch ? [...brainExcludes, ...baseline] : brainExcludes;
|
|
114
|
-
const forExcludes =
|
|
115
|
-
const typePhrase = relevance.productType ? toPhrase(relevance.productType) : null;
|
|
208
|
+
const excludes = buysAccessory ? baseline : brainExcludes.length === 0 ? baseline : isDeviceSearch ? [...brainExcludes, ...baseline] : brainExcludes;
|
|
209
|
+
const forExcludes = [...brainExcludes, ...baseline];
|
|
116
210
|
const queryStems = queryWords.flat();
|
|
117
211
|
const typedTheClass = targets.some((target) => phraseIndex(queryStems, target) >= 0);
|
|
118
|
-
const
|
|
212
|
+
const wordList = queryWords.map((word) => word.join(" "));
|
|
213
|
+
const roles = wordList.map(modelWordRole);
|
|
214
|
+
const nameAt = roles.flatMap((role, i) => role === "name" ? [i] : []);
|
|
215
|
+
const codeAt = roles.flatMap((role, i) => role === "code" ? [i] : []);
|
|
216
|
+
const lineHeads = wordList.map((_, i) => roles[i] === "line" && i > 0 ? wordList[i - 1] : null);
|
|
217
|
+
return (product) => {
|
|
119
218
|
var _a2, _b2;
|
|
219
|
+
if (isDeviceSearch && filedAsBook(product.storeCategory)) {
|
|
220
|
+
return {
|
|
221
|
+
score: 0,
|
|
222
|
+
relevant: false,
|
|
223
|
+
adjunct: false
|
|
224
|
+
};
|
|
225
|
+
}
|
|
120
226
|
const stems = tokenize(`${(_a2 = product.name) != null ? _a2 : ""} ${(_b2 = product.brand) != null ? _b2 : ""}`).map(stem);
|
|
121
|
-
const classAnchor = targets.length
|
|
227
|
+
const classAnchor = targets.length === 0 ? -1 : buysAccessory ? targets.reduce((best, target) => earliest(best, unorderedClassIndex(stems, target)), -1) : firstIndex(stems, targets);
|
|
228
|
+
const accessoryAt = accessoryNames.length > 0 ? firstIndex(stems, accessoryNames) : -1;
|
|
122
229
|
const classCovered = classAnchor >= 0 && typePhrase !== null;
|
|
123
|
-
const
|
|
124
|
-
const
|
|
125
|
-
const
|
|
126
|
-
const
|
|
230
|
+
const spelled = titleSpellings(stems);
|
|
231
|
+
const carried = queryWordsCarried(wordList, stems, spelled);
|
|
232
|
+
const coveredAt = (i) => carried[i] || classCovered && typePhrase !== null && samePhrase(queryWords[i], typePhrase) || accessoryAt >= 0 && queryWords[i].length === 1 && queryWords[i][0] === queryHead;
|
|
233
|
+
const coveredCount = queryWords.filter((_, i) => coveredAt(i)).length;
|
|
234
|
+
const coversQuery = queryWords.length > 0 && coveredCount >= requiredCoverage(queryWords.length);
|
|
235
|
+
const linesAsAsked = lineHeads.filter((head, i) => head !== null && stems.some((t, at) => t === head && stems[at + 1] === wordList[i])).length;
|
|
236
|
+
const score = coveredCount + linesAsAsked / 2;
|
|
237
|
+
const carriesName = nameAt.length === 0 || nameAt.some(coveredAt);
|
|
238
|
+
const carriesModel = codeAt.every(coveredAt);
|
|
239
|
+
const anchorsOnQuery = coversQuery && carriesName && carriesModel && (targets.length === 0 || !typedTheClass);
|
|
240
|
+
const onClass = (classAnchor >= 0 || anchorsOnQuery) && !namesAnotherModel(stems, spelled, wordList, roles);
|
|
127
241
|
const queryAnchor = anchorsOnQuery ? firstIndex(stems, queryWords) : -1;
|
|
128
|
-
const anchor =
|
|
242
|
+
const anchor = onClass && accessoryAt >= 0 ? accessoryAt : earliest(classAnchor, queryAnchor);
|
|
129
243
|
const forIndex = firstIndex(stems, FOR_MARKERS);
|
|
130
244
|
const compatibleIndex = firstIndex(stems, COMPATIBLE_MARKER);
|
|
131
|
-
const isAdjunct = anchor >= 0 && (excludes.some((phrase) => excludeFollows(stems, phrase, anchor)) || compatibleIndex >= 0 && anchor > compatibleIndex || forIndex >= 0 && anchor > forIndex && forExcludes.some((phrase) =>
|
|
245
|
+
const isAdjunct = anchor >= 0 && (excludes.some((phrase) => excludeFollows(stems, phrase, anchor)) || compatibleIndex >= 0 && anchor > compatibleIndex || forIndex >= 0 && anchor > forIndex && forExcludes.some((phrase) => namesTheItem(stems, phrase, anchor)));
|
|
132
246
|
return {
|
|
133
|
-
product,
|
|
134
|
-
index,
|
|
135
247
|
score,
|
|
136
|
-
relevant: onClass && !isAdjunct
|
|
248
|
+
relevant: onClass && !isAdjunct,
|
|
249
|
+
adjunct: isAdjunct
|
|
137
250
|
};
|
|
138
|
-
}
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
function filterProductsByRelevance(products, relevance) {
|
|
254
|
+
if (!relevance || products.length === 0) return products;
|
|
255
|
+
const judge = relevanceJudge(relevance);
|
|
256
|
+
if (!judge) return products;
|
|
257
|
+
const kept = products.map((product, index) => __spreadValues({
|
|
258
|
+
product,
|
|
259
|
+
index
|
|
260
|
+
}, judge(product))).filter((entry) => entry.relevant);
|
|
139
261
|
kept.sort((a, b) => b.score - a.score || a.index - b.index);
|
|
140
262
|
return kept.map(({
|
|
141
263
|
product
|
|
142
264
|
}) => product);
|
|
143
|
-
}
|
|
265
|
+
}
|
|
266
|
+
function accessoryTest(query) {
|
|
267
|
+
const judge = query.trim() ? relevanceJudge({
|
|
268
|
+
query
|
|
269
|
+
}) : null;
|
|
270
|
+
return (title) => !!judge && judge({
|
|
271
|
+
name: title
|
|
272
|
+
}).adjunct;
|
|
273
|
+
}export{accessoryTest,filterProductsByRelevance};//# sourceMappingURL=searchRelevance.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchRelevance.js","sources":["../../../../src/features/shopping/services/searchRelevance.ts"],"sourcesContent":["/**\n * Does this product answer the query the user actually typed?\n *\n * Two things let unrelated rows onto the grid, and neither is fixable by looking\n * at the query string alone:\n *\n * 1. Conversational framing reached the providers verbatim. Retailer keyword\n * search OR-matches tokens, so \"i only asked for running shoes\" pulled in\n * \"I Am Only the Running Man\" and an \"I Only Run for Cake\" mug.\n * 2. Retailer catalogs text-match the product word, so even a clean \"shoes\"\n * returns shoe LACES, a shoe TRAY and the \"Shoe Books\" paperbacks — every\n * one of them carrying the class noun.\n *\n * (1) is yantra-brain's job and always was: its shopping task returns `query`\n * with the filler already gone. (2) needs to know what the product IS in order\n * to say what it is not, and the answer differs per query — the exclusions for\n * \"shoes\" have nothing in common with those for \"air fryer\". So the brain\n * returns that too, as `productType` / `synonyms` / `excludes`.\n *\n * NOTHING here is a word list. This module holds only the grammar for applying\n * what the brain returned:\n *\n * - singular/plural stemming, so \"shoes\" matches \"Shoe\";\n * - phrase matching, because a productType can be \"coffee maker\";\n * - the positional rule for exclusions — an excluded word AFTER the product\n * word is an accessory (\"Laptop Stand\", \"Shoe Laces\"), the same word BEFORE\n * it is a qualifier (\"Stand Mixer\", \"Lace-up Shoe\").\n *\n * No brain verdict, no filtering: {@link filterProductsByRelevance} returns the\n * list untouched rather than guessing with rules of its own.\n */\n\n/** The relevance half of yantra-brain's shopping intent. */\nexport interface ShoppingRelevance {\n /** Clean product terms — the brain's `query`, filler already stripped. */\n query?: string;\n /** Product class being bought (\"shoe\", \"coffee maker\"); absent for brand/model queries. */\n productType?: string;\n /** Other words a retailer might title the same product with. */\n synonyms?: string[];\n /** Words naming a DIFFERENT product that shares the class word. */\n excludes?: string[];\n /**\n * The department the brain filed the request under. Read for one thing: a\n * device department is where {@link ACCESSORY_TERMS} is the right vocabulary,\n * so there it is applied alongside the brain's own excludes.\n */\n departmentId?: string;\n}\n\n/**\n * Crude singular stem — enough to make \"shoes\"/\"shoe\" and \"watches\"/\"watch\" the\n * same token. Deliberately not a real stemmer: over-stemming (\"running\" → \"run\")\n * would match an \"I Only Run for Cake\" mug to a running shoe.\n */\nfunction stem(word: string): string {\n if (word.length <= 3) return word;\n if (/ies$/.test(word)) return `${word.slice(0, -3)}y`;\n if (/(?:ch|sh|ss|x|z)es$/.test(word)) return word.slice(0, -2);\n if (/s$/.test(word) && !/(?:ss|us|is)$/.test(word)) return word.slice(0, -1);\n return word;\n}\n\nfunction tokenize(text: string): string[] {\n return (text || '')\n .toLowerCase()\n .replace(/['’]/g, '')\n .split(/[^a-z0-9]+/)\n .filter(Boolean);\n}\n\n/**\n * English function words — closed-class grammar, not product vocabulary.\n *\n * They are dropped before the query's words are used as coverage, because they\n * carry no product meaning and counting them lets junk clear the bar: \"shoes\n * for running\" is three words, so half-coverage is two, and \"Running Board for\n * Truck\" scored exactly two — \"running\" and \"for\" — with nothing of the product\n * in it. Removing them costs nothing (no title is relevant BECAUSE it says\n * \"for\") and makes the bar mean what it says.\n */\nconst FUNCTION_WORDS = new Set([\n 'a',\n 'an',\n 'the',\n 'and',\n 'or',\n 'of',\n 'for',\n 'with',\n 'without',\n 'in',\n 'on',\n 'at',\n 'to',\n 'from',\n 'by',\n 'as',\n 'is',\n 'are',\n 'be',\n 'that',\n 'this',\n 'these',\n 'those',\n 'it',\n 'its',\n 'my',\n 'our',\n 'your',\n 'their',\n 'his',\n 'her',\n 'me',\n 'us',\n 'you',\n 'i',\n]);\n\n/** A brain-supplied word or phrase, ready to match against a title. */\ntype Phrase = string[];\n\nfunction toPhrase(value: string): Phrase {\n return tokenize(value).map(stem);\n}\n\nfunction toPhrases(values: string[] | undefined): Phrase[] {\n return (values ?? []).map(toPhrase).filter((phrase) => phrase.length > 0);\n}\n\n/**\n * Index of `phrase` in `stems`, or -1. Whole-token matching throughout: an\n * exclusion of \"lace\" must not fire on \"necklace\", and \"book\" must not fire on\n * \"notebook\".\n */\nfunction phraseIndex(stems: string[], phrase: Phrase): number {\n if (phrase.length === 0) return -1;\n for (let i = 0; i + phrase.length <= stems.length; i++) {\n let hit = true;\n for (let j = 0; j < phrase.length; j++) {\n if (stems[i + j] !== phrase[j]) {\n hit = false;\n break;\n }\n }\n if (hit) return i;\n }\n return -1;\n}\n\nfunction samePhrase(a: Phrase, b: Phrase): boolean {\n return a.length === b.length && a.every((token, i) => token === b[i]);\n}\n\n/** Earliest position at which any of `phrases` appears, or -1. */\nfunction firstIndex(stems: string[], phrases: Phrase[]): number {\n let best = -1;\n for (const phrase of phrases) {\n const at = phraseIndex(stems, phrase);\n if (at >= 0 && (best < 0 || at < best)) best = at;\n }\n return best;\n}\n\n/**\n * Keep only products the query asked for, best match first.\n *\n * - The brain named a `productType` → the title must carry it or one of its\n * synonyms, OR cover the query the way the next rule describes. The second\n * half is what keeps a brand/model title that never says its class (\"Apple\n * MacBook Air 13.6-inch, M2 Chip\" for \"macbook\", class \"laptop\"). A novel\n * titled \"Ballet Shoes\" carries the class word, but see the exclusion rule.\n * - It named none (a brand/model query like \"nike pegasus 41\", or the brain was\n * unreachable) → the title must cover {@link requiredCoverage} of the query's\n * CONTENT words: all of them for a one- or two-word query, at least half and\n * never fewer than two beyond that. Half of two is one, and one word out of\n * two is how \"Running Board for Truck\" answered \"shoes for running\".\n * - Either way, a brain-supplied exclusion appearing AFTER the product word\n * drops the row: \"Shoe Laces\" and \"Laptop Stand\" are accessories, while the\n * same words before it (\"Lace-up Shoe\", \"Stand Mixer\") qualify the product.\n *\n * Survivors rank by how much of the query they cover, so actual RUNNING shoes\n * sort above plain shoes.\n */\n\n/**\n * How many of a query's content words a title must carry when the brain named no\n * product class — the degraded lane, where there is no productType to anchor on\n * and no synonyms to forgive a listing's wording.\n *\n * Short queries need EVERY word, because with two words \"at least half\" is one,\n * and one shared word is a coincidence, not a match. Longer queries keep the\n * half rule (with a floor of two) so a listing that spells one token differently\n * still lands.\n */\nfunction requiredCoverage(wordCount: number): number {\n return wordCount <= 2 ? wordCount : Math.max(2, Math.ceil(wordCount / 2));\n}\n\n/**\n * A CROSS-CATEGORY accessory baseline. A case / sleeve / adapter / stand / dock\n * is an accessory FOR whatever product it names, which is exactly the positional\n * rule above: it is what still drops the bags and dongles from a bare \"macbook\n * pro laptop\" when the brain was unreachable.\n *\n * Where it applies:\n * - the brain named no exclusions at all → it is the exclusion list;\n * - the brain filed the request under a DEVICE department → it is added to the\n * brain's list, not replaced by it. The brain's excludes are a handful of\n * words; for \"macbook\" they were case / charger / stand / screen protector,\n * and with nothing else in force a wired mouse, a VGA adapter and a laptop\n * bag were the top \"Catalog matches\" for a laptop search;\n * - a title that names the product only after \"for\" / \"fits\" / \"compatible\"\n * (\"Mouse for MacBook\") → always, see FOR_MARKERS.\n *\n * It does NOT otherwise apply on top of a brain verdict. These words are drawn\n * from consumer electronics, and the store sells everything — \"sleeve\" is a\n * t-shirt's cut, \"cover\" is a book's, \"strap\" is a watch's, \"mouse\" is a cat\n * toy. Any term the SHOPPER typed is removed in every case, so \"laptop case\"\n * still shows cases.\n */\nconst ACCESSORY_TERMS: string[] = [\n 'case',\n 'cover',\n 'shell',\n 'sleeve',\n 'bag',\n 'pouch',\n 'folio',\n 'skin',\n 'sticker',\n 'decal',\n 'adapter',\n 'adaptor',\n 'dongle',\n 'hub',\n 'converter',\n 'charger',\n 'cable',\n 'cord',\n 'stand',\n 'mount',\n 'holder',\n 'dock',\n 'station',\n 'lock',\n 'cradle',\n 'protector',\n 'strap',\n 'lanyard',\n 'replacement',\n 'mouse',\n 'mousepad',\n // A book ABOUT the device (\"MacBook For Seniors … (Paperback)\") is not the device.\n 'paperback',\n 'hardcover',\n // Multi-word: \"Laptop Screen\" is a replacement part, not a laptop. These can\n // START on the product word, so the positional test uses the phrase's END.\n 'screen protector',\n 'privacy screen',\n 'keyboard cover',\n 'laptop screen',\n 'replacement screen',\n 'carrying case',\n 'mouse pad',\n];\n\n/**\n * Departments whose products ARE devices, where {@link ACCESSORY_TERMS} is the\n * category's own vocabulary rather than a guess from another one.\n */\nconst DEVICE_DEPARTMENTS: ReadonlySet<string> = new Set(['high-tech', 'gaming', 'camera']);\n\n// \"X for MacBook\" / \"Fits iPhone\" / \"Compatible with …\" — when the product word\n// appears AFTER one of these markers, the listing is describing what the item is\n// FOR, so an accessory noun anywhere makes it an adjunct even when it PRECEDES\n// the product word (\"USB Adapter for MacBook Pro\"), which the positional rule\n// alone would miss.\nconst FOR_MARKERS: Phrase[] = [['for'], ['fit'], ['compatible']];\n// \"Compatible with <product>\" is the one marker only an adjunct is written with:\n// \"Bottomless Portafilter Compatible with Breville Espresso Machine\" names no\n// accessory word the baseline knows, but a product that is the class itself never\n// says it is compatible with it. \"For\" and \"fit\" stay noun-gated: \"Ready for\n// Anything Backpack\" and \"Slim Fit Jeans\" are the products, not adjuncts.\nconst COMPATIBLE_MARKER: Phrase[] = [['compatible']];\n\n/**\n * The universal accessory excludes, minus anything the shopper actually asked\n * for. A phrase is dropped from the list only when the query contains its HEAD\n * noun (the last token) — \"laptop case\" keeps cases, but \"macbook pro laptop\"\n * still excludes \"laptop screen\", because the shopper typed the product word\n * \"laptop\", not the accessory word \"screen\".\n */\nfunction accessoryExcludePhrases(queryStemSet: Set<string>): Phrase[] {\n return ACCESSORY_TERMS.map(toPhrase).filter(\n (phrase) => phrase.length > 0 && !queryStemSet.has(phrase[phrase.length - 1]),\n );\n}\n\n/**\n * True if `phrase` occurs and its LAST token is past `anchor`. Using the END,\n * not the start, is what disqualifies \"Laptop Screen\": the phrase begins ON the\n * product word (\"laptop\"), so a start-position \"> anchor\" test would miss it,\n * but \"screen\" plainly follows the product word.\n */\nfunction excludeFollows(stems: string[], phrase: Phrase, anchor: number): boolean {\n const at = phraseIndex(stems, phrase);\n return at >= 0 && at + phrase.length - 1 > anchor;\n}\n\nexport function filterProductsByRelevance<T extends { name: string; brand?: string }>(\n products: T[],\n relevance: ShoppingRelevance | undefined,\n): T[] {\n if (!relevance || products.length === 0) return products;\n\n const targets = toPhrases([relevance.productType, ...(relevance.synonyms ?? [])].filter(Boolean) as string[]);\n const brainExcludes = toPhrases(relevance.excludes);\n // Content words only — see FUNCTION_WORDS. A query that is nothing BUT\n // function words keeps them, rather than becoming un-judgeable.\n const queryTokens = tokenize(relevance.query ?? '');\n const contentTokens = queryTokens.filter((token) => !FUNCTION_WORDS.has(token));\n const queryWords = toPhrases(contentTokens.length > 0 ? contentTokens : queryTokens);\n\n // Nothing to judge against — the brain declined or answered without a shape.\n if (targets.length === 0 && queryWords.length === 0) return products;\n\n // The brain's per-category excludes; the universal accessory baseline (minus\n // anything the shopper typed) instead when it gave none, and as well when it\n // filed the request under a device department. See ACCESSORY_TERMS.\n const queryStemSet = new Set(queryWords.flat());\n const baseline = accessoryExcludePhrases(queryStemSet);\n const isDeviceSearch = DEVICE_DEPARTMENTS.has(relevance.departmentId ?? '');\n const excludes =\n brainExcludes.length === 0 ? baseline : isDeviceSearch ? [...brainExcludes, ...baseline] : brainExcludes;\n // \"X for <product>\" names X, whatever the category: there the baseline\n // always counts as evidence of an accessory.\n const forExcludes = brainExcludes.length === 0 || isDeviceSearch ? excludes : [...brainExcludes, ...baseline];\n\n const typePhrase = relevance.productType ? toPhrase(relevance.productType) : null;\n // Did the shopper name the class themselves (\"dog food\", \"running shoes\")?\n // Then the class word is THE anchor, as it always was. Only when they named\n // something else - a brand or model (\"macbook\", \"iphone 15\") whose class the\n // brain inferred - do their own words anchor too; otherwise \"Dog Mat for\n // Food & Water\" would pass \"dog food\" for carrying both words.\n const queryStems = queryWords.flat();\n const typedTheClass = targets.some((target) => phraseIndex(queryStems, target) >= 0);\n\n const kept = products\n .map((product, index) => {\n const stems = tokenize(`${product.name ?? ''} ${product.brand ?? ''}`).map(stem);\n const classAnchor = targets.length > 0 ? firstIndex(stems, targets) : -1;\n\n // A synonym match satisfies the class word for ranking too, so\n // \"Running Sneakers\" scores as highly on \"running shoes\" as\n // \"Running Shoes\" does — otherwise the title that happens to use the\n // user's exact noun always wins, which is not a relevance signal.\n const classCovered = classAnchor >= 0 && typePhrase !== null;\n const score = queryWords.filter(\n (word) =>\n phraseIndex(stems, word) >= 0 ||\n (classCovered && typePhrase !== null && samePhrase(word, typePhrase)),\n ).length;\n const coversQuery = queryWords.length > 0 && score >= requiredCoverage(queryWords.length);\n\n // On class when the title carries the product class, OR - for a\n // brand/model query (see typedTheClass) - when it carries what the\n // shopper actually typed. The class word alone was not enough: for\n // \"macbook\" the brain's class is \"laptop\", and an \"Apple MacBook Air\n // 13.6-inch, M2 Chip\" never says laptop - every real MacBook without\n // that word was dropped while a mouse \"for MacBook … Laptop\" was\n // kept, because IT said laptop.\n const anchorsOnQuery = coversQuery && (targets.length === 0 || !typedTheClass);\n const onClass = classAnchor >= 0 || anchorsOnQuery;\n const queryAnchor = anchorsOnQuery ? firstIndex(stems, queryWords) : -1;\n // The product word the rules below read positions against: the\n // earliest place the title names the product, either way.\n const anchor =\n classAnchor >= 0 && queryAnchor >= 0\n ? Math.min(classAnchor, queryAnchor)\n : Math.max(classAnchor, queryAnchor);\n\n // An exclusion disqualifies where it FOLLOWS the product word\n // (\"Laptop Stand\"), OR where the title frames the product as what the\n // item is FOR (\"Adapter for Laptop\") — a for/fits/compatible marker\n // before the product word, plus any excluded noun anywhere.\n const forIndex = firstIndex(stems, FOR_MARKERS);\n const compatibleIndex = firstIndex(stems, COMPATIBLE_MARKER);\n const isAdjunct =\n anchor >= 0 &&\n (excludes.some((phrase) => excludeFollows(stems, phrase, anchor)) ||\n (compatibleIndex >= 0 && anchor > compatibleIndex) ||\n (forIndex >= 0 &&\n anchor > forIndex &&\n forExcludes.some((phrase) => phraseIndex(stems, phrase) >= 0)));\n\n return { product, index, score, relevant: onClass && !isAdjunct };\n })\n .filter((entry) => entry.relevant);\n\n // Better coverage first; original merge order (source ranking) breaks ties.\n kept.sort((a, b) => b.score - a.score || a.index - b.index);\n return kept.map(({ product }) => product);\n}\n"],"names":["_a","_b"],"mappings":"AAuDA,SAAS,KAAK,IAAsB,EAAA;AAClC,EAAI,IAAA,IAAA,CAAK,MAAU,IAAA,CAAA,EAAU,OAAA,IAAA;AAC7B,EAAI,IAAA,MAAA,CAAO,IAAK,CAAA,IAAI,CAAG,EAAA,OAAO,GAAG,IAAK,CAAA,KAAA,CAAM,CAAG,EAAA,EAAE,CAAC,CAAA,CAAA,CAAA;AAClD,EAAI,IAAA,qBAAA,CAAsB,KAAK,IAAI,CAAA,SAAU,IAAK,CAAA,KAAA,CAAM,GAAG,EAAE,CAAA;AAC7D,EAAA,IAAI,IAAK,CAAA,IAAA,CAAK,IAAI,CAAA,IAAK,CAAC,eAAA,CAAgB,IAAK,CAAA,IAAI,CAAG,EAAA,OAAO,IAAK,CAAA,KAAA,CAAM,GAAG,EAAE,CAAA;AAC3E,EAAO,OAAA,IAAA;AACT;AACA,SAAS,SAAS,IAAwB,EAAA;AACxC,EAAA,OAAA,CAAQ,IAAQ,IAAA,EAAA,EAAI,WAAY,EAAA,CAAE,OAAQ,CAAA,OAAA,EAAS,EAAE,CAAA,CAAE,KAAM,CAAA,YAAY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["../../../../src/features/shopping/services/searchRelevance.ts"],"sourcesContent":["/**\n * Native twin of the web surface's `services/searchRelevance.ts` (0.49.0), verbatim.\n *\n * Does this product answer the query the user actually typed?\n *\n * Two things let unrelated rows onto the grid, and neither is fixable by looking\n * at the query string alone:\n *\n * 1. Conversational framing reached the providers verbatim. Retailer keyword\n * search OR-matches tokens, so \"i only asked for running shoes\" pulled in\n * \"I Am Only the Running Man\" and an \"I Only Run for Cake\" mug.\n * 2. Retailer catalogs text-match the product word, so even a clean \"shoes\"\n * returns shoe LACES, a shoe TRAY and the \"Shoe Books\" paperbacks — every\n * one of them carrying the class noun.\n *\n * (1) is yantra-brain's job and always was: its shopping task returns `query`\n * with the filler already gone. (2) needs to know what the product IS in order\n * to say what it is not, and the answer differs per query — the exclusions for\n * \"shoes\" have nothing in common with those for \"air fryer\". So the brain\n * returns that too, as `productType` / `synonyms` / `excludes`.\n *\n * NOTHING here is a word list. This module holds only the grammar for applying\n * what the brain returned:\n *\n * - singular/plural stemming, so \"shoes\" matches \"Shoe\";\n * - phrase matching, because a productType can be \"coffee maker\";\n * - the positional rule for exclusions — an excluded word AFTER the product\n * word is an accessory (\"Laptop Stand\", \"Shoe Laces\"), the same word BEFORE\n * it is a qualifier (\"Stand Mixer\", \"Lace-up Shoe\").\n *\n * No brain verdict, no filtering: {@link filterProductsByRelevance} returns the\n * list untouched rather than guessing with rules of its own.\n */\n\nimport { codeFamily, modelWordRole, type ModelWordRole } from './modelWords';\n\n/** The relevance half of yantra-brain's shopping intent. */\nexport interface ShoppingRelevance {\n /** Clean product terms — the brain's `query`, filler already stripped. */\n query?: string;\n /** Product class being bought (\"shoe\", \"coffee maker\"); absent for brand/model queries. */\n productType?: string;\n /** Other words a retailer might title the same product with. */\n synonyms?: string[];\n /** Words naming a DIFFERENT product that shares the class word. */\n excludes?: string[];\n /**\n * The department the brain filed the request under. Read for one thing: a\n * device department is where {@link ACCESSORY_TERMS} is the right vocabulary,\n * so there it is applied alongside the brain's own excludes.\n */\n departmentId?: string;\n}\n\n/**\n * Crude singular stem — enough to make \"shoes\"/\"shoe\" and \"watches\"/\"watch\" the\n * same token. Deliberately not a real stemmer: over-stemming (\"running\" → \"run\")\n * would match an \"I Only Run for Cake\" mug to a running shoe.\n */\nfunction stem(word: string): string {\n if (word.length <= 3) return word;\n if (/ies$/.test(word)) return `${word.slice(0, -3)}y`;\n if (/(?:ch|sh|ss|x|z)es$/.test(word)) return word.slice(0, -2);\n if (/s$/.test(word) && !/(?:ss|us|is)$/.test(word)) return word.slice(0, -1);\n return word;\n}\n\nfunction tokenize(text: string): string[] {\n return (text || '')\n .toLowerCase()\n .replace(/['’]/g, '')\n .split(/[^a-z0-9]+/)\n .filter(Boolean);\n}\n\n/**\n * English function words — closed-class grammar, not product vocabulary.\n *\n * They are dropped before the query's words are used as coverage, because they\n * carry no product meaning and counting them lets junk clear the bar: \"shoes\n * for running\" is three words, so half-coverage is two, and \"Running Board for\n * Truck\" scored exactly two — \"running\" and \"for\" — with nothing of the product\n * in it. Removing them costs nothing (no title is relevant BECAUSE it says\n * \"for\") and makes the bar mean what it says.\n */\nconst FUNCTION_WORDS = new Set([\n 'a',\n 'an',\n 'the',\n 'and',\n 'or',\n 'of',\n 'for',\n 'with',\n 'without',\n 'in',\n 'on',\n 'at',\n 'to',\n 'from',\n 'by',\n 'as',\n 'is',\n 'are',\n 'be',\n 'that',\n 'this',\n 'these',\n 'those',\n 'it',\n 'its',\n 'my',\n 'our',\n 'your',\n 'their',\n 'his',\n 'her',\n 'me',\n 'us',\n 'you',\n 'i',\n]);\n\n/** A brain-supplied word or phrase, ready to match against a title. */\ntype Phrase = string[];\n\nfunction toPhrase(value: string): Phrase {\n return tokenize(value).map(stem);\n}\n\nfunction toPhrases(values: string[] | undefined): Phrase[] {\n return (values ?? []).map(toPhrase).filter((phrase) => phrase.length > 0);\n}\n\n/**\n * Index of `phrase` in `stems` at or after `from`, or -1. Whole-token matching\n * throughout: an exclusion of \"lace\" must not fire on \"necklace\", and \"book\"\n * must not fire on \"notebook\".\n */\nfunction phraseIndex(stems: string[], phrase: Phrase, from = 0): number {\n if (phrase.length === 0) return -1;\n for (let i = Math.max(0, from); i + phrase.length <= stems.length; i++) {\n let hit = true;\n for (let j = 0; j < phrase.length; j++) {\n if (stems[i + j] !== phrase[j]) {\n hit = false;\n break;\n }\n }\n if (hit) return i;\n }\n return -1;\n}\n\nfunction samePhrase(a: Phrase, b: Phrase): boolean {\n return a.length === b.length && a.every((token, i) => token === b[i]);\n}\n\n/** Earliest position at which any of `phrases` appears, or -1. */\nfunction firstIndex(stems: string[], phrases: Phrase[]): number {\n let best = -1;\n for (const phrase of phrases) {\n const at = phraseIndex(stems, phrase);\n if (at >= 0 && (best < 0 || at < best)) best = at;\n }\n return best;\n}\n\n/**\n * Keep only products the query asked for, best match first.\n *\n * - The brain named a `productType` → the title must carry it or one of its\n * synonyms, OR cover the query the way the next rule describes. The second\n * half is what keeps a brand/model title that never says its class (\"Apple\n * MacBook Air 13.6-inch, M2 Chip\" for \"macbook\", class \"laptop\"). A novel\n * titled \"Ballet Shoes\" carries the class word, but see the exclusion rule.\n * - It named none (a brand/model query like \"nike pegasus 41\", or the brain was\n * unreachable) → the title must cover {@link requiredCoverage} of the query's\n * CONTENT words: all of them for a one- or two-word query, at least half and\n * never fewer than two beyond that. Half of two is one, and one word out of\n * two is how \"Running Board for Truck\" answered \"shoes for running\".\n * - Covering the query means covering what NAMES the product and the model:\n * qualifiers alone (\"m3 pro\" of \"m3 pro macbook\", a garment iron's model) are\n * not the product, and a model code the shopper typed (\"m3\") must be there.\n * Words split differently count (\"wh-1000xm5\" = \"WH1000XM5\").\n * - A title naming another model of the same shape - another chip code (\"M2\n * Pro\" for \"m3 pro\"), another number after the product word (\"iPhone 14\" for\n * \"iphone 15\") - is not the product, whichever rule let it in.\n * - Either way, a brain-supplied exclusion appearing AFTER the product word\n * drops the row: \"Shoe Laces\" and \"Laptop Stand\" are accessories, while the\n * same words before it (\"Lace-up Shoe\", \"Stand Mixer\") qualify the product.\n *\n * Survivors rank by how much of the query they cover, so actual RUNNING shoes\n * sort above plain shoes, and the model line named as asked (\"M3 Pro\") above\n * the other lines of that model (\"MacBook Pro ... M3\").\n */\n\n/**\n * How many of a query's content words a title must carry when the brain named no\n * product class — the degraded lane, where there is no productType to anchor on\n * and no synonyms to forgive a listing's wording.\n *\n * Short queries need EVERY word, because with two words \"at least half\" is one,\n * and one shared word is a coincidence, not a match. Longer queries keep the\n * half rule (with a floor of two) so a listing that spells one token differently\n * still lands.\n */\nfunction requiredCoverage(wordCount: number): number {\n return wordCount <= 2 ? wordCount : Math.max(2, Math.ceil(wordCount / 2));\n}\n\n/**\n * A CROSS-CATEGORY accessory baseline. A case / sleeve / adapter / stand / dock\n * is an accessory FOR whatever product it names, which is exactly the positional\n * rule above: it is what still drops the bags and dongles from a bare \"macbook\n * pro laptop\" when the brain was unreachable.\n *\n * Where it applies:\n * - the brain named no exclusions at all → it is the exclusion list;\n * - the brain filed the request under a DEVICE department → it is added to the\n * brain's list, not replaced by it. The brain's excludes are a handful of\n * words; for \"macbook\" they were case / charger / stand / screen protector,\n * and with nothing else in force a wired mouse, a VGA adapter and a laptop\n * bag were the top \"Catalog matches\" for a laptop search;\n * - a title that names the product only after \"for\" / \"fits\" / \"compatible\"\n * (\"Mouse for MacBook\") → always, see FOR_MARKERS.\n *\n * It does NOT otherwise apply on top of a brain verdict. These words are drawn\n * from consumer electronics, and the store sells everything — \"sleeve\" is a\n * t-shirt's cut, \"cover\" is a book's, \"strap\" is a watch's, \"mouse\" is a cat\n * toy. Any term the SHOPPER typed is removed in every case, so \"laptop case\"\n * still shows cases.\n */\nconst ACCESSORY_TERMS: string[] = [\n 'case',\n 'cover',\n 'shell',\n 'sleeve',\n 'bag',\n 'pouch',\n 'folio',\n 'skin',\n 'sticker',\n 'decal',\n 'adapter',\n 'adaptor',\n 'dongle',\n 'hub',\n 'converter',\n 'charger',\n 'cable',\n 'cord',\n 'stand',\n 'mount',\n 'holder',\n 'dock',\n 'station',\n 'lock',\n 'cradle',\n 'protector',\n 'strap',\n 'lanyard',\n 'replacement',\n 'power bank',\n 'mouse',\n 'mousepad',\n // A book ABOUT the device (\"MacBook For Seniors … (Paperback)\") is not the device.\n 'paperback',\n 'hardcover',\n // Multi-word: \"Laptop Screen\" is a replacement part, not a laptop. These can\n // START on the product word, so the positional test uses the phrase's END.\n 'screen protector',\n 'privacy screen',\n 'keyboard cover',\n 'laptop screen',\n 'replacement screen',\n 'carrying case',\n 'mouse pad',\n];\n\n/**\n * Departments whose products ARE devices, where {@link ACCESSORY_TERMS} is the\n * category's own vocabulary rather than a guess from another one.\n */\nconst DEVICE_DEPARTMENTS: ReadonlySet<string> = new Set(['high-tech', 'gaming', 'camera']);\n\n/**\n * The part of {@link ACCESSORY_TERMS} that says a listing is a BOOK, not a thing:\n * neither the device nor anything made for it. Unlike the accessory nouns, these\n * stay in force when the shopper is buying an accessory - \"iPad for Seniors\n * (Covers All iPads) (Paperback)\" carries both words of \"ipad cover\".\n */\nconst FORMAT_TERMS: string[] = ['paperback', 'hardcover'];\n\n/**\n * The single nouns of {@link ACCESSORY_TERMS} that name an accessory when they\n * head a query or a product class: \"ipad cover\" is a cover, \"laptop stand\" a\n * stand, \"usb c hub\" a hub. \"Replacement\" qualifies a part and names none.\n */\nconst ACCESSORY_NOUNS: ReadonlySet<string> = new Set(\n ACCESSORY_TERMS.filter((term) => !term.includes(' ') && term !== 'replacement' && !FORMAT_TERMS.includes(term)).map(\n stem,\n ),\n);\n\n/**\n * The nouns sellers use interchangeably for what encloses a device: one shop's\n * \"iPad mini Cover\" is another's \"Smart Folio for iPad mini\", a \"Case\", a\n * \"Shell\" or a \"Sleeve\". When the shopper asks for one of them, any of them\n * answers. (Measured for \"mini ipad covers\": Apple's own \"Smart Folio for iPad\n * mini\" said neither case nor cover, and was dropped at Target and the catalog.)\n */\nconst ENCLOSURE_NOUNS: ReadonlySet<string> = new Set(\n ['case', 'cover', 'shell', 'sleeve', 'pouch', 'folio', 'skin'].map(stem),\n);\n\n/**\n * Prepositions that end the noun phrase a query names: \"case for ipad\" is a case,\n * \"shoes for running\" are shoes.\n */\nconst PREPOSITIONS: ReadonlySet<string> = new Set(['for', 'with', 'without', 'in', 'on', 'to', 'from', 'by', 'of']);\n\n/**\n * The noun a query shops for. English compounds are head-final (\"ipad cover\" is a\n * cover, \"running shoes\" are shoes) and a prepositional tail only qualifies the\n * head, so it is the last content word before the first preposition.\n */\nfunction headNoun(tokens: string[]): string | undefined {\n const cut = tokens.findIndex((token, i) => i > 0 && PREPOSITIONS.has(token));\n const words = (cut > 0 ? tokens.slice(0, cut) : tokens).filter((token) => !FUNCTION_WORDS.has(token));\n return words.length > 0 ? stem(words[words.length - 1]) : undefined;\n}\n\n/**\n * Where `phrase` names the class in a title written in any order, or -1: every\n * word of it is in the title, and the answer is the position of its HEAD (last)\n * word. Only for an accessory class - see `buysAccessory` - where sellers put the\n * device after the noun as often as before it: \"Case for iPad\", \"MoKo for iPad\n * (A16) 11th Generation Case\" and \"iPad Case\" are the same \"ipad case\". A device\n * or food class keeps the strict phrase, which is what tells \"Dog Food\" from a\n * \"Dog Mat for Food & Water\".\n */\nfunction unorderedClassIndex(stems: string[], phrase: Phrase): number {\n const contiguous = phraseIndex(stems, phrase);\n if (contiguous >= 0) return contiguous;\n if (phrase.length < 2 || !phrase.every((word) => stems.includes(word))) return -1;\n return stems.indexOf(phrase[phrase.length - 1]);\n}\n\n/** The smaller of two positions, -1 meaning \"not there\". */\nfunction earliest(a: number, b: number): number {\n if (a < 0) return b;\n if (b < 0) return a;\n return Math.min(a, b);\n}\n\n/**\n * A store that files a row under Books (\"Pre-Owned Books\") is selling a book about\n * the thing - \"Pre-Owned My iPad (Covers IOS 7 on iPad Air …)\" for \"ipad cover\" -\n * however well its title matches. Read only for a device search: in any other\n * department a book may be exactly what the shopper wants.\n */\nfunction filedAsBook(storeCategory: string | undefined): boolean {\n return tokenize(storeCategory ?? '').some((token) => stem(token) === 'book');\n}\n\n// \"X for MacBook\" / \"Fits iPhone\" / \"Compatible with …\" — when the product word\n// appears AFTER one of these markers, the listing is describing what the item is\n// FOR, so an accessory noun anywhere makes it an adjunct even when it PRECEDES\n// the product word (\"USB Adapter for MacBook Pro\"), which the positional rule\n// alone would miss.\nconst FOR_MARKERS: Phrase[] = [['for'], ['fit'], ['compatible']];\n// \"Compatible with <product>\" is the one marker only an adjunct is written with:\n// \"Bottomless Portafilter Compatible with Breville Espresso Machine\" names no\n// accessory word the baseline knows, but a product that is the class itself never\n// says it is compatible with it. \"For\" and \"fit\" stay noun-gated: \"Ready for\n// Anything Backpack\" and \"Slim Fit Jeans\" are the products, not adjuncts.\nconst COMPATIBLE_MARKER: Phrase[] = [['compatible']];\n\n/**\n * The universal accessory excludes, minus anything the shopper actually asked\n * for. A phrase is dropped from the list only when the query contains its HEAD\n * noun (the last token) — \"laptop case\" keeps cases, but \"macbook pro laptop\"\n * still excludes \"laptop screen\", because the shopper typed the product word\n * \"laptop\", not the accessory word \"screen\".\n */\nfunction accessoryExcludePhrases(queryStemSet: Set<string>): Phrase[] {\n return ACCESSORY_TERMS.map(toPhrase).filter(\n (phrase) => phrase.length > 0 && !queryStemSet.has(phrase[phrase.length - 1]),\n );\n}\n\nconst FORMAT_STEMS: ReadonlySet<string> = new Set(FORMAT_TERMS.map(stem));\nconst isFormat = (phrase: Phrase): boolean => phrase.length === 1 && FORMAT_STEMS.has(phrase[0]);\n\n/** Words that open the list of what a listing comes with (\"w/\" reads as \"w\", \"built-in\" as \"built\"). */\nconst WITH_MARKERS: ReadonlySet<string> = new Set(['with', 'w', 'include', 'including', 'built']);\n\n/**\n * True if `phrase` occurs with its LAST token past `anchor`. Using the END,\n * not the start, is what disqualifies \"Laptop Screen\": the phrase begins ON the\n * product word (\"laptop\"), so a start-position \"> anchor\" test would miss it,\n * but \"screen\" plainly follows the product word. Every mention counts, not the\n * first: \"Case-Mate AirPods Pro 3 Protective Case\" names the maker before the\n * product word and the item after it.\n */\nfunction excludeFollows(stems: string[], phrase: Phrase, anchor: number): boolean {\n const at = phraseIndex(stems, phrase, anchor - phrase.length + 2);\n if (at < 0) return false;\n // What a listing comes WITH is part of it: \"iPad Case with Screen Protector\",\n // \"Laptop with Charger\", \"Necklace w/ Gift Box\". The standalone accessory still\n // goes - \"iPad Screen Protector\" names it right after the product word, and\n // \"Screen Protector for iPad\" falls to the \"for\" rule. A format is the whole\n // listing's, never something it comes with: \"… with iPadOS 13 (Paperback)\".\n return isFormat(phrase) || !withBetween(stems, anchor, at);\n}\n\n/** Whether a \"comes with\" list opens between positions `from` and `to`. */\nfunction withBetween(stems: string[], from: number, to: number): boolean {\n for (let i = from + 1; i < to; i++) {\n if (WITH_MARKERS.has(stems[i])) return true;\n }\n return false;\n}\n\n/**\n * Whether an excluded `phrase` in the title speaks for the item itself under the\n * \"for\" rule: anywhere before the product word (\"USB Adapter for MacBook\"), or\n * after it outside a \"comes with\" list - \"for iPad … Case with Keyboard\" is a case.\n */\nfunction namesTheItem(stems: string[], phrase: Phrase, anchor: number): boolean {\n const at = phraseIndex(stems, phrase);\n return at >= 0 && (at < anchor || isFormat(phrase) || !withBetween(stems, anchor, at));\n}\n\n/**\n * Every way a title spells a word: its own words, and each run of two or three\n * of them written together - \"Mac Book\" says \"macbook\", \"RTX 4090\" \"rtx4090\",\n * \"Air Pods\" \"airpod\".\n */\nfunction titleSpellings(stems: string[]): Set<string> {\n const out = new Set(stems);\n for (let i = 0; i + 1 < stems.length; i++) {\n out.add(stems[i] + stems[i + 1]);\n if (i + 2 < stems.length) out.add(stems[i] + stems[i + 1] + stems[i + 2]);\n }\n return out;\n}\n\n/**\n * Which of the query's words a title carries, a word split differently on\n * either side counting: \"wh-1000xm5\" is in \"Sony WH1000XM5\", and \"macbook\" in\n * \"Mac Book Pro\". A title's joined words only stand in for a query word of four\n * letters or more - two short tokens run together (\"s\"+\"e\") are a coincidence.\n */\nfunction queryWordsCarried(words: string[], stems: string[], spelled: Set<string>): boolean[] {\n const own = new Set(stems);\n const carried = words.map((word) => own.has(word) || (word.length >= 4 && spelled.has(word)));\n for (let i = 0; i < words.length; i++) {\n for (const span of [2, 3]) {\n if (i + span > words.length) continue;\n if (own.has(words.slice(i, i + span).join(''))) {\n for (let j = i; j < i + span; j++) carried[j] = true;\n }\n }\n }\n return carried;\n}\n\n/**\n * Whether a title names a DIFFERENT model than the one the shopper asked for:\n *\n * - another code of the same family and not the one asked for (\"MacBook Pro\n * M2 Pro\" or \"M5 Pro\" for \"m3 pro macbook\", \"Galaxy S23\" for \"s24\");\n * - another number straight after the product word the shopper put a number\n * after (\"iPhone 14 Pro Max\" for \"iphone 15 pro max\", \"Pegasus 40\" for\n * \"nike pegasus 41\").\n *\n * Only a different model of the SAME shape counts: a title that names no chip\n * at all (\"MacBook Pro 14-inch 2023\") is not ruled out here, and neither is a\n * part number (\"A2992\") beside the model asked for.\n */\nfunction namesAnotherModel(stems: string[], spelled: Set<string>, words: string[], roles: ModelWordRole[]): boolean {\n return words.some((word, i) => {\n if (spelled.has(word)) return false;\n if (roles[i] === 'code') {\n const family = codeFamily(word);\n return family !== null && [...spelled].some((t) => t !== word && codeFamily(t) === family);\n }\n if (roles[i] === 'number' && i > 0 && roles[i - 1] === 'name') {\n const head = words[i - 1];\n return stems.some(\n (t, at) =>\n t === head &&\n at + 1 < stems.length &&\n /^\\d+$/.test(stems[at + 1]) &&\n stems[at + 1].length === word.length &&\n stems[at + 1] !== word,\n );\n }\n return false;\n });\n}\n\ninterface RelevanceVerdict {\n /** How many of the query's words the listing covers, plus a half for each model line it names as asked. */\n score: number;\n /** On class and not an accessory for it: the listing answers the search. */\n relevant: boolean;\n /** A part or accessory for the product searched (\"Laptop Stand\", \"Adapter for MacBook\"). */\n adjunct: boolean;\n}\n\ntype RelevanceJudge = (product: { name: string; brand?: string; storeCategory?: string }) => RelevanceVerdict;\n\n/** How each listing is judged against `relevance`; null when there is nothing to judge against. */\nfunction relevanceJudge(relevance: ShoppingRelevance): RelevanceJudge | null {\n const brainTargets = toPhrases([relevance.productType, ...(relevance.synonyms ?? [])].filter(Boolean) as string[]);\n const brainExcludes = toPhrases(relevance.excludes);\n // Content words only — see FUNCTION_WORDS. A query that is nothing BUT\n // function words keeps them, rather than becoming un-judgeable.\n const queryTokens = tokenize(relevance.query ?? '');\n const contentTokens = queryTokens.filter((token) => !FUNCTION_WORDS.has(token));\n const queryWords = toPhrases(contentTokens.length > 0 ? contentTokens : queryTokens);\n\n // Nothing to judge against — the brain declined or answered without a shape.\n if (brainTargets.length === 0 && queryWords.length === 0) return null;\n\n const typePhrase = relevance.productType ? toPhrase(relevance.productType) : null;\n\n // Is the shopper buying an ACCESSORY (\"ipad cover\", \"laptop stand\", \"usb c\n // hub\")? Their own head noun says so, or the head of the brain's class\n // (\"tablet case\"). Then the accessory baseline is the wrong yardstick: the\n // other accessory words in a title describe the thing being bought - an\n // \"iPad Case with Pencil Holder\", a \"Folio Case with Stand\", a \"Hard Shell\" -\n // and reading them as \"a different product\" dropped every case Amazon,\n // Walmart and Target returned for \"ipad cover\" (16/16, 24/24) while a book\n // titled \"My iPad (Covers iOS 7 …)\" was the one result left. Only the format\n // words (a book about the thing) stay in force.\n const queryHead = headNoun(queryTokens);\n const typeHead = typePhrase?.[typePhrase.length - 1];\n const buysAccessory = [queryHead, typeHead].some((head) => head !== undefined && ACCESSORY_NOUNS.has(head));\n const buysEnclosure = [queryHead, typeHead].some((head) => head !== undefined && ENCLOSURE_NOUNS.has(head));\n // The class in every enclosure word: \"ipad cover\" is also \"ipad folio\", \"ipad case\" …\n const targets: Phrase[] = buysEnclosure\n ? [\n ...new Map(\n brainTargets\n .flatMap((target) =>\n ENCLOSURE_NOUNS.has(target[target.length - 1])\n ? [...ENCLOSURE_NOUNS].map((noun) => [...target.slice(0, -1), noun])\n : [target],\n )\n .map((target) => [target.join(' '), target] as const),\n ).values(),\n ]\n : brainTargets;\n // What a seller may call the accessory the shopper named: the brain's own\n // class nouns, so \"ipad cover\" is answered by an \"iPad Case\", a \"Folio Case\"\n // or a \"Sleeve\" - whichever word the listing happened to use.\n const accessoryNames: Phrase[] = buysAccessory\n ? [\n ...new Set([\n queryHead,\n ...targets.map((target) => target[target.length - 1]),\n ...(buysEnclosure ? ENCLOSURE_NOUNS : []),\n ]),\n ]\n .filter((noun): noun is string => noun !== undefined && ACCESSORY_NOUNS.has(noun))\n .map((noun) => [noun])\n : [];\n\n // The brain's per-category excludes; the universal accessory baseline (minus\n // anything the shopper typed) instead when it gave none, and as well when it\n // filed the request under a device department. See ACCESSORY_TERMS.\n const queryStemSet = new Set(queryWords.flat());\n const baseline = buysAccessory ? toPhrases(FORMAT_TERMS) : accessoryExcludePhrases(queryStemSet);\n const isDeviceSearch = DEVICE_DEPARTMENTS.has(relevance.departmentId ?? '');\n // For an accessory, a word the brain excludes AFTER the accessory's own noun\n // is one of its features: \"Case for iPad mini, Multiple Angles Magnetic Stand\n // Cover\", \"Trifold Stand\", \"with Keyboard\". The brain meant a stand or a\n // keyboard sold on its own, which names no accessory noun, or names the item\n // first and the device after \"for\" - the rule below. So for an accessory the\n // positional rule keeps only the format words.\n const excludes = buysAccessory\n ? baseline\n : brainExcludes.length === 0\n ? baseline\n : isDeviceSearch\n ? [...brainExcludes, ...baseline]\n : brainExcludes;\n // \"X for <product>\" names X, whatever the category: there the brain's\n // excludes and the baseline always count as evidence of an accessory.\n const forExcludes = [...brainExcludes, ...baseline];\n\n // Did the shopper name the class themselves (\"dog food\", \"running shoes\")?\n // Then the class word is THE anchor, as it always was. Only when they named\n // something else - a brand or model (\"macbook\", \"iphone 15\") whose class the\n // brain inferred - do their own words anchor too; otherwise \"Dog Mat for\n // Food & Water\" would pass \"dog food\" for carrying both words.\n const queryStems = queryWords.flat();\n const typedTheClass = targets.some((target) => phraseIndex(queryStems, target) >= 0);\n\n // What each of the shopper's words does in the product's name (modelWords):\n // the words that NAME it, and the qualifiers that say which one. \"M3 Pro\"\n // alone is a chip, and also a garment iron.\n const wordList = queryWords.map((word) => word.join(' '));\n const roles = wordList.map(modelWordRole);\n const nameAt = roles.flatMap((role, i) => (role === 'name' ? [i] : []));\n const codeAt = roles.flatMap((role, i) => (role === 'code' ? [i] : []));\n // A model-line word and the word it qualifies, as the shopper wrote them (\"m3\" → \"pro\").\n const lineHeads = wordList.map((_, i) => (roles[i] === 'line' && i > 0 ? wordList[i - 1] : null));\n\n return (product) => {\n if (isDeviceSearch && filedAsBook(product.storeCategory)) {\n return { score: 0, relevant: false, adjunct: false };\n }\n const stems = tokenize(`${product.name ?? ''} ${product.brand ?? ''}`).map(stem);\n const classAnchor =\n targets.length === 0\n ? -1\n : buysAccessory\n ? targets.reduce((best, target) => earliest(best, unorderedClassIndex(stems, target)), -1)\n : firstIndex(stems, targets);\n // Where the title names the accessory by any of the brain's nouns for it.\n const accessoryAt = accessoryNames.length > 0 ? firstIndex(stems, accessoryNames) : -1;\n\n // A synonym match satisfies the class word for ranking too, so\n // \"Running Sneakers\" scores as highly on \"running shoes\" as\n // \"Running Shoes\" does — otherwise the title that happens to use the\n // user's exact noun always wins, which is not a relevance signal. For\n // an accessory the same goes for the shopper's noun: a \"Case\" answers\n // the \"cover\" of \"ipad cover\" as fully as a \"Cover\" does.\n const classCovered = classAnchor >= 0 && typePhrase !== null;\n const spelled = titleSpellings(stems);\n const carried = queryWordsCarried(wordList, stems, spelled);\n const coveredAt = (i: number): boolean =>\n carried[i] ||\n (classCovered && typePhrase !== null && samePhrase(queryWords[i], typePhrase)) ||\n (accessoryAt >= 0 && queryWords[i].length === 1 && queryWords[i][0] === queryHead);\n const coveredCount = queryWords.filter((_, i) => coveredAt(i)).length;\n const coversQuery = queryWords.length > 0 && coveredCount >= requiredCoverage(queryWords.length);\n // The model line named as asked (\"M3 Pro\" for \"m3 pro\", not the \"Pro\" of\n // \"MacBook Pro ... M3\") ranks above the other lines of the same model.\n const linesAsAsked = lineHeads.filter(\n (head, i) => head !== null && stems.some((t, at) => t === head && stems[at + 1] === wordList[i]),\n ).length;\n const score = coveredCount + linesAsAsked / 2;\n\n // On class when the title carries the product class, OR - for a\n // brand/model query (see typedTheClass) - when it carries what the\n // shopper actually typed. The class word alone was not enough: for\n // \"macbook\" the brain's class is \"laptop\", and an \"Apple MacBook Air\n // 13.6-inch, M2 Chip\" never says laptop - every real MacBook without\n // that word was dropped while a mouse \"for MacBook … Laptop\" was\n // kept, because IT said laptop.\n //\n // Carrying the shopper's words means carrying what NAMES the product\n // and the model it is: the qualifiers alone are not it. \"Oliso M3 Pro\n // Garment Iron\" carries two of \"m3 pro macbook\" - the chip and the line\n // - and none of what the shopper is buying; \"Apple MacBook Neo (A18\n // Pro)\" carries \"macbook\" and \"pro\" but not the M3 that says which\n // MacBook.\n const carriesName = nameAt.length === 0 || nameAt.some(coveredAt);\n const carriesModel = codeAt.every(coveredAt);\n const anchorsOnQuery = coversQuery && carriesName && carriesModel && (targets.length === 0 || !typedTheClass);\n const onClass = (classAnchor >= 0 || anchorsOnQuery) && !namesAnotherModel(stems, spelled, wordList, roles);\n const queryAnchor = anchorsOnQuery ? firstIndex(stems, queryWords) : -1;\n // The product word the rules below read positions against: the\n // earliest place the title names the product, either way. For an\n // accessory that is the accessory noun itself, with the device it\n // fits as a qualifier: in \"iPad Keyboard Case\" the keyboard qualifies\n // the case, as \"Stand\" qualifies \"Stand Mixer\".\n const anchor = onClass && accessoryAt >= 0 ? accessoryAt : earliest(classAnchor, queryAnchor);\n\n // An exclusion disqualifies where it FOLLOWS the product word\n // (\"Laptop Stand\"), OR where the title frames the product as what the\n // item is FOR (\"Adapter for Laptop\") — a for/fits/compatible marker\n // before the product word, plus any excluded noun anywhere.\n const forIndex = firstIndex(stems, FOR_MARKERS);\n const compatibleIndex = firstIndex(stems, COMPATIBLE_MARKER);\n const isAdjunct =\n anchor >= 0 &&\n (excludes.some((phrase) => excludeFollows(stems, phrase, anchor)) ||\n (compatibleIndex >= 0 && anchor > compatibleIndex) ||\n (forIndex >= 0 &&\n anchor > forIndex &&\n forExcludes.some((phrase) => namesTheItem(stems, phrase, anchor))));\n\n return { score, relevant: onClass && !isAdjunct, adjunct: isAdjunct };\n };\n}\n\nexport function filterProductsByRelevance<T extends { name: string; brand?: string; storeCategory?: string }>(\n products: T[],\n relevance: ShoppingRelevance | undefined,\n): T[] {\n if (!relevance || products.length === 0) return products;\n const judge = relevanceJudge(relevance);\n if (!judge) return products;\n const kept = products\n .map((product, index) => ({ product, index, ...judge(product) }))\n .filter((entry) => entry.relevant);\n\n // Better coverage first; original merge order (source ranking) breaks ties.\n kept.sort((a, b) => b.score - a.score || a.index - b.index);\n return kept.map(({ product }) => product);\n}\n\n/**\n * Whether a listing title is a part or an accessory for what `query` names, by\n * the same rules as the search: \"Laptop Bag ... Compatible with MacBook Pro 16\"\n * and \"Power Bank for MacBook Pro\" for \"macbook pro\", never an \"Apple MacBook\n * Pro 14-inch\". Asked once per query, then per title.\n */\nexport function accessoryTest(query: string): (title: string) => boolean {\n const judge = query.trim() ? relevanceJudge({ query }) : null;\n return (title) => !!judge && judge({ name: title }).adjunct;\n}\n"],"names":["_a","_b"],"mappings":";;;;;;;;;;;;;;;;AA2DA,SAAS,KAAK,IAAsB,EAAA;AAClC,EAAI,IAAA,IAAA,CAAK,MAAU,IAAA,CAAA,EAAU,OAAA,IAAA;AAC7B,EAAI,IAAA,MAAA,CAAO,IAAK,CAAA,IAAI,CAAG,EAAA,OAAO,GAAG,IAAK,CAAA,KAAA,CAAM,CAAG,EAAA,EAAE,CAAC,CAAA,CAAA,CAAA;AAClD,EAAI,IAAA,qBAAA,CAAsB,KAAK,IAAI,CAAA,SAAU,IAAK,CAAA,KAAA,CAAM,GAAG,EAAE,CAAA;AAC7D,EAAA,IAAI,IAAK,CAAA,IAAA,CAAK,IAAI,CAAA,IAAK,CAAC,eAAA,CAAgB,IAAK,CAAA,IAAI,CAAG,EAAA,OAAO,IAAK,CAAA,KAAA,CAAM,GAAG,EAAE,CAAA;AAC3E,EAAO,OAAA,IAAA;AACT;AACA,SAAS,SAAS,IAAw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AS,CAAA;AACtC,EAAI,IAAA,CAAC,OAAc,OAAA,QAAA;AACnB,EAAA,MAAM,IAAO,GAAA,QAAA,CAAS,GAAI,CAAA,CAAC,SAAS,KAAW,KAAA,cAAA,CAAA;AAAA,IAC7C,OAAA;AAAA,IACA;AAAA,GAAA,EACG,MAAM,OAAO,CAAA,CAChB,EAAE,MAAO,CAAA,CAAA,KAAA,KAAS,MAAM,QAAQ,CAAA;AAGlC,EAAK,IAAA,CAAA,IAAA,CAAK,CAAC,CAAA,EAAG,CAAM,KAAA,CAAA,CAAE,KAAQ,GAAA,CAAA,CAAE,KAAS,IAAA,CAAA,CAAE,KAAQ,GAAA,CAAA,CAAE,KAAK,CAAA;AAC1D,EAAO,OAAA,IAAA,CAAK,IAAI,CAAC;AAAA,IACf;AAAA,QACI,OAAO,CAAA;AACf;AAQO,SAAS,cAAc,KAA2C,EAAA;AACvE,EAAA,MAAM,KAAQ,GAAA,KAAA,CAAM,IAAK,EAAA,GAAI,cAAe,CAAA;AAAA,IAC1C;AAAA,GACD,CAAI,GAAA,IAAA;AACL,EAAA,OAAO,CAAS,KAAA,KAAA,CAAC,CAAC,KAAA,IAAS,KAAM,CAAA;AAAA,IAC/B,IAAM,EAAA;AAAA,GACP,CAAE,CAAA,OAAA;AACL"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {productSource}from'../catalog.js';const SECOND_HAND = /\b(?:pre-?owned|used|refurbished|renewed|restored|open[- ]box|seller refurbished|for parts|like new|gently used|vintage)\b/i;
|
|
2
|
+
const SECOND_HAND_TITLE = /\((?:renewed|renewed premium|refurbished|pre-owned|used|open box)\)|\brenewed premium\b|^restored\b|\b(?:geek squad )?(?:certified )?refurbished\b|\bpre-?owned\b|\bopen[- ]box\b/i;
|
|
3
|
+
function isSecondHand(product) {
|
|
4
|
+
if (product.source === "used") return true;
|
|
5
|
+
if (product.condition && SECOND_HAND.test(product.condition) && !/^(brand )?new\b/i.test(product.condition)) {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
return SECOND_HAND_TITLE.test(product.name);
|
|
9
|
+
}
|
|
10
|
+
function productSection(product) {
|
|
11
|
+
return isSecondHand(product) ? "used" : productSource(product);
|
|
12
|
+
}export{isSecondHand,productSection};//# sourceMappingURL=secondHand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secondHand.js","sources":["../../../../src/features/shopping/services/secondHand.ts"],"sourcesContent":["/**\n * Second-hand rows from every lane - the shared half of the web surface's\n * `services/usedListings.ts` (0.49.0), verbatim. The rest of that file is the\n * Used lane itself (marketplaces, thrift and resale shops read in the shopper's\n * own browser, a model picking specialists, the card reader), which a phone has\n * no paired browser for. What reaches native is a SERVER row that is\n * second-hand: Amazon's \"(Renewed)\", eBay's \"Pre-Owned\", Walmart's \"Restored\",\n * Best Buy's \"Geek Squad Certified Refurbished\" titles, and Google Shopping rows\n * whose link is on a second-hand site (re-homed to `used` by retailerUrl).\n */\nimport { productSource, type Product, type ProductSource } from '../catalog';\nimport { usedSiteOfHost } from './usedSites';\n\n/** A store's own words for stock that is not new, in a title or a condition. */\nconst SECOND_HAND =\n /\\b(?:pre-?owned|used|refurbished|renewed|restored|open[- ]box|seller refurbished|for parts|like new|gently used|vintage)\\b/i;\n/** The same, said only in a title, where \"used\" and \"vintage\" also describe new things (\"used for\", \"vintage style\"). */\nconst SECOND_HAND_TITLE =\n /\\((?:renewed|renewed premium|refurbished|pre-owned|used|open box)\\)|\\brenewed premium\\b|^restored\\b|\\b(?:geek squad )?(?:certified )?refurbished\\b|\\bpre-?owned\\b|\\bopen[- ]box\\b/i;\n\n/**\n * True when a row is second-hand stock: a listing on a second-hand site, a row\n * whose store gives a condition other than new (eBay's \"Pre-Owned\"), or a title\n * that says so in the store's own words (Amazon's \"(Renewed)\", Walmart's\n * \"Restored\", Best Buy's \"Geek Squad Certified Refurbished\"). The Used section\n * shows these, whichever lane found them.\n */\nexport function isSecondHand(product: Pick<Product, 'source' | 'condition' | 'name'>): boolean {\n if (product.source === 'used') return true;\n if (product.condition && SECOND_HAND.test(product.condition) && !/^(brand )?new\\b/i.test(product.condition)) {\n return true;\n }\n return SECOND_HAND_TITLE.test(product.name);\n}\n\n/** The site a second-hand card's store chip names, from its link (\"Facebook Marketplace\"); undefined off the list. */\nexport function usedSiteName(url: string | undefined): string | undefined {\n return usedSiteOfHost(url)?.name;\n}\n\n/**\n * The results section a row sits in (web `SearchResults` `sectionOf`): second-hand\n * stock shares one section, whichever lane found it - an eBay \"Pre-Owned\" row or\n * an Amazon \"(Renewed)\" one sits with the second-hand site listings.\n */\nexport function productSection(product: Product): ProductSource {\n return isSecondHand(product) ? 'used' : productSource(product);\n}\n"],"names":[],"mappings":"0CAcA,MAAM,WAAc,GAAA,6HAAA;AAEpB,MAAM,iBAAoB,GAAA,oLAAA;AASnB,SAAS,aAAa,OAAkE,EAAA;AAC7F,EAAI,IAAA,OAAA,CAAQ,MAAW,KAAA,MAAA,EAAe,OAAA,IAAA;AACtC,EAAA,IAAI,OAAQ,CAAA,SAAA,IAAa,WAAY,CAAA,IAAA,CAAK,OAAQ,CAAA,SAAS,CAAK,IAAA,CAAC,kBAAmB,CAAA,IAAA,CAAK,OAAQ,CAAA,SAAS,CAAG,EAAA;AAC3G,IAAO,OAAA,IAAA;AAAA;AAET,EAAO,OAAA,iBAAA,CAAkB,IAAK,CAAA,OAAA,CAAQ,IAAI,CAAA;AAC5C;AAYO,SAAS,eAAe,OAAiC,EAAA;AAC9D,EAAA,OAAO,YAAa,CAAA,OAAO,CAAI,GAAA,MAAA,GAAS,cAAc,OAAO,CAAA;AAC/D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {SOURCE_LABELS,SOURCE_ORDER,departmentBadge}from'../catalog.js';import {pickConnectorImageUrl}from'../resolveProductImage.js';import {searchAmazonProducts}from'./amazonProductSearch.js';import {isCatalogConfigured,searchCatalogProducts}from'./catalogProductSearch.js';import {SHOPPING_RETAILER_IDS,searchRetailerProducts,RETAILER_SEARCH_CONFIGS}from'./retailerProductSearch.js';import {reconcilePricing,parsePrice}from'./pricing.js';import {
|
|
1
|
+
import {SOURCE_LABELS,SOURCE_ORDER,departmentBadge}from'../catalog.js';import {isSearchStandIn}from'../imageSizing.js';import {pickConnectorImageUrl}from'../resolveProductImage.js';import {searchAmazonProducts}from'./amazonProductSearch.js';import {isCatalogConfigured,searchCatalogProducts}from'./catalogProductSearch.js';import {SHOPPING_RETAILER_IDS,searchRetailerProducts,RETAILER_SEARCH_CONFIGS}from'./retailerProductSearch.js';import {reconcilePricing,parsePrice}from'./pricing.js';import {keepShowableProducts}from'./productAvailability.js';import {isAggregatorSource,detectRetailerSourceFromUrl}from'./retailerUrl.js';import {isConnectorLaneAbort,invokeShoppingSearchConnector}from'./shoppingSearchConnectorClient.js';import {positiveCount}from'./countText.js';import {filterProductsByRelevance}from'./searchRelevance.js';var __defProp = Object.defineProperty;
|
|
2
2
|
var __defProps = Object.defineProperties;
|
|
3
3
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -228,18 +228,77 @@ async function searchViaConnector(params) {
|
|
|
228
228
|
function normalizeTitleKey(name) {
|
|
229
229
|
return name.toLowerCase().replace(/[^a-z0-9]+/g, " ").trim().slice(0, 80);
|
|
230
230
|
}
|
|
231
|
+
function storeOf(product) {
|
|
232
|
+
const store = product.source === "catalog" && product.retailerId || product.source || "";
|
|
233
|
+
return store.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
234
|
+
}
|
|
235
|
+
function combineSameListing(kept, other) {
|
|
236
|
+
var _a, _b;
|
|
237
|
+
if (storeOf(kept) !== storeOf(other)) return kept;
|
|
238
|
+
const next = __spreadValues({}, kept);
|
|
239
|
+
if (!(kept.rating > 0) && other.rating > 0) {
|
|
240
|
+
next.rating = other.rating;
|
|
241
|
+
next.reviews = other.reviews;
|
|
242
|
+
}
|
|
243
|
+
const keptPhoto = kept.imageUrl && !isSearchStandIn(kept.imageUrl) ? kept.imageUrl : void 0;
|
|
244
|
+
if (!keptPhoto && other.imageUrl && !isSearchStandIn(other.imageUrl)) next.imageUrl = other.imageUrl;
|
|
245
|
+
if (!((_a = kept.images) == null ? void 0 : _a.length) && ((_b = other.images) == null ? void 0 : _b.length)) next.images = other.images;
|
|
246
|
+
const takePrice = other.price > 0 && (!(kept.price > 0) || other.readInBrowser && !kept.readInBrowser && !kept.priceVerified);
|
|
247
|
+
if (takePrice) {
|
|
248
|
+
next.price = other.price;
|
|
249
|
+
if (other.originalPrice !== void 0) next.originalPrice = other.originalPrice;
|
|
250
|
+
else delete next.originalPrice;
|
|
251
|
+
} else if (kept.originalPrice === void 0 && other.originalPrice !== void 0 && kept.price === other.price) {
|
|
252
|
+
next.originalPrice = other.originalPrice;
|
|
253
|
+
}
|
|
254
|
+
if (other.readInBrowser) next.readInBrowser = true;
|
|
255
|
+
if (other.inStock === false) next.inStock = false;
|
|
256
|
+
else if (kept.inStock === void 0 && typeof other.inStock === "boolean") next.inStock = other.inStock;
|
|
257
|
+
if (next.inStock === false) {
|
|
258
|
+
delete next.delivery;
|
|
259
|
+
delete next.badges;
|
|
260
|
+
} else {
|
|
261
|
+
if (kept.delivery === void 0 && other.delivery !== void 0) next.delivery = other.delivery;
|
|
262
|
+
if (kept.badges === void 0 && other.badges !== void 0) next.badges = other.badges;
|
|
263
|
+
}
|
|
264
|
+
if (kept.boughtRecently === void 0 && other.boughtRecently !== void 0) {
|
|
265
|
+
next.boughtRecently = other.boughtRecently;
|
|
266
|
+
}
|
|
267
|
+
return reconcilePricing(next);
|
|
268
|
+
}
|
|
231
269
|
function mergeShoppingProductSources(groups) {
|
|
232
|
-
|
|
270
|
+
var _a;
|
|
271
|
+
const seen = /* @__PURE__ */ new Map();
|
|
233
272
|
const merged = [];
|
|
234
273
|
for (const group of groups) {
|
|
235
274
|
for (const product of group) {
|
|
236
275
|
const key = normalizeTitleKey(product.name);
|
|
237
|
-
|
|
238
|
-
|
|
276
|
+
const idKey = `id:${product.id}`;
|
|
277
|
+
const at = (_a = seen.get(idKey)) != null ? _a : key ? seen.get(key) : void 0;
|
|
278
|
+
if (at !== void 0) {
|
|
279
|
+
merged[at] = combineSameListing(merged[at], product);
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
if (key) seen.set(key, merged.length);
|
|
283
|
+
seen.set(idKey, merged.length);
|
|
239
284
|
merged.push(product);
|
|
240
285
|
}
|
|
241
286
|
}
|
|
242
|
-
return merged;
|
|
287
|
+
return [...merged.filter((product) => product.inStock !== false), ...merged.filter((product) => product.inStock === false)];
|
|
288
|
+
}
|
|
289
|
+
function mergeIntoGrid(rows, copies) {
|
|
290
|
+
const at = new Map(rows.map((product, index) => [product.id, index]));
|
|
291
|
+
const next = [...rows];
|
|
292
|
+
const pending = [];
|
|
293
|
+
for (const copy of copies) {
|
|
294
|
+
const index = at.get(copy.id);
|
|
295
|
+
if (index === void 0) pending.push(copy);
|
|
296
|
+
else next[index] = combineSameListing(next[index], copy);
|
|
297
|
+
}
|
|
298
|
+
return {
|
|
299
|
+
rows: [...next.filter((product) => product.inStock !== false), ...next.filter((p) => p.inStock === false)],
|
|
300
|
+
pending
|
|
301
|
+
};
|
|
243
302
|
}
|
|
244
303
|
function emptySourceBuckets() {
|
|
245
304
|
return Object.fromEntries(SOURCE_ORDER.map((source) => [source, []]));
|
|
@@ -317,7 +376,7 @@ function keepRelevant(products, relevance) {
|
|
|
317
376
|
return relevant;
|
|
318
377
|
}
|
|
319
378
|
function finalizeRows(products, relevance) {
|
|
320
|
-
return
|
|
379
|
+
return keepShowableProducts(keepRelevant(products, relevance)).map(reconcilePricing);
|
|
321
380
|
}
|
|
322
381
|
async function searchShoppingProductsFast(params, options = {}) {
|
|
323
382
|
var _a, _b;
|
|
@@ -401,7 +460,7 @@ async function searchShoppingProductsFast(params, options = {}) {
|
|
|
401
460
|
error: partialErrors.join(" \xB7 ")
|
|
402
461
|
} : {});
|
|
403
462
|
}
|
|
404
|
-
async function searchShoppingProductsRest(params) {
|
|
463
|
+
async function searchShoppingProductsRest(params, options = {}) {
|
|
405
464
|
var _a, _b, _c;
|
|
406
465
|
const {
|
|
407
466
|
query,
|
|
@@ -420,8 +479,21 @@ async function searchShoppingProductsRest(params) {
|
|
|
420
479
|
maxResults: retailerMaxResults,
|
|
421
480
|
category
|
|
422
481
|
};
|
|
423
|
-
const
|
|
424
|
-
const retailerOutcomes = await Promise.allSettled(SHOPPING_RETAILER_IDS.map((id) =>
|
|
482
|
+
const connectorCall = Promise.allSettled([searchViaConnector(searchParams)]).then((r) => r[0]);
|
|
483
|
+
const retailerOutcomes = await Promise.allSettled(SHOPPING_RETAILER_IDS.map((id) => {
|
|
484
|
+
const call = searchRetailerProducts(id, sharedRetailer);
|
|
485
|
+
if (options.onLane) {
|
|
486
|
+
const onLane = options.onLane;
|
|
487
|
+
call.then((found) => {
|
|
488
|
+
const lane = emptySourceBuckets();
|
|
489
|
+
collectRetailerLane(lane, RETAILER_SEARCH_CONFIGS[id].source, found.products);
|
|
490
|
+
const rows = finalizeRows(mergeBySourceOrder(lane), params.relevance);
|
|
491
|
+
if (rows.length > 0) onLane(rows);
|
|
492
|
+
}, () => void 0);
|
|
493
|
+
}
|
|
494
|
+
return call;
|
|
495
|
+
}));
|
|
496
|
+
const connectorOutcome = await connectorCall;
|
|
425
497
|
if (retailerOutcomes.some((o) => o.status === "rejected" && isUnknownActionError(o.reason))) {
|
|
426
498
|
console.warn("[shoppingProductSearch] Retailer LIST action missing on agent \u2014 apply first-aid 005 to yantra-shopping-search. Falling back to URL sectioning from Yantra ANALYZE.");
|
|
427
499
|
}
|
|
@@ -448,4 +520,4 @@ async function searchShoppingProductsRest(params) {
|
|
|
448
520
|
return {
|
|
449
521
|
products
|
|
450
522
|
};
|
|
451
|
-
}export{DEFAULT_BROWSE_QUERY,DEPARTMENT_SEARCH_PRESETS,SOURCE_LABELS,SOURCE_ORDER,detectRetailerSourceFromUrl,emptySourceBuckets,inferProductSourceFromUrl,isCatalogConfigured,mapAnalyzeResultToProducts,mergeBySourceOrder,mergeShoppingProductSources,rehomeAggregatorProduct,rehomeYantraProductsByUrl,sanitizeShoppingProviderError,searchShoppingProductsFast,searchShoppingProductsRest};//# sourceMappingURL=shoppingProductSearch.js.map
|
|
523
|
+
}export{DEFAULT_BROWSE_QUERY,DEPARTMENT_SEARCH_PRESETS,SOURCE_LABELS,SOURCE_ORDER,combineSameListing,detectRetailerSourceFromUrl,emptySourceBuckets,inferProductSourceFromUrl,isCatalogConfigured,mapAnalyzeResultToProducts,mergeBySourceOrder,mergeIntoGrid,mergeShoppingProductSources,rehomeAggregatorProduct,rehomeYantraProductsByUrl,sanitizeShoppingProviderError,searchShoppingProductsFast,searchShoppingProductsRest};//# sourceMappingURL=shoppingProductSearch.js.map
|