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