@depict-ai/react-ui 1.5.3 → 1.5.5

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.
@@ -0,0 +1,816 @@
1
+ import { add_to_version_info as $2GFvs$add_to_version_info, catchify as $2GFvs$catchify, queueMacroTask as $2GFvs$queueMacroTask, instant_exec_on_suspect_history_change as $2GFvs$instant_exec_on_suspect_history_change, derror as $2GFvs$derror } from "@depict-ai/utilishared/latest";
2
+ import { CategoryTitle as $43099132aad1ceb6$re_export$CategoryTitle, embedded_num_products as $43099132aad1ceb6$re_export$EmbeddedNumProducts, DepictAPI as $2GFvs$DepictAPI, ProductCardError as $2GFvs$ProductCardError, DepictSearch as $2GFvs$DepictSearch, DepictCategory as $2GFvs$DepictCategory, get_search_query_updating_blocked_signal as $2GFvs$get_search_query_updating_blocked_signal, SearchPage as $2GFvs$SearchPage, defaultColsAtSize as $2GFvs$defaultColsAtSize, defaultGridSpacing as $2GFvs$defaultGridSpacing, CategoryPage as $2GFvs$CategoryPage, defaultCategoryTitlePlugin as $2GFvs$defaultCategoryTitlePlugin, BreadCrumbs as $2GFvs$BreadCrumbs, QuickLinks as $2GFvs$QuickLinks, ImagePlaceholder as $2GFvs$ImagePlaceholder, TextPlaceholder as $2GFvs$TextPlaceholder, open_modal_with_alignment as $2GFvs$open_modal_with_alignment, SearchField as $2GFvs$SearchField, fetchDepictRecommendations as $2GFvs$fetchDepictRecommendations } from "@depict-ai/ui/latest";
3
+ import { untrack as $2GFvs$untrack, createRoot as $2GFvs$createRoot, createEffect as $2GFvs$createEffect, createMemo as $2GFvs$createMemo, createComponent as $2GFvs$createComponent, Show as $2GFvs$Show, getOwner as $2GFvs$getOwner, runWithOwner as $2GFvs$runWithOwner, onCleanup as $2GFvs$onCleanup, createSignal as $2GFvs$createSignal, createComputed as $2GFvs$createComputed } from "solid-js";
4
+ import { createElement as $2GFvs$createElement, Fragment as $2GFvs$Fragment, useEffect as $2GFvs$useEffect, useState as $2GFvs$useState, useRef as $2GFvs$useRef, Component as $2GFvs$Component, forwardRef as $2GFvs$forwardRef, useCallback as $2GFvs$useCallback } from "react";
5
+ import { defaultLocale as $2GFvs$defaultLocale } from "@depict-ai/ui/locales/latest";
6
+ import { render as $2GFvs$render, hydrate as $2GFvs$hydrate } from "solid-js/web";
7
+ import { jsx as $2GFvs$jsx } from "react/jsx-runtime";
8
+ import { createPortal as $2GFvs$createPortal } from "react-dom";
9
+ import { createStore as $2GFvs$createStore, reconcile as $2GFvs$reconcile } from "solid-js/store";
10
+ import { DPC as $2GFvs$DPC } from "@depict-ai/dpc/latest";
11
+
12
+ /*! Depict.ai search and product listing react SDK wrapper */ // This is where the actual source of your React stuff should live
13
+ // Note, if you add an export here, also add one in src-server/main.ts
14
+ import { register_es_version } from "../multi_import_deduplicator.mjs";
15
+ register_es_version("react-ui", "latest");
16
+ const $c9c4d066f9a5b51b$export$83d89fbfd8236492 = "1.5.5";
17
+ const $42858f023ef23dab$export$8e769ad4338a911e = {
18
+ usedLocale: (0, $2GFvs$createSignal)((0, $2GFvs$defaultLocale)),
19
+ search_instances: new Map(),
20
+ category_instances: new Map(),
21
+ api: null,
22
+ dpc: null,
23
+ merchant: (0, $2GFvs$createSignal)(),
24
+ market: (0, $2GFvs$createSignal)(),
25
+ userId: (0, $2GFvs$createSignal)(),
26
+ sessionId: (0, $2GFvs$createSignal)(),
27
+ known_category_paths: new Set(),
28
+ search_page_path_: (0, $2GFvs$createSignal)(),
29
+ search_page_in_dom: (0, $2GFvs$createSignal)(false),
30
+ category_page_in_dom: (0, $2GFvs$createSignal)(false),
31
+ provider_is_updating: (0, $2GFvs$createSignal)(false),
32
+ enable_content_search: (0, $2GFvs$createSignal)()
33
+ };
34
+ class $d5c9e1f3545b4984$export$d0f82e3ef89b1f22 extends (0, $2GFvs$Component) {
35
+ constructor(props) {
36
+ super(props);
37
+ this.state = {
38
+ hasError: false
39
+ };
40
+ }
41
+ static getDerivedStateFromError() {
42
+ // Update state so the next render will show the fallback UI.
43
+ return {
44
+ hasError: true
45
+ };
46
+ }
47
+ componentDidCatch(error) {
48
+ this.props.on_error(error);
49
+ }
50
+ render() {
51
+ if (this.state.hasError)
52
+ // You can render any custom fallback UI
53
+ return (0, $2GFvs$createElement)("div", {
54
+ children: "Component failed"
55
+ });
56
+ return this.props.children;
57
+ }
58
+ }
59
+ let $c83ba9ab79386687$var$run_on_href_change;
60
+ let $c83ba9ab79386687$var$old_href = location.href;
61
+ function $c83ba9ab79386687$export$74f3924c5027fe1d(cb) {
62
+ $c83ba9ab79386687$var$run_on_href_change = cb;
63
+ }
64
+ (0, $2GFvs$instant_exec_on_suspect_history_change).add((0, $2GFvs$catchify)(() => {
65
+ const {
66
+ href: href
67
+ } = location;
68
+ if ($c83ba9ab79386687$var$run_on_href_change && $c83ba9ab79386687$var$old_href !== href) $c83ba9ab79386687$var$run_on_href_change(href);
69
+ $c83ba9ab79386687$var$old_href = href;
70
+ }));
71
+ const $c83ba9ab79386687$export$775e6b3892b5ad52 = (url = location) => url.pathname == (0, $2GFvs$untrack)((0, $42858f023ef23dab$export$8e769ad4338a911e).search_page_path_[0]); // might have changed therefore get it from globalState
72
+ const $c83ba9ab79386687$export$30c8a12df09be0e4 = (url = location) => (0, $42858f023ef23dab$export$8e769ad4338a911e).known_category_paths.has(url.pathname);
73
+ function $c83ba9ab79386687$export$f6e64e17bd69eeef({
74
+ solid_component: solid_component,
75
+ props: props,
76
+ wrapper_type = "div",
77
+ wrapper_style = {},
78
+ hydrate_function_when_ssr: hydrate_function_when_ssr
79
+ }) {
80
+ const [portals, set_portals] = (0, $2GFvs$useState)([]);
81
+ const wrapper_element_ref = (0, $2GFvs$useRef)();
82
+ const [[store, write_store]] = (0, $2GFvs$useState)(() => (0, $2GFvs$createStore)(props));
83
+ // Update store when props change
84
+ write_store((0, $2GFvs$reconcile)(props));
85
+ (0, $2GFvs$useEffect)(() => {
86
+ const wrapper_element = wrapper_element_ref.current;
87
+ // If someone only rendered a solid component on the client that *could* be hydrated (no childNodes) then we fall back to `render` to avoid solid complaining about not being able to hydrate or crashing because the result of generateHydrationScript hasn't run at all
88
+ // This can happen for HMR or when SSR capable components are only rendered on the client
89
+ const render_function = hydrate_function_when_ssr && wrapper_element.childNodes.length ? hydrate_function_when_ssr : (0, $2GFvs$render);
90
+ const dispose = render_function(() => solid_component(store, set_portals), wrapper_element);
91
+ return dispose;
92
+ }, []);
93
+ return (0, $2GFvs$createElement)((0, $2GFvs$Fragment), null, (0, $2GFvs$createElement)(wrapper_type, {
94
+ ref: wrapper_element_ref,
95
+ style: wrapper_style,
96
+ ...(hydrate_function_when_ssr ? {
97
+ // We need this because on the server we put the solid SSR rendered string into html but it won't match on the client, luckily we can just suppress it
98
+ suppressHydrationWarning: true,
99
+ dangerouslySetInnerHTML: {
100
+ __html: ""
101
+ }
102
+ } : {})
103
+ }), ...portals);
104
+ }
105
+ function $c83ba9ab79386687$export$e5139bbbb9a05035(component, is_set) {
106
+ return (...args) => {
107
+ const default_is_set = (0, $2GFvs$createMemo)(() => !!((0, $42858f023ef23dab$export$8e769ad4338a911e).merchant[0]() && (0, $42858f023ef23dab$export$8e769ad4338a911e).market[0]())); // Apparently Show re-renders kids otherwise even if the falsiness of the condition doesn't change
108
+ const should_show = (0, $2GFvs$createMemo)(prev => {
109
+ if (!prev && (0, $42858f023ef23dab$export$8e769ad4338a911e).provider_is_updating[0]())
110
+ // Why `!prev`? See https://gitlab.com/depict-ai/depict.ai/-/merge_requests/7854#note_1495776987
111
+ // If we weren't showing the component and the DepictProvider is currently updating, wait for it to have finished updating before showing the component
112
+ // Otherwise as soon as tenant and market is set we render the CategoryPage, but we might not have a DepictCategory yet, see https://depictaiworkspace.slack.com/archives/C04UZ2Z0RNE/p1690895918347289?thread_ts=1688391305.529449&cid=C04UZ2Z0RNE
113
+ return false;
114
+ return (is_set || default_is_set)();
115
+ });
116
+ // @ts-ignore
117
+ return (0, $2GFvs$createComponent)((0, $2GFvs$Show), {
118
+ get when() {
119
+ return should_show();
120
+ },
121
+ get children() {
122
+ return component(...args);
123
+ }
124
+ });
125
+ };
126
+ }
127
+ async function $c83ba9ab79386687$export$79c79419c1ef0081({
128
+ display: display,
129
+ component_portals: component_portals,
130
+ set_portals: set_portals,
131
+ react_template: react_template
132
+ }) {
133
+ let set_react_has_ran_hooks;
134
+ let was_cleaned_up = false;
135
+ const react_has_ran_hooks = new Promise(r => set_react_has_ran_hooks = r);
136
+ const solid_container = document.createElement("div");
137
+ const owner = (0, $2GFvs$getOwner)();
138
+ const reactProductCard = (0, $2GFvs$jsx)(props => {
139
+ // Sneak in a hook into their product card component to know once react has finished rendering and running hooks
140
+ (0, $2GFvs$useEffect)(set_react_has_ran_hooks, []);
141
+ return react_template(props);
142
+ }, {
143
+ display: display
144
+ });
145
+ const reactProductCardInErrorBoundary = (0, $2GFvs$jsx)((0, $d5c9e1f3545b4984$export$d0f82e3ef89b1f22), {
146
+ children: reactProductCard,
147
+ on_error: error => (0, $2GFvs$runWithOwner)(owner, () => {
148
+ if (was_cleaned_up) return; // Would infinite loop if we'd throw after we've already been cleaned up. That is because the `ErrorBoundary` won't be "registered" with the cleaned-up owner anymore so react would hear about the throw and attempt to re-render the error boundary or something which would throw again, etc.
149
+ throw new (0, $2GFvs$ProductCardError)(error);
150
+ })
151
+ });
152
+ const portal = $2GFvs$createPortal(reactProductCardInErrorBoundary, solid_container);
153
+ component_portals.add(portal);
154
+ set_portals([...component_portals]);
155
+ (0, $2GFvs$onCleanup)(() => {
156
+ was_cleaned_up = true;
157
+ // this will stop working after any await so be careful to not await before this, or you'll have to carry the owner over with getOwner and runWithOwner
158
+ component_portals.delete(portal);
159
+ // Updating i.e. the merchant will cause a setState call while rendering the DepictProvider component which is illegal because it usually infinite loops react apps. In our case it doesn't though, so we just evade detection by doing it a microtask later. See also https://github.com/facebook/react/issues/18178#issuecomment-595846312
160
+ queueMicrotask(() => set_portals([...component_portals]));
161
+ });
162
+ await react_has_ran_hooks; // After react has created elements it still takes some time to actually connect the refs and run the hooks. We don't want to replace placeholders before then.
163
+ return [solid_container];
164
+ }
165
+ let $8071251ee4e9ffa1$var$set = false;
166
+ let $8071251ee4e9ffa1$var$padding_animation;
167
+ function $8071251ee4e9ffa1$export$6453cbc34515a94d() {
168
+ const are_on_search_or_category_page = () => (0, $c83ba9ab79386687$export$775e6b3892b5ad52)() || (0, $c83ba9ab79386687$export$30c8a12df09be0e4)();
169
+ if ($8071251ee4e9ffa1$var$set) return; // Just being safe
170
+ $8071251ee4e9ffa1$var$set = true;
171
+ // We used to initialise this variable with false which in some cases (scroll to top button in FloatingButtons) would cause the scroll to be blocked when it shouldn't (see https://depictaiworkspace.slack.com/archives/C058KQ3MU8Z/p1686141321127089?thread_ts=1686134246.109689&cid=C058KQ3MU8Z)
172
+ // I don't know why we'd want to initialise it with false? The only reason I can see is in the hopes of scroll restoration working on initial page load, but it basically never does due to react rendering and executing our component too late
173
+ let should_use_old_scroll = true;
174
+ const old_scrollTo = window.scrollTo;
175
+ const next_router_event_target = $8071251ee4e9ffa1$var$make_next_router_event_target(); // So we can use once: true
176
+ window.scrollTo = (...args) => {
177
+ if (should_use_old_scroll || process.env.__NEXT_SCROLL_RESTORATION || !are_on_search_or_category_page() || history.scrollRestoration === "manual" // I.e. Chimi has manual scroll restoration that we don't want to block https://depictaiworkspace.slack.com/archives/C058KQ3MU8Z/p1686658007164019?thread_ts=1686134246.109689&cid=C058KQ3MU8Z
178
+ ) return Reflect.apply(old_scrollTo, window, args);else should_use_old_scroll = true;
179
+ };
180
+ // When popping state, add padding in the same event as the "popstate" event (required) and then remove it once our stuff is in the DOM
181
+ addEventListener("popstate", (0, $2GFvs$catchify)(() => {
182
+ if (!are_on_search_or_category_page()) {
183
+ $8071251ee4e9ffa1$var$removeLotsOfPadding(); // Just making sure
184
+ return;
185
+ }
186
+ should_use_old_scroll = false;
187
+ const [get_search_page_in_dom] = (0, $42858f023ef23dab$export$8e769ad4338a911e).search_page_in_dom;
188
+ const [get_category_page_in_dom] = (0, $42858f023ef23dab$export$8e769ad4338a911e).category_page_in_dom;
189
+ const search_page_in_dom = (0, $2GFvs$untrack)(get_search_page_in_dom);
190
+ const category_page_in_dom = (0, $2GFvs$untrack)(get_category_page_in_dom);
191
+ const new_is_search = (0, $c83ba9ab79386687$export$775e6b3892b5ad52)();
192
+ const new_is_category = (0, $c83ba9ab79386687$export$30c8a12df09be0e4)();
193
+ let accessor_to_wait_for;
194
+ if (search_page_in_dom && new_is_search || category_page_in_dom && new_is_category) {
195
+ // Already on the page we're going to
196
+ $8071251ee4e9ffa1$var$removeLotsOfPadding();
197
+ return;
198
+ }
199
+ $8071251ee4e9ffa1$var$addLotsOfPadding();
200
+ if (new_is_search && category_page_in_dom) accessor_to_wait_for = get_search_page_in_dom;else if (new_is_category && search_page_in_dom) accessor_to_wait_for = get_category_page_in_dom;else accessor_to_wait_for = new_is_search ? get_search_page_in_dom : get_category_page_in_dom;
201
+ (0, $2GFvs$createRoot)(dispose => (0, $2GFvs$createEffect)(() => {
202
+ if (accessor_to_wait_for()) {
203
+ $8071251ee4e9ffa1$var$removeLotsOfPadding();
204
+ dispose();
205
+ }
206
+ }));
207
+ }));
208
+ window?.next?.router?.events?.on(
209
+ // We have to use the actual next router here, if we'd use next_router_event_target for this window.event wouldn't be the popstate anymore
210
+ "routeChangeStart", (0, $2GFvs$catchify)(() => {
211
+ // this is for when we navigate to a new page (replaceState or pushState)
212
+ // We need to ensure that the page doesn't get shorter before the new history entry has been pushed
213
+ // There is beforeHistoryChange which fires literally the line of code before the history API is called, so we make the page long until a task after that
214
+ // The challenge is knowing on routeChangeStart if we're in a popstate (back/forward) or a pushState/replaceState
215
+ // We use the deprecated window.event property for that
216
+ // This is catchified, so we should see in sentry when it starts failing if browsers ever remove it???
217
+ if (window.event instanceof PopStateEvent) return;
218
+ $8071251ee4e9ffa1$var$addLotsOfPadding();
219
+ next_router_event_target.addEventListener("beforeHistoryChange", (0, $2GFvs$catchify)(() => (0, $2GFvs$queueMacroTask)($8071251ee4e9ffa1$var$removeLotsOfPadding)), {
220
+ once: true
221
+ });
222
+ }));
223
+ }
224
+ /*
225
+ Here we want to be able to add padding that *definitely* gets applied and then be able to revert precisely to what was before.
226
+ The best way to achieve this is using an animation that with the fill set to none. This is because animations have the absolute highest precedence in CSS, even higher than !important. Then, to revert to the old padding, we just play the animation which is 1ms long so, it immediately finishes and whatever was defined before takes precedence again.
227
+ */
228
+ function $8071251ee4e9ffa1$var$addLotsOfPadding() {
229
+ if ($8071251ee4e9ffa1$var$padding_animation) return; // We're already showing a bunch of padding
230
+ $8071251ee4e9ffa1$var$padding_animation = document.body.animate({
231
+ paddingBottom: (history.state?.search_scroll_restoration_data?.[0]?.min_results_loaded || 150) * 500 + "px",
232
+ offset: 0
233
+ }, 1);
234
+ $8071251ee4e9ffa1$var$padding_animation.pause();
235
+ }
236
+ function $8071251ee4e9ffa1$var$removeLotsOfPadding() {
237
+ if ($8071251ee4e9ffa1$var$padding_animation) {
238
+ $8071251ee4e9ffa1$var$padding_animation.play();
239
+ $8071251ee4e9ffa1$var$padding_animation = undefined;
240
+ }
241
+ }
242
+ function $8071251ee4e9ffa1$var$make_next_router_event_target() {
243
+ const next_router_event_target = new EventTarget();
244
+ window?.next?.router?.events?.on("beforeHistoryChange", () => next_router_event_target.dispatchEvent(new CustomEvent("beforeHistoryChange")));
245
+ return next_router_event_target;
246
+ }
247
+ const $7216ca4c8308a0f9$export$599d4515591ef232 = (relativeUrl, isReplace, scroll) => {
248
+ let Page;
249
+ (function (Page) {
250
+ Page[Page["OTHER"] = 0] = "OTHER";
251
+ Page[Page["SEARCH"] = 1] = "SEARCH";
252
+ Page[Page["CATEGORY"] = 2] = "CATEGORY";
253
+ })(Page || (Page = {}));
254
+ const current_page = (0, $c83ba9ab79386687$export$775e6b3892b5ad52)() ? Page.SEARCH : (0, $c83ba9ab79386687$export$30c8a12df09be0e4)() ? Page.CATEGORY : Page.OTHER;
255
+ const target_u_o = new URL(relativeUrl, location.origin);
256
+ const target_page = (0, $c83ba9ab79386687$export$775e6b3892b5ad52)(target_u_o) ? Page.SEARCH : (0, $c83ba9ab79386687$export$30c8a12df09be0e4)(target_u_o) ? Page.CATEGORY : Page.OTHER;
257
+ window.next.router[isReplace ? "replace" : "push"](relativeUrl, undefined, {
258
+ shallow: current_page === target_page && target_page !== Page.OTHER,
259
+ scroll:
260
+ // Can't go shallowly to other pages
261
+ scroll
262
+ });
263
+ };
264
+ const $a00d8f27abd5d0b0$export$38b98fae14bd1f64 = () => {
265
+ if (!(0, $42858f023ef23dab$export$8e769ad4338a911e).dpc) throw new Error("Depict tracking is not configured. Wrap your app in a DepictProvider.");
266
+ return {
267
+ dpc: (0, $42858f023ef23dab$export$8e769ad4338a911e).dpc
268
+ };
269
+ };
270
+ const $a00d8f27abd5d0b0$export$47e064413edabf36 = (merchant, market, userId, sessionId) => {
271
+ if (!merchant) return;
272
+ try {
273
+ let {
274
+ dpc: dpc
275
+ } = (0, $42858f023ef23dab$export$8e769ad4338a911e);
276
+ if (!dpc) dpc = (0, $42858f023ef23dab$export$8e769ad4338a911e).dpc = new (0, $2GFvs$DPC)(merchant, {
277
+ market: market
278
+ });
279
+ dpc.merchant = merchant;
280
+ dpc.market = market;
281
+ dpc.setUserId(userId);
282
+ dpc.setSessionId(sessionId);
283
+ } catch (e) {
284
+ // Make sure to not break the users app if we throw
285
+ queueMicrotask(() => {
286
+ throw e;
287
+ });
288
+ }
289
+ };
290
+ function $80202ccbe2ade418$export$bae2769a30719c48(disposable, stateKey) {
291
+ const actual_function = dispose => {
292
+ const {
293
+ usedLocale: [get_locale],
294
+ merchant: [get_merchant],
295
+ market: [get_market],
296
+ search_query_url_param_name: search_query_url_param_name,
297
+ search_page_path_: [get_search_page_path],
298
+ enable_content_search: [get_enable_content_search]
299
+ } = (0, $42858f023ef23dab$export$8e769ad4338a911e);
300
+ const instance = new (0, $2GFvs$DepictSearch)({
301
+ api: (0, $42858f023ef23dab$export$8e769ad4338a911e).api,
302
+ search_query_url_param_name: search_query_url_param_name,
303
+ market: (0, $2GFvs$untrack)(get_market),
304
+ // TODO: check if we can do this
305
+ merchant: (0, $2GFvs$untrack)(get_merchant),
306
+ enable_category_suggestions: (0, $42858f023ef23dab$export$8e769ad4338a911e).enableCategorySuggestions ?? false,
307
+ // default category suggestions to false for @depict-ai/react-ui (https://linear.app/depictai/issue/FRO-401/default-enablecategorysuggestions-to-false)
308
+ localization: (0, $2GFvs$untrack)(get_locale),
309
+ url_transformer: url => url.pathname = (0, $2GFvs$untrack)(get_search_page_path),
310
+ on_navigation: (0, $42858f023ef23dab$export$8e769ad4338a911e).on_navigation,
311
+ unique_instance_key_for_state: stateKey,
312
+ enable_content_search: (0, $2GFvs$untrack)(get_enable_content_search)
313
+ });
314
+ (0, $2GFvs$createComputed)(() => {
315
+ const new_merchant = get_merchant();
316
+ if (new_merchant) instance.merchant = new_merchant;
317
+ });
318
+ (0, $2GFvs$createComputed)(() => {
319
+ const new_market = get_market();
320
+ if (new_market) instance.market = new_market;
321
+ });
322
+ (0, $2GFvs$createComputed)(() => instance.localization = get_locale());
323
+ (0, $2GFvs$createComputed)(() => instance.enable_content_search = get_enable_content_search());
324
+ return {
325
+ instance: instance,
326
+ dispose: dispose,
327
+ users: 0
328
+ };
329
+ };
330
+ const function_length_0 = () => actual_function();
331
+ const function_length_1 = dispose => actual_function(dispose);
332
+ return (0, $2GFvs$createRoot)(disposable ? function_length_1 : function_length_0); // solid-js creates roots differently based on if it can detect a dispose argument, with function.length. That's why this is written like this
333
+ }
334
+
335
+ function $9145bcf81a0216ce$export$248b95d5073d5bab(disposable, stateKey) {
336
+ const actual_function = dispose => {
337
+ const {
338
+ usedLocale: [get_locale],
339
+ merchant: [get_merchant],
340
+ market: [get_market]
341
+ } = (0, $42858f023ef23dab$export$8e769ad4338a911e);
342
+ const instance = new (0, $2GFvs$DepictCategory)({
343
+ api: (0, $42858f023ef23dab$export$8e769ad4338a911e).api,
344
+ market: (0, $2GFvs$untrack)(get_market),
345
+ // TODO: check if we can do this
346
+ merchant: (0, $2GFvs$untrack)(get_merchant),
347
+ localization: (0, $2GFvs$untrack)(get_locale),
348
+ on_navigation: (0, $42858f023ef23dab$export$8e769ad4338a911e).on_navigation,
349
+ unique_instance_key_for_state: stateKey
350
+ });
351
+ (0, $2GFvs$createComputed)(() => {
352
+ const new_merchant = get_merchant();
353
+ if (new_merchant) instance.merchant = new_merchant;
354
+ });
355
+ (0, $2GFvs$createComputed)(() => {
356
+ const new_market = get_market();
357
+ if (new_market) instance.market = new_market;
358
+ });
359
+ (0, $2GFvs$createComputed)(() => instance.localization = get_locale());
360
+ return {
361
+ instance: instance,
362
+ dispose: dispose,
363
+ users: 0
364
+ };
365
+ };
366
+ const function_length_0 = () => actual_function();
367
+ const function_length_1 = dispose => actual_function(dispose);
368
+ return (0, $2GFvs$createRoot)(disposable ? function_length_1 : function_length_0); // solid-js creates roots differently based on if it can detect a dispose argument, with function.length. That's why this is written like this
369
+ }
370
+
371
+ let $5376eb2a386cd90d$var$provider_instances = 0;
372
+ function $5376eb2a386cd90d$export$9fac37a9c21c2f3b(props) {
373
+ (0, $42858f023ef23dab$export$8e769ad4338a911e).provider_is_updating[1](true);
374
+ try {
375
+ return $5376eb2a386cd90d$var$ActualDepictProvider(props);
376
+ } finally {
377
+ (0, $42858f023ef23dab$export$8e769ad4338a911e).provider_is_updating[1](false);
378
+ }
379
+ }
380
+ function $5376eb2a386cd90d$var$ActualDepictProvider(props) {
381
+ const {
382
+ children: children,
383
+ navigateFunction: navigateFunction,
384
+ market: market,
385
+ merchant: merchant,
386
+ locale: locale,
387
+ metaData: metaData,
388
+ userId: userId,
389
+ sessionId: sessionId
390
+ } = props;
391
+ const usedLocale = locale ?? (0, $2GFvs$defaultLocale);
392
+ const {
393
+ searchPagePath: searchPagePath,
394
+ urlParamName: urlParamName,
395
+ enableCategorySuggestions: enableCategorySuggestions,
396
+ enableContentSearch: enableContentSearch
397
+ } = props.search ?? {};
398
+ $5376eb2a386cd90d$var$multiple_depictprovider_guard();
399
+ // Will run on other prop changes, but harmless
400
+ (0, $42858f023ef23dab$export$8e769ad4338a911e).userId[1](userId);
401
+ (0, $42858f023ef23dab$export$8e769ad4338a911e).sessionId[1](sessionId);
402
+ (0, $42858f023ef23dab$export$8e769ad4338a911e).usedLocale[1](usedLocale);
403
+ (0, $42858f023ef23dab$export$8e769ad4338a911e).enable_content_search[1](enableContentSearch);
404
+ (0, $42858f023ef23dab$export$8e769ad4338a911e).metaData = metaData;
405
+ (0, $42858f023ef23dab$export$8e769ad4338a911e).search_query_url_param_name = urlParamName;
406
+ (0, $42858f023ef23dab$export$8e769ad4338a911e).enableCategorySuggestions = enableCategorySuggestions;
407
+ (0, $a00d8f27abd5d0b0$export$47e064413edabf36)(merchant, market, userId, sessionId);
408
+ if (!market || !merchant) return (0, $2GFvs$createElement)((0, $2GFvs$Fragment), null, children);
409
+ (0, $42858f023ef23dab$export$8e769ad4338a911e).market[1](market);
410
+ (0, $42858f023ef23dab$export$8e769ad4338a911e).merchant[1](merchant);
411
+ (0, $8071251ee4e9ffa1$export$6453cbc34515a94d)();
412
+ try {
413
+ const {
414
+ search_instances: search_instances,
415
+ category_instances: category_instances,
416
+ search_page_path_: [, set_search_page_path]
417
+ } = (0, $42858f023ef23dab$export$8e769ad4338a911e);
418
+ if (typeof window?.next?.router === "undefined" && !navigateFunction) throw new Error("You must provide a navigateFunction when not using Next.js.");
419
+ const on_navigation = ({
420
+ is_replace: is_replace,
421
+ new_url: new_url,
422
+ scroll: scroll
423
+ }) => {
424
+ const new_relative_url = new_url.origin === location.origin ? new_url.pathname + new_url.search + new_url.hash : new_url.href; // bail out of making URL relative if it's not possible
425
+ if (navigateFunction) navigateFunction(new_relative_url, {
426
+ replace: is_replace,
427
+ scroll: scroll
428
+ });else (0, $7216ca4c8308a0f9$export$599d4515591ef232)(new_relative_url, is_replace, scroll);
429
+ };
430
+ (0, $42858f023ef23dab$export$8e769ad4338a911e).on_navigation = on_navigation;
431
+ (0, $42858f023ef23dab$export$8e769ad4338a911e).api ||= new (0, $2GFvs$DepictAPI)({
432
+ get_metadata: async () => (0, $42858f023ef23dab$export$8e769ad4338a911e).metaData,
433
+ get_user_id: () => (0, $2GFvs$untrack)((0, $42858f023ef23dab$export$8e769ad4338a911e).userId[0]),
434
+ get_session_id: () => (0, $2GFvs$untrack)((0, $42858f023ef23dab$export$8e769ad4338a911e).sessionId[0])
435
+ });
436
+ (0, $42858f023ef23dab$export$8e769ad4338a911e).api.page_url_creator = props.pageURLCreator;
437
+ (0, $42858f023ef23dab$export$8e769ad4338a911e).api.display_transformers = props.displayTransformers;
438
+ if (searchPagePath) set_search_page_path($5376eb2a386cd90d$var$ensure_correct_formatting(searchPagePath));
439
+ if (!search_instances.get(undefined)) {
440
+ // Create initial search instance which always exists. It i.e. gards against the state getting deleted from history.state by someone pushing to it with an empty object, which commonly people copy from code snippets.
441
+ // Also, it emulates the behavior pre-supporting multiple "depict blocks" on the same page
442
+ const instance = (0, $80202ccbe2ade418$export$bae2769a30719c48)(false);
443
+ search_instances.set(undefined, instance);
444
+ }
445
+ if (!category_instances.get(undefined)) {
446
+ const instance = (0, $9145bcf81a0216ce$export$248b95d5073d5bab)(false);
447
+ category_instances.set(undefined, instance);
448
+ }
449
+ } catch (e) {
450
+ // Make sure to not break the users app if we throw
451
+ queueMicrotask(() => {
452
+ throw e;
453
+ });
454
+ }
455
+ return (0, $2GFvs$createElement)((0, $2GFvs$Fragment), null, children);
456
+ }
457
+ function $5376eb2a386cd90d$var$ensure_correct_formatting(path) {
458
+ // Make sure the path starts with a slash as it always will and is_page will fail otherwise
459
+ if (!path.startsWith("/")) return "/" + path;
460
+ return path;
461
+ }
462
+ function $5376eb2a386cd90d$var$multiple_depictprovider_guard() {
463
+ (0, $2GFvs$useEffect)(() => {
464
+ $5376eb2a386cd90d$var$provider_instances++;
465
+ if ($5376eb2a386cd90d$var$provider_instances > 1) throw new Error("You are using multiple DepictProviders. This is not supported and will lead to unexpected behavior. You can create multiple SearchPage and CategoryPage components, but only one DepictProvider.");
466
+ return () => {
467
+ $5376eb2a386cd90d$var$provider_instances--;
468
+ };
469
+ }, []);
470
+ }
471
+ const $421f32789b6f111f$export$80e99ee6b29cadd2 = /*#__PURE__*/(0, $2GFvs$forwardRef)((_, ref) => {
472
+ return /*#__PURE__*/(0, $2GFvs$createElement)("div", {
473
+ className: "depict aligner",
474
+ style: {
475
+ height: "100%"
476
+ },
477
+ ref: ref
478
+ });
479
+ });
480
+ function $99489374cd4f601d$export$f4d89133c6985668(type, stateKey, componentName) {
481
+ const instances = (0, $42858f023ef23dab$export$8e769ad4338a911e)[type + "_instances"];
482
+ if (!instances.get(undefined)) throw Error(`${componentName}: State not set up. Did you forget to wrap your app in DepictProvider? Also make sure you've provided a merchant and a market.`);
483
+ let instance = instances.get(stateKey);
484
+ if (!instance) {
485
+ instance = type === "search" ? (0, $80202ccbe2ade418$export$bae2769a30719c48)(true, stateKey) : (0, $9145bcf81a0216ce$export$248b95d5073d5bab)(true, stateKey);
486
+ instances.set(stateKey, instance);
487
+ }
488
+ instance.users++;
489
+ (0, $2GFvs$onCleanup)(() => {
490
+ instance.users--;
491
+ if (!instance.users && instance?.dispose) {
492
+ // main instance is not disposable, and shouldn't be deletable either
493
+ instance.dispose();
494
+ instances.delete(stateKey);
495
+ }
496
+ });
497
+ return instance.instance;
498
+ }
499
+ const $4a678f0c87b12e78$var$rendered_components_with_state_key = new Set();
500
+ function $4a678f0c87b12e78$export$a54ec244c8863715(props) {
501
+ return (0, $c83ba9ab79386687$export$f6e64e17bd69eeef)({
502
+ solid_component: (0, $c83ba9ab79386687$export$e5139bbbb9a05035)($4a678f0c87b12e78$var$SolidSearchPage),
503
+ props: props
504
+ });
505
+ }
506
+ function $4a678f0c87b12e78$var$SolidSearchPage(props, set_portals) {
507
+ const depict_search = (0, $2GFvs$createMemo)(() => {
508
+ const instance = (0, $99489374cd4f601d$export$f4d89133c6985668)("search", props.stateKey, "SearchPage");
509
+ (0, $2GFvs$onCleanup)(() => {
510
+ // Make sure we don't block the search query updating signal when we switch to a new provider instance
511
+ (0, $2GFvs$get_search_query_updating_blocked_signal)(instance)?.[1](false);
512
+ });
513
+ return instance;
514
+ });
515
+ const update_updating_blocked_signal = () => {
516
+ // if search instances changes, also re-check for good measure (otherwise would have untrack around depict_search)
517
+ const signal = (0, $2GFvs$get_search_query_updating_blocked_signal)(depict_search());
518
+ if (!signal) throw Error("No search_query_updating_blocked_signal when rendering SearchPage");
519
+ const [, write_signal] = signal;
520
+ // This causes a bug. To reproduce:
521
+ // 1. Go to front page
522
+ // 2. Make a search
523
+ // 3. Press back button
524
+ // 4. Open search modal
525
+ // 5. Check the list of previous queries - the query just made isn't shown
526
+ // This is because on the front page the search_query updating is blocked because it's not the search page, and that means that `filtered_previous_searches` in Autocomplete.tsx doesn't filter out the current search query
527
+ // Because it's so minor and would be quite hard to fix (one would need a second "actual search query" signal just for this purpose) it's wontfix for now
528
+ // EDIT: now that we're resetting this in the onCleanup of the memo above this might no longer be the case
529
+ write_signal(!(0, $c83ba9ab79386687$export$775e6b3892b5ad52)(location));
530
+ };
531
+ const [, set_search_page_in_dom] = (0, $42858f023ef23dab$export$8e769ad4338a911e).search_page_in_dom;
532
+ const component_portals = new Set();
533
+ // We should only get here once react already has a DOM node which means we should be in the DOM
534
+ set_search_page_in_dom(true);
535
+ (0, $2GFvs$onCleanup)(() => set_search_page_in_dom(false));
536
+ // react is really slow with disposing components, we want to avoid a flash of another search query when you click on a product and navigate away
537
+ (0, $c83ba9ab79386687$export$74f3924c5027fe1d)(update_updating_blocked_signal); // if we navigate, re-check
538
+ (0, $2GFvs$createComputed)(() => {
539
+ (0, $42858f023ef23dab$export$8e769ad4338a911e).search_page_path_[0](); // if react defined path changes, re-check
540
+ update_updating_blocked_signal();
541
+ });
542
+ $4a678f0c87b12e78$var$search_page_path_checker();
543
+ return (0, $2GFvs$createMemo)(() => {
544
+ const stateKey = (0, $2GFvs$untrack)(() => props.stateKey);
545
+ if ($4a678f0c87b12e78$var$rendered_components_with_state_key.has(stateKey)) throw new Error(`You have multiple SearchPage components with the same stateKey: ${stateKey}. Each SearchPage component must have a unique stateKey.`);
546
+ $4a678f0c87b12e78$var$rendered_components_with_state_key.add(stateKey);
547
+ (0, $2GFvs$onCleanup)(() => $4a678f0c87b12e78$var$rendered_components_with_state_key.delete(stateKey));
548
+ return (0, $2GFvs$SearchPage)({
549
+ // Default config goes here
550
+ get include_input_field() {
551
+ return props.includeInputField;
552
+ },
553
+ get cols_at_size() {
554
+ return props.columnsAtSize ?? (0, $2GFvs$defaultColsAtSize);
555
+ },
556
+ get grid_spacing() {
557
+ return props.gridSpacing ?? (0, $2GFvs$defaultGridSpacing);
558
+ },
559
+ depict_search: depict_search(),
560
+ product_card_template: display => (0, $c83ba9ab79386687$export$79c79419c1ef0081)({
561
+ display: display,
562
+ react_template: (0, $2GFvs$untrack)(() => props.productCard),
563
+ component_portals: component_portals,
564
+ set_portals: set_portals
565
+ })
566
+ });
567
+ });
568
+ }
569
+ /**
570
+ * Users often set the searchPagePath to something without the market which breaks everything using the searchPagePath internally, notably refining the search query. Add a warning for them.
571
+ */
572
+ function $4a678f0c87b12e78$var$search_page_path_checker() {
573
+ let has_warned = false;
574
+ (0, $2GFvs$createEffect)(() => {
575
+ if (has_warned) return;
576
+ const should_be_path = (0, $42858f023ef23dab$export$8e769ad4338a911e).search_page_path_[0]();
577
+ const {
578
+ pathname: pathname
579
+ } = location;
580
+ if (
581
+ // allow some variability just to be sure
582
+ should_be_path !== pathname && should_be_path + "/" !== pathname && should_be_path !== pathname + "/") {
583
+ (0, $2GFvs$derror)("searchPagePath is set to", should_be_path, "but the SearchPage is rendered at", pathname, ". Please double-check your searchPagePath is where the SearchPage component ends up being rendered, after all redirects, unless you're sure this is intentional.");
584
+ has_warned = true;
585
+ }
586
+ });
587
+ }
588
+ const $48d7f568740a317d$var$rendered_components_with_state_key = new Set();
589
+ function $48d7f568740a317d$export$f7d2f673fc2f091d(props) {
590
+ return (0, $c83ba9ab79386687$export$f6e64e17bd69eeef)({
591
+ // @ts-ignore
592
+ solid_component: (0, $c83ba9ab79386687$export$e5139bbbb9a05035)($48d7f568740a317d$var$SolidCategoryPage),
593
+ props: props,
594
+ wrapper_type: "div",
595
+ wrapper_style: {}
596
+ });
597
+ }
598
+ function $48d7f568740a317d$var$SolidCategoryPage(props, set_portals) {
599
+ const depict_category = (0, $2GFvs$createMemo)(() => (0, $99489374cd4f601d$export$f4d89133c6985668)("category", props.stateKey, "CategoryPage") // stateKey can change
600
+ );
601
+
602
+ const [category_state_set, set_category_state_set] = (0, $2GFvs$createSignal)(false);
603
+ const component_portals = new Set();
604
+ const [, set_category_page_in_dom] = (0, $42858f023ef23dab$export$8e769ad4338a911e).category_page_in_dom;
605
+ // We should only get here once react already has a DOM node which means we should be in the DOM
606
+ set_category_page_in_dom(true);
607
+ (0, $2GFvs$onCleanup)(() => set_category_page_in_dom(false));
608
+ (0, $2GFvs$createComputed)(() => {
609
+ const {
610
+ categoryId: categoryId
611
+ } = props;
612
+ depict_category().category_id = categoryId;
613
+ if (categoryId) {
614
+ set_category_state_set(true);
615
+ (0, $42858f023ef23dab$export$8e769ad4338a911e).known_category_paths.add(location.pathname);
616
+ }
617
+ });
618
+ (0, $2GFvs$createComputed)(() => depict_category().listing_type = props.listingType);
619
+ const category = () => (0, $2GFvs$createMemo)(() => {
620
+ const stateKey = (0, $2GFvs$untrack)(() => props.stateKey);
621
+ if ($48d7f568740a317d$var$rendered_components_with_state_key.has(stateKey)) throw new Error(`You have multiple CategoryPage components with the same stateKey: ${stateKey}. Each CategoryPage component must have a unique stateKey.`);
622
+ $48d7f568740a317d$var$rendered_components_with_state_key.add(stateKey);
623
+ (0, $2GFvs$onCleanup)(() => $48d7f568740a317d$var$rendered_components_with_state_key.delete(stateKey));
624
+ return (0, $2GFvs$CategoryPage)({
625
+ depict_category: depict_category(),
626
+ get cols_at_size() {
627
+ return props.columnsAtSize ?? (0, $2GFvs$defaultColsAtSize);
628
+ },
629
+ get grid_spacing() {
630
+ return props.gridSpacing ?? (0, $2GFvs$defaultGridSpacing);
631
+ },
632
+ category_title: (0, $2GFvs$untrack)(() => props.categoryTitlePlugin) || (0, $2GFvs$defaultCategoryTitlePlugin),
633
+ get show_breadcrumbs() {
634
+ return props.showBreadcrumbs;
635
+ },
636
+ get show_quicklinks() {
637
+ return props.showQuicklinks;
638
+ },
639
+ product_card_template: display => (0, $c83ba9ab79386687$export$79c79419c1ef0081)({
640
+ display: display,
641
+ react_template: (0, $2GFvs$untrack)(() => props.productCard),
642
+ component_portals: component_portals,
643
+ set_portals: set_portals
644
+ })
645
+ });
646
+ });
647
+ return (0, $c83ba9ab79386687$export$e5139bbbb9a05035)(category, category_state_set);
648
+ }
649
+ function $f866f7ed9f751af4$export$5646050d516e06bc(react_props) {
650
+ return (0, $c83ba9ab79386687$export$f6e64e17bd69eeef)({
651
+ solid_component: (0, $c83ba9ab79386687$export$e5139bbbb9a05035)($f866f7ed9f751af4$var$vanilla_breadcrumbs),
652
+ props: react_props
653
+ });
654
+ }
655
+ function $f866f7ed9f751af4$var$vanilla_breadcrumbs(props) {
656
+ // memo so stateKey can be dynamically changed
657
+ return (0, $2GFvs$createMemo)(() => {
658
+ const depict_category = (0, $99489374cd4f601d$export$f4d89133c6985668)("category", props.stateKey, "BreadCrumbs");
659
+ return (0, $2GFvs$BreadCrumbs)({
660
+ depict_category: depict_category
661
+ });
662
+ });
663
+ }
664
+ function $b68a14248b7ef667$export$466cdc317043f6cb(react_props = {}) {
665
+ return (0, $c83ba9ab79386687$export$f6e64e17bd69eeef)({
666
+ solid_component: (0, $c83ba9ab79386687$export$e5139bbbb9a05035)($b68a14248b7ef667$var$vanilla_quick_links),
667
+ props: react_props
668
+ });
669
+ }
670
+ function $b68a14248b7ef667$var$vanilla_quick_links(props) {
671
+ // memo so stateKey can be dynamically changed
672
+ return (0, $2GFvs$createMemo)(() => {
673
+ const depict_category = (0, $99489374cd4f601d$export$f4d89133c6985668)("category", props.stateKey, "QuickLinks");
674
+ return (0, $2GFvs$QuickLinks)({
675
+ depict_category: depict_category
676
+ });
677
+ });
678
+ }
679
+ const $f446a84f85ba06f6$export$3f37af283f8fb843 = raw_react_props => {
680
+ const react_props = {
681
+ class: raw_react_props.className,
682
+ ...raw_react_props
683
+ };
684
+ return (0, $c83ba9ab79386687$export$f6e64e17bd69eeef)({
685
+ solid_component: props_store => (0, $2GFvs$ImagePlaceholder)(props_store),
686
+ props: react_props,
687
+ wrapper_type: "span",
688
+ hydrate_function_when_ssr: (0, $2GFvs$hydrate)
689
+ });
690
+ };
691
+ const $cbd250061abf11cb$export$89c6019e4baa40b1 = raw_react_props => {
692
+ const react_props = {
693
+ class: raw_react_props.className,
694
+ ...raw_react_props
695
+ };
696
+ return (0, $c83ba9ab79386687$export$f6e64e17bd69eeef)({
697
+ solid_component: props_store => (0, $2GFvs$TextPlaceholder)(props_store),
698
+ props: react_props,
699
+ wrapper_type: "span",
700
+ hydrate_function_when_ssr: (0, $2GFvs$hydrate),
701
+ wrapper_style: {
702
+ "height": "100%"
703
+ }
704
+ });
705
+ };
706
+ const $41cab674edff4277$export$d69d8daa20eae175 = createOpenModalParams => {
707
+ const {
708
+ location = "centered",
709
+ alignerRef: alignerRef,
710
+ stateKey: stateKey
711
+ } = createOpenModalParams;
712
+ let [deduped_variable, set_deduped_variable] = (0, $2GFvs$useState)();
713
+ // When component using this hook unmounts, "untrack" our component and dispose the search instance if needed
714
+ (0, $2GFvs$useEffect)(() => deduped_variable?.[1]?.(), []);
715
+ const openModal = () => {
716
+ // Get the search instance and track this component, but only once (basically work around re-rendering)
717
+ // We have to do this in the openModal function since people might call this hook before creating DepictProvider
718
+ if (!deduped_variable) {
719
+ deduped_variable = (0, $2GFvs$createRoot)(dispose => [(0, $99489374cd4f601d$export$f4d89133c6985668)("search", stateKey, "useSearchModal"), dispose]);
720
+ set_deduped_variable(deduped_variable);
721
+ }
722
+ const [search] = deduped_variable;
723
+ if (location === "aligned" && alignerRef?.current) (0, $2GFvs$open_modal_with_alignment)({
724
+ "element": alignerRef.current,
725
+ "location": location,
726
+ "search": search
727
+ });else (0, $2GFvs$open_modal_with_alignment)({
728
+ "location": "centered",
729
+ "search": search
730
+ });
731
+ };
732
+ return openModal;
733
+ };
734
+ function $70344e5e0d0fea06$export$912994940e660d32(params = {}) {
735
+ const open = (0, $41cab674edff4277$export$d69d8daa20eae175)({
736
+ globalState: $42858f023ef23dab$export$8e769ad4338a911e,
737
+ ...params
738
+ });
739
+ return {
740
+ open: open
741
+ };
742
+ }
743
+ const $2b886cf548a4775c$export$9bb30bbe003b82e0 = (props = {}) => {
744
+ // We should just export a plain SearchField component here, not a weird hook thing, but I don't want to make a breaking change. Just fixing the re-rendering issue for now.
745
+ // Create signal that persists across renders
746
+ const [[get_aligner_signal_value, set_aligner_signal_value]] = (0, $2GFvs$useState)((0, $2GFvs$createSignal)());
747
+ // Update signal value when alignerRef changes
748
+ set_aligner_signal_value(props?.alignerRef);
749
+ // Make sure react never re-renders the actual SearchField component
750
+ const componentFunction = (0, $2GFvs$useCallback)(() => (0, $c83ba9ab79386687$export$f6e64e17bd69eeef)({
751
+ solid_component: (0, $c83ba9ab79386687$export$e5139bbbb9a05035)(() => {
752
+ return (0, $2GFvs$createMemo)(() => {
753
+ const depict_search = (0, $99489374cd4f601d$export$f4d89133c6985668)("search", props.stateKey, "useSearchField");
754
+ return (0, $2GFvs$SearchField)({
755
+ depict_search: depict_search,
756
+ get aligner_ref() {
757
+ // React mutates the object at some random time so only get the current value once it actually is requested
758
+ return get_aligner_signal_value()?.current;
759
+ }
760
+ });
761
+ });
762
+ }),
763
+ props: {}
764
+ }), []);
765
+ return {
766
+ SearchField: componentFunction
767
+ };
768
+ };
769
+ function $1bb4271dc44722e2$export$6501da23a2770fc() {
770
+ return {
771
+ fetchRecommendations: $1bb4271dc44722e2$var$fetchRecommendations
772
+ };
773
+ }
774
+ function $1bb4271dc44722e2$var$fetchRecommendations(opts) {
775
+ const {
776
+ merchant: [get_merchant],
777
+ market: [get_market],
778
+ userId: [get_userId],
779
+ sessionId: [get_sessionId]
780
+ } = (0, $42858f023ef23dab$export$8e769ad4338a911e);
781
+ const merchant = (0, $2GFvs$untrack)(get_merchant);
782
+ const market = (0, $2GFvs$untrack)(get_market);
783
+ if (!merchant || !market) throw new Error("Depict recommendations are not configured. Wrap your app in a DepictProvider.");
784
+ return (0, $2GFvs$fetchDepictRecommendations)({
785
+ merchant: merchant,
786
+ market: market,
787
+ userId: (0, $2GFvs$untrack)(get_userId),
788
+ sessionId: (0, $2GFvs$untrack)(get_sessionId),
789
+ ...opts
790
+ });
791
+ }
792
+ const $a92aa2beb560b8af$export$804fac5697cfbe35 = router => (relativeUrl, {
793
+ scroll: scroll,
794
+ replace: replace
795
+ }) => {
796
+ let Page;
797
+ (function (Page) {
798
+ Page[Page["OTHER"] = 0] = "OTHER";
799
+ Page[Page["SEARCH"] = 1] = "SEARCH";
800
+ Page[Page["CATEGORY"] = 2] = "CATEGORY";
801
+ })(Page || (Page = {}));
802
+ const current_page = (0, $c83ba9ab79386687$export$775e6b3892b5ad52)() ? Page.SEARCH : (0, $c83ba9ab79386687$export$30c8a12df09be0e4)() ? Page.CATEGORY : Page.OTHER;
803
+ const target_u_o = new URL(relativeUrl, location.origin);
804
+ const target_page = (0, $c83ba9ab79386687$export$775e6b3892b5ad52)(target_u_o) ? Page.SEARCH : (0, $c83ba9ab79386687$export$30c8a12df09be0e4)(target_u_o) ? Page.CATEGORY : Page.OTHER;
805
+ router[replace ? "replace" : "push"](relativeUrl, undefined, {
806
+ shallow: current_page === target_page && target_page !== Page.OTHER,
807
+ scroll:
808
+ // Can't go shallowly to other pages
809
+ scroll
810
+ });
811
+ };
812
+ const $97603d19204ec48d$export$b8a61e5c71402559 = {
813
+ nextRouterNavigation: $a92aa2beb560b8af$export$804fac5697cfbe35
814
+ };
815
+ (0, $2GFvs$add_to_version_info)("react-ui", (0, $c9c4d066f9a5b51b$export$83d89fbfd8236492));
816
+ export { $b68a14248b7ef667$export$466cdc317043f6cb as QuickLinks, $f866f7ed9f751af4$export$5646050d516e06bc as BreadCrumbs, $421f32789b6f111f$export$80e99ee6b29cadd2 as ComponentAligner, $5376eb2a386cd90d$export$9fac37a9c21c2f3b as DepictProvider, $48d7f568740a317d$export$f7d2f673fc2f091d as CategoryPage, $4a678f0c87b12e78$export$a54ec244c8863715 as SearchPage, $f446a84f85ba06f6$export$3f37af283f8fb843 as ImagePlaceholder, $cbd250061abf11cb$export$89c6019e4baa40b1 as TextPlaceholder, $70344e5e0d0fea06$export$912994940e660d32 as useSearchModal, $2b886cf548a4775c$export$9bb30bbe003b82e0 as useSearchField, $1bb4271dc44722e2$export$6501da23a2770fc as useFetchRecommendations, $a00d8f27abd5d0b0$export$38b98fae14bd1f64 as usePerformanceClient, $43099132aad1ceb6$re_export$CategoryTitle as CategoryTitle, $43099132aad1ceb6$re_export$EmbeddedNumProducts as EmbeddedNumProducts, $c9c4d066f9a5b51b$export$83d89fbfd8236492 as version, $97603d19204ec48d$export$b8a61e5c71402559 as Navigation };