@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/main.js CHANGED
@@ -1,7 +1,6 @@
1
1
  var $46MJV$depictaiutilishared = require("@depict-ai/utilishared");
2
2
  var $46MJV$solidjsweb = require("solid-js/web");
3
3
  var $46MJV$solidjs = require("solid-js");
4
- var $46MJV$lzstring = require("lz-string");
5
4
 
6
5
  function $parcel$export(e, n, v, s) {
7
6
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
@@ -35,7 +34,7 @@ $parcel$export(module.exports, "solid_format_price", () => $5fc9fc23df1591db$exp
35
34
  $parcel$export(module.exports, "connect_search_field_height_to_aligner_height", () => $246e3e89a097f014$export$828dcdd425fd3231);
36
35
  $parcel$export(module.exports, "PageReplacer", () => $37e96a5ebc768cc7$export$3ccaa27d81dd8556);
37
36
  $parcel$export(module.exports, "version", () => $ae93561d5649a847$export$83d89fbfd8236492);
38
- /*! Depict.ai search and product listing SDK */ const $ae93561d5649a847$export$83d89fbfd8236492 = "0.0.64";
37
+ /*! Depict.ai search and product listing SDK */ const $ae93561d5649a847$export$83d89fbfd8236492 = "0.0.65";
39
38
 
40
39
 
41
40
 
@@ -89,16 +88,14 @@ function $1ee6da2465098194$var$history_state_change(signals, entries, state) {
89
88
  }
90
89
 
91
90
 
92
- function $92acef13f7f7585b$export$90a2b6b3fb2a1455({ get_default_values_: get_default_values_ , current_sorting_: [, set_current_sorting] , selected_filters_: [get_selected_filters, set_selected_filters] }) {
93
- const state = (0, $1ee6da2465098194$export$e183a13865960371)(get_default_values_());
91
+ function $0de081f67b6d15b5$export$9862539c89138352(get_default_values) {
92
+ const state = (0, $1ee6da2465098194$export$e183a13865960371)(get_default_values());
94
93
  const reset_state = ()=>{
95
- const new_defaults = get_default_values_();
94
+ const new_defaults = get_default_values();
96
95
  for(const key in state){
97
96
  const new_value = new_defaults[key];
98
97
  state[key][1](new_value);
99
98
  }
100
- set_current_sorting();
101
- if (get_selected_filters().length > 0) set_selected_filters([]);
102
99
  };
103
100
  return [
104
101
  reset_state,
@@ -156,8 +153,9 @@ class $9ce64f69303c371e$export$e015ed2f2950f2e3 {
156
153
  async #cached_post_request(endpoint1, input_req, fallback_response) {
157
154
  const cache_obj = this.#get_cache_obj_for_endpoint(endpoint1);
158
155
  const with_ids = $9ce64f69303c371e$var$add_ids_to_request(input_req);
159
- const request = this.#get_metadata ? Object.assign(with_ids, {
160
- metadata: await this.#get_metadata()
156
+ const metaData = await this.#get_metadata?.();
157
+ const request = metaData ? Object.assign(with_ids, {
158
+ metadata: metaData
161
159
  }) : with_ids;
162
160
  const body = JSON.stringify((0, $46MJV$depictaiutilishared.sort_obj)(request));
163
161
  const response_from_cache = cache_obj.cache_[body]?.deref?.();
@@ -2781,6 +2779,156 @@ var $6865c7388a79e957$export$2e2bcd8739ae039 = {
2781
2779
 
2782
2780
 
2783
2781
 
2782
+ function $0bc45cf6753f874a$export$b288c38ae3fddb56({ available_filters_: available_filters_ , local_filter_cache_: [read_local_cache, write_local_cache] , selected_filters_: [read_selected_filters] }) {
2783
+ let last_remote_state;
2784
+ (0, $46MJV$solidjs.createComputed)(()=>{
2785
+ const remote_filters = Object.fromEntries(available_filters_()?.map((filter)=>[
2786
+ JSON.stringify([
2787
+ filter.field,
2788
+ filter.op,
2789
+ filter?.meta?.type
2790
+ ]),
2791
+ filter
2792
+ ]) || []);
2793
+ const local_filters = Object.fromEntries(read_local_cache().map((filter)=>[
2794
+ JSON.stringify([
2795
+ filter.field,
2796
+ filter.op,
2797
+ filter?.meta?.type
2798
+ ]),
2799
+ filter
2800
+ ]));
2801
+ const selected_filters = Object.fromEntries(read_selected_filters().map((filter_obj)=>[
2802
+ JSON.stringify([
2803
+ filter_obj.field,
2804
+ filter_obj.op
2805
+ ]),
2806
+ filter_obj
2807
+ ]));
2808
+ const new_local_filter_state = [];
2809
+ // 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
2810
+ for (const filter_id of [
2811
+ ...Object.keys(local_filters).filter((key)=>!(key in remote_filters)),
2812
+ ...Object.keys(remote_filters)
2813
+ ]){
2814
+ const local_filter = local_filters[filter_id];
2815
+ const remote_filter = remote_filters[filter_id];
2816
+ const filter_id_without_meta_type = JSON.stringify(JSON.parse(filter_id).slice(0, 2));
2817
+ 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
2818
+ {
2819
+ if (filter_id_without_meta_type in selected_filters) new_local_filter_state.push($0bc45cf6753f874a$var$modify_only_local_filter(local_filter, selected_filters[filter_id_without_meta_type]));
2820
+ } else if (!local_filter) // just take the remote one
2821
+ new_local_filter_state.push(remote_filter);
2822
+ else {
2823
+ // both exist, merge them if needed
2824
+ const remote_meta = remote_filter.meta;
2825
+ const local_meta = local_filter.meta;
2826
+ const this_applied_filter = selected_filters[filter_id_without_meta_type];
2827
+ 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
2828
+ new_local_filter_state.push(remote_filter);
2829
+ else {
2830
+ const data_objs_in_remote = Object.fromEntries(remote_meta.values.map((value, index)=>[
2831
+ JSON.stringify(value),
2832
+ {
2833
+ value_: value,
2834
+ count_: remote_meta.counts?.[index],
2835
+ name_: remote_meta.names?.[index]
2836
+ }
2837
+ ]));
2838
+ const data_objs_in_local = Object.fromEntries(local_meta.values.map((value, index)=>[
2839
+ JSON.stringify(value),
2840
+ {
2841
+ value_: value,
2842
+ count_: 0,
2843
+ name_: local_meta.names?.[index]
2844
+ }
2845
+ ]));
2846
+ const new_data = [
2847
+ ...Object.keys(data_objs_in_local).filter((key)=>{
2848
+ // put data entries that are selected and don't exist in new remote state first
2849
+ if (key in data_objs_in_remote) return false;
2850
+ const selected_values = this_applied_filter.data;
2851
+ return selected_values.some((value)=>{
2852
+ const is_equal = JSON.stringify(value) === key;
2853
+ if (is_equal) return true;
2854
+ if (local_meta.type === remote_meta.type && local_meta.type === "checkbox-hierarchical") {
2855
+ // 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.
2856
+ const selected_values = data_objs_in_local[key].value_;
2857
+ const values_length = value?.length;
2858
+ if (values_length > 1 && values_length - 1 === selected_values.length) {
2859
+ let is_parent = true;
2860
+ for(let i = 0; i < selected_values.length; i++)if (selected_values[i] !== value[i]) is_parent = false;
2861
+ return is_parent;
2862
+ }
2863
+ }
2864
+ return false;
2865
+ });
2866
+ }).map((key)=>data_objs_in_local[key]),
2867
+ ...Object.values(data_objs_in_remote)
2868
+ ];
2869
+ const new_values = new_data.map(({ value_: value_ })=>value_);
2870
+ const result = {
2871
+ ...remote_filter,
2872
+ meta: {
2873
+ ...remote_filter.meta,
2874
+ values: new_values,
2875
+ names: new_data.map(({ name_: name_ })=>name_),
2876
+ counts: new_data.map(({ count_: count_ })=>count_)
2877
+ }
2878
+ };
2879
+ new_local_filter_state.push(result);
2880
+ }
2881
+ }
2882
+ }
2883
+ 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
2884
+ JSON.stringify(new_local_filter_state) !== JSON.stringify(read_local_cache())) // Sorry……… They're not that big
2885
+ write_local_cache(new_local_filter_state);
2886
+ last_remote_state = available_filters_();
2887
+ });
2888
+ return read_local_cache;
2889
+ }
2890
+ /**
2891
+ * 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.
2892
+ * This sets the counts to 0 (if applicable) and removes non-selected options (if applicable)
2893
+ */ function $0bc45cf6753f874a$var$modify_only_local_filter(local_filter_object, selected_filter) {
2894
+ const old_meta = local_filter_object.meta;
2895
+ const selected_filter_data = selected_filter.data;
2896
+ const modified_filter_object = {
2897
+ ...local_filter_object
2898
+ };
2899
+ if (old_meta) {
2900
+ const new_meta = {
2901
+ ...old_meta
2902
+ };
2903
+ modified_filter_object.meta = new_meta;
2904
+ // set counts to 0
2905
+ if ("counts" in new_meta) {
2906
+ const counts = new_meta.counts;
2907
+ if (counts) new_meta.counts = counts.map(()=>0);
2908
+ }
2909
+ if (Array.isArray(selected_filter_data) && "values" in new_meta) {
2910
+ // we have an array of values and want to strip the ones from the available ones that aren't selected
2911
+ const values = new_meta.values;
2912
+ if (Array.isArray(values)) {
2913
+ const jsond_set_values = selected_filter_data.map((data)=>JSON.stringify(data));
2914
+ const indexes_to_remove = new Set();
2915
+ for(let i = 0; i < values.length; i++){
2916
+ const value = values[i];
2917
+ 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
2918
+ indexes_to_remove.add(i);
2919
+ }
2920
+ new_meta.values = values.filter((_, index)=>!indexes_to_remove.has(index));
2921
+ if (new_meta.names) new_meta.names = new_meta.names.filter((_, index)=>!indexes_to_remove.has(index));
2922
+ if (new_meta.counts) // remove counts that are too much, they're all zero anyway if they exist
2923
+ new_meta.counts.length -= indexes_to_remove.size;
2924
+ }
2925
+ }
2926
+ }
2927
+ return modified_filter_object;
2928
+ }
2929
+
2930
+
2931
+
2784
2932
 
2785
2933
 
2786
2934
 
@@ -2947,7 +3095,11 @@ function $1587765bd31f3722$export$3f1a388cc0d8fed7(props) {
2947
3095
  });
2948
3096
  }
2949
3097
  function $1587765bd31f3722$var$ActualFilterBody(props) {
2950
- const [modified_available_filters_with_selected_unexisting_ones_injected_from_local_state] = props.local_filter_cache_;
3098
+ const modified_available_filters_with_selected_unexisting_ones_injected_from_local_state = (0, $0bc45cf6753f874a$export$b288c38ae3fddb56)({
3099
+ available_filters_: props.available_filters_,
3100
+ selected_filters_: props.selected_filters_,
3101
+ local_filter_cache_: props.local_filter_cache_
3102
+ });
2951
3103
  const togglable_filters = (0, $46MJV$solidjs.createMemo)(()=>modified_available_filters_with_selected_unexisting_ones_injected_from_local_state().filter((item)=>item?.meta?.group_title));
2952
3104
  const untogglable_filters = (0, $46MJV$solidjs.createMemo)(()=>modified_available_filters_with_selected_unexisting_ones_injected_from_local_state().filter((item)=>!item?.meta?.group_title));
2953
3105
  const togglable_filters_grouped_by_collapsible = (0, $46MJV$solidjs.createMemo)(()=>{
@@ -3148,10 +3300,9 @@ function $1587765bd31f3722$var$ActualFilterBody(props) {
3148
3300
 
3149
3301
 
3150
3302
  const $cc8aaf130b1dc1ea$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="sorting-attributes"></div>`, 2), $cc8aaf130b1dc1ea$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="sorting-direction"></div>`, 2), $cc8aaf130b1dc1ea$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div><div class="input-row"><input type="radio"><span class="custom-indicator"></span></div></div>`, 7), $cc8aaf130b1dc1ea$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div><label class="input-row"><input type="radio"><span class="custom-indicator"></span></label></div>`, 7);
3151
- function $cc8aaf130b1dc1ea$export$1f1775a58da589b5({ available_sortings_: available_sortings_ , current_sorting_: [get_current_sorting, set_current_sorting] }) {
3303
+ function $cc8aaf130b1dc1ea$export$1f1775a58da589b5({ available_sortings_: available_sortings_ , current_sorting_: current_sorting_ }) {
3152
3304
  const title_radio_name = (0, $46MJV$depictaiutilishared.make_random_classname)();
3153
3305
  const order_radio_name = (0, $46MJV$depictaiutilishared.make_random_classname)();
3154
- const meta_of_currently_selected_sorting = (0, $46MJV$solidjs.createMemo)(()=>available_sortings_()?.find?.((sorting)=>sorting.field === get_current_sorting()?.field)?.meta);
3155
3306
  return (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Show), {
3156
3307
  get when () {
3157
3308
  return available_sortings_()?.length;
@@ -3183,14 +3334,14 @@ function $cc8aaf130b1dc1ea$export$1f1775a58da589b5({ available_sortings_: availa
3183
3334
  },
3184
3335
  children: (item, index)=>{
3185
3336
  const is_checked = (0, $46MJV$solidjs.createMemo)(()=>{
3186
- const sort = get_current_sorting();
3337
+ const sort = current_sorting_[0]();
3187
3338
  if (!sort) // if no sortings are selected, "select" first sort
3188
3339
  return index === 0;
3189
3340
  return sort.field === item().field && (sort.order === item().order || item().meta.values?.length > 1);
3190
3341
  });
3191
3342
  return /* wrapping div for flex gap polyfill scss mixin */ (()=>{
3192
3343
  const _el$8 = $cc8aaf130b1dc1ea$var$_tmpl$4.cloneNode(true), _el$9 = _el$8.firstChild, _el$10 = _el$9.firstChild, _el$11 = _el$10.nextSibling;
3193
- (0, $46MJV$solidjsweb.addEventListener)(_el$10, "change", (0, $46MJV$depictaiutilishared.catchify)(()=>set_current_sorting(item())));
3344
+ (0, $46MJV$solidjsweb.addEventListener)(_el$10, "change", (0, $46MJV$depictaiutilishared.catchify)(()=>current_sorting_[1](item())));
3194
3345
  (0, $46MJV$solidjsweb.setAttribute)(_el$10, "name", title_radio_name);
3195
3346
  (0, $46MJV$solidjsweb.insert)(_el$9, ()=>item().meta.title, null);
3196
3347
  (0, $46MJV$solidjsweb.effect)(()=>_el$10.checked = is_checked());
@@ -3202,25 +3353,27 @@ function $cc8aaf130b1dc1ea$export$1f1775a58da589b5({ available_sortings_: availa
3202
3353
  })(),
3203
3354
  (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Show), {
3204
3355
  get when () {
3205
- return meta_of_currently_selected_sorting()?.values?.length > 1;
3356
+ return current_sorting_[0]()?.meta?.values?.length > 1;
3206
3357
  },
3207
3358
  get children () {
3208
3359
  const _el$2 = $cc8aaf130b1dc1ea$var$_tmpl$2.cloneNode(true);
3209
3360
  (0, $46MJV$solidjsweb.insert)(_el$2, (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Index), {
3210
3361
  get each () {
3211
- return meta_of_currently_selected_sorting()?.values;
3362
+ return current_sorting_[0]().meta.values;
3212
3363
  },
3213
3364
  children: (order_value, index)=>{
3214
- const is_checked = (0, $46MJV$solidjs.createMemo)(()=>get_current_sorting()?.order === order_value());
3215
3365
  return (()=>{
3216
3366
  const _el$12 = $cc8aaf130b1dc1ea$var$_tmpl$4.cloneNode(true), _el$13 = _el$12.firstChild, _el$14 = _el$13.firstChild, _el$15 = _el$14.nextSibling;
3217
- (0, $46MJV$solidjsweb.addEventListener)(_el$14, "change", (0, $46MJV$depictaiutilishared.catchify)(()=>set_current_sorting((c)=>c && {
3367
+ (0, $46MJV$solidjsweb.addEventListener)(_el$14, "change", (0, $46MJV$depictaiutilishared.catchify)(()=>current_sorting_[1]((c)=>c && {
3218
3368
  ...c,
3219
3369
  order: order_value()
3220
3370
  })));
3221
3371
  (0, $46MJV$solidjsweb.setAttribute)(_el$14, "name", order_radio_name);
3222
- (0, $46MJV$solidjsweb.insert)(_el$13, ()=>meta_of_currently_selected_sorting()?.names?.[index], null);
3223
- (0, $46MJV$solidjsweb.effect)(()=>_el$14.checked = is_checked());
3372
+ (0, $46MJV$solidjsweb.insert)(_el$13, ()=>current_sorting_[0]()?.meta?.names?.[index], null);
3373
+ (0, $46MJV$solidjsweb.effect)(()=>_el$14.checked = (0, $46MJV$solidjs.createMemo)(()=>{
3374
+ const sort = current_sorting_[0]();
3375
+ return sort?.order === order_value();
3376
+ })());
3224
3377
  return _el$12;
3225
3378
  })();
3226
3379
  }
@@ -3565,167 +3718,12 @@ function $66ddbcbc40487f95$export$9bf11afa910f536e({ args_for_sorting_: args_for
3565
3718
 
3566
3719
 
3567
3720
 
3568
-
3569
- function $0bc45cf6753f874a$export$b288c38ae3fddb56({ available_filters_: available_filters_ , local_filter_cache_: [read_local_cache, write_local_cache] , selected_filters_: [read_selected_filters] }) {
3570
- let last_remote_state;
3571
- (0, $46MJV$solidjs.createComputed)(()=>{
3572
- const remote_filters = Object.fromEntries(available_filters_()?.map((filter)=>[
3573
- JSON.stringify([
3574
- filter.field,
3575
- filter.op,
3576
- filter?.meta?.type
3577
- ]),
3578
- filter
3579
- ]) || []);
3580
- const local_filters = Object.fromEntries(read_local_cache().map((filter)=>[
3581
- JSON.stringify([
3582
- filter.field,
3583
- filter.op,
3584
- filter?.meta?.type
3585
- ]),
3586
- filter
3587
- ]));
3588
- const selected_filters = Object.fromEntries(read_selected_filters().map((filter_obj)=>[
3589
- JSON.stringify([
3590
- filter_obj.field,
3591
- filter_obj.op
3592
- ]),
3593
- filter_obj
3594
- ]));
3595
- const new_local_filter_state = [];
3596
- // 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
3597
- for (const filter_id of [
3598
- ...Object.keys(local_filters).filter((key)=>!(key in remote_filters)),
3599
- ...Object.keys(remote_filters)
3600
- ]){
3601
- const local_filter = local_filters[filter_id];
3602
- const remote_filter = remote_filters[filter_id];
3603
- const filter_id_without_meta_type = JSON.stringify(JSON.parse(filter_id).slice(0, 2));
3604
- 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
3605
- {
3606
- if (filter_id_without_meta_type in selected_filters) new_local_filter_state.push($0bc45cf6753f874a$var$modify_only_local_filter(local_filter, selected_filters[filter_id_without_meta_type]));
3607
- } else if (!local_filter) // just take the remote one
3608
- new_local_filter_state.push(remote_filter);
3609
- else {
3610
- // both exist, merge them if needed
3611
- const remote_meta = remote_filter.meta;
3612
- const local_meta = local_filter.meta;
3613
- const this_applied_filter = selected_filters[filter_id_without_meta_type];
3614
- 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
3615
- new_local_filter_state.push(remote_filter);
3616
- else {
3617
- const data_objs_in_remote = Object.fromEntries(remote_meta.values.map((value, index)=>[
3618
- JSON.stringify(value),
3619
- {
3620
- value_: value,
3621
- count_: remote_meta.counts?.[index],
3622
- name_: remote_meta.names?.[index]
3623
- }
3624
- ]));
3625
- const data_objs_in_local = Object.fromEntries(local_meta.values.map((value, index)=>[
3626
- JSON.stringify(value),
3627
- {
3628
- value_: value,
3629
- count_: 0,
3630
- name_: local_meta.names?.[index]
3631
- }
3632
- ]));
3633
- const new_data = [
3634
- ...Object.keys(data_objs_in_local).filter((key)=>{
3635
- // put data entries that are selected and don't exist in new remote state first
3636
- if (key in data_objs_in_remote) return false;
3637
- const selected_values = this_applied_filter.data;
3638
- return selected_values.some((value)=>{
3639
- const is_equal = JSON.stringify(value) === key;
3640
- if (is_equal) return true;
3641
- if (local_meta.type === remote_meta.type && local_meta.type === "checkbox-hierarchical") {
3642
- // 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.
3643
- const selected_values = data_objs_in_local[key].value_;
3644
- const values_length = value?.length;
3645
- if (values_length > 1 && values_length - 1 === selected_values.length) {
3646
- let is_parent = true;
3647
- for(let i = 0; i < selected_values.length; i++)if (selected_values[i] !== value[i]) is_parent = false;
3648
- return is_parent;
3649
- }
3650
- }
3651
- return false;
3652
- });
3653
- }).map((key)=>data_objs_in_local[key]),
3654
- ...Object.values(data_objs_in_remote)
3655
- ];
3656
- const new_values = new_data.map(({ value_: value_ })=>value_);
3657
- const result = {
3658
- ...remote_filter,
3659
- meta: {
3660
- ...remote_filter.meta,
3661
- values: new_values,
3662
- names: new_data.map(({ name_: name_ })=>name_),
3663
- counts: new_data.map(({ count_: count_ })=>count_)
3664
- }
3665
- };
3666
- new_local_filter_state.push(result);
3667
- }
3668
- }
3669
- }
3670
- 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
3671
- JSON.stringify(new_local_filter_state) !== JSON.stringify(read_local_cache())) // Sorry……… They're not that big
3672
- write_local_cache(new_local_filter_state);
3673
- last_remote_state = available_filters_();
3674
- });
3675
- }
3676
- /**
3677
- * 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.
3678
- * This sets the counts to 0 (if applicable) and removes non-selected options (if applicable)
3679
- */ function $0bc45cf6753f874a$var$modify_only_local_filter(local_filter_object, selected_filter) {
3680
- const old_meta = local_filter_object.meta;
3681
- const selected_filter_data = selected_filter.data;
3682
- const modified_filter_object = {
3683
- ...local_filter_object
3684
- };
3685
- if (old_meta) {
3686
- const new_meta = {
3687
- ...old_meta
3688
- };
3689
- modified_filter_object.meta = new_meta;
3690
- // set counts to 0
3691
- if ("counts" in new_meta) {
3692
- const counts = new_meta.counts;
3693
- if (counts) new_meta.counts = counts.map(()=>0);
3694
- }
3695
- if (Array.isArray(selected_filter_data) && "values" in new_meta) {
3696
- // we have an array of values and want to strip the ones from the available ones that aren't selected
3697
- const values = new_meta.values;
3698
- if (Array.isArray(values)) {
3699
- const jsond_set_values = selected_filter_data.map((data)=>JSON.stringify(data));
3700
- const indexes_to_remove = new Set();
3701
- for(let i = 0; i < values.length; i++){
3702
- const value = values[i];
3703
- 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
3704
- indexes_to_remove.add(i);
3705
- }
3706
- new_meta.values = values.filter((_, index)=>!indexes_to_remove.has(index));
3707
- if (new_meta.names) new_meta.names = new_meta.names.filter((_, index)=>!indexes_to_remove.has(index));
3708
- if (new_meta.counts) // remove counts that are too much, they're all zero anyway if they exist
3709
- new_meta.counts.length -= indexes_to_remove.size;
3710
- }
3711
- }
3712
- }
3713
- return modified_filter_object;
3714
- }
3715
-
3716
-
3717
3721
  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);
3718
3722
  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_ }) {
3719
3723
  return (0, $0f2f58dd60b11888$export$b69d0d92862de18b)({
3720
3724
  severity_: "error",
3721
3725
  message_: "Sorting and filters failed",
3722
3726
  get children () {
3723
- // 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
3724
- (0, $0bc45cf6753f874a$export$b288c38ae3fddb56)({
3725
- available_filters_: available_filters_,
3726
- selected_filters_: selected_filters_,
3727
- local_filter_cache_: local_filter_cache_
3728
- });
3729
3727
  const cleanup_promise = new Promise((r)=>(0, $46MJV$solidjs.onCleanup)(r));
3730
3728
  const [filters_open, set_filters_open] = search_filters_open_;
3731
3729
  const [sorting_open, set_sorting_open] = search_sorting_open_;
@@ -4096,166 +4094,6 @@ function $fd64465f894d1f29$var$ActualFloatingButtons({ search_filters_open_: [ge
4096
4094
 
4097
4095
 
4098
4096
 
4099
-
4100
-
4101
-
4102
-
4103
- const $49bdb822440abcec$var$operator_map = {
4104
- "eq": "≡",
4105
- "neq": "≠",
4106
- "in": "∈",
4107
- "nin": "∉",
4108
- "leq": "≤",
4109
- "geq": "≥",
4110
- "inrange": "\uD83D\uDD22"
4111
- };
4112
- const $49bdb822440abcec$var$ascending_token = "\uD83D\uDCC8";
4113
- const $49bdb822440abcec$var$descending_token = "\uD83D\uDCC9";
4114
- const $49bdb822440abcec$export$4f506378e99f23dd = "filter_";
4115
- const $49bdb822440abcec$export$196aa1ee621a9930 = "sorting";
4116
- const $49bdb822440abcec$var$range_delimiter = "-";
4117
- function $49bdb822440abcec$export$7bcff1eb3eca57d7() {
4118
- const current_sorting_ = (0, $46MJV$solidjs.createSignal)();
4119
- const selected_filters_ = (0, $46MJV$solidjs.createSignal)([]);
4120
- const [get_sorting, set_sorting] = current_sorting_;
4121
- const [get_selected_filters, set_selected_filters] = selected_filters_;
4122
- const [get_current_href, set_current_href] = (0, $46MJV$solidjs.createSignal)(location.href);
4123
- const history_change_handler = ()=>set_current_href(location.href);
4124
- let writer_started = false;
4125
- (0, $46MJV$depictaiutilishared.instant_exec_on_suspect_history_change).add(history_change_handler);
4126
- (0, $46MJV$solidjs.onCleanup)(()=>(0, $46MJV$depictaiutilishared.instant_exec_on_suspect_history_change).delete(history_change_handler));
4127
- (0, $46MJV$solidjs.createComputed)(()=>{
4128
- const { searchParams: searchParams } = new URL(get_current_href());
4129
- const sorting = searchParams.get($49bdb822440abcec$export$196aa1ee621a9930);
4130
- (0, $46MJV$solidjs.batch)(()=>{
4131
- set_sorting: {
4132
- if (!sorting) {
4133
- set_sorting();
4134
- break set_sorting;
4135
- }
4136
- let target_field;
4137
- let target_order;
4138
- if (sorting.endsWith($49bdb822440abcec$var$ascending_token)) {
4139
- target_field = sorting.slice(0, -$49bdb822440abcec$var$ascending_token.length);
4140
- target_order = "asc";
4141
- } else if (sorting.endsWith($49bdb822440abcec$var$descending_token)) {
4142
- target_field = sorting.slice(0, -$49bdb822440abcec$var$descending_token.length);
4143
- target_order = "desc";
4144
- } else {
4145
- (0, $46MJV$depictaiutilishared.dlog)("Invalid sorting query param value", sorting);
4146
- break set_sorting;
4147
- }
4148
- const current_sorting = (0, $46MJV$solidjs.untrack)(get_sorting);
4149
- // Do some diffing since we might assume in certain places of the code that if the signal changes it means the sorting has changed
4150
- if (current_sorting?.field !== target_field || current_sorting?.order !== target_order) set_sorting({
4151
- field: target_field,
4152
- order: target_order
4153
- });
4154
- }
4155
- const found_filters = [];
4156
- for (const key of searchParams.keys()){
4157
- if (!key.startsWith($49bdb822440abcec$export$4f506378e99f23dd)) continue;
4158
- for (const op of Object.keys($49bdb822440abcec$var$operator_map)){
4159
- const token = $49bdb822440abcec$var$operator_map[op];
4160
- if (!key.endsWith(token)) continue;
4161
- const field = key.slice($49bdb822440abcec$export$4f506378e99f23dd.length, -token.length);
4162
- const data = searchParams.get(key);
4163
- if (data) {
4164
- let parsed_data;
4165
- if (op === "inrange") parsed_data = data.split($49bdb822440abcec$var$range_delimiter).map((x)=>parseFloat(x));
4166
- else if (data === "1") parsed_data = "true";
4167
- else if (data === "0") parsed_data = "false";
4168
- else try {
4169
- parsed_data = JSON.parse((0, $46MJV$lzstring.decompressFromBase64)(data));
4170
- } catch (e) {
4171
- (0, $46MJV$depictaiutilishared.dlog)("Failed to parse filter data", key, data, e);
4172
- continue;
4173
- }
4174
- found_filters.push({
4175
- field: field,
4176
- op: op,
4177
- data: parsed_data
4178
- });
4179
- }
4180
- }
4181
- }
4182
- const selected_filters = (0, $46MJV$solidjs.untrack)(get_selected_filters);
4183
- const found_filters_map = new Map(found_filters.map(({ field: field , op: op , data: data })=>[
4184
- JSON.stringify([
4185
- field,
4186
- op
4187
- ]),
4188
- data
4189
- ]));
4190
- // Sorry for this diffing algorithm lol. Looking forwards to Records and Tuples.
4191
- if (selected_filters.length !== found_filters.length || !selected_filters.every(({ field: field , op: op , data: data })=>JSON.stringify(found_filters_map.get(JSON.stringify([
4192
- field,
4193
- op
4194
- ]))) === JSON.stringify(data))) set_selected_filters(found_filters);
4195
- if (!writer_started) {
4196
- $49bdb822440abcec$var$start_href_writer(get_sorting, get_selected_filters);
4197
- writer_started = true;
4198
- }
4199
- });
4200
- });
4201
- return {
4202
- current_sorting_: current_sorting_,
4203
- selected_filters_: selected_filters_
4204
- };
4205
- }
4206
- function $49bdb822440abcec$var$start_href_writer(get_sorting, get_selected_filters) {
4207
- // 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)
4208
- (0, $46MJV$solidjs.createComputed)((0, $46MJV$solidjs.on)([
4209
- get_sorting,
4210
- get_selected_filters
4211
- ], ([sorting, filters])=>{
4212
- const current_href = location.href;
4213
- const url_object = new URL(current_href);
4214
- const { searchParams: searchParams } = url_object;
4215
- const keys = [
4216
- ...searchParams.keys()
4217
- ]; // get keys here to be able to iterate over it later while modifying the search params
4218
- if (sorting) {
4219
- const { field: field , order: order } = sorting;
4220
- const ascending = order === "asc";
4221
- searchParams.set($49bdb822440abcec$export$196aa1ee621a9930, field + (ascending ? $49bdb822440abcec$var$ascending_token : $49bdb822440abcec$var$descending_token));
4222
- } else searchParams.delete($49bdb822440abcec$export$196aa1ee621a9930);
4223
- for (const key of keys)if (key.startsWith($49bdb822440abcec$export$4f506378e99f23dd)) searchParams.delete(key);
4224
- for (const filter of filters){
4225
- const { field: field , op: op , data: data } = filter;
4226
- let value;
4227
- if (op === "inrange" && Array.isArray(data)) value = data.join($49bdb822440abcec$var$range_delimiter);
4228
- else if (data === "true") value = "1";
4229
- else if (data === "false") value = "0";
4230
- else value = (0, $46MJV$lzstring.compressToBase64)(JSON.stringify(data));
4231
- searchParams.set($49bdb822440abcec$export$4f506378e99f23dd + field + $49bdb822440abcec$var$operator_map[op], value);
4232
- }
4233
- // 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
4234
- const unmodified_search_params = [
4235
- ...new URL(current_href).searchParams
4236
- ];
4237
- const new_search_params = new Map(searchParams);
4238
- 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
4239
- history.replaceState({}, "", url_object.href);
4240
- }, {
4241
- defer: true
4242
- }));
4243
- }
4244
-
4245
-
4246
- function $88b2d66be18220f6$export$bca5a41ac5ef1190(url) {
4247
- if (!url) return url;
4248
- const got_u_o = url instanceof URL;
4249
- const u_o = got_u_o ? url : new URL(url);
4250
- const { searchParams: searchParams } = u_o;
4251
- const current_search_params = new URLSearchParams(location.search);
4252
- if (current_search_params.has((0, $49bdb822440abcec$export$196aa1ee621a9930))) searchParams.set((0, $49bdb822440abcec$export$196aa1ee621a9930), current_search_params.get((0, $49bdb822440abcec$export$196aa1ee621a9930)));
4253
- for (const key of current_search_params.keys())if (key.startsWith((0, $49bdb822440abcec$export$4f506378e99f23dd))) searchParams.set(key, current_search_params.get(key));
4254
- if (got_u_o) return u_o;
4255
- return u_o.href;
4256
- }
4257
-
4258
-
4259
4097
  const $495e9998757c5d32$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<nav class="crumbs"></nav>`, 2), $495e9998757c5d32$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<a class="crumb"></a>`, 2), $495e9998757c5d32$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<span class="separator"></span>`, 2);
4260
4098
  function $495e9998757c5d32$export$5646050d516e06bc({ crumb_data_: get_api_crumb_data , on_crumb_click_: on_crumb_click_ , i18n_: i18n_ }) {
4261
4099
  const placeholder_crumb_data = [
@@ -4273,20 +4111,11 @@ function $495e9998757c5d32$export$5646050d516e06bc({ crumb_data_: get_api_crumb_
4273
4111
  get each () {
4274
4112
  return crumb_data();
4275
4113
  },
4276
- children: (unmodified_display_accessor, index)=>{
4277
- const modified_display_accessor = (0, $46MJV$solidjs.createMemo)(()=>{
4278
- const value = unmodified_display_accessor();
4279
- if (!value) return value;
4280
- return {
4281
- ...value,
4282
- // 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
4283
- page_url: (0, $88b2d66be18220f6$export$bca5a41ac5ef1190)(value.page_url)
4284
- };
4285
- });
4114
+ children: (display_accessor, index)=>{
4286
4115
  return [
4287
4116
  (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Show), {
4288
4117
  get when () {
4289
- return modified_display_accessor();
4118
+ return display_accessor();
4290
4119
  },
4291
4120
  get fallback () {
4292
4121
  return (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$depictaiutilishared.Placeholder), {
@@ -4296,9 +4125,9 @@ function $495e9998757c5d32$export$5646050d516e06bc({ crumb_data_: get_api_crumb_
4296
4125
  },
4297
4126
  get children () {
4298
4127
  const _el$2 = $495e9998757c5d32$var$_tmpl$2.cloneNode(true);
4299
- (0, $46MJV$solidjsweb.addEventListener)(_el$2, "click", (0, $46MJV$depictaiutilishared.catchify)((ev)=>on_crumb_click_(ev, modified_display_accessor())), true);
4300
- (0, $46MJV$solidjsweb.insert)(_el$2, ()=>modified_display_accessor().title);
4301
- (0, $46MJV$solidjsweb.effect)(()=>(0, $46MJV$solidjsweb.setAttribute)(_el$2, "href", modified_display_accessor().page_url));
4128
+ (0, $46MJV$solidjsweb.addEventListener)(_el$2, "click", (0, $46MJV$depictaiutilishared.catchify)((ev)=>on_crumb_click_(ev, display_accessor())), true);
4129
+ (0, $46MJV$solidjsweb.insert)(_el$2, ()=>display_accessor().title);
4130
+ (0, $46MJV$solidjsweb.effect)(()=>(0, $46MJV$solidjsweb.setAttribute)(_el$2, "href", display_accessor().page_url));
4302
4131
  return _el$2;
4303
4132
  }
4304
4133
  }),
@@ -4335,9 +4164,7 @@ function $495e9998757c5d32$export$5646050d516e06bc({ crumb_data_: get_api_crumb_
4335
4164
 
4336
4165
 
4337
4166
 
4338
-
4339
4167
  const $cdc2c00c0a7da86e$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<nav class="quicklinks"></nav>`, 2), $cdc2c00c0a7da86e$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div>QuickLinks failed</div>`, 2), $cdc2c00c0a7da86e$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<a class="quicklink"></a>`, 2);
4340
- const $cdc2c00c0a7da86e$export$e2cf3f19dd3f8aac = "went_sideways_clear_filters";
4341
4168
  function $cdc2c00c0a7da86e$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_ }) {
4342
4169
  let scrolling_logic_ran_for_query_id = false;
4343
4170
  let last_scroll_position;
@@ -4459,43 +4286,20 @@ function $cdc2c00c0a7da86e$export$466cdc317043f6cb({ quicklinks_data_: quicklink
4459
4286
  get each () {
4460
4287
  return place_holdey_quicklinks_data();
4461
4288
  },
4462
- children: (unmodified_display_accessor, index)=>{
4289
+ children: (display_accessor, index)=>{
4463
4290
  const is_selected = (0, $46MJV$solidjs.createMemo)(()=>selected_index() === index);
4464
- // Problem: if opening a sibling link in a new tab, filter clearing behavior is no longer consistent
4465
- // Solution:
4466
- // If current one in quick links they're siblings, don't add state to the url
4467
- // If it's not in it, it's a child of the current one, so add state
4468
- // (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)
4469
- // Problem: When you don't open a link in a new tab, we don't display the filter cleared toast
4470
- // 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
4471
- const is_child = (0, $46MJV$solidjs.createMemo)(()=>{
4472
- const current_id = current_query_id_();
4473
- return !quicklinks_data_()?.find(({ query_id: query_id })=>query_id === current_id);
4474
- });
4475
- const modified_display_accessor = (0, $46MJV$solidjs.createMemo)(()=>{
4476
- const value = unmodified_display_accessor();
4477
- if (!value) return value;
4478
- const new_page_url = new URL(value.page_url, location.origin);
4479
- (0, $88b2d66be18220f6$export$bca5a41ac5ef1190)(new_page_url);
4480
- if (!is_child()) new_page_url.searchParams.set($cdc2c00c0a7da86e$export$e2cf3f19dd3f8aac, "true");
4481
- return {
4482
- ...value,
4483
- // 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
4484
- page_url: new_page_url.href
4485
- };
4486
- });
4487
4291
  return (()=>{
4488
4292
  const _el$3 = $cdc2c00c0a7da86e$var$_tmpl$3.cloneNode(true);
4489
4293
  (0, $46MJV$solidjsweb.addEventListener)(_el$3, "click", (0, $46MJV$depictaiutilishared.catchify)((ev)=>{
4490
4294
  if (is_selected() && !ev.metaKey && !ev.ctrlKey && !ev.button) ev.preventDefault();
4491
- else if (modified_display_accessor()) on_link_click_(ev, modified_display_accessor());
4295
+ else if (display_accessor()) on_link_click_(ev, display_accessor());
4492
4296
  }), true);
4493
- (0, $46MJV$solidjsweb.insert)(_el$3, ()=>modified_display_accessor()?.title || (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$depictaiutilishared.Placeholder), {
4297
+ (0, $46MJV$solidjsweb.insert)(_el$3, ()=>display_accessor()?.title || (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$depictaiutilishared.Placeholder), {
4494
4298
  height: "1em",
4495
4299
  width: "10ch"
4496
4300
  }));
4497
4301
  (0, $46MJV$solidjsweb.effect)((_p$)=>{
4498
- const _v$ = !!is_selected(), _v$2 = modified_display_accessor()?.page_url || "javascript:void(0)";
4302
+ const _v$ = !!is_selected(), _v$2 = display_accessor()?.page_url || "javascript:void(0)";
4499
4303
  _v$ !== _p$._v$ && _el$3.classList.toggle("selected", _p$._v$ = _v$);
4500
4304
  _v$2 !== _p$._v$2 && (0, $46MJV$solidjsweb.setAttribute)(_el$3, "href", _p$._v$2 = _v$2);
4501
4305
  return _p$;
@@ -4670,7 +4474,6 @@ let $29b757e2ae26852c$export$44dad306455dddf;
4670
4474
  })($29b757e2ae26852c$export$44dad306455dddf || ($29b757e2ae26852c$export$44dad306455dddf = {}));
4671
4475
 
4672
4476
 
4673
-
4674
4477
  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);
4675
4478
  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_ , 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_ }) {
4676
4479
  let results_for;
@@ -4693,26 +4496,6 @@ function $671632478f2a7ce7$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
4693
4496
  const first_result_in_viewport_ = (0, $46MJV$solidjs.createSignal)();
4694
4497
  const last_result_in_viewport_ = (0, $46MJV$solidjs.createSignal)();
4695
4498
  const [can_write_scroll_restoration_, set_can_write_scroll_restoration] = (0, $46MJV$solidjs.createSignal)(false);
4696
- const tracking_function_for_plp_results = (0, $46MJV$solidjs.createReaction)(()=>{
4697
- // 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
4698
- const url_object = new URL(location.href);
4699
- const { searchParams: searchParams } = url_object;
4700
- if (searchParams.get((0, $cdc2c00c0a7da86e$export$e2cf3f19dd3f8aac)) !== "true") return;
4701
- searchParams.delete((0, $cdc2c00c0a7da86e$export$e2cf3f19dd3f8aac));
4702
- history.pushState(history.state, "", url_object.href);
4703
- (0, $46MJV$depictaiutilishared.dlog)("Flag to clear filters was set, clearing filters");
4704
- (0, $46MJV$depictaiutilishared.queueMacroTask)(()=>{
4705
- // Do it next task so that all the filters have time to populate
4706
- (0, $92e4e7906daa1ff8$export$8895d39404bd2bb1)({
4707
- user_triggered_: false,
4708
- i18n_: i18n_,
4709
- also_clear_sorting_: false,
4710
- selected_filters_: selected_filters_,
4711
- expanded_hierarchical_filters_: expanded_hierarchical_filters_,
4712
- local_filter_cache_: local_filter_cache_
4713
- });
4714
- });
4715
- });
4716
4499
  const query_base_ = (0, $08349e39f239a034$export$210f130a61ac1e8d)(()=>{
4717
4500
  const sort_obj = get_sorting() && {
4718
4501
  ...get_sorting()
@@ -4744,7 +4527,6 @@ function $671632478f2a7ce7$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
4744
4527
  } : {}
4745
4528
  })
4746
4529
  })));
4747
- tracking_function_for_plp_results(plp_results_);
4748
4530
  const available_sortings_ = (0, $46MJV$solidjs.createMemo)(()=>plp_results_()?.sorts?.map((sort)=>({
4749
4531
  ...sort,
4750
4532
  order: sort.order ?? "desc"
@@ -5121,7 +4903,6 @@ function $f27b0b326e0a87e2$export$23fca46f3143581f(component, error_message) {
5121
4903
  }
5122
4904
 
5123
4905
 
5124
-
5125
4906
  const $068a627cc18f7bb6$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="depict plp category"></div>`, 2);
5126
4907
  const $068a627cc18f7bb6$var$min_products_to_fetch_ = 20;
5127
4908
  const $068a627cc18f7bb6$var$privately_shared_properties = /*@__PURE__*/ new WeakMap();
@@ -5167,20 +4948,17 @@ class $068a627cc18f7bb6$export$f34314aa9505732e {
5167
4948
  $068a627cc18f7bb6$export$f34314aa9505732e.#has_been_constructed = true;
5168
4949
  Object.assign(this, props_on_class); // set initial signal values
5169
4950
  (0, $33815c5a406b6cc0$export$5162a71f252e6122)();
5170
- const { selected_filters_: selected_filters_ , current_sorting_: current_sorting_ } = (0, $49bdb822440abcec$export$7bcff1eb3eca57d7)();
5171
- const [reset_history_state_, state_] = (0, $92acef13f7f7585b$export$90a2b6b3fb2a1455)({
5172
- selected_filters_: selected_filters_,
5173
- current_sorting_: current_sorting_,
5174
- get_default_values_: ()=>({
5175
- category_filters_open: false,
5176
- category_sorting_open: false,
5177
- category_expanded_filters: [],
5178
- // 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
5179
- category_local_filter_cache: [],
5180
- category_expanded_hierarchical_filters: [],
5181
- category_scroll_restoration_data: []
5182
- })
5183
- });
4951
+ const [reset_history_state_, state_] = (0, $0de081f67b6d15b5$export$9862539c89138352)(()=>({
4952
+ category_sorting: undefined,
4953
+ category_filters_open: false,
4954
+ category_sorting_open: false,
4955
+ category_expanded_filters: [],
4956
+ // 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
4957
+ category_selected_filters: [],
4958
+ category_local_filter_cache: [],
4959
+ category_expanded_hierarchical_filters: [],
4960
+ category_scroll_restoration_data: []
4961
+ }));
5184
4962
  const i18n_ = (0, $623202ae203e9e59$export$f091cbac892643a4)(this.#locale_signal[0]);
5185
4963
  const on_category_link_click_ = (e, d)=>{
5186
4964
  if (e.button || e.metaKey || e.ctrlKey) // Not single page navigating because button is not 0 or ctrl/command click
@@ -5205,8 +4983,6 @@ class $068a627cc18f7bb6$export$f34314aa9505732e {
5205
4983
  reset_history_state_: reset_history_state_,
5206
4984
  depict_api_: api ?? new (0, $9ce64f69303c371e$export$e015ed2f2950f2e3)(),
5207
4985
  on_category_link_click_: on_category_link_click_,
5208
- selected_filters_: selected_filters_,
5209
- current_sorting_: current_sorting_,
5210
4986
  slider_arrow_button_: (0, $46MJV$depictaiutilishared.GenericSliderArrowButton)({
5211
4987
  height_: 12,
5212
4988
  width_: 6.46
@@ -5223,7 +4999,7 @@ function $068a627cc18f7bb6$export$e2bf8ce7779e827e({ depict_category: depict_cat
5223
4999
  grid_spacing: grid_spacing.horizontal
5224
5000
  };
5225
5001
  return (0, $f27b0b326e0a87e2$export$23fca46f3143581f)(()=>{
5226
- 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;
5002
+ 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;
5227
5003
  (0, $46MJV$solidjs.onCleanup)(reset_history_state_);
5228
5004
  return (0, $671632478f2a7ce7$export$f7d2f673fc2f091d)({
5229
5005
  tenant_: ()=>depict_category.merchant,
@@ -5577,15 +5353,14 @@ function $2989e355f64e18e1$export$b94867ecbd698f21({ search_field_value_: search
5577
5353
  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
5578
5354
  {
5579
5355
  if (input_field.selectionStart === 0 && input_field.selectionEnd === input_field.value.length) // everything was selected, clear filters on next submit on next input
5580
- input_field.addEventListener("input", (0, $46MJV$depictaiutilishared.catchify)(()=>clear_filters_(false)), // We don't count this as user triggered since it wasn't explicit
5581
- {
5356
+ input_field.addEventListener("input", (0, $46MJV$depictaiutilishared.catchify)(clear_filters_), {
5582
5357
  once: true
5583
5358
  });
5584
5359
  }
5585
5360
  }));
5586
5361
  (0, $46MJV$solidjsweb.addEventListener)(_el$4, "input", (0, $46MJV$depictaiutilishared.catchify)(()=>{
5587
5362
  const { value: value } = input_field;
5588
- if (!disabled_ && !value.length) clear_filters_(false); // if the user clears the whole field, reset filters on next submit
5363
+ if (!disabled_ && !value.length) clear_filters_(); // if the user clears the whole field, reset filters on next submit
5589
5364
  search_field_value_[1](value);
5590
5365
  }), true);
5591
5366
  (0, $46MJV$solidjsweb.addEventListener)(_el$4, "keydown", (0, $46MJV$depictaiutilishared.catchify)((e)=>{
@@ -5611,7 +5386,7 @@ function $2989e355f64e18e1$export$b94867ecbd698f21({ search_field_value_: search
5611
5386
  _el$4.classList.toggle("has-adjacent-back-button", !!on_back_);
5612
5387
  (0, $46MJV$solidjsweb.addEventListener)(_el$5, "click", (0, $46MJV$depictaiutilishared.catchify)(()=>{
5613
5388
  search_field_value_[1]("");
5614
- clear_filters_(true);
5389
+ clear_filters_();
5615
5390
  if (disabled_) return;
5616
5391
  input_field.focus();
5617
5392
  }), true);
@@ -5829,27 +5604,27 @@ function $67b60b572b7b7059$export$b3ad617e9036868(modal_body_style, input_field,
5829
5604
 
5830
5605
 
5831
5606
  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_ }) {
5832
- const [get_selected_filters] = selected_filters_;
5833
- // Possible values:
5834
- // 0 - we should not clear next submit
5835
- // 1 - we should clear next submit due to internal heuristics
5836
- // 2 - we should clear next submit due to EXPLICIT user action (i.e. clear button pressed)
5837
- const clear_filters_next_submit_ = (0, $46MJV$solidjs.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
5607
+ const [get_selected_filters, set_selected_filters] = selected_filters_;
5608
+ const clear_filters_next_submit_ = (0, $46MJV$solidjs.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
5838
5609
  const [get_clear_filters_next_submit, set_clear_filters_next_submit] = clear_filters_next_submit_;
5839
- const clear_filters = (user_triggered)=>set_clear_filters_next_submit(user_triggered ? 2 : 1);
5610
+ const clear_filters = ()=>set_clear_filters_next_submit(true);
5840
5611
  (0, $46MJV$solidjs.createComputed)((0, $46MJV$solidjs.on)(get_selected_filters, ()=>{
5841
5612
  // if the selected filters update, clear the clearing signal
5842
- set_clear_filters_next_submit(0);
5613
+ set_clear_filters_next_submit(false);
5843
5614
  }, {
5844
5615
  defer: true
5845
5616
  }));
5846
5617
  (0, $46MJV$solidjs.createComputed)((0, $46MJV$solidjs.on)(get_search_query, (0, $46MJV$depictaiutilishared.catchify)(()=>{
5847
5618
  // when a query was submitted, clear filters if clear was pressed before
5848
- const clear_value = (0, $46MJV$solidjs.untrack)(get_clear_filters_next_submit);
5849
- if (clear_value) {
5850
- set_clear_filters_next_submit(0);
5619
+ if ((0, $46MJV$solidjs.untrack)(get_clear_filters_next_submit)) {
5620
+ set_clear_filters_next_submit(false);
5621
+ set_selected_filters([]);
5622
+ // also collapse expanded filters in hierarchical filter tree again
5623
+ expanded_hierarchical_filters_[1]([]);
5624
+ // also clear sorting
5625
+ current_sorting_[1](undefined);
5851
5626
  (0, $92e4e7906daa1ff8$export$8895d39404bd2bb1)({
5852
- user_triggered_: clear_value === 2,
5627
+ user_triggered_: true,
5853
5628
  selected_filters_: selected_filters_,
5854
5629
  i18n_: i18n_,
5855
5630
  also_clear_sorting_: true,
@@ -7575,7 +7350,6 @@ function $246e3e89a097f014$export$828dcdd425fd3231(aligner) {
7575
7350
  }
7576
7351
 
7577
7352
 
7578
-
7579
7353
  const $79fbf145b15af988$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="depict plp search"></div>`, 2);
7580
7354
  /**
7581
7355
  * 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.
@@ -7588,7 +7362,7 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
7588
7362
  #market_signal = (0, $46MJV$solidjs.createSignal)();
7589
7363
  #modal_open_signal = (0, $46MJV$solidjs.createSignal)(false);
7590
7364
  static #has_been_constructed = false;
7591
- 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
7365
+ 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
7592
7366
  disable_scrolling_during_modal = true , api: api , bottom_distance_under_modal_: bottom_distance_under_modal_ , render_instant_card: render_instant_card , ...props_on_class }){
7593
7367
  if ($79fbf145b15af988$export$ac6237957a15b3f0.#has_been_constructed) throw new Error("You can only have one instance of DepictSearch");
7594
7368
  Object.assign(this, props_on_class);
@@ -7610,22 +7384,19 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
7610
7384
  target_url.searchParams.set(search_param_name, new_search_query);
7611
7385
  on_navigation(target_url.href);
7612
7386
  });
7613
- const { current_sorting_: current_sorting_ , selected_filters_: selected_filters_ } = (0, $49bdb822440abcec$export$7bcff1eb3eca57d7)();
7614
- const [reset_history_state_, state_] = (0, $92acef13f7f7585b$export$90a2b6b3fb2a1455)({
7615
- selected_filters_: selected_filters_,
7616
- current_sorting_: current_sorting_,
7617
- get_default_values_: ()=>({
7618
- search_field_value: new URLSearchParams(location.search).get(search_query_url_param_name) ?? "",
7619
- search_filters_open: false,
7620
- search_sorting_open: false,
7621
- search_expanded_filters: [],
7622
- // 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
7623
- search_local_filter_cache: [],
7624
- search_expanded_hierarchical_filters: [],
7625
- search_showing_recommendation_rows: (0, $9f81b7ced87aabf2$export$1c8c715550dc689d),
7626
- search_scroll_restoration_data: []
7627
- })
7628
- });
7387
+ const [reset_history_state_, state_] = (0, $0de081f67b6d15b5$export$9862539c89138352)(()=>({
7388
+ search_field_value: new URLSearchParams(location.search).get(search_query_url_param_name) ?? "",
7389
+ search_sorting: undefined,
7390
+ search_filters_open: false,
7391
+ search_sorting_open: false,
7392
+ search_expanded_filters: [],
7393
+ // 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
7394
+ search_selected_filters: [],
7395
+ search_local_filter_cache: [],
7396
+ search_expanded_hierarchical_filters: [],
7397
+ search_showing_recommendation_rows: (0, $9f81b7ced87aabf2$export$1c8c715550dc689d),
7398
+ search_scroll_restoration_data: []
7399
+ }));
7629
7400
  const search_query_updating_blocked_ = (0, $46MJV$solidjs.createSignal)(false);
7630
7401
  const { [search_query_url_param_name]: raw_search_query_signal } = (0, $690220645373c65e$export$2542ffb77b620b02)({
7631
7402
  [search_query_url_param_name]: ""
@@ -7647,9 +7418,9 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
7647
7418
  });
7648
7419
  const i18n_ = (0, $623202ae203e9e59$export$f091cbac892643a4)(this.#locale_signal[0]);
7649
7420
  const clear_filters_on_next_submit_ = (0, $8b282f736ce4f3b8$export$e026af0c7b64ea5f)({
7650
- selected_filters_: selected_filters_,
7421
+ selected_filters_: state_.search_selected_filters,
7651
7422
  search_query_: search_query_signal_,
7652
- current_sorting_: current_sorting_,
7423
+ current_sorting_: state_.search_sorting,
7653
7424
  expanded_hierarchical_filters_: state_.search_expanded_hierarchical_filters,
7654
7425
  i18n_: i18n_,
7655
7426
  local_filter_cache_: state_.search_local_filter_cache
@@ -7672,9 +7443,7 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
7672
7443
  configured_submit_query_: configured_submit_query_,
7673
7444
  search_query_signal_: search_query_signal_,
7674
7445
  i18n_: i18n_,
7675
- search_query_updating_blocked_: search_query_updating_blocked_,
7676
- current_sorting_: current_sorting_,
7677
- selected_filters_: selected_filters_
7446
+ search_query_updating_blocked_: search_query_updating_blocked_
7678
7447
  });
7679
7448
  (0, $33815c5a406b6cc0$export$5162a71f252e6122)();
7680
7449
  (0, $46MJV$depictaiutilishared.catchify)(async ()=>{
@@ -7701,7 +7470,7 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
7701
7470
  min_products_to_fetch_: $79fbf145b15af988$var$min_products_to_fetch_,
7702
7471
  render_instant_card_: render_instant_card,
7703
7472
  render_instant_card_placeholder_: (0, $17c49340edfdbb31$export$ee1733d9a8495996),
7704
- has_sort_or_filters_: (0, $46MJV$solidjs.createMemo)(()=>!!(Object.keys(selected_filters_[0]())?.length || current_sorting_[0]()))
7473
+ has_sort_or_filters_: (0, $46MJV$solidjs.createMemo)(()=>!!(Object.keys(state_.search_selected_filters[0]())?.length || state_.search_sorting[0]()))
7705
7474
  },
7706
7475
  i18n_: i18n_,
7707
7476
  enable_category_suggestions_: enable_category_suggestions,
@@ -7841,7 +7610,7 @@ function $79fbf145b15af988$export$f2dc7e4e4aa11abb({ depict_search: depict_searc
7841
7610
  });
7842
7611
  });
7843
7612
  },
7844
- current_sorting_: shared_properties.current_sorting_,
7613
+ current_sorting_: state_.search_sorting,
7845
7614
  search_filters_open_: state_.search_filters_open,
7846
7615
  search_sorting_open_: state_.search_sorting_open,
7847
7616
  expanded_filters_: state_.search_expanded_filters,
@@ -7852,7 +7621,7 @@ function $79fbf145b15af988$export$f2dc7e4e4aa11abb({ depict_search: depict_searc
7852
7621
  });
7853
7622
  } : false,
7854
7623
  expanded_hierarchical_filters_: state_.search_expanded_hierarchical_filters,
7855
- selected_filters_: shared_properties.selected_filters_,
7624
+ selected_filters_: state_.search_selected_filters,
7856
7625
  showing_recommendation_rows_: state_.search_showing_recommendation_rows,
7857
7626
  scroll_restoration_data_: state_.search_scroll_restoration_data,
7858
7627
  include_input_field_: include_input_field,