@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.
package/ES10/index.js ADDED
@@ -0,0 +1,849 @@
1
+ import { add_to_version_info as $jb2Oo$add_to_version_info, catchify as $jb2Oo$catchify, queueMacroTask as $jb2Oo$queueMacroTask, instant_exec_on_suspect_history_change as $jb2Oo$instant_exec_on_suspect_history_change, derror as $jb2Oo$derror } from "@depict-ai/utilishared/ES10";
2
+ import { CategoryTitle as $383b6fd56bf151bd$re_export$CategoryTitle, embedded_num_products as $383b6fd56bf151bd$re_export$EmbeddedNumProducts, DepictAPI as $jb2Oo$DepictAPI, ProductCardError as $jb2Oo$ProductCardError, DepictSearch as $jb2Oo$DepictSearch, DepictCategory as $jb2Oo$DepictCategory, get_search_query_updating_blocked_signal as $jb2Oo$get_search_query_updating_blocked_signal, SearchPage as $jb2Oo$SearchPage, defaultColsAtSize as $jb2Oo$defaultColsAtSize, defaultGridSpacing as $jb2Oo$defaultGridSpacing, CategoryPage as $jb2Oo$CategoryPage, defaultCategoryTitlePlugin as $jb2Oo$defaultCategoryTitlePlugin, BreadCrumbs as $jb2Oo$BreadCrumbs, QuickLinks as $jb2Oo$QuickLinks, ImagePlaceholder as $jb2Oo$ImagePlaceholder, TextPlaceholder as $jb2Oo$TextPlaceholder, open_modal_with_alignment as $jb2Oo$open_modal_with_alignment, SearchField as $jb2Oo$SearchField, fetchDepictRecommendations as $jb2Oo$fetchDepictRecommendations } from "@depict-ai/ui/ES10";
3
+ import { untrack as $jb2Oo$untrack, createRoot as $jb2Oo$createRoot, createEffect as $jb2Oo$createEffect, createMemo as $jb2Oo$createMemo, createComponent as $jb2Oo$createComponent, Show as $jb2Oo$Show, getOwner as $jb2Oo$getOwner, runWithOwner as $jb2Oo$runWithOwner, onCleanup as $jb2Oo$onCleanup, createSignal as $jb2Oo$createSignal, createComputed as $jb2Oo$createComputed } from "solid-js";
4
+ import { createElement as $jb2Oo$createElement, Fragment as $jb2Oo$Fragment, useEffect as $jb2Oo$useEffect, useState as $jb2Oo$useState, useRef as $jb2Oo$useRef, Component as $jb2Oo$Component, forwardRef as $jb2Oo$forwardRef, useCallback as $jb2Oo$useCallback } from "react";
5
+ import { defaultLocale as $jb2Oo$defaultLocale } from "@depict-ai/ui/locales/ES10";
6
+ import { render as $jb2Oo$render, hydrate as $jb2Oo$hydrate } from "solid-js/web";
7
+ import { jsx as $jb2Oo$jsx } from "react/jsx-runtime";
8
+ import { createPortal as $jb2Oo$createPortal } from "react-dom";
9
+ import { createStore as $jb2Oo$createStore, reconcile as $jb2Oo$reconcile } from "solid-js/store";
10
+ import { DPC as $jb2Oo$DPC } from "@depict-ai/dpc/ES10";
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", "ES10");
16
+ const $9bd9bb8700ab2ada$export$83d89fbfd8236492 = "1.5.5";
17
+ const $8c691d7f86317052$export$8e769ad4338a911e = {
18
+ usedLocale: (0, $jb2Oo$createSignal)((0, $jb2Oo$defaultLocale)),
19
+ search_instances: new Map(),
20
+ category_instances: new Map(),
21
+ api: null,
22
+ dpc: null,
23
+ merchant: (0, $jb2Oo$createSignal)(),
24
+ market: (0, $jb2Oo$createSignal)(),
25
+ userId: (0, $jb2Oo$createSignal)(),
26
+ sessionId: (0, $jb2Oo$createSignal)(),
27
+ known_category_paths: new Set(),
28
+ search_page_path_: (0, $jb2Oo$createSignal)(),
29
+ search_page_in_dom: (0, $jb2Oo$createSignal)(false),
30
+ category_page_in_dom: (0, $jb2Oo$createSignal)(false),
31
+ provider_is_updating: (0, $jb2Oo$createSignal)(false),
32
+ enable_content_search: (0, $jb2Oo$createSignal)()
33
+ };
34
+ class $88d93ed7309e90d1$export$d0f82e3ef89b1f22 extends (0, $jb2Oo$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, $jb2Oo$createElement)("div", {
54
+ children: "Component failed"
55
+ });
56
+ return this.props.children;
57
+ }
58
+ }
59
+ let $0dd9d9a9c7da4c1d$var$run_on_href_change;
60
+ let $0dd9d9a9c7da4c1d$var$old_href = location.href;
61
+ function $0dd9d9a9c7da4c1d$export$74f3924c5027fe1d(cb) {
62
+ $0dd9d9a9c7da4c1d$var$run_on_href_change = cb;
63
+ }
64
+ (0, $jb2Oo$instant_exec_on_suspect_history_change).add((0, $jb2Oo$catchify)(() => {
65
+ const {
66
+ href: href
67
+ } = location;
68
+ if ($0dd9d9a9c7da4c1d$var$run_on_href_change && $0dd9d9a9c7da4c1d$var$old_href !== href) $0dd9d9a9c7da4c1d$var$run_on_href_change(href);
69
+ $0dd9d9a9c7da4c1d$var$old_href = href;
70
+ }));
71
+ const $0dd9d9a9c7da4c1d$export$775e6b3892b5ad52 = function () {
72
+ let url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : location;
73
+ return url.pathname == (0, $jb2Oo$untrack)((0, $8c691d7f86317052$export$8e769ad4338a911e).search_page_path_[0]);
74
+ }; // might have changed therefore get it from globalState
75
+ const $0dd9d9a9c7da4c1d$export$30c8a12df09be0e4 = function () {
76
+ let url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : location;
77
+ return (0, $8c691d7f86317052$export$8e769ad4338a911e).known_category_paths.has(url.pathname);
78
+ };
79
+ function $0dd9d9a9c7da4c1d$export$f6e64e17bd69eeef(_ref) {
80
+ let {
81
+ solid_component: solid_component,
82
+ props: props,
83
+ wrapper_type = "div",
84
+ wrapper_style = {},
85
+ hydrate_function_when_ssr: hydrate_function_when_ssr
86
+ } = _ref;
87
+ const [portals, set_portals] = (0, $jb2Oo$useState)([]);
88
+ const wrapper_element_ref = (0, $jb2Oo$useRef)();
89
+ const [[store, write_store]] = (0, $jb2Oo$useState)(() => (0, $jb2Oo$createStore)(props));
90
+ // Update store when props change
91
+ write_store((0, $jb2Oo$reconcile)(props));
92
+ (0, $jb2Oo$useEffect)(() => {
93
+ const wrapper_element = wrapper_element_ref.current;
94
+ // 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
95
+ // This can happen for HMR or when SSR capable components are only rendered on the client
96
+ const render_function = hydrate_function_when_ssr && wrapper_element.childNodes.length ? hydrate_function_when_ssr : (0, $jb2Oo$render);
97
+ const dispose = render_function(() => solid_component(store, set_portals), wrapper_element);
98
+ return dispose;
99
+ }, []);
100
+ return (0, $jb2Oo$createElement)((0, $jb2Oo$Fragment), null, (0, $jb2Oo$createElement)(wrapper_type, {
101
+ ref: wrapper_element_ref,
102
+ style: wrapper_style,
103
+ ...(hydrate_function_when_ssr ? {
104
+ // 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
105
+ suppressHydrationWarning: true,
106
+ dangerouslySetInnerHTML: {
107
+ __html: ""
108
+ }
109
+ } : {})
110
+ }), ...portals);
111
+ }
112
+ function $0dd9d9a9c7da4c1d$export$e5139bbbb9a05035(component, is_set) {
113
+ return function () {
114
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
115
+ const default_is_set = (0, $jb2Oo$createMemo)(() => !!((0, $8c691d7f86317052$export$8e769ad4338a911e).merchant[0]() && (0, $8c691d7f86317052$export$8e769ad4338a911e).market[0]())); // Apparently Show re-renders kids otherwise even if the falsiness of the condition doesn't change
116
+ const should_show = (0, $jb2Oo$createMemo)(prev => {
117
+ if (!prev && (0, $8c691d7f86317052$export$8e769ad4338a911e).provider_is_updating[0]())
118
+ // Why `!prev`? See https://gitlab.com/depict-ai/depict.ai/-/merge_requests/7854#note_1495776987
119
+ // If we weren't showing the component and the DepictProvider is currently updating, wait for it to have finished updating before showing the component
120
+ // 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
121
+ return false;
122
+ return (is_set || default_is_set)();
123
+ });
124
+ // @ts-ignore
125
+ return (0, $jb2Oo$createComponent)((0, $jb2Oo$Show), {
126
+ get when() {
127
+ return should_show();
128
+ },
129
+ get children() {
130
+ return component(...args);
131
+ }
132
+ });
133
+ };
134
+ }
135
+ async function $0dd9d9a9c7da4c1d$export$79c79419c1ef0081(_ref2) {
136
+ let {
137
+ display: display,
138
+ component_portals: component_portals,
139
+ set_portals: set_portals,
140
+ react_template: react_template
141
+ } = _ref2;
142
+ let set_react_has_ran_hooks;
143
+ let was_cleaned_up = false;
144
+ const react_has_ran_hooks = new Promise(r => set_react_has_ran_hooks = r);
145
+ const solid_container = document.createElement("div");
146
+ const owner = (0, $jb2Oo$getOwner)();
147
+ const reactProductCard = (0, $jb2Oo$jsx)(props => {
148
+ // Sneak in a hook into their product card component to know once react has finished rendering and running hooks
149
+ (0, $jb2Oo$useEffect)(set_react_has_ran_hooks, []);
150
+ return react_template(props);
151
+ }, {
152
+ display: display
153
+ });
154
+ const reactProductCardInErrorBoundary = (0, $jb2Oo$jsx)((0, $88d93ed7309e90d1$export$d0f82e3ef89b1f22), {
155
+ children: reactProductCard,
156
+ on_error: error => (0, $jb2Oo$runWithOwner)(owner, () => {
157
+ 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.
158
+ throw new (0, $jb2Oo$ProductCardError)(error);
159
+ })
160
+ });
161
+ const portal = $jb2Oo$createPortal(reactProductCardInErrorBoundary, solid_container);
162
+ component_portals.add(portal);
163
+ set_portals([...component_portals]);
164
+ (0, $jb2Oo$onCleanup)(() => {
165
+ was_cleaned_up = true;
166
+ // 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
167
+ component_portals.delete(portal);
168
+ // 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
169
+ queueMicrotask(() => set_portals([...component_portals]));
170
+ });
171
+ 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.
172
+ return [solid_container];
173
+ }
174
+ let $64144f6d578fd8ac$var$set = false;
175
+ let $64144f6d578fd8ac$var$padding_animation;
176
+ function $64144f6d578fd8ac$export$6453cbc34515a94d() {
177
+ var _window, _window$next, _window$next$router, _window$next$router$e;
178
+ const are_on_search_or_category_page = () => (0, $0dd9d9a9c7da4c1d$export$775e6b3892b5ad52)() || (0, $0dd9d9a9c7da4c1d$export$30c8a12df09be0e4)();
179
+ if ($64144f6d578fd8ac$var$set) return; // Just being safe
180
+ $64144f6d578fd8ac$var$set = true;
181
+ // 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)
182
+ // 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
183
+ let should_use_old_scroll = true;
184
+ const old_scrollTo = window.scrollTo;
185
+ const next_router_event_target = $64144f6d578fd8ac$var$make_next_router_event_target(); // So we can use once: true
186
+ window.scrollTo = function () {
187
+ 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
188
+ ) {
189
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
190
+ return Reflect.apply(old_scrollTo, window, args);
191
+ } else should_use_old_scroll = true;
192
+ };
193
+ // 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
194
+ addEventListener("popstate", (0, $jb2Oo$catchify)(() => {
195
+ if (!are_on_search_or_category_page()) {
196
+ $64144f6d578fd8ac$var$removeLotsOfPadding(); // Just making sure
197
+ return;
198
+ }
199
+ should_use_old_scroll = false;
200
+ const [get_search_page_in_dom] = (0, $8c691d7f86317052$export$8e769ad4338a911e).search_page_in_dom;
201
+ const [get_category_page_in_dom] = (0, $8c691d7f86317052$export$8e769ad4338a911e).category_page_in_dom;
202
+ const search_page_in_dom = (0, $jb2Oo$untrack)(get_search_page_in_dom);
203
+ const category_page_in_dom = (0, $jb2Oo$untrack)(get_category_page_in_dom);
204
+ const new_is_search = (0, $0dd9d9a9c7da4c1d$export$775e6b3892b5ad52)();
205
+ const new_is_category = (0, $0dd9d9a9c7da4c1d$export$30c8a12df09be0e4)();
206
+ let accessor_to_wait_for;
207
+ if (search_page_in_dom && new_is_search || category_page_in_dom && new_is_category) {
208
+ // Already on the page we're going to
209
+ $64144f6d578fd8ac$var$removeLotsOfPadding();
210
+ return;
211
+ }
212
+ $64144f6d578fd8ac$var$addLotsOfPadding();
213
+ 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;
214
+ (0, $jb2Oo$createRoot)(dispose => (0, $jb2Oo$createEffect)(() => {
215
+ if (accessor_to_wait_for()) {
216
+ $64144f6d578fd8ac$var$removeLotsOfPadding();
217
+ dispose();
218
+ }
219
+ }));
220
+ }));
221
+ (_window = window) === null || _window === void 0 || (_window$next = _window.next) === null || _window$next === void 0 || (_window$next$router = _window$next.router) === null || _window$next$router === void 0 || (_window$next$router$e = _window$next$router.events) === null || _window$next$router$e === void 0 || _window$next$router$e.on(
222
+ // 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
223
+ "routeChangeStart", (0, $jb2Oo$catchify)(() => {
224
+ // this is for when we navigate to a new page (replaceState or pushState)
225
+ // We need to ensure that the page doesn't get shorter before the new history entry has been pushed
226
+ // 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
227
+ // The challenge is knowing on routeChangeStart if we're in a popstate (back/forward) or a pushState/replaceState
228
+ // We use the deprecated window.event property for that
229
+ // This is catchified, so we should see in sentry when it starts failing if browsers ever remove it???
230
+ if (window.event instanceof PopStateEvent) return;
231
+ $64144f6d578fd8ac$var$addLotsOfPadding();
232
+ next_router_event_target.addEventListener("beforeHistoryChange", (0, $jb2Oo$catchify)(() => (0, $jb2Oo$queueMacroTask)($64144f6d578fd8ac$var$removeLotsOfPadding)), {
233
+ once: true
234
+ });
235
+ }));
236
+ }
237
+ /*
238
+ Here we want to be able to add padding that *definitely* gets applied and then be able to revert precisely to what was before.
239
+ 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.
240
+ */
241
+ function $64144f6d578fd8ac$var$addLotsOfPadding() {
242
+ var _history$state, _history$state$search, _history$state$search2;
243
+ if ($64144f6d578fd8ac$var$padding_animation) return; // We're already showing a bunch of padding
244
+ $64144f6d578fd8ac$var$padding_animation = document.body.animate({
245
+ paddingBottom: (((_history$state = history.state) === null || _history$state === void 0 ? void 0 : (_history$state$search = _history$state.search_scroll_restoration_data) === null || _history$state$search === void 0 ? void 0 : (_history$state$search2 = _history$state$search[0]) === null || _history$state$search2 === void 0 ? void 0 : _history$state$search2.min_results_loaded) || 150) * 500 + "px",
246
+ offset: 0
247
+ }, 1);
248
+ $64144f6d578fd8ac$var$padding_animation.pause();
249
+ }
250
+ function $64144f6d578fd8ac$var$removeLotsOfPadding() {
251
+ if ($64144f6d578fd8ac$var$padding_animation) {
252
+ $64144f6d578fd8ac$var$padding_animation.play();
253
+ $64144f6d578fd8ac$var$padding_animation = undefined;
254
+ }
255
+ }
256
+ function $64144f6d578fd8ac$var$make_next_router_event_target() {
257
+ var _window2, _window2$next, _window2$next$router, _window2$next$router$;
258
+ const next_router_event_target = new EventTarget();
259
+ (_window2 = window) === null || _window2 === void 0 || (_window2$next = _window2.next) === null || _window2$next === void 0 || (_window2$next$router = _window2$next.router) === null || _window2$next$router === void 0 || (_window2$next$router$ = _window2$next$router.events) === null || _window2$next$router$ === void 0 || _window2$next$router$.on("beforeHistoryChange", () => next_router_event_target.dispatchEvent(new CustomEvent("beforeHistoryChange")));
260
+ return next_router_event_target;
261
+ }
262
+ const $7abe9e29758fa0eb$export$599d4515591ef232 = (relativeUrl, isReplace, scroll) => {
263
+ let Page;
264
+ (function (Page) {
265
+ Page[Page["OTHER"] = 0] = "OTHER";
266
+ Page[Page["SEARCH"] = 1] = "SEARCH";
267
+ Page[Page["CATEGORY"] = 2] = "CATEGORY";
268
+ })(Page || (Page = {}));
269
+ const current_page = (0, $0dd9d9a9c7da4c1d$export$775e6b3892b5ad52)() ? Page.SEARCH : (0, $0dd9d9a9c7da4c1d$export$30c8a12df09be0e4)() ? Page.CATEGORY : Page.OTHER;
270
+ const target_u_o = new URL(relativeUrl, location.origin);
271
+ const target_page = (0, $0dd9d9a9c7da4c1d$export$775e6b3892b5ad52)(target_u_o) ? Page.SEARCH : (0, $0dd9d9a9c7da4c1d$export$30c8a12df09be0e4)(target_u_o) ? Page.CATEGORY : Page.OTHER;
272
+ window.next.router[isReplace ? "replace" : "push"](relativeUrl, undefined, {
273
+ shallow: current_page === target_page && target_page !== Page.OTHER,
274
+ scroll:
275
+ // Can't go shallowly to other pages
276
+ scroll
277
+ });
278
+ };
279
+ const $b34796f5ebe3470e$export$38b98fae14bd1f64 = () => {
280
+ if (!(0, $8c691d7f86317052$export$8e769ad4338a911e).dpc) throw new Error("Depict tracking is not configured. Wrap your app in a DepictProvider.");
281
+ return {
282
+ dpc: (0, $8c691d7f86317052$export$8e769ad4338a911e).dpc
283
+ };
284
+ };
285
+ const $b34796f5ebe3470e$export$47e064413edabf36 = (merchant, market, userId, sessionId) => {
286
+ if (!merchant) return;
287
+ try {
288
+ let {
289
+ dpc: dpc
290
+ } = (0, $8c691d7f86317052$export$8e769ad4338a911e);
291
+ if (!dpc) dpc = (0, $8c691d7f86317052$export$8e769ad4338a911e).dpc = new (0, $jb2Oo$DPC)(merchant, {
292
+ market: market
293
+ });
294
+ dpc.merchant = merchant;
295
+ dpc.market = market;
296
+ dpc.setUserId(userId);
297
+ dpc.setSessionId(sessionId);
298
+ } catch (e) {
299
+ // Make sure to not break the users app if we throw
300
+ queueMicrotask(() => {
301
+ throw e;
302
+ });
303
+ }
304
+ };
305
+ function $bef9f58602be2478$export$bae2769a30719c48(disposable, stateKey) {
306
+ const actual_function = dispose => {
307
+ var _globalState$enableCa;
308
+ const {
309
+ usedLocale: [get_locale],
310
+ merchant: [get_merchant],
311
+ market: [get_market],
312
+ search_query_url_param_name: search_query_url_param_name,
313
+ search_page_path_: [get_search_page_path],
314
+ enable_content_search: [get_enable_content_search]
315
+ } = (0, $8c691d7f86317052$export$8e769ad4338a911e);
316
+ const instance = new (0, $jb2Oo$DepictSearch)({
317
+ api: (0, $8c691d7f86317052$export$8e769ad4338a911e).api,
318
+ search_query_url_param_name: search_query_url_param_name,
319
+ market: (0, $jb2Oo$untrack)(get_market),
320
+ // TODO: check if we can do this
321
+ merchant: (0, $jb2Oo$untrack)(get_merchant),
322
+ enable_category_suggestions: (_globalState$enableCa = (0, $8c691d7f86317052$export$8e769ad4338a911e).enableCategorySuggestions) !== null && _globalState$enableCa !== void 0 ? _globalState$enableCa : false,
323
+ // default category suggestions to false for @depict-ai/react-ui (https://linear.app/depictai/issue/FRO-401/default-enablecategorysuggestions-to-false)
324
+ localization: (0, $jb2Oo$untrack)(get_locale),
325
+ url_transformer: url => url.pathname = (0, $jb2Oo$untrack)(get_search_page_path),
326
+ on_navigation: (0, $8c691d7f86317052$export$8e769ad4338a911e).on_navigation,
327
+ unique_instance_key_for_state: stateKey,
328
+ enable_content_search: (0, $jb2Oo$untrack)(get_enable_content_search)
329
+ });
330
+ (0, $jb2Oo$createComputed)(() => {
331
+ const new_merchant = get_merchant();
332
+ if (new_merchant) instance.merchant = new_merchant;
333
+ });
334
+ (0, $jb2Oo$createComputed)(() => {
335
+ const new_market = get_market();
336
+ if (new_market) instance.market = new_market;
337
+ });
338
+ (0, $jb2Oo$createComputed)(() => instance.localization = get_locale());
339
+ (0, $jb2Oo$createComputed)(() => instance.enable_content_search = get_enable_content_search());
340
+ return {
341
+ instance: instance,
342
+ dispose: dispose,
343
+ users: 0
344
+ };
345
+ };
346
+ const function_length_0 = () => actual_function();
347
+ const function_length_1 = dispose => actual_function(dispose);
348
+ return (0, $jb2Oo$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
349
+ }
350
+
351
+ function $b1c85026e863c95b$export$248b95d5073d5bab(disposable, stateKey) {
352
+ const actual_function = dispose => {
353
+ const {
354
+ usedLocale: [get_locale],
355
+ merchant: [get_merchant],
356
+ market: [get_market]
357
+ } = (0, $8c691d7f86317052$export$8e769ad4338a911e);
358
+ const instance = new (0, $jb2Oo$DepictCategory)({
359
+ api: (0, $8c691d7f86317052$export$8e769ad4338a911e).api,
360
+ market: (0, $jb2Oo$untrack)(get_market),
361
+ // TODO: check if we can do this
362
+ merchant: (0, $jb2Oo$untrack)(get_merchant),
363
+ localization: (0, $jb2Oo$untrack)(get_locale),
364
+ on_navigation: (0, $8c691d7f86317052$export$8e769ad4338a911e).on_navigation,
365
+ unique_instance_key_for_state: stateKey
366
+ });
367
+ (0, $jb2Oo$createComputed)(() => {
368
+ const new_merchant = get_merchant();
369
+ if (new_merchant) instance.merchant = new_merchant;
370
+ });
371
+ (0, $jb2Oo$createComputed)(() => {
372
+ const new_market = get_market();
373
+ if (new_market) instance.market = new_market;
374
+ });
375
+ (0, $jb2Oo$createComputed)(() => instance.localization = get_locale());
376
+ return {
377
+ instance: instance,
378
+ dispose: dispose,
379
+ users: 0
380
+ };
381
+ };
382
+ const function_length_0 = () => actual_function();
383
+ const function_length_1 = dispose => actual_function(dispose);
384
+ return (0, $jb2Oo$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
385
+ }
386
+
387
+ let $18e5b9f66c7ade8e$var$provider_instances = 0;
388
+ function $18e5b9f66c7ade8e$export$9fac37a9c21c2f3b(props) {
389
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).provider_is_updating[1](true);
390
+ try {
391
+ return $18e5b9f66c7ade8e$var$ActualDepictProvider(props);
392
+ } finally {
393
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).provider_is_updating[1](false);
394
+ }
395
+ }
396
+ function $18e5b9f66c7ade8e$var$ActualDepictProvider(props) {
397
+ var _props$search;
398
+ const {
399
+ children: children,
400
+ navigateFunction: navigateFunction,
401
+ market: market,
402
+ merchant: merchant,
403
+ locale: locale,
404
+ metaData: metaData,
405
+ userId: userId,
406
+ sessionId: sessionId
407
+ } = props;
408
+ const usedLocale = locale !== null && locale !== void 0 ? locale : (0, $jb2Oo$defaultLocale);
409
+ const {
410
+ searchPagePath: searchPagePath,
411
+ urlParamName: urlParamName,
412
+ enableCategorySuggestions: enableCategorySuggestions,
413
+ enableContentSearch: enableContentSearch
414
+ } = (_props$search = props.search) !== null && _props$search !== void 0 ? _props$search : {};
415
+ $18e5b9f66c7ade8e$var$multiple_depictprovider_guard();
416
+ // Will run on other prop changes, but harmless
417
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).userId[1](userId);
418
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).sessionId[1](sessionId);
419
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).usedLocale[1](usedLocale);
420
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).enable_content_search[1](enableContentSearch);
421
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).metaData = metaData;
422
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).search_query_url_param_name = urlParamName;
423
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).enableCategorySuggestions = enableCategorySuggestions;
424
+ (0, $b34796f5ebe3470e$export$47e064413edabf36)(merchant, market, userId, sessionId);
425
+ if (!market || !merchant) return (0, $jb2Oo$createElement)((0, $jb2Oo$Fragment), null, children);
426
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).market[1](market);
427
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).merchant[1](merchant);
428
+ (0, $64144f6d578fd8ac$export$6453cbc34515a94d)();
429
+ try {
430
+ var _window, _window$next;
431
+ const {
432
+ search_instances: search_instances,
433
+ category_instances: category_instances,
434
+ search_page_path_: [, set_search_page_path]
435
+ } = (0, $8c691d7f86317052$export$8e769ad4338a911e);
436
+ if (typeof ((_window = window) === null || _window === void 0 ? void 0 : (_window$next = _window.next) === null || _window$next === void 0 ? void 0 : _window$next.router) === "undefined" && !navigateFunction) throw new Error("You must provide a navigateFunction when not using Next.js.");
437
+ const on_navigation = _ref => {
438
+ let {
439
+ is_replace: is_replace,
440
+ new_url: new_url,
441
+ scroll: scroll
442
+ } = _ref;
443
+ 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
444
+ if (navigateFunction) navigateFunction(new_relative_url, {
445
+ replace: is_replace,
446
+ scroll: scroll
447
+ });else (0, $7abe9e29758fa0eb$export$599d4515591ef232)(new_relative_url, is_replace, scroll);
448
+ };
449
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).on_navigation = on_navigation;
450
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).api || ((0, $8c691d7f86317052$export$8e769ad4338a911e).api = new (0, $jb2Oo$DepictAPI)({
451
+ get_metadata: async () => (0, $8c691d7f86317052$export$8e769ad4338a911e).metaData,
452
+ get_user_id: () => (0, $jb2Oo$untrack)((0, $8c691d7f86317052$export$8e769ad4338a911e).userId[0]),
453
+ get_session_id: () => (0, $jb2Oo$untrack)((0, $8c691d7f86317052$export$8e769ad4338a911e).sessionId[0])
454
+ }));
455
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).api.page_url_creator = props.pageURLCreator;
456
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).api.display_transformers = props.displayTransformers;
457
+ if (searchPagePath) set_search_page_path($18e5b9f66c7ade8e$var$ensure_correct_formatting(searchPagePath));
458
+ if (!search_instances.get(undefined)) {
459
+ // 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.
460
+ // Also, it emulates the behavior pre-supporting multiple "depict blocks" on the same page
461
+ const instance = (0, $bef9f58602be2478$export$bae2769a30719c48)(false);
462
+ search_instances.set(undefined, instance);
463
+ }
464
+ if (!category_instances.get(undefined)) {
465
+ const instance = (0, $b1c85026e863c95b$export$248b95d5073d5bab)(false);
466
+ category_instances.set(undefined, instance);
467
+ }
468
+ } catch (e) {
469
+ // Make sure to not break the users app if we throw
470
+ queueMicrotask(() => {
471
+ throw e;
472
+ });
473
+ }
474
+ return (0, $jb2Oo$createElement)((0, $jb2Oo$Fragment), null, children);
475
+ }
476
+ function $18e5b9f66c7ade8e$var$ensure_correct_formatting(path) {
477
+ // Make sure the path starts with a slash as it always will and is_page will fail otherwise
478
+ if (!path.startsWith("/")) return "/" + path;
479
+ return path;
480
+ }
481
+ function $18e5b9f66c7ade8e$var$multiple_depictprovider_guard() {
482
+ (0, $jb2Oo$useEffect)(() => {
483
+ $18e5b9f66c7ade8e$var$provider_instances++;
484
+ if ($18e5b9f66c7ade8e$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.");
485
+ return () => {
486
+ $18e5b9f66c7ade8e$var$provider_instances--;
487
+ };
488
+ }, []);
489
+ }
490
+ const $f6a205a95e4fdee3$export$80e99ee6b29cadd2 = /*#__PURE__*/(0, $jb2Oo$forwardRef)((_, ref) => {
491
+ return /*#__PURE__*/(0, $jb2Oo$createElement)("div", {
492
+ className: "depict aligner",
493
+ style: {
494
+ height: "100%"
495
+ },
496
+ ref: ref
497
+ });
498
+ });
499
+ function $fda7a7820477f957$export$f4d89133c6985668(type, stateKey, componentName) {
500
+ const instances = (0, $8c691d7f86317052$export$8e769ad4338a911e)[type + "_instances"];
501
+ if (!instances.get(undefined)) throw Error("".concat(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."));
502
+ let instance = instances.get(stateKey);
503
+ if (!instance) {
504
+ instance = type === "search" ? (0, $bef9f58602be2478$export$bae2769a30719c48)(true, stateKey) : (0, $b1c85026e863c95b$export$248b95d5073d5bab)(true, stateKey);
505
+ instances.set(stateKey, instance);
506
+ }
507
+ instance.users++;
508
+ (0, $jb2Oo$onCleanup)(() => {
509
+ var _instance;
510
+ instance.users--;
511
+ if (!instance.users && (_instance = instance) !== null && _instance !== void 0 && _instance.dispose) {
512
+ // main instance is not disposable, and shouldn't be deletable either
513
+ instance.dispose();
514
+ instances.delete(stateKey);
515
+ }
516
+ });
517
+ return instance.instance;
518
+ }
519
+ const $d059770e7af9e2dc$var$rendered_components_with_state_key = new Set();
520
+ function $d059770e7af9e2dc$export$a54ec244c8863715(props) {
521
+ return (0, $0dd9d9a9c7da4c1d$export$f6e64e17bd69eeef)({
522
+ solid_component: (0, $0dd9d9a9c7da4c1d$export$e5139bbbb9a05035)($d059770e7af9e2dc$var$SolidSearchPage),
523
+ props: props
524
+ });
525
+ }
526
+ function $d059770e7af9e2dc$var$SolidSearchPage(props, set_portals) {
527
+ const depict_search = (0, $jb2Oo$createMemo)(() => {
528
+ const instance = (0, $fda7a7820477f957$export$f4d89133c6985668)("search", props.stateKey, "SearchPage");
529
+ (0, $jb2Oo$onCleanup)(() => {
530
+ var _get_search_query_upd;
531
+ // Make sure we don't block the search query updating signal when we switch to a new provider instance
532
+ (_get_search_query_upd = (0, $jb2Oo$get_search_query_updating_blocked_signal)(instance)) === null || _get_search_query_upd === void 0 || _get_search_query_upd[1](false);
533
+ });
534
+ return instance;
535
+ });
536
+ const update_updating_blocked_signal = () => {
537
+ // if search instances changes, also re-check for good measure (otherwise would have untrack around depict_search)
538
+ const signal = (0, $jb2Oo$get_search_query_updating_blocked_signal)(depict_search());
539
+ if (!signal) throw Error("No search_query_updating_blocked_signal when rendering SearchPage");
540
+ const [, write_signal] = signal;
541
+ // This causes a bug. To reproduce:
542
+ // 1. Go to front page
543
+ // 2. Make a search
544
+ // 3. Press back button
545
+ // 4. Open search modal
546
+ // 5. Check the list of previous queries - the query just made isn't shown
547
+ // 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
548
+ // 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
549
+ // EDIT: now that we're resetting this in the onCleanup of the memo above this might no longer be the case
550
+ write_signal(!(0, $0dd9d9a9c7da4c1d$export$775e6b3892b5ad52)(location));
551
+ };
552
+ const [, set_search_page_in_dom] = (0, $8c691d7f86317052$export$8e769ad4338a911e).search_page_in_dom;
553
+ const component_portals = new Set();
554
+ // We should only get here once react already has a DOM node which means we should be in the DOM
555
+ set_search_page_in_dom(true);
556
+ (0, $jb2Oo$onCleanup)(() => set_search_page_in_dom(false));
557
+ // 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
558
+ (0, $0dd9d9a9c7da4c1d$export$74f3924c5027fe1d)(update_updating_blocked_signal); // if we navigate, re-check
559
+ (0, $jb2Oo$createComputed)(() => {
560
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).search_page_path_[0](); // if react defined path changes, re-check
561
+ update_updating_blocked_signal();
562
+ });
563
+ $d059770e7af9e2dc$var$search_page_path_checker();
564
+ return (0, $jb2Oo$createMemo)(() => {
565
+ const stateKey = (0, $jb2Oo$untrack)(() => props.stateKey);
566
+ if ($d059770e7af9e2dc$var$rendered_components_with_state_key.has(stateKey)) throw new Error("You have multiple SearchPage components with the same stateKey: ".concat(stateKey, ". Each SearchPage component must have a unique stateKey."));
567
+ $d059770e7af9e2dc$var$rendered_components_with_state_key.add(stateKey);
568
+ (0, $jb2Oo$onCleanup)(() => $d059770e7af9e2dc$var$rendered_components_with_state_key.delete(stateKey));
569
+ return (0, $jb2Oo$SearchPage)({
570
+ // Default config goes here
571
+ get include_input_field() {
572
+ return props.includeInputField;
573
+ },
574
+ get cols_at_size() {
575
+ var _props$columnsAtSize;
576
+ return (_props$columnsAtSize = props.columnsAtSize) !== null && _props$columnsAtSize !== void 0 ? _props$columnsAtSize : (0, $jb2Oo$defaultColsAtSize);
577
+ },
578
+ get grid_spacing() {
579
+ var _props$gridSpacing;
580
+ return (_props$gridSpacing = props.gridSpacing) !== null && _props$gridSpacing !== void 0 ? _props$gridSpacing : (0, $jb2Oo$defaultGridSpacing);
581
+ },
582
+ depict_search: depict_search(),
583
+ product_card_template: display => (0, $0dd9d9a9c7da4c1d$export$79c79419c1ef0081)({
584
+ display: display,
585
+ react_template: (0, $jb2Oo$untrack)(() => props.productCard),
586
+ component_portals: component_portals,
587
+ set_portals: set_portals
588
+ })
589
+ });
590
+ });
591
+ }
592
+ /**
593
+ * 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.
594
+ */
595
+ function $d059770e7af9e2dc$var$search_page_path_checker() {
596
+ let has_warned = false;
597
+ (0, $jb2Oo$createEffect)(() => {
598
+ if (has_warned) return;
599
+ const should_be_path = (0, $8c691d7f86317052$export$8e769ad4338a911e).search_page_path_[0]();
600
+ const {
601
+ pathname: pathname
602
+ } = location;
603
+ if (
604
+ // allow some variability just to be sure
605
+ should_be_path !== pathname && should_be_path + "/" !== pathname && should_be_path !== pathname + "/") {
606
+ (0, $jb2Oo$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.");
607
+ has_warned = true;
608
+ }
609
+ });
610
+ }
611
+ const $e86a296a07b17ad5$var$rendered_components_with_state_key = new Set();
612
+ function $e86a296a07b17ad5$export$f7d2f673fc2f091d(props) {
613
+ return (0, $0dd9d9a9c7da4c1d$export$f6e64e17bd69eeef)({
614
+ // @ts-ignore
615
+ solid_component: (0, $0dd9d9a9c7da4c1d$export$e5139bbbb9a05035)($e86a296a07b17ad5$var$SolidCategoryPage),
616
+ props: props,
617
+ wrapper_type: "div",
618
+ wrapper_style: {}
619
+ });
620
+ }
621
+ function $e86a296a07b17ad5$var$SolidCategoryPage(props, set_portals) {
622
+ const depict_category = (0, $jb2Oo$createMemo)(() => (0, $fda7a7820477f957$export$f4d89133c6985668)("category", props.stateKey, "CategoryPage") // stateKey can change
623
+ );
624
+
625
+ const [category_state_set, set_category_state_set] = (0, $jb2Oo$createSignal)(false);
626
+ const component_portals = new Set();
627
+ const [, set_category_page_in_dom] = (0, $8c691d7f86317052$export$8e769ad4338a911e).category_page_in_dom;
628
+ // We should only get here once react already has a DOM node which means we should be in the DOM
629
+ set_category_page_in_dom(true);
630
+ (0, $jb2Oo$onCleanup)(() => set_category_page_in_dom(false));
631
+ (0, $jb2Oo$createComputed)(() => {
632
+ const {
633
+ categoryId: categoryId
634
+ } = props;
635
+ depict_category().category_id = categoryId;
636
+ if (categoryId) {
637
+ set_category_state_set(true);
638
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).known_category_paths.add(location.pathname);
639
+ }
640
+ });
641
+ (0, $jb2Oo$createComputed)(() => depict_category().listing_type = props.listingType);
642
+ const category = () => (0, $jb2Oo$createMemo)(() => {
643
+ const stateKey = (0, $jb2Oo$untrack)(() => props.stateKey);
644
+ if ($e86a296a07b17ad5$var$rendered_components_with_state_key.has(stateKey)) throw new Error("You have multiple CategoryPage components with the same stateKey: ".concat(stateKey, ". Each CategoryPage component must have a unique stateKey."));
645
+ $e86a296a07b17ad5$var$rendered_components_with_state_key.add(stateKey);
646
+ (0, $jb2Oo$onCleanup)(() => $e86a296a07b17ad5$var$rendered_components_with_state_key.delete(stateKey));
647
+ return (0, $jb2Oo$CategoryPage)({
648
+ depict_category: depict_category(),
649
+ get cols_at_size() {
650
+ var _props$columnsAtSize;
651
+ return (_props$columnsAtSize = props.columnsAtSize) !== null && _props$columnsAtSize !== void 0 ? _props$columnsAtSize : (0, $jb2Oo$defaultColsAtSize);
652
+ },
653
+ get grid_spacing() {
654
+ var _props$gridSpacing;
655
+ return (_props$gridSpacing = props.gridSpacing) !== null && _props$gridSpacing !== void 0 ? _props$gridSpacing : (0, $jb2Oo$defaultGridSpacing);
656
+ },
657
+ category_title: (0, $jb2Oo$untrack)(() => props.categoryTitlePlugin) || (0, $jb2Oo$defaultCategoryTitlePlugin),
658
+ get show_breadcrumbs() {
659
+ return props.showBreadcrumbs;
660
+ },
661
+ get show_quicklinks() {
662
+ return props.showQuicklinks;
663
+ },
664
+ product_card_template: display => (0, $0dd9d9a9c7da4c1d$export$79c79419c1ef0081)({
665
+ display: display,
666
+ react_template: (0, $jb2Oo$untrack)(() => props.productCard),
667
+ component_portals: component_portals,
668
+ set_portals: set_portals
669
+ })
670
+ });
671
+ });
672
+ return (0, $0dd9d9a9c7da4c1d$export$e5139bbbb9a05035)(category, category_state_set);
673
+ }
674
+ function $ec632214ac078e79$export$5646050d516e06bc(react_props) {
675
+ return (0, $0dd9d9a9c7da4c1d$export$f6e64e17bd69eeef)({
676
+ solid_component: (0, $0dd9d9a9c7da4c1d$export$e5139bbbb9a05035)($ec632214ac078e79$var$vanilla_breadcrumbs),
677
+ props: react_props
678
+ });
679
+ }
680
+ function $ec632214ac078e79$var$vanilla_breadcrumbs(props) {
681
+ // memo so stateKey can be dynamically changed
682
+ return (0, $jb2Oo$createMemo)(() => {
683
+ const depict_category = (0, $fda7a7820477f957$export$f4d89133c6985668)("category", props.stateKey, "BreadCrumbs");
684
+ return (0, $jb2Oo$BreadCrumbs)({
685
+ depict_category: depict_category
686
+ });
687
+ });
688
+ }
689
+ function $c61814cfb91ead09$export$466cdc317043f6cb() {
690
+ let react_props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
691
+ return (0, $0dd9d9a9c7da4c1d$export$f6e64e17bd69eeef)({
692
+ solid_component: (0, $0dd9d9a9c7da4c1d$export$e5139bbbb9a05035)($c61814cfb91ead09$var$vanilla_quick_links),
693
+ props: react_props
694
+ });
695
+ }
696
+ function $c61814cfb91ead09$var$vanilla_quick_links(props) {
697
+ // memo so stateKey can be dynamically changed
698
+ return (0, $jb2Oo$createMemo)(() => {
699
+ const depict_category = (0, $fda7a7820477f957$export$f4d89133c6985668)("category", props.stateKey, "QuickLinks");
700
+ return (0, $jb2Oo$QuickLinks)({
701
+ depict_category: depict_category
702
+ });
703
+ });
704
+ }
705
+ const $6406849926c3f794$export$3f37af283f8fb843 = raw_react_props => {
706
+ const react_props = {
707
+ class: raw_react_props.className,
708
+ ...raw_react_props
709
+ };
710
+ return (0, $0dd9d9a9c7da4c1d$export$f6e64e17bd69eeef)({
711
+ solid_component: props_store => (0, $jb2Oo$ImagePlaceholder)(props_store),
712
+ props: react_props,
713
+ wrapper_type: "span",
714
+ hydrate_function_when_ssr: (0, $jb2Oo$hydrate)
715
+ });
716
+ };
717
+ const $2c7738b65cbcac1c$export$89c6019e4baa40b1 = raw_react_props => {
718
+ const react_props = {
719
+ class: raw_react_props.className,
720
+ ...raw_react_props
721
+ };
722
+ return (0, $0dd9d9a9c7da4c1d$export$f6e64e17bd69eeef)({
723
+ solid_component: props_store => (0, $jb2Oo$TextPlaceholder)(props_store),
724
+ props: react_props,
725
+ wrapper_type: "span",
726
+ hydrate_function_when_ssr: (0, $jb2Oo$hydrate),
727
+ wrapper_style: {
728
+ "height": "100%"
729
+ }
730
+ });
731
+ };
732
+ const $1283ca5a3f4a4617$export$d69d8daa20eae175 = createOpenModalParams => {
733
+ const {
734
+ location = "centered",
735
+ alignerRef: alignerRef,
736
+ stateKey: stateKey
737
+ } = createOpenModalParams;
738
+ let [deduped_variable, set_deduped_variable] = (0, $jb2Oo$useState)();
739
+ // When component using this hook unmounts, "untrack" our component and dispose the search instance if needed
740
+ (0, $jb2Oo$useEffect)(() => {
741
+ var _deduped_variable, _deduped_variable$;
742
+ return (_deduped_variable = deduped_variable) === null || _deduped_variable === void 0 ? void 0 : (_deduped_variable$ = _deduped_variable[1]) === null || _deduped_variable$ === void 0 ? void 0 : _deduped_variable$.call(_deduped_variable);
743
+ }, []);
744
+ const openModal = () => {
745
+ // Get the search instance and track this component, but only once (basically work around re-rendering)
746
+ // We have to do this in the openModal function since people might call this hook before creating DepictProvider
747
+ if (!deduped_variable) {
748
+ deduped_variable = (0, $jb2Oo$createRoot)(dispose => [(0, $fda7a7820477f957$export$f4d89133c6985668)("search", stateKey, "useSearchModal"), dispose]);
749
+ set_deduped_variable(deduped_variable);
750
+ }
751
+ const [search] = deduped_variable;
752
+ if (location === "aligned" && alignerRef !== null && alignerRef !== void 0 && alignerRef.current) (0, $jb2Oo$open_modal_with_alignment)({
753
+ "element": alignerRef.current,
754
+ "location": location,
755
+ "search": search
756
+ });else (0, $jb2Oo$open_modal_with_alignment)({
757
+ "location": "centered",
758
+ "search": search
759
+ });
760
+ };
761
+ return openModal;
762
+ };
763
+ function $356d18d3ed66814e$export$912994940e660d32() {
764
+ let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
765
+ const open = (0, $1283ca5a3f4a4617$export$d69d8daa20eae175)({
766
+ globalState: $8c691d7f86317052$export$8e769ad4338a911e,
767
+ ...params
768
+ });
769
+ return {
770
+ open: open
771
+ };
772
+ }
773
+ const $4c71282d292aac6d$export$9bb30bbe003b82e0 = function () {
774
+ let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
775
+ // 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.
776
+ // Create signal that persists across renders
777
+ const [[get_aligner_signal_value, set_aligner_signal_value]] = (0, $jb2Oo$useState)((0, $jb2Oo$createSignal)());
778
+ // Update signal value when alignerRef changes
779
+ set_aligner_signal_value(props === null || props === void 0 ? void 0 : props.alignerRef);
780
+ // Make sure react never re-renders the actual SearchField component
781
+ const componentFunction = (0, $jb2Oo$useCallback)(() => (0, $0dd9d9a9c7da4c1d$export$f6e64e17bd69eeef)({
782
+ solid_component: (0, $0dd9d9a9c7da4c1d$export$e5139bbbb9a05035)(() => {
783
+ return (0, $jb2Oo$createMemo)(() => {
784
+ const depict_search = (0, $fda7a7820477f957$export$f4d89133c6985668)("search", props.stateKey, "useSearchField");
785
+ return (0, $jb2Oo$SearchField)({
786
+ depict_search: depict_search,
787
+ get aligner_ref() {
788
+ var _get_aligner_signal_v;
789
+ // React mutates the object at some random time so only get the current value once it actually is requested
790
+ return (_get_aligner_signal_v = get_aligner_signal_value()) === null || _get_aligner_signal_v === void 0 ? void 0 : _get_aligner_signal_v.current;
791
+ }
792
+ });
793
+ });
794
+ }),
795
+ props: {}
796
+ }), []);
797
+ return {
798
+ SearchField: componentFunction
799
+ };
800
+ };
801
+ function $1895644749ca8d8a$export$6501da23a2770fc() {
802
+ return {
803
+ fetchRecommendations: $1895644749ca8d8a$var$fetchRecommendations
804
+ };
805
+ }
806
+ function $1895644749ca8d8a$var$fetchRecommendations(opts) {
807
+ const {
808
+ merchant: [get_merchant],
809
+ market: [get_market],
810
+ userId: [get_userId],
811
+ sessionId: [get_sessionId]
812
+ } = (0, $8c691d7f86317052$export$8e769ad4338a911e);
813
+ const merchant = (0, $jb2Oo$untrack)(get_merchant);
814
+ const market = (0, $jb2Oo$untrack)(get_market);
815
+ if (!merchant || !market) throw new Error("Depict recommendations are not configured. Wrap your app in a DepictProvider.");
816
+ return (0, $jb2Oo$fetchDepictRecommendations)({
817
+ merchant: merchant,
818
+ market: market,
819
+ userId: (0, $jb2Oo$untrack)(get_userId),
820
+ sessionId: (0, $jb2Oo$untrack)(get_sessionId),
821
+ ...opts
822
+ });
823
+ }
824
+ const $05726fa9c7eda0a1$export$804fac5697cfbe35 = router => (relativeUrl, _ref) => {
825
+ let {
826
+ scroll: scroll,
827
+ replace: replace
828
+ } = _ref;
829
+ let Page;
830
+ (function (Page) {
831
+ Page[Page["OTHER"] = 0] = "OTHER";
832
+ Page[Page["SEARCH"] = 1] = "SEARCH";
833
+ Page[Page["CATEGORY"] = 2] = "CATEGORY";
834
+ })(Page || (Page = {}));
835
+ const current_page = (0, $0dd9d9a9c7da4c1d$export$775e6b3892b5ad52)() ? Page.SEARCH : (0, $0dd9d9a9c7da4c1d$export$30c8a12df09be0e4)() ? Page.CATEGORY : Page.OTHER;
836
+ const target_u_o = new URL(relativeUrl, location.origin);
837
+ const target_page = (0, $0dd9d9a9c7da4c1d$export$775e6b3892b5ad52)(target_u_o) ? Page.SEARCH : (0, $0dd9d9a9c7da4c1d$export$30c8a12df09be0e4)(target_u_o) ? Page.CATEGORY : Page.OTHER;
838
+ router[replace ? "replace" : "push"](relativeUrl, undefined, {
839
+ shallow: current_page === target_page && target_page !== Page.OTHER,
840
+ scroll:
841
+ // Can't go shallowly to other pages
842
+ scroll
843
+ });
844
+ };
845
+ const $a7dfdd84298ae791$export$b8a61e5c71402559 = {
846
+ nextRouterNavigation: $05726fa9c7eda0a1$export$804fac5697cfbe35
847
+ };
848
+ (0, $jb2Oo$add_to_version_info)("react-ui", (0, $9bd9bb8700ab2ada$export$83d89fbfd8236492));
849
+ export { $c61814cfb91ead09$export$466cdc317043f6cb as QuickLinks, $ec632214ac078e79$export$5646050d516e06bc as BreadCrumbs, $f6a205a95e4fdee3$export$80e99ee6b29cadd2 as ComponentAligner, $18e5b9f66c7ade8e$export$9fac37a9c21c2f3b as DepictProvider, $e86a296a07b17ad5$export$f7d2f673fc2f091d as CategoryPage, $d059770e7af9e2dc$export$a54ec244c8863715 as SearchPage, $6406849926c3f794$export$3f37af283f8fb843 as ImagePlaceholder, $2c7738b65cbcac1c$export$89c6019e4baa40b1 as TextPlaceholder, $356d18d3ed66814e$export$912994940e660d32 as useSearchModal, $4c71282d292aac6d$export$9bb30bbe003b82e0 as useSearchField, $1895644749ca8d8a$export$6501da23a2770fc as useFetchRecommendations, $b34796f5ebe3470e$export$38b98fae14bd1f64 as usePerformanceClient, $383b6fd56bf151bd$re_export$CategoryTitle as CategoryTitle, $383b6fd56bf151bd$re_export$EmbeddedNumProducts as EmbeddedNumProducts, $9bd9bb8700ab2ada$export$83d89fbfd8236492 as version, $a7dfdd84298ae791$export$b8a61e5c71402559 as Navigation };