@depict-ai/ui 2.1.22 → 3.0.0

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/latest/index.cjs CHANGED
@@ -1,6 +1,7 @@
1
1
  var $gVhhF$depictaiutilishared = require("@depict-ai/utilishared/latest");
2
2
  var $gVhhF$solidjsweb = require("solid-js/web");
3
3
  var $gVhhF$solidjs = require("solid-js");
4
+ var $gVhhF$depictaiutilisharedlatest = require("@depict-ai/utilishared/latest");
4
5
  var $gVhhF$solidjsstore = require("solid-js/store");
5
6
  require("../multi_import_deduplicator.cjs").register_es_version("ui", "latest");
6
7
  function $parcel$export(e, n, v, s) {
@@ -11,6 +12,10 @@ function $parcel$export(e, n, v, s) {
11
12
  configurable: true
12
13
  });
13
14
  }
15
+ $parcel$export(module.exports, "Tab", () => $8c38828ae2321937$export$3e41faf802a29e71);
16
+ $parcel$export(module.exports, "Tabs", () => $8c38828ae2321937$export$b2539bed5023c21c);
17
+ $parcel$export(module.exports, "ShopTheLookButton", () => $a5f3eaa1a24bbc1e$export$d4973c31938cbfd1);
18
+ $parcel$export(module.exports, "history_dot_state_to_state", () => $6e22b5314fb52f4c$export$e183a13865960371);
14
19
  $parcel$export(module.exports, "strip_encoded_filter_and_sort", () => $1ab22f2cd39b3061$export$916e6850778505f6);
15
20
  $parcel$export(module.exports, "encode_filters", () => $1ab22f2cd39b3061$export$58aa3f171519b6d7);
16
21
  $parcel$export(module.exports, "decode_filters", () => $1ab22f2cd39b3061$export$f934fa24c3a86811);
