@depict-ai/ui 0.0.64 → 0.0.65

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/module.js CHANGED
@@ -1,9 +1,8 @@
1
- import {add_to_version_info as $g9l4l$add_to_version_info, fetch_recs as $g9l4l$fetch_recs, snakeCasifyObject as $g9l4l$snakeCasifyObject, GenericSliderArrowButton as $g9l4l$GenericSliderArrowButton, catchify as $g9l4l$catchify, base_url as $g9l4l$base_url, get_depict_id as $g9l4l$get_depict_id, get_user_id as $g9l4l$get_user_id, get_session_id as $g9l4l$get_session_id, dlog as $g9l4l$dlog, make_url_with_query_params as $g9l4l$make_url_with_query_params, fetch_retry as $g9l4l$fetch_retry, add_version_query_params as $g9l4l$add_version_query_params, sort_obj as $g9l4l$sort_obj, Tenant as $g9l4l$Tenant, queueMacroTask as $g9l4l$queueMacroTask, Placeholder as $g9l4l$Placeholder, report as $g9l4l$report, javascript_media_query as $g9l4l$javascript_media_query, standard_price_format as $g9l4l$standard_price_format, deparallelize_no_drop as $g9l4l$deparallelize_no_drop, default_rr as $g9l4l$default_rr, make_random_classname as $g9l4l$make_random_classname, n_col_styling_with_dist as $g9l4l$n_col_styling_with_dist, observer as $g9l4l$observer, Lazyfier as $g9l4l$Lazyfier, deparallelize as $g9l4l$deparallelize, Rec_Renderer as $g9l4l$Rec_Renderer, CrossIcon as $g9l4l$CrossIcon, useExpandingContainer as $g9l4l$useExpandingContainer, Amazing_Slider as $g9l4l$Amazing_Slider, slider_snap_css as $g9l4l$slider_snap_css, slider_fading_factory as $g9l4l$slider_fading_factory, MinusIcon as $g9l4l$MinusIcon, FilterIcon as $g9l4l$FilterIcon, SortIconAsc as $g9l4l$SortIconAsc, SortIconDesc as $g9l4l$SortIconDesc, PlusIcon as $g9l4l$PlusIcon, TickIcon as $g9l4l$TickIcon, ArrowUp as $g9l4l$ArrowUp, instant_exec_on_suspect_history_change as $g9l4l$instant_exec_on_suspect_history_change, normal_get_product_id as $g9l4l$normal_get_product_id, ContainedPlaceholderImage as $g9l4l$ContainedPlaceholderImage, BackIcon as $g9l4l$BackIcon, SearchIcon as $g9l4l$SearchIcon, Layout as $g9l4l$Layout, make_placeholder_rr as $g9l4l$make_placeholder_rr, async_iterable_ipns as $g9l4l$async_iterable_ipns, make_asyncIterable_exiter as $g9l4l$make_asyncIterable_exiter, href_change_ipns as $g9l4l$href_change_ipns, depict_click as $g9l4l$depict_click, impression_track_element as $g9l4l$impression_track_element, add_new_tab_listener as $g9l4l$add_new_tab_listener, ContainedImage as $g9l4l$ContainedImage, buildThresholdList as $g9l4l$buildThresholdList, PreviousSearchIcon as $g9l4l$PreviousSearchIcon, insert_surfaces as $g9l4l$insert_surfaces, instant_exec_on_popstate_before_ipns_update as $g9l4l$instant_exec_on_popstate_before_ipns_update} from "@depict-ai/utilishared";
1
+ import {add_to_version_info as $g9l4l$add_to_version_info, fetch_recs as $g9l4l$fetch_recs, snakeCasifyObject as $g9l4l$snakeCasifyObject, GenericSliderArrowButton as $g9l4l$GenericSliderArrowButton, catchify as $g9l4l$catchify, base_url as $g9l4l$base_url, get_depict_id as $g9l4l$get_depict_id, get_user_id as $g9l4l$get_user_id, get_session_id as $g9l4l$get_session_id, dlog as $g9l4l$dlog, make_url_with_query_params as $g9l4l$make_url_with_query_params, fetch_retry as $g9l4l$fetch_retry, add_version_query_params as $g9l4l$add_version_query_params, sort_obj as $g9l4l$sort_obj, Tenant as $g9l4l$Tenant, Placeholder as $g9l4l$Placeholder, report as $g9l4l$report, javascript_media_query as $g9l4l$javascript_media_query, standard_price_format as $g9l4l$standard_price_format, deparallelize_no_drop as $g9l4l$deparallelize_no_drop, default_rr as $g9l4l$default_rr, make_random_classname as $g9l4l$make_random_classname, n_col_styling_with_dist as $g9l4l$n_col_styling_with_dist, observer as $g9l4l$observer, Lazyfier as $g9l4l$Lazyfier, queueMacroTask as $g9l4l$queueMacroTask, deparallelize as $g9l4l$deparallelize, Rec_Renderer as $g9l4l$Rec_Renderer, CrossIcon as $g9l4l$CrossIcon, useExpandingContainer as $g9l4l$useExpandingContainer, Amazing_Slider as $g9l4l$Amazing_Slider, slider_snap_css as $g9l4l$slider_snap_css, slider_fading_factory as $g9l4l$slider_fading_factory, MinusIcon as $g9l4l$MinusIcon, FilterIcon as $g9l4l$FilterIcon, SortIconAsc as $g9l4l$SortIconAsc, SortIconDesc as $g9l4l$SortIconDesc, PlusIcon as $g9l4l$PlusIcon, TickIcon as $g9l4l$TickIcon, ArrowUp as $g9l4l$ArrowUp, normal_get_product_id as $g9l4l$normal_get_product_id, ContainedPlaceholderImage as $g9l4l$ContainedPlaceholderImage, BackIcon as $g9l4l$BackIcon, SearchIcon as $g9l4l$SearchIcon, Layout as $g9l4l$Layout, make_placeholder_rr as $g9l4l$make_placeholder_rr, async_iterable_ipns as $g9l4l$async_iterable_ipns, make_asyncIterable_exiter as $g9l4l$make_asyncIterable_exiter, href_change_ipns as $g9l4l$href_change_ipns, depict_click as $g9l4l$depict_click, impression_track_element as $g9l4l$impression_track_element, add_new_tab_listener as $g9l4l$add_new_tab_listener, ContainedImage as $g9l4l$ContainedImage, buildThresholdList as $g9l4l$buildThresholdList, PreviousSearchIcon as $g9l4l$PreviousSearchIcon, insert_surfaces as $g9l4l$insert_surfaces, instant_exec_on_popstate_before_ipns_update as $g9l4l$instant_exec_on_popstate_before_ipns_update} from "@depict-ai/utilishared";
2
2
  import {template as $g9l4l$template, insert as $g9l4l$insert, effect as $g9l4l$effect, setAttribute as $g9l4l$setAttribute, createComponent as $g9l4l$createComponent, use as $g9l4l$use, addEventListener as $g9l4l$addEventListener, delegateEvents as $g9l4l$delegateEvents, spread as $g9l4l$spread, memo as $g9l4l$memo, style as $g9l4l$style, mergeProps as $g9l4l$mergeProps, classList as $g9l4l$classList, className as $g9l4l$className} from "solid-js/web";
3
- import {createSignal as $g9l4l$createSignal, onCleanup as $g9l4l$onCleanup, createComputed as $g9l4l$createComputed, createEffect as $g9l4l$createEffect, untrack as $g9l4l$untrack, batch as $g9l4l$batch, createReaction as $g9l4l$createReaction, createResource as $g9l4l$createResource, createMemo as $g9l4l$createMemo, Show as $g9l4l$Show, createRenderEffect as $g9l4l$createRenderEffect, runWithOwner as $g9l4l$runWithOwner, createRoot as $g9l4l$createRoot, getOwner as $g9l4l$getOwner, on as $g9l4l$on, Index as $g9l4l$Index, For as $g9l4l$For, ErrorBoundary as $g9l4l$ErrorBoundary} from "solid-js";
4
- import {decompressFromBase64 as $g9l4l$decompressFromBase64, compressToBase64 as $g9l4l$compressToBase64} from "lz-string";
3
+ import {createSignal as $g9l4l$createSignal, onCleanup as $g9l4l$onCleanup, createComputed as $g9l4l$createComputed, createEffect as $g9l4l$createEffect, untrack as $g9l4l$untrack, batch as $g9l4l$batch, createResource as $g9l4l$createResource, createMemo as $g9l4l$createMemo, Show as $g9l4l$Show, createRenderEffect as $g9l4l$createRenderEffect, runWithOwner as $g9l4l$runWithOwner, createRoot as $g9l4l$createRoot, getOwner as $g9l4l$getOwner, on as $g9l4l$on, Index as $g9l4l$Index, For as $g9l4l$For, ErrorBoundary as $g9l4l$ErrorBoundary} from "solid-js";
5
4
 
6
- /*! Depict.ai search and product listing SDK */ const $18bf1d29fb889cca$export$83d89fbfd8236492 = "0.0.64";
5
+ /*! Depict.ai search and product listing SDK */ const $18bf1d29fb889cca$export$83d89fbfd8236492 = "0.0.65";
7
6
 
8
7
 
9
8
 
@@ -57,16 +56,14 @@ function $014a147d094b0d08$var$history_state_change(signals, entries, state) {
57
56
  }
