@depict-ai/ui 0.0.79 → 0.0.81

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/dist/main.js CHANGED
@@ -31,11 +31,11 @@ $parcel$export(module.exports, "DepictAPI", () => $9ce64f69303c371e$export$e015e
31
31
  $parcel$export(module.exports, "media_query_to_accessor", () => $beec9d22e42ed2cf$export$d9f36cf74e24d595);
32
32
  $parcel$export(module.exports, "setup_fast_leave", () => $d589470b68ce5b67$export$689e204eadb33baf);
33
33
  $parcel$export(module.exports, "show_toast", () => $b3e6a0e9382bf87e$export$5196e4c01fa56fcb);
34
- $parcel$export(module.exports, "solid_format_price", () => $5fc9fc23df1591db$export$469c7af753d08925);
34
+ $parcel$export(module.exports, "SolidFormatPrice", () => $5fc9fc23df1591db$export$a71e92cfbb498adc);
35
35
  $parcel$export(module.exports, "connect_search_field_height_to_aligner_height", () => $246e3e89a097f014$export$828dcdd425fd3231);
36
36
  $parcel$export(module.exports, "PageReplacer", () => $37e96a5ebc768cc7$export$3ccaa27d81dd8556);
37
37
  $parcel$export(module.exports, "version", () => $ae93561d5649a847$export$83d89fbfd8236492);
38
- /*! Depict.ai search and product listing SDK */ const $ae93561d5649a847$export$83d89fbfd8236492 = "0.0.79";
38
+ /*! Depict.ai search and product listing SDK */ const $ae93561d5649a847$export$83d89fbfd8236492 = "0.0.81";
39
39
 
40
40
 
41
41
 
@@ -57,25 +57,28 @@ async function $8c4e48a4bf96b284$export$58e808b1db15d3bc({ merchant: merchant ,
57
57
 
58
58
 
59
59
 
60
- function $1ee6da2465098194$export$e183a13865960371(params_to_default_value) {
60
+ function $1ee6da2465098194$export$e183a13865960371(params_to_default_value, router_) {
61
61
  const signals = {};
62
62
  const entries = Object.entries(params_to_default_value);
63
63
  const event_handler = (0, $46MJV$depictaiutilishared.catchify)(({ state: state })=>$1ee6da2465098194$var$history_state_change(signals, entries, state));
64
- for (const [param, default_value] of entries){
65
- const [read_signal] = signals[param] = (0, $46MJV$solidjs.createSignal)(history.state?.[param] ?? default_value);
66
- (0, $46MJV$solidjs.createComputed)((0, $46MJV$depictaiutilishared.catchify)(()=>{
64
+ // createRenderEffect because we need the instant execution so the signals always contain values, even before solid's render phase
65
+ (0, $46MJV$solidjs.createRenderEffect)(()=>{
66
+ let signal_changed = false;
67
+ let { state: state } = history; // cloning isn't necessary because we're calling replaceState on it anyway
68
+ if (state === null || typeof state != "object") state = {};
69
+ for (const [param, default_value] of entries){
70
+ const [read_signal] = signals[param] ||= (0, $46MJV$solidjs.createSignal)(state[param] ?? default_value);
67
71
  const new_value = read_signal();
68
- let { state: state } = history; // cloning isn't necessary because we're calling replaceState on it anyway
69
- if (new_value !== state?.[param]) {
70
- if (state === null || typeof state != "object") state = {};
72
+ if (new_value !== state[param]) {
73
+ signal_changed = true;
71
74
  state[param] = new_value;
72
- history.replaceState(state, "", location.href);
73
75
  }
74
- }));
75
- }
76
+ }
77
+ if (signal_changed) router_.navigate_.replace_state_(state);
78
+ });
76
79
  window.addEventListener("popstate", event_handler);
77
80
  (0, $46MJV$solidjs.onCleanup)((0, $46MJV$depictaiutilishared.catchify)(()=>window.removeEventListener("popstate", event_handler)));
78
- (0, $46MJV$solidjs.createEffect)((0, $46MJV$depictaiutilishared.catchify)(()=>(0, $46MJV$solidjs.untrack)((0, $46MJV$depictaiutilishared.catchify)(()=>$1ee6da2465098194$var$history_state_change(signals, entries, history.state))))); // we need this to run after the first writing
81
+ (0, $46MJV$solidjs.createEffect)((0, $46MJV$depictaiutilishared.catchify)(()=>(0, $46MJV$solidjs.untrack)((0, $46MJV$depictaiutilishared.catchify)(()=>$1ee6da2465098194$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
79
82
  return signals;
80
83
  }
81
84
  function $1ee6da2465098194$var$history_state_change(signals, entries, state) {
@@ -89,8 +92,8 @@ function $1ee6da2465098194$var$history_state_change(signals, entries, state) {
89
92
  }
90
93
 
91
94
 
92
- function $0de081f67b6d15b5$export$9862539c89138352(get_default_values_) {
93
- const state = (0, $1ee6da2465098194$export$e183a13865960371)(get_default_values_());
95
+ function $0de081f67b6d15b5$export$9862539c89138352(get_default_values_, router_) {
96
+ const state = (0, $1ee6da2465098194$export$e183a13865960371)(get_default_values_(), router_);
94
97
  const reset_state = ()=>{
95
98
  const new_defaults = get_default_values_();
96
99
  for(const key in state){
@@ -315,8 +318,12 @@ function $891da49c419865de$export$92f2da32c6e7e7ee({ search_results_: search_res
315
318
 
316
319
 
317
320
 
318
- function $5fc9fc23df1591db$export$469c7af753d08925({ price_: price_ , price_formatting_: price_formatting_ }) {
319
- return (0, $46MJV$solidjs.createMemo)(()=>(0, $46MJV$depictaiutilishared.standard_price_format)(price_(), price_formatting_().places_after_comma_, price_formatting_().decimal_places_delimiter_, price_formatting_().thousands_delimiter_));
321
+
322
+ function $5fc9fc23df1591db$export$a71e92cfbb498adc(props) {
323
+ return (0, $46MJV$solidjs.createMemo)(()=>{
324
+ const price_formatting = props.price_formatting_;
325
+ return (0, $46MJV$depictaiutilishared.standard_price_format)(props.price_, price_formatting.places_after_comma_, price_formatting.decimal_places_delimiter_, price_formatting.thousands_delimiter_);
326
+ });
320
327
  }
321
328
 
322
329
 
@@ -423,19 +430,27 @@ function $08fa9d20f7ec85af$export$83fd5de5504a7a67({ formatted_number_of_results
423
430
  }));
424
431
  });
425
432
  return (()=>{
426
- const _el$ = $08fa9d20f7ec85af$var$_tmpl$.cloneNode(true), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.nextSibling, _el$6 = _el$4.nextSibling, _el$7 = _el$6.nextSibling, _el$10 = _el$7.nextSibling, _el$8 = _el$10.nextSibling, _el$9 = _el$8.nextSibling;
433
+ const _el$ = $08fa9d20f7ec85af$var$_tmpl$.cloneNode(true), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.nextSibling, _el$7 = _el$4.nextSibling, _el$8 = _el$7.nextSibling, _el$11 = _el$8.nextSibling, _el$9 = _el$11.nextSibling, _el$10 = _el$9.nextSibling;
427
434
  const _ref$ = element;
428
435
  typeof _ref$ === "function" ? (0, $46MJV$solidjsweb.use)(_ref$, _el$) : element = _el$;
429
- (0, $46MJV$solidjsweb.insert)(_el$3, (0, $5fc9fc23df1591db$export$469c7af753d08925)({
430
- price_: first_to_show,
431
- price_formatting_: modified_price_formatting_
436
+ (0, $46MJV$solidjsweb.insert)(_el$3, (0, $46MJV$solidjsweb.createComponent)((0, $5fc9fc23df1591db$export$a71e92cfbb498adc), {
437
+ get price_ () {
438
+ return first_to_show();
439
+ },
440
+ get price_formatting_ () {
441
+ return modified_price_formatting_();
442
+ }
432
443
  }));
433
- (0, $46MJV$solidjsweb.insert)(_el$6, (0, $5fc9fc23df1591db$export$469c7af753d08925)({
434
- price_: last_to_show,
435
- price_formatting_: modified_price_formatting_
444
+ (0, $46MJV$solidjsweb.insert)(_el$7, (0, $46MJV$solidjsweb.createComponent)((0, $5fc9fc23df1591db$export$a71e92cfbb498adc), {
445
+ get price_ () {
446
+ return last_to_show();
447
+ },
448
+ get price_formatting_ () {
449
+ return modified_price_formatting_();
450
+ }
436
451
  }));
437
- (0, $46MJV$solidjsweb.insert)(_el$2, of_, _el$10);
438
- (0, $46MJV$solidjsweb.insert)(_el$9, count_to_show);
452
+ (0, $46MJV$solidjsweb.insert)(_el$2, of_, _el$11);
453
+ (0, $46MJV$solidjsweb.insert)(_el$10, count_to_show);
439
454
  return _el$;
440
455
  })();
441
456
  }
@@ -448,134 +463,6 @@ function $08fa9d20f7ec85af$export$83fd5de5504a7a67({ formatted_number_of_results
448
463
 
449
464
 
450
465
 
451
- /** @jsxImportSource solid-js */
452
- function $1089684cb32bf922$export$daf1a0aef2143a61({ first_result_in_viewport_: [, set_first_result_in_viewport_] , last_result_in_viewport_: [, set_last_result_in_viewport_] }) {
453
- const intersecting = new Set();
454
- const counting_is = new IntersectionObserver((records)=>{
455
- let kids;
456
- for (const { intersectionRatio: intersectionRatio , target: target } of records){
457
- const intersects = intersectionRatio > 0;
458
- const has_target = intersecting.has(target);
459
- if (intersects && !has_target) intersecting.add(target);
460
- else if (!intersects && has_target) intersecting.delete(target);
461
- }
462
- const numbers = [
463
- ...intersecting
464
- ].map((el)=>{
465
- const index = (kids ||= [
466
- ...el.parentElement?.children || []
467
- ]).indexOf(el);
468
- if (index < 0) return undefined;
469
- return index + 1;
470
- }).filter((item)=>item != undefined);
471
- set_first_result_in_viewport_(Math.min(...numbers));
472
- set_last_result_in_viewport_(Math.max(...numbers));
473
- });
474
- (0, $46MJV$solidjs.onCleanup)(()=>counting_is.disconnect());
475
- return (els)=>{
476
- for(let i = 0; i < els?.length; i++){
477
- const el = els[i];
478
- if (el instanceof Element) counting_is.observe(el);
479
- }
480
- };
481
- }
482
-
483
-
484
- /** @jsxImportSource solid-js */
485
-
486
- function $6154d0a3d9e9b16e$export$36aef51ac7a64eae({ depict_api_: depict_api_ , min_products_to_fetch_: min_products_to_fetch_ , all_products_loaded_: all_products_loaded_ , query_base_: query_base_ , observe_for_counting_: observe_for_counting_ , start_cursor_: start_cursor_ }) {
487
- let last_loaded = +new Date();
488
- let dead = false;
489
- let current_cursor = start_cursor_;
490
- const target_to_info = new Map();
491
- const tear_down = (0, $46MJV$depictaiutilishared.catchify)((loaded_all_products)=>{
492
- intersection_observer.disconnect();
493
- target_to_info.clear();
494
- dead = true;
495
- if (loaded_all_products) all_products_loaded_?.[1]?.(true);
496
- });
497
- const deduped_load_more = (0, $46MJV$depictaiutilishared.deparallelize)(async (...args)=>{
498
- const now = +new Date();
499
- // load faster if someone is scrolling aggressively
500
- const num_to_load = now - last_loaded < 10000 ? min_products_to_fetch_ * 5 : min_products_to_fetch_;
501
- const new_cursor = await $6154d0a3d9e9b16e$var$load_more(...args, num_to_load);
502
- if (new_cursor) current_cursor = new_cursor;
503
- last_loaded = now;
504
- });
505
- const intersection_observer = new IntersectionObserver((0, $46MJV$depictaiutilishared.catchify)((records)=>{
506
- let num_children;
507
- for(let i = 0; i < records.length; i++){
508
- // we assume they all have the same parent 👀
509
- const record = records[i];
510
- if (record.intersectionRatio <= 0) continue;
511
- const { target: target } = record;
512
- const parent = target.parentElement;
513
- if (!parent) continue; // we're not in DOM or something funky
514
- if (num_children == undefined) {
515
- const kids = parent.childElementCount;
516
- if (isNaN(kids)) continue;
517
- num_children = kids;
518
- }
519
- const info = target_to_info.get(target);
520
- if (!info) continue; // How did this happen?
521
- let actual_index_;
522
- for(let i = 0; i < num_children; i++){
523
- const child = parent.children[i];
524
- if (child === target) {
525
- actual_index_ = i;
526
- break;
527
- }
528
- }
529
- if (actual_index_ == undefined) continue;
530
- const in_range = actual_index_ / num_children * 100;
531
- const range_to_load_at = current_cursor === start_cursor_ ? 50 : 75; // if first load, load earlier
532
- if (in_range > range_to_load_at) {
533
- // load if more than 75% of elements are in view, this will make so that we load sooner and sooner which maybe (?) will adjust to people scrolling quickly :)
534
- intersection_observer.disconnect(); // no need to watch these els anymore
535
- deduped_load_more({
536
- depict_api_: depict_api_,
537
- info_: info,
538
- container_: parent,
539
- query_base_: query_base_,
540
- on_reached_end_: ()=>tear_down(true),
541
- cursor_: current_cursor
542
- });
543
- }
544
- }
545
- }));
546
- (0, $46MJV$solidjs.onCleanup)(tear_down);
547
- return (items, _display, info_)=>{
548
- observe_for_counting_(items);
549
- if (dead) return items;
550
- for(let i = 0; i < items?.length; i++){
551
- const item = items[i];
552
- if (item instanceof Element) {
553
- target_to_info.set(item, info_);
554
- intersection_observer.observe(item);
555
- }
556
- }
557
- return items;
558
- };
559
- }
560
- async function $6154d0a3d9e9b16e$var$load_more({ depict_api_: depict_api_ , query_base_: query_base_ , container_: container_ , on_reached_end_: on_reached_end_ , info_: { rendering_options: rendering_options , t: t } , cursor_: cursor_ }, num_results_to_load) {
561
- (0, $46MJV$depictaiutilishared.dlog)("SearchResults: Loading more");
562
- const base_part = (0, $46MJV$solidjs.untrack)(query_base_);
563
- const api_response = await depict_api_["query_id" in base_part ? "list" : "query"]({
564
- cursor: cursor_,
565
- limit: num_results_to_load,
566
- ...base_part
567
- });
568
- const new_displays = api_response?.displays || [];
569
- const { elements: elements } = await (0, $46MJV$depictaiutilishared.Rec_Renderer)(t, {
570
- ...rendering_options,
571
- recs: new_displays || []
572
- });
573
- if (elements) container_.append(...elements);
574
- else (0, $46MJV$depictaiutilishared.dlog)("SearchResults: Got no elements, that's weird", api_response);
575
- if ("cursor" in api_response) return api_response.cursor;
576
- else if (!api_response?.failed) on_reached_end_();
577
- }
578
-
579
466
 
580
467
 
581
468
 
@@ -710,7 +597,8 @@ function $92e4e7906daa1ff8$export$8895d39404bd2bb1(props) {
710
597
  const { user_triggered_: user_triggered_ , i18n_: i18n_ , also_clear_sorting_: also_clear_sorting_ , local_filter_cache_: [get_local_filter_cache, set_local_filter_cache] , selected_filters_: [get_selected_filters, set_selected_filters] , expanded_hierarchical_filters_: [get_expanded_hierarchical_filters, set_expanded_hierarchical_filters] , delay_toast_: delay_toast_ } = props;
711
598
  const previous_selected_filters = (0, $46MJV$solidjs.untrack)(get_selected_filters);
712
599
  if (!previous_selected_filters.length) {
713
- // no filters selected, do nothing
600
+ // no filters selected, still clear sorting if applicable but don't display a toast for that since it's very minor
601
+ if (also_clear_sorting_) props.current_sorting_[1]();
714
602
  if (delay_toast_) return ()=>{};
715
603
  return;
716
604
  }
@@ -810,13 +698,8 @@ function $2b4e3538e183d885$export$ef6006467f04ee41({ i18n_: i18n_ , expanded_hie
810
698
  ]);
811
699
 
812
700
 
813
- /*
814
- * Usually product templates are somewhat height-elastic depending on the content, i.e. if the title is longer we might up to two extra rows for this. That means that the placeholders almost never will reflect the size of the actual content when we do scroll restoration. This magic number specifies how many extra placeholders we should render everytime to compensate for this, since if the placeholders are in total shorter than the old scroll location the scroll restoration won't work.
815
- */ const $39d15a684cb3e309$export$6c9030e511152266 = 30;
816
-
817
-
818
701
  function $8e863dc22b06b688$export$a2cc176055f8f08() {
819
- return document.createComment("Please try setting `colsAtSize` on `DepictProvider`/`DepictSearch` to change the grid before setting it with CSS. If you do with CSS, set `ColsAtSize` to an empty array to ensure no declarations created by the SDK leak through.");
702
+ return document.createComment("Please try setting `colsAtSize` on the `SearchPage`/`CategoryPage` components to change the grid before setting it with CSS. If you do with CSS, set `ColsAtSize` to an empty array to ensure no declarations created by the SDK leak through.");
820
703
  }
821
704
 
822
705
 
@@ -869,77 +752,347 @@ function $0f2f58dd60b11888$export$b69d0d92862de18b(props) {
869
752
  }
870
753
 
871
754
 
872
- const $8d94abc871e13baf$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="PLP-results"></div>`, 2), $8d94abc871e13baf$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="cards"></div>`, 2);
873
- let $8d94abc871e13baf$var$cached_placeholder_element;
874
- function $8d94abc871e13baf$export$3925f87b1545cfc6({ plp_results_: plp_results_ , depict_api_: depict_api_ , all_products_loaded_: all_products_loaded_ , min_products_to_fetch_: min_products_to_fetch_ , query_base_: query_base_ , first_result_in_viewport_: first_result_in_viewport_ , last_result_in_viewport_: last_result_in_viewport_ , scroll_restoration_data_: scroll_restoration_data_ , no_results_options_: no_results_options_ , desktop_filter_elements_: desktop_filter_elements_ , sort_or_filter_open_: sort_or_filter_open_ , rr_options_: rr_options_ , layout_options_: layout_options_ , tenant_object_: tenant_object_ , type_for_tracking_: type_for_tracking_ , id_currently_querying_for_: id_currently_querying_for_ }) {
875
- // 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
876
- const is_loading = (0, $46MJV$solidjs.createMemo)(()=>plp_results_.loading || query_base_.loading);
877
- const cleanup_old_cards = [];
878
- const render_and_insert_results = (0, $46MJV$depictaiutilishared.deparallelize_no_drop)(async (insert_into, owner)=>{
879
- const fallback_to_no_results = ()=>(0, $46MJV$solidjs.runWithOwner)(owner, ()=>insert_into.replaceChildren(...(0, $2b4e3538e183d885$export$ef6006467f04ee41)(no_results_options_)));
880
- const observe_for_counting_ = (0, $46MJV$solidjs.runWithOwner)(owner, ()=>(0, $1089684cb32bf922$export$daf1a0aef2143a61)({
881
- last_result_in_viewport_: last_result_in_viewport_,
882
- first_result_in_viewport_: first_result_in_viewport_
883
- }));
884
- const current_results = (0, $46MJV$solidjs.untrack)(plp_results_);
885
- const current_cursor = current_results.cursor;
886
- const load_more_post_processor = current_cursor // if we already got everything, don't make actual load more post processor.
887
- ? (0, $6154d0a3d9e9b16e$export$36aef51ac7a64eae)({
888
- depict_api_: depict_api_,
889
- min_products_to_fetch_: min_products_to_fetch_,
890
- all_products_loaded_: all_products_loaded_,
891
- query_base_: query_base_,
892
- observe_for_counting_: observe_for_counting_,
893
- start_cursor_: current_cursor
894
- }) : function(items) {
895
- observe_for_counting_(items);
896
- return items;
897
- };
898
- // create owner to run product cards with an Owner, so they know when they've gotten removed
899
- const [owner_for_cards, dispose_our_cards] = (0, $46MJV$solidjs.createRoot)((dispose)=>[
900
- (0, $46MJV$solidjs.getOwner)(),
901
- dispose
755
+
756
+
757
+ function $f93412cebc8f7bac$export$2f0cbfbb4354bb52(elements) {
758
+ // FYI this probably doesn't work on hugely deep nestings or large amount of elements
759
+ return (0, $46MJV$solidjs.createMemo)(()=>$f93412cebc8f7bac$var$unwrapping_helper(elements));
760
+ }
761
+ function $f93412cebc8f7bac$var$unwrapping_helper(elements) {
762
+ const result = [];
763
+ if (Array.isArray(elements)) for(let i = 0; i < elements.length; i++){
764
+ const element = elements[i];
765
+ result.push(...$f93412cebc8f7bac$var$unwrapping_helper(element));
766
+ }
767
+ else if (typeof elements == "function") result.push(...$f93412cebc8f7bac$var$unwrapping_helper(elements()));
768
+ else if (elements != undefined && typeof elements != "boolean") result.push(elements);
769
+ return result;
770
+ }
771
+
772
+
773
+ let $7b0b7e887b485a91$var$cached_placeholder_element;
774
+ let $7b0b7e887b485a91$var$rendering_cached_placeholder_element;
775
+ function $7b0b7e887b485a91$export$f33414a4df0afd3f({ product_card_template_: product_card_template_ , num_placeholders_: num_placeholders_ }) {
776
+ const [get_elements, set_elements] = (0, $46MJV$solidjs.createSignal)([]);
777
+ let existing_num = 0;
778
+ (0, $46MJV$solidjs.createRenderEffect)(()=>{
779
+ const to_add = num_placeholders_() - existing_num;
780
+ if (to_add <= 0) return;
781
+ // Below comment is from when we used recommendation renderer and manual DOM manipulation for this, but I'm still scared to remove placeholders and mess up scroll restoration, so I'm keeping the way it worked. Otherwise, <Index> could be used which would be far more elegant.
782
+ // We don't need to remove placeholders, only need to add. The reason for that is that chrome restores the scroll position once all tasks queued as reaction of the "popstate" events have been completed in the task queue. That means that we need to get the placeholders in fast, or we might lose scroll position if the previous site was shorter.
783
+ // The query id and the amount might update in separate tasks because one comes from href_change_ipns and the other one from another "popstate" listener. Therefore, we need to be able to dynamically add more placeholders. I'm not entirely sure about this anymore though, since we have the scroll position on a per-id basis it might work anyway but THIS WORKS, and I've been working on this bug for 3 hours so let's just keep it this way.
784
+ set_elements((prev)=>[
785
+ ...prev,
786
+ ...Array.from({
787
+ length: to_add
788
+ }).map(()=>$7b0b7e887b485a91$var$Placeholder({
789
+ product_card_template_: product_card_template_
790
+ }))
902
791
  ]);
903
- const rendering_result = await (0, $46MJV$depictaiutilishared.default_rr)(tenant_object_, {
904
- type: type_for_tracking_,
905
- recs: current_results.displays,
906
- ...rr_options_,
907
- ...typeof rr_options_.template === "function" ? {
908
- template: $8d94abc871e13baf$var$wrap_template_to_throw_into_error_boundary(rr_options_.template, owner_for_cards)
909
- } : {},
910
- post_processors: [
911
- ...rr_options_.post_processors || [],
912
- load_more_post_processor
913
- ]
792
+ existing_num += to_add;
793
+ });
794
+ return get_elements; // https://github.com/solidjs/solid/releases/tag/v1.7.0
795
+ }
796
+ /**
797
+ * Get one placeholder element. It will be cloned for each placeholder for ultimate performance even when solid-js isn't rendering the placeholders.
798
+ */ function $7b0b7e887b485a91$var$Placeholder({ product_card_template_: product_card_template_ }) {
799
+ const get_cloned_placeholders = (element_to_clone = $7b0b7e887b485a91$var$cached_placeholder_element)=>Array.isArray(element_to_clone) ? element_to_clone.map((el)=>el instanceof Node ? el.cloneNode(true) : el) : element_to_clone;
800
+ if ($7b0b7e887b485a91$var$cached_placeholder_element) return get_cloned_placeholders();
801
+ let dispose_original_copy;
802
+ const get_unwrapped_element = (0, $46MJV$solidjs.createRoot)((dispose)=>{
803
+ dispose_original_copy = dispose;
804
+ // if product_card_template_ is async and rejects the resource will take care of throwing upwards here in the solid-js error handling system
805
+ const [resource] = (0, $46MJV$solidjs.createResource)(()=>{
806
+ if ($7b0b7e887b485a91$var$rendering_cached_placeholder_element) return $7b0b7e887b485a91$var$rendering_cached_placeholder_element;
807
+ const return_value = product_card_template_(null, undefined);
808
+ if (typeof return_value === "object" && typeof return_value?.then === "function") // Is Promise or promise-like object
809
+ $7b0b7e887b485a91$var$rendering_cached_placeholder_element = return_value;
810
+ return return_value;
914
811
  });
915
- // check if we still should insert or something new happened while we were rendering
916
- if ((0, $46MJV$solidjs.untrack)(has_no_results_or_failed) || (0, $46MJV$solidjs.untrack)(is_loading)) {
917
- (0, $46MJV$depictaiutilishared.dlog)("PLPResults: Not inserting rendered results because we became loading or switched to no results");
918
- return;
919
- }
920
- const { elements: elements , should_stay_inserted: should_stay_inserted } = rendering_result;
921
- if (!elements) {
922
- fallback_to_no_results(); // rendering failed at this point but just pretend it's no results
812
+ return (0, $46MJV$solidjs.createMemo)(()=>{
813
+ if (resource.loading) return ()=>[];
814
+ return (0, $f93412cebc8f7bac$export$2f0cbfbb4354bb52)(resource);
815
+ });
816
+ });
817
+ (0, $46MJV$solidjs.onCleanup)(()=>{
818
+ if ($7b0b7e887b485a91$var$rendering_cached_placeholder_element) {
819
+ // If we're still rendering in our separate root, let the rendering finish or other <Placeholder> components waiting for it might get an incomplete result
820
+ const unset_current_rendering = ()=>{
821
+ dispose_original_copy();
822
+ $7b0b7e887b485a91$var$rendering_cached_placeholder_element = undefined;
823
+ };
824
+ $7b0b7e887b485a91$var$rendering_cached_placeholder_element?.then(unset_current_rendering, unset_current_rendering);
825
+ } else // Otherwise, just make sure we've disposed our root
826
+ dispose_original_copy();
827
+ });
828
+ return (0, $46MJV$solidjs.createMemo)(()=>{
829
+ const unwrapped_array = get_unwrapped_element()();
830
+ if (!unwrapped_array?.length || !unwrapped_array.every((item)=>item)) // Haven't finished rendering yet in case of "async" rendering, so don't freeze the elements yet
831
+ return;
832
+ // placeholders have finished rendering, freeze the elements
833
+ $7b0b7e887b485a91$var$cached_placeholder_element = get_cloned_placeholders(unwrapped_array); // Clone initial return value so that who gave us the elements can't mutate them, which has caused issues before with react
834
+ $7b0b7e887b485a91$var$rendering_cached_placeholder_element = undefined;
835
+ dispose_original_copy(); // So that this memo will never re-run and the placeholder rendering function can clean up
836
+ return get_cloned_placeholders(); // clone, just in case. If we wouldn't, someone could modify the copy in the DOM, and it would affect the cached version
837
+ });
838
+ }
839
+
840
+
841
+ /*
842
+ * Usually product templates are somewhat height-elastic depending on the content, i.e. if the title is longer we might up to two extra rows for this. That means that the placeholders almost never will reflect the size of the actual content when we do scroll restoration. This magic number specifies how many extra placeholders we should render everytime to compensate for this, since if the placeholders are in total shorter than the old scroll location the scroll restoration won't work.
843
+ */ const $39d15a684cb3e309$export$6c9030e511152266 = 30;
844
+
845
+
846
+ /** @jsxImportSource solid-js */
847
+
848
+
849
+
850
+ function $20717024e763c0fa$export$5e4aed86c12acdd9({ percentage_in_view_: percentage_in_view_ , set_extra_displays_: set_extra_displays_ , all_products_loaded_: all_products_loaded_ , plp_results_: plp_results_ , min_products_to_fetch_: min_products_to_fetch_ , query_base_: query_base_ , depict_api_: depict_api_ }) {
851
+ let last_loaded = +new Date();
852
+ let is_loading_more = false;
853
+ let is_first_load = true;
854
+ const [get_last_cursor, set_last_cursor] = (0, $46MJV$solidjs.createSignal)();
855
+ (0, $46MJV$solidjs.createComputed)((0, $46MJV$solidjs.on)(plp_results_, ()=>set_extra_displays_([]), {
856
+ defer: true
857
+ })); // empty array when a new request has completed (don't run this initially since it will already be empty)
858
+ (0, $46MJV$solidjs.createComputed)(()=>{
859
+ set_last_cursor(plp_results_()?.cursor);
860
+ last_loaded = +new Date();
861
+ is_first_load = true;
862
+ });
863
+ (0, $46MJV$solidjs.createEffect)((0, $46MJV$depictaiutilishared.catchify)(async ()=>{
864
+ const be_above_percentage = is_first_load ? 50 : 75; // if first load, load earlier
865
+ if (percentage_in_view_() < be_above_percentage || is_loading_more) return;
866
+ if (!get_last_cursor()) {
867
+ // dlog("All results loaded, can't load more");
868
+ all_products_loaded_?.[1](true); // This is unset in SearchPage as we start fetching new results
923
869
  return;
924
870
  }
925
- insert_into.replaceChildren(...elements);
926
- // Dispose the old cards just after the cards have been removed from the DOM
927
- cleanup_old_cards.forEach((cleanup_function)=>cleanup_function());
928
- cleanup_old_cards.push(dispose_our_cards); // push after calling, so that we don't instantly demolish ourselves lol
929
- should_stay_inserted?.then((should)=>{
930
- // If we shouldn't stay inserted for some reason, switch back to no results
931
- if (!should) fallback_to_no_results();
871
+ // dlog("More than ", be_above_percentage, "% in view, ", percentage_in_view_(), "%, loading more");
872
+ is_loading_more = true;
873
+ const base_part = (0, $46MJV$solidjs.untrack)(query_base_);
874
+ const now = +new Date();
875
+ // load faster if someone is scrolling aggressively
876
+ const number_of_results_to_load = is_first_load ? // After first load, always just load 20 since people might just be browsing the top ones still
877
+ min_products_to_fetch_ : now - last_loaded < 10000 ? min_products_to_fetch_ * 5 : min_products_to_fetch_;
878
+ // dlog("loading ", number_of_results_to_load, "products, because it was", now - last_loaded, "ms since last load");
879
+ const api_response = await depict_api_["query_id" in base_part ? "list" : "query"]({
880
+ cursor: get_last_cursor(),
881
+ limit: number_of_results_to_load,
882
+ ...base_part
883
+ });
884
+ const new_displays = api_response?.displays || [];
885
+ set_extra_displays_((old_value)=>{
886
+ // We want this to go fast. The apply method is the fastest way to add to an array, and AFAIK it's faster to add than to create a new one.
887
+ // eslint-disable-next-line prefer-spread
888
+ old_value.push.apply(old_value, new_displays);
889
+ return old_value;
932
890
  });
891
+ set_last_cursor(api_response.cursor);
892
+ is_loading_more = false;
893
+ last_loaded = +new Date();
894
+ is_first_load = false;
895
+ }));
896
+ }
897
+
898
+
899
+
900
+ function $ef82a1d4fac1efad$export$63dd0350f8559dda({ displays_by_key_: displays_by_key_ , get_last_result_in_viewport_: get_last_result_in_viewport_ , index_to_target_map_: index_to_target_map_ , is_loading_: is_loading_ , get_extra_displays: get_extra_displays }) {
901
+ const [get_has_rendered_toggle, set_has_rendered_toggle] = (0, $46MJV$solidjs.createSignal)(false);
902
+ (0, $46MJV$solidjs.createEffect)(()=>{
903
+ // We need this to run after the "render phase"
904
+ get_extra_displays();
905
+ set_has_rendered_toggle((old)=>!old);
906
+ });
907
+ return (0, $46MJV$solidjs.createMemo)(()=>{
908
+ const last = get_last_result_in_viewport_();
909
+ // Check if we are past the last result, in that case we want it to count as 100% for a better infinite scroll experience
910
+ past_last_result_check: {
911
+ const elements_of_last_result = index_to_target_map_.get(index_to_target_map_.size - 1);
912
+ if (elements_of_last_result) {
913
+ if ((0, $46MJV$solidjs.untrack)(is_loading_)) {
914
+ // We're loading, wait check again after we have inserted our new results
915
+ get_has_rendered_toggle();
916
+ break past_last_result_check;
917
+ }
918
+ for (const element of elements_of_last_result){
919
+ if (document.documentElement.contains(element) && element.getBoundingClientRect().top <= 0) // dlog(element, "which is of last product card is in or above viewport, probably loading more");
920
+ return 100;
921
+ }
922
+ }
923
+ }
924
+ if (isNaN(last)) return 0;
925
+ if (Math.abs(last) === Infinity) // No product card in view and not after last card, assume first card
926
+ return 0;
927
+ return last / displays_by_key_().size * 100;
928
+ });
929
+ }
930
+
931
+
932
+
933
+
934
+ /**
935
+ * Gets product_id (the thing we key the rendering on) from a display
936
+ */ function $f1ea6fcde8fab269$export$548d053aba053d79(display) {
937
+ if ("variant_index" in display) {
938
+ const actual_display = display.variant_displays[display.variant_index];
939
+ return actual_display.product_id;
940
+ }
941
+ return display.product_id;
942
+ }
943
+
944
+
945
+
946
+ function $ea6c1dd5af2900d8$export$7f8bd308237ab5a5(get_displays_) {
947
+ const displays_by_key_ = (0, $46MJV$solidjs.createMemo)(()=>{
948
+ const displays = get_displays_();
949
+ // We key by product_id because that's what can be used to uniquely identify products
950
+ // This way <For> can optimize the rendering
951
+ const map = new Map();
952
+ for(let i = 0; i < displays.length; i++){
953
+ const display = displays[i];
954
+ const product_id = (0, $f1ea6fcde8fab269$export$548d053aba053d79)(display);
955
+ map.set(product_id, display);
956
+ }
957
+ return map;
958
+ });
959
+ return displays_by_key_;
960
+ }
961
+ function $ea6c1dd5af2900d8$export$43f0fb951fcb0c54({ displays_by_key_: displays_by_key_ , merchant_: merchant_ , market_: market_ , product_card_template_: product_card_template_ , do_per_elements_: do_per_elements_ }) {
962
+ return (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.For), {
963
+ get each () {
964
+ return [
965
+ ...displays_by_key_().keys()
966
+ ];
967
+ },
968
+ children: (product_id, index)=>{
969
+ // We're using `untrack` here since we don't want to react in here to displays_by_key changing
970
+ // As long as our key stays the same we assume that the display hasn't changed, so we don't want to rerender
971
+ // If the key gets removed, <For> will remove us
972
+ const owner = (0, $46MJV$solidjs.getOwner)();
973
+ const display_accessor = (0, $46MJV$solidjs.createMemo)(()=>displays_by_key_().get(product_id));
974
+ const [product_card_resource] = (0, $46MJV$solidjs.createResource)((0, $46MJV$solidjs.createMemo)(()=>[
975
+ merchant_(),
976
+ market_()
977
+ ]), // re-render when merchant or market changes
978
+ ([merchant, market])=>{
979
+ // get display in the function that re-runs when merchant or market have changed, since the display may have changed but product_id not
980
+ const display = (0, $46MJV$solidjs.untrack)(display_accessor);
981
+ return product_card_template_(display, {
982
+ set_on_index_change: (fn)=>(0, $46MJV$solidjs.runWithOwner)(owner, ()=>(0, $46MJV$solidjs.createEffect)(()=>fn(index()))),
983
+ merchant: merchant,
984
+ market: market
985
+ });
986
+ });
987
+ const node_accessor = (0, $f93412cebc8f7bac$export$2f0cbfbb4354bb52)(product_card_resource);
988
+ (0, $46MJV$solidjs.createEffect)(()=>{
989
+ const product_card_nodes = node_accessor();
990
+ const display = display_accessor();
991
+ const elements = [];
992
+ for(let i = 0; i < product_card_nodes.length; i++){
993
+ const element = product_card_nodes[i];
994
+ if (!(element instanceof Element)) continue;
995
+ elements.push(element);
996
+ // Add tracking ids
997
+ if (!(element instanceof HTMLElement)) continue; // Apparently only HTMLElements have dataset
998
+ const { dataset: dataset } = element;
999
+ const { search_result_id: search_result_id , product_listing_result_id: product_listing_result_id , recommendation_id: recommendation_id } = display;
1000
+ if (search_result_id) dataset.searchResultId = search_result_id;
1001
+ else if (product_listing_result_id) dataset.productListingResultId = product_listing_result_id;
1002
+ else if (recommendation_id) dataset.recommendationId = recommendation_id;
1003
+ }
1004
+ do_per_elements_?.(elements, index);
1005
+ });
1006
+ return product_card_resource; // https://github.com/solidjs/solid/releases/tag/v1.7.0
1007
+ }
1008
+ });
1009
+ }
1010
+
1011
+
1012
+ function $f67fba44c7515f35$export$a1fd619a4743ca08({ plp_results_: plp_results_ , product_card_template_: product_card_template_ , first_result_in_viewport_: [, set_first_result_in_viewport] , last_result_in_viewport_: [get_last_result_in_viewport_, set_last_result_in_viewport] , merchant_: merchant_ , market_: market_ , all_products_loaded_: all_products_loaded_ , min_products_to_fetch_: min_products_to_fetch_ , query_base_: query_base_ , depict_api_: depict_api_ , is_loading_: is_loading_ }) {
1013
+ // The following sets up an intersection observer to determine which results are in the viewport, used for the ScrollStatus indicator and knowing when to load more
1014
+ const target_to_index_map = new Map();
1015
+ const index_to_target_map_ = new Map();
1016
+ const currently_intersecting = new Set();
1017
+ const intersection_observer = new IntersectionObserver((0, $46MJV$depictaiutilishared.catchify)((records)=>{
1018
+ for(let i = 0; i < records.length; i++){
1019
+ const record = records[i];
1020
+ const { target: target , intersectionRatio: intersectionRatio } = record;
1021
+ const index_of_target = target_to_index_map.get(target);
1022
+ const is_in_set = currently_intersecting.has(index_of_target);
1023
+ if (intersectionRatio > 0) {
1024
+ if (!is_in_set) currently_intersecting.add(index_of_target);
1025
+ } else if (is_in_set) currently_intersecting.delete(index_of_target);
1026
+ }
1027
+ set_first_result_in_viewport(Math.min(...currently_intersecting) + 1); // +1 because we want to start counting at 1
1028
+ set_last_result_in_viewport(Math.max(...currently_intersecting) + 1);
1029
+ }, "PLPResults IO failed"));
1030
+ // Although typing doesn't reflect it, plp_results is guaranteed to contain an array of at least one display at this point
1031
+ const [get_extra_displays, set_extra_displays_] = (0, $46MJV$solidjs.createSignal)([], {
1032
+ equals: false
1033
+ });
1034
+ const displays_by_key_ = (0, $ea6c1dd5af2900d8$export$7f8bd308237ab5a5)((0, $46MJV$solidjs.createMemo)(()=>[
1035
+ ...plp_results_().displays,
1036
+ ...get_extra_displays()
1037
+ ]));
1038
+ const percentage_in_view_ = (0, $ef82a1d4fac1efad$export$63dd0350f8559dda)({
1039
+ get_last_result_in_viewport_: get_last_result_in_viewport_,
1040
+ displays_by_key_: displays_by_key_,
1041
+ index_to_target_map_: index_to_target_map_,
1042
+ is_loading_: is_loading_,
1043
+ get_extra_displays: get_extra_displays
1044
+ });
1045
+ (0, $20717024e763c0fa$export$5e4aed86c12acdd9)({
1046
+ percentage_in_view_: percentage_in_view_,
1047
+ set_extra_displays_: set_extra_displays_,
1048
+ all_products_loaded_: all_products_loaded_,
1049
+ plp_results_: plp_results_,
1050
+ min_products_to_fetch_: min_products_to_fetch_,
1051
+ query_base_: query_base_,
1052
+ depict_api_: depict_api_
1053
+ });
1054
+ return (0, $ea6c1dd5af2900d8$export$43f0fb951fcb0c54)({
1055
+ displays_by_key_: displays_by_key_,
1056
+ merchant_: merchant_,
1057
+ market_: market_,
1058
+ product_card_template_: product_card_template_,
1059
+ do_per_elements_: (elements, index_accessor)=>// Adds/removes elements from the "results in viewport" intersection observer above
1060
+ (0, $46MJV$solidjs.createEffect)(()=>{
1061
+ const display_index = index_accessor();
1062
+ // Nested createEffect because we only want to re-run this when the index changes
1063
+ // We need to save in a map which index the elements of this template are so that we can know that in the IntersectionObserver callback
1064
+ for(let i = 0; i < elements.length; i++){
1065
+ const element = elements[i];
1066
+ target_to_index_map.set(element, display_index);
1067
+ intersection_observer.observe(element);
1068
+ (0, $46MJV$solidjs.onCleanup)(()=>{
1069
+ intersection_observer.unobserve(element);
1070
+ target_to_index_map.delete(element);
1071
+ currently_intersecting.delete(display_index);
1072
+ });
1073
+ }
1074
+ index_to_target_map_.set(display_index, elements);
1075
+ (0, $46MJV$solidjs.onCleanup)(()=>index_to_target_map_.delete(display_index));
1076
+ })
933
1077
  });
1078
+ }
1079
+
1080
+
1081
+ const $8d94abc871e13baf$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="PLP-results"></div>`, 2), $8d94abc871e13baf$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="cards"></div>`, 2), $8d94abc871e13baf$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<style></style>`, 2);
1082
+ function $8d94abc871e13baf$export$3925f87b1545cfc6({ plp_results_: plp_results_ , depict_api_: depict_api_ , all_products_loaded_: all_products_loaded_ , min_products_to_fetch_: min_products_to_fetch_ , query_base_: query_base_ , first_result_in_viewport_: first_result_in_viewport_ , last_result_in_viewport_: last_result_in_viewport_ , scroll_restoration_data_: [get_scroll_restoration_data] , no_results_options_: no_results_options_ , desktop_filter_elements_: desktop_filter_elements_ , sort_or_filter_open_: sort_or_filter_open_ , product_card_template_: product_card_template_ , layout_options_: layout_options_ , id_currently_querying_for_: id_currently_querying_for_ }) {
1083
+ // 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
1084
+ const is_loading_ = (0, $46MJV$solidjs.createMemo)(()=>plp_results_.loading || query_base_.loading);
1085
+ const merchant_ = (0, $46MJV$solidjs.createMemo)(()=>query_base_().tenant);
1086
+ const market_ = (0, $46MJV$solidjs.createMemo)(()=>query_base_().market);
934
1087
  const has_no_results_or_failed = (0, $46MJV$solidjs.createMemo)(()=>{
935
1088
  const displays = plp_results_()?.displays;
936
- return !is_loading() && (!Array.isArray(displays) || !displays.length);
1089
+ return !is_loading_() && (!Array.isArray(displays) || !displays.length);
937
1090
  });
938
- if (all_products_loaded_) (0, $46MJV$solidjs.createComputed)(()=>{
1091
+ if (all_products_loaded_) // This is for the case that all products were loaded in the first result I think?
1092
+ (0, $46MJV$solidjs.createComputed)(()=>{
939
1093
  const is_at_end = !plp_results_()?.cursor; // or failed, but we don't wanna / it's not easy to retry
940
- if (!is_loading() && is_at_end) all_products_loaded_[1](true);
1094
+ if (!is_loading_() && is_at_end) all_products_loaded_[1](true);
941
1095
  });
942
- (0, $46MJV$solidjs.onCleanup)(()=>cleanup_old_cards.forEach((fn)=>fn())); // if everything gets cleaned up without new cards replacing the old ones, clean up the last cards
943
1096
  return (()=>{
944
1097
  const _el$ = $8d94abc871e13baf$var$_tmpl$.cloneNode(true);
945
1098
  (0, $46MJV$solidjsweb.insert)(_el$, (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Show), {
@@ -953,7 +1106,7 @@ function $8d94abc871e13baf$export$3925f87b1545cfc6({ plp_results_: plp_results_
953
1106
  return (0, $0f2f58dd60b11888$export$b69d0d92862de18b)({
954
1107
  severity_: "error",
955
1108
  // More granular error handling
956
- // This _also_ fails when a product card rendering fails due to the runWithOwner with a root that was created inside the "root"/"context" of this ErrorBoundary
1109
+ // This _also_ fails when a product card rendering fails
957
1110
  on_error_: (retry)=>{
958
1111
  // re-try / reset ErrorBoundary next time we're getting product cards
959
1112
  const track = (0, $46MJV$solidjs.createReaction)(retry);
@@ -965,83 +1118,108 @@ function $8d94abc871e13baf$export$3925f87b1545cfc6({ plp_results_: plp_results_
965
1118
  // So that the styling looks pretty when we've failed
966
1119
  message_: "Result rendering failed",
967
1120
  get children () {
1121
+ let suspense_contents;
1122
+ let is_just_after_plp_results_update = false;
1123
+ let fallback_is_alive = false;
968
1124
  const random_id = (0, $46MJV$depictaiutilishared.make_random_classname)();
969
- const selector_beginning = `.depict.plp #${random_id}>`;
970
- const cards = (()=>{
971
- const _el$2 = $8d94abc871e13baf$var$_tmpl$2.cloneNode(true);
972
- (0, $46MJV$solidjsweb.setAttribute)(_el$2, "id", random_id);
973
- return _el$2;
974
- })();
975
- const style = document.createElement("style");
976
- (0, $46MJV$solidjs.createRenderEffect)(()=>{
977
- // Add grid styling that changes when filters get opened/closed
978
- const when_filters_closed_cols = layout_options_.cols_at_size;
979
- const cols_at_size = sort_or_filter_open_() ? when_filters_closed_cols.map((row)=>{
980
- const [num_cols_default, , , , override_cols] = row;
981
- const cloned_row = [
982
- ...row
983
- ];
984
- // @ts-ignore
985
- cloned_row[0] = num_cols_default - 1;
986
- if (override_cols) // @ts-ignore
987
- cloned_row[4] = {
988
- overrides: Object.fromEntries(Object.entries(override_cols.overrides).map(([row, column])=>[
989
- row,
990
- column - 1
991
- ]))
992
- };
993
- return cloned_row;
994
- }) : when_filters_closed_cols;
995
- const css = (0, $46MJV$depictaiutilishared.n_col_styling_with_dist)(selector_beginning, layout_options_.grid_spacing, cols_at_size, "grid", layout_options_.override_vertical_spacing);
996
- style.replaceChildren(css);
1125
+ const selector_beginning_ = `.depict.plp #${random_id}>`;
1126
+ const [get_styling, set_styling_] = (0, $46MJV$solidjs.createSignal)("");
1127
+ const [get_should_have_placeholders_rendered, set_should_have_placeholders_rendered] = (0, $46MJV$solidjs.createSignal)(false);
1128
+ const rendered_placeholders = (0, $46MJV$solidjs.createMemo)(()=>get_should_have_placeholders_rendered() ? (0, $7b0b7e887b485a91$export$f33414a4df0afd3f)({
1129
+ product_card_template_: product_card_template_,
1130
+ num_placeholders_: (0, $46MJV$solidjs.createMemo)(()=>{
1131
+ // Can't use the data out of request_base for the id because request_base is too late, we need the correct amount of placeholders before the browser has restored the scroll state after processing all popstate events
1132
+ return (0, $39d15a684cb3e309$export$6c9030e511152266) + (get_scroll_restoration_data().find(({ for_id: for_id })=>for_id === id_currently_querying_for_())?.min_results_loaded ?? min_products_to_fetch_);
1133
+ })
1134
+ }) : undefined);
1135
+ const [get_suspense_is_blocked, set_suspense_is_blocked] = (0, $46MJV$solidjs.createSignal)(false);
1136
+ (0, $46MJV$solidjs.createComputed)(()=>{
1137
+ if (!is_loading_()) return;
1138
+ set_should_have_placeholders_rendered(true);
1139
+ set_suspense_is_blocked(false);
1140
+ is_just_after_plp_results_update = true;
997
1141
  });
998
- (0, $46MJV$solidjs.createRenderEffect)(// render placeholders / product cards
999
- (0, $46MJV$depictaiutilishared.catchify)(async ()=>{
1000
- const owner_ = (0, $46MJV$solidjs.getOwner)();
1001
- if (is_loading()) await $8d94abc871e13baf$var$insert_placeholders({
1002
- scroll_restoration_data_: scroll_restoration_data_,
1003
- id_currently_querying_for_: id_currently_querying_for_,
1004
- rr_options_: rr_options_,
1005
- tenant_object_: tenant_object_,
1006
- min_products_to_fetch_: min_products_to_fetch_,
1007
- owner_: owner_,
1008
- cards_element_: cards
1009
- });
1010
- else if (!has_no_results_or_failed()) {
1011
- plp_results_(); // re-run render_and_insert_results when results change
1012
- render_and_insert_results(cards, owner_);
1013
- }
1014
- }));
1015
- // copied from RecommendationGrid
1016
- // convoluted lazy loading that
1017
- // when the elements are in the DOM starts IntersectionObserver on whole grid
1018
- // when grid intersects starts Lazyfier
1019
- // this is because Lazyfier is fucking stupid
1020
- (0, $46MJV$depictaiutilishared.observer).wait_for_element(cards).then((0, $46MJV$depictaiutilishared.catchify)((element)=>{
1021
- let start_lazy_loading;
1022
- const lazy_loading_promise = new Promise((r)=>start_lazy_loading = r);
1023
- const lf = new (0, $46MJV$depictaiutilishared.Lazyfier)({
1024
- only_load_intersecting: true,
1025
- wait_for_dominsertion: lazy_loading_promise,
1026
- ignore_data_urls: true,
1027
- lazyfinder: {
1028
- unload () {}
1029
- }
1030
- });
1031
- lf.start_observing_for_new_children_(element);
1032
- const i_o = new IntersectionObserver((0, $46MJV$depictaiutilishared.catchify)((records)=>{
1033
- for (const record of records)if (record.intersectionRatio > 0) {
1034
- start_lazy_loading();
1035
- i_o.disconnect();
1036
- return;
1142
+ $8d94abc871e13baf$var$results_grid_styling_generator({
1143
+ layout_options_: layout_options_,
1144
+ set_styling_: set_styling_,
1145
+ sort_or_filter_open_: sort_or_filter_open_,
1146
+ selector_beginning_: selector_beginning_
1147
+ });
1148
+ const has_at_least_one_display = (0, $46MJV$solidjs.createMemo)(()=>!!plp_results_()?.displays?.length); // Only de-construct below stuff if we get 0 displays. Important that this returns boolean so that below Suspense only gets re-created if it actually changes
1149
+ const block_suspense_if_needed = ()=>{
1150
+ if (!is_just_after_plp_results_update) return;
1151
+ is_just_after_plp_results_update = false;
1152
+ fallback_is_alive = false;
1153
+ set_suspense_is_blocked(true);
1154
+ };
1155
+ const non_placeholder_product_cards = (0, $46MJV$solidjs.createMemo)(()=>has_at_least_one_display() && // This suspense ensures that if someone has async templates, we still show placeholders until the product cards actually have finished rendering (automagically since they're createResource's)
1156
+ // We're creating it outside the <Show> so that we can benefit from <For>'s optimisation between changing results
1157
+ // (For the whole idea of the displays being cached to work we can't tear down and re-run ProductCards for every new result.
1158
+ // We have to keep ProductCards alive, but hidden, and feed them new data as soon as we had it)
1159
+ (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Suspense), {
1160
+ get fallback () {
1161
+ return (()=>{
1162
+ fallback_is_alive = true;
1163
+ (0, $46MJV$solidjs.onCleanup)(block_suspense_if_needed); // Block suspense after initial run every time after we fetch
1164
+ return (0, $46MJV$solidjs.createMemo)(()=>{
1165
+ // We need to be able to block the suspense since when async product cards are *rendering* we want to show the placeholders on initial load but not when loading more
1166
+ // In future we could have individual suspense's for each product card, but that's too much for now
1167
+ if (get_suspense_is_blocked()) return suspense_contents;
1168
+ set_should_have_placeholders_rendered(true); // just in case
1169
+ (0, $46MJV$solidjs.onCleanup)(()=>set_should_have_placeholders_rendered(false));
1170
+ return rendered_placeholders; // I lifted the placeholders into the memo since we don't want to re-render them when switching from <Show> to <Suspense>
1171
+ });
1172
+ })();
1173
+ },
1174
+ get children () {
1175
+ return (()=>{
1176
+ suspense_contents = (0, $f67fba44c7515f35$export$a1fd619a4743ca08)({
1177
+ product_card_template_: product_card_template_,
1178
+ plp_results_: plp_results_,
1179
+ last_result_in_viewport_: last_result_in_viewport_,
1180
+ first_result_in_viewport_: first_result_in_viewport_,
1181
+ market_: market_,
1182
+ merchant_: merchant_,
1183
+ all_products_loaded_: all_products_loaded_,
1184
+ min_products_to_fetch_: min_products_to_fetch_,
1185
+ query_base_: query_base_,
1186
+ depict_api_: depict_api_,
1187
+ is_loading_: is_loading_
1188
+ });
1189
+ (0, $46MJV$solidjs.onCleanup)(()=>suspense_contents = undefined);
1190
+ return suspense_contents;
1191
+ })();
1037
1192
  }
1038
1193
  }));
1039
- i_o.observe(cards);
1194
+ (0, $46MJV$solidjs.createEffect)((0, $46MJV$solidjs.on)(plp_results_, ()=>{
1195
+ if (!fallback_is_alive) // if all product card rendering functions after the initial rendering are synchronous the suspense boundary will never go into the fallback, so we don't know when they have finished rendering, and we can block the suspense. Therefore, we're just doing it with this effect
1196
+ block_suspense_if_needed();
1197
+ }, {
1198
+ defer: true
1040
1199
  }));
1041
1200
  return [
1042
- (0, $8e863dc22b06b688$export$a2cc176055f8f08)(),
1043
- cards,
1044
- style
1201
+ (0, $46MJV$solidjsweb.memo)((0, $8e863dc22b06b688$export$a2cc176055f8f08)),
1202
+ (()=>{
1203
+ const _el$2 = $8d94abc871e13baf$var$_tmpl$2.cloneNode(true);
1204
+ (0, $46MJV$solidjsweb.setAttribute)(_el$2, "id", random_id);
1205
+ (0, $46MJV$solidjsweb.insert)(_el$2, (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Show), {
1206
+ get when () {
1207
+ return !is_loading_();
1208
+ },
1209
+ get fallback () {
1210
+ return rendered_placeholders();
1211
+ },
1212
+ get children () {
1213
+ return non_placeholder_product_cards();
1214
+ }
1215
+ }));
1216
+ return _el$2;
1217
+ })(),
1218
+ (()=>{
1219
+ const _el$3 = $8d94abc871e13baf$var$_tmpl$3.cloneNode(true);
1220
+ (0, $46MJV$solidjsweb.insert)(_el$3, get_styling);
1221
+ return _el$3;
1222
+ })()
1045
1223
  ];
1046
1224
  }
1047
1225
  });
@@ -1052,63 +1230,32 @@ function $8d94abc871e13baf$export$3925f87b1545cfc6({ plp_results_: plp_results_
1052
1230
  return _el$;
1053
1231
  })();
1054
1232
  }
1055
- async function $8d94abc871e13baf$var$insert_placeholders({ scroll_restoration_data_: [get_scroll_restoration_data] , min_products_to_fetch_: min_products_to_fetch_ , tenant_object_: tenant_object_ , rr_options_: rr_options_ , owner_: owner_ , cards_element_: cards_element_ , id_currently_querying_for_: id_currently_querying_for_ }) {
1056
- const num_placeholders = // we don't need runWithOwner here because we haven't had an await yet, so we haven't lost the owner
1057
- (0, $46MJV$solidjs.createMemo)(()=>{
1058
- // Can't use the data out of request_base for the id because request_base is too late, we need the correct amount of placeholders before the browser has restored the scroll state after processing all popstate events
1059
- return (0, $39d15a684cb3e309$export$6c9030e511152266) + (get_scroll_restoration_data().find(({ for_id: for_id })=>for_id === id_currently_querying_for_())?.min_results_loaded ?? min_products_to_fetch_);
1233
+ /**
1234
+ * Sets styling to styling generated by "Layout" (n_col_styling_with_dist) depending on if filters are open or not
1235
+ * This function is special to the actual PLPResults.
1236
+ */ function $8d94abc871e13baf$var$results_grid_styling_generator({ layout_options_: layout_options_ , sort_or_filter_open_: sort_or_filter_open_ , set_styling_: set_styling_ , selector_beginning_: selector_beginning_ }) {
1237
+ (0, $46MJV$solidjs.createRenderEffect)(()=>{
1238
+ // Add grid styling that changes when filters get opened/closed
1239
+ const when_filters_closed_cols = layout_options_.cols_at_size;
1240
+ const cols_at_size = sort_or_filter_open_() ? when_filters_closed_cols.map((row)=>{
1241
+ const [num_cols_default, , , , override_cols] = row;
1242
+ const cloned_row = [
1243
+ ...row
1244
+ ];
1245
+ // @ts-ignore
1246
+ cloned_row[0] = num_cols_default - 1;
1247
+ if (override_cols) // @ts-ignore
1248
+ cloned_row[4] = {
1249
+ overrides: Object.fromEntries(Object.entries(override_cols.overrides).map(([row, column])=>[
1250
+ row,
1251
+ column - 1
1252
+ ]))
1253
+ };
1254
+ return cloned_row;
1255
+ }) : when_filters_closed_cols;
1256
+ const css = (0, $46MJV$depictaiutilishared.n_col_styling_with_dist)(selector_beginning_, layout_options_.grid_spacing, cols_at_size, "grid", layout_options_.override_vertical_spacing);
1257
+ set_styling_(css);
1060
1258
  });
1061
- let existing_num = 0;
1062
- let removed_old_children = false;
1063
- if (!$8d94abc871e13baf$var$cached_placeholder_element) {
1064
- const [dispose_card, root_in_root] = (0, $46MJV$solidjs.createRoot)((dispose)=>[
1065
- dispose,
1066
- (0, $46MJV$solidjs.getOwner)()
1067
- ]);
1068
- const { elements: elements } = await (0, $46MJV$depictaiutilishared.default_rr)(tenant_object_, {
1069
- ...rr_options_,
1070
- type: "placeholder",
1071
- pre_processors: [],
1072
- post_processors: [],
1073
- ...typeof rr_options_.template === "function" ? {
1074
- template: $8d94abc871e13baf$var$wrap_template_to_throw_into_error_boundary(rr_options_.template, root_in_root, ()=>(0, $46MJV$depictaiutilishared.queueMacroTask)((0, $46MJV$depictaiutilishared.catchify)(dispose_card)) // we just want it cloned and dead
1075
- )
1076
- } : {},
1077
- recs: [
1078
- {
1079
- page_url: "javascript:void(0)"
1080
- }
1081
- ] // This later gets ignored and turned into `null` by the SDK functions in the @depict-ai/ui package
1082
- });
1083
- const element = elements?.find((e)=>e instanceof HTMLElement || e instanceof SVGElement);
1084
- if (!element) return [];
1085
- $8d94abc871e13baf$var$cached_placeholder_element = element.cloneNode(true); // don't save the actual element, clone it directly so that the who provided it can't modify it later (this has caused a bug before with react)
1086
- }
1087
- (0, $46MJV$solidjs.runWithOwner)(owner_, ()=>(0, $46MJV$solidjs.createRenderEffect)(()=>{
1088
- const to_add = num_placeholders() - existing_num;
1089
- if (to_add <= 0) return;
1090
- // We don't need to remove placeholders, only need to add. The reason for that is that chrome restores the scroll position once all tasks queued as reaction of the "popstate" events have been completed in the task queue. That means that we need to get the placeholders in fast, or we might lose scroll position if the previous site was shorter.
1091
- // The query id and the amount might update in separate tasks because one comes from href_change_ipns and the other one from another "popstate" listener. Therefore, we need to be able to dynamically add more placeholders. I'm not entirely sure about this anymore though, since we have the scroll position on a per-id basis it might work anyway but THIS WORKS, and I've been working on this bug for 3 hours so let's just keep it this way.
1092
- cards_element_[removed_old_children ? "append" : (removed_old_children = true, "replaceChildren")](...Array.from({
1093
- length: to_add
1094
- }).map(()=>$8d94abc871e13baf$var$cached_placeholder_element.cloneNode(true)));
1095
- existing_num += to_add;
1096
- }));
1097
- }
1098
- function $8d94abc871e13baf$var$wrap_template_to_throw_into_error_boundary(template, root_in_root, on_finally) {
1099
- return async (...args)=>{
1100
- try {
1101
- return await (0, $46MJV$solidjs.runWithOwner)(root_in_root, ()=>template(...args)) || [];
1102
- } catch (e) {
1103
- (0, $46MJV$solidjs.runWithOwner)(root_in_root, ()=>{
1104
- // Throw in case of promise rejection, ultimately into ErrorBoundary
1105
- throw e;
1106
- });
1107
- return [];
1108
- } finally{
1109
- on_finally?.();
1110
- }
1111
- };
1112
1259
  }
1113
1260
 
1114
1261
 
@@ -1381,16 +1528,24 @@ function $c130252ae1aed6e2$export$fecbb157621501bd({ number_of_rendered_selected
1381
1528
  };
1382
1529
  (0, $46MJV$solidjsweb.insert)(_el$5, (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$depictaiutilishared.CrossIcon), {}), _el$6);
1383
1530
  (0, $46MJV$solidjsweb.insert)(_el$6, ()=>price_formatting_().pre_, _el$7);
1384
- (0, $46MJV$solidjsweb.insert)(_el$6, ()=>(0, $5fc9fc23df1591db$export$469c7af753d08925)({
1385
- price_: (0, $46MJV$solidjs.createMemo)(()=>filter().data[0]),
1386
- price_formatting_: price_formatting_
1387
- }), _el$7);
1531
+ (0, $46MJV$solidjsweb.insert)(_el$6, (0, $46MJV$solidjsweb.createComponent)((0, $5fc9fc23df1591db$export$a71e92cfbb498adc), {
1532
+ get price_ () {
1533
+ return filter().data[0];
1534
+ },
1535
+ get price_formatting_ () {
1536
+ return price_formatting_();
1537
+ }
1538
+ }), _el$7);
1388
1539
  (0, $46MJV$solidjsweb.insert)(_el$6, ()=>price_formatting_().post_, _el$7);
1389
1540
  (0, $46MJV$solidjsweb.insert)(_el$6, ()=>price_formatting_().pre_, null);
1390
- (0, $46MJV$solidjsweb.insert)(_el$6, ()=>(0, $5fc9fc23df1591db$export$469c7af753d08925)({
1391
- price_: (0, $46MJV$solidjs.createMemo)(()=>filter().data[1]),
1392
- price_formatting_: price_formatting_
1393
- }), null);
1541
+ (0, $46MJV$solidjsweb.insert)(_el$6, (0, $46MJV$solidjsweb.createComponent)((0, $5fc9fc23df1591db$export$a71e92cfbb498adc), {
1542
+ get price_ () {
1543
+ return filter().data[1];
1544
+ },
1545
+ get price_formatting_ () {
1546
+ return price_formatting_();
1547
+ }
1548
+ }), null);
1394
1549
  (0, $46MJV$solidjsweb.insert)(_el$6, ()=>price_formatting_().post_, null);
1395
1550
  return _el$5;
1396
1551
  })();
@@ -1689,7 +1844,7 @@ function $76bb4acbbb94c2c6$export$ca21a16d65b3dd8({ show_extras_: [get_show_extr
1689
1844
  const $8984a0a949b1c852$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<form class="checkboxes"></form>`, 2);
1690
1845
  const $8984a0a949b1c852$var$max_visible_without_collapsing = 7;
1691
1846
  const $8984a0a949b1c852$var$show_non_collapsible_when_collapsed = 4;
1692
- function $8984a0a949b1c852$export$dd948f91abc3a1c4({ filter_: filter_ , selected_filters_: [get_selected_filters, set_selected_filters] , i18n_: i18n_ , view_more_button_below_group_: [_get_view_more_button_below_group_, set_view_more_button_below_group_] }) {
1847
+ function $8984a0a949b1c852$export$dd948f91abc3a1c4({ filter_: filter_ , selected_filters_: [get_selected_filters, set_selected_filters] , i18n_: i18n_ , view_more_button_below_group_: [, set_view_more_button_below_group_] }) {
1693
1848
  const existing_filter = (0, $46MJV$solidjs.createMemo)(()=>{
1694
1849
  const { field: field , op: op } = filter_();
1695
1850
  return get_selected_filters().find(({ field: checking_field , op: checking_op })=>checking_field === field && checking_op === op);
@@ -1770,7 +1925,7 @@ function $8984a0a949b1c852$export$dd948f91abc3a1c4({ filter_: filter_ , selected
1770
1925
  ...base_object,
1771
1926
  data: [
1772
1927
  ...new FormData(form)
1773
- ].filter(([_key, value])=>value === "on").map(([key])=>key)
1928
+ ].filter(([, value])=>value === "on").map(([key])=>key)
1774
1929
  };
1775
1930
  const selected_filters = [
1776
1931
  ...get_selected_filters()
@@ -1961,16 +2116,24 @@ function $6833018d8bbbb2ad$var$RangeSelector({ max_: max_ , min_: min_ , current
1961
2116
  i18n_: i18n_
1962
2117
  }), _el$8);
1963
2118
  (0, $46MJV$solidjsweb.insert)(_el$9, pre_price, null);
1964
- (0, $46MJV$solidjsweb.insert)(_el$9, ()=>(0, $5fc9fc23df1591db$export$469c7af753d08925)({
1965
- price_: min_,
1966
- price_formatting_: price_formatting_
1967
- }), null);
2119
+ (0, $46MJV$solidjsweb.insert)(_el$9, (0, $46MJV$solidjsweb.createComponent)((0, $5fc9fc23df1591db$export$a71e92cfbb498adc), {
2120
+ get price_ () {
2121
+ return min_();
2122
+ },
2123
+ get price_formatting_ () {
2124
+ return price_formatting_();
2125
+ }
2126
+ }), null);
1968
2127
  (0, $46MJV$solidjsweb.insert)(_el$9, post_price, null);
1969
2128
  (0, $46MJV$solidjsweb.insert)(_el$10, pre_price, null);
1970
- (0, $46MJV$solidjsweb.insert)(_el$10, ()=>(0, $5fc9fc23df1591db$export$469c7af753d08925)({
1971
- price_: max_,
1972
- price_formatting_: price_formatting_
1973
- }), null);
2129
+ (0, $46MJV$solidjsweb.insert)(_el$10, (0, $46MJV$solidjsweb.createComponent)((0, $5fc9fc23df1591db$export$a71e92cfbb498adc), {
2130
+ get price_ () {
2131
+ return max_();
2132
+ },
2133
+ get price_formatting_ () {
2134
+ return price_formatting_();
2135
+ }
2136
+ }), null);
1974
2137
  (0, $46MJV$solidjsweb.insert)(_el$10, post_price, null);
1975
2138
  (0, $46MJV$solidjsweb.effect)((_p$)=>{
1976
2139
  const _v$ = i18n_.range_filter_low_point_aria_label_(), _v$2 = min_(), _v$3 = max_(), _v$4 = i18n_.range_filter_high_point_aria_label_(), _v$5 = min_(), _v$6 = max_();
@@ -2875,48 +3038,57 @@ var $6865c7388a79e957$export$2e2bcd8739ae039 = {
2875
3038
  const $8578879ddb04f368$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<span class="show-selected" aria-hidden="true"><span></span></span>`, 4);
2876
3039
  function $8578879ddb04f368$export$53c59af873b303c9({ selected_filters_in_group_: selected_filters_in_group_ , i18n_: { price_formatting_: price_formatting_ } }) {
2877
3040
  const [show_tick_icon, set_show_tick_icon] = (0, $46MJV$solidjs.createSignal)(false);
2878
- return (()=>{
2879
- const _el$ = $8578879ddb04f368$var$_tmpl$.cloneNode(true), _el$2 = _el$.firstChild;
2880
- (0, $46MJV$solidjsweb.insert)(_el$2, ()=>(0, $46MJV$solidjs.createMemo)(()=>(0, $46MJV$solidjs.batch)(()=>{
2881
- set_show_tick_icon(false);
2882
- let { size: size } = selected_filters_in_group_();
2883
- try_specific: {
2884
- if (size > 1) break try_specific;
2885
- for (const [selected_filter, filter_data] of selected_filters_in_group_()){
2886
- // we're intentionally not looping in this statement since we always just want to show the first thing in the filter group
2887
- const { meta: meta } = filter_data;
2888
- const { type: type } = meta;
2889
- if (type === "range") return [
2890
- (0, $46MJV$solidjsweb.memo)(()=>price_formatting_().pre_),
2891
- (0, $46MJV$solidjsweb.memo)(()=>(0, $5fc9fc23df1591db$export$469c7af753d08925)({
2892
- price_: (0, $46MJV$solidjs.createMemo)(()=>selected_filter.data[0]),
2893
- price_formatting_: price_formatting_
2894
- })),
2895
- (0, $46MJV$solidjsweb.memo)(()=>price_formatting_().post_),
2896
- " – ",
2897
- (0, $46MJV$solidjsweb.memo)(()=>price_formatting_().pre_),
2898
- (0, $46MJV$solidjsweb.memo)(()=>(0, $5fc9fc23df1591db$export$469c7af753d08925)({
2899
- price_: (0, $46MJV$solidjs.createMemo)(()=>selected_filter.data[1]),
2900
- price_formatting_: price_formatting_
2901
- })),
2902
- (0, $46MJV$solidjsweb.memo)(()=>price_formatting_().post_)
2903
- ];
2904
- else {
2905
- const { data: data } = selected_filter;
2906
- const data_is_array = Array.isArray(data);
2907
- if (data_is_array && data.length !== 1) {
2908
- size = data.length;
2909
- break try_specific;
2910
- }
2911
- const needle = data_is_array ? data[0] : data;
2912
- const index_in_meta = meta.values.findIndex((value)=>needle === value || Array.isArray(needle) && Array.isArray(value) && needle.length === value.length && value.every((item, index)=>needle[index] === item));
2913
- return meta.names?.[index_in_meta] || meta.values?.[index_in_meta];
3041
+ const text = (0, $46MJV$solidjs.createMemo)(()=>(0, $46MJV$solidjs.batch)(()=>{
3042
+ set_show_tick_icon(false);
3043
+ let { size: size } = selected_filters_in_group_();
3044
+ try_specific: {
3045
+ if (size > 1) break try_specific;
3046
+ for (const [selected_filter, filter_data] of selected_filters_in_group_()){
3047
+ // we're intentionally not looping in this statement since we always just want to show the first thing in the filter group
3048
+ const { meta: meta } = filter_data;
3049
+ const { type: type } = meta;
3050
+ if (type === "range") return [
3051
+ (0, $46MJV$solidjsweb.memo)(()=>price_formatting_().pre_),
3052
+ (0, $46MJV$solidjsweb.createComponent)((0, $5fc9fc23df1591db$export$a71e92cfbb498adc), {
3053
+ get price_ () {
3054
+ return selected_filter.data[0];
3055
+ },
3056
+ get price_formatting_ () {
3057
+ return price_formatting_();
3058
+ }
3059
+ }),
3060
+ (0, $46MJV$solidjsweb.memo)(()=>price_formatting_().post_),
3061
+ " – ",
3062
+ (0, $46MJV$solidjsweb.memo)(()=>price_formatting_().pre_),
3063
+ (0, $46MJV$solidjsweb.createComponent)((0, $5fc9fc23df1591db$export$a71e92cfbb498adc), {
3064
+ get price_ () {
3065
+ return selected_filter.data[1];
3066
+ },
3067
+ get price_formatting_ () {
3068
+ return price_formatting_();
2914
3069
  }
3070
+ }),
3071
+ (0, $46MJV$solidjsweb.memo)(()=>price_formatting_().post_)
3072
+ ];
3073
+ else {
3074
+ const { data: data } = selected_filter;
3075
+ const data_is_array = Array.isArray(data);
3076
+ if (data_is_array && data.length !== 1) {
3077
+ size = data.length;
3078
+ break try_specific;
2915
3079
  }
3080
+ const needle = data_is_array ? data[0] : data;
3081
+ const index_in_meta = meta.values.findIndex((value)=>needle === value || Array.isArray(needle) && Array.isArray(value) && needle.length === value.length && value.every((item, index)=>needle[index] === item));
3082
+ return meta.names?.[index_in_meta] || meta.values?.[index_in_meta];
2916
3083
  }
2917
- set_show_tick_icon(true);
2918
- return size + "";
2919
- })));
3084
+ }
3085
+ }
3086
+ set_show_tick_icon(true);
3087
+ return size + "";
3088
+ }));
3089
+ return (()=>{
3090
+ const _el$ = $8578879ddb04f368$var$_tmpl$.cloneNode(true), _el$2 = _el$.firstChild;
3091
+ (0, $46MJV$solidjsweb.insert)(_el$2, text);
2920
3092
  (0, $46MJV$solidjsweb.insert)(_el$, (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Show), {
2921
3093
  get when () {
2922
3094
  return show_tick_icon();
@@ -2982,6 +3154,7 @@ function $5804fd6cbfb7160f$export$ab34afce88557c0e(props) {
2982
3154
 
2983
3155
 
2984
3156
 
3157
+
2985
3158
  const $1587765bd31f3722$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="filter-collapsible"></div>`, 2), $1587765bd31f3722$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<button class="clear-group"><span></span></button>`, 4), $1587765bd31f3722$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="view-more-clear"></div>`, 2), $1587765bd31f3722$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="filter-collapsible-body"><div class="filter-part"></div></div>`, 4), $1587765bd31f3722$var$_tmpl$5 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<details class="filter-collapsible"></details>`, 2), $1587765bd31f3722$var$_tmpl$6 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<summary class="filter-group-summary"><div class="summary"><span></span><div class="selected-w-sign"></div></div></summary>`, 8), $1587765bd31f3722$var$_tmpl$7 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="ungrouped"></div>`, 2), $1587765bd31f3722$var$_tmpl$8 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<button class="clear-all-filters major"></button>`, 2);
2986
3159
  function $1587765bd31f3722$export$3f1a388cc0d8fed7(props) {
2987
3160
  // Split like this to make placeholder wrapping more visible & this component is exported and used in MobileModal
@@ -3093,13 +3266,22 @@ function $1587765bd31f3722$var$ActualFilterBody(props) {
3093
3266
  return "Filter group " + JSON.stringify(section_) + " failed";
3094
3267
  },
3095
3268
  get children () {
3096
- return (0, $46MJV$solidjs.createMemo)(()=>(0, $46MJV$solidjs.createMemo)(()=>(0, $6865c7388a79e957$export$2e2bcd8739ae039)[filter()?.meta?.type])()?.({
3097
- filter_: filter,
3098
- expanded_hierarchical_filters_: props.expanded_hierarchical_filters_,
3099
- selected_filters_: props.selected_filters_,
3100
- i18n_: props.i18n_,
3101
- view_more_button_below_group_: view_more_button_below_group
3102
- }));
3269
+ return (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjsweb.Dynamic), {
3270
+ get component () {
3271
+ return (0, $6865c7388a79e957$export$2e2bcd8739ae039)[filter()?.meta?.type];
3272
+ },
3273
+ filter_: filter,
3274
+ get expanded_hierarchical_filters_ () {
3275
+ return props.expanded_hierarchical_filters_;
3276
+ },
3277
+ get selected_filters_ () {
3278
+ return props.selected_filters_;
3279
+ },
3280
+ get i18n_ () {
3281
+ return props.i18n_;
3282
+ },
3283
+ view_more_button_below_group_: view_more_button_below_group
3284
+ });
3103
3285
  }
3104
3286
  })
3105
3287
  }));
@@ -3155,19 +3337,27 @@ function $1587765bd31f3722$var$ActualFilterBody(props) {
3155
3337
  get each () {
3156
3338
  return untogglable_filters();
3157
3339
  },
3158
- children: (filter)=>// create memo to diff the function with next function
3159
- {
3340
+ children: (filter)=>{
3160
3341
  const view_more_button_below_group = (0, $46MJV$solidjs.createSignal)();
3161
- const filter_element_memo = (0, $46MJV$solidjs.createMemo)(()=>(0, $46MJV$solidjs.createMemo)(()=>(0, $6865c7388a79e957$export$2e2bcd8739ae039)[filter()?.meta?.type])()?.({
3342
+ const [get_view_more_button_below_group] = view_more_button_below_group;
3343
+ return [
3344
+ (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjsweb.Dynamic), {
3345
+ get component () {
3346
+ return (0, $6865c7388a79e957$export$2e2bcd8739ae039)[filter()?.meta?.type];
3347
+ },
3162
3348
  filter_: filter,
3163
- expanded_hierarchical_filters_: props.expanded_hierarchical_filters_,
3164
- selected_filters_: props.selected_filters_,
3165
- i18n_: props.i18n_,
3349
+ get expanded_hierarchical_filters_ () {
3350
+ return props.expanded_hierarchical_filters_;
3351
+ },
3352
+ get selected_filters_ () {
3353
+ return props.selected_filters_;
3354
+ },
3355
+ get i18n_ () {
3356
+ return props.i18n_;
3357
+ },
3166
3358
  view_more_button_below_group_: view_more_button_below_group
3167
- }));
3168
- return [
3169
- filter_element_memo,
3170
- view_more_button_below_group[0]
3359
+ }),
3360
+ (0, $46MJV$solidjsweb.memo)(get_view_more_button_below_group)
3171
3361
  ];
3172
3362
  }
3173
3363
  }));
@@ -3775,6 +3965,7 @@ function $0bc45cf6753f874a$export$b288c38ae3fddb56({ available_filters_: availab
3775
3965
 
3776
3966
  const $881cb1745bafff7a$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="filters"><div class="body"></div></div>`, 4), $881cb1745bafff7a$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="sorting"><div class="body"></div></div>`, 4), $881cb1745bafff7a$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="sort-and-filter-buttons"><div class="outer"><div class="inner"></div></div></div>`, 6), $881cb1745bafff7a$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<span class="num-filters"></span>`, 2), $881cb1745bafff7a$var$_tmpl$5 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="open-filters-button-container"><button class="filter toggle-button major-minor-transition" type="button"><span></span></button></div>`, 6), $881cb1745bafff7a$var$_tmpl$6 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<button class="toggle-button for-sorting major-minor-transition"><span></span></button>`, 4);
3777
3967
  function $881cb1745bafff7a$export$d7841e452f2e59a8({ current_sorting_: current_sorting_ , set_extra_els_in_results_container_: set_extra_els_in_results_container_ , search_filters_open_: search_filters_open_ , search_sorting_open_: search_sorting_open_ , set_sort_or_filter_open_: set_sort_or_filter_open_ , i18n_: i18n_ , available_sortings_: available_sortings_ , available_filters_: available_filters_ , expanded_filters_: expanded_filters_ , middle_elements_: middle_elements_ , input_modal_open_: input_modal_open_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , number_of_rendered_selected_filters_items_: number_of_rendered_selected_filters_items_ , set_sort_and_filter_element_: set_sort_and_filter_element_ , formatted_number_of_results_: formatted_number_of_results_ , filter_button_width_: filter_button_width_ , sort_button_width_: sort_button_width_ , selected_filters_: selected_filters_ , local_filter_cache_: local_filter_cache_ , get_extra_filters_button_: get_extra_filters_button_ , get_extra_sorting_button_: get_extra_sorting_button_ }) {
3968
+ // @ts-ignore
3778
3969
  return (0, $0f2f58dd60b11888$export$b69d0d92862de18b)({
3779
3970
  severity_: "error",
3780
3971
  message_: "Sorting and filters failed",
@@ -4568,90 +4759,6 @@ function $cdc2c00c0a7da86e$export$466cdc317043f6cb({ quicklinks_data_: quicklink
4568
4759
 
4569
4760
 
4570
4761
 
4571
-
4572
-
4573
- function $207f7b30db90d048$export$3945d6db2dfd3d12({ crumb_data_: crumb_data_ , query_id_: query_id_ , i18n_: i18n_ , selected_filters_: selected_filters_ , local_filter_cache_: local_filter_cache_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , plp_results_: plp_results_ , router_: router_ }) {
4574
- // If we just got opened in a new tab, clear filters instantly and remove the flag
4575
- $207f7b30db90d048$var$clear_if_opened_new_tab_with_sideways_url_params_flag({
4576
- plp_results_: plp_results_,
4577
- local_filter_cache_: local_filter_cache_,
4578
- expanded_hierarchical_filters_: expanded_hierarchical_filters_,
4579
- selected_filters_: selected_filters_,
4580
- i18n_: i18n_,
4581
- router_: router_
4582
- });
4583
- // Code below is for when we're already open and the user navigates to a new category
4584
- let previous_crumb_data = (0, $46MJV$solidjs.untrack)(crumb_data_);
4585
- let query_id_when_we_got_previous_data = (0, $46MJV$solidjs.untrack)(query_id_);
4586
- let allow_filter_clearing = true; // set to false when going backwards/forwards
4587
- // temporarily disable filter clearing when going backwards/forwards
4588
- const handler = ()=>allow_filter_clearing = false;
4589
- 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
4590
- (0, $46MJV$solidjs.onCleanup)(()=>window.removeEventListener("popstate", handler));
4591
- (0, $46MJV$solidjs.createEffect)((0, $46MJV$solidjs.on)(crumb_data_, (0, $46MJV$depictaiutilishared.catchify)((new_crumb_data)=>{
4592
- const query_id_of_new_data = query_id_();
4593
- if (allow_filter_clearing && previous_crumb_data && new_crumb_data && query_id_of_new_data !== query_id_when_we_got_previous_data) {
4594
- const previous_length = previous_crumb_data.length;
4595
- const new_length = new_crumb_data.length;
4596
- const went_upwards = new_length < previous_length;
4597
- const went_downwards = previous_length < new_length;
4598
- const shorter_array = went_upwards ? new_crumb_data : previous_crumb_data;
4599
- const longer_array = went_upwards ? previous_crumb_data : new_crumb_data;
4600
- if (!((went_upwards || went_downwards) && shorter_array.every(({ query_id: query_id }, index)=>longer_array[index].query_id === query_id))) {
4601
- // We went sideways, not up or down. Clear filters.
4602
- (0, $92e4e7906daa1ff8$export$8895d39404bd2bb1)({
4603
- user_triggered_: false,
4604
- i18n_: i18n_,
4605
- also_clear_sorting_: false,
4606
- selected_filters_: selected_filters_,
4607
- expanded_hierarchical_filters_: expanded_hierarchical_filters_,
4608
- local_filter_cache_: local_filter_cache_
4609
- });
4610
- // Also ensure we don't have `sideways_url_params_flag` set anymore
4611
- $207f7b30db90d048$var$delete_sideways_param_flag(router_);
4612
- }
4613
- }
4614
- query_id_when_we_got_previous_data = query_id_of_new_data;
4615
- previous_crumb_data = new_crumb_data;
4616
- if (!allow_filter_clearing) allow_filter_clearing = true;
4617
- })));
4618
- }
4619
- function $207f7b30db90d048$var$clear_if_opened_new_tab_with_sideways_url_params_flag({ plp_results_: plp_results_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , i18n_: i18n_ , selected_filters_: selected_filters_ , local_filter_cache_: local_filter_cache_ , router_: router_ }) {
4620
- const tracking_function_for_plp_results = (0, $46MJV$solidjs.createReaction)(()=>{
4621
- // On first rendering of the CategoryPage (after we have results), check if we got to this URL by going sideways in QuickLinks and clear filters with toast if so
4622
- const had_flag = $207f7b30db90d048$var$delete_sideways_param_flag(router_);
4623
- if (!had_flag) return;
4624
- (0, $46MJV$depictaiutilishared.dlog)("Flag to clear filters was set, clearing filters");
4625
- (0, $46MJV$depictaiutilishared.queueMacroTask)(()=>{
4626
- // Do it next task so that all the filters have time to populate
4627
- (0, $92e4e7906daa1ff8$export$8895d39404bd2bb1)({
4628
- user_triggered_: false,
4629
- i18n_: i18n_,
4630
- also_clear_sorting_: false,
4631
- selected_filters_: selected_filters_,
4632
- expanded_hierarchical_filters_: expanded_hierarchical_filters_,
4633
- local_filter_cache_: local_filter_cache_
4634
- });
4635
- });
4636
- });
4637
- tracking_function_for_plp_results(plp_results_);
4638
- }
4639
- function $207f7b30db90d048$var$delete_sideways_param_flag(router) {
4640
- const url_object = new URL(location.href);
4641
- const { searchParams: searchParams } = url_object;
4642
- if (searchParams.get((0, $c6a04c153e9853a7$export$e2cf3f19dd3f8aac)) !== "true") return false;
4643
- searchParams.delete((0, $c6a04c153e9853a7$export$e2cf3f19dd3f8aac));
4644
- router.navigate_.go_to_({
4645
- new_url_: url_object,
4646
- is_replace_: true,
4647
- force_spa_navigation_: true
4648
- });
4649
- return true;
4650
- }
4651
-
4652
-
4653
-
4654
-
4655
4762
  const $151280ad98f4438b$var$max_history_change_frequency = 300;
4656
4763
  const $151280ad98f4438b$var$api_max_products_per_request = 100;
4657
4764
  function $151280ad98f4438b$export$6e49da55e449af7c({ scroll_restoration_data_: [, set_scroll_restoration_data] , last_result_in_viewport_: [get_last_result_in_viewport_] , id_: id_ , can_write_scroll_restoration_: can_write_scroll_restoration_ }) {
@@ -4764,8 +4871,92 @@ let $29b757e2ae26852c$export$44dad306455dddf;
4764
4871
  })($29b757e2ae26852c$export$44dad306455dddf || ($29b757e2ae26852c$export$44dad306455dddf = {}));
4765
4872
 
4766
4873
 
4874
+
4875
+
4876
+
4877
+
4878
+ function $207f7b30db90d048$export$3945d6db2dfd3d12({ crumb_data_: crumb_data_ , query_id_: query_id_ , i18n_: i18n_ , selected_filters_: selected_filters_ , local_filter_cache_: local_filter_cache_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , plp_results_: plp_results_ , router_: router_ }) {
4879
+ // If we just got opened in a new tab, clear filters instantly and remove the flag
4880
+ $207f7b30db90d048$var$clear_if_opened_new_tab_with_sideways_url_params_flag({
4881
+ plp_results_: plp_results_,
4882
+ local_filter_cache_: local_filter_cache_,
4883
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
4884
+ selected_filters_: selected_filters_,
4885
+ i18n_: i18n_,
4886
+ router_: router_
4887
+ });
4888
+ // Code below is for when we're already open and the user navigates to a new category
4889
+ let previous_crumb_data = (0, $46MJV$solidjs.untrack)(crumb_data_);
4890
+ let query_id_when_we_got_previous_data = (0, $46MJV$solidjs.untrack)(query_id_);
4891
+ let allow_filter_clearing = true; // set to false when going backwards/forwards
4892
+ // temporarily disable filter clearing when going backwards/forwards
4893
+ const handler = ()=>allow_filter_clearing = false;
4894
+ 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
4895
+ (0, $46MJV$solidjs.onCleanup)(()=>window.removeEventListener("popstate", handler));
4896
+ (0, $46MJV$solidjs.createEffect)((0, $46MJV$solidjs.on)(crumb_data_, (0, $46MJV$depictaiutilishared.catchify)((new_crumb_data)=>{
4897
+ const query_id_of_new_data = query_id_();
4898
+ if (allow_filter_clearing && previous_crumb_data && new_crumb_data && query_id_of_new_data !== query_id_when_we_got_previous_data) {
4899
+ const previous_length = previous_crumb_data.length;
4900
+ const new_length = new_crumb_data.length;
4901
+ const went_upwards = new_length < previous_length;
4902
+ const went_downwards = previous_length < new_length;
4903
+ const shorter_array = went_upwards ? new_crumb_data : previous_crumb_data;
4904
+ const longer_array = went_upwards ? previous_crumb_data : new_crumb_data;
4905
+ if (!((went_upwards || went_downwards) && shorter_array.every(({ query_id: query_id }, index)=>longer_array[index].query_id === query_id))) {
4906
+ // We went sideways, not up or down. Clear filters.
4907
+ (0, $92e4e7906daa1ff8$export$8895d39404bd2bb1)({
4908
+ user_triggered_: false,
4909
+ i18n_: i18n_,
4910
+ also_clear_sorting_: false,
4911
+ selected_filters_: selected_filters_,
4912
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
4913
+ local_filter_cache_: local_filter_cache_
4914
+ });
4915
+ // Also ensure we don't have `sideways_url_params_flag` set anymore
4916
+ $207f7b30db90d048$var$delete_sideways_param_flag(router_);
4917
+ }
4918
+ }
4919
+ query_id_when_we_got_previous_data = query_id_of_new_data;
4920
+ previous_crumb_data = new_crumb_data;
4921
+ if (!allow_filter_clearing) allow_filter_clearing = true;
4922
+ })));
4923
+ }
4924
+ function $207f7b30db90d048$var$clear_if_opened_new_tab_with_sideways_url_params_flag({ plp_results_: plp_results_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , i18n_: i18n_ , selected_filters_: selected_filters_ , local_filter_cache_: local_filter_cache_ , router_: router_ }) {
4925
+ const tracking_function_for_plp_results = (0, $46MJV$solidjs.createReaction)(()=>{
4926
+ // On first rendering of the CategoryPage (after we have results), check if we got to this URL by going sideways in QuickLinks and clear filters with toast if so
4927
+ const had_flag = $207f7b30db90d048$var$delete_sideways_param_flag(router_);
4928
+ if (!had_flag) return;
4929
+ (0, $46MJV$depictaiutilishared.dlog)("Flag to clear filters was set, clearing filters");
4930
+ (0, $46MJV$depictaiutilishared.queueMacroTask)(()=>{
4931
+ // Do it next task so that all the filters have time to populate
4932
+ (0, $92e4e7906daa1ff8$export$8895d39404bd2bb1)({
4933
+ user_triggered_: false,
4934
+ i18n_: i18n_,
4935
+ also_clear_sorting_: false,
4936
+ selected_filters_: selected_filters_,
4937
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
4938
+ local_filter_cache_: local_filter_cache_
4939
+ });
4940
+ });
4941
+ });
4942
+ tracking_function_for_plp_results(plp_results_);
4943
+ }
4944
+ function $207f7b30db90d048$var$delete_sideways_param_flag(router) {
4945
+ const url_object = new URL(location.href);
4946
+ const { searchParams: searchParams } = url_object;
4947
+ if (searchParams.get((0, $c6a04c153e9853a7$export$e2cf3f19dd3f8aac)) !== "true") return false;
4948
+ searchParams.delete((0, $c6a04c153e9853a7$export$e2cf3f19dd3f8aac));
4949
+ router.navigate_.go_to_({
4950
+ new_url_: url_object,
4951
+ is_replace_: true,
4952
+ force_spa_navigation_: true
4953
+ });
4954
+ return true;
4955
+ }
4956
+
4957
+
4767
4958
  const $671632478f2a7ce7$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="product-count"> </div>`, 2), $671632478f2a7ce7$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div></div>`, 2), $671632478f2a7ce7$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="filter-results-for-one-row"></div>`, 2), $671632478f2a7ce7$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="depict plp category"><div class="listing-page"></div></div>`, 4);
4768
- function $671632478f2a7ce7$export$f7d2f673fc2f091d({ depict_api_: depict_api_ , query_id_: query_id_ , current_sorting_: current_sorting_ , min_products_to_fetch_: min_products_to_fetch_ , category_filters_open_: category_filters_open_ , category_sorting_open_: category_sorting_open_ , expanded_filters_: expanded_filters_ , selected_filters_: selected_filters_ , get_quicklinks_accessor_: get_quicklinks_accessor_ , i18n_: incoming_i18n , get_breadcrumb_accessor_: get_breadcrumb_accessor_ , slider_arrow_button_: slider_arrow_button_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , local_filter_cache_: local_filter_cache_ , tenant_: tenant_ , market_: market_ , router_: router_ , show_quicklinks_: show_quicklinks_ , category_title_: category_title_ , show_breadcrumbs_: show_breadcrumbs_ , layout_options_: layout_options_ , scroll_restoration_data_: scroll_restoration_data_ , rr_options_: rr_options_ , get_product_id_: get_product_id_ }) {
4959
+ function $671632478f2a7ce7$export$f7d2f673fc2f091d({ depict_api_: depict_api_ , query_id_: query_id_ , current_sorting_: current_sorting_ , min_products_to_fetch_: min_products_to_fetch_ , category_filters_open_: category_filters_open_ , category_sorting_open_: category_sorting_open_ , expanded_filters_: expanded_filters_ , selected_filters_: selected_filters_ , get_quicklinks_accessor_: get_quicklinks_accessor_ , i18n_: incoming_i18n , get_breadcrumb_accessor_: get_breadcrumb_accessor_ , slider_arrow_button_: slider_arrow_button_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , local_filter_cache_: local_filter_cache_ , tenant_: tenant_ , market_: market_ , router_: router_ , show_quicklinks_: show_quicklinks_ , category_title_: category_title_ , show_breadcrumbs_: show_breadcrumbs_ , layout_options_: layout_options_ , scroll_restoration_data_: scroll_restoration_data_ , product_card_template_: product_card_template_ }) {
4769
4960
  let results_for;
4770
4961
  let only_show_filters_opener_;
4771
4962
  let middle_elements_;
@@ -4775,12 +4966,6 @@ function $671632478f2a7ce7$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
4775
4966
  show_n_results_: incoming_i18n.show_n_products_,
4776
4967
  no_results_text_: incoming_i18n.no_products_text_
4777
4968
  };
4778
- const tenant_object_ = new (0, $46MJV$depictaiutilishared.Tenant)({
4779
- TENANT: (0, $46MJV$solidjs.untrack)(tenant_),
4780
- MARKET: (0, $46MJV$solidjs.untrack)(market_),
4781
- GA_ID: "",
4782
- get_product_id: get_product_id_
4783
- });
4784
4969
  const [get_sorting] = current_sorting_;
4785
4970
  const number_of_rendered_selected_filters_items_ = (0, $46MJV$solidjs.createSignal)(0);
4786
4971
  const first_result_in_viewport_ = (0, $46MJV$solidjs.createSignal)();
@@ -5017,11 +5202,9 @@ function $671632478f2a7ce7$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
5017
5202
  last_result_in_viewport_: last_result_in_viewport_,
5018
5203
  scroll_restoration_data_: scroll_restoration_data_,
5019
5204
  layout_options_: layout_options_,
5020
- rr_options_: rr_options_,
5205
+ product_card_template_: product_card_template_,
5021
5206
  sort_or_filter_open_: sort_or_filter_open_,
5022
5207
  desktop_filter_elements_: desktop_filter_elements_,
5023
- tenant_object_: tenant_object_,
5024
- type_for_tracking_: "category",
5025
5208
  id_currently_querying_for_: query_id_,
5026
5209
  no_results_options_: {
5027
5210
  selected_filters_: selected_filters_,
@@ -5172,6 +5355,7 @@ function $623202ae203e9e59$export$f091cbac892643a4(obj) {
5172
5355
 
5173
5356
  function $f27b0b326e0a87e2$export$23fca46f3143581f(component, error_message) {
5174
5357
  const component_in_error_boundary = (do_with_elements)=>{
5358
+ // @ts-ignore
5175
5359
  return (0, $0f2f58dd60b11888$export$b69d0d92862de18b)({
5176
5360
  severity_: "error",
5177
5361
  message_: error_message,
@@ -5198,13 +5382,16 @@ function $f27b0b326e0a87e2$export$23fca46f3143581f(component, error_message) {
5198
5382
 
5199
5383
 
5200
5384
 
5201
- function $004640621ca953d0$export$7bcff1eb3eca57d7(router) {
5385
+ function $cb699e435fadd254$export$477caf01aecaeb2a({ search_query_url_param_name_: search_query_url_param_name_ , router_: router_ }) {
5386
+ const search_query_ = search_query_url_param_name_ ? (0, $46MJV$solidjs.createSignal)("") : undefined;
5387
+ const get_search_query_ = search_query_?.[0];
5388
+ const set_search_query = search_query_?.[1];
5202
5389
  const current_sorting_ = (0, $46MJV$solidjs.createSignal)();
5203
5390
  const selected_filters_ = (0, $46MJV$solidjs.createSignal)([]);
5204
- const [get_sorting, set_sorting] = current_sorting_;
5205
- const [get_selected_filters, set_selected_filters] = selected_filters_;
5391
+ const [get_sorting_, set_sorting] = current_sorting_;
5392
+ const [get_selected_filters_, set_selected_filters] = selected_filters_;
5206
5393
  const [get_current_href, set_current_href] = (0, $46MJV$solidjs.createSignal)(location.href);
5207
- const history_change_handler = ()=>set_current_href(location.href);
5394
+ const history_change_handler = (0, $46MJV$depictaiutilishared.catchify)(()=>set_current_href(location.href));
5208
5395
  const owner = (0, $46MJV$solidjs.getOwner)() || (0, $46MJV$solidjs.createRoot)(()=>(0, $46MJV$solidjs.getOwner)());
5209
5396
  let writer_started = false;
5210
5397
  (0, $46MJV$depictaiutilishared.instant_exec_on_suspect_history_change).add(history_change_handler);
@@ -5214,12 +5401,12 @@ function $004640621ca953d0$export$7bcff1eb3eca57d7(router) {
5214
5401
  (0, $46MJV$solidjs.batch)(()=>{
5215
5402
  const found_sorting = (0, $c6a04c153e9853a7$export$766e9676e74997d3)(searchParams);
5216
5403
  if (found_sorting) {
5217
- const current_sorting = (0, $46MJV$solidjs.untrack)(get_sorting);
5404
+ const current_sorting = (0, $46MJV$solidjs.untrack)(get_sorting_);
5218
5405
  // Do some diffing since we might assume in certain places of the code that if the signal changes it means the sorting has changed
5219
5406
  if (current_sorting?.field !== found_sorting.field || current_sorting?.order !== found_sorting.order) set_sorting(found_sorting);
5220
5407
  } else set_sorting();
5221
5408
  const found_filters = (0, $c6a04c153e9853a7$export$f934fa24c3a86811)(searchParams);
5222
- const selected_filters = (0, $46MJV$solidjs.untrack)(get_selected_filters);
5409
+ const selected_filters = (0, $46MJV$solidjs.untrack)(get_selected_filters_);
5223
5410
  const found_filters_map = new Map(found_filters.map(({ field: field , op: op , data: data })=>[
5224
5411
  JSON.stringify([
5225
5412
  field,
@@ -5232,25 +5419,36 @@ function $004640621ca953d0$export$7bcff1eb3eca57d7(router) {
5232
5419
  field,
5233
5420
  op
5234
5421
  ]))) === JSON.stringify(data))) set_selected_filters(found_filters);
5422
+ if (search_query_url_param_name_) {
5423
+ const found_query = searchParams.get(search_query_url_param_name_);
5424
+ set_search_query(found_query || "");
5425
+ }
5235
5426
  if (!writer_started) {
5236
5427
  // The owner here is the createComputed which gets disposed the next time the computation runs - but we actually just want to delay the start of the href_writer until our signals contain the current value of the URL, therefore the runWithOwner
5237
- (0, $46MJV$solidjs.runWithOwner)(owner, ()=>$004640621ca953d0$var$start_href_writer(get_sorting, get_selected_filters, router));
5428
+ (0, $46MJV$solidjs.runWithOwner)(owner, ()=>$cb699e435fadd254$var$start_href_writer({
5429
+ get_sorting_: get_sorting_,
5430
+ get_selected_filters_: get_selected_filters_,
5431
+ router_: router_
5432
+ }));
5238
5433
  writer_started = true;
5239
5434
  }
5240
5435
  });
5241
5436
  });
5437
+ // @ts-ignore
5242
5438
  return {
5243
5439
  current_sorting_: current_sorting_,
5244
- selected_filters_: selected_filters_
5440
+ selected_filters_: selected_filters_,
5441
+ ...typeof search_query_url_param_name_ === "string" ? {
5442
+ search_query_accessor_: get_search_query_
5443
+ } : {}
5245
5444
  };
5246
5445
  }
5247
5446
  /**
5248
5447
  * Writes the sorting and filters to the URL query parameters when they change.
5249
- */ function $004640621ca953d0$var$start_href_writer(get_sorting, get_selected_filters, router) {
5250
- // This has to be a createComputed because there can be some kind of URL query bouncing back and forwards otherwise (observed when clearing filters by making a new search)
5251
- (0, $46MJV$solidjs.createComputed)((0, $46MJV$solidjs.on)([
5252
- get_sorting,
5253
- get_selected_filters
5448
+ */ function $cb699e435fadd254$var$start_href_writer({ get_sorting_: get_sorting_ , get_selected_filters_: get_selected_filters_ , router_: router_ }) {
5449
+ (0, $46MJV$solidjs.createEffect)((0, $46MJV$solidjs.on)([
5450
+ get_sorting_,
5451
+ get_selected_filters_
5254
5452
  ], ([sorting, filters])=>{
5255
5453
  const current_href = location.href;
5256
5454
  const url_object = new URL(current_href);
@@ -5268,7 +5466,7 @@ function $004640621ca953d0$export$7bcff1eb3eca57d7(router) {
5268
5466
  // Having the array middle step because if we'd check the "size" property of the map the algorithm could be fooled if there were two query parameters with the same key
5269
5467
  const new_search_params_map = new Map(new_search_params);
5270
5468
  if (unmodified_search_params.length !== new_search_params.length || !unmodified_search_params.every(([key, value])=>new_search_params_map.get(key) === value)) // Only update URL if it actually changed
5271
- router.navigate_.go_to_({
5469
+ router_.navigate_.go_to_({
5272
5470
  is_replace_: true,
5273
5471
  new_url_: url_object.href,
5274
5472
  force_spa_navigation_: true
@@ -5328,10 +5526,14 @@ class $43940d5ca403c293$export$7e1297a3a19f10d8 {
5328
5526
  * @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
5329
5527
  * @param is_replace_ if you want to replace the current URL in history instead of pushing a new one
5330
5528
  * @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
5331
- */ go_to_: async ({ new_url_: new_url_ , event_: event_ , force_spa_navigation_: force_spa_navigation_ , is_replace_: is_replace_ , category_query_id_: category_query_id_ })=>{
5529
+ */ go_to_: (0, $46MJV$depictaiutilishared.catchify)(async ({ new_url_: raw_new_url , event_: event_ , force_spa_navigation_: force_spa_navigation_ , is_replace_: is_replace_ , category_query_id_: category_query_id_ })=>{
5530
+ const new_url_ = raw_new_url instanceof URL ? raw_new_url : new URL(raw_new_url, location.origin);
5332
5531
  const wants_hard_navigation = this.on_navigation_ === "hard_navigation";
5333
5532
  if (this.#dont_attempt_navigation(event_)) return;
5334
- if (wants_hard_navigation && !force_spa_navigation_) {
5533
+ const different_origin = new_url_.origin !== location.origin;
5534
+ if (wants_hard_navigation && (!force_spa_navigation_ || different_origin)) {
5535
+ if (force_spa_navigation_ && different_origin) // If we call history.pushState on a different origin, it will throw an error, so fallback to hard navigations
5536
+ (0, $46MJV$depictaiutilishared.dwarn)("Can't single page navigate to", new_url_.href, "due to different origin, this MIGHT mean you should fix the URLs");
5335
5537
  if (!event_) // If we haven't gotten an event, nothing will happen by not calling prevent default, so we need to change the URL
5336
5538
  location.assign(new_url_);
5337
5539
  return;
@@ -5349,7 +5551,7 @@ class $43940d5ca403c293$export$7e1297a3a19f10d8 {
5349
5551
  new_url: new_url_ instanceof URL ? new_url_ : new URL(new_url_, location.origin)
5350
5552
  });
5351
5553
  await promise;
5352
- }
5554
+ })
5353
5555
  };
5354
5556
  constructor(on_navigation){
5355
5557
  this.on_navigation_ = on_navigation;
@@ -5411,7 +5613,9 @@ class $068a627cc18f7bb6$export$f34314aa9505732e {
5411
5613
  Object.assign(this, props_on_class); // set initial signal values
5412
5614
  (0, $33815c5a406b6cc0$export$5162a71f252e6122)();
5413
5615
  if (on_navigation) this.#router.on_navigation_ = on_navigation;
5414
- const { selected_filters_: selected_filters_ , current_sorting_: current_sorting_ } = (0, $004640621ca953d0$export$7bcff1eb3eca57d7)(this.#router);
5616
+ const { selected_filters_: selected_filters_ , current_sorting_: current_sorting_ } = (0, $cb699e435fadd254$export$477caf01aecaeb2a)({
5617
+ router_: this.#router
5618
+ });
5415
5619
  const [reset_history_state_, state_] = (0, $0de081f67b6d15b5$export$9862539c89138352)(()=>({
5416
5620
  category_filters_open: false,
5417
5621
  category_sorting_open: false,
@@ -5420,7 +5624,7 @@ class $068a627cc18f7bb6$export$f34314aa9505732e {
5420
5624
  category_local_filter_cache: [],
5421
5625
  category_expanded_hierarchical_filters: [],
5422
5626
  category_scroll_restoration_data: []
5423
- }));
5627
+ }), this.#router);
5424
5628
  const i18n_ = (0, $623202ae203e9e59$export$f091cbac892643a4)(this.#locale_signal[0]);
5425
5629
  $068a627cc18f7bb6$var$privately_shared_properties.set(this, {
5426
5630
  state_: state_,
@@ -5439,7 +5643,7 @@ class $068a627cc18f7bb6$export$f34314aa9505732e {
5439
5643
  });
5440
5644
  }
5441
5645
  }
5442
- function $068a627cc18f7bb6$export$e2bf8ce7779e827e({ depict_category: depict_category , grid_spacing: grid_spacing , cols_at_size: cols_at_size , product_card_template: product_card_template , get_product_id: get_product_id , show_breadcrumbs: show_breadcrumbs = true , show_quicklinks: show_quicklinks = true , category_title: category_title }) {
5646
+ function $068a627cc18f7bb6$export$e2bf8ce7779e827e({ depict_category: depict_category , grid_spacing: grid_spacing , cols_at_size: cols_at_size , product_card_template: product_card_template , show_breadcrumbs: show_breadcrumbs = true , show_quicklinks: show_quicklinks = true , category_title: category_title }) {
5443
5647
  const shared_properties = $068a627cc18f7bb6$var$get_shared_properties(depict_category);
5444
5648
  const grid_spacing_override = typeof grid_spacing === "string" ? {
5445
5649
  grid_spacing: grid_spacing
@@ -5472,17 +5676,11 @@ function $068a627cc18f7bb6$export$e2bf8ce7779e827e({ depict_category: depict_cat
5472
5676
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
5473
5677
  selected_filters_: selected_filters_,
5474
5678
  scroll_restoration_data_: scroll_restoration_data_,
5475
- get_product_id_: get_product_id,
5476
5679
  layout_options_: {
5477
5680
  cols_at_size: (0, $7958d3dbd96a4f87$export$6daf8749b65a1b77)(cols_at_size),
5478
5681
  ...grid_spacing_override
5479
5682
  },
5480
- rr_options_: {
5481
- template: (display, info)=>{
5482
- const is_placeholder = info.rendering_options.type === "placeholder";
5483
- return product_card_template(is_placeholder ? null : display, info);
5484
- }
5485
- }
5683
+ product_card_template_: product_card_template
5486
5684
  });
5487
5685
  }, "Entire CategoryPage failed");
5488
5686
  }
@@ -5888,22 +6086,48 @@ function $2989e355f64e18e1$export$b94867ecbd698f21({ search_field_value_: search
5888
6086
 
5889
6087
 
5890
6088
 
6089
+
6090
+
5891
6091
  const $9f81b7ced87aabf2$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="cards"></div>`, 2), $9f81b7ced87aabf2$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="search-recs"><h3 class="search-recs-title"></h3></div>`, 4), $9f81b7ced87aabf2$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<button class="show-more major" type="button"></button>`, 2);
5892
6092
  const $9f81b7ced87aabf2$export$1c8c715550dc689d = 2;
5893
- function $9f81b7ced87aabf2$export$7de92c4c2205ebf3({ depict_api_: depict_api_ , i18n_: i18n_ , tenant_object_: tenant_object_ , search_query_base_: search_query_base_ , rr_options_: rr_options_ , showing_recommendation_rows_: showing_recommendation_rows_ , view_more_button_: view_more_button_ = true , layout_options_: layout_options_ }) {
5894
- const [is_showing_something, set_is_showing_something] = (0, $46MJV$solidjs.createSignal)(false);
5895
- const cards = $9f81b7ced87aabf2$var$_tmpl$.cloneNode(true);
5896
- const on_next_render = [];
5897
- const main_element = (()=>{
6093
+ function $9f81b7ced87aabf2$export$7de92c4c2205ebf3({ depict_api_: depict_api_ , i18n_: i18n_ , search_query_base_: search_query_base_ , product_card_template_: product_card_template_ , showing_recommendation_rows_: showing_recommendation_rows_ , view_more_button_: view_more_button_ = true , layout_options_: layout_options_ }) {
6094
+ const [get_showing_recommendation_rows] = showing_recommendation_rows_; // We reset this in after_submit in search.tsx FYI
6095
+ const rows_object = view_more_button_ ? $9f81b7ced87aabf2$var$make_state_saved_rows(showing_recommendation_rows_, i18n_) : "all";
6096
+ const [recommendations_resource] = (0, $46MJV$solidjs.createResource)(search_query_base_, (query)=>depict_api_.get_recommended(query).then((r)=>r.displays));
6097
+ const is_showing_something = (0, $46MJV$solidjs.createMemo)(()=>recommendations_resource.loading || recommendations_resource()?.length);
6098
+ const num_placeholders_ = (0, $46MJV$solidjs.createMemo)(()=>(0, $39d15a684cb3e309$export$6c9030e511152266) + get_showing_recommendation_rows() * Math.max(...layout_options_.cols_at_size.map(([per_column])=>per_column)));
6099
+ const cards = (()=>{
6100
+ const _el$ = $9f81b7ced87aabf2$var$_tmpl$.cloneNode(true);
6101
+ (0, $46MJV$solidjsweb.insert)(_el$, (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Suspense), {
6102
+ get fallback () {
6103
+ return (0, $7b0b7e887b485a91$export$f33414a4df0afd3f)({
6104
+ num_placeholders_: num_placeholders_,
6105
+ product_card_template_: product_card_template_
6106
+ });
6107
+ },
6108
+ get children () {
6109
+ return (()=>{
6110
+ // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
6111
+ const displays_by_key_ = (0, $ea6c1dd5af2900d8$export$7f8bd308237ab5a5)((0, $46MJV$solidjs.createMemo)(()=>recommendations_resource() || []));
6112
+ return (0, $ea6c1dd5af2900d8$export$43f0fb951fcb0c54)({
6113
+ displays_by_key_: displays_by_key_,
6114
+ merchant_: (0, $46MJV$solidjs.createMemo)(()=>search_query_base_().tenant),
6115
+ market_: (0, $46MJV$solidjs.createMemo)(()=>search_query_base_().market),
6116
+ product_card_template_: product_card_template_
6117
+ });
6118
+ })();
6119
+ }
6120
+ }));
6121
+ return _el$;
6122
+ })();
6123
+ const search_recs_elements = (()=>{
5898
6124
  const _el$2 = $9f81b7ced87aabf2$var$_tmpl$2.cloneNode(true), _el$3 = _el$2.firstChild;
5899
6125
  (0, $46MJV$solidjsweb.insert)(_el$3, ()=>i18n_.search_recs_title_());
5900
6126
  (0, $46MJV$solidjsweb.insert)(_el$2, (0, $8e863dc22b06b688$export$a2cc176055f8f08), null);
5901
6127
  (0, $46MJV$solidjsweb.insert)(_el$2, cards, null);
5902
6128
  return _el$2;
5903
6129
  })();
5904
- const [get_showing_recommendation_rows] = showing_recommendation_rows_;
5905
- const rows_object = view_more_button_ ? $9f81b7ced87aabf2$var$make_state_saved_rows(showing_recommendation_rows_, i18n_) : "all";
5906
- const cleanup_old_cards = [];
6130
+ // the cards element must have a parent for Layout to work, therefore we're inserting it into a div above
5907
6131
  (0, $46MJV$depictaiutilishared.Layout)({
5908
6132
  container_element: cards,
5909
6133
  layout: "grid",
@@ -5913,77 +6137,11 @@ function $9f81b7ced87aabf2$export$7de92c4c2205ebf3({ depict_api_: depict_api_ ,
5913
6137
  e,
5914
6138
  "Layout failed"
5915
6139
  ], "error"));
5916
- // copied from RecommendationGrid
5917
- // convoluted lazy loading that
5918
- // when the elements are in the DOM starts IntersectionObserver on whole grid
5919
- // when grid intersects starts Lazyfier
5920
- // this is because Lazyfier is fucking stupid
5921
- (0, $46MJV$depictaiutilishared.observer).wait_for_element(cards).then((0, $46MJV$depictaiutilishared.catchify)((element)=>{
5922
- let start_lazy_loading;
5923
- const lazy_loading_promise = new Promise((r)=>start_lazy_loading = r);
5924
- const lf = new (0, $46MJV$depictaiutilishared.Lazyfier)({
5925
- only_load_intersecting: true,
5926
- wait_for_dominsertion: lazy_loading_promise,
5927
- ignore_data_urls: true,
5928
- lazyfinder: {
5929
- unload () {}
5930
- }
5931
- });
5932
- lf.start_observing_for_new_children_(element);
5933
- const i_o = new IntersectionObserver((0, $46MJV$depictaiutilishared.catchify)((records)=>{
5934
- for (const record of records)if (record.intersectionRatio > 0) {
5935
- start_lazy_loading();
5936
- i_o.disconnect();
5937
- return;
5938
- }
5939
- }));
5940
- i_o.observe(cards);
5941
- }));
5942
- const deparallelized_recs_fetcher = (0, $46MJV$depictaiutilishared.deparallelize_no_drop)((0, $46MJV$depictaiutilishared.catchify)(async (base_query)=>{
5943
- const recs_promise = depict_api_.get_recommended(base_query).then((r)=>r.displays);
5944
- // create owner to run product cards with an Owner, so they know when they've gotten removed
5945
- const [owner_for_cards, dispose_our_cards] = (0, $46MJV$solidjs.createRoot)((dispose)=>[
5946
- (0, $46MJV$solidjs.getOwner)(),
5947
- dispose
5948
- ]);
5949
- const rendering_result = await (await (0, $46MJV$depictaiutilishared.make_placeholder_rr)({
5950
- // render the max amount of elements that there could be, to make sure scroll restoration works (placeholders can't be shorter than actual content)
5951
- num_items: (0, $39d15a684cb3e309$export$6c9030e511152266) + (0, $46MJV$solidjs.untrack)(get_showing_recommendation_rows) * Math.max(...layout_options_.cols_at_size.map(([per_column])=>per_column))
5952
- }))(tenant_object_, // @ts-ignore - make_placeholder_rr types is a touchy subject
5953
- {
5954
- type: "search_recs",
5955
- recs: recs_promise,
5956
- ...rr_options_,
5957
- ...typeof rr_options_.template === "function" ? {
5958
- template: (...args)=>(0, $46MJV$solidjs.runWithOwner)(owner_for_cards, ()=>// give template the possibility to know when it gets removed from the DOM by using solid-js onCleanup
5959
- // @ts-ignore
5960
- rr_options_.template(...args))
5961
- } : {}
5962
- });
5963
- const { elements: elements , should_stay_inserted: should_stay_inserted } = rendering_result;
5964
- let dead = false;
5965
- while(on_next_render.length)on_next_render.pop()();
5966
- on_next_render.push(()=>dead = true);
5967
- if (!elements) {
5968
- set_is_showing_something(false);
5969
- return;
5970
- }
5971
- cards.replaceChildren(...elements);
5972
- // Dispose the old cards just after the cards have been removed from the DOM
5973
- cleanup_old_cards.forEach((cleanup_function)=>cleanup_function());
5974
- cleanup_old_cards.push(dispose_our_cards); // push after calling, so that we don't instantly demolish ourselves lol
5975
- set_is_showing_something(true);
5976
- should_stay_inserted?.then((should)=>{
5977
- if (!should && !dead /* just in case */ ) set_is_showing_something(false);
5978
- });
5979
- }));
5980
- (0, $46MJV$solidjs.createRenderEffect)(()=>deparallelized_recs_fetcher(search_query_base_()));
5981
- (0, $46MJV$solidjs.onCleanup)(()=>cleanup_old_cards.forEach((fn)=>fn())); // if everything gets cleaned up without new cards replacing the old ones, clean up the last cards
5982
6140
  return (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Show), {
5983
6141
  get when () {
5984
6142
  return is_showing_something();
5985
6143
  },
5986
- children: main_element
6144
+ children: search_recs_elements
5987
6145
  });
5988
6146
  }
5989
6147
  function $9f81b7ced87aabf2$var$make_state_saved_rows([get_showing_recommendation_rows, set_showing_recommendation_rows], i18n_) {
@@ -6065,7 +6223,7 @@ function $67b60b572b7b7059$export$b3ad617e9036868(modal_body_style, input_field,
6065
6223
 
6066
6224
 
6067
6225
 
6068
- function $8b282f736ce4f3b8$export$e026af0c7b64ea5f({ selected_filters_: selected_filters_ , search_query_: [get_search_query] , current_sorting_: current_sorting_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , i18n_: i18n_ , local_filter_cache_: local_filter_cache_ }) {
6226
+ function $8b282f736ce4f3b8$export$e026af0c7b64ea5f({ selected_filters_: selected_filters_ , get_search_query_: get_search_query_ , current_sorting_: current_sorting_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , i18n_: i18n_ , local_filter_cache_: local_filter_cache_ }) {
6069
6227
  const [get_selected_filters] = selected_filters_;
6070
6228
  // Possible values:
6071
6229
  // 0 - we should not clear next submit
@@ -6080,7 +6238,7 @@ function $8b282f736ce4f3b8$export$e026af0c7b64ea5f({ selected_filters_: selected
6080
6238
  }, {
6081
6239
  defer: true
6082
6240
  }));
6083
- (0, $46MJV$solidjs.createComputed)((0, $46MJV$solidjs.on)(get_search_query, (0, $46MJV$depictaiutilishared.catchify)(()=>{
6241
+ (0, $46MJV$solidjs.createComputed)((0, $46MJV$solidjs.on)(get_search_query_, (0, $46MJV$depictaiutilishared.catchify)(()=>{
6084
6242
  // when a query was submitted, clear filters if clear was pressed before
6085
6243
  const clear_value = (0, $46MJV$solidjs.untrack)(get_clear_filters_next_submit);
6086
6244
  if (clear_value) {
@@ -6105,12 +6263,11 @@ function $8b282f736ce4f3b8$export$e026af0c7b64ea5f({ selected_filters_: selected
6105
6263
 
6106
6264
 
6107
6265
 
6108
- function $ad118c2ba257d9b7$export$84bba84a7b837187(search_query) {
6266
+ function $ad118c2ba257d9b7$export$84bba84a7b837187(read_search_query) {
6109
6267
  const ls = localStorage;
6110
6268
  const key = "depict_searches";
6111
6269
  const previous_searches = (0, $46MJV$solidjs.createSignal)(JSON.parse(ls[key] || "[]"));
6112
6270
  const [read_previous_searches, write_previous_searches] = previous_searches;
6113
- const [read_search_query] = search_query;
6114
6271
  (0, $46MJV$solidjs.createEffect)((0, $46MJV$depictaiutilishared.catchify)(()=>{
6115
6272
  const json_encoded = JSON.stringify(read_previous_searches());
6116
6273
  if (ls[key] !== json_encoded) ls[key] = json_encoded;
@@ -6131,9 +6288,9 @@ function $ad118c2ba257d9b7$export$84bba84a7b837187(search_query) {
6131
6288
 
6132
6289
 
6133
6290
 
6134
- async function $1c323edfb89c9dca$export$e16630ecb9644a1c({ on_submit_with_unchanged_value_: on_submit_with_unchanged_value_ , search_param_name_: search_param_name_ , set_search_field_value_: set_search_field_value_ , search_query_: [read_search_query] , url_transformer_: url_transformer_ , router_: router_ , after_submit_: after_submit_ , get_new_query: get_new_query }) {
6291
+ async function $1c323edfb89c9dca$export$e16630ecb9644a1c({ on_submit_with_unchanged_value_: on_submit_with_unchanged_value_ , search_param_name_: search_param_name_ , set_search_field_value_: set_search_field_value_ , get_search_query_: get_search_query_ , url_transformer_: url_transformer_ , router_: router_ , after_submit_: after_submit_ , get_new_query: get_new_query }) {
6135
6292
  const new_search_query = get_new_query();
6136
- const previous_query = (0, $46MJV$solidjs.untrack)(read_search_query);
6293
+ const previous_query = (0, $46MJV$solidjs.untrack)(get_search_query_);
6137
6294
  if (previous_query === new_search_query && new URLSearchParams(location.search).has(search_param_name_)) {
6138
6295
  // don't push a history entry / re-search if someone submits a search again
6139
6296
  // do close the modal though
@@ -6157,32 +6314,6 @@ async function $1c323edfb89c9dca$export$e16630ecb9644a1c({ on_submit_with_unchan
6157
6314
 
6158
6315
 
6159
6316
 
6160
- function $690220645373c65e$export$2542ffb77b620b02(params_to_default_value) {
6161
- // TODO: remove this abstraction, put it in same place as filters
6162
- // TODO: make it only return an accessor
6163
- const signals = {};
6164
- const entries = Object.entries(params_to_default_value);
6165
- for (const [param, default_value] of entries)signals[param] = (0, $46MJV$solidjs.createSignal)(default_value ?? "");
6166
- const [exit_iterable, exitable_iterable] = (0, $46MJV$depictaiutilishared.make_asyncIterable_exiter)((0, $46MJV$depictaiutilishared.href_change_ipns));
6167
- (0, $46MJV$solidjs.onCleanup)((0, $46MJV$depictaiutilishared.catchify)(exit_iterable));
6168
- (0, $46MJV$depictaiutilishared.catchify)(async ()=>{
6169
- for await (const href of exitable_iterable){
6170
- const { searchParams: searchParams } = new URL(href);
6171
- for (const [param, default_value] of entries){
6172
- const [_get, set] = signals[param];
6173
- if (searchParams.has(param)) {
6174
- const new_val = searchParams.get(param) ?? default_value ?? "";
6175
- set(new_val);
6176
- } else set(default_value ?? "");
6177
- }
6178
- }
6179
- })();
6180
- return signals;
6181
- }
6182
-
6183
-
6184
-
6185
-
6186
6317
 
6187
6318
 
6188
6319
 
@@ -6222,7 +6353,8 @@ function $690220645373c65e$export$2542ffb77b620b02(params_to_default_value) {
6222
6353
 
6223
6354
 
6224
6355
  const $1bf0125991f2d39b$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<span class="orig price"></span>`, 2), $1bf0125991f2d39b$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<a class="instant-card"><div class="img-part"></div><div class="right-part"><div class="title-brand-tagline"><span class="brand"></span><span class="title"></span></div><div class="price-container"><span class="price"></span></div></div></a>`, 16), $1bf0125991f2d39b$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="tagline"></div>`, 2);
6225
- const $1bf0125991f2d39b$export$b05c0ae390cf3e06 = (display_or_variant_container, { i18n: i18n , market: market }, router_)=>{
6356
+ const $1bf0125991f2d39b$export$b05c0ae390cf3e06 = (display_or_variant_container, { i18n: i18n }, router_)=>{
6357
+ const search_result_id = (0, $46MJV$solidjs.createMemo)(()=>display_or_variant_container().search_result_id);
6226
6358
  const display = (0, $46MJV$solidjs.createMemo)(()=>{
6227
6359
  const display = display_or_variant_container();
6228
6360
  // Support for backend's new display format
@@ -6240,19 +6372,19 @@ const $1bf0125991f2d39b$export$b05c0ae390cf3e06 = (display_or_variant_container,
6240
6372
  });
6241
6373
  const image_url = (0, $46MJV$solidjs.createMemo)(()=>display().image_url);
6242
6374
  const contained_image = (0, $46MJV$solidjs.createMemo)(()=>(0, $46MJV$depictaiutilishared.ContainedImage)({
6375
+ loading: "lazy",
6243
6376
  aspect_ratio: 1,
6244
6377
  alt: "",
6245
6378
  rendering_options: {},
6246
- // @ts-ignore
6247
- "data-src": image_url(),
6379
+ "src": image_url(),
6248
6380
  srcset_opts: {
6249
- set_dataset: true
6381
+ set_dataset: false
6250
6382
  },
6251
- init_with_placeholder: true
6383
+ sizes: "0px"
6252
6384
  }));
6253
6385
  const is_sale = (0, $46MJV$solidjs.createMemo)(()=>display().sale_price !== display().original_price);
6254
6386
  const href = (0, $46MJV$solidjs.createMemo)(()=>display().page_url);
6255
- const returnVal = (()=>{
6387
+ return (()=>{
6256
6388
  const _el$ = $1bf0125991f2d39b$var$_tmpl$2.cloneNode(true), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling, _el$4 = _el$3.firstChild, _el$5 = _el$4.firstChild, _el$6 = _el$5.nextSibling, _el$7 = _el$4.nextSibling, _el$9 = _el$7.firstChild;
6257
6389
  (0, $46MJV$solidjsweb.addEventListener)(_el$, "click", (0, $46MJV$depictaiutilishared.catchify)((event_)=>router_.navigate_.go_to_({
6258
6390
  new_url_: href(),
@@ -6280,33 +6412,41 @@ const $1bf0125991f2d39b$export$b05c0ae390cf3e06 = (display_or_variant_container,
6280
6412
  get children () {
6281
6413
  const _el$8 = $1bf0125991f2d39b$var$_tmpl$.cloneNode(true);
6282
6414
  (0, $46MJV$solidjsweb.insert)(_el$8, ()=>i18n.price_formatting_().pre_, null);
6283
- (0, $46MJV$solidjsweb.insert)(_el$8, ()=>(0, $5fc9fc23df1591db$export$469c7af753d08925)({
6284
- price_: (0, $46MJV$solidjs.createMemo)(()=>display().original_price),
6285
- price_formatting_: i18n.price_formatting_
6286
- }), null);
6415
+ (0, $46MJV$solidjsweb.insert)(_el$8, (0, $46MJV$solidjsweb.createComponent)((0, $5fc9fc23df1591db$export$a71e92cfbb498adc), {
6416
+ get price_ () {
6417
+ return display().original_price;
6418
+ },
6419
+ get price_formatting_ () {
6420
+ return i18n.price_formatting_();
6421
+ }
6422
+ }), null);
6287
6423
  (0, $46MJV$solidjsweb.insert)(_el$8, ()=>i18n.price_formatting_().post_, null);
6288
6424
  return _el$8;
6289
6425
  }
6290
6426
  }), _el$9);
6291
6427
  (0, $46MJV$solidjsweb.insert)(_el$9, ()=>i18n.price_formatting_().pre_, null);
6292
- (0, $46MJV$solidjsweb.insert)(_el$9, ()=>(0, $5fc9fc23df1591db$export$469c7af753d08925)({
6293
- price_: (0, $46MJV$solidjs.createMemo)(()=>display().sale_price),
6294
- price_formatting_: i18n.price_formatting_
6295
- }), null);
6428
+ (0, $46MJV$solidjsweb.insert)(_el$9, (0, $46MJV$solidjsweb.createComponent)((0, $5fc9fc23df1591db$export$a71e92cfbb498adc), {
6429
+ get price_ () {
6430
+ return display().sale_price;
6431
+ },
6432
+ get price_formatting_ () {
6433
+ return i18n.price_formatting_();
6434
+ }
6435
+ }), null);
6296
6436
  (0, $46MJV$solidjsweb.insert)(_el$9, ()=>i18n.price_formatting_().post_, null);
6297
6437
  (0, $46MJV$solidjsweb.effect)((_p$)=>{
6298
- const _v$ = href(), _v$2 = !!is_sale();
6438
+ const _v$ = href(), _v$2 = search_result_id(), _v$3 = !!is_sale();
6299
6439
  _v$ !== _p$._v$ && (0, $46MJV$solidjsweb.setAttribute)(_el$, "href", _p$._v$ = _v$);
6300
- _v$2 !== _p$._v$2 && _el$9.classList.toggle("sales-price", _p$._v$2 = _v$2);
6440
+ _v$2 !== _p$._v$2 && (0, $46MJV$solidjsweb.setAttribute)(_el$, "data-search-result-id", _p$._v$2 = _v$2);
6441
+ _v$3 !== _p$._v$3 && _el$9.classList.toggle("sales-price", _p$._v$3 = _v$3);
6301
6442
  return _p$;
6302
6443
  }, {
6303
6444
  _v$: undefined,
6304
- _v$2: undefined
6445
+ _v$2: undefined,
6446
+ _v$3: undefined
6305
6447
  });
6306
6448
  return _el$;
6307
6449
  })();
6308
- // This solves a JSX type issue where the return value does not match with the explicit JSX.Element type for some reason
6309
- return returnVal;
6310
6450
  };
6311
6451
  (0, $46MJV$solidjsweb.delegateEvents)([
6312
6452
  "click"
@@ -6343,7 +6483,7 @@ function $4cadf33fd6aaf4b6$export$62f101a8aa597bf8({ depict_api_: depict_api_ ,
6343
6483
  }));
6344
6484
  const sliced_displays = (0, $46MJV$solidjs.createMemo)(()=>search_results()?.displays?.slice(0, max_cards));
6345
6485
  let placeholder;
6346
- const container = (()=>{
6486
+ return (()=>{
6347
6487
  const _el$ = $4cadf33fd6aaf4b6$var$_tmpl$.cloneNode(true);
6348
6488
  (0, $46MJV$solidjsweb.insert)(_el$, (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Show), {
6349
6489
  get when () {
@@ -6361,8 +6501,8 @@ function $4cadf33fd6aaf4b6$export$62f101a8aa597bf8({ depict_api_: depict_api_ ,
6361
6501
  get each () {
6362
6502
  return sliced_displays();
6363
6503
  },
6364
- children: (d, i)=>$4cadf33fd6aaf4b6$var$track_elements(d, i, // Custom instant card requires a re-render on every display or i18n update
6365
- render_instant_card_ ? (0, $46MJV$solidjs.createMemo)(()=>render_instant_card_(d(), {
6504
+ children: (d, i)=>{
6505
+ const card = render_instant_card_ ? (0, $46MJV$solidjs.createMemo)(()=>render_instant_card_(d(), {
6366
6506
  index: i,
6367
6507
  i18n: (0, $850f0c7c629012e3$export$27b710c08412a7ad)(i18n_),
6368
6508
  merchant: tenant_(),
@@ -6372,79 +6512,14 @@ function $4cadf33fd6aaf4b6$export$62f101a8aa597bf8({ depict_api_: depict_api_ ,
6372
6512
  i18n: i18n_,
6373
6513
  merchant: tenant_(),
6374
6514
  market: market_()
6375
- }, router_), tenant_, market_)
6515
+ }, router_);
6516
+ return card;
6517
+ }
6376
6518
  });
6377
6519
  }
6378
6520
  }));
6379
6521
  return _el$;
6380
6522
  })();
6381
- new (0, $46MJV$depictaiutilishared.Lazyfier)({
6382
- container: container,
6383
- lazyfinder: {
6384
- unload () {}
6385
- },
6386
- ignore_data_urls: true
6387
- });
6388
- return container;
6389
- }
6390
- function $4cadf33fd6aaf4b6$var$track_elements(display, index, elements, tenant, market) {
6391
- const type = "instant_result";
6392
- const unwrapped_elements = $4cadf33fd6aaf4b6$var$unwrap_solid_jsx_element(elements);
6393
- const disconnectors = [];
6394
- (0, $46MJV$solidjs.createComputed)(()=>{
6395
- let stop = false;
6396
- const modern_or_legacy_d = display(); // For every display
6397
- const d = "variant_index" in modern_or_legacy_d ? modern_or_legacy_d.variant_displays[modern_or_legacy_d.variant_index] : modern_or_legacy_d;
6398
- const t = tenant(); // and tenant
6399
- const m = market(); // / market combination
6400
- const click_handler = ()=>{
6401
- (0, $46MJV$depictaiutilishared.depict_click)({
6402
- tenant: (0, $46MJV$solidjs.untrack)(tenant),
6403
- market: (0, $46MJV$solidjs.untrack)(market),
6404
- ...d,
6405
- click_location: type + "_" + (index + 1),
6406
- recommendation_type: type
6407
- });
6408
- localStorage.setItem(`depict_attribution_${d.product_id}`, d.search_result_id);
6409
- };
6410
- while(disconnectors.length)// disconnect stuff from old display
6411
- disconnectors.pop()();
6412
- disconnectors.push(()=>stop = true);
6413
- (0, $46MJV$solidjs.createComputed)(()=>{
6414
- if (stop) return;
6415
- const filtered_els = unwrapped_elements().filter((el)=>el instanceof Element);
6416
- for (const element of filtered_els){
6417
- element.addEventListener("click", click_handler);
6418
- disconnectors.push((0, $46MJV$depictaiutilishared.impression_track_element)({
6419
- element: element,
6420
- data: {
6421
- tenant: t,
6422
- market: m,
6423
- recommendation_type: type,
6424
- recommendation_id: d.recommendation_id,
6425
- product_id: d.product_id,
6426
- entity_price: d.entity_price
6427
- }
6428
- }), ()=>element.removeEventListener("click", click_handler));
6429
- }
6430
- (0, $46MJV$depictaiutilishared.add_new_tab_listener)(filtered_els, d, 1, (disconnector)=>disconnectors.push(disconnector));
6431
- });
6432
- });
6433
- return elements;
6434
- }
6435
- function $4cadf33fd6aaf4b6$var$unwrap_solid_jsx_element(elements) {
6436
- // FYI this probably doesn't work on hugely deep nestings or large amount of elements
6437
- return (0, $46MJV$solidjs.createMemo)(()=>$4cadf33fd6aaf4b6$var$unwrapping_helper(elements));
6438
- }
6439
- function $4cadf33fd6aaf4b6$var$unwrapping_helper(elements) {
6440
- const result = [];
6441
- if (Array.isArray(elements)) for(let i = 0; i < elements.length; i++){
6442
- const element = elements[i];
6443
- result.push(...$4cadf33fd6aaf4b6$var$unwrapping_helper(element));
6444
- }
6445
- else if (typeof elements == "function") result.push(...$4cadf33fd6aaf4b6$var$unwrapping_helper(elements()));
6446
- else if (elements != undefined && typeof elements != "boolean") result.push(elements);
6447
- return result;
6448
6523
  }
6449
6524
 
6450
6525
 
@@ -6678,14 +6753,14 @@ function $5a0afe153acd45d7$export$ba17c5b7e6dda39f({ whole_text_to_display_: who
6678
6753
 
6679
6754
 
6680
6755
  const $aabe56c678fa29ec$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<a class="suggestion"></a>`, 2), $aabe56c678fa29ec$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="search-icon"></div>`, 2), $aabe56c678fa29ec$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<span class="type"></span>`, 2), $aabe56c678fa29ec$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div><span class="value"></span></div>`, 4), $aabe56c678fa29ec$var$_tmpl$5 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<h2 class="text"></h2>`, 2), $aabe56c678fa29ec$var$_tmpl$6 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="suggestion-container query"></div>`, 2), $aabe56c678fa29ec$var$_tmpl$7 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="suggestion-container page"></div>`, 2), $aabe56c678fa29ec$var$_tmpl$8 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="suggestions"></div>`, 2);
6681
- function $aabe56c678fa29ec$export$e872e2339fb04a7f({ suggestion_memo_: suggestion_memo_ , search_page_url_param_name_: search_page_url_param_name_ , selected_index_: [read_selected_index_, write_selected_index_] , url_transformer_: url_transformer_ , filtered_previous_searches_: filtered_previous_searches_ , currently_showing_suggestions_: currently_showing_suggestions_ , on_previous_searches_page_: on_previous_searches_page_ , i18n_: i18n_ , include_category_suggestions_: include_category_suggestions_ , searching_for_value_: searching_for_value_ , router_: router_ , submit_query_: submit_query_ }) {
6756
+ function $aabe56c678fa29ec$export$e872e2339fb04a7f({ suggestion_memo_: suggestion_memo_ , search_query_url_param_name_: search_query_url_param_name_ , selected_index_: [read_selected_index_, write_selected_index_] , url_transformer_: url_transformer_ , filtered_previous_searches_: filtered_previous_searches_ , currently_showing_suggestions_: currently_showing_suggestions_ , on_previous_searches_page_: on_previous_searches_page_ , i18n_: i18n_ , include_category_suggestions_: include_category_suggestions_ , searching_for_value_: searching_for_value_ , router_: router_ , submit_query_: submit_query_ }) {
6682
6757
  const queries_memo = (0, $46MJV$solidjs.createMemo)(()=>suggestion_memo_().filter(({ type: type , title: title })=>type === (0, $81eea900c72d569b$export$3cf9497e790da491) && !filtered_previous_searches_().includes(title) // don't show the ones we already show from the history
6683
6758
  ));
6684
6759
  const not_queries_memo = (0, $46MJV$solidjs.createMemo)(()=>suggestion_memo_().filter(({ type: type })=>type !== (0, $81eea900c72d569b$export$3cf9497e790da491)));
6685
6760
  const render_entry = (input_obj, autocomplete_data_index, index, is_history = false)=>{
6686
6761
  const is_query = (0, $46MJV$solidjs.createMemo)(()=>input_obj().type === (0, $81eea900c72d569b$export$3cf9497e790da491));
6687
6762
  const href_with_changed_params_accessor = (0, $46MJV$solidjs.createMemo)(()=>is_query() ? (0, $41151dd3f5de2c98$export$91c3b6774e8be0f5)({
6688
- param_: search_page_url_param_name_,
6763
+ param_: search_query_url_param_name_,
6689
6764
  value_: (0, $46MJV$solidjs.createMemo)(()=>input_obj().title),
6690
6765
  url_transformer_: url_transformer_
6691
6766
  }) : undefined);
@@ -7021,7 +7096,7 @@ function $bc74fbd61efdd8a5$var$open_link_on_cmd_pressed(e, href) {
7021
7096
 
7022
7097
 
7023
7098
  const $81eea900c72d569b$export$3cf9497e790da491 = "query";
7024
- function $81eea900c72d569b$export$2f2b9559550c7bbc({ search_field_value_: search_field_value_ , search_query_: [get_search_query_] , search_page_url_param_name_: search_page_url_param_name_ , previous_searches_: unfiltered_previous_searches , previous_searches_text_: previous_searches_text_ , depict_api_: depict_api_ , tenant_: tenant_ , market_: market_ , input_field_: input_field_ , url_transformer_: url_transformer_ , currently_showing_suggestions_: currently_showing_suggestions_ , set_override_on_enter_fn_: set_override_on_enter_fn_ , selected_index_: selected_index_ , i18n_: i18n_ , include_category_suggestions_: include_category_suggestions_ , submit_query_: submit_query_ , router_: router_ }) {
7099
+ function $81eea900c72d569b$export$2f2b9559550c7bbc({ search_field_value_: search_field_value_ , get_search_query_: get_search_query_ , search_query_url_param_name_: search_query_url_param_name_ , previous_searches_: unfiltered_previous_searches , previous_searches_text_: previous_searches_text_ , depict_api_: depict_api_ , tenant_: tenant_ , market_: market_ , input_field_: input_field_ , url_transformer_: url_transformer_ , currently_showing_suggestions_: currently_showing_suggestions_ , set_override_on_enter_fn_: set_override_on_enter_fn_ , selected_index_: selected_index_ , i18n_: i18n_ , include_category_suggestions_: include_category_suggestions_ , submit_query_: submit_query_ , router_: router_ }) {
7025
7100
  const [searching_for_value, set_searching_for_value] = (0, $46MJV$solidjs.createSignal)();
7026
7101
  const [read_search_field_value] = search_field_value_;
7027
7102
  const updating_blocked = (0, $46MJV$solidjs.createSignal)(false);
@@ -7062,7 +7137,7 @@ function $81eea900c72d569b$export$2f2b9559550c7bbc({ search_field_value_: search
7062
7137
  updating_blocked_: updating_blocked,
7063
7138
  currently_showing_suggestions_: currently_showing_suggestions_,
7064
7139
  set_override_on_enter_fn_: set_override_on_enter_fn_,
7065
- search_query_param_name_: search_page_url_param_name_,
7140
+ search_query_param_name_: search_query_url_param_name_,
7066
7141
  url_transformer_: url_transformer_,
7067
7142
  router_: router_
7068
7143
  });
@@ -7077,7 +7152,7 @@ function $81eea900c72d569b$export$2f2b9559550c7bbc({ search_field_value_: search
7077
7152
  get set_unfiltered_previous_searches_ () {
7078
7153
  return unfiltered_previous_searches[1];
7079
7154
  },
7080
- search_query_param_name_: search_page_url_param_name_,
7155
+ search_query_param_name_: search_query_url_param_name_,
7081
7156
  text_: previous_searches_text_,
7082
7157
  get previous_searches_ () {
7083
7158
  return (0, $46MJV$solidjs.createMemo)(()=>filtered_previous_searches().slice(0, 5));
@@ -7104,7 +7179,7 @@ function $81eea900c72d569b$export$2f2b9559550c7bbc({ search_field_value_: search
7104
7179
  i18n_: i18n_,
7105
7180
  url_transformer_: url_transformer_,
7106
7181
  searching_for_value_: searching_for_value,
7107
- search_page_url_param_name_: search_page_url_param_name_,
7182
+ search_query_url_param_name_: search_query_url_param_name_,
7108
7183
  selected_index_: selected_index_,
7109
7184
  suggestion_memo_: read_suggestion_signal,
7110
7185
  currently_showing_suggestions_: currently_showing_suggestions_,
@@ -7139,13 +7214,13 @@ function $fe1bd893954cc9ca$export$c7e181728ad525f(url) {
7139
7214
  }
7140
7215
 
7141
7216
 
7142
- function $4ee1f6be4255fde6$export$3340fdd8259bd4fd({ get_search_field_value_: get_search_field_value_ , search_page_url_param_name_: search_page_url_param_name_ , url_transformer_: url_transformer_ , get_search_query_: get_search_query_ }) {
7217
+ function $4ee1f6be4255fde6$export$3340fdd8259bd4fd({ get_search_field_value_: get_search_field_value_ , search_query_url_param_name_: search_query_url_param_name_ , url_transformer_: url_transformer_ , get_search_query_: get_search_query_ }) {
7143
7218
  let debounce_timeout;
7144
7219
  const stop_timeout = ()=>clearTimeout(debounce_timeout);
7145
7220
  const send_to_ga = (0, $46MJV$depictaiutilishared.catchify)(()=>{
7146
7221
  const fake_url = new URL(location.href);
7147
7222
  const { searchParams: searchParams } = fake_url;
7148
- searchParams.set(search_page_url_param_name_, (0, $46MJV$solidjs.untrack)(get_search_field_value_));
7223
+ searchParams.set(search_query_url_param_name_, (0, $46MJV$solidjs.untrack)(get_search_field_value_));
7149
7224
  searchParams.set("instant_result", "true");
7150
7225
  url_transformer_?.(fake_url);
7151
7226
  (0, $fe1bd893954cc9ca$export$c7e181728ad525f)(fake_url);
@@ -7196,7 +7271,7 @@ function $4a976b492943589f$export$f021bdedd3ec901a(props) {
7196
7271
 
7197
7272
 
7198
7273
  const $121d25ca6af2898f$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="discover-more"><button class="major" type="button"></button></div>`, 4), $121d25ca6af2898f$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<b></b>`, 2), $121d25ca6af2898f$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="depict-search-modal"><div class="body"><div class="padded"></div></div></div>`, 6), $121d25ca6af2898f$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="depict plp search"><div class="depict-search-modal-backdrop"></div></div>`, 4);
7199
- function $121d25ca6af2898f$export$1c593cbd6f1e10bc({ search_field_value_: props_search_field_value , search_query_: search_query_ , search_page_url_param_name_: search_page_url_param_name_ , previous_searches_: previous_searches_ , close_modal_: close_modal_ , style_props_: style_props_ = (0, $46MJV$solidjs.createSignal)({}) , depict_api_: depict_api_ , tenant_: tenant_ , market_: market_ , submit_query_: props_submit_query , instant_results_options_: instant_results_options_ , register_closing_animation_: register_closing_animation_ , url_transformer_: url_transformer_ , closing_animation_: closing_animation_ , clear_filters_: clear_filters_ , i18n_: i18n_ , disable_scrolling_: disable_scrolling_ = true , enable_category_suggestions_: enable_category_suggestions_ , class_list_: class_list_ , bottom_distance_under_modal_: bottom_distance_under_modal_ , selected_text_range_: selected_text_range_ , dont_sync_search_field_value_except_on_submit_: dont_sync_search_field_value_except_on_submit_ = false , router_: router_ }) {
7274
+ function $121d25ca6af2898f$export$1c593cbd6f1e10bc({ search_field_value_: props_search_field_value , get_search_query_: get_search_query_ , search_query_url_param_name_: search_query_url_param_name_ , previous_searches_: previous_searches_ , close_modal_: close_modal_ , style_props_: style_props_ = (0, $46MJV$solidjs.createSignal)({}) , depict_api_: depict_api_ , tenant_: tenant_ , market_: market_ , submit_query_: props_submit_query , instant_results_options_: instant_results_options_ , register_closing_animation_: register_closing_animation_ , url_transformer_: url_transformer_ , closing_animation_: closing_animation_ , clear_filters_: clear_filters_ , i18n_: i18n_ , disable_scrolling_: disable_scrolling_ = true , enable_category_suggestions_: enable_category_suggestions_ , class_list_: class_list_ , bottom_distance_under_modal_: bottom_distance_under_modal_ , selected_text_range_: selected_text_range_ , dont_sync_search_field_value_except_on_submit_: dont_sync_search_field_value_except_on_submit_ = false , router_: router_ }) {
7200
7275
  let on_enter_in_search_field_function;
7201
7276
  // As per feedback from stronger we sometimes want a modal with the search field value disconnected from the one in the rest of the UI, see https://depictaiworkspace.slack.com/archives/C02J16R9XEH/p1679065878487709.
7202
7277
  // This is desired for when the modal is opened from a UI element that visually does not look connected with the search page or current query
@@ -7223,7 +7298,7 @@ function $121d25ca6af2898f$export$1c593cbd6f1e10bc({ search_field_value_: props_
7223
7298
  equals: false
7224
7299
  });
7225
7300
  if (disable_scrolling_) (0, $fa41c421eb980e23$export$fe334901e8bebd57)();
7226
- $121d25ca6af2898f$var$close_modal_when_navigating_away(close_modal_, search_page_url_param_name_);
7301
+ $121d25ca6af2898f$var$close_modal_when_navigating_away(close_modal_, search_query_url_param_name_);
7227
7302
  window.addEventListener("keydown", close_on_escape_handler);
7228
7303
  (0, $46MJV$solidjs.onCleanup)((0, $46MJV$depictaiutilishared.catchify)(()=>window.removeEventListener("keydown", close_on_escape_handler)));
7229
7304
  const owner = (0, $46MJV$solidjs.getOwner)();
@@ -7248,8 +7323,8 @@ function $121d25ca6af2898f$export$1c593cbd6f1e10bc({ search_field_value_: props_
7248
7323
  (0, $4ee1f6be4255fde6$export$3340fdd8259bd4fd)({
7249
7324
  get_search_field_value_: get_search_field_value_,
7250
7325
  url_transformer_: url_transformer_,
7251
- search_page_url_param_name_: search_page_url_param_name_,
7252
- get_search_query_: search_query_[0]
7326
+ search_query_url_param_name_: search_query_url_param_name_,
7327
+ get_search_query_: get_search_query_
7253
7328
  });
7254
7329
  const random_classname = (0, $46MJV$depictaiutilishared.make_random_classname)();
7255
7330
  const body_style = (0, $46MJV$solidjs.createMemo)(()=>{
@@ -7266,7 +7341,6 @@ function $121d25ca6af2898f$export$1c593cbd6f1e10bc({ search_field_value_: props_
7266
7341
  input_field_ref_: (element)=>set_input_field(element),
7267
7342
  override_on_enter_: (e)=>on_enter_in_search_field_function?.(e),
7268
7343
  on_back_: close_modal_,
7269
- search_query_: search_query_,
7270
7344
  search_field_value_: search_field_value_,
7271
7345
  submit_query_: submit_query_,
7272
7346
  clear_filters_: clear_filters_,
@@ -7298,9 +7372,9 @@ function $121d25ca6af2898f$export$1c593cbd6f1e10bc({ search_field_value_: props_
7298
7372
  get previous_searches_text_ () {
7299
7373
  return i18n_.previous_searches_text_;
7300
7374
  },
7301
- search_query_: search_query_,
7375
+ get_search_query_: get_search_query_,
7302
7376
  previous_searches_: previous_searches_,
7303
- search_page_url_param_name_: search_page_url_param_name_,
7377
+ search_query_url_param_name_: search_query_url_param_name_,
7304
7378
  market_: market_,
7305
7379
  tenant_: tenant_,
7306
7380
  selected_index_: selected_index,
@@ -7358,7 +7432,7 @@ function $121d25ca6af2898f$export$1c593cbd6f1e10bc({ search_field_value_: props_
7358
7432
  })()
7359
7433
  ];
7360
7434
  }
7361
- function $121d25ca6af2898f$var$close_modal_when_navigating_away(close_modal, search_page_url_param_name_) {
7435
+ function $121d25ca6af2898f$var$close_modal_when_navigating_away(close_modal, search_query_url_param_name_) {
7362
7436
  const [exit_iterable, exitable_iterable] = (0, $46MJV$depictaiutilishared.make_asyncIterable_exiter)((0, $46MJV$depictaiutilishared.href_change_ipns));
7363
7437
  let set_initial_values = false;
7364
7438
  let old_pathname;
@@ -7368,7 +7442,7 @@ function $121d25ca6af2898f$var$close_modal_when_navigating_away(close_modal, sea
7368
7442
  for await (const href of exitable_iterable){
7369
7443
  const u_o = new URL(href);
7370
7444
  const new_pathname = u_o.pathname;
7371
- const new_param_value = u_o.searchParams.get(search_page_url_param_name_);
7445
+ const new_param_value = u_o.searchParams.get(search_query_url_param_name_);
7372
7446
  if (set_initial_values) {
7373
7447
  if (new_param_value !== old_param_value || new_pathname !== old_pathname) {
7374
7448
  // close modal when pathname or query changes
@@ -7457,9 +7531,9 @@ function $ea038dec4ee16624$export$c05a196222ba1302({ suggestions_: suggestions_
7457
7531
 
7458
7532
 
7459
7533
  const $297ca03cb5dd5701$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<b></b>`, 2), $297ca03cb5dd5701$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="results-for"></div>`, 2);
7460
- function $297ca03cb5dd5701$export$9dd50d35b9d94fdf({ search_query_: search_query_ , i18n_: i18n_ , formatted_number_of_results_: formatted_number_of_results_ }) {
7534
+ function $297ca03cb5dd5701$export$9dd50d35b9d94fdf({ get_search_query_: get_search_query_ , i18n_: i18n_ , formatted_number_of_results_: formatted_number_of_results_ }) {
7461
7535
  const contents = (0, $46MJV$solidjs.createMemo)((0, $46MJV$depictaiutilishared.catchify)(()=>{
7462
- const q = search_query_[0]();
7536
+ const q = get_search_query_();
7463
7537
  return i18n_.get_showing_results_for_()((()=>{
7464
7538
  const _el$ = $297ca03cb5dd5701$var$_tmpl$.cloneNode(true);
7465
7539
  (0, $46MJV$solidjsweb.insert)(_el$, q);
@@ -7486,15 +7560,8 @@ function $297ca03cb5dd5701$export$9dd50d35b9d94fdf({ search_query_: search_query
7486
7560
 
7487
7561
  const $93779a41dce11249$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="filter-results-for-one-row"></div>`, 2), $93779a41dce11249$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="depict plp search"><div class="listing-page"></div></div>`, 4);
7488
7562
  function $93779a41dce11249$export$a54ec244c8863715(opts) {
7489
- const { depict_api_: depict_api_ , search_field_value_: search_field_value_ , search_query_: search_query_ , open_modal_: open_modal_ , submit_query_: submit_query_ , current_sorting_: current_sorting_ , min_products_to_fetch_: min_products_to_fetch_ , search_filters_open_: search_filters_open_ , search_sorting_open_: search_sorting_open_ , expanded_filters_: expanded_filters_ , input_modal_open_: input_modal_open_ , selected_filters_: selected_filters_ , i18n_: i18n_ , slider_arrow_button_: slider_arrow_button_ , make_category_suggestion_card_: make_category_suggestion_card_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , clear_filters_on_next_submit_: clear_filters_on_next_submit_ , local_filter_cache_: local_filter_cache_ , include_input_field_: include_input_field_ , tenant_: tenant_ , market_: market_ , showing_recommendation_rows_: showing_recommendation_rows_ , rr_options_: rr_options_ , recommendations_rr_options_: recommendations_rr_options_ = rr_options_ , search_recs_view_more_: search_recs_view_more_ , get_product_id_: get_product_id_ , disable_search_recommendations_: disable_search_recommendations_ , layout_options_: layout_options_ , recommendations_layout_options_: recommendations_layout_options_ = layout_options_ , scroll_restoration_data_: scroll_restoration_data_ } = opts;
7490
- const tenant_object_ = new (0, $46MJV$depictaiutilishared.Tenant)({
7491
- TENANT: (0, $46MJV$solidjs.untrack)(tenant_),
7492
- MARKET: (0, $46MJV$solidjs.untrack)(market_),
7493
- GA_ID: "",
7494
- get_product_id: get_product_id_
7495
- });
7563
+ const { depict_api_: depict_api_ , search_field_value_: search_field_value_ , get_search_query_: get_search_query_ , open_modal_: open_modal_ , submit_query_: submit_query_ , current_sorting_: current_sorting_ , min_products_to_fetch_: min_products_to_fetch_ , search_filters_open_: search_filters_open_ , search_sorting_open_: search_sorting_open_ , expanded_filters_: expanded_filters_ , input_modal_open_: input_modal_open_ , selected_filters_: selected_filters_ , i18n_: i18n_ , slider_arrow_button_: slider_arrow_button_ , make_category_suggestion_card_: make_category_suggestion_card_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , clear_filters_on_next_submit_: clear_filters_on_next_submit_ , local_filter_cache_: local_filter_cache_ , include_input_field_: include_input_field_ , tenant_: tenant_ , market_: market_ , showing_recommendation_rows_: showing_recommendation_rows_ , search_recs_view_more_: search_recs_view_more_ , disable_search_recommendations_: disable_search_recommendations_ , layout_options_: layout_options_ , recommendations_layout_options_: recommendations_layout_options_ = layout_options_ , scroll_restoration_data_: scroll_restoration_data_ , product_card_template_: product_card_template_ } = opts;
7496
7564
  const [get_sorting] = current_sorting_;
7497
- const [get_search_query] = search_query_;
7498
7565
  const all_products_loaded_ = (0, $46MJV$solidjs.createSignal)(false);
7499
7566
  const [get_all_products_loaded, set_all_products_loaded] = all_products_loaded_;
7500
7567
  const number_of_rendered_selected_filters_items_ = (0, $46MJV$solidjs.createSignal)(0);
@@ -7510,7 +7577,7 @@ function $93779a41dce11249$export$a54ec244c8863715(opts) {
7510
7577
  return {
7511
7578
  tenant: tenant_(),
7512
7579
  market: market_(),
7513
- query: get_search_query(),
7580
+ query: get_search_query_(),
7514
7581
  ...f.length ? {
7515
7582
  filters: f
7516
7583
  } : {},
@@ -7523,7 +7590,7 @@ function $93779a41dce11249$export$a54ec244c8863715(opts) {
7523
7590
  set_all_products_loaded(false);
7524
7591
  // only first page of results
7525
7592
  return await (0, $151280ad98f4438b$export$cc42dd29bf655ab6)({
7526
- id_: (0, $46MJV$solidjs.untrack)(get_search_query),
7593
+ id_: (0, $46MJV$solidjs.untrack)(get_search_query_),
7527
7594
  min_products_to_fetch_: min_products_to_fetch_,
7528
7595
  scroll_restoration_data_: scroll_restoration_data_,
7529
7596
  make_request_: (limit, cursor)=>depict_api_.query({
@@ -7536,7 +7603,7 @@ function $93779a41dce11249$export$a54ec244c8863715(opts) {
7536
7603
  });
7537
7604
  }));
7538
7605
  const [suggestions] = (0, $46MJV$solidjs.createResource)((0, $46MJV$solidjs.createMemo)(()=>({
7539
- query: search_query_[0](),
7606
+ query: get_search_query_(),
7540
7607
  tenant: tenant_(),
7541
7608
  market: market_()
7542
7609
  })), (opts)=>depict_api_.suggest(opts));
@@ -7553,7 +7620,6 @@ function $93779a41dce11249$export$a54ec244c8863715(opts) {
7553
7620
  let div_with_field_class;
7554
7621
  search_field = SafeSearchField({
7555
7622
  i18n_: i18n_,
7556
- search_query_: search_query_,
7557
7623
  search_field_value_: search_field_value_,
7558
7624
  submit_query_: submit_query_,
7559
7625
  clear_filters_: clear_filters_on_next_submit_,
@@ -7591,7 +7657,7 @@ function $93779a41dce11249$export$a54ec244c8863715(opts) {
7591
7657
  });
7592
7658
  const [sort_and_filter_element_, set_sort_and_filter_element_] = (0, $46MJV$solidjs.createSignal)();
7593
7659
  const results_for = (0, $46MJV$solidjsweb.createComponent)((0, $297ca03cb5dd5701$export$9dd50d35b9d94fdf), {
7594
- search_query_: search_query_,
7660
+ get_search_query_: get_search_query_,
7595
7661
  i18n_: i18n_,
7596
7662
  formatted_number_of_results_: formatted_number_of_results_
7597
7663
  });
@@ -7630,7 +7696,7 @@ function $93779a41dce11249$export$a54ec244c8863715(opts) {
7630
7696
  (0, $46MJV$depictaiutilishared.catchify)((0, $151280ad98f4438b$export$6e49da55e449af7c))({
7631
7697
  scroll_restoration_data_: scroll_restoration_data_,
7632
7698
  last_result_in_viewport_: last_result_in_viewport_,
7633
- id_: get_search_query,
7699
+ id_: get_search_query_,
7634
7700
  can_write_scroll_restoration_: can_write_scroll_restoration_
7635
7701
  });
7636
7702
  (0, $46MJV$solidjs.createComputed)(()=>{
@@ -7642,13 +7708,9 @@ function $93779a41dce11249$export$a54ec244c8863715(opts) {
7642
7708
  available_filters_: available_filters_
7643
7709
  });
7644
7710
  (0, $46MJV$solidjs.createEffect)(()=>{
7645
- get_search_query();
7711
+ get_search_query_();
7646
7712
  (0, $fe1bd893954cc9ca$export$c7e181728ad525f)(location);
7647
7713
  });
7648
- (0, $46MJV$solidjs.createComputed)(()=>{
7649
- tenant_object_.tenant = tenant_object_.TENANT = tenant_();
7650
- tenant_object_.market = tenant_object_.MARKET = market_();
7651
- });
7652
7714
  return [
7653
7715
  document.createComment("Search page based on Depict SDK"),
7654
7716
  (()=>{
@@ -7704,12 +7766,10 @@ function $93779a41dce11249$export$a54ec244c8863715(opts) {
7704
7766
  last_result_in_viewport_: last_result_in_viewport_,
7705
7767
  scroll_restoration_data_: scroll_restoration_data_,
7706
7768
  desktop_filter_elements_: desktop_filter_elements_,
7707
- rr_options_: rr_options_,
7769
+ product_card_template_: product_card_template_,
7708
7770
  layout_options_: layout_options_,
7709
7771
  sort_or_filter_open_: sort_or_filter_open_,
7710
- tenant_object_: tenant_object_,
7711
- type_for_tracking_: "search",
7712
- id_currently_querying_for_: get_search_query,
7772
+ id_currently_querying_for_: get_search_query_,
7713
7773
  no_results_options_: {
7714
7774
  selected_filters_: selected_filters_,
7715
7775
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
@@ -7735,9 +7795,8 @@ function $93779a41dce11249$export$a54ec244c8863715(opts) {
7735
7795
  search_query_base_: search_query_base_,
7736
7796
  layout_options_: recommendations_layout_options_,
7737
7797
  showing_recommendation_rows_: showing_recommendation_rows_,
7738
- rr_options_: recommendations_rr_options_,
7739
7798
  view_more_button_: search_recs_view_more_,
7740
- tenant_object_: tenant_object_
7799
+ product_card_template_: product_card_template_
7741
7800
  });
7742
7801
  }
7743
7802
  });
@@ -7822,13 +7881,17 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
7822
7881
  #modal_open_signal = (0, $46MJV$solidjs.createSignal)(false);
7823
7882
  static #has_been_constructed = false;
7824
7883
  #router = new (0, $43940d5ca403c293$export$7e1297a3a19f10d8)("hard_navigation");
7825
- constructor({ search_query_url_param_name: search_query_url_param_name = "query" , url_transformer: url_transformer , on_navigation: on_navigation , enable_category_suggestions: enable_category_suggestions = true , disable_scrolling_during_modal: // Stuff needed for non-standard customer deployments that we shouldn't actually expose
7826
- disable_scrolling_during_modal = true , api: api , bottom_distance_under_modal_: bottom_distance_under_modal_ , render_instant_card: render_instant_card , ...props_on_class }){
7884
+ constructor({ search_query_url_param_name: search_query_url_param_name_ = "query" , url_transformer: url_transformer , on_navigation: on_navigation , enable_category_suggestions: enable_category_suggestions = true , disable_scrolling_during_modal: // Stuff needed for non-standard customer deployments that we shouldn't actually expose
7885
+ disable_scrolling_during_modal = true , api: api , bottom_distance_under_modal: bottom_distance_under_modal , render_instant_card: render_instant_card , ...props_on_class }){
7827
7886
  if ($79fbf145b15af988$export$ac6237957a15b3f0.#has_been_constructed) throw new Error("You can only have one instance of DepictSearch");
7828
7887
  Object.assign(this, props_on_class);
7829
- const { current_sorting_: current_sorting_ , selected_filters_: selected_filters_ } = (0, $004640621ca953d0$export$7bcff1eb3eca57d7)(this.#router);
7888
+ if (on_navigation) this.#router.on_navigation_ = on_navigation;
7889
+ const { current_sorting_: current_sorting_ , selected_filters_: selected_filters_ , search_query_accessor_: raw_search_query_accessor } = (0, $cb699e435fadd254$export$477caf01aecaeb2a)({
7890
+ search_query_url_param_name_: search_query_url_param_name_,
7891
+ router_: this.#router
7892
+ });
7830
7893
  const [reset_history_state_, state_] = (0, $0de081f67b6d15b5$export$9862539c89138352)(()=>({
7831
- search_field_value: new URLSearchParams(location.search).get(search_query_url_param_name) ?? "",
7894
+ search_field_value: new URLSearchParams(location.search).get(search_query_url_param_name_) ?? "",
7832
7895
  search_filters_open: false,
7833
7896
  search_sorting_open: false,
7834
7897
  search_expanded_filters: [],
@@ -7837,14 +7900,15 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
7837
7900
  search_expanded_hierarchical_filters: [],
7838
7901
  search_showing_recommendation_rows: (0, $9f81b7ced87aabf2$export$1c8c715550dc689d),
7839
7902
  search_scroll_restoration_data: []
7840
- }));
7903
+ }), this.#router);
7841
7904
  const search_query_updating_blocked_ = (0, $46MJV$solidjs.createSignal)(false);
7842
- const { [search_query_url_param_name]: raw_search_query_signal } = (0, $690220645373c65e$export$2542ffb77b620b02)({
7843
- [search_query_url_param_name]: ""
7905
+ const [get_search_query_updating_blocked] = search_query_updating_blocked_;
7906
+ const get_search_query_ = (0, $46MJV$solidjs.createMemo)((previous_value)=>{
7907
+ if (get_search_query_updating_blocked()) return previous_value;
7908
+ else return raw_search_query_accessor();
7844
7909
  });
7845
- const search_query_signal_ = (0, $46MJV$solidjs.createSignal)((0, $46MJV$solidjs.untrack)(raw_search_query_signal[0]));
7846
7910
  const depict_api_ = api ?? new (0, $9ce64f69303c371e$export$e015ed2f2950f2e3)();
7847
- const previous_searches = (0, $ad118c2ba257d9b7$export$84bba84a7b837187)(search_query_signal_);
7911
+ const previous_searches = (0, $ad118c2ba257d9b7$export$84bba84a7b837187)(get_search_query_);
7848
7912
  const [, set_search_showing_recommendation_rows] = state_.search_showing_recommendation_rows;
7849
7913
  const after_submit_ = ()=>set_search_showing_recommendation_rows((0, $9f81b7ced87aabf2$export$1c8c715550dc689d)); // do this every time after we have submitted a new query - otherwise there might already be a saved number of rows in the state
7850
7914
  const on_submit_with_unchanged_value_ = ()=>this.modal_open = false;
@@ -7852,31 +7916,24 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
7852
7916
  const configured_submit_query_ = (new_query)=>(0, $1c323edfb89c9dca$export$e16630ecb9644a1c)({
7853
7917
  on_submit_with_unchanged_value_: on_submit_with_unchanged_value_,
7854
7918
  set_search_field_value_: set_search_field_value_,
7855
- search_query_: search_query_signal_,
7856
- search_param_name_: search_query_url_param_name,
7857
- url_transformer_: url_transformer,
7919
+ get_search_query_: get_search_query_,
7920
+ search_param_name_: search_query_url_param_name_,
7858
7921
  after_submit_: after_submit_,
7859
7922
  get_new_query: ()=>new_query || (0, $46MJV$solidjs.untrack)(get_search_field_value_),
7923
+ url_transformer_: url_transformer,
7860
7924
  router_: this.#router
7861
7925
  });
7862
7926
  const i18n_ = (0, $623202ae203e9e59$export$f091cbac892643a4)(this.#locale_signal[0]);
7863
7927
  const clear_filters_on_next_submit_ = (0, $8b282f736ce4f3b8$export$e026af0c7b64ea5f)({
7864
7928
  selected_filters_: selected_filters_,
7865
- search_query_: search_query_signal_,
7929
+ get_search_query_: get_search_query_,
7866
7930
  current_sorting_: current_sorting_,
7867
7931
  expanded_hierarchical_filters_: state_.search_expanded_hierarchical_filters,
7868
7932
  i18n_: i18n_,
7869
7933
  local_filter_cache_: state_.search_local_filter_cache
7870
7934
  });
7871
- if (on_navigation) this.#router.on_navigation_ = on_navigation;
7872
- (0, $46MJV$solidjs.createComputed)(()=>{
7873
- const [get_search_query_updating_blocked] = search_query_updating_blocked_;
7874
- const [get_raw_search_query_signal] = raw_search_query_signal;
7875
- const [, set_search_query_signal] = search_query_signal_; // this signal won't get written from anywhere, see url_params_to_signals JSDoc
7876
- if (!get_search_query_updating_blocked()) set_search_query_signal(get_raw_search_query_signal());
7877
- });
7878
7935
  $79fbf145b15af988$var$privately_shared_properties.set(this, {
7879
- search_query_url_param_name_: search_query_url_param_name,
7936
+ search_query_url_param_name_: search_query_url_param_name_,
7880
7937
  reset_history_state_: reset_history_state_,
7881
7938
  state_: state_,
7882
7939
  router_: this.#router,
@@ -7885,7 +7942,7 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
7885
7942
  enable_category_suggestions_: enable_category_suggestions,
7886
7943
  clear_filters_on_next_submit_: clear_filters_on_next_submit_,
7887
7944
  configured_submit_query_: configured_submit_query_,
7888
- search_query_signal_: search_query_signal_,
7945
+ get_search_query_: get_search_query_,
7889
7946
  i18n_: i18n_,
7890
7947
  search_query_updating_blocked_: search_query_updating_blocked_,
7891
7948
  current_sorting_: current_sorting_,
@@ -7899,8 +7956,8 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
7899
7956
  return (0, $121d25ca6af2898f$export$1c593cbd6f1e10bc)(...args);
7900
7957
  }, {
7901
7958
  search_field_value_: state_.search_field_value,
7902
- search_query_: search_query_signal_,
7903
- search_page_url_param_name_: search_query_url_param_name,
7959
+ get_search_query_: get_search_query_,
7960
+ search_query_url_param_name_: search_query_url_param_name_,
7904
7961
  previous_searches_: previous_searches,
7905
7962
  depict_api_: depict_api_,
7906
7963
  tenant_: this.#merchant_signal[0],
@@ -7918,7 +7975,7 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
7918
7975
  i18n_: i18n_,
7919
7976
  enable_category_suggestions_: enable_category_suggestions,
7920
7977
  disable_scrolling_: disable_scrolling_during_modal,
7921
- bottom_distance_under_modal_: bottom_distance_under_modal_
7978
+ bottom_distance_under_modal_: bottom_distance_under_modal
7922
7979
  });
7923
7980
  // This will add some default behaviour to open_modal_ if no style_props_ are supplied
7924
7981
  // The default behaviour is to align the modal with the input field if possible
@@ -8029,7 +8086,7 @@ function $79fbf145b15af988$var$get_shared_properties(depict_search) {
8029
8086
  if (!shared_properties) throw new Error("Can't connect to provided DepictSearch instance");
8030
8087
  return shared_properties;
8031
8088
  }
8032
- function $79fbf145b15af988$export$f2dc7e4e4aa11abb({ depict_search: depict_search , include_input_field: include_input_field , grid_spacing: grid_spacing , cols_at_size: cols_at_size , product_card_template: product_card_template , get_product_id: get_product_id = (0, $46MJV$depictaiutilishared.normal_get_product_id) , extra_depict_options: extra_depict_options }) {
8089
+ function $79fbf145b15af988$export$f2dc7e4e4aa11abb({ depict_search: depict_search , include_input_field: include_input_field , grid_spacing: grid_spacing , cols_at_size: cols_at_size , product_card_template: product_card_template , extra_depict_options: extra_depict_options }) {
8033
8090
  const shared_properties = $79fbf145b15af988$var$get_shared_properties(depict_search);
8034
8091
  const grid_spacing_override = typeof grid_spacing === "string" ? {
8035
8092
  grid_spacing: grid_spacing
@@ -8048,7 +8105,7 @@ function $79fbf145b15af988$export$f2dc7e4e4aa11abb({ depict_search: depict_searc
8048
8105
  min_products_to_fetch_: $79fbf145b15af988$var$min_products_to_fetch_,
8049
8106
  local_filter_cache_: state_.search_local_filter_cache,
8050
8107
  search_field_value_: state_.search_field_value,
8051
- search_query_: shared_properties.search_query_signal_,
8108
+ get_search_query_: shared_properties.get_search_query_,
8052
8109
  clear_filters_on_next_submit_: shared_properties.clear_filters_on_next_submit_,
8053
8110
  open_modal_: (...args)=>depict_search.modal_open = args,
8054
8111
  submit_query_: shared_properties.configured_submit_query_,
@@ -8096,15 +8153,7 @@ function $79fbf145b15af988$export$f2dc7e4e4aa11abb({ depict_search: depict_searc
8096
8153
  height_: 12,
8097
8154
  width_: 6.46
8098
8155
  }),
8099
- rr_options_: {
8100
- template: (display, info)=>{
8101
- const is_placeholder = info.rendering_options.type === "placeholder";
8102
- return product_card_template(is_placeholder ? null : display, info);
8103
- },
8104
- pre_processors: extra_depict_options?.pre_processors,
8105
- post_processors: extra_depict_options?.post_processors
8106
- },
8107
- get_product_id_: get_product_id
8156
+ product_card_template_: product_card_template
8108
8157
  });
8109
8158
  }, "Entire SearchPage failed");
8110
8159
  }
@@ -8113,9 +8162,6 @@ function $79fbf145b15af988$export$316f6f283ae64765({ depict_search: depict_searc
8113
8162
  return (0, $f27b0b326e0a87e2$export$23fca46f3143581f)(()=>{
8114
8163
  let input_element;
8115
8164
  const search_field = (0, $46MJV$solidjsweb.createComponent)((0, $2989e355f64e18e1$export$b94867ecbd698f21), {
8116
- get search_query_ () {
8117
- return shared_properties.search_query_signal_;
8118
- },
8119
8165
  get search_field_value_ () {
8120
8166
  return shared_properties.state_.search_field_value;
8121
8167
  },