@@ -37,12 +42,12 @@ $parcel$export(module.exports, "SolidLayout", () => $f48d0fbb00835aaa$export$d21
37
42
  $parcel$export(module.exports, "general_modal_abstraction", () => $9abb0a35d4b60ed3$export$79b1565500412d9b);
38
43
  $parcel$export(module.exports, "CrossIcon", () => $c77c68e559a1506c$export$3b621d86b1566b2);
39
44
  $parcel$export(module.exports, "GenericSliderArrowButton", () => $0f313083912e447a$export$8be2714ec7f169ee);
40
- $parcel$export(module.exports, "fetchDepictRecommendations", () => $bc91d938b8c601b4$export$58e808b1db15d3bc);
45
+ $parcel$export(module.exports, "fetchDepictRecommendations", () => $bd429c994399dd82$export$58e808b1db15d3bc);
41
46
  $parcel$export(module.exports, "QuickLinks", () => $48567ac5b39bac56$export$de035477d6fef996);
42
47
  $parcel$export(module.exports, "BreadCrumbs", () => $48567ac5b39bac56$export$5b7c3ce0ebe51f86);
43
48
  $parcel$export(module.exports, "CategoryTitle", () => $0b23bfd073d9a4e8$export$b91cec6bdc6b32a1);
44
49
  $parcel$export(module.exports, "embedded_num_products", () => $85b747260aa175c9$export$824dde41348efed1);
45
- $parcel$export(module.exports, "get_categories", () => $63b10c9f461e0ef6$export$643598a327b5833e);
50
+ $parcel$export(module.exports, "get_listings", () => $6382a1b83da39674$export$c1a6b039e689a58e);
46
51
  $parcel$export(module.exports, "DepictCategory", () => $48567ac5b39bac56$export$f34314aa9505732e);
47
52
  $parcel$export(module.exports, "CategoryPage", () => $48567ac5b39bac56$export$e2bf8ce7779e827e);
48
53
  $parcel$export(module.exports, "DepictSearch", () => $2c61e4cd8229c49a$export$ac6237957a15b3f0);
@@ -72,202 +77,16 @@ $parcel$export(module.exports, "defaultColsAtSize", () => $a3280f0aad997933$expo
72
77
  $parcel$export(module.exports, "defaultCategoryTitlePlugin", () => $a3280f0aad997933$export$7bf543b9d9be2c22);
73
78
  $parcel$export(module.exports, "version", () => $b757f75811f3261f$export$83d89fbfd8236492);
74
79
  /*! Depict.ai search and product listing SDK */
75
- const $b757f75811f3261f$export$83d89fbfd8236492 = "2.1.22";
76
- const $1ab22f2cd39b3061$var$fallback_operator = "in";
77
- const $1ab22f2cd39b3061$var$fallback_token = "";
78
- const $1ab22f2cd39b3061$var$legacy_filter_prefix = "filter_";
79
- const $1ab22f2cd39b3061$var$operator_map = {
80
- "eq": "≡",
81
- "neq": "≠",
82
- "in": "∈",
83
- "nin": "∉",
84
- "leq": "≤",
85
- "geq": "≥",
86
- "inrange": "\uD83D\uDD22"
87
- };
88
- const $1ab22f2cd39b3061$var$ascending_token = "\uD83D\uDCC8";
89
- const $1ab22f2cd39b3061$var$descending_token = "\uD83D\uDCC9";
90
- const $1ab22f2cd39b3061$var$range_delimiter = "-";
91
- const $1ab22f2cd39b3061$var$string_item_delimiter = "‚"; // This is not a comma but a comma-like character that browsers will render in the URL bar.
92
- const $1ab22f2cd39b3061$var$array_item_delimiter = "‣"; // FIXME: decide on a character. Could theoretically be a double string delimiter.
93
- const $1ab22f2cd39b3061$var$empty_item_replacement = "0️⃣";
94
- const $1ab22f2cd39b3061$var$op_to_token = op => {
95
- if (op === $1ab22f2cd39b3061$var$fallback_operator) return $1ab22f2cd39b3061$var$fallback_token;
96
- return $1ab22f2cd39b3061$var$operator_map[op];
97
- };
98
- /**
99
- * Checks if a given array of filter data can be neatly serialized into an URL query parameter, or if it should fall back to JSON+base64.
100
- * The requirements are either an array of strings, containing no reserved characters, or an array of arrays of strings, containing no reserved characters.
101
- * No deep or mixed nesting levels are supported.
102
- */
103
- function $1ab22f2cd39b3061$var$array_is_serializable(array, is_root = true) {
104
- if (array.every(item => Array.isArray(item))) {
105
- if (!is_root)
106
- // Deeply nested arrays are not supported, but also don't exist as filters (yet)
107
- return false;
108
- return array.every(item => $1ab22f2cd39b3061$var$array_is_serializable(item, false));
109
- }
110
- if (array.some(item => typeof item !== "string"))
111
- // Numbers are not supported, since 1 and "1" would encode to the same thing
112
- return false;
113
- // Encoding reserved characters is not supported
114
- return !array.some(item => item.includes($1ab22f2cd39b3061$var$array_item_delimiter) || item.includes($1ab22f2cd39b3061$var$string_item_delimiter) || item === $1ab22f2cd39b3061$var$empty_item_replacement);
115
- }
116
- /**
117
- * Human readable string[] or string[][] serialization for URLs.
118
- * @param array
119
- * @returns
120
- */
121
- function $1ab22f2cd39b3061$var$encode_array(array) {
122
- const is_nested = array.every(item => Array.isArray(item));
123
- if (is_nested) return array.map($1ab22f2cd39b3061$var$encode_array).join($1ab22f2cd39b3061$var$array_item_delimiter) + $1ab22f2cd39b3061$var$array_item_delimiter; // Nested arrays require a suffix to close nesting levels
124
- return array.map(item => item === "" ? $1ab22f2cd39b3061$var$empty_item_replacement : item).join($1ab22f2cd39b3061$var$string_item_delimiter);
125
- }
126
- function $1ab22f2cd39b3061$var$decode_array(encoded_array) {
127
- const is_nested = encoded_array.includes($1ab22f2cd39b3061$var$array_item_delimiter);
128
- if (is_nested) return encoded_array.split($1ab22f2cd39b3061$var$array_item_delimiter).filter(s => s !== "") // Remove empty segments, caused by trailing delimiter
129
- .map($1ab22f2cd39b3061$var$decode_array);
130
- return encoded_array.split($1ab22f2cd39b3061$var$string_item_delimiter).filter(s => s !== "") // Remove empty segments, caused by trailing delimiter in the single item special case
131
- .map(item => item === $1ab22f2cd39b3061$var$empty_item_replacement ? "" : item);
132
- }
133
- function $1ab22f2cd39b3061$var$encode_filter_data(op, data) {
134
- if (data === "true")
135
- // boolean encoding
136
- return "1";
137
- if (data === "false")
138
- // boolean encoding
139
- return "0";
140
- const data_is_array = Array.isArray(data);
141
- if (op === "inrange" && data_is_array && data.every(item => typeof item === "number"))
142
- // numeric range filter encoding
143
- return data.join($1ab22f2cd39b3061$var$range_delimiter);
144
- if (data_is_array && $1ab22f2cd39b3061$var$array_is_serializable(data)) {
145
- const encoded_data = $1ab22f2cd39b3061$var$encode_array(data);
146
- if (!encoded_data.includes($1ab22f2cd39b3061$var$array_item_delimiter) && !encoded_data.includes($1ab22f2cd39b3061$var$string_item_delimiter))
147
- // A string[] with only one item will encode without delimiters, which is indistinguishable from a plain string during decoding
148
- // In that case we add a delimiter suffix at the end
149
- return encoded_data + $1ab22f2cd39b3061$var$string_item_delimiter;
150
- return encoded_data;
151
- }
152
- // Fallback encoding
153
- return $gVhhF$depictaiutilishared.base64_encode_unicode(JSON.stringify(data));
154
- }
155
- function $1ab22f2cd39b3061$var$decode_filter_data(op, encoded_data) {
156
- if (encoded_data === "1") return "true";
157
- if (encoded_data === "0") return "false";
158
- if (op === "inrange" && encoded_data.includes($1ab22f2cd39b3061$var$range_delimiter)) return encoded_data.split($1ab22f2cd39b3061$var$range_delimiter).map(x => parseFloat(x));
159
- if (encoded_data.includes($1ab22f2cd39b3061$var$string_item_delimiter) || encoded_data.includes($1ab22f2cd39b3061$var$array_item_delimiter)) return $1ab22f2cd39b3061$var$decode_array(encoded_data);
160
- try {
161
- return JSON.parse($gVhhF$depictaiutilishared.base64_decode_unicode(encoded_data));
162
- } catch (e) {
163
- $gVhhF$depictaiutilishared.dlog("Failed to fallback parse filter data", op, encoded_data, e);
164
- }
165
- return null;
166
- }
167
- function $1ab22f2cd39b3061$export$58aa3f171519b6d7(filters, search_params, filter_query_param_prefix) {
168
- for (const filter of filters) {
169
- const {
170
- field: field,
171
- op: op,
172
- data: data
173
- } = filter;
174
- const encoded_data = $1ab22f2cd39b3061$var$encode_filter_data(op, data);
175
- search_params.set(filter_query_param_prefix + field + $1ab22f2cd39b3061$var$op_to_token(op), encoded_data);
176
- }
177
- }
178
- function $1ab22f2cd39b3061$export$f934fa24c3a86811(search_params, filter_query_param_prefix) {
179
- const found_filters = [];
180
- for (const key of search_params.keys()) {
181
- // Allow for backwards compatibility with the old filter query param prefix
182
- let chosen_prefix = filter_query_param_prefix;
183
- if (!key.startsWith(chosen_prefix)) {
184
- chosen_prefix = $1ab22f2cd39b3061$var$legacy_filter_prefix;
185
- if (!key.startsWith(chosen_prefix)) continue;
186
- }
187
- const encoded_data = search_params.get(key);
188
- if (!encoded_data) continue;
189
- const [op, token] = Object.entries($1ab22f2cd39b3061$var$operator_map).find(([, token]) => key.endsWith(token)) || [$1ab22f2cd39b3061$var$fallback_operator, $1ab22f2cd39b3061$var$fallback_token];
190
- const data = $1ab22f2cd39b3061$var$decode_filter_data(op, encoded_data);
191
- if (!data) continue;
192
- const field = key.slice(chosen_prefix.length, token ? -token.length : undefined);
193
- found_filters.push({
194
- field: field,
195
- op: op,
196
- data: data
197
- });
198
- }
199
- return found_filters;
200
- }
201
- function $1ab22f2cd39b3061$export$62acb285a7579555(sorting, search_params, sorting_query_param) {
202
- if (!sorting) return;
203
- const {
204
- field: field,
205
- order: order
206
- } = sorting;
207
- const ascending = order === "asc";
208
- search_params.set(sorting_query_param, field + (ascending ? $1ab22f2cd39b3061$var$ascending_token : $1ab22f2cd39b3061$var$descending_token));
209
- }
210
- function $1ab22f2cd39b3061$export$766e9676e74997d3(search_params, sorting_query_param_) {
211
- const encoded_sorting = search_params.get(sorting_query_param_);
212
- if (!encoded_sorting) return;
213
- if (encoded_sorting.endsWith($1ab22f2cd39b3061$var$ascending_token)) return {
214
- field: encoded_sorting.slice(0, -$1ab22f2cd39b3061$var$ascending_token.length),
215
- order: "asc"
216
- };
217
- if (encoded_sorting.endsWith($1ab22f2cd39b3061$var$descending_token)) return {
218
- field: encoded_sorting.slice(0, -$1ab22f2cd39b3061$var$descending_token.length),
219
- order: "desc"
220
- };
221
- $gVhhF$depictaiutilishared.dlog("Invalid sorting query param value", encoded_sorting);
222
- return;
223
- }
224
- function $1ab22f2cd39b3061$export$916e6850778505f6(search_params, filter_query_param_prefix, sorting_query_param) {
225
- // We'll be modifying the URLSearchParams object, so we need to make a copy of the keys first
226
- const keys = [...search_params.keys()];
227
- for (const key of keys) if (key.startsWith(filter_query_param_prefix) || key === sorting_query_param || key.startsWith($1ab22f2cd39b3061$var$legacy_filter_prefix)) search_params.delete(key);
228
- }
229
- const $1ab22f2cd39b3061$export$cf5feb2102aec7f2 = "went_sideways_clear_filters";
230
- function $1ab22f2cd39b3061$export$43cd1e747fecd42e({
231
- to_url_: to_url_,
232
- set_clearing_flag_: set_clearing_flag_,
233
- from_search_params_ = new URLSearchParams(location.search),
234
- sorting_query_param_: sorting_query_param_,
235
- filter_query_param_prefix_: filter_query_param_prefix_
236
- }) {
237
- if (!to_url_) return to_url_;
238
- const was_url_object = to_url_ instanceof URL;
239
- const url_object = was_url_object ? to_url_ : new URL(to_url_, location.origin);
240
- const {
241
- searchParams: searchParams
242
- } = url_object;
243
- if (set_clearing_flag_) searchParams.set($1ab22f2cd39b3061$export$cf5feb2102aec7f2, "true");
244
- if (from_search_params_.has(sorting_query_param_)) searchParams.set(sorting_query_param_, from_search_params_.get(sorting_query_param_));
245
- for (const key of from_search_params_.keys()) if (key.startsWith(filter_query_param_prefix_)) searchParams.set(key, from_search_params_.get(key));
246
- if (was_url_object) return url_object;
247
- return url_object.href;
248
- }
249
- const $84798aaa863a4909$var$ListingContext = /*@__PURE__*/$gVhhF$solidjs.createContext();
250
- function $84798aaa863a4909$export$e68cff63f76bd15b(props) {
251
- const our_object = {};
252
- return $gVhhF$solidjsweb.createComponent($84798aaa863a4909$var$ListingContext.Provider, {
253
- value: our_object,
254
- get children() {
255
- return props.children;
256
- }
257
- });
258
- }
259
- function $84798aaa863a4909$export$8d0c4fdbb05a2f2e() {
260
- return $gVhhF$solidjs.useContext($84798aaa863a4909$var$ListingContext);
261
- }
262
- const $93304d59a9747aa6$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div>`);
263
- function $93304d59a9747aa6$export$94026ee33dbabc26(props) {
80
+ const $b757f75811f3261f$export$83d89fbfd8236492 = "3.0.0";
81
+ const $0f313083912e447a$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 14 26"><path d="M2 24.656c-.078 0-.156-.016-.234-.047s-.133-.066-.187-.129c-.117-.117-.176-.258-.176-.422s.059-.305.176-.422l10.371-10.371L1.578 2.883c-.117-.117-.176-.258-.176-.422s.059-.305.176-.422.258-.176.422-.176.305.059.422.176l10.805 10.793a.59.59 0 0 1 .176.434c0 .172-.059.305-.176.422L2.422 24.48a.42.42 0 0 1-.199.129.54.54 0 0 1-.223.047zm0 0"fill=#0f0f0f>`);
82
+ function $0f313083912e447a$export$8be2714ec7f169ee(props = {}) {
264
83
  return (() => {
265
- const _el$ = $gVhhF$solidjsweb.getNextElement($93304d59a9747aa6$var$_tmpl$);
84
+ const _el$ = $gVhhF$solidjsweb.getNextElement($0f313083912e447a$var$_tmpl$);
266
85
  $gVhhF$solidjsweb.effect(_p$ => {
267
- const _v$ = `position:relative;width:100%;padding-bottom:${1 / props.aspectRatio * 100}%`,
268
- _v$2 = props.class;
269
- _p$._v$ = $gVhhF$solidjsweb.style(_el$, _v$, _p$._v$);
270
- _v$2 !== _p$._v$2 && $gVhhF$solidjsweb.className(_el$, _p$._v$2 = _v$2);
86
+ const _v$ = props.width_ ?? 14,
87
+ _v$2 = props.height_ ?? 26;
88
+ _v$ !== _p$._v$ && $gVhhF$solidjsweb.setAttribute(_el$, "width", _p$._v$ = _v$);
89
+ _v$2 !== _p$._v$2 && $gVhhF$solidjsweb.setAttribute(_el$, "height", _p$._v$2 = _v$2);
271
90
  return _p$;
272
91
  }, {
273
92
  _v$: undefined,
@@ -276,204 +95,532 @@ function $93304d59a9747aa6$export$94026ee33dbabc26(props) {
276
95
  return _el$;
277
96
  })();
278
97
  }
279
- function $19950faaac026e09$export$e6fffe67d4cdd848(whatToWatch) {
280
- const [size, setSize] = $gVhhF$solidjs.createSignal(0);
281
- const resizeObserver = new ResizeObserver($gVhhF$depictaiutilishared.catchify(records => {
282
- for (let j = 0; j < records.length; j++) {
283
- const {
284
- width: width
285
- } = records[j].contentRect;
286
- if (!width) continue;
287
- // add extra 5% just in case. + safari is (in some cases) acting a bit questionable and needs a third extra to fill the set width
288
- const new_size = width * 1.05 * ((0, $gVhhF$depictaiutilishared.is_safari) ? 4 / 3 : 1);
289
- setSize(Math.round(new_size));
98
+ const $a0e53f99354809d9$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div>`);
99
+ function $a0e53f99354809d9$export$6649caad96ef8870({
100
+ children: children,
101
+ slider_ref_: slider_ref_,
102
+ faded_opacity_ = 0.7,
103
+ mutation_plugins_ = [],
104
+ disable_fading_: disable_fading_,
105
+ arrow_width_: arrow_width_,
106
+ arrow_height_: arrow_height_
107
+ }) {
108
+ const slider = new (0, $gVhhF$depictaiutilishared.Amazing_Slider)({
109
+ button_contents: {
110
+ left: [(() => {
111
+ const _el$ = $gVhhF$solidjsweb.getNextElement($a0e53f99354809d9$var$_tmpl$);
112
+ $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent((0, $0f313083912e447a$export$8be2714ec7f169ee), {
113
+ height_: arrow_height_,
114
+ width_: arrow_width_
115
+ }));
116
+ return _el$;
117
+ })()],
118
+ right: [(() => {
119
+ const _el$2 = $gVhhF$solidjsweb.getNextElement($a0e53f99354809d9$var$_tmpl$);
120
+ $gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $0f313083912e447a$export$8be2714ec7f169ee), {
121
+ height_: arrow_height_,
122
+ width_: arrow_width_
123
+ }));
124
+ return _el$2;
125
+ })()]
126
+ },
127
+ constructor_plugins: [$gVhhF$depictaiutilishared.slider_snap_css().constructor_plugin],
128
+ mutation_plugins: [...(disable_fading_ ? [] : [$gVhhF$depictaiutilishared.slider_fading_factory({
129
+ threshold_: 0.96,
130
+ faded_opacity_: faded_opacity_
131
+ }).mutation_plugin_]), ...mutation_plugins_]
132
+ });
133
+ $gVhhF$solidjsweb.insert(slider.insert_here, children);
134
+ $gVhhF$solidjs.onCleanup(() => slider.observer.disconnect());
135
+ slider_ref_?.(slider);
136
+ return slider.container;
137
+ }
138
+ const $8c38828ae2321937$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<section aria-live=polite role=region class=tabs-body>`),
139
+ $8c38828ae2321937$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<nav role=tablist class=tabs-bar>`),
140
+ $8c38828ae2321937$var$_tmpl$3 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<article role=tabpanel>`);
141
+ const $8c38828ae2321937$var$TabsContext = /*@__PURE__*/$gVhhF$solidjs.createContext();
142
+ const $8c38828ae2321937$var$useTabs = () => $gVhhF$solidjs.useContext($8c38828ae2321937$var$TabsContext);
143
+ function $8c38828ae2321937$export$b2539bed5023c21c(props) {
144
+ return $gVhhF$solidjsweb.createComponent($8c38828ae2321937$var$TabsContext.Provider, {
145
+ value: new (0, $gVhhF$depictaiutilisharedlatest.ListenableSet)(),
146
+ get children() {
147
+ return $gVhhF$solidjsweb.createComponent($8c38828ae2321937$var$ActualTabs, $gVhhF$solidjsweb.mergeProps(props, {
148
+ get children() {
149
+ return props.children;
150
+ }
151
+ }));
290
152
  }
291
- }));
292
- // If we start observing elements before they're in the DOM Chrome (Version 117.0.5938.92 (Official Build) (arm64)) sometimes gives us a resize event with a width of 0 and then doesn't dispatch one with the actual width once it's in the DOM. So we wait until the element is in the DOM before we start observing it.
293
- // It doesn't seem to work even when waiting for it to be in the DOM, also wait an animation frame
294
- const disconnect = (0, $gVhhF$depictaiutilishared.observer).onexists(whatToWatch, ({
295
- element: element
296
- }) => requestAnimationFrame($gVhhF$depictaiutilishared.catchify(() => resizeObserver.observe(element))));
297
- $gVhhF$solidjs.onCleanup(() => {
298
- resizeObserver.disconnect();
299
- disconnect();
300
153
  });
301
- return size;
302
154
  }
303
- const $19950faaac026e09$var$onIdleFunctionsSymbol = /*@__PURE__*/Symbol("onIdleFunctions");
304
- function $19950faaac026e09$export$6e5611bc7e57e477(props) {
305
- // Enable reactive props
306
- const otherOptions = $gVhhF$solidjs.createMemo(() => {
307
- const cloned_props = {
308
- ...props
309
- };
310
- delete cloned_props.resolutions;
311
- // @ts-ignore
312
- delete cloned_props.size;
313
- // @ts-ignore
314
- delete cloned_props.src;
315
- return cloned_props;
316
- });
317
- const src_options = $gVhhF$solidjs.createMemo(() => {
318
- const src = new URL(props.src, location.origin);
319
- const fallback_src = $19950faaac026e09$var$generateImageUrl(src, 400);
320
- const srcset = $19950faaac026e09$var$make_srcset(src, props.resolutions || [64, 128, 256, 300, 400, 512, 768, 1024, 1280, 1536, 2048, 4096]);
321
- return {
322
- src: fallback_src,
323
- srcset: srcset
324
- };
155
+ function $8c38828ae2321937$var$ActualTabs(props) {
156
+ const [tabsReactive, setTabsReactive] = $gVhhF$solidjs.createSignal([]); // Can't have a store since reconciling with a store would call the children getters, and we could get x-tle rendered components
157
+ const [currentlySelected, setCurrentlySelected] = $gVhhF$solidjs.createSignal();
158
+ const [tabsVisitedOnce, setTabsVisitedOnce] = $gVhhF$solidjs.createSignal(new Set(), {
159
+ equals: false
325
160
  });
326
- // Work around https://github.com/solidjs/solid/issues/1828
327
- const img = new Image(); // Need to use new Image or browser might not start loading image before it's in the DOM
328
- const [hasSetSize, setHasSetSize] = $gVhhF$solidjs.createSignal(false);
329
- const [hasDecoded, setHasDecoded] = $gVhhF$solidjs.createSignal(false);
330
- const sizePX = $gVhhF$solidjs.createMemo(() => `${props.size()}px`); // props.size could be a getter that expects a cleanup so get it in this memo instead of where we set img.sizes
331
- const listingContext = $84798aaa863a4909$export$8d0c4fdbb05a2f2e();
332
- // Batch idle callbacks so that MutationObserver can batch the resulting mutations better, so we don't lose tons of CPU time to MutationObservers doing lots of things for each image
333
- // Happened on singular, they have some weird observer (+we also have one but ours is at least 3x more efficient)
334
- const executeWhenIdleBatched = fn => {
335
- if (typeof requestIdleCallback !== "function") return setTimeout(fn); // Old browsers don't get optimisation
336
- const existingStack = listingContext?.[$19950faaac026e09$var$onIdleFunctionsSymbol];
337
- if (existingStack) return existingStack.add(fn);
338
- const newStack = new Set([fn]);
339
- if (listingContext) listingContext[$19950faaac026e09$var$onIdleFunctionsSymbol] = newStack;
340
- const processStackWhenIdle = () => requestIdleCallback(deadline => {
341
- const start = performance.now();
342
- const thirdDeadlineTime = deadline.timeRemaining() / 3; // observers coming after this take up 2-3x the time so don't use all of it
343
- for (const fn of newStack) {
344
- newStack.delete(fn);
345
- fn();
346
- const timeTaken = performance.now() - start;
347
- if ((!deadline.timeRemaining() || timeTaken > thirdDeadlineTime) && newStack.size) {
348
- // There's still work to be done but no time, so schedule another idle callback
349
- processStackWhenIdle();
350
- return;
351
- }
352
- }
353
- // Stack is empty
354
- if (listingContext) delete listingContext[$19950faaac026e09$var$onIdleFunctionsSymbol];
355
- }, {
356
- timeout: 15000
357
- } // long timeout, better to not have images than to freeze the browser. But also we don't want to confuse user why no iamges are loading
358
- );
359
-
360
- processStackWhenIdle();
161
+ const isSelected = $gVhhF$solidjs.createSelector(currentlySelected);
162
+ const owner = $gVhhF$solidjs.getOwner();
163
+ const updateTabsSignal = $gVhhF$depictaiutilisharedlatest.catchify(() => $gVhhF$solidjs.runWithOwner(owner, () => setTabsReactive([...ourTabsSet])));
164
+ const ourTabsSet = $8c38828ae2321937$var$useTabs();
165
+ const location = $gVhhF$depictaiutilisharedlatest.use_href_accessor();
166
+ const linkWithChangedHash = hash => {
167
+ const u_o = new URL(location());
168
+ u_o.hash = hash;
169
+ return u_o.href;
361
170
  };
362
- let sizeSetFastPath = false;
363
- let hasDecodedFastPath = false;
364
- let timeoutSet = false;
365
- let gotCleanedUp = false;
366
- $gVhhF$solidjs.onCleanup(() => gotCleanedUp = true);
367
- $gVhhF$solidjsweb.spread(img, $gVhhF$solidjs.mergeProps(otherOptions), false, true);
368
- $gVhhF$solidjs.createEffect(() => {
369
- if (!props.size()) return; // wait until we have a size
370
- if (timeoutSet) return;
371
- const handler = $gVhhF$depictaiutilishared.catchify(() => {
372
- if (gotCleanedUp) return;
373
- img.sizes = sizePX(); // use latest available value of props.size
374
- if (!sizeSetFastPath) {
375
- setHasSetSize(true);
376
- sizeSetFastPath = true;
377
- }
378
- timeoutSet = false;
379
- });
380
- // Throttle the updating of sizes to avoid unnecessary image re-fetches during resize
381
- // And also because we first set src after sizes has been set, wait with loading and decoding images until browser is idle
382
- // This greatly improves performance when loading (more) products
383
- // See https://depictaiworkspace.slack.com/archives/C05NJ0K3WRL/p1698220617663139
384
- executeWhenIdleBatched(handler);
385
- timeoutSet = true;
171
+ const headerItems = $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Index), {
172
+ get each() {
173
+ return tabsReactive();
174
+ },
175
+ children: item => {
176
+ const weSelected = $gVhhF$solidjs.createMemo(() => isSelected(item().id));
177
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjsweb.Dynamic), $gVhhF$solidjsweb.mergeProps({
178
+ get component() {
179
+ return props.AnchorComponent;
180
+ },
181
+ get ["aria-controls"]() {
182
+ return item().id;
183
+ },
184
+ role: "tab",
185
+ get classList() {
186
+ return {
187
+ selected: weSelected()
188
+ };
189
+ }
190
+ }, () => weSelected() ? {} : {
191
+ href: linkWithChangedHash(item().id)
192
+ }, {
193
+ get children() {
194
+ return item().label;
195
+ }
196
+ }));
197
+ }
386
198
  });
199
+ // Enable nice pattern of doing <Tabs><Tab>Content</Tab><Tab>More content</Tab></Tabs>
200
+ $gVhhF$solidjs.children(() => props.children); // "Render" children (.children is a getter), this means that we now can connect the children with the parent
201
+ for (const event of ["add", "delete"]) {
202
+ ourTabsSet.addEventListener(event, updateTabsSignal);
203
+ $gVhhF$solidjs.onCleanup(() => ourTabsSet.removeEventListener(event, updateTabsSignal));
204
+ }
205
+ updateTabsSignal();
387
206
  $gVhhF$solidjs.createEffect(() => {
388
- if (!props.size() || !hasSetSize()) return; // If size isn't known or set, don't assign src yet since it would cause the most low res image to load
389
- Object.assign(img, src_options());
390
- // Add to DOM once decoded to not require/block any paints before image has completed loading and avoid showing broken image symbol
391
- // We can do this because there has to be a container around us giving us a size
392
- // No need to listen if we're already in the DOM
393
- if (hasDecodedFastPath) return;
394
- if (props.loading === "lazy") {
395
- // For lazy loading there's no decoding to wait for as it only occurs when the image is visible
396
- // Make sure src is set before we put the image into the DOM though so no broken image symbol is shown
397
- setHasDecoded(true);
398
- hasDecodedFastPath = true;
207
+ const {
208
+ hash: hash
209
+ } = new URL(location());
210
+ const id = hash.slice(1);
211
+ if (tabsReactive().some(item => item.id === id)) {
212
+ setCurrentlySelected(id);
399
213
  return;
400
214
  }
401
- img.decode().catch(e => $gVhhF$depictaiutilishared.dwarn("Failed to decode image", e, img)) // Display the image also if loading failed so webdev can debug and doesn't get "no image"
402
- .then(async () => {
403
- // Also wait with inserting image (i.e. paint) until browser is idle
404
- await new Promise(r => executeWhenIdleBatched(r));
405
- if (gotCleanedUp) return;
406
- setHasDecoded(true);
407
- hasDecodedFastPath = true;
408
- });
409
- });
410
- return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
411
- get when() {
412
- return hasDecoded();
413
- },
414
- children: img
215
+ if (!currentlySelected() || !tabsReactive().some(item => item.id === currentlySelected())) {
216
+ // Select first one by default if possible
217
+ const firstTab = tabsReactive()[0]?.id;
218
+ if (!firstTab) return;
219
+ setCurrentlySelected(firstTab);
220
+ }
415
221
  });
222
+ return [$gVhhF$solidjsweb.memo(() => (props.wrapTabBar || (v => v))((() => {
223
+ const _el$2 = $gVhhF$solidjsweb.getNextElement($8c38828ae2321937$var$_tmpl$2);
224
+ $gVhhF$solidjsweb.insert(_el$2, (() => {
225
+ const _c$ = $gVhhF$solidjsweb.memo(() => !!props.slidable);
226
+ return () => _c$() ? $gVhhF$solidjsweb.createComponent((0, $a0e53f99354809d9$export$6649caad96ef8870), {
227
+ children: headerItems
228
+ }) : headerItems;
229
+ })());
230
+ return _el$2;
231
+ })())), (() => {
232
+ const _el$ = $gVhhF$solidjsweb.getNextElement($8c38828ae2321937$var$_tmpl$);
233
+ $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Index), {
234
+ get each() {
235
+ return tabsReactive();
236
+ },
237
+ children: item => {
238
+ const weSelected = $gVhhF$solidjs.createMemo(() => isSelected(item().id));
239
+ $gVhhF$solidjs.createEffect(() => {
240
+ if (weSelected()) {
241
+ setTabsVisitedOnce(prev => {
242
+ prev.add(item().id);
243
+ return prev;
244
+ });
245
+ $gVhhF$solidjs.untrack(() => item().onSelected?.());
246
+ }
247
+ });
248
+ $gVhhF$solidjs.onCleanup(() => setTabsVisitedOnce(prev => (prev.delete(item().id), prev)));
249
+ return (() => {
250
+ const _el$3 = $gVhhF$solidjsweb.getNextElement($8c38828ae2321937$var$_tmpl$3);
251
+ $gVhhF$solidjsweb.insert(_el$3, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
252
+ get when() {
253
+ return tabsVisitedOnce().has(item().id);
254
+ },
255
+ get children() {
256
+ return item().children;
257
+ }
258
+ }));
259
+ $gVhhF$solidjsweb.effect(_p$ => {
260
+ const _v$ = item().id,
261
+ _v$2 = !!weSelected(),
262
+ _v$3 = weSelected() ? "" : "none";
263
+ _v$ !== _p$._v$ && $gVhhF$solidjsweb.setAttribute(_el$3, "id", _p$._v$ = _v$);
264
+ _v$2 !== _p$._v$2 && _el$3.classList.toggle("selected", _p$._v$2 = _v$2);
265
+ _v$3 !== _p$._v$3 && ((_p$._v$3 = _v$3) != null ? _el$3.style.setProperty("display", _v$3) : _el$3.style.removeProperty("display"));
266
+ return _p$;
267
+ }, {
268
+ _v$: undefined,
269
+ _v$2: undefined,
270
+ _v$3: undefined
271
+ });
272
+ return _el$3;
273
+ })();
274
+ }
275
+ }));
276
+ return _el$;
277
+ })()];
416
278
  }
417
- function $19950faaac026e09$var$make_srcset(url, resolutions) {
418
- return resolutions.map(width => `${$19950faaac026e09$var$generateImageUrl(url, width)} ${width}w`).join(", ");
419
- }
420
- function $19950faaac026e09$var$generateImageUrl(url, width) {
421
- // This function is quite slow, we maybe could do string concat with encodeURIComponent instead if shopify handles double width params well?
422
- url.searchParams.set("width", width);
423
- return url.href;
279
+ function $8c38828ae2321937$export$3e41faf802a29e71(props) {
280
+ const currentTabs = $8c38828ae2321937$var$useTabs();
281
+ if (!currentTabs) throw new Error("Tab must be a child of Tabs");
282
+ const id = $gVhhF$solidjs.createUniqueId();
283
+ const ourSet = currentTabs;
284
+ const extendedProps = $gVhhF$solidjs.mergeProps({
285
+ id: id
286
+ }, props);
287
+ ourSet.add(extendedProps);
288
+ $gVhhF$solidjs.onCleanup(() => ourSet.delete(extendedProps));
289
+ return undefined;
424
290
  }
425
- const $a33065cfed827fc0$var$backupSizeSignal = /*@__PURE__*/$gVhhF$solidjs.createSignal();
426
- const $a33065cfed827fc0$export$d7b7ab832c20e2f4 = /*@__PURE__*/Symbol("ShopifyContainedImage");
427
- function $a33065cfed827fc0$export$e4b984597b71e989(props) {
428
- const context = $84798aaa863a4909$export$8d0c4fdbb05a2f2e();
429
- if (context && !context[$a33065cfed827fc0$export$d7b7ab832c20e2f4])
430
- // create a signal that's the same for all items in this listing
431
- context[$a33065cfed827fc0$export$d7b7ab832c20e2f4] = $gVhhF$solidjs.createSignal();
432
- const [currentImageSize, setCurrentImageSize] = context?.[$a33065cfed827fc0$export$d7b7ab832c20e2f4] || $a33065cfed827fc0$var$backupSizeSignal; // use global fallback signal (might lead to blurry images) if no context is available
433
- const container = $gVhhF$solidjsweb.createComponent((0, $93304d59a9747aa6$export$94026ee33dbabc26), {
434
- get aspectRatio() {
435
- return props.aspectRatio;
436
- },
437
- get ["class"]() {
438
- return props.class;
291
+ async function $9abb0a35d4b60ed3$export$79b1565500412d9b(search_modal, modal_fn_opts, parent) {
292
+ const body = parent || (await (0, $gVhhF$depictaiutilishared.observer).wait_for_element("body"));
293
+ let dispose_and_remove;
294
+ const open_modal_ = $gVhhF$depictaiutilishared.catchify(async (extra_options_for_modal = {}, on_dispose) => {
295
+ // Below await is very intentional,
296
+ // The reason is that effects don't run in <Suspense> boundaries before they've resolved and this carries even through roots created, but if a modal is opened from a suspense boundary we still want the effects in it to run
297
+ // This is because the suspense is for the content in the page and not the modal (the modal goes above it)
298
+ // By having an await here, solid loses all its knowledge of the suspense boundary
299
+ // (there is also some bug where effects don't run when created inside a suspense boundary that is resolved)
300
+ if (await dispose_and_remove)
301
+ // modal is already open
302
+ return;
303
+ const modal_els = $gVhhF$solidjs.createRoot(dispose => {
304
+ let closing_animation;
305
+ let animation_started;
306
+ dispose_and_remove = () => {
307
+ const actually_close = () => {
308
+ dispose();
309
+ on_dispose?.();
310
+ modal_els.forEach(el => el.remove());
311
+ };
312
+ if (animation_started && +new Date() - animation_started > 1000)
313
+ // Animation broke, close it this time
314
+ actually_close();else if (!animation_started && closing_animation) {
315
+ animation_started = +new Date();
316
+ $gVhhF$depictaiutilishared.catchify(closing_animation)()?.then($gVhhF$depictaiutilishared.catchify(actually_close));
317
+ } else actually_close();
318
+ };
319
+ return search_modal({
320
+ ...modal_fn_opts,
321
+ ...extra_options_for_modal,
322
+ close_modal_: close_modal_,
323
+ open_modal_: open_modal_,
324
+ register_closing_animation_: animation => closing_animation = animation
325
+ });
326
+ });
327
+ body.append(...modal_els);
328
+ });
329
+ const close_modal_ = $gVhhF$depictaiutilishared.catchify(() => {
330
+ if (dispose_and_remove) {
331
+ // modal is open
332
+ const dispose_fn = dispose_and_remove;
333
+ // set dispose function to undefined in case that it triggers this dispose function itself. Not doing it leads to a bug like https://github.com/solidjs/solid/discussions/1194
334
+ dispose_and_remove = undefined;
335
+ dispose_fn();
439
336
  }
440
337
  });
441
- const owner = $gVhhF$solidjs.getOwner();
442
- let createdSizeAccessor = false;
443
- let wasCleanedUp = false;
444
- $gVhhF$solidjs.createEffect(() => {
445
- if (currentImageSize() || wasCleanedUp) return; // We get into the effect when onCleanup is called if we don't have wasCleanedUp
446
- // ensure we always have a size accessor
447
- // what this whole thing does is set the sizes attribute to the actual size of one of the existing image containers, therefore the value doesn't have to manually be specified
448
- createdSizeAccessor = true;
449
- setCurrentImageSize(() => $gVhhF$solidjs.runWithOwner(owner, () => $19950faaac026e09$export$e6fffe67d4cdd848(container)));
338
+ return {
339
+ open_modal_: open_modal_,
340
+ close_modal_: close_modal_
341
+ };
342
+ }
343
+ function $6e22b5314fb52f4c$export$e183a13865960371(params_to_default_value, router_) {
344
+ const signals = {};
345
+ const entries = Object.entries(params_to_default_value);
346
+ const event_handler = $gVhhF$depictaiutilishared.catchify((what_happened, args) => {
347
+ // Intentionally always update our signals to the history state to allow external control of SDK state for doing things like https://linear.app/depictai/issue/X-1432/is-this-possible-with-the-depict-sdk
348
+ if (what_happened !== "popstate") return;
349
+ // Had to undo the comment above,but leaving the history. Doing this because discovering why it doesn't work is a deja-vu and I don't want to have to discover it again.
350
+ // If we want others to interface with our state, it's better to expose it from DepictCategory/DepictSearch
351
+ // The reason for that is because writes to the state trigger writes to the state (something about local filter state, see the comment where `last_remote_state !== available_filters_()` happens in create_modified_filters.tsx)
352
+ // And can infinite loop, like in https://app.jiminny.com/playback/569c8f65-edea-4735-bd9e-4eb5a0b14cad
353
+ // It's the classical equilibrium problem when syncing state both down and up, and it's much easier to avoid than solve
354
+ $6e22b5314fb52f4c$var$history_state_change(signals, entries, args.state);
450
355
  });
451
- $gVhhF$solidjs.onCleanup(() => {
452
- wasCleanedUp = true; // important to set this before the function call below and always, so the dead effects don't create dead size accessors
453
- if (!createdSizeAccessor) return;
454
- $gVhhF$depictaiutilishared.queueMacroTask(() => setCurrentImageSize(undefined)); // unset the size accessor next event loop iteration, so that all onCleanup's have time to run, since the effects run more aggressively and can create a size accessor with a cleaned up owner otherwise
356
+ // createRenderEffect because we need the instant execution so the signals always contain values, even before solid's render phase
357
+ $gVhhF$solidjs.createRenderEffect(() => {
358
+ let signal_changed = false;
359
+ let {
360
+ state: state
361
+ } = globalThis?.history || {
362
+ state: {}
363
+ }; // cloning isn't necessary because we're calling replaceState on it anyway
364
+ if (state === null || typeof state != "object") state = {};
365
+ for (const [param, default_value] of entries) {
366
+ const [read_signal] = signals[param] ||= $gVhhF$solidjs.createSignal(state[param] ?? default_value);
367
+ const new_value = read_signal();
368
+ if (new_value !== state[param]) {
369
+ signal_changed = true;
370
+ state[param] = new_value;
371
+ }
372
+ }
373
+ if (signal_changed) router_.navigate_.replace_state_(state);
455
374
  });
456
-
457
- $gVhhF$solidjsweb.insert(container, $gVhhF$solidjsweb.createComponent((0, $19950faaac026e09$export$6e5611bc7e57e477), {
458
- style: "width: 100%; height: 100%; object-fit: contain; position: absolute; inset: 0;",
459
- get size() {
460
- return $gVhhF$solidjs.createMemo(() => currentImageSize()?.() || 0);
375
+ // history_dot_state_to_state needs to update after its signals after url_state does BUT in the same task (might even have to be in the same tick in the microtask queue). If we'd use window.addEventListener("popstate") it would be guaranteed to be too late since each event listener has its own task
376
+ (0, $gVhhF$depictaiutilishared.instant_exec_on_suspect_history_change).add(event_handler);
377
+ $gVhhF$solidjs.onCleanup($gVhhF$depictaiutilishared.catchify(() => (0, $gVhhF$depictaiutilishared.instant_exec_on_suspect_history_change).delete(event_handler)));
378
+ $gVhhF$solidjs.createEffect($gVhhF$depictaiutilishared.catchify(() => $gVhhF$solidjs.untrack($gVhhF$depictaiutilishared.catchify(() => $6e22b5314fb52f4c$var$history_state_change(signals, entries, history.state))))); // we need this to run after reading the initial state from history.state to write the defaults to history.state
379
+ return signals;
380
+ }
381
+ function $6e22b5314fb52f4c$var$history_state_change(signals, entries, state) {
382
+ $gVhhF$solidjs.batch(() => {
383
+ for (const [param, default_value] of entries) {
384
+ const [, write_signal] = signals[param];
385
+ const new_value = state?.[param];
386
+ write_signal(new_value ?? default_value);
387
+ }
388
+ });
389
+ }
390
+ const $d84fe647b84b5dc5$export$3064e1e8c6513da3 = new Set();
391
+ let $d84fe647b84b5dc5$var$has_ran = false;
392
+ function $d84fe647b84b5dc5$export$5162a71f252e6122() {
393
+ if ($d84fe647b84b5dc5$var$has_ran || typeof history !== "object") return;
394
+ $d84fe647b84b5dc5$var$has_ran = true;
395
+ for (const function_name of ["replaceState", "pushState"]) {
396
+ if (Object.getOwnPropertyNames(history).includes(function_name)) $d84fe647b84b5dc5$var$proxy_push_state(function_name, history);
397
+ $d84fe647b84b5dc5$var$proxy_push_state(function_name, History.prototype);
398
+ }
399
+ }
400
+ function $d84fe647b84b5dc5$var$proxy_push_state(function_name, thing) {
401
+ thing[function_name] = new Proxy(thing[function_name], {
402
+ apply(target, this_arg, arg_list) {
403
+ try {
404
+ const old_state = history.state;
405
+ if (typeof old_state == "object" && old_state !== null) {
406
+ // This effectively disallows the user from passing in a string, number, null or undefined
407
+ const intended_new_value_as_obj = typeof arg_list[0] === "object" ? arg_list[0] ?? {} : {};
408
+ const cloned_object = {
409
+ ...intended_new_value_as_obj
410
+ };
411
+ for (const key in old_state) {
412
+ if (!$d84fe647b84b5dc5$var$starts_with_any_prefix(key)) continue;
413
+ if (!(key in cloned_object)) cloned_object[key] = old_state[key];
414
+ }
415
+ arg_list[0] = cloned_object;
416
+ }
417
+ } catch (e) {
418
+ $gVhhF$depictaiutilishared.report([e, "Failed to preserve items in history.state"], "error");
419
+ }
420
+ return Reflect.apply(target, this_arg, arg_list);
421
+ }
422
+ });
423
+ }
424
+ function $d84fe647b84b5dc5$var$starts_with_any_prefix(key) {
425
+ for (const prefix of $d84fe647b84b5dc5$export$3064e1e8c6513da3) {
426
+ if (key.startsWith(prefix)) return true;
427
+ }
428
+ }
429
+ class $e96dd13889871fc0$export$7e1297a3a19f10d8 {
430
+ /**
431
+ * Function that will be called when we want to navigate, or a string saying it's not an SPA. You can change this OTG
432
+ */ /**
433
+ * We store listing_id in history.state and do operate on this both here and in js-ui, this is the key to be used which js-ui provides
434
+ */
435
+ #throwing_on_navigation(...args) {
436
+ const {
437
+ on_navigation_: on_navigation_
438
+ } = this;
439
+ if (typeof on_navigation_ !== "function") throw new Error("on_navigation_ is not a function");
440
+ // make sure that we don't accidentally catchify if the SDK consumer has fucked up
441
+ try {
442
+ return on_navigation_(...args);
443
+ } catch (e) {
444
+ queueMicrotask(() => {
445
+ throw e;
446
+ });
447
+ }
448
+ }
449
+ /**
450
+ * Checks if this tab shouldn't navigate because user wants to open in new tab
451
+ */
452
+ #dont_attempt_navigation(ev) {
453
+ return ev?.button || ev?.metaKey || ev?.ctrlKey;
454
+ }
455
+ /**
456
+ * Vue has async router that needs to be awaited (it navigates after a microtask)
457
+ * This standardises waiting for all kinds of routers
458
+ */
459
+ #get_navigation_happened_promise(is_replace) {
460
+ return new Promise(resolve => {
461
+ const handler = what_happened => {
462
+ if (what_happened === (is_replace ? "replaceState" : "pushState")) {
463
+ resolve();
464
+ (0, $gVhhF$depictaiutilishared.instant_exec_on_suspect_history_change).delete(handler);
465
+ }
466
+ };
467
+ (0, $gVhhF$depictaiutilishared.instant_exec_on_suspect_history_change).add(handler);
468
+ });
469
+ }
470
+ navigate_ = {
471
+ /**
472
+ * Call this if you *just* want to replace the state object in history.state
473
+ */
474
+ replace_state_: new_state => {
475
+ // This doesn't break any router, so we just do this directly for now, since many don't expose an interface for changing the state
476
+ globalThis?.history?.replaceState(new_state, "");
461
477
  },
462
- get src() {
463
- return props.src;
478
+ /**
479
+ * Call this to change the URL
480
+ * @param new_url_ new URL to go to
481
+ * @param event_ event if you have this in a click handler, will not do anything on cmd/ctrl or non-left click then
482
+ * @param force_spa_navigation_ if you want to force SPA navigation even if on_navigation_ is set to "hard_navigation". You should only set this to true for inter-SDK-page navigations
483
+ * @param is_replace_ if you want to replace the current URL in history instead of pushing a new one
484
+ * @param listing_id_ If you are navigating to a category and know the listing_id of, please provide it. This is for making a better devEx in js-ui
485
+ */
486
+ go_to_: $gVhhF$depictaiutilishared.catchify(async ({
487
+ new_url_: raw_new_url,
488
+ event_: event_,
489
+ force_spa_navigation_: force_spa_navigation_,
490
+ is_replace_: is_replace_,
491
+ listing_id_: listing_id_,
492
+ scroll = true
493
+ }) => {
494
+ const new_url_ = raw_new_url instanceof URL ? raw_new_url : new URL(raw_new_url, location.origin);
495
+ const wants_hard_navigation = this.on_navigation_ === "hard_navigation";
496
+ if (this.#dont_attempt_navigation(event_)) return;
497
+ const different_origin = new_url_.origin !== location.origin;
498
+ if (wants_hard_navigation && (!force_spa_navigation_ || different_origin)) {
499
+ if (force_spa_navigation_ && different_origin)
500
+ // If we call history.pushState on a different origin, it will throw an error, so fallback to hard navigations
501
+ $gVhhF$depictaiutilishared.dwarn("Can't single page navigate to", new_url_.href, "due to different origin, this MIGHT mean you should fix the URLs");
502
+ if (!event_)
503
+ // If we haven't gotten an event, nothing will happen by not calling prevent default, so we need to change the URL
504
+ location.assign(new_url_);
505
+ return;
506
+ }
507
+ event_?.preventDefault();
508
+ const promise = this.#get_navigation_happened_promise(true);
509
+ if (force_spa_navigation_ && wants_hard_navigation) {
510
+ // Don't allow hard navigation if we're forcing SPA navigation, which we do for things where PageReplacer can be used for performance
511
+ const new_state = history.state;
512
+ if (listing_id_) {
513
+ // In JS-UI we need to know the listing_id of the current category, therefore push it into state
514
+ if (!this.listing_id_state_key) $gVhhF$depictaiutilishared.report(new Error("listing_id_state_key is not set"), "error");
515
+ new_state[this.listing_id_state_key] = listing_id_;
516
+ }
517
+ history[is_replace_ ? "replaceState" : "pushState"](new_state, "", new_url_);
518
+ } else this.#throwing_on_navigation.call(this, {
519
+ is_replace: is_replace_,
520
+ new_url: new_url_ instanceof URL ? new_url_ : new URL(new_url_, location.origin),
521
+ scroll: scroll
522
+ });
523
+ await promise;
524
+ })
525
+ };
526
+ constructor(on_navigation, listing_id_state_key) {
527
+ this.listing_id_state_key = listing_id_state_key;
528
+ this.on_navigation_ = on_navigation;
529
+ }
530
+ }
531
+ function $ca1176b694a6ee2e$export$fe334901e8bebd57() {
532
+ const cleanup_fns = [];
533
+ const cleanup = () => cleanup_fns.forEach(f => f());
534
+ // use an animation to automatically retain the `overflow` values and all other styling
535
+ for (const element of [document.documentElement, document.body]) {
536
+ try {
537
+ const animation = element.animate({
538
+ overflow: "hidden",
539
+ offset: 0
540
+ }, 1);
541
+ animation.pause();
542
+ const fn = $gVhhF$depictaiutilishared.catchify(animation.play.bind(animation));
543
+ cleanup_fns.push(fn);
544
+ $gVhhF$solidjs.onCleanup(fn);
545
+ } catch (e) {
546
+ $gVhhF$depictaiutilishared.dlog("Probably partial keyframe error", e);
464
547
  }
465
- }));
466
- return container;
548
+ if (getComputedStyle(element).overflow !== "hidden") {
549
+ // safari gets special hacky treatment
550
+ const style = element.style;
551
+ const original_value = style.overflow;
552
+ style.overflow = "hidden";
553
+ const fn = $gVhhF$depictaiutilishared.catchify(() => style.overflow = original_value);
554
+ cleanup_fns.push(fn);
555
+ $gVhhF$solidjs.onCleanup(fn);
556
+ }
557
+ }
558
+ return cleanup;
559
+ } // the way that houdini does that (FYI) it fixes the page jumps
560
+ // const from_top = scrollY;
561
+ // document.body.style.position = "fixed";
562
+ // document.body.style.left = 0;
563
+ // document.body.style.right = 0;
564
+ // document.body.style.top = `-${from_top}px`;
565
+ // document.body.style.overflowY = "scroll";
566
+
567
+ // Errors caused by SDK consuming code interfacing with the SDK, not the SDK itself or other Depict packages
568
+ class $7dd1edb2ee2b43ad$export$e1d52e4f0c7557a1 extends Error {}
569
+ class $7dd1edb2ee2b43ad$export$aa14a9f43128f61f extends $7dd1edb2ee2b43ad$export$e1d52e4f0c7557a1 {
570
+ constructor(templateError) {
571
+ super("Uncaught error in product card template", {
572
+ cause: templateError
573
+ });
574
+ }
467
575
  }
468
- const $0f313083912e447a$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 14 26"><path d="M2 24.656c-.078 0-.156-.016-.234-.047s-.133-.066-.187-.129c-.117-.117-.176-.258-.176-.422s.059-.305.176-.422l10.371-10.371L1.578 2.883c-.117-.117-.176-.258-.176-.422s.059-.305.176-.422.258-.176.422-.176.305.059.422.176l10.805 10.793a.59.59 0 0 1 .176.434c0 .172-.059.305-.176.422L2.422 24.48a.42.42 0 0 1-.199.129.54.54 0 0 1-.223.047zm0 0"fill=#0f0f0f>`);
469
- function $0f313083912e447a$export$8be2714ec7f169ee(props = {}) {
576
+ const $edafe91daf3091d7$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div><!$><!/><!$><!/>`);
577
+ function $edafe91daf3091d7$export$b69d0d92862de18b(props) {
578
+ return $gVhhF$solidjs.ErrorBoundary({
579
+ fallback(err, retry) {
580
+ const {
581
+ message_: message_,
582
+ severity_: severity_
583
+ } = props;
584
+ let message = message_;
585
+ if (err instanceof (0, $7dd1edb2ee2b43ad$export$aa14a9f43128f61f)) {
586
+ console.error(err.cause);
587
+ message = `${message}: ${err.message}`;
588
+ } else $gVhhF$depictaiutilishared.report([err, message_], severity_);
589
+ return (() => {
590
+ const _el$ = $gVhhF$solidjsweb.getNextElement($edafe91daf3091d7$var$_tmpl$),
591
+ _el$2 = _el$.firstChild,
592
+ [_el$3, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$2.nextSibling),
593
+ _el$4 = _el$3.nextSibling,
594
+ [_el$5, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$4.nextSibling);
595
+ $gVhhF$solidjsweb.insert(_el$, message, _el$3, _co$);
596
+ $gVhhF$solidjsweb.insert(_el$, () => props.on_error_?.(retry), _el$5, _co$2);
597
+ $gVhhF$solidjsweb.effect(_$p => $gVhhF$solidjsweb.classList(_el$, Object.fromEntries(props.class_list_?.map(c => [c, true]) || []), _$p));
598
+ return _el$;
599
+ })();
600
+ },
601
+ get children() {
602
+ return props.children;
603
+ }
604
+ });
605
+ }
606
+ const $c77c68e559a1506c$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<svg xmlns=http://www.w3.org/2000/svg width=21.064 height=21.064 viewBox="0 0 21.064 21.064"><path d="M11.669 10.531l9.156-9.156a.78.78 0 0 0 .237-.569c0-.221-.079-.412-.237-.569A.8.8 0 0 0 20.24 0a.77.77 0 0 0-.569.237l-9.14 9.14-9.14-9.14A.79.79 0 0 0 .807 0a.77.77 0 0 0-.569.237A.78.78 0 0 0 0 .807a.77.77 0 0 0 .237.569l9.156 9.156-9.156 9.14c-.159.157-.237.349-.237.569s.079.412.237.569c.085.085.174.148.268.19a1.095 1.095 0 0 0 .316.048.894.894 0 0 0 .285-.048.84.84 0 0 0 .285-.19l9.139-9.14 9.14 9.14a.894.894 0 0 0 .268.19 1.049 1.049 0 0 0 .301.048.941.941 0 0 0 .301-.048.84.84 0 0 0 .285-.19.78.78 0 0 0 .237-.569c0-.221-.079-.412-.237-.569z">`);
607
+ function $c77c68e559a1506c$export$3b621d86b1566b2(props = {}) {
470
608
  return (() => {
471
- const _el$ = $gVhhF$solidjsweb.getNextElement($0f313083912e447a$var$_tmpl$);
609
+ const _el$ = $gVhhF$solidjsweb.getNextElement($c77c68e559a1506c$var$_tmpl$);
610
+ $gVhhF$solidjsweb.spread(_el$, props, true, true);
611
+ $gVhhF$solidjsweb.runHydrationEvents();
612
+ return _el$;
613
+ })();
614
+ }
615
+ const $9fe9883b1d8ecccc$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span>`);
616
+ function $9fe9883b1d8ecccc$export$acb3eaade4b23afd(props) {
617
+ return (() => {
618
+ const _el$ = $gVhhF$solidjsweb.getNextElement($9fe9883b1d8ecccc$var$_tmpl$);
472
619
  $gVhhF$solidjsweb.effect(_p$ => {
473
- const _v$ = props.width_ ?? 14,
474
- _v$2 = props.height_ ?? 26;
475
- _v$ !== _p$._v$ && $gVhhF$solidjsweb.setAttribute(_el$, "width", _p$._v$ = _v$);
476
- _v$2 !== _p$._v$2 && $gVhhF$solidjsweb.setAttribute(_el$, "height", _p$._v$2 = _v$2);
620
+ const _v$ = `depict-placeholder ${props.class || ""}`,
621
+ _v$2 = props.style;
622
+ _v$ !== _p$._v$ && $gVhhF$solidjsweb.className(_el$, _p$._v$ = _v$);
623
+ _p$._v$2 = $gVhhF$solidjsweb.style(_el$, _v$2, _p$._v$2);
477
624
  return _p$;
478
625
  }, {
479
626
  _v$: undefined,
@@ -482,109 +629,149 @@ function $0f313083912e447a$export$8be2714ec7f169ee(props = {}) {
482
629
  return _el$;
483
630
  })();
484
631
  }
485
- const $a0e53f99354809d9$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div>`);
486
- function $a0e53f99354809d9$export$6649caad96ef8870({
487
- children: children,
488
- slider_ref_: slider_ref_,
489
- faded_opacity_ = 0.7,
490
- mutation_plugins_ = [],
491
- disable_fading_: disable_fading_,
492
- arrow_width_: arrow_width_,
493
- arrow_height_: arrow_height_
494
- }) {
495
- const slider = new (0, $gVhhF$depictaiutilishared.Amazing_Slider)({
496
- button_contents: {
497
- left: [(() => {
498
- const _el$ = $gVhhF$solidjsweb.getNextElement($a0e53f99354809d9$var$_tmpl$);
499
- $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent((0, $0f313083912e447a$export$8be2714ec7f169ee), {
500
- height_: arrow_height_,
501
- width_: arrow_width_
502
- }));
503
- return _el$;
504
- })()],
505
- right: [(() => {
506
- const _el$2 = $gVhhF$solidjsweb.getNextElement($a0e53f99354809d9$var$_tmpl$);
507
- $gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $0f313083912e447a$export$8be2714ec7f169ee), {
508
- height_: arrow_height_,
509
- width_: arrow_width_
510
- }));
511
- return _el$2;
512
- })()]
632
+ function $3bc4a89b971a3af5$export$3f37af283f8fb843(props) {
633
+ const style = $gVhhF$solidjs.createMemo(() => {
634
+ const {
635
+ style: style,
636
+ height: height,
637
+ width: width,
638
+ aspectRatio: aspectRatio
639
+ } = props;
640
+ const is_image = aspectRatio != undefined;
641
+ const size_data = is_image ? {
642
+ width: "100%",
643
+ "padding-bottom": 1 / aspectRatio * 100 + "%"
644
+ } : {
645
+ width: width,
646
+ height: height
647
+ };
648
+ return {
649
+ display: "block",
650
+ ...(style || {}),
651
+ ...size_data
652
+ };
653
+ });
654
+ return $gVhhF$solidjsweb.createComponent((0, $9fe9883b1d8ecccc$export$acb3eaade4b23afd), {
655
+ get style() {
656
+ return style();
513
657
  },
514
- constructor_plugins: [$gVhhF$depictaiutilishared.slider_snap_css().constructor_plugin],
515
- mutation_plugins: [...(disable_fading_ ? [] : [$gVhhF$depictaiutilishared.slider_fading_factory({
516
- threshold_: 0.96,
517
- faded_opacity_: faded_opacity_
518
- }).mutation_plugin_]), ...mutation_plugins_]
658
+ get ["class"]() {
659
+ return props.class;
660
+ }
519
661
  });
520
- $gVhhF$solidjsweb.insert(slider.insert_here, children);
521
- $gVhhF$solidjs.onCleanup(() => slider.observer.disconnect());
522
- slider_ref_?.(slider);
523
- return slider.container;
524
662
  }
525
-
526
- /** @jsxImportSource solid-js */
527
-
528
- function $f13855d1b951b24a$export$ebdc3711f7e02ccd(what_to_watch) {
529
- const [width, setWidth] = $gVhhF$solidjs.createSignal();
530
- const resizeObserver = new ResizeObserver($gVhhF$depictaiutilishared.catchify(records => {
531
- for (let j = 0; j < records.length; j++) {
532
- const width = records[j].borderBoxSize?.[0]?.inlineSize ?? what_to_watch.getBoundingClientRect().width;
533
- setWidth(width);
663
+ const $bbe694fe824b9c78$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=image-container>`);
664
+ function $bbe694fe824b9c78$export$41e1a079d40a0d58(props) {
665
+ const [display] = $gVhhF$solidjs.createResource(() => ({
666
+ merchant: props.merchant_,
667
+ market: props.market_,
668
+ locale: props.locale_,
669
+ product_ids: [props.productId_]
670
+ }), async request => {
671
+ const response = await fetch($gVhhF$depictaiutilishared.add_version_query_params(`${(0, $gVhhF$depictaiutilishared.base_url)}/v3/get-displays`), {
672
+ method: "POST",
673
+ body: JSON.stringify(request)
674
+ });
675
+ const decoded = await response.json();
676
+ return decoded.displays[0];
677
+ });
678
+ const placeholder = $gVhhF$solidjsweb.createComponent((0, $3bc4a89b971a3af5$export$3f37af283f8fb843), {
679
+ get aspectRatio() {
680
+ return props.imageAspectRatio_;
534
681
  }
535
- }));
536
- // If we start observing elements before they're in the DOM Chrome (Version 117.0.5938.92 (Official Build) (arm64)) sometimes gives us a resize event with a width of 0 and then doesn't dispatch one with the actual width once it's in the DOM. So we wait until the element is in the DOM before we start observing it.
537
- // It doesn't seem to work even when waiting for it to be in the DOM, also wait an animation frame
538
- const disconnect = (0, $gVhhF$depictaiutilishared.observer).onexists(what_to_watch, ({
539
- element: element
540
- }) => requestAnimationFrame($gVhhF$depictaiutilishared.catchify(() => {
541
- const current_size = what_to_watch.getBoundingClientRect().width;
542
- if (current_size)
543
- // If element has size, set signal to that. ResizeObserver only triggers when the content is visible in some cases, but it might already have a size. This reduces size filter expanding animation jank in chrome.
544
- setWidth(current_size);
545
- resizeObserver.observe(element);
546
- })));
547
- $gVhhF$solidjs.onCleanup(() => {
548
- resizeObserver.disconnect();
549
- disconnect();
550
682
  });
551
- return width;
683
+ return (() => {
684
+ const _el$ = $gVhhF$solidjsweb.getNextElement($bbe694fe824b9c78$var$_tmpl$);
685
+ $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Suspense), {
686
+ fallback: placeholder,
687
+ get children() {
688
+ return (() => {
689
+ const imageUrl = $gVhhF$solidjs.createMemo(() => {
690
+ const d = display();
691
+ const variant = d?.variant_displays[d?.variant_index];
692
+ return variant?.image_urls?.[0] || variant?.display_image_url;
693
+ });
694
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
695
+ get when() {
696
+ return imageUrl();
697
+ },
698
+ fallback: "Cannot load image",
699
+ get children() {
700
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$depictaiutilishared.ContainedImage), {
701
+ loading: "lazy",
702
+ srcset_opts: {
703
+ set_dataset: false
704
+ },
705
+ get src() {
706
+ return imageUrl();
707
+ },
708
+ get aspect_ratio() {
709
+ return props.imageAspectRatio_;
710
+ },
711
+ rendering_options: {},
712
+ alt: "Product image showing the current product with other outfits highlighted on the model"
713
+ });
714
+ }
715
+ });
716
+ })();
717
+ }
718
+ }));
719
+ return _el$;
720
+ })();
552
721
  }
553
- const $4e04be41243c3d80$var$transform_elements = sorted_cols_at_size => {
554
- const cols_at_size = [];
555
- for (let i = 0; i < sorted_cols_at_size.length; i++) {
556
- const [nb_cols, width] = sorted_cols_at_size[i];
557
- const next_width = sorted_cols_at_size[i + 1]?.[1];
558
- const max_width = i === 0 ? "" : `${width}px`;
559
- const min_width = next_width !== undefined ? `${next_width + 1}px` : "";
560
- const col_at_size = [nb_cols, min_width, max_width];
561
- cols_at_size.push(col_at_size);
562
- }
563
- return cols_at_size;
564
- };
565
- const $4e04be41243c3d80$export$6daf8749b65a1b77 = cols_at_size => {
566
- // Check that every element is an array
567
- const are_arrays = cols_at_size.every(element => Array.isArray(element));
568
- if (!are_arrays) throw new Error("Every element in cols_at_size must be an array");
569
- // Check width duplicates
570
- const widths = cols_at_size.map(([_, width]) => width);
571
- const widths_set = new Set(widths);
572
- if (widths_set.size < widths.length) throw new Error("There are duplicate widths in cols_at_size");
573
- if (cols_at_size.length === 1) {
574
- const [nb_cols, width] = cols_at_size[0];
575
- const max_width = width !== undefined ? `${width}px` : "";
576
- return [[nb_cols, "", max_width]];
577
- }
578
- // Sort widths in ascending order
579
- const sorted_cols_at_size = [...cols_at_size].sort((a, b) => {
580
- const [_b, width_A] = a;
581
- const [_a, width_b] = b;
582
- if (width_A === undefined) return -1;
583
- if (width_b === undefined) return 1;
584
- return width_b - width_A;
722
+ function $061ff5b4c3d36171$export$89c6019e4baa40b1(props) {
723
+ const style = $gVhhF$solidjs.createMemo(() => {
724
+ const {
725
+ style: style,
726
+ height: height,
727
+ width: width
728
+ } = props;
729
+ return {
730
+ ...(style || {}),
731
+ height: height ?? "1em",
732
+ ...(width && {
733
+ width: width
734
+ })
735
+ };
585
736
  });
586
- return $4e04be41243c3d80$var$transform_elements(sorted_cols_at_size);
587
- };
737
+ return $gVhhF$solidjsweb.createComponent((0, $9fe9883b1d8ecccc$export$acb3eaade4b23afd), {
738
+ get style() {
739
+ return style();
740
+ },
741
+ get ["class"]() {
742
+ return props.class;
743
+ }
744
+ });
745
+ }
746
+ const $6b502b1b2155a0bc$export$5c28802497c8a83c = /*@__PURE__*/Symbol("category_title_type");
747
+ const $0b23bfd073d9a4e8$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=category-title><h1 class=title></h1><span class=explanation> \u{2014} <!$><!/>`);
748
+ const $0b23bfd073d9a4e8$export$b91cec6bdc6b32a1 = /*@__PURE__*/(() => {
749
+ const actual_function = ({
750
+ category_title_: category_title_,
751
+ product_count_: product_count_
752
+ }) => {
753
+ return (() => {
754
+ const _el$ = $gVhhF$solidjsweb.getNextElement($0b23bfd073d9a4e8$var$_tmpl$),
755
+ _el$2 = _el$.firstChild,
756
+ _el$3 = _el$2.nextSibling,
757
+ _el$4 = _el$3.firstChild,
758
+ _el$5 = _el$4.nextSibling,
759
+ [_el$6, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$5.nextSibling);
760
+ $gVhhF$solidjsweb.insert(_el$2, () => category_title_() || $gVhhF$solidjsweb.createComponent((0, $061ff5b4c3d36171$export$89c6019e4baa40b1), {
761
+ height: "1em",
762
+ width: "10ch"
763
+ }));
764
+ $gVhhF$solidjsweb.insert(_el$3, product_count_, _el$6, _co$);
765
+ return _el$;
766
+ })();
767
+ };
768
+ // This is wrong but parcel can't build correctly, it says unexpected undefined
769
+ actual_function[(0, $6b502b1b2155a0bc$export$5c28802497c8a83c)] = "simple";
770
+ return actual_function;
771
+ })();
772
+ const $a3280f0aad997933$export$c3834fa86c616831 = [[4], [3, 1024], [2, 901]];
773
+ const $a3280f0aad997933$export$864d304a0bc46829 = "2%";
774
+ const $a3280f0aad997933$export$7bf543b9d9be2c22 = (0, $0b23bfd073d9a4e8$export$b91cec6bdc6b32a1);
588
775
  function $fc23d7668ae0011d$export$a2cc176055f8f08() {
589
776
  const text = "Please try setting `columnsAtSize`/`gridSpacing` on the `SearchPage`/`CategoryPage` components to change the grid before setting it with CSS. If you do with CSS, set `columnsAtSize` to an empty array to ensure no declarations created by the SDK leak through.";
590
777
  return (0, $gVhhF$solidjsweb.isServer) ? {
@@ -727,8 +914,6 @@ function $a73063cc642f3e5f$export$7f8bd308237ab5a5(get_displays_) {
727
914
  const $a73063cc642f3e5f$var$result_ids = ["search_result_id", "product_listing_result_id", "recommendation_id"];
728
915
  function $a73063cc642f3e5f$export$43f0fb951fcb0c54({
729
916
  displays_by_key_: displays_by_key_,
730
- merchant_: merchant_,
731
- market_: market_,
732
917
  product_card_template_: product_card_template_,
733
918
  do_per_elements_: do_per_elements_,
734
919
  content_blocks_: content_blocks_
@@ -749,10 +934,9 @@ function $a73063cc642f3e5f$export$43f0fb951fcb0c54({
749
934
  return prev;
750
935
  return new_display;
751
936
  });
752
- const [product_card_resource] = $gVhhF$solidjs.createResource(() => [merchant_(), market_(), display_accessor()],
753
- // re-render when the reference to the display object changes or the merchant or market changes
754
- // (We don't want to re-render if nothing has changed)
755
- ([merchant, market, display]) => {
937
+ const [product_card_resource] = $gVhhF$solidjs.createResource(display_accessor,
938
+ // re-render when the reference to the display object changes
939
+ display => {
756
940
  // It's easy for merchants to accidentally mutate the display or some sub-object thereof
757
941
  // We had a case on singular where they popped an image url and due to use caching after some time there was no image
758
942
  // Attempt cloning the displays if possible (99.9% of the cases probably) and if not, just use the original display
@@ -765,12 +949,9 @@ function $a73063cc642f3e5f$export$43f0fb951fcb0c54({
765
949
  }
766
950
  }
767
951
  return product_card_template_(display, {
768
- set_on_index_change: fn => $gVhhF$solidjs.runWithOwner(owner, () => $gVhhF$solidjs.createEffect(() => fn(index()))),
769
- merchant: merchant,
770
- market: market // recommendation_grid can provide a sneaky undefined here just FYI
952
+ set_on_index_change: fn => $gVhhF$solidjs.runWithOwner(owner, () => $gVhhF$solidjs.createEffect(() => fn(index())))
771
953
  });
772
954
  });
773
-
774
955
  const node_accessor = $5f7d55c710fd1bc2$export$2f0cbfbb4354bb52(product_card_resource);
775
956
  $gVhhF$solidjs.createEffect(() => {
776
957
  const product_card_nodes = node_accessor();
@@ -821,46 +1002,6 @@ function $a73063cc642f3e5f$var$deep_equal(obj1, obj2) {
821
1002
  }
822
1003
  return false;
823
1004
  }
824
-
825
- // Errors caused by SDK consuming code interfacing with the SDK, not the SDK itself or other Depict packages
826
- class $7dd1edb2ee2b43ad$export$e1d52e4f0c7557a1 extends Error {}
827
- class $7dd1edb2ee2b43ad$export$aa14a9f43128f61f extends $7dd1edb2ee2b43ad$export$e1d52e4f0c7557a1 {
828
- constructor(templateError) {
829
- super("Uncaught error in product card template", {
830
- cause: templateError
831
- });
832
- }
833
- }
834
- const $edafe91daf3091d7$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div><!$><!/><!$><!/>`);
835
- function $edafe91daf3091d7$export$b69d0d92862de18b(props) {
836
- return $gVhhF$solidjs.ErrorBoundary({
837
- fallback(err, retry) {
838
- const {
839
- message_: message_,
840
- severity_: severity_
841
- } = props;
842
- let message = message_;
843
- if (err instanceof (0, $7dd1edb2ee2b43ad$export$aa14a9f43128f61f)) {
844
- console.error(err.cause);
845
- message = `${message}: ${err.message}`;
846
- } else $gVhhF$depictaiutilishared.report([err, message_], severity_);
847
- return (() => {
848
- const _el$ = $gVhhF$solidjsweb.getNextElement($edafe91daf3091d7$var$_tmpl$),
849
- _el$2 = _el$.firstChild,
850
- [_el$3, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$2.nextSibling),
851
- _el$4 = _el$3.nextSibling,
852
- [_el$5, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$4.nextSibling);
853
- $gVhhF$solidjsweb.insert(_el$, message, _el$3, _co$);
854
- $gVhhF$solidjsweb.insert(_el$, () => props.on_error_?.(retry), _el$5, _co$2);
855
- $gVhhF$solidjsweb.effect(_$p => $gVhhF$solidjsweb.classList(_el$, Object.fromEntries(props.class_list_?.map(c => [c, true]) || []), _$p));
856
- return _el$;
857
- })();
858
- },
859
- get children() {
860
- return props.children;
861
- }
862
- });
863
- }
864
1005
  const $f48d0fbb00835aaa$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div>`),
865
1006
  $f48d0fbb00835aaa$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<style type=text/css>`);
866
1007
  function $f48d0fbb00835aaa$export$d21e32dfedac04be(props) {
@@ -940,69 +1081,1016 @@ function $f48d0fbb00835aaa$export$445d8d3f5f706a40(props, container_element, ins
940
1081
  const max_rows = rows_or_empty_object().max_rows;
941
1082
  if (!isNaN(max_rows) && max_rows >= 0 && rows_visible > max_rows) set_rows_visible()(max_rows);
942
1083
  });
943
- $gVhhF$solidjs.createEffect(() => set_force_style_update(" ")); // force style update after hydration due to https://discord.com/channels/722131463138705510/722167424186843267/1151544212517552168
944
- $gVhhF$solidjs.createRenderEffect(() => {
945
- // Be careful to only read show_all_rows in here (ofc doesn't apply to nested effects)
946
- if (show_all_rows()) {
947
- // no view more functionality requested
948
- set_styling(() => col_styling);
949
- return;
1084
+ $gVhhF$solidjs.createEffect(() => set_force_style_update(" ")); // force style update after hydration due to https://discord.com/channels/722131463138705510/722167424186843267/1151544212517552168
1085
+ $gVhhF$solidjs.createRenderEffect(() => {
1086
+ // Be careful to only read show_all_rows in here (ofc doesn't apply to nested effects)
1087
+ if (show_all_rows()) {
1088
+ // no view more functionality requested
1089
+ set_styling(() => col_styling);
1090
+ return;
1091
+ }
1092
+ update_children_count();
1093
+ if (!(0, $gVhhF$solidjsweb.isServer)) {
1094
+ const mutation_observer = new MutationObserver($gVhhF$depictaiutilishared.catchify(update_children_count));
1095
+ mutation_observer.observe(container_element, {
1096
+ childList: true
1097
+ });
1098
+ $gVhhF$solidjs.onCleanup(() => mutation_observer.disconnect());
1099
+ }
1100
+ set_styling(
1101
+ // this is needed because solid will think that the memo-accessor is a setter function otherwise
1102
+ () => $gVhhF$solidjs.createMemo(() => {
1103
+ const {
1104
+ rows_per_click: rows_per_click,
1105
+ max_rows = -1,
1106
+ start_rows: start_rows
1107
+ } = rows_or_empty_object();
1108
+ const rows_visible = get_rows_visible();
1109
+ const children_count = get_children_count();
1110
+ return force_style_update() + col_styling() + props.cols_at_size.map(options => {
1111
+ const [recs_per_row, min, max] = options;
1112
+ let should_hide_view_more_button;
1113
+ let visible_recs;
1114
+ if (props.disable_partial_rows) {
1115
+ visible_recs = $gVhhF$depictaiutilishared.layout_get_visible_recs_without_partial_rows(rows_visible, children_count, options);
1116
+ const visible_recs_next_show_more = $gVhhF$depictaiutilishared.layout_get_visible_recs_without_partial_rows(rows_visible + (rows_per_click || 0),
1117
+ // Should this really be zero when we default rows_per_click to 1?
1118
+ children_count, options);
1119
+ should_hide_view_more_button = visible_recs === visible_recs_next_show_more;
1120
+ } else {
1121
+ visible_recs = $gVhhF$depictaiutilishared.layout_get_total_rec_amount_for_row(rows_visible, options);
1122
+ should_hide_view_more_button = visible_recs >= children_count;
1123
+ }
1124
+ const should_hide_button_final = should_hide_view_more_button || max_rows !== -1 && rows_visible >= max_rows;
1125
+ // I don't really understand the logic for when the view more button gets hidden so IDK if below is correct, but it works how it should for now
1126
+ const should_hide_view_less_button = !should_hide_view_more_button || start_rows == undefined || rows_visible <= start_rows || children_count <= recs_per_row * start_rows;
1127
+ return `${$gVhhF$depictaiutilishared.layout_media_query_header(min, max)}{${selector_beginning}:nth-child(n+${visible_recs + 1}){display:none}${props.layout == "slider" ? `${selector_beginning}:nth-child(n+${visible_recs}){margin-right:0}` : ""}${should_hide_button_final ? `.depict .${view_more_button_class}{display:none!important}` : ``}${should_hide_view_less_button ? `.depict .${view_less_button_class}{display:none!important}` : ``}}`;
1128
+ }).join("");
1129
+ }));
1130
+ });
1131
+ const style_element = (() => {
1132
+ const _el$4 = $gVhhF$solidjsweb.getNextElement($f48d0fbb00835aaa$var$_tmpl$2);
1133
+ $gVhhF$solidjsweb.insert(_el$4, get_styling);
1134
+ return _el$4;
1135
+ })(); // need to create this after set_styling has been called or else there will be no styling in the SSR'd output
1136
+ if (insert_after_container) container_element.after(style_element);
1137
+ return [container_element, $gVhhF$solidjsweb.memo(view_more_button_container), $gVhhF$solidjsweb.memo(view_less_button_container), style_element];
1138
+ }
1139
+ $gVhhF$solidjsweb.delegateEvents(["click"]);
1140
+ const $b8e79813f4f7ebe4$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<h2 class=recs-title>`),
1141
+ $b8e79813f4f7ebe4$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=recommendation-grid><!$><!/><!$><!/>`);
1142
+ function $b8e79813f4f7ebe4$export$7da560f849543dff({
1143
+ recommendations_resource_: recommendations_resource_,
1144
+ product_card_template_: product_card_template_,
1145
+ layout_options_: layout_options_,
1146
+ rows_object_: rows_object_,
1147
+ title_: title_
1148
+ }) {
1149
+ const is_showing_something = $gVhhF$solidjs.createMemo(() => recommendations_resource_.loading || recommendations_resource_()?.length);
1150
+ const title = $gVhhF$solidjs.createMemo(() => title_?.()); // In case getter/accessor creates elements, don't create them twice
1151
+ const num_placeholders_ = () => 20;
1152
+ const elements = [$gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
1153
+ get when() {
1154
+ return title();
1155
+ },
1156
+ get children() {
1157
+ const _el$ = $gVhhF$solidjsweb.getNextElement($b8e79813f4f7ebe4$var$_tmpl$);
1158
+ $gVhhF$solidjsweb.insert(_el$, title);
1159
+ return _el$;
1160
+ }
1161
+ }), (() => {
1162
+ const _el$2 = $gVhhF$solidjsweb.getNextElement($b8e79813f4f7ebe4$var$_tmpl$2),
1163
+ _el$3 = _el$2.firstChild,
1164
+ [_el$4, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$3.nextSibling),
1165
+ _el$5 = _el$4.nextSibling,
1166
+ [_el$6, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$5.nextSibling);
1167
+ $gVhhF$solidjsweb.insert(_el$2, (0, $fc23d7668ae0011d$export$a2cc176055f8f08), _el$4, _co$);
1168
+ $gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $f48d0fbb00835aaa$export$d21e32dfedac04be), $gVhhF$solidjsweb.mergeProps({
1169
+ get rows() {
1170
+ return rows_object_();
1171
+ },
1172
+ layout: "grid",
1173
+ element_attributes: {
1174
+ class: "cards"
1175
+ }
1176
+ }, layout_options_, {
1177
+ get children() {
1178
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Suspense), {
1179
+ get fallback() {
1180
+ return $0caf87eaa19079da$export$f33414a4df0afd3f({
1181
+ num_placeholders_: num_placeholders_,
1182
+ product_card_template_: product_card_template_
1183
+ });
1184
+ },
1185
+ get children() {
1186
+ return (() => {
1187
+ // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
1188
+ const displays_by_key_ = $a73063cc642f3e5f$export$7f8bd308237ab5a5($gVhhF$solidjs.createMemo(() => recommendations_resource_() || []));
1189
+ return $a73063cc642f3e5f$export$43f0fb951fcb0c54({
1190
+ displays_by_key_: displays_by_key_,
1191
+ product_card_template_: product_card_template_
1192
+ });
1193
+ })();
1194
+ }
1195
+ });
1196
+ }
1197
+ })), _el$6, _co$2);
1198
+ return _el$2;
1199
+ })()];
1200
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
1201
+ get when() {
1202
+ return is_showing_something();
1203
+ },
1204
+ children: elements
1205
+ });
1206
+ }
1207
+ const $4e04be41243c3d80$var$transform_elements = sorted_cols_at_size => {
1208
+ const cols_at_size = [];
1209
+ for (let i = 0; i < sorted_cols_at_size.length; i++) {
1210
+ const [nb_cols, width] = sorted_cols_at_size[i];
1211
+ const next_width = sorted_cols_at_size[i + 1]?.[1];
1212
+ const max_width = i === 0 ? "" : `${width}px`;
1213
+ const min_width = next_width !== undefined ? `${next_width + 1}px` : "";
1214
+ const col_at_size = [nb_cols, min_width, max_width];
1215
+ cols_at_size.push(col_at_size);
1216
+ }
1217
+ return cols_at_size;
1218
+ };
1219
+ const $4e04be41243c3d80$export$6daf8749b65a1b77 = cols_at_size => {
1220
+ // Check that every element is an array
1221
+ const are_arrays = cols_at_size.every(element => Array.isArray(element));
1222
+ if (!are_arrays) throw new Error("Every element in cols_at_size must be an array");
1223
+ // Check width duplicates
1224
+ const widths = cols_at_size.map(([_, width]) => width);
1225
+ const widths_set = new Set(widths);
1226
+ if (widths_set.size < widths.length) throw new Error("There are duplicate widths in cols_at_size");
1227
+ if (cols_at_size.length === 1) {
1228
+ const [nb_cols, width] = cols_at_size[0];
1229
+ const max_width = width !== undefined ? `${width}px` : "";
1230
+ return [[nb_cols, "", max_width]];
1231
+ }
1232
+ // Sort widths in ascending order
1233
+ const sorted_cols_at_size = [...cols_at_size].sort((a, b) => {
1234
+ const [_b, width_A] = a;
1235
+ const [_a, width_b] = b;
1236
+ if (width_A === undefined) return -1;
1237
+ if (width_b === undefined) return 1;
1238
+ return width_b - width_A;
1239
+ });
1240
+ return $4e04be41243c3d80$var$transform_elements(sorted_cols_at_size);
1241
+ };
1242
+ function $95837413165cc2df$export$23fca46f3143581f(component, error_message) {
1243
+ const component_in_error_boundary = do_with_elements => {
1244
+ const error_boundary_wrapped = $edafe91daf3091d7$export$b69d0d92862de18b({
1245
+ severity_: "error",
1246
+ message_: error_message,
1247
+ get children() {
1248
+ const elements = component();
1249
+ do_with_elements?.(elements);
1250
+ return elements;
1251
+ }
1252
+ });
1253
+ // This might return an accessor, in that case we need to "unwrap" it since our SDK consumers expect HTML elements or arrays thereof
1254
+ if (typeof error_boundary_wrapped === "function")
1255
+ // @ts-ignore
1256
+ return error_boundary_wrapped();
1257
+ // On the server it returns a string, so we just return that
1258
+ return error_boundary_wrapped;
1259
+ };
1260
+ const owner = $gVhhF$solidjs.getOwner();
1261
+ if (owner == null) return $gVhhF$solidjs.createRoot(dispose => {
1262
+ // if we're not already run in a root, create a root and automatically dispose it when the first returned element is removed from the DOM
1263
+ return component_in_error_boundary(elements => {
1264
+ const have_multiple = Array.isArray(elements);
1265
+ if (have_multiple ? !elements?.length : !elements) return;
1266
+ (0, $gVhhF$depictaiutilishared.observer).onremoved(have_multiple ? elements[0] : elements, ({
1267
+ element: element
1268
+ }) => {
1269
+ if (document.documentElement.contains(element)) return; // If element has instantly been re-inserted, don't dispose
1270
+ // See https://depictaiworkspace.slack.com/archives/C050GHEPBTR/p1695809102791259?thread_ts=1695106805.459729&cid=C050GHEPBTR
1271
+ dispose();
1272
+ });
1273
+ });
1274
+ });else
1275
+ // we're already in a root so cleanups are handled
1276
+ return component_in_error_boundary();
1277
+ }
1278
+ const $84798aaa863a4909$var$ListingContext = /*@__PURE__*/$gVhhF$solidjs.createContext();
1279
+ function $84798aaa863a4909$export$e68cff63f76bd15b(props) {
1280
+ const our_object = {};
1281
+ return $gVhhF$solidjsweb.createComponent($84798aaa863a4909$var$ListingContext.Provider, {
1282
+ value: our_object,
1283
+ get children() {
1284
+ return props.children;
1285
+ }
1286
+ });
1287
+ }
1288
+ function $84798aaa863a4909$export$8d0c4fdbb05a2f2e() {
1289
+ return $gVhhF$solidjs.useContext($84798aaa863a4909$var$ListingContext);
1290
+ }
1291
+ const $1f8dbf7e28b3eff2$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<button class="show-more major"type=button>`),
1292
+ $1f8dbf7e28b3eff2$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class="depict plp recommendations">`);
1293
+ function $1f8dbf7e28b3eff2$export$9756467d34d91cdb(props) {
1294
+ return $95837413165cc2df$export$23fca46f3143581f(() => {
1295
+ const rows_object_ = $gVhhF$solidjs.createMemo(() => {
1296
+ const {
1297
+ view_more_button: view_more_button,
1298
+ max_rows: max_rows
1299
+ } = props;
1300
+ if (!view_more_button) {
1301
+ if (max_rows) return {
1302
+ max_rows: max_rows
1303
+ };
1304
+ return "all";
1305
+ }
1306
+ return {
1307
+ max_rows: max_rows,
1308
+ start_rows: view_more_button.start_rows,
1309
+ rows_per_click: view_more_button.rows_per_click ?? 2,
1310
+ button: (() => {
1311
+ const _el$ = $gVhhF$solidjsweb.getNextElement($1f8dbf7e28b3eff2$var$_tmpl$);
1312
+ $gVhhF$solidjsweb.insert(_el$, () => view_more_button.text);
1313
+ return _el$;
1314
+ })()
1315
+ };
1316
+ });
1317
+ const grid_spacing_override = $gVhhF$solidjs.createMemo(() => {
1318
+ const {
1319
+ grid_spacing: grid_spacing
1320
+ } = props; // can be reactive
1321
+ return typeof grid_spacing === "string" ? {
1322
+ grid_spacing: grid_spacing
1323
+ } : {
1324
+ override_vertical_spacing: grid_spacing.vertical,
1325
+ grid_spacing: grid_spacing.horizontal
1326
+ };
1327
+ });
1328
+ const [recommendations_resource_] = $gVhhF$solidjs.createResource(() => props.recommendations, recs => recs);
1329
+ return (() => {
1330
+ const _el$2 = $gVhhF$solidjsweb.getNextElement($1f8dbf7e28b3eff2$var$_tmpl$2);
1331
+ $gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $84798aaa863a4909$export$e68cff63f76bd15b), {
1332
+ get children() {
1333
+ return $b8e79813f4f7ebe4$export$7da560f849543dff({
1334
+ rows_object_: rows_object_,
1335
+ product_card_template_: (...args) => props.product_card_template(...args),
1336
+ recommendations_resource_: recommendations_resource_,
1337
+ title_: () => props.title,
1338
+ layout_options_: $gVhhF$solidjs.createMemo(() => ({
1339
+ cols_at_size: $4e04be41243c3d80$export$6daf8749b65a1b77(props.cols_at_size),
1340
+ ...grid_spacing_override()
1341
+ }))
1342
+ });
1343
+ }
1344
+ }));
1345
+ return _el$2;
1346
+ })();
1347
+ }, "RecommendationGrid failed");
1348
+ }
1349
+ const $f55548318724b05c$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<a>`);
1350
+ function $f55548318724b05c$export$6b35356958ae5587(props) {
1351
+ const gridSpacing = (0, $a3280f0aad997933$export$864d304a0bc46829);
1352
+ const columnsAtSize = [[3], [2, 901]];
1353
+ const href = $gVhhF$depictaiutilishared.use_href_accessor();
1354
+ const hrefWithoutHash = $gVhhF$solidjs.createMemo(() => {
1355
+ // Don't let the hash count for knowing when the user navigated away as we change the hash when different tabs are selected
1356
+ const url = new URL(href());
1357
+ url.hash = "";
1358
+ return "" + url;
1359
+ });
1360
+ const makeJSXElementCloseModalWhenClicked = returnValue => {
1361
+ const resolved = $gVhhF$solidjs.children(() => returnValue);
1362
+ $gVhhF$solidjs.createEffect(() => {
1363
+ // If someone clicks on a product card in the shop the look modal, close the modal the next time the href changes
1364
+ for (const item of resolved.toArray()) {
1365
+ if (!(item instanceof Element)) return;
1366
+ item.addEventListener("click", $gVhhF$depictaiutilishared.catchify(() =>
1367
+ // run with modal owner so we don't do stuff after the modal closes
1368
+ // can't have the owner of the product card as that gets disposed if the productId changes which might be too early (before location.href has changed)
1369
+ $gVhhF$solidjs.runWithOwner(props.modalOwner_, () => $gVhhF$solidjs.createEffect($gVhhF$solidjs.on(hrefWithoutHash, props.actually_close_modal_, {
1370
+ defer: true
1371
+ })))), {
1372
+ capture: true
1373
+ });
1374
+ }
1375
+ });
1376
+ return resolved;
1377
+ };
1378
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
1379
+ get when() {
1380
+ return !props.products_to_shop_.error;
1381
+ },
1382
+ fallback: "Failed fetching shop by look recommendations",
1383
+ get children() {
1384
+ return $gVhhF$solidjsweb.createComponent((0, $8c38828ae2321937$export$b2539bed5023c21c), {
1385
+ AnchorComponent: anchorProps => (() => {
1386
+ const _el$ = $gVhhF$solidjsweb.getNextElement($f55548318724b05c$var$_tmpl$);
1387
+ _el$.$$click = e => {
1388
+ const {
1389
+ href: href
1390
+ } = anchorProps;
1391
+ if (!href) return;
1392
+ props.pseudo_router_.navigate_.go_to_({
1393
+ scroll: false,
1394
+ is_replace_: false,
1395
+ new_url_: new URL(href),
1396
+ event_: e
1397
+ });
1398
+ };
1399
+ $gVhhF$solidjsweb.spread(_el$, anchorProps, false, true);
1400
+ $gVhhF$solidjsweb.insert(_el$, () => anchorProps.children);
1401
+ $gVhhF$solidjsweb.runHydrationEvents();
1402
+ return _el$;
1403
+ })(),
1404
+ get children() {
1405
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Suspense), {
1406
+ get fallback() {
1407
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Index), {
1408
+ get each() {
1409
+ return Array.from({
1410
+ length: 2
1411
+ });
1412
+ },
1413
+ children: () => $gVhhF$solidjsweb.createComponent((0, $8c38828ae2321937$export$3e41faf802a29e71), {
1414
+ get label() {
1415
+ return $gVhhF$solidjsweb.createComponent((0, $061ff5b4c3d36171$export$89c6019e4baa40b1), {
1416
+ height: "1em",
1417
+ width: "10ch"
1418
+ });
1419
+ },
1420
+ get children() {
1421
+ return $gVhhF$solidjsweb.createComponent((0, $1f8dbf7e28b3eff2$export$9756467d34d91cdb), {
1422
+ grid_spacing: gridSpacing,
1423
+ cols_at_size: columnsAtSize,
1424
+ recommendations: new Promise(r => $gVhhF$solidjs.onCleanup(() => r([]))),
1425
+ get product_card_template() {
1426
+ return props.productCardTemplate_;
1427
+ },
1428
+ max_rows: 2
1429
+ });
1430
+ }
1431
+ })
1432
+ });
1433
+ },
1434
+ get children() {
1435
+ return (() => {
1436
+ const groups = $gVhhF$solidjs.createMemo(() => Object.keys(props.products_to_shop_()?.shop_the_look || {}));
1437
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.For), {
1438
+ get each() {
1439
+ return groups();
1440
+ },
1441
+ children: group => $gVhhF$solidjsweb.createComponent((0, $8c38828ae2321937$export$3e41faf802a29e71), {
1442
+ label: group,
1443
+ get id() {
1444
+ return "shop-the-look-" + group.replaceAll(" ", "-").toLowerCase();
1445
+ },
1446
+ get children() {
1447
+ return $gVhhF$solidjsweb.createComponent((0, $1f8dbf7e28b3eff2$export$9756467d34d91cdb), {
1448
+ grid_spacing: gridSpacing,
1449
+ cols_at_size: columnsAtSize,
1450
+ get recommendations() {
1451
+ return Promise.resolve(props.products_to_shop_().shop_the_look[group]);
1452
+ },
1453
+ product_card_template: (...args) => {
1454
+ const returnValue = props.productCardTemplate_(...args);
1455
+ // Product card template can return promise, handle that
1456
+ if (typeof returnValue === "object" && returnValue && "then" in returnValue) {
1457
+ const owner = $gVhhF$solidjs.getOwner();
1458
+ return returnValue.then(returnValue => $gVhhF$solidjs.runWithOwner(owner, () => makeJSXElementCloseModalWhenClicked(returnValue)));
1459
+ }
1460
+ return makeJSXElementCloseModalWhenClicked(returnValue);
1461
+ }
1462
+ });
1463
+ }
1464
+ })
1465
+ });
1466
+ })();
1467
+ }
1468
+ });
1469
+ }
1470
+ });
1471
+ }
1472
+ });
1473
+ }
1474
+ $gVhhF$solidjsweb.delegateEvents(["click"]);
1475
+ const $b0ceb08960135d83$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=top-bar><button class=close>`),
1476
+ $b0ceb08960135d83$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=below-top-bar><h2>Outfit recommendations</h2><div class=image-and-suggestions><!$><!/><div class=tabs>`),
1477
+ $b0ceb08960135d83$var$_tmpl$3 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div id=depict-shop-the-look-modal class="depict shop-the-look"><div class=shop-the-look-backdrop></div><div class=modal-contents>`);
1478
+ function $b0ceb08960135d83$export$a3cbef418994a664(props) {
1479
+ const pseudo_router_ = new (0, $e96dd13889871fc0$export$7e1297a3a19f10d8)(props.onNavigation);
1480
+ const closing_animations = [];
1481
+ const owner = $gVhhF$solidjs.getOwner();
1482
+ const isBig = () => matchMedia("(min-height: 740px) and (min-width: 740px)").matches;
1483
+ props.register_closing_animation_(() => Promise.all(closing_animations.map(animation => animation().finished)));
1484
+ $ca1176b694a6ee2e$export$fe334901e8bebd57();
1485
+ return [(() => {
1486
+ const _el$ = $gVhhF$solidjsweb.getNextElement($b0ceb08960135d83$var$_tmpl$3),
1487
+ _el$2 = _el$.firstChild,
1488
+ _el$3 = _el$2.nextSibling;
1489
+ const _ref$ = $gVhhF$depictaiutilishared.catchify(element => {
1490
+ const disconnect = (0, $gVhhF$depictaiutilishared.observer).onexists(element, ({
1491
+ element: element
1492
+ }) => {
1493
+ const animation = element.animate({
1494
+ opacity: [0, 1],
1495
+ backdropFilter: ["blur(0)", "blur(3px)"]
1496
+ }, {
1497
+ duration: 150,
1498
+ fill: "forwards",
1499
+ easing: "ease-in-out"
1500
+ });
1501
+ closing_animations.push(() => (animation.reverse(), animation));
1502
+ });
1503
+ $gVhhF$solidjs.onCleanup(disconnect);
1504
+ });
1505
+ typeof _ref$ === "function" && $gVhhF$solidjsweb.use(_ref$, _el$2);
1506
+ $gVhhF$solidjsweb.addEventListener(_el$2, "click", props.actually_close_modal_, true);
1507
+ $gVhhF$solidjsweb.use(element => {
1508
+ const disconnect = (0, $gVhhF$depictaiutilishared.observer).onexists(element, ({
1509
+ element: element
1510
+ }) => element.animate({
1511
+ opacity: [0, 1],
1512
+ transform: isBig() ? ["translate(-50%,-150%)", "translate(-50%,-50%)"] : ["translate(-50%,80%)", "translate(-50%,0%)"]
1513
+ }, {
1514
+ duration: 250,
1515
+ easing: "ease-in"
1516
+ }));
1517
+ closing_animations.push(() => element.animate({
1518
+ opacity: [1, 0],
1519
+ transform: isBig() ? ["translate(-50%,-50%)", "translate(-50%,-150%)"] : ["translate(-50%,0%)", "translate(-50%,80%)"]
1520
+ }, {
1521
+ duration: 150,
1522
+ easing: "ease-out"
1523
+ }));
1524
+ $gVhhF$solidjs.onCleanup(disconnect);
1525
+ }, _el$3);
1526
+ $gVhhF$solidjsweb.insert(_el$3, $gVhhF$solidjsweb.createComponent((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
1527
+ message_: "ShopTheLookModal failed",
1528
+ severity_: "error",
1529
+ get children() {
1530
+ return [(() => {
1531
+ const _el$4 = $gVhhF$solidjsweb.getNextElement($b0ceb08960135d83$var$_tmpl$),
1532
+ _el$5 = _el$4.firstChild;
1533
+ $gVhhF$solidjsweb.addEventListener(_el$5, "click", props.actually_close_modal_, true);
1534
+ $gVhhF$solidjsweb.insert(_el$5, $gVhhF$solidjsweb.createComponent((0, $c77c68e559a1506c$export$3b621d86b1566b2), {
1535
+ width: 16,
1536
+ height: 16
1537
+ }));
1538
+ $gVhhF$solidjsweb.runHydrationEvents();
1539
+ return _el$4;
1540
+ })(), (() => {
1541
+ const _el$6 = $gVhhF$solidjsweb.getNextElement($b0ceb08960135d83$var$_tmpl$2),
1542
+ _el$7 = _el$6.firstChild,
1543
+ _el$8 = _el$7.nextSibling,
1544
+ _el$10 = _el$8.firstChild,
1545
+ [_el$11, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$10.nextSibling),
1546
+ _el$9 = _el$11.nextSibling;
1547
+ $gVhhF$solidjsweb.insert(_el$8, $gVhhF$solidjsweb.createComponent((0, $bbe694fe824b9c78$export$41e1a079d40a0d58), {
1548
+ get locale_() {
1549
+ return props.locale;
1550
+ },
1551
+ get market_() {
1552
+ return props.market;
1553
+ },
1554
+ get merchant_() {
1555
+ return props.merchant;
1556
+ },
1557
+ get imageAspectRatio_() {
1558
+ return props.imageAspectRatio;
1559
+ },
1560
+ get productId_() {
1561
+ return props.productId;
1562
+ }
1563
+ }), _el$11, _co$);
1564
+ $gVhhF$solidjsweb.insert(_el$9, $gVhhF$solidjsweb.createComponent((0, $f55548318724b05c$export$6b35356958ae5587), {
1565
+ modalOwner_: owner,
1566
+ pseudo_router_: pseudo_router_,
1567
+ get productCardTemplate_() {
1568
+ return props.productCardTemplate;
1569
+ },
1570
+ get products_to_shop_() {
1571
+ return props.products_to_shop_;
1572
+ },
1573
+ get actually_close_modal_() {
1574
+ return props.actually_close_modal_;
1575
+ }
1576
+ }));
1577
+ return _el$6;
1578
+ })()];
1579
+ }
1580
+ }));
1581
+ $gVhhF$solidjsweb.runHydrationEvents();
1582
+ return _el$;
1583
+ })()];
1584
+ }
1585
+ $gVhhF$solidjsweb.delegateEvents(["click"]);
1586
+ const $a5f3eaa1a24bbc1e$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div>Failed fetching shop the look recommendations`),
1587
+ $a5f3eaa1a24bbc1e$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<button>`);
1588
+ const $a5f3eaa1a24bbc1e$var$CANT_FETCH = "Failed fetching shop the look recommendations";
1589
+ let $a5f3eaa1a24bbc1e$var$setModalShouldBeOpen;
1590
+ let $a5f3eaa1a24bbc1e$var$modalProps;
1591
+ function $a5f3eaa1a24bbc1e$export$d4973c31938cbfd1(props) {
1592
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.ErrorBoundary), {
1593
+ fallback: () => $gVhhF$solidjsweb.getNextElement($a5f3eaa1a24bbc1e$var$_tmpl$),
1594
+ get children() {
1595
+ return $gVhhF$solidjsweb.createComponent($a5f3eaa1a24bbc1e$var$ActualShopTheLookButton, props);
1596
+ }
1597
+ });
1598
+ }
1599
+ function $a5f3eaa1a24bbc1e$var$ActualShopTheLookButton(props) {
1600
+ const [products_to_shop_] = $gVhhF$solidjs.createResource(() => ({
1601
+ merchant: props.merchant,
1602
+ market: props.market,
1603
+ locale: props.locale,
1604
+ product_ids: [props.productId],
1605
+ type: "shop_the_look",
1606
+ session_id: $gVhhF$depictaiutilishared.get_session_id()
1607
+ }), async request => {
1608
+ const response = await fetch($gVhhF$depictaiutilishared.add_version_query_params(`${(0, $gVhhF$depictaiutilishared.base_url)}/v3/shop-the-look`), {
1609
+ method: "POST",
1610
+ body: JSON.stringify(request)
1611
+ });
1612
+ if (!response.ok) {
1613
+ $gVhhF$depictaiutilishared.dwarn(response);
1614
+ throw new Error($a5f3eaa1a24bbc1e$var$CANT_FETCH);
1615
+ }
1616
+ const decoded = await response.json();
1617
+ return decoded;
1618
+ });
1619
+ const [localProps, partForModal] = $gVhhF$solidjs.splitProps(props, ["buttonAttributes"]);
1620
+ const {
1621
+ openModal: openModal,
1622
+ closeModal: closeModal
1623
+ } = $a5f3eaa1a24bbc1e$var$useShopTheLookModal();
1624
+ const hasAnythingToShow = $gVhhF$solidjs.createMemo(() => Object.entries(products_to_shop_()?.shop_the_look || {}).length);
1625
+ const displayStyleValue = $gVhhF$solidjs.createMemo(() => hasAnythingToShow() ? "" : "none");
1626
+ const button = (() => {
1627
+ const _el$2 = $gVhhF$solidjsweb.getNextElement($a5f3eaa1a24bbc1e$var$_tmpl$2);
1628
+ $gVhhF$solidjsweb.spread(_el$2, $gVhhF$solidjsweb.mergeProps(() => localProps.buttonAttributes), false, true);
1629
+ $gVhhF$solidjsweb.insert(_el$2, () => localProps?.buttonAttributes?.children || "Shop the look");
1630
+ $gVhhF$solidjsweb.runHydrationEvents();
1631
+ return _el$2;
1632
+ })();
1633
+ $gVhhF$solidjs.createEffect(() => button.style.display = displayStyleValue()); // Set our attributes like this, so we allow total control over the button from the outside via buttonAttributes
1634
+ $gVhhF$solidjs.createEffect(() => !hasAnythingToShow() && closeModal()); // close modal if we ever get into the state of having it open and not having anything to show
1635
+ $a5f3eaa1a24bbc1e$var$modalProps = $gVhhF$solidjs.mergeProps(partForModal, {
1636
+ products_to_shop_: products_to_shop_
1637
+ });
1638
+ button.addEventListener("click", openModal);
1639
+ return button;
1640
+ }
1641
+ /**
1642
+ * This does not need to be run in a root at all, it will create a root every time the modal is opened and then tear it down when the modal is closed again
1643
+ */
1644
+ function $a5f3eaa1a24bbc1e$var$useShopTheLookModal() {
1645
+ if ($a5f3eaa1a24bbc1e$var$setModalShouldBeOpen) return $a5f3eaa1a24bbc1e$var$setModalShouldBeOpen;
1646
+ return $a5f3eaa1a24bbc1e$var$setModalShouldBeOpen = $gVhhF$solidjs.createRoot(() => $a5f3eaa1a24bbc1e$var$actualSetupModal());
1647
+ }
1648
+ function $a5f3eaa1a24bbc1e$var$actualSetupModal() {
1649
+ // Save modal state in history so modal is still open after people go back
1650
+ const history_key = "depict_shop_the_look_open";
1651
+ const {
1652
+ [history_key]: [history_value, set_history_value]
1653
+ } = $6e22b5314fb52f4c$export$e183a13865960371({
1654
+ [history_key]: false
1655
+ }, {
1656
+ navigate_: {
1657
+ replace_state_: new_state => globalThis?.history?.replaceState(new_state, "")
1658
+ }
1659
+ });
1660
+ (0, $d84fe647b84b5dc5$export$3064e1e8c6513da3).add(history_key);
1661
+ const actually_close_modal_ = () => set_history_value(false);
1662
+ const owner = $gVhhF$solidjs.getOwner();
1663
+ $gVhhF$depictaiutilishared.catchify(async () => {
1664
+ const {
1665
+ open_modal_: open_modal_,
1666
+ close_modal_: close_modal_
1667
+ } = await $9abb0a35d4b60ed3$export$79b1565500412d9b((0, $b0ceb08960135d83$export$a3cbef418994a664), {
1668
+ actually_close_modal_: actually_close_modal_
1669
+ });
1670
+ $gVhhF$solidjs.runWithOwner(owner, () => $gVhhF$solidjs.createEffect(() => {
1671
+ if (history_value()) open_modal_($a5f3eaa1a24bbc1e$var$modalProps);else close_modal_();
1672
+ }));
1673
+ })();
1674
+ return {
1675
+ openModal: () => set_history_value(true),
1676
+ closeModal: actually_close_modal_
1677
+ };
1678
+ }
1679
+ const $1ab22f2cd39b3061$var$fallback_operator = "in";
1680
+ const $1ab22f2cd39b3061$var$fallback_token = "";
1681
+ const $1ab22f2cd39b3061$var$legacy_filter_prefix = "filter_";
1682
+ const $1ab22f2cd39b3061$var$operator_map = {
1683
+ "eq": "\u2261",
1684
+ "neq": "\u2260",
1685
+ "in": "\u2208",
1686
+ "nin": "\u2209",
1687
+ "leq": "\u2264",
1688
+ "geq": "\u2265",
1689
+ "inrange": "\uD83D\uDD22"
1690
+ };
1691
+ const $1ab22f2cd39b3061$var$ascending_token = "\uD83D\uDCC8";
1692
+ const $1ab22f2cd39b3061$var$descending_token = "\uD83D\uDCC9";
1693
+ const $1ab22f2cd39b3061$var$range_delimiter = "-";
1694
+ const $1ab22f2cd39b3061$var$string_item_delimiter = "\u201A"; // This is not a comma but a comma-like character that browsers will render in the URL bar.
1695
+ const $1ab22f2cd39b3061$var$array_item_delimiter = "\u2023"; // FIXME: decide on a character. Could theoretically be a double string delimiter.
1696
+ const $1ab22f2cd39b3061$var$empty_item_replacement = "0\uFE0F\u20E3";
1697
+ const $1ab22f2cd39b3061$var$op_to_token = op => {
1698
+ if (op === $1ab22f2cd39b3061$var$fallback_operator) return $1ab22f2cd39b3061$var$fallback_token;
1699
+ return $1ab22f2cd39b3061$var$operator_map[op];
1700
+ };
1701
+ /**
1702
+ * Checks if a given array of filter data can be neatly serialized into an URL query parameter, or if it should fall back to JSON+base64.
1703
+ * The requirements are either an array of strings, containing no reserved characters, or an array of arrays of strings, containing no reserved characters.
1704
+ * No deep or mixed nesting levels are supported.
1705
+ */
1706
+ function $1ab22f2cd39b3061$var$array_is_serializable(array, is_root = true) {
1707
+ if (array.every(item => Array.isArray(item))) {
1708
+ if (!is_root)
1709
+ // Deeply nested arrays are not supported, but also don't exist as filters (yet)
1710
+ return false;
1711
+ return array.every(item => $1ab22f2cd39b3061$var$array_is_serializable(item, false));
1712
+ }
1713
+ if (array.some(item => typeof item !== "string"))
1714
+ // Numbers are not supported, since 1 and "1" would encode to the same thing
1715
+ return false;
1716
+ // Encoding reserved characters is not supported
1717
+ return !array.some(item => item.includes($1ab22f2cd39b3061$var$array_item_delimiter) || item.includes($1ab22f2cd39b3061$var$string_item_delimiter) || item === $1ab22f2cd39b3061$var$empty_item_replacement);
1718
+ }
1719
+ /**
1720
+ * Human readable string[] or string[][] serialization for URLs.
1721
+ * @param array
1722
+ * @returns
1723
+ */
1724
+ function $1ab22f2cd39b3061$var$encode_array(array) {
1725
+ const is_nested = array.every(item => Array.isArray(item));
1726
+ if (is_nested) return array.map($1ab22f2cd39b3061$var$encode_array).join($1ab22f2cd39b3061$var$array_item_delimiter) + $1ab22f2cd39b3061$var$array_item_delimiter; // Nested arrays require a suffix to close nesting levels
1727
+ return array.map(item => item === "" ? $1ab22f2cd39b3061$var$empty_item_replacement : item).join($1ab22f2cd39b3061$var$string_item_delimiter);
1728
+ }
1729
+ function $1ab22f2cd39b3061$var$decode_array(encoded_array) {
1730
+ const is_nested = encoded_array.includes($1ab22f2cd39b3061$var$array_item_delimiter);
1731
+ if (is_nested) return encoded_array.split($1ab22f2cd39b3061$var$array_item_delimiter).filter(s => s !== "") // Remove empty segments, caused by trailing delimiter
1732
+ .map($1ab22f2cd39b3061$var$decode_array);
1733
+ return encoded_array.split($1ab22f2cd39b3061$var$string_item_delimiter).filter(s => s !== "") // Remove empty segments, caused by trailing delimiter in the single item special case
1734
+ .map(item => item === $1ab22f2cd39b3061$var$empty_item_replacement ? "" : item);
1735
+ }
1736
+ function $1ab22f2cd39b3061$var$encode_filter_data(op, data) {
1737
+ if (data === "true")
1738
+ // boolean encoding
1739
+ return "1";
1740
+ if (data === "false")
1741
+ // boolean encoding
1742
+ return "0";
1743
+ const data_is_array = Array.isArray(data);
1744
+ if (op === "inrange" && data_is_array && data.every(item => typeof item === "number"))
1745
+ // numeric range filter encoding
1746
+ return data.join($1ab22f2cd39b3061$var$range_delimiter);
1747
+ if (data_is_array && $1ab22f2cd39b3061$var$array_is_serializable(data)) {
1748
+ const encoded_data = $1ab22f2cd39b3061$var$encode_array(data);
1749
+ if (!encoded_data.includes($1ab22f2cd39b3061$var$array_item_delimiter) && !encoded_data.includes($1ab22f2cd39b3061$var$string_item_delimiter))
1750
+ // A string[] with only one item will encode without delimiters, which is indistinguishable from a plain string during decoding
1751
+ // In that case we add a delimiter suffix at the end
1752
+ return encoded_data + $1ab22f2cd39b3061$var$string_item_delimiter;
1753
+ return encoded_data;
1754
+ }
1755
+ // Fallback encoding
1756
+ return $gVhhF$depictaiutilishared.base64_encode_unicode(JSON.stringify(data));
1757
+ }
1758
+ function $1ab22f2cd39b3061$var$decode_filter_data(op, encoded_data) {
1759
+ if (encoded_data === "1") return "true";
1760
+ if (encoded_data === "0") return "false";
1761
+ if (op === "inrange" && encoded_data.includes($1ab22f2cd39b3061$var$range_delimiter)) return encoded_data.split($1ab22f2cd39b3061$var$range_delimiter).map(x => parseFloat(x));
1762
+ if (encoded_data.includes($1ab22f2cd39b3061$var$string_item_delimiter) || encoded_data.includes($1ab22f2cd39b3061$var$array_item_delimiter)) return $1ab22f2cd39b3061$var$decode_array(encoded_data);
1763
+ try {
1764
+ return JSON.parse($gVhhF$depictaiutilishared.base64_decode_unicode(encoded_data));
1765
+ } catch (e) {
1766
+ $gVhhF$depictaiutilishared.dlog("Failed to fallback parse filter data", op, encoded_data, e);
1767
+ }
1768
+ return null;
1769
+ }
1770
+ function $1ab22f2cd39b3061$export$58aa3f171519b6d7(filters, search_params, filter_query_param_prefix) {
1771
+ for (const filter of filters) {
1772
+ const {
1773
+ field: field,
1774
+ op: op,
1775
+ data: data
1776
+ } = filter;
1777
+ const encoded_data = $1ab22f2cd39b3061$var$encode_filter_data(op, data);
1778
+ search_params.set(filter_query_param_prefix + field + $1ab22f2cd39b3061$var$op_to_token(op), encoded_data);
1779
+ }
1780
+ }
1781
+ function $1ab22f2cd39b3061$export$f934fa24c3a86811(search_params, filter_query_param_prefix) {
1782
+ const found_filters = [];
1783
+ for (const key of search_params.keys()) {
1784
+ // Allow for backwards compatibility with the old filter query param prefix
1785
+ let chosen_prefix = filter_query_param_prefix;
1786
+ if (!key.startsWith(chosen_prefix)) {
1787
+ chosen_prefix = $1ab22f2cd39b3061$var$legacy_filter_prefix;
1788
+ if (!key.startsWith(chosen_prefix)) continue;
1789
+ }
1790
+ const encoded_data = search_params.get(key);
1791
+ if (!encoded_data) continue;
1792
+ const [op, token] = Object.entries($1ab22f2cd39b3061$var$operator_map).find(([, token]) => key.endsWith(token)) || [$1ab22f2cd39b3061$var$fallback_operator, $1ab22f2cd39b3061$var$fallback_token];
1793
+ const data = $1ab22f2cd39b3061$var$decode_filter_data(op, encoded_data);
1794
+ if (!data) continue;
1795
+ const field = key.slice(chosen_prefix.length, token ? -token.length : undefined);
1796
+ found_filters.push({
1797
+ field: field,
1798
+ op: op,
1799
+ data: data
1800
+ });
1801
+ }
1802
+ return found_filters;
1803
+ }
1804
+ function $1ab22f2cd39b3061$export$62acb285a7579555(sorting, search_params, sorting_query_param) {
1805
+ if (!sorting) return;
1806
+ const {
1807
+ field: field,
1808
+ order: order
1809
+ } = sorting;
1810
+ const ascending = order === "asc";
1811
+ search_params.set(sorting_query_param, field + (ascending ? $1ab22f2cd39b3061$var$ascending_token : $1ab22f2cd39b3061$var$descending_token));
1812
+ }
1813
+ function $1ab22f2cd39b3061$export$766e9676e74997d3(search_params, sorting_query_param_) {
1814
+ const encoded_sorting = search_params.get(sorting_query_param_);
1815
+ if (!encoded_sorting) return;
1816
+ if (encoded_sorting.endsWith($1ab22f2cd39b3061$var$ascending_token)) return {
1817
+ field: encoded_sorting.slice(0, -$1ab22f2cd39b3061$var$ascending_token.length),
1818
+ order: "asc"
1819
+ };
1820
+ if (encoded_sorting.endsWith($1ab22f2cd39b3061$var$descending_token)) return {
1821
+ field: encoded_sorting.slice(0, -$1ab22f2cd39b3061$var$descending_token.length),
1822
+ order: "desc"
1823
+ };
1824
+ $gVhhF$depictaiutilishared.dlog("Invalid sorting query param value", encoded_sorting);
1825
+ return;
1826
+ }
1827
+ function $1ab22f2cd39b3061$export$916e6850778505f6(search_params, filter_query_param_prefix, sorting_query_param) {
1828
+ // We'll be modifying the URLSearchParams object, so we need to make a copy of the keys first
1829
+ const keys = [...search_params.keys()];
1830
+ for (const key of keys) if (key.startsWith(filter_query_param_prefix) || key === sorting_query_param || key.startsWith($1ab22f2cd39b3061$var$legacy_filter_prefix)) search_params.delete(key);
1831
+ }
1832
+ const $1ab22f2cd39b3061$export$cf5feb2102aec7f2 = "went_sideways_clear_filters";
1833
+ function $1ab22f2cd39b3061$export$43cd1e747fecd42e({
1834
+ to_url_: to_url_,
1835
+ set_clearing_flag_: set_clearing_flag_,
1836
+ from_search_params_ = new URLSearchParams(location.search),
1837
+ sorting_query_param_: sorting_query_param_,
1838
+ filter_query_param_prefix_: filter_query_param_prefix_
1839
+ }) {
1840
+ if (!to_url_) return to_url_;
1841
+ const was_url_object = to_url_ instanceof URL;
1842
+ const url_object = was_url_object ? to_url_ : new URL(to_url_, location.origin);
1843
+ const {
1844
+ searchParams: searchParams
1845
+ } = url_object;
1846
+ if (set_clearing_flag_) searchParams.set($1ab22f2cd39b3061$export$cf5feb2102aec7f2, "true");
1847
+ if (from_search_params_.has(sorting_query_param_)) searchParams.set(sorting_query_param_, from_search_params_.get(sorting_query_param_));
1848
+ for (const key of from_search_params_.keys()) if (key.startsWith(filter_query_param_prefix_)) searchParams.set(key, from_search_params_.get(key));
1849
+ if (was_url_object) return url_object;
1850
+ return url_object.href;
1851
+ }
1852
+ const $93304d59a9747aa6$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div>`);
1853
+ function $93304d59a9747aa6$export$94026ee33dbabc26(props) {
1854
+ return (() => {
1855
+ const _el$ = $gVhhF$solidjsweb.getNextElement($93304d59a9747aa6$var$_tmpl$);
1856
+ $gVhhF$solidjsweb.effect(_p$ => {
1857
+ const _v$ = `position:relative;width:100%;padding-bottom:${1 / props.aspectRatio * 100}%`,
1858
+ _v$2 = props.class;
1859
+ _p$._v$ = $gVhhF$solidjsweb.style(_el$, _v$, _p$._v$);
1860
+ _v$2 !== _p$._v$2 && $gVhhF$solidjsweb.className(_el$, _p$._v$2 = _v$2);
1861
+ return _p$;
1862
+ }, {
1863
+ _v$: undefined,
1864
+ _v$2: undefined
1865
+ });
1866
+ return _el$;
1867
+ })();
1868
+ }
1869
+ function $19950faaac026e09$export$e6fffe67d4cdd848(whatToWatch) {
1870
+ const [size, setSize] = $gVhhF$solidjs.createSignal(0);
1871
+ const resizeObserver = new ResizeObserver($gVhhF$depictaiutilishared.catchify(records => {
1872
+ for (let j = 0; j < records.length; j++) {
1873
+ const {
1874
+ width: width
1875
+ } = records[j].contentRect;
1876
+ if (!width) continue;
1877
+ // add extra 5% just in case. + safari is (in some cases) acting a bit questionable and needs a third extra to fill the set width
1878
+ const new_size = width * 1.05 * ((0, $gVhhF$depictaiutilishared.is_safari) ? 4 / 3 : 1);
1879
+ setSize(Math.round(new_size));
1880
+ }
1881
+ }));
1882
+ // If we start observing elements before they're in the DOM Chrome (Version 117.0.5938.92 (Official Build) (arm64)) sometimes gives us a resize event with a width of 0 and then doesn't dispatch one with the actual width once it's in the DOM. So we wait until the element is in the DOM before we start observing it.
1883
+ // It doesn't seem to work even when waiting for it to be in the DOM, also wait an animation frame
1884
+ const disconnect = (0, $gVhhF$depictaiutilishared.observer).onexists(whatToWatch, ({
1885
+ element: element
1886
+ }) => requestAnimationFrame($gVhhF$depictaiutilishared.catchify(() => resizeObserver.observe(element))));
1887
+ $gVhhF$solidjs.onCleanup(() => {
1888
+ resizeObserver.disconnect();
1889
+ disconnect();
1890
+ });
1891
+ return size;
1892
+ }
1893
+ const $19950faaac026e09$var$onIdleFunctionsSymbol = /*@__PURE__*/Symbol("onIdleFunctions");
1894
+ function $19950faaac026e09$export$6e5611bc7e57e477(props) {
1895
+ // Enable reactive props
1896
+ const otherOptions = $gVhhF$solidjs.createMemo(() => {
1897
+ const cloned_props = {
1898
+ ...props
1899
+ };
1900
+ delete cloned_props.resolutions;
1901
+ // @ts-ignore
1902
+ delete cloned_props.size;
1903
+ // @ts-ignore
1904
+ delete cloned_props.src;
1905
+ return cloned_props;
1906
+ });
1907
+ const src_options = $gVhhF$solidjs.createMemo(() => {
1908
+ const src = new URL(props.src, location.origin);
1909
+ const fallback_src = $19950faaac026e09$var$generateImageUrl(src, 400);
1910
+ const srcset = $19950faaac026e09$var$make_srcset(src, props.resolutions || [64, 128, 256, 300, 400, 512, 768, 1024, 1280, 1536, 2048, 4096]);
1911
+ return {
1912
+ src: fallback_src,
1913
+ srcset: srcset
1914
+ };
1915
+ });
1916
+ // Work around https://github.com/solidjs/solid/issues/1828
1917
+ const img = new Image(); // Need to use new Image or browser might not start loading image before it's in the DOM
1918
+ const [hasSetSize, setHasSetSize] = $gVhhF$solidjs.createSignal(false);
1919
+ const [hasDecoded, setHasDecoded] = $gVhhF$solidjs.createSignal(false);
1920
+ const sizePX = $gVhhF$solidjs.createMemo(() => `${props.size()}px`); // props.size could be a getter that expects a cleanup so get it in this memo instead of where we set img.sizes
1921
+ const listingContext = $84798aaa863a4909$export$8d0c4fdbb05a2f2e();
1922
+ // Batch idle callbacks so that MutationObserver can batch the resulting mutations better, so we don't lose tons of CPU time to MutationObservers doing lots of things for each image
1923
+ // Happened on singular, they have some weird observer (+we also have one but ours is at least 3x more efficient)
1924
+ const executeWhenIdleBatched = fn => {
1925
+ if (typeof requestIdleCallback !== "function") return setTimeout(fn); // Old browsers don't get optimisation
1926
+ const existingStack = listingContext?.[$19950faaac026e09$var$onIdleFunctionsSymbol];
1927
+ if (existingStack) return existingStack.add(fn);
1928
+ const newStack = new Set([fn]);
1929
+ if (listingContext) listingContext[$19950faaac026e09$var$onIdleFunctionsSymbol] = newStack;
1930
+ const processStackWhenIdle = () => requestIdleCallback(deadline => {
1931
+ const start = performance.now();
1932
+ const thirdDeadlineTime = deadline.timeRemaining() / 3; // observers coming after this take up 2-3x the time so don't use all of it
1933
+ for (const fn of newStack) {
1934
+ newStack.delete(fn);
1935
+ fn();
1936
+ const timeTaken = performance.now() - start;
1937
+ if ((!deadline.timeRemaining() || timeTaken > thirdDeadlineTime) && newStack.size) {
1938
+ // There's still work to be done but no time, so schedule another idle callback
1939
+ processStackWhenIdle();
1940
+ return;
1941
+ }
1942
+ }
1943
+ // Stack is empty
1944
+ if (listingContext) delete listingContext[$19950faaac026e09$var$onIdleFunctionsSymbol];
1945
+ }, {
1946
+ timeout: 15000
1947
+ } // long timeout, better to not have images than to freeze the browser. But also we don't want to confuse user why no iamges are loading
1948
+ );
1949
+
1950
+ processStackWhenIdle();
1951
+ };
1952
+ let sizeSetFastPath = false;
1953
+ let hasDecodedFastPath = false;
1954
+ let timeoutSet = false;
1955
+ let gotCleanedUp = false;
1956
+ $gVhhF$solidjs.onCleanup(() => gotCleanedUp = true);
1957
+ $gVhhF$solidjsweb.spread(img, $gVhhF$solidjs.mergeProps(otherOptions), false, true);
1958
+ $gVhhF$solidjs.createEffect(() => {
1959
+ if (!props.size()) return; // wait until we have a size
1960
+ if (timeoutSet) return;
1961
+ const handler = $gVhhF$depictaiutilishared.catchify(() => {
1962
+ if (gotCleanedUp) return;
1963
+ img.sizes = sizePX(); // use latest available value of props.size
1964
+ if (!sizeSetFastPath) {
1965
+ setHasSetSize(true);
1966
+ sizeSetFastPath = true;
1967
+ }
1968
+ timeoutSet = false;
1969
+ });
1970
+ // Throttle the updating of sizes to avoid unnecessary image re-fetches during resize
1971
+ // And also because we first set src after sizes has been set, wait with loading and decoding images until browser is idle
1972
+ // This greatly improves performance when loading (more) products
1973
+ // See https://depictaiworkspace.slack.com/archives/C05NJ0K3WRL/p1698220617663139
1974
+ executeWhenIdleBatched(handler);
1975
+ timeoutSet = true;
1976
+ });
1977
+ $gVhhF$solidjs.createEffect(() => {
1978
+ if (!props.size() || !hasSetSize()) return; // If size isn't known or set, don't assign src yet since it would cause the most low res image to load
1979
+ Object.assign(img, src_options());
1980
+ // Add to DOM once decoded to not require/block any paints before image has completed loading and avoid showing broken image symbol
1981
+ // We can do this because there has to be a container around us giving us a size
1982
+ // No need to listen if we're already in the DOM
1983
+ if (hasDecodedFastPath) return;
1984
+ if (props.loading === "lazy") {
1985
+ // For lazy loading there's no decoding to wait for as it only occurs when the image is visible
1986
+ // Make sure src is set before we put the image into the DOM though so no broken image symbol is shown
1987
+ setHasDecoded(true);
1988
+ hasDecodedFastPath = true;
1989
+ return;
1990
+ }
1991
+ img.decode().catch(e => $gVhhF$depictaiutilishared.dwarn("Failed to decode image", e, img)) // Display the image also if loading failed so webdev can debug and doesn't get "no image"
1992
+ .then(async () => {
1993
+ // Also wait with inserting image (i.e. paint) until browser is idle
1994
+ await new Promise(r => executeWhenIdleBatched(r));
1995
+ if (gotCleanedUp) return;
1996
+ setHasDecoded(true);
1997
+ hasDecodedFastPath = true;
1998
+ });
1999
+ });
2000
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
2001
+ get when() {
2002
+ return hasDecoded();
2003
+ },
2004
+ children: img
2005
+ });
2006
+ }
2007
+ function $19950faaac026e09$var$make_srcset(url, resolutions) {
2008
+ return resolutions.map(width => `${$19950faaac026e09$var$generateImageUrl(url, width)} ${width}w`).join(", ");
2009
+ }
2010
+ function $19950faaac026e09$var$generateImageUrl(url, width) {
2011
+ // This function is quite slow, we maybe could do string concat with encodeURIComponent instead if shopify handles double width params well?
2012
+ url.searchParams.set("width", width);
2013
+ return url.href;
2014
+ }
2015
+ const $a33065cfed827fc0$var$backupSizeSignal = /*@__PURE__*/$gVhhF$solidjs.createSignal();
2016
+ const $a33065cfed827fc0$export$d7b7ab832c20e2f4 = /*@__PURE__*/Symbol("ShopifyContainedImage");
2017
+ function $a33065cfed827fc0$export$e4b984597b71e989(props) {
2018
+ const context = $84798aaa863a4909$export$8d0c4fdbb05a2f2e();
2019
+ if (context && !context[$a33065cfed827fc0$export$d7b7ab832c20e2f4])
2020
+ // create a signal that's the same for all items in this listing
2021
+ context[$a33065cfed827fc0$export$d7b7ab832c20e2f4] = $gVhhF$solidjs.createSignal();
2022
+ const [currentImageSize, setCurrentImageSize] = context?.[$a33065cfed827fc0$export$d7b7ab832c20e2f4] || $a33065cfed827fc0$var$backupSizeSignal; // use global fallback signal (might lead to blurry images) if no context is available
2023
+ const container = $gVhhF$solidjsweb.createComponent((0, $93304d59a9747aa6$export$94026ee33dbabc26), {
2024
+ get aspectRatio() {
2025
+ return props.aspectRatio;
2026
+ },
2027
+ get ["class"]() {
2028
+ return props.class;
2029
+ }
2030
+ });
2031
+ const owner = $gVhhF$solidjs.getOwner();
2032
+ let createdSizeAccessor = false;
2033
+ let wasCleanedUp = false;
2034
+ $gVhhF$solidjs.createEffect(() => {
2035
+ if (currentImageSize() || wasCleanedUp) return; // We get into the effect when onCleanup is called if we don't have wasCleanedUp
2036
+ // ensure we always have a size accessor
2037
+ // what this whole thing does is set the sizes attribute to the actual size of one of the existing image containers, therefore the value doesn't have to manually be specified
2038
+ createdSizeAccessor = true;
2039
+ setCurrentImageSize(() => $gVhhF$solidjs.runWithOwner(owner, () => $19950faaac026e09$export$e6fffe67d4cdd848(container)));
2040
+ });
2041
+ $gVhhF$solidjs.onCleanup(() => {
2042
+ wasCleanedUp = true; // important to set this before the function call below and always, so the dead effects don't create dead size accessors
2043
+ if (!createdSizeAccessor) return;
2044
+ $gVhhF$depictaiutilishared.queueMacroTask(() => setCurrentImageSize(undefined)); // unset the size accessor next event loop iteration, so that all onCleanup's have time to run, since the effects run more aggressively and can create a size accessor with a cleaned up owner otherwise
2045
+ });
2046
+
2047
+ $gVhhF$solidjsweb.insert(container, $gVhhF$solidjsweb.createComponent((0, $19950faaac026e09$export$6e5611bc7e57e477), {
2048
+ style: "width: 100%; height: 100%; object-fit: contain; position: absolute; inset: 0;",
2049
+ get size() {
2050
+ return $gVhhF$solidjs.createMemo(() => currentImageSize()?.() || 0);
2051
+ },
2052
+ get src() {
2053
+ return props.src;
2054
+ },
2055
+ get alt() {
2056
+ return props.alt;
950
2057
  }
951
- update_children_count();
952
- if (!(0, $gVhhF$solidjsweb.isServer)) {
953
- const mutation_observer = new MutationObserver($gVhhF$depictaiutilishared.catchify(update_children_count));
954
- mutation_observer.observe(container_element, {
955
- childList: true
956
- });
957
- $gVhhF$solidjs.onCleanup(() => mutation_observer.disconnect());
2058
+ }));
2059
+ return container;
2060
+ }
2061
+
2062
+ /** @jsxImportSource solid-js */
2063
+
2064
+ function $f13855d1b951b24a$export$ebdc3711f7e02ccd(what_to_watch) {
2065
+ const [width, setWidth] = $gVhhF$solidjs.createSignal();
2066
+ const resizeObserver = new ResizeObserver($gVhhF$depictaiutilishared.catchify(records => {
2067
+ for (let j = 0; j < records.length; j++) {
2068
+ const width = records[j].borderBoxSize?.[0]?.inlineSize ?? what_to_watch.getBoundingClientRect().width;
2069
+ setWidth(width);
958
2070
  }
959
- set_styling(
960
- // this is needed because solid will think that the memo-accessor is a setter function otherwise
961
- () => $gVhhF$solidjs.createMemo(() => {
962
- const {
963
- rows_per_click: rows_per_click,
964
- max_rows = -1,
965
- start_rows: start_rows
966
- } = rows_or_empty_object();
967
- const rows_visible = get_rows_visible();
968
- const children_count = get_children_count();
969
- return force_style_update() + col_styling() + props.cols_at_size.map(options => {
970
- const [recs_per_row, min, max] = options;
971
- let should_hide_view_more_button;
972
- let visible_recs;
973
- if (props.disable_partial_rows) {
974
- visible_recs = $gVhhF$depictaiutilishared.layout_get_visible_recs_without_partial_rows(rows_visible, children_count, options);
975
- const visible_recs_next_show_more = $gVhhF$depictaiutilishared.layout_get_visible_recs_without_partial_rows(rows_visible + (rows_per_click || 0),
976
- // Should this really be zero when we default rows_per_click to 1?
977
- children_count, options);
978
- should_hide_view_more_button = visible_recs === visible_recs_next_show_more;
979
- } else {
980
- visible_recs = $gVhhF$depictaiutilishared.layout_get_total_rec_amount_for_row(rows_visible, options);
981
- should_hide_view_more_button = visible_recs >= children_count;
982
- }
983
- const should_hide_button_final = should_hide_view_more_button || max_rows !== -1 && rows_visible >= max_rows;
984
- // I don't really understand the logic for when the view more button gets hidden so IDK if below is correct, but it works how it should for now
985
- const should_hide_view_less_button = !should_hide_view_more_button || start_rows == undefined || rows_visible <= start_rows || children_count <= recs_per_row * start_rows;
986
- return `${$gVhhF$depictaiutilishared.layout_media_query_header(min, max)}{${selector_beginning}:nth-child(n+${visible_recs + 1}){display:none}${props.layout == "slider" ? `${selector_beginning}:nth-child(n+${visible_recs}){margin-right:0}` : ""}${should_hide_button_final ? `.depict .${view_more_button_class}{display:none!important}` : ``}${should_hide_view_less_button ? `.depict .${view_less_button_class}{display:none!important}` : ``}}`;
987
- }).join("");
988
- }));
2071
+ }));
2072
+ // If we start observing elements before they're in the DOM Chrome (Version 117.0.5938.92 (Official Build) (arm64)) sometimes gives us a resize event with a width of 0 and then doesn't dispatch one with the actual width once it's in the DOM. So we wait until the element is in the DOM before we start observing it.
2073
+ // It doesn't seem to work even when waiting for it to be in the DOM, also wait an animation frame
2074
+ const disconnect = (0, $gVhhF$depictaiutilishared.observer).onexists(what_to_watch, ({
2075
+ element: element
2076
+ }) => requestAnimationFrame($gVhhF$depictaiutilishared.catchify(() => {
2077
+ const current_size = what_to_watch.getBoundingClientRect().width;
2078
+ if (current_size)
2079
+ // If element has size, set signal to that. ResizeObserver only triggers when the content is visible in some cases, but it might already have a size. This reduces size filter expanding animation jank in chrome.
2080
+ setWidth(current_size);
2081
+ resizeObserver.observe(element);
2082
+ })));
2083
+ $gVhhF$solidjs.onCleanup(() => {
2084
+ resizeObserver.disconnect();
2085
+ disconnect();
989
2086
  });
990
- const style_element = (() => {
991
- const _el$4 = $gVhhF$solidjsweb.getNextElement($f48d0fbb00835aaa$var$_tmpl$2);
992
- $gVhhF$solidjsweb.insert(_el$4, get_styling);
993
- return _el$4;
994
- })(); // need to create this after set_styling has been called or else there will be no styling in the SSR'd output
995
- if (insert_after_container) container_element.after(style_element);
996
- return [container_element, $gVhhF$solidjsweb.memo(view_more_button_container), $gVhhF$solidjsweb.memo(view_less_button_container), style_element];
2087
+ return width;
997
2088
  }
998
- $gVhhF$solidjsweb.delegateEvents(["click"]);
999
2089
  const $363ce4d1d71041aa$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<h2 class=recs-title>`);
1000
2090
  function $363ce4d1d71041aa$export$d41d19e89346fa2({
1001
2091
  recommendations_resource_: recommendations_resource_,
1002
2092
  product_card_template_: product_card_template_,
1003
2093
  layout_options_: layout_options_,
1004
- merchant_: merchant_,
1005
- market_: market_,
1006
2094
  title_: title_
1007
2095
  }) {
1008
2096
  const is_showing_something = $gVhhF$solidjs.createMemo(() => recommendations_resource_.loading || recommendations_resource_()?.length);
@@ -1034,205 +2122,37 @@ function $363ce4d1d71041aa$export$d41d19e89346fa2({
1034
2122
  $gVhhF$depictaiutilishared.slider_fractional_factory(0, 0.75).constructor_plugin.call(slider, {}); // enable fractional scrolling
1035
2123
  insert_here.before($fc23d7668ae0011d$export$a2cc176055f8f08());
1036
2124
  },
1037
- get children() {
1038
- return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Suspense), {
1039
- get fallback() {
1040
- return $0caf87eaa19079da$export$f33414a4df0afd3f({
1041
- num_placeholders_: num_placeholders_,
1042
- product_card_template_: product_card_template_
1043
- });
1044
- },
1045
- get children() {
1046
- return (() => {
1047
- // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
1048
- const displays_by_key_ = $a73063cc642f3e5f$export$7f8bd308237ab5a5($gVhhF$solidjs.createMemo(() => recommendations_resource_() || []));
1049
- return $a73063cc642f3e5f$export$43f0fb951fcb0c54({
1050
- displays_by_key_: displays_by_key_,
1051
- merchant_: merchant_,
1052
- market_: market_,
1053
- product_card_template_: product_card_template_
1054
- });
1055
- })();
1056
- }
1057
- });
1058
- }
1059
- })];
1060
- return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
1061
- get when() {
1062
- return is_showing_something();
1063
- },
1064
- children: slider
1065
- });
1066
- }
1067
- function $95837413165cc2df$export$23fca46f3143581f(component, error_message) {
1068
- const component_in_error_boundary = do_with_elements => {
1069
- const error_boundary_wrapped = $edafe91daf3091d7$export$b69d0d92862de18b({
1070
- severity_: "error",
1071
- message_: error_message,
1072
- get children() {
1073
- const elements = component();
1074
- do_with_elements?.(elements);
1075
- return elements;
1076
- }
1077
- });
1078
- // This might return an accessor, in that case we need to "unwrap" it since our SDK consumers expect HTML elements or arrays thereof
1079
- if (typeof error_boundary_wrapped === "function")
1080
- // @ts-ignore
1081
- return error_boundary_wrapped();
1082
- // On the server it returns a string, so we just return that
1083
- return error_boundary_wrapped;
1084
- };
1085
- const owner = $gVhhF$solidjs.getOwner();
1086
- if (owner == null) return $gVhhF$solidjs.createRoot(dispose => {
1087
- // if we're not already run in a root, create a root and automatically dispose it when the first returned element is removed from the DOM
1088
- return component_in_error_boundary(elements => {
1089
- const have_multiple = Array.isArray(elements);
1090
- if (have_multiple ? !elements?.length : !elements) return;
1091
- (0, $gVhhF$depictaiutilishared.observer).onremoved(have_multiple ? elements[0] : elements, ({
1092
- element: element
1093
- }) => {
1094
- if (document.documentElement.contains(element)) return; // If element has instantly been re-inserted, don't dispose
1095
- // See https://depictaiworkspace.slack.com/archives/C050GHEPBTR/p1695809102791259?thread_ts=1695106805.459729&cid=C050GHEPBTR
1096
- dispose();
1097
- });
1098
- });
1099
- });else
1100
- // we're already in a root so cleanups are handled
1101
- return component_in_error_boundary();
1102
- }
1103
- const $72f96c4782db0b1b$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class="depict recommendations">`);
1104
- function $72f96c4782db0b1b$export$9574e176201e5e8d(props) {
1105
- return $95837413165cc2df$export$23fca46f3143581f(() => {
1106
- const grid_spacing_override = $gVhhF$solidjs.createMemo(() => {
1107
- const {
1108
- grid_spacing: grid_spacing
1109
- } = props; // can be reactive
1110
- return typeof grid_spacing === "string" ? {
1111
- grid_spacing: grid_spacing
1112
- } : {
1113
- override_vertical_spacing: grid_spacing.vertical,
1114
- grid_spacing: grid_spacing.horizontal
1115
- };
1116
- });
1117
- const [recommendations_resource_] = $gVhhF$solidjs.createResource(() => props.recommendations, recs => recs);
1118
- return (() => {
1119
- const _el$ = $gVhhF$solidjsweb.getNextElement($72f96c4782db0b1b$var$_tmpl$);
1120
- $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent((0, $84798aaa863a4909$export$e68cff63f76bd15b), {
1121
- get children() {
1122
- return $363ce4d1d71041aa$export$d41d19e89346fa2({
1123
- product_card_template_: (...args) => props.product_card_template(...args),
1124
- recommendations_resource_: recommendations_resource_,
1125
- market_: () => props.market,
1126
- merchant_: () => props.merchant,
1127
- title_: () => props.title,
1128
- layout_options_: $gVhhF$solidjs.createMemo(() => ({
1129
- cols_at_size: $4e04be41243c3d80$export$6daf8749b65a1b77(props.cols_at_size),
1130
- ...grid_spacing_override()
1131
- }))
1132
- });
1133
- }
1134
- }));
1135
- return _el$;
1136
- })();
1137
- }, "RecommendationSlider failed");
1138
- }
1139
- const $b8e79813f4f7ebe4$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<h2 class=recs-title>`),
1140
- $b8e79813f4f7ebe4$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=recommendation-grid><!$><!/><!$><!/>`);
1141
- function $b8e79813f4f7ebe4$export$7da560f849543dff({
1142
- recommendations_resource_: recommendations_resource_,
1143
- product_card_template_: product_card_template_,
1144
- layout_options_: layout_options_,
1145
- merchant_: merchant_,
1146
- market_: market_,
1147
- rows_object_: rows_object_,
1148
- title_: title_
1149
- }) {
1150
- const is_showing_something = $gVhhF$solidjs.createMemo(() => recommendations_resource_.loading || recommendations_resource_()?.length);
1151
- const title = $gVhhF$solidjs.createMemo(() => title_?.()); // In case getter/accessor creates elements, don't create them twice
1152
- const num_placeholders_ = () => 20;
1153
- const elements = [$gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
1154
- get when() {
1155
- return title();
1156
- },
1157
- get children() {
1158
- const _el$ = $gVhhF$solidjsweb.getNextElement($b8e79813f4f7ebe4$var$_tmpl$);
1159
- $gVhhF$solidjsweb.insert(_el$, title);
1160
- return _el$;
1161
- }
1162
- }), (() => {
1163
- const _el$2 = $gVhhF$solidjsweb.getNextElement($b8e79813f4f7ebe4$var$_tmpl$2),
1164
- _el$3 = _el$2.firstChild,
1165
- [_el$4, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$3.nextSibling),
1166
- _el$5 = _el$4.nextSibling,
1167
- [_el$6, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$5.nextSibling);
1168
- $gVhhF$solidjsweb.insert(_el$2, (0, $fc23d7668ae0011d$export$a2cc176055f8f08), _el$4, _co$);
1169
- $gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $f48d0fbb00835aaa$export$d21e32dfedac04be), $gVhhF$solidjsweb.mergeProps({
1170
- get rows() {
1171
- return rows_object_();
1172
- },
1173
- layout: "grid",
1174
- element_attributes: {
1175
- class: "cards"
1176
- }
1177
- }, layout_options_, {
1178
- get children() {
1179
- return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Suspense), {
1180
- get fallback() {
1181
- return $0caf87eaa19079da$export$f33414a4df0afd3f({
1182
- num_placeholders_: num_placeholders_,
2125
+ get children() {
2126
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Suspense), {
2127
+ get fallback() {
2128
+ return $0caf87eaa19079da$export$f33414a4df0afd3f({
2129
+ num_placeholders_: num_placeholders_,
2130
+ product_card_template_: product_card_template_
2131
+ });
2132
+ },
2133
+ get children() {
2134
+ return (() => {
2135
+ // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
2136
+ const displays_by_key_ = $a73063cc642f3e5f$export$7f8bd308237ab5a5($gVhhF$solidjs.createMemo(() => recommendations_resource_() || []));
2137
+ return $a73063cc642f3e5f$export$43f0fb951fcb0c54({
2138
+ displays_by_key_: displays_by_key_,
1183
2139
  product_card_template_: product_card_template_
1184
2140
  });
1185
- },
1186
- get children() {
1187
- return (() => {
1188
- // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
1189
- const displays_by_key_ = $a73063cc642f3e5f$export$7f8bd308237ab5a5($gVhhF$solidjs.createMemo(() => recommendations_resource_() || []));
1190
- return $a73063cc642f3e5f$export$43f0fb951fcb0c54({
1191
- displays_by_key_: displays_by_key_,
1192
- merchant_: merchant_,
1193
- market_: market_,
1194
- product_card_template_: product_card_template_
1195
- });
1196
- })();
1197
- }
1198
- });
1199
- }
1200
- })), _el$6, _co$2);
1201
- return _el$2;
1202
- })()];
2141
+ })();
2142
+ }
2143
+ });
2144
+ }
2145
+ })];
1203
2146
  return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
