@depict-ai/ui 1.4.4 → 1.4.6

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/ES10/index.js CHANGED
@@ -8,7 +8,7 @@ import $8tj43$babelruntimehelpersdefineProperty from "@babel/runtime/helpers/def
8
8
  /*! Depict.ai search and product listing SDK */
9
9
  import { register_es_version } from "../multi_import_deduplicator.mjs";
10
10
  register_es_version("ui", "ES10");
11
- const $8db9a15135765c11$export$83d89fbfd8236492 = "1.4.4";
11
+ const $8db9a15135765c11$export$83d89fbfd8236492 = "1.4.6";
12
12
  function $8e8b179489080711$export$5bad61ecde080b1f() {
13
13
  const {
14
14
  collapse: collapse,
@@ -686,7 +686,7 @@ function $4711a82d08d2021b$export$fecbb157621501bd(_ref) {
686
686
  }
687
687
  (0, $8tj43$delegateEvents)(["click"]);
688
688
  const $6b73914551534ea8$var$_tmpl$ = /*#__PURE__*/(0, $8tj43$template)(`<span class="count"></span>`, 2),
689
- $6b73914551534ea8$var$_tmpl$2 = /*#__PURE__*/(0, $8tj43$template)(`<label class="input-row"><div class="left"><input type="checkbox"><span class="custom-indicator"></span><span class="text"></span></div><!#><!/></label>`, 11);
689
+ $6b73914551534ea8$var$_tmpl$2 = /*#__PURE__*/(0, $8tj43$template)(`<label class="input-row"><div class="left"><input type="checkbox"><span class="custom-indicator"></span><span class="text line-clamp"></span></div><!#><!/></label>`, 11);
690
690
  const $6b73914551534ea8$export$48513f6b9f8ce62d = props => {
691
691
  // It seems like there's no diffing without memos here (since we often just have computations in the getters above that update to the same result often because their dependencies change with unrelated changes often), so put memos here to avoid unneeded DOM changes
692
692
  const count = (0, $8tj43$createMemo)(() => props.count_);
@@ -2808,9 +2808,14 @@ function $63f1f8dbcd07d3b0$var$ActualSolidLayout(props, container_element) {
2808
2808
  // Copy of Layout from utilishared but using solid-js signals instead of async iterable IPNS
2809
2809
  const show_all_rows = (0, $8tj43$createMemo)(() => props.rows === "all");
2810
2810
  const rows_or_empty_object = (0, $8tj43$createMemo)(() => show_all_rows() ? {} : props.rows);
2811
- const button_elements = (0, $cb64b315b25cfc59$export$2f0cbfbb4354bb52)((0, $8tj43$createMemo)(() => rows_or_empty_object().button));
2812
- const have_a_button = (0, $8tj43$createMemo)(() => {
2813
- const button = button_elements();
2811
+ const view_more_button_elements = (0, $cb64b315b25cfc59$export$2f0cbfbb4354bb52)((0, $8tj43$createMemo)(() => rows_or_empty_object().button));
2812
+ const view_less_button_elements = (0, $cb64b315b25cfc59$export$2f0cbfbb4354bb52)((0, $8tj43$createMemo)(() => rows_or_empty_object().view_less_button));
2813
+ const have_a_view_more_button = (0, $8tj43$createMemo)(() => {
2814
+ const button = view_more_button_elements();
2815
+ return !(!button || Array.isArray(button) && !button.length);
2816
+ });
2817
+ const have_a_view_less_button = (0, $8tj43$createMemo)(() => {
2818
+ const button = view_less_button_elements();
2814
2819
  return !(!button || Array.isArray(button) && !button.length);
2815
2820
  });
2816
2821
  const [get_styling, set_styling] = (0, $8tj43$createSignal)();
@@ -2819,22 +2824,38 @@ function $63f1f8dbcd07d3b0$var$ActualSolidLayout(props, container_element) {
2819
2824
  const [get_children_count, set_children_count] = (0, $8tj43$createSignal)(0);
2820
2825
  const update_children_count = () => set_children_count(container_element.children.length);
2821
2826
  const col_styling = (0, $8tj43$createMemo)(() => (0, $8tj43$n_col_styling_with_dist)(selector_beginning, props.grid_spacing, props.cols_at_size, props.layout, props.override_vertical_spacing));
2822
- const default_currently_visible_signal = (0, $8tj43$createSignal)(0); // Keep this signal here so it doesn't change when rows_or_empty_object and I think it's to be expected that the "internal default signal" stays the same
2827
+ const default_currently_visible_signal = (0, $8tj43$createSignal)((0, $8tj43$untrack)(() => {
2828
+ var _rows_or_empty_object;
2829
+ return (_rows_or_empty_object = rows_or_empty_object().start_rows) !== null && _rows_or_empty_object !== void 0 ? _rows_or_empty_object : 1;
2830
+ })); // Keep this signal here, so it doesn't change when rows_or_empty_object and I think it's to be expected that the "internal default signal" stays the same
2823
2831
  const rows_visible_signal = (0, $8tj43$createMemo)(() => rows_or_empty_object().currently_visible || default_currently_visible_signal);
2824
2832
  const get_rows_visible = (0, $8tj43$createMemo)(() => rows_visible_signal()[0]());
2825
2833
  const set_rows_visible = (0, $8tj43$createMemo)(() => rows_visible_signal()[1]);
2826
- const button_class = (0, $8tj43$make_random_classname)();
2827
- const button_container = (0, $8tj43$createMemo)(() => have_a_button() && (() => {
2834
+ const view_more_button_class = (0, $8tj43$make_random_classname)();
2835
+ const view_less_button_class = (0, $8tj43$make_random_classname)();
2836
+ const view_more_button_container = (0, $8tj43$createMemo)(() => have_a_view_more_button() && (() => {
2828
2837
  const _el$2 = (0, $8tj43$getNextElement)($63f1f8dbcd07d3b0$var$_tmpl$);
2829
2838
  (0, $8tj43$addEventListener)(_el$2, "click", (0, $8tj43$catchify)(() => set_rows_visible()(prev => {
2830
- var _rows_or_empty_object;
2831
- return prev + ((_rows_or_empty_object = rows_or_empty_object().rows_per_click) !== null && _rows_or_empty_object !== void 0 ? _rows_or_empty_object : 1);
2839
+ var _rows_or_empty_object2;
2840
+ return prev + ((_rows_or_empty_object2 = rows_or_empty_object().rows_per_click) !== null && _rows_or_empty_object2 !== void 0 ? _rows_or_empty_object2 : 1);
2832
2841
  })), true);
2833
- (0, $8tj43$className)(_el$2, "load-more-container " + button_class);
2842
+ (0, $8tj43$className)(_el$2, "load-more-container ".concat(view_more_button_class));
2834
2843
  (0, $8tj43$insert)(_el$2, () => rows_or_empty_object().button);
2835
2844
  (0, $8tj43$runHydrationEvents)();
2836
2845
  return _el$2;
2837
2846
  })());
2847
+ // We need to have duplicate buttons because which ones is shown depends on the number of rows visible and therefore on the viewport size and therefore on the css media queries
2848
+ const view_less_button_container = (0, $8tj43$createMemo)(() => have_a_view_less_button() && (() => {
2849
+ const _el$3 = (0, $8tj43$getNextElement)($63f1f8dbcd07d3b0$var$_tmpl$);
2850
+ (0, $8tj43$addEventListener)(_el$3, "click", (0, $8tj43$catchify)(() => set_rows_visible()(() => {
2851
+ var _rows_or_empty_object3;
2852
+ return (_rows_or_empty_object3 = rows_or_empty_object().start_rows) !== null && _rows_or_empty_object3 !== void 0 ? _rows_or_empty_object3 : 1;
2853
+ })), true);
2854
+ (0, $8tj43$className)(_el$3, "load-less-container ".concat(view_less_button_class));
2855
+ (0, $8tj43$insert)(_el$3, () => rows_or_empty_object().view_less_button);
2856
+ (0, $8tj43$runHydrationEvents)();
2857
+ return _el$3;
2858
+ })());
2838
2859
  container_element.classList.add(container_class);
2839
2860
  (0, $8tj43$createComputed)(() => {
2840
2861
  // Make sure we don't have more rows visible than max_rows (this could happen by max_rows being decreased)
@@ -2849,10 +2870,6 @@ function $63f1f8dbcd07d3b0$var$ActualSolidLayout(props, container_element) {
2849
2870
  set_styling(() => col_styling);
2850
2871
  return;
2851
2872
  }
2852
- (0, $8tj43$untrack)(() => {
2853
- var _rows_or_empty_object2;
2854
- return set_rows_visible()((_rows_or_empty_object2 = rows_or_empty_object().start_rows) !== null && _rows_or_empty_object2 !== void 0 ? _rows_or_empty_object2 : 1);
2855
- });
2856
2873
  update_children_count();
2857
2874
  const mutation_observer = new MutationObserver((0, $8tj43$catchify)(update_children_count));
2858
2875
  mutation_observer.observe(container_element, {
@@ -2864,33 +2881,36 @@ function $63f1f8dbcd07d3b0$var$ActualSolidLayout(props, container_element) {
2864
2881
  () => (0, $8tj43$createMemo)(() => {
2865
2882
  const {
2866
2883
  rows_per_click: rows_per_click,
2867
- max_rows = -1
2884
+ max_rows = -1,
2885
+ start_rows: start_rows
2868
2886
  } = rows_or_empty_object();
2869
2887
  const rows_visible = get_rows_visible();
2870
2888
  const children_count = get_children_count();
2871
2889
  return col_styling() + props.cols_at_size.map(options => {
2872
- const [, min, max] = options;
2873
- let should_hide_button;
2890
+ const [recs_per_row, min, max] = options;
2891
+ let should_hide_view_more_button;
2874
2892
  let visible_recs;
2875
2893
  if (props.disable_partial_rows) {
2876
2894
  visible_recs = (0, $8tj43$layout_get_visible_recs_without_partial_rows)(rows_visible, children_count, options);
2877
2895
  const visible_recs_next_show_more = (0, $8tj43$layout_get_visible_recs_without_partial_rows)(rows_visible + (rows_per_click || 0),
2878
2896
  // Should this really be zero when we default rows_per_click to 1?
2879
2897
  children_count, options);
2880
- should_hide_button = visible_recs === visible_recs_next_show_more;
2898
+ should_hide_view_more_button = visible_recs === visible_recs_next_show_more;
2881
2899
  } else {
2882
2900
  visible_recs = (0, $8tj43$layout_get_total_rec_amount_for_row)(rows_visible, options);
2883
- should_hide_button = visible_recs >= children_count;
2901
+ should_hide_view_more_button = visible_recs >= children_count;
2884
2902
  }
2885
- const should_hide_button_final = button_class && (should_hide_button || max_rows !== -1 && rows_visible >= max_rows);
2886
- return "".concat((0, $8tj43$layout_media_query_header)(min, max), "{").concat(selector_beginning, ":nth-child(n+").concat(visible_recs + 1, "){display:none}").concat(props.layout == "slider" ? "".concat(selector_beginning, ":nth-child(n+").concat(visible_recs, "){margin-right:0}") : "").concat(should_hide_button_final ? ".depict .".concat(button_class, "{display:none!important}") : "", "}");
2903
+ const should_hide_button_final = should_hide_view_more_button || max_rows !== -1 && rows_visible >= max_rows;
2904
+ // I don't really understand the logic for when the view more button gets hidden so IDK if below is correct, but it works how it should for now
2905
+ const should_hide_view_less_button = !should_hide_view_more_button || start_rows == undefined || rows_visible <= start_rows || children_count <= recs_per_row * start_rows;
2906
+ return "".concat((0, $8tj43$layout_media_query_header)(min, max), "{").concat(selector_beginning, ":nth-child(n+").concat(visible_recs + 1, "){display:none}").concat(props.layout == "slider" ? "".concat(selector_beginning, ":nth-child(n+").concat(visible_recs, "){margin-right:0}") : "").concat(should_hide_button_final ? ".depict .".concat(view_more_button_class, "{display:none!important}") : "").concat(should_hide_view_less_button ? ".depict .".concat(view_less_button_class, "{display:none!important}") : "", "}");
2887
2907
  }).join("");
2888
2908
  }));
2889
2909
  });
2890
- return [container_element, (0, $8tj43$memo)(button_container), (() => {
2891
- const _el$3 = (0, $8tj43$getNextElement)($63f1f8dbcd07d3b0$var$_tmpl$2);
2892
- (0, $8tj43$insert)(_el$3, get_styling);
2893
- return _el$3;
2910
+ return [container_element, (0, $8tj43$memo)(view_more_button_container), (0, $8tj43$memo)(view_less_button_container), (() => {
2911
+ const _el$4 = (0, $8tj43$getNextElement)($63f1f8dbcd07d3b0$var$_tmpl$2);
2912
+ (0, $8tj43$insert)(_el$4, get_styling);
2913
+ return _el$4;
2894
2914
  })()];
2895
2915
  }
2896
2916
  (0, $8tj43$delegateEvents)(["click"]);
@@ -2997,6 +3017,43 @@ function $972f6bce0f9d61be$var$history_state_change(signals, entries, state) {
2997
3017
  }
2998
3018
  });
2999
3019
  }
3020
+ const $68e6625c8d51f847$export$3064e1e8c6513da3 = new Set();
3021
+ let $68e6625c8d51f847$var$has_ran = false;
3022
+ function $68e6625c8d51f847$export$5162a71f252e6122() {
3023
+ if ($68e6625c8d51f847$var$has_ran || typeof history !== "object") return;
3024
+ $68e6625c8d51f847$var$has_ran = true;
3025
+ for (const function_name of ["replaceState", "pushState"]) {
3026
+ if (Object.getOwnPropertyNames(history).includes(function_name)) $68e6625c8d51f847$var$proxy_push_state(function_name, history);
3027
+ $68e6625c8d51f847$var$proxy_push_state(function_name, History.prototype);
3028
+ }
3029
+ }
3030
+ function $68e6625c8d51f847$var$proxy_push_state(function_name, thing) {
3031
+ thing[function_name] = new Proxy(thing[function_name], {
3032
+ apply(target, this_arg, arg_list) {
3033
+ try {
3034
+ if (typeof arg_list[0] == "object") {
3035
+ const cloned_object = {
3036
+ ...arg_list[0]
3037
+ };
3038
+ const old_state = history.state;
3039
+ for (const key in old_state) {
3040
+ if (!$68e6625c8d51f847$var$starts_with_any_prefix(key)) continue;
3041
+ if (!(key in cloned_object)) cloned_object[key] = old_state[key];
3042
+ }
3043
+ arg_list[0] = cloned_object;
3044
+ }
3045
+ } catch (e) {
3046
+ (0, $8tj43$report)([e, "Failed to preserve items in history.state"], "error");
3047
+ }
3048
+ return Reflect.apply(target, this_arg, arg_list);
3049
+ }
3050
+ });
3051
+ }
3052
+ function $68e6625c8d51f847$var$starts_with_any_prefix(key) {
3053
+ for (const prefix of $68e6625c8d51f847$export$3064e1e8c6513da3) {
3054
+ if (key.startsWith(prefix)) return true;
3055
+ }
3056
+ }
3000
3057
  function $bc811d9630f9579b$export$9862539c89138352(_ref) {
3001
3058
  let {
3002
3059
  get_default_values_: get_default_values_,
@@ -3023,6 +3080,8 @@ function $bc811d9630f9579b$export$9862539c89138352(_ref) {
3023
3080
  let [key, value] = _ref3;
3024
3081
  return [key.slice(prefix_.length), value];
3025
3082
  }));
3083
+ (0, $68e6625c8d51f847$export$3064e1e8c6513da3).add(prefix_);
3084
+ // There's intentionally no onCleanup here since we want to preserve the state even if all components (in i.e. react-ui) that use the provider running this are unmounted and the provider is destroyed, since it might be re-created and need the old state (for example for doing scroll restoration)
3026
3085
  return [reset_state, unprefixed_state];
3027
3086
  }
3028
3087
 
@@ -3084,16 +3143,17 @@ var $284849364a6ef73a$var$_get_user_id = /*#__PURE__*/new WeakMap();
3084
3143
  var $284849364a6ef73a$var$_get_session_id = /*#__PURE__*/new WeakMap();
3085
3144
  var $284849364a6ef73a$var$_guard_url_creator_length = /*#__PURE__*/new WeakSet();
3086
3145
  var $284849364a6ef73a$var$_run_url_creator_for_suggest = /*#__PURE__*/new WeakSet();
3087
- var $284849364a6ef73a$var$_run_url_creator_for_rest = /*#__PURE__*/new WeakSet();
3146
+ var $284849364a6ef73a$var$_run_display_transformers_for_rest = /*#__PURE__*/new WeakSet();
3088
3147
  var $284849364a6ef73a$var$_cached_post_request = /*#__PURE__*/new WeakSet();
3089
3148
  class $284849364a6ef73a$export$e015ed2f2950f2e3 {
3090
3149
  constructor(options) {
3091
3150
  $284849364a6ef73a$var$_classPrivateMethodInitSpec(this, $284849364a6ef73a$var$_cached_post_request);
3092
- $284849364a6ef73a$var$_classPrivateMethodInitSpec(this, $284849364a6ef73a$var$_run_url_creator_for_rest);
3151
+ $284849364a6ef73a$var$_classPrivateMethodInitSpec(this, $284849364a6ef73a$var$_run_display_transformers_for_rest);
3093
3152
  $284849364a6ef73a$var$_classPrivateMethodInitSpec(this, $284849364a6ef73a$var$_run_url_creator_for_suggest);
3094
3153
  $284849364a6ef73a$var$_classPrivateMethodInitSpec(this, $284849364a6ef73a$var$_guard_url_creator_length);
3095
3154
  $284849364a6ef73a$var$_classPrivateMethodInitSpec(this, $284849364a6ef73a$var$_get_cache_obj_for_endpoint);
3096
3155
  (0, $8tj43$babelruntimehelpersdefineProperty)(this, "page_url_creator", void 0);
3156
+ (0, $8tj43$babelruntimehelpersdefineProperty)(this, "display_transformers", void 0);
3097
3157
  $284849364a6ef73a$var$_classPrivateFieldInitSpec(this, $284849364a6ef73a$var$_supports_finalization_registry, {
3098
3158
  writable: true,
3099
3159
  value: typeof FinalizationRegistry === "function"
@@ -3132,12 +3192,14 @@ class $284849364a6ef73a$export$e015ed2f2950f2e3 {
3132
3192
  get_metadata: get_metadata,
3133
3193
  get_user_id: _get_user_id2,
3134
3194
  get_session_id: _get_session_id2,
3135
- page_url_creator: page_url_creator
3195
+ page_url_creator: _page_url_creator,
3196
+ display_transformers: _display_transformers
3136
3197
  } = options !== null && options !== void 0 ? options : {};
3137
3198
  (0, $8tj43$babelruntimehelpersclassPrivateFieldSet)(this, $284849364a6ef73a$var$_get_metadata, get_metadata);
3138
3199
  (0, $8tj43$babelruntimehelpersclassPrivateFieldSet)(this, $284849364a6ef73a$var$_get_user_id, _get_user_id2);
3139
3200
  (0, $8tj43$babelruntimehelpersclassPrivateFieldSet)(this, $284849364a6ef73a$var$_get_session_id, _get_session_id2);
3140
- this.page_url_creator = page_url_creator;
3201
+ this.page_url_creator = _page_url_creator;
3202
+ this.display_transformers = _display_transformers;
3141
3203
  }
3142
3204
  async suggest(input_req) {
3143
3205
  var _classPrivateFieldGet4;
@@ -3214,14 +3276,19 @@ function $284849364a6ef73a$var$_guard_url_creator_length2(expected, received) {
3214
3276
  }
3215
3277
  }
3216
3278
  async function $284849364a6ef73a$var$_run_url_creator_for_suggest2(merchant, market, response) {
3217
- if (!this.page_url_creator) return response;
3279
+ var _this$display_transfo;
3280
+ const page_url_creator = this.page_url_creator;
3281
+ const category_transformer = (_this$display_transfo = this.display_transformers) === null || _this$display_transfo === void 0 ? void 0 : _this$display_transfo.categories;
3282
+ if (!page_url_creator && !category_transformer) return response;
3218
3283
  // find category suggestions, run thing with them, and then replace them
3219
3284
  const category_suggestions = response.suggestions.filter(suggestion => suggestion.type === "category");
3220
- const page_urls = await this.page_url_creator({
3221
- type: "categories",
3285
+ const page_urls = await (page_url_creator || category_transformer)({
3222
3286
  market: market,
3223
3287
  merchant: merchant,
3224
- data: [...category_suggestions]
3288
+ data: [...category_suggestions],
3289
+ ...(page_url_creator ? {
3290
+ type: "categories"
3291
+ } : {})
3225
3292
  });
3226
3293
  $284849364a6ef73a$var$_classPrivateMethodGet(this, $284849364a6ef73a$var$_guard_url_creator_length, $284849364a6ef73a$var$_guard_url_creator_length2).call(this, category_suggestions, page_urls);
3227
3294
  while (page_urls.length)
@@ -3229,17 +3296,29 @@ async function $284849364a6ef73a$var$_run_url_creator_for_suggest2(merchant, mar
3229
3296
  Object.defineProperties(category_suggestions.pop(), Object.getOwnPropertyDescriptors(page_urls.pop()));
3230
3297
  return response;
3231
3298
  }
3232
- async function $284849364a6ef73a$var$_run_url_creator_for_rest2(merchant, market, input_data) {
3233
- if (!this.page_url_creator) return input_data;
3299
+ async function $284849364a6ef73a$var$_run_display_transformers_for_rest2(merchant, market, input_data) {
3300
+ const {
3301
+ page_url_creator: page_url_creator,
3302
+ display_transformers: display_transformers
3303
+ } = this;
3304
+ if (!page_url_creator && !display_transformers) return input_data;
3305
+ const product_transformer = display_transformers === null || display_transformers === void 0 ? void 0 : display_transformers.products;
3306
+ const category_transformer = display_transformers === null || display_transformers === void 0 ? void 0 : display_transformers.categories;
3307
+ const content_result_transformer = display_transformers === null || display_transformers === void 0 ? void 0 : display_transformers.contentResults;
3234
3308
  const displays = input_data.displays;
3235
- const breadcrumb = input_data.breadcrumb;
3236
- const quick_links = input_data.quick_links;
3237
- if (displays) {
3238
- const page_urls = await this.page_url_creator({
3239
- type: "products",
3309
+ const {
3310
+ breadcrumb: breadcrumb,
3311
+ quick_links: quick_links,
3312
+ content_search_links: content_search_links
3313
+ } = input_data;
3314
+ if (displays && (page_url_creator || product_transformer)) {
3315
+ const page_urls = await (page_url_creator || product_transformer)({
3240
3316
  merchant: merchant,
3241
3317
  market: market,
3242
- displays: [...input_data.displays]
3318
+ displays: [...input_data.displays],
3319
+ ...(page_url_creator ? {
3320
+ type: "products"
3321
+ } : {})
3243
3322
  });
3244
3323
  $284849364a6ef73a$var$_classPrivateMethodGet(this, $284849364a6ef73a$var$_guard_url_creator_length, $284849364a6ef73a$var$_guard_url_creator_length2).call(this, displays, page_urls);
3245
3324
  for (let i = 0; i < displays.length; i++) {
@@ -3257,19 +3336,30 @@ async function $284849364a6ef73a$var$_run_url_creator_for_rest2(merchant, market
3257
3336
  displays[i] = new_display_or_page_url;
3258
3337
  }
3259
3338
  }
3260
- for (const category_display_array of [breadcrumb, quick_links]) {
3339
+ if (page_url_creator || category_transformer) for (const category_display_array of [breadcrumb, quick_links]) {
3261
3340
  if (!category_display_array) continue;
3262
- const page_urls = await this.page_url_creator({
3263
- type: "categories",
3341
+ const page_urls = await (page_url_creator || category_transformer)({
3264
3342
  merchant: merchant,
3265
3343
  market: market,
3266
- data: [...category_display_array]
3344
+ data: [...category_display_array],
3345
+ ...(page_url_creator ? {
3346
+ type: "categories"
3347
+ } : {})
3267
3348
  });
3268
3349
  $284849364a6ef73a$var$_classPrivateMethodGet(this, $284849364a6ef73a$var$_guard_url_creator_length, $284849364a6ef73a$var$_guard_url_creator_length2).call(this, category_display_array, page_urls);
3269
3350
  for (let i = 0; i < category_display_array.length; i++)
3270
3351
  // Copy over getters so we sneakily can make this reactive
3271
3352
  Object.defineProperties(category_display_array[i], Object.getOwnPropertyDescriptors(page_urls[i]));
3272
3353
  }
3354
+ if (content_search_links !== null && content_search_links !== void 0 && content_search_links.length && content_result_transformer) {
3355
+ const result = await content_result_transformer({
3356
+ merchant: merchant,
3357
+ market: market,
3358
+ data: [...content_search_links]
3359
+ });
3360
+ $284849364a6ef73a$var$_classPrivateMethodGet(this, $284849364a6ef73a$var$_guard_url_creator_length, $284849364a6ef73a$var$_guard_url_creator_length2).call(this, content_search_links, result);
3361
+ input_data.content_search_links = result;
3362
+ }
3273
3363
  return input_data;
3274
3364
  }
3275
3365
  async function $284849364a6ef73a$var$_cached_post_request2(endpoint, input_req, fallback_response) {
@@ -3297,7 +3387,7 @@ async function $284849364a6ef73a$var$_cached_post_request2(endpoint, input_req,
3297
3387
  let result;
3298
3388
  try {
3299
3389
  const unmodified_result = await api_response.json();
3300
- result = await $284849364a6ef73a$var$_classPrivateMethodGet(this, $284849364a6ef73a$var$_run_url_creator_for_rest, $284849364a6ef73a$var$_run_url_creator_for_rest2).call(this, input_req.tenant, input_req.market, unmodified_result);
3390
+ result = await $284849364a6ef73a$var$_classPrivateMethodGet(this, $284849364a6ef73a$var$_run_display_transformers_for_rest, $284849364a6ef73a$var$_run_display_transformers_for_rest2).call(this, input_req.tenant, input_req.market, unmodified_result);
3301
3391
  } catch (e) {
3302
3392
  (0, $8tj43$dwarn)("URL creator or json decoding failed", e);
3303
3393
  break return_successfully;
@@ -3387,12 +3477,11 @@ function $9b5022ae72f56399$var$correct_range_filter_range_once(_ref3) {
3387
3477
  }
3388
3478
  function $43fbdca0f726a34b$export$92f2da32c6e7e7ee(_ref) {
3389
3479
  let {
3390
- search_results_: search_results_,
3480
+ number_: number_,
3391
3481
  i18n_: i18n_
3392
3482
  } = _ref;
3393
3483
  return (0, $8tj43$createMemo)(() => {
3394
- var _search_results_;
3395
- const n_hits = (_search_results_ = search_results_()) === null || _search_results_ === void 0 ? void 0 : _search_results_.n_hits;
3484
+ const n_hits = number_();
3396
3485
  if (isNaN(n_hits)) return "";
3397
3486
  const price_formatting = i18n_.price_formatting_();
3398
3487
  return (0, $8tj43$standard_price_format)(n_hits, 0,
@@ -6027,7 +6116,10 @@ function $4b4b262708b516ee$export$f7d2f673fc2f091d(_ref) {
6027
6116
  const [sort_or_filter_open_, set_sort_or_filter_open_] = (0, $8tj43$createSignal)(false);
6028
6117
  const [desktop_filter_elements_, set_desktop_filter_elements] = (0, $8tj43$createSignal)();
6029
6118
  const formatted_number_of_results_ = (0, $43fbdca0f726a34b$export$92f2da32c6e7e7ee)({
6030
- search_results_: plp_results_,
6119
+ number_: (0, $8tj43$createMemo)(() => {
6120
+ var _plp_results_5;
6121
+ return (_plp_results_5 = plp_results_()) === null || _plp_results_5 === void 0 ? void 0 : _plp_results_5.n_hits;
6122
+ }),
6031
6123
  i18n_: i18n_
6032
6124
  });
6033
6125
  const [sort_and_filter_element_, set_sort_and_filter_element_] = (0, $8tj43$createSignal)();
@@ -6058,8 +6150,8 @@ function $4b4b262708b516ee$export$f7d2f673fc2f091d(_ref) {
6058
6150
  }), _el$4, _co$);
6059
6151
  (0, $8tj43$insert)(_el$, (0, $8tj43$createComponent)((0, $8tj43$Show), {
6060
6152
  get when() {
6061
- var _plp_results_5;
6062
- return ((_plp_results_5 = plp_results_()) === null || _plp_results_5 === void 0 ? void 0 : _plp_results_5.n_hits) === 1;
6153
+ var _plp_results_6;
6154
+ return ((_plp_results_6 = plp_results_()) === null || _plp_results_6 === void 0 ? void 0 : _plp_results_6.n_hits) === 1;
6063
6155
  },
6064
6156
  get fallback() {
6065
6157
  return i18n_.products_();
@@ -6278,8 +6370,8 @@ function $4b4b262708b516ee$export$f7d2f673fc2f091d(_ref) {
6278
6370
  formatted_number_of_results_: formatted_number_of_results_,
6279
6371
  i18n_: i18n_,
6280
6372
  number_of_results_: (0, $8tj43$createMemo)(() => {
6281
- var _plp_results_6;
6282
- return (_plp_results_6 = plp_results_()) === null || _plp_results_6 === void 0 ? void 0 : _plp_results_6.n_hits;
6373
+ var _plp_results_7;
6374
+ return (_plp_results_7 = plp_results_()) === null || _plp_results_7 === void 0 ? void 0 : _plp_results_7.n_hits;
6283
6375
  })
6284
6376
  });
6285
6377
  }
@@ -6301,37 +6393,6 @@ function $4b4b262708b516ee$export$f7d2f673fc2f091d(_ref) {
6301
6393
  return _el$13;
6302
6394
  })()];
6303
6395
  }
6304
- let $68e6625c8d51f847$var$has_ran = false;
6305
- function $68e6625c8d51f847$export$5162a71f252e6122() {
6306
- if ($68e6625c8d51f847$var$has_ran || typeof history !== "object") return;
6307
- $68e6625c8d51f847$var$has_ran = true;
6308
- for (const function_name of ["replaceState", "pushState"]) {
6309
- if (Object.getOwnPropertyNames(history).includes(function_name)) $68e6625c8d51f847$var$proxy_push_state(function_name, history);
6310
- $68e6625c8d51f847$var$proxy_push_state(function_name, History.prototype);
6311
- }
6312
- }
6313
- function $68e6625c8d51f847$var$proxy_push_state(function_name, thing) {
6314
- thing[function_name] = new Proxy(thing[function_name], {
6315
- apply(target, this_arg, arg_list) {
6316
- try {
6317
- if (typeof arg_list[0] == "object") {
6318
- const cloned_object = {
6319
- ...arg_list[0]
6320
- };
6321
- const old_state = history.state;
6322
- for (const key in old_state) {
6323
- if (!key.startsWith("category_") && !key.startsWith("search_")) continue;
6324
- if (!(key in cloned_object)) cloned_object[key] = old_state[key];
6325
- }
6326
- arg_list[0] = cloned_object;
6327
- }
6328
- } catch (e) {
6329
- (0, $8tj43$report)([e, "Failed to preserve items in history.state"], "error");
6330
- }
6331
- return Reflect.apply(target, this_arg, arg_list);
6332
- }
6333
- });
6334
- }
6335
6396
  const $a9c7ba6087881ac2$var$transform_elements = sorted_cols_at_size => {
6336
6397
  const cols_at_size = [];
6337
6398
  for (let i = 0; i < sorted_cols_at_size.length; i++) {
@@ -6674,7 +6735,6 @@ function $f5f54892fd0c7d9f$var$_classApplyDescriptorGet(receiver, descriptor) {
6674
6735
  return descriptor.value;
6675
6736
  }
6676
6737
  // We just pass page_url_creator to DepictAPI when we instantiate it, so don't allow it to be specified if api is already specified
6677
- // on old displays, no page_url_creator can be specified
6678
6738
  /**
6679
6739
  * Type for the private properties that are shared between the different exported search SDK wrapper functions.
6680
6740
  * SDK users are not allowed to change/access these, they're an internal implementation detail.
@@ -6742,6 +6802,7 @@ class $f5f54892fd0c7d9f$export$f34314aa9505732e {
6742
6802
  api: api,
6743
6803
  on_navigation: on_navigation,
6744
6804
  page_url_creator: page_url_creator,
6805
+ display_transformers: display_transformers,
6745
6806
  unique_instance_key_for_state = "",
6746
6807
  query_id_state_key: query_id_state_key,
6747
6808
  ...props_on_class
@@ -6810,8 +6871,10 @@ class $f5f54892fd0c7d9f$export$f34314aa9505732e {
6810
6871
  quicklinks_signal_: (0, $8tj43$createSignal)(),
6811
6872
  i18n_: i18n_,
6812
6873
  reset_history_state_: reset_history_state_,
6874
+ // @ts-ignore
6813
6875
  depict_api_: api !== null && api !== void 0 ? api : new (0, $284849364a6ef73a$export$e015ed2f2950f2e3)({
6814
- page_url_creator: page_url_creator
6876
+ page_url_creator: page_url_creator,
6877
+ display_transformers: display_transformers
6815
6878
  }),
6816
6879
  router_: (0, $8tj43$babelruntimehelpersclassPrivateFieldGet)(this, $f5f54892fd0c7d9f$var$_router),
6817
6880
  selected_filters_: selected_filters_,
@@ -7466,13 +7529,12 @@ function $8ef6232475d44150$export$7de92c4c2205ebf3(_ref) {
7466
7529
  });
7467
7530
  }
7468
7531
  function $8ef6232475d44150$var$make_state_saved_rows(_ref3, i18n_) {
7469
- var _untrack;
7470
7532
  let [get_showing_recommendation_rows, set_showing_recommendation_rows] = _ref3;
7471
- const currently_visible = (0, $8tj43$createSignal)(0); // this number shouldn't matter for anything except typing
7533
+ const currently_visible = (0, $8tj43$createSignal)((0, $8tj43$untrack)(get_showing_recommendation_rows));
7472
7534
  const [get_currently_visible, set_currently_visible] = currently_visible;
7473
7535
  const rows = {
7474
7536
  currently_visible: currently_visible,
7475
- start_rows: (_untrack = (0, $8tj43$untrack)(get_showing_recommendation_rows)) !== null && _untrack !== void 0 ? _untrack : $8ef6232475d44150$export$1c8c715550dc689d,
7537
+ start_rows: $8ef6232475d44150$export$1c8c715550dc689d,
7476
7538
  rows_per_click: 3,
7477
7539
  button: (() => {
7478
7540
  const _el$7 = (0, $8tj43$getNextElement)($8ef6232475d44150$var$_tmpl$2);
@@ -7645,7 +7707,7 @@ const $b65f93acbf91da56$export$27b710c08412a7ad = obj => {
7645
7707
  return Object.fromEntries(Object.keys(obj).map(key => [key, obj[key]()]));
7646
7708
  };
7647
7709
  const $9a693c7e832d3f18$var$_tmpl$ = /*#__PURE__*/(0, $8tj43$template)(`<span class="orig price"><!#><!/><!#><!/><!#><!/></span>`, 8),
7648
- $9a693c7e832d3f18$var$_tmpl$2 = /*#__PURE__*/(0, $8tj43$template)(`<a class="instant-card"><div class="img-part"></div><div class="right-part"><div class="title-brand-tagline"><span class="brand"></span><span class="title"></span><!#><!/></div><div class="price-container"><!#><!/><span class="price"><!#><!/><!#><!/><!#><!/></span></div></div></a>`, 26),
7710
+ $9a693c7e832d3f18$var$_tmpl$2 = /*#__PURE__*/(0, $8tj43$template)(`<a class="instant-card"><div class="img-part"></div><div class="right-part"><div class="title-brand-tagline"><span class="brand"></span><span class="title line-clamp"></span><!#><!/></div><div class="price-container"><!#><!/><span class="price"><!#><!/><!#><!/><!#><!/></span></div></div></a>`, 26),
7649
7711
  $9a693c7e832d3f18$var$_tmpl$3 = /*#__PURE__*/(0, $8tj43$template)(`<div class="tagline"></div>`, 2);
7650
7712
  const $9a693c7e832d3f18$export$b05c0ae390cf3e06 = (display_or_variant_container, _ref, router_) => {
7651
7713
  let {
@@ -7783,9 +7845,11 @@ function $f7414b949aeabc90$export$62f101a8aa597bf8(_ref) {
7783
7845
  render_instant_card_placeholder_: render_instant_card_placeholder_,
7784
7846
  min_products_to_fetch_: min_products_to_fetch_,
7785
7847
  has_sort_or_filters_: has_sort_or_filters_,
7786
- set_num_results_accessor_: set_num_results_accessor_,
7848
+ set_total_num_results_accessor_: set_total_num_results_accessor_,
7787
7849
  i18n_: i18n_,
7788
- router_: router_
7850
+ router_: router_,
7851
+ set_modal_search_results_: set_modal_search_results_,
7852
+ content_search_enabled_: content_search_enabled_
7789
7853
  } = _ref;
7790
7854
  const max_cards = 4;
7791
7855
  const [read_current_instant_query, write_current_instant_query] = (0, $8tj43$createSignal)("");
@@ -7810,13 +7874,23 @@ function $f7414b949aeabc90$export$62f101a8aa597bf8(_ref) {
7810
7874
  ...variable_data
7811
7875
  });
7812
7876
  }));
7813
- set_num_results_accessor_(() => (0, $43fbdca0f726a34b$export$92f2da32c6e7e7ee)({
7814
- search_results_: search_results,
7877
+ // Maybe we should move this createResoure out of this component, on the other hand it bloats the parent component and if it fails it takes more than needed with it, so I think writing the content results from here is better
7878
+ // This is for the press-enter-to-instant-content-result feature which gets called from Autocomplete.tsx
7879
+ set_modal_search_results_(() => search_results);
7880
+ (0, $8tj43$onCleanup)(() => set_modal_search_results_(undefined)); // for consistency, in case this component crashes
7881
+ set_total_num_results_accessor_(() => (0, $43fbdca0f726a34b$export$92f2da32c6e7e7ee)({
7882
+ number_: (0, $8tj43$createMemo)(() => {
7883
+ var _search_results, _search_results2, _search_results2$cont;
7884
+ const hits = (_search_results = search_results()) === null || _search_results === void 0 ? void 0 : _search_results.n_hits;
7885
+ const content_results = (_search_results2 = search_results()) === null || _search_results2 === void 0 ? void 0 : (_search_results2$cont = _search_results2.content_search_links) === null || _search_results2$cont === void 0 ? void 0 : _search_results2$cont.length;
7886
+ if (!content_results || !content_search_enabled_()) return hits;
7887
+ return (hits !== null && hits !== void 0 ? hits : 0) + content_results;
7888
+ }),
7815
7889
  i18n_: i18n_
7816
7890
  }));
7817
7891
  const sliced_displays = (0, $8tj43$createMemo)(() => {
7818
- var _search_results, _search_results$displ;
7819
- return (_search_results = search_results()) === null || _search_results === void 0 ? void 0 : (_search_results$displ = _search_results.displays) === null || _search_results$displ === void 0 ? void 0 : _search_results$displ.slice(0, max_cards);
7892
+ var _search_results3, _search_results3$disp;
7893
+ return (_search_results3 = search_results()) === null || _search_results3 === void 0 ? void 0 : (_search_results3$disp = _search_results3.displays) === null || _search_results3$disp === void 0 ? void 0 : _search_results3$disp.slice(0, max_cards);
7820
7894
  });
7821
7895
  let placeholder;
7822
7896
  return (() => {
@@ -7828,8 +7902,8 @@ function $f7414b949aeabc90$export$62f101a8aa597bf8(_ref) {
7828
7902
  },
7829
7903
  get fallback() {
7830
7904
  return (0, $8tj43$createMemo)(() => {
7831
- var _search_results2;
7832
- if (Array.isArray((_search_results2 = search_results()) === null || _search_results2 === void 0 ? void 0 : _search_results2.displays))
7905
+ var _search_results4;
7906
+ if (Array.isArray((_search_results4 = search_results()) === null || _search_results4 === void 0 ? void 0 : _search_results4.displays))
7833
7907
  // remove placeholders if we have a response but no results
7834
7908
  return undefined;
7835
7909
  return new Array(max_cards).fill(1).map(() => (placeholder || (placeholder = render_instant_card_placeholder_())).cloneNode(true));
@@ -7917,7 +7991,7 @@ function $6d95ef50ee01d5a1$export$5d2caaa6b530761c() {
7917
7991
  return (0, $8tj43$getNextElement)($6d95ef50ee01d5a1$var$_tmpl$);
7918
7992
  }
7919
7993
  const $494c9ad553139dbc$var$_tmpl$ = /*#__PURE__*/(0, $8tj43$template)(`<div class="previous-searches"><h2 class="text"></h2><div class="list"></div></div>`, 6),
7920
- $494c9ad553139dbc$var$_tmpl$2 = /*#__PURE__*/(0, $8tj43$template)(`<a class="item"><div class="left"><!#><!/><span></span></div><button class="delete"></button></a>`, 10);
7994
+ $494c9ad553139dbc$var$_tmpl$2 = /*#__PURE__*/(0, $8tj43$template)(`<a class="item"><div class="left"><!#><!/><span class="line-clamp"></span></div><button class="delete"></button></a>`, 10);
7921
7995
  function $494c9ad553139dbc$export$a146ac6fa8346a25(_ref) {
7922
7996
  let {
7923
7997
  text_: text_,
@@ -8003,15 +8077,18 @@ function $494c9ad553139dbc$export$a146ac6fa8346a25(_ref) {
8003
8077
  return ((_read_selected_index_ = read_selected_index_()) === null || _read_selected_index_ === void 0 ? void 0 : _read_selected_index_[0]) === 0 && ((_read_selected_index_2 = read_selected_index_()) === null || _read_selected_index_2 === void 0 ? void 0 : _read_selected_index_2[1]) === index;
8004
8078
  })(),
8005
8079
  _v$2 = href(),
8006
- _v$3 = i18n_.previous_searches_delete_entry_from_history_();
8080
+ _v$3 = item(),
8081
+ _v$4 = i18n_.previous_searches_delete_entry_from_history_();
8007
8082
  _v$ !== _p$._v$ && _el$4.classList.toggle("selected", _p$._v$ = _v$);
8008
8083
  _v$2 !== _p$._v$2 && (0, $8tj43$setAttribute)(_el$4, "href", _p$._v$2 = _v$2);
8009
- _v$3 !== _p$._v$3 && (0, $8tj43$setAttribute)(_el$9, "title", _p$._v$3 = _v$3);
8084
+ _v$3 !== _p$._v$3 && (0, $8tj43$setAttribute)(_el$6, "title", _p$._v$3 = _v$3);
8085
+ _v$4 !== _p$._v$4 && (0, $8tj43$setAttribute)(_el$9, "title", _p$._v$4 = _v$4);
8010
8086
  return _p$;
8011
8087
  }, {
8012
8088
  _v$: undefined,
8013
8089
  _v$2: undefined,
8014
- _v$3: undefined
8090
+ _v$3: undefined,
8091
+ _v$4: undefined
8015
8092
  });
8016
8093
  return _el$4;
8017
8094
  })();
@@ -8081,18 +8158,38 @@ function $02b6641aa50ce528$export$ba17c5b7e6dda39f(_ref) {
8081
8158
  const _el$2 = (0, $8tj43$getNextElement)($02b6641aa50ce528$var$_tmpl$2);
8082
8159
  (0, $8tj43$className)(_el$2, class_);
8083
8160
  (0, $8tj43$insert)(_el$2, text_itself);
8084
- (0, $8tj43$effect)(() => _el$2.classList.toggle("has-history-match", !!get_has_highlighted()));
8161
+ (0, $8tj43$effect)(_p$ => {
8162
+ const _v$ = !!get_has_highlighted(),
8163
+ _v$2 = whole_text_to_display_memo() /* for when line-clamped, users can see full text on hover */;
8164
+ _v$ !== _p$._v$ && _el$2.classList.toggle("has-history-match", _p$._v$ = _v$);
8165
+ _v$2 !== _p$._v$2 && (0, $8tj43$setAttribute)(_el$2, "title", _p$._v$2 = _v$2);
8166
+ return _p$;
8167
+ }, {
8168
+ _v$: undefined,
8169
+ _v$2: undefined
8170
+ });
8085
8171
  return _el$2;
8086
8172
  })();
8087
8173
  }
8174
+ const $3c5e15c6ee4227a9$var$_tmpl$ = /*#__PURE__*/(0, $8tj43$template)(`<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 256 256"><path d="M56 26.455a13.71 13.71 0 0 0-9.578 3.967A13.71 13.71 0 0 0 42.455 40v176a13.71 13.71 0 0 0 3.967 9.578A13.71 13.71 0 0 0 56 229.545h144A13.71 13.71 0 0 0 213.545 216V88a2.456 2.456 0 0 1 0-.002c.001-1.452-.597-2.895-1.623-3.922l-55.998-55.998a5.61 5.61 0 0 0-3.922-1.623 2.456 2.456 0 0 1-.002 0zm0 11.09h88A2.456 2.456 0 0 1 146.455 40v48c0 2.903 2.642 5.545 5.545 5.545h48A2.456 2.456 0 0 1 202.455 96v120a2.456 2.456 0 0 1-2.455 2.455H56A2.456 2.456 0 0 1 53.545 216V40A2.456 2.456 0 0 1 56 37.545zm103.061 11.498a2.456 2.456 0 0 1 2.676.531l28.689 28.689a2.456 2.456 0 0 1-1.736 4.191H160A2.456 2.456 0 0 1 157.545 80V51.311a2.456 2.456 0 0 1 1.516-2.268zM96 130.455c-2.903 0-5.545 2.642-5.545 5.545s2.642 5.545 5.545 5.545h64c2.903 0 5.545-2.642 5.545-5.545s-2.642-5.545-5.545-5.545zm0 32c-2.903 0-5.545 2.642-5.545 5.545s2.642 5.545 5.545 5.545h64c2.903 0 5.545-2.642 5.545-5.545s-2.642-5.545-5.545-5.545z"></path></svg>`, 4);
8175
+ function $3c5e15c6ee4227a9$export$605674723bcc715c() {
8176
+ let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
8177
+ return (() => {
8178
+ const _el$ = (0, $8tj43$getNextElement)($3c5e15c6ee4227a9$var$_tmpl$);
8179
+ (0, $8tj43$spread)(_el$, props, true, true);
8180
+ (0, $8tj43$runHydrationEvents)();
8181
+ return _el$;
8182
+ })();
8183
+ }
8088
8184
  const $40dd3f46f55d62ba$var$_tmpl$ = /*#__PURE__*/(0, $8tj43$template)(`<a class="suggestion"></a>`, 2),
8089
8185
  $40dd3f46f55d62ba$var$_tmpl$2 = /*#__PURE__*/(0, $8tj43$template)(`<div class="search-icon"></div>`, 2),
8090
8186
  $40dd3f46f55d62ba$var$_tmpl$3 = /*#__PURE__*/(0, $8tj43$template)(`<span class="type"></span>`, 2),
8091
8187
  $40dd3f46f55d62ba$var$_tmpl$4 = /*#__PURE__*/(0, $8tj43$template)(`<div><!#><!/><span class="value"></span></div>`, 6),
8092
- $40dd3f46f55d62ba$var$_tmpl$5 = /*#__PURE__*/(0, $8tj43$template)(`<h2 class="text"></h2>`, 2),
8093
- $40dd3f46f55d62ba$var$_tmpl$6 = /*#__PURE__*/(0, $8tj43$template)(`<div class="suggestion-container query"><!#><!/><!#><!/></div>`, 6),
8094
- $40dd3f46f55d62ba$var$_tmpl$7 = /*#__PURE__*/(0, $8tj43$template)(`<div class="suggestion-container page"></div>`, 2),
8095
- $40dd3f46f55d62ba$var$_tmpl$8 = /*#__PURE__*/(0, $8tj43$template)(`<div class="suggestions"><!#><!/><!#><!/><!#><!/></div>`, 8);
8188
+ $40dd3f46f55d62ba$var$_tmpl$5 = /*#__PURE__*/(0, $8tj43$template)(`<div class="with-icon"><!#><!/><!#><!/></div>`, 6),
8189
+ $40dd3f46f55d62ba$var$_tmpl$6 = /*#__PURE__*/(0, $8tj43$template)(`<h2 class="text"></h2>`, 2),
8190
+ $40dd3f46f55d62ba$var$_tmpl$7 = /*#__PURE__*/(0, $8tj43$template)(`<div class="suggestion-container query"><!#><!/><!#><!/></div>`, 6),
8191
+ $40dd3f46f55d62ba$var$_tmpl$8 = /*#__PURE__*/(0, $8tj43$template)(`<div class="suggestion-container page"></div>`, 2),
8192
+ $40dd3f46f55d62ba$var$_tmpl$9 = /*#__PURE__*/(0, $8tj43$template)(`<div class="suggestions"><!#><!/><!#><!/><!#><!/></div>`, 8);
8096
8193
  function $40dd3f46f55d62ba$export$e872e2339fb04a7f(_ref) {
8097
8194
  let {
8098
8195
  suggestion_memo_: suggestion_memo_,
@@ -8106,7 +8203,8 @@ function $40dd3f46f55d62ba$export$e872e2339fb04a7f(_ref) {
8106
8203
  include_category_suggestions_: include_category_suggestions_,
8107
8204
  searching_for_value_: searching_for_value_,
8108
8205
  router_: router_,
8109
- submit_query_: submit_query_
8206
+ submit_query_: submit_query_,
8207
+ get_content_results_: get_content_results_
8110
8208
  } = _ref;
8111
8209
  const queries_memo = (0, $8tj43$createMemo)(() => suggestion_memo_().filter(_ref2 => {
8112
8210
  let {
@@ -8117,12 +8215,18 @@ function $40dd3f46f55d62ba$export$e872e2339fb04a7f(_ref) {
8117
8215
  } // don't show the ones we already show from the history
8118
8216
  ));
8119
8217
 
8120
- const not_queries_memo = (0, $8tj43$createMemo)(() => suggestion_memo_().filter(_ref3 => {
8121
- let {
8122
- type: type
8123
- } = _ref3;
8124
- return type !== (0, $7cd4d275a9f8d600$export$3cf9497e790da491);
8125
- }));
8218
+ const not_queries_memo = (0, $8tj43$createMemo)(() => {
8219
+ // For the section that shows categories and content results
8220
+ // We want to limit to 3 items, and we want to show the categories first
8221
+ const content_results = get_content_results_() || [];
8222
+ const from_suggest_request = include_category_suggestions_ ? suggestion_memo_().filter(_ref3 => {
8223
+ let {
8224
+ type: type
8225
+ } = _ref3;
8226
+ return type !== (0, $7cd4d275a9f8d600$export$3cf9497e790da491);
8227
+ }) : [];
8228
+ return [...from_suggest_request.slice(0, content_results.length ? 2 : 3), ...content_results.slice(0, 1)];
8229
+ });
8126
8230
  const render_entry = function (input_obj, autocomplete_data_index, index) {
8127
8231
  let is_history = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
8128
8232
  const is_query = (0, $8tj43$createMemo)(() => input_obj().type === (0, $7cd4d275a9f8d600$export$3cf9497e790da491));
@@ -8132,6 +8236,10 @@ function $40dd3f46f55d62ba$export$e872e2339fb04a7f(_ref) {
8132
8236
  url_transformer_: url_transformer_
8133
8237
  }) : undefined);
8134
8238
  const href = (0, $8tj43$createMemo)(() => is_query() ? href_with_changed_params_accessor()() : input_obj().page_url);
8239
+ const is_selected = (0, $8tj43$createMemo)(() => {
8240
+ var _read_selected_index_, _read_selected_index_2;
8241
+ return ((_read_selected_index_ = read_selected_index_()) === null || _read_selected_index_ === void 0 ? void 0 : _read_selected_index_[0]) === autocomplete_data_index && ((_read_selected_index_2 = read_selected_index_()) === null || _read_selected_index_2 === void 0 ? void 0 : _read_selected_index_2[1]) === index;
8242
+ });
8135
8243
  return (() => {
8136
8244
  const _el$ = (0, $8tj43$getNextElement)($40dd3f46f55d62ba$var$_tmpl$);
8137
8245
  (0, $8tj43$use)(element => element.addEventListener("click", (0, $8tj43$catchify)(ev => {
@@ -8145,7 +8253,7 @@ function $40dd3f46f55d62ba$export$e872e2339fb04a7f(_ref) {
8145
8253
  return;
8146
8254
  }
8147
8255
  router_.navigate_.go_to_({
8148
- new_url_: input_obj().page_url,
8256
+ new_url_: href(),
8149
8257
  is_replace_: false,
8150
8258
  event_: ev
8151
8259
  });
@@ -8167,20 +8275,20 @@ function $40dd3f46f55d62ba$export$e872e2339fb04a7f(_ref) {
8167
8275
  return (0, $8tj43$createComponent)((0, $6d95ef50ee01d5a1$export$5d2caaa6b530761c), {});
8168
8276
  }
8169
8277
  }), (0, $8tj43$createComponent)((0, $02b6641aa50ce528$export$ba17c5b7e6dda39f), {
8170
- class_: "value",
8278
+ class_: "value line-clamp",
8171
8279
  get whole_text_to_display_() {
8172
8280
  return (0, $8tj43$createMemo)(() => input_obj().title);
8173
8281
  },
8174
8282
  searching_for_value_: searching_for_value_
8175
8283
  })] : [(0, $8tj43$memo)((() => {
8176
- const _c$2 = (0, $8tj43$memo)(() => typeof input_obj().parent_title === "string");
8284
+ const _c$2 = (0, $8tj43$memo)(() => typeof input_obj() /* this is a harmless lie */.parent_title === "string");
8177
8285
  return () => _c$2() ? (() => {
8178
8286
  const _el$4 = (0, $8tj43$getNextElement)($40dd3f46f55d62ba$var$_tmpl$4),
8179
8287
  _el$6 = _el$4.firstChild,
8180
8288
  [_el$7, _co$] = (0, $8tj43$getNextMarker)(_el$6.nextSibling),
8181
8289
  _el$5 = _el$7.nextSibling;
8182
8290
  (0, $8tj43$insert)(_el$4, (0, $8tj43$createComponent)((0, $02b6641aa50ce528$export$ba17c5b7e6dda39f), {
8183
- class_: "category",
8291
+ class_: "category line-clamp",
8184
8292
  get whole_text_to_display_() {
8185
8293
  return (0, $8tj43$createMemo)(() => input_obj().title);
8186
8294
  },
@@ -8188,16 +8296,38 @@ function $40dd3f46f55d62ba$export$e872e2339fb04a7f(_ref) {
8188
8296
  }), _el$7, _co$);
8189
8297
  (0, $8tj43$insert)(_el$5, () => input_obj().parent_title);
8190
8298
  return _el$4;
8191
- })() : (0, $8tj43$createComponent)((0, $02b6641aa50ce528$export$ba17c5b7e6dda39f), {
8192
- class_: "category",
8193
- get whole_text_to_display_() {
8194
- return (0, $8tj43$createMemo)(() => input_obj().title);
8195
- },
8196
- searching_for_value_: searching_for_value_
8197
- });
8299
+ })() : (() => {
8300
+ const _c$3 = (0, $8tj43$memo)(() => input_obj().type === "content");
8301
+ return () => _c$3() ? (() => {
8302
+ const _el$8 = (0, $8tj43$getNextElement)($40dd3f46f55d62ba$var$_tmpl$5),
8303
+ _el$9 = _el$8.firstChild,
8304
+ [_el$10, _co$2] = (0, $8tj43$getNextMarker)(_el$9.nextSibling),
8305
+ _el$11 = _el$10.nextSibling,
8306
+ [_el$12, _co$3] = (0, $8tj43$getNextMarker)(_el$11.nextSibling);
8307
+ (0, $8tj43$insert)(_el$8, (0, $8tj43$createComponent)((0, $3c5e15c6ee4227a9$export$605674723bcc715c), {
8308
+ width: "16",
8309
+ height: "16"
8310
+ }), _el$10, _co$2);
8311
+ (0, $8tj43$insert)(_el$8, (0, $8tj43$createComponent)((0, $02b6641aa50ce528$export$ba17c5b7e6dda39f), {
8312
+ class_: "content line-clamp",
8313
+ get whole_text_to_display_() {
8314
+ return (0, $8tj43$createMemo)(() => input_obj().title);
8315
+ },
8316
+ searching_for_value_: searching_for_value_
8317
+ }), _el$12, _co$3);
8318
+ return _el$8;
8319
+ })() : (0, $8tj43$createComponent)((0, $02b6641aa50ce528$export$ba17c5b7e6dda39f), {
8320
+ class_: "category line-clamp",
8321
+ get whole_text_to_display_() {
8322
+ return (0, $8tj43$createMemo)(() => input_obj().title);
8323
+ },
8324
+ searching_for_value_: searching_for_value_
8325
+ });
8326
+ })();
8198
8327
  })()), (() => {
8199
8328
  const _el$3 = (0, $8tj43$getNextElement)($40dd3f46f55d62ba$var$_tmpl$3);
8200
8329
  (0, $8tj43$insert)(_el$3, (0, $8tj43$createMemo)(() => {
8330
+ if (input_obj().type === "content") return i18n_.content_();
8201
8331
  if (input_obj().category_type === "BRAND") return i18n_.brand_();
8202
8332
  return i18n_.category_();
8203
8333
  }));
@@ -8206,10 +8336,7 @@ function $40dd3f46f55d62ba$export$e872e2339fb04a7f(_ref) {
8206
8336
  })());
8207
8337
  (0, $8tj43$effect)(_p$ => {
8208
8338
  const _v$ = {
8209
- selected: (0, $8tj43$createMemo)(() => {
8210
- var _read_selected_index_, _read_selected_index_2;
8211
- return ((_read_selected_index_ = read_selected_index_()) === null || _read_selected_index_ === void 0 ? void 0 : _read_selected_index_[0]) === autocomplete_data_index && ((_read_selected_index_2 = read_selected_index_()) === null || _read_selected_index_2 === void 0 ? void 0 : _read_selected_index_2[1]) === index;
8212
- })(),
8339
+ selected: is_selected(),
8213
8340
  history: is_history,
8214
8341
  ["type-" + input_obj().type]: true
8215
8342
  },
@@ -8236,8 +8363,8 @@ function $40dd3f46f55d62ba$export$e872e2339fb04a7f(_ref) {
8236
8363
  };
8237
8364
  const should_show_previous_searches_in_query_part = (0, $8tj43$createMemo)(() => !on_previous_searches_page_());
8238
8365
  const should_show_at_all = (0, $8tj43$createMemo)(() => {
8239
- var _suggestion_memo_;
8240
- return ((_suggestion_memo_ = suggestion_memo_()) === null || _suggestion_memo_ === void 0 ? void 0 : _suggestion_memo_.length) || should_show_previous_searches_in_query_part() && filtered_previous_searches_().length;
8366
+ var _suggestion_memo_, _get_content_results_;
8367
+ return ((_suggestion_memo_ = suggestion_memo_()) === null || _suggestion_memo_ === void 0 ? void 0 : _suggestion_memo_.length) || should_show_previous_searches_in_query_part() && filtered_previous_searches_().length || ((_get_content_results_ = get_content_results_()) === null || _get_content_results_ === void 0 ? void 0 : _get_content_results_.length);
8241
8368
  });
8242
8369
  const should_show_query_part = (0, $8tj43$createMemo)(() => queries_memo().length || filtered_previous_searches_().length);
8243
8370
  return (0, $8tj43$createComponent)((0, $8tj43$Show), {
@@ -8245,34 +8372,34 @@ function $40dd3f46f55d62ba$export$e872e2339fb04a7f(_ref) {
8245
8372
  return should_show_at_all();
8246
8373
  },
8247
8374
  get children() {
8248
- const _el$8 = (0, $8tj43$getNextElement)($40dd3f46f55d62ba$var$_tmpl$8),
8249
- _el$16 = _el$8.firstChild,
8250
- [_el$17, _co$4] = (0, $8tj43$getNextMarker)(_el$16.nextSibling),
8251
- _el$18 = _el$17.nextSibling,
8252
- [_el$19, _co$5] = (0, $8tj43$getNextMarker)(_el$18.nextSibling),
8253
- _el$20 = _el$19.nextSibling,
8254
- [_el$21, _co$6] = (0, $8tj43$getNextMarker)(_el$20.nextSibling);
8255
- (0, $8tj43$insert)(_el$8, (0, $8tj43$createComponent)((0, $8tj43$Show), {
8375
+ const _el$13 = (0, $8tj43$getNextElement)($40dd3f46f55d62ba$var$_tmpl$9),
8376
+ _el$21 = _el$13.firstChild,
8377
+ [_el$22, _co$6] = (0, $8tj43$getNextMarker)(_el$21.nextSibling),
8378
+ _el$23 = _el$22.nextSibling,
8379
+ [_el$24, _co$7] = (0, $8tj43$getNextMarker)(_el$23.nextSibling),
8380
+ _el$25 = _el$24.nextSibling,
8381
+ [_el$26, _co$8] = (0, $8tj43$getNextMarker)(_el$25.nextSibling);
8382
+ (0, $8tj43$insert)(_el$13, (0, $8tj43$createComponent)((0, $8tj43$Show), {
8256
8383
  get when() {
8257
8384
  return on_previous_searches_page_();
8258
8385
  },
8259
8386
  get children() {
8260
- const _el$9 = (0, $8tj43$getNextElement)($40dd3f46f55d62ba$var$_tmpl$5);
8261
- (0, $8tj43$insert)(_el$9, () => i18n_.suggestions_());
8262
- return _el$9;
8387
+ const _el$14 = (0, $8tj43$getNextElement)($40dd3f46f55d62ba$var$_tmpl$6);
8388
+ (0, $8tj43$insert)(_el$14, () => i18n_.suggestions_());
8389
+ return _el$14;
8263
8390
  }
8264
- }), _el$17, _co$4);
8265
- (0, $8tj43$insert)(_el$8, (0, $8tj43$createComponent)((0, $8tj43$Show), {
8391
+ }), _el$22, _co$6);
8392
+ (0, $8tj43$insert)(_el$13, (0, $8tj43$createComponent)((0, $8tj43$Show), {
8266
8393
  get when() {
8267
8394
  return should_show_query_part();
8268
8395
  },
8269
8396
  get children() {
8270
- const _el$10 = (0, $8tj43$getNextElement)($40dd3f46f55d62ba$var$_tmpl$6),
8271
- _el$11 = _el$10.firstChild,
8272
- [_el$12, _co$2] = (0, $8tj43$getNextMarker)(_el$11.nextSibling),
8273
- _el$13 = _el$12.nextSibling,
8274
- [_el$14, _co$3] = (0, $8tj43$getNextMarker)(_el$13.nextSibling);
8275
- (0, $8tj43$insert)(_el$10, (0, $8tj43$createComponent)((0, $8tj43$Show), {
8397
+ const _el$15 = (0, $8tj43$getNextElement)($40dd3f46f55d62ba$var$_tmpl$7),
8398
+ _el$16 = _el$15.firstChild,
8399
+ [_el$17, _co$4] = (0, $8tj43$getNextMarker)(_el$16.nextSibling),
8400
+ _el$18 = _el$17.nextSibling,
8401
+ [_el$19, _co$5] = (0, $8tj43$getNextMarker)(_el$18.nextSibling);
8402
+ (0, $8tj43$insert)(_el$15, (0, $8tj43$createComponent)((0, $8tj43$Show), {
8276
8403
  get when() {
8277
8404
  return should_show_previous_searches_in_query_part();
8278
8405
  },
@@ -8295,8 +8422,8 @@ function $40dd3f46f55d62ba$export$e872e2339fb04a7f(_ref) {
8295
8422
  });
8296
8423
  })();
8297
8424
  }
8298
- }), _el$12, _co$2);
8299
- (0, $8tj43$insert)(_el$10, () => {
8425
+ }), _el$17, _co$4);
8426
+ (0, $8tj43$insert)(_el$15, () => {
8300
8427
  const index_in_autocomplete = 2;
8301
8428
  set_list_until_cleanup(queries_memo, index_in_autocomplete);
8302
8429
  return (0, $8tj43$createComponent)((0, $8tj43$Index), {
@@ -8305,18 +8432,18 @@ function $40dd3f46f55d62ba$export$e872e2339fb04a7f(_ref) {
8305
8432
  },
8306
8433
  children: (item, index) => render_entry(item, index_in_autocomplete, index)
8307
8434
  });
8308
- }, _el$14, _co$3);
8309
- return _el$10;
8435
+ }, _el$19, _co$5);
8436
+ return _el$15;
8310
8437
  }
8311
- }), _el$19, _co$5);
8312
- (0, $8tj43$insert)(_el$8, (0, $8tj43$createComponent)((0, $8tj43$Show), {
8438
+ }), _el$24, _co$7);
8439
+ (0, $8tj43$insert)(_el$13, (0, $8tj43$createComponent)((0, $8tj43$Show), {
8313
8440
  get when() {
8314
- return not_queries_memo().length && include_category_suggestions_;
8441
+ return not_queries_memo().length;
8315
8442
  },
8316
8443
  keyed: false,
8317
8444
  get children() {
8318
- const _el$15 = (0, $8tj43$getNextElement)($40dd3f46f55d62ba$var$_tmpl$7);
8319
- (0, $8tj43$insert)(_el$15, () => {
8445
+ const _el$20 = (0, $8tj43$getNextElement)($40dd3f46f55d62ba$var$_tmpl$8);
8446
+ (0, $8tj43$insert)(_el$20, () => {
8320
8447
  const index_in_autocomplete = 3;
8321
8448
  set_list_until_cleanup(not_queries_memo, index_in_autocomplete);
8322
8449
  return (0, $8tj43$createComponent)((0, $8tj43$Index), {
@@ -8326,15 +8453,30 @@ function $40dd3f46f55d62ba$export$e872e2339fb04a7f(_ref) {
8326
8453
  children: (item, index) => render_entry(item, index_in_autocomplete, index)
8327
8454
  });
8328
8455
  });
8329
- return _el$15;
8456
+ return _el$20;
8330
8457
  }
8331
- }), _el$21, _co$6);
8332
- (0, $8tj43$effect)(() => _el$8.classList.toggle("compact", !!on_previous_searches_page_()));
8333
- return _el$8;
8458
+ }), _el$26, _co$8);
8459
+ (0, $8tj43$effect)(() => _el$13.classList.toggle("compact", !!on_previous_searches_page_()));
8460
+ return _el$13;
8334
8461
  }
8335
8462
  });
8336
8463
  }
8337
- const $2ebb1d6ae6763f7a$var$_tmpl$ = /*#__PURE__*/(0, $8tj43$template)(`<a target="_blank"></a>`, 2);
8464
+ const $76b6e14a50da4597$var$_tmpl$ = /*#__PURE__*/(0, $8tj43$template)(`<a target="_blank"></a>`, 2);
8465
+ function $76b6e14a50da4597$export$1efe1013da60d0e4(e, href) {
8466
+ if (e.metaKey || e.ctrlKey) {
8467
+ // Open link in a new tab with cmd/ctrl + enter.
8468
+ const link = (() => {
8469
+ const _el$ = (0, $8tj43$getNextElement)($76b6e14a50da4597$var$_tmpl$);
8470
+ (0, $8tj43$setAttribute)(_el$, "href", href);
8471
+ return _el$;
8472
+ })();
8473
+ document.body.append(link);
8474
+ link.click();
8475
+ link.remove();
8476
+ return true;
8477
+ }
8478
+ return false;
8479
+ }
8338
8480
  function $2ebb1d6ae6763f7a$export$217899a935ef803b(_ref) {
8339
8481
  let {
8340
8482
  selected_index_: [read_selected_index, write_selected_index],
@@ -8412,6 +8554,7 @@ function $2ebb1d6ae6763f7a$var$actual_navigation_working_on_fake_data(_ref2) {
8412
8554
  const sfv = get_search_field_value();
8413
8555
  if (!(0, $8tj43$untrack)(() => read_updating_blocked())) previous_value = sfv;
8414
8556
  });
8557
+ const owner = (0, $8tj43$getOwner)();
8415
8558
  const handler = (0, $8tj43$catchify)(_ref3 => {
8416
8559
  let {
8417
8560
  keyCode: keyCode
@@ -8444,29 +8587,29 @@ function $2ebb1d6ae6763f7a$var$actual_navigation_working_on_fake_data(_ref2) {
8444
8587
  const {
8445
8588
  title: title
8446
8589
  } = selected_entry;
8447
- block_updating_for_one_change();
8590
+ (0, $8tj43$runWithOwner)(owner, block_updating_for_one_change);
8448
8591
  set_search_field_value(title);
8449
- override_on_enter_for_this_entry(e => {
8592
+ (0, $8tj43$runWithOwner)(owner, () => override_on_enter_for_this_entry(e => {
8450
8593
  // Open search query in new tab on cmd+enter
8451
8594
  // If it's not cmd+enter, pressing enter will just submit the value that was put into the field while selecting with the arrow keys ;)
8452
8595
  const url = new URL(location);
8453
8596
  url_transformer_ === null || url_transformer_ === void 0 || url_transformer_(url);
8454
8597
  url.searchParams.set(search_query_param_name_, title);
8455
- return $2ebb1d6ae6763f7a$var$open_link_on_cmd_pressed(e, url.href);
8456
- });
8457
- } else if ((selected_entry === null || selected_entry === void 0 ? void 0 : selected_entry.type) == "category") override_on_enter_for_this_entry(e => {
8598
+ return (0, $76b6e14a50da4597$export$1efe1013da60d0e4)(e, url.href);
8599
+ }));
8600
+ } else if ((selected_entry === null || selected_entry === void 0 ? void 0 : selected_entry.type) == "category" || (selected_entry === null || selected_entry === void 0 ? void 0 : selected_entry.type) === "content") (0, $8tj43$runWithOwner)(owner, () => override_on_enter_for_this_entry(e => {
8458
8601
  const {
8459
8602
  page_url: page_url
8460
8603
  } = selected_entry;
8461
- if (!$2ebb1d6ae6763f7a$var$open_link_on_cmd_pressed(e, page_url))
8604
+ if (!(0, $76b6e14a50da4597$export$1efe1013da60d0e4)(e, page_url))
8462
8605
  // Above fn will return true if it opened a new tab, and we won't make these checks anymore
8463
8606
  router_.navigate_.go_to_({
8464
8607
  new_url_: page_url,
8465
8608
  is_replace_: false
8466
8609
  });
8467
8610
  return true;
8468
- });else if (!selected_entry) {
8469
- block_updating_for_one_change();
8611
+ }));else if (!selected_entry) {
8612
+ (0, $8tj43$runWithOwner)(owner, block_updating_for_one_change);
8470
8613
  set_search_field_value(previous_value);
8471
8614
  }
8472
8615
  });
@@ -8478,20 +8621,39 @@ function $2ebb1d6ae6763f7a$var$actual_navigation_working_on_fake_data(_ref2) {
8478
8621
  (0, $8tj43$onCleanup)((0, $8tj43$catchify)(() => el.removeEventListener("keyup", handler)));
8479
8622
  });
8480
8623
  }
8481
- function $2ebb1d6ae6763f7a$var$open_link_on_cmd_pressed(e, href) {
8482
- if (e.metaKey || e.ctrlKey) {
8483
- // Open link in a new tab with cmd/ctrl + enter.
8484
- const link = (() => {
8485
- const _el$ = (0, $8tj43$getNextElement)($2ebb1d6ae6763f7a$var$_tmpl$);
8486
- (0, $8tj43$setAttribute)(_el$, "href", href);
8487
- return _el$;
8488
- })();
8489
- document.body.append(link);
8490
- link.click();
8491
- link.remove();
8492
- return true;
8493
- }
8494
- return false;
8624
+ function $c4dee1ef44de29ca$export$af0124069c150252(_ref) {
8625
+ let {
8626
+ set_override_on_enter_fn_: set_override_on_enter_fn_,
8627
+ get_modal_search_results_: get_modal_search_results_,
8628
+ read_suggestion_signal_: read_suggestion_signal_,
8629
+ router_: router_,
8630
+ content_results_: content_results_
8631
+ } = _ref;
8632
+ const [get_autocomplete_wants_override_function, set_autocomplete_wants_override_function] = (0, $8tj43$createSignal)(() => false);
8633
+ (0, $8tj43$createComputed)(() => {
8634
+ var _get_modal_search_res, _search_results$displ;
8635
+ const suggestions = read_suggestion_signal_();
8636
+ const search_results = (_get_modal_search_res = get_modal_search_results_()) === null || _get_modal_search_res === void 0 ? void 0 : _get_modal_search_res();
8637
+ const content_results = content_results_();
8638
+ // If we only have one content result and nothing else, go there when pressing enter
8639
+ if (!suggestions.length && !(search_results !== null && search_results !== void 0 && (_search_results$displ = search_results.displays) !== null && _search_results$displ !== void 0 && _search_results$displ.length) && (content_results === null || content_results === void 0 ? void 0 : content_results.length) === 1) {
8640
+ const [{
8641
+ page_url: page_url
8642
+ }] = content_results;
8643
+ set_override_on_enter_fn_(e => {
8644
+ if (!(0, $76b6e14a50da4597$export$1efe1013da60d0e4)(e, page_url))
8645
+ // Above fn will return true if it opened a new tab, and we won't make these checks anymore
8646
+ router_.navigate_.go_to_({
8647
+ new_url_: page_url,
8648
+ is_replace_: false
8649
+ });
8650
+ return true;
8651
+ });
8652
+ return;
8653
+ }
8654
+ set_override_on_enter_fn_(get_autocomplete_wants_override_function());
8655
+ });
8656
+ return new_fn => set_autocomplete_wants_override_function(() => new_fn);
8495
8657
  }
8496
8658
  const $7cd4d275a9f8d600$export$3cf9497e790da491 = "query";
8497
8659
  function $7cd4d275a9f8d600$export$2f2b9559550c7bbc(_ref) {
@@ -8512,12 +8674,15 @@ function $7cd4d275a9f8d600$export$2f2b9559550c7bbc(_ref) {
8512
8674
  i18n_: i18n_,
8513
8675
  include_category_suggestions_: include_category_suggestions_,
8514
8676
  submit_query_: submit_query_,
8515
- router_: router_
8677
+ router_: router_,
8678
+ get_modal_search_results_: get_modal_search_results_,
8679
+ content_search_enabled_: content_search_enabled_
8516
8680
  } = _ref;
8517
8681
  const [searching_for_value, set_searching_for_value] = (0, $8tj43$createSignal)();
8682
+ const [show_stale_content_results, set_show_stale_content_results] = (0, $8tj43$createSignal)(false);
8518
8683
  const [read_search_field_value] = search_field_value_;
8519
8684
  const updating_blocked = (0, $8tj43$createSignal)(false);
8520
- const [read_suggestion_signal, write_suggestion_signal] = (0, $8tj43$createSignal)([]);
8685
+ const [read_suggestion_signal_, write_suggestion_signal] = (0, $8tj43$createSignal)([]);
8521
8686
  const filtered_previous_searches = (0, $8tj43$createMemo)(() => [...unfiltered_previous_searches[0]()].reverse().filter(q => q !== get_search_query_()));
8522
8687
  const deparallelized_fn = (0, $8tj43$deparallelize_no_drop)(async request_obj => {
8523
8688
  var _api_response$suggest;
@@ -8541,15 +8706,39 @@ function $7cd4d275a9f8d600$export$2f2b9559550c7bbc(_ref) {
8541
8706
  });
8542
8707
 
8543
8708
  const show_previous_searches_component = (0, $8tj43$createMemo)(() => !read_search_field_value() || (0, $8tj43$untrack)(updating_blocked[0]) && !(0, $8tj43$untrack)(searching_for_value));
8709
+ const get_content_results_ = (0, $8tj43$createMemo)(prev => {
8710
+ var _get_modal_search_res, _get_modal_search_res2, _get_modal_search_res3;
8711
+ if (!content_search_enabled_()) return [];
8712
+ if (show_stale_content_results())
8713
+ // don't update content results when query suggestions don't update because otherwise they disappear when trying to keyboard navigate to them
8714
+ return prev;
8715
+ return (_get_modal_search_res = get_modal_search_results_()) === null || _get_modal_search_res === void 0 ? void 0 : (_get_modal_search_res2 = _get_modal_search_res()) === null || _get_modal_search_res2 === void 0 ? void 0 : (_get_modal_search_res3 = _get_modal_search_res2.content_search_links) === null || _get_modal_search_res3 === void 0 ? void 0 : _get_modal_search_res3.map(link => ({
8716
+ page_url: link.page_url,
8717
+ type: "content",
8718
+ title: link.title
8719
+ }));
8720
+ });
8721
+ // Ideally we'd propagate up the suggestion signal too and call this from SearchModal.tsx? Because it's not super related with autocomplete, but it's not a huge feature, and it's easier here so keeping it.
8722
+ // It's the functionality to open the content results page when you press enter, in the modal, when there's only one content result
8723
+ const manipulated_set_override_on_enter_fn_ = (0, $c4dee1ef44de29ca$export$af0124069c150252)({
8724
+ set_override_on_enter_fn_: set_override_on_enter_fn_,
8725
+ get_modal_search_results_: get_modal_search_results_,
8726
+ read_suggestion_signal_: read_suggestion_signal_,
8727
+ router_: router_,
8728
+ content_results_: get_content_results_
8729
+ });
8544
8730
  (0, $8tj43$createComputed)(() => {
8545
8731
  const field_value = read_search_field_value();
8546
- if (!(0, $8tj43$untrack)(updating_blocked[0])) {
8732
+ if ((0, $8tj43$untrack)(updating_blocked[0]))
8733
+ // not using updating_blocked instead of below signal since I presume they'd start updating too early then
8734
+ set_show_stale_content_results(true);else {
8547
8735
  set_searching_for_value(field_value);
8548
8736
  deparallelized_fn({
8549
8737
  query: field_value,
8550
8738
  tenant: tenant_(),
8551
8739
  market: market_()
8552
8740
  });
8741
+ set_show_stale_content_results(false);
8553
8742
  }
8554
8743
  });
8555
8744
  (0, $8tj43$createComputed)((0, $8tj43$on)(search_field_value_[0], () => !updating_blocked[0]() && selected_index_[1](undefined), {
@@ -8561,7 +8750,7 @@ function $7cd4d275a9f8d600$export$2f2b9559550c7bbc(_ref) {
8561
8750
  search_field_value_: search_field_value_,
8562
8751
  updating_blocked_: updating_blocked,
8563
8752
  currently_showing_suggestions_: currently_showing_suggestions_,
8564
- set_override_on_enter_fn_: set_override_on_enter_fn_,
8753
+ set_override_on_enter_fn_: manipulated_set_override_on_enter_fn_,
8565
8754
  search_query_param_name_: search_query_url_param_name_,
8566
8755
  url_transformer_: url_transformer_,
8567
8756
  router_: router_
@@ -8601,11 +8790,12 @@ function $7cd4d275a9f8d600$export$2f2b9559550c7bbc(_ref) {
8601
8790
  },
8602
8791
  on_previous_searches_page_: show_previous_searches_component,
8603
8792
  i18n_: i18n_,
8793
+ get_content_results_: get_content_results_,
8604
8794
  url_transformer_: url_transformer_,
8605
8795
  searching_for_value_: searching_for_value,
8606
8796
  search_query_url_param_name_: search_query_url_param_name_,
8607
8797
  selected_index_: selected_index_,
8608
- suggestion_memo_: read_suggestion_signal,
8798
+ suggestion_memo_: read_suggestion_signal_,
8609
8799
  currently_showing_suggestions_: currently_showing_suggestions_,
8610
8800
  include_category_suggestions_: include_category_suggestions_,
8611
8801
  router_: router_,
@@ -8717,7 +8907,8 @@ function $e82132ed97521828$export$1c593cbd6f1e10bc(_ref) {
8717
8907
  bottom_distance_under_modal_: bottom_distance_under_modal_,
8718
8908
  selected_text_range_: selected_text_range_,
8719
8909
  dont_sync_search_field_value_except_on_submit_ = false,
8720
- router_: router_
8910
+ router_: router_,
8911
+ content_search_enabled_: content_search_enabled_
8721
8912
  } = _ref;
8722
8913
  let on_enter_in_search_field_function;
8723
8914
  // As per feedback from stronger we sometimes want a modal with the search field value disconnected from the one in the rest of the UI, see https://depictaiworkspace.slack.com/archives/C02J16R9XEH/p1679065878487709.
@@ -8734,48 +8925,38 @@ function $e82132ed97521828$export$1c593cbd6f1e10bc(_ref) {
8734
8925
  };
8735
8926
  const [input_field, set_input_field] = (0, $8tj43$createSignal)();
8736
8927
  const [get_search_field_value_] = search_field_value_;
8737
- const [elements_outside_scrollable, set_elements_outside_scrollable] = (0, $8tj43$createSignal)();
8738
- const [elements_inside_scrollable, set_elements_inside_scrollable] = (0, $8tj43$createSignal)();
8928
+ const [get_modal_search_results, set_modal_search_results_] = (0, $8tj43$createSignal)();
8739
8929
  const close_on_escape_handler = (0, $8tj43$catchify)(_ref2 => {
8740
8930
  let {
8741
8931
  key: key
8742
8932
  } = _ref2;
8743
8933
  if (key === "Escape") close_modal_();
8744
8934
  });
8745
- const [get_num_results_accessor, set_num_results_accessor_] = (0, $8tj43$createSignal)();
8935
+ const [get_total_num_results_accessor, set_total_num_results_accessor_] = (0, $8tj43$createSignal)();
8746
8936
  const selected_index = (0, $8tj43$createSignal)();
8747
8937
  const currently_showing_suggestions_ = (0, $8tj43$createSignal)([], {
8748
8938
  equals: false
8749
8939
  });
8940
+ const less_than_700_high = (0, $00a5b94f0c11efbb$export$d9f36cf74e24d595)("(max-height:700px)");
8941
+ const DiscoverMoreSection = () => (() => {
8942
+ const _el$ = (0, $8tj43$getNextElement)($e82132ed97521828$var$_tmpl$),
8943
+ _el$2 = _el$.firstChild;
8944
+ (0, $8tj43$addEventListener)(_el$2, "click", (0, $8tj43$catchify)(() => submit_query_()), true);
8945
+ (0, $8tj43$insert)(_el$2, (() => {
8946
+ const _c$ = (0, $8tj43$memo)(() => !!get_search_field_value_());
8947
+ return () => _c$() ? i18n_.modal_view_all_results_()((() => {
8948
+ const _el$3 = (0, $8tj43$getNextElement)($e82132ed97521828$var$_tmpl$2);
8949
+ (0, $8tj43$insert)(_el$3, () => get_total_num_results_accessor === null || get_total_num_results_accessor === void 0 ? void 0 : get_total_num_results_accessor());
8950
+ return _el$3;
8951
+ })()) : i18n_.modal_discover_more_();
8952
+ })());
8953
+ (0, $8tj43$runHydrationEvents)();
8954
+ return _el$;
8955
+ })();
8750
8956
  if (disable_scrolling_) (0, $e56d241d0f33d459$export$fe334901e8bebd57)();
8751
8957
  $e82132ed97521828$var$close_modal_when_navigating_away(close_modal_, search_query_url_param_name_);
8752
8958
  window.addEventListener("keydown", close_on_escape_handler);
8753
8959
  (0, $8tj43$onCleanup)((0, $8tj43$catchify)(() => window.removeEventListener("keydown", close_on_escape_handler)));
8754
- const owner = (0, $8tj43$getOwner)();
8755
- (0, $8tj43$onCleanup)((0, $8tj43$javascript_media_query)("(max-height:700px)", _ref3 => {
8756
- let {
8757
- matches: matches
8758
- } = _ref3;
8759
- return (0, $8tj43$runWithOwner)(owner, () => {
8760
- // the if below is reactive so we need an owner
8761
- (matches ? set_elements_outside_scrollable : set_elements_inside_scrollable)("");
8762
- (matches ? set_elements_inside_scrollable : set_elements_outside_scrollable)((() => {
8763
- const _el$ = (0, $8tj43$getNextElement)($e82132ed97521828$var$_tmpl$),
8764
- _el$2 = _el$.firstChild;
8765
- (0, $8tj43$addEventListener)(_el$2, "click", (0, $8tj43$catchify)(() => submit_query_()), true);
8766
- (0, $8tj43$insert)(_el$2, (() => {
8767
- const _c$ = (0, $8tj43$memo)(() => !!get_search_field_value_());
8768
- return () => _c$() ? i18n_.modal_view_all_results_()((() => {
8769
- const _el$3 = (0, $8tj43$getNextElement)($e82132ed97521828$var$_tmpl$2);
8770
- (0, $8tj43$insert)(_el$3, () => get_num_results_accessor === null || get_num_results_accessor === void 0 ? void 0 : get_num_results_accessor());
8771
- return _el$3;
8772
- })()) : i18n_.modal_discover_more_();
8773
- })());
8774
- (0, $8tj43$runHydrationEvents)();
8775
- return _el$;
8776
- })());
8777
- });
8778
- }).remove);
8779
8960
  if (closing_animation_) register_closing_animation_(closing_animation_);
8780
8961
  (0, $a09bb7c652acf957$export$3340fdd8259bd4fd)({
8781
8962
  get_search_field_value_: get_search_field_value_,
@@ -8830,10 +9011,10 @@ function $e82132ed97521828$export$1c593cbd6f1e10bc(_ref) {
8830
9011
  [_el$16, _co$5] = (0, $8tj43$getNextMarker)(_el$15.nextSibling),
8831
9012
  _el$17 = _el$5.nextSibling,
8832
9013
  [_el$18, _co$6] = (0, $8tj43$getNextMarker)(_el$17.nextSibling);
8833
- (0, $8tj43$addEventListener)(_el$4, "click", (0, $8tj43$catchify)(_ref4 => {
9014
+ (0, $8tj43$addEventListener)(_el$4, "click", (0, $8tj43$catchify)(_ref3 => {
8834
9015
  let {
8835
9016
  target: target
8836
- } = _ref4;
9017
+ } = _ref3;
8837
9018
  if (target === modal_element) close_modal_();
8838
9019
  }), true);
8839
9020
  (0, $8tj43$insert)(_el$5, search_field, _el$14, _co$4);
@@ -8861,7 +9042,9 @@ function $e82132ed97521828$export$1c593cbd6f1e10bc(_ref) {
8861
9042
  i18n_: i18n_,
8862
9043
  include_category_suggestions_: enable_category_suggestions_ !== null && enable_category_suggestions_ !== void 0 ? enable_category_suggestions_ : true,
8863
9044
  router_: router_,
8864
- submit_query_: submit_query_
9045
+ submit_query_: submit_query_,
9046
+ get_modal_search_results_: get_modal_search_results,
9047
+ content_search_enabled_: content_search_enabled_
8865
9048
  });
8866
9049
  }
8867
9050
  }), _el$8, _co$);
@@ -8875,14 +9058,30 @@ function $e82132ed97521828$export$1c593cbd6f1e10bc(_ref) {
8875
9058
  tenant_: tenant_,
8876
9059
  i18n_: i18n_,
8877
9060
  market_: market_,
8878
- set_num_results_accessor_: set_num_results_accessor_,
9061
+ set_total_num_results_accessor_: set_total_num_results_accessor_,
8879
9062
  router_: router_,
9063
+ set_modal_search_results_: set_modal_search_results_,
9064
+ content_search_enabled_: content_search_enabled_,
8880
9065
  ...instant_results_options_
8881
9066
  });
8882
9067
  }
8883
9068
  }), _el$10, _co$2);
8884
- (0, $8tj43$insert)(_el$6, elements_inside_scrollable, _el$12, _co$3);
8885
- (0, $8tj43$insert)(_el$5, elements_outside_scrollable, _el$16, _co$5);
9069
+ (0, $8tj43$insert)(_el$6, (0, $8tj43$createComponent)((0, $8tj43$Show), {
9070
+ get when() {
9071
+ return less_than_700_high();
9072
+ },
9073
+ get children() {
9074
+ return (0, $8tj43$createComponent)(DiscoverMoreSection, {});
9075
+ }
9076
+ }), _el$12, _co$3);
9077
+ (0, $8tj43$insert)(_el$5, (0, $8tj43$createComponent)((0, $8tj43$Show), {
9078
+ get when() {
9079
+ return !less_than_700_high();
9080
+ },
9081
+ get children() {
9082
+ return (0, $8tj43$createComponent)(DiscoverMoreSection, {});
9083
+ }
9084
+ }), _el$16, _co$5);
8886
9085
  (0, $8tj43$insert)(_el$4, (0, $8tj43$createComponent)((0, $a86e71c0015bd8ab$export$f021bdedd3ec901a), {
8887
9086
  styles: body_style
8888
9087
  }), _el$18, _co$6);
@@ -8993,11 +9192,13 @@ function $69602b3d8fd54c38$export$9dd50d35b9d94fdf(_ref) {
8993
9192
  let {
8994
9193
  get_search_query_: get_search_query_,
8995
9194
  i18n_: i18n_,
8996
- formatted_number_of_results_: formatted_number_of_results_
9195
+ formatted_number_of_results_: formatted_number_of_results_,
9196
+ number_of_results_: number_of_results_,
9197
+ type: type
8997
9198
  } = _ref;
8998
9199
  const contents = (0, $8tj43$createMemo)((0, $8tj43$catchify)(() => {
8999
9200
  const q = get_search_query_();
9000
- return i18n_.get_showing_results_for_()((() => {
9201
+ return i18n_[type === $69602b3d8fd54c38$export$2452208c79fe93ea.content ? "get_showing_pages_for_" : "get_showing_results_for_"]()((() => {
9001
9202
  const _el$ = (0, $8tj43$getNextElement)($69602b3d8fd54c38$var$_tmpl$);
9002
9203
  (0, $8tj43$insert)(_el$, q);
9003
9204
  return _el$;
@@ -9005,7 +9206,7 @@ function $69602b3d8fd54c38$export$9dd50d35b9d94fdf(_ref) {
9005
9206
  const _el$2 = (0, $8tj43$getNextElement)($69602b3d8fd54c38$var$_tmpl$);
9006
9207
  (0, $8tj43$insert)(_el$2, formatted_number_of_results_);
9007
9208
  return _el$2;
9008
- })());
9209
+ })(), !!q, number_of_results_());
9009
9210
  }));
9010
9211
  return (() => {
9011
9212
  const _el$3 = (0, $8tj43$getNextElement)($69602b3d8fd54c38$var$_tmpl$2);
@@ -9013,6 +9214,11 @@ function $69602b3d8fd54c38$export$9dd50d35b9d94fdf(_ref) {
9013
9214
  return _el$3;
9014
9215
  })();
9015
9216
  }
9217
+ let $69602b3d8fd54c38$export$2452208c79fe93ea;
9218
+ (function (ShowingResultsForType) {
9219
+ ShowingResultsForType[ShowingResultsForType["products"] = 0] = "products";
9220
+ ShowingResultsForType[ShowingResultsForType["content"] = 1] = "content";
9221
+ })($69602b3d8fd54c38$export$2452208c79fe93ea || ($69602b3d8fd54c38$export$2452208c79fe93ea = {}));
9016
9222
  function $8e8ce3f7a5eb11a6$export$41b4894022a3580f() {
9017
9223
  let {
9018
9224
  style_props_ = (0, $8tj43$createSignal)({})
@@ -9032,8 +9238,521 @@ function $8e8ce3f7a5eb11a6$export$41b4894022a3580f() {
9032
9238
  })));
9033
9239
  return style_props_;
9034
9240
  }
9241
+ const $f3a159279dc1a8fb$var$_tmpl$ = /*#__PURE__*/(0, $8tj43$template)(`<span class="highlighted-part"></span>`, 2);
9242
+ const $f3a159279dc1a8fb$var$dont_cut_in_between_less_than_characters = 30;
9243
+ function $f3a159279dc1a8fb$export$e1a98a189fd2c0e7(_ref) {
9244
+ let {
9245
+ content_result_: content_result_,
9246
+ key_: key_,
9247
+ cut_when_possible_: cut_when_possible_
9248
+ } = _ref;
9249
+ const matched_tokens = (0, $8tj43$createMemo)(() => {
9250
+ var _content_result_$high, _content_result_$high2;
9251
+ return (_content_result_$high = content_result_().highlights) === null || _content_result_$high === void 0 ? void 0 : (_content_result_$high2 = _content_result_$high.find(highlight => highlight.field == key_)) === null || _content_result_$high2 === void 0 ? void 0 : _content_result_$high2.matched_tokens;
9252
+ });
9253
+ const full_value = (0, $8tj43$createMemo)(() => {
9254
+ var _content_result_$key_;
9255
+ return (_content_result_$key_ = content_result_()[key_]) === null || _content_result_$key_ === void 0 ? void 0 : _content_result_$key_.replaceAll("\n", " ");
9256
+ });
9257
+ return (0, $8tj43$createComponent)((0, $8tj43$Show), {
9258
+ get when() {
9259
+ var _matched_tokens;
9260
+ return (_matched_tokens = matched_tokens()) === null || _matched_tokens === void 0 ? void 0 : _matched_tokens.length;
9261
+ },
9262
+ get fallback() {
9263
+ return full_value();
9264
+ },
9265
+ get children() {
9266
+ return (() => {
9267
+ const segmented_cut_text = (0, $8tj43$createMemo)(() => {
9268
+ const segmented_text = $f3a159279dc1a8fb$var$segment_text(full_value(), matched_tokens());
9269
+ if (cut_when_possible_) $f3a159279dc1a8fb$var$cut_text(segmented_text);
9270
+ return segmented_text;
9271
+ });
9272
+ return (0, $8tj43$createComponent)((0, $8tj43$Index), {
9273
+ get each() {
9274
+ return segmented_cut_text();
9275
+ },
9276
+ children: item => {
9277
+ return (0, $8tj43$createComponent)((0, $8tj43$Show), {
9278
+ get when() {
9279
+ return item().highlighted_;
9280
+ },
9281
+ get fallback() {
9282
+ return item().text_;
9283
+ },
9284
+ get children() {
9285
+ const _el$ = (0, $8tj43$getNextElement)($f3a159279dc1a8fb$var$_tmpl$);
9286
+ (0, $8tj43$insert)(_el$, () => item().text_);
9287
+ return _el$;
9288
+ }
9289
+ });
9290
+ }
9291
+ });
9292
+ })();
9293
+ }
9294
+ });
9295
+ }
9296
+ function $f3a159279dc1a8fb$var$cut_text(segmented_text) {
9297
+ // cut away chunks of text that are not highlighted to give a google-like overview of the content
9298
+ const highlighted_segments = segmented_text === null || segmented_text === void 0 ? void 0 : segmented_text.filter(segment => segment.highlighted_);
9299
+ if (!segmented_text || !(highlighted_segments !== null && highlighted_segments !== void 0 && highlighted_segments.length)) return;
9300
+ // We have one or more highlighted segments
9301
+ if (highlighted_segments.length === 1) {
9302
+ // cut away from the left until the start of the highlighted sentence if just one sentence is highlighted
9303
+ $f3a159279dc1a8fb$var$cut_start(segmented_text.indexOf(highlighted_segments[0]), segmented_text);
9304
+ return;
9305
+ }
9306
+ // We have two or more highlighted segments, take the two biggest chunks and show them + a bit text around
9307
+ const sorted_highlighted_segments = [...highlighted_segments].sort((a, b) => b.text_.trim().length - a.text_.trim().length // trim to avoid unfair comparisons due to whitespace
9308
+ );
9309
+
9310
+ const [longest_segment, next_longest_segment] = sorted_highlighted_segments;
9311
+ // We need to cut before the first segment - possibly through other segments - and maybe between segments
9312
+ let [index_of_first_segment, index_of_second_segment] = [segmented_text.indexOf(longest_segment), segmented_text.indexOf(next_longest_segment)].sort((a, b) => a - b);
9313
+ $f3a159279dc1a8fb$var$cut_start(index_of_first_segment, segmented_text);
9314
+ // update indexes since we might have removed segments
9315
+ [index_of_first_segment, index_of_second_segment] = [segmented_text.indexOf(longest_segment), segmented_text.indexOf(next_longest_segment)].sort((a, b) => a - b);
9316
+ let number_of_characters_between_segments = 0;
9317
+ for (let i = index_of_first_segment + 1; i < index_of_second_segment; i++) {
9318
+ const segment = segmented_text[i];
9319
+ number_of_characters_between_segments += segment.text_.length;
9320
+ }
9321
+ if (number_of_characters_between_segments < $f3a159279dc1a8fb$var$dont_cut_in_between_less_than_characters)
9322
+ // don't cut if there are less than 30 characters between the two segments
9323
+ return;
9324
+ // We have more than 50 characters between the two segments, cut between them
9325
+ const [split_start_segment, split_start_character] = $f3a159279dc1a8fb$var$find_split_point(index_of_first_segment, index_of_second_segment, segmented_text);
9326
+ const [split_end_segment, split_end_character] = $f3a159279dc1a8fb$var$find_split_point(index_of_second_segment, index_of_first_segment, segmented_text);
9327
+ if (split_start_segment === undefined || split_end_segment === undefined ||
9328
+ // identical split point, or split end before split start, can't do anything
9329
+ split_start_segment == split_end_segment && split_start_character >= split_end_character || split_start_segment > split_end_segment) return;
9330
+ const dots_segment = {
9331
+ text_: " … ",
9332
+ highlighted_: false
9333
+ };
9334
+ const split_and_dotted_values = segmented_text.flatMap((segment, i) => {
9335
+ if (i < split_start_segment || i > split_end_segment) return segment;
9336
+ const text = segment.text_;
9337
+ if (i == split_end_segment && i == split_start_segment) return [{
9338
+ ...segment,
9339
+ text_: text.slice(0, split_start_character).trimEnd()
9340
+ }, dots_segment, {
9341
+ ...segment,
9342
+ text_: text.slice(split_end_character + 1, text.length).trimStart()
9343
+ }];else if (i == split_start_segment) {
9344
+ segment.text_ = text.slice(0, split_start_character).trimEnd(); // this would be split_start_character + 1, but we want to remove the last "dot" because . ... looks weird
9345
+ return segment;
9346
+ } else if (i == split_end_segment) return [dots_segment, {
9347
+ ...segment,
9348
+ text_: text.slice(split_end_character + 1, text.length).trimStart()
9349
+ }];
9350
+ return []; // remove all segments inbetween
9351
+ });
9352
+
9353
+ segmented_text.splice(0, segmented_text.length, ...split_and_dotted_values); // Sorry…
9354
+ $f3a159279dc1a8fb$var$heal_holes(segmented_text);
9355
+ }
9356
+ function $f3a159279dc1a8fb$var$heal_holes(segmented_text) {
9357
+ // try to heal "holes" created in the segments so there are only alternating segments
9358
+ const segments_to_delete = new Set();
9359
+ for (let i = 0; i < segmented_text.length; i++) {
9360
+ var _previous_segment, _previous_segment2;
9361
+ const segment = segmented_text[i];
9362
+ let previous_segment;
9363
+ for (let j = i - 1; j >= 0; j--) {
9364
+ previous_segment = segmented_text[j];
9365
+ // Don't write to a segment that's marked for deletion or the contents we write to it will be deleted
9366
+ if (!segments_to_delete.has(previous_segment)) break;
9367
+ }
9368
+ if ((_previous_segment = previous_segment) !== null && _previous_segment !== void 0 && _previous_segment.highlighted_ && segment.highlighted_ || ((_previous_segment2 = previous_segment) === null || _previous_segment2 === void 0 ? void 0 : _previous_segment2.highlighted_) === false && segment.highlighted_ === false) {
9369
+ previous_segment.text_ += segment.text_; // IDK if this ever happens
9370
+ segments_to_delete.add(segment);
9371
+ }
9372
+ }
9373
+ for (const segment of segments_to_delete) {
9374
+ const index = segmented_text.indexOf(segment);
9375
+ segmented_text.splice(index, 1);
9376
+ }
9377
+ }
9378
+ function $f3a159279dc1a8fb$var$find_split_point(index_of_start_segment, index_of_end_segment, segmented_text) {
9379
+ let be_very_aggressive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
9380
+ const should_loop_backwards = index_of_start_segment > index_of_end_segment;
9381
+ const step = should_loop_backwards ? -1 : 1;
9382
+ const desperate_split_attempts = [":", ";", ","];
9383
+ while (desperate_split_attempts.length) {
9384
+ const split_point_between_words = [];
9385
+ // for the middle also try to split with a few more characters if the default ones don't work over a full run
9386
+ const desperate_split_attempt = desperate_split_attempts.pop();
9387
+ let is_first_character = true;
9388
+ for (let i = index_of_start_segment + step; should_loop_backwards ? i > index_of_end_segment : i < index_of_end_segment; i += step) {
9389
+ const segment = segmented_text[i];
9390
+ const text = segment.text_;
9391
+ for (let j = should_loop_backwards ? text.length - 1 : 0; should_loop_backwards ? j >= 0 : j < text.length; j += step) {
9392
+ const character = text[j];
9393
+ if (character == "." || character == "?" || character == "!" || character == desperate_split_attempt) return [i, j]; // segment index, character index
9394
+ if (is_first_character) is_first_character = false;else if (be_very_aggressive && character == " ") {
9395
+ split_point_between_words.push([i, j]);
9396
+ if (split_point_between_words.length > 3)
9397
+ // We can't find a split point, so we'll just split between words
9398
+ // This is because for UI reasons we only want to show 2 lines of text, so we need to be very aggressive with getting the second match soon
9399
+ return split_point_between_words[1];
9400
+ }
9401
+ }
9402
+ }
9403
+ }
9404
+ return [];
9405
+ }
9406
+ function $f3a159279dc1a8fb$var$cut_start(cut_left_of_index, segmented_text) {
9407
+ // Cut the start of the text to bring the first matching token
9408
+ let is_first_character = false;
9409
+ let words_encountered = 0;
9410
+ outmost_loop: for (let i = cut_left_of_index - 1; i >= 0; i--) {
9411
+ const segment = segmented_text[i];
9412
+ // We assume that two adjacent highlighted segments don't exist and have been merged if they were to have existed
9413
+ const text = segment.text_;
9414
+ for (let j = text.length - 1; j >= 0; j--) {
9415
+ const character = text[j];
9416
+ const is_space = character == " ";
9417
+ if (!is_first_character && is_space) words_encountered++;
9418
+ if (character == "." || character == "?" || character == "!" || character == "," || words_encountered > 8 && is_space) {
9419
+ // We have to be really aggressive at the start of sentences so stuff can be seen on mobile, hence comma
9420
+ segment.text_ = text.slice(j + 1).trimStart();
9421
+ segmented_text.splice(0, i);
9422
+ if (character === "," || is_space)
9423
+ // if we cut at a comma or psace, we add a … at the beginning
9424
+ segmented_text.unshift({
9425
+ text_: "… ",
9426
+ highlighted_: false
9427
+ });
9428
+ break outmost_loop;
9429
+ }
9430
+ if (is_first_character) is_first_character = false;
9431
+ }
9432
+ }
9433
+ $f3a159279dc1a8fb$var$heal_holes(segmented_text); // if we added a ... there could now be a sequence that's not alternating true/false
9434
+ }
9435
+
9436
+ function $f3a159279dc1a8fb$var$segment_text(text, matched_strings) {
9437
+ // segment text where the matched strings are highlighted sections
9438
+ const output = [];
9439
+ if (!text) return; // shouldn't happen but whatever
9440
+ for (let i = 0; i < text.length; i++) {
9441
+ const found_strings = [];
9442
+ if (!i || text[i - 1] == " ")
9443
+ // only match at the start of a word or string, it looks weird if i.e. "we" is highlighted in "activewear
9444
+ for (let j = 0; j < matched_strings.length; j++) {
9445
+ const matched_string = matched_strings[j];
9446
+ const part_in_text = text.slice(i, i + matched_string.length);
9447
+ if (matched_string.length < 2) continue; // don't match on single characters, i.e. "I", it looks weird
9448
+ if (part_in_text.toLowerCase() === matched_string.toLowerCase()) found_strings.push(part_in_text); // use the casing from the text, not from typesense, can look weird otherwise
9449
+ }
9450
+
9451
+ const last_index_in_output = output.length - 1;
9452
+ if (!found_strings.length) {
9453
+ var _output$last_index_in;
9454
+ const character = text[i];
9455
+ if (((_output$last_index_in = output[last_index_in_output]) === null || _output$last_index_in === void 0 ? void 0 : _output$last_index_in.highlighted_) === false || output.length && /\s/.test(character))
9456
+ // always push whitespace characters to the last segment, this is because typesense doesn't see them as part of the matched tokens but we want to be able to detect "phat" matched segments
9457
+ output[last_index_in_output].text_ += character;else output.push({
9458
+ highlighted_: false,
9459
+ text_: character
9460
+ });
9461
+ } else {
9462
+ var _output$last_index_in2;
9463
+ const longest_found_string = found_strings.reduce((a, b) => a.length > b.length ? a : b);
9464
+ if ((_output$last_index_in2 = output[last_index_in_output]) !== null && _output$last_index_in2 !== void 0 && _output$last_index_in2.highlighted_) output[last_index_in_output].text_ += longest_found_string;else output.push({
9465
+ highlighted_: true,
9466
+ text_: longest_found_string
9467
+ });
9468
+ i += longest_found_string.length - 1;
9469
+ }
9470
+ }
9471
+ return output;
9472
+ }
9473
+ const $22470de5f42cc35d$var$_tmpl$ = /*#__PURE__*/(0, $8tj43$template)(`<a></a>`, 2),
9474
+ $22470de5f42cc35d$var$_tmpl$2 = /*#__PURE__*/(0, $8tj43$template)(`<div></div>`, 2),
9475
+ $22470de5f42cc35d$var$_tmpl$3 = /*#__PURE__*/(0, $8tj43$template)(`<div class="description line-clamp"></div>`, 2),
9476
+ $22470de5f42cc35d$var$_tmpl$4 = /*#__PURE__*/(0, $8tj43$template)(`<div class="content-card"><div class="image"></div><div class="info"><!#><!/><!#><!/></div></div>`, 10);
9477
+ function $22470de5f42cc35d$export$f631859cab12b342(_ref) {
9478
+ let {
9479
+ router_: router_,
9480
+ content_result_: content_result_
9481
+ } = _ref;
9482
+ const make_link_attributes = () => {
9483
+ const result = content_result_ === null || content_result_ === void 0 ? void 0 : content_result_();
9484
+ if (!result) return;
9485
+ return {
9486
+ href: result.page_url,
9487
+ onClick: (0, $8tj43$catchify)(ev => router_.navigate_.go_to_({
9488
+ new_url_: result.page_url,
9489
+ is_replace_: false,
9490
+ event_: ev
9491
+ }))
9492
+ };
9493
+ };
9494
+ const LinkIfPossible = _ref2 => {
9495
+ let {
9496
+ children: children,
9497
+ ...attributes
9498
+ } = _ref2;
9499
+ if (content_result_) return (() => {
9500
+ const _el$ = (0, $8tj43$getNextElement)($22470de5f42cc35d$var$_tmpl$);
9501
+ (0, $8tj43$spread)(_el$, attributes, false, true);
9502
+ (0, $8tj43$insert)(_el$, children);
9503
+ (0, $8tj43$runHydrationEvents)();
9504
+ return _el$;
9505
+ })();
9506
+ return (() => {
9507
+ const _el$2 = (0, $8tj43$getNextElement)($22470de5f42cc35d$var$_tmpl$2);
9508
+ (0, $8tj43$spread)(_el$2, attributes, false, true);
9509
+ (0, $8tj43$insert)(_el$2, children);
9510
+ (0, $8tj43$runHydrationEvents)();
9511
+ return _el$2;
9512
+ })();
9513
+ };
9514
+ return (() => {
9515
+ const _el$3 = (0, $8tj43$getNextElement)($22470de5f42cc35d$var$_tmpl$4),
9516
+ _el$4 = _el$3.firstChild,
9517
+ _el$5 = _el$4.nextSibling,
9518
+ _el$7 = _el$5.firstChild,
9519
+ [_el$8, _co$] = (0, $8tj43$getNextMarker)(_el$7.nextSibling),
9520
+ _el$9 = _el$8.nextSibling,
9521
+ [_el$10, _co$2] = (0, $8tj43$getNextMarker)(_el$9.nextSibling);
9522
+ (0, $8tj43$insert)(_el$4, (0, $8tj43$createComponent)(LinkIfPossible, (0, $8tj43$mergeProps)(make_link_attributes, {
9523
+ tabIndex: "-1",
9524
+ get children() {
9525
+ return (0, $8tj43$createComponent)((0, $3c5e15c6ee4227a9$export$605674723bcc715c), {
9526
+ width: "28",
9527
+ height: "28"
9528
+ });
9529
+ }
9530
+ })));
9531
+ (0, $8tj43$insert)(_el$5, (0, $8tj43$createComponent)(LinkIfPossible, (0, $8tj43$mergeProps)({
9532
+ "class": "content-title line-clamp"
9533
+ }, make_link_attributes, {
9534
+ get title() {
9535
+ return content_result_ === null || content_result_ === void 0 ? void 0 : content_result_().title;
9536
+ },
9537
+ get children() {
9538
+ return content_result_ ? (0, $8tj43$createComponent)((0, $f3a159279dc1a8fb$export$e1a98a189fd2c0e7), {
9539
+ content_result_: content_result_,
9540
+ key_: "title",
9541
+ cut_when_possible_: false
9542
+ }) : (0, $8tj43$createComponent)((0, $ceafb6fb91c6f394$export$89c6019e4baa40b1), {
9543
+ height: "1em",
9544
+ width: "20ch"
9545
+ });
9546
+ }
9547
+ })), _el$8, _co$);
9548
+ (0, $8tj43$insert)(_el$5, (0, $8tj43$createComponent)((0, $8tj43$Show), {
9549
+ get when() {
9550
+ return (content_result_ === null || content_result_ === void 0 ? void 0 : content_result_().description) || !content_result_;
9551
+ },
9552
+ get children() {
9553
+ const _el$6 = (0, $8tj43$getNextElement)($22470de5f42cc35d$var$_tmpl$3);
9554
+ (0, $8tj43$insert)(_el$6, (0, $8tj43$createComponent)((0, $8tj43$Show), {
9555
+ when: content_result_,
9556
+ get fallback() {
9557
+ return Array.from({
9558
+ length: 4
9559
+ }).map(() => (0, $8tj43$createComponent)((0, $ceafb6fb91c6f394$export$89c6019e4baa40b1), {
9560
+ height: "1em",
9561
+ width: "min(50ch, 100%)"
9562
+ }));
9563
+ },
9564
+ get children() {
9565
+ return (0, $8tj43$createComponent)((0, $f3a159279dc1a8fb$export$e1a98a189fd2c0e7), {
9566
+ content_result_: content_result_,
9567
+ key_: "description",
9568
+ cut_when_possible_: true
9569
+ });
9570
+ }
9571
+ }));
9572
+ return _el$6;
9573
+ }
9574
+ }), _el$10, _co$2);
9575
+ return _el$3;
9576
+ })();
9577
+ }
9578
+ function $881e8953a9103f10$export$9ff751cd77687edc(_ref) {
9579
+ let {
9580
+ search_results_: search_results_,
9581
+ router_: router_
9582
+ } = _ref;
9583
+ const content_results = (0, $8tj43$createMemo)(() => {
9584
+ var _search_results_;
9585
+ return (_search_results_ = search_results_()) === null || _search_results_ === void 0 ? void 0 : _search_results_.content_search_links;
9586
+ });
9587
+ const content_results_by_page_url = (0, $8tj43$createMemo)(() => {
9588
+ const map = new Map();
9589
+ const results = content_results();
9590
+ if (!results) return map;
9591
+ for (let i = 0; i < results.length; i++) {
9592
+ const content_result = results[i];
9593
+ map.set(content_result.page_url, content_result);
9594
+ }
9595
+ return map;
9596
+ });
9597
+ return (0, $8tj43$createComponent)((0, $8tj43$For), {
9598
+ get each() {
9599
+ return [...content_results_by_page_url().keys()];
9600
+ },
9601
+ children: page_url => {
9602
+ const content_result = (0, $8tj43$createMemo)(() => content_results_by_page_url().get(page_url));
9603
+ return (0, $8tj43$createComponent)((0, $22470de5f42cc35d$export$f631859cab12b342), {
9604
+ content_result_: content_result,
9605
+ router_: router_
9606
+ });
9607
+ }
9608
+ });
9609
+ }
9610
+ function $ad4f3c9872fbeb48$export$4405d077f0a20494(_ref) {
9611
+ let {
9612
+ content_results_rows_: [get_history_state_content_results_rows],
9613
+ cols_at_size_: cols_at_size_
9614
+ } = _ref;
9615
+ const largest_column = (0, $8tj43$createMemo)(() => {
9616
+ const largest_in_cols_at_size = Math.max(...cols_at_size_().map(_ref2 => {
9617
+ let [cols] = _ref2;
9618
+ return cols;
9619
+ }));
9620
+ if (isNaN(largest_in_cols_at_size) || Math.abs(largest_in_cols_at_size) === Infinity) return 4; // fallback to something big so we always have the right amount of placeholders
9621
+ return largest_in_cols_at_size;
9622
+ });
9623
+ const num_placeholders = (0, $8tj43$createMemo)(() => {
9624
+ var _get_history_state_co;
9625
+ return ((_get_history_state_co = get_history_state_content_results_rows()) !== null && _get_history_state_co !== void 0 ? _get_history_state_co : (0, $d53ebed6f63304e4$export$70ceae36059a1036)) * largest_column();
9626
+ });
9627
+ return (0, $8tj43$createComponent)((0, $8tj43$Index), {
9628
+ get each() {
9629
+ return Array.from({
9630
+ length: num_placeholders()
9631
+ });
9632
+ },
9633
+ children: () => (0, $8tj43$createComponent)((0, $22470de5f42cc35d$export$f631859cab12b342), {})
9634
+ });
9635
+ }
9636
+ const $d53ebed6f63304e4$var$_tmpl$ = /*#__PURE__*/(0, $8tj43$template)(`<div class="content-results"><!#><!/><!#><!/></div>`, 6),
9637
+ $d53ebed6f63304e4$var$_tmpl$2 = /*#__PURE__*/(0, $8tj43$template)(`<button class="view-more"></button>`, 2),
9638
+ $d53ebed6f63304e4$var$_tmpl$3 = /*#__PURE__*/(0, $8tj43$template)(`<button class="view-less"></button>`, 2);
9639
+ const $d53ebed6f63304e4$export$70ceae36059a1036 = 1;
9640
+ function $d53ebed6f63304e4$export$6d0c9c22f6652669(_ref) {
9641
+ let {
9642
+ search_results_: search_results_,
9643
+ get_search_query_: get_search_query_,
9644
+ i18n_: i18n_,
9645
+ layout_options_: layout_options_,
9646
+ router_: router_,
9647
+ query_base_: query_base_,
9648
+ content_results_rows_: content_results_rows_
9649
+ } = _ref;
9650
+ const content_results = (0, $8tj43$createMemo)(() => {
9651
+ var _search_results_;
9652
+ return (_search_results_ = search_results_()) === null || _search_results_ === void 0 ? void 0 : _search_results_.content_search_links;
9653
+ });
9654
+ const num_results = (0, $8tj43$createMemo)(() => {
9655
+ var _content_results;
9656
+ return (_content_results = content_results()) === null || _content_results === void 0 ? void 0 : _content_results.length;
9657
+ });
9658
+ const is_loading_ = (0, $8tj43$createMemo)(() => search_results_.loading || query_base_.loading); // See comment in PLPResults/index.tsx on why we need this
9659
+ const formatted_number_of_results_ = (0, $43fbdca0f726a34b$export$92f2da32c6e7e7ee)({
9660
+ number_: num_results,
9661
+ i18n_: i18n_
9662
+ });
9663
+ const [is_showing_placeholders, set_is_showing_placeholders] = (0, $8tj43$createSignal)(false);
9664
+ const rows_object = $d53ebed6f63304e4$var$make_state_saved_rows(content_results_rows_, i18n_);
9665
+ return (() => {
9666
+ const _el$ = (0, $8tj43$getNextElement)($d53ebed6f63304e4$var$_tmpl$),
9667
+ _el$2 = _el$.firstChild,
9668
+ [_el$3, _co$] = (0, $8tj43$getNextMarker)(_el$2.nextSibling),
9669
+ _el$4 = _el$3.nextSibling,
9670
+ [_el$5, _co$2] = (0, $8tj43$getNextMarker)(_el$4.nextSibling);
9671
+ (0, $8tj43$insert)(_el$, (0, $8tj43$createComponent)((0, $69602b3d8fd54c38$export$9dd50d35b9d94fdf), {
9672
+ get_search_query_: get_search_query_,
9673
+ i18n_: i18n_,
9674
+ formatted_number_of_results_: formatted_number_of_results_,
9675
+ get type() {
9676
+ return (0, $69602b3d8fd54c38$export$2452208c79fe93ea).content;
9677
+ },
9678
+ number_of_results_: num_results
9679
+ }), _el$3, _co$);
9680
+ (0, $8tj43$insert)(_el$, (0, $8tj43$createComponent)((0, $63f1f8dbcd07d3b0$export$d21e32dfedac04be), (0, $8tj43$mergeProps)({
9681
+ layout: "grid",
9682
+ element_attributes: {
9683
+ class: "cards"
9684
+ }
9685
+ }, layout_options_, {
9686
+ rows: rows_object,
9687
+ get children() {
9688
+ return (0, $8tj43$createComponent)((0, $8tj43$Suspense), {
9689
+ get fallback() {
9690
+ return (() => {
9691
+ set_is_showing_placeholders(true);
9692
+ (0, $8tj43$onCleanup)(() => set_is_showing_placeholders(false));
9693
+ return (0, $8tj43$createComponent)((0, $ad4f3c9872fbeb48$export$4405d077f0a20494), {
9694
+ content_results_rows_: content_results_rows_,
9695
+ get cols_at_size_() {
9696
+ return (0, $8tj43$createMemo)(() => layout_options_().cols_at_size);
9697
+ }
9698
+ });
9699
+ })();
9700
+ },
9701
+ get children() {
9702
+ return (0, $8tj43$createComponent)((0, $881e8953a9103f10$export$9ff751cd77687edc), {
9703
+ router_: router_,
9704
+ search_results_: search_results_
9705
+ });
9706
+ }
9707
+ });
9708
+ }
9709
+ })), _el$5, _co$2);
9710
+ (0, $8tj43$effect)(_p$ => {
9711
+ var _content_results2;
9712
+ const _v$ = !!is_showing_placeholders(),
9713
+ _v$2 = is_loading_() || ((_content_results2 = content_results()) === null || _content_results2 === void 0 ? void 0 : _content_results2.length) > 0 ? "" : "none";
9714
+ _v$ !== _p$._v$ && _el$.classList.toggle("loading", _p$._v$ = _v$);
9715
+ _v$2 !== _p$._v$2 && _el$.style.setProperty("display", _p$._v$2 = _v$2);
9716
+ return _p$;
9717
+ }, {
9718
+ _v$: undefined,
9719
+ _v$2: undefined
9720
+ });
9721
+ return _el$;
9722
+ })();
9723
+ }
9724
+ function $d53ebed6f63304e4$var$make_state_saved_rows(_ref2, i18n_) {
9725
+ let [get_showing_content_results_rows, set_showing_content_results_rows] = _ref2;
9726
+ const currently_visible = (0, $8tj43$createSignal)((0, $8tj43$untrack)(get_showing_content_results_rows));
9727
+ const [get_currently_visible, set_currently_visible] = currently_visible;
9728
+ const rows = {
9729
+ currently_visible: currently_visible,
9730
+ start_rows: $d53ebed6f63304e4$export$70ceae36059a1036,
9731
+ button: (() => {
9732
+ const _el$6 = (0, $8tj43$getNextElement)($d53ebed6f63304e4$var$_tmpl$2);
9733
+ (0, $8tj43$insert)(_el$6, () => i18n_.view_more_());
9734
+ return _el$6;
9735
+ })(),
9736
+ view_less_button: (() => {
9737
+ const _el$7 = (0, $8tj43$getNextElement)($d53ebed6f63304e4$var$_tmpl$3);
9738
+ (0, $8tj43$insert)(_el$7, () => i18n_.view_less_());
9739
+ return _el$7;
9740
+ })(),
9741
+ rows_per_click: 3
9742
+ };
9743
+ (0, $8tj43$createComputed)((0, $8tj43$on)(get_currently_visible, new_visible => set_showing_content_results_rows(new_visible), {
9744
+ defer: true
9745
+ }));
9746
+ (0, $8tj43$createComputed)((0, $8tj43$on)(get_showing_content_results_rows, function () {
9747
+ let new_rows = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : $d53ebed6f63304e4$export$70ceae36059a1036;
9748
+ return set_currently_visible(new_rows);
9749
+ }, {
9750
+ defer: true
9751
+ }));
9752
+ return rows;
9753
+ }
9035
9754
  const $da279c5a540c6846$var$_tmpl$ = /*#__PURE__*/(0, $8tj43$template)(`<div class="filter-results-for-one-row"><!#><!/><!#><!/></div>`, 6),
9036
- $da279c5a540c6846$var$_tmpl$2 = /*#__PURE__*/(0, $8tj43$template)(`<div class="depict plp search"><div class="listing-page"><!#><!/><!#><!/><!#><!/><!#><!/><!#><!/><!#><!/></div><!#><!/><!#><!/></div>`, 20);
9755
+ $da279c5a540c6846$var$_tmpl$2 = /*#__PURE__*/(0, $8tj43$template)(`<div class="depict plp search"><div class="listing-page"><!#><!/><!#><!/><!#><!/><!#><!/><!#><!/><!#><!/><!#><!/></div><!#><!/><!#><!/></div>`, 22);
9037
9756
  function $da279c5a540c6846$export$a54ec244c8863715(_ref) {
9038
9757
  let {
9039
9758
  depict_api_: depict_api_,
@@ -9063,7 +9782,11 @@ function $da279c5a540c6846$export$a54ec244c8863715(_ref) {
9063
9782
  recommendations_layout_options_: recommendations_layout_options_,
9064
9783
  scroll_restoration_data_: scroll_restoration_data_,
9065
9784
  product_card_template_: product_card_template_,
9066
- modal_body_style_ref_: modal_body_style_ref_
9785
+ modal_body_style_ref_: modal_body_style_ref_,
9786
+ router_: router_,
9787
+ content_results_rows_: content_results_rows_,
9788
+ content_layout_options_: content_layout_options_,
9789
+ content_search_enabled_: content_search_enabled_
9067
9790
  } = _ref;
9068
9791
  const [get_sorting] = current_sorting_;
9069
9792
  const all_products_loaded_ = (0, $8tj43$createSignal)(false);
@@ -9130,16 +9853,29 @@ function $da279c5a540c6846$export$a54ec244c8863715(_ref) {
9130
9853
  const SafeSearchField = (0, $8tj43$catchify)((0, $584c06c09cf4609d$export$b94867ecbd698f21));
9131
9854
  const [sort_or_filter_open_, set_sort_or_filter_open_] = (0, $8tj43$createSignal)(false);
9132
9855
  const [desktop_filter_elements_, set_desktop_filter_elements] = (0, $8tj43$createSignal)();
9856
+ const n_hits = (0, $8tj43$createMemo)(() => {
9857
+ var _search_results_3;
9858
+ return (_search_results_3 = search_results_()) === null || _search_results_3 === void 0 ? void 0 : _search_results_3.n_hits;
9859
+ });
9133
9860
  const formatted_number_of_results_ = (0, $43fbdca0f726a34b$export$92f2da32c6e7e7ee)({
9134
- search_results_: search_results_,
9861
+ number_: n_hits,
9135
9862
  i18n_: i18n_
9136
9863
  });
9137
9864
  const [sort_and_filter_element_, set_sort_and_filter_element_] = (0, $8tj43$createSignal)();
9138
- const results_for = (0, $8tj43$createComponent)((0, $69602b3d8fd54c38$export$9dd50d35b9d94fdf), {
9865
+ const no_results_text_ = (0, $8tj43$createMemo)(() => {
9866
+ var _search_results_4, _search_results_4$con;
9867
+ return ((_search_results_4 = search_results_()) !== null && _search_results_4 !== void 0 && (_search_results_4$con = _search_results_4.content_search_links) !== null && _search_results_4$con !== void 0 && _search_results_4$con.length ? i18n_.no_products_ : i18n_.no_results_text_)();
9868
+ });
9869
+ const results_for = (0, $8tj43$createComponent)((0, $69602b3d8fd54c38$export$9dd50d35b9d94fdf), (0, $8tj43$mergeProps)({
9870
+ get type() {
9871
+ return (0, $69602b3d8fd54c38$export$2452208c79fe93ea).products;
9872
+ },
9873
+ number_of_results_: n_hits
9874
+ }, {
9139
9875
  get_search_query_: get_search_query_,
9140
9876
  i18n_: i18n_,
9141
9877
  formatted_number_of_results_: formatted_number_of_results_
9142
- });
9878
+ }));
9143
9879
  const filters_opener = (0, $7396052a1484264f$export$d7841e452f2e59a8)({
9144
9880
  set_sort_or_filter_open_: set_sort_or_filter_open_,
9145
9881
  set_extra_els_in_results_container_: set_desktop_filter_elements,
@@ -9263,10 +9999,12 @@ function $da279c5a540c6846$export$a54ec244c8863715(_ref) {
9263
9999
  [_el$17, _co$7] = (0, $8tj43$getNextMarker)(_el$16.nextSibling),
9264
10000
  _el$18 = _el$17.nextSibling,
9265
10001
  [_el$19, _co$8] = (0, $8tj43$getNextMarker)(_el$18.nextSibling),
9266
- _el$20 = _el$7.nextSibling,
10002
+ _el$20 = _el$19.nextSibling,
9267
10003
  [_el$21, _co$9] = (0, $8tj43$getNextMarker)(_el$20.nextSibling),
9268
- _el$22 = _el$21.nextSibling,
9269
- [_el$23, _co$10] = (0, $8tj43$getNextMarker)(_el$22.nextSibling);
10004
+ _el$22 = _el$7.nextSibling,
10005
+ [_el$23, _co$10] = (0, $8tj43$getNextMarker)(_el$22.nextSibling),
10006
+ _el$24 = _el$23.nextSibling,
10007
+ [_el$25, _co$11] = (0, $8tj43$getNextMarker)(_el$24.nextSibling);
9270
10008
  (0, $8tj43$insert)(_el$7, get_search_field_elements, _el$9, _co$3);
9271
10009
  (0, $8tj43$insert)(_el$7, make_category_suggestion_card_ ? (0, $8tj43$createComponent)((0, $74777e8fe65b3dcb$export$b69d0d92862de18b), {
9272
10010
  severity_: "error",
@@ -9278,7 +10016,29 @@ function $da279c5a540c6846$export$a54ec244c8863715(_ref) {
9278
10016
  });
9279
10017
  }
9280
10018
  }) : null, _el$11, _co$4);
9281
- (0, $8tj43$insert)(_el$7, () => results_filters[0](), _el$13, _co$5);
10019
+ (0, $8tj43$insert)(_el$7, (0, $8tj43$createComponent)((0, $74777e8fe65b3dcb$export$b69d0d92862de18b), {
10020
+ severity_: "error",
10021
+ message_: "ContentResults failed",
10022
+ get children() {
10023
+ return (0, $8tj43$createComponent)((0, $8tj43$Show), {
10024
+ get when() {
10025
+ return content_search_enabled_();
10026
+ },
10027
+ get children() {
10028
+ return (0, $8tj43$createComponent)((0, $d53ebed6f63304e4$export$6d0c9c22f6652669), {
10029
+ content_results_rows_: content_results_rows_,
10030
+ search_results_: search_results_,
10031
+ i18n_: i18n_,
10032
+ get_search_query_: get_search_query_,
10033
+ layout_options_: content_layout_options_,
10034
+ router_: router_,
10035
+ query_base_: search_query_base_
10036
+ });
10037
+ }
10038
+ });
10039
+ }
10040
+ }), _el$13, _co$5);
10041
+ (0, $8tj43$insert)(_el$7, () => results_filters[0](), _el$15, _co$6);
9282
10042
  (0, $8tj43$insert)(_el$7, (0, $8tj43$createComponent)((0, $8tj43$Show), {
9283
10043
  get when() {
9284
10044
  var _selected_filters_$;
@@ -9302,7 +10062,7 @@ function $da279c5a540c6846$export$a54ec244c8863715(_ref) {
9302
10062
  }
9303
10063
  });
9304
10064
  }
9305
- }), _el$15, _co$6);
10065
+ }), _el$17, _co$7);
9306
10066
  (0, $8tj43$insert)(_el$7, (0, $8tj43$createComponent)((0, $74777e8fe65b3dcb$export$b69d0d92862de18b), {
9307
10067
  severity_: "error",
9308
10068
  message_: "Search results failed",
@@ -9325,11 +10085,14 @@ function $da279c5a540c6846$export$a54ec244c8863715(_ref) {
9325
10085
  selected_filters_: selected_filters_,
9326
10086
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
9327
10087
  local_filter_cache_: local_filter_cache_,
9328
- i18n_: i18n_
10088
+ i18n_: {
10089
+ ...i18n_,
10090
+ no_results_text_: no_results_text_
10091
+ }
9329
10092
  }
9330
10093
  });
9331
10094
  }
9332
- }), _el$17, _co$7);
10095
+ }), _el$19, _co$8);
9333
10096
  (0, $8tj43$insert)(_el$7, (0, $8tj43$createComponent)((0, $8tj43$Show), {
9334
10097
  get when() {
9335
10098
  return get_all_products_loaded() && !disable_search_recommendations_;
@@ -9357,7 +10120,7 @@ function $da279c5a540c6846$export$a54ec244c8863715(_ref) {
9357
10120
  }
9358
10121
  });
9359
10122
  }
9360
- }), _el$19, _co$8);
10123
+ }), _el$21, _co$9);
9361
10124
  (0, $8tj43$insert)(_el$6, (0, $8tj43$createComponent)((0, $74777e8fe65b3dcb$export$b69d0d92862de18b), {
9362
10125
  message_: "Scroll status failed",
9363
10126
  severity_: "error",
@@ -9368,12 +10131,12 @@ function $da279c5a540c6846$export$a54ec244c8863715(_ref) {
9368
10131
  formatted_number_of_results_: formatted_number_of_results_,
9369
10132
  i18n_: i18n_,
9370
10133
  number_of_results_: (0, $8tj43$createMemo)(() => {
9371
- var _search_results_3;
9372
- return (_search_results_3 = search_results_()) === null || _search_results_3 === void 0 ? void 0 : _search_results_3.n_hits;
10134
+ var _search_results_5;
10135
+ return (_search_results_5 = search_results_()) === null || _search_results_5 === void 0 ? void 0 : _search_results_5.n_hits;
9373
10136
  })
9374
10137
  });
9375
10138
  }
9376
- }), _el$21, _co$9);
10139
+ }), _el$23, _co$10);
9377
10140
  (0, $8tj43$insert)(_el$6, (0, $8tj43$createComponent)((0, $74777e8fe65b3dcb$export$b69d0d92862de18b), {
9378
10141
  message_: "Floating buttons failed",
9379
10142
  severity_: "error",
@@ -9386,7 +10149,7 @@ function $da279c5a540c6846$export$a54ec244c8863715(_ref) {
9386
10149
  i18n_: i18n_
9387
10150
  });
9388
10151
  }
9389
- }), _el$23, _co$10);
10152
+ }), _el$25, _co$11);
9390
10153
  (0, $8tj43$effect)(() => (0, $8tj43$setAttribute)(_el$6, "id", (0, $c3820807ac1e6fd7$export$44dad306455dddf).SEARCH_PAGE));
9391
10154
  return _el$6;
9392
10155
  })()];
@@ -9411,6 +10174,38 @@ function $37e8c97bb6876197$export$828dcdd425fd3231(aligner) {
9411
10174
  cleanup: cleanup
9412
10175
  };
9413
10176
  }
10177
+
10178
+ /**
10179
+ * Content results ContentCard look stupid on mobile if there are two columns of them, so we limit the number of columns to 1 if the screen is too small
10180
+ */
10181
+ function $3f7203368ad0d3ca$export$ff7109b9b2b206ba(sdk_cols_at_size) {
10182
+ let min_width_for_more_than_one_column = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500;
10183
+ if (!sdk_cols_at_size.length) return sdk_cols_at_size;
10184
+ const sorted_sizes = sdk_cols_at_size.map(_ref => {
10185
+ let [cols, max_width] = _ref;
10186
+ return [cols, max_width !== null && max_width !== void 0 ? max_width : Infinity];
10187
+ }).sort((_ref2, _ref3) => {
10188
+ let [, a] = _ref2;
10189
+ let [, b] = _ref3;
10190
+ return a - b;
10191
+ });
10192
+ const [[, smallest_max_width]] = sorted_sizes;
10193
+ if (smallest_max_width > min_width_for_more_than_one_column)
10194
+ // If everything above min_width_for_more_than_one_column, we can just add a 1 column at the beginning
10195
+ return [[1, min_width_for_more_than_one_column], ...sdk_cols_at_size];
10196
+ const to_delete = [];
10197
+ for (let i = 0; i < sorted_sizes.length; i++) {
10198
+ const [, max_width] = sorted_sizes[i];
10199
+ if (max_width > min_width_for_more_than_one_column) continue;
10200
+ to_delete.push(i);
10201
+ }
10202
+ while (to_delete.length) sorted_sizes.splice(to_delete.pop(), 1);
10203
+ sorted_sizes.unshift([1, min_width_for_more_than_one_column]);
10204
+ return sorted_sizes.map(_ref4 => {
10205
+ let [cols, max_width] = _ref4;
10206
+ return max_width == Infinity ? [cols] : [cols, max_width];
10207
+ });
10208
+ }
9414
10209
  const $eb064bc3350276c1$var$_tmpl$ = /*#__PURE__*/(0, $8tj43$template)(`<div class="depict plp search"></div>`, 2);
9415
10210
  function $eb064bc3350276c1$var$_classPrivateFieldInitSpec(obj, privateMap, value) {
9416
10211
  $eb064bc3350276c1$var$_checkPrivateRedeclaration(obj, privateMap);
@@ -9442,6 +10237,7 @@ function $eb064bc3350276c1$var$_classApplyDescriptorGet(receiver, descriptor) {
9442
10237
  * 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.
9443
10238
  */
9444
10239
  const $eb064bc3350276c1$var$privately_shared_properties = /*@__PURE__*/new WeakMap();
10240
+ const $eb064bc3350276c1$var$content_search_default = false;
9445
10241
  const $eb064bc3350276c1$var$min_products_to_fetch_ = 20;
9446
10242
  const $eb064bc3350276c1$export$bde3eb976dfded9 = depict_search => {
9447
10243
  var _privately_shared_pro;
@@ -9451,6 +10247,7 @@ var $eb064bc3350276c1$var$_locale_signal = /*#__PURE__*/new WeakMap();
9451
10247
  var $eb064bc3350276c1$var$_merchant_signal = /*#__PURE__*/new WeakMap();
9452
10248
  var $eb064bc3350276c1$var$_market_signal = /*#__PURE__*/new WeakMap();
9453
10249
  var $eb064bc3350276c1$var$_modal_open_signal = /*#__PURE__*/new WeakMap();
10250
+ var $eb064bc3350276c1$var$_content_search_signal = /*#__PURE__*/new WeakMap();
9454
10251
  var $eb064bc3350276c1$var$_router = /*#__PURE__*/new WeakMap();
9455
10252
  class $eb064bc3350276c1$export$ac6237957a15b3f0 {
9456
10253
  constructor(_ref) {
@@ -9462,9 +10259,10 @@ class $eb064bc3350276c1$export$ac6237957a15b3f0 {
9462
10259
  on_navigation: on_navigation,
9463
10260
  enable_category_suggestions = true,
9464
10261
  page_url_creator: page_url_creator,
10262
+ display_transformers: display_transformers,
10263
+ api: api,
9465
10264
  // Stuff needed for non-standard customer deployments that we shouldn't actually expose
9466
10265
  disable_scrolling_during_modal = true,
9467
- api: api,
9468
10266
  bottom_distance_under_modal: bottom_distance_under_modal,
9469
10267
  render_instant_card: render_instant_card,
9470
10268
  ...props_on_class
@@ -9485,6 +10283,10 @@ class $eb064bc3350276c1$export$ac6237957a15b3f0 {
9485
10283
  writable: true,
9486
10284
  value: (0, $8tj43$createSignal)(false)
9487
10285
  });
10286
+ $eb064bc3350276c1$var$_classPrivateFieldInitSpec(this, $eb064bc3350276c1$var$_content_search_signal, {
10287
+ writable: true,
10288
+ value: (0, $8tj43$createSignal)()
10289
+ });
9488
10290
  $eb064bc3350276c1$var$_classPrivateFieldInitSpec(this, $eb064bc3350276c1$var$_router, {
9489
10291
  writable: true,
9490
10292
  value: new (0, $ac571292d606f30b$export$7e1297a3a19f10d8)("hard_navigation")
@@ -9520,6 +10322,7 @@ class $eb064bc3350276c1$export$ac6237957a15b3f0 {
9520
10322
  local_filter_cache: [],
9521
10323
  expanded_hierarchical_filters: [],
9522
10324
  showing_recommendation_rows: (0, $8ef6232475d44150$export$1c8c715550dc689d),
10325
+ content_results_rows: (0, $d53ebed6f63304e4$export$70ceae36059a1036),
9523
10326
  scroll_restoration_data: []
9524
10327
  };
9525
10328
  },
@@ -9531,12 +10334,18 @@ class $eb064bc3350276c1$export$ac6237957a15b3f0 {
9531
10334
  const get_search_query_ = (0, $8tj43$createMemo)(previous_value => {
9532
10335
  if (get_search_query_updating_blocked()) return previous_value;else return raw_search_query_accessor();
9533
10336
  });
10337
+ // @ts-ignore
9534
10338
  const depict_api_ = api !== null && api !== void 0 ? api : new (0, $284849364a6ef73a$export$e015ed2f2950f2e3)({
9535
- page_url_creator: page_url_creator
10339
+ page_url_creator: page_url_creator,
10340
+ display_transformers: display_transformers
9536
10341
  });
9537
10342
  const previous_searches = (0, $07d90b8270ece8de$export$84bba84a7b837187)(get_search_query_);
9538
10343
  const [, set_search_showing_recommendation_rows] = state_.showing_recommendation_rows;
9539
- const after_submit_ = () => set_search_showing_recommendation_rows((0, $8ef6232475d44150$export$1c8c715550dc689d)); // do this every time after we have submitted a new query - otherwise there might already be a saved number of rows in the state
10344
+ const [, set_search_content_results_rows] = state_.content_results_rows;
10345
+ const after_submit_ = () => {
10346
+ set_search_showing_recommendation_rows((0, $8ef6232475d44150$export$1c8c715550dc689d));
10347
+ set_search_content_results_rows((0, $d53ebed6f63304e4$export$70ceae36059a1036));
10348
+ }; // do this every time after we have submitted a new query - otherwise there might already be a saved number of rows in the state
9540
10349
  const on_submit_with_unchanged_value_ = () => this.modal_open = false;
9541
10350
  const [get_search_field_value_, set_search_field_value_] = state_.field_value;
9542
10351
  const configured_submit_query_ = new_query => (0, $86b0ff0c85e5fc6c$export$e16630ecb9644a1c)({
@@ -9594,6 +10403,10 @@ class $eb064bc3350276c1$export$ac6237957a15b3f0 {
9594
10403
  submit_query_: configured_submit_query_,
9595
10404
  url_transformer_: url_transformer,
9596
10405
  router_: (0, $8tj43$babelruntimehelpersclassPrivateFieldGet)(this, $eb064bc3350276c1$var$_router),
10406
+ content_search_enabled_: () => {
10407
+ var _classPrivateFieldGet2;
10408
+ return (_classPrivateFieldGet2 = (0, $8tj43$babelruntimehelpersclassPrivateFieldGet)(this, $eb064bc3350276c1$var$_content_search_signal)[0]()) !== null && _classPrivateFieldGet2 !== void 0 ? _classPrivateFieldGet2 : $eb064bc3350276c1$var$content_search_default;
10409
+ },
9597
10410
  instant_results_options_: {
9598
10411
  min_products_to_fetch_: $eb064bc3350276c1$var$min_products_to_fetch_,
9599
10412
  render_instant_card_: render_instant_card,
@@ -9662,6 +10475,12 @@ class $eb064bc3350276c1$export$ac6237957a15b3f0 {
9662
10475
  (0, $8tj43$onCleanup)(() => $eb064bc3350276c1$var$_classStaticPrivateFieldSpecGet($eb064bc3350276c1$export$ac6237957a15b3f0, $eb064bc3350276c1$export$ac6237957a15b3f0, $eb064bc3350276c1$var$_keys_constructed_with).delete(unique_instance_key_for_state));
9663
10476
  });
9664
10477
  }
10478
+ get enable_content_search() {
10479
+ return (0, $8tj43$babelruntimehelpersclassPrivateFieldGet)(this, $eb064bc3350276c1$var$_content_search_signal)[0]();
10480
+ }
10481
+ set enable_content_search(new_state) {
10482
+ (0, $8tj43$babelruntimehelpersclassPrivateFieldGet)(this, $eb064bc3350276c1$var$_content_search_signal)[1](new_state);
10483
+ }
9665
10484
  get on_navigation() {
9666
10485
  // The only non-reactive public property on the class (I don't see it making sense to have it reactive)
9667
10486
  return (0, $8tj43$babelruntimehelpersclassPrivateFieldGet)(this, $eb064bc3350276c1$var$_router).on_navigation_;
@@ -9748,6 +10567,10 @@ function $eb064bc3350276c1$export$f2dc7e4e4aa11abb(props) {
9748
10567
  depict_api_: shared_properties.depict_api_,
9749
10568
  min_products_to_fetch_: $eb064bc3350276c1$var$min_products_to_fetch_,
9750
10569
  local_filter_cache_: state_.local_filter_cache,
10570
+ content_search_enabled_: () => {
10571
+ var _depict_search$enable;
10572
+ return (_depict_search$enable = depict_search.enable_content_search) !== null && _depict_search$enable !== void 0 ? _depict_search$enable : $eb064bc3350276c1$var$content_search_default;
10573
+ },
9751
10574
  search_field_value_: state_.field_value,
9752
10575
  get_search_query_: shared_properties.get_search_query_,
9753
10576
  clear_filters_on_next_submit_: shared_properties.clear_filters_on_next_submit_,
@@ -9777,6 +10600,8 @@ function $eb064bc3350276c1$export$f2dc7e4e4aa11abb(props) {
9777
10600
  search_filters_open_: state_.filters_open,
9778
10601
  search_sorting_open_: state_.sorting_open,
9779
10602
  expanded_filters_: state_.expanded_filters,
10603
+ content_results_rows_: state_.content_results_rows,
10604
+ router_: shared_properties.router_,
9780
10605
  make_category_suggestion_card_: shared_properties.enable_category_suggestions_ ? category_suggestion_ => {
9781
10606
  return (0, $dea31647b99a443b$export$d757d54550ebfb3d)({
9782
10607
  category_suggestion_: category_suggestion_,
@@ -9792,6 +10617,10 @@ function $eb064bc3350276c1$export$f2dc7e4e4aa11abb(props) {
9792
10617
  cols_at_size: (0, $a9c7ba6087881ac2$export$6daf8749b65a1b77)(props.cols_at_size),
9793
10618
  ...grid_spacing_override()
9794
10619
  })),
10620
+ content_layout_options_: (0, $8tj43$createMemo)(() => ({
10621
+ cols_at_size: (0, $a9c7ba6087881ac2$export$6daf8749b65a1b77)((0, $3f7203368ad0d3ca$export$ff7109b9b2b206ba)(props.cols_at_size)),
10622
+ ...grid_spacing_override()
10623
+ })),
9795
10624
  recommendations_layout_options_: (0, $8tj43$createMemo)(() => {
9796
10625
  const {
9797
10626
  extra_depict_options: extra_depict_options