@depict-ai/ui 2.1.12 → 2.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/latest/index.cjs CHANGED
@@ -19,7 +19,7 @@ $parcel$export(module.exports, "ListingProvider", () => $84798aaa863a4909$export
19
19
  $parcel$export(module.exports, "useListing", () => $84798aaa863a4909$export$8d0c4fdbb05a2f2e);
20
20
  $parcel$export(module.exports, "ShopifyContainedImage", () => $a33065cfed827fc0$export$e4b984597b71e989);
21
21
  $parcel$export(module.exports, "SlidableItems", () => $a0e53f99354809d9$export$6649caad96ef8870);
22
- $parcel$export(module.exports, "make_accurate_size_accessor", () => $e5f442fb78c98741$export$9f191182275e9ef);
22
+ $parcel$export(module.exports, "make_accurate_width_accessor", () => $f13855d1b951b24a$export$ebdc3711f7e02ccd);
23
23
  $parcel$export(module.exports, "RecommendationSlider", () => $72f96c4782db0b1b$export$9574e176201e5e8d);
24
24
  $parcel$export(module.exports, "RecommendationGrid", () => $1f8dbf7e28b3eff2$export$9756467d34d91cdb);
25
25
  $parcel$export(module.exports, "ShopifyResponsiveImg", () => $19950faaac026e09$export$6e5611bc7e57e477);
@@ -70,7 +70,7 @@ $parcel$export(module.exports, "defaultColsAtSize", () => $a3280f0aad997933$expo
70
70
  $parcel$export(module.exports, "defaultCategoryTitlePlugin", () => $a3280f0aad997933$export$7bf543b9d9be2c22);
71
71
  $parcel$export(module.exports, "version", () => $b757f75811f3261f$export$83d89fbfd8236492);
72
72
  /*! Depict.ai search and product listing SDK */
73
- const $b757f75811f3261f$export$83d89fbfd8236492 = "2.1.12";
73
+ const $b757f75811f3261f$export$83d89fbfd8236492 = "2.1.14";
74
74
  const $1ab22f2cd39b3061$var$fallback_operator = "in";
75
75
  const $1ab22f2cd39b3061$var$fallback_token = "";
76
76
  const $1ab22f2cd39b3061$var$legacy_filter_prefix = "filter_";
@@ -511,24 +511,30 @@ function $a0e53f99354809d9$export$6649caad96ef8870({
511
511
 
512
512
  /** @jsxImportSource solid-js */
513
513
 
514
- function $e5f442fb78c98741$export$9f191182275e9ef(what_to_watch) {
515
- const [size, setSize] = $gVhhF$solidjs.createSignal();
514
+ function $f13855d1b951b24a$export$ebdc3711f7e02ccd(what_to_watch) {
515
+ const [width, setWidth] = $gVhhF$solidjs.createSignal();
516
516
  const resizeObserver = new ResizeObserver($gVhhF$depictaiutilishared.catchify(records => {
517
517
  for (let j = 0; j < records.length; j++) {
518
518
  const width = records[j].borderBoxSize?.[0]?.inlineSize ?? what_to_watch.getBoundingClientRect().width;
519
- setSize(width);
519
+ setWidth(width);
520
520
  }
521
521
  }));
522
522
  // If we start observing elements before they're in the DOM Chrome (Version 117.0.5938.92 (Official Build) (arm64)) sometimes gives us a resize event with a width of 0 and then doesn't dispatch one with the actual width once it's in the DOM. So we wait until the element is in the DOM before we start observing it.
523
523
  // It doesn't seem to work even when waiting for it to be in the DOM, also wait an animation frame
524
524
  const disconnect = (0, $gVhhF$depictaiutilishared.observer).onexists(what_to_watch, ({
525
525
  element: element
526
- }) => requestAnimationFrame($gVhhF$depictaiutilishared.catchify(() => resizeObserver.observe(element))));
526
+ }) => requestAnimationFrame($gVhhF$depictaiutilishared.catchify(() => {
527
+ const current_size = what_to_watch.getBoundingClientRect().width;
528
+ if (current_size)
529
+ // If element has size, set signal to that. ResizeObserver only triggers when the content is visible in some cases, but it might already have a size. This reduces size filter expanding animation jank in chrome.
530
+ setWidth(current_size);
531
+ resizeObserver.observe(element);
532
+ })));
527
533
  $gVhhF$solidjs.onCleanup(() => {
528
534
  resizeObserver.disconnect();
529
535
  disconnect();
530
536
  });
531
- return size;
537
+ return width;
532
538
  }
533
539
  const $4e04be41243c3d80$var$transform_elements = sorted_cols_at_size => {
534
540
  const cols_at_size = [];
@@ -1514,16 +1520,11 @@ function $47e2cc552c02110c$export$8895d39404bd2bb1(props) {
1514
1520
  if (delay_toast_) return show_configured_toast;else show_configured_toast();
1515
1521
  }
1516
1522
  $gVhhF$solidjsweb.delegateEvents(["click"]);
1517
- const $c77c68e559a1506c$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<svg><path d="M11.669 10.531l9.156-9.156a.78.78 0 0 0 .237-.569c0-.221-.079-.412-.237-.569A.8.8 0 0 0 20.24 0a.77.77 0 0 0-.569.237l-9.14 9.14-9.14-9.14A.79.79 0 0 0 .807 0a.77.77 0 0 0-.569.237A.78.78 0 0 0 0 .807a.77.77 0 0 0 .237.569l9.156 9.156-9.156 9.14c-.159.157-.237.349-.237.569s.079.412.237.569c.085.085.174.148.268.19a1.095 1.095 0 0 0 .316.048.894.894 0 0 0 .285-.048.84.84 0 0 0 .285-.19l9.139-9.14 9.14 9.14a.894.894 0 0 0 .268.19 1.049 1.049 0 0 0 .301.048.941.941 0 0 0 .301-.048.84.84 0 0 0 .285-.19.78.78 0 0 0 .237-.569c0-.221-.079-.412-.237-.569z">`);
1523
+ const $c77c68e559a1506c$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<svg xmlns=http://www.w3.org/2000/svg width=21.064 height=21.047 viewBox="0 0 21.064 21.064"><path d="M11.669 10.531l9.156-9.156a.78.78 0 0 0 .237-.569c0-.221-.079-.412-.237-.569A.8.8 0 0 0 20.24 0a.77.77 0 0 0-.569.237l-9.14 9.14-9.14-9.14A.79.79 0 0 0 .807 0a.77.77 0 0 0-.569.237A.78.78 0 0 0 0 .807a.77.77 0 0 0 .237.569l9.156 9.156-9.156 9.14c-.159.157-.237.349-.237.569s.079.412.237.569c.085.085.174.148.268.19a1.095 1.095 0 0 0 .316.048.894.894 0 0 0 .285-.048.84.84 0 0 0 .285-.19l9.139-9.14 9.14 9.14a.894.894 0 0 0 .268.19 1.049 1.049 0 0 0 .301.048.941.941 0 0 0 .301-.048.84.84 0 0 0 .285-.19.78.78 0 0 0 .237-.569c0-.221-.079-.412-.237-.569z">`);
1518
1524
  function $c77c68e559a1506c$export$3b621d86b1566b2(props = {}) {
1519
1525
  return (() => {
1520
1526
  const _el$ = $gVhhF$solidjsweb.getNextElement($c77c68e559a1506c$var$_tmpl$);
1521
- $gVhhF$solidjsweb.spread(_el$, $gVhhF$solidjsweb.mergeProps(props, {
1522
- "xmlns": "http://www.w3.org/2000/svg",
1523
- "width": "21.064",
1524
- "height": "21.047",
1525
- "viewBox": "0 0 21.064 21.064"
1526
- }), true, true);
1527
+ $gVhhF$solidjsweb.spread(_el$, props, true, true);
1527
1528
  $gVhhF$solidjsweb.runHydrationEvents();
1528
1529
  return _el$;
1529
1530
  })();
@@ -1837,7 +1838,7 @@ $gVhhF$solidjsweb.delegateEvents(["click"]);
1837
1838
  const $1c63082b2da848ad$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span class=count>`),
1838
1839
  $1c63082b2da848ad$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<label class=input-row><div class=left><input type=checkbox><span class=custom-indicator></span><span class="text line-clamp"></span></div><!$><!/>`);
1839
1840
  const $1c63082b2da848ad$export$48513f6b9f8ce62d = props => {
1840
- // 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
1841
+ /* don't destructure props, it could have reactive getters */ // 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
1841
1842
  const count = $gVhhF$solidjs.createMemo(() => props.count_);
1842
1843
  const label = $gVhhF$solidjs.createMemo(() => props.label_);
1843
1844
  const checked = $gVhhF$solidjs.createMemo(() => props.checked_);
@@ -1930,6 +1931,78 @@ function $0fe1e7efdf4200d6$export$ca21a16d65b3dd8({
1930
1931
  })();
1931
1932
  }
1932
1933
  $gVhhF$solidjsweb.delegateEvents(["click"]);
1934
+ const $d023ed916c84e75d$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span class=highlighted-part>`),
1935
+ $d023ed916c84e75d$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span>`);
1936
+ function $d023ed916c84e75d$export$ba17c5b7e6dda39f({
1937
+ whole_text_to_display_: whole_text_to_display_memo,
1938
+ searching_for_value_: searching_for_value_memo,
1939
+ class_: class_
1940
+ }) {
1941
+ const [get_has_highlighted, set_has_highlighted] = $gVhhF$solidjs.createSignal(false);
1942
+ const text_itself = $gVhhF$solidjs.createMemo(() => $gVhhF$solidjs.batch(() => {
1943
+ set_has_highlighted(false);
1944
+ const searching_for_value = searching_for_value_memo();
1945
+ const whole_text_to_display_ = whole_text_to_display_memo();
1946
+ let for_black = "";
1947
+ let pushed_grey = false;
1948
+ const search_q = searching_for_value;
1949
+ if (!search_q) return whole_text_to_display_;
1950
+ const output = [];
1951
+ const searching_for = search_q.toLowerCase();
1952
+ const push_black = () => {
1953
+ if (for_black) {
1954
+ set_has_highlighted(true);
1955
+ output.push((() => {
1956
+ const _el$ = $gVhhF$solidjsweb.getNextElement($d023ed916c84e75d$var$_tmpl$);
1957
+ $gVhhF$solidjsweb.insert(_el$, for_black);
1958
+ return _el$;
1959
+ })()); // "black"
1960
+ for_black = "";
1961
+ }
1962
+ };
1963
+ for (let i = 0; i < whole_text_to_display_.length;) {
1964
+ let is_whole_word = true;
1965
+ let searching_for_but_with_texts_casing = "";
1966
+ const i_at_start = i;
1967
+ for (let j = 0; j < searching_for.length; i++, j++) {
1968
+ const letter_in_suggestion = whole_text_to_display_[i];
1969
+ if (letter_in_suggestion?.toLowerCase() !== searching_for[j]) {
1970
+ is_whole_word = false;
1971
+ i = i_at_start;
1972
+ break;
1973
+ }
1974
+ searching_for_but_with_texts_casing += letter_in_suggestion;
1975
+ }
1976
+ if (is_whole_word) {
1977
+ push_black();
1978
+ output.push(searching_for_but_with_texts_casing);
1979
+ pushed_grey = true;
1980
+ } else for_black += whole_text_to_display_[i++];
1981
+ }
1982
+ push_black();
1983
+ if (!pushed_grey) {
1984
+ set_has_highlighted(false);
1985
+ return whole_text_to_display_;
1986
+ }
1987
+ return output;
1988
+ }));
1989
+ return (() => {
1990
+ const _el$2 = $gVhhF$solidjsweb.getNextElement($d023ed916c84e75d$var$_tmpl$2);
1991
+ $gVhhF$solidjsweb.className(_el$2, class_);
1992
+ $gVhhF$solidjsweb.insert(_el$2, text_itself);
1993
+ $gVhhF$solidjsweb.effect(_p$ => {
1994
+ const _v$ = !!get_has_highlighted(),
1995
+ _v$2 = whole_text_to_display_memo() /* for when line-clamped, users can see full text on hover */;
1996
+ _v$ !== _p$._v$ && _el$2.classList.toggle("has-match", _p$._v$ = _v$);
1997
+ _v$2 !== _p$._v$2 && $gVhhF$solidjsweb.setAttribute(_el$2, "title", _p$._v$2 = _v$2);
1998
+ return _p$;
1999
+ }, {
2000
+ _v$: undefined,
2001
+ _v$2: undefined
2002
+ });
2003
+ return _el$2;
2004
+ })();
2005
+ }
1933
2006
  const $d94869c80e337a3d$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<form class=checkboxes><!$><!/><!$><!/>`);
1934
2007
  const $d94869c80e337a3d$var$max_visible_without_collapsing = 15;
1935
2008
  const $d94869c80e337a3d$var$show_non_collapsible_when_collapsed = 4;
@@ -1937,7 +2010,8 @@ function $d94869c80e337a3d$export$dd948f91abc3a1c4({
1937
2010
  filter_: filter_,
1938
2011
  selected_filters_: [get_selected_filters, set_selected_filters],
1939
2012
  i18n_: i18n_,
1940
- view_more_button_below_group_: [, set_view_more_button_below_group_]
2013
+ view_more_button_below_group_: [, set_view_more_button_below_group_],
2014
+ filter_query_: filter_query_
1941
2015
  }) {
1942
2016
  const existing_filter = $gVhhF$solidjs.createMemo(() => {
1943
2017
  const {
@@ -1965,12 +2039,18 @@ function $d94869c80e337a3d$export$dd948f91abc3a1c4({
1965
2039
  const value = $daa394359b026187$export$325f75597868c4f0(checkbox().value_);
1966
2040
  return !!data?.some(item => $daa394359b026187$export$325f75597868c4f0(item) === value);
1967
2041
  });
2042
+ const value = $gVhhF$solidjs.createMemo(() => checkbox().value_);
1968
2043
  return $gVhhF$solidjsweb.createComponent((0, $1c63082b2da848ad$export$48513f6b9f8ce62d), {
1969
2044
  get value_() {
1970
- return checkbox().value_;
2045
+ return value();
1971
2046
  },
1972
2047
  get label_() {
1973
- return checkbox().name_;
2048
+ return $gVhhF$solidjsweb.createComponent((0, $d023ed916c84e75d$export$ba17c5b7e6dda39f), {
2049
+ get whole_text_to_display_() {
2050
+ return $gVhhF$solidjs.createMemo(() => checkbox().name_ || value());
2051
+ },
2052
+ searching_for_value_: () => filter_query_?.()
2053
+ });
1974
2054
  },
1975
2055
  get count_() {
1976
2056
  return checkbox().count_;
@@ -2062,7 +2142,8 @@ const $c1dc1554c1b94233$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<f
2062
2142
  $c1dc1554c1b94233$var$_tmpl$3 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<label class=input-row><div class=left><input type=radio><span class=custom-indicator></span><!$><!/></div><!$><!/>`);