1204
2147
  get when() {
1205
2148
  return is_showing_something();
1206
2149
  },
1207
- children: elements
2150
+ children: slider
1208
2151
  });
1209
2152
  }
1210
- const $1f8dbf7e28b3eff2$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<button class="show-more major"type=button>`),
1211
- $1f8dbf7e28b3eff2$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class="depict plp recommendations">`);
1212
- function $1f8dbf7e28b3eff2$export$9756467d34d91cdb(props) {
2153
+ const $72f96c4782db0b1b$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class="depict recommendations">`);
2154
+ function $72f96c4782db0b1b$export$9574e176201e5e8d(props) {
1213
2155
  return $95837413165cc2df$export$23fca46f3143581f(() => {
1214
- const rows_object_ = $gVhhF$solidjs.createMemo(() => {
1215
- const {
1216
- view_more_button: view_more_button,
1217
- max_rows: max_rows
1218
- } = props;
1219
- if (!view_more_button) {
1220
- if (max_rows) return {
1221
- max_rows: max_rows
1222
- };
1223
- return "all";
1224
- }
1225
- return {
1226
- max_rows: max_rows,
1227
- start_rows: view_more_button.start_rows,
1228
- rows_per_click: view_more_button.rows_per_click ?? 2,
1229
- button: (() => {
1230
- const _el$ = $gVhhF$solidjsweb.getNextElement($1f8dbf7e28b3eff2$var$_tmpl$);
1231
- $gVhhF$solidjsweb.insert(_el$, () => view_more_button.text);
1232
- return _el$;
1233
- })()
1234
- };
1235
- });
1236
2156
  const grid_spacing_override = $gVhhF$solidjs.createMemo(() => {
1237
2157
  const {
1238
2158
  grid_spacing: grid_spacing
@@ -1246,15 +2166,12 @@ function $1f8dbf7e28b3eff2$export$9756467d34d91cdb(props) {
1246
2166
  });
1247
2167
  const [recommendations_resource_] = $gVhhF$solidjs.createResource(() => props.recommendations, recs => recs);
1248
2168
  return (() => {
1249
- const _el$2 = $gVhhF$solidjsweb.getNextElement($1f8dbf7e28b3eff2$var$_tmpl$2);
1250
- $gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $84798aaa863a4909$export$e68cff63f76bd15b), {
2169
+ const _el$ = $gVhhF$solidjsweb.getNextElement($72f96c4782db0b1b$var$_tmpl$);
2170
+ $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent((0, $84798aaa863a4909$export$e68cff63f76bd15b), {
1251
2171
  get children() {
1252
- return $b8e79813f4f7ebe4$export$7da560f849543dff({
1253
- rows_object_: rows_object_,
2172
+ return $363ce4d1d71041aa$export$d41d19e89346fa2({
1254
2173
  product_card_template_: (...args) => props.product_card_template(...args),
1255
2174
  recommendations_resource_: recommendations_resource_,
1256
- market_: () => props.market,
1257
- merchant_: () => props.merchant,
1258
2175
  title_: () => props.title,
1259
2176
  layout_options_: $gVhhF$solidjs.createMemo(() => ({
1260
2177
  cols_at_size: $4e04be41243c3d80$export$6daf8749b65a1b77(props.cols_at_size),
@@ -1263,9 +2180,9 @@ function $1f8dbf7e28b3eff2$export$9756467d34d91cdb(props) {
1263
2180
  });
1264
2181
  }
1265
2182
  }));
1266
- return _el$2;
2183
+ return _el$;
1267
2184
  })();
1268
- }, "RecommendationGrid failed");
2185
+ }, "RecommendationSlider failed");
1269
2186
  }
1270
2187
  function $4b455f60dadde8b8$export$5bad61ecde080b1f(...params) {
1271
2188
  const {
@@ -1560,15 +2477,6 @@ function $47e2cc552c02110c$export$8895d39404bd2bb1(props) {
1560
2477
  if (delay_toast_) return show_configured_toast;else show_configured_toast();
1561
2478
  }
1562
2479
  $gVhhF$solidjsweb.delegateEvents(["click"]);
1563
- const $c77c68e559a1506c$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<svg xmlns=http://www.w3.org/2000/svg width=21.064 height=21.047 viewBox="0 0 21.064 21.064"><path d="M11.669 10.531l9.156-9.156a.78.78 0 0 0 .237-.569c0-.221-.079-.412-.237-.569A.8.8 0 0 0 20.24 0a.77.77 0 0 0-.569.237l-9.14 9.14-9.14-9.14A.79.79 0 0 0 .807 0a.77.77 0 0 0-.569.237A.78.78 0 0 0 0 .807a.77.77 0 0 0 .237.569l9.156 9.156-9.156 9.14c-.159.157-.237.349-.237.569s.079.412.237.569c.085.085.174.148.268.19a1.095 1.095 0 0 0 .316.048.894.894 0 0 0 .285-.048.84.84 0 0 0 .285-.19l9.139-9.14 9.14 9.14a.894.894 0 0 0 .268.19 1.049 1.049 0 0 0 .301.048.941.941 0 0 0 .301-.048.84.84 0 0 0 .285-.19.78.78 0 0 0 .237-.569c0-.221-.079-.412-.237-.569z">`);
1564
- function $c77c68e559a1506c$export$3b621d86b1566b2(props = {}) {
1565
- return (() => {
1566
- const _el$ = $gVhhF$solidjsweb.getNextElement($c77c68e559a1506c$var$_tmpl$);
1567
- $gVhhF$solidjsweb.spread(_el$, props, true, true);
1568
- $gVhhF$solidjsweb.runHydrationEvents();
1569
- return _el$;
1570
- })();
1571
- }
1572
2480
 
