diff --git a/CHANGELOG.md b/CHANGELOG.md index a23d93361..7fb967704 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,15 @@ # CHANGE LOG -## 3.15.0-beta.2 +## 3.15.0 ### Features -- Added support for Multi-Application IDs (see [preview documentation](https://deploy-preview-9703--algolia-docs.netlify.app/doc/integration/magento-2/getting-started/quick-start/#support-for-multiple-application-ids)) -- Refactored frontend library to no longer utilize the legacy `algoliaBundle` (see [preview documentation](https://deploy-preview-9703--algolia-docs.netlify.app/doc/integration/magento-2/customize/custom-front-end-events/?client=php#frontend-javascript-libraries-and-the-legacy-bundle)) +- Added support for Multi-Application IDs (see [documentation](https://www.algolia.com/doc/integration/magento-2/getting-started/quick-start/#support-for-multiple-application-ids)) +- Refactored frontend library to no longer utilize the legacy `algoliaBundle` (see [documentation](https://www.algolia.com/doc/integration/magento-2/customize/custom-front-end-events/?client=php#frontend-javascript-libraries-and-the-legacy-bundle)) - Added support for core Algolia UI library overrides via RequireJS - Added support for mixins through RequireJS in addition to [front end custom events](https://www.algolia.com/doc/integration/magento-2/customize/custom-front-end-events) - See our `CustomAlgolia` demo extension's [1.4.0 release](https://github.com/algolia/algoliasearch-custom-algolia-magento-2/releases/tag/1.4.0) for examples on how to take advantage of these changes - Added granular profiling through the [Magento Profiler](https://experienceleague.adobe.com/en/docs/commerce-operations/configuration-guide/setup/mage-profiler) to aid in troubleshooting indexing performance issues -- Added a feature to enable automatic price indexing within the Advanced section of the configuration (This feature should help alleviate issues where missing pricing records prevent Algolia from being able to index products. See [preview documentation](https://deploy-preview-9703--algolia-docs.netlify.app/doc/integration/magento-2/troubleshooting/data-indexes-queues/#price-index-dependencies) for further details.) +- Added a feature to enable automatic price indexing within the Advanced section of the configuration (This feature should help alleviate issues where missing pricing records prevent Algolia from being able to index products. See [documentation](https://www.algolia.com/doc/integration/magento-2/troubleshooting/data-indexes-queues/#price-index-dependencies) for further details.) ### Updates - Tests: Added possibility to run tests with multiple applications IDs. @@ -22,17 +22,17 @@ - Debugging information now writes to `algolia.log` - Removed dependency on `algoliaBundle` package - Removed dependency on JavaScript global `window` objects with the exception of `algoliaConfig` -- The Hogan.js library is still packaged for injection as needed but be advised that Mustache.js is now used internally instead (see [preview documentation](https://deploy-preview-9703--algolia-docs.netlify.app/doc/integration/magento-2/customize/instant-search-page/?client=php#mustache-templates)) +- The Hogan.js library is still packaged for injection as needed but be advised that Mustache.js is now used internally instead (see [documentation](https://www.algolia.com/doc/integration/magento-2/customize/instant-search-page/?client=php#mustache-templates)) - JavaScript bundling is supported but to use the RequireJS Optimizer transpiling will be needed for ES6 constructs ### Bug Fixes - Fixed a bug where admin menus didn't display properly on Magento 2.4.7 - Fixed customer groups prices ranges on configurable products - Fixed a bug where categories highlighting didn't work as expected on PLP powered by InstantSearch +- Fixed a bug where excluded websites weren't taken into account while indexing customer prices on products. (thanks @kamilszewczyk) ### Breaking Changes -- If you have customized your front end implementation based on the `algoliaBundle` you may need to shim your application accordingly (Full details are shared in [our preview documentation](https://deploy-preview-9703--algolia-docs.netlify.app/doc/integration/magento-2/troubleshooting/front-end-issues/)) - +- If you have customized your front end implementation based on the `algoliaBundle` you may need to shim your application accordingly (Full details are shared in [our documentation](https://www.algolia.com/doc/integration/magento-2/troubleshooting/front-end-issues/)) ## 3.14.4 @@ -128,25 +128,6 @@ If you have customized your Algolia implementation or are running on an older ve - Dropped support for Magento 2.3 - PHP 8.1+ required -## 3.14.0-beta.2 - -### Updates - -- Introduced new admin groups to InstantSearch for improved UX -- Updated `ConfigHelper` to use new paths -- Added data patch to migrate old configurations -- Bugfix for query rule disable on facets with new admin groupings -- Added new sorting admin option via source model -- Added derived virtual replica enablement to `ConfigHelper` based on `ArraySerialized` -- Intro’d simplified data structures to avoid array diff mismatches -- Intro’d new `ReplicaManager` abstraction to map Magento sorting to Algolia replica configuration -- Removed dependencies in backend models to handle replica config updates in Algolia addressing stale data -- Added `ReplicaState` registry for tracking changes to sorting configuration to minimize number of replica build operations -- Added logic to preserve replicas created outside of Magento such as Merchandising Studio "sorting strategies" -- Introduced PHP 8 constructor property promotion on affected classes -- Added stronger typing to affected classes and methods -- Added Looking Similar recommendations - ## 3.13.8 ### Bug Fixes @@ -188,20 +169,6 @@ If you have customized your Algolia implementation or are running on an older ve - Fixed lock timeout issue on indexing queue integration test - Community fix added - job queue dropping jobs from sandwiched full reindexes - thank you @pikulsky -## 3.14.0-beta.1 - -### Updates: - -- New PHP API client (v4) under the hood for communicating with Algolia -- Authenticated user tokens now utilized for backend and frontend events to track entire customer journey -- Revenue data now sent with all events including application of Magento specific discounts such as catalog price rules and customer group pricing -- Support for event subtypes allowing the capture of conversion data for both "Add to cart" and "Place order" events -- Increased protection of PII in the event data - -### Bug fixes: -- Fixed issue with how Algolia extension handles end user consent for allowing cookies -- Improved handling of user tokens across insights events and corresponding queries - ## 3.13.3 ### Updates diff --git a/Helper/ConfigHelper.php b/Helper/ConfigHelper.php index 68fb6ac67..909b3f6cf 100755 --- a/Helper/ConfigHelper.php +++ b/Helper/ConfigHelper.php @@ -1386,6 +1386,7 @@ public function getExtraSettings($section, $storeId = null) /** * @param $storeId * @return bool + * @deprecated This feature is deprecated and will be replaced in an upcoming version */ public function preventBackendRendering($storeId = null) { diff --git a/Plugin/RenderingCacheContextPlugin.php b/Plugin/RenderingCacheContextPlugin.php index 43803fea2..039c7079c 100755 --- a/Plugin/RenderingCacheContextPlugin.php +++ b/Plugin/RenderingCacheContextPlugin.php @@ -5,7 +5,9 @@ use Algolia\AlgoliaSearch\Helper\ConfigHelper; use Magento\Framework\App\Http\Context as HttpContext; use Magento\Framework\App\Request\Http; +use Magento\Framework\Exception\NoSuchEntityException; use Magento\Store\Model\StoreManagerInterface; +use Magento\UrlRewrite\Model\UrlFinderInterface; /** * The purpose of this class is to render different cached versions of the pages according to the user agent. @@ -15,39 +17,36 @@ */ class RenderingCacheContextPlugin { - public const RENDERING_CONTEXT = 'rendering_context'; + public const RENDERING_CONTEXT = 'algolia_rendering_context'; public const RENDERING_WITH_BACKEND = 'with_backend'; public const RENDERING_WITHOUT_BACKEND = 'without_backend'; - private $configHelper; - private $storeManager; - private $request; + public const CATEGORY_CONTROLLER = 'category'; + public const CATEGORY_ROUTE = 'catalog/category/view'; public function __construct( - ConfigHelper $configHelper, - StoreManagerInterface $storeManager, - Http $request - ) { - $this->configHelper = $configHelper; - $this->storeManager = $storeManager; - $this->request = $request; - } + protected ConfigHelper $configHelper, + protected StoreManagerInterface $storeManager, + protected Http $request, + protected UrlFinderInterface $urlFinder + ) { } /** - * Add Rendering context for caching purposes - * (If the prevent rendering configuration is enabled and the user agent has no white card to display it, + * Add a rendering context to the vary string data to distinguish which versions of the category PLP should be cached + * (If the "prevent backend rendering" configuration is enabled and the user agent is not whitelisted to display it, * we set a different page variation, and the FPC stores a different cached page) * - * @param HttpContext $subject - * @param string[] $data + * IMPORTANT: + * Magento\Framework\App\Http\Context::getData can be called multiple times over the course of the request lifecycle + * it is important that this plugin return the data consistently - or the cache will be invalidated unexpectedly! * - * @return array + * @param HttpContext $subject + * @param array $data + * @return array original params + * @throws NoSuchEntityException */ - public function afterGetData(HttpContext $subject, $data) - { - $storeId = $this->storeManager->getStore()->getId(); - if (!($this->request->getControllerName() === 'category' - && $this->configHelper->replaceCategories($storeId) === true)) { + public function afterGetData(HttpContext $subject, array $data): array { + if (!$this->shouldApplyCacheContext()) { return $data; } @@ -59,4 +58,52 @@ public function afterGetData(HttpContext $subject, $data) return $data; } + + /** + * @param int $storeId + * @return string + */ + protected function getOriginalRoute(int $storeId): string + { + $requestUri = $this->request->getRequestUri(); + + $rewrite = $this->urlFinder->findOneByData([ + 'request_path' => ltrim($requestUri, '/'), + 'store_id' => $storeId, + ]); + + return $rewrite?->getTargetPath() ?? ""; + } + + /** + * @param string $path + * @return bool + */ + protected function isCategoryRoute(string $path): bool { + $path = ltrim($path, '/'); + return str_starts_with($path, self::CATEGORY_ROUTE); + } + + /** + * This can be called in a variety of contexts - so this should always be called consistently + * + * @param int $storeId + * @return bool + */ + protected function isCategoryPage(int $storeId): bool + { + return $this->request->getControllerName() === self::CATEGORY_CONTROLLER + || $this->isCategoryRoute($this->request->getRequestUri()) + || $this->isCategoryRoute($this->getOriginalRoute($storeId)); + } + + /** + * @return bool + * @throws NoSuchEntityException + */ + protected function shouldApplyCacheContext(): bool + { + $storeId = $this->storeManager->getStore()->getId(); + return $this->isCategoryPage($storeId) && $this->configHelper->replaceCategories($storeId); + } } diff --git a/Test/Integration/Frontend/Category/CategoryCacheTest.php b/Test/Integration/Frontend/Category/CategoryCacheTest.php new file mode 100644 index 000000000..2dd8bd589 --- /dev/null +++ b/Test/Integration/Frontend/Category/CategoryCacheTest.php @@ -0,0 +1,370 @@ + 20, 'name' => 'Women', 'hasProducts' => false], + ['categoryId' => 21, 'name' => 'Women > Tops', 'hasProducts' => true], + ['categoryId' => 22, 'name' => 'Women > Bottoms', 'hasProducts' => true], + ['categoryId' => 11, 'name' => 'Men', 'hasProducts' => false], + ['categoryId' => 12, 'name' => 'Men > Tops', 'hasProducts' => true], + ['categoryId' => 13, 'name' => 'Men > Bottoms', 'hasProducts' => true], + ]; + } + + protected function setUp(): void + { + parent::setUp(); + $this->cacheManager = $this->_objectManager->get(CacheManager::class); + $this->config = $this->_objectManager->get(ScopeConfigInterface::class); + + // Default user agent + $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36'; + } + + public static function setUpBeforeClass(): void + { + self::reindexAll(); + } + + /** You must index to OpenSearch to get the default backend render */ + protected static function reindexAll(): void + { + $objectManager = ObjectManager::getInstance(); + $indexerRegistry = $objectManager->get(IndexerRegistry::class); + + $indexerCodes = [ + 'catalog_category_product', + 'catalog_product_category', + 'catalog_product_price', + 'cataloginventory_stock', + 'catalogsearch_fulltext' + ]; + + foreach ($indexerCodes as $indexerCode) { + $indexerRegistry->get($indexerCode)->reindexAll(); + } + } + + /** + * Selectively refresh the FPC cache (must be done at intervals) + * Warm the cache via MISS tests but only reset the cache once per MISS test + * Due to data provider test methods can be called multiple times + */ + protected function resetCache(string $testMethod): void + { + if (!in_array($testMethod, self::$cacheResets)) { + $this->cacheManager->clean(['full_page']); + self::$cacheResets[] = $testMethod; + } + } + + /** + * @dataProvider getCategoryProvider + * @depends testFullPageCacheAvailable + * @magentoConfigFixture current_store system/full_page_cache/caching_application 1 + * @magentoConfigFixture current_store algoliasearch_advanced/advanced/prevent_backend_rendering 0 + * @magentoConfigFixture current_store algoliasearch_instant/instant/replace_categories 1 + * @magentoCache full_page enabled + */ + public function testCategoryPlpMissBackendRenderOn(int $categoryId, string $name, bool $hasProducts): void + { + $this->assertReplaceCategories(); + + $this->resetCache(__METHOD__); + $this->dispatchCategoryPlpRequest($categoryId); + $response = $this->getResponse(); + $this->assertEquals(200, $response->getHttpResponseCode(), 'Request failed'); + $this->assertEquals( + 'MISS', + $response->getHeader('X-Magento-Cache-Debug')->getFieldValue(), + "expected MISS on category {$name} id {$categoryId}" + ); + $this->assertContains( + 'FPC', + explode(',', $response->getHeader('X-Magento-Tags')->getFieldValue()), + "expected FPC tag on category {$name} id {$categoryId}" + ); + + if ($hasProducts) { + $this->assertMatchesRegularExpression('//', $response->getContent(), 'Backend content was not rendered.'); + } + } + + /** + * @dataProvider getCategoryProvider + * @depends testCategoryPlpMissBackendRenderOn + * @magentoConfigFixture current_store system/full_page_cache/caching_application 1 + * @magentoConfigFixture current_store algoliasearch_advanced/advanced/prevent_backend_rendering 0 + * @magentoConfigFixture current_store algoliasearch_instant/instant/replace_categories 1 + * @magentoCache full_page enabled + */ + public function testCategoryPlpHitBackendRenderOn(int $categoryId, string $name): void + { + $this->assertReplaceCategories(); + + $this->registerPageHitSpy(); + + $this->dispatchCategoryPlpRequest($categoryId); + $response = $this->getResponse(); + $this->assertEquals(200, $response->getHttpResponseCode(), 'Request failed'); + } + + /** + * @dataProvider getCategoryProvider + * @depends testFullPageCacheAvailable + * @magentoConfigFixture current_store system/full_page_cache/caching_application 1 + * @magentoConfigFixture current_store algoliasearch_advanced/advanced/prevent_backend_rendering 1 + * @magentoConfigFixture current_store algoliasearch_instant/instant/replace_categories 1 + * @magentoCache full_page enabled + */ + public function testCategoryPlpMissBackendRenderOff(int $categoryId, string $name, bool $hasProducts): void + { + $this->assertPreventBackend(); + + $this->resetCache(__METHOD__); + $this->dispatchCategoryPlpRequest($categoryId); + $response = $this->getResponse(); + $this->assertEquals(200, $response->getHttpResponseCode(), 'Request failed'); + $this->assertEquals( + 'MISS', + $response->getHeader('X-Magento-Cache-Debug')->getFieldValue(), + "expected MISS on category {$name} id {$categoryId}" + ); + $this->assertContains( + 'FPC', + explode(',', $response->getHeader('X-Magento-Tags')->getFieldValue()), + "expected FPC tag on category {$name} id {$categoryId}" + ); + + if ($hasProducts) { + $this->assertDoesNotMatchRegularExpression('//', $response->getContent(), 'Backend content was rendered.'); + } + } + + /** + * @dataProvider getCategoryProvider + * @depends testCategoryPlpMissBackendRenderOff + * @magentoConfigFixture current_store system/full_page_cache/caching_application 1 + * @magentoConfigFixture current_store algoliasearch_advanced/advanced/prevent_backend_rendering 1 + * @magentoConfigFixture current_store algoliasearch_instant/instant/replace_categories 1 + * @magentoCache full_page enabled + */ + public function testCategoryPlpHitBackendRenderOff(int $categoryId, string $name): void + { + $this->assertPreventBackend(); + + $this->registerPageHitSpy(); + + $this->dispatchCategoryPlpRequest($categoryId); + $response = $this->getResponse(); + + $this->assertEquals(200, $response->getHttpResponseCode(), 'Request failed'); + } + + /** + * @dataProvider getCategoryProvider + * @depends testCategoryPlpHitBackendRenderOff + * @magentoConfigFixture current_store system/full_page_cache/caching_application 1 + * @magentoConfigFixture current_store algoliasearch_advanced/advanced/prevent_backend_rendering 1 + * @magentoConfigFixture current_store algoliasearch_instant/instant/replace_categories 1 + * @magentoDataFixture Algolia_AlgoliaSearch::Test/Integration/_files/backend_render_user_agents.php + * @magentoCache full_page enabled + */ + public function testCategoryPlpMissBackendRenderWhiteList(int $categoryId, string $name, bool $hasProducts): void + { + $this->assertPreventBackend(); + + $this->setupUserAgent(); + + $this->dispatchCategoryPlpRequest($categoryId); + + $response = $this->getResponse(); + $this->assertEquals(200, $response->getHttpResponseCode(), 'Request failed'); + $this->assertEquals( + 'MISS', + $response->getHeader('X-Magento-Cache-Debug')->getFieldValue(), + "expected MISS on category {$name} id {$categoryId}" + ); + $this->assertContains( + 'FPC', + explode(',', $response->getHeader('X-Magento-Tags')->getFieldValue()), + "expected FPC tag on category {$name} id {$categoryId}" + ); + + if ($hasProducts) { + $this->assertMatchesRegularExpression('//', $response->getContent(), 'Backend content was not rendered.'); + } + } + + /** + * @dataProvider getCategoryProvider + * @depends testCategoryPlpMissBackendRenderOff + * @magentoConfigFixture current_store system/full_page_cache/caching_application 1 + * @magentoConfigFixture current_store algoliasearch_advanced/advanced/prevent_backend_rendering 1 + * @magentoConfigFixture current_store algoliasearch_instant/instant/replace_categories 1 + * @magentoDataFixture Algolia_AlgoliaSearch::Test/Integration/_files/backend_render_user_agents.php + * @magentoCache full_page enabled + */ + public function testCategoryPlpHitBackendRenderWhiteList(int $categoryId, string $name): void + { + $this->assertPreventBackend(); + + $this->setupUserAgent(); + + $this->registerPageHitSpy(); + + $this->dispatchCategoryPlpRequest($categoryId); + $response = $this->getResponse(); + $this->assertEquals(200, $response->getHttpResponseCode(), 'Request failed'); + } + + public function testFullPageCacheAvailable(): void + { + $types = $this->cacheManager->getAvailableTypes(); + $this->assertContains('full_page', $types); + } + + + protected function assertConfig(string $path, string $expected, string $message): void + { + $this->assertEquals($expected, $this->config->getValue($path, ScopeInterface::SCOPE_STORE), $message); + } + + protected function assertReplaceCategories(): void + { + $this->assertConfig( + 'algoliasearch_instant/instant/replace_categories', + 1, + "Replace categories must be enabled for this test." + ); + } + + protected function assertPreventBackend(): void + { + $this->assertConfig( + 'algoliasearch_advanced/advanced/prevent_backend_rendering', + 1, + "Prevent backend rendering must be enabled for this test." + ); + } + + protected function assertUserAgentAllowed(string $userAgent): void + { + $this->assertStringContainsString( + $userAgent, + $this->config->getValue('algoliasearch_advanced/advanced/backend_rendering_allowed_user_agents', ScopeInterface::SCOPE_STORE), + "Allowed user agents for backend render must include $userAgent" + ); + } + + protected function setupUserAgent(): void + { + $testUserAgent = self::TEST_USER_AGENT; + $this->assertUserAgentAllowed($testUserAgent); + $_SERVER['HTTP_USER_AGENT'] = $testUserAgent; + } + + /** + * The \Magento\TestFramework\TestCase\AbstractController::dispatch is flawed for this use case as it does not + * populate the URI which is used to build the cache key in \Magento\Framework\App\PageCache\Identifier::getValue + * + * This provides a workaround + * + * @param string $uri + * @return void + */ + protected function dispatchHttpRequest(string $uri): void + { + $request = $this->_objectManager->get(\Magento\Framework\App\Request\Http::class); + $request->setDispatched(false); + $request->setUri($uri); + $request->setRequestUri($uri); + $this->_getBootstrap()->runApp(); + } + + /** + * It is imperative to always use the same URL format between MISS and HIT to ensure + * that the cache key is generated consistently + * @param int $categoryId + * @return string + */ + protected function getCategoryUrl(int $categoryId): string + { + return self::BASE_CATEGORY_URL . $categoryId; + } + + /** + * Dispatches a request using a properly formatted URL to ensure consistent cache key creation + */ + protected function dispatchCategoryPlpRequest(int $categoryId): void + { + $this->dispatchHttpRequest($this->getCategoryUrl($categoryId)); + } + + /** + * The response object is modified differently by the BuiltinPlugin which prevents anything useful + * being returned by AbstractController::getResponse when a HIT is encountered + * + * Therefore we apply a "spy" on the plugin via a mock to ensure that the proper header is added + * when the cache has been warmed (by the first MISS) + * + * @return void + */ + protected function registerPageHitSpy(): void + { + $mockedPluginClass = \Magento\PageCache\Model\App\FrontController\BuiltinPlugin::class; + $mockedPluginMethod = 'addDebugHeader'; + $cachePluginMock = $this->getMockBuilder($mockedPluginClass) + ->setConstructorArgs([ + $this->_objectManager->get(\Magento\PageCache\Model\Config::class), + $this->_objectManager->get(\Magento\Framework\App\PageCache\Version::class), + $this->_objectManager->get(\Magento\Framework\App\PageCache\Kernel::class), + $this->_objectManager->get(\Magento\Framework\App\State::class) + ]) + ->onlyMethods([$mockedPluginMethod]) + ->getMock(); + $cachePluginMock + ->expects($this->once()) + ->method($mockedPluginMethod) + ->with( + $this->isInstanceOf(ResponseHttp::class), + $this->equalTo("X-Magento-Cache-Debug"), + $this->equalTo("HIT"), + $this->isType('boolean') + ) + ->willReturnCallback( + function (ResponseHttp $response, $name, $value, $replace) + use ($mockedPluginClass, $mockedPluginMethod, $cachePluginMock) + { + $originalMethod = new \ReflectionMethod($mockedPluginClass, $mockedPluginMethod); + return $originalMethod->invoke($cachePluginMock, $response, $name, $value, $replace); + } + ); + $this->_objectManager->addSharedInstance( + $cachePluginMock, + $mockedPluginClass + ); + } + +} diff --git a/Test/Integration/Search/SearchTest.php b/Test/Integration/Frontend/Search/SearchTest.php similarity index 98% rename from Test/Integration/Search/SearchTest.php rename to Test/Integration/Frontend/Search/SearchTest.php index ef52f1e9a..4ae24d116 100644 --- a/Test/Integration/Search/SearchTest.php +++ b/Test/Integration/Frontend/Search/SearchTest.php @@ -1,6 +1,6 @@ get(MutableScopeConfigInterface::class); + +// Set complex configuration value +$scopeConfig->setValue( + 'algoliasearch_advanced/advanced/backend_rendering_allowed_user_agents', + join("\n", ["Googlebot", "Bingbot", "Foobot"]), + \Magento\Store\Model\ScopeInterface::SCOPE_STORE +); diff --git a/Test/Integration/_files/second_website_with_two_stores_and_products.php b/Test/Integration/_files/second_website_with_two_stores_and_products.php index 3283de0bb..28c49ee0a 100644 --- a/Test/Integration/_files/second_website_with_two_stores_and_products.php +++ b/Test/Integration/_files/second_website_with_two_stores_and_products.php @@ -1,6 +1,6 @@ configHelper = $this->createMock(ConfigHelper::class); + $this->storeManager = $this->createMock(StoreManagerInterface::class); + $this->request = $this->createMock(Http::class); + $this->urlFinder = $this->createMock(UrlFinderInterface::class); + + $this->plugin = new RenderingCacheContextPluginTestable( + $this->configHelper, + $this->storeManager, + $this->request, + $this->urlFinder + ); + } + + protected function getStoreMock(): StoreInterface + { + $store = $this->createMock(StoreInterface::class); + $store->method('getId')->willReturn(1); + return $store; + } + + public function testAfterGetDataAddsRenderingContextNoBackendRender(): void + { + $this->configHelper->method('preventBackendRendering')->willReturn(true); + $this->storeManager->method('getStore')->willReturn($this->getStoreMock()); + + $this->request->method('getControllerName')->willReturn('category'); + $this->configHelper->method('replaceCategories')->willReturn(true); + + $result = $this->plugin->afterGetData( + $this->createMock(HttpContext::class), + [] + ); + + $this->assertArrayHasKey(RenderingCacheContextPlugin::RENDERING_CONTEXT, $result); + $this->assertEquals(RenderingCacheContextPlugin::RENDERING_WITHOUT_BACKEND, $result[RenderingCacheContextPlugin::RENDERING_CONTEXT]); + } + + public function testAfterGetDataAddsRenderingContextWithBackendRender(): void + { + $subject = $this->createMock(HttpContext::class); + + $this->configHelper->method('preventBackendRendering')->willReturn(false); + $this->storeManager->method('getStore')->willReturn($this->getStoreMock()); + + $this->request->method('getControllerName')->willReturn('category'); + $this->configHelper->method('replaceCategories')->willReturn(true); + + $result = $this->plugin->afterGetData( + $this->createMock(HttpContext::class), + [] + ); + + $this->assertArrayHasKey(RenderingCacheContextPlugin::RENDERING_CONTEXT, $result); + $this->assertEquals(RenderingCacheContextPlugin::RENDERING_WITH_BACKEND, $result[RenderingCacheContextPlugin::RENDERING_CONTEXT]); + } + + public function testAfterGetDataDoesNotModifyDataIfNotApplicable(): void + { + $subject = $this->createMock(HttpContext::class); + + $this->configHelper->method('preventBackendRendering')->willReturn(false); + $this->storeManager->method('getStore')->willReturn($this->getStoreMock()); + + $this->request->method('getControllerName')->willReturn('product'); + $this->request->method('getRequestUri')->willReturn('some-product.html'); + $this->configHelper->method('replaceCategories')->willReturn(false); + + $data = ['existing_key' => 'existing_value']; + $result = $this->plugin->afterGetData($subject, $data); + + $this->assertEquals($data, $result); + } + + public function testIsCategoryRoute(): void + { + $this->assertTrue($this->plugin->isCategoryRoute('catalog/category/view')); + $this->assertFalse($this->plugin->isCategoryRoute('some/other/route')); + } + + public function testGetOriginalRoute(): void + { + $storeId = 1; + $requestUri = '/some-path'; + $targetPath = 'catalog/category/view/id/42'; + + $this->request->method('getRequestUri')->willReturn($requestUri); + + $urlRewrite = $this->createMock(\Magento\UrlRewrite\Service\V1\Data\UrlRewrite::class); + $urlRewrite->method('getTargetPath')->willReturn($targetPath); + + $this->urlFinder->method('findOneByData')->willReturn($urlRewrite); + + $this->assertEquals($targetPath, $this->plugin->getOriginalRoute($storeId)); + } + + public function testShouldApplyCacheContext(): void + { + $this->storeManager->method('getStore')->willReturn($this->getStoreMock()); + + $this->request->method('getControllerName')->willReturn('category'); + $this->configHelper->method('replaceCategories')->willReturn(true); + + $this->assertTrue($this->plugin->shouldApplyCacheContext()); + } +} diff --git a/Test/Unit/Plugin/RenderingCacheContextPluginTestable.php b/Test/Unit/Plugin/RenderingCacheContextPluginTestable.php new file mode 100644 index 000000000..6df452c48 --- /dev/null +++ b/Test/Unit/Plugin/RenderingCacheContextPluginTestable.php @@ -0,0 +1,23 @@ +⚠ Algolia injects its search results via InstantSearch in place of default search results. Enable this setting to hide default search results completely. By preventing your store from backend rendering you might break your SEO and accessibility of your store by search crawlers. +