2063
2143
  function $c1dc1554c1b94233$export$430444115f70a734({
2064
2144
  selected_filters_: selected_filters_,
2065
- filter_: filter_
2145
+ filter_: filter_,
2146
+ filter_query_: filter_query_
2066
2147
  }) {
2067
2148
  const radio_name = $gVhhF$depictaiutilishared.make_random_classname();
2068
2149
  const existing_filter = $gVhhF$solidjs.createMemo(() => {
@@ -2084,6 +2165,12 @@ function $c1dc1554c1b94233$export$430444115f70a734({
2084
2165
  children: (value, index) => {
2085
2166
  const random_selector = $gVhhF$depictaiutilishared.make_random_classname();
2086
2167
  const count = $gVhhF$solidjs.createMemo(() => filter_().meta.counts?.[index]);
2168
+ const label = $gVhhF$solidjs.createMemo(() => {
2169
+ const name = filter_().meta?.names?.[index];
2170
+ if (name) return name;
2171
+ const v = value();
2172
+ return Array.isArray(v) ? v.join(" - ") : v + "";
2173
+ });
2087
2174
  return (() => {
2088
2175
  const _el$2 = $gVhhF$solidjsweb.getNextElement($c1dc1554c1b94233$var$_tmpl$3),
2089
2176
  _el$3 = _el$2.firstChild,
@@ -2108,11 +2195,9 @@ function $c1dc1554c1b94233$export$430444115f70a734({
2108
2195
  }));
2109
2196
  $gVhhF$solidjsweb.setAttribute(_el$4, "id", random_selector);
2110
2197
  $gVhhF$solidjsweb.setAttribute(_el$4, "name", radio_name);
2111
- $gVhhF$solidjsweb.insert(_el$3, $gVhhF$solidjs.createMemo(() => {
2112
- const name = filter_().meta?.names?.[index];
2113
- if (name) return name;
2114
- const v = value();
2115
- return Array.isArray(v) ? v.join(" - ") : v;
2198
+ $gVhhF$solidjsweb.insert(_el$3, $gVhhF$solidjsweb.createComponent((0, $d023ed916c84e75d$export$ba17c5b7e6dda39f), {
2199
+ whole_text_to_display_: label,
2200
+ searching_for_value_: () => filter_query_?.()
2116
2201
  }), _el$7, _co$);
2117
2202
  $gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
2118
2203
  get when() {
@@ -2144,7 +2229,8 @@ const $0b7222ba8a8bb72f$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<d
2144
2229
  function $0b7222ba8a8bb72f$export$e0d834a0ad870cda({
2145
2230
  filter_: filter_,
2146
2231
  selected_filters_: selected_filters_,
2147
- i18n_: i18n_
2232
+ i18n_: i18n_,
2233
+ filter_query_: filter_query_
2148
2234
  }) {
2149
2235
  // If you ever attempt to implement that one can drag one range "knob" over the other like on prisjakt, see https://gitlab.com/depict-ai/depict.ai/-/merge_requests/8458/diffs?commit_id=c52dbdd15ca073489bee138b15d27bb6bf2992df
2150
2236
  // The issue with it is that one wants to discard the changes to the lower value as soon as the lower value has become the upper value when dragging the initially lower knob over the initially upper knob
@@ -2523,142 +2609,411 @@ function $7567511a7c3e4bd7$export$e5c2828934226505({
2523
2609
  });
2524
2610
  return outer_div;
2525
2611
  }
2526
- const $3bdc00a1353c1150$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<form class="checkboxes hierarchical"><!$><!/><!$><!/>`),
2527
- $3bdc00a1353c1150$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=checkbox-details><!$><!/><!$><!/>`),
2528
- $3bdc00a1353c1150$var$_tmpl$3 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<details>`),
2529
- $3bdc00a1353c1150$var$_tmpl$4 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<summary class=category-parent><div class=summary><span class=count></span><!$><!/>`);
2530
- const $3bdc00a1353c1150$var$max_visible_without_collapsing = 15;
2531
- const $3bdc00a1353c1150$var$show_non_collapsible_when_collapsed = 4;
2532
- function $3bdc00a1353c1150$export$a32086fa6616eafd({
2533
- filter_: filter_,
2534
- selected_filters_: selected_filters_,
2535
- i18n_: i18n_,
2536
- view_more_button_below_group_: view_more_button_below_group_,
2537
- expanded_hierarchical_filters_: expanded_hierarchical_filters_
2612
+ const $5ea5a82e398f6f44$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span class=highlighted-part>`);
2613
+ const $5ea5a82e398f6f44$var$dont_cut_in_between_less_than_characters = 30;
2614
+ function $5ea5a82e398f6f44$export$e1a98a189fd2c0e7({
2615
+ content_result_: content_result_,
2616
+ key_: key_,
2617
+ cut_when_possible_: cut_when_possible_
2538
2618
  }) {
2539
- let form;
2540
- const existing_filter = $gVhhF$solidjs.createMemo(() => {
2541
- const {
2542
- field: field,
2543
- op: op
2544
- } = filter_();
2545
- return selected_filters_[0]().find(({
2546
- field: checking_field,
2547
- op: checking_op
2548
- }) => checking_field === field && checking_op === op);
2549
- });
2550
- const show_extras = $gVhhF$solidjs.createSignal(false);
2551
- const trigger_sync_ = $3bdc00a1353c1150$var$batching_filter_state_syncer({
2552
- filter_: filter_,
2553
- existing_filter_: existing_filter,
2554
- selected_filters_: selected_filters_,
2555
- get category_structure_() {
2556
- return structured_categories();
2557
- }
2558
- });
2559
- const structured_categories = $gVhhF$solidjs.createMemo(() => {
2560
- const execute_when_structure_finished = [];
2561
- const {
2562
- values: values,
2563
- names: names,
2564
- counts: counts
2565
- } = filter_().meta;
2566
- const data_structure = {};
2567
- for (let i = 0; i < values.length; i++) {
2568
- const value = values[i];
2569
- let pointer = data_structure;
2570
- let parent_ = {};
2571
- let created_an_object = false;
2572
- for (let j = 0; j < value.length; j++) {
2573
- const this_categories_name = value[j];
2574
- const obj = pointer[this_categories_name] ||= (() => {
2575
- const value_as_string = value.map(v => typeof v === "number" ? v + "" : v); // don't think backend will ever send numbers but technically it's allowed;
2576
- const created_obj = {
2577
- name_: names[i],
2578
- count_: counts?.[i],
2579
- parent_: parent_,
2580
- is_expanded_: $3bdc00a1353c1150$var$make_expanded_signal({
2581
- expanded_hierarchical_filters_: expanded_hierarchical_filters_,
2582
- filter_value_: value_as_string
2583
- }),
2584
- value_: value_as_string,
2585
- children_: {}
2586
- };
2587
- const {
2588
- signal_: signal_,
2589
- on_structure_complete_: on_structure_complete_
2590
- } = $3bdc00a1353c1150$var$create_updating_signal({
2591
- self_: created_obj,
2592
- existing_filter_: $gVhhF$solidjs.untrack(existing_filter),
2593
- trigger_sync_: trigger_sync_
2594
- });
2595
- execute_when_structure_finished.push(on_structure_complete_);
2596
- created_obj.is_checked_ = signal_;
2597
- parent_ = created_obj;
2598
- created_an_object = true;
2599
- return created_obj;
2600
- })();
2601
- pointer = obj.children_;
2602
- parent_ = obj;
2603
- }
2604
- if (!created_an_object && "value_" in parent_) {
2605
- // if an object was created for our "depth" in the hierarchy but not for our specific entry this means that the entry array was unsorted and looked something like
2606
- // [
2607
- // ["Öl", "IPA"],
2608
- // ["Öl", "Pale Ale"],
2609
- // ["Öl", "Ale"],
2610
- // ["Öl", "Mörk Lager"],
2611
- // ["Öl", "Suröl"],
2612
- // ["Öl", "Veteöl"],
2613
- // ["Öl", "Stout och Porter"],
2614
- // ["Öl"], // <- We are here, our `hierarchical_data_structure[string]`-object was created when we iterated over ["Öl", "IPA"]
2615
- // ["Öl", "Ljus Lager"],
2616
- // ];
2617
- // In this case we want to just correct the name and value of the already created object, which will be in parent_
2618
- parent_.value_ = value.map(v => v + "");
2619
- parent_.name_ = names[i];
2620
- parent_.count_ = counts[i];
2621
- parent_.is_expanded_ = $3bdc00a1353c1150$var$make_expanded_signal({
2622
- expanded_hierarchical_filters_: expanded_hierarchical_filters_,
2623
- filter_value_: parent_.value_
2624
- });
2625
- }
2626
- }
2627
- while (execute_when_structure_finished.length) execute_when_structure_finished.pop()();
2628
- $3bdc00a1353c1150$var$expand_until_choice(data_structure);
2629
- $gVhhF$depictaiutilishared.dlog("CheckboxHierarchicalFilter: Recomputed structured_categories", data_structure);
2630
- return data_structure;
2631
- });
2632
- const some_top_level_are_hidden = $gVhhF$solidjs.createMemo(() => Object.keys(structured_categories()).length > $3bdc00a1353c1150$var$max_visible_without_collapsing);
2633
- const {
2634
- expand: expand,
2635
- collapse: collapse,
2636
- ExpandingContainer: ExpandingContainer
2637
- } = $4b455f60dadde8b8$export$5bad61ecde080b1f({
2638
- duration: 200
2639
- });
2640
- const expanding_container_els = $gVhhF$solidjsweb.createComponent(ExpandingContainer, {
2619
+ const matched_tokens = $gVhhF$solidjs.createMemo(() => content_result_().highlights?.find(highlight => highlight.field == key_)?.matched_tokens);
2620
+ const full_value = $gVhhF$solidjs.createMemo(() => content_result_()[key_]?.replaceAll("\n", " "));
2621
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
2622
+ get when() {
2623
+ return matched_tokens()?.length;
2624
+ },
2625
+ get fallback() {
2626
+ return full_value();
2627
+ },
2641
2628
  get children() {
2642
- return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
2643
- get when() {
2644
- return some_top_level_are_hidden();
2645
- },
2646
- get children() {
2647
- return $3bdc00a1353c1150$var$render_stuff($gVhhF$solidjs.createMemo(() => Object.fromEntries(Object.entries(structured_categories()).slice($3bdc00a1353c1150$var$show_non_collapsible_when_collapsed))), existing_filter, i18n_);
2648
- }
2649
- });
2629
+ return (() => {
2630
+ const segmented_cut_text = $gVhhF$solidjs.createMemo(() => {
2631
+ const segmented_text = $5ea5a82e398f6f44$export$1b00d74faf266c56(full_value(), matched_tokens());
2632
+ if (cut_when_possible_) $5ea5a82e398f6f44$var$cut_text(segmented_text);
2633
+ return segmented_text;
2634
+ });
2635
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Index), {
2636
+ get each() {
2637
+ return segmented_cut_text();
2638
+ },
2639
+ children: item => {
2640
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
2641
+ get when() {
2642
+ return item().highlighted_;
2643
+ },
2644
+ get fallback() {
2645
+ return item().text_;
2646
+ },
2647
+ get children() {
2648
+ const _el$ = $gVhhF$solidjsweb.getNextElement($5ea5a82e398f6f44$var$_tmpl$);
2649
+ $gVhhF$solidjsweb.insert(_el$, () => item().text_);
2650
+ return _el$;
2651
+ }
2652
+ });
2653
+ }
2654
+ });
2655
+ })();
2650
2656
  }
2651
2657
  });
2652
- $gVhhF$solidjs.createRenderEffect(() => {
2653
- view_more_button_below_group_[1](some_top_level_are_hidden() ? $gVhhF$solidjsweb.createComponent((0, $0fe1e7efdf4200d6$export$ca21a16d65b3dd8), {
2654
- show_extras_: show_extras,
2655
- i18n_: i18n_
2656
- }) : []);
2657
- });
2658
- $gVhhF$solidjs.createEffect($gVhhF$depictaiutilishared.catchify(async () => {
2659
- if (!some_top_level_are_hidden()) {
2660
- await collapse();
2661
- return;
2658
+ }
2659
+ function $5ea5a82e398f6f44$var$cut_text(segmented_text) {
2660
+ // cut away chunks of text that are not highlighted to give a google-like overview of the content
2661
+ const highlighted_segments = segmented_text?.filter(segment => segment.highlighted_);
2662
+ if (!segmented_text || !highlighted_segments?.length) return;
2663
+ // We have one or more highlighted segments
2664
+ if (highlighted_segments.length === 1) {
2665
+ // cut away from the left until the start of the highlighted sentence if just one sentence is highlighted
2666
+ $5ea5a82e398f6f44$var$cut_start(segmented_text.indexOf(highlighted_segments[0]), segmented_text);
2667
+ return;
2668
+ }
2669
+ // We have two or more highlighted segments, take the two biggest chunks and show them + a bit text around
2670
+ 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
2671
+ );
2672
+
2673
+ const [longest_segment, next_longest_segment] = sorted_highlighted_segments;
2674
+ // We need to cut before the first segment - possibly through other segments - and maybe between segments
2675
+ 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);
2676
+ $5ea5a82e398f6f44$var$cut_start(index_of_first_segment, segmented_text);
2677
+ // update indexes since we might have removed segments
2678
+ [index_of_first_segment, index_of_second_segment] = [segmented_text.indexOf(longest_segment), segmented_text.indexOf(next_longest_segment)].sort((a, b) => a - b);
2679
+ let number_of_characters_between_segments = 0;
2680
+ for (let i = index_of_first_segment + 1; i < index_of_second_segment; i++) {
2681
+ const segment = segmented_text[i];
2682
+ number_of_characters_between_segments += segment.text_.length;
2683
+ }
2684
+ if (number_of_characters_between_segments < $5ea5a82e398f6f44$var$dont_cut_in_between_less_than_characters)
2685
+ // don't cut if there are less than 30 characters between the two segments
2686
+ return;
2687
+ // We have more than 50 characters between the two segments, cut between them
2688
+ const [split_start_segment, split_start_character] = $5ea5a82e398f6f44$var$find_split_point(index_of_first_segment, index_of_second_segment, segmented_text);
2689
+ const [split_end_segment, split_end_character] = $5ea5a82e398f6f44$var$find_split_point(index_of_second_segment, index_of_first_segment, segmented_text);
2690
+ if (split_start_segment === undefined || split_end_segment === undefined ||
2691
+ // identical split point, or split end before split start, can't do anything
2692
+ split_start_segment == split_end_segment && split_start_character >= split_end_character || split_start_segment > split_end_segment) return;
2693
+ const dots_segment = {
2694
+ text_: " … ",
2695
+ highlighted_: false
2696
+ };
2697
+ const split_and_dotted_values = segmented_text.flatMap((segment, i) => {
2698
+ if (i < split_start_segment || i > split_end_segment) return segment;
2699
+ const text = segment.text_;
2700
+ if (i == split_end_segment && i == split_start_segment) return [{
2701
+ ...segment,
2702
+ text_: text.slice(0, split_start_character).trimEnd()
2703
+ }, dots_segment, {
2704
+ ...segment,
2705
+ text_: text.slice(split_end_character + 1, text.length).trimStart()
2706
+ }];else if (i == split_start_segment) {
2707
+ 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
2708
+ return segment;
2709
+ } else if (i == split_end_segment) return [dots_segment, {
2710
+ ...segment,
2711
+ text_: text.slice(split_end_character + 1, text.length).trimStart()
2712
+ }];
2713
+ return []; // remove all segments inbetween
2714
+ });
2715
+
2716
+ segmented_text.splice(0, segmented_text.length, ...split_and_dotted_values); // Sorry…
2717
+ $5ea5a82e398f6f44$var$heal_holes(segmented_text);
2718
+ }
2719
+ function $5ea5a82e398f6f44$var$heal_holes(segmented_text) {
2720
+ // try to heal "holes" created in the segments so there are only alternating segments
2721
+ const segments_to_delete = new Set();
2722
+ for (let i = 0; i < segmented_text.length; i++) {
2723
+ const segment = segmented_text[i];
2724
+ let previous_segment;
2725
+ for (let j = i - 1; j >= 0; j--) {
2726
+ previous_segment = segmented_text[j];
2727
+ // Don't write to a segment that's marked for deletion or the contents we write to it will be deleted
2728
+ if (!segments_to_delete.has(previous_segment)) break;
2729
+ }
2730
+ if (previous_segment?.highlighted_ && segment.highlighted_ || previous_segment?.highlighted_ === false && segment.highlighted_ === false) {
2731
+ previous_segment.text_ += segment.text_; // IDK if this ever happens
2732
+ segments_to_delete.add(segment);
2733
+ }
2734
+ }
2735
+ for (const segment of segments_to_delete) {
2736
+ const index = segmented_text.indexOf(segment);
2737
+ segmented_text.splice(index, 1);
2738
+ }
2739
+ }
2740
+ function $5ea5a82e398f6f44$var$find_split_point(index_of_start_segment, index_of_end_segment, segmented_text, be_very_aggressive = true) {
2741
+ const should_loop_backwards = index_of_start_segment > index_of_end_segment;
2742
+ const step = should_loop_backwards ? -1 : 1;
2743
+ const desperate_split_attempts = [":", ";", ","];
2744
+ while (desperate_split_attempts.length) {
2745
+ const split_point_between_words = [];
2746
+ // for the middle also try to split with a few more characters if the default ones don't work over a full run
2747
+ const desperate_split_attempt = desperate_split_attempts.pop();
2748
+ let is_first_character = true;
2749
+ for (let i = index_of_start_segment + step; should_loop_backwards ? i > index_of_end_segment : i < index_of_end_segment; i += step) {
2750
+ const segment = segmented_text[i];
2751
+ const text = segment.text_;
2752
+ for (let j = should_loop_backwards ? text.length - 1 : 0; should_loop_backwards ? j >= 0 : j < text.length; j += step) {
2753
+ const character = text[j];
2754
+ if (character == "." || character == "?" || character == "!" || character == desperate_split_attempt) return [i, j]; // segment index, character index
2755
+ if (is_first_character) is_first_character = false;else if (be_very_aggressive && character == " ") {
2756
+ split_point_between_words.push([i, j]);
2757
+ if (split_point_between_words.length > 3)
2758
+ // We can't find a split point, so we'll just split between words
2759
+ // 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
2760
+ return split_point_between_words[1];
2761
+ }
2762
+ }
2763
+ }
2764
+ }
2765
+ return [];
2766
+ }
2767
+ function $5ea5a82e398f6f44$var$cut_start(cut_left_of_index, segmented_text) {
2768
+ // Cut the start of the text to bring the first matching token
2769
+ let is_first_character = false;
2770
+ let words_encountered = 0;
2771
+ outmost_loop: for (let i = cut_left_of_index - 1; i >= 0; i--) {
2772
+ const segment = segmented_text[i];
2773
+ // We assume that two adjacent highlighted segments don't exist and have been merged if they were to have existed
2774
+ const text = segment.text_;
2775
+ for (let j = text.length - 1; j >= 0; j--) {
2776
+ const character = text[j];
2777
+ const is_space = character == " ";
2778
+ if (!is_first_character && is_space) words_encountered++;
2779
+ if (character == "." || character == "?" || character == "!" || character == "," || words_encountered > 8 && is_space) {
2780
+ // We have to be really aggressive at the start of sentences so stuff can be seen on mobile, hence comma
2781
+ segment.text_ = text.slice(j + 1).trimStart();
2782
+ segmented_text.splice(0, i);
2783
+ if (character === "," || is_space)
2784
+ // if we cut at a comma or psace, we add a … at the beginning
2785
+ segmented_text.unshift({
2786
+ text_: "… ",
2787
+ highlighted_: false
2788
+ });
2789
+ break outmost_loop;
2790
+ }
2791
+ if (is_first_character) is_first_character = false;
2792
+ }
2793
+ }
2794
+ $5ea5a82e398f6f44$var$heal_holes(segmented_text); // if we added a ... there could now be a sequence that's not alternating true/false
2795
+ }
2796
+
2797
+ function $5ea5a82e398f6f44$export$1b00d74faf266c56(text, matched_strings, loose = false) {
2798
+ const output = [];
2799
+ if (!text) return; // shouldn't happen but whatever
2800
+ for (let i = 0; i < text.length; i++) {
2801
+ const found_strings = [];
2802
+ if (!i || text[i - 1] == " " || loose)
2803
+ // only match at the start of a word or string, it looks weird if i.e. "we" is highlighted in "activewear
2804
+ for (let j = 0; j < matched_strings.length; j++) {
2805
+ const matched_string = matched_strings[j];
2806
+ const part_in_text = text.slice(i, i + matched_string.length);
2807
+ if (matched_string.length < 2 && !loose) continue; // don't match on single characters, i.e. "I", it looks weird
2808
+ 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
2809
+ }
2810
+
2811
+ const last_index_in_output = output.length - 1;
2812
+ if (!found_strings.length) {
2813
+ const character = text[i];
2814
+ if (output[last_index_in_output]?.highlighted_ === false || output.length && /\s/.test(character))
2815
+ // 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
2816
+ output[last_index_in_output].text_ += character;else output.push({
2817
+ highlighted_: false,
2818
+ text_: character
2819
+ });
2820
+ } else {
2821
+ const longest_found_string = found_strings.reduce((a, b) => a.length > b.length ? a : b);
2822
+ if (output[last_index_in_output]?.highlighted_) output[last_index_in_output].text_ += longest_found_string;else output.push({
2823
+ highlighted_: true,
2824
+ text_: longest_found_string
2825
+ });
2826
+ i += longest_found_string.length - 1;
2827
+ }
2828
+ }
2829
+ return output;
2830
+ }
2831
+ const $f6efb1605fcb9f39$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span>`),
2832
+ $f6efb1605fcb9f39$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span class=highlighted-part>`);
2833
+ function $f6efb1605fcb9f39$export$8e79c28529dbfa90(props) {
2834
+ const segmented_text = $gVhhF$solidjs.createMemo(() => {
2835
+ const {
2836
+ to_highlight_: to_highlight_,
2837
+ text_: text_
2838
+ } = props;
2839
+ return $5ea5a82e398f6f44$export$1b00d74faf266c56(text_, to_highlight_ ? [to_highlight_] : [], true);
2840
+ });
2841
+ const has_highlights = $gVhhF$solidjs.createMemo(() => segmented_text().some(segment => segment.highlighted_));
2842
+ return (() => {
2843
+ const _el$ = $gVhhF$solidjsweb.getNextElement($f6efb1605fcb9f39$var$_tmpl$);
2844
+ $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Index), {
2845
+ get each() {
2846
+ return segmented_text();
2847
+ },
2848
+ children: item => {
2849
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
2850
+ get when() {
2851
+ return item().highlighted_;
2852
+ },
2853
+ get fallback() {
2854
+ return item().text_;
2855
+ },
2856
+ get children() {
2857
+ const _el$2 = $gVhhF$solidjsweb.getNextElement($f6efb1605fcb9f39$var$_tmpl$2);
2858
+ $gVhhF$solidjsweb.insert(_el$2, () => item().text_);
2859
+ return _el$2;
2860
+ }
2861
+ });
2862
+ }
2863
+ }));
2864
+ $gVhhF$solidjsweb.effect(_p$ => {
2865
+ const _v$ = props.text_,
2866
+ _v$2 = !!has_highlights();
2867
+ _v$ !== _p$._v$ && $gVhhF$solidjsweb.setAttribute(_el$, "title", _p$._v$ = _v$);
2868
+ _v$2 !== _p$._v$2 && _el$.classList.toggle("has-match", _p$._v$2 = _v$2);
2869
+ return _p$;
2870
+ }, {
2871
+ _v$: undefined,
2872
+ _v$2: undefined
2873
+ });
2874
+ return _el$;
2875
+ })();
2876
+ }
2877
+ const $3bdc00a1353c1150$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<form class="checkboxes hierarchical"><!$><!/><!$><!/>`),
2878
+ $3bdc00a1353c1150$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=checkbox-details><!$><!/><!$><!/>`),
2879
+ $3bdc00a1353c1150$var$_tmpl$3 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<details>`),
2880
+ $3bdc00a1353c1150$var$_tmpl$4 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<summary class=category-parent><div class=summary><span class=count></span><!$><!/>`);
2881
+ const $3bdc00a1353c1150$var$max_visible_without_collapsing = 15;
2882
+ const $3bdc00a1353c1150$var$show_non_collapsible_when_collapsed = 4;
2883
+ function $3bdc00a1353c1150$export$a32086fa6616eafd({
2884
+ filter_: filter_,
2885
+ selected_filters_: selected_filters_,
2886
+ i18n_: i18n_,
2887
+ view_more_button_below_group_: view_more_button_below_group_,
2888
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
2889
+ filter_query_: filter_query_
2890
+ }) {
2891
+ let form;
2892
+ const existing_filter = $gVhhF$solidjs.createMemo(() => {
2893
+ const {
2894
+ field: field,
2895
+ op: op
2896
+ } = filter_();
2897
+ return selected_filters_[0]().find(({
2898
+ field: checking_field,
2899
+ op: checking_op
2900
+ }) => checking_field === field && checking_op === op);
2901
+ });
2902
+ const show_extras = $gVhhF$solidjs.createSignal(false);
2903
+ const is_being_searched_ = $gVhhF$solidjs.createMemo(() => !!filter_query_?.()); // If the user is searching in the filter
2904
+ const trigger_sync_ = $3bdc00a1353c1150$var$batching_filter_state_syncer({
2905
+ filter_: filter_,
2906
+ existing_filter_: existing_filter,
2907
+ selected_filters_: selected_filters_,
2908
+ get category_structure_() {
2909
+ return structured_categories();
2910
+ }
2911
+ });
2912
+ const structured_categories = $gVhhF$solidjs.createMemo(() => {
2913
+ const execute_when_structure_finished = [];
2914
+ const {
2915
+ values: values,
2916
+ names: names,
2917
+ counts: counts
2918
+ } = filter_().meta;
2919
+ const data_structure = {};
2920
+ for (let i = 0; i < values.length; i++) {
2921
+ const value = values[i];
2922
+ let pointer = data_structure;
2923
+ let parent_ = {};
2924
+ let created_an_object = false;
2925
+ for (let j = 0; j < value.length; j++) {
2926
+ const this_categories_name = value[j];
2927
+ const obj = pointer[this_categories_name] ||= (() => {
2928
+ const value_as_string = value.map(v => typeof v === "number" ? v + "" : v); // don't think backend will ever send numbers but technically it's allowed;
2929
+ const created_obj = {
2930
+ name_: names[i],
2931
+ count_: counts?.[i],
2932
+ parent_: parent_,
2933
+ is_expanded_: $3bdc00a1353c1150$var$make_expanded_signal({
2934
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
2935
+ filter_value_: value_as_string,
2936
+ is_being_searched_: is_being_searched_
2937
+ }),
2938
+ value_: value_as_string,
2939
+ children_: {}
2940
+ };
2941
+ const {
2942
+ signal_: signal_,
2943
+ on_structure_complete_: on_structure_complete_
2944
+ } = $3bdc00a1353c1150$var$create_updating_signal({
2945
+ self_: created_obj,
2946
+ existing_filter_: $gVhhF$solidjs.untrack(existing_filter),
2947
+ trigger_sync_: trigger_sync_
2948
+ });
2949
+ execute_when_structure_finished.push(on_structure_complete_);
2950
+ created_obj.is_checked_ = signal_;
2951
+ parent_ = created_obj;
2952
+ created_an_object = true;
2953
+ return created_obj;
2954
+ })();
2955
+ pointer = obj.children_;
2956
+ parent_ = obj;
2957
+ }
2958
+ if (!created_an_object && "value_" in parent_) {
2959
+ // if an object was created for our "depth" in the hierarchy but not for our specific entry this means that the entry array was unsorted and looked something like
2960
+ // [
2961
+ // ["Öl", "IPA"],
2962
+ // ["Öl", "Pale Ale"],
2963
+ // ["Öl", "Ale"],
2964
+ // ["Öl", "Mörk Lager"],
2965
+ // ["Öl", "Suröl"],
2966
+ // ["Öl", "Veteöl"],
2967
+ // ["Öl", "Stout och Porter"],
2968
+ // ["Öl"], // <- We are here, our `hierarchical_data_structure[string]`-object was created when we iterated over ["Öl", "IPA"]
2969
+ // ["Öl", "Ljus Lager"],
2970
+ // ];
2971
+ // In this case we want to just correct the name and value of the already created object, which will be in parent_
2972
+ parent_.value_ = value.map(v => v + "");
2973
+ parent_.name_ = names[i];
2974
+ parent_.count_ = counts?.[i];
2975
+ parent_.is_expanded_ = $3bdc00a1353c1150$var$make_expanded_signal({
2976
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
2977
+ filter_value_: parent_.value_,
2978
+ is_being_searched_: is_being_searched_
2979
+ });
2980
+ }
2981
+ }
2982
+ while (execute_when_structure_finished.length) execute_when_structure_finished.pop()();
2983
+ $3bdc00a1353c1150$var$expand_until_choice(data_structure);
2984
+ $gVhhF$depictaiutilishared.dlog("CheckboxHierarchicalFilter: Recomputed structured_categories", data_structure);
2985
+ return data_structure;
2986
+ });
2987
+ const some_top_level_are_hidden = $gVhhF$solidjs.createMemo(() => Object.keys(structured_categories()).length > $3bdc00a1353c1150$var$max_visible_without_collapsing);
2988
+ const {
2989
+ expand: expand,
2990
+ collapse: collapse,
2991
+ ExpandingContainer: ExpandingContainer
2992
+ } = $4b455f60dadde8b8$export$5bad61ecde080b1f({
2993
+ duration: 200
2994
+ });
2995
+ const expanding_container_els = $gVhhF$solidjsweb.createComponent(ExpandingContainer, {
2996
+ get children() {
2997
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
2998
+ get when() {
2999
+ return some_top_level_are_hidden();
3000
+ },
3001
+ get children() {
3002
+ return $3bdc00a1353c1150$var$render_stuff($gVhhF$solidjs.createMemo(() => Object.fromEntries(Object.entries(structured_categories()).slice($3bdc00a1353c1150$var$show_non_collapsible_when_collapsed))), existing_filter, i18n_, filter_query_);
3003
+ }
3004
+ });
3005
+ }
3006
+ });
3007
+ $gVhhF$solidjs.createRenderEffect(() => {
3008
+ view_more_button_below_group_[1](some_top_level_are_hidden() ? $gVhhF$solidjsweb.createComponent((0, $0fe1e7efdf4200d6$export$ca21a16d65b3dd8), {
3009
+ show_extras_: show_extras,
3010
+ i18n_: i18n_
3011
+ }) : []);
3012
+ });
3013
+ $gVhhF$solidjs.createEffect($gVhhF$depictaiutilishared.catchify(async () => {
3014
+ if (!some_top_level_are_hidden()) {
3015
+ await collapse();
3016
+ return;
2662
3017
  }
2663
3018
  if (show_extras[0]()) await expand();else await collapse();
2664
3019
  }));
@@ -2670,13 +3025,13 @@ function $3bdc00a1353c1150$export$a32086fa6616eafd({
2670
3025
  [_el$5, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$4.nextSibling);
2671
3026
  const _ref$ = form;
2672
3027
  typeof _ref$ === "function" ? $gVhhF$solidjsweb.use(_ref$, _el$) : form = _el$;
2673
- $gVhhF$solidjsweb.insert(_el$, () => $3bdc00a1353c1150$var$render_stuff($gVhhF$solidjs.createMemo(() => some_top_level_are_hidden() ? Object.fromEntries(Object.entries(structured_categories()).slice(0, $3bdc00a1353c1150$var$show_non_collapsible_when_collapsed)) : structured_categories()), existing_filter, i18n_), _el$3, _co$);
3028
+ $gVhhF$solidjsweb.insert(_el$, () => $3bdc00a1353c1150$var$render_stuff($gVhhF$solidjs.createMemo(() => some_top_level_are_hidden() ? Object.fromEntries(Object.entries(structured_categories()).slice(0, $3bdc00a1353c1150$var$show_non_collapsible_when_collapsed)) : structured_categories()), existing_filter, i18n_, filter_query_), _el$3, _co$);
2674
3029
  $gVhhF$solidjsweb.insert(_el$, expanding_container_els, _el$5, _co$2);
2675
3030
  $gVhhF$solidjsweb.effect(() => _el$.classList.toggle("any-expandable", !!Object.values(structured_categories()).some(category => Object.keys(category.children_).length)));
2676
3031
  return _el$;
2677
3032
  })();
2678
3033
  }
2679
- function $3bdc00a1353c1150$var$render_stuff(data, existing_filter, i18n_) {
3034
+ function $3bdc00a1353c1150$var$render_stuff(data, existing_filter, i18n_, filter_query_) {
2680
3035
  const keys = $gVhhF$solidjs.createMemo(() => Object.keys(data()));
2681
3036
  return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.For), {
2682
3037
  get each() {
@@ -2691,6 +3046,8 @@ function $3bdc00a1353c1150$var$render_stuff(data, existing_filter, i18n_) {
2691
3046
  // for some reason the for thing doesn't dispose of us if the key no longer exists?? so I'm doing it with show instead
2692
3047
  const value = $gVhhF$solidjs.createMemo(() => data()[key]); // still sometimes get undefined here even though we have <Show>
2693
3048
  const has_expandable = $gVhhF$solidjs.createMemo(() => !!Object.keys(value()?.children_ || {}).length);
3049
+ const value_as_string = $gVhhF$solidjs.createMemo(() => JSON.stringify(value()?.value_));
3050
+ const label_text = $gVhhF$solidjs.createMemo(() => value()?.name_ || value_as_string());
2694
3051
  return (() => {
2695
3052
  const _el$6 = $gVhhF$solidjsweb.getNextElement($3bdc00a1353c1150$var$_tmpl$2),
2696
3053
  _el$7 = _el$6.firstChild,
@@ -2699,10 +3056,17 @@ function $3bdc00a1353c1150$var$render_stuff(data, existing_filter, i18n_) {
2699
3056
  [_el$10, _co$4] = $gVhhF$solidjsweb.getNextMarker(_el$9.nextSibling);
2700
3057
  $gVhhF$solidjsweb.insert(_el$6, $gVhhF$solidjsweb.createComponent((0, $1c63082b2da848ad$export$48513f6b9f8ce62d), {
2701
3058
  get value_() {
2702
- return JSON.stringify(value()?.value_);
3059
+ return value_as_string();
2703
3060
  },
2704
3061
  get label_() {
2705
- return value()?.name_;
3062
+ return $gVhhF$solidjsweb.createComponent((0, $f6efb1605fcb9f39$export$8e79c28529dbfa90), {
3063
+ get text_() {
3064
+ return label_text();
3065
+ },
3066
+ get to_highlight_() {
3067
+ return filter_query_?.();
3068
+ }
3069
+ });
2706
3070
  },
2707
3071
  get count_() {
2708
3072
  return $gVhhF$solidjsweb.memo(() => !!has_expandable())() ? undefined : value()?.count_;
@@ -2782,7 +3146,7 @@ function $3bdc00a1353c1150$var$render_stuff(data, existing_filter, i18n_) {
2782
3146
  return is_open();
2783
3147
  },
2784
3148
  get children() {
2785
- return $3bdc00a1353c1150$var$render_stuff($gVhhF$solidjs.createMemo(() => value()?.children_ || {}), existing_filter, i18n_);
3149
+ return $3bdc00a1353c1150$var$render_stuff($gVhhF$solidjs.createMemo(() => value()?.children_ || {}), existing_filter, i18n_, filter_query_);
2786
3150
  }
2787
3151
  });
2788
3152
  })();
@@ -2893,7 +3257,8 @@ function $3bdc00a1353c1150$var$create_updating_signal({
2893
3257
  }
2894
3258
  function $3bdc00a1353c1150$var$make_expanded_signal({
2895
3259
  expanded_hierarchical_filters_: [read_expanded_hierarchical_filters, write_expanded_hierarchical_filters],
2896
- filter_value_: filter_value_
3260
+ filter_value_: filter_value_,
3261
+ is_being_searched_: is_being_searched_
2897
3262
  }) {
2898
3263
  const index_in_expanded_filters = $gVhhF$solidjs.createMemo(() => read_expanded_hierarchical_filters().findIndex(({
2899
3264
  value_: value_
@@ -2932,7 +3297,9 @@ function $3bdc00a1353c1150$var$make_expanded_signal({
2932
3297
  defer: true
2933
3298
  }));
2934
3299
  return {
2935
- ui_should_show_expanded_: $gVhhF$solidjs.createMemo(() => user_choice_signal[0]() ?? get_low_precedence_expanded()),
3300
+ ui_should_show_expanded_: $gVhhF$solidjs.createMemo(
3301
+ // When user is searching through filters, expand everything they haven't collapsed, so they can see the results
3302
+ () => user_choice_signal[0]() ?? (is_being_searched_() || get_low_precedence_expanded())),
2936
3303
  set_low_precedence_expanded_: set_low_precedence_expanded,
2937
3304
  set_user_expanded_: set_user_choice_expanded
2938
3305
  };
@@ -2961,7 +3328,9 @@ const $0ef1681699140f1a$var$gap_px = 5;
2961
3328
  const $0ef1681699140f1a$var$max_columns = 3;
2962
3329
  const $0ef1681699140f1a$export$414f6a19d38e655c = ({
2963
3330
  filter_: filter_,
2964
- selected_filters_: [get_selected_filters, set_selected_filters]
3331
+ selected_filters_: [get_selected_filters, set_selected_filters],
3332
+ filter_query_: filter_query_,
3333
+ details_element_width_: details_element_width_
2965
3334
  }) => {
2966
3335
  const existing_filter = $gVhhF$solidjs.createMemo(() => {
2967
3336
  const {
@@ -2989,7 +3358,7 @@ const $0ef1681699140f1a$export$414f6a19d38e655c = ({
2989
3358
  const container_width_accessor = $gVhhF$solidjs.createMemo(() => {
2990
3359
  const element = container();
2991
3360
  if (!element) return;
2992
- return $e5f442fb78c98741$export$9f191182275e9ef(element);
3361
+ return $f13855d1b951b24a$export$ebdc3711f7e02ccd(element);
2993
3362
  });
2994
3363
  const [shadow_children, set_shadow_children] = $gVhhF$solidjs.createSignal(new Set(), {
2995
3364
  equals: false
@@ -3000,11 +3369,11 @@ const $0ef1681699140f1a$export$414f6a19d38e655c = ({
3000
3369
  return _el$;
3001
3370
  })(); // for getting the smallest possible sizes of all the items
3002
3371
  $gVhhF$solidjs.createEffect(() => {
3003
- const container_width = container_width_accessor()?.();
3004
- if (container_width == undefined) return;
3372
+ const container_width = container_width_accessor()?.() || details_element_width_();
3373
+ if (container_width === undefined) return; // On firefox, unexpanded <details> elements' contents dont't have a width, fall back to the width of the details element itself to not have janky expanding animations due to wrong number of columns at point of expanding
3005
3374
  $0ef1681699140f1a$var$adjust_sizes(container_width, sizes_set(), set_cols_at_size);
3006
3375
  });
3007
- return [shadow_grid, $gVhhF$solidjsweb.createComponent((0, $f48d0fbb00835aaa$export$d21e32dfedac04be), {
3376
+ return [$gVhhF$solidjsweb.createComponent((0, $f48d0fbb00835aaa$export$d21e32dfedac04be), {
3008
3377
  get cols_at_size() {
3009
3378
  return cols_at_size();
3010
3379
  },
@@ -3026,66 +3395,72 @@ const $0ef1681699140f1a$export$414f6a19d38e655c = ({
3026
3395
  const current_value = $daa394359b026187$export$325f75597868c4f0(value().value_);
3027
3396
  return !!data?.some(item => $daa394359b026187$export$325f75597868c4f0(item) === current_value);
3028
3397
  });
3029
- const MakeButton = attributes => (() => {
3030
- const _el$2 = $gVhhF$solidjsweb.getNextElement($0ef1681699140f1a$var$_tmpl$3),
3031
- _el$5 = _el$2.firstChild,
3032
- [_el$6, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$5.nextSibling),
3033
- _el$7 = _el$6.nextSibling,
3034
- [_el$8, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$7.nextSibling);
3035
- $gVhhF$solidjsweb.spread(_el$2, $gVhhF$solidjsweb.mergeProps(attributes, {
3036
- get disabled() {
3037
- return $gVhhF$solidjsweb.memo(() => value().count_ === 0)() && !is_selected();
3038
- },
3039
- get classList() {
3040
- return {
3041
- minor: !is_selected(),
3042
- major: is_selected(),
3043
- "major-minor-transition": true
3044
- };
3045
- },
3046
- get onClick() {
3047
- return $gVhhF$depictaiutilishared.catchify(() => {
3048
- const set_filter = existing_filter();
3049
- const {
3050
- field: field,
3051
- op: op
3052
- } = filter_();
3053
- const base_object = set_filter ? set_filter : {
3054
- op: op,
3055
- field: field
3056
- };
3057
- const old_data = base_object.data;
3058
- const new_data = [...(Array.isArray(old_data) ? [...old_data] : old_data ? [old_data] : [])];
3059
- const new_filter_object = {
3060
- ...base_object,
3061
- data: new_data
3398
+ const MakeButton = attributes => {
3399
+ const label = $gVhhF$solidjs.createMemo(() => value().name_ || value().value_ + "");
3400
+ return (() => {
3401
+ const _el$2 = $gVhhF$solidjsweb.getNextElement($0ef1681699140f1a$var$_tmpl$3),
3402
+ _el$5 = _el$2.firstChild,
3403
+ [_el$6, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$5.nextSibling),
3404
+ _el$7 = _el$6.nextSibling,
3405
+ [_el$8, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$7.nextSibling);
3406
+ $gVhhF$solidjsweb.spread(_el$2, $gVhhF$solidjsweb.mergeProps(attributes, {
3407
+ get disabled() {
3408
+ return $gVhhF$solidjsweb.memo(() => value().count_ === 0)() && !is_selected();
3409
+ },
3410
+ get classList() {
3411
+ return {
3412
+ minor: !is_selected(),
3413
+ major: is_selected(),
3414
+ "major-minor-transition": true
3062
3415
  };
3063
- if (!is_selected()) new_filter_object.data.push(value().value_);else {
3064
- const current_value_lower = $daa394359b026187$export$325f75597868c4f0(value().value_);
3065
- new_filter_object.data = new_filter_object.data.filter(v => $daa394359b026187$export$325f75597868c4f0(v) !== current_value_lower);
3066
- }
3067
- const selected_filters = [...get_selected_filters().filter(f => f !== set_filter), ...(new_filter_object.data.length ? [new_filter_object] : [])];
3068
- set_selected_filters(selected_filters);
3069
- });
3070
- }
3071
- }), false, true);
3072
- $gVhhF$solidjsweb.insert(_el$2, () => value().value_, _el$6, _co$);
3073
- $gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
3074
- get when() {
3075
- return value().count_ != undefined;
3076
- },
3077
- get children() {
3078
- const _el$3 = $gVhhF$solidjsweb.getNextElement($0ef1681699140f1a$var$_tmpl$2),
3079
- _el$4 = _el$3.firstChild;
3080
- $gVhhF$solidjsweb.insert(_el$4, () => value().count_);
3081
- return _el$3;
3082
- }
3083
- }), _el$8, _co$2);
3084
- $gVhhF$solidjsweb.runHydrationEvents();
3085
- return _el$2;
3086
- })();
3416
+ },
3417
+ get onClick() {
3418
+ return $gVhhF$depictaiutilishared.catchify(() => {
3419
+ const set_filter = existing_filter();
3420
+ const {
3421
+ field: field,
3422
+ op: op
3423
+ } = filter_();
3424
+ const base_object = set_filter ? set_filter : {
3425
+ op: op,
3426
+ field: field
3427
+ };
3428
+ const old_data = base_object.data;
3429
+ const new_data = [...(Array.isArray(old_data) ? [...old_data] : old_data ? [old_data] : [])];
3430
+ const new_filter_object = {
3431
+ ...base_object,
3432
+ data: new_data
3433
+ };
3434
+ if (!is_selected()) new_filter_object.data.push(value().value_);else {
3435
+ const current_value_lower = $daa394359b026187$export$325f75597868c4f0(value().value_);
3436
+ new_filter_object.data = new_filter_object.data.filter(v => $daa394359b026187$export$325f75597868c4f0(v) !== current_value_lower);
3437
+ }
3438
+ const selected_filters = [...get_selected_filters().filter(f => f !== set_filter), ...(new_filter_object.data.length ? [new_filter_object] : [])];
3439
+ set_selected_filters(selected_filters);
3440
+ });
3441
+ }
3442
+ }), false, true);
3443
+ $gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $d023ed916c84e75d$export$ba17c5b7e6dda39f), {
3444
+ whole_text_to_display_: label,
3445
+ searching_for_value_: () => filter_query_?.()
3446
+ }), _el$6, _co$);
3447
+ $gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
3448
+ get when() {
3449
+ return value().count_ != undefined;
3450
+ },
3451
+ get children() {
3452
+ const _el$3 = $gVhhF$solidjsweb.getNextElement($0ef1681699140f1a$var$_tmpl$2),
3453
+ _el$4 = _el$3.firstChild;
3454
+ $gVhhF$solidjsweb.insert(_el$4, () => value().count_);
3455
+ return _el$3;
3456
+ }
3457
+ }), _el$8, _co$2);
3458
+ $gVhhF$solidjsweb.runHydrationEvents();
3459
+ return _el$2;
3460
+ })();
3461
+ };
3087
3462
  const invisible_size_button = $gVhhF$solidjsweb.createComponent(MakeButton, {});
3088
- const smallest_possible_size = $e5f442fb78c98741$export$9f191182275e9ef(invisible_size_button); // create ResizeObserver for the invisible size button where the div hugs its content
3463
+ const smallest_possible_size = $f13855d1b951b24a$export$ebdc3711f7e02ccd(invisible_size_button); // create ResizeObserver for the invisible size button where the div hugs its content
3089
3464
  const sizes_value = $gVhhF$solidjs.untrack(sizes_set);
3090
3465
  const shadow_children_value = $gVhhF$solidjs.untrack(shadow_children);
3091
3466
  sizes_value.add(smallest_possible_size);
@@ -3105,7 +3480,7 @@ const $0ef1681699140f1a$export$414f6a19d38e655c = ({
3105
3480
  }
3106
3481
  });
3107
3482
  }
3108
- })];
3483
+ }), shadow_grid];
3109
3484
  };
3110
3485
  /**
3111
3486
  * Calculate and apply cols_at_size overrides to fit as many items as possible in a row, evenly spaced
@@ -3171,7 +3546,8 @@ function $b51a2b8b9355e66c$export$82ed4b28ecb67608({
3171
3546
  filter_: filter_,
3172
3547
  selected_filters_: [get_selected_filters, set_selected_filters],
3173
3548
  i18n_: i18n_,
3174
- view_more_button_below_group_: [_get_view_more_button_below_group_, set_view_more_button_below_group_]
3549
+ view_more_button_below_group_: [_get_view_more_button_below_group_, set_view_more_button_below_group_],
3550
+ filter_query_: filter_query_
3175
3551
  }) {
3176
3552
  // same as in CheckboxFilter, maybe we should make this DRY at some point
3177
3553
  const existing_filter = $gVhhF$solidjs.createMemo(() => {
@@ -3205,12 +3581,17 @@ function $b51a2b8b9355e66c$export$82ed4b28ecb67608({
3205
3581
  const value = $daa394359b026187$export$325f75597868c4f0(checkbox().value_);
3206
3582
  return !!data?.some(item => $daa394359b026187$export$325f75597868c4f0(item) === value);
3207
3583
  });
3584
+ const value = $gVhhF$solidjs.createMemo(() => checkbox().value_);
3585
+ const label_text = $gVhhF$solidjs.createMemo(() => checkbox().name_ || value() + "");
3208
3586
  const input_row = $gVhhF$solidjsweb.createComponent((0, $1c63082b2da848ad$export$48513f6b9f8ce62d), {
3209
3587
  get value_() {
3210
- return checkbox().value_;
3588
+ return value();
3211
3589
  },
3212
3590
  get label_() {
3213
- return checkbox().name_;
3591
+ return $gVhhF$solidjsweb.createComponent((0, $d023ed916c84e75d$export$ba17c5b7e6dda39f), {
3592
+ whole_text_to_display_: label_text,
3593
+ searching_for_value_: () => filter_query_?.()
3594
+ });
3214
3595
  },
3215
3596
  get count_() {
3216
3597
  return checkbox().count_;
@@ -3513,10 +3894,167 @@ function $061ff5b4c3d36171$export$89c6019e4baa40b1(props) {
3513
3894
  }
3514
3895
  });
3515
3896
  }
3897
+ const $87d7574e1d89d69b$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<svg xmlns=http://www.w3.org/2000/svg width=20 height=22 viewBox="0 0 20 22"><path d="M19.811 20.174l-6.234-6.809a7.96 7.96 0 0 0 .923-1.179c.274-.424.502-.865.687-1.323a8.04 8.04 0 0 0 .42-1.436 7.88 7.88 0 0 0 .144-1.507c0-.526-.051-1.042-.154-1.548-.096-.506-.243-.995-.441-1.466s-.441-.919-.728-1.343a8.28 8.28 0 0 0-.984-1.21 7.86 7.86 0 0 0-1.2-.984A7.56 7.56 0 0 0 10.89.651C10.418.453 9.929.302 9.423.2S8.401.046 7.875.046 6.833.097 6.327.2 5.332.453 4.86.651a7.56 7.56 0 0 0-1.354.718c-.431.287-.831.615-1.2.984a8.28 8.28 0 0 0-.984 1.21 7.73 7.73 0 0 0-.728 1.343c-.198.472-.349.96-.451 1.466A8.31 8.31 0 0 0 0 7.921a8.31 8.31 0 0 0 .144 1.548c.103.506.253.995.451 1.466a8.08 8.08 0 0 0 .728 1.354 7.86 7.86 0 0 0 .984 1.2 7.54 7.54 0 0 0 1.2.995c.431.287.882.53 1.354.728.472.191.96.338 1.466.441a8.31 8.31 0 0 0 1.548.144c.451 0 .896-.038 1.333-.113a7.83 7.83 0 0 0 1.282-.328 7.55 7.55 0 0 0 1.2-.533 8.08 8.08 0 0 0 1.107-.749l6.245 6.809a.45.45 0 0 0 .174.123.55.55 0 0 0 .205.041.61.61 0 0 0 .195-.031c.061-.021.116-.055.164-.102.109-.096.164-.219.164-.369.007-.144-.038-.267-.133-.369zM1.046 7.921c0-.937.178-1.818.533-2.646.362-.834.851-1.559 1.466-2.174.622-.615 1.347-1.101 2.174-1.456.827-.362 1.712-.543 2.656-.543s1.829.181 2.656.543c.827.355 1.548.841 2.164 1.456.622.615 1.111 1.34 1.466 2.174a6.52 6.52 0 0 1 .543 2.646c0 .943-.181 1.829-.543 2.656a6.89 6.89 0 0 1-1.466 2.174c-.615.615-1.336 1.104-2.164 1.466-.827.356-1.712.533-2.656.533s-1.829-.178-2.656-.533c-.827-.362-1.552-.851-2.174-1.466-.615-.622-1.104-1.347-1.466-2.174-.355-.827-.533-1.712-.533-2.656z">`);
3898
+ function $87d7574e1d89d69b$export$82eafebb825fc23f(props = {}) {
3899
+ return (() => {
3900
+ const _el$ = $gVhhF$solidjsweb.getNextElement($87d7574e1d89d69b$var$_tmpl$);
3901
+ $gVhhF$solidjsweb.spread(_el$, props, true, true);
3902
+ $gVhhF$solidjsweb.runHydrationEvents();
3903
+ return _el$;
3904
+ })();
3905
+ }
3906
+ const $47d8681015b71901$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=search-in-filters><input type=text class=query><!$><!/><button class=clear-filter-search>`);
3907
+ const $47d8681015b71901$var$min_items_to_enable_filter_searching = 10; // For checkbox hierarchical we 2x this
3908
+ function $47d8681015b71901$export$4b2c5292ffe0c5dd(filter_array_, section, i18n_) {
3909
+ const [filter_query_, set_filter_query_] = $gVhhF$solidjs.createSignal();
3910
+ // Check if we have enough items to enable searching
3911
+ const enable_searchability = $gVhhF$solidjs.createMemo(() => {
3912
+ let count = 0;
3913
+ for (const filter of filter_array_()) {
3914
+ const type = filter.meta?.type;
3915
+ if (type === "range") continue;
3916
+ const length = filter.meta.values.length;
3917
+ count += type === "checkbox-color" || type === "checkbox-grid" ? length / 3 : length; // For checkbox-color we have two columns, checkbox-grid three, so we can show search later
3918
+ }
3919
+
3920
+ return count >= $47d8681015b71901$var$min_items_to_enable_filter_searching;
3921
+ });
3922
+ const SearchThisFilterGroup_ = () => {
3923
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
3924
+ get when() {
3925
+ return enable_searchability();
3926
+ },
3927
+ get children() {
3928
+ const _el$ = $gVhhF$solidjsweb.getNextElement($47d8681015b71901$var$_tmpl$),
3929
+ _el$2 = _el$.firstChild,
3930
+ _el$4 = _el$2.nextSibling,
3931
+ [_el$5, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$4.nextSibling),
3932
+ _el$3 = _el$5.nextSibling;
3933
+ _el$2.$$input = ev => set_filter_query_(ev.currentTarget.value);
3934
+ $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent((0, $87d7574e1d89d69b$export$82eafebb825fc23f), {
3935
+ width: "16",
3936
+ height: "17.6",
3937
+ "class": "search-icon"
3938
+ }), _el$5, _co$);
3939
+ _el$3.$$click = () => set_filter_query_();
3940
+ $gVhhF$solidjsweb.insert(_el$3, $gVhhF$solidjsweb.createComponent((0, $c77c68e559a1506c$export$3b621d86b1566b2), {
3941
+ width: "12",
3942
+ height: "12"
3943
+ }));
3944
+ $gVhhF$solidjsweb.effect(_p$ => {
3945
+ const _v$ = i18n_.search_a_filter_()(section),
3946
+ _v$2 = filter_query_() ? "" : "none";
3947
+ _v$ !== _p$._v$ && $gVhhF$solidjsweb.setAttribute(_el$2, "placeholder", _p$._v$ = _v$);
3948
+ _v$2 !== _p$._v$2 && ((_p$._v$2 = _v$2) != null ? _el$3.style.setProperty("display", _v$2) : _el$3.style.removeProperty("display"));
3949
+ return _p$;
3950
+ }, {
3951
+ _v$: undefined,
3952
+ _v$2: undefined
3953
+ });
3954
+ $gVhhF$solidjsweb.effect(() => $gVhhF$solidjsweb.setProperty(_el$2, "value", filter_query_() || ""));
3955
+ $gVhhF$solidjsweb.runHydrationEvents();
3956
+ return _el$;
3957
+ }
3958
+ });
3959
+ };
3960
+ const searched_filter_array_ = $gVhhF$solidjs.createMemo(() => {
3961
+ const query = filter_query_();
3962
+ if (!enable_searchability() || !query) return filter_array_();
3963
+ const lowercase_query = query.toLowerCase();
3964
+ const check_string_match = to_check => {
3965
+ to_check = to_check.toLowerCase();
3966
+ return to_check.includes(lowercase_query) || lowercase_query.includes(to_check);
3967
+ };
3968
+ return filter_array_().map(filter => {
3969
+ const type = filter.meta?.type;
3970
+ if (type === "range") return filter; // can't search in range filters and for checkbox-hierarchical we do the searching in the filter component since we have access to a hierarchical structure there
3971
+ const meta = filter.meta;
3972
+ const {
3973
+ values: values,
3974
+ names: names,
3975
+ counts: counts
3976
+ } = meta;
3977
+ if (!Array.isArray(values)) return filter; // Might have to adjust this in the future, but I think these super simple filters won't need search
3978
+ const is_hierarchical_checkbox = type === "checkbox-hierarchical";
3979
+ // Which index of counts, values and names should be kept
3980
+ const filtered_indexes = values.map((item, index) => {
3981
+ const item_from_names = names?.[index];
3982
+ if (item_from_names && !is_hierarchical_checkbox)
3983
+ // We should use names if they exist, but sometimes backend doesn't provide any at all, and sometimes they are undefined, presumably from create_modified_filters
3984
+ item = item_from_names;
3985
+ if (typeof item === "number") return true;
3986
+ if (is_hierarchical_checkbox && names)
3987
+ // Special case for hierarchical checkboxes where we need to check if any of the names in the path match the query
3988
+ item = item.map((_, index) => names[$47d8681015b71901$var$find_str_arr_in_str_arr_arr("findIndex", values, item.slice(0, index + 1))]);
3989
+ if (Array.isArray(item)) return item.some(item => check_string_match(item + "")); // If any of the items in the array match, keep it
3990
+ return check_string_match(item);
3991
+ });
3992
+ const new_values = values.filter((_, i) => filtered_indexes[i]);
3993
+ if (!new_values.length) return false; // false = please delete this filter, see below
3994
+ const new_filter_object = {
3995
+ ...filter,
3996
+ meta: {
3997
+ ...meta,
3998
+ ...(counts ? {
3999
+ counts: counts?.filter((_, i) => filtered_indexes[i])
4000
+ } : {}),
4001
+ ...(names ? {
4002
+ names: meta.names?.filter((_, i) => filtered_indexes[i])
4003
+ } : {}),
4004
+ values: new_values
4005
+ }
4006
+ };
4007
+ if (is_hierarchical_checkbox) {
4008
+ // For hierarchical checkbox we need to fill the holes created by filtering, for example if there is
4009
+ // ["Clothes"]
4010
+ // ["Clothes", "Blazers"]
4011
+ // And the user searched for "blazers" we need to add back ["Clothes"] so CheckboxHierarchicalFilter doesn't get confused
4012
+ // I explored doing the filtering there instead, but it's very hard to do it early enough before the expansion/collapsedness is calculated and check-logic is set up in relation to other items
4013
+ // So we do it here instead
4014
+ const new_meta = new_filter_object.meta;
4015
+ const new_values = new_meta.values;
4016
+ for (const value of new_values) {
4017
+ if (!Array.isArray(value)) continue; // Shouldn't happen
4018
+ if (value.length < 2) continue; // No parent
4019
+ const parent = value.slice(0, -1);
4020
+ // Check if parent exists
4021
+ if ($47d8681015b71901$var$find_str_arr_in_str_arr_arr("some", new_values, parent)) continue; // Parent exists
4022
+ // Otherwise, put it back
4023
+ const index_to_restore = $47d8681015b71901$var$find_str_arr_in_str_arr_arr("findIndex", values, parent);
4024
+ if (index_to_restore < 0) {
4025
+ $gVhhF$depictaiutilishared.dwarn("Can't restore", parent, "to", new_values);
4026
+ continue;
4027
+ }
4028
+ const current_index_of_us = new_values.findIndex(item => item === value);
4029
+ new_values.splice(current_index_of_us, 0, values[index_to_restore]);
4030
+ const count_to_restore = counts?.[index_to_restore];
4031
+ if (count_to_restore) new_meta.counts?.splice(current_index_of_us, 0, count_to_restore);
4032
+ const name_to_restore = names?.[index_to_restore];
4033
+ if (name_to_restore) new_meta.names?.splice(current_index_of_us, 0, name_to_restore);
4034
+ }
4035
+ }
4036
+ return new_filter_object;
4037
+ }).filter(filter => filter); // Delete filters that don't have a value anymore
4038
+ });
4039
+
4040
+ return {
4041
+ SearchThisFilterGroup_: SearchThisFilterGroup_,
4042
+ searched_filter_array_: searched_filter_array_,
4043
+ filter_query_: filter_query_
4044
+ };
4045
+ }
4046
+ /**
4047
+ * Finds/whatevers what's effectively one hierarchical filter item in an array of hierarchical filter items
4048
+ * Functions similar to this happen loads in create_modified_filters, but they have additional checks so not touching them RN
4049
+ */
4050
+ function $47d8681015b71901$var$find_str_arr_in_str_arr_arr(operation, haystack, needle) {
4051
+ return haystack[operation](value => value.length === needle.length && value.every((item, index) => item === needle[index]));
4052
+ }
4053
+ $gVhhF$solidjsweb.delegateEvents(["input", "click"]);
3516
4054
  const $aff9a96d30ed3563$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=filter-collapsible>`),
3517
4055
  $aff9a96d30ed3563$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<button class=clear-group><!$><!/><span>`),
3518
4056
  $aff9a96d30ed3563$var$_tmpl$3 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=view-more-clear><!$><!/><!$><!/>`),
3519
- $aff9a96d30ed3563$var$_tmpl$4 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=filter-collapsible-body><div class=filter-part></div><!$><!/>`),
4057
+ $aff9a96d30ed3563$var$_tmpl$4 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=filter-collapsible-body><div class=filter-part><!$><!/><!$><!/></div><!$><!/>`),
3520
4058
  $aff9a96d30ed3563$var$_tmpl$5 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<details class=filter-collapsible>`),
3521
4059
  $aff9a96d30ed3563$var$_tmpl$6 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<summary class=filter-group-summary><div class=summary><span></span><div class=selected-w-sign><!$><!/><!$><!/>`),
3522
4060
  $aff9a96d30ed3563$var$_tmpl$7 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=ungrouped>`),
@@ -3571,6 +4109,11 @@ function $aff9a96d30ed3563$var$ActualFilterBody(props) {
3571
4109
  const filter_array_ = $gVhhF$solidjs.createMemo(() => {
3572
4110
  return Object.values(togglable_filters_grouped_by_collapsible())[get_section_index()];
3573
4111
  });
4112
+ const {
4113
+ SearchThisFilterGroup_: SearchThisFilterGroup_,
4114
+ searched_filter_array_: searched_filter_array_,
4115
+ filter_query_: filter_query_
4116
+ } = $47d8681015b71901$export$4b2c5292ffe0c5dd(filter_array_, section_, props.i18n_);
3574
4117
  const is_open = $8c939a05b87fbbbc$export$ab34afce88557c0e({
3575
4118
  get expanded_filters_() {
3576
4119
  return props.expanded_filters_;
@@ -3583,27 +4126,30 @@ function $aff9a96d30ed3563$var$ActualFilterBody(props) {
3583
4126
  // this is absolutely not accurate which is why we have the .filter below, it's just the easiest way to get the typing of the map correct
3584
4127
  filter_from_api]).filter(([selected_filter]) => selected_filter)));
3585
4128
  const a_filter_is_selected = $gVhhF$solidjs.createMemo(() => selected_filters_in_group().size);
4129
+ const [get_details_width, set_get_details_width] = $gVhhF$solidjs.createSignal();
4130
+ const details_element_width_ = $gVhhF$solidjs.createMemo(() => get_details_width?.()?.());
3586
4131
  return $gVhhF$solidjsweb.createComponent((0, $a69e505a12a77874$export$6c6d7a51fa9aa15d), {
3587
4132
  is_open_: is_open,
3588
4133
  get details_() {
3589
4134
  return (() => {
3590
- const _el$15 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$5);
3591
- $gVhhF$solidjsweb.setAttribute(_el$15, "data-group-title", section_);
3592
- return _el$15;
4135
+ const _el$19 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$5);
4136
+ $gVhhF$solidjsweb.use(element => set_get_details_width(() => $f13855d1b951b24a$export$ebdc3711f7e02ccd(element)), _el$19);
4137
+ $gVhhF$solidjsweb.setAttribute(_el$19, "data-group-title", section_);
4138
+ return _el$19;
3593
4139
  })();
3594
4140
  },
3595
4141
  get summary_() {
3596
4142
  return (() => {
3597
- const _el$16 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$6),
3598
- _el$17 = _el$16.firstChild,
3599
- _el$18 = _el$17.firstChild,
3600
- _el$19 = _el$18.nextSibling,
3601
- _el$20 = _el$19.firstChild,
3602
- [_el$21, _co$5] = $gVhhF$solidjsweb.getNextMarker(_el$20.nextSibling),
3603
- _el$22 = _el$21.nextSibling,
3604
- [_el$23, _co$6] = $gVhhF$solidjsweb.getNextMarker(_el$22.nextSibling);
3605
- $gVhhF$solidjsweb.insert(_el$18, section_);
3606
- $gVhhF$solidjsweb.insert(_el$19, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
4143
+ const _el$20 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$6),
4144
+ _el$21 = _el$20.firstChild,
4145
+ _el$22 = _el$21.firstChild,
4146
+ _el$23 = _el$22.nextSibling,
4147
+ _el$24 = _el$23.firstChild,
4148
+ [_el$25, _co$7] = $gVhhF$solidjsweb.getNextMarker(_el$24.nextSibling),
4149
+ _el$26 = _el$25.nextSibling,
4150
+ [_el$27, _co$8] = $gVhhF$solidjsweb.getNextMarker(_el$26.nextSibling);
4151
+ $gVhhF$solidjsweb.insert(_el$22, section_);
4152
+ $gVhhF$solidjsweb.insert(_el$23, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
3607
4153
  get when() {
3608
4154
  return a_filter_is_selected();
3609
4155
  },
@@ -3615,26 +4161,31 @@ function $aff9a96d30ed3563$var$ActualFilterBody(props) {
3615
4161
  }
3616
4162
  });
3617
4163
  }
3618
- }), _el$21, _co$5);
3619
- $gVhhF$solidjsweb.insert(_el$19, $gVhhF$solidjsweb.createComponent((0, $7567511a7c3e4bd7$export$e5c2828934226505), {
4164
+ }), _el$25, _co$7);
4165
+ $gVhhF$solidjsweb.insert(_el$23, $gVhhF$solidjsweb.createComponent((0, $7567511a7c3e4bd7$export$e5c2828934226505), {
3620
4166
  get expanded_() {
3621
4167
  return is_open[0];
3622
4168
  },
3623
4169
  get i18n_() {
3624
4170
  return props.i18n_;
3625
4171
  }
3626
- }), _el$23, _co$6);
3627
- return _el$16;
4172
+ }), _el$27, _co$8);
4173
+ return _el$20;
3628
4174
  })();
3629
4175
  },
3630
4176
  get children() {
3631
4177
  const _el$2 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$4),
3632
4178
  _el$3 = _el$2.firstChild,
3633
- _el$13 = _el$3.nextSibling,
3634
- [_el$14, _co$4] = $gVhhF$solidjsweb.getNextMarker(_el$13.nextSibling);
4179
+ _el$4 = _el$3.firstChild,
4180
+ [_el$5, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$4.nextSibling),
4181
+ _el$6 = _el$5.nextSibling,
4182
+ [_el$7, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$6.nextSibling),
4183
+ _el$17 = _el$3.nextSibling,
4184
+ [_el$18, _co$6] = $gVhhF$solidjsweb.getNextMarker(_el$17.nextSibling);
4185
+ $gVhhF$solidjsweb.insert(_el$3, $gVhhF$solidjsweb.createComponent(SearchThisFilterGroup_, {}), _el$5, _co$);
3635
4186
  $gVhhF$solidjsweb.insert(_el$3, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Index), {
3636
4187
  get each() {
3637
- return filter_array_();
4188
+ return searched_filter_array_();
3638
4189
  },
3639
4190
  children: filter => $gVhhF$solidjsweb.createComponent((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
3640
4191
  severity_: "error",
@@ -3656,11 +4207,13 @@ function $aff9a96d30ed3563$var$ActualFilterBody(props) {
3656
4207
  get i18n_() {
3657
4208
  return props.i18n_;
3658
4209
  },
3659
- view_more_button_below_group_: view_more_button_below_group
4210
+ view_more_button_below_group_: view_more_button_below_group,
4211
+ filter_query_: filter_query_,
4212
+ details_element_width_: details_element_width_
3660
4213
  });
3661
4214
  }
3662
4215
  })
3663
- }));
4216
+ }), _el$7, _co$2);
3664
4217
  $gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
3665
4218
  get when() {
3666
4219
  return $gVhhF$solidjs.createMemo(() => {
@@ -3669,22 +4222,22 @@ function $aff9a96d30ed3563$var$ActualFilterBody(props) {
3669
4222
  })();
3670
4223
  },
3671
4224
  get children() {
3672
- const _el$4 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$3),
3673
- _el$9 = _el$4.firstChild,
3674
- [_el$10, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$9.nextSibling),
3675
- _el$11 = _el$10.nextSibling,
3676
- [_el$12, _co$3] = $gVhhF$solidjsweb.getNextMarker(_el$11.nextSibling);
3677
- $gVhhF$solidjsweb.insert(_el$4, () => view_more_button_below_group[0](), _el$10, _co$2);
3678
- $gVhhF$solidjsweb.insert(_el$4, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
4225
+ const _el$8 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$3),
4226
+ _el$13 = _el$8.firstChild,
4227
+ [_el$14, _co$4] = $gVhhF$solidjsweb.getNextMarker(_el$13.nextSibling),
4228
+ _el$15 = _el$14.nextSibling,
4229
+ [_el$16, _co$5] = $gVhhF$solidjsweb.getNextMarker(_el$15.nextSibling);
4230
+ $gVhhF$solidjsweb.insert(_el$8, () => view_more_button_below_group[0](), _el$14, _co$4);
4231
+ $gVhhF$solidjsweb.insert(_el$8, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
3679
4232
  get when() {
3680
4233
  return a_filter_is_selected();
3681
4234
  },
3682
4235
  get children() {
3683
- const _el$5 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$2),
3684
- _el$7 = _el$5.firstChild,
3685
- [_el$8, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$7.nextSibling),
3686
- _el$6 = _el$8.nextSibling;
3687
- $gVhhF$solidjsweb.addEventListener(_el$5, "click", $gVhhF$depictaiutilishared.catchify(() => {
4236
+ const _el$9 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$2),
4237
+ _el$11 = _el$9.firstChild,
4238
+ [_el$12, _co$3] = $gVhhF$solidjsweb.getNextMarker(_el$11.nextSibling),
4239
+ _el$10 = _el$12.nextSibling;
4240
+ $gVhhF$solidjsweb.addEventListener(_el$9, "click", $gVhhF$depictaiutilishared.catchify(() => {
3688
4241
  const new_filter_obj = [...props.selected_filters_[0]()];
3689
4242
  for (const filter of filter_array_()) {
3690
4243
  const index = new_filter_obj.findIndex(({
@@ -3695,15 +4248,15 @@ function $aff9a96d30ed3563$var$ActualFilterBody(props) {
3695
4248
  }
3696
4249
  props.selected_filters_[1](new_filter_obj);
3697
4250
  }), true);
3698
- $gVhhF$solidjsweb.insert(_el$5, $gVhhF$solidjsweb.createComponent((0, $c77c68e559a1506c$export$3b621d86b1566b2), {}), _el$8, _co$);
3699
- $gVhhF$solidjsweb.insert(_el$6, () => props.i18n_.clear_individual_filter_());
4251
+ $gVhhF$solidjsweb.insert(_el$9, $gVhhF$solidjsweb.createComponent((0, $c77c68e559a1506c$export$3b621d86b1566b2), {}), _el$12, _co$3);
4252
+ $gVhhF$solidjsweb.insert(_el$10, () => props.i18n_.clear_individual_filter_());
3700
4253
  $gVhhF$solidjsweb.runHydrationEvents();
3701
- return _el$5;
4254
+ return _el$9;
3702
4255
  }
3703
- }), _el$12, _co$3);
3704
- return _el$4;
4256
+ }), _el$16, _co$5);
4257
+ return _el$8;
3705
4258
  }
3706
- }), _el$14, _co$4);
4259
+ }), _el$18, _co$6);
3707
4260
  return _el$2;
3708
4261
  }
3709
4262
  });
@@ -3716,8 +4269,8 @@ function $aff9a96d30ed3563$var$ActualFilterBody(props) {
3716
4269
  return untogglable_filters()?.length;
3717
4270
  },
3718
4271
  get children() {
3719
- const _el$24 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$7);
3720
- $gVhhF$solidjsweb.insert(_el$24, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Index), {
4272
+ const _el$28 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$7);
4273
+ $gVhhF$solidjsweb.insert(_el$28, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Index), {
3721
4274
  get each() {
3722
4275
  return untogglable_filters();
3723
4276
  },
@@ -3742,15 +4295,15 @@ function $aff9a96d30ed3563$var$ActualFilterBody(props) {
3742
4295
  }), $gVhhF$solidjsweb.memo(get_view_more_button_below_group)];
3743
4296
  }
3744
4297
  }));
3745
- return _el$24;
4298
+ return _el$28;
3746
4299
  }
3747
4300
  }), $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
3748
4301
  get when() {
3749
4302
  return $gVhhF$solidjsweb.memo(() => !!!props.are_in_modal_ /* modal has its own clear button */)() && props.selected_filters_[0]()?.length;
3750
4303
  },
3751
4304
  get children() {
3752
- const _el$25 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$8);
3753
- $gVhhF$solidjsweb.addEventListener(_el$25, "click", $gVhhF$depictaiutilishared.catchify(() => $47e2cc552c02110c$export$8895d39404bd2bb1({
4305
+ const _el$29 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$8);
4306
+ $gVhhF$solidjsweb.addEventListener(_el$29, "click", $gVhhF$depictaiutilishared.catchify(() => $47e2cc552c02110c$export$8895d39404bd2bb1({
3754
4307
  user_triggered_: true,
3755
4308
  selected_filters_: props.selected_filters_,
3756
4309
  i18n_: props.i18n_,
@@ -3758,9 +4311,9 @@ function $aff9a96d30ed3563$var$ActualFilterBody(props) {
3758
4311
  expanded_hierarchical_filters_: props.expanded_hierarchical_filters_,
3759
4312
  local_filter_cache_: props.local_filter_cache_
3760
4313
  })), true);
3761
- $gVhhF$solidjsweb.insert(_el$25, () => props.i18n_.clear_all_filters_from_big_button_());
4314
+ $gVhhF$solidjsweb.insert(_el$29, () => props.i18n_.clear_all_filters_from_big_button_());
3762
4315
  $gVhhF$solidjsweb.runHydrationEvents();
3763
- return _el$25;
4316
+ return _el$29;
3764
4317
  }
3765
4318
  })];
3766
4319
  }
@@ -8001,19 +8554,6 @@ const $3df11fc61432d1fd$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<s
8001
8554
  function $3df11fc61432d1fd$export$1c641004b5485fed() {
8002
8555
  return $gVhhF$solidjsweb.getNextElement($3df11fc61432d1fd$var$_tmpl$);
8003
8556
  }
8004
- const $87d7574e1d89d69b$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<svg><path d="M19.811 20.174l-6.234-6.809a7.96 7.96 0 0 0 .923-1.179c.274-.424.502-.865.687-1.323a8.04 8.04 0 0 0 .42-1.436 7.88 7.88 0 0 0 .144-1.507c0-.526-.051-1.042-.154-1.548-.096-.506-.243-.995-.441-1.466s-.441-.919-.728-1.343a8.28 8.28 0 0 0-.984-1.21 7.86 7.86 0 0 0-1.2-.984A7.56 7.56 0 0 0 10.89.651C10.418.453 9.929.302 9.423.2S8.401.046 7.875.046 6.833.097 6.327.2 5.332.453 4.86.651a7.56 7.56 0 0 0-1.354.718c-.431.287-.831.615-1.2.984a8.28 8.28 0 0 0-.984 1.21 7.73 7.73 0 0 0-.728 1.343c-.198.472-.349.96-.451 1.466A8.31 8.31 0 0 0 0 7.921a8.31 8.31 0 0 0 .144 1.548c.103.506.253.995.451 1.466a8.08 8.08 0 0 0 .728 1.354 7.86 7.86 0 0 0 .984 1.2 7.54 7.54 0 0 0 1.2.995c.431.287.882.53 1.354.728.472.191.96.338 1.466.441a8.31 8.31 0 0 0 1.548.144c.451 0 .896-.038 1.333-.113a7.83 7.83 0 0 0 1.282-.328 7.55 7.55 0 0 0 1.2-.533 8.08 8.08 0 0 0 1.107-.749l6.245 6.809a.45.45 0 0 0 .174.123.55.55 0 0 0 .205.041.61.61 0 0 0 .195-.031c.061-.021.116-.055.164-.102.109-.096.164-.219.164-.369.007-.144-.038-.267-.133-.369zM1.046 7.921c0-.937.178-1.818.533-2.646.362-.834.851-1.559 1.466-2.174.622-.615 1.347-1.101 2.174-1.456.827-.362 1.712-.543 2.656-.543s1.829.181 2.656.543c.827.355 1.548.841 2.164 1.456.622.615 1.111 1.34 1.466 2.174a6.52 6.52 0 0 1 .543 2.646c0 .943-.181 1.829-.543 2.656a6.89 6.89 0 0 1-1.466 2.174c-.615.615-1.336 1.104-2.164 1.466-.827.356-1.712.533-2.656.533s-1.829-.178-2.656-.533c-.827-.362-1.552-.851-2.174-1.466-.615-.622-1.104-1.347-1.466-2.174-.355-.827-.533-1.712-.533-2.656z">`);
8005
- function $87d7574e1d89d69b$export$82eafebb825fc23f(props = {}) {
8006
- return (() => {
8007
- const _el$ = $gVhhF$solidjsweb.getNextElement($87d7574e1d89d69b$var$_tmpl$);
8008
- $gVhhF$solidjsweb.spread(_el$, $gVhhF$solidjsweb.mergeProps(props, {
8009
- "xmlns": "http://www.w3.org/2000/svg",
8010
- "width": "20",
8011
- "height": "22"
8012
- }), true, true);
8013
- $gVhhF$solidjsweb.runHydrationEvents();
8014
- return _el$;
8015
- })();
8016
- }
8017
8557
  const $66b8b9a9613c141d$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<button class=back type=button>`),
8018
8558
  $66b8b9a9613c141d$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=search-field><!$><!/><div class=field><input class=query tabindex=0><button type=button class=clear></button></div><button class="submit major"type=button>`);
8019
8559
  function $66b8b9a9613c141d$export$b94867ecbd698f21({
@@ -8751,91 +9291,19 @@ function $9a268bf73b31a717$export$a146ac6fa8346a25({
8751
9291
  _v$3 !== _p$._v$3 && $gVhhF$solidjsweb.setAttribute(_el$6, "title", _p$._v$3 = _v$3);
8752
9292
  _v$4 !== _p$._v$4 && $gVhhF$solidjsweb.setAttribute(_el$9, "title", _p$._v$4 = _v$4);
8753
9293
  return _p$;
8754
- }, {
8755
- _v$: undefined,
8756
- _v$2: undefined,
8757
- _v$3: undefined,
8758
- _v$4: undefined
8759
- });
8760
- return _el$4;
8761
- })();
8762
- }
8763
- }));
8764
- return _el$;
8765
- }
8766
- });
8767
- }
8768
- const $d023ed916c84e75d$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span class=highlighted-part>`),
8769
- $d023ed916c84e75d$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span>`);
8770
- function $d023ed916c84e75d$export$ba17c5b7e6dda39f({
8771
- whole_text_to_display_: whole_text_to_display_memo,
8772
- searching_for_value_: searching_for_value_memo,
8773
- class_: class_
8774
- }) {
8775
- const [get_has_highlighted, set_has_highlighted] = $gVhhF$solidjs.createSignal(false);
8776
- const text_itself = $gVhhF$solidjs.createMemo(() => $gVhhF$solidjs.batch(() => {
8777
- set_has_highlighted(false);
8778
- const searching_for_value = searching_for_value_memo();
8779
- const whole_text_to_display_ = whole_text_to_display_memo();
8780
- let for_black = "";
8781
- let pushed_grey = false;
8782
- const search_q = searching_for_value;
8783
- if (!search_q) return whole_text_to_display_;
8784
- const output = [];
8785
- const searching_for = search_q.toLowerCase();
8786
- const push_black = () => {
8787
- if (for_black) {
8788
- set_has_highlighted(true);
8789
- output.push((() => {
8790
- const _el$ = $gVhhF$solidjsweb.getNextElement($d023ed916c84e75d$var$_tmpl$);
8791
- $gVhhF$solidjsweb.insert(_el$, for_black);
8792
- return _el$;
8793
- })()); // "black"
8794
- for_black = "";
8795
- }
8796
- };
8797
- for (let i = 0; i < whole_text_to_display_.length;) {
8798
- let is_whole_word = true;
8799
- let searching_for_but_with_texts_casing = "";
8800
- const i_at_start = i;
8801
- for (let j = 0; j < searching_for.length; i++, j++) {
8802
- const letter_in_suggestion = whole_text_to_display_[i];
8803
- if (letter_in_suggestion?.toLowerCase() !== searching_for[j]) {
8804
- is_whole_word = false;
8805
- i = i_at_start;
8806
- break;
9294
+ }, {
9295
+ _v$: undefined,
9296
+ _v$2: undefined,
9297
+ _v$3: undefined,
9298
+ _v$4: undefined
9299
+ });
9300
+ return _el$4;
9301
+ })();
8807
9302
  }
8808
- searching_for_but_with_texts_casing += letter_in_suggestion;
8809
- }
8810
- if (is_whole_word) {
8811
- push_black();
8812
- output.push(searching_for_but_with_texts_casing);
8813
- pushed_grey = true;
8814
- } else for_black += whole_text_to_display_[i++];
8815
- }
8816
- push_black();
8817
- if (!pushed_grey) {
8818
- set_has_highlighted(false);
8819
- return whole_text_to_display_;
9303
+ }));
9304
+ return _el$;
8820
9305
  }