1573
2481
  /**
1574
2482
  * Lower cases a string if possible. Mostly used to make the filter url values case-insensitive.
@@ -1579,7 +2487,7 @@ function $daa394359b026187$export$325f75597868c4f0(stuff) {
1579
2487
  }
1580
2488
  const $235a2771a44e28e9$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<button class="clear-all-filters minor">`),
1581
2489
  $235a2771a44e28e9$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=inner><span class=title><!$><!/>: </span><!$><!/>`),
1582
- $235a2771a44e28e9$var$_tmpl$3 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<button class="clear-filter major"><!$><!/><span><!$><!/><!$><!/><!$><!/> – <!$><!/><!$><!/><!$><!/>`),
2490
+ $235a2771a44e28e9$var$_tmpl$3 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<button class="clear-filter major"><!$><!/><span><!$><!/><!$><!/><!$><!/> \u{2013} <!$><!/><!$><!/><!$><!/>`),
1583
2491
  $235a2771a44e28e9$var$_tmpl$4 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<button class="clear-filter major"><!$><!/><span>`);
1584
2492
  function $235a2771a44e28e9$export$fecbb157621501bd({
1585
2493
  number_of_rendered_selected_filters_items_: number_of_rendered_selected_filters_items_,
@@ -2752,7 +3660,7 @@ function $5ea5a82e398f6f44$var$cut_text(segmented_text) {
2752
3660
  // identical split point, or split end before split start, can't do anything
2753
3661
  split_start_segment == split_end_segment && split_start_character >= split_end_character || split_start_segment > split_end_segment) return;
2754
3662
  const dots_segment = {
2755
- text_: " … ",
3663
+ text_: " \u2026 ",
2756
3664
  highlighted_: false
2757
3665
  };
2758
3666
  const split_and_dotted_values = segmented_text.flatMap((segment, i) => {
@@ -2844,7 +3752,7 @@ function $5ea5a82e398f6f44$var$cut_start(cut_left_of_index, segmented_text) {
2844
3752
  if (character === "," || is_space)
2845
3753
  // if we cut at a comma or psace, we add a … at the beginning
2846
3754
  segmented_text.unshift({
2847
- text_: "… ",
3755
+ text_: "\u2026 ",
2848
3756
  highlighted_: false
2849
3757
  });
2850
3758
  break outmost_loop;
@@ -3858,7 +4766,7 @@ function $b064919833b3e80b$export$53c59af873b303c9({
3858
4766
  get price_formatting_() {
3859
4767
  return price_formatting_();
3860
4768
  }
3861
- }), $gVhhF$solidjsweb.memo(() => price_formatting_().post_), " – ", $gVhhF$solidjsweb.memo(() => price_formatting_().pre_), $gVhhF$solidjsweb.createComponent((0, $d659702496cb72ea$export$a71e92cfbb498adc), {
4769
+ }), $gVhhF$solidjsweb.memo(() => price_formatting_().post_), " \u2013 ", $gVhhF$solidjsweb.memo(() => price_formatting_().pre_), $gVhhF$solidjsweb.createComponent((0, $d659702496cb72ea$export$a71e92cfbb498adc), {
3862
4770
  get price_() {
3863
4771
  return selected_filter.data[1];
3864
4772
  },
@@ -3948,47 +4856,6 @@ function $8c939a05b87fbbbc$export$ab34afce88557c0e(props) {
3948
4856
  }));
3949
4857
  return is_open;
3950
4858
  }
3951
- const $9fe9883b1d8ecccc$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span>`);
3952
- function $9fe9883b1d8ecccc$export$acb3eaade4b23afd(props) {
3953
- return (() => {
3954
- const _el$ = $gVhhF$solidjsweb.getNextElement($9fe9883b1d8ecccc$var$_tmpl$);
3955
- $gVhhF$solidjsweb.effect(_p$ => {
3956
- const _v$ = `depict-placeholder ${props.class || ""}`,
3957
- _v$2 = props.style;
3958
- _v$ !== _p$._v$ && $gVhhF$solidjsweb.className(_el$, _p$._v$ = _v$);
3959
- _p$._v$2 = $gVhhF$solidjsweb.style(_el$, _v$2, _p$._v$2);
3960
- return _p$;
3961
- }, {
3962
- _v$: undefined,
3963
- _v$2: undefined
3964
- });
3965
- return _el$;
3966
- })();
3967
- }
3968
- function $061ff5b4c3d36171$export$89c6019e4baa40b1(props) {
3969
- const style = $gVhhF$solidjs.createMemo(() => {
3970
- const {
3971
- style: style,
3972
- height: height,
3973
- width: width
3974
- } = props;
3975
- return {
3976
- ...(style || {}),
3977
- height: height ?? "1em",
3978
- ...(width && {
3979
- width: width
3980
- })
3981
- };
3982
- });
3983
- return $gVhhF$solidjsweb.createComponent((0, $9fe9883b1d8ecccc$export$acb3eaade4b23afd), {
3984
- get style() {
3985
- return style();
3986
- },
3987
- get ["class"]() {
3988
- return props.class;
3989
- }
3990
- });
3991
- }
3992
4859
  const $87d7574e1d89d69b$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<svg xmlns=http://www.w3.org/2000/svg width=20 height=22 viewBox="0 0 20 22"><path d="M19.811 20.174l-6.234-6.809a7.96 7.96 0 0 0 .923-1.179c.274-.424.502-.865.687-1.323a8.04 8.04 0 0 0 .42-1.436 7.88 7.88 0 0 0 .144-1.507c0-.526-.051-1.042-.154-1.548-.096-.506-.243-.995-.441-1.466s-.441-.919-.728-1.343a8.28 8.28 0 0 0-.984-1.21 7.86 7.86 0 0 0-1.2-.984A7.56 7.56 0 0 0 10.89.651C10.418.453 9.929.302 9.423.2S8.401.046 7.875.046 6.833.097 6.327.2 5.332.453 4.86.651a7.56 7.56 0 0 0-1.354.718c-.431.287-.831.615-1.2.984a8.28 8.28 0 0 0-.984 1.21 7.73 7.73 0 0 0-.728 1.343c-.198.472-.349.96-.451 1.466A8.31 8.31 0 0 0 0 7.921a8.31 8.31 0 0 0 .144 1.548c.103.506.253.995.451 1.466a8.08 8.08 0 0 0 .728 1.354 7.86 7.86 0 0 0 .984 1.2 7.54 7.54 0 0 0 1.2.995c.431.287.882.53 1.354.728.472.191.96.338 1.466.441a8.31 8.31 0 0 0 1.548.144c.451 0 .896-.038 1.333-.113a7.83 7.83 0 0 0 1.282-.328 7.55 7.55 0 0 0 1.2-.533 8.08 8.08 0 0 0 1.107-.749l6.245 6.809a.45.45 0 0 0 .174.123.55.55 0 0 0 .205.041.61.61 0 0 0 .195-.031c.061-.021.116-.055.164-.102.109-.096.164-.219.164-.369.007-.144-.038-.267-.133-.369zM1.046 7.921c0-.937.178-1.818.533-2.646.362-.834.851-1.559 1.466-2.174.622-.615 1.347-1.101 2.174-1.456.827-.362 1.712-.543 2.656-.543s1.829.181 2.656.543c.827.355 1.548.841 2.164 1.456.622.615 1.111 1.34 1.466 2.174a6.52 6.52 0 0 1 .543 2.646c0 .943-.181 1.829-.543 2.656a6.89 6.89 0 0 1-1.466 2.174c-.615.615-1.336 1.104-2.164 1.466-.827.356-1.712.533-2.656.533s-1.829-.178-2.656-.533c-.827-.362-1.552-.851-2.174-1.466-.615-.622-1.104-1.347-1.466-2.174-.355-.827-.533-1.712-.533-2.656z">`);
3993
4860
  function $87d7574e1d89d69b$export$82eafebb825fc23f(props = {}) {
3994
4861
  return (() => {
@@ -4543,150 +5410,33 @@ function $70482f04605572e2$var$modify_only_local_filter(local_filter_object, sel
4543
5410
  }
4544
5411
  return modified_filter_object;
4545
5412
  }
4546
- async function $9abb0a35d4b60ed3$export$79b1565500412d9b(search_modal, modal_fn_opts, parent) {
4547
- const body = parent || (await (0, $gVhhF$depictaiutilishared.observer).wait_for_element("body"));
4548
- let dispose_and_remove;
4549
- const open_modal_ = (extra_options_for_modal = {}, on_dispose) => {
4550
- if (dispose_and_remove)
4551
- // modal is already open
4552
- return;
4553
- const modal_els = $gVhhF$solidjs.createRoot(dispose => {
4554
- let closing_animation;
4555
- let animation_started;
4556
- dispose_and_remove = () => {
4557
- const actually_close = () => {
4558
- dispose();
4559
- on_dispose?.();
4560
- modal_els.forEach(el => el.remove());
4561
- };
4562
- if (animation_started && +new Date() - animation_started > 1000)
4563
- // Animation broke, close it this time
4564
- actually_close();else if (!animation_started && closing_animation) {
4565
- animation_started = +new Date();
4566
- $gVhhF$depictaiutilishared.catchify(closing_animation)()?.then($gVhhF$depictaiutilishared.catchify(actually_close));
4567
- } else actually_close();
4568
- };
4569
- return search_modal({
4570
- ...modal_fn_opts,
4571
- ...extra_options_for_modal,
4572
- close_modal_: close_modal_,
4573
- open_modal_: open_modal_,
4574
- register_closing_animation_: animation => closing_animation = animation
4575
- });
4576
- });
4577
- body.append(...modal_els);
4578
- };
4579
- const close_modal_ = () => {
4580
- if (dispose_and_remove) {
4581
- // modal is open
4582
- const dispose_fn = dispose_and_remove;
4583
- // set dispose function to undefined in case that it triggers this dispose function itself. Not doing it leads to a bug like https://github.com/solidjs/solid/discussions/1194
4584
- dispose_and_remove = undefined;
4585
- dispose_fn();
4586
- }
4587
- };
4588
- return {
4589
- open_modal_: open_modal_,
4590
- close_modal_: close_modal_
4591
- };
4592
- }
4593
- async function $bc91d938b8c601b4$export$58e808b1db15d3bc({
4594
- merchant: merchant,
4595
- market: market,
4596
- headers: headers,
4597
- ...fetch_recs_options
4598
- }) {
4599
- return await $gVhhF$depictaiutilishared.fetch_recs({
4600
- tenant: merchant,
4601
- market: market
4602
- }, $gVhhF$depictaiutilishared.snakeCasifyObject(fetch_recs_options), headers);
4603
- }
4604
- function $6e22b5314fb52f4c$export$e183a13865960371(params_to_default_value, router_) {
4605
- const signals = {};
4606
- const entries = Object.entries(params_to_default_value);
4607
- const event_handler = $gVhhF$depictaiutilishared.catchify((what_happened, args) => {
4608
- // Intentionally always update our signals to the history state to allow external control of SDK state for doing things like https://linear.app/depictai/issue/X-1432/is-this-possible-with-the-depict-sdk
4609
- if (what_happened !== "popstate") return;
4610
- // Had to undo the comment above,but leaving the history. Doing this because discovering why it doesn't work is a deja-vu and I don't want to have to discover it again.
4611
- // If we want others to interface with our state, it's better to expose it from DepictCategory/DepictSearch
4612
- // The reason for that is because writes to the state trigger writes to the state (something about local filter state, see the comment where `last_remote_state !== available_filters_()` happens in create_modified_filters.tsx)
4613
- // And can infinite loop, like in https://app.jiminny.com/playback/569c8f65-edea-4735-bd9e-4eb5a0b14cad
4614
- // It's the classical equilibrium problem when syncing state both down and up, and it's much easier to avoid than solve
4615
- $6e22b5314fb52f4c$var$history_state_change(signals, entries, args.state);
4616
- });
4617
- // createRenderEffect because we need the instant execution so the signals always contain values, even before solid's render phase
4618
- $gVhhF$solidjs.createRenderEffect(() => {
4619
- let signal_changed = false;
4620
- let {
4621
- state: state
4622
- } = globalThis?.history || {
4623
- state: {}
4624
- }; // cloning isn't necessary because we're calling replaceState on it anyway
4625
- if (state === null || typeof state != "object") state = {};
4626
- for (const [param, default_value] of entries) {
4627
- const [read_signal] = signals[param] ||= $gVhhF$solidjs.createSignal(state[param] ?? default_value);
4628
- const new_value = read_signal();
4629
- if (new_value !== state[param]) {
4630
- signal_changed = true;
4631
- state[param] = new_value;
4632
- }
4633
- }
4634
- if (signal_changed) router_.navigate_.replace_state_(state);
4635
- });
4636
- // history_dot_state_to_state needs to update after its signals after url_state does BUT in the same task (might even have to be in the same tick in the microtask queue). If we'd use window.addEventListener("popstate") it would be guaranteed to be too late since each event listener has its own task
4637
- (0, $gVhhF$depictaiutilishared.instant_exec_on_suspect_history_change).add(event_handler);
4638
- $gVhhF$solidjs.onCleanup($gVhhF$depictaiutilishared.catchify(() => (0, $gVhhF$depictaiutilishared.instant_exec_on_suspect_history_change).delete(event_handler)));
4639
- $gVhhF$solidjs.createEffect($gVhhF$depictaiutilishared.catchify(() => $gVhhF$solidjs.untrack($gVhhF$depictaiutilishared.catchify(() => $6e22b5314fb52f4c$var$history_state_change(signals, entries, history.state))))); // we need this to run after reading the initial state from history.state to write the defaults to history.state
4640
- return signals;
4641
- }
4642
- function $6e22b5314fb52f4c$var$history_state_change(signals, entries, state) {
4643
- $gVhhF$solidjs.batch(() => {
4644
- for (const [param, default_value] of entries) {
4645
- const [, write_signal] = signals[param];
4646
- const new_value = state?.[param];
4647
- write_signal(new_value ?? default_value);
4648
- }
4649
- });
4650
- }
4651
- const $d84fe647b84b5dc5$export$3064e1e8c6513da3 = new Set();
4652
- let $d84fe647b84b5dc5$var$has_ran = false;
4653
- function $d84fe647b84b5dc5$export$5162a71f252e6122() {
4654
- if ($d84fe647b84b5dc5$var$has_ran || typeof history !== "object") return;
4655
- $d84fe647b84b5dc5$var$has_ran = true;
4656
- for (const function_name of ["replaceState", "pushState"]) {
4657
- if (Object.getOwnPropertyNames(history).includes(function_name)) $d84fe647b84b5dc5$var$proxy_push_state(function_name, history);
4658
- $d84fe647b84b5dc5$var$proxy_push_state(function_name, History.prototype);
4659
- }
4660
- }
4661
- function $d84fe647b84b5dc5$var$proxy_push_state(function_name, thing) {
4662
- thing[function_name] = new Proxy(thing[function_name], {
4663
- apply(target, this_arg, arg_list) {
4664
- try {
4665
- const old_state = history.state;
4666
- if (typeof old_state == "object" && old_state !== null) {
4667
- // This effectively disallows the user from passing in a string, number, null or undefined
4668
- const intended_new_value_as_obj = typeof arg_list[0] === "object" ? arg_list[0] ?? {} : {};
4669
- const cloned_object = {
4670
- ...intended_new_value_as_obj
4671
- };
4672
- for (const key in old_state) {
4673
- if (!$d84fe647b84b5dc5$var$starts_with_any_prefix(key)) continue;
4674
- if (!(key in cloned_object)) cloned_object[key] = old_state[key];
4675
- }
4676
- arg_list[0] = cloned_object;
4677
- }
4678
- } catch (e) {
4679
- $gVhhF$depictaiutilishared.report([e, "Failed to preserve items in history.state"], "error");
4680
- }
4681
- return Reflect.apply(target, this_arg, arg_list);
5413
+ async function $bd429c994399dd82$export$58e808b1db15d3bc(options) {
5414
+ const headers = options.headers;
5415
+ const product_id = options.productId || options.product_id; // Second fallback here is just because there was very little missing to make this work with snake_case input and in case someone puts in snake case'd stuff already (preview browser did) we can easily not break it
5416
+ const cleaned_up_options = $gVhhF$depictaiutilishared.snakeCasifyObject(options);
5417
+ delete cleaned_up_options.headers;
5418
+ delete cleaned_up_options.product_id;
5419
+ cleaned_up_options.session_id ||= $gVhhF$depictaiutilishared.get_session_id();
5420
+ if (product_id && !cleaned_up_options.product_ids) cleaned_up_options.product_ids = [product_id];
5421
+ const options_to_send = cleaned_up_options;
5422
+ const url = $gVhhF$depictaiutilishared.add_version_query_params(`${(0, $gVhhF$depictaiutilishared.base_url)}/v3/recommend/products`);
5423
+ return await $gVhhF$depictaiutilishared.fetch_retry(url, {
5424
+ body: JSON.stringify(options_to_send),
5425
+ ...(headers ? {
5426
+ headers: headers
5427
+ } : {}),
5428
+ method: "POST"
5429
+ }).catch(e => $gVhhF$depictaiutilishared.dlog("fetch_retry threw", e)).then(async maybe_response => {
5430
+ if (!maybe_response) return [];
5431
+ let decoded;
5432
+ try {
5433
+ decoded = await maybe_response.json();
5434
+ } catch (e) {
5435
+ $gVhhF$depictaiutilishared.dlog("Failed to decode JSON", e);
4682
5436
  }
5437
+ return decoded?.displays || [];
4683
5438
  });
4684
5439
  }
4685
- function $d84fe647b84b5dc5$var$starts_with_any_prefix(key) {
4686
- for (const prefix of $d84fe647b84b5dc5$export$3064e1e8c6513da3) {
4687
- if (key.startsWith(prefix)) return true;
4688
- }
4689
- }
4690
5440
  function $26a56f6b44703084$export$9862539c89138352({
4691
5441
  get_default_values_: get_default_values_,
4692
5442
  router_: router_,
@@ -4742,8 +5492,8 @@ function $67dc366d96177e70$export$967e966fca9515e(api_response) {
4742
5492
  }
4743
5493
  return api_response;
4744
5494
  }
4745
- const $e1d6c0f3d89d531c$var$v2_base_url = (0, $gVhhF$depictaiutilishared.base_url) + "/v2/";
4746
- const $e1d6c0f3d89d531c$var$search_base_url = $e1d6c0f3d89d531c$var$v2_base_url + "search/";
5495
+ const $e1d6c0f3d89d531c$var$v3_base_url = (0, $gVhhF$depictaiutilishared.base_url) + "/v3/";
5496
+ const $e1d6c0f3d89d531c$var$search_base_url = $e1d6c0f3d89d531c$var$v3_base_url + "search/";
4747
5497
  class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
4748
5498
  #supports_finalization_registry = typeof FinalizationRegistry === "function";
4749
5499
  #cache_objs = {};
@@ -4762,18 +5512,14 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
4762
5512
  const request = {
4763
5513
  ...input_req
4764
5514
  };
4765
- request.dsid ??= $gVhhF$depictaiutilishared.get_depict_id();
4766
- // Todo: remove the default user and session IDs once we've confirmed backend can handle it and do whatever fallback is necessary.
4767
- request.user_id ??= this.#get_user_id?.() || $gVhhF$depictaiutilishared.get_user_id();
4768
5515
  request.session_id ??= this.#get_session_id?.() || $gVhhF$depictaiutilishared.get_session_id();
4769
5516
  return request;
4770
5517
  };
4771
5518
  #get_metadata;
4772
- #get_user_id;
4773
5519
  #get_session_id;
4774
5520
  #guard_url_creator_length(expected, received) {
4775
5521
  if (expected.length !== received.length) {
4776
- const e = new Error("Page URL creator returned wrong number of page URLs, got " + received.length + ", expected " + expected.length);
5522
+ const e = new Error("displayTransformer returned wrong number of page URLs, got " + received.length + ", expected " + expected.length);
4777
5523
  queueMicrotask(() => {
4778
5524
  throw e;
4779
5525
  });
@@ -4810,8 +5556,9 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
4810
5556
  const category_transformer = display_transformers?.categories;
4811
5557
  const content_result_transformer = display_transformers?.contentResults;
4812
5558
  const displays = input_data.displays;
5559
+ const owner = $gVhhF$solidjs.getOwner();
4813
5560
  const {
4814
- breadcrumb: breadcrumb,
5561
+ breadcrumbs: breadcrumbs,
4815
5562
  quick_links: quick_links,
4816
5563
  content_search_links: content_search_links
4817
5564
  } = input_data;
@@ -4840,7 +5587,7 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
4840
5587
  displays[i] = new_display_or_page_url;
4841
5588
  }
4842
5589
  }
4843
- if (page_url_creator || category_transformer) for (const category_display_array of [breadcrumb, quick_links]) {
5590
+ if (page_url_creator || category_transformer) for (const category_display_array of [breadcrumbs, quick_links]) {
4844
5591
  if (!category_display_array) continue;
4845
5592
  const page_urls = await (page_url_creator || category_transformer)({
4846
5593
  merchant: merchant,
@@ -4856,24 +5603,32 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
4856
5603
  Object.defineProperties(category_display_array[i], Object.getOwnPropertyDescriptors(page_urls[i]));
4857
5604
  }
4858
5605
  if (content_search_links?.length && content_result_transformer) {
4859
- const result = await content_result_transformer({
5606
+ const result = await $gVhhF$solidjs.runWithOwner(owner, () => content_result_transformer({
4860
5607
  merchant: merchant,
4861
5608
  market: market,
4862
5609
  data: [...content_search_links]
4863
- });
5610
+ }));
4864
5611
  this.#guard_url_creator_length(content_search_links, result);
4865
5612
  input_data.content_search_links = result;
4866
5613
  }
4867
5614
  return input_data;
4868
5615
  }
4869
- async #cached_post_request(endpoint, input_req, fallback_response) {
4870
- const cache_obj = this.#get_cache_obj_for_endpoint(endpoint);
4871
- const with_ids = this.#add_ids_to_request(input_req);
5616
+ async #cached_request({
5617
+ endpoint_: endpoint_,
5618
+ input_req_: input_req_,
5619
+ fallback_response_: fallback_response_,
5620
+ method_ = "POST",
5621
+ delete_key_before_sending_: delete_key_before_sending_ // only supported for GET requests
5622
+ }) {
5623
+ const cache_obj = this.#get_cache_obj_for_endpoint(endpoint_);
5624
+ const with_ids = this.#add_ids_to_request(input_req_);
5625
+ const owner = $gVhhF$solidjs.getOwner();
4872
5626
  const metaData = await this.#get_metadata?.();
4873
5627
  const request = metaData ? Object.assign(with_ids, {
4874
5628
  metadata: metaData
4875
5629
  }) : with_ids;
4876
- const body = JSON.stringify($gVhhF$depictaiutilishared.sort_obj(request));
5630
+ const sorted_request = $gVhhF$depictaiutilishared.sort_obj(request);
5631
+ const body = JSON.stringify(sorted_request);
4877
5632
  const response_from_cache = cache_obj.cache_[body]?.deref?.();
4878
5633
  if (response_from_cache) return response_from_cache;
4879
5634
  const in_progress_request = cache_obj.in_progress_[body];
@@ -4881,18 +5636,23 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
4881
5636
  let resolve_in_progress;
4882
5637
  cache_obj.in_progress_[body] = new Promise(r => resolve_in_progress = r);
4883
5638
  try {
4884
- const api_response = await $gVhhF$depictaiutilishared.fetch_retry($gVhhF$depictaiutilishared.add_version_query_params(endpoint), {
4885
- method: "POST",
4886
- body: body
5639
+ const is_post = method_ === "POST";
5640
+ if (!is_post && delete_key_before_sending_) delete sorted_request[delete_key_before_sending_];
5641
+ const url_to_request = is_post ? endpoint_ : $gVhhF$depictaiutilishared.make_url_with_query_params(endpoint_, sorted_request);
5642
+ const api_response = await $gVhhF$depictaiutilishared.fetch_retry($gVhhF$depictaiutilishared.add_version_query_params(url_to_request), {
5643
+ method: method_,
5644
+ ...(is_post ? {
5645
+ body: body
5646
+ } : {})
4887
5647
  });
4888
5648
  return_successfully: {
4889
5649
  if (!api_response || api_response.status !== 200) break return_successfully;
4890
5650
  let result;
4891
5651
  try {
4892
5652
  const unmodified_result = await api_response.json();
4893
- result = await this.#run_display_transformers_for_rest(input_req.tenant, input_req.market, unmodified_result);
5653
+ result = await $gVhhF$solidjs.runWithOwner(owner, () => this.#run_display_transformers_for_rest(input_req_.merchant, input_req_.market, unmodified_result));
4894
5654
  } catch (e) {
4895
- $gVhhF$depictaiutilishared.dwarn("URL creator or json decoding failed", e);
5655
+ $gVhhF$depictaiutilishared.dwarn("displayTransformer or json decoding failed", e);
4896
5656
  break return_successfully;
4897
5657
  }
4898
5658
  // Here result actually becomes O
@@ -4910,7 +5670,7 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
4910
5670
  return result;
4911
5671
  }
4912
5672
  // If we get here, the request failed
4913
- const retval = fallback_response(input_req);
5673
+ const retval = fallback_response_(input_req_);
4914
5674
  resolve_in_progress(retval);
4915
5675
  return retval;
4916
5676
  } finally {
@@ -4920,19 +5680,18 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
4920
5680
  constructor(options) {
4921
5681
  const {
4922
5682
  get_metadata: get_metadata,
4923
- get_user_id: get_user_id,
4924
5683
  get_session_id: get_session_id,
4925
5684
  page_url_creator: page_url_creator,
4926
5685
  display_transformers: display_transformers
4927
5686
  } = options ?? {};
4928
5687
  this.#get_metadata = get_metadata;
4929
- this.#get_user_id = get_user_id;
4930
5688
  this.#get_session_id = get_session_id;
4931
5689
  this.page_url_creator = page_url_creator;
4932
5690
  this.display_transformers = display_transformers;
4933
5691
  }
4934
5692
  async suggest(input_req) {
4935
5693
  const with_ids = this.#add_ids_to_request(input_req);
5694
+ const owner = $gVhhF$solidjs.getOwner();
4936
5695
  const metaData = await this.#get_metadata?.();
4937
5696
  const request = metaData ? Object.assign(with_ids, {
4938
5697
  metadata: JSON.stringify(metaData)
@@ -4944,9 +5703,9 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
4944
5703
  const decoded_json = await results.json();
4945
5704
  if (!Array.isArray(decoded_json?.suggestions)) break attempt_to_return_api_response;
4946
5705
  try {
4947
- return await this.#run_url_creator_for_suggest(input_req.tenant, input_req.market, decoded_json);
5706
+ return await $gVhhF$solidjs.runWithOwner(owner, () => this.#run_url_creator_for_suggest(input_req.merchant, input_req.market, decoded_json));
4948
5707
  } catch (e) {
4949
- $gVhhF$depictaiutilishared.dwarn("URL creator failed", e);
5708
+ $gVhhF$depictaiutilishared.dwarn("displayTransformer failed", e);
4950
5709
  }
4951
5710
  }
4952
5711
  return {
@@ -4956,31 +5715,67 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
4956
5715
  };
4957
5716
  }
4958
5717
  async query(input_req) {
4959
- return await this.#cached_post_request($e1d6c0f3d89d531c$var$search_base_url + "results", input_req, () => ({
4960
- "n_hits": 0,
4961
- "displays": [],
4962
- "sorts": [],
4963
- "filters": [],
4964
- "search_request_id": "error",
4965
- failed: true
4966
- }));
5718
+ return await this.#cached_request({
5719
+ endpoint_: $e1d6c0f3d89d531c$var$search_base_url + "results",
5720
+ input_req_: input_req,
5721
+ fallback_response_: () => ({
5722
+ "n_hits": 0,
5723
+ "displays": [],
5724
+ "sorts": [],
5725
+ "filters": [],
5726
+ "search_request_id": "error",
5727
+ failed: true
5728
+ })
5729
+ });
4967
5730
  }
4968
- async list(input_req) {
4969
- return await this.#cached_post_request($e1d6c0f3d89d531c$var$v2_base_url + "product-listing", input_req, () => ({
4970
- "n_hits": 0,
4971
- "displays": [],
4972
- "sorts": [],
4973
- "filters": [],
4974
- "breadcrumb": [],
4975
- "quick_links": [],
4976
- "product_listing_request_id": "error",
4977
- failed: true
4978
- }));
5731
+ async get_listing(input_req) {
5732
+ return await this.#cached_request({
5733
+ endpoint_: $e1d6c0f3d89d531c$var$v3_base_url + "listings/" + encodeURIComponent(input_req.listing_id),
5734
+ input_req_: input_req,
5735
+ fallback_response_: () => ({
5736
+ listing_id: "",
5737
+ listing_type: "category",
5738
+ "title": "",
5739
+ "description": "string",
5740
+ "replace_meta_tags": true,
5741
+ "slug": "",
5742
+ "updated_at": new Date().toISOString(),
5743
+ "breadcrumbs": [],
5744
+ "quick_links": [],
5745
+ failed: true
5746
+ }),
5747
+ method_: "GET",
5748
+ delete_key_before_sending_: "listing_id" // this goes into the path, but we still need to have it in the request object until the last second as we want to include it as a key when caching requests
5749
+ });
5750
+ }
5751
+
5752
+ async get_listing_products(input_req) {
5753
+ const listing_id = input_req.listing_id; // listing_id goes into the path
5754
+ const cloned_request = {
5755
+ ...input_req
5756
+ };
5757
+ delete cloned_request["listing_id"];
5758
+ return await this.#cached_request({
5759
+ endpoint_: $e1d6c0f3d89d531c$var$v3_base_url + "listings/" + encodeURIComponent(listing_id) + "/products",
5760
+ input_req_: input_req,
5761
+ fallback_response_: () => ({
5762
+ "n_hits": 0,
5763
+ "displays": [],
5764
+ "sorts": [],
5765
+ "filters": [],
5766
+ "product_listing_request_id": "error",
5767
+ failed: true
5768
+ })
5769
+ });
4979
5770
  }
4980
5771
  async get_recommended(input_req) {
4981
- return await this.#cached_post_request($e1d6c0f3d89d531c$var$search_base_url + "related", input_req, () => ({
4982
- displays: []
4983
- }));
5772
+ return await this.#cached_request({
5773
+ endpoint_: $e1d6c0f3d89d531c$var$search_base_url + "related",
5774
+ input_req_: input_req,
5775
+ fallback_response_: () => ({
5776
+ displays: []
5777
+ })
5778
+ });
4984
5779
  }
4985
5780
  }
4986
5781
  function $b54e6192d0caa293$export$d9f36cf74e24d595(media_query) {
@@ -5079,7 +5874,7 @@ function $76b6ac05693f5c71$export$205efb947c7ffd78(handler, passive = true) {
5079
5874
  $gVhhF$solidjs.onCleanup(() => removeEventListener(event, catchified_handler));
5080
5875
  }
5081
5876
  }
5082
- const $401aee5f33dca9e2$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=scroll-status style=display:none><span class=text><b></b> – <b></b> <!$><!/> <b>`);
5877
+ const $401aee5f33dca9e2$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=scroll-status style=display:none><span class=text><b></b> \u{2013} <b></b> <!$><!/> <b>`);
5083
5878
  function $401aee5f33dca9e2$export$83fd5de5504a7a67({
5084
5879
  formatted_number_of_results_: formatted_number_of_results_,
5085
5880
  first_result_in_viewport_: [get_first_result_in_viewport],
@@ -5301,7 +6096,7 @@ function $3f08fe2992a2a8ca$export$5e4aed86c12acdd9({
5301
6096
  // After first load, always just load 20 since people might just be browsing the top ones still
5302
6097
  min_products_to_fetch_ : now - last_loaded < 10000 ? min_products_to_fetch_ * 5 : min_products_to_fetch_;
5303
6098
  // dlog("loading ", number_of_results_to_load, "products, because it was", now - last_loaded, "ms since last load");
5304
- const api_response = await depict_api_["query_id" in base_part ? "list" : "query"]({
6099
+ const api_response = await depict_api_["listing_id" in base_part ? "get_listing_products" : "query"]({
5305
6100
  cursor: get_last_cursor(),
5306
6101
  limit: number_of_results_to_load,
5307
6102
  ...base_part
@@ -5364,8 +6159,6 @@ function $ac167f6af6a48fc3$export$a1fd619a4743ca08({
5364
6159
  product_card_template_: product_card_template_,
5365
6160
  first_result_in_viewport_: [, set_first_result_in_viewport],
5366
6161
  last_result_in_viewport_: [get_last_result_in_viewport_, set_last_result_in_viewport],
5367
- merchant_: merchant_,
5368
- market_: market_,
5369
6162
  all_products_loaded_: all_products_loaded_,
5370
6163
  min_products_to_fetch_: min_products_to_fetch_,
5371
6164
  query_base_: query_base_,
@@ -5417,8 +6210,6 @@ function $ac167f6af6a48fc3$export$a1fd619a4743ca08({
5417
6210
  });
5418
6211
  return $a73063cc642f3e5f$export$43f0fb951fcb0c54({
5419
6212
  displays_by_key_: displays_by_key_,
5420
- merchant_: merchant_,
5421
- market_: market_,
5422
6213
  product_card_template_: product_card_template_,
5423
6214
  content_blocks_: content_blocks_,
5424
6215
  do_per_elements_: (elements, index_accessor) =>
@@ -5574,37 +6365,6 @@ function $055384b985678603$export$a79e666719b3647c(cols_at_size_) {
5574
6365
  });
5575
6366
  return n_cols_currently_showing;
5576
6367
  }
5577
- function $3bc4a89b971a3af5$export$3f37af283f8fb843(props) {
5578
- const style = $gVhhF$solidjs.createMemo(() => {
5579
- const {
5580
- style: style,
5581
- height: height,
5582
- width: width,
5583
- aspectRatio: aspectRatio
5584
- } = props;
5585
- const is_image = aspectRatio != undefined;
5586
- const size_data = is_image ? {
5587
- width: "100%",
5588
- "padding-bottom": 1 / aspectRatio * 100 + "%"
5589
- } : {
5590
- width: width,
5591
- height: height
5592
- };
5593
- return {
5594
- display: "block",
5595
- ...(style || {}),
5596
- ...size_data
5597
- };
5598
- });
5599
- return $gVhhF$solidjsweb.createComponent((0, $9fe9883b1d8ecccc$export$acb3eaade4b23afd), {
5600
- get style() {
5601
- return style();
5602
- },
5603
- get ["class"]() {
5604
- return props.class;
5605
- }
5606
- });
5607
- }
5608
6368
  const $d92f338ba8f9da9b$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=content-block-wrapper>`);
5609
6369
  function $d92f338ba8f9da9b$export$791ef57e62e21c3f({
5610
6370
  content_blocks_: incoming_content_blocks,
@@ -5815,8 +6575,6 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
5815
6575
  }) {
5816
6576
  // The plp_results_ resource will be delayed because we're using createBatchedMemo to not make triplicate API requests, but we need to show the placeholders before already to match Chrome and Firefox's "content has to be there, ready for scroll restoration, before all popstate tasks have been completed"-requirement
5817
6577
  const is_loading_ = $gVhhF$solidjs.createMemo(() => plp_results_.loading || query_base_.loading);
5818
- const merchant_ = $gVhhF$solidjs.createMemo(() => query_base_().tenant);
5819
- const market_ = $gVhhF$solidjs.createMemo(() => query_base_().market);
5820
6578
  const has_no_results_or_failed = $gVhhF$solidjs.createMemo(() => {
5821
6579
  const displays = plp_results_()?.displays;
5822
6580
  return !is_loading_() && (!Array.isArray(displays) || !displays.length);
@@ -5930,8 +6688,6 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
5930
6688
  plp_results_: plp_results_,
5931
6689
  last_result_in_viewport_: last_result_in_viewport_,
5932
6690
  first_result_in_viewport_: first_result_in_viewport_,
5933
- market_: market_,
5934
- merchant_: merchant_,
5935
6691
  all_products_loaded_: all_products_loaded_,
5936
6692
  min_products_to_fetch_: min_products_to_fetch_,
5937
6693
  query_base_: query_base_,
@@ -6110,42 +6866,6 @@ function $be89be42ce9ea60f$export$1f1775a58da589b5({
6110
6866
  }
6111
6867
  });
6112
6868
  }
6113
- function $ca1176b694a6ee2e$export$fe334901e8bebd57() {
6114
- const cleanup_fns = [];
6115
- const cleanup = () => cleanup_fns.forEach(f => f());
6116
- // use an animation to automatically retain the `overflow` values and all other styling
6117
- for (const element of [document.documentElement, document.body]) {
6118
- try {
6119
- const animation = element.animate({
6120
- overflow: "hidden",
6121
- offset: 0
6122
- }, 1);
6123
- animation.pause();
6124
- const fn = $gVhhF$depictaiutilishared.catchify(animation.play.bind(animation));
6125
- cleanup_fns.push(fn);
6126
- $gVhhF$solidjs.onCleanup(fn);
6127
- } catch (e) {
6128
- $gVhhF$depictaiutilishared.dlog("Probably partial keyframe error", e);
6129
- }
6130
- if (getComputedStyle(element).overflow !== "hidden") {
6131
- // safari gets special hacky treatment
6132
- const style = element.style;
6133
- const original_value = style.overflow;
6134
- style.overflow = "hidden";
6135
- const fn = $gVhhF$depictaiutilishared.catchify(() => style.overflow = original_value);
6136
- cleanup_fns.push(fn);
6137
- $gVhhF$solidjs.onCleanup(fn);
6138
- }
6139
- }
6140
- return cleanup;
6141
- } // the way that houdini does that (FYI) it fixes the page jumps
6142
- // const from_top = scrollY;
6143
- // document.body.style.position = "fixed";
6144
- // document.body.style.left = 0;
6145
- // document.body.style.right = 0;
6146
- // document.body.style.top = `-${from_top}px`;
6147
- // document.body.style.overflowY = "scroll";
6148
-
6149
6869
  const $f958b5ac0e4a78da$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<svg xmlns=http://www.w3.org/2000/svg width=14 height=14 class=sort-icon><path d="M6.199 10.254a.35.35 0 0 0-.496 0L3.5 12.453V.348a.35.35 0 0 0-.7 0v12.105L.598 10.254c-.137-.137-.359-.137-.492 0a.35.35 0 0 0 0 .492l2.797 2.801a.35.35 0 0 0 .496 0L6.2 10.746c.137-.137.137-.355 0-.492zM9.449 3.5H8.051a.35.35 0 0 1-.352-.352V1.75c0-.191.156-.352.352-.352h1.398c.195 0 .352.16.352.352v1.398a.35.35 0 0 1-.352.352zm-1.051-.699h.703v-.699h-.703zm0 0"></path><path d="M10.852 6.301H8.051a.35.35 0 0 1-.352-.352V4.551a.35.35 0 0 1 .352-.352h2.801a.35.35 0 0 1 .348.352v1.398a.35.35 0 0 1-.348.352zm-2.453-.699H10.5v-.703H8.398zm3.851 3.5H8.051c-.195 0-.352-.16-.352-.352V7.352A.35.35 0 0 1 8.051 7h4.199c.191 0 .352.156.352.352V8.75c0 .191-.16.352-.352.352zm-3.852-.703h3.5V7.7h-3.5zm5.25 3.499H8.051a.35.35 0 0 1-.352-.348v-1.402a.35.35 0 0 1 .352-.348h5.598a.35.35 0 0 1 .352.348v1.402a.35.35 0 0 1-.352.348zm-5.25-.699H13.3V10.5H8.398zm0 0">`);
6150
6870
  function $f958b5ac0e4a78da$export$da32f7add8a22e86(props = {}) {
6151
6871
  return (() => {
@@ -6984,7 +7704,6 @@ function $e53b2e7e632ac4cb$export$5646050d516e06bc({
6984
7704
  }) {
6985
7705
  const placeholder_crumb_data = [,,,];
6986
7706
  const crumb_data = $gVhhF$solidjs.createMemo(() => get_api_crumb_data() || placeholder_crumb_data);
6987
- const href_accessor = $gVhhF$depictaiutilishared.use_href_accessor();
6988
7707
  return $gVhhF$solidjsweb.createComponent((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
6989
7708
  severity_: "error",
6990
7709
  message_: "BreadCrumbs failed",
@@ -6995,10 +7714,8 @@ function $e53b2e7e632ac4cb$export$5646050d516e06bc({
6995
7714
  return crumb_data();
6996
7715
  },
6997
7716
  children: (display_accessor, index) => {
6998
- const is_last = $gVhhF$solidjs.createMemo(() => index === crumb_data()?.length - 1);
6999
- const url = $gVhhF$solidjs.createMemo(() => is_last() ? href_accessor() : display_accessor()?.page_url);
7000
7717
  const href = $gVhhF$solidjs.createMemo(() => $1ab22f2cd39b3061$export$43cd1e747fecd42e({
7001
- to_url_: url(),
7718
+ to_url_: display_accessor()?.page_url,
7002
7719
  filter_query_param_prefix_: filter_query_param_prefix_,
7003
7720
  sorting_query_param_: sorting_query_param_
7004
7721
  }));
@@ -7019,7 +7736,7 @@ function $e53b2e7e632ac4cb$export$5646050d516e06bc({
7019
7736
  is_replace_: false,
7020
7737
  event_: ev,
7021
7738
  force_spa_navigation_: true,
7022
- category_query_id_: display_accessor()?.query_id
7739
+ listing_id_: display_accessor()?.listing_id
7023
7740
  })), true);
7024
7741
  $gVhhF$solidjsweb.insert(_el$2, () => display_accessor().title);
7025
7742
  $gVhhF$solidjsweb.effect(() => $gVhhF$solidjsweb.setAttribute(_el$2, "href", href()));
@@ -7050,42 +7767,42 @@ const $8cceb1d3a967f369$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<n
7050
7767
  function $8cceb1d3a967f369$export$466cdc317043f6cb({
7051
7768
  quicklinks_data_: quicklinks_data_,
7052
7769
  router_: router_,
7053
- current_query_id_: current_query_id_,
7770
+ current_listing_id_: current_listing_id_,
7054
7771
  breadcrumb_data_: breadcrumb_data_,
7055
7772
  i18n_: i18n_,
7056
7773
  sorting_query_param_: sorting_query_param_,
7057
7774
  filter_query_param_prefix_: filter_query_param_prefix_
7058
7775
  }) {
7059
- let scrolling_logic_ran_for_query_id = false;
7776
+ let scrolling_logic_ran_for_listing_id = false;
7060
7777
  let last_scroll_position;
7061
7778
  let scroll_to_element_on_dom_insertion;
7062
7779
  let last_was_placeholder = false;
7063
7780
  let sliding_element;
7064
7781
  $gVhhF$solidjs.createComputed(() => {
7065
- current_query_id_();
7066
- scrolling_logic_ran_for_query_id = false;
7782
+ current_listing_id_();
7783
+ scrolling_logic_ran_for_listing_id = false;
7067
7784
  });
7068
7785
  const place_holdey_quicklinks_data = $gVhhF$solidjs.createMemo(() => quicklinks_data_() || [,,,]);
7069
- const selected_index = $gVhhF$solidjs.createMemo(() => quicklinks_data_()?.findIndex(item => item.query_id === current_query_id_())); // this will be -1 when viewing child categories
7070
- const scrollpos_per_queryid = {};
7786
+ const selected_index = $gVhhF$solidjs.createMemo(() => quicklinks_data_()?.findIndex(item => item.listing_id === current_listing_id_())); // this will be -1 when viewing child categories
7787
+ const scrollpos_per_listing_id = {};
7071
7788
  const mutation_plugins = [function () {
7072
- if (!scrolling_logic_ran_for_query_id) return;
7789
+ if (!scrolling_logic_ran_for_listing_id) return;
7073
7790
  const {
7074
7791
  scrollLeft: scrollLeft
7075
7792
  } = this.insert_here;
7076
7793
  if (scrollLeft > 0) {
7077
7794
  last_scroll_position = scrollLeft;
7078
- const current_id = $gVhhF$solidjs.untrack(current_query_id_);
7795
+ const current_id = $gVhhF$solidjs.untrack(current_listing_id_);
7079
7796
  // make sure to not save position where selected item isn't in viewport
7080
7797
  const current_selected_index = $gVhhF$solidjs.untrack(selected_index);
7081
7798
  const intersecting_thing = this.intersecting_items_object[current_selected_index];
7082
- if (intersecting_thing?.intersectionRatio >= 0.95 || current_selected_index == undefined || current_selected_index < 0) scrollpos_per_queryid[current_id] = scrollLeft;else if (current_id in scrollpos_per_queryid)
7799
+ if (intersecting_thing?.intersectionRatio >= 0.95 || current_selected_index == undefined || current_selected_index < 0) scrollpos_per_listing_id[current_id] = scrollLeft;else if (current_id in scrollpos_per_listing_id)
7083
7800
  // if about to go out of view, stop saving it so that the "always show new things in view" thing can get to work
7084
- delete scrollpos_per_queryid[current_id];
7801
+ delete scrollpos_per_listing_id[current_id];
7085
7802
  }
7086
7803
  }];
7087
7804
  $gVhhF$solidjs.createComputed(() => {
7088
- if (place_holdey_quicklinks_data()?.[0]?.query_id) {
7805
+ if (place_holdey_quicklinks_data()?.[0]?.listing_id) {
7089
7806
  if (last_was_placeholder) queueMicrotask($gVhhF$depictaiutilishared.catchify(() => {
7090
7807
  sliding_element?.scrollTo({
7091
7808
  left: 0
@@ -7138,13 +7855,13 @@ function $8cceb1d3a967f369$export$466cdc317043f6cb({
7138
7855
  equals: false
7139
7856
  }), new_data => {
7140
7857
  const quicklinks_data = quicklinks_data_(); // this signal should have updated by now since this is a createEffect
7141
- const current_id = current_query_id_();
7858
+ const current_id = current_listing_id_();
7142
7859
  if (!new_data || !quicklinks_data || !current_id) return;
7143
7860
  const owner = $gVhhF$solidjs.getOwner();
7144
7861
  queueMicrotask(() => {
7145
7862
  // has to be in microtask so that elements have rendered and are scroll-to-able
7146
- scrolling_logic_ran_for_query_id = true;
7147
- const saved_scroll_position = scrollpos_per_queryid[current_id];
7863
+ scrolling_logic_ran_for_listing_id = true;
7864
+ const saved_scroll_position = scrollpos_per_listing_id[current_id];
7148
7865
  if (saved_scroll_position) {
7149
7866
  insert_here.scrollTo({
7150
7867
  left: saved_scroll_position
@@ -7186,10 +7903,10 @@ function $8cceb1d3a967f369$export$466cdc317043f6cb({
7186
7903
  // Problem: When you don't open a link in a new tab, we don't display the filter cleared toast
7187
7904
  // Solution: instead of not adding the state to the url, add a flag to the link if it's a sibling and then display the toast on load if the flag is set
7188
7905
  const is_sibling = $gVhhF$solidjs.createMemo(() => {
7189
- const current_id = current_query_id_();
7906
+ const current_id = current_listing_id_();
7190
7907
  return quicklinks_data_()?.some(({
7191
- query_id: query_id
7192
- }) => query_id === current_id);
7908
+ listing_id: listing_id
7909
+ }) => listing_id === current_id);
7193
7910
  });
7194
7911
  const href = $gVhhF$solidjs.createMemo(() =>
7195
7912
  // We don't want these links to delete the sort and filter state by default, only if `clear_filters_when_going_sideways` explicitly clears them
@@ -7210,7 +7927,7 @@ function $8cceb1d3a967f369$export$466cdc317043f6cb({
7210
7927
  is_replace_: false,
7211
7928
  event_: ev,
7212
7929
  force_spa_navigation_: true,
7213
- category_query_id_: display_accessor()?.query_id
7930
+ listing_id_: display_accessor()?.listing_id
7214
7931
  });
7215
7932
  }), true);
7216
7933
  $gVhhF$solidjsweb.insert(_el$3, () => display_accessor()?.title || $gVhhF$solidjsweb.createComponent((0, $061ff5b4c3d36171$export$89c6019e4baa40b1), {
@@ -7308,10 +8025,12 @@ async function $276380e4607fb9fb$export$cc42dd29bf655ab6({
7308
8025
  const total_products_to_fetch = to_fetch_according_to_state < min_products_to_fetch_ ? min_products_to_fetch_ : to_fetch_according_to_state + 20; // if we fetch according to state, fetch some more in case that the screen size increased, there's some in-accuracy or for the user to scroll. Sometimes the load more post processor will trigger to fetch more after this, but I think that's ok.
7309
8026
  if (total_products_to_fetch <= $276380e4607fb9fb$var$api_max_products_per_request) return await make_request_(total_products_to_fetch);
7310
8027
  const displays = [];
8028
+ const owner = $gVhhF$solidjs.getOwner();
7311
8029
  let last_response;
7312
8030
  let next_cursor;
7313
8031
  for (let fetch_this_time = $276380e4607fb9fb$var$api_max_products_per_request; displays.length < total_products_to_fetch;) {
7314
- last_response = await make_request_(fetch_this_time, next_cursor);
8032
+ // Carry over the request when making the owner so that display transformers can use onCleanup
8033
+ last_response = await $gVhhF$solidjs.runWithOwner(owner, () => make_request_(fetch_this_time, next_cursor));
7315
8034
  const new_displays = last_response.displays;
7316
8035
  displays.push(...new_displays);
7317
8036
  next_cursor = last_response.cursor;
@@ -7365,7 +8084,7 @@ let $0b6e2070a98de347$export$44dad306455dddf;
7365
8084
  })($0b6e2070a98de347$export$44dad306455dddf || ($0b6e2070a98de347$export$44dad306455dddf = {}));
7366
8085
  function $ef972f5c10b1c5b4$export$3945d6db2dfd3d12({
7367
8086
  crumb_data_: crumb_data_,
7368
- query_id_: query_id_,
8087
+ listing_id_: listing_id_,
7369
8088
  i18n_: i18n_,
7370
8089
  selected_filters_: selected_filters_,
7371
8090
  local_filter_cache_: local_filter_cache_,
@@ -7384,15 +8103,15 @@ function $ef972f5c10b1c5b4$export$3945d6db2dfd3d12({
7384
8103
  });
7385
8104
  // Code below is for when we're already open and the user navigates to a new category
7386
8105
  let previous_crumb_data = $gVhhF$solidjs.untrack(crumb_data_);
7387
- let query_id_when_we_got_previous_data = $gVhhF$solidjs.untrack(query_id_);
8106
+ let listing_id_when_we_got_previous_data = $gVhhF$solidjs.untrack(listing_id_);
7388
8107
  let allow_filter_clearing = true; // set to false when going backwards/forwards
7389
8108
  // temporarily disable filter clearing when going backwards/forwards
7390
8109
  const handler = () => allow_filter_clearing = false;
7391
8110
  window.addEventListener("popstate", handler); // popstate only gets called when using back/forwards button of browser or the history navigate to achieve the same, but not on pushState or replaceState
7392
8111
  $gVhhF$solidjs.onCleanup(() => window.removeEventListener("popstate", handler));
7393
8112
  $gVhhF$solidjs.createEffect($gVhhF$solidjs.on(crumb_data_, $gVhhF$depictaiutilishared.catchify(new_crumb_data => {
7394
- const query_id_of_new_data = query_id_();
7395
- if (allow_filter_clearing && previous_crumb_data && new_crumb_data && query_id_of_new_data !== query_id_when_we_got_previous_data) {
8113
+ const listing_id_of_new_data = listing_id_();
8114
+ if (allow_filter_clearing && previous_crumb_data && new_crumb_data && listing_id_of_new_data !== listing_id_when_we_got_previous_data) {
7396
8115
  const previous_length = previous_crumb_data.length;
7397
8116
  const new_length = new_crumb_data.length;
7398
8117
  const went_upwards = new_length < previous_length;
@@ -7400,8 +8119,8 @@ function $ef972f5c10b1c5b4$export$3945d6db2dfd3d12({
7400
8119
  const shorter_array = went_upwards ? new_crumb_data : previous_crumb_data;
7401
8120
  const longer_array = went_upwards ? previous_crumb_data : new_crumb_data;
7402
8121
  if (!((went_upwards || went_downwards) && shorter_array.every(({
7403
- query_id: query_id
7404
- }, index) => longer_array[index].query_id === query_id))) {
8122
+ listing_id: listing_id
8123
+ }, index) => longer_array[index].listing_id === listing_id))) {
7405
8124
  // We went sideways, not up or down. Clear filters.
7406
8125
  $47e2cc552c02110c$export$8895d39404bd2bb1({
7407
8126
  user_triggered_: false,
@@ -7415,7 +8134,7 @@ function $ef972f5c10b1c5b4$export$3945d6db2dfd3d12({
7415
8134
  sideways_filter_clearing_flag_[1](false);
7416
8135
  }
7417
8136
  }
7418
- query_id_when_we_got_previous_data = query_id_of_new_data;
8137
+ listing_id_when_we_got_previous_data = listing_id_of_new_data;
7419
8138
  previous_crumb_data = new_crumb_data;
7420
8139
  if (!allow_filter_clearing) allow_filter_clearing = true;
7421
8140
  })));
@@ -7447,16 +8166,16 @@ function $ef972f5c10b1c5b4$var$clear_if_opened_new_tab_with_sideways_url_params_
7447
8166
  });
7448
8167
  tracking_function_for_plp_results(plp_results_);
7449
8168
  }
7450
- const $839b3341523d31a2$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=statement style=white-space:pre-wrap>No category ID specified, this is probably unintentional. Make sure to create (and insert) the CategoryPage *after* you have specified a category ID in your Depict Provider.`),
7451
- $839b3341523d31a2$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=buttons><button class="ok major">`);
7452
- function $839b3341523d31a2$export$d4fc5c0e68a52116(el, query_id_, i18n_) {
8169
+ const $bb9760b7a8acdc18$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=statement style=white-space:pre-wrap>No category ID specified, this is probably unintentional. Make sure to create (and insert) the CategoryPage *after* you have specified a category ID in your Depict Provider.`),
8170
+ $bb9760b7a8acdc18$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=buttons><button class="ok major">`);
8171
+ function $bb9760b7a8acdc18$export$7af06a63c5a976c9(el, listing_id, i18n_) {
7453
8172
  if (!(0, $gVhhF$depictaiutilishared.is_debug)) return; // Just to make sure we don't show this in production
7454
8173
  const owner = $gVhhF$solidjs.getOwner();
7455
8174
  const disconnect = (0, $gVhhF$depictaiutilishared.observer).onexists(el, ({
7456
8175
  element: element
7457
8176
  }) => $gVhhF$solidjs.runWithOwner(owner, () => $gVhhF$solidjs.createEffect(() => {
7458
8177
  if (!document.documentElement.contains(element)) return;
7459
- if (!query_id_()) {
8178
+ if (!listing_id()) {
7460
8179
  const warning = "No category ID specified, this is probably unintentional. Make sure to create (and insert) the CategoryPage *after* you have specified a category ID in your Depict Provider.";
7461
8180
  $gVhhF$depictaiutilishared.dwarn(warning);
7462
8181
  const {
@@ -7467,8 +8186,8 @@ function $839b3341523d31a2$export$d4fc5c0e68a52116(el, query_id_, i18n_) {
7467
8186
  style: {
7468
8187
  background: "#ffb830"
7469
8188
  },
7470
- children: [$gVhhF$solidjsweb.getNextElement($839b3341523d31a2$var$_tmpl$), (() => {
7471
- const _el$2 = $gVhhF$solidjsweb.getNextElement($839b3341523d31a2$var$_tmpl$2),
8189
+ children: [$gVhhF$solidjsweb.getNextElement($bb9760b7a8acdc18$var$_tmpl$), (() => {
8190
+ const _el$2 = $gVhhF$solidjsweb.getNextElement($bb9760b7a8acdc18$var$_tmpl$2),
7472
8191
  _el$3 = _el$2.firstChild;
7473
8192
  _el$3.$$click = () => close_toast_() /* We have to wait for close_toast_ to get defined after the call to show_toast */;