58
57
 
59
58
 
60
- function $764ea8aa12c4fc5b$export$90a2b6b3fb2a1455({ get_default_values_: get_default_values_ , current_sorting_: [, set_current_sorting] , selected_filters_: [get_selected_filters, set_selected_filters] }) {
61
- const state = (0, $014a147d094b0d08$export$e183a13865960371)(get_default_values_());
59
+ function $3075a4497054bec6$export$9862539c89138352(get_default_values) {
60
+ const state = (0, $014a147d094b0d08$export$e183a13865960371)(get_default_values());
62
61
  const reset_state = ()=>{
63
- const new_defaults = get_default_values_();
62
+ const new_defaults = get_default_values();
64
63
  for(const key in state){
65
64
  const new_value = new_defaults[key];
66
65
  state[key][1](new_value);
67
66
  }
68
- set_current_sorting();
69
- if (get_selected_filters().length > 0) set_selected_filters([]);
70
67
  };
71
68
  return [
72
69
  reset_state,
@@ -124,8 +121,9 @@ class $3846bb34098c738f$export$e015ed2f2950f2e3 {
124
121
  async #cached_post_request(endpoint1, input_req, fallback_response) {
125
122
  const cache_obj = this.#get_cache_obj_for_endpoint(endpoint1);
126
123
  const with_ids = $3846bb34098c738f$var$add_ids_to_request(input_req);
127
- const request = this.#get_metadata ? Object.assign(with_ids, {
128
- metadata: await this.#get_metadata()
124
+ const metaData = await this.#get_metadata?.();
125
+ const request = metaData ? Object.assign(with_ids, {
126
+ metadata: metaData
129
127
  }) : with_ids;
130
128
  const body = JSON.stringify((0, $g9l4l$sort_obj)(request));
131
129
  const response_from_cache = cache_obj.cache_[body]?.deref?.();
@@ -2749,6 +2747,156 @@ var $7b224b353182ce9a$export$2e2bcd8739ae039 = {
2749
2747
 
2750
2748
 
2751
2749
 
2750
+ function $dd3727f29e682893$export$b288c38ae3fddb56({ available_filters_: available_filters_ , local_filter_cache_: [read_local_cache, write_local_cache] , selected_filters_: [read_selected_filters] }) {
2751
+ let last_remote_state;
2752
+ (0, $g9l4l$createComputed)(()=>{
2753
+ const remote_filters = Object.fromEntries(available_filters_()?.map((filter)=>[
2754
+ JSON.stringify([
2755
+ filter.field,
2756
+ filter.op,
2757
+ filter?.meta?.type
2758
+ ]),
2759
+ filter
2760
+ ]) || []);
2761
+ const local_filters = Object.fromEntries(read_local_cache().map((filter)=>[
2762
+ JSON.stringify([
2763
+ filter.field,
2764
+ filter.op,
2765
+ filter?.meta?.type
2766
+ ]),
2767
+ filter
2768
+ ]));
2769
+ const selected_filters = Object.fromEntries(read_selected_filters().map((filter_obj)=>[
2770
+ JSON.stringify([
2771
+ filter_obj.field,
2772
+ filter_obj.op
2773
+ ]),
2774
+ filter_obj
2775
+ ]));
2776
+ const new_local_filter_state = [];
2777
+ // we want to be as close as possible to available_filters_ in local_filters except that we want to keep values from previous available_filters_ as long as they're selected
2778
+ for (const filter_id of [
2779
+ ...Object.keys(local_filters).filter((key)=>!(key in remote_filters)),
2780
+ ...Object.keys(remote_filters)
2781
+ ]){
2782
+ const local_filter = local_filters[filter_id];
2783
+ const remote_filter = remote_filters[filter_id];
2784
+ const filter_id_without_meta_type = JSON.stringify(JSON.parse(filter_id).slice(0, 2));
2785
+ if (!remote_filter) // check if this filter is selected, if it is just take the local one but set counts to 0 and remove non-selected options
2786
+ {
2787
+ if (filter_id_without_meta_type in selected_filters) new_local_filter_state.push($dd3727f29e682893$var$modify_only_local_filter(local_filter, selected_filters[filter_id_without_meta_type]));
2788
+ } else if (!local_filter) // just take the remote one
2789
+ new_local_filter_state.push(remote_filter);
2790
+ else {
2791
+ // both exist, merge them if needed
2792
+ const remote_meta = remote_filter.meta;
2793
+ const local_meta = local_filter.meta;
2794
+ const this_applied_filter = selected_filters[filter_id_without_meta_type];
2795
+ if (!remote_meta || !local_meta || !("values" in remote_meta) || !("values" in local_meta) || !Array.isArray(this_applied_filter?.data)) // can't or shouldn't be merged due to not being selected, just take remote one
2796
+ new_local_filter_state.push(remote_filter);
2797
+ else {
2798
+ const data_objs_in_remote = Object.fromEntries(remote_meta.values.map((value, index)=>[
2799
+ JSON.stringify(value),
2800
+ {
2801
+ value_: value,
2802
+ count_: remote_meta.counts?.[index],
2803
+ name_: remote_meta.names?.[index]
2804
+ }
2805
+ ]));
2806
+ const data_objs_in_local = Object.fromEntries(local_meta.values.map((value, index)=>[
2807
+ JSON.stringify(value),
2808
+ {
2809
+ value_: value,
2810
+ count_: 0,
2811
+ name_: local_meta.names?.[index]
2812
+ }
2813
+ ]));
2814
+ const new_data = [
2815
+ ...Object.keys(data_objs_in_local).filter((key)=>{
2816
+ // put data entries that are selected and don't exist in new remote state first
2817
+ if (key in data_objs_in_remote) return false;
2818
+ const selected_values = this_applied_filter.data;
2819
+ return selected_values.some((value)=>{
2820
+ const is_equal = JSON.stringify(value) === key;
2821
+ if (is_equal) return true;
2822
+ if (local_meta.type === remote_meta.type && local_meta.type === "checkbox-hierarchical") {
2823
+ // Very special case for hierarchical checkboxes - when a parent has all kids checked and a kid is deselected, the parent gets deselected. But since if it still has selected children we don't want to remove it from the filter state, even though it isn't selected, as the UI won't know the correct title of the parent category otherwise. This keeps it in that case.
2824
+ const selected_values = data_objs_in_local[key].value_;
2825
+ const values_length = value?.length;
2826
+ if (values_length > 1 && values_length - 1 === selected_values.length) {
2827
+ let is_parent = true;
2828
+ for(let i = 0; i < selected_values.length; i++)if (selected_values[i] !== value[i]) is_parent = false;
2829
+ return is_parent;
2830
+ }
2831
+ }
2832
+ return false;
2833
+ });
2834
+ }).map((key)=>data_objs_in_local[key]),
2835
+ ...Object.values(data_objs_in_remote)
2836
+ ];
2837
+ const new_values = new_data.map(({ value_: value_ })=>value_);
2838
+ const result = {
2839
+ ...remote_filter,
2840
+ meta: {
2841
+ ...remote_filter.meta,
2842
+ values: new_values,
2843
+ names: new_data.map(({ name_: name_ })=>name_),
2844
+ counts: new_data.map(({ count_: count_ })=>count_)
2845
+ }
2846
+ };
2847
+ new_local_filter_state.push(result);
2848
+ }
2849
+ }
2850
+ }
2851
+ if (last_remote_state !== available_filters_() || // we HAVE to update the local filter state (it can contain same info but needs to be different object reference) every time the API state changes, otherwise the CheckboxHierarchicalFilter component doesn't update
2852
+ JSON.stringify(new_local_filter_state) !== JSON.stringify(read_local_cache())) // Sorry……… They're not that big
2853
+ write_local_cache(new_local_filter_state);
2854
+ last_remote_state = available_filters_();
2855
+ });
2856
+ return read_local_cache;
2857
+ }
2858
+ /**
2859
+ * When a filter is only available locally due to being selected in a previous navigation, we want to make that clear and prevent further "invalid" choices.
2860
+ * This sets the counts to 0 (if applicable) and removes non-selected options (if applicable)
2861
+ */ function $dd3727f29e682893$var$modify_only_local_filter(local_filter_object, selected_filter) {
2862
+ const old_meta = local_filter_object.meta;
2863
+ const selected_filter_data = selected_filter.data;
2864
+ const modified_filter_object = {
2865
+ ...local_filter_object
2866
+ };
2867
+ if (old_meta) {
2868
+ const new_meta = {
2869
+ ...old_meta
2870
+ };
2871
+ modified_filter_object.meta = new_meta;
2872
+ // set counts to 0
2873
+ if ("counts" in new_meta) {
2874
+ const counts = new_meta.counts;
2875
+ if (counts) new_meta.counts = counts.map(()=>0);
2876
+ }
2877
+ if (Array.isArray(selected_filter_data) && "values" in new_meta) {
2878
+ // we have an array of values and want to strip the ones from the available ones that aren't selected
2879
+ const values = new_meta.values;
2880
+ if (Array.isArray(values)) {
2881
+ const jsond_set_values = selected_filter_data.map((data)=>JSON.stringify(data));
2882
+ const indexes_to_remove = new Set();
2883
+ for(let i = 0; i < values.length; i++){
2884
+ const value = values[i];
2885
+ if (!jsond_set_values.includes(JSON.stringify(value))) // We want to remove the entry with this value from the filter object because it's not selected
2886
+ indexes_to_remove.add(i);
2887
+ }
2888
+ new_meta.values = values.filter((_, index)=>!indexes_to_remove.has(index));
2889
+ if (new_meta.names) new_meta.names = new_meta.names.filter((_, index)=>!indexes_to_remove.has(index));
2890
+ if (new_meta.counts) // remove counts that are too much, they're all zero anyway if they exist
2891
+ new_meta.counts.length -= indexes_to_remove.size;
2892
+ }
2893
+ }
2894
+ }
2895
+ return modified_filter_object;
2896
+ }
2897
+
2898
+
2899
+
2752
2900
 
2753
2901
 
2754
2902
 
@@ -2915,7 +3063,11 @@ function $8aff437d739a524d$export$3f1a388cc0d8fed7(props) {
2915
3063
  });
2916
3064
  }
2917
3065
  function $8aff437d739a524d$var$ActualFilterBody(props) {
2918
- const [modified_available_filters_with_selected_unexisting_ones_injected_from_local_state] = props.local_filter_cache_;
3066
+ const modified_available_filters_with_selected_unexisting_ones_injected_from_local_state = (0, $dd3727f29e682893$export$b288c38ae3fddb56)({
3067
+ available_filters_: props.available_filters_,
3068
+ selected_filters_: props.selected_filters_,
3069
+ local_filter_cache_: props.local_filter_cache_
3070
+ });
2919
3071
  const togglable_filters = (0, $g9l4l$createMemo)(()=>modified_available_filters_with_selected_unexisting_ones_injected_from_local_state().filter((item)=>item?.meta?.group_title));
2920
3072
  const untogglable_filters = (0, $g9l4l$createMemo)(()=>modified_available_filters_with_selected_unexisting_ones_injected_from_local_state().filter((item)=>!item?.meta?.group_title));
2921
3073
  const togglable_filters_grouped_by_collapsible = (0, $g9l4l$createMemo)(()=>{
@@ -3116,10 +3268,9 @@ function $8aff437d739a524d$var$ActualFilterBody(props) {
3116
3268
 
3117
3269
 
3118
3270
  const $c23bd3d951eee1f2$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="sorting-attributes"></div>`, 2), $c23bd3d951eee1f2$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="sorting-direction"></div>`, 2), $c23bd3d951eee1f2$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div><div class="input-row"><input type="radio"><span class="custom-indicator"></span></div></div>`, 7), $c23bd3d951eee1f2$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div><label class="input-row"><input type="radio"><span class="custom-indicator"></span></label></div>`, 7);
3119
- function $c23bd3d951eee1f2$export$1f1775a58da589b5({ available_sortings_: available_sortings_ , current_sorting_: [get_current_sorting, set_current_sorting] }) {
3271
+ function $c23bd3d951eee1f2$export$1f1775a58da589b5({ available_sortings_: available_sortings_ , current_sorting_: current_sorting_ }) {
3120
3272
  const title_radio_name = (0, $g9l4l$make_random_classname)();
3121
3273
  const order_radio_name = (0, $g9l4l$make_random_classname)();
3122
- const meta_of_currently_selected_sorting = (0, $g9l4l$createMemo)(()=>available_sortings_()?.find?.((sorting)=>sorting.field === get_current_sorting()?.field)?.meta);
3123
3274
  return (0, $g9l4l$createComponent)((0, $g9l4l$Show), {
3124
3275
  get when () {
3125
3276
  return available_sortings_()?.length;
@@ -3151,14 +3302,14 @@ function $c23bd3d951eee1f2$export$1f1775a58da589b5({ available_sortings_: availa
3151
3302
  },
3152
3303
  children: (item, index)=>{
3153
3304
  const is_checked = (0, $g9l4l$createMemo)(()=>{
3154
- const sort = get_current_sorting();
3305
+ const sort = current_sorting_[0]();
3155
3306
  if (!sort) // if no sortings are selected, "select" first sort
3156
3307
  return index === 0;
3157
3308
  return sort.field === item().field && (sort.order === item().order || item().meta.values?.length > 1);
3158
3309
  });
3159
3310
  return /* wrapping div for flex gap polyfill scss mixin */ (()=>{
3160
3311
  const _el$8 = $c23bd3d951eee1f2$var$_tmpl$4.cloneNode(true), _el$9 = _el$8.firstChild, _el$10 = _el$9.firstChild, _el$11 = _el$10.nextSibling;
3161
- (0, $g9l4l$addEventListener)(_el$10, "change", (0, $g9l4l$catchify)(()=>set_current_sorting(item())));
3312
+ (0, $g9l4l$addEventListener)(_el$10, "change", (0, $g9l4l$catchify)(()=>current_sorting_[1](item())));
3162
3313
  (0, $g9l4l$setAttribute)(_el$10, "name", title_radio_name);
3163
3314
  (0, $g9l4l$insert)(_el$9, ()=>item().meta.title, null);
3164
3315
  (0, $g9l4l$effect)(()=>_el$10.checked = is_checked());
@@ -3170,25 +3321,27 @@ function $c23bd3d951eee1f2$export$1f1775a58da589b5({ available_sortings_: availa
3170
3321
  })(),
3171
3322
  (0, $g9l4l$createComponent)((0, $g9l4l$Show), {
3172
3323
  get when () {
3173
- return meta_of_currently_selected_sorting()?.values?.length > 1;
3324
+ return current_sorting_[0]()?.meta?.values?.length > 1;
3174
3325
  },
3175
3326
  get children () {
3176
3327
  const _el$2 = $c23bd3d951eee1f2$var$_tmpl$2.cloneNode(true);
3177
3328
  (0, $g9l4l$insert)(_el$2, (0, $g9l4l$createComponent)((0, $g9l4l$Index), {
3178
3329
  get each () {
3179
- return meta_of_currently_selected_sorting()?.values;
3330
+ return current_sorting_[0]().meta.values;
3180
3331
  },
3181
3332
  children: (order_value, index)=>{
3182
- const is_checked = (0, $g9l4l$createMemo)(()=>get_current_sorting()?.order === order_value());
3183
3333
  return (()=>{
3184
3334
  const _el$12 = $c23bd3d951eee1f2$var$_tmpl$4.cloneNode(true), _el$13 = _el$12.firstChild, _el$14 = _el$13.firstChild, _el$15 = _el$14.nextSibling;
3185
- (0, $g9l4l$addEventListener)(_el$14, "change", (0, $g9l4l$catchify)(()=>set_current_sorting((c)=>c && {
3335
+ (0, $g9l4l$addEventListener)(_el$14, "change", (0, $g9l4l$catchify)(()=>current_sorting_[1]((c)=>c && {
3186
3336
  ...c,
3187
3337
  order: order_value()
3188
3338
  })));
3189
3339
  (0, $g9l4l$setAttribute)(_el$14, "name", order_radio_name);
3190
- (0, $g9l4l$insert)(_el$13, ()=>meta_of_currently_selected_sorting()?.names?.[index], null);
3191
- (0, $g9l4l$effect)(()=>_el$14.checked = is_checked());
3340
+ (0, $g9l4l$insert)(_el$13, ()=>current_sorting_[0]()?.meta?.names?.[index], null);
3341
+ (0, $g9l4l$effect)(()=>_el$14.checked = (0, $g9l4l$createMemo)(()=>{
3342
+ const sort = current_sorting_[0]();
3343
+ return sort?.order === order_value();
3344
+ })());
3192
3345
  return _el$12;
3193
3346
  })();
3194
3347
  }
@@ -3533,167 +3686,12 @@ function $fd7da6fb3e08aa40$export$9bf11afa910f536e({ args_for_sorting_: args_for
3533
3686
 
3534
3687
 
3535
3688
 
3536
-
3537
- function $dd3727f29e682893$export$b288c38ae3fddb56({ available_filters_: available_filters_ , local_filter_cache_: [read_local_cache, write_local_cache] , selected_filters_: [read_selected_filters] }) {
3538
- let last_remote_state;
3539
- (0, $g9l4l$createComputed)(()=>{
3540
- const remote_filters = Object.fromEntries(available_filters_()?.map((filter)=>[
3541
- JSON.stringify([
3542
- filter.field,
3543
- filter.op,
3544
- filter?.meta?.type
3545
- ]),
3546
- filter
3547
- ]) || []);
3548
- const local_filters = Object.fromEntries(read_local_cache().map((filter)=>[
3549
- JSON.stringify([
3550
- filter.field,
3551
- filter.op,
3552
- filter?.meta?.type
3553
- ]),
3554
- filter
3555
- ]));
3556
- const selected_filters = Object.fromEntries(read_selected_filters().map((filter_obj)=>[
3557
- JSON.stringify([
3558
- filter_obj.field,
3559
- filter_obj.op
3560
- ]),
3561
- filter_obj
3562
- ]));
3563
- const new_local_filter_state = [];
3564
- // we want to be as close as possible to available_filters_ in local_filters except that we want to keep values from previous available_filters_ as long as they're selected
3565
- for (const filter_id of [
3566
- ...Object.keys(local_filters).filter((key)=>!(key in remote_filters)),
3567
- ...Object.keys(remote_filters)
3568
- ]){
3569
- const local_filter = local_filters[filter_id];
3570
- const remote_filter = remote_filters[filter_id];
3571
- const filter_id_without_meta_type = JSON.stringify(JSON.parse(filter_id).slice(0, 2));
3572
- if (!remote_filter) // check if this filter is selected, if it is just take the local one but set counts to 0 and remove non-selected options
3573
- {
3574
- if (filter_id_without_meta_type in selected_filters) new_local_filter_state.push($dd3727f29e682893$var$modify_only_local_filter(local_filter, selected_filters[filter_id_without_meta_type]));
3575
- } else if (!local_filter) // just take the remote one
3576
- new_local_filter_state.push(remote_filter);
3577
- else {
3578
- // both exist, merge them if needed
3579
- const remote_meta = remote_filter.meta;
3580
- const local_meta = local_filter.meta;
3581
- const this_applied_filter = selected_filters[filter_id_without_meta_type];
3582
- if (!remote_meta || !local_meta || !("values" in remote_meta) || !("values" in local_meta) || !Array.isArray(this_applied_filter?.data)) // can't or shouldn't be merged due to not being selected, just take remote one
3583
- new_local_filter_state.push(remote_filter);
3584
- else {
3585
- const data_objs_in_remote = Object.fromEntries(remote_meta.values.map((value, index)=>[
3586
- JSON.stringify(value),
3587
- {
3588
- value_: value,
3589
- count_: remote_meta.counts?.[index],
3590
- name_: remote_meta.names?.[index]
3591
- }
3592
- ]));
3593
- const data_objs_in_local = Object.fromEntries(local_meta.values.map((value, index)=>[
3594
- JSON.stringify(value),
3595
- {
3596
- value_: value,
3597
- count_: 0,
3598
- name_: local_meta.names?.[index]
3599
- }
3600
- ]));
3601
- const new_data = [
3602
- ...Object.keys(data_objs_in_local).filter((key)=>{
3603
- // put data entries that are selected and don't exist in new remote state first
3604
- if (key in data_objs_in_remote) return false;
3605
- const selected_values = this_applied_filter.data;
3606
- return selected_values.some((value)=>{
3607
- const is_equal = JSON.stringify(value) === key;
3608
- if (is_equal) return true;
3609
- if (local_meta.type === remote_meta.type && local_meta.type === "checkbox-hierarchical") {
3610
- // Very special case for hierarchical checkboxes - when a parent has all kids checked and a kid is deselected, the parent gets deselected. But since if it still has selected children we don't want to remove it from the filter state, even though it isn't selected, as the UI won't know the correct title of the parent category otherwise. This keeps it in that case.
3611
- const selected_values = data_objs_in_local[key].value_;
3612
- const values_length = value?.length;
3613
- if (values_length > 1 && values_length - 1 === selected_values.length) {
3614
- let is_parent = true;
3615
- for(let i = 0; i < selected_values.length; i++)if (selected_values[i] !== value[i]) is_parent = false;
3616
- return is_parent;
3617
- }
3618
- }
3619
- return false;
3620
- });
3621
- }).map((key)=>data_objs_in_local[key]),
3622
- ...Object.values(data_objs_in_remote)
3623
- ];
3624
- const new_values = new_data.map(({ value_: value_ })=>value_);
3625
- const result = {
3626
- ...remote_filter,
3627
- meta: {
3628
- ...remote_filter.meta,
3629
- values: new_values,
3630
- names: new_data.map(({ name_: name_ })=>name_),
3631
- counts: new_data.map(({ count_: count_ })=>count_)
3632
- }
3633
- };
3634
- new_local_filter_state.push(result);
3635
- }
3636
- }
3637
- }
3638
- if (last_remote_state !== available_filters_() || // we HAVE to update the local filter state (it can contain same info but needs to be different object reference) every time the API state changes, otherwise the CheckboxHierarchicalFilter component doesn't update
3639
- JSON.stringify(new_local_filter_state) !== JSON.stringify(read_local_cache())) // Sorry……… They're not that big
3640
- write_local_cache(new_local_filter_state);
3641
- last_remote_state = available_filters_();
3642
- });
3643
- }
3644
- /**
3645
- * When a filter is only available locally due to being selected in a previous navigation, we want to make that clear and prevent further "invalid" choices.
3646
- * This sets the counts to 0 (if applicable) and removes non-selected options (if applicable)
3647
- */ function $dd3727f29e682893$var$modify_only_local_filter(local_filter_object, selected_filter) {
3648
- const old_meta = local_filter_object.meta;
3649
- const selected_filter_data = selected_filter.data;
3650
- const modified_filter_object = {
3651
- ...local_filter_object
3652
- };
3653
- if (old_meta) {
3654
- const new_meta = {
3655
- ...old_meta
3656
- };
3657
- modified_filter_object.meta = new_meta;
3658
- // set counts to 0
3659
- if ("counts" in new_meta) {
3660
- const counts = new_meta.counts;
3661
- if (counts) new_meta.counts = counts.map(()=>0);
3662
- }
3663
- if (Array.isArray(selected_filter_data) && "values" in new_meta) {
3664
- // we have an array of values and want to strip the ones from the available ones that aren't selected
3665
- const values = new_meta.values;
3666
- if (Array.isArray(values)) {
3667
- const jsond_set_values = selected_filter_data.map((data)=>JSON.stringify(data));
3668
- const indexes_to_remove = new Set();
3669
- for(let i = 0; i < values.length; i++){
3670
- const value = values[i];
3671
- if (!jsond_set_values.includes(JSON.stringify(value))) // We want to remove the entry with this value from the filter object because it's not selected
3672
- indexes_to_remove.add(i);
3673
- }
3674
- new_meta.values = values.filter((_, index)=>!indexes_to_remove.has(index));
3675
- if (new_meta.names) new_meta.names = new_meta.names.filter((_, index)=>!indexes_to_remove.has(index));
3676
- if (new_meta.counts) // remove counts that are too much, they're all zero anyway if they exist
3677
- new_meta.counts.length -= indexes_to_remove.size;
3678
- }
3679
- }
3680
- }
3681
- return modified_filter_object;
3682
- }
3683
-
3684
-
3685
3689
  const $bf7fe049e78f975a$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="filters"><div class="body"></div></div>`, 4), $bf7fe049e78f975a$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="sorting"><div class="body"></div></div>`, 4), $bf7fe049e78f975a$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="sort-and-filter-buttons"><div class="outer"><div class="inner"></div></div></div>`, 6), $bf7fe049e78f975a$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<span class="num-filters"></span>`, 2), $bf7fe049e78f975a$var$_tmpl$5 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="open-filters-button-container"><button class="filter toggle-button major-minor-transition" type="button"><span></span></button></div>`, 6), $bf7fe049e78f975a$var$_tmpl$6 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<button class="toggle-button for-sorting major-minor-transition"><span></span></button>`, 4);
3686
3690
  function $bf7fe049e78f975a$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_ }) {
3687
3691
  return (0, $a406ebe9523f192f$export$b69d0d92862de18b)({
3688
3692
  severity_: "error",
3689
3693
  message_: "Sorting and filters failed",
3690
3694
  get children () {
3691
- // This could technically be in SearchPage and CategoryPage and would be better suited there since it writes into local_filter_cache_ which i.e. SelectedFilters uses, but it's better suited here IMO due to DRY and being inside the correct error boundary here
3692
- (0, $dd3727f29e682893$export$b288c38ae3fddb56)({
3693
- available_filters_: available_filters_,
3694
- selected_filters_: selected_filters_,
3695
- local_filter_cache_: local_filter_cache_
3696
- });
3697
3695
  const cleanup_promise = new Promise((r)=>(0, $g9l4l$onCleanup)(r));
3698
3696
  const [filters_open, set_filters_open] = search_filters_open_;
3699
3697
  const [sorting_open, set_sorting_open] = search_sorting_open_;
@@ -4064,166 +4062,6 @@ function $4a2667e8d77eb55a$var$ActualFloatingButtons({ search_filters_open_: [ge
4064
4062
 
4065
4063
 
4066
4064
 
4067
-
4068
-
4069
-
4070
-
4071
- const $4ebab5f2b1a65493$var$operator_map = {
4072
- "eq": "≡",
4073
- "neq": "≠",
4074
- "in": "∈",
4075
- "nin": "∉",
4076
- "leq": "≤",
4077
- "geq": "≥",
4078
- "inrange": "\uD83D\uDD22"
4079
- };
4080
- const $4ebab5f2b1a65493$var$ascending_token = "\uD83D\uDCC8";
4081
- const $4ebab5f2b1a65493$var$descending_token = "\uD83D\uDCC9";
4082
- const $4ebab5f2b1a65493$export$4f506378e99f23dd = "filter_";
4083
- const $4ebab5f2b1a65493$export$196aa1ee621a9930 = "sorting";
4084
- const $4ebab5f2b1a65493$var$range_delimiter = "-";
4085
- function $4ebab5f2b1a65493$export$7bcff1eb3eca57d7() {
4086
- const current_sorting_ = (0, $g9l4l$createSignal)();
4087
- const selected_filters_ = (0, $g9l4l$createSignal)([]);
4088
- const [get_sorting, set_sorting] = current_sorting_;
4089
- const [get_selected_filters, set_selected_filters] = selected_filters_;
4090
- const [get_current_href, set_current_href] = (0, $g9l4l$createSignal)(location.href);
4091
- const history_change_handler = ()=>set_current_href(location.href);
4092
- let writer_started = false;
4093
- (0, $g9l4l$instant_exec_on_suspect_history_change).add(history_change_handler);
4094
- (0, $g9l4l$onCleanup)(()=>(0, $g9l4l$instant_exec_on_suspect_history_change).delete(history_change_handler));
4095
- (0, $g9l4l$createComputed)(()=>{
4096
- const { searchParams: searchParams } = new URL(get_current_href());
4097
- const sorting = searchParams.get($4ebab5f2b1a65493$export$196aa1ee621a9930);
4098
- (0, $g9l4l$batch)(()=>{
4099
- set_sorting: {
4100
- if (!sorting) {
4101
- set_sorting();
4102
- break set_sorting;
4103
- }
4104
- let target_field;
4105
- let target_order;
4106
- if (sorting.endsWith($4ebab5f2b1a65493$var$ascending_token)) {
4107
- target_field = sorting.slice(0, -$4ebab5f2b1a65493$var$ascending_token.length);
4108
- target_order = "asc";
4109
- } else if (sorting.endsWith($4ebab5f2b1a65493$var$descending_token)) {
4110
- target_field = sorting.slice(0, -$4ebab5f2b1a65493$var$descending_token.length);
4111
- target_order = "desc";
4112
- } else {
4113
- (0, $g9l4l$dlog)("Invalid sorting query param value", sorting);
4114
- break set_sorting;
4115
- }
4116
- const current_sorting = (0, $g9l4l$untrack)(get_sorting);
4117
- // Do some diffing since we might assume in certain places of the code that if the signal changes it means the sorting has changed
4118
- if (current_sorting?.field !== target_field || current_sorting?.order !== target_order) set_sorting({
4119
- field: target_field,
4120
- order: target_order
4121
- });
4122
- }
4123
- const found_filters = [];
4124
- for (const key of searchParams.keys()){
4125
- if (!key.startsWith($4ebab5f2b1a65493$export$4f506378e99f23dd)) continue;
4126
- for (const op of Object.keys($4ebab5f2b1a65493$var$operator_map)){
4127
- const token = $4ebab5f2b1a65493$var$operator_map[op];
4128
- if (!key.endsWith(token)) continue;
4129
- const field = key.slice($4ebab5f2b1a65493$export$4f506378e99f23dd.length, -token.length);
4130
- const data = searchParams.get(key);
4131
- if (data) {
4132
- let parsed_data;
4133
- if (op === "inrange") parsed_data = data.split($4ebab5f2b1a65493$var$range_delimiter).map((x)=>parseFloat(x));
4134
- else if (data === "1") parsed_data = "true";
4135
- else if (data === "0") parsed_data = "false";
4136
- else try {
4137
- parsed_data = JSON.parse((0, $g9l4l$decompressFromBase64)(data));
4138
- } catch (e) {
4139
- (0, $g9l4l$dlog)("Failed to parse filter data", key, data, e);
4140
- continue;
4141
- }
4142
- found_filters.push({
4143
- field: field,
4144
- op: op,
4145
- data: parsed_data
4146
- });
4147
- }
4148
- }
4149
- }
4150
- const selected_filters = (0, $g9l4l$untrack)(get_selected_filters);
4151
- const found_filters_map = new Map(found_filters.map(({ field: field , op: op , data: data })=>[
4152
- JSON.stringify([
4153
- field,
4154
- op
4155
- ]),
4156
- data
4157
- ]));
4158
- // Sorry for this diffing algorithm lol. Looking forwards to Records and Tuples.
4159
- if (selected_filters.length !== found_filters.length || !selected_filters.every(({ field: field , op: op , data: data })=>JSON.stringify(found_filters_map.get(JSON.stringify([
4160
- field,
4161
- op
4162
- ]))) === JSON.stringify(data))) set_selected_filters(found_filters);
4163
- if (!writer_started) {
4164
- $4ebab5f2b1a65493$var$start_href_writer(get_sorting, get_selected_filters);
4165
- writer_started = true;
4166
- }
4167
- });
4168
- });
4169
- return {
4170
- current_sorting_: current_sorting_,
4171
- selected_filters_: selected_filters_
4172
- };
4173
- }
4174
- function $4ebab5f2b1a65493$var$start_href_writer(get_sorting, get_selected_filters) {
4175
- // 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)
4176
- (0, $g9l4l$createComputed)((0, $g9l4l$on)([
4177
- get_sorting,
4178
- get_selected_filters
4179
- ], ([sorting, filters])=>{
4180
- const current_href = location.href;
4181
- const url_object = new URL(current_href);
4182
- const { searchParams: searchParams } = url_object;
4183
- const keys = [
4184
- ...searchParams.keys()
4185
- ]; // get keys here to be able to iterate over it later while modifying the search params
4186
- if (sorting) {
4187
- const { field: field , order: order } = sorting;
4188
- const ascending = order === "asc";
4189
- searchParams.set($4ebab5f2b1a65493$export$196aa1ee621a9930, field + (ascending ? $4ebab5f2b1a65493$var$ascending_token : $4ebab5f2b1a65493$var$descending_token));
4190
- } else searchParams.delete($4ebab5f2b1a65493$export$196aa1ee621a9930);
4191
- for (const key of keys)if (key.startsWith($4ebab5f2b1a65493$export$4f506378e99f23dd)) searchParams.delete(key);
4192
- for (const filter of filters){
4193
- const { field: field , op: op , data: data } = filter;
4194
- let value;
4195
- if (op === "inrange" && Array.isArray(data)) value = data.join($4ebab5f2b1a65493$var$range_delimiter);
4196
- else if (data === "true") value = "1";
4197
- else if (data === "false") value = "0";
4198
- else value = (0, $g9l4l$compressToBase64)(JSON.stringify(data));
4199
- searchParams.set($4ebab5f2b1a65493$export$4f506378e99f23dd + field + $4ebab5f2b1a65493$var$operator_map[op], value);
4200
- }
4201
- // We can't just check if the URL is equal since sometimes the order of the parameters in the URL changes (randomly?) so we need to compare them one by one
4202
- const unmodified_search_params = [
4203
- ...new URL(current_href).searchParams
4204
- ];
4205
- const new_search_params = new Map(searchParams);
4206
- if (unmodified_search_params.length !== new_search_params.size || !unmodified_search_params.every(([key, value])=>new_search_params.get(key) === value)) // Only update URL if it actually changed
4207
- history.replaceState({}, "", url_object.href);
4208
- }, {
4209
- defer: true
4210
- }));
4211
- }
4212
-
4213
-
4214
- function $36c8a3d571f01d23$export$bca5a41ac5ef1190(url) {
4215
- if (!url) return url;
4216
- const got_u_o = url instanceof URL;
4217
- const u_o = got_u_o ? url : new URL(url);
4218
- const { searchParams: searchParams } = u_o;
4219
- const current_search_params = new URLSearchParams(location.search);
4220
- if (current_search_params.has((0, $4ebab5f2b1a65493$export$196aa1ee621a9930))) searchParams.set((0, $4ebab5f2b1a65493$export$196aa1ee621a9930), current_search_params.get((0, $4ebab5f2b1a65493$export$196aa1ee621a9930)));
4221
- for (const key of current_search_params.keys())if (key.startsWith((0, $4ebab5f2b1a65493$export$4f506378e99f23dd))) searchParams.set(key, current_search_params.get(key));
4222
- if (got_u_o) return u_o;
4223
- return u_o.href;
4224
- }
4225
-
4226
-
4227
4065
  const $1b5a927e48d892a1$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<nav class="crumbs"></nav>`, 2), $1b5a927e48d892a1$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<a class="crumb"></a>`, 2), $1b5a927e48d892a1$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<span class="separator"></span>`, 2);
4228
4066
  function $1b5a927e48d892a1$export$5646050d516e06bc({ crumb_data_: get_api_crumb_data , on_crumb_click_: on_crumb_click_ , i18n_: i18n_ }) {
4229
4067
  const placeholder_crumb_data = [
@@ -4241,20 +4079,11 @@ function $1b5a927e48d892a1$export$5646050d516e06bc({ crumb_data_: get_api_crumb_
4241
4079
  get each () {
4242
4080
  return crumb_data();
4243
4081
  },
4244
- children: (unmodified_display_accessor, index)=>{
4245
- const modified_display_accessor = (0, $g9l4l$createMemo)(()=>{
4246
- const value = unmodified_display_accessor();
4247
- if (!value) return value;
4248
- return {
4249
- ...value,
4250
- // We don't want these links to delete the sort and filter state by default, only if `clear_filters_when_going_sideways` explicitly clears them
4251
- page_url: (0, $36c8a3d571f01d23$export$bca5a41ac5ef1190)(value.page_url)
4252
- };
4253
- });
4082
+ children: (display_accessor, index)=>{
4254
4083
  return [
4255
4084
  (0, $g9l4l$createComponent)((0, $g9l4l$Show), {
4256
4085
  get when () {
4257
- return modified_display_accessor();
4086
+ return display_accessor();
4258
4087
  },
4259
4088
  get fallback () {
4260
4089
  return (0, $g9l4l$createComponent)((0, $g9l4l$Placeholder), {
@@ -4264,9 +4093,9 @@ function $1b5a927e48d892a1$export$5646050d516e06bc({ crumb_data_: get_api_crumb_
4264
4093
  },
4265
4094
  get children () {
4266
4095
  const _el$2 = $1b5a927e48d892a1$var$_tmpl$2.cloneNode(true);
4267
- (0, $g9l4l$addEventListener)(_el$2, "click", (0, $g9l4l$catchify)((ev)=>on_crumb_click_(ev, modified_display_accessor())), true);
4268
- (0, $g9l4l$insert)(_el$2, ()=>modified_display_accessor().title);
4269
- (0, $g9l4l$effect)(()=>(0, $g9l4l$setAttribute)(_el$2, "href", modified_display_accessor().page_url));
4096
+ (0, $g9l4l$addEventListener)(_el$2, "click", (0, $g9l4l$catchify)((ev)=>on_crumb_click_(ev, display_accessor())), true);
4097
+ (0, $g9l4l$insert)(_el$2, ()=>display_accessor().title);
4098
+ (0, $g9l4l$effect)(()=>(0, $g9l4l$setAttribute)(_el$2, "href", display_accessor().page_url));
4270
4099
  return _el$2;
4271
4100
  }
4272
4101
  }),
@@ -4303,9 +4132,7 @@ function $1b5a927e48d892a1$export$5646050d516e06bc({ crumb_data_: get_api_crumb_
4303
4132
 
4304
4133
 
4305
4134
 
4306
-
4307
4135
  const $6af87e1502f04aa3$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<nav class="quicklinks"></nav>`, 2), $6af87e1502f04aa3$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div>QuickLinks failed</div>`, 2), $6af87e1502f04aa3$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<a class="quicklink"></a>`, 2);
4308
- const $6af87e1502f04aa3$export$e2cf3f19dd3f8aac = "went_sideways_clear_filters";
4309
4136
  function $6af87e1502f04aa3$export$466cdc317043f6cb({ quicklinks_data_: quicklinks_data_ , on_link_click_: on_link_click_ , current_query_id_: current_query_id_ , slider_arrow_button_: slider_arrow_button_ , breadcrumb_data_: breadcrumb_data_ , i18n_: i18n_ }) {
4310
4137
  let scrolling_logic_ran_for_query_id = false;
4311
4138
  let last_scroll_position;
@@ -4427,43 +4254,20 @@ function $6af87e1502f04aa3$export$466cdc317043f6cb({ quicklinks_data_: quicklink
4427
4254
  get each () {
4428
4255
  return place_holdey_quicklinks_data();
4429
4256
  },
4430
- children: (unmodified_display_accessor, index)=>{
4257
+ children: (display_accessor, index)=>{
4431
4258
  const is_selected = (0, $g9l4l$createMemo)(()=>selected_index() === index);
4432
- // Problem: if opening a sibling link in a new tab, filter clearing behavior is no longer consistent
4433
- // Solution:
4434
- // If current one in quick links they're siblings, don't add state to the url
4435
- // If it's not in it, it's a child of the current one, so add state
4436
- // (This brought up the issue on what happens if someone links to a filter that no longer exists, I chose to ignore that for now)
4437
- // Problem: When you don't open a link in a new tab, we don't display the filter cleared toast
4438
- // Solution: instead of not adding the state to the url, add a flag to the link if it's a sibling and then display the toast on load if the flag is set
4439
- const is_child = (0, $g9l4l$createMemo)(()=>{
4440
- const current_id = current_query_id_();
4441
- return !quicklinks_data_()?.find(({ query_id: query_id })=>query_id === current_id);
4442
- });
4443
- const modified_display_accessor = (0, $g9l4l$createMemo)(()=>{
4444
- const value = unmodified_display_accessor();
4445
- if (!value) return value;
4446
- const new_page_url = new URL(value.page_url, location.origin);
4447
- (0, $36c8a3d571f01d23$export$bca5a41ac5ef1190)(new_page_url);
4448
- if (!is_child()) new_page_url.searchParams.set($6af87e1502f04aa3$export$e2cf3f19dd3f8aac, "true");
4449
- return {
4450
- ...value,
4451
- // We don't want these links to delete the sort and filter state by default, only if `clear_filters_when_going_sideways` explicitly clears them
4452
- page_url: new_page_url.href
4453
- };
4454
- });
4455
4259
  return (()=>{
4456
4260
  const _el$3 = $6af87e1502f04aa3$var$_tmpl$3.cloneNode(true);
4457
4261
  (0, $g9l4l$addEventListener)(_el$3, "click", (0, $g9l4l$catchify)((ev)=>{
4458
4262
  if (is_selected() && !ev.metaKey && !ev.ctrlKey && !ev.button) ev.preventDefault();
4459
- else if (modified_display_accessor()) on_link_click_(ev, modified_display_accessor());
4263
+ else if (display_accessor()) on_link_click_(ev, display_accessor());
4460
4264
  }), true);
4461
- (0, $g9l4l$insert)(_el$3, ()=>modified_display_accessor()?.title || (0, $g9l4l$createComponent)((0, $g9l4l$Placeholder), {
4265
+ (0, $g9l4l$insert)(_el$3, ()=>display_accessor()?.title || (0, $g9l4l$createComponent)((0, $g9l4l$Placeholder), {
4462
4266
  height: "1em",
4463
4267
  width: "10ch"
4464
4268
  }));
4465
4269
  (0, $g9l4l$effect)((_p$)=>{
4466
- const _v$ = !!is_selected(), _v$2 = modified_display_accessor()?.page_url || "javascript:void(0)";
4270
+ const _v$ = !!is_selected(), _v$2 = display_accessor()?.page_url || "javascript:void(0)";
4467
4271
  _v$ !== _p$._v$ && _el$3.classList.toggle("selected", _p$._v$ = _v$);
4468
4272
  _v$2 !== _p$._v$2 && (0, $g9l4l$setAttribute)(_el$3, "href", _p$._v$2 = _v$2);
4469
4273
  return _p$;
@@ -4638,7 +4442,6 @@ let $01115659405f3c64$export$44dad306455dddf;
4638
4442
  })($01115659405f3c64$export$44dad306455dddf || ($01115659405f3c64$export$44dad306455dddf = {}));
4639
4443
 
4640
4444
 
4641
-
4642
4445
  const $1ae892b13d7746ab$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="product-count"> </div>`, 2), $1ae892b13d7746ab$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div></div>`, 2), $1ae892b13d7746ab$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="filter-results-for-one-row"></div>`, 2), $1ae892b13d7746ab$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="depict plp category"><div class="listing-page"></div></div>`, 4);
4643
4446
  function $1ae892b13d7746ab$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_ , on_category_link_click_: on_category_link_click_ , 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_ }) {
4644
4447
  let results_for;
@@ -4661,26 +4464,6 @@ function $1ae892b13d7746ab$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
4661
4464
  const first_result_in_viewport_ = (0, $g9l4l$createSignal)();
4662
4465
  const last_result_in_viewport_ = (0, $g9l4l$createSignal)();
4663
4466
  const [can_write_scroll_restoration_, set_can_write_scroll_restoration] = (0, $g9l4l$createSignal)(false);
4664
- const tracking_function_for_plp_results = (0, $g9l4l$createReaction)(()=>{
4665
- // 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
4666
- const url_object = new URL(location.href);
4667
- const { searchParams: searchParams } = url_object;
4668
- if (searchParams.get((0, $6af87e1502f04aa3$export$e2cf3f19dd3f8aac)) !== "true") return;
4669
- searchParams.delete((0, $6af87e1502f04aa3$export$e2cf3f19dd3f8aac));
4670
- history.pushState(history.state, "", url_object.href);
4671
- (0, $g9l4l$dlog)("Flag to clear filters was set, clearing filters");
4672
- (0, $g9l4l$queueMacroTask)(()=>{
4673
- // Do it next task so that all the filters have time to populate
4674
- (0, $af89070cc0052779$export$8895d39404bd2bb1)({
4675
- user_triggered_: false,
4676
- i18n_: i18n_,
4677
- also_clear_sorting_: false,
4678
- selected_filters_: selected_filters_,
4679
- expanded_hierarchical_filters_: expanded_hierarchical_filters_,
4680
- local_filter_cache_: local_filter_cache_
4681
- });
4682
- });
4683
- });
4684
4467
  const query_base_ = (0, $930337c3b3b5f896$export$210f130a61ac1e8d)(()=>{
4685
4468
  const sort_obj = get_sorting() && {
4686
4469
  ...get_sorting()
@@ -4712,7 +4495,6 @@ function $1ae892b13d7746ab$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
4712
4495
  } : {}
4713
4496
  })
4714
4497
  })));
4715
- tracking_function_for_plp_results(plp_results_);
4716
4498
  const available_sortings_ = (0, $g9l4l$createMemo)(()=>plp_results_()?.sorts?.map((sort)=>({
4717
4499
  ...sort,
4718
4500
  order: sort.order ?? "desc"
@@ -5089,7 +4871,6 @@ function $c7f938ac40924f3b$export$23fca46f3143581f(component, error_message) {
5089
4871
  }
5090
4872
 
5091
4873
 
5092
-
5093
4874
  const $ec52ef1e6c117813$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="depict plp category"></div>`, 2);
5094
4875
  const $ec52ef1e6c117813$var$min_products_to_fetch_ = 20;
5095
4876
  const $ec52ef1e6c117813$var$privately_shared_properties = /*@__PURE__*/ new WeakMap();
@@ -5135,20 +4916,17 @@ class $ec52ef1e6c117813$export$f34314aa9505732e {
5135
4916
  $ec52ef1e6c117813$export$f34314aa9505732e.#has_been_constructed = true;
5136
4917
  Object.assign(this, props_on_class); // set initial signal values
5137
4918
  (0, $2864fd26f57ff474$export$5162a71f252e6122)();
5138
- const { selected_filters_: selected_filters_ , current_sorting_: current_sorting_ } = (0, $4ebab5f2b1a65493$export$7bcff1eb3eca57d7)();
5139
- const [reset_history_state_, state_] = (0, $764ea8aa12c4fc5b$export$90a2b6b3fb2a1455)({
5140
- selected_filters_: selected_filters_,
5141
- current_sorting_: current_sorting_,
5142
- get_default_values_: ()=>({
5143
- category_filters_open: false,
5144
- category_sorting_open: false,
5145
- category_expanded_filters: [],
5146
- // WARNING, it is insanely important, when creating the signals like this using make_resettable_history_state, that the two lines below are in *precisely that order*. The reason for that is that make_resettable_history_state will write the values of the signals in the order that they are written here when a "popstate" event occurs. If the filter cache is popped before the selected filters are the code in create_modified_filters() in FilterBody.tsx is going to re-calculate search_local_filter_cache without knowing the real value of search_selected_filters and we'll end up with too few filters in search_local_filter_cache in some cases
5147
- category_local_filter_cache: [],
5148
- category_expanded_hierarchical_filters: [],
5149
- category_scroll_restoration_data: []
5150
- })
5151
- });
4919
+ const [reset_history_state_, state_] = (0, $3075a4497054bec6$export$9862539c89138352)(()=>({
4920
+ category_sorting: undefined,
4921
+ category_filters_open: false,
4922
+ category_sorting_open: false,
4923
+ category_expanded_filters: [],
4924
+ // WARNING, it is insanely important, when creating the signals like this using make_resettable_history_state, that the two lines below are in *precisely that order*. The reason for that is that make_resettable_history_state will write the values of the signals in the order that they are written here when a "popstate" event occurs. If the filter cache is popped before the selected filters are the code in create_modified_filters() in FilterBody.tsx is going to re-calculate search_local_filter_cache without knowing the real value of search_selected_filters and we'll end up with too few filters in search_local_filter_cache in some cases
4925
+ category_selected_filters: [],
4926
+ category_local_filter_cache: [],
4927
+ category_expanded_hierarchical_filters: [],
4928
+ category_scroll_restoration_data: []
4929
+ }));
5152
4930
  const i18n_ = (0, $0466953901b38f18$export$f091cbac892643a4)(this.#locale_signal[0]);
5153
4931
  const on_category_link_click_ = (e, d)=>{
5154
4932
  if (e.button || e.metaKey || e.ctrlKey) // Not single page navigating because button is not 0 or ctrl/command click
@@ -5173,8 +4951,6 @@ class $ec52ef1e6c117813$export$f34314aa9505732e {
5173
4951
  reset_history_state_: reset_history_state_,
5174
4952
  depict_api_: api ?? new (0, $3846bb34098c738f$export$e015ed2f2950f2e3)(),
5175
4953
  on_category_link_click_: on_category_link_click_,
5176
- selected_filters_: selected_filters_,
5177
- current_sorting_: current_sorting_,
5178
4954
  slider_arrow_button_: (0, $g9l4l$GenericSliderArrowButton)({
5179
4955
  height_: 12,
5180
4956
  width_: 6.46
@@ -5191,7 +4967,7 @@ function $ec52ef1e6c117813$export$e2bf8ce7779e827e({ depict_category: depict_cat
5191
4967
  grid_spacing: grid_spacing.horizontal
5192
4968
  };
5193
4969
  return (0, $c7f938ac40924f3b$export$23fca46f3143581f)(()=>{
5194
- const { state_: { category_local_filter_cache: local_filter_cache_ , category_filters_open: category_filters_open_ , category_sorting_open: category_sorting_open_ , category_expanded_filters: expanded_filters_ , category_expanded_hierarchical_filters: expanded_hierarchical_filters_ , category_scroll_restoration_data: scroll_restoration_data_ } , current_sorting_: current_sorting_ , selected_filters_: selected_filters_ , reset_history_state_: reset_history_state_ , depict_api_: depict_api_ , i18n_: i18n_ , on_category_link_click_: on_category_link_click_ , breadcrumb_signal_: breadcrumb_signal_ , quicklinks_signal_: quicklinks_signal_ , slider_arrow_button_: slider_arrow_button_ } = shared_properties;
4970
+ const { state_: { category_local_filter_cache: local_filter_cache_ , category_sorting: current_sorting_ , category_filters_open: category_filters_open_ , category_sorting_open: category_sorting_open_ , category_expanded_filters: expanded_filters_ , category_expanded_hierarchical_filters: expanded_hierarchical_filters_ , category_selected_filters: selected_filters_ , category_scroll_restoration_data: scroll_restoration_data_ } , reset_history_state_: reset_history_state_ , depict_api_: depict_api_ , i18n_: i18n_ , on_category_link_click_: on_category_link_click_ , breadcrumb_signal_: breadcrumb_signal_ , quicklinks_signal_: quicklinks_signal_ , slider_arrow_button_: slider_arrow_button_ } = shared_properties;
5195
4971
  (0, $g9l4l$onCleanup)(reset_history_state_);
5196
4972
  return (0, $1ae892b13d7746ab$export$f7d2f673fc2f091d)({
5197
4973
  tenant_: ()=>depict_category.merchant,
@@ -5545,15 +5321,14 @@ function $6ded59a142c93078$export$b94867ecbd698f21({ search_field_value_: search
5545
5321
  if (!disabled_) // just in case. The field not actually being disabled when being disabled_ is so that you can focus it and open the modal. We don't want any of the other input-field-interaction features to work
5546
5322
  {
5547
5323
  if (input_field.selectionStart === 0 && input_field.selectionEnd === input_field.value.length) // everything was selected, clear filters on next submit on next input
5548
- input_field.addEventListener("input", (0, $g9l4l$catchify)(()=>clear_filters_(false)), // We don't count this as user triggered since it wasn't explicit
5549
- {
5324
+ input_field.addEventListener("input", (0, $g9l4l$catchify)(clear_filters_), {
5550
5325
  once: true
5551
5326
  });
5552
5327
  }
5553
5328
  }));
5554
5329
  (0, $g9l4l$addEventListener)(_el$4, "input", (0, $g9l4l$catchify)(()=>{
5555
5330
  const { value: value } = input_field;
5556
- if (!disabled_ && !value.length) clear_filters_(false); // if the user clears the whole field, reset filters on next submit
5331
+ if (!disabled_ && !value.length) clear_filters_(); // if the user clears the whole field, reset filters on next submit
5557
5332
  search_field_value_[1](value);
5558
5333
  }), true);
5559
5334
  (0, $g9l4l$addEventListener)(_el$4, "keydown", (0, $g9l4l$catchify)((e)=>{
@@ -5579,7 +5354,7 @@ function $6ded59a142c93078$export$b94867ecbd698f21({ search_field_value_: search
5579
5354
  _el$4.classList.toggle("has-adjacent-back-button", !!on_back_);
5580
5355
  (0, $g9l4l$addEventListener)(_el$5, "click", (0, $g9l4l$catchify)(()=>{
5581
5356
  search_field_value_[1]("");
5582
- clear_filters_(true);
5357
+ clear_filters_();
5583
5358
  if (disabled_) return;
5584
5359
  input_field.focus();
5585
5360
  }), true);
@@ -5797,27 +5572,27 @@ function $079defea521d5e2a$export$b3ad617e9036868(modal_body_style, input_field,
5797
5572
 
5798
5573
 
5799
5574
  function $a0d89ff25220eb8d$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_ }) {
5800
- const [get_selected_filters] = selected_filters_;
5801
- // Possible values:
5802
- // 0 - we should not clear next submit
5803
- // 1 - we should clear next submit due to internal heuristics
5804
- // 2 - we should clear next submit due to EXPLICIT user action (i.e. clear button pressed)
5805
- const clear_filters_next_submit_ = (0, $g9l4l$createSignal)(0); // we store this here (and not in history.state) (maybe there's a better place) because it's a very temporary thing. I.e. as soon as anything breaks the "flow of intent" to make a new search we want this reset
5575
+ const [get_selected_filters, set_selected_filters] = selected_filters_;
5576
+ const clear_filters_next_submit_ = (0, $g9l4l$createSignal)(false); // we store this here (and not in history.state) (maybe there's a better place) because it's a very temporary thing. I.e. as soon as anything breaks the "flow of intent" to make a new search we want this reset
5806
5577
  const [get_clear_filters_next_submit, set_clear_filters_next_submit] = clear_filters_next_submit_;
5807
- const clear_filters = (user_triggered)=>set_clear_filters_next_submit(user_triggered ? 2 : 1);
5578
+ const clear_filters = ()=>set_clear_filters_next_submit(true);
5808
5579
  (0, $g9l4l$createComputed)((0, $g9l4l$on)(get_selected_filters, ()=>{
5809
5580
  // if the selected filters update, clear the clearing signal
5810
- set_clear_filters_next_submit(0);
5581
+ set_clear_filters_next_submit(false);
5811
5582
  }, {
5812
5583
  defer: true
5813
5584
  }));
5814
5585
  (0, $g9l4l$createComputed)((0, $g9l4l$on)(get_search_query, (0, $g9l4l$catchify)(()=>{
5815
5586
  // when a query was submitted, clear filters if clear was pressed before
5816
- const clear_value = (0, $g9l4l$untrack)(get_clear_filters_next_submit);
5817
- if (clear_value) {
5818
- set_clear_filters_next_submit(0);
5587
+ if ((0, $g9l4l$untrack)(get_clear_filters_next_submit)) {
5588
+ set_clear_filters_next_submit(false);
5589
+ set_selected_filters([]);
5590
+ // also collapse expanded filters in hierarchical filter tree again
5591
+ expanded_hierarchical_filters_[1]([]);
5592
+ // also clear sorting
5593
+ current_sorting_[1](undefined);
5819
5594
  (0, $af89070cc0052779$export$8895d39404bd2bb1)({
5820
- user_triggered_: clear_value === 2,
5595
+ user_triggered_: true,
5821
5596
  selected_filters_: selected_filters_,
5822
5597
  i18n_: i18n_,
5823
5598
  also_clear_sorting_: true,
@@ -7543,7 +7318,6 @@ function $a79ffb1cbfbd2a09$export$828dcdd425fd3231(aligner) {
7543
7318
  }
7544
7319
 
7545
7320
 
7546
-
7547
7321
  const $540e930c58500cbe$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="depict plp search"></div>`, 2);
7548
7322
  /**
7549
7323
  * Type for the private properties that are shared between the different exported search SDK wrapper functions. SDK users are not allowed to change/access these, they're an internal implementation detail.
@@ -7556,7 +7330,7 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
7556
7330
  #market_signal = (0, $g9l4l$createSignal)();
7557
7331
  #modal_open_signal = (0, $g9l4l$createSignal)(false);
7558
7332
  static #has_been_constructed = false;
7559
- constructor({ search_query_url_param_name: search_query_url_param_name = "query" , url_transformer: url_transformer , on_navigation: raw_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
7333
+ constructor({ search_query_url_param_name: search_query_url_param_name = "search_query" , url_transformer: url_transformer , on_navigation: raw_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
7560
7334
  disable_scrolling_during_modal = true , api: api , bottom_distance_under_modal_: bottom_distance_under_modal_ , render_instant_card: render_instant_card , ...props_on_class }){
7561
7335
  if ($540e930c58500cbe$export$ac6237957a15b3f0.#has_been_constructed) throw new Error("You can only have one instance of DepictSearch");
7562
7336
  Object.assign(this, props_on_class);
@@ -7578,22 +7352,19 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
7578
7352
  target_url.searchParams.set(search_param_name, new_search_query);
7579
7353
  on_navigation(target_url.href);
7580
7354
  });
7581
- const { current_sorting_: current_sorting_ , selected_filters_: selected_filters_ } = (0, $4ebab5f2b1a65493$export$7bcff1eb3eca57d7)();
7582
- const [reset_history_state_, state_] = (0, $764ea8aa12c4fc5b$export$90a2b6b3fb2a1455)({
7583
- selected_filters_: selected_filters_,
7584
- current_sorting_: current_sorting_,
7585
- get_default_values_: ()=>({
7586
- search_field_value: new URLSearchParams(location.search).get(search_query_url_param_name) ?? "",
7587
- search_filters_open: false,
7588
- search_sorting_open: false,
7589
- search_expanded_filters: [],
7590
- // WARNING, it is insanely important, when creating the signals like this using make_resettable_history_state, that the two lines below are in *precisely that order*. The reason for that is that make_resettable_history_state will write the values of the signals in the order that they are written here when a "popstate" event occurs. If the filter cache is popped before the selected filters are the code in create_modified_filters() in FilterBody.tsx is going to re-calculate search_local_filter_cache without knowing the real value of search_selected_filters, and we'll end up with too few filters in search_local_filter_cache in some cases
7591
- search_local_filter_cache: [],
7592
- search_expanded_hierarchical_filters: [],
7593
- search_showing_recommendation_rows: (0, $aee0c68312d971f4$export$1c8c715550dc689d),
7594
- search_scroll_restoration_data: []
7595
- })
7596
- });
7355
+ const [reset_history_state_, state_] = (0, $3075a4497054bec6$export$9862539c89138352)(()=>({
7356
+ search_field_value: new URLSearchParams(location.search).get(search_query_url_param_name) ?? "",
7357
+ search_sorting: undefined,
7358
+ search_filters_open: false,
7359
+ search_sorting_open: false,
7360
+ search_expanded_filters: [],
7361
+ // WARNING, it is insanely important, when creating the signals like this using make_resettable_history_state, that the two lines below are in *precisely that order*. The reason for that is that make_resettable_history_state will write the values of the signals in the order that they are written here when a "popstate" event occurs. If the filter cache is popped before the selected filters are the code in create_modified_filters() in FilterBody.tsx is going to re-calculate search_local_filter_cache without knowing the real value of search_selected_filters, and we'll end up with too few filters in search_local_filter_cache in some cases
7362
+ search_selected_filters: [],
7363
+ search_local_filter_cache: [],
7364
+ search_expanded_hierarchical_filters: [],
7365
+ search_showing_recommendation_rows: (0, $aee0c68312d971f4$export$1c8c715550dc689d),
7366
+ search_scroll_restoration_data: []
7367
+ }));
7597
7368
  const search_query_updating_blocked_ = (0, $g9l4l$createSignal)(false);
7598
7369
  const { [search_query_url_param_name]: raw_search_query_signal } = (0, $4ad18a8b237ff7f6$export$2542ffb77b620b02)({
7599
7370
  [search_query_url_param_name]: ""
@@ -7615,9 +7386,9 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
7615
7386
  });
7616
7387
  const i18n_ = (0, $0466953901b38f18$export$f091cbac892643a4)(this.#locale_signal[0]);
7617
7388
  const clear_filters_on_next_submit_ = (0, $a0d89ff25220eb8d$export$e026af0c7b64ea5f)({
7618
- selected_filters_: selected_filters_,
7389
+ selected_filters_: state_.search_selected_filters,
7619
7390
  search_query_: search_query_signal_,
7620
- current_sorting_: current_sorting_,
7391
+ current_sorting_: state_.search_sorting,
7621
7392
  expanded_hierarchical_filters_: state_.search_expanded_hierarchical_filters,
7622
7393
  i18n_: i18n_,
7623
7394
  local_filter_cache_: state_.search_local_filter_cache
@@ -7640,9 +7411,7 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
7640
7411
  configured_submit_query_: configured_submit_query_,
7641
7412
  search_query_signal_: search_query_signal_,
7642
7413
  i18n_: i18n_,
7643
- search_query_updating_blocked_: search_query_updating_blocked_,
7644
- current_sorting_: current_sorting_,
7645
- selected_filters_: selected_filters_
7414
+ search_query_updating_blocked_: search_query_updating_blocked_
7646
7415
  });
7647
7416
  (0, $2864fd26f57ff474$export$5162a71f252e6122)();
7648
7417
  (0, $g9l4l$catchify)(async ()=>{
@@ -7669,7 +7438,7 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
7669
7438
  min_products_to_fetch_: $540e930c58500cbe$var$min_products_to_fetch_,
7670
7439
  render_instant_card_: render_instant_card,
7671
7440
  render_instant_card_placeholder_: (0, $aaacfac0064e97d9$export$ee1733d9a8495996),
7672
- has_sort_or_filters_: (0, $g9l4l$createMemo)(()=>!!(Object.keys(selected_filters_[0]())?.length || current_sorting_[0]()))
7441
+ has_sort_or_filters_: (0, $g9l4l$createMemo)(()=>!!(Object.keys(state_.search_selected_filters[0]())?.length || state_.search_sorting[0]()))
7673
7442
  },
7674
7443
  i18n_: i18n_,
7675
7444
  enable_category_suggestions_: enable_category_suggestions,
@@ -7809,7 +7578,7 @@ function $540e930c58500cbe$export$f2dc7e4e4aa11abb({ depict_search: depict_searc
7809
7578
  });
7810
7579
  });
7811
7580
  },
7812
- current_sorting_: shared_properties.current_sorting_,
7581
+ current_sorting_: state_.search_sorting,
7813
7582
  search_filters_open_: state_.search_filters_open,
7814
7583
  search_sorting_open_: state_.search_sorting_open,
7815
7584
  expanded_filters_: state_.search_expanded_filters,
@@ -7820,7 +7589,7 @@ function $540e930c58500cbe$export$f2dc7e4e4aa11abb({ depict_search: depict_searc
7820
7589
  });
7821
7590
  } : false,
7822
7591
  expanded_hierarchical_filters_: state_.search_expanded_hierarchical_filters,
7823
- selected_filters_: shared_properties.selected_filters_,
7592
+ selected_filters_: state_.search_selected_filters,
7824
7593
  showing_recommendation_rows_: state_.search_showing_recommendation_rows,
7825
7594
  scroll_restoration_data_: state_.search_scroll_restoration_data,
7826
7595
  include_input_field_: include_input_field,