8821
- return output;
8822
- }));
8823
- return (() => {
8824
- const _el$2 = $gVhhF$solidjsweb.getNextElement($d023ed916c84e75d$var$_tmpl$2);
8825
- $gVhhF$solidjsweb.className(_el$2, class_);
8826
- $gVhhF$solidjsweb.insert(_el$2, text_itself);
8827
- $gVhhF$solidjsweb.effect(_p$ => {
8828
- const _v$ = !!get_has_highlighted(),
8829
- _v$2 = whole_text_to_display_memo() /* for when line-clamped, users can see full text on hover */;
8830
- _v$ !== _p$._v$ && _el$2.classList.toggle("has-history-match", _p$._v$ = _v$);
8831
- _v$2 !== _p$._v$2 && $gVhhF$solidjsweb.setAttribute(_el$2, "title", _p$._v$2 = _v$2);
8832
- return _p$;
8833
- }, {
8834
- _v$: undefined,
8835
- _v$2: undefined
8836
- });
8837
- return _el$2;
8838
- })();
9306
+ });
8839
9307
  }
8840
9308
  const $c0125412b4ea0c93$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.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">`);
8841
9309
  function $c0125412b4ea0c93$export$605674723bcc715c(props = {}) {
@@ -8874,8 +9342,8 @@ function $6b65ba8af12c5a26$export$e872e2339fb04a7f({
8874
9342
  type: type,
8875
9343
  title: title
8876
9344
  }) => type === (0, $3ec9e21d6b6debdd$export$3cf9497e790da491) && !filtered_previous_searches_().includes(title) // don't show the ones we already show from the history
8877
- ));
8878
-
9345
+ ) // + limit to three query suggestions, API sends more sometimes
9346
+ .slice(0, 3));
8879
9347
  const not_queries_memo = $gVhhF$solidjs.createMemo(() => {
8880
9348
  // For the section that shows categories and content results
8881
9349
  // We want to limit to 3 items, and we want to show the categories first
@@ -9855,226 +10323,6 @@ function $2005eec80e40088f$export$41b4894022a3580f({
9855
10323
  })));