7474
8193
  $gVhhF$solidjsweb.insert(_el$3, () => i18n_.ok_());
@@ -7481,7 +8200,6 @@ function $839b3341523d31a2$export$d4fc5c0e68a52116(el, query_id_, i18n_) {
7481
8200
  $gVhhF$solidjs.onCleanup(disconnect);
7482
8201
  }
7483
8202
  $gVhhF$solidjsweb.delegateEvents(["click"]);
7484
- const $6b502b1b2155a0bc$export$5c28802497c8a83c = /*@__PURE__*/Symbol("category_title_type");
7485
8203
  function $6a8e766e914723d8$export$d31a1a1a83ad9413(plp_results_, [get_selected_filters, set_selected_filters]) {
7486
8204
  $gVhhF$solidjs.createComputed(() => {
7487
8205
  const available_filters = plp_results_()?.filters;
@@ -7513,8 +8231,7 @@ const $840d88a04b2d22a7$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<d
7513
8231
  $840d88a04b2d22a7$var$_tmpl$4 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class="depict plp category"><div class=listing-page><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/></div><!$><!/><!$><!/>`);
7514
8232
  function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7515
8233
  depict_api_: depict_api_,
7516
- query_id_: query_id_,
7517
- listing_type_: listing_type_,
8234
+ listing_id_: listing_id_,
7518
8235
  meta_title_suffix_: meta_title_suffix_,
7519
8236
  current_sorting_: current_sorting_,
7520
8237
  min_products_to_fetch_: min_products_to_fetch_,
@@ -7527,7 +8244,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7527
8244
  get_breadcrumb_accessor_: get_breadcrumb_accessor_,
7528
8245
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
7529
8246
  local_filter_cache_: local_filter_cache_,
7530
- tenant_: tenant_,
8247
+ merchant_: merchant_,
7531
8248
  market_: market_,
7532
8249
  router_: router_,
7533
8250
  show_quicklinks_: show_quicklinks_,
@@ -7550,22 +8267,25 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7550
8267
  show_n_results_: incoming_i18n.show_n_products_,
7551
8268
  no_results_text_: incoming_i18n.no_products_text_
7552
8269
  };
8270
+ const {
8271
+ backend_locale_: backend_locale_
8272
+ } = i18n_;
7553
8273
  const [get_sorting] = current_sorting_;
7554
8274
  const number_of_rendered_selected_filters_items_ = $gVhhF$solidjs.createSignal(0);
7555
8275
  const first_result_in_viewport_ = $gVhhF$solidjs.createSignal();
7556
8276
  const last_result_in_viewport_ = $gVhhF$solidjs.createSignal();
7557
8277
  const [can_write_scroll_restoration_, set_can_write_scroll_restoration] = $gVhhF$solidjs.createSignal(false);
7558
- const query_base_ = $8cd545330f2674dc$export$210f130a61ac1e8d(() => {
8278
+ const products_query_base_ = $8cd545330f2674dc$export$210f130a61ac1e8d(() => {
7559
8279
  const sort_obj = get_sorting() && {
7560
8280
  ...get_sorting()
7561
8281
  };
7562
8282
  delete sort_obj?.meta;
7563
8283
  const f = selected_filters_[0]();
7564
8284
  return {
7565
- tenant: tenant_(),
8285
+ merchant: merchant_(),
7566
8286
  market: market_(),
7567
- query_id: query_id_(),
7568
- type: listing_type_(),
8287
+ locale: backend_locale_(),
8288
+ listing_id: listing_id_(),
7569
8289
  ...(f.length ? {
7570
8290
  filters: f
7571
8291
  } : {}),
@@ -7574,13 +8294,14 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7574
8294
  } : {})
7575
8295
  };
7576
8296
  });
7577
- const [plp_results_] = $gVhhF$solidjs.createResource(query_base_,
8297
+ // Make "Get products in listing" request to get products in listing
8298
+ const [plp_products_] = $gVhhF$solidjs.createResource(products_query_base_,
7578
8299
  // only first page of results, unless the history state says we should load more (can't do that in load more thing, I tested, they need to be added at once for the browser to not give up scroll restoration)
7579
8300
  $gVhhF$depictaiutilishared.catchify(base_query => $276380e4607fb9fb$export$cc42dd29bf655ab6({
7580
- id_: $gVhhF$solidjs.untrack(query_id_),
8301
+ id_: $gVhhF$solidjs.untrack(listing_id_),
7581
8302
  scroll_restoration_data_: scroll_restoration_data_,
7582
8303
  min_products_to_fetch_: min_products_to_fetch_,
7583
- make_request_: (limit, cursor) => depict_api_.list({
8304
+ make_request_: (limit, cursor) => depict_api_.get_listing_products({
7584
8305
  ...base_query,
7585
8306
  limit: limit,
7586
8307
  ...(cursor ? {
@@ -7588,24 +8309,33 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7588
8309
  } : {})
7589
8310
  })
7590
8311
  })));
7591
- const available_sortings_ = $gVhhF$solidjs.createMemo(() => plp_results_()?.sorts?.map(sort => ({
8312
+ const meta_query_base = $8cd545330f2674dc$export$210f130a61ac1e8d(() => ({
8313
+ merchant: merchant_(),
8314
+ market: market_(),
8315
+ locale: backend_locale_(),
8316
+ listing_id: listing_id_()
8317
+ }));
8318
+ // Make "Get Listing" request to get quicklinks, breadcrumbs, title, etc
8319
+ const [plp_meta] = $gVhhF$solidjs.createResource(meta_query_base, $gVhhF$depictaiutilishared.catchify(query => depict_api_.get_listing(query)));
8320
+ const available_sortings_ = $gVhhF$solidjs.createMemo(() => plp_products_()?.sorts?.map(sort => ({
7592
8321
  ...sort,
7593
8322
  order: sort.order ?? "desc"
7594
8323
  })));
7595
- const available_filters_ = $gVhhF$solidjs.createMemo(() => plp_results_()?.filters);
7596
- const crumb_data_ = $gVhhF$solidjs.createMemo(() => plp_results_()?.breadcrumb);
7597
- const quicklinks_data_ = $gVhhF$solidjs.createMemo(() => plp_results_()?.quick_links);
8324
+ const available_filters_ = $gVhhF$solidjs.createMemo(() => plp_products_()?.filters);
8325
+ const title = $gVhhF$solidjs.createMemo(() => plp_meta()?.title);
8326
+ const crumb_data_ = $840d88a04b2d22a7$var$add_us_to_crumbs(plp_meta, title);
8327
+ const quicklinks_data_ = $gVhhF$solidjs.createMemo(() => plp_meta()?.quick_links);
7598
8328
  const meta_tag_data_ = $gVhhF$solidjs.createMemo(() => {
7599
- if (plp_results_()?.metadata?.replace_meta_tags) return {
7600
- title: plp_results_()?.metadata?.title + (meta_title_suffix_() || ""),
7601
- description: plp_results_()?.metadata?.description
8329
+ if (plp_meta()?.replace_meta_tags) return {
8330
+ title: plp_meta()?.title + (meta_title_suffix_() || ""),
8331
+ description: plp_meta()?.description
7602
8332
  };
7603
8333
  });
7604
8334
  $gVhhF$depictaiutilishared.edit_current_page_meta_tags(meta_tag_data_);
7605
8335
  const [sort_or_filter_open_, set_sort_or_filter_open_] = $gVhhF$solidjs.createSignal(false);
7606
8336
  const [desktop_filter_elements_, set_desktop_filter_elements] = $gVhhF$solidjs.createSignal();
7607
8337
  const formatted_number_of_results_ = $0f400c3f7248d5f1$export$92f2da32c6e7e7ee({
7608
- number_: $gVhhF$solidjs.createMemo(() => plp_results_()?.n_hits),
8338
+ number_: $gVhhF$solidjs.createMemo(() => plp_products_()?.n_hits),
7609
8339
  i18n_: i18n_
7610
8340
  });
7611
8341
  const [sort_and_filter_element_, set_sort_and_filter_element_] = $gVhhF$solidjs.createSignal();
@@ -7624,7 +8354,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7624
8354
  [_el$6, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$5.nextSibling);
7625
8355
  $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
7626
8356
  get when() {
7627
- return plp_results_.loading;
8357
+ return plp_products_.loading;
7628
8358
  },
7629
8359
  fallback: formatted_number_of_results_,
7630
8360
  get children() {
@@ -7636,7 +8366,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7636
8366
  }), _el$4, _co$);
7637
8367
  $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
7638
8368
  get when() {
7639
- return plp_results_()?.n_hits === 1;
8369
+ return plp_products_()?.n_hits === 1;
7640
8370
  },
7641
8371
  get fallback() {
7642
8372
  return i18n_.products_();
@@ -7647,11 +8377,10 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7647
8377
  }), _el$6, _co$2);
7648
8378
  return _el$;
7649
8379
  })();
7650
- $6a8e766e914723d8$export$d31a1a1a83ad9413(plp_results_, selected_filters_);
8380
+ $6a8e766e914723d8$export$d31a1a1a83ad9413(plp_products_, selected_filters_);
7651
8381
  // aiming to have as little unneeded functionality in the bundle as possible, therefore we have two kinds of components that can "plug in" here depending on if there should be a title in the category page along with the count in a row above the buttons on mobile or if it should merge between the buttons when possible
7652
8382
  if (category_title_type === "simple") {
7653
8383
  const CategoryTitleComponent = category_title_;
7654
- const title = $gVhhF$solidjs.createMemo(() => crumb_data_()?.at(-1)?.title ?? plp_results_()?.metadata?.title);
7655
8384
  results_for = $gVhhF$solidjsweb.createComponent(CategoryTitleComponent, {
7656
8385
  category_title_: title,
7657
8386
  get product_count_() {
@@ -7697,12 +8426,12 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7697
8426
  $gVhhF$depictaiutilishared.catchify((0, $276380e4607fb9fb$export$6e49da55e449af7c))({
7698
8427
  scroll_restoration_data_: scroll_restoration_data_,
7699
8428
  last_result_in_viewport_: last_result_in_viewport_,
7700
- id_: query_id_,
8429
+ id_: listing_id_,
7701
8430
  can_write_scroll_restoration_: can_write_scroll_restoration_
7702
8431
  });
7703
8432
  on_filters_constructed_?.();
7704
8433
  $gVhhF$solidjs.createComputed(() => {
7705
- if (plp_results_.loading) set_can_write_scroll_restoration(false);else if (plp_results_()) set_can_write_scroll_restoration(true);
8434
+ if (plp_products_.loading) set_can_write_scroll_restoration(false);else if (plp_products_()) set_can_write_scroll_restoration(true);
7706
8435
  });
7707
8436
  $gVhhF$solidjs.createRenderEffect($gVhhF$depictaiutilishared.catchify(async () => {
7708
8437
  const slim = is_slim_();
@@ -7726,13 +8455,13 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7726
8455
  available_filters_: available_filters_
7727
8456
  });
7728
8457
  $ef972f5c10b1c5b4$export$3945d6db2dfd3d12({
7729
- query_id_: query_id_,
8458
+ listing_id_: listing_id_,
7730
8459
  crumb_data_: crumb_data_,
7731
8460
  i18n_: i18n_,
7732
8461
  selected_filters_: selected_filters_,
7733
8462
  local_filter_cache_: local_filter_cache_,
7734
8463
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
7735
- plp_results_: plp_results_,
8464
+ plp_results_: plp_products_,
7736
8465
  sideways_filter_clearing_flag_: sideways_filter_clearing_flag_
7737
8466
  });
7738
8467
  get_breadcrumb_accessor_?.(crumb_data_);
@@ -7756,7 +8485,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7756
8485
  [_el$28, _co$11] = $gVhhF$solidjsweb.getNextMarker(_el$27.nextSibling),
7757
8486
  _el$29 = _el$28.nextSibling,
7758
8487
  [_el$30, _co$12] = $gVhhF$solidjsweb.getNextMarker(_el$29.nextSibling);
7759
- $gVhhF$solidjsweb.use(el => process.env.NODE_ENV === "development" && $839b3341523d31a2$export$d4fc5c0e68a52116(el, query_id_, i18n_), _el$13);
8488
+ $gVhhF$solidjsweb.use(el => process.env.NODE_ENV === "development" && $bb9760b7a8acdc18$export$7af06a63c5a976c9(el, listing_id_, i18n_), _el$13);
7760
8489
  $gVhhF$solidjsweb.insert(_el$14, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
7761
8490
  get when() {
7762
8491
  return show_breadcrumbs_();
@@ -7778,7 +8507,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7778
8507
  get children() {
7779
8508
  return $gVhhF$solidjsweb.createComponent((0, $8cceb1d3a967f369$export$466cdc317043f6cb), {
7780
8509
  quicklinks_data_: quicklinks_data_,
7781
- current_query_id_: query_id_,
8510
+ current_listing_id_: listing_id_,
7782
8511
  router_: router_,
7783
8512
  breadcrumb_data_: crumb_data_,
7784
8513
  i18n_: i18n_,
@@ -7821,8 +8550,8 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7821
8550
  min_products_to_fetch_:
7822
8551
  // if you want to get if all products have been loaded you can add an optional signal here, see SearchPage
7823
8552
  min_products_to_fetch_,
7824
- query_base_: query_base_,
7825
- plp_results_: plp_results_,
8553
+ query_base_: products_query_base_,
8554
+ plp_results_: plp_products_,
7826
8555
  depict_api_: depict_api_,
7827
8556
  first_result_in_viewport_: first_result_in_viewport_,
7828
8557
  last_result_in_viewport_: last_result_in_viewport_,
@@ -7832,7 +8561,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7832
8561
  sort_or_filter_open_: sort_or_filter_open_,
7833
8562
  desktop_filter_elements_: desktop_filter_elements_,
7834
8563
  content_blocks_by_row_: content_blocks_by_row_,
7835
- id_currently_querying_for_: query_id_,
8564
+ id_currently_querying_for_: listing_id_,
7836
8565
  no_results_options_: {
7837
8566
  selected_filters_: selected_filters_,
7838
8567
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
@@ -7853,7 +8582,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7853
8582
  last_result_in_viewport_: last_result_in_viewport_,
7854
8583
  formatted_number_of_results_: formatted_number_of_results_,
7855
8584
  i18n_: i18n_,
7856
- number_of_results_: $gVhhF$solidjs.createMemo(() => plp_results_()?.n_hits)
8585
+ number_of_results_: $gVhhF$solidjs.createMemo(() => plp_products_()?.n_hits)
7857
8586
  });
7858
8587
  }
7859
8588
  }), _el$28, _co$11);
@@ -7874,16 +8603,40 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7874
8603
  return _el$13;
7875
8604
  })()];
7876
8605
  }
8606
+ /**
8607
+ * Adds the current page as last breadcrumb to the breadcrumb trail
8608
+ */
8609
+ function $840d88a04b2d22a7$var$add_us_to_crumbs(plp_meta, title) {
8610
+ const href_accessor = $gVhhF$depictaiutilishared.use_href_accessor();
8611
+ return $gVhhF$solidjs.createMemo(() => {
8612
+ const api_value = plp_meta()?.breadcrumbs;
8613
+ if (!api_value) return api_value;
8614
+ return [...api_value, {
8615
+ get listing_id() {
8616
+ return plp_meta().listing_id;
8617
+ },
8618
+ get title() {
8619
+ return title();
8620
+ },
8621
+ get page_url() {
8622
+ return href_accessor();
8623
+ },
8624
+ get slug() {
8625
+ return plp_meta().slug;
8626
+ }
8627
+ }];
8628
+ });
8629
+ }
7877
8630
  function $c79fd10a3ab7d6e0$export$477caf01aecaeb2a(options) {
7878
8631
  const router_ = options.router_;
7879
8632
  const search_query_url_param_name_ = "search_query_url_param_name_" in options ? options.search_query_url_param_name_ : undefined;
7880
8633
  const search_query_ = search_query_url_param_name_ ? $gVhhF$solidjs.createSignal("") : undefined;
7881
- const override_query_id_query_param_names_ = "override_query_id_query_param_names_" in options ? options.override_query_id_query_param_names_ : undefined;
7882
- const override_query_id_ = override_query_id_query_param_names_ ? $gVhhF$solidjs.createSignal(null) : undefined;
8634
+ const override_listing_id_query_param_names_ = "override_listing_id_query_param_names_" in options ? options.override_listing_id_query_param_names_ : undefined;
8635
+ const override_listing_id_ = override_listing_id_query_param_names_ ? $gVhhF$solidjs.createSignal(null) : undefined;
7883
8636
  const get_search_query_ = search_query_?.[0];
7884
8637
  const set_search_query = search_query_?.[1];
7885
- const get_override_query_id_ = override_query_id_?.[0];
7886
- const set_override_query_id = override_query_id_?.[1];
8638
+ const get_override_listing_id_ = override_listing_id_?.[0];
8639
+ const set_override_listing_id = override_listing_id_?.[1];
7887
8640
  const current_sorting_ = $gVhhF$solidjs.createSignal();
7888
8641
  const selected_filters_ = $gVhhF$solidjs.createSignal([]);
7889
8642
  const sideways_filter_clearing_flag_ = $gVhhF$solidjs.createSignal(false);
@@ -7928,10 +8681,10 @@ function $c79fd10a3ab7d6e0$export$477caf01aecaeb2a(options) {
7928
8681
  const found_query = searchParams.get(search_query_url_param_name_);
7929
8682
  set_search_query(found_query || "");
7930
8683
  }
7931
- if (override_query_id_query_param_names_) {
7932
- const found_override_query_id = override_query_id_query_param_names_.map(n => searchParams.get(n)).find(n => n);
7933
- set_override_query_id(found_override_query_id || null);
7934
- if (found_override_query_id) $gVhhF$depictaiutilishared.dlog("Found override query id:", found_override_query_id); // This stuff might get confusing so better log it
8684
+ if (override_listing_id_query_param_names_) {
8685
+ const found_override_listing_id = override_listing_id_query_param_names_.map(n => searchParams.get(n)).find(n => n);
8686
+ set_override_listing_id(found_override_listing_id || null);
8687
+ if (found_override_listing_id) $gVhhF$depictaiutilishared.dlog("Found override query id:", found_override_listing_id); // This stuff might get confusing so better log it
7935
8688
  }
7936
8689
 
7937
8690
  if (searchParams.get((0, $1ab22f2cd39b3061$export$cf5feb2102aec7f2)) === "true") set_has_sideways_filter_clearing_flag(true);
@@ -7958,8 +8711,8 @@ function $c79fd10a3ab7d6e0$export$477caf01aecaeb2a(options) {
7958
8711
  } : {
7959
8712
  sideways_filter_clearing_flag_: sideways_filter_clearing_flag_
7960
8713
  }),
7961
- ...(typeof override_query_id_query_param_names_ === "object" ? {
7962
- override_query_id_accessor_: get_override_query_id_
8714
+ ...(typeof override_listing_id_query_param_names_ === "object" ? {
8715
+ override_listing_id_accessor_: get_override_listing_id_
7963
8716
  } : {})
7964
8717
  };
7965
8718
  }
@@ -8004,108 +8757,6 @@ function $c79fd10a3ab7d6e0$var$start_href_writer({
8004
8757
  function $c79fd10a3ab7d6e0$var$delete_sideways_param_flag(searchParams) {
8005
8758
  if (searchParams.get((0, $1ab22f2cd39b3061$export$cf5feb2102aec7f2)) === "true") searchParams.delete((0, $1ab22f2cd39b3061$export$cf5feb2102aec7f2));
8006
8759
  }
8007
- class $e96dd13889871fc0$export$7e1297a3a19f10d8 {
8008
- /**
8009
- * Function that will be called when we want to navigate, or a string saying it's not an SPA. You can change this OTG
8010
- */ /**
8011
- * We store query_id in history.state and do operate on this both here and in js-ui, this is the key to be used which js-ui provides
8012
- */
8013
- #throwing_on_navigation(...args) {
8014
- const {
8015
- on_navigation_: on_navigation_
8016
- } = this;
8017
- if (typeof on_navigation_ !== "function") throw new Error("on_navigation_ is not a function");
8018
- // make sure that we don't accidentally catchify if the SDK consumer has fucked up
8019
- try {
8020
- return on_navigation_(...args);
8021
- } catch (e) {
8022
- queueMicrotask(() => {
8023
- throw e;
8024
- });
8025
- }
8026
- }
8027
- /**
8028
- * Checks if this tab shouldn't navigate because user wants to open in new tab
8029
- */
8030
- #dont_attempt_navigation(ev) {
8031
- return ev?.button || ev?.metaKey || ev?.ctrlKey;
8032
- }
8033
- /**
8034
- * Vue has async router that needs to be awaited (it navigates after a microtask)
8035
- * This standardises waiting for all kinds of routers
8036
- */
8037
- #get_navigation_happened_promise(is_replace) {
8038
- return new Promise(resolve => {
8039
- const handler = what_happened => {
8040
- if (what_happened === (is_replace ? "replaceState" : "pushState")) {
8041
- resolve();
8042
- (0, $gVhhF$depictaiutilishared.instant_exec_on_suspect_history_change).delete(handler);
8043
- }
8044
- };
8045
- (0, $gVhhF$depictaiutilishared.instant_exec_on_suspect_history_change).add(handler);
8046
- });
8047
- }
8048
- navigate_ = {
8049
- /**
8050
- * Call this if you *just* want to replace the state object in history.state
8051
- */
8052
- replace_state_: new_state => {
8053
- // This doesn't break any router, so we just do this directly for now, since many don't expose an interface for changing the state
8054
- globalThis?.history?.replaceState(new_state, "");
8055
- },
8056
- /**
8057
- * Call this to change the URL
8058
- * @param new_url_ new URL to go to
8059
- * @param event_ event if you have this in a click handler, will not do anything on cmd/ctrl or non-left click then
8060
- * @param force_spa_navigation_ if you want to force SPA navigation even if on_navigation_ is set to "hard_navigation". You should only set this to true for inter-SDK-page navigations
8061
- * @param is_replace_ if you want to replace the current URL in history instead of pushing a new one
8062
- * @param category_query_id_ If you are navigating to a category and know the query_id of, please provide it. This is for making a better devEx in js-ui
8063
- */
8064
- go_to_: $gVhhF$depictaiutilishared.catchify(async ({
8065
- new_url_: raw_new_url,
8066
- event_: event_,
8067
- force_spa_navigation_: force_spa_navigation_,
8068
- is_replace_: is_replace_,
8069
- category_query_id_: category_query_id_,
8070
- scroll = true
8071
- }) => {
8072
- const new_url_ = raw_new_url instanceof URL ? raw_new_url : new URL(raw_new_url, location.origin);
8073
- const wants_hard_navigation = this.on_navigation_ === "hard_navigation";
8074
- if (this.#dont_attempt_navigation(event_)) return;
8075
- const different_origin = new_url_.origin !== location.origin;
8076
- if (wants_hard_navigation && (!force_spa_navigation_ || different_origin)) {
8077
- if (force_spa_navigation_ && different_origin)
8078
- // If we call history.pushState on a different origin, it will throw an error, so fallback to hard navigations
8079
- $gVhhF$depictaiutilishared.dwarn("Can't single page navigate to", new_url_.href, "due to different origin, this MIGHT mean you should fix the URLs");
8080
- if (!event_)
8081
- // If we haven't gotten an event, nothing will happen by not calling prevent default, so we need to change the URL
8082
- location.assign(new_url_);
8083
- return;
8084
- }
8085
- event_?.preventDefault();
8086
- const promise = this.#get_navigation_happened_promise(true);
8087
- if (force_spa_navigation_ && wants_hard_navigation) {
8088
- // Don't allow hard navigation if we're forcing SPA navigation, which we do for things where PageReplacer can be used for performance
8089
- const new_state = history.state;
8090
- if (category_query_id_) {
8091
- // In JS-UI we need to know the query_id of the current category, therefore push it into state
8092
- if (!this.query_id_state_key) $gVhhF$depictaiutilishared.report(new Error("query_id_state_key is not set"), "error");
8093
- new_state[this.query_id_state_key] = category_query_id_;
8094
- }
8095
- history[is_replace_ ? "replaceState" : "pushState"](new_state, "", new_url_);
8096
- } else this.#throwing_on_navigation.call(this, {
8097
- is_replace: is_replace_,
8098
- new_url: new_url_ instanceof URL ? new_url_ : new URL(new_url_, location.origin),
8099
- scroll: scroll
8100
- });
8101
- await promise;
8102
- })
8103
- };
8104
- constructor(on_navigation, query_id_state_key) {
8105
- this.query_id_state_key = query_id_state_key;
8106
- this.on_navigation_ = on_navigation;
8107
- }
8108
- }
8109
8760
 
8110
8761
  /**
8111
8762
  * Wraps a function in a try/catch block and throws the error globally. If undefined is provided as fn, a no-op is returned.
@@ -8141,26 +8792,25 @@ const $48567ac5b39bac56$var$InExternalAreaDiv = ({
8141
8792
  })();
8142
8793
  class $48567ac5b39bac56$export$f34314aa9505732e {
8143
8794
  #router;
8144
- #locale_signal = $gVhhF$solidjs.createSignal();
8795
+ #localization_signal = $gVhhF$solidjs.createSignal();
8145
8796
  #merchant_signal = $gVhhF$solidjs.createSignal();
8146
8797
  #market_signal = $gVhhF$solidjs.createSignal();
8147
- #query_id_signal = $gVhhF$solidjs.createSignal("");
8798
+ #listing_id_signal = $gVhhF$solidjs.createSignal("");
8148
8799
  #meta_title_suffix_ = $gVhhF$solidjs.createSignal();
8149
- #disable_override_query_id = $gVhhF$solidjs.createSignal();
8150
- #listing_type_signal = $gVhhF$solidjs.createSignal();
8800
+ #disable_override_listing_id = $gVhhF$solidjs.createSignal();
8151
8801
  static #keys_constructed_with = /*@__PURE__*/new Set();
8152
8802
  get localization() {
8153
8803
  // allow reactive access
8154
- return this.#locale_signal[0]();
8804
+ return this.#localization_signal[0]();
8155
8805
  }
8156
8806
  set localization(locale_obj) {
8157
- this.#locale_signal[1](locale_obj);
8807
+ this.#localization_signal[1](locale_obj);
8158
8808
  }
8159
- get category_id() {
8160
- return this.#query_id_signal[0]();
8809
+ get listing_id() {
8810
+ return this.#listing_id_signal[0]();
8161
8811
  }
8162
- set category_id(id) {
8163
- this.#query_id_signal[1](id);
8812
+ set listing_id(id) {
8813
+ this.#listing_id_signal[1](id);
8164
8814
  }
8165
8815
  get merchant() {
8166
8816
  return this.#merchant_signal[0]();
@@ -8174,23 +8824,17 @@ class $48567ac5b39bac56$export$f34314aa9505732e {
8174
8824
  set market(market) {
8175
8825
  this.#market_signal[1](market);
8176
8826
  }
8177
- get listing_type() {
8178
- return this.#listing_type_signal[0]();
8179
- }
8180
- set listing_type(listing_type) {
8181
- this.#listing_type_signal[1](listing_type);
8182
- }
8183
8827
  get meta_title_suffix() {
8184
8828
  return this.#meta_title_suffix_[0]();
8185
8829
  }
8186
8830
  set meta_title_suffix(new_suffix) {
8187
8831
  this.#meta_title_suffix_[1](new_suffix);
8188
8832
  }
8189
- get disable_override_query_id() {
8190
- return this.#disable_override_query_id[0]();
8833
+ get disable_override_listing_id() {
8834
+ return this.#disable_override_listing_id[0]();
8191
8835
  }
8192
- set disable_override_query_id(new_value) {
8193
- this.#disable_override_query_id[1](new_value);
8836
+ set disable_override_listing_id(new_value) {
8837
+ this.#disable_override_listing_id[1](new_value);
8194
8838
  }
8195
8839
  get on_navigation() {
8196
8840
  // The only non-reactive public property on the class (I don't see it making sense to have it reactive)
@@ -8205,7 +8849,7 @@ class $48567ac5b39bac56$export$f34314aa9505732e {
8205
8849
  page_url_creator: page_url_creator,
8206
8850
  display_transformers: display_transformers,
8207
8851
  unique_instance_key_for_state = "",
8208
- query_id_state_key: query_id_state_key,
8852
+ listing_id_state_key: listing_id_state_key,
8209
8853
  ...props_on_class
8210
8854
  }) {
8211
8855
  const owner = $gVhhF$solidjs.getOwner() || $gVhhF$solidjs.createRoot(() => $gVhhF$solidjs.getOwner()); // we might have an owner, if so, pass it on. Otherwise, create one so solid doesn't print warnings to the console
@@ -8215,21 +8859,21 @@ class $48567ac5b39bac56$export$f34314aa9505732e {
8215
8859
  throw new Error("You can only have one instance of DepictCategory with the same uniqueInstanceKeyForState");
8216
8860
  Object.assign(this, props_on_class); // set initial signal values
8217
8861
  $d84fe647b84b5dc5$export$5162a71f252e6122();
8218
- this.#router = new (0, $e96dd13889871fc0$export$7e1297a3a19f10d8)("hard_navigation", query_id_state_key);
8862
+ this.#router = new (0, $e96dd13889871fc0$export$7e1297a3a19f10d8)("hard_navigation", listing_id_state_key);
8219
8863
  if (on_navigation) this.#router.on_navigation_ = on_navigation;
8220
- const override_query_id_query_param_names_ = ["query_id_" + unique_instance_key_for_state, "query_id"]; // If you're wondering why this is an array https://gitlab.com/depict-ai/depict.ai/-/merge_requests/7958#note_1511700842
8864
+ const override_listing_id_query_param_names_ = ["listing_id_" + unique_instance_key_for_state, "listing_id"]; // If you're wondering why this is an array https://gitlab.com/depict-ai/depict.ai/-/merge_requests/7958#note_1511700842
8221
8865
  const sorting_query_param_ = "sorting" + unique_instance_key_for_state;
8222
8866
  const filter_query_param_prefix_ = "f" + unique_instance_key_for_state + "_";
8223
8867
  const {
8224
8868
  selected_filters_: selected_filters_,
8225
8869
  current_sorting_: current_sorting_,
8226
8870
  sideways_filter_clearing_flag_: sideways_filter_clearing_flag_,
8227
- override_query_id_accessor_: override_query_id_accessor_
8871
+ override_listing_id_accessor_: override_listing_id_accessor_
8228
8872
  } = $c79fd10a3ab7d6e0$export$477caf01aecaeb2a({
8229
8873
  router_: this.#router,
8230
8874
  sorting_query_param_: sorting_query_param_,
8231
8875
  filter_query_param_prefix_: filter_query_param_prefix_,
8232
- override_query_id_query_param_names_: override_query_id_query_param_names_
8876
+ override_listing_id_query_param_names_: override_listing_id_query_param_names_
8233
8877
  });
8234
8878
  const [reset_history_state_, state_] = $26a56f6b44703084$export$9862539c89138352({
8235
8879
  get_default_values_: () => ({
@@ -8244,7 +8888,7 @@ class $48567ac5b39bac56$export$f34314aa9505732e {
8244
8888
  router_: this.#router,
8245
8889
  prefix_: "category" + unique_instance_key_for_state + "_"
8246
8890
  });
8247
- const i18n_ = $0785f4c9947d9b5f$export$f091cbac892643a4(this.#locale_signal[0]);
8891
+ const i18n_ = $0785f4c9947d9b5f$export$f091cbac892643a4(this.#localization_signal[0]);
8248
8892
  $48567ac5b39bac56$var$privately_shared_properties.set(this, {
8249
8893
  state_: state_,
8250
8894
  breadcrumb_signal_: $gVhhF$solidjs.createSignal(),
@@ -8259,7 +8903,7 @@ class $48567ac5b39bac56$export$f34314aa9505732e {
8259
8903
  router_: this.#router,
8260
8904
  selected_filters_: selected_filters_,
8261
8905
  current_sorting_: current_sorting_,
8262
- override_query_id_accessor_: override_query_id_accessor_,
8906
+ override_listing_id_accessor_: override_listing_id_accessor_,
8263
8907
  sideways_filter_clearing_flag_: sideways_filter_clearing_flag_,
8264
8908
  sorting_query_param_: sorting_query_param_,
8265
8909
  filter_query_param_prefix_: filter_query_param_prefix_
@@ -8279,11 +8923,11 @@ function $48567ac5b39bac56$export$e2bf8ce7779e827e(props) {
8279
8923
  return $95837413165cc2df$export$23fca46f3143581f(() => {
8280
8924
  $gVhhF$solidjs.createEffect(prev => {
8281
8925
  // this is here (and not on DepictCategory) so that people also know when PageReplacer removes the page, it's intended to help people replace their own content when a depict page is navigated, see https://depictaiworkspace.slack.com/archives/C04M8MGCF3K/p1691670636155369
8282
- const id = depict_category.category_id; // <- this is a reactive getter
8283
- $deaaf04362a1bc71$export$f50b88e2a00918b5(props.on_query_id_change)(id, prev);
8926
+ const id = depict_category.listing_id; // <- this is a reactive getter
8927
+ $deaaf04362a1bc71$export$f50b88e2a00918b5(props.on_listing_id_change)(id, prev);
8284
8928
  return id;
8285
8929
  });
8286
- $gVhhF$solidjs.onCleanup(() => $deaaf04362a1bc71$export$f50b88e2a00918b5(props.on_query_id_change)());
8930
+ $gVhhF$solidjs.onCleanup(() => $deaaf04362a1bc71$export$f50b88e2a00918b5(props.on_listing_id_change)());
8287
8931
  const grid_spacing_override = $gVhhF$solidjs.createMemo(() => {
8288
8932
  const {
8289
8933
  grid_spacing: grid_spacing
@@ -8306,7 +8950,7 @@ function $48567ac5b39bac56$export$e2bf8ce7779e827e(props) {
8306
8950
  },
8307
8951
  current_sorting_: current_sorting_,
8308
8952
  selected_filters_: selected_filters_,
8309
- override_query_id_accessor_: override_query_id_accessor_,
8953
+ override_listing_id_accessor_: override_listing_id_accessor_,
8310
8954
  reset_history_state_: reset_history_state_,
8311
8955
  depict_api_: depict_api_,
8312
8956
  i18n_: i18n_,
@@ -8319,14 +8963,13 @@ function $48567ac5b39bac56$export$e2bf8ce7779e827e(props) {
8319
8963
  } = shared_properties;
8320
8964
  $gVhhF$solidjs.onCleanup(reset_history_state_);
8321
8965
  return $840d88a04b2d22a7$export$f7d2f673fc2f091d({
8322
- tenant_: () => depict_category.merchant,
8966
+ merchant_: () => depict_category.merchant,
8323
8967
  market_: () => depict_category.market,
8324
8968
  depict_api_: depict_api_,
8325
8969
  min_products_to_fetch_: $48567ac5b39bac56$var$min_products_to_fetch_,
8326
8970
  local_filter_cache_: local_filter_cache_,
8327
- query_id_: $gVhhF$solidjs.createMemo(() => !depict_category.disable_override_query_id && override_query_id_accessor_() || depict_category.category_id),
8971
+ listing_id_: $gVhhF$solidjs.createMemo(() => !depict_category.disable_override_listing_id && override_listing_id_accessor_() || depict_category.listing_id),
8328
8972
  meta_title_suffix_: () => depict_category.meta_title_suffix,
8329
- listing_type_: () => depict_category.listing_type,
8330
8973
  i18n_: i18n_,
8331
8974
  show_quicklinks_: $gVhhF$solidjs.createMemo(() => props.show_quicklinks ?? true),
8332
8975
  category_title_: category_title,
@@ -8392,7 +9035,7 @@ function $48567ac5b39bac56$export$de035477d6fef996({
8392
9035
  i18n_: i18n_,
8393
9036
  quicklinks_data_: quicklinks_data_,
8394
9037
  router_: router_,
8395
- current_query_id_: () => depict_category.category_id,
9038
+ current_listing_id_: () => depict_category.listing_id,
8396
9039
  breadcrumb_data_: breadcrumb_data_,
8397
9040
  sorting_query_param_: sorting_query_param_,
8398
9041
  filter_query_param_prefix_: filter_query_param_prefix_
@@ -8405,31 +9048,6 @@ function $48567ac5b39bac56$var$get_shared_properties(depict_category) {
8405
9048
  if (!shared_properties) throw new Error("Can't connect to provided DepictCategory instance");
8406
9049
  return shared_properties;
8407
9050
  }
8408
- const $0b23bfd073d9a4e8$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=category-title><h1 class=title></h1><span class=explanation> — <!$><!/>`);
8409
- const $0b23bfd073d9a4e8$export$b91cec6bdc6b32a1 = /*@__PURE__*/(() => {
8410
- const actual_function = ({
8411
- category_title_: category_title_,
8412
- product_count_: product_count_
8413
- }) => {
8414
- return (() => {
8415
- const _el$ = $gVhhF$solidjsweb.getNextElement($0b23bfd073d9a4e8$var$_tmpl$),
8416
- _el$2 = _el$.firstChild,
8417
- _el$3 = _el$2.nextSibling,
8418
- _el$4 = _el$3.firstChild,
8419
- _el$5 = _el$4.nextSibling,
8420
- [_el$6, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$5.nextSibling);
8421
- $gVhhF$solidjsweb.insert(_el$2, () => category_title_() || $gVhhF$solidjsweb.createComponent((0, $061ff5b4c3d36171$export$89c6019e4baa40b1), {
8422
- height: "1em",
8423
- width: "10ch"
8424
- }));
8425
- $gVhhF$solidjsweb.insert(_el$3, product_count_, _el$6, _co$);
8426
- return _el$;
8427
- })();
8428
- };
8429
- // This is wrong but parcel can't build correctly, it says unexpected undefined
8430
- actual_function[(0, $6b502b1b2155a0bc$export$5c28802497c8a83c)] = "simple";
8431
- return actual_function;
8432
- })();
8433
9051
  const $85b747260aa175c9$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class="sort-and-filter-buttons fake"aria-hidden=true style=position:absolute;z-index:-1;pointer-events:none;opacity:0><div class=outer><div class=inner><!$><!/><!$><!/><!$><!/>`);
8434
9052
  const $85b747260aa175c9$export$824dde41348efed1 = /*@__PURE__*/(() => {
8435
9053
  const actual_function = ({
@@ -8528,11 +9146,11 @@ const $85b747260aa175c9$export$824dde41348efed1 = /*@__PURE__*/(() => {
8528
9146
  actual_function[(0, $6b502b1b2155a0bc$export$5c28802497c8a83c)] = "interactive";
8529
9147
  return actual_function;
8530
9148
  })();
8531
- const $63b10c9f461e0ef6$var$TEN_MINUTES = 600000;
8532
- const $63b10c9f461e0ef6$var$TWENTY_FOUR_HOURS = 86400000;
8533
- async function $63b10c9f461e0ef6$export$643598a327b5833e(tenant, market, type) {
9149
+ const $6382a1b83da39674$var$TEN_MINUTES = 600000;
9150
+ const $6382a1b83da39674$var$TWENTY_FOUR_HOURS = 86400000;
9151
+ async function $6382a1b83da39674$export$c1a6b039e689a58e(merchant, market, locale) {
8534
9152
  let localstorage_value;
8535
- const localstorage_key = `depict_${tenant}_${type ?? "categories"}_` + market;
9153
+ const localstorage_key = `depict_listings_${JSON.stringify([merchant, market, locale])}}`;
8536
9154
  try {
8537
9155
  const in_ls = localStorage[localstorage_key];
8538
9156
  if (in_ls) localstorage_value = JSON.parse(in_ls);
@@ -8544,20 +9162,20 @@ async function $63b10c9f461e0ef6$export$643598a327b5833e(tenant, market, type) {
8544
9162
  const stored_queries = localstorage_value?.queries;
8545
9163
  if (Array.isArray(stored_queries) && typeof updated === "number") {
8546
9164
  const age = now - updated;
8547
- if (stored_queries.length && age < $63b10c9f461e0ef6$var$TEN_MINUTES)
9165
+ if (stored_queries.length && age < $6382a1b83da39674$var$TEN_MINUTES)
8548
9166
  // if younger than 10 minutes and probably valid data, just return stored value
8549
- return stored_queries;else if (age < $63b10c9f461e0ef6$var$TWENTY_FOUR_HOURS) {
9167
+ return stored_queries;else if (age < $6382a1b83da39674$var$TWENTY_FOUR_HOURS) {
8550
9168
  // if younger than a day, return stored value but still trigger re-fetch, so we have fresh data next page load (stale data this one but never a delay)
8551
- $63b10c9f461e0ef6$var$fetch_and_store_categories(tenant, market, localstorage_key, type).catch(e => $gVhhF$depictaiutilishared.report([e, "couldn't fetch categories"], "warning"));
9169
+ $6382a1b83da39674$var$fetch_and_store_categories(merchant, market, locale, localstorage_key).catch(e => $gVhhF$depictaiutilishared.report([e, "couldn't fetch categories"], "warning"));
8552
9170
  return stored_queries;
8553
9171
  }
8554
9172
  // else: we are older and just fetch, store and return new queries
8555
9173
  }
8556
9174
 
8557
- return await $63b10c9f461e0ef6$var$fetch_and_store_categories(tenant, market, localstorage_key, type);
9175
+ return await $6382a1b83da39674$var$fetch_and_store_categories(merchant, market, locale, localstorage_key);
8558
9176
  }
8559
- async function $63b10c9f461e0ef6$var$fetch_and_store_categories(tenant, market, localstorage_key, type) {
8560
- const new_categories = await $63b10c9f461e0ef6$var$download_categories(tenant, market, type);
9177
+ async function $6382a1b83da39674$var$fetch_and_store_categories(merchant, market, locale, localstorage_key) {
9178
+ const new_categories = await $6382a1b83da39674$var$download_categories(merchant, market, locale);
8561
9179
  try {
8562
9180
  localStorage[localstorage_key] = JSON.stringify({
8563
9181
  updated: +new Date(),
@@ -8569,24 +9187,22 @@ async function $63b10c9f461e0ef6$var$fetch_and_store_categories(tenant, market,
8569
9187
 
8570
9188
  return new_categories;
8571
9189
  }
8572
- async function $63b10c9f461e0ef6$var$download_categories(tenant, market, type) {
8573
- const fetched = await $gVhhF$depictaiutilishared.fetch_retry((0, $gVhhF$depictaiutilishared.base_url) + "/v2/product-listing/queries", {
8574
- method: "POST",
8575
- body: JSON.stringify({
8576
- tenant: tenant,
8577
- market: market,
8578
- ...(type ? {
8579
- type: type
8580
- } : {})
8581
- })
8582
- });
9190
+ async function $6382a1b83da39674$var$download_categories(merchant, market, locale) {
9191
+ const url = new URL((0, $gVhhF$depictaiutilishared.base_url) + "/v3/listings");
9192
+ const request = {
9193
+ merchant: merchant,
9194
+ market: market,
9195
+ locale: locale
9196
+ };
9197
+ url.search = "" + new URLSearchParams(request);
9198
+ const fetched = await $gVhhF$depictaiutilishared.fetch_retry(url.href);
8583
9199
  if (!fetched) return [];
8584
9200
  try {
8585
9201
  if (fetched.status !== 200) {
8586
9202
  $gVhhF$depictaiutilishared.dlog("failed to fetch queries, server responded with", fetched.status, fetched, await fetched.text());
8587
9203
  return [];
8588
9204
  }
8589
- return (await fetched.json())?.query_ids;
9205
+ return await fetched.json();
8590
9206
  } catch (e) {
8591
9207
  $gVhhF$depictaiutilishared.dlog("failed to decode queries json", fetched, e);
8592
9208
  return [];
@@ -8837,8 +9453,6 @@ function $fb29c6201c369e39$export$7de92c4c2205ebf3({
8837
9453
  }));
8838
9454
  return $a73063cc642f3e5f$export$43f0fb951fcb0c54({
8839
9455
  displays_by_key_: displays_by_key_,
8840
- merchant_: $gVhhF$solidjs.createMemo(() => search_query_base_().tenant),
8841
- market_: $gVhhF$solidjs.createMemo(() => search_query_base_().market),
8842
9456
  product_card_template_: product_card_template_
8843
9457
  });
8844
9458
  })();
@@ -9154,7 +9768,7 @@ const $6ae556e536054e87$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<d
9154
9768
  function $6ae556e536054e87$export$62f101a8aa597bf8({
9155
9769
  depict_api_: depict_api_,
9156
9770
  search_field_value_: [get_search_field_value],
9157
- tenant_: tenant_,
9771
+ merchant_: merchant_,
9158
9772
  market_: market_,
9159
9773
  render_instant_card_: render_instant_card_,
9160
9774
  render_instant_card_placeholder_: render_instant_card_placeholder_,
@@ -9178,8 +9792,10 @@ function $6ae556e536054e87$export$62f101a8aa597bf8({
9178
9792
  timeout = setTimeout($gVhhF$depictaiutilishared.catchify(() => write_current_instant_query(value)), 250);
9179
9793
  });
9180
9794
  const [search_results] = $gVhhF$solidjs.createResource($gVhhF$solidjs.createMemo(() => ({
9181
- tenant: tenant_(),
9795
+ // <-- key order important, see comment below
9796
+ merchant: merchant_(),
9182
9797
  market: market_(),
9798
+ locale: i18n_.backend_locale_(),
9183
9799
  query: read_current_instant_query()
9184
9800
  })), $gVhhF$depictaiutilishared.catchify(variable_data => {
9185
9801
  return depict_api_.query({
@@ -9227,12 +9843,12 @@ function $6ae556e536054e87$export$62f101a8aa597bf8({
9227
9843
  const card = render_instant_card_ ? $gVhhF$solidjs.createMemo(() => render_instant_card_(d(), {
9228
9844
  index: i,
9229
9845
  i18n: $639c124c22b6cbaa$export$27b710c08412a7ad(i18n_),
9230
- merchant: tenant_(),
9846
+ merchant: merchant_(),
9231
9847
  market: market_()
9232
9848
  })) : $6ae613870d3380fc$export$b05c0ae390cf3e06(d, {
9233
9849
  index: i,
9234
9850
  i18n: i18n_,
9235
- merchant: tenant_(),
9851
+ merchant: merchant_(),
9236
9852
  market: market_()
9237
9853
  }, router_);
9238
9854
  return card;
@@ -9869,7 +10485,7 @@ function $3ec9e21d6b6debdd$export$2f2b9559550c7bbc({
9869
10485
  previous_searches_: [unfiltered_previous_searches, set_unfiltered_previous_searches_],
9870
10486
  previous_searches_text_: previous_searches_text_,
9871
10487
  depict_api_: depict_api_,
9872
- tenant_: tenant_,
10488
+ merchant_: merchant_,
9873
10489
  market_: market_,
9874
10490
  input_field_: input_field_,
9875
10491
  url_transformer_: url_transformer_,
@@ -9942,9 +10558,10 @@ function $3ec9e21d6b6debdd$export$2f2b9559550c7bbc({
9942
10558
  set_show_stale_content_results(true);else {
9943
10559
  set_searching_for_value(field_value);
9944
10560
  deparallelized_fn({
9945
- query: field_value,
9946
- tenant: tenant_(),
9947
- market: market_()
10561
+ merchant: merchant_(),
10562
+ market: market_(),
10563
+ locale: i18n_.backend_locale_(),
10564
+ query: field_value
9948
10565
  });
9949
10566
  set_show_stale_content_results(false);
9950
10567
  }
@@ -10080,7 +10697,7 @@ function $f40a47a30a358305$export$1c593cbd6f1e10bc({
10080
10697
  close_modal_: close_modal_,
10081
10698
  style_props_ = $gVhhF$solidjs.createSignal({}),
10082
10699
  depict_api_: depict_api_,
10083
- tenant_: tenant_,
10700
+ merchant_: merchant_,
10084
10701
  market_: market_,
10085
10702
  submit_query_: props_submit_query,
10086
10703
  instant_results_options_: instant_results_options_,
@@ -10217,7 +10834,7 @@ function $f40a47a30a358305$export$1c593cbd6f1e10bc({
10217
10834
  previous_searches_: previous_searches_,
10218
10835
  search_query_url_param_name_: search_query_url_param_name_,
10219
10836
  market_: market_,
10220
- tenant_: tenant_,
10837
+ merchant_: merchant_,
10221
10838
  selected_index_: selected_index,
10222
10839
  currently_showing_suggestions_: currently_showing_suggestions_,
10223
10840
  depict_api_: depict_api_,
@@ -10240,7 +10857,7 @@ function $f40a47a30a358305$export$1c593cbd6f1e10bc({
10240
10857
  return $6ae556e536054e87$export$62f101a8aa597bf8({
10241
10858
  search_field_value_: search_field_value_,
10242
10859
  depict_api_: depict_api_,
10243
- tenant_: tenant_,
10860
+ merchant_: merchant_,
10244
10861
  i18n_: i18n_,
10245
10862
  market_: market_,
10246
10863
  set_total_num_results_accessor_: set_total_num_results_accessor_,
@@ -10722,6 +11339,9 @@ function $f1d7cb69f839a526$export$a54ec244c8863715({
10722
11339
  const first_result_in_viewport_ = $gVhhF$solidjs.createSignal();
10723
11340
  const last_result_in_viewport_ = $gVhhF$solidjs.createSignal();
10724
11341
  const [can_write_scroll_restoration_, set_can_write_scroll_restoration] = $gVhhF$solidjs.createSignal(false);
11342
+ const {
11343
+ backend_locale_: backend_locale_
11344
+ } = i18n_;
10725
11345
  const search_query_base_ = $8cd545330f2674dc$export$210f130a61ac1e8d(() => {
10726
11346
  const sort_obj = get_sorting() && {
10727
11347
  ...get_sorting()
@@ -10729,8 +11349,9 @@ function $f1d7cb69f839a526$export$a54ec244c8863715({
10729
11349
  delete sort_obj?.meta;
10730
11350
  const f = selected_filters_[0]();
10731
11351
  return {
10732
- tenant: tenant_(),
11352
+ merchant: tenant_(),
10733
11353
  market: market_(),
11354
+ locale: backend_locale_(),
10734
11355
  query: get_search_query_(),
10735
11356
  ...(f.length ? {
10736
11357
  filters: f
@@ -10756,11 +11377,12 @@ function $f1d7cb69f839a526$export$a54ec244c8863715({
10756
11377
  })
10757
11378
  });
10758
11379
  }));
10759
- const [suggestions] = $gVhhF$solidjs.createResource($gVhhF$solidjs.createMemo(() => ({
11380
+ const [suggestions] = $gVhhF$solidjs.createResource(() => ({
10760
11381
  query: get_search_query_(),
10761
- tenant: tenant_(),
10762
- market: market_()
10763
- })), opts => depict_api_.suggest(opts));
11382
+ merchant: tenant_(),
11383
+ market: market_(),
11384
+ locale: backend_locale_()
11385
+ }), opts => depict_api_.suggest(opts));
10764
11386
  const available_sortings_ = $gVhhF$solidjs.createMemo(() => search_results_()?.sorts?.map(sort => ({
10765
11387
  ...sort,
10766
11388
  order: sort.order ?? "desc"
@@ -11245,7 +11867,7 @@ class $2c61e4cd8229c49a$export$ac6237957a15b3f0 {
11245
11867
  search_query_url_param_name_: search_query_url_param_name_,
11246
11868
  previous_searches_: previous_searches,
11247
11869
  depict_api_: depict_api_,
11248
- tenant_: this.#merchant_signal[0],
11870
+ merchant_: this.#merchant_signal[0],
11249
11871
  clear_filters_: clear_filters_on_next_submit_,
11250
11872
  market_: this.#market_signal[0],
11251
11873
  submit_query_: configured_submit_query_,
@@ -11359,11 +11981,12 @@ class $2c61e4cd8229c49a$export$ac6237957a15b3f0 {
11359
11981
  depict_api_: depict_api_
11360
11982
  } = $2c61e4cd8229c49a$var$privately_shared_properties.get(this);
11361
11983
  const result = await depict_api_.query({
11362
- tenant: this.merchant,
11984
+ merchant: this.merchant,
11363
11985
  market: this.market,
11364
11986
  query: query,
11365
11987
  filters: filters,
11366
- limit: maxResults
11988
+ limit: maxResults,
11989
+ locale: this.localization.backend_locale_
11367
11990
  });
11368
11991
  if (result.failed) throw new Error("Failed to fetch search results");
11369
11992
  return result.displays;
@@ -11803,7 +12426,4 @@ function $0a6acf31d1eae57c$var$clean_url(url) {
11803
12426
  url_object.hash = "";
11804
12427
  return url_object.href;
11805
12428
  }
11806
- const $a3280f0aad997933$export$c3834fa86c616831 = [[4], [3, 1024], [2, 901]];
11807
- const $a3280f0aad997933$export$864d304a0bc46829 = "2%";
11808
- const $a3280f0aad997933$export$7bf543b9d9be2c22 = (0, $0b23bfd073d9a4e8$export$b91cec6bdc6b32a1);
11809
12429
  $gVhhF$depictaiutilishared.add_to_version_info("ui", (0, $b757f75811f3261f$export$83d89fbfd8236492));