@depict-ai/ui 2.1.23 → 3.0.1

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.23";
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.1";
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,207 +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);
547
+ }
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
+ }
575
+ }
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
+ })();
464
600
  },
465
- get alt() {
466
- return props.alt;
601
+ get children() {
602
+ return props.children;
467
603
  }
468
- }));
469
- return container;
604
+ });
470
605
  }
471
- 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>`);
472
- function $0f313083912e447a$export$8be2714ec7f169ee(props = {}) {
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 = {}) {
473
608
  return (() => {
474
- 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$);
475
619
  $gVhhF$solidjsweb.effect(_p$ => {
476
- const _v$ = props.width_ ?? 14,
477
- _v$2 = props.height_ ?? 26;
478
- _v$ !== _p$._v$ && $gVhhF$solidjsweb.setAttribute(_el$, "width", _p$._v$ = _v$);
479
- _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);
480
624
  return _p$;
481
625
  }, {
482
626
  _v$: undefined,
@@ -485,109 +629,149 @@ function $0f313083912e447a$export$8be2714ec7f169ee(props = {}) {
485
629
  return _el$;
486
630
  })();
487
631
  }
488
- const $a0e53f99354809d9$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div>`);
489
- function $a0e53f99354809d9$export$6649caad96ef8870({
490
- children: children,
491
- slider_ref_: slider_ref_,
492
- faded_opacity_ = 0.7,
493
- mutation_plugins_ = [],
494
- disable_fading_: disable_fading_,
495
- arrow_width_: arrow_width_,
496
- arrow_height_: arrow_height_
497
- }) {
498
- const slider = new (0, $gVhhF$depictaiutilishared.Amazing_Slider)({
499
- button_contents: {
500
- left: [(() => {
501
- const _el$ = $gVhhF$solidjsweb.getNextElement($a0e53f99354809d9$var$_tmpl$);
502
- $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent((0, $0f313083912e447a$export$8be2714ec7f169ee), {
503
- height_: arrow_height_,
504
- width_: arrow_width_
505
- }));
506
- return _el$;
507
- })()],
508
- right: [(() => {
509
- const _el$2 = $gVhhF$solidjsweb.getNextElement($a0e53f99354809d9$var$_tmpl$);
510
- $gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $0f313083912e447a$export$8be2714ec7f169ee), {
511
- height_: arrow_height_,
512
- width_: arrow_width_
513
- }));
514
- return _el$2;
515
- })()]
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();
516
657
  },
517
- constructor_plugins: [$gVhhF$depictaiutilishared.slider_snap_css().constructor_plugin],
518
- mutation_plugins: [...(disable_fading_ ? [] : [$gVhhF$depictaiutilishared.slider_fading_factory({
519
- threshold_: 0.96,
520
- faded_opacity_: faded_opacity_
521
- }).mutation_plugin_]), ...mutation_plugins_]
658
+ get ["class"]() {
659
+ return props.class;
660
+ }
522
661
  });
523
- $gVhhF$solidjsweb.insert(slider.insert_here, children);
524
- $gVhhF$solidjs.onCleanup(() => slider.observer.disconnect());
525
- slider_ref_?.(slider);
526
- return slider.container;
527
662
  }
528
-
529
- /** @jsxImportSource solid-js */
530
-
531
- function $f13855d1b951b24a$export$ebdc3711f7e02ccd(what_to_watch) {
532
- const [width, setWidth] = $gVhhF$solidjs.createSignal();
533
- const resizeObserver = new ResizeObserver($gVhhF$depictaiutilishared.catchify(records => {
534
- for (let j = 0; j < records.length; j++) {
535
- const width = records[j].borderBoxSize?.[0]?.inlineSize ?? what_to_watch.getBoundingClientRect().width;
536
- 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_;
537
681
  }
538
- }));
539
- // 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.
540
- // It doesn't seem to work even when waiting for it to be in the DOM, also wait an animation frame
541
- const disconnect = (0, $gVhhF$depictaiutilishared.observer).onexists(what_to_watch, ({
542
- element: element
543
- }) => requestAnimationFrame($gVhhF$depictaiutilishared.catchify(() => {
544
- const current_size = what_to_watch.getBoundingClientRect().width;
545
- if (current_size)
546
- // 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.
547
- setWidth(current_size);
548
- resizeObserver.observe(element);
549
- })));
550
- $gVhhF$solidjs.onCleanup(() => {
551
- resizeObserver.disconnect();
552
- disconnect();
553
682
  });
554
- 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
+ })();
555
721
  }
556
- const $4e04be41243c3d80$var$transform_elements = sorted_cols_at_size => {
557
- const cols_at_size = [];
558
- for (let i = 0; i < sorted_cols_at_size.length; i++) {
559
- const [nb_cols, width] = sorted_cols_at_size[i];
560
- const next_width = sorted_cols_at_size[i + 1]?.[1];
561
- const max_width = i === 0 ? "" : `${width}px`;
562
- const min_width = next_width !== undefined ? `${next_width + 1}px` : "";
563
- const col_at_size = [nb_cols, min_width, max_width];
564
- cols_at_size.push(col_at_size);
565
- }
566
- return cols_at_size;
567
- };
568
- const $4e04be41243c3d80$export$6daf8749b65a1b77 = cols_at_size => {
569
- // Check that every element is an array
570
- const are_arrays = cols_at_size.every(element => Array.isArray(element));
571
- if (!are_arrays) throw new Error("Every element in cols_at_size must be an array");
572
- // Check width duplicates
573
- const widths = cols_at_size.map(([_, width]) => width);
574
- const widths_set = new Set(widths);
575
- if (widths_set.size < widths.length) throw new Error("There are duplicate widths in cols_at_size");
576
- if (cols_at_size.length === 1) {
577
- const [nb_cols, width] = cols_at_size[0];
578
- const max_width = width !== undefined ? `${width}px` : "";
579
- return [[nb_cols, "", max_width]];
580
- }
581
- // Sort widths in ascending order
582
- const sorted_cols_at_size = [...cols_at_size].sort((a, b) => {
583
- const [_b, width_A] = a;
584
- const [_a, width_b] = b;
585
- if (width_A === undefined) return -1;
586
- if (width_b === undefined) return 1;
587
- 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
+ };
588
736
  });