9856
10324
  return style_props_;
9857
10325
  }
9858
- const $5ea5a82e398f6f44$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span class=highlighted-part>`);
9859
- const $5ea5a82e398f6f44$var$dont_cut_in_between_less_than_characters = 30;
9860
- function $5ea5a82e398f6f44$export$e1a98a189fd2c0e7({
9861
- content_result_: content_result_,
9862
- key_: key_,
9863
- cut_when_possible_: cut_when_possible_
9864
- }) {
9865
- const matched_tokens = $gVhhF$solidjs.createMemo(() => content_result_().highlights?.find(highlight => highlight.field == key_)?.matched_tokens);
9866
- const full_value = $gVhhF$solidjs.createMemo(() => content_result_()[key_]?.replaceAll("\n", " "));
9867
- return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
9868
- get when() {
9869
- return matched_tokens()?.length;
9870
- },
9871
- get fallback() {
9872
- return full_value();
9873
- },
9874
- get children() {
9875
- return (() => {
9876
- const segmented_cut_text = $gVhhF$solidjs.createMemo(() => {
9877
- const segmented_text = $5ea5a82e398f6f44$var$segment_text(full_value(), matched_tokens());
9878
- if (cut_when_possible_) $5ea5a82e398f6f44$var$cut_text(segmented_text);
9879
- return segmented_text;
9880
- });
9881
- return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Index), {
9882
- get each() {
9883
- return segmented_cut_text();
9884
- },
9885
- children: item => {
9886
- return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
9887
- get when() {
9888
- return item().highlighted_;
9889
- },
9890
- get fallback() {
9891
- return item().text_;
9892
- },
9893
- get children() {
9894
- const _el$ = $gVhhF$solidjsweb.getNextElement($5ea5a82e398f6f44$var$_tmpl$);
9895
- $gVhhF$solidjsweb.insert(_el$, () => item().text_);
9896
- return _el$;
9897
- }
9898
- });
9899
- }
9900
- });
9901
- })();
9902
- }
9903
- });
9904
- }
9905
- function $5ea5a82e398f6f44$var$cut_text(segmented_text) {
9906
- // cut away chunks of text that are not highlighted to give a google-like overview of the content
9907
- const highlighted_segments = segmented_text?.filter(segment => segment.highlighted_);
9908
- if (!segmented_text || !highlighted_segments?.length) return;
9909
- // We have one or more highlighted segments
9910
- if (highlighted_segments.length === 1) {
9911
- // cut away from the left until the start of the highlighted sentence if just one sentence is highlighted
9912
- $5ea5a82e398f6f44$var$cut_start(segmented_text.indexOf(highlighted_segments[0]), segmented_text);
9913
- return;
9914
- }
9915
- // We have two or more highlighted segments, take the two biggest chunks and show them + a bit text around
9916
- 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
9917
- );
9918
-
9919
- const [longest_segment, next_longest_segment] = sorted_highlighted_segments;
9920
- // We need to cut before the first segment - possibly through other segments - and maybe between segments
9921
- 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);
9922
- $5ea5a82e398f6f44$var$cut_start(index_of_first_segment, segmented_text);
9923
- // update indexes since we might have removed segments
9924
- [index_of_first_segment, index_of_second_segment] = [segmented_text.indexOf(longest_segment), segmented_text.indexOf(next_longest_segment)].sort((a, b) => a - b);
9925
- let number_of_characters_between_segments = 0;
9926
- for (let i = index_of_first_segment + 1; i < index_of_second_segment; i++) {
9927
- const segment = segmented_text[i];
9928
- number_of_characters_between_segments += segment.text_.length;
9929
- }
9930
- if (number_of_characters_between_segments < $5ea5a82e398f6f44$var$dont_cut_in_between_less_than_characters)
9931
- // don't cut if there are less than 30 characters between the two segments
9932
- return;
9933
- // We have more than 50 characters between the two segments, cut between them
9934
- const [split_start_segment, split_start_character] = $5ea5a82e398f6f44$var$find_split_point(index_of_first_segment, index_of_second_segment, segmented_text);
9935
- const [split_end_segment, split_end_character] = $5ea5a82e398f6f44$var$find_split_point(index_of_second_segment, index_of_first_segment, segmented_text);
9936
- if (split_start_segment === undefined || split_end_segment === undefined ||
9937
- // identical split point, or split end before split start, can't do anything
9938
- split_start_segment == split_end_segment && split_start_character >= split_end_character || split_start_segment > split_end_segment) return;
9939
- const dots_segment = {
9940
- text_: " … ",
9941
- highlighted_: false
9942
- };
9943
- const split_and_dotted_values = segmented_text.flatMap((segment, i) => {
9944
- if (i < split_start_segment || i > split_end_segment) return segment;
9945
- const text = segment.text_;
9946
- if (i == split_end_segment && i == split_start_segment) return [{
9947
- ...segment,
9948
- text_: text.slice(0, split_start_character).trimEnd()
9949
- }, dots_segment, {
9950
- ...segment,
9951
- text_: text.slice(split_end_character + 1, text.length).trimStart()
9952
- }];else if (i == split_start_segment) {
9953
- 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
9954
- return segment;
9955
- } else if (i == split_end_segment) return [dots_segment, {
9956
- ...segment,
9957
- text_: text.slice(split_end_character + 1, text.length).trimStart()
9958
- }];
9959
- return []; // remove all segments inbetween
9960
- });
9961
-
9962
- segmented_text.splice(0, segmented_text.length, ...split_and_dotted_values); // Sorry…
9963
- $5ea5a82e398f6f44$var$heal_holes(segmented_text);
9964
- }
9965
- function $5ea5a82e398f6f44$var$heal_holes(segmented_text) {
9966
- // try to heal "holes" created in the segments so there are only alternating segments
9967
- const segments_to_delete = new Set();
9968
- for (let i = 0; i < segmented_text.length; i++) {
9969
- const segment = segmented_text[i];
9970
- let previous_segment;
9971
- for (let j = i - 1; j >= 0; j--) {
9972
- previous_segment = segmented_text[j];
9973
- // Don't write to a segment that's marked for deletion or the contents we write to it will be deleted
9974
- if (!segments_to_delete.has(previous_segment)) break;
9975
- }
9976
- if (previous_segment?.highlighted_ && segment.highlighted_ || previous_segment?.highlighted_ === false && segment.highlighted_ === false) {
9977
- previous_segment.text_ += segment.text_; // IDK if this ever happens
9978
- segments_to_delete.add(segment);
9979
- }
9980
- }
9981
- for (const segment of segments_to_delete) {
9982
- const index = segmented_text.indexOf(segment);
9983
- segmented_text.splice(index, 1);
9984
- }
9985
- }
9986
- function $5ea5a82e398f6f44$var$find_split_point(index_of_start_segment, index_of_end_segment, segmented_text, be_very_aggressive = true) {
9987
- const should_loop_backwards = index_of_start_segment > index_of_end_segment;
9988
- const step = should_loop_backwards ? -1 : 1;
9989
- const desperate_split_attempts = [":", ";", ","];
9990
- while (desperate_split_attempts.length) {
9991
- const split_point_between_words = [];
9992
- // for the middle also try to split with a few more characters if the default ones don't work over a full run
9993
- const desperate_split_attempt = desperate_split_attempts.pop();
9994
- let is_first_character = true;
9995
- for (let i = index_of_start_segment + step; should_loop_backwards ? i > index_of_end_segment : i < index_of_end_segment; i += step) {
9996
- const segment = segmented_text[i];
9997
- const text = segment.text_;
9998
- for (let j = should_loop_backwards ? text.length - 1 : 0; should_loop_backwards ? j >= 0 : j < text.length; j += step) {
9999
- const character = text[j];
10000
- if (character == "." || character == "?" || character == "!" || character == desperate_split_attempt) return [i, j]; // segment index, character index
10001
- if (is_first_character) is_first_character = false;else if (be_very_aggressive && character == " ") {
10002
- split_point_between_words.push([i, j]);
10003
- if (split_point_between_words.length > 3)
10004
- // We can't find a split point, so we'll just split between words
10005
- // 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
10006
- return split_point_between_words[1];
10007
- }
10008
- }
10009
- }
10010
- }
10011
- return [];
10012
- }
10013
- function $5ea5a82e398f6f44$var$cut_start(cut_left_of_index, segmented_text) {
10014
- // Cut the start of the text to bring the first matching token
10015
- let is_first_character = false;
10016
- let words_encountered = 0;
10017
- outmost_loop: for (let i = cut_left_of_index - 1; i >= 0; i--) {
10018
- const segment = segmented_text[i];
10019
- // We assume that two adjacent highlighted segments don't exist and have been merged if they were to have existed
10020
- const text = segment.text_;
10021
- for (let j = text.length - 1; j >= 0; j--) {
10022
- const character = text[j];
10023
- const is_space = character == " ";
10024
- if (!is_first_character && is_space) words_encountered++;
10025
- if (character == "." || character == "?" || character == "!" || character == "," || words_encountered > 8 && is_space) {
10026
- // We have to be really aggressive at the start of sentences so stuff can be seen on mobile, hence comma
10027
- segment.text_ = text.slice(j + 1).trimStart();
10028
- segmented_text.splice(0, i);
10029
- if (character === "," || is_space)
10030
- // if we cut at a comma or psace, we add a … at the beginning
10031
- segmented_text.unshift({
10032
- text_: "… ",
10033
- highlighted_: false
10034
- });
10035
- break outmost_loop;
10036
- }
10037
- if (is_first_character) is_first_character = false;
10038
- }
10039
- }
10040
- $5ea5a82e398f6f44$var$heal_holes(segmented_text); // if we added a ... there could now be a sequence that's not alternating true/false
10041
- }
10042
-
10043
- function $5ea5a82e398f6f44$var$segment_text(text, matched_strings) {
10044
- // segment text where the matched strings are highlighted sections
10045
- const output = [];
10046
- if (!text) return; // shouldn't happen but whatever
10047
- for (let i = 0; i < text.length; i++) {
10048
- const found_strings = [];
10049
- if (!i || text[i - 1] == " ")
10050
- // only match at the start of a word or string, it looks weird if i.e. "we" is highlighted in "activewear
10051
- for (let j = 0; j < matched_strings.length; j++) {
10052
- const matched_string = matched_strings[j];
10053
- const part_in_text = text.slice(i, i + matched_string.length);
10054
- if (matched_string.length < 2) continue; // don't match on single characters, i.e. "I", it looks weird
10055
- 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
10056
- }
10057
-
10058
- const last_index_in_output = output.length - 1;
10059
- if (!found_strings.length) {
10060
- const character = text[i];
10061
- if (output[last_index_in_output]?.highlighted_ === false || output.length && /\s/.test(character))
10062
- // 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
10063
- output[last_index_in_output].text_ += character;else output.push({
10064
- highlighted_: false,
10065
- text_: character
10066
- });
10067
- } else {
10068
- const longest_found_string = found_strings.reduce((a, b) => a.length > b.length ? a : b);
10069
- if (output[last_index_in_output]?.highlighted_) output[last_index_in_output].text_ += longest_found_string;else output.push({
10070
- highlighted_: true,
10071
- text_: longest_found_string
10072
- });
10073
- i += longest_found_string.length - 1;
10074
- }
10075
- }
10076
- return output;
10077
- }
10078
10326
  const $76227de40be817e5$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<a>`),
10079
10327
  $76227de40be817e5$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div>`),
10080
10328
  $76227de40be817e5$var$_tmpl$3 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class="description line-clamp">`),
@@ -10150,7 +10398,7 @@ function $76227de40be817e5$export$f631859cab12b342({
10150
10398
  })), _el$8, _co$);
10151
10399
  $gVhhF$solidjsweb.insert(_el$5, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
10152
10400
  get when() {
10153
- return content_result_?.().description || !content_result_;
10401
+ return content_result_?.().description;
10154
10402
  },
10155
10403
  get children() {
10156
10404
  const _el$6 = $gVhhF$solidjsweb.getNextElement($76227de40be817e5$var$_tmpl$3);