+ This feature is deprecated and will be replaced in a future version. ]]> diff --git a/etc/di.xml b/etc/di.xml index e43cf48f5..2988bb042 100755 --- a/etc/di.xml +++ b/etc/di.xml @@ -194,6 +194,13 @@ + + + Algolia\AlgoliaSearch\Service\AlgoliaConnector\Proxy + Algolia\AlgoliaSearch\Service\Product\IndexOptionsBuilder\Proxy + + + algolia diff --git a/etc/module.xml b/etc/module.xml index 77a190cc3..0e0341b9c 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,6 +1,6 @@ - + diff --git a/view/frontend/web/js/lib/algolia-autocomplete.min.js b/view/frontend/web/js/lib/algolia-autocomplete.min.js index 7460dfca6..d7dc53f5b 100644 --- a/view/frontend/web/js/lib/algolia-autocomplete.min.js +++ b/view/frontend/web/js/lib/algolia-autocomplete.min.js @@ -6,4 +6,3 @@ */ /*! @algolia/autocomplete-js 1.17.9 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/autocomplete-js"]={})}(this,(function(e){"use strict";function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function n(e){for(var n=1;n=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function a(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,u,a=[],l=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=i.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(e){c=!0,o=e}finally{try{if(!l&&null!=n.return&&(u=n.return(),Object(u)!==u))return}finally{if(c)throw o}}return a}}(e,t)||c(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||c(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){if(e){if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,t):void 0}}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function x(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function N(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:20,n=[],r=0;r=3||2===n&&r>=4||1===n&&r>=10);function i(t,n,r){if(o&&void 0!==r){var i=r[0].__autocomplete_algoliaCredentials,u={"X-Algolia-Application-Id":i.appId,"X-Algolia-API-Key":i.apiKey};e.apply(void 0,[t].concat(D(n),[{headers:u}]))}else e.apply(void 0,[t].concat(D(n)))}return{init:function(t,n){e("init",{appId:t,apiKey:n})},setAuthenticatedUserToken:function(t){e("setAuthenticatedUserToken",t)},setUserToken:function(t){e("setUserToken",t)},clickedObjectIDsAfterSearch:function(){for(var e=arguments.length,t=new Array(e),n=0;n0&&i("clickedObjectIDsAfterSearch",B(t),t[0].items)},clickedObjectIDs:function(){for(var e=arguments.length,t=new Array(e),n=0;n0&&i("clickedObjectIDs",B(t),t[0].items)},clickedFilters:function(){for(var t=arguments.length,n=new Array(t),r=0;r0&&e.apply(void 0,["clickedFilters"].concat(n))},convertedObjectIDsAfterSearch:function(){for(var e=arguments.length,t=new Array(e),n=0;n0&&i("convertedObjectIDsAfterSearch",B(t),t[0].items)},convertedObjectIDs:function(){for(var e=arguments.length,t=new Array(e),n=0;n0&&i("convertedObjectIDs",B(t),t[0].items)},convertedFilters:function(){for(var t=arguments.length,n=new Array(t),r=0;r0&&e.apply(void 0,["convertedFilters"].concat(n))},viewedObjectIDs:function(){for(var e=arguments.length,t=new Array(e),n=0;n0&&t.reduce((function(e,t){var n=t.items,r=k(t,A);return[].concat(D(e),D(q(N(N({},r),{},{objectIDs:(null==n?void 0:n.map((function(e){return e.objectID})))||r.objectIDs})).map((function(e){return{items:n,payload:e}}))))}),[]).forEach((function(e){var t=e.items;return i("viewedObjectIDs",[e.payload],t)}))},viewedFilters:function(){for(var t=arguments.length,n=new Array(t),r=0;r0&&e.apply(void 0,["viewedFilters"].concat(n))}}}function L(e){var t=e.items.reduce((function(e,t){var n;return e[t.__autocomplete_indexName]=(null!==(n=e[t.__autocomplete_indexName])&&void 0!==n?n:[]).concat(t),e}),{});return Object.keys(t).map((function(e){return{index:e,items:t[e],algoliaSource:["autocomplete"]}}))}function F(e){return e.objectID&&e.__autocomplete_indexName&&e.__autocomplete_queryID}function U(e){return U="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},U(e)}function M(e){return function(e){if(Array.isArray(e))return H(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return H(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return H(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function H(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&z({onItemsChange:o,items:n,insights:c,state:t}))}}),0);return{name:"aa.algoliaInsightsPlugin",subscribe:function(e){var t=e.setContext,n=e.onSelect,r=e.onActive;function o(e){t({algoliaInsightsPlugin:{__algoliaSearchParameters:W(W({},a?{clickAnalytics:!0}:{}),e?{userToken:X(e)}:{}),insights:c}})}l("addAlgoliaAgent","insights-plugin"),o(),l("onUserTokenChange",(function(e){o(e)})),l("getUserToken",null,(function(e,t){o(t)})),n((function(e){var t=e.item,n=e.state,r=e.event,o=e.source;F(t)&&i({state:n,event:r,insights:c,item:t,insightsEvents:[W({eventName:"Item Selected"},j({item:t,items:o.getItems().filter(F)}))]})})),r((function(e){var t=e.item,n=e.source,r=e.state,o=e.event;F(t)&&u({state:r,event:o,insights:c,item:t,insightsEvents:[W({eventName:"Item Active"},j({item:t,items:n.getItems().filter(F)}))]})}))},onStateChange:function(e){var t=e.state;m({state:t})},__autocomplete_pluginOptions:e}}function J(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0;return[].concat(M(t),["autocomplete-internal"],M(null!==(e=n.algoliaInsightsPlugin)&&void 0!==e&&e.__automaticInsights?["autocomplete-automatic"]:[]))}function X(e){return"number"==typeof e?e.toString():e}function Y(e,t){var n=t;return{then:function(t,r){return Y(e.then(ee(t,n,e),ee(r,n,e)),n)},catch:function(t){return Y(e.catch(ee(t,n,e)),n)},finally:function(t){return t&&n.onCancelList.push(t),Y(e.finally(ee(t&&function(){return n.onCancelList=[],t()},n,e)),n)},cancel:function(){n.isCanceled=!0;var e=n.onCancelList;n.onCancelList=[],e.forEach((function(e){e()}))},isCanceled:function(){return!0===n.isCanceled}}}function Z(e){return Y(e,{isCanceled:!1,onCancelList:[]})}function ee(e,t,n){return e?function(n){return t.isCanceled?n:e(n)}:n}function te(e,t,n,r){if(!n)return null;if(e<0&&(null===t||null!==r&&0===t))return n+e;var o=(null===t?-1:t)+e;return o<=-1||o>=n?null===r?null:0:o}function ne(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function re(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=new Array(t);n0},reshape:function(e){return e.sources}},e),{},{id:null!==(n=e.id)&&void 0!==n?n:d(),plugins:o,initialState:Se({activeItemId:null,query:"",completion:null,collections:[],isOpen:!1,status:"idle",context:{}},e.initialState),onStateChange:function(t){var n;null===(n=e.onStateChange)||void 0===n||n.call(e,t),o.forEach((function(e){var n;return null===(n=e.onStateChange)||void 0===n?void 0:n.call(e,t)}))},onSubmit:function(t){var n;null===(n=e.onSubmit)||void 0===n||n.call(e,t),o.forEach((function(e){var n;return null===(n=e.onSubmit)||void 0===n?void 0:n.call(e,t)}))},onReset:function(t){var n;null===(n=e.onReset)||void 0===n||n.call(e,t),o.forEach((function(e){var n;return null===(n=e.onReset)||void 0===n?void 0:n.call(e,t)}))},getSources:function(n){return Promise.all([].concat(he(o.map((function(e){return e.getSources}))),[e.getSources]).filter(Boolean).map((function(e){return function(e,t){var n=[];return Promise.resolve(e(t)).then((function(e){return Promise.all(e.filter((function(e){return Boolean(e)})).map((function(e){if(e.sourceId,n.includes(e.sourceId))throw new Error("[Autocomplete] The `sourceId` ".concat(JSON.stringify(e.sourceId)," is not unique."));n.push(e.sourceId);var t={getItemInputValue:function(e){return e.state.query},getItemUrl:function(){},onSelect:function(e){(0,e.setIsOpen)(!1)},onActive:_,onResolve:_};Object.keys(t).forEach((function(e){t[e].__default=!0}));var r=re(re({},t),e);return Promise.resolve(r)})))}))}(e,n)}))).then((function(e){return m(e)})).then((function(e){return e.map((function(e){return Se(Se({},e),{},{onSelect:function(n){e.onSelect(n),t.forEach((function(e){var t;return null===(t=e.onSelect)||void 0===t?void 0:t.call(e,n)}))},onActive:function(n){e.onActive(n),t.forEach((function(e){var t;return null===(t=e.onActive)||void 0===t?void 0:t.call(e,n)}))},onResolve:function(n){e.onResolve(n),t.forEach((function(e){var t;return null===(t=e.onResolve)||void 0===t?void 0:t.call(e,n)}))}})}))}))},navigator:Se({navigate:function(e){var t=e.itemUrl;r.location.assign(t)},navigateNewTab:function(e){var t=e.itemUrl,n=r.open(t,"_blank","noopener");null==n||n.focus()},navigateNewWindow:function(e){var t=e.itemUrl;r.open(t,"_blank","noopener")}},e.navigator)})}function we(e){return we="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},we(e)}function Ie(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ae(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var Qe,Ke,$e,ze=null,Ge=(Qe=-1,Ke=-1,$e=void 0,function(e){var t=++Qe;return Promise.resolve(e).then((function(e){return $e&&t=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function rt(e){return rt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},rt(e)}var ot=["props","refresh","store"],it=["inputElement","formElement","panelElement"],ut=["inputElement"],at=["inputElement","maxLength"],lt=["source"],ct=["item","source"];function st(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ft(e){for(var t=1;t=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function vt(e){var t=e.props,n=e.refresh,r=e.store,o=mt(e,ot);return{getEnvironmentProps:function(e){var n=e.inputElement,o=e.formElement,i=e.panelElement;function u(e){!r.getState().isOpen&&r.pendingRequests.isEmpty()||e.target===n||!1===[o,i].some((function(t){return n=t,r=e.target,n===r||n.contains(r);var n,r}))&&(r.dispatch("blur",null),t.debug||r.pendingRequests.cancelAll())}return ft({onTouchStart:u,onMouseDown:u,onTouchMove:function(e){!1!==r.getState().isOpen&&n===t.environment.document.activeElement&&e.target!==n&&n.blur()}},mt(e,it))},getRootProps:function(e){return ft({role:"combobox","aria-expanded":r.getState().isOpen,"aria-haspopup":"listbox","aria-controls":r.getState().isOpen?r.getState().collections.map((function(e){var n=e.source;return ae(t.id,"list",n)})).join(" "):void 0,"aria-labelledby":ae(t.id,"label")},e)},getFormProps:function(e){return e.inputElement,ft({action:"",noValidate:!0,role:"search",onSubmit:function(i){var u;i.preventDefault(),t.onSubmit(ft({event:i,refresh:n,state:r.getState()},o)),r.dispatch("submit",null),null===(u=e.inputElement)||void 0===u||u.blur()},onReset:function(i){var u;i.preventDefault(),t.onReset(ft({event:i,refresh:n,state:r.getState()},o)),r.dispatch("reset",null),null===(u=e.inputElement)||void 0===u||u.focus()}},mt(e,ut))},getLabelProps:function(e){return ft({htmlFor:ae(t.id,"input"),id:ae(t.id,"label")},e)},getInputProps:function(e){var i;function u(e){(t.openOnFocus||Boolean(r.getState().query))&&Je(ft({event:e,props:t,query:r.getState().completion||r.getState().query,refresh:n,store:r},o)),r.dispatch("focus",null)}var a=e||{};a.inputElement;var l=a.maxLength,c=void 0===l?512:l,s=mt(a,at),f=ue(r.getState()),p=function(e){return Boolean(e&&e.match(le))}((null===(i=t.environment.navigator)||void 0===i?void 0:i.userAgent)||""),m=t.enterKeyHint||(null!=f&&f.itemUrl&&!p?"go":"search");return ft({"aria-autocomplete":"both","aria-activedescendant":r.getState().isOpen&&null!==r.getState().activeItemId?ae(t.id,"item-".concat(r.getState().activeItemId),null==f?void 0:f.source):void 0,"aria-controls":r.getState().isOpen?r.getState().collections.map((function(e){var n=e.source;return ae(t.id,"list",n)})).join(" "):void 0,"aria-labelledby":ae(t.id,"label"),value:r.getState().completion||r.getState().query,id:ae(t.id,"input"),autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",enterKeyHint:m,spellCheck:"false",autoFocus:t.autoFocus,placeholder:t.placeholder,maxLength:c,type:"search",onChange:function(e){var i=e.currentTarget.value;t.ignoreCompositionEvents&&ce(e).isComposing?o.setQuery(i):Je(ft({event:e,props:t,query:i.slice(0,c),refresh:n,store:r},o))},onCompositionEnd:function(e){Je(ft({event:e,props:t,query:e.currentTarget.value.slice(0,c),refresh:n,store:r},o))},onKeyDown:function(e){ce(e).isComposing||function(e){var t=e.event,n=e.props,r=e.refresh,o=e.store,i=nt(e,Ye);if("ArrowUp"===t.key||"ArrowDown"===t.key){var u=function(){var e=ue(o.getState()),t=n.environment.document.getElementById(ae(n.id,"item-".concat(o.getState().activeItemId),null==e?void 0:e.source));t&&(t.scrollIntoViewIfNeeded?t.scrollIntoViewIfNeeded(!1):t.scrollIntoView(!1))},a=function(){var e=ue(o.getState());if(null!==o.getState().activeItemId&&e){var n=e.item,u=e.itemInputValue,a=e.itemUrl,l=e.source;l.onActive(et({event:t,item:n,itemInputValue:u,itemUrl:a,refresh:r,source:l,state:o.getState()},i))}};t.preventDefault(),!1===o.getState().isOpen&&(n.openOnFocus||Boolean(o.getState().query))?Je(et({event:t,props:n,query:o.getState().query,refresh:r,store:o},i)).then((function(){o.dispatch(t.key,{nextActiveItemId:n.defaultActiveItemId}),a(),setTimeout(u,0)})):(o.dispatch(t.key,{}),a(),u())}else if("Escape"===t.key)t.preventDefault(),o.dispatch(t.key,null),o.pendingRequests.cancelAll();else if("Tab"===t.key)o.dispatch("blur",null),o.pendingRequests.cancelAll();else if("Enter"===t.key){if(null===o.getState().activeItemId||o.getState().collections.every((function(e){return 0===e.items.length})))return void(n.debug||o.pendingRequests.cancelAll());t.preventDefault();var l=ue(o.getState()),c=l.item,s=l.itemInputValue,f=l.itemUrl,p=l.source;if(t.metaKey||t.ctrlKey)void 0!==f&&(p.onSelect(et({event:t,item:c,itemInputValue:s,itemUrl:f,refresh:r,source:p,state:o.getState()},i)),n.navigator.navigateNewTab({itemUrl:f,item:c,state:o.getState()}));else if(t.shiftKey)void 0!==f&&(p.onSelect(et({event:t,item:c,itemInputValue:s,itemUrl:f,refresh:r,source:p,state:o.getState()},i)),n.navigator.navigateNewWindow({itemUrl:f,item:c,state:o.getState()}));else if(t.altKey);else{if(void 0!==f)return p.onSelect(et({event:t,item:c,itemInputValue:s,itemUrl:f,refresh:r,source:p,state:o.getState()},i)),void n.navigator.navigate({itemUrl:f,item:c,state:o.getState()});Je(et({event:t,nextState:{isOpen:!1},props:n,query:s,refresh:r,store:o},i)).then((function(){p.onSelect(et({event:t,item:c,itemInputValue:s,itemUrl:f,refresh:r,source:p,state:o.getState()},i))}))}}}(ft({event:e,props:t,refresh:n,store:r},o))},onFocus:u,onBlur:_,onClick:function(n){e.inputElement!==t.environment.document.activeElement||r.getState().isOpen||u(n)}},s)},getPanelProps:function(e){return ft({onMouseDown:function(e){e.preventDefault()},onMouseLeave:function(){r.dispatch("mouseleave",null)}},e)},getListProps:function(e){var n=e||{},r=n.source,o=mt(n,lt);return ft({role:"listbox","aria-labelledby":ae(t.id,"label"),id:ae(t.id,"list",r)},o)},getItemProps:function(e){var i=e.item,u=e.source,a=mt(e,ct);return ft({id:ae(t.id,"item-".concat(i.__autocomplete_id),u),role:"option","aria-selected":r.getState().activeItemId===i.__autocomplete_id,onMouseMove:function(e){if(i.__autocomplete_id!==r.getState().activeItemId){r.dispatch("mousemove",i.__autocomplete_id);var t=ue(r.getState());if(null!==r.getState().activeItemId&&t){var u=t.item,a=t.itemInputValue,l=t.itemUrl,c=t.source;c.onActive(ft({event:e,item:u,itemInputValue:a,itemUrl:l,refresh:n,source:c,state:r.getState()},o))}}},onMouseDown:function(e){e.preventDefault()},onClick:function(e){var a=u.getItemInputValue({item:i,state:r.getState()}),l=u.getItemUrl({item:i,state:r.getState()});(l?Promise.resolve():Je(ft({event:e,nextState:{isOpen:!1},props:t,query:a,refresh:n,store:r},o))).then((function(){u.onSelect(ft({event:e,item:i,itemInputValue:a,itemUrl:l,refresh:n,source:u,state:r.getState()},o))}))}},a)}}}function dt(e){return dt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},dt(e)}function yt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function bt(e){for(var t=1;t=5&&((o||!e&&5===r)&&(u.push(r,0,o,n),r=6),e&&(u.push(r,e,0,n),r=6)),o=""},l=0;l"===t?(r=1,o=""):o=t+o[0]:i?t===i?i="":o+=t:'"'===t||"'"===t?i=t:">"===t?(a(),r=1):r&&("="===t?(r=5,n=o,o=""):"/"===t&&(r<5||">"===e[l][c+1])?(a(),3===r&&(u=u[0]),r=u,(u=u[0]).push(2,0,r),r=0):" "===t||"\t"===t||"\n"===t||"\r"===t?(a(),r=2):o+=t),3===r&&"!--"===o&&(r=4,u=u[0])}return a(),u}(e)),t),arguments,[])).length>1?t:t[0]}var Tt=function(e){var t=e.environment,n=t.document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("class","aa-ClearIcon"),n.setAttribute("viewBox","0 0 24 24"),n.setAttribute("width","18"),n.setAttribute("height","18"),n.setAttribute("fill","currentColor");var r=t.document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d","M5.293 6.707l5.293 5.293-5.293 5.293c-0.391 0.391-0.391 1.024 0 1.414s1.024 0.391 1.414 0l5.293-5.293 5.293 5.293c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414l-5.293-5.293 5.293-5.293c0.391-0.391 0.391-1.024 0-1.414s-1.024-0.391-1.414 0l-5.293 5.293-5.293-5.293c-0.391-0.391-1.024-0.391-1.414 0s-0.391 1.024 0 1.414z"),n.appendChild(r),n};function qt(e,t){if("string"==typeof t){var n=e.document.querySelector(t);return"The element ".concat(JSON.stringify(t)," is not in the document."),n}return t}function Bt(){for(var e=arguments.length,t=new Array(e),n=0;n2&&(u.children=arguments.length>3?Zt.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(i in e.defaultProps)void 0===u[i]&&(u[i]=e.defaultProps[i]);return mn(e,u,r,o,null)}function mn(e,t,n,r,o){var i={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==o?++tn:o};return null==o&&null!=en.vnode&&en.vnode(i),i}function vn(e){return e.children}function dn(e,t){this.props=e,this.context=t}function yn(e,t){if(null==t)return e.__?yn(e.__,e.__.__k.indexOf(e)+1):null;for(var n;tt&&nn.sort(un));hn.__r=0}function _n(e,t,n,r,o,i,u,a,l,c){var s,f,p,m,v,d,y,b=r&&r.__k||ln,g=b.length;for(n.__k=[],s=0;s0?mn(m.type,m.props,m.key,m.ref?m.ref:null,m.__v):m)){if(m.__=n,m.__b=n.__b+1,null===(p=b[s])||p&&m.key==p.key&&m.type===p.type)b[s]=void 0;else for(f=0;f=0;t--)if((n=e.__k[t])&&(r=jn(n)))return r;return null}function Pn(e,t,n){"-"===t[0]?e.setProperty(t,null==n?"":n):e[t]=null==n?"":"number"!=typeof n||cn.test(t)?n:n+"px"}function wn(e,t,n,r,o){var i;e:if("style"===t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof r&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||Pn(e.style,t,"");if(n)for(t in n)r&&n[t]===r[t]||Pn(e.style,t,n[t])}else if("o"===t[0]&&"n"===t[1])i=t!==(t=t.replace(/Capture$/,"")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+i]=n,n?r||e.addEventListener(t,i?An:In,i):e.removeEventListener(t,i?An:In,i);else if("dangerouslySetInnerHTML"!==t){if(o)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==t&&"height"!==t&&"href"!==t&&"list"!==t&&"form"!==t&&"tabIndex"!==t&&"download"!==t&&t in e)try{e[t]=null==n?"":n;break e}catch(e){}"function"==typeof n||(null==n||!1===n&&"-"!==t[4]?e.removeAttribute(t):e.setAttribute(t,n))}}function In(e){return this.l[e.type+!1](en.event?en.event(e):e)}function An(e){return this.l[e.type+!0](en.event?en.event(e):e)}function En(e,t,n,r,o,i,u,a,l){var c,s,f,p,m,v,d,y,b,g,h,_,O,S,j,P=t.type;if(void 0!==t.constructor)return null;null!=n.__h&&(l=n.__h,a=t.__e=n.__e,t.__h=null,i=[a]),(c=en.__b)&&c(t);try{e:if("function"==typeof P){if(y=t.props,b=(c=P.contextType)&&r[c.__c],g=c?b?b.props.value:c.__:r,n.__c?d=(s=t.__c=n.__c).__=s.__E:("prototype"in P&&P.prototype.render?t.__c=s=new P(y,g):(t.__c=s=new dn(y,g),s.constructor=P,s.render=Nn),b&&b.sub(s),s.props=y,s.state||(s.state={}),s.context=g,s.__n=r,f=s.__d=!0,s.__h=[],s._sb=[]),null==s.__s&&(s.__s=s.state),null!=P.getDerivedStateFromProps&&(s.__s==s.state&&(s.__s=sn({},s.__s)),sn(s.__s,P.getDerivedStateFromProps(y,s.__s))),p=s.props,m=s.state,s.__v=t,f)null==P.getDerivedStateFromProps&&null!=s.componentWillMount&&s.componentWillMount(),null!=s.componentDidMount&&s.__h.push(s.componentDidMount);else{if(null==P.getDerivedStateFromProps&&y!==p&&null!=s.componentWillReceiveProps&&s.componentWillReceiveProps(y,g),!s.__e&&null!=s.shouldComponentUpdate&&!1===s.shouldComponentUpdate(y,s.__s,g)||t.__v===n.__v){for(t.__v!==n.__v&&(s.props=y,s.state=s.__s,s.__d=!1),s.__e=!1,t.__e=n.__e,t.__k=n.__k,t.__k.forEach((function(e){e&&(e.__=t)})),h=0;h0&&void 0!==arguments[0]?arguments[0]:[];return{get:function(){return e},add:function(t){var n=e[e.length-1];(null==n?void 0:n.isHighlighted)===t.isHighlighted?e[e.length-1]={value:n.value+t.value,isHighlighted:n.isHighlighted}:e.push(t)}}}(n?[{value:n,isHighlighted:!1}]:[]);return t.forEach((function(e){var t=e.split(qn);r.add({value:t[0],isHighlighted:!0}),""!==t[1]&&r.add({value:t[1],isHighlighted:!1})})),r.get()}function Rn(e){return function(e){if(Array.isArray(e))return Ln(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return Ln(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ln(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ln(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n",""":'"',"'":"'"},Mn=new RegExp(/\w/i),Hn=/&(amp|quot|lt|gt|#39);/g,Vn=RegExp(Hn.source);function Wn(e,t){var n,r,o,i=e[t],u=(null===(n=e[t+1])||void 0===n?void 0:n.isHighlighted)||!0,a=(null===(r=e[t-1])||void 0===r?void 0:r.isHighlighted)||!0;return Mn.test((o=i.value)&&Vn.test(o)?o.replace(Hn,(function(e){return Un[e]})):o)||a!==u?i.isHighlighted:a}function Qn(e){return Qn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Qn(e)}function Kn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function $n(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function cr(e){return function(e){if(Array.isArray(e))return sr(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return sr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return sr(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function sr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0;if(!_.value.core.openOnFocus&&!t.query)return n;var r=Boolean(y.current||_.value.renderer.renderNoResults);return!n&&r||n},__autocomplete_metadata:{userAgents:_r,options:e}}))})),j=f(n({collections:[],completion:null,context:{},isOpen:!1,query:"",activeItemId:null,status:"idle"},_.value.core.initialState)),P={getEnvironmentProps:_.value.renderer.getEnvironmentProps,getFormProps:_.value.renderer.getFormProps,getInputProps:_.value.renderer.getInputProps,getItemProps:_.value.renderer.getItemProps,getLabelProps:_.value.renderer.getLabelProps,getListProps:_.value.renderer.getListProps,getPanelProps:_.value.renderer.getPanelProps,getRootProps:_.value.renderer.getRootProps},w={setActiveItemId:S.value.setActiveItemId,setQuery:S.value.setQuery,setCollections:S.value.setCollections,setIsOpen:S.value.setIsOpen,setStatus:S.value.setStatus,setContext:S.value.setContext,refresh:S.value.refresh,navigator:S.value.navigator},I=m((function(){return Nt.bind(_.value.renderer.renderer.createElement)})),A=m((function(){return Yt({autocomplete:S.value,autocompleteScopeApi:w,classNames:_.value.renderer.classNames,environment:_.value.core.environment,isDetached:O.value,placeholder:_.value.core.placeholder,propGetters:P,setIsModalOpen:k,state:j.current,translations:_.value.renderer.translations})}));function E(){Qt(A.value.panel,{style:O.value?{}:hr({panelPlacement:_.value.renderer.panelPlacement,container:A.value.root,form:A.value.form,environment:_.value.core.environment})})}function D(e){j.current=e;var t={autocomplete:S.value,autocompleteScopeApi:w,classNames:_.value.renderer.classNames,components:_.value.renderer.components,container:_.value.renderer.container,html:I.value,dom:A.value,panelContainer:O.value?A.value.detachedContainer:_.value.renderer.panelContainer,propGetters:P,state:j.current,renderer:_.value.renderer.renderer},r=!b(e)&&!y.current&&_.value.renderer.renderNoResults||_.value.renderer.render;!function(e){var t=e.autocomplete,r=e.autocompleteScopeApi,o=e.dom,i=e.propGetters,u=e.state;Kt(o.root,i.getRootProps(n({state:u,props:t.getRootProps({})},r))),Kt(o.input,i.getInputProps(n({state:u,props:t.getInputProps({inputElement:o.input}),inputElement:o.input},r))),Qt(o.label,{hidden:"stalled"===u.status}),Qt(o.loadingIndicator,{hidden:"stalled"!==u.status}),Qt(o.clearButton,{hidden:!u.query}),Qt(o.detachedSearchButtonQuery,{textContent:u.query}),Qt(o.detachedSearchButtonPlaceholder,{hidden:Boolean(u.query)})}(t),function(e,t){var r=t.autocomplete,o=t.autocompleteScopeApi,u=t.classNames,a=t.html,l=t.dom,c=t.panelContainer,s=t.propGetters,f=t.state,p=t.components,m=t.renderer;if(f.isOpen){c.contains(l.panel)||"loading"===f.status||c.appendChild(l.panel),l.panel.classList.toggle("aa-Panel--stalled","stalled"===f.status);var v=f.collections.filter((function(e){var t=e.source,n=e.items;return t.templates.noResults||n.length>0})).map((function(e,t){var l=e.source,c=e.items;return m.createElement("section",{key:t,className:u.source,"data-autocomplete-source-id":l.sourceId},l.templates.header&&m.createElement("div",{className:u.sourceHeader},l.templates.header({components:p,createElement:m.createElement,Fragment:m.Fragment,items:c,source:l,state:f,html:a})),l.templates.noResults&&0===c.length?m.createElement("div",{className:u.sourceNoResults},l.templates.noResults({components:p,createElement:m.createElement,Fragment:m.Fragment,source:l,state:f,html:a})):m.createElement("ul",i({className:u.list},s.getListProps(n({state:f,props:r.getListProps({source:l})},o))),c.map((function(e){var t=r.getItemProps({item:e,source:l});return m.createElement("li",i({key:t.id,className:u.item},s.getItemProps(n({state:f,props:t},o))),l.templates.item({components:p,createElement:m.createElement,Fragment:m.Fragment,item:e,state:f,html:a}))}))),l.templates.footer&&m.createElement("div",{className:u.sourceFooter},l.templates.footer({components:p,createElement:m.createElement,Fragment:m.Fragment,items:c,source:l,state:f,html:a})))})),d=m.createElement(m.Fragment,null,m.createElement("div",{className:u.panelLayout},v),m.createElement("div",{className:"aa-GradientBottom"})),y=v.reduce((function(e,t){return e[t.props["data-autocomplete-source-id"]]=t,e}),{});e(n(n({children:d,state:f,sections:v,elements:y},m),{},{components:p,html:a},o),l.panel)}else c.contains(l.panel)&&c.removeChild(l.panel)}(r,t)}function C(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l();var t=_.value.renderer,n=t.components,r=u(t,Or);g.current=Lt(r,_.value.core,{components:Ft(n,(function(e){return!e.value.hasOwnProperty("__autocomplete_componentName")})),initialState:j.current},e),v(),c(),S.value.refresh().then((function(){D(j.current)}))}function k(e){e!==_.value.core.environment.document.body.contains(A.value.detachedOverlay)&&(e?(_.value.core.environment.document.body.appendChild(A.value.detachedOverlay),_.value.core.environment.document.body.classList.add("aa-Detached"),A.value.input.focus()):(_.value.core.environment.document.body.removeChild(A.value.detachedOverlay),_.value.core.environment.document.body.classList.remove("aa-Detached")))}return a((function(){var e=S.value.getEnvironmentProps({formElement:A.value.form,panelElement:A.value.panel,inputElement:A.value.input});return Qt(_.value.core.environment,e),function(){Qt(_.value.core.environment,Object.keys(e).reduce((function(e,t){return n(n({},e),{},o({},t,void 0))}),{}))}})),a((function(){var e=O.value?_.value.core.environment.document.body:_.value.renderer.panelContainer,t=O.value?A.value.detachedOverlay:A.value.panel;return O.value&&j.current.isOpen&&k(!0),D(j.current),function(){e.contains(t)&&(e.removeChild(t),e.classList.remove("aa-Detached"))}})),a((function(){var e=_.value.renderer.container;return e.appendChild(A.value.root),function(){e.removeChild(A.value.root)}})),a((function(){var e=p((function(e){D(e.state)}),0);return h.current=function(t){var n=t.state,r=t.prevState;(O.value&&r.isOpen!==n.isOpen&&k(n.isOpen),O.value||!n.isOpen||r.isOpen||E(),n.query!==r.query)&&_.value.core.environment.document.querySelectorAll(".aa-Panel--scrollable").forEach((function(e){0!==e.scrollTop&&(e.scrollTop=0)}));e({state:n})},function(){h.current=void 0}})),a((function(){var e=p((function(){var e=O.value;O.value=_.value.core.environment.matchMedia(_.value.renderer.detachedMediaQuery).matches,e!==O.value?C({}):requestAnimationFrame(E)}),20);return _.value.core.environment.addEventListener("resize",e),function(){_.value.core.environment.removeEventListener("resize",e)}})),a((function(){if(!O.value)return function(){};function e(e){A.value.detachedContainer.classList.toggle("aa-DetachedContainer--modal",e)}function t(t){e(t.matches)}var n=_.value.core.environment.matchMedia(getComputedStyle(_.value.core.environment.document.documentElement).getPropertyValue("--aa-detached-modal-media-query"));e(n.matches);var r=Boolean(n.addEventListener);return r?n.addEventListener("change",t):n.addListener(t),function(){r?n.removeEventListener("change",t):n.removeListener(t)}})),a((function(){return requestAnimationFrame(E),function(){}})),n(n({},w),{},{update:C,destroy:function(){l()}})},e.getAlgoliaFacets=function(e){var t=Sr({transformResponse:function(e){return e.facetHits}}),r=e.queries.map((function(e){return n(n({},e),{},{type:"facet"})}));return t(n(n({},e),{},{queries:r}))},e.getAlgoliaResults=jr,Object.defineProperty(e,"__esModule",{value:!0})})); -//# sourceMappingURL=index.production.js.map diff --git a/view/frontend/web/js/lib/insights-plugin.min.js b/view/frontend/web/js/lib/insights-plugin.min.js index 6a35dac69..a399cb32f 100644 --- a/view/frontend/web/js/lib/insights-plugin.min.js +++ b/view/frontend/web/js/lib/insights-plugin.min.js @@ -6,4 +6,3 @@ */ /*! @algolia/autocomplete-plugin-algolia-insights 1.17.4 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/autocomplete-plugin-algolia-insights"]={})}(this,(function(e){"use strict";function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function n(e){for(var n=1;n=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,c,a=[],u=!0,l=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(a.push(r.value),a.length!==t);u=!0);}catch(e){l=!0,i=e}finally{try{if(!u&&null!=n.return&&(c=n.return(),Object(c)!==c))return}finally{if(l)throw i}}return a}}(e,t)||a(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||a(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){if(e){if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n1&&void 0!==arguments[1]?arguments[1]:20,r=[],i=0;i=3||2===r&&a>=4||1===r&&a>=10);function l(t,n,r){if(u&&void 0!==r){var i=r[0].__autocomplete_algoliaCredentials,o={"X-Algolia-Application-Id":i.appId,"X-Algolia-API-Key":i.apiKey};e.apply(void 0,[t].concat(c(n),[{headers:o}]))}else e.apply(void 0,[t].concat(c(n)))}return{init:function(t,n){e("init",{appId:t,apiKey:n})},setAuthenticatedUserToken:function(t){e("setAuthenticatedUserToken",t)},setUserToken:function(t){e("setUserToken",t)},clickedObjectIDsAfterSearch:function(){for(var e=arguments.length,t=new Array(e),n=0;n0&&l("clickedObjectIDsAfterSearch",h(t),t[0].items)},clickedObjectIDs:function(){for(var e=arguments.length,t=new Array(e),n=0;n0&&l("clickedObjectIDs",h(t),t[0].items)},clickedFilters:function(){for(var t=arguments.length,n=new Array(t),r=0;r0&&e.apply(void 0,["clickedFilters"].concat(n))},convertedObjectIDsAfterSearch:function(){for(var e=arguments.length,t=new Array(e),n=0;n0&&l("convertedObjectIDsAfterSearch",h(t),t[0].items)},convertedObjectIDs:function(){for(var e=arguments.length,t=new Array(e),n=0;n0&&l("convertedObjectIDs",h(t),t[0].items)},convertedFilters:function(){for(var t=arguments.length,n=new Array(t),r=0;r0&&e.apply(void 0,["convertedFilters"].concat(n))},viewedObjectIDs:function(){for(var e=arguments.length,t=new Array(e),r=0;r0&&t.reduce((function(e,t){var r=t.items,o=i(t,v);return[].concat(c(e),c(d(n(n({},o),{},{objectIDs:(null==r?void 0:r.map((function(e){return e.objectID})))||o.objectIDs})).map((function(e){return{items:r,payload:e}}))))}),[]).forEach((function(e){var t=e.items;return l("viewedObjectIDs",[e.payload],t)}))},viewedFilters:function(){for(var t=arguments.length,n=new Array(t),r=0;r0&&e.apply(void 0,["viewedFilters"].concat(n))}}}function b(e){var t=e.items.reduce((function(e,t){var n;return e[t.__autocomplete_indexName]=(null!==(n=e[t.__autocomplete_indexName])&&void 0!==n?n:[]).concat(t),e}),{});return Object.keys(t).map((function(e){return{index:e,items:t[e],algoliaSource:["autocomplete"]}}))}function j(e){return e.objectID&&e.__autocomplete_indexName&&e.__autocomplete_queryID}var I="2.15.0",O="https://cdn.jsdelivr.net/npm/search-insights@".concat(I,"/dist/search-insights.min.js"),A=l((function(e){var t=e.onItemsChange,r=e.items,i=e.insights,o=e.state;t({insights:i,insightsEvents:b({items:r}).map((function(e){return n({eventName:"Items Viewed"},e)})),state:o})}),400);function w(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0;return[].concat(c(t),["autocomplete-internal"],c(null!==(e=n.algoliaInsightsPlugin)&&void 0!==e&&e.__automaticInsights?["autocomplete-automatic"]:[]))}function _(e){return"number"==typeof e?e.toString():e}e.createAlgoliaInsightsPlugin=function(e){var t=function(e){return n({onItemsChange:function(e){var t=e.insights,r=e.insightsEvents,i=e.state;t.viewedObjectIDs.apply(t,c(r.map((function(e){return n(n({},e),{},{algoliaSource:w(e.algoliaSource,i.context)})}))))},onSelect:function(e){var t=e.insights,r=e.insightsEvents,i=e.state;t.clickedObjectIDsAfterSearch.apply(t,c(r.map((function(e){return n(n({},e),{},{algoliaSource:w(e.algoliaSource,i.context)})}))))},onActive:p,__autocomplete_clickAnalytics:!0},e)}(e),r=t.insightsClient,i=t.insightsInitParams,o=t.onItemsChange,a=t.onSelect,u=t.onActive,s=t.__autocomplete_clickAnalytics,m=r;if(r||function(e){if("undefined"!=typeof window)e({window:window})}((function(e){var t=e.window,n=t.AlgoliaAnalyticsObject||"aa";"string"==typeof n&&(m=t[n]),m||(t.AlgoliaAnalyticsObject=n,t[n]||(t[n]=function(){t[n].queue||(t[n].queue=[]);for(var e=arguments.length,r=new Array(e),i=0;i0&&A({onItemsChange:o,items:n,insights:v,state:t}))}}),0);return{name:"aa.algoliaInsightsPlugin",subscribe:function(e){var t=e.setContext,r=e.onSelect,i=e.onActive,o=!1;function c(e){t({algoliaInsightsPlugin:{__algoliaSearchParameters:n(n({},s?{clickAnalytics:!0}:{}),e?{userToken:_(e)}:{}),insights:v}})}m("addAlgoliaAgent","insights-plugin"),c(),m("onUserTokenChange",(function(e){o||c(e)})),m("getUserToken",null,(function(e,t){o||c(t)})),m("onAuthenticatedUserTokenChange",(function(e){e?(o=!0,c(e)):(o=!1,m("getUserToken",null,(function(e,t){return c(t)})))})),m("getAuthenticatedUserToken",null,(function(e,t){t&&(o=!0,c(t))})),r((function(e){var t=e.item,r=e.state,i=e.event,o=e.source;j(t)&&a({state:r,event:i,insights:v,item:t,insightsEvents:[n({eventName:"Item Selected"},g({item:t,items:o.getItems().filter(j)}))]})})),i((function(e){var t=e.item,r=e.source,i=e.state,o=e.event;j(t)&&u({state:i,event:o,insights:v,item:t,insightsEvents:[n({eventName:"Item Active"},g({item:t,items:r.getItems().filter(j)}))]})}))},onStateChange:function(e){var t=e.state;h({state:t})},__autocomplete_pluginOptions:e}},Object.defineProperty(e,"__esModule",{value:!0})})); -//# sourceMappingURL=index.production.js.map diff --git a/view/frontend/web/js/lib/query-suggestions-plugin.min.js b/view/frontend/web/js/lib/query-suggestions-plugin.min.js index 5f6adb583..0c22e774b 100644 --- a/view/frontend/web/js/lib/query-suggestions-plugin.min.js +++ b/view/frontend/web/js/lib/query-suggestions-plugin.min.js @@ -6,4 +6,3 @@ */ /*! @algolia/autocomplete-plugin-query-suggestions 1.17.4 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/autocomplete-plugin-query-suggestions"]={})}(this,(function(e){"use strict";function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function r(e){for(var r=1;re.length)&&(t=e.length);for(var r=0,n=new Array(t);r=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return u=e.done,e},e:function(e){c=!0,a=e},f:function(){try{u||null==r.return||r.return()}finally{if(c)throw a}}}}var a="1.17.4",u=[{segment:"autocomplete-core",version:a}];function c(e){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c(e)}function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;t=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function d(e){return function(e){if(Array.isArray(e))return h(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return h(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return h(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&o++;var p,y=i(f);try{for(y.s();!(p=y.n()).done;){var m=p.value;u.push(r({__autocomplete_qsCategory:m},t))}}catch(e){y.e(e)}finally{y.f()}}return e.push.apply(e,u),e}),[])}})},templates:A({onTapAhead:m})},onTapAhead:m,state:y})]},__autocomplete_pluginOptions:e}},e.getTemplates=A,Object.defineProperty(e,"__esModule",{value:!0})})); -//# sourceMappingURL=index.production.js.map diff --git a/view/frontend/web/js/lib/recent-searches-plugin.min.js b/view/frontend/web/js/lib/recent-searches-plugin.min.js index 3f1820229..b42b0378f 100644 --- a/view/frontend/web/js/lib/recent-searches-plugin.min.js +++ b/view/frontend/web/js/lib/recent-searches-plugin.min.js @@ -6,4 +6,3 @@ */ /*! @algolia/autocomplete-plugin-recent-searches 1.8.3 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/autocomplete-plugin-recent-searches"]={})}(this,(function(e){"use strict";function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function n(e){for(var n=1;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&void 0!==arguments[0]?arguments[0]:{};return Array.isArray(u.current)?n(n({},r),{},{facetFilters:[].concat(o(null!==(e=r.facetFilters)&&void 0!==e?e:[]),o(u.current.map((function(e){return["objectID:-".concat(e.label)]})))),hitsPerPage:Math.max(1,(null!==(t=r.hitsPerPage)&&void 0!==t?t:10)-u.current.length)}):r}}),__autocomplete_pluginOptions:e}}function g(e){var t=e.query,n=e.items,r=e.limit;return t?n.filter((function(e){return e.label.toLowerCase().includes(t.toLowerCase())})).slice(0,r).map((function(e){return i({item:e,query:t})})):n.slice(0,r).map((function(e){return i({item:e,query:t})}))}function v(e){return n({limit:5,search:g,transformSource:function(e){return e.source}},e)}e.addHighlightedAttribute=i,e.createLocalStorageRecentSearchesPlugin=function(e){var t=v(e),r=t.key,a=t.limit,i=t.transformSource,u=t.search,s=t.subscribe,m=function(e){var t=e.key,n=e.limit,r=e.search,a=l({key:t});return{onAdd:function(e){a.setItem([e].concat(o(a.getItem())))},onRemove:function(e){a.setItem(a.getItem().filter((function(t){return t.id!==e})))},getAll:function(){return r({query:arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",items:a.getItem(),limit:n}).slice(0,n)}}}({key:[c,r].join(":"),limit:a,search:u});return n(n({},f({transformSource:i,storage:m,subscribe:s})),{},{name:"aa.localStorageRecentSearchesPlugin",__autocomplete_pluginOptions:e})},e.createRecentSearchesPlugin=f,e.getTemplates=s,e.search=g,Object.defineProperty(e,"__esModule",{value:!0})})); -//# sourceMappingURL=index.production.js.map