589
- return $4e04be41243c3d80$var$transform_elements(sorted_cols_at_size);
590
- };
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);
591
775
  function $fc23d7668ae0011d$export$a2cc176055f8f08() {
592
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.";
593
777
  return (0, $gVhhF$solidjsweb.isServer) ? {
@@ -730,8 +914,6 @@ function $a73063cc642f3e5f$export$7f8bd308237ab5a5(get_displays_) {
730
914
  const $a73063cc642f3e5f$var$result_ids = ["search_result_id", "product_listing_result_id", "recommendation_id"];
731
915
  function $a73063cc642f3e5f$export$43f0fb951fcb0c54({
732
916
  displays_by_key_: displays_by_key_,
733
- merchant_: merchant_,
734
- market_: market_,
735
917
  product_card_template_: product_card_template_,
736
918
  do_per_elements_: do_per_elements_,
737
919
  content_blocks_: content_blocks_
@@ -752,10 +934,9 @@ function $a73063cc642f3e5f$export$43f0fb951fcb0c54({
752
934
  return prev;
753
935
  return new_display;
754
936
  });
755
- const [product_card_resource] = $gVhhF$solidjs.createResource(() => [merchant_(), market_(), display_accessor()],
756
- // re-render when the reference to the display object changes or the merchant or market changes
757
- // (We don't want to re-render if nothing has changed)
758
- ([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 => {
759
940
  // It's easy for merchants to accidentally mutate the display or some sub-object thereof
760
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
761
942
  // Attempt cloning the displays if possible (99.9% of the cases probably) and if not, just use the original display
@@ -768,12 +949,9 @@ function $a73063cc642f3e5f$export$43f0fb951fcb0c54({
768
949
  }
769
950
  }
770
951
  return product_card_template_(display, {
771
- set_on_index_change: fn => $gVhhF$solidjs.runWithOwner(owner, () => $gVhhF$solidjs.createEffect(() => fn(index()))),
772
- merchant: merchant,
773
- 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())))
774
953
  });
775
954
  });
776
-
777
955
  const node_accessor = $5f7d55c710fd1bc2$export$2f0cbfbb4354bb52(product_card_resource);
778
956
  $gVhhF$solidjs.createEffect(() => {
779
957
  const product_card_nodes = node_accessor();
@@ -824,46 +1002,6 @@ function $a73063cc642f3e5f$var$deep_equal(obj1, obj2) {
824
1002
  }
825
1003
  return false;
826
1004
  }
827
-
828
- // Errors caused by SDK consuming code interfacing with the SDK, not the SDK itself or other Depict packages
829
- class $7dd1edb2ee2b43ad$export$e1d52e4f0c7557a1 extends Error {}
830
- class $7dd1edb2ee2b43ad$export$aa14a9f43128f61f extends $7dd1edb2ee2b43ad$export$e1d52e4f0c7557a1 {
831
- constructor(templateError) {
832
- super("Uncaught error in product card template", {
833
- cause: templateError
834
- });
835
- }
836
- }
837
- const $edafe91daf3091d7$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div><!$><!/><!$><!/>`);
838
- function $edafe91daf3091d7$export$b69d0d92862de18b(props) {
839
- return $gVhhF$solidjs.ErrorBoundary({
840
- fallback(err, retry) {
841
- const {
842
- message_: message_,
843
- severity_: severity_
844
- } = props;
845
- let message = message_;
846
- if (err instanceof (0, $7dd1edb2ee2b43ad$export$aa14a9f43128f61f)) {
847
- console.error(err.cause);
848
- message = `${message}: ${err.message}`;
849
- } else $gVhhF$depictaiutilishared.report([err, message_], severity_);
850
- return (() => {
851
- const _el$ = $gVhhF$solidjsweb.getNextElement($edafe91daf3091d7$var$_tmpl$),
852
- _el$2 = _el$.firstChild,
853
- [_el$3, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$2.nextSibling),
854
- _el$4 = _el$3.nextSibling,
855
- [_el$5, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$4.nextSibling);
856
- $gVhhF$solidjsweb.insert(_el$, message, _el$3, _co$);
857
- $gVhhF$solidjsweb.insert(_el$, () => props.on_error_?.(retry), _el$5, _co$2);
858
- $gVhhF$solidjsweb.effect(_$p => $gVhhF$solidjsweb.classList(_el$, Object.fromEntries(props.class_list_?.map(c => [c, true]) || []), _$p));
859
- return _el$;
860
- })();
861
- },
862
- get children() {
863
- return props.children;
864
- }
865
- });
866
- }
867
1005
  const $f48d0fbb00835aaa$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div>`),
868
1006
  $f48d0fbb00835aaa$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<style type=text/css>`);
869
1007
  function $f48d0fbb00835aaa$export$d21e32dfedac04be(props) {
@@ -943,69 +1081,1016 @@ function $f48d0fbb00835aaa$export$445d8d3f5f706a40(props, container_element, ins
943
1081
  const max_rows = rows_or_empty_object().max_rows;
944
1082
  if (!isNaN(max_rows) && max_rows >= 0 && rows_visible > max_rows) set_rows_visible()(max_rows);
945
1083
  });
946
- $gVhhF$solidjs.createEffect(() => set_force_style_update(" ")); // force style update after hydration due to https://discord.com/channels/722131463138705510/722167424186843267/1151544212517552168
947
- $gVhhF$solidjs.createRenderEffect(() => {
948
- // Be careful to only read show_all_rows in here (ofc doesn't apply to nested effects)
949
- if (show_all_rows()) {
950
- // no view more functionality requested
951
- set_styling(() => col_styling);
952
- 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;
953
2057
  }
954
- update_children_count();
955
- if (!(0, $gVhhF$solidjsweb.isServer)) {
956
- const mutation_observer = new MutationObserver($gVhhF$depictaiutilishared.catchify(update_children_count));
957
- mutation_observer.observe(container_element, {
958
- childList: true
959
- });
960
- $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);
961
2070
  }
962
- set_styling(
963
- // this is needed because solid will think that the memo-accessor is a setter function otherwise
964
- () => $gVhhF$solidjs.createMemo(() => {
965
- const {
966
- rows_per_click: rows_per_click,
967
- max_rows = -1,
968
- start_rows: start_rows
969
- } = rows_or_empty_object();
970
- const rows_visible = get_rows_visible();
971
- const children_count = get_children_count();
972
- return force_style_update() + col_styling() + props.cols_at_size.map(options => {
973
- const [recs_per_row, min, max] = options;
974
- let should_hide_view_more_button;
975
- let visible_recs;
976
- if (props.disable_partial_rows) {
977
- visible_recs = $gVhhF$depictaiutilishared.layout_get_visible_recs_without_partial_rows(rows_visible, children_count, options);
978
- const visible_recs_next_show_more = $gVhhF$depictaiutilishared.layout_get_visible_recs_without_partial_rows(rows_visible + (rows_per_click || 0),
979
- // Should this really be zero when we default rows_per_click to 1?
980
- children_count, options);
981
- should_hide_view_more_button = visible_recs === visible_recs_next_show_more;
982
- } else {
983
- visible_recs = $gVhhF$depictaiutilishared.layout_get_total_rec_amount_for_row(rows_visible, options);
984
- should_hide_view_more_button = visible_recs >= children_count;
985
- }
986
- const should_hide_button_final = should_hide_view_more_button || max_rows !== -1 && rows_visible >= max_rows;
987
- // 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
988
- 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;
989
- 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}` : ``}}`;
990
- }).join("");
991
- }));
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();
992
2086
  });
993
- const style_element = (() => {
994
- const _el$4 = $gVhhF$solidjsweb.getNextElement($f48d0fbb00835aaa$var$_tmpl$2);
995
- $gVhhF$solidjsweb.insert(_el$4, get_styling);
996
- return _el$4;
997
- })(); // need to create this after set_styling has been called or else there will be no styling in the SSR'd output
998
- if (insert_after_container) container_element.after(style_element);
999
- return [container_element, $gVhhF$solidjsweb.memo(view_more_button_container), $gVhhF$solidjsweb.memo(view_less_button_container), style_element];
2087
+ return width;
1000
2088
  }
1001
- $gVhhF$solidjsweb.delegateEvents(["click"]);
1002
2089
  const $363ce4d1d71041aa$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<h2 class=recs-title>`);
1003
2090
  function $363ce4d1d71041aa$export$d41d19e89346fa2({
1004
2091
  recommendations_resource_: recommendations_resource_,
1005
2092
  product_card_template_: product_card_template_,
1006
2093
  layout_options_: layout_options_,
1007
- merchant_: merchant_,
1008
- market_: market_,
1009
2094
  title_: title_
1010
2095
  }) {
1011
2096
  const is_showing_something = $gVhhF$solidjs.createMemo(() => recommendations_resource_.loading || recommendations_resource_()?.length);
@@ -1039,203 +2124,35 @@ function $363ce4d1d71041aa$export$d41d19e89346fa2({
1039
2124
  },
1040
2125
  get children() {
1041
2126
  return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Suspense), {
1042
- get fallback() {
1043
- return $0caf87eaa19079da$export$f33414a4df0afd3f({
1044
- num_placeholders_: num_placeholders_,
1045
- product_card_template_: product_card_template_
1046
- });
1047
- },
1048
- get children() {
1049
- return (() => {
1050
- // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
1051
- const displays_by_key_ = $a73063cc642f3e5f$export$7f8bd308237ab5a5($gVhhF$solidjs.createMemo(() => recommendations_resource_() || []));
1052
- return $a73063cc642f3e5f$export$43f0fb951fcb0c54({
1053
- displays_by_key_: displays_by_key_,
1054
- merchant_: merchant_,
1055
- market_: market_,
1056
- product_card_template_: product_card_template_
1057
- });
1058
- })();
1059
- }
1060
- });
1061
- }
1062
- })];
1063
- return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
1064
- get when() {
1065
- return is_showing_something();
1066
- },
1067
- children: slider
1068
- });
1069
- }
1070
- function $95837413165cc2df$export$23fca46f3143581f(component, error_message) {
1071
- const component_in_error_boundary = do_with_elements => {
1072
- const error_boundary_wrapped = $edafe91daf3091d7$export$b69d0d92862de18b({
1073
- severity_: "error",
1074
- message_: error_message,
1075
- get children() {
1076
- const elements = component();
1077
- do_with_elements?.(elements);
1078
- return elements;
1079
- }
1080
- });
1081
- // This might return an accessor, in that case we need to "unwrap" it since our SDK consumers expect HTML elements or arrays thereof
1082
- if (typeof error_boundary_wrapped === "function")
1083
- // @ts-ignore
1084
- return error_boundary_wrapped();
1085
- // On the server it returns a string, so we just return that
1086
- return error_boundary_wrapped;
1087
- };
1088
- const owner = $gVhhF$solidjs.getOwner();
1089
- if (owner == null) return $gVhhF$solidjs.createRoot(dispose => {
1090
- // 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
1091
- return component_in_error_boundary(elements => {
1092
- const have_multiple = Array.isArray(elements);
1093
- if (have_multiple ? !elements?.length : !elements) return;
1094
- (0, $gVhhF$depictaiutilishared.observer).onremoved(have_multiple ? elements[0] : elements, ({
1095
- element: element
1096
- }) => {
1097
- if (document.documentElement.contains(element)) return; // If element has instantly been re-inserted, don't dispose
1098
- // See https://depictaiworkspace.slack.com/archives/C050GHEPBTR/p1695809102791259?thread_ts=1695106805.459729&cid=C050GHEPBTR
1099
- dispose();
1100
- });
1101
- });
1102
- });else
1103
- // we're already in a root so cleanups are handled
1104
- return component_in_error_boundary();
1105
- }
1106
- const $72f96c4782db0b1b$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class="depict recommendations">`);
1107
- function $72f96c4782db0b1b$export$9574e176201e5e8d(props) {
1108
- return $95837413165cc2df$export$23fca46f3143581f(() => {
1109
- const grid_spacing_override = $gVhhF$solidjs.createMemo(() => {
1110
- const {
1111
- grid_spacing: grid_spacing
1112
- } = props; // can be reactive
1113
- return typeof grid_spacing === "string" ? {
1114
- grid_spacing: grid_spacing
1115
- } : {
1116
- override_vertical_spacing: grid_spacing.vertical,
1117
- grid_spacing: grid_spacing.horizontal
1118
- };
1119
- });
1120
- const [recommendations_resource_] = $gVhhF$solidjs.createResource(() => props.recommendations, recs => recs);
1121
- return (() => {
1122
- const _el$ = $gVhhF$solidjsweb.getNextElement($72f96c4782db0b1b$var$_tmpl$);
1123
- $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent((0, $84798aaa863a4909$export$e68cff63f76bd15b), {
1124
- get children() {
1125
- return $363ce4d1d71041aa$export$d41d19e89346fa2({
1126
- product_card_template_: (...args) => props.product_card_template(...args),
1127
- recommendations_resource_: recommendations_resource_,
1128
- market_: () => props.market,
1129
- merchant_: () => props.merchant,
1130
- title_: () => props.title,
1131
- layout_options_: $gVhhF$solidjs.createMemo(() => ({
1132
- cols_at_size: $4e04be41243c3d80$export$6daf8749b65a1b77(props.cols_at_size),
1133
- ...grid_spacing_override()
1134
- }))
1135
- });
1136
- }
1137
- }));
1138
- return _el$;
1139
- })();
1140
- }, "RecommendationSlider failed");
1141
- }
1142
- const $b8e79813f4f7ebe4$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<h2 class=recs-title>`),
1143
- $b8e79813f4f7ebe4$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=recommendation-grid><!$><!/><!$><!/>`);
1144
- function $b8e79813f4f7ebe4$export$7da560f849543dff({
1145
- recommendations_resource_: recommendations_resource_,
1146
- product_card_template_: product_card_template_,
1147
- layout_options_: layout_options_,
1148
- merchant_: merchant_,
1149
- market_: market_,
1150
- rows_object_: rows_object_,
1151
- title_: title_
1152
- }) {
1153
- const is_showing_something = $gVhhF$solidjs.createMemo(() => recommendations_resource_.loading || recommendations_resource_()?.length);
1154
- const title = $gVhhF$solidjs.createMemo(() => title_?.()); // In case getter/accessor creates elements, don't create them twice
1155
- const num_placeholders_ = () => 20;
1156
- const elements = [$gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
1157
- get when() {
1158
- return title();
1159
- },
1160
- get children() {
1161
- const _el$ = $gVhhF$solidjsweb.getNextElement($b8e79813f4f7ebe4$var$_tmpl$);
1162
- $gVhhF$solidjsweb.insert(_el$, title);
1163
- return _el$;
1164
- }
1165
- }), (() => {
1166
- const _el$2 = $gVhhF$solidjsweb.getNextElement($b8e79813f4f7ebe4$var$_tmpl$2),
1167
- _el$3 = _el$2.firstChild,
1168
- [_el$4, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$3.nextSibling),
1169
- _el$5 = _el$4.nextSibling,
1170
- [_el$6, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$5.nextSibling);
1171
- $gVhhF$solidjsweb.insert(_el$2, (0, $fc23d7668ae0011d$export$a2cc176055f8f08), _el$4, _co$);
1172
- $gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $f48d0fbb00835aaa$export$d21e32dfedac04be), $gVhhF$solidjsweb.mergeProps({
1173
- get rows() {
1174
- return rows_object_();
1175
- },
1176
- layout: "grid",
1177
- element_attributes: {
1178
- class: "cards"
1179
- }
1180
- }, layout_options_, {
1181
- get children() {
1182
- return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Suspense), {
1183
- get fallback() {
1184
- return $0caf87eaa19079da$export$f33414a4df0afd3f({
1185
- num_placeholders_: num_placeholders_,
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_,
1186
2139
  product_card_template_: product_card_template_
1187
2140
  });
1188
- },
1189
- get children() {
1190
- return (() => {
1191
- // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
1192
- const displays_by_key_ = $a73063cc642f3e5f$export$7f8bd308237ab5a5($gVhhF$solidjs.createMemo(() => recommendations_resource_() || []));
1193
- return $a73063cc642f3e5f$export$43f0fb951fcb0c54({
1194
- displays_by_key_: displays_by_key_,
1195
- merchant_: merchant_,
1196
- market_: market_,
1197
- product_card_template_: product_card_template_
1198
- });
1199
- })();
1200
- }
1201
- });
1202
- }
1203
- })), _el$6, _co$2);
1204
- return _el$2;
1205
- })()];
2141
+ })();
2142
+ }
2143
+ });
2144
+ }
2145
+ })];
1206
2146
  return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
1207
2147
  get when() {
1208
2148
  return is_showing_something();
1209
2149
  },
1210
- children: elements
2150
+ children: slider
1211
2151
  });
1212
2152
  }
1213
- const $1f8dbf7e28b3eff2$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<button class="show-more major"type=button>`),
1214
- $1f8dbf7e28b3eff2$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class="depict plp recommendations">`);
1215
- function $1f8dbf7e28b3eff2$export$9756467d34d91cdb(props) {
2153
+ const $72f96c4782db0b1b$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class="depict recommendations">`);
2154
+ function $72f96c4782db0b1b$export$9574e176201e5e8d(props) {
1216
2155
  return $95837413165cc2df$export$23fca46f3143581f(() => {
1217
- const rows_object_ = $gVhhF$solidjs.createMemo(() => {
1218
- const {
1219
- view_more_button: view_more_button,
1220
- max_rows: max_rows
1221
- } = props;
1222
- if (!view_more_button) {
1223
- if (max_rows) return {
1224
- max_rows: max_rows
1225
- };
1226
- return "all";
1227
- }
1228
- return {
1229
- max_rows: max_rows,
1230
- start_rows: view_more_button.start_rows,
1231
- rows_per_click: view_more_button.rows_per_click ?? 2,
1232
- button: (() => {
1233
- const _el$ = $gVhhF$solidjsweb.getNextElement($1f8dbf7e28b3eff2$var$_tmpl$);
1234
- $gVhhF$solidjsweb.insert(_el$, () => view_more_button.text);
1235
- return _el$;
1236
- })()
1237
- };
1238
- });
1239
2156
  const grid_spacing_override = $gVhhF$solidjs.createMemo(() => {
1240
2157
  const {
1241
2158
  grid_spacing: grid_spacing
@@ -1249,15 +2166,12 @@ function $1f8dbf7e28b3eff2$export$9756467d34d91cdb(props) {
1249
2166
  });
1250
2167
  const [recommendations_resource_] = $gVhhF$solidjs.createResource(() => props.recommendations, recs => recs);
1251
2168
  return (() => {
1252
- const _el$2 = $gVhhF$solidjsweb.getNextElement($1f8dbf7e28b3eff2$var$_tmpl$2);
1253
- $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), {
1254
2171
  get children() {
1255
- return $b8e79813f4f7ebe4$export$7da560f849543dff({
1256
- rows_object_: rows_object_,
2172
+ return $363ce4d1d71041aa$export$d41d19e89346fa2({
1257
2173
  product_card_template_: (...args) => props.product_card_template(...args),
1258
2174
  recommendations_resource_: recommendations_resource_,
1259
- market_: () => props.market,
1260
- merchant_: () => props.merchant,
1261
2175
  title_: () => props.title,
1262
2176
  layout_options_: $gVhhF$solidjs.createMemo(() => ({
1263
2177
  cols_at_size: $4e04be41243c3d80$export$6daf8749b65a1b77(props.cols_at_size),
@@ -1266,9 +2180,9 @@ function $1f8dbf7e28b3eff2$export$9756467d34d91cdb(props) {
1266
2180
  });
1267
2181
  }
1268
2182
  }));
1269
- return _el$2;
2183
+ return _el$;
1270
2184
  })();
1271
- }, "RecommendationGrid failed");
2185
+ }, "RecommendationSlider failed");
1272
2186
  }
1273
2187
  function $4b455f60dadde8b8$export$5bad61ecde080b1f(...params) {
1274
2188
  const {
@@ -1563,15 +2477,6 @@ function $47e2cc552c02110c$export$8895d39404bd2bb1(props) {
1563
2477
  if (delay_toast_) return show_configured_toast;else show_configured_toast();
1564
2478
  }
1565
2479
  $gVhhF$solidjsweb.delegateEvents(["click"]);
1566
- 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">`);
1567
- function $c77c68e559a1506c$export$3b621d86b1566b2(props = {}) {
1568
- return (() => {
1569
- const _el$ = $gVhhF$solidjsweb.getNextElement($c77c68e559a1506c$var$_tmpl$);
1570
- $gVhhF$solidjsweb.spread(_el$, props, true, true);
1571
- $gVhhF$solidjsweb.runHydrationEvents();
1572
- return _el$;
1573
- })();
1574
- }
1575
2480
 
1576
2481
  /**
1577
2482
  * Lower cases a string if possible. Mostly used to make the filter url values case-insensitive.
@@ -1582,7 +2487,7 @@ function $daa394359b026187$export$325f75597868c4f0(stuff) {
1582
2487
  }
1583
2488
  const $235a2771a44e28e9$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<button class="clear-all-filters minor">`),
1584
2489
  $235a2771a44e28e9$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=inner><span class=title><!$><!/>: </span><!$><!/>`),
1585
- $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} <!$><!/><!$><!/><!$><!/>`),
1586
2491
  $235a2771a44e28e9$var$_tmpl$4 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<button class="clear-filter major"><!$><!/><span>`);
1587
2492
  function $235a2771a44e28e9$export$fecbb157621501bd({
1588
2493
  number_of_rendered_selected_filters_items_: number_of_rendered_selected_filters_items_,
@@ -2755,7 +3660,7 @@ function $5ea5a82e398f6f44$var$cut_text(segmented_text) {
2755
3660
  // identical split point, or split end before split start, can't do anything
2756
3661
  split_start_segment == split_end_segment && split_start_character >= split_end_character || split_start_segment > split_end_segment) return;
2757
3662
  const dots_segment = {
2758
- text_: " … ",
3663
+ text_: " \u2026 ",
2759
3664
  highlighted_: false
2760
3665
  };
2761
3666
  const split_and_dotted_values = segmented_text.flatMap((segment, i) => {
@@ -2847,7 +3752,7 @@ function $5ea5a82e398f6f44$var$cut_start(cut_left_of_index, segmented_text) {
2847
3752
  if (character === "," || is_space)
2848
3753
  // if we cut at a comma or psace, we add a … at the beginning
2849
3754
  segmented_text.unshift({
2850
- text_: "… ",
3755
+ text_: "\u2026 ",
2851
3756
  highlighted_: false
2852
3757
  });
2853
3758
  break outmost_loop;
@@ -3861,7 +4766,7 @@ function $b064919833b3e80b$export$53c59af873b303c9({
3861
4766
  get price_formatting_() {
3862
4767
  return price_formatting_();
3863
4768
  }
3864
- }), $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), {
3865
4770
  get price_() {
3866
4771
  return selected_filter.data[1];
3867
4772
  },
@@ -3951,47 +4856,6 @@ function $8c939a05b87fbbbc$export$ab34afce88557c0e(props) {
3951
4856
  }));
3952
4857
  return is_open;
3953
4858
  }
3954
- const $9fe9883b1d8ecccc$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span>`);
3955
- function $9fe9883b1d8ecccc$export$acb3eaade4b23afd(props) {
3956
- return (() => {
3957
- const _el$ = $gVhhF$solidjsweb.getNextElement($9fe9883b1d8ecccc$var$_tmpl$);
3958
- $gVhhF$solidjsweb.effect(_p$ => {
3959
- const _v$ = `depict-placeholder ${props.class || ""}`,
3960
- _v$2 = props.style;
3961
- _v$ !== _p$._v$ && $gVhhF$solidjsweb.className(_el$, _p$._v$ = _v$);
3962
- _p$._v$2 = $gVhhF$solidjsweb.style(_el$, _v$2, _p$._v$2);
3963
- return _p$;
3964
- }, {
3965
- _v$: undefined,
3966
- _v$2: undefined
3967
- });
3968
- return _el$;
3969
- })();
3970
- }
3971
- function $061ff5b4c3d36171$export$89c6019e4baa40b1(props) {
3972
- const style = $gVhhF$solidjs.createMemo(() => {
3973
- const {
3974
- style: style,
3975
- height: height,
3976
- width: width
3977
- } = props;
3978
- return {
3979
- ...(style || {}),
3980
- height: height ?? "1em",
3981
- ...(width && {
3982
- width: width
3983
- })
3984
- };
3985
- });
3986
- return $gVhhF$solidjsweb.createComponent((0, $9fe9883b1d8ecccc$export$acb3eaade4b23afd), {
3987
- get style() {
3988
- return style();
3989
- },
3990
- get ["class"]() {
3991
- return props.class;
3992
- }
3993
- });
3994
- }
3995
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">`);
3996
4860
  function $87d7574e1d89d69b$export$82eafebb825fc23f(props = {}) {
3997
4861
  return (() => {
@@ -4546,150 +5410,33 @@ function $70482f04605572e2$var$modify_only_local_filter(local_filter_object, sel
4546
5410
  }
4547
5411
  return modified_filter_object;
4548
5412
  }
4549
- async function $9abb0a35d4b60ed3$export$79b1565500412d9b(search_modal, modal_fn_opts, parent) {
4550
- const body = parent || (await (0, $gVhhF$depictaiutilishared.observer).wait_for_element("body"));
4551
- let dispose_and_remove;
4552
- const open_modal_ = (extra_options_for_modal = {}, on_dispose) => {
4553
- if (dispose_and_remove)
4554
- // modal is already open
4555
- return;
4556
- const modal_els = $gVhhF$solidjs.createRoot(dispose => {
4557
- let closing_animation;
4558
- let animation_started;
4559
- dispose_and_remove = () => {
4560
- const actually_close = () => {
4561
- dispose();
4562
- on_dispose?.();
4563
- modal_els.forEach(el => el.remove());
4564
- };
4565
- if (animation_started && +new Date() - animation_started > 1000)
4566
- // Animation broke, close it this time
4567
- actually_close();else if (!animation_started && closing_animation) {
4568
- animation_started = +new Date();
4569
- $gVhhF$depictaiutilishared.catchify(closing_animation)()?.then($gVhhF$depictaiutilishared.catchify(actually_close));
4570
- } else actually_close();
4571
- };
4572
- return search_modal({
4573
- ...modal_fn_opts,
4574
- ...extra_options_for_modal,
4575
- close_modal_: close_modal_,
4576
- open_modal_: open_modal_,
4577
- register_closing_animation_: animation => closing_animation = animation
4578
- });
4579
- });
4580
- body.append(...modal_els);
4581
- };
4582
- const close_modal_ = () => {
4583
- if (dispose_and_remove) {
4584
- // modal is open
4585
- const dispose_fn = dispose_and_remove;
4586
- // 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
4587
- dispose_and_remove = undefined;
4588
- dispose_fn();
4589
- }
4590
- };
4591
- return {
4592
- open_modal_: open_modal_,
4593
- close_modal_: close_modal_
4594
- };
4595
- }
4596
- async function $bc91d938b8c601b4$export$58e808b1db15d3bc({
4597
- merchant: merchant,
4598
- market: market,
4599
- headers: headers,
4600
- ...fetch_recs_options
4601
- }) {
4602
- return await $gVhhF$depictaiutilishared.fetch_recs({
4603
- tenant: merchant,
4604
- market: market
4605
- }, $gVhhF$depictaiutilishared.snakeCasifyObject(fetch_recs_options), headers);
4606
- }
4607
- function $6e22b5314fb52f4c$export$e183a13865960371(params_to_default_value, router_) {
4608
- const signals = {};
4609
- const entries = Object.entries(params_to_default_value);
4610
- const event_handler = $gVhhF$depictaiutilishared.catchify((what_happened, args) => {
4611
- // 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
4612
- if (what_happened !== "popstate") return;
4613
- // 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.
4614
- // If we want others to interface with our state, it's better to expose it from DepictCategory/DepictSearch
4615
- // 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)
4616
- // And can infinite loop, like in https://app.jiminny.com/playback/569c8f65-edea-4735-bd9e-4eb5a0b14cad
4617
- // It's the classical equilibrium problem when syncing state both down and up, and it's much easier to avoid than solve
4618
- $6e22b5314fb52f4c$var$history_state_change(signals, entries, args.state);
4619
- });
4620
- // createRenderEffect because we need the instant execution so the signals always contain values, even before solid's render phase
4621
- $gVhhF$solidjs.createRenderEffect(() => {
4622
- let signal_changed = false;
4623
- let {
4624
- state: state
4625
- } = globalThis?.history || {
4626
- state: {}
4627
- }; // cloning isn't necessary because we're calling replaceState on it anyway
4628
- if (state === null || typeof state != "object") state = {};
4629
- for (const [param, default_value] of entries) {
4630
- const [read_signal] = signals[param] ||= $gVhhF$solidjs.createSignal(state[param] ?? default_value);
4631
- const new_value = read_signal();
4632
- if (new_value !== state[param]) {
4633
- signal_changed = true;
4634
- state[param] = new_value;
4635
- }
4636
- }
4637
- if (signal_changed) router_.navigate_.replace_state_(state);
4638
- });
4639
- // 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
4640
- (0, $gVhhF$depictaiutilishared.instant_exec_on_suspect_history_change).add(event_handler);
4641
- $gVhhF$solidjs.onCleanup($gVhhF$depictaiutilishared.catchify(() => (0, $gVhhF$depictaiutilishared.instant_exec_on_suspect_history_change).delete(event_handler)));
4642
- $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
4643
- return signals;
4644
- }
4645
- function $6e22b5314fb52f4c$var$history_state_change(signals, entries, state) {
4646
- $gVhhF$solidjs.batch(() => {
4647
- for (const [param, default_value] of entries) {
4648
- const [, write_signal] = signals[param];
4649
- const new_value = state?.[param];
4650
- write_signal(new_value ?? default_value);
4651
- }
4652
- });
4653
- }
4654
- const $d84fe647b84b5dc5$export$3064e1e8c6513da3 = new Set();
4655
- let $d84fe647b84b5dc5$var$has_ran = false;
4656
- function $d84fe647b84b5dc5$export$5162a71f252e6122() {
4657
- if ($d84fe647b84b5dc5$var$has_ran || typeof history !== "object") return;
4658
- $d84fe647b84b5dc5$var$has_ran = true;
4659
- for (const function_name of ["replaceState", "pushState"]) {
4660
- if (Object.getOwnPropertyNames(history).includes(function_name)) $d84fe647b84b5dc5$var$proxy_push_state(function_name, history);
4661
- $d84fe647b84b5dc5$var$proxy_push_state(function_name, History.prototype);
4662
- }
4663
- }
4664
- function $d84fe647b84b5dc5$var$proxy_push_state(function_name, thing) {
4665
- thing[function_name] = new Proxy(thing[function_name], {
4666
- apply(target, this_arg, arg_list) {
4667
- try {
4668
- const old_state = history.state;
4669
- if (typeof old_state == "object" && old_state !== null) {
4670
- // This effectively disallows the user from passing in a string, number, null or undefined
4671
- const intended_new_value_as_obj = typeof arg_list[0] === "object" ? arg_list[0] ?? {} : {};
4672
- const cloned_object = {
4673
- ...intended_new_value_as_obj
4674
- };
4675
- for (const key in old_state) {
4676
- if (!$d84fe647b84b5dc5$var$starts_with_any_prefix(key)) continue;
4677
- if (!(key in cloned_object)) cloned_object[key] = old_state[key];
4678
- }
4679
- arg_list[0] = cloned_object;
4680
- }
4681
- } catch (e) {
4682
- $gVhhF$depictaiutilishared.report([e, "Failed to preserve items in history.state"], "error");
4683
- }
4684
- 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);
4685
5436
  }
5437
+ return decoded?.displays || [];
4686
5438
  });
4687
5439
  }
4688
- function $d84fe647b84b5dc5$var$starts_with_any_prefix(key) {
4689
- for (const prefix of $d84fe647b84b5dc5$export$3064e1e8c6513da3) {
4690
- if (key.startsWith(prefix)) return true;
4691
- }
4692
- }
4693
5440
  function $26a56f6b44703084$export$9862539c89138352({
4694
5441
  get_default_values_: get_default_values_,
4695
5442
  router_: router_,
@@ -4745,8 +5492,8 @@ function $67dc366d96177e70$export$967e966fca9515e(api_response) {
4745
5492
  }
4746
5493
  return api_response;
4747
5494
  }
4748
- const $e1d6c0f3d89d531c$var$v2_base_url = (0, $gVhhF$depictaiutilishared.base_url) + "/v2/";
4749
- 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/";
4750
5497
  class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
4751
5498
  #supports_finalization_registry = typeof FinalizationRegistry === "function";
4752
5499
  #cache_objs = {};
@@ -4765,18 +5512,14 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
4765
5512
  const request = {
4766
5513
  ...input_req
4767
5514
  };
4768
- request.dsid ??= $gVhhF$depictaiutilishared.get_depict_id();
4769
- // Todo: remove the default user and session IDs once we've confirmed backend can handle it and do whatever fallback is necessary.
4770
- request.user_id ??= this.#get_user_id?.() || $gVhhF$depictaiutilishared.get_user_id();
4771
5515
  request.session_id ??= this.#get_session_id?.() || $gVhhF$depictaiutilishared.get_session_id();
4772
5516
  return request;
4773
5517
  };
4774
5518
  #get_metadata;
4775
- #get_user_id;
4776
5519
  #get_session_id;
4777
5520
  #guard_url_creator_length(expected, received) {
4778
5521
  if (expected.length !== received.length) {
4779
- 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);
4780
5523
  queueMicrotask(() => {
4781
5524
  throw e;
4782
5525
  });
@@ -4813,8 +5556,9 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
4813
5556
  const category_transformer = display_transformers?.categories;
4814
5557
  const content_result_transformer = display_transformers?.contentResults;
4815
5558
  const displays = input_data.displays;
5559
+ const owner = $gVhhF$solidjs.getOwner();
4816
5560
  const {
4817
- breadcrumb: breadcrumb,
5561
+ breadcrumbs: breadcrumbs,
4818
5562
  quick_links: quick_links,
4819
5563
  content_search_links: content_search_links
4820
5564
  } = input_data;
@@ -4843,40 +5587,48 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
4843
5587
  displays[i] = new_display_or_page_url;
4844
5588
  }
4845
5589
  }
4846
- 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]) {
4847
5591
  if (!category_display_array) continue;
4848
- const page_urls = await (page_url_creator || category_transformer)({
5592
+ const page_urls = await $gVhhF$solidjs.runWithOwner(owner, () => (page_url_creator || category_transformer)({
4849
5593
  merchant: merchant,
4850
5594
  market: market,
4851
5595
  data: [...category_display_array],
4852
5596
  ...(page_url_creator ? {
4853
5597
  type: "categories"
4854
5598
  } : {})
4855
- });
5599
+ }));
4856
5600
  this.#guard_url_creator_length(category_display_array, page_urls);
4857
5601
  for (let i = 0; i < category_display_array.length; i++)
4858
5602
  // Copy over getters so we sneakily can make this reactive
4859
5603
  Object.defineProperties(category_display_array[i], Object.getOwnPropertyDescriptors(page_urls[i]));
4860
5604
  }
4861
5605
  if (content_search_links?.length && content_result_transformer) {
4862
- const result = await content_result_transformer({
5606
+ const result = await $gVhhF$solidjs.runWithOwner(owner, () => content_result_transformer({
4863
5607
  merchant: merchant,
4864
5608
  market: market,
4865
5609
  data: [...content_search_links]
4866
- });
5610
+ }));
4867
5611
  this.#guard_url_creator_length(content_search_links, result);
4868
5612
  input_data.content_search_links = result;
4869
5613
  }
4870
5614
  return input_data;
4871
5615
  }
4872
- async #cached_post_request(endpoint, input_req, fallback_response) {
4873
- const cache_obj = this.#get_cache_obj_for_endpoint(endpoint);
4874
- 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();
4875
5626
  const metaData = await this.#get_metadata?.();
4876
5627
  const request = metaData ? Object.assign(with_ids, {
4877
5628
  metadata: metaData
4878
5629
  }) : with_ids;
4879
- 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);
4880
5632
  const response_from_cache = cache_obj.cache_[body]?.deref?.();
4881
5633
  if (response_from_cache) return response_from_cache;
4882
5634
  const in_progress_request = cache_obj.in_progress_[body];
@@ -4884,18 +5636,23 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
4884
5636
  let resolve_in_progress;
4885
5637
  cache_obj.in_progress_[body] = new Promise(r => resolve_in_progress = r);
4886
5638
  try {
4887
- const api_response = await $gVhhF$depictaiutilishared.fetch_retry($gVhhF$depictaiutilishared.add_version_query_params(endpoint), {
4888
- method: "POST",
4889
- 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
+ } : {})
4890
5647
  });
4891
5648
  return_successfully: {
4892
5649
  if (!api_response || api_response.status !== 200) break return_successfully;
4893
5650
  let result;
4894
5651
  try {
4895
5652
  const unmodified_result = await api_response.json();
4896
- 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));
4897
5654
  } catch (e) {
4898
- $gVhhF$depictaiutilishared.dwarn("URL creator or json decoding failed", e);
5655
+ $gVhhF$depictaiutilishared.dwarn("displayTransformer or json decoding failed", e);
4899
5656
  break return_successfully;
4900
5657
  }
4901
5658
  // Here result actually becomes O
@@ -4913,7 +5670,7 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
4913
5670
  return result;
4914
5671
  }
4915
5672
  // If we get here, the request failed
4916
- const retval = fallback_response(input_req);
5673
+ const retval = fallback_response_(input_req_);
4917
5674
  resolve_in_progress(retval);
4918
5675
  return retval;
4919
5676
  } finally {
@@ -4923,19 +5680,18 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
4923
5680
  constructor(options) {
4924
5681
  const {
4925
5682
  get_metadata: get_metadata,
4926
- get_user_id: get_user_id,
4927
5683
  get_session_id: get_session_id,
4928
5684
  page_url_creator: page_url_creator,
4929
5685
  display_transformers: display_transformers
4930
5686
  } = options ?? {};
4931
5687
  this.#get_metadata = get_metadata;
4932
- this.#get_user_id = get_user_id;
4933
5688
  this.#get_session_id = get_session_id;
4934
5689
  this.page_url_creator = page_url_creator;
4935
5690
  this.display_transformers = display_transformers;
4936
5691
  }
4937
5692
  async suggest(input_req) {
4938
5693
  const with_ids = this.#add_ids_to_request(input_req);
5694
+ const owner = $gVhhF$solidjs.getOwner();
4939
5695
  const metaData = await this.#get_metadata?.();
4940
5696
  const request = metaData ? Object.assign(with_ids, {
4941
5697
  metadata: JSON.stringify(metaData)
@@ -4947,9 +5703,9 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
4947
5703
  const decoded_json = await results.json();
4948
5704
  if (!Array.isArray(decoded_json?.suggestions)) break attempt_to_return_api_response;
4949
5705
  try {
4950
- 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));
4951
5707
  } catch (e) {
4952
- $gVhhF$depictaiutilishared.dwarn("URL creator failed", e);
5708
+ $gVhhF$depictaiutilishared.dwarn("displayTransformer failed", e);
4953
5709
  }
4954
5710
  }
4955
5711
  return {
@@ -4959,31 +5715,67 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
4959
5715
  };
4960
5716
  }
4961
5717
  async query(input_req) {
4962
- return await this.#cached_post_request($e1d6c0f3d89d531c$var$search_base_url + "results", input_req, () => ({
4963
- "n_hits": 0,
4964
- "displays": [],
4965
- "sorts": [],
4966
- "filters": [],
4967
- "search_request_id": "error",
4968
- failed: true
4969
- }));
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
+ });
4970
5730
  }
4971
- async list(input_req) {
4972
- return await this.#cached_post_request($e1d6c0f3d89d531c$var$v2_base_url + "product-listing", input_req, () => ({
4973
- "n_hits": 0,
4974
- "displays": [],
4975
- "sorts": [],
4976
- "filters": [],
4977
- "breadcrumb": [],
4978
- "quick_links": [],
4979
- "product_listing_request_id": "error",
4980
- failed: true
4981
- }));
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
+ });
4982
5770
  }
4983
5771
  async get_recommended(input_req) {
4984
- return await this.#cached_post_request($e1d6c0f3d89d531c$var$search_base_url + "related", input_req, () => ({
4985
- displays: []
4986
- }));
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
+ });
4987
5779
  }
4988
5780
  }
4989
5781
  function $b54e6192d0caa293$export$d9f36cf74e24d595(media_query) {
@@ -5082,7 +5874,7 @@ function $76b6ac05693f5c71$export$205efb947c7ffd78(handler, passive = true) {
5082
5874
  $gVhhF$solidjs.onCleanup(() => removeEventListener(event, catchified_handler));
5083
5875
  }
5084
5876
  }
5085
- 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>`);
5086
5878
  function $401aee5f33dca9e2$export$83fd5de5504a7a67({
5087
5879
  formatted_number_of_results_: formatted_number_of_results_,
5088
5880
  first_result_in_viewport_: [get_first_result_in_viewport],
@@ -5304,7 +6096,7 @@ function $3f08fe2992a2a8ca$export$5e4aed86c12acdd9({
5304
6096
  // After first load, always just load 20 since people might just be browsing the top ones still
5305
6097
  min_products_to_fetch_ : now - last_loaded < 10000 ? min_products_to_fetch_ * 5 : min_products_to_fetch_;
5306
6098
  // dlog("loading ", number_of_results_to_load, "products, because it was", now - last_loaded, "ms since last load");
5307
- 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"]({
5308
6100
  cursor: get_last_cursor(),
5309
6101
  limit: number_of_results_to_load,
5310
6102
  ...base_part
@@ -5367,8 +6159,6 @@ function $ac167f6af6a48fc3$export$a1fd619a4743ca08({
5367
6159
  product_card_template_: product_card_template_,
5368
6160
  first_result_in_viewport_: [, set_first_result_in_viewport],
5369
6161
  last_result_in_viewport_: [get_last_result_in_viewport_, set_last_result_in_viewport],
5370
- merchant_: merchant_,
5371
- market_: market_,
5372
6162
  all_products_loaded_: all_products_loaded_,
5373
6163
  min_products_to_fetch_: min_products_to_fetch_,
5374
6164
  query_base_: query_base_,
@@ -5420,8 +6210,6 @@ function $ac167f6af6a48fc3$export$a1fd619a4743ca08({
5420
6210
  });
5421
6211
  return $a73063cc642f3e5f$export$43f0fb951fcb0c54({
5422
6212
  displays_by_key_: displays_by_key_,
5423
- merchant_: merchant_,
5424
- market_: market_,
5425
6213
  product_card_template_: product_card_template_,
5426
6214
  content_blocks_: content_blocks_,
5427
6215
  do_per_elements_: (elements, index_accessor) =>
@@ -5577,37 +6365,6 @@ function $055384b985678603$export$a79e666719b3647c(cols_at_size_) {
5577
6365
  });
5578
6366
  return n_cols_currently_showing;
5579
6367
  }
5580
- function $3bc4a89b971a3af5$export$3f37af283f8fb843(props) {
5581
- const style = $gVhhF$solidjs.createMemo(() => {
5582
- const {
5583
- style: style,
5584
- height: height,
5585
- width: width,
5586
- aspectRatio: aspectRatio
5587
- } = props;
5588
- const is_image = aspectRatio != undefined;
5589
- const size_data = is_image ? {
5590
- width: "100%",
5591
- "padding-bottom": 1 / aspectRatio * 100 + "%"
5592
- } : {
5593
- width: width,
5594
- height: height
5595
- };
5596
- return {
5597
- display: "block",
5598
- ...(style || {}),
5599
- ...size_data
5600
- };
5601
- });
5602
- return $gVhhF$solidjsweb.createComponent((0, $9fe9883b1d8ecccc$export$acb3eaade4b23afd), {
5603
- get style() {
5604
- return style();
5605
- },
5606
- get ["class"]() {
5607
- return props.class;
5608
- }
5609
- });
5610
- }
5611
6368
  const $d92f338ba8f9da9b$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=content-block-wrapper>`);
5612
6369
  function $d92f338ba8f9da9b$export$791ef57e62e21c3f({
5613
6370
  content_blocks_: incoming_content_blocks,
@@ -5818,8 +6575,6 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
5818
6575
  }) {
5819
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
5820
6577
  const is_loading_ = $gVhhF$solidjs.createMemo(() => plp_results_.loading || query_base_.loading);
5821
- const merchant_ = $gVhhF$solidjs.createMemo(() => query_base_().tenant);
5822
- const market_ = $gVhhF$solidjs.createMemo(() => query_base_().market);
5823
6578
  const has_no_results_or_failed = $gVhhF$solidjs.createMemo(() => {
5824
6579
  const displays = plp_results_()?.displays;
5825
6580
  return !is_loading_() && (!Array.isArray(displays) || !displays.length);
@@ -5933,8 +6688,6 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
5933
6688
  plp_results_: plp_results_,
5934
6689
  last_result_in_viewport_: last_result_in_viewport_,
5935
6690
  first_result_in_viewport_: first_result_in_viewport_,
5936
- market_: market_,
5937
- merchant_: merchant_,
5938
6691
  all_products_loaded_: all_products_loaded_,
5939
6692
  min_products_to_fetch_: min_products_to_fetch_,
5940
6693
  query_base_: query_base_,
@@ -6113,42 +6866,6 @@ function $be89be42ce9ea60f$export$1f1775a58da589b5({
6113
6866
  }
6114
6867
  });
6115
6868
  }
6116
- function $ca1176b694a6ee2e$export$fe334901e8bebd57() {
6117
- const cleanup_fns = [];
6118
- const cleanup = () => cleanup_fns.forEach(f => f());
6119
- // use an animation to automatically retain the `overflow` values and all other styling
6120
- for (const element of [document.documentElement, document.body]) {
6121
- try {
6122
- const animation = element.animate({
6123
- overflow: "hidden",
6124
- offset: 0
6125
- }, 1);
6126
- animation.pause();
6127
- const fn = $gVhhF$depictaiutilishared.catchify(animation.play.bind(animation));
6128
- cleanup_fns.push(fn);
6129
- $gVhhF$solidjs.onCleanup(fn);
6130
- } catch (e) {
6131
- $gVhhF$depictaiutilishared.dlog("Probably partial keyframe error", e);
6132
- }
6133
- if (getComputedStyle(element).overflow !== "hidden") {
6134
- // safari gets special hacky treatment
6135
- const style = element.style;
6136
- const original_value = style.overflow;
6137
- style.overflow = "hidden";
6138
- const fn = $gVhhF$depictaiutilishared.catchify(() => style.overflow = original_value);
6139
- cleanup_fns.push(fn);
6140
- $gVhhF$solidjs.onCleanup(fn);
6141
- }
6142
- }
6143
- return cleanup;
6144
- } // the way that houdini does that (FYI) it fixes the page jumps
6145
- // const from_top = scrollY;
6146
- // document.body.style.position = "fixed";
6147
- // document.body.style.left = 0;
6148
- // document.body.style.right = 0;
6149
- // document.body.style.top = `-${from_top}px`;
6150
- // document.body.style.overflowY = "scroll";
6151
-
6152
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">`);
6153
6870
  function $f958b5ac0e4a78da$export$da32f7add8a22e86(props = {}) {
6154
6871
  return (() => {
@@ -6987,7 +7704,6 @@ function $e53b2e7e632ac4cb$export$5646050d516e06bc({
6987
7704
  }) {
6988
7705
  const placeholder_crumb_data = [,,,];
6989
7706
  const crumb_data = $gVhhF$solidjs.createMemo(() => get_api_crumb_data() || placeholder_crumb_data);
6990
- const href_accessor = $gVhhF$depictaiutilishared.use_href_accessor();
6991
7707
  return $gVhhF$solidjsweb.createComponent((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
6992
7708
  severity_: "error",
6993
7709
  message_: "BreadCrumbs failed",
@@ -6998,11 +7714,11 @@ function $e53b2e7e632ac4cb$export$5646050d516e06bc({
6998
7714
  return crumb_data();
6999
7715
  },
7000
7716
  children: (display_accessor, index) => {
7001
- const is_last = $gVhhF$solidjs.createMemo(() => index === crumb_data()?.length - 1);
7002
- const url = $gVhhF$solidjs.createMemo(() => is_last() ? href_accessor() : display_accessor()?.page_url);
7003
7717
  const href = $gVhhF$solidjs.createMemo(() => $1ab22f2cd39b3061$export$43cd1e747fecd42e({
7004
- to_url_: url(),
7005
- filter_query_param_prefix_: filter_query_param_prefix_,
7718
+ to_url_: display_accessor()?.page_url,
7719
+ filter_query_param_prefix_:
7720
+ // page_url here can be a getter if that was added in the display transformers as a way of making this reactive
7721
+ filter_query_param_prefix_,
7006
7722
  sorting_query_param_: sorting_query_param_
7007
7723
  }));
7008
7724
  return [$gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
@@ -7022,7 +7738,7 @@ function $e53b2e7e632ac4cb$export$5646050d516e06bc({
7022
7738
  is_replace_: false,
7023
7739
  event_: ev,
7024
7740
  force_spa_navigation_: true,
7025
- category_query_id_: display_accessor()?.query_id
7741
+ listing_id_: display_accessor()?.listing_id
7026
7742
  })), true);
7027
7743
  $gVhhF$solidjsweb.insert(_el$2, () => display_accessor().title);
7028
7744
  $gVhhF$solidjsweb.effect(() => $gVhhF$solidjsweb.setAttribute(_el$2, "href", href()));
@@ -7053,42 +7769,42 @@ const $8cceb1d3a967f369$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<n
7053
7769
  function $8cceb1d3a967f369$export$466cdc317043f6cb({
7054
7770
  quicklinks_data_: quicklinks_data_,
7055
7771
  router_: router_,
7056
- current_query_id_: current_query_id_,
7772
+ current_listing_id_: current_listing_id_,
7057
7773
  breadcrumb_data_: breadcrumb_data_,
7058
7774
  i18n_: i18n_,
7059
7775
  sorting_query_param_: sorting_query_param_,
7060
7776
  filter_query_param_prefix_: filter_query_param_prefix_
7061
7777
  }) {
7062
- let scrolling_logic_ran_for_query_id = false;
7778
+ let scrolling_logic_ran_for_listing_id = false;
7063
7779
  let last_scroll_position;
7064
7780
  let scroll_to_element_on_dom_insertion;
7065
7781
  let last_was_placeholder = false;
7066
7782
  let sliding_element;
7067
7783
  $gVhhF$solidjs.createComputed(() => {
7068
- current_query_id_();
7069
- scrolling_logic_ran_for_query_id = false;
7784
+ current_listing_id_();
7785
+ scrolling_logic_ran_for_listing_id = false;
7070
7786
  });
7071
7787
  const place_holdey_quicklinks_data = $gVhhF$solidjs.createMemo(() => quicklinks_data_() || [,,,]);
7072
- const selected_index = $gVhhF$solidjs.createMemo(() => quicklinks_data_()?.findIndex(item => item.query_id === current_query_id_())); // this will be -1 when viewing child categories
7073
- const scrollpos_per_queryid = {};
7788
+ const selected_index = $gVhhF$solidjs.createMemo(() => quicklinks_data_()?.findIndex(item => item.listing_id === current_listing_id_())); // this will be -1 when viewing child categories
7789
+ const scrollpos_per_listing_id = {};
7074
7790
  const mutation_plugins = [function () {
7075
- if (!scrolling_logic_ran_for_query_id) return;
7791
+ if (!scrolling_logic_ran_for_listing_id) return;
7076
7792
  const {
7077
7793
  scrollLeft: scrollLeft
7078
7794
  } = this.insert_here;
7079
7795
  if (scrollLeft > 0) {
7080
7796
  last_scroll_position = scrollLeft;
7081
- const current_id = $gVhhF$solidjs.untrack(current_query_id_);
7797
+ const current_id = $gVhhF$solidjs.untrack(current_listing_id_);
7082
7798
  // make sure to not save position where selected item isn't in viewport
7083
7799
  const current_selected_index = $gVhhF$solidjs.untrack(selected_index);
7084
7800
  const intersecting_thing = this.intersecting_items_object[current_selected_index];
7085
- 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)
7801
+ 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)
7086
7802
  // if about to go out of view, stop saving it so that the "always show new things in view" thing can get to work
7087
- delete scrollpos_per_queryid[current_id];
7803
+ delete scrollpos_per_listing_id[current_id];
7088
7804
  }
7089
7805
  }];
7090
7806
  $gVhhF$solidjs.createComputed(() => {
7091
- if (place_holdey_quicklinks_data()?.[0]?.query_id) {
7807
+ if (place_holdey_quicklinks_data()?.[0]?.listing_id) {
7092
7808
  if (last_was_placeholder) queueMicrotask($gVhhF$depictaiutilishared.catchify(() => {
7093
7809
  sliding_element?.scrollTo({
7094
7810
  left: 0
@@ -7141,13 +7857,13 @@ function $8cceb1d3a967f369$export$466cdc317043f6cb({
7141
7857
  equals: false
7142
7858
  }), new_data => {
7143
7859
  const quicklinks_data = quicklinks_data_(); // this signal should have updated by now since this is a createEffect
7144
- const current_id = current_query_id_();
7860
+ const current_id = current_listing_id_();
7145
7861
  if (!new_data || !quicklinks_data || !current_id) return;
7146
7862
  const owner = $gVhhF$solidjs.getOwner();
7147
7863
  queueMicrotask(() => {
7148
7864
  // has to be in microtask so that elements have rendered and are scroll-to-able
7149
- scrolling_logic_ran_for_query_id = true;
7150
- const saved_scroll_position = scrollpos_per_queryid[current_id];
7865
+ scrolling_logic_ran_for_listing_id = true;
7866
+ const saved_scroll_position = scrollpos_per_listing_id[current_id];
7151
7867
  if (saved_scroll_position) {
7152
7868
  insert_here.scrollTo({
7153
7869
  left: saved_scroll_position
@@ -7189,10 +7905,10 @@ function $8cceb1d3a967f369$export$466cdc317043f6cb({
7189
7905
  // Problem: When you don't open a link in a new tab, we don't display the filter cleared toast
7190
7906
  // 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
7191
7907
  const is_sibling = $gVhhF$solidjs.createMemo(() => {
7192
- const current_id = current_query_id_();
7908
+ const current_id = current_listing_id_();
7193
7909
  return quicklinks_data_()?.some(({
7194
- query_id: query_id
7195
- }) => query_id === current_id);
7910
+ listing_id: listing_id
7911
+ }) => listing_id === current_id);
7196
7912
  });
7197
7913
  const href = $gVhhF$solidjs.createMemo(() =>
7198
7914
  // 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
@@ -7213,7 +7929,7 @@ function $8cceb1d3a967f369$export$466cdc317043f6cb({
7213
7929
  is_replace_: false,
7214
7930
  event_: ev,
7215
7931
  force_spa_navigation_: true,
7216
- category_query_id_: display_accessor()?.query_id
7932
+ listing_id_: display_accessor()?.listing_id
7217
7933
  });
7218
7934
  }), true);
7219
7935
  $gVhhF$solidjsweb.insert(_el$3, () => display_accessor()?.title || $gVhhF$solidjsweb.createComponent((0, $061ff5b4c3d36171$export$89c6019e4baa40b1), {
@@ -7311,10 +8027,12 @@ async function $276380e4607fb9fb$export$cc42dd29bf655ab6({
7311
8027
  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.
7312
8028
  if (total_products_to_fetch <= $276380e4607fb9fb$var$api_max_products_per_request) return await make_request_(total_products_to_fetch);
7313
8029
  const displays = [];
8030
+ const owner = $gVhhF$solidjs.getOwner();
7314
8031
  let last_response;
7315
8032
  let next_cursor;
7316
8033
  for (let fetch_this_time = $276380e4607fb9fb$var$api_max_products_per_request; displays.length < total_products_to_fetch;) {
7317
- last_response = await make_request_(fetch_this_time, next_cursor);
8034
+ // Carry over the request when making the owner so that display transformers can use onCleanup
8035
+ last_response = await $gVhhF$solidjs.runWithOwner(owner, () => make_request_(fetch_this_time, next_cursor));
7318
8036
  const new_displays = last_response.displays;
7319
8037
  displays.push(...new_displays);
7320
8038
  next_cursor = last_response.cursor;
@@ -7368,7 +8086,7 @@ let $0b6e2070a98de347$export$44dad306455dddf;
7368
8086
  })($0b6e2070a98de347$export$44dad306455dddf || ($0b6e2070a98de347$export$44dad306455dddf = {}));
7369
8087
  function $ef972f5c10b1c5b4$export$3945d6db2dfd3d12({
7370
8088
  crumb_data_: crumb_data_,
7371
- query_id_: query_id_,
8089
+ listing_id_: listing_id_,
7372
8090
  i18n_: i18n_,
7373
8091
  selected_filters_: selected_filters_,
7374
8092
  local_filter_cache_: local_filter_cache_,
@@ -7387,15 +8105,15 @@ function $ef972f5c10b1c5b4$export$3945d6db2dfd3d12({
7387
8105
  });
7388
8106
  // Code below is for when we're already open and the user navigates to a new category
7389
8107
  let previous_crumb_data = $gVhhF$solidjs.untrack(crumb_data_);
7390
- let query_id_when_we_got_previous_data = $gVhhF$solidjs.untrack(query_id_);
8108
+ let listing_id_when_we_got_previous_data = $gVhhF$solidjs.untrack(listing_id_);
7391
8109
  let allow_filter_clearing = true; // set to false when going backwards/forwards
7392
8110
  // temporarily disable filter clearing when going backwards/forwards
7393
8111
  const handler = () => allow_filter_clearing = false;
7394
8112
  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
7395
8113
  $gVhhF$solidjs.onCleanup(() => window.removeEventListener("popstate", handler));
7396
8114
  $gVhhF$solidjs.createEffect($gVhhF$solidjs.on(crumb_data_, $gVhhF$depictaiutilishared.catchify(new_crumb_data => {
7397
- const query_id_of_new_data = query_id_();
7398
- if (allow_filter_clearing && previous_crumb_data && new_crumb_data && query_id_of_new_data !== query_id_when_we_got_previous_data) {
8115
+ const listing_id_of_new_data = listing_id_();
8116
+ if (allow_filter_clearing && previous_crumb_data && new_crumb_data && listing_id_of_new_data !== listing_id_when_we_got_previous_data) {
7399
8117
  const previous_length = previous_crumb_data.length;
7400
8118
  const new_length = new_crumb_data.length;
7401
8119
  const went_upwards = new_length < previous_length;
@@ -7403,8 +8121,8 @@ function $ef972f5c10b1c5b4$export$3945d6db2dfd3d12({
7403
8121
  const shorter_array = went_upwards ? new_crumb_data : previous_crumb_data;
7404
8122
  const longer_array = went_upwards ? previous_crumb_data : new_crumb_data;
7405
8123
  if (!((went_upwards || went_downwards) && shorter_array.every(({
7406
- query_id: query_id
7407
- }, index) => longer_array[index].query_id === query_id))) {
8124
+ listing_id: listing_id
8125
+ }, index) => longer_array[index].listing_id === listing_id))) {
7408
8126
  // We went sideways, not up or down. Clear filters.
7409
8127
  $47e2cc552c02110c$export$8895d39404bd2bb1({
7410
8128
  user_triggered_: false,
@@ -7418,7 +8136,7 @@ function $ef972f5c10b1c5b4$export$3945d6db2dfd3d12({
7418
8136
  sideways_filter_clearing_flag_[1](false);
7419
8137
  }
7420
8138
  }
7421
- query_id_when_we_got_previous_data = query_id_of_new_data;
8139
+ listing_id_when_we_got_previous_data = listing_id_of_new_data;
7422
8140
  previous_crumb_data = new_crumb_data;
7423
8141
  if (!allow_filter_clearing) allow_filter_clearing = true;
7424
8142
  })));
@@ -7450,17 +8168,17 @@ function $ef972f5c10b1c5b4$var$clear_if_opened_new_tab_with_sideways_url_params_
7450
8168
  });
7451
8169
  tracking_function_for_plp_results(plp_results_);
7452
8170
  }
7453
- 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.`),
7454
- $839b3341523d31a2$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=buttons><button class="ok major">`);
7455
- function $839b3341523d31a2$export$d4fc5c0e68a52116(el, query_id_, i18n_) {
8171
+ const $bb9760b7a8acdc18$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=statement style=white-space:pre-wrap>No listingId specified, this is probably unintentional. Make sure to create (and insert) the CategoryPage *after* you have specified a listingId.`),
8172
+ $bb9760b7a8acdc18$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=buttons><button class="ok major">`);
8173
+ function $bb9760b7a8acdc18$export$7af06a63c5a976c9(el, listing_id, i18n_) {
7456
8174
  if (!(0, $gVhhF$depictaiutilishared.is_debug)) return; // Just to make sure we don't show this in production
7457
8175
  const owner = $gVhhF$solidjs.getOwner();
7458
8176
  const disconnect = (0, $gVhhF$depictaiutilishared.observer).onexists(el, ({
7459
8177
  element: element
7460
8178
  }) => $gVhhF$solidjs.runWithOwner(owner, () => $gVhhF$solidjs.createEffect(() => {
7461
8179
  if (!document.documentElement.contains(element)) return;
7462
- if (!query_id_()) {
7463
- 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.";
8180
+ if (!listing_id()) {
8181
+ const warning = "No listingId specified, this is probably unintentional. Make sure to create (and insert) the CategoryPage *after* you have specified a listingId.";
7464
8182
  $gVhhF$depictaiutilishared.dwarn(warning);
7465
8183
  const {
7466
8184
  close_toast_: close_toast_
@@ -7470,8 +8188,8 @@ function $839b3341523d31a2$export$d4fc5c0e68a52116(el, query_id_, i18n_) {
7470
8188
  style: {
7471
8189
  background: "#ffb830"
7472
8190
  },
7473
- children: [$gVhhF$solidjsweb.getNextElement($839b3341523d31a2$var$_tmpl$), (() => {
7474
- const _el$2 = $gVhhF$solidjsweb.getNextElement($839b3341523d31a2$var$_tmpl$2),
8191
+ children: [$gVhhF$solidjsweb.getNextElement($bb9760b7a8acdc18$var$_tmpl$), (() => {
8192
+ const _el$2 = $gVhhF$solidjsweb.getNextElement($bb9760b7a8acdc18$var$_tmpl$2),
7475
8193
  _el$3 = _el$2.firstChild;
7476
8194
  _el$3.$$click = () => close_toast_() /* We have to wait for close_toast_ to get defined after the call to show_toast */;
7477
8195
  $gVhhF$solidjsweb.insert(_el$3, () => i18n_.ok_());
@@ -7484,7 +8202,6 @@ function $839b3341523d31a2$export$d4fc5c0e68a52116(el, query_id_, i18n_) {
7484
8202
  $gVhhF$solidjs.onCleanup(disconnect);
7485
8203
  }
7486
8204
  $gVhhF$solidjsweb.delegateEvents(["click"]);
7487
- const $6b502b1b2155a0bc$export$5c28802497c8a83c = /*@__PURE__*/Symbol("category_title_type");
7488
8205
  function $6a8e766e914723d8$export$d31a1a1a83ad9413(plp_results_, [get_selected_filters, set_selected_filters]) {
7489
8206
  $gVhhF$solidjs.createComputed(() => {
7490
8207
  const available_filters = plp_results_()?.filters;
@@ -7516,8 +8233,7 @@ const $840d88a04b2d22a7$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<d
7516
8233
  $840d88a04b2d22a7$var$_tmpl$4 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class="depict plp category"><div class=listing-page><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/></div><!$><!/><!$><!/>`);
7517
8234
  function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7518
8235
  depict_api_: depict_api_,
7519
- query_id_: query_id_,
7520
- listing_type_: listing_type_,
8236
+ listing_id_: listing_id_,
7521
8237
  meta_title_suffix_: meta_title_suffix_,
7522
8238
  current_sorting_: current_sorting_,
7523
8239
  min_products_to_fetch_: min_products_to_fetch_,
@@ -7530,7 +8246,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7530
8246
  get_breadcrumb_accessor_: get_breadcrumb_accessor_,
7531
8247
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
7532
8248
  local_filter_cache_: local_filter_cache_,
7533
- tenant_: tenant_,
8249
+ merchant_: merchant_,
7534
8250
  market_: market_,
7535
8251
  router_: router_,
7536
8252
  show_quicklinks_: show_quicklinks_,
@@ -7553,22 +8269,25 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7553
8269
  show_n_results_: incoming_i18n.show_n_products_,
7554
8270
  no_results_text_: incoming_i18n.no_products_text_
7555
8271
  };
8272
+ const {
8273
+ backend_locale_: backend_locale_
8274
+ } = i18n_;
7556
8275
  const [get_sorting] = current_sorting_;
7557
8276
  const number_of_rendered_selected_filters_items_ = $gVhhF$solidjs.createSignal(0);
7558
8277
  const first_result_in_viewport_ = $gVhhF$solidjs.createSignal();
7559
8278
  const last_result_in_viewport_ = $gVhhF$solidjs.createSignal();
7560
8279
  const [can_write_scroll_restoration_, set_can_write_scroll_restoration] = $gVhhF$solidjs.createSignal(false);
7561
- const query_base_ = $8cd545330f2674dc$export$210f130a61ac1e8d(() => {
8280
+ const products_query_base_ = $8cd545330f2674dc$export$210f130a61ac1e8d(() => {
7562
8281
  const sort_obj = get_sorting() && {
7563
8282
  ...get_sorting()
7564
8283
  };
7565
8284
  delete sort_obj?.meta;
7566
8285
  const f = selected_filters_[0]();
7567
8286
  return {
7568
- tenant: tenant_(),
8287
+ merchant: merchant_(),
7569
8288
  market: market_(),
7570
- query_id: query_id_(),
7571
- type: listing_type_(),
8289
+ locale: backend_locale_(),
8290
+ listing_id: listing_id_(),
7572
8291
  ...(f.length ? {
7573
8292
  filters: f
7574
8293
  } : {}),
@@ -7577,13 +8296,14 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7577
8296
  } : {})
7578
8297
  };
7579
8298
  });
7580
- const [plp_results_] = $gVhhF$solidjs.createResource(query_base_,
8299
+ // Make "Get products in listing" request to get products in listing
8300
+ const [plp_products_] = $gVhhF$solidjs.createResource(products_query_base_,
7581
8301
  // 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)
7582
8302
  $gVhhF$depictaiutilishared.catchify(base_query => $276380e4607fb9fb$export$cc42dd29bf655ab6({
7583
- id_: $gVhhF$solidjs.untrack(query_id_),
8303
+ id_: $gVhhF$solidjs.untrack(listing_id_),
7584
8304
  scroll_restoration_data_: scroll_restoration_data_,
7585
8305
  min_products_to_fetch_: min_products_to_fetch_,
7586
- make_request_: (limit, cursor) => depict_api_.list({
8306
+ make_request_: (limit, cursor) => depict_api_.get_listing_products({
7587
8307
  ...base_query,
7588
8308
  limit: limit,
7589
8309
  ...(cursor ? {
@@ -7591,24 +8311,33 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7591
8311
  } : {})
7592
8312
  })
7593
8313
  })));
7594
- const available_sortings_ = $gVhhF$solidjs.createMemo(() => plp_results_()?.sorts?.map(sort => ({
8314
+ const meta_query_base = $8cd545330f2674dc$export$210f130a61ac1e8d(() => ({
8315
+ merchant: merchant_(),
8316
+ market: market_(),
8317
+ locale: backend_locale_(),
8318
+ listing_id: listing_id_()
8319
+ }));
8320
+ // Make "Get Listing" request to get quicklinks, breadcrumbs, title, etc
8321
+ const [plp_meta] = $gVhhF$solidjs.createResource(meta_query_base, $gVhhF$depictaiutilishared.catchify(query => depict_api_.get_listing(query)));
8322
+ const available_sortings_ = $gVhhF$solidjs.createMemo(() => plp_products_()?.sorts?.map(sort => ({
7595
8323
  ...sort,
7596
8324
  order: sort.order ?? "desc"
7597
8325
  })));
7598
- const available_filters_ = $gVhhF$solidjs.createMemo(() => plp_results_()?.filters);
7599
- const crumb_data_ = $gVhhF$solidjs.createMemo(() => plp_results_()?.breadcrumb);
7600
- const quicklinks_data_ = $gVhhF$solidjs.createMemo(() => plp_results_()?.quick_links);
8326
+ const available_filters_ = $gVhhF$solidjs.createMemo(() => plp_products_()?.filters);
8327
+ const title = $gVhhF$solidjs.createMemo(() => plp_meta()?.title);
8328
+ const crumb_data_ = $840d88a04b2d22a7$var$add_us_to_crumbs(plp_meta, title);
8329
+ const quicklinks_data_ = $gVhhF$solidjs.createMemo(() => plp_meta()?.quick_links);
7601
8330
  const meta_tag_data_ = $gVhhF$solidjs.createMemo(() => {
7602
- if (plp_results_()?.metadata?.replace_meta_tags) return {
7603
- title: plp_results_()?.metadata?.title + (meta_title_suffix_() || ""),
7604
- description: plp_results_()?.metadata?.description
8331
+ if (plp_meta()?.replace_meta_tags) return {
8332
+ title: plp_meta()?.title + (meta_title_suffix_() || ""),
8333
+ description: plp_meta()?.description
7605
8334
  };
7606
8335
  });
7607
8336
  $gVhhF$depictaiutilishared.edit_current_page_meta_tags(meta_tag_data_);
7608
8337
  const [sort_or_filter_open_, set_sort_or_filter_open_] = $gVhhF$solidjs.createSignal(false);
7609
8338
  const [desktop_filter_elements_, set_desktop_filter_elements] = $gVhhF$solidjs.createSignal();
7610
8339
  const formatted_number_of_results_ = $0f400c3f7248d5f1$export$92f2da32c6e7e7ee({
7611
- number_: $gVhhF$solidjs.createMemo(() => plp_results_()?.n_hits),
8340
+ number_: $gVhhF$solidjs.createMemo(() => plp_products_()?.n_hits),
7612
8341
  i18n_: i18n_
7613
8342
  });
7614
8343
  const [sort_and_filter_element_, set_sort_and_filter_element_] = $gVhhF$solidjs.createSignal();
@@ -7627,7 +8356,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7627
8356
  [_el$6, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$5.nextSibling);
7628
8357
  $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
7629
8358
  get when() {
7630
- return plp_results_.loading;
8359
+ return plp_products_.loading;
7631
8360
  },
7632
8361
  fallback: formatted_number_of_results_,
7633
8362
  get children() {
@@ -7639,7 +8368,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7639
8368
  }), _el$4, _co$);
7640
8369
  $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
7641
8370
  get when() {
7642
- return plp_results_()?.n_hits === 1;
8371
+ return plp_products_()?.n_hits === 1;
7643
8372
  },
7644
8373
  get fallback() {
7645
8374
  return i18n_.products_();
@@ -7650,11 +8379,10 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7650
8379
  }), _el$6, _co$2);
7651
8380
  return _el$;
7652
8381
  })();
7653
- $6a8e766e914723d8$export$d31a1a1a83ad9413(plp_results_, selected_filters_);
8382
+ $6a8e766e914723d8$export$d31a1a1a83ad9413(plp_products_, selected_filters_);
7654
8383
  // 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
7655
8384
  if (category_title_type === "simple") {
7656
8385
  const CategoryTitleComponent = category_title_;
7657
- const title = $gVhhF$solidjs.createMemo(() => crumb_data_()?.at(-1)?.title ?? plp_results_()?.metadata?.title);
7658
8386
  results_for = $gVhhF$solidjsweb.createComponent(CategoryTitleComponent, {
7659
8387
  category_title_: title,
7660
8388
  get product_count_() {
@@ -7700,12 +8428,12 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7700
8428
  $gVhhF$depictaiutilishared.catchify((0, $276380e4607fb9fb$export$6e49da55e449af7c))({
7701
8429
  scroll_restoration_data_: scroll_restoration_data_,
7702
8430
  last_result_in_viewport_: last_result_in_viewport_,
7703
- id_: query_id_,
8431
+ id_: listing_id_,
7704
8432
  can_write_scroll_restoration_: can_write_scroll_restoration_
7705
8433
  });
7706
8434
  on_filters_constructed_?.();
7707
8435
  $gVhhF$solidjs.createComputed(() => {
7708
- if (plp_results_.loading) set_can_write_scroll_restoration(false);else if (plp_results_()) set_can_write_scroll_restoration(true);
8436
+ if (plp_products_.loading) set_can_write_scroll_restoration(false);else if (plp_products_()) set_can_write_scroll_restoration(true);
7709
8437
  });
7710
8438
  $gVhhF$solidjs.createRenderEffect($gVhhF$depictaiutilishared.catchify(async () => {
7711
8439
  const slim = is_slim_();
@@ -7729,13 +8457,13 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7729
8457
  available_filters_: available_filters_
7730
8458
  });
7731
8459
  $ef972f5c10b1c5b4$export$3945d6db2dfd3d12({
7732
- query_id_: query_id_,
8460
+ listing_id_: listing_id_,
7733
8461
  crumb_data_: crumb_data_,
7734
8462
  i18n_: i18n_,
7735
8463
  selected_filters_: selected_filters_,
7736
8464
  local_filter_cache_: local_filter_cache_,
7737
8465
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
7738
- plp_results_: plp_results_,
8466
+ plp_results_: plp_products_,
7739
8467
  sideways_filter_clearing_flag_: sideways_filter_clearing_flag_
7740
8468
  });
7741
8469
  get_breadcrumb_accessor_?.(crumb_data_);
@@ -7759,7 +8487,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7759
8487
  [_el$28, _co$11] = $gVhhF$solidjsweb.getNextMarker(_el$27.nextSibling),
7760
8488
  _el$29 = _el$28.nextSibling,
7761
8489
  [_el$30, _co$12] = $gVhhF$solidjsweb.getNextMarker(_el$29.nextSibling);
7762
- $gVhhF$solidjsweb.use(el => process.env.NODE_ENV === "development" && $839b3341523d31a2$export$d4fc5c0e68a52116(el, query_id_, i18n_), _el$13);
8490
+ $gVhhF$solidjsweb.use(el => process.env.NODE_ENV === "development" && $bb9760b7a8acdc18$export$7af06a63c5a976c9(el, listing_id_, i18n_), _el$13);
7763
8491
  $gVhhF$solidjsweb.insert(_el$14, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
7764
8492
  get when() {
7765
8493
  return show_breadcrumbs_();
@@ -7781,7 +8509,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7781
8509
  get children() {
7782
8510
  return $gVhhF$solidjsweb.createComponent((0, $8cceb1d3a967f369$export$466cdc317043f6cb), {
7783
8511
  quicklinks_data_: quicklinks_data_,
7784
- current_query_id_: query_id_,
8512
+ current_listing_id_: listing_id_,
7785
8513
  router_: router_,
7786
8514
  breadcrumb_data_: crumb_data_,
7787
8515
  i18n_: i18n_,
@@ -7824,8 +8552,8 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7824
8552
  min_products_to_fetch_:
7825
8553
  // if you want to get if all products have been loaded you can add an optional signal here, see SearchPage
7826
8554
  min_products_to_fetch_,
7827
- query_base_: query_base_,
7828
- plp_results_: plp_results_,
8555
+ query_base_: products_query_base_,
8556
+ plp_results_: plp_products_,
7829
8557
  depict_api_: depict_api_,
7830
8558
  first_result_in_viewport_: first_result_in_viewport_,
7831
8559
  last_result_in_viewport_: last_result_in_viewport_,
@@ -7835,7 +8563,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7835
8563
  sort_or_filter_open_: sort_or_filter_open_,
7836
8564
  desktop_filter_elements_: desktop_filter_elements_,
7837
8565
  content_blocks_by_row_: content_blocks_by_row_,
7838
- id_currently_querying_for_: query_id_,
8566
+ id_currently_querying_for_: listing_id_,
7839
8567
  no_results_options_: {
7840
8568
  selected_filters_: selected_filters_,
7841
8569
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
@@ -7856,7 +8584,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7856
8584
  last_result_in_viewport_: last_result_in_viewport_,
7857
8585
  formatted_number_of_results_: formatted_number_of_results_,
7858
8586
  i18n_: i18n_,
7859
- number_of_results_: $gVhhF$solidjs.createMemo(() => plp_results_()?.n_hits)
8587
+ number_of_results_: $gVhhF$solidjs.createMemo(() => plp_products_()?.n_hits)
7860
8588
  });
7861
8589
  }
7862
8590
  }), _el$28, _co$11);
@@ -7877,16 +8605,40 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7877
8605
  return _el$13;
7878
8606
  })()];
7879
8607
  }
8608
+ /**
8609
+ * Adds the current page as last breadcrumb to the breadcrumb trail
8610
+ */
8611
+ function $840d88a04b2d22a7$var$add_us_to_crumbs(plp_meta, title) {
8612
+ const href_accessor = $gVhhF$depictaiutilishared.use_href_accessor();
8613
+ return $gVhhF$solidjs.createMemo(() => {
8614
+ const api_value = plp_meta()?.breadcrumbs;
8615
+ if (!api_value) return api_value;
8616
+ return [...api_value, {
8617
+ get listing_id() {
8618
+ return plp_meta().listing_id;
8619
+ },
8620
+ get title() {
8621
+ return title();
8622
+ },
8623
+ get page_url() {
8624
+ return href_accessor();
8625
+ },
8626
+ get slug() {
8627
+ return plp_meta().slug;
8628
+ }
8629
+ }];
8630
+ });
8631
+ }
7880
8632
  function $c79fd10a3ab7d6e0$export$477caf01aecaeb2a(options) {
7881
8633
  const router_ = options.router_;
7882
8634
  const search_query_url_param_name_ = "search_query_url_param_name_" in options ? options.search_query_url_param_name_ : undefined;
7883
8635
  const search_query_ = search_query_url_param_name_ ? $gVhhF$solidjs.createSignal("") : undefined;
7884
- const override_query_id_query_param_names_ = "override_query_id_query_param_names_" in options ? options.override_query_id_query_param_names_ : undefined;
7885
- const override_query_id_ = override_query_id_query_param_names_ ? $gVhhF$solidjs.createSignal(null) : undefined;
8636
+ const override_listing_id_query_param_names_ = "override_listing_id_query_param_names_" in options ? options.override_listing_id_query_param_names_ : undefined;
8637
+ const override_listing_id_ = override_listing_id_query_param_names_ ? $gVhhF$solidjs.createSignal(null) : undefined;
7886
8638
  const get_search_query_ = search_query_?.[0];
7887
8639
  const set_search_query = search_query_?.[1];
7888
- const get_override_query_id_ = override_query_id_?.[0];
7889
- const set_override_query_id = override_query_id_?.[1];
8640
+ const get_override_listing_id_ = override_listing_id_?.[0];
8641
+ const set_override_listing_id = override_listing_id_?.[1];
7890
8642
  const current_sorting_ = $gVhhF$solidjs.createSignal();
7891
8643
  const selected_filters_ = $gVhhF$solidjs.createSignal([]);
7892
8644
  const sideways_filter_clearing_flag_ = $gVhhF$solidjs.createSignal(false);
@@ -7931,10 +8683,10 @@ function $c79fd10a3ab7d6e0$export$477caf01aecaeb2a(options) {
7931
8683
  const found_query = searchParams.get(search_query_url_param_name_);
7932
8684
  set_search_query(found_query || "");
7933
8685
  }
7934
- if (override_query_id_query_param_names_) {
7935
- const found_override_query_id = override_query_id_query_param_names_.map(n => searchParams.get(n)).find(n => n);
7936
- set_override_query_id(found_override_query_id || null);
7937
- 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
8686
+ if (override_listing_id_query_param_names_) {
8687
+ const found_override_listing_id = override_listing_id_query_param_names_.map(n => searchParams.get(n)).find(n => n);
8688
+ set_override_listing_id(found_override_listing_id || null);
8689
+ 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
7938
8690
  }
7939
8691
 
7940
8692
  if (searchParams.get((0, $1ab22f2cd39b3061$export$cf5feb2102aec7f2)) === "true") set_has_sideways_filter_clearing_flag(true);
@@ -7961,8 +8713,8 @@ function $c79fd10a3ab7d6e0$export$477caf01aecaeb2a(options) {
7961
8713
  } : {
7962
8714
  sideways_filter_clearing_flag_: sideways_filter_clearing_flag_
7963
8715
  }),
7964
- ...(typeof override_query_id_query_param_names_ === "object" ? {
7965
- override_query_id_accessor_: get_override_query_id_
8716
+ ...(typeof override_listing_id_query_param_names_ === "object" ? {
8717
+ override_listing_id_accessor_: get_override_listing_id_
7966
8718
  } : {})
7967
8719
  };
7968
8720
  }
@@ -8007,108 +8759,6 @@ function $c79fd10a3ab7d6e0$var$start_href_writer({
8007
8759
  function $c79fd10a3ab7d6e0$var$delete_sideways_param_flag(searchParams) {
8008
8760
  if (searchParams.get((0, $1ab22f2cd39b3061$export$cf5feb2102aec7f2)) === "true") searchParams.delete((0, $1ab22f2cd39b3061$export$cf5feb2102aec7f2));
8009
8761
  }
8010
- class $e96dd13889871fc0$export$7e1297a3a19f10d8 {
8011
- /**
8012
- * Function that will be called when we want to navigate, or a string saying it's not an SPA. You can change this OTG
8013
- */ /**
8014
- * 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
8015
- */
8016
- #throwing_on_navigation(...args) {
8017
- const {
8018
- on_navigation_: on_navigation_
8019
- } = this;
8020
- if (typeof on_navigation_ !== "function") throw new Error("on_navigation_ is not a function");
8021
- // make sure that we don't accidentally catchify if the SDK consumer has fucked up
8022
- try {
8023
- return on_navigation_(...args);
8024
- } catch (e) {
8025
- queueMicrotask(() => {
8026
- throw e;
8027
- });
8028
- }
8029
- }
8030
- /**
8031
- * Checks if this tab shouldn't navigate because user wants to open in new tab
8032
- */
8033
- #dont_attempt_navigation(ev) {
8034
- return ev?.button || ev?.metaKey || ev?.ctrlKey;
8035
- }
8036
- /**
8037
- * Vue has async router that needs to be awaited (it navigates after a microtask)
8038
- * This standardises waiting for all kinds of routers
8039
- */
8040
- #get_navigation_happened_promise(is_replace) {
8041
- return new Promise(resolve => {
8042
- const handler = what_happened => {
8043
- if (what_happened === (is_replace ? "replaceState" : "pushState")) {
8044
- resolve();
8045
- (0, $gVhhF$depictaiutilishared.instant_exec_on_suspect_history_change).delete(handler);
8046
- }
8047
- };
8048
- (0, $gVhhF$depictaiutilishared.instant_exec_on_suspect_history_change).add(handler);
8049
- });
8050
- }
8051
- navigate_ = {
8052
- /**
8053
- * Call this if you *just* want to replace the state object in history.state
8054
- */
8055
- replace_state_: new_state => {
8056
- // 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
8057
- globalThis?.history?.replaceState(new_state, "");
8058
- },
8059
- /**
8060
- * Call this to change the URL
8061
- * @param new_url_ new URL to go to
8062
- * @param event_ event if you have this in a click handler, will not do anything on cmd/ctrl or non-left click then
8063
- * @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
8064
- * @param is_replace_ if you want to replace the current URL in history instead of pushing a new one
8065
- * @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
8066
- */
8067
- go_to_: $gVhhF$depictaiutilishared.catchify(async ({
8068
- new_url_: raw_new_url,
8069
- event_: event_,
8070
- force_spa_navigation_: force_spa_navigation_,
8071
- is_replace_: is_replace_,
8072
- category_query_id_: category_query_id_,
8073
- scroll = true
8074
- }) => {
8075
- const new_url_ = raw_new_url instanceof URL ? raw_new_url : new URL(raw_new_url, location.origin);
8076
- const wants_hard_navigation = this.on_navigation_ === "hard_navigation";
8077
- if (this.#dont_attempt_navigation(event_)) return;
8078
- const different_origin = new_url_.origin !== location.origin;
8079
- if (wants_hard_navigation && (!force_spa_navigation_ || different_origin)) {
8080
- if (force_spa_navigation_ && different_origin)
8081
- // If we call history.pushState on a different origin, it will throw an error, so fallback to hard navigations
8082
- $gVhhF$depictaiutilishared.dwarn("Can't single page navigate to", new_url_.href, "due to different origin, this MIGHT mean you should fix the URLs");
8083
- if (!event_)
8084
- // If we haven't gotten an event, nothing will happen by not calling prevent default, so we need to change the URL
8085
- location.assign(new_url_);
8086
- return;
8087
- }
8088
- event_?.preventDefault();
8089
- const promise = this.#get_navigation_happened_promise(true);
8090
- if (force_spa_navigation_ && wants_hard_navigation) {
8091
- // Don't allow hard navigation if we're forcing SPA navigation, which we do for things where PageReplacer can be used for performance
8092
- const new_state = history.state;
8093
- if (category_query_id_) {
8094
- // In JS-UI we need to know the query_id of the current category, therefore push it into state
8095
- if (!this.query_id_state_key) $gVhhF$depictaiutilishared.report(new Error("query_id_state_key is not set"), "error");
8096
- new_state[this.query_id_state_key] = category_query_id_;
8097
- }
8098
- history[is_replace_ ? "replaceState" : "pushState"](new_state, "", new_url_);
8099
- } else this.#throwing_on_navigation.call(this, {
8100
- is_replace: is_replace_,
8101
- new_url: new_url_ instanceof URL ? new_url_ : new URL(new_url_, location.origin),
8102
- scroll: scroll
8103
- });
8104
- await promise;
8105
- })
8106
- };
8107
- constructor(on_navigation, query_id_state_key) {
8108
- this.query_id_state_key = query_id_state_key;
8109
- this.on_navigation_ = on_navigation;
8110
- }
8111
- }
8112
8762
 
8113
8763
  /**
8114
8764
  * Wraps a function in a try/catch block and throws the error globally. If undefined is provided as fn, a no-op is returned.
@@ -8144,26 +8794,25 @@ const $48567ac5b39bac56$var$InExternalAreaDiv = ({
8144
8794
  })();
8145
8795
  class $48567ac5b39bac56$export$f34314aa9505732e {
8146
8796
  #router;
8147
- #locale_signal = $gVhhF$solidjs.createSignal();
8797
+ #localization_signal = $gVhhF$solidjs.createSignal();
8148
8798
  #merchant_signal = $gVhhF$solidjs.createSignal();
8149
8799
  #market_signal = $gVhhF$solidjs.createSignal();
8150
- #query_id_signal = $gVhhF$solidjs.createSignal("");
8800
+ #listing_id_signal = $gVhhF$solidjs.createSignal("");
8151
8801
  #meta_title_suffix_ = $gVhhF$solidjs.createSignal();
8152
- #disable_override_query_id = $gVhhF$solidjs.createSignal();
8153
- #listing_type_signal = $gVhhF$solidjs.createSignal();
8802
+ #disable_override_listing_id = $gVhhF$solidjs.createSignal();
8154
8803
  static #keys_constructed_with = /*@__PURE__*/new Set();
8155
8804
  get localization() {
8156
8805
  // allow reactive access
8157
- return this.#locale_signal[0]();
8806
+ return this.#localization_signal[0]();
8158
8807
  }
8159
8808
  set localization(locale_obj) {
8160
- this.#locale_signal[1](locale_obj);
8809
+ this.#localization_signal[1](locale_obj);
8161
8810
  }
8162
- get category_id() {
8163
- return this.#query_id_signal[0]();
8811
+ get listing_id() {
8812
+ return this.#listing_id_signal[0]();
8164
8813
  }
8165
- set category_id(id) {
8166
- this.#query_id_signal[1](id);
8814
+ set listing_id(id) {
8815
+ this.#listing_id_signal[1](id);
8167
8816
  }
8168
8817
  get merchant() {
8169
8818
  return this.#merchant_signal[0]();
@@ -8177,23 +8826,17 @@ class $48567ac5b39bac56$export$f34314aa9505732e {
8177
8826
  set market(market) {
8178
8827
  this.#market_signal[1](market);
8179
8828
  }
8180
- get listing_type() {
8181
- return this.#listing_type_signal[0]();
8182
- }
8183
- set listing_type(listing_type) {
8184
- this.#listing_type_signal[1](listing_type);
8185
- }
8186
8829
  get meta_title_suffix() {
8187
8830
  return this.#meta_title_suffix_[0]();
8188
8831
  }
8189
8832
  set meta_title_suffix(new_suffix) {
8190
8833
  this.#meta_title_suffix_[1](new_suffix);
8191
8834
  }
8192
- get disable_override_query_id() {
8193
- return this.#disable_override_query_id[0]();
8835
+ get disable_override_listing_id() {
8836
+ return this.#disable_override_listing_id[0]();
8194
8837
  }
8195
- set disable_override_query_id(new_value) {
8196
- this.#disable_override_query_id[1](new_value);
8838
+ set disable_override_listing_id(new_value) {
8839
+ this.#disable_override_listing_id[1](new_value);
8197
8840
  }
8198
8841
  get on_navigation() {
8199
8842
  // The only non-reactive public property on the class (I don't see it making sense to have it reactive)
@@ -8208,7 +8851,7 @@ class $48567ac5b39bac56$export$f34314aa9505732e {
8208
8851
  page_url_creator: page_url_creator,
8209
8852
  display_transformers: display_transformers,
8210
8853
  unique_instance_key_for_state = "",
8211
- query_id_state_key: query_id_state_key,
8854
+ listing_id_state_key: listing_id_state_key,
8212
8855
  ...props_on_class
8213
8856
  }) {
8214
8857
  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
@@ -8218,21 +8861,21 @@ class $48567ac5b39bac56$export$f34314aa9505732e {
8218
8861
  throw new Error("You can only have one instance of DepictCategory with the same uniqueInstanceKeyForState");
8219
8862
  Object.assign(this, props_on_class); // set initial signal values
8220
8863
  $d84fe647b84b5dc5$export$5162a71f252e6122();
8221
- this.#router = new (0, $e96dd13889871fc0$export$7e1297a3a19f10d8)("hard_navigation", query_id_state_key);
8864
+ this.#router = new (0, $e96dd13889871fc0$export$7e1297a3a19f10d8)("hard_navigation", listing_id_state_key);
8222
8865
  if (on_navigation) this.#router.on_navigation_ = on_navigation;
8223
- 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
8866
+ 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
8224
8867
  const sorting_query_param_ = "sorting" + unique_instance_key_for_state;
8225
8868
  const filter_query_param_prefix_ = "f" + unique_instance_key_for_state + "_";
8226
8869
  const {
8227
8870
  selected_filters_: selected_filters_,
8228
8871
  current_sorting_: current_sorting_,
8229
8872
  sideways_filter_clearing_flag_: sideways_filter_clearing_flag_,
8230
- override_query_id_accessor_: override_query_id_accessor_
8873
+ override_listing_id_accessor_: override_listing_id_accessor_
8231
8874
  } = $c79fd10a3ab7d6e0$export$477caf01aecaeb2a({
8232
8875
  router_: this.#router,
8233
8876
  sorting_query_param_: sorting_query_param_,
8234
8877
  filter_query_param_prefix_: filter_query_param_prefix_,
8235
- override_query_id_query_param_names_: override_query_id_query_param_names_
8878
+ override_listing_id_query_param_names_: override_listing_id_query_param_names_
8236
8879
  });
8237
8880
  const [reset_history_state_, state_] = $26a56f6b44703084$export$9862539c89138352({
8238
8881
  get_default_values_: () => ({
@@ -8247,7 +8890,7 @@ class $48567ac5b39bac56$export$f34314aa9505732e {
8247
8890
  router_: this.#router,
8248
8891
  prefix_: "category" + unique_instance_key_for_state + "_"
8249
8892
  });
8250
- const i18n_ = $0785f4c9947d9b5f$export$f091cbac892643a4(this.#locale_signal[0]);
8893
+ const i18n_ = $0785f4c9947d9b5f$export$f091cbac892643a4(this.#localization_signal[0]);
8251
8894
  $48567ac5b39bac56$var$privately_shared_properties.set(this, {
8252
8895
  state_: state_,
8253
8896
  breadcrumb_signal_: $gVhhF$solidjs.createSignal(),
@@ -8262,7 +8905,7 @@ class $48567ac5b39bac56$export$f34314aa9505732e {
8262
8905
  router_: this.#router,
8263
8906
  selected_filters_: selected_filters_,
8264
8907
  current_sorting_: current_sorting_,
8265
- override_query_id_accessor_: override_query_id_accessor_,
8908
+ override_listing_id_accessor_: override_listing_id_accessor_,
8266
8909
  sideways_filter_clearing_flag_: sideways_filter_clearing_flag_,
8267
8910
  sorting_query_param_: sorting_query_param_,
8268
8911
  filter_query_param_prefix_: filter_query_param_prefix_
@@ -8282,11 +8925,11 @@ function $48567ac5b39bac56$export$e2bf8ce7779e827e(props) {
8282
8925
  return $95837413165cc2df$export$23fca46f3143581f(() => {
8283
8926
  $gVhhF$solidjs.createEffect(prev => {
8284
8927
  // 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
8285
- const id = depict_category.category_id; // <- this is a reactive getter
8286
- $deaaf04362a1bc71$export$f50b88e2a00918b5(props.on_query_id_change)(id, prev);
8928
+ const id = depict_category.listing_id; // <- this is a reactive getter
8929
+ $deaaf04362a1bc71$export$f50b88e2a00918b5(props.on_listing_id_change)(id, prev);
8287
8930
  return id;
8288
8931
  });
8289
- $gVhhF$solidjs.onCleanup(() => $deaaf04362a1bc71$export$f50b88e2a00918b5(props.on_query_id_change)());
8932
+ $gVhhF$solidjs.onCleanup(() => $deaaf04362a1bc71$export$f50b88e2a00918b5(props.on_listing_id_change)());
8290
8933
  const grid_spacing_override = $gVhhF$solidjs.createMemo(() => {
8291
8934
  const {
8292
8935
  grid_spacing: grid_spacing
@@ -8309,7 +8952,7 @@ function $48567ac5b39bac56$export$e2bf8ce7779e827e(props) {
8309
8952
  },
8310
8953
  current_sorting_: current_sorting_,
8311
8954
  selected_filters_: selected_filters_,
8312
- override_query_id_accessor_: override_query_id_accessor_,
8955
+ override_listing_id_accessor_: override_listing_id_accessor_,
8313
8956
  reset_history_state_: reset_history_state_,
8314
8957
  depict_api_: depict_api_,
8315
8958
  i18n_: i18n_,
@@ -8322,14 +8965,13 @@ function $48567ac5b39bac56$export$e2bf8ce7779e827e(props) {
8322
8965
  } = shared_properties;
8323
8966
  $gVhhF$solidjs.onCleanup(reset_history_state_);
8324
8967
  return $840d88a04b2d22a7$export$f7d2f673fc2f091d({
8325
- tenant_: () => depict_category.merchant,
8968
+ merchant_: () => depict_category.merchant,
8326
8969
  market_: () => depict_category.market,
8327
8970
  depict_api_: depict_api_,
8328
8971
  min_products_to_fetch_: $48567ac5b39bac56$var$min_products_to_fetch_,
8329
8972
  local_filter_cache_: local_filter_cache_,
8330
- query_id_: $gVhhF$solidjs.createMemo(() => !depict_category.disable_override_query_id && override_query_id_accessor_() || depict_category.category_id),
8973
+ listing_id_: $gVhhF$solidjs.createMemo(() => !depict_category.disable_override_listing_id && override_listing_id_accessor_() || depict_category.listing_id),
8331
8974
  meta_title_suffix_: () => depict_category.meta_title_suffix,
8332
- listing_type_: () => depict_category.listing_type,
8333
8975
  i18n_: i18n_,
8334
8976
  show_quicklinks_: $gVhhF$solidjs.createMemo(() => props.show_quicklinks ?? true),
8335
8977
  category_title_: category_title,
@@ -8395,7 +9037,7 @@ function $48567ac5b39bac56$export$de035477d6fef996({
8395
9037
  i18n_: i18n_,
8396
9038
  quicklinks_data_: quicklinks_data_,
8397
9039
  router_: router_,
8398
- current_query_id_: () => depict_category.category_id,
9040
+ current_listing_id_: () => depict_category.listing_id,
8399
9041
  breadcrumb_data_: breadcrumb_data_,
8400
9042
  sorting_query_param_: sorting_query_param_,
8401
9043
  filter_query_param_prefix_: filter_query_param_prefix_
@@ -8408,31 +9050,6 @@ function $48567ac5b39bac56$var$get_shared_properties(depict_category) {
8408
9050
  if (!shared_properties) throw new Error("Can't connect to provided DepictCategory instance");
8409
9051
  return shared_properties;
8410
9052
  }
8411
- const $0b23bfd073d9a4e8$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=category-title><h1 class=title></h1><span class=explanation> — <!$><!/>`);
8412
- const $0b23bfd073d9a4e8$export$b91cec6bdc6b32a1 = /*@__PURE__*/(() => {
8413
- const actual_function = ({
8414
- category_title_: category_title_,
8415
- product_count_: product_count_
8416
- }) => {
8417
- return (() => {
8418
- const _el$ = $gVhhF$solidjsweb.getNextElement($0b23bfd073d9a4e8$var$_tmpl$),
8419
- _el$2 = _el$.firstChild,
8420
- _el$3 = _el$2.nextSibling,
8421
- _el$4 = _el$3.firstChild,
8422
- _el$5 = _el$4.nextSibling,
8423
- [_el$6, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$5.nextSibling);
8424
- $gVhhF$solidjsweb.insert(_el$2, () => category_title_() || $gVhhF$solidjsweb.createComponent((0, $061ff5b4c3d36171$export$89c6019e4baa40b1), {
8425
- height: "1em",
8426
- width: "10ch"
8427
- }));
8428
- $gVhhF$solidjsweb.insert(_el$3, product_count_, _el$6, _co$);
8429
- return _el$;
8430
- })();
8431
- };
8432
- // This is wrong but parcel can't build correctly, it says unexpected undefined
8433
- actual_function[(0, $6b502b1b2155a0bc$export$5c28802497c8a83c)] = "simple";
8434
- return actual_function;
8435
- })();
8436
9053
  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><!$><!/><!$><!/><!$><!/>`);
8437
9054
  const $85b747260aa175c9$export$824dde41348efed1 = /*@__PURE__*/(() => {
8438
9055
  const actual_function = ({
@@ -8531,11 +9148,11 @@ const $85b747260aa175c9$export$824dde41348efed1 = /*@__PURE__*/(() => {
8531
9148
  actual_function[(0, $6b502b1b2155a0bc$export$5c28802497c8a83c)] = "interactive";
8532
9149
  return actual_function;
8533
9150
  })();
8534
- const $63b10c9f461e0ef6$var$TEN_MINUTES = 600000;
8535
- const $63b10c9f461e0ef6$var$TWENTY_FOUR_HOURS = 86400000;
8536
- async function $63b10c9f461e0ef6$export$643598a327b5833e(tenant, market, type) {
9151
+ const $6382a1b83da39674$var$TEN_MINUTES = 600000;
9152
+ const $6382a1b83da39674$var$TWENTY_FOUR_HOURS = 86400000;
9153
+ async function $6382a1b83da39674$export$c1a6b039e689a58e(merchant, market, locale) {
8537
9154
  let localstorage_value;
8538
- const localstorage_key = `depict_${tenant}_${type ?? "categories"}_` + market;
9155
+ const localstorage_key = `depict_listings_${JSON.stringify([merchant, market, locale])}}`;
8539
9156
  try {
8540
9157
  const in_ls = localStorage[localstorage_key];
8541
9158
  if (in_ls) localstorage_value = JSON.parse(in_ls);
@@ -8547,20 +9164,20 @@ async function $63b10c9f461e0ef6$export$643598a327b5833e(tenant, market, type) {
8547
9164
  const stored_queries = localstorage_value?.queries;
8548
9165
  if (Array.isArray(stored_queries) && typeof updated === "number") {
8549
9166
  const age = now - updated;
8550
- if (stored_queries.length && age < $63b10c9f461e0ef6$var$TEN_MINUTES)
9167
+ if (stored_queries.length && age < $6382a1b83da39674$var$TEN_MINUTES)
8551
9168
  // if younger than 10 minutes and probably valid data, just return stored value
8552
- return stored_queries;else if (age < $63b10c9f461e0ef6$var$TWENTY_FOUR_HOURS) {
9169
+ return stored_queries;else if (age < $6382a1b83da39674$var$TWENTY_FOUR_HOURS) {
8553
9170
  // 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)
8554
- $63b10c9f461e0ef6$var$fetch_and_store_categories(tenant, market, localstorage_key, type).catch(e => $gVhhF$depictaiutilishared.report([e, "couldn't fetch categories"], "warning"));
9171
+ $6382a1b83da39674$var$fetch_and_store_categories(merchant, market, locale, localstorage_key).catch(e => $gVhhF$depictaiutilishared.report([e, "couldn't fetch categories"], "warning"));
8555
9172
  return stored_queries;
8556
9173
  }
8557
9174
  // else: we are older and just fetch, store and return new queries
8558
9175
  }
8559
9176
 
8560
- return await $63b10c9f461e0ef6$var$fetch_and_store_categories(tenant, market, localstorage_key, type);
9177
+ return await $6382a1b83da39674$var$fetch_and_store_categories(merchant, market, locale, localstorage_key);
8561
9178
  }
8562
- async function $63b10c9f461e0ef6$var$fetch_and_store_categories(tenant, market, localstorage_key, type) {
8563
- const new_categories = await $63b10c9f461e0ef6$var$download_categories(tenant, market, type);
9179
+ async function $6382a1b83da39674$var$fetch_and_store_categories(merchant, market, locale, localstorage_key) {
9180
+ const new_categories = await $6382a1b83da39674$var$download_categories(merchant, market, locale);
8564
9181
  try {
8565
9182
  localStorage[localstorage_key] = JSON.stringify({
8566
9183
  updated: +new Date(),
@@ -8572,24 +9189,22 @@ async function $63b10c9f461e0ef6$var$fetch_and_store_categories(tenant, market,
8572
9189
 
8573
9190
  return new_categories;
8574
9191
  }
8575
- async function $63b10c9f461e0ef6$var$download_categories(tenant, market, type) {
8576
- const fetched = await $gVhhF$depictaiutilishared.fetch_retry((0, $gVhhF$depictaiutilishared.base_url) + "/v2/product-listing/queries", {
8577
- method: "POST",
8578
- body: JSON.stringify({
8579
- tenant: tenant,
8580
- market: market,
8581
- ...(type ? {
8582
- type: type
8583
- } : {})
8584
- })
8585
- });
9192
+ async function $6382a1b83da39674$var$download_categories(merchant, market, locale) {
9193
+ const url = new URL((0, $gVhhF$depictaiutilishared.base_url) + "/v3/listings");
9194
+ const request = {
9195
+ merchant: merchant,
9196
+ market: market,
9197
+ locale: locale
9198
+ };
9199
+ url.search = "" + new URLSearchParams(request);
9200
+ const fetched = await $gVhhF$depictaiutilishared.fetch_retry(url.href);
8586
9201
  if (!fetched) return [];
8587
9202
  try {
8588
9203
  if (fetched.status !== 200) {
8589
9204
  $gVhhF$depictaiutilishared.dlog("failed to fetch queries, server responded with", fetched.status, fetched, await fetched.text());
8590
9205
  return [];
8591
9206
  }
8592
- return (await fetched.json())?.query_ids;
9207
+ return await fetched.json();
8593
9208
  } catch (e) {
8594
9209
  $gVhhF$depictaiutilishared.dlog("failed to decode queries json", fetched, e);
8595
9210
  return [];
@@ -8840,8 +9455,6 @@ function $fb29c6201c369e39$export$7de92c4c2205ebf3({
8840
9455
  }));
8841
9456
  return $a73063cc642f3e5f$export$43f0fb951fcb0c54({
8842
9457
  displays_by_key_: displays_by_key_,
8843
- merchant_: $gVhhF$solidjs.createMemo(() => search_query_base_().tenant),
8844
- market_: $gVhhF$solidjs.createMemo(() => search_query_base_().market),
8845
9458
  product_card_template_: product_card_template_
8846
9459
  });
8847
9460
  })();
@@ -9157,7 +9770,7 @@ const $6ae556e536054e87$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<d
9157
9770
  function $6ae556e536054e87$export$62f101a8aa597bf8({
9158
9771
  depict_api_: depict_api_,
9159
9772
  search_field_value_: [get_search_field_value],
9160
- tenant_: tenant_,
9773
+ merchant_: merchant_,
9161
9774
  market_: market_,
9162
9775
  render_instant_card_: render_instant_card_,
9163
9776
  render_instant_card_placeholder_: render_instant_card_placeholder_,
@@ -9181,8 +9794,10 @@ function $6ae556e536054e87$export$62f101a8aa597bf8({
9181
9794
  timeout = setTimeout($gVhhF$depictaiutilishared.catchify(() => write_current_instant_query(value)), 250);
9182
9795
  });
9183
9796
  const [search_results] = $gVhhF$solidjs.createResource($gVhhF$solidjs.createMemo(() => ({
9184
- tenant: tenant_(),
9797
+ // <-- key order important, see comment below
9798
+ merchant: merchant_(),
9185
9799
  market: market_(),
9800
+ locale: i18n_.backend_locale_(),
9186
9801
  query: read_current_instant_query()
9187
9802
  })), $gVhhF$depictaiutilishared.catchify(variable_data => {
9188
9803
  return depict_api_.query({
@@ -9230,12 +9845,12 @@ function $6ae556e536054e87$export$62f101a8aa597bf8({
9230
9845
  const card = render_instant_card_ ? $gVhhF$solidjs.createMemo(() => render_instant_card_(d(), {
9231
9846
  index: i,
9232
9847
  i18n: $639c124c22b6cbaa$export$27b710c08412a7ad(i18n_),
9233
- merchant: tenant_(),
9848
+ merchant: merchant_(),
9234
9849
  market: market_()
9235
9850
  })) : $6ae613870d3380fc$export$b05c0ae390cf3e06(d, {
9236
9851
  index: i,
9237
9852
  i18n: i18n_,
9238
- merchant: tenant_(),
9853
+ merchant: merchant_(),
9239
9854
  market: market_()
9240
9855
  }, router_);
9241
9856
  return card;
@@ -9872,7 +10487,7 @@ function $3ec9e21d6b6debdd$export$2f2b9559550c7bbc({
9872
10487
  previous_searches_: [unfiltered_previous_searches, set_unfiltered_previous_searches_],
9873
10488
  previous_searches_text_: previous_searches_text_,
9874
10489
  depict_api_: depict_api_,
9875
- tenant_: tenant_,
10490
+ merchant_: merchant_,
9876
10491
  market_: market_,
9877
10492
  input_field_: input_field_,
9878
10493
  url_transformer_: url_transformer_,
@@ -9945,9 +10560,10 @@ function $3ec9e21d6b6debdd$export$2f2b9559550c7bbc({
9945
10560
  set_show_stale_content_results(true);else {
9946
10561
  set_searching_for_value(field_value);
9947
10562
  deparallelized_fn({
9948
- query: field_value,
9949
- tenant: tenant_(),
9950
- market: market_()
10563
+ merchant: merchant_(),
10564
+ market: market_(),
10565
+ locale: i18n_.backend_locale_(),
10566
+ query: field_value
9951
10567
  });
9952
10568
  set_show_stale_content_results(false);
9953
10569
  }
@@ -10083,7 +10699,7 @@ function $f40a47a30a358305$export$1c593cbd6f1e10bc({
10083
10699
  close_modal_: close_modal_,
10084
10700
  style_props_ = $gVhhF$solidjs.createSignal({}),
10085
10701
  depict_api_: depict_api_,
10086
- tenant_: tenant_,
10702
+ merchant_: merchant_,
10087
10703
  market_: market_,
10088
10704
  submit_query_: props_submit_query,
10089
10705
  instant_results_options_: instant_results_options_,
@@ -10220,7 +10836,7 @@ function $f40a47a30a358305$export$1c593cbd6f1e10bc({
10220
10836
  previous_searches_: previous_searches_,
10221
10837
  search_query_url_param_name_: search_query_url_param_name_,
10222
10838
  market_: market_,
10223
- tenant_: tenant_,
10839
+ merchant_: merchant_,
10224
10840
  selected_index_: selected_index,
10225
10841
  currently_showing_suggestions_: currently_showing_suggestions_,
10226
10842
  depict_api_: depict_api_,
@@ -10243,7 +10859,7 @@ function $f40a47a30a358305$export$1c593cbd6f1e10bc({
10243
10859
  return $6ae556e536054e87$export$62f101a8aa597bf8({
10244
10860
  search_field_value_: search_field_value_,
10245
10861
  depict_api_: depict_api_,
10246
- tenant_: tenant_,
10862
+ merchant_: merchant_,
10247
10863
  i18n_: i18n_,
10248
10864
  market_: market_,
10249
10865
  set_total_num_results_accessor_: set_total_num_results_accessor_,
@@ -10725,6 +11341,9 @@ function $f1d7cb69f839a526$export$a54ec244c8863715({
10725
11341
  const first_result_in_viewport_ = $gVhhF$solidjs.createSignal();
10726
11342
  const last_result_in_viewport_ = $gVhhF$solidjs.createSignal();
10727
11343
  const [can_write_scroll_restoration_, set_can_write_scroll_restoration] = $gVhhF$solidjs.createSignal(false);
11344
+ const {
11345
+ backend_locale_: backend_locale_
11346
+ } = i18n_;
10728
11347
  const search_query_base_ = $8cd545330f2674dc$export$210f130a61ac1e8d(() => {
10729
11348
  const sort_obj = get_sorting() && {
10730
11349
  ...get_sorting()
@@ -10732,8 +11351,9 @@ function $f1d7cb69f839a526$export$a54ec244c8863715({
10732
11351
  delete sort_obj?.meta;
10733
11352
  const f = selected_filters_[0]();
10734
11353
  return {
10735
- tenant: tenant_(),
11354
+ merchant: tenant_(),
10736
11355
  market: market_(),
11356
+ locale: backend_locale_(),
10737
11357
  query: get_search_query_(),
10738
11358
  ...(f.length ? {
10739
11359
  filters: f
@@ -10759,11 +11379,12 @@ function $f1d7cb69f839a526$export$a54ec244c8863715({
10759
11379
  })
10760
11380
  });
10761
11381
  }));
10762
- const [suggestions] = $gVhhF$solidjs.createResource($gVhhF$solidjs.createMemo(() => ({
11382
+ const [suggestions] = $gVhhF$solidjs.createResource(() => ({
10763
11383
  query: get_search_query_(),
10764
- tenant: tenant_(),
10765
- market: market_()
10766
- })), opts => depict_api_.suggest(opts));
11384
+ merchant: tenant_(),
11385
+ market: market_(),
11386
+ locale: backend_locale_()
11387
+ }), opts => depict_api_.suggest(opts));
10767
11388
  const available_sortings_ = $gVhhF$solidjs.createMemo(() => search_results_()?.sorts?.map(sort => ({
10768
11389
  ...sort,
10769
11390
  order: sort.order ?? "desc"
@@ -11248,7 +11869,7 @@ class $2c61e4cd8229c49a$export$ac6237957a15b3f0 {
11248
11869
  search_query_url_param_name_: search_query_url_param_name_,
11249
11870
  previous_searches_: previous_searches,
11250
11871
  depict_api_: depict_api_,
11251
- tenant_: this.#merchant_signal[0],
11872
+ merchant_: this.#merchant_signal[0],
11252
11873
  clear_filters_: clear_filters_on_next_submit_,
11253
11874
  market_: this.#market_signal[0],
11254
11875
  submit_query_: configured_submit_query_,
@@ -11362,11 +11983,12 @@ class $2c61e4cd8229c49a$export$ac6237957a15b3f0 {
11362
11983
  depict_api_: depict_api_
11363
11984
  } = $2c61e4cd8229c49a$var$privately_shared_properties.get(this);
11364
11985
  const result = await depict_api_.query({
11365
- tenant: this.merchant,
11986
+ merchant: this.merchant,
11366
11987
  market: this.market,
11367
11988
  query: query,
11368
11989
  filters: filters,
11369
- limit: maxResults
11990
+ limit: maxResults,
11991
+ locale: this.localization.backend_locale_
11370
11992
  });
11371
11993
  if (result.failed) throw new Error("Failed to fetch search results");
11372
11994
  return result.displays;
@@ -11806,7 +12428,4 @@ function $0a6acf31d1eae57c$var$clean_url(url) {
11806
12428
  url_object.hash = "";
11807
12429
  return url_object.href;
11808
12430
  }
11809
- const $a3280f0aad997933$export$c3834fa86c616831 = [[4], [3, 1024], [2, 901]];
11810
- const $a3280f0aad997933$export$864d304a0bc46829 = "2%";
11811
- const $a3280f0aad997933$export$7bf543b9d9be2c22 = (0, $0b23bfd073d9a4e8$export$b91cec6bdc6b32a1);
11812
12431
  $gVhhF$depictaiutilishared.add_to_version_info("ui", (0, $b757f75811f3261f$export$83d89fbfd8236492));