@internetarchive/collection-browser 0.4.7 → 0.4.8-alpha.1

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.
Files changed (223) hide show
  1. package/.editorconfig +29 -29
  2. package/.github/workflows/ci.yml +26 -26
  3. package/.github/workflows/gh-pages-main.yml +39 -39
  4. package/.github/workflows/npm-publish.yml +39 -39
  5. package/.github/workflows/pr-preview.yml +38 -38
  6. package/.husky/pre-commit +4 -4
  7. package/LICENSE +661 -661
  8. package/README.md +83 -83
  9. package/dist/index.d.ts +9 -9
  10. package/dist/index.js +9 -9
  11. package/dist/src/app-root.d.ts +50 -50
  12. package/dist/src/app-root.js +278 -278
  13. package/dist/src/assets/img/icons/arrow-left.d.ts +2 -2
  14. package/dist/src/assets/img/icons/arrow-left.js +2 -2
  15. package/dist/src/assets/img/icons/arrow-right.d.ts +2 -2
  16. package/dist/src/assets/img/icons/arrow-right.js +2 -2
  17. package/dist/src/assets/img/icons/chevron.d.ts +2 -2
  18. package/dist/src/assets/img/icons/chevron.js +2 -2
  19. package/dist/src/assets/img/icons/empty-query.d.ts +2 -2
  20. package/dist/src/assets/img/icons/empty-query.js +2 -2
  21. package/dist/src/assets/img/icons/eye-closed.d.ts +2 -2
  22. package/dist/src/assets/img/icons/eye-closed.js +2 -2
  23. package/dist/src/assets/img/icons/eye.d.ts +2 -2
  24. package/dist/src/assets/img/icons/eye.js +2 -2
  25. package/dist/src/assets/img/icons/favorite-filled.d.ts +1 -1
  26. package/dist/src/assets/img/icons/favorite-filled.js +2 -2
  27. package/dist/src/assets/img/icons/login-required.d.ts +1 -1
  28. package/dist/src/assets/img/icons/login-required.js +2 -2
  29. package/dist/src/assets/img/icons/mediatype/account.d.ts +1 -1
  30. package/dist/src/assets/img/icons/mediatype/account.js +2 -2
  31. package/dist/src/assets/img/icons/mediatype/audio.d.ts +1 -1
  32. package/dist/src/assets/img/icons/mediatype/audio.js +2 -2
  33. package/dist/src/assets/img/icons/mediatype/collection.d.ts +1 -1
  34. package/dist/src/assets/img/icons/mediatype/collection.js +2 -2
  35. package/dist/src/assets/img/icons/mediatype/data.d.ts +1 -1
  36. package/dist/src/assets/img/icons/mediatype/data.js +2 -2
  37. package/dist/src/assets/img/icons/mediatype/etree.d.ts +1 -1
  38. package/dist/src/assets/img/icons/mediatype/etree.js +2 -2
  39. package/dist/src/assets/img/icons/mediatype/film.d.ts +1 -1
  40. package/dist/src/assets/img/icons/mediatype/film.js +2 -2
  41. package/dist/src/assets/img/icons/mediatype/images.d.ts +1 -1
  42. package/dist/src/assets/img/icons/mediatype/images.js +2 -2
  43. package/dist/src/assets/img/icons/mediatype/radio.d.ts +1 -1
  44. package/dist/src/assets/img/icons/mediatype/radio.js +2 -2
  45. package/dist/src/assets/img/icons/mediatype/software.d.ts +1 -1
  46. package/dist/src/assets/img/icons/mediatype/software.js +2 -2
  47. package/dist/src/assets/img/icons/mediatype/texts.d.ts +1 -1
  48. package/dist/src/assets/img/icons/mediatype/texts.js +2 -2
  49. package/dist/src/assets/img/icons/mediatype/tv.d.ts +1 -1
  50. package/dist/src/assets/img/icons/mediatype/tv.js +2 -2
  51. package/dist/src/assets/img/icons/mediatype/video.d.ts +1 -1
  52. package/dist/src/assets/img/icons/mediatype/video.js +2 -2
  53. package/dist/src/assets/img/icons/mediatype/web.d.ts +1 -1
  54. package/dist/src/assets/img/icons/mediatype/web.js +2 -2
  55. package/dist/src/assets/img/icons/null-result.d.ts +2 -2
  56. package/dist/src/assets/img/icons/null-result.js +2 -2
  57. package/dist/src/assets/img/icons/restricted.d.ts +1 -1
  58. package/dist/src/assets/img/icons/restricted.js +2 -2
  59. package/dist/src/assets/img/icons/reviews.d.ts +1 -1
  60. package/dist/src/assets/img/icons/reviews.js +2 -2
  61. package/dist/src/assets/img/icons/upload.d.ts +1 -1
  62. package/dist/src/assets/img/icons/upload.js +2 -2
  63. package/dist/src/assets/img/icons/views.d.ts +1 -1
  64. package/dist/src/assets/img/icons/views.js +2 -2
  65. package/dist/src/circular-activity-indicator.d.ts +5 -5
  66. package/dist/src/circular-activity-indicator.js +17 -17
  67. package/dist/src/collection-browser.d.ts +277 -277
  68. package/dist/src/collection-browser.js +1194 -1194
  69. package/dist/src/collection-facets/facet-tombstone-row.d.ts +5 -5
  70. package/dist/src/collection-facets/facet-tombstone-row.js +15 -15
  71. package/dist/src/collection-facets/facets-template.d.ts +16 -16
  72. package/dist/src/collection-facets/facets-template.js +125 -125
  73. package/dist/src/collection-facets/more-facets-content.d.ts +77 -77
  74. package/dist/src/collection-facets/more-facets-content.js +357 -357
  75. package/dist/src/collection-facets/more-facets-pagination.d.ts +36 -36
  76. package/dist/src/collection-facets/more-facets-pagination.js +192 -192
  77. package/dist/src/collection-facets.d.ts +77 -77
  78. package/dist/src/collection-facets.js +383 -383
  79. package/dist/src/empty-placeholder.d.ts +11 -11
  80. package/dist/src/empty-placeholder.js +42 -42
  81. package/dist/src/language-code-handler/language-code-handler.d.ts +37 -37
  82. package/dist/src/language-code-handler/language-code-handler.js +26 -26
  83. package/dist/src/language-code-handler/language-code-mapping.d.ts +1 -1
  84. package/dist/src/language-code-handler/language-code-mapping.js +562 -562
  85. package/dist/src/mediatype/mediatype-config.d.ts +3 -3
  86. package/dist/src/mediatype/mediatype-config.js +85 -85
  87. package/dist/src/models.d.ts +114 -114
  88. package/dist/src/models.js +125 -125
  89. package/dist/src/restoration-state-handler.d.ts +45 -45
  90. package/dist/src/restoration-state-handler.js +230 -230
  91. package/dist/src/sort-filter-bar/alpha-bar.d.ts +12 -12
  92. package/dist/src/sort-filter-bar/alpha-bar.js +52 -52
  93. package/dist/src/sort-filter-bar/img/compact.d.ts +1 -1
  94. package/dist/src/sort-filter-bar/img/compact.js +2 -2
  95. package/dist/src/sort-filter-bar/img/list.d.ts +1 -1
  96. package/dist/src/sort-filter-bar/img/list.js +2 -2
  97. package/dist/src/sort-filter-bar/img/sort-triangle.d.ts +1 -1
  98. package/dist/src/sort-filter-bar/img/sort-triangle.js +2 -2
  99. package/dist/src/sort-filter-bar/img/tile.d.ts +1 -1
  100. package/dist/src/sort-filter-bar/img/tile.js +2 -2
  101. package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +108 -108
  102. package/dist/src/sort-filter-bar/sort-filter-bar.js +438 -438
  103. package/dist/src/styles/item-image-styles.d.ts +8 -8
  104. package/dist/src/styles/item-image-styles.js +9 -9
  105. package/dist/src/tiles/collection-browser-loading-tile.d.ts +5 -5
  106. package/dist/src/tiles/collection-browser-loading-tile.js +15 -15
  107. package/dist/src/tiles/grid/account-tile.d.ts +17 -17
  108. package/dist/src/tiles/grid/account-tile.js +46 -46
  109. package/dist/src/tiles/grid/collection-tile.d.ts +14 -14
  110. package/dist/src/tiles/grid/collection-tile.js +53 -53
  111. package/dist/src/tiles/grid/item-tile.d.ts +29 -29
  112. package/dist/src/tiles/grid/item-tile.js +108 -108
  113. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.d.ts +1 -1
  114. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +7 -7
  115. package/dist/src/tiles/grid/tile-stats.d.ts +10 -10
  116. package/dist/src/tiles/grid/tile-stats.js +40 -40
  117. package/dist/src/tiles/hover/hover-pane-controller.d.ts +197 -197
  118. package/dist/src/tiles/hover/hover-pane-controller.js +331 -331
  119. package/dist/src/tiles/hover/tile-hover-pane.d.ts +15 -15
  120. package/dist/src/tiles/hover/tile-hover-pane.js +38 -38
  121. package/dist/src/tiles/image-block.d.ts +17 -17
  122. package/dist/src/tiles/image-block.js +72 -72
  123. package/dist/src/tiles/item-image.d.ts +35 -35
  124. package/dist/src/tiles/item-image.js +117 -117
  125. package/dist/src/tiles/list/account-label.d.ts +1 -1
  126. package/dist/src/tiles/list/account-label.js +6 -6
  127. package/dist/src/tiles/list/date-label.d.ts +1 -1
  128. package/dist/src/tiles/list/date-label.js +12 -12
  129. package/dist/src/tiles/list/tile-list-compact-header.d.ts +12 -12
  130. package/dist/src/tiles/list/tile-list-compact-header.js +41 -41
  131. package/dist/src/tiles/list/tile-list-compact.d.ts +21 -21
  132. package/dist/src/tiles/list/tile-list-compact.js +99 -99
  133. package/dist/src/tiles/list/tile-list.d.ts +55 -55
  134. package/dist/src/tiles/list/tile-list.js +297 -296
  135. package/dist/src/tiles/list/tile-list.js.map +1 -1
  136. package/dist/src/tiles/mediatype-icon.d.ts +9 -9
  137. package/dist/src/tiles/mediatype-icon.js +47 -47
  138. package/dist/src/tiles/overlay/icon-overlay.d.ts +10 -10
  139. package/dist/src/tiles/overlay/icon-overlay.js +40 -40
  140. package/dist/src/tiles/overlay/icon-text-overlay.d.ts +9 -9
  141. package/dist/src/tiles/overlay/icon-text-overlay.js +38 -38
  142. package/dist/src/tiles/overlay/text-overlay.d.ts +10 -10
  143. package/dist/src/tiles/overlay/text-overlay.js +42 -42
  144. package/dist/src/tiles/text-snippet-block.d.ts +27 -27
  145. package/dist/src/tiles/text-snippet-block.js +73 -73
  146. package/dist/src/tiles/tile-dispatcher.d.ts +55 -55
  147. package/dist/src/tiles/tile-dispatcher.js +176 -176
  148. package/dist/src/utils/analytics-events.d.ts +22 -22
  149. package/dist/src/utils/analytics-events.js +24 -24
  150. package/dist/src/utils/format-count.d.ts +7 -7
  151. package/dist/src/utils/format-count.js +76 -76
  152. package/dist/src/utils/format-date.d.ts +2 -2
  153. package/dist/src/utils/format-date.js +23 -23
  154. package/dist/src/utils/format-unit-size.d.ts +2 -2
  155. package/dist/src/utils/format-unit-size.js +33 -33
  156. package/dist/test/collection-browser.test.d.ts +1 -1
  157. package/dist/test/collection-browser.test.js +584 -584
  158. package/dist/test/collection-facets/facets-template.test.d.ts +1 -1
  159. package/dist/test/collection-facets/facets-template.test.js +62 -62
  160. package/dist/test/collection-facets/more-facets-content.test.d.ts +1 -1
  161. package/dist/test/collection-facets/more-facets-content.test.js +114 -114
  162. package/dist/test/collection-facets/more-facets-pagination.test.d.ts +1 -1
  163. package/dist/test/collection-facets/more-facets-pagination.test.js +117 -117
  164. package/dist/test/collection-facets.test.d.ts +2 -2
  165. package/dist/test/collection-facets.test.js +508 -508
  166. package/dist/test/empty-placeholder.test.d.ts +1 -1
  167. package/dist/test/empty-placeholder.test.js +33 -33
  168. package/dist/test/icon-overlay.test.d.ts +1 -1
  169. package/dist/test/icon-overlay.test.js +24 -24
  170. package/dist/test/image-block.test.d.ts +1 -1
  171. package/dist/test/image-block.test.js +48 -48
  172. package/dist/test/item-image.test.d.ts +1 -1
  173. package/dist/test/item-image.test.js +84 -84
  174. package/dist/test/mediatype-config.test.d.ts +1 -1
  175. package/dist/test/mediatype-config.test.js +16 -16
  176. package/dist/test/mocks/mock-analytics-handler.d.ts +10 -10
  177. package/dist/test/mocks/mock-analytics-handler.js +15 -15
  178. package/dist/test/mocks/mock-collection-name-cache.d.ts +7 -7
  179. package/dist/test/mocks/mock-collection-name-cache.js +13 -13
  180. package/dist/test/mocks/mock-search-responses.d.ts +12 -12
  181. package/dist/test/mocks/mock-search-responses.js +341 -341
  182. package/dist/test/mocks/mock-search-service.d.ts +13 -13
  183. package/dist/test/mocks/mock-search-service.js +40 -40
  184. package/dist/test/restoration-state-handler.test.d.ts +1 -1
  185. package/dist/test/restoration-state-handler.test.js +125 -125
  186. package/dist/test/sort-filter-bar/alpha-bar.test.d.ts +1 -1
  187. package/dist/test/sort-filter-bar/alpha-bar.test.js +43 -43
  188. package/dist/test/sort-filter-bar/sort-filter-bar.test.d.ts +1 -1
  189. package/dist/test/sort-filter-bar/sort-filter-bar.test.js +197 -197
  190. package/dist/test/text-overlay.test.d.ts +1 -1
  191. package/dist/test/text-overlay.test.js +48 -48
  192. package/dist/test/text-snippet-block.test.d.ts +1 -1
  193. package/dist/test/text-snippet-block.test.js +57 -57
  194. package/dist/test/tile-stats.test.d.ts +1 -1
  195. package/dist/test/tile-stats.test.js +33 -33
  196. package/dist/test/tiles/grid/account-tile.test.d.ts +1 -1
  197. package/dist/test/tiles/grid/account-tile.test.js +60 -60
  198. package/dist/test/tiles/grid/collection-tile.test.d.ts +1 -1
  199. package/dist/test/tiles/grid/collection-tile.test.js +57 -57
  200. package/dist/test/tiles/grid/item-tile.test.d.ts +1 -1
  201. package/dist/test/tiles/grid/item-tile.test.js +142 -142
  202. package/dist/test/tiles/hover/hover-pane-controller.test.d.ts +1 -1
  203. package/dist/test/tiles/hover/hover-pane-controller.test.js +257 -257
  204. package/dist/test/tiles/hover/tile-hover-pane.test.d.ts +1 -1
  205. package/dist/test/tiles/hover/tile-hover-pane.test.js +13 -13
  206. package/dist/test/tiles/list/tile-list-compact.test.d.ts +1 -1
  207. package/dist/test/tiles/list/tile-list-compact.test.js +92 -92
  208. package/dist/test/tiles/list/tile-list.test.d.ts +1 -1
  209. package/dist/test/tiles/list/tile-list.test.js +153 -153
  210. package/dist/test/utils/format-count.test.d.ts +1 -1
  211. package/dist/test/utils/format-count.test.js +23 -23
  212. package/dist/test/utils/format-date.test.d.ts +1 -1
  213. package/dist/test/utils/format-date.test.js +17 -17
  214. package/dist/test/utils/format-unit-size.test.d.ts +1 -1
  215. package/dist/test/utils/format-unit-size.test.js +17 -17
  216. package/local.archive.org.cert +86 -86
  217. package/local.archive.org.key +27 -27
  218. package/package.json +1 -1
  219. package/renovate.json +6 -6
  220. package/src/tiles/list/tile-list.ts +3 -1
  221. package/tsconfig.json +21 -21
  222. package/web-dev-server.config.mjs +30 -30
  223. package/web-test-runner.config.mjs +41 -41
@@ -1,194 +1,194 @@
1
- import { __decorate } from "tslib";
2
- /* eslint-disable import/no-duplicates */
3
- import { html, css, LitElement, nothing, } from 'lit';
4
- import { customElement, property, query, state } from 'lit/decorators.js';
5
- import { classMap } from 'lit/directives/class-map.js';
6
- import { FilterConstraint, FilterMapBuilder, SearchType, } from '@internetarchive/search-service';
7
- import '@internetarchive/infinite-scroller';
8
- import './tiles/tile-dispatcher';
9
- import './tiles/collection-browser-loading-tile';
10
- import './sort-filter-bar/sort-filter-bar';
11
- import './collection-facets';
12
- import './circular-activity-indicator';
13
- import './sort-filter-bar/sort-filter-bar';
14
- import { SortField, SortFieldToMetadataField, defaultSelectedFacets, prefixFilterAggregationKeys, } from './models';
15
- import { RestorationStateHandler, } from './restoration-state-handler';
16
- import chevronIcon from './assets/img/icons/chevron';
17
- import { LanguageCodeHandler } from './language-code-handler/language-code-handler';
18
- import './empty-placeholder';
19
- import { analyticsActions, analyticsCategories, } from './utils/analytics-events';
20
- let CollectionBrowser = class CollectionBrowser extends LitElement {
21
- constructor() {
22
- super(...arguments);
23
- this.baseImageUrl = 'https://archive.org';
24
- this.searchType = SearchType.METADATA;
25
- this.sortParam = null;
26
- this.selectedSort = SortField.relevance;
27
- this.selectedTitleFilter = null;
28
- this.selectedCreatorFilter = null;
29
- this.sortDirection = null;
30
- this.pageSize = 50;
31
- this.showHistogramDatePicker = false;
32
- /** describes where this component is being used */
33
- this.searchContext = analyticsCategories.default;
34
- this.pageContext = 'search';
35
- this.restorationStateHandler = new RestorationStateHandler({
36
- context: this.pageContext,
37
- });
38
- this.mobileBreakpoint = 600;
39
- this.loggedIn = false;
40
- this.modalManager = undefined;
41
- /**
42
- * If item management UI active
43
- */
44
- this.isManageView = false;
45
- /**
46
- * The page that the consumer wants to load.
47
- */
48
- this.initialPageNumber = 1;
49
- /**
50
- * This the the number of pages that we want to show.
51
- *
52
- * The data isn't necessarily loaded for all of the pages, but this lets us
53
- * know how many cells we should render.
54
- */
55
- this.pagesToRender = this.initialPageNumber;
56
- this.searchResultsLoading = false;
57
- this.facetsLoading = false;
58
- this.fullYearAggregationLoading = false;
59
- this.mobileView = false;
60
- this.mobileFacetsVisible = false;
61
- this.placeholderType = null;
62
- this.prefixFilterCountMap = {};
63
- this.languageCodeHandler = new LanguageCodeHandler();
64
- /**
65
- * When we're animated scrolling to the page, we don't want to fetch
66
- * all of the pages as it scrolls so this lets us know if we're scrolling
67
- */
68
- this.isScrollingToCell = false;
69
- /**
70
- * When we've reached the end of the data, stop trying to fetch more
71
- */
72
- this.endOfDataReached = false;
73
- /**
74
- * When page width resizes from desktop to mobile, set true to
75
- * disable expand/collapse transition when loading.
76
- */
77
- this.isResizeToMobile = false;
78
- this.placeholderCellTemplate = html `<collection-browser-loading-tile></collection-browser-loading-tile>`;
79
- /**
80
- * The results per page so we can paginate.
81
- *
82
- * This allows us to start in the middle of the search results and
83
- * fetch data before or after the current page. If we don't have a key
84
- * for the previous/next page, we'll fetch the next/previous page to populate it
85
- */
86
- this.dataSource = {};
87
- // we only want to scroll on the very first query change
88
- // so this keeps track of whether we've already set the initial query
89
- this.initialQueryChangeHappened = false;
90
- this.historyPopOccurred = false;
91
- // this maps the query to the pages being fetched for that query
92
- this.pageFetchesInProgress = {};
93
- }
94
- tileModelAtCellIndex(index) {
95
- var _a;
96
- const pageNumber = Math.floor(index / this.pageSize) + 1;
97
- const itemIndex = index % this.pageSize;
98
- const model = (_a = this.dataSource[pageNumber]) === null || _a === void 0 ? void 0 : _a[itemIndex];
99
- /**
100
- * If we encounter a model we don't have yet and we're not in the middle of an
101
- * automated scroll, fetch the page and just return undefined.
102
- * The datasource will be updated once the page is loaded and the cell will be rendered.
103
- *
104
- * We disable it during the automated scroll since we may fetch pages for cells the
105
- * user may never see.
106
- */
107
- if (!model && !this.isScrollingToCell) {
108
- this.fetchPage(pageNumber);
109
- }
110
- return model;
111
- }
112
- get sortFilterQueries() {
113
- const queries = [this.titleQuery, this.creatorQuery];
114
- return queries.filter(q => q).join(' AND ');
115
- }
116
- // this is the total number of tiles we expect if
117
- // the data returned is a full page worth
118
- // this is useful for putting in placeholders for the expected number of tiles
119
- get estimatedTileCount() {
120
- return this.pagesToRender * this.pageSize;
121
- }
122
- // this is the actual number of tiles in the datasource,
123
- // which is useful for removing excess placeholder tiles
124
- // once we reached the end of the data
125
- get actualTileCount() {
126
- return Object.keys(this.dataSource).reduce((acc, page) => acc + this.dataSource[page].length, 0);
127
- }
128
- /**
129
- * Go to the given page of results
130
- *
131
- * @param pageNumber
132
- */
133
- goToPage(pageNumber) {
134
- this.initialPageNumber = pageNumber;
135
- this.pagesToRender = pageNumber;
136
- return this.scrollToPage(pageNumber);
137
- }
138
- clearFilters() {
139
- this.selectedFacets = defaultSelectedFacets;
140
- this.sortParam = null;
141
- this.selectedTitleFilter = null;
142
- this.selectedCreatorFilter = null;
143
- this.titleQuery = undefined;
144
- this.creatorQuery = undefined;
145
- this.selectedSort = SortField.relevance;
146
- this.sortDirection = null;
147
- }
148
- /**
149
- * Manually requests to perform a search, which will only be executed if one of
150
- * the query, the search type, or the sort has changed.
151
- */
152
- requestSearch() {
153
- this.handleQueryChange();
154
- }
155
- render() {
156
- this.setPlaceholderType();
1
+ import { __decorate } from "tslib";
2
+ /* eslint-disable import/no-duplicates */
3
+ import { html, css, LitElement, nothing, } from 'lit';
4
+ import { customElement, property, query, state } from 'lit/decorators.js';
5
+ import { classMap } from 'lit/directives/class-map.js';
6
+ import { FilterConstraint, FilterMapBuilder, SearchType, } from '@internetarchive/search-service';
7
+ import '@internetarchive/infinite-scroller';
8
+ import './tiles/tile-dispatcher';
9
+ import './tiles/collection-browser-loading-tile';
10
+ import './sort-filter-bar/sort-filter-bar';
11
+ import './collection-facets';
12
+ import './circular-activity-indicator';
13
+ import './sort-filter-bar/sort-filter-bar';
14
+ import { SortField, SortFieldToMetadataField, defaultSelectedFacets, prefixFilterAggregationKeys, } from './models';
15
+ import { RestorationStateHandler, } from './restoration-state-handler';
16
+ import chevronIcon from './assets/img/icons/chevron';
17
+ import { LanguageCodeHandler } from './language-code-handler/language-code-handler';
18
+ import './empty-placeholder';
19
+ import { analyticsActions, analyticsCategories, } from './utils/analytics-events';
20
+ let CollectionBrowser = class CollectionBrowser extends LitElement {
21
+ constructor() {
22
+ super(...arguments);
23
+ this.baseImageUrl = 'https://archive.org';
24
+ this.searchType = SearchType.METADATA;
25
+ this.sortParam = null;
26
+ this.selectedSort = SortField.relevance;
27
+ this.selectedTitleFilter = null;
28
+ this.selectedCreatorFilter = null;
29
+ this.sortDirection = null;
30
+ this.pageSize = 50;
31
+ this.showHistogramDatePicker = false;
32
+ /** describes where this component is being used */
33
+ this.searchContext = analyticsCategories.default;
34
+ this.pageContext = 'search';
35
+ this.restorationStateHandler = new RestorationStateHandler({
36
+ context: this.pageContext,
37
+ });
38
+ this.mobileBreakpoint = 600;
39
+ this.loggedIn = false;
40
+ this.modalManager = undefined;
41
+ /**
42
+ * If item management UI active
43
+ */
44
+ this.isManageView = false;
45
+ /**
46
+ * The page that the consumer wants to load.
47
+ */
48
+ this.initialPageNumber = 1;
49
+ /**
50
+ * This the the number of pages that we want to show.
51
+ *
52
+ * The data isn't necessarily loaded for all of the pages, but this lets us
53
+ * know how many cells we should render.
54
+ */
55
+ this.pagesToRender = this.initialPageNumber;
56
+ this.searchResultsLoading = false;
57
+ this.facetsLoading = false;
58
+ this.fullYearAggregationLoading = false;
59
+ this.mobileView = false;
60
+ this.mobileFacetsVisible = false;
61
+ this.placeholderType = null;
62
+ this.prefixFilterCountMap = {};
63
+ this.languageCodeHandler = new LanguageCodeHandler();
64
+ /**
65
+ * When we're animated scrolling to the page, we don't want to fetch
66
+ * all of the pages as it scrolls so this lets us know if we're scrolling
67
+ */
68
+ this.isScrollingToCell = false;
69
+ /**
70
+ * When we've reached the end of the data, stop trying to fetch more
71
+ */
72
+ this.endOfDataReached = false;
73
+ /**
74
+ * When page width resizes from desktop to mobile, set true to
75
+ * disable expand/collapse transition when loading.
76
+ */
77
+ this.isResizeToMobile = false;
78
+ this.placeholderCellTemplate = html `<collection-browser-loading-tile></collection-browser-loading-tile>`;
79
+ /**
80
+ * The results per page so we can paginate.
81
+ *
82
+ * This allows us to start in the middle of the search results and
83
+ * fetch data before or after the current page. If we don't have a key
84
+ * for the previous/next page, we'll fetch the next/previous page to populate it
85
+ */
86
+ this.dataSource = {};
87
+ // we only want to scroll on the very first query change
88
+ // so this keeps track of whether we've already set the initial query
89
+ this.initialQueryChangeHappened = false;
90
+ this.historyPopOccurred = false;
91
+ // this maps the query to the pages being fetched for that query
92
+ this.pageFetchesInProgress = {};
93
+ }
94
+ tileModelAtCellIndex(index) {
95
+ var _a;
96
+ const pageNumber = Math.floor(index / this.pageSize) + 1;
97
+ const itemIndex = index % this.pageSize;
98
+ const model = (_a = this.dataSource[pageNumber]) === null || _a === void 0 ? void 0 : _a[itemIndex];
99
+ /**
100
+ * If we encounter a model we don't have yet and we're not in the middle of an
101
+ * automated scroll, fetch the page and just return undefined.
102
+ * The datasource will be updated once the page is loaded and the cell will be rendered.
103
+ *
104
+ * We disable it during the automated scroll since we may fetch pages for cells the
105
+ * user may never see.
106
+ */
107
+ if (!model && !this.isScrollingToCell) {
108
+ this.fetchPage(pageNumber);
109
+ }
110
+ return model;
111
+ }
112
+ get sortFilterQueries() {
113
+ const queries = [this.titleQuery, this.creatorQuery];
114
+ return queries.filter(q => q).join(' AND ');
115
+ }
116
+ // this is the total number of tiles we expect if
117
+ // the data returned is a full page worth
118
+ // this is useful for putting in placeholders for the expected number of tiles
119
+ get estimatedTileCount() {
120
+ return this.pagesToRender * this.pageSize;
121
+ }
122
+ // this is the actual number of tiles in the datasource,
123
+ // which is useful for removing excess placeholder tiles
124
+ // once we reached the end of the data
125
+ get actualTileCount() {
126
+ return Object.keys(this.dataSource).reduce((acc, page) => acc + this.dataSource[page].length, 0);
127
+ }
128
+ /**
129
+ * Go to the given page of results
130
+ *
131
+ * @param pageNumber
132
+ */
133
+ goToPage(pageNumber) {
134
+ this.initialPageNumber = pageNumber;
135
+ this.pagesToRender = pageNumber;
136
+ return this.scrollToPage(pageNumber);
137
+ }
138
+ clearFilters() {
139
+ this.selectedFacets = defaultSelectedFacets;
140
+ this.sortParam = null;
141
+ this.selectedTitleFilter = null;
142
+ this.selectedCreatorFilter = null;
143
+ this.titleQuery = undefined;
144
+ this.creatorQuery = undefined;
145
+ this.selectedSort = SortField.relevance;
146
+ this.sortDirection = null;
147
+ }
148
+ /**
149
+ * Manually requests to perform a search, which will only be executed if one of
150
+ * the query, the search type, or the sort has changed.
151
+ */
152
+ requestSearch() {
153
+ this.handleQueryChange();
154
+ }
155
+ render() {
156
+ this.setPlaceholderType();
157
157
  return html `
158
158
  <div
159
159
  id="content-container"
160
160
  class=${this.mobileView ? 'mobile' : 'desktop'}
161
161
  >
162
- ${this.placeholderType
163
- ? this.emptyPlaceholderTemplate
162
+ ${this.placeholderType
163
+ ? this.emptyPlaceholderTemplate
164
164
  : this.collectionBrowserTemplate}
165
165
  </div>
166
- `;
167
- }
168
- setPlaceholderType() {
169
- this.placeholderType = null;
170
- if (!this.baseQuery) {
171
- this.placeholderType = 'empty-query';
172
- }
173
- if ((!this.searchResultsLoading && this.totalResults === 0) ||
174
- !this.searchService) {
175
- this.placeholderType = 'null-result';
176
- }
177
- }
178
- get emptyPlaceholderTemplate() {
166
+ `;
167
+ }
168
+ setPlaceholderType() {
169
+ this.placeholderType = null;
170
+ if (!this.baseQuery) {
171
+ this.placeholderType = 'empty-query';
172
+ }
173
+ if ((!this.searchResultsLoading && this.totalResults === 0) ||
174
+ !this.searchService) {
175
+ this.placeholderType = 'null-result';
176
+ }
177
+ }
178
+ get emptyPlaceholderTemplate() {
179
179
  return html `
180
180
  <empty-placeholder
181
181
  .placeholderType=${this.placeholderType}
182
182
  ?isMobileView=${this.mobileView}
183
183
  ></empty-placeholder>
184
184
  ${this.infiniteScrollerTemplate}
185
- `;
186
- }
187
- get collectionBrowserTemplate() {
188
- var _a;
189
- const shouldShowSearching = this.searchResultsLoading || this.totalResults === undefined;
190
- const resultsCount = (_a = this.totalResults) === null || _a === void 0 ? void 0 : _a.toLocaleString();
191
- const resultsLabel = this.totalResults === 1 ? 'Result' : 'Results';
185
+ `;
186
+ }
187
+ get collectionBrowserTemplate() {
188
+ var _a;
189
+ const shouldShowSearching = this.searchResultsLoading || this.totalResults === undefined;
190
+ const resultsCount = (_a = this.totalResults) === null || _a === void 0 ? void 0 : _a.toLocaleString();
191
+ const resultsLabel = this.totalResults === 1 ? 'Result' : 'Results';
192
192
  return html `<div
193
193
  id="left-column"
194
194
  class="column${this.isResizeToMobile ? ' preload' : ''}"
@@ -206,8 +206,8 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
206
206
  </div>
207
207
  <div
208
208
  id="facets-container"
209
- class=${!this.mobileView || this.mobileFacetsVisible
210
- ? 'expanded'
209
+ class=${!this.mobileView || this.mobileFacetsVisible
210
+ ? 'expanded'
211
211
  : ''}
212
212
  >
213
213
  ${this.facetsTemplate}
@@ -215,13 +215,13 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
215
215
  </div>
216
216
  <div id="right-column" class="column">
217
217
  ${this.sortFilterBarTemplate}
218
- ${this.displayMode === `list-compact`
219
- ? this.listHeaderTemplate
218
+ ${this.displayMode === `list-compact`
219
+ ? this.listHeaderTemplate
220
220
  : nothing}
221
221
  ${this.infiniteScrollerTemplate}
222
- </div>`;
223
- }
224
- get infiniteScrollerTemplate() {
222
+ </div>`;
223
+ }
224
+ get infiniteScrollerTemplate() {
225
225
  return html `<infinite-scroller
226
226
  class=${this.infiniteScrollerClasses}
227
227
  itemCount=${this.placeholderType ? 0 : nothing}
@@ -229,16 +229,16 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
229
229
  .placeholderCellTemplate=${this.placeholderCellTemplate}
230
230
  @scrollThresholdReached=${this.scrollThresholdReached}
231
231
  @visibleCellsChanged=${this.visibleCellsChanged}
232
- ></infinite-scroller>`;
233
- }
234
- get infiniteScrollerClasses() {
235
- var _a;
236
- return classMap({
237
- [(_a = this.displayMode) !== null && _a !== void 0 ? _a : '']: !!this.displayMode,
238
- hidden: !!this.placeholderType,
239
- });
240
- }
241
- get sortFilterBarTemplate() {
232
+ ></infinite-scroller>`;
233
+ }
234
+ get infiniteScrollerClasses() {
235
+ var _a;
236
+ return classMap({
237
+ [(_a = this.displayMode) !== null && _a !== void 0 ? _a : '']: !!this.displayMode,
238
+ hidden: !!this.placeholderType,
239
+ });
240
+ }
241
+ get sortFilterBarTemplate() {
242
242
  return html `
243
243
  <sort-filter-bar
244
244
  .selectedSort=${this.selectedSort}
@@ -254,113 +254,113 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
254
254
  @creatorLetterChanged=${this.creatorLetterSelected}
255
255
  >
256
256
  </sort-filter-bar>
257
- `;
258
- }
259
- userChangedSort(e) {
260
- var _a;
261
- const { selectedSort, sortDirection } = e.detail;
262
- this.selectedSort = selectedSort;
263
- this.sortDirection = sortDirection;
264
- if (((_a = this.currentPage) !== null && _a !== void 0 ? _a : 1) > 1) {
265
- this.goToPage(1);
266
- }
267
- this.currentPage = 1;
268
- }
269
- sendSortByAnalytics(prevSortDirection) {
270
- var _a;
271
- const directionCleared = prevSortDirection && !this.sortDirection;
272
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
273
- category: this.searchContext,
274
- action: analyticsActions.sortBy,
275
- label: `${this.selectedSort}${this.sortDirection || directionCleared ? `-${this.sortDirection}` : ''}`,
276
- });
277
- }
278
- selectedSortChanged() {
279
- if (this.selectedSort === 'relevance' || this.sortDirection === null) {
280
- this.sortParam = null;
281
- return;
282
- }
283
- const sortField = SortFieldToMetadataField[this.selectedSort];
284
- if (!sortField)
285
- return;
286
- this.sortParam = { field: sortField, direction: this.sortDirection };
287
- // Lazy-load the alphabet counts for title/creator sort bar as needed
288
- this.updatePrefixFiltersForCurrentSort();
289
- }
290
- displayModeChanged(e) {
291
- var _a;
292
- this.displayMode = e.detail.displayMode;
293
- if (this.displayMode) {
294
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
295
- category: this.searchContext,
296
- action: analyticsActions.displayMode,
297
- label: this.displayMode,
298
- });
299
- }
300
- }
301
- /** Send Analytics when sorting by title's first letter
302
- * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
303
- * */
304
- sendFilterByTitleAnalytics(prevSelectedLetter) {
305
- var _a;
306
- if (!prevSelectedLetter && !this.selectedTitleFilter) {
307
- return;
308
- }
309
- const cleared = prevSelectedLetter && this.selectedTitleFilter === null;
310
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
311
- category: this.searchContext,
312
- action: analyticsActions.filterByTitle,
313
- label: cleared
314
- ? `clear-${prevSelectedLetter}`
315
- : `${prevSelectedLetter || 'start'}-${this.selectedTitleFilter}`,
316
- });
317
- }
318
- selectedTitleLetterChanged() {
319
- this.titleQuery = this.selectedTitleFilter
320
- ? `firstTitle:${this.selectedTitleFilter}`
321
- : undefined;
322
- }
323
- /** Send Analytics when filtering by creator's first letter
324
- * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
325
- * */
326
- sendFilterByCreatorAnalytics(prevSelectedLetter) {
327
- var _a;
328
- if (!prevSelectedLetter && !this.selectedCreatorFilter) {
329
- return;
330
- }
331
- const cleared = prevSelectedLetter && this.selectedCreatorFilter === null;
332
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
333
- category: this.searchContext,
334
- action: analyticsActions.filterByCreator,
335
- label: cleared
336
- ? `clear-${prevSelectedLetter}`
337
- : `${prevSelectedLetter || 'start'}-${this.selectedCreatorFilter}`,
338
- });
339
- }
340
- selectedCreatorLetterChanged() {
341
- this.creatorQuery = this.selectedCreatorFilter
342
- ? `firstCreator:${this.selectedCreatorFilter}`
343
- : undefined;
344
- }
345
- titleLetterSelected(e) {
346
- this.selectedCreatorFilter = null;
347
- this.selectedTitleFilter = e.detail.selectedLetter;
348
- }
349
- creatorLetterSelected(e) {
350
- this.selectedTitleFilter = null;
351
- this.selectedCreatorFilter = e.detail.selectedLetter;
352
- }
353
- get mobileFacetsTemplate() {
257
+ `;
258
+ }
259
+ userChangedSort(e) {
260
+ var _a;
261
+ const { selectedSort, sortDirection } = e.detail;
262
+ this.selectedSort = selectedSort;
263
+ this.sortDirection = sortDirection;
264
+ if (((_a = this.currentPage) !== null && _a !== void 0 ? _a : 1) > 1) {
265
+ this.goToPage(1);
266
+ }
267
+ this.currentPage = 1;
268
+ }
269
+ sendSortByAnalytics(prevSortDirection) {
270
+ var _a;
271
+ const directionCleared = prevSortDirection && !this.sortDirection;
272
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
273
+ category: this.searchContext,
274
+ action: analyticsActions.sortBy,
275
+ label: `${this.selectedSort}${this.sortDirection || directionCleared ? `-${this.sortDirection}` : ''}`,
276
+ });
277
+ }
278
+ selectedSortChanged() {
279
+ if (this.selectedSort === 'relevance' || this.sortDirection === null) {
280
+ this.sortParam = null;
281
+ return;
282
+ }
283
+ const sortField = SortFieldToMetadataField[this.selectedSort];
284
+ if (!sortField)
285
+ return;
286
+ this.sortParam = { field: sortField, direction: this.sortDirection };
287
+ // Lazy-load the alphabet counts for title/creator sort bar as needed
288
+ this.updatePrefixFiltersForCurrentSort();
289
+ }
290
+ displayModeChanged(e) {
291
+ var _a;
292
+ this.displayMode = e.detail.displayMode;
293
+ if (this.displayMode) {
294
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
295
+ category: this.searchContext,
296
+ action: analyticsActions.displayMode,
297
+ label: this.displayMode,
298
+ });
299
+ }
300
+ }
301
+ /** Send Analytics when sorting by title's first letter
302
+ * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
303
+ * */
304
+ sendFilterByTitleAnalytics(prevSelectedLetter) {
305
+ var _a;
306
+ if (!prevSelectedLetter && !this.selectedTitleFilter) {
307
+ return;
308
+ }
309
+ const cleared = prevSelectedLetter && this.selectedTitleFilter === null;
310
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
311
+ category: this.searchContext,
312
+ action: analyticsActions.filterByTitle,
313
+ label: cleared
314
+ ? `clear-${prevSelectedLetter}`
315
+ : `${prevSelectedLetter || 'start'}-${this.selectedTitleFilter}`,
316
+ });
317
+ }
318
+ selectedTitleLetterChanged() {
319
+ this.titleQuery = this.selectedTitleFilter
320
+ ? `firstTitle:${this.selectedTitleFilter}`
321
+ : undefined;
322
+ }
323
+ /** Send Analytics when filtering by creator's first letter
324
+ * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
325
+ * */
326
+ sendFilterByCreatorAnalytics(prevSelectedLetter) {
327
+ var _a;
328
+ if (!prevSelectedLetter && !this.selectedCreatorFilter) {
329
+ return;
330
+ }
331
+ const cleared = prevSelectedLetter && this.selectedCreatorFilter === null;
332
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
333
+ category: this.searchContext,
334
+ action: analyticsActions.filterByCreator,
335
+ label: cleared
336
+ ? `clear-${prevSelectedLetter}`
337
+ : `${prevSelectedLetter || 'start'}-${this.selectedCreatorFilter}`,
338
+ });
339
+ }
340
+ selectedCreatorLetterChanged() {
341
+ this.creatorQuery = this.selectedCreatorFilter
342
+ ? `firstCreator:${this.selectedCreatorFilter}`
343
+ : undefined;
344
+ }
345
+ titleLetterSelected(e) {
346
+ this.selectedCreatorFilter = null;
347
+ this.selectedTitleFilter = e.detail.selectedLetter;
348
+ }
349
+ creatorLetterSelected(e) {
350
+ this.selectedTitleFilter = null;
351
+ this.selectedCreatorFilter = e.detail.selectedLetter;
352
+ }
353
+ get mobileFacetsTemplate() {
354
354
  return html `
355
355
  <div id="mobile-filter-collapse">
356
356
  <h1
357
- @click=${() => {
358
- this.isResizeToMobile = false;
359
- this.mobileFacetsVisible = !this.mobileFacetsVisible;
357
+ @click=${() => {
358
+ this.isResizeToMobile = false;
359
+ this.mobileFacetsVisible = !this.mobileFacetsVisible;
360
360
  }}
361
- @keyup=${() => {
362
- this.isResizeToMobile = false;
363
- this.mobileFacetsVisible = !this.mobileFacetsVisible;
361
+ @keyup=${() => {
362
+ this.isResizeToMobile = false;
363
+ this.mobileFacetsVisible = !this.mobileFacetsVisible;
364
364
  }}
365
365
  >
366
366
  <span class="collapser ${this.mobileFacetsVisible ? 'open' : ''}">
@@ -369,9 +369,9 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
369
369
  Filters
370
370
  </h1>
371
371
  </div>
372
- `;
373
- }
374
- get facetsTemplate() {
372
+ `;
373
+ }
374
+ get facetsTemplate() {
375
375
  return html `
376
376
  <collection-facets
377
377
  @facetsChanged=${this.facetsChanged}
@@ -397,16 +397,16 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
397
397
  .analyticsHandler=${this.analyticsHandler}
398
398
  >
399
399
  </collection-facets>
400
- `;
401
- }
402
- get loadingTemplate() {
400
+ `;
401
+ }
402
+ get loadingTemplate() {
403
403
  return html `
404
404
  <div class="loading-cover">
405
405
  <circular-activity-indicator></circular-activity-indicator>
406
406
  </div>
407
- `;
408
- }
409
- get listHeaderTemplate() {
407
+ `;
408
+ }
409
+ get listHeaderTemplate() {
410
410
  return html `
411
411
  <div id="list-header">
412
412
  <tile-dispatcher
@@ -418,746 +418,746 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
418
418
  >
419
419
  </tile-dispatcher>
420
420
  </div>
421
- `;
422
- }
423
- histogramDateRangeUpdated(e) {
424
- var _a;
425
- const { minDate, maxDate } = e.detail;
426
- [this.minSelectedDate, this.maxSelectedDate] = [minDate, maxDate];
427
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
428
- category: this.searchContext,
429
- action: analyticsActions.histogramChanged,
430
- label: this.dateRangeQueryClause,
431
- });
432
- }
433
- get dateRangeQueryClause() {
434
- if (!this.minSelectedDate || !this.maxSelectedDate) {
435
- return undefined;
436
- }
437
- return `year:[${this.minSelectedDate} TO ${this.maxSelectedDate}]`;
438
- }
439
- firstUpdated() {
440
- this.setupStateRestorationObserver();
441
- this.restoreState();
442
- }
443
- updated(changed) {
444
- var _a;
445
- if (changed.has('displayMode') ||
446
- changed.has('baseNavigationUrl') ||
447
- changed.has('baseImageUrl') ||
448
- changed.has('loggedIn')) {
449
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
450
- }
451
- if (changed.has('baseQuery')) {
452
- this.emitBaseQueryChanged();
453
- }
454
- if (changed.has('searchType')) {
455
- this.emitSearchTypeChanged();
456
- }
457
- if (changed.has('currentPage') || changed.has('displayMode')) {
458
- this.persistState();
459
- }
460
- if (changed.has('baseQuery') ||
461
- changed.has('titleQuery') ||
462
- changed.has('creatorQuery') ||
463
- changed.has('minSelectedDate') ||
464
- changed.has('maxSelectedDate') ||
465
- changed.has('sortParam') ||
466
- changed.has('selectedFacets') ||
467
- changed.has('searchService')) {
468
- this.handleQueryChange();
469
- }
470
- if (changed.has('baseQuery') ||
471
- changed.has('minSelectedDate') ||
472
- changed.has('maxSelectedDate') ||
473
- changed.has('selectedFacets')) {
474
- this.refreshLetterCounts();
475
- }
476
- if (changed.has('selectedSort') || changed.has('sortDirection')) {
477
- const prevSortDirection = changed.get('sortDirection');
478
- this.sendSortByAnalytics(prevSortDirection);
479
- this.selectedSortChanged();
480
- }
481
- if (changed.has('selectedTitleFilter')) {
482
- this.sendFilterByTitleAnalytics(changed.get('selectedTitleFilter'));
483
- this.selectedTitleLetterChanged();
484
- }
485
- if (changed.has('selectedCreatorFilter')) {
486
- this.sendFilterByCreatorAnalytics(changed.get('selectedCreatorFilter'));
487
- this.selectedCreatorLetterChanged();
488
- }
489
- if (changed.has('pagesToRender')) {
490
- if (!this.endOfDataReached && this.infiniteScroller) {
491
- this.infiniteScroller.itemCount = this.estimatedTileCount;
492
- }
493
- }
494
- if (changed.has('resizeObserver')) {
495
- const oldObserver = changed.get('resizeObserver');
496
- if (oldObserver)
497
- this.disconnectResizeObserver(oldObserver);
498
- this.setupResizeObserver();
499
- }
500
- }
501
- disconnectedCallback() {
502
- if (this.resizeObserver) {
503
- this.disconnectResizeObserver(this.resizeObserver);
504
- }
505
- if (this.boundNavigationHandler) {
506
- window.removeEventListener('popstate', this.boundNavigationHandler);
507
- }
508
- }
509
- handleResize(entry) {
510
- const previousView = this.mobileView;
511
- if (entry.target === this.contentContainer) {
512
- this.mobileView = entry.contentRect.width < this.mobileBreakpoint;
513
- // If changing from desktop to mobile disable transition
514
- if (this.mobileView && !previousView) {
515
- this.isResizeToMobile = true;
516
- }
517
- }
518
- }
519
- emitBaseQueryChanged() {
520
- this.dispatchEvent(new CustomEvent('baseQueryChanged', {
521
- detail: {
522
- baseQuery: this.baseQuery,
523
- },
524
- }));
525
- }
526
- emitSearchTypeChanged() {
527
- this.dispatchEvent(new CustomEvent('searchTypeChanged', {
528
- detail: this.searchType,
529
- }));
530
- }
531
- disconnectResizeObserver(resizeObserver) {
532
- resizeObserver.removeObserver({
533
- target: this.contentContainer,
534
- handler: this,
535
- });
536
- }
537
- setupResizeObserver() {
538
- if (!this.resizeObserver)
539
- return;
540
- this.resizeObserver.addObserver({
541
- target: this.contentContainer,
542
- handler: this,
543
- });
544
- }
545
- /**
546
- * When the visible cells change from the infinite scroller, we want to emit
547
- * which page is currently visible so the consumer can update its UI or the URL
548
- *
549
- * @param e
550
- * @returns
551
- */
552
- visibleCellsChanged(e) {
553
- if (this.isScrollingToCell)
554
- return;
555
- const { visibleCellIndices } = e.detail;
556
- if (visibleCellIndices.length === 0)
557
- return;
558
- const lastVisibleCellIndex = visibleCellIndices[visibleCellIndices.length - 1];
559
- const lastVisibleCellPage = Math.floor(lastVisibleCellIndex / this.pageSize) + 1;
560
- if (this.currentPage !== lastVisibleCellPage) {
561
- this.currentPage = lastVisibleCellPage;
562
- }
563
- const event = new CustomEvent('visiblePageChanged', {
564
- detail: {
565
- pageNumber: lastVisibleCellPage,
566
- },
567
- });
568
- this.dispatchEvent(event);
569
- }
570
- async handleQueryChange() {
571
- var _a;
572
- // only reset if the query has actually changed
573
- if (!this.searchService || this.pageFetchQueryKey === this.previousQueryKey)
574
- return;
575
- this.previousQueryKey = this.pageFetchQueryKey;
576
- this.dataSource = {};
577
- this.totalResults = undefined;
578
- this.aggregations = undefined;
579
- this.fullYearsHistogramAggregation = undefined;
580
- this.pageFetchesInProgress = {};
581
- this.endOfDataReached = false;
582
- this.pagesToRender = this.initialPageNumber;
583
- // Reset the infinite scroller's item count, so that it
584
- // shows tile placeholders until the new query's results load in
585
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
586
- if (!this.initialQueryChangeHappened && this.initialPageNumber > 1) {
587
- this.scrollToPage(this.initialPageNumber);
588
- }
589
- this.initialQueryChangeHappened = true;
590
- // if the query changed as part of a window.history pop event, we don't want to
591
- // persist the state because it overwrites the forward history
592
- if (!this.historyPopOccurred) {
593
- this.persistState();
594
- this.historyPopOccurred = false;
595
- }
596
- await Promise.all([this.doInitialPageFetch(), this.fetchFacets()]);
597
- }
598
- setupStateRestorationObserver() {
599
- if (this.boundNavigationHandler)
600
- return;
601
- this.boundNavigationHandler = this.historyNavigationHandler.bind(this);
602
- // when the user navigates back, we want to update the UI to match the URL
603
- window.addEventListener('popstate', this.boundNavigationHandler);
604
- }
605
- historyNavigationHandler() {
606
- this.historyPopOccurred = true;
607
- this.restoreState();
608
- }
609
- restoreState() {
610
- var _a, _b, _c, _d, _e, _f;
611
- const restorationState = this.restorationStateHandler.getRestorationState();
612
- this.displayMode = restorationState.displayMode;
613
- if (restorationState.searchType != null)
614
- this.searchType = restorationState.searchType;
615
- this.selectedSort = (_a = restorationState.selectedSort) !== null && _a !== void 0 ? _a : SortField.relevance;
616
- this.sortDirection = (_b = restorationState.sortDirection) !== null && _b !== void 0 ? _b : null;
617
- this.selectedTitleFilter = (_c = restorationState.selectedTitleFilter) !== null && _c !== void 0 ? _c : null;
618
- this.selectedCreatorFilter = (_d = restorationState.selectedCreatorFilter) !== null && _d !== void 0 ? _d : null;
619
- this.selectedFacets = restorationState.selectedFacets;
620
- this.baseQuery = restorationState.baseQuery;
621
- this.titleQuery = restorationState.titleQuery;
622
- this.creatorQuery = restorationState.creatorQuery;
623
- this.sortParam = (_e = restorationState.sortParam) !== null && _e !== void 0 ? _e : null;
624
- this.currentPage = (_f = restorationState.currentPage) !== null && _f !== void 0 ? _f : 1;
625
- this.minSelectedDate = restorationState.minSelectedDate;
626
- this.maxSelectedDate = restorationState.maxSelectedDate;
627
- if (this.currentPage > 1) {
628
- this.goToPage(this.currentPage);
629
- }
630
- }
631
- persistState() {
632
- var _a, _b, _c, _d, _e;
633
- const restorationState = {
634
- displayMode: this.displayMode,
635
- searchType: this.searchType,
636
- sortParam: (_a = this.sortParam) !== null && _a !== void 0 ? _a : undefined,
637
- selectedSort: this.selectedSort,
638
- sortDirection: (_b = this.sortDirection) !== null && _b !== void 0 ? _b : undefined,
639
- selectedFacets: (_c = this.selectedFacets) !== null && _c !== void 0 ? _c : defaultSelectedFacets,
640
- baseQuery: this.baseQuery,
641
- currentPage: this.currentPage,
642
- titleQuery: this.titleQuery,
643
- creatorQuery: this.creatorQuery,
644
- minSelectedDate: this.minSelectedDate,
645
- maxSelectedDate: this.maxSelectedDate,
646
- selectedTitleFilter: (_d = this.selectedTitleFilter) !== null && _d !== void 0 ? _d : undefined,
647
- selectedCreatorFilter: (_e = this.selectedCreatorFilter) !== null && _e !== void 0 ? _e : undefined,
648
- };
649
- this.restorationStateHandler.persistState(restorationState);
650
- }
651
- async doInitialPageFetch() {
652
- this.searchResultsLoading = true;
653
- await this.fetchPage(this.initialPageNumber);
654
- this.searchResultsLoading = false;
655
- }
656
- get filterMap() {
657
- const builder = new FilterMapBuilder();
658
- // Add the date range, if applicable
659
- if (this.minSelectedDate) {
660
- builder.addFilter('year', this.minSelectedDate, FilterConstraint.GREATER_OR_EQUAL);
661
- }
662
- if (this.maxSelectedDate) {
663
- builder.addFilter('year', this.maxSelectedDate, FilterConstraint.LESS_OR_EQUAL);
664
- }
665
- // Add any selected facets
666
- if (this.selectedFacets) {
667
- for (const [facetName, facetValues] of Object.entries(this.selectedFacets)) {
668
- const { name, values } = this.prepareFacetForFetch(facetName, facetValues);
669
- for (const [value, bucket] of Object.entries(values)) {
670
- let constraint;
671
- if (bucket.state === 'selected') {
672
- constraint = FilterConstraint.INCLUDE;
673
- }
674
- else if (bucket.state === 'hidden') {
675
- constraint = FilterConstraint.EXCLUDE;
676
- }
677
- if (constraint) {
678
- builder.addFilter(name, value, constraint);
679
- }
680
- }
681
- }
682
- }
683
- const filterMap = builder.build();
684
- // TEMP: At present, the backend search engine incorrectly returns 0 results if
685
- // the _first_ language filter contains a space, so let's try to avoid that if possible.
686
- if (filterMap.language) {
687
- for (const [value, constraint] of Object.entries(filterMap.language)) {
688
- if (value.includes(' ')) {
689
- // Delete and re-add this filter to make it the last one on the parent object
690
- // (Technically this isn't in the standard, but most browser impls output
691
- // object keys in the order they were added.)
692
- delete filterMap.language[value];
693
- filterMap.language[value] = constraint;
694
- }
695
- else {
696
- // As soon as we reach one without a space, we're done
697
- break;
698
- }
699
- }
700
- }
701
- return filterMap;
702
- }
703
- /** The base query joined with any title/creator letter filters */
704
- get filteredQuery() {
705
- if (!this.baseQuery)
706
- return undefined;
707
- let filteredQuery = this.baseQuery;
708
- const { sortFilterQueries } = this;
709
- if (sortFilterQueries) {
710
- filteredQuery += ` AND ${sortFilterQueries}`;
711
- }
712
- return filteredQuery;
713
- }
714
- /** The full query, including year facets and date range clauses */
715
- get fullQuery() {
716
- if (!this.baseQuery)
717
- return undefined;
718
- let fullQuery = this.baseQuery;
719
- const { facetQuery, dateRangeQueryClause, sortFilterQueries } = this;
720
- if (facetQuery) {
721
- fullQuery += ` AND ${facetQuery}`;
722
- }
723
- if (dateRangeQueryClause) {
724
- fullQuery += ` AND ${dateRangeQueryClause}`;
725
- }
726
- if (sortFilterQueries) {
727
- fullQuery += ` AND ${sortFilterQueries}`;
728
- }
729
- return fullQuery;
730
- }
731
- /** The full query without any title/creator letter filters */
732
- get fullQueryWithoutAlphaFilters() {
733
- if (!this.baseQuery)
734
- return undefined;
735
- let fullQuery = this.baseQuery;
736
- const { facetQuery, dateRangeQueryClause } = this;
737
- if (facetQuery) {
738
- fullQuery += ` AND ${facetQuery}`;
739
- }
740
- if (dateRangeQueryClause) {
741
- fullQuery += ` AND ${dateRangeQueryClause}`;
742
- }
743
- return fullQuery;
744
- }
745
- /**
746
- * Generates a query string for the given facets
747
- *
748
- * Example: `mediatype:("collection" OR "audio" OR -"etree") AND year:("2000" OR "2001")`
749
- */
750
- get facetQuery() {
751
- if (!this.selectedFacets)
752
- return undefined;
753
- const facetClauses = [];
754
- for (const [facetName, facetValues] of Object.entries(this.selectedFacets)) {
755
- facetClauses.push(this.buildFacetClause(facetName, facetValues));
756
- }
757
- return this.joinFacetClauses(facetClauses);
758
- }
759
- /**
760
- * Builds an OR-joined facet clause for the given facet name and values.
761
- *
762
- * E.g., for name `subject` and values
763
- * `{ foo: { state: 'selected' }, bar: { state: 'hidden' } }`
764
- * this will produce the clause
765
- * `subject:("foo" OR -"bar")`.
766
- *
767
- * @param facetName The facet type (e.g., 'collection')
768
- * @param facetValues The facet buckets, mapped by their keys
769
- */
770
- buildFacetClause(facetName, facetValues) {
771
- const { name: facetQueryName, values } = this.prepareFacetForFetch(facetName, facetValues);
772
- const facetEntries = Object.entries(values);
773
- if (facetEntries.length === 0)
774
- return '';
775
- const facetValuesArray = [];
776
- for (const [key, facetData] of facetEntries) {
777
- const plusMinusPrefix = facetData.state === 'hidden' ? '-' : '';
778
- facetValuesArray.push(`${plusMinusPrefix}"${key}"`);
779
- }
780
- const valueQuery = facetValuesArray.join(` OR `);
781
- return `${facetQueryName}:(${valueQuery})`;
782
- }
783
- /**
784
- * Handles some special pre-request normalization steps for certain facet types
785
- * that require them.
786
- *
787
- * @param facetName The name of the facet type (e.g., 'language')
788
- * @param facetValues An array of values for that facet type
789
- */
790
- prepareFacetForFetch(facetName, facetValues) {
791
- let [normalizedName, normalizedValues] = [facetName, facetValues];
792
- // The full "search engine" name of the lending field is "lending___status"
793
- if (facetName === 'lending') {
794
- normalizedName = 'lending___status';
795
- }
796
- // Language codes like "en-US|en-GB|en" need to be broken apart into individual values
797
- if (facetName === 'language') {
798
- normalizedValues = {};
799
- for (const [facetValue, facetData] of Object.entries(facetValues)) {
800
- const languages = this.languageCodeHandler.getCodeArrayFromCodeString(facetValue);
801
- for (const lang of languages) {
802
- normalizedValues[lang] = { ...facetData };
803
- }
804
- }
805
- }
806
- return {
807
- name: normalizedName,
808
- values: normalizedValues,
809
- };
810
- }
811
- /**
812
- * Takes an array of facet clauses, and combines them into a
813
- * full AND-joined facet query string. Empty clauses are ignored.
814
- */
815
- joinFacetClauses(facetClauses) {
816
- const nonEmptyFacetClauses = facetClauses.filter(clause => clause.length > 0);
817
- return nonEmptyFacetClauses.length > 0
818
- ? `(${nonEmptyFacetClauses.join(' AND ')})`
819
- : undefined;
820
- }
821
- facetsChanged(e) {
822
- this.selectedFacets = e.detail;
823
- }
824
- facetClickHandler(name, facetSelected, negative) {
825
- var _a, _b;
826
- if (negative) {
827
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
828
- category: this.searchContext,
829
- action: facetSelected
830
- ? analyticsActions.facetNegativeSelected
831
- : analyticsActions.facetNegativeDeselected,
832
- label: name,
833
- });
834
- }
835
- else {
836
- (_b = this.analyticsHandler) === null || _b === void 0 ? void 0 : _b.sendEvent({
837
- category: this.searchContext,
838
- action: facetSelected
839
- ? analyticsActions.facetSelected
840
- : analyticsActions.facetDeselected,
841
- label: name,
842
- });
843
- }
844
- }
845
- async fetchFacets() {
846
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
847
- if (!this.filteredQuery)
848
- return;
849
- const params = {
850
- query: this.filteredQuery,
851
- rows: 0,
852
- filters: this.filterMap,
853
- // Fetch a few extra buckets beyond the 6 we show, in case some get suppressed
854
- aggregationsSize: 10,
855
- // Note: we don't need an aggregations param to fetch the default aggregations from the PPS.
856
- // The default aggregations for the search_results page type should be what we need here.
857
- };
858
- this.facetsLoading = true;
859
- this.previousSearchType = this.searchType;
860
- const results = await ((_a = this.searchService) === null || _a === void 0 ? void 0 : _a.search(params, this.searchType));
861
- this.facetsLoading = false;
862
- this.aggregations = (_b = results === null || results === void 0 ? void 0 : results.success) === null || _b === void 0 ? void 0 : _b.response.aggregations;
863
- this.fullYearsHistogramAggregation =
864
- (_f = (_e = (_d = (_c = results === null || results === void 0 ? void 0 : results.success) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.aggregations) === null || _e === void 0 ? void 0 : _e.year_histogram) !== null && _f !== void 0 ? _f : (_j = (_h = (_g = results === null || results === void 0 ? void 0 : results.success) === null || _g === void 0 ? void 0 : _g.response) === null || _h === void 0 ? void 0 : _h.aggregations) === null || _j === void 0 ? void 0 : _j['year-histogram']; // Temp fix until PPS FTS key is fixed to use underscore
865
- }
866
- scrollToPage(pageNumber) {
867
- return new Promise(resolve => {
868
- const cellIndexToScrollTo = this.pageSize * (pageNumber - 1);
869
- // without this setTimeout, Safari just pauses until the `fetchPage` is complete
870
- // then scrolls to the cell
871
- setTimeout(() => {
872
- var _a;
873
- this.isScrollingToCell = true;
874
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.scrollToCell(cellIndexToScrollTo, true);
875
- // This timeout is to give the scroll animation time to finish
876
- // then updating the infinite scroller once we're done scrolling
877
- // There's no scroll animation completion callback so we're
878
- // giving it 0.5s to finish.
879
- setTimeout(() => {
880
- var _a;
881
- this.isScrollingToCell = false;
882
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
883
- resolve();
884
- }, 500);
885
- }, 0);
886
- });
887
- }
888
- /**
889
- * The query key is a string that uniquely identifies the current search.
890
- * It consists of:
891
- * - The current base query
892
- * - The current search type
893
- * - Any currently-applied facets
894
- * - Any currently-applied date range
895
- * - Any currently-applied prefix filters
896
- * - The current sort options
897
- *
898
- * This lets us keep track of queries so we don't persist data that's
899
- * no longer relevant.
900
- */
901
- get pageFetchQueryKey() {
902
- var _a, _b;
903
- return `${this.fullQuery}-${this.searchType}-${(_a = this.sortParam) === null || _a === void 0 ? void 0 : _a.field}-${(_b = this.sortParam) === null || _b === void 0 ? void 0 : _b.direction}`;
904
- }
905
- async fetchPage(pageNumber) {
906
- var _a, _b, _c, _d, _e;
907
- if (!this.filteredQuery)
908
- return;
909
- // if we already have data, don't fetch again
910
- if (this.dataSource[pageNumber])
911
- return;
912
- if (this.endOfDataReached)
913
- return;
914
- // if a fetch is already in progress for this query and page, don't fetch again
915
- const { pageFetchQueryKey } = this;
916
- const pageFetches = (_a = this.pageFetchesInProgress[pageFetchQueryKey]) !== null && _a !== void 0 ? _a : new Set();
917
- if (pageFetches.has(pageNumber))
918
- return;
919
- pageFetches.add(pageNumber);
920
- this.pageFetchesInProgress[pageFetchQueryKey] = pageFetches;
921
- const sortParams = this.sortParam ? [this.sortParam] : [];
922
- const params = {
923
- query: this.filteredQuery,
924
- page: pageNumber,
925
- rows: this.pageSize,
926
- sort: sortParams,
927
- filters: this.filterMap,
928
- aggregations: { omit: true },
929
- };
930
- const searchResponse = await ((_b = this.searchService) === null || _b === void 0 ? void 0 : _b.search(params, this.searchType));
931
- const success = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.success;
932
- if (!success)
933
- return;
934
- this.totalResults = success.response.totalResults;
935
- // this is checking to see if the query has changed since the data was fetched
936
- // if so, we just want to discard the data since there should be a new query
937
- // right behind it
938
- const searchQuery = success.request.clientParameters.user_query;
939
- const searchSort = success.request.clientParameters.sort;
940
- let sortChanged = false;
941
- if (!searchSort || searchSort.length === 0) {
942
- // if we went from no sort to sort, the sort has changed
943
- if (this.sortParam) {
944
- sortChanged = true;
945
- }
946
- }
947
- else {
948
- // check if the sort has changed
949
- for (const sortType of searchSort) {
950
- const [field, direction] = sortType.split(':');
951
- if (field !== ((_c = this.sortParam) === null || _c === void 0 ? void 0 : _c.field) ||
952
- direction !== ((_d = this.sortParam) === null || _d === void 0 ? void 0 : _d.direction)) {
953
- sortChanged = true;
954
- break;
955
- }
956
- }
957
- }
958
- const queryChangedSinceFetch = searchQuery !== this.filteredQuery || sortChanged;
959
- if (queryChangedSinceFetch)
960
- return;
961
- const { results } = success.response;
962
- if (results && results.length > 0) {
963
- this.preloadCollectionNames(results);
964
- this.updateDataSource(pageNumber, results);
965
- }
966
- // When we reach the end of the data, we can set the infinite scroller's
967
- // item count to the real total number of results (rather than the
968
- // temporary estimates based on pages rendered so far).
969
- if (results.length < this.pageSize) {
970
- this.endOfDataReached = true;
971
- if (this.infiniteScroller) {
972
- this.infiniteScroller.itemCount = this.totalResults;
973
- }
974
- }
975
- (_e = this.pageFetchesInProgress[pageFetchQueryKey]) === null || _e === void 0 ? void 0 : _e.delete(pageNumber);
976
- this.searchResultsLoading = false;
977
- }
978
- preloadCollectionNames(results) {
979
- var _a;
980
- const collectionIds = results
981
- .map(result => { var _a; return (_a = result.collection) === null || _a === void 0 ? void 0 : _a.values; })
982
- .flat();
983
- const collectionIdsArray = Array.from(new Set(collectionIds));
984
- (_a = this.collectionNameCache) === null || _a === void 0 ? void 0 : _a.preloadIdentifiers(collectionIdsArray);
985
- }
986
- /**
987
- * This is useful for determining whether we need to reload the scroller.
988
- *
989
- * When the fetch completes, we need to reload the scroller if the cells for that
990
- * page are visible, but if the page is not currenlty visible, we don't need to reload
991
- */
992
- get currentVisiblePageNumbers() {
993
- var _a, _b;
994
- const visibleCells = (_b = (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.getVisibleCellIndices()) !== null && _b !== void 0 ? _b : [];
995
- const visiblePages = new Set();
996
- visibleCells.forEach(cellIndex => {
997
- const visiblePage = Math.floor(cellIndex / this.pageSize) + 1;
998
- visiblePages.add(visiblePage);
999
- });
1000
- return Array.from(visiblePages);
1001
- }
1002
- /**
1003
- * Update the datasource from the fetch response
1004
- *
1005
- * @param pageNumber
1006
- * @param results
1007
- */
1008
- updateDataSource(pageNumber, results) {
1009
- var _a;
1010
- // copy our existing datasource so when we set it below, it gets set
1011
- // instead of modifying the existing dataSource since object changes
1012
- // don't trigger a re-render
1013
- const datasource = { ...this.dataSource };
1014
- const tiles = [];
1015
- results === null || results === void 0 ? void 0 : results.forEach(result => {
1016
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
1017
- if (!result.identifier)
1018
- return;
1019
- let loginRequired = false;
1020
- let contentWarning = false;
1021
- // Check if item and item in "modifying" collection, setting above flags
1022
- if (((_a = result.collection) === null || _a === void 0 ? void 0 : _a.values.length) &&
1023
- ((_b = result.mediatype) === null || _b === void 0 ? void 0 : _b.value) !== 'collection') {
1024
- for (const collection of (_d = (_c = result.collection) === null || _c === void 0 ? void 0 : _c.values) !== null && _d !== void 0 ? _d : []) {
1025
- if (collection === 'loggedin') {
1026
- loginRequired = true;
1027
- if (contentWarning)
1028
- break;
1029
- }
1030
- if (collection === 'no-preview') {
1031
- contentWarning = true;
1032
- if (loginRequired)
1033
- break;
1034
- }
1035
- }
1036
- }
1037
- tiles.push({
1038
- averageRating: (_e = result.avg_rating) === null || _e === void 0 ? void 0 : _e.value,
1039
- collections: (_g = (_f = result.collection) === null || _f === void 0 ? void 0 : _f.values) !== null && _g !== void 0 ? _g : [],
1040
- collectionFilesCount: (_j = (_h = result.collection_files_count) === null || _h === void 0 ? void 0 : _h.value) !== null && _j !== void 0 ? _j : 0,
1041
- collectionSize: (_l = (_k = result.collection_size) === null || _k === void 0 ? void 0 : _k.value) !== null && _l !== void 0 ? _l : 0,
1042
- commentCount: (_o = (_m = result.num_reviews) === null || _m === void 0 ? void 0 : _m.value) !== null && _o !== void 0 ? _o : 0,
1043
- creator: (_p = result.creator) === null || _p === void 0 ? void 0 : _p.value,
1044
- creators: (_r = (_q = result.creator) === null || _q === void 0 ? void 0 : _q.values) !== null && _r !== void 0 ? _r : [],
1045
- dateAdded: (_s = result.addeddate) === null || _s === void 0 ? void 0 : _s.value,
1046
- dateArchived: (_t = result.publicdate) === null || _t === void 0 ? void 0 : _t.value,
1047
- datePublished: (_u = result.date) === null || _u === void 0 ? void 0 : _u.value,
1048
- dateReviewed: (_v = result.reviewdate) === null || _v === void 0 ? void 0 : _v.value,
1049
- description: (_w = result.description) === null || _w === void 0 ? void 0 : _w.values.join('\n'),
1050
- favCount: (_y = (_x = result.num_favorites) === null || _x === void 0 ? void 0 : _x.value) !== null && _y !== void 0 ? _y : 0,
1051
- identifier: result.identifier,
1052
- issue: (_z = result.issue) === null || _z === void 0 ? void 0 : _z.value,
1053
- itemCount: (_1 = (_0 = result.item_count) === null || _0 === void 0 ? void 0 : _0.value) !== null && _1 !== void 0 ? _1 : 0,
1054
- mediatype: (_3 = (_2 = result.mediatype) === null || _2 === void 0 ? void 0 : _2.value) !== null && _3 !== void 0 ? _3 : 'data',
1055
- snippets: (_5 = (_4 = result.highlight) === null || _4 === void 0 ? void 0 : _4.values) !== null && _5 !== void 0 ? _5 : [],
1056
- source: (_6 = result.source) === null || _6 === void 0 ? void 0 : _6.value,
1057
- subjects: (_8 = (_7 = result.subject) === null || _7 === void 0 ? void 0 : _7.values) !== null && _8 !== void 0 ? _8 : [],
1058
- title: this.etreeTitle((_9 = result.title) === null || _9 === void 0 ? void 0 : _9.value, (_10 = result.mediatype) === null || _10 === void 0 ? void 0 : _10.value, (_11 = result.collection) === null || _11 === void 0 ? void 0 : _11.values),
1059
- volume: (_12 = result.volume) === null || _12 === void 0 ? void 0 : _12.value,
1060
- viewCount: (_14 = (_13 = result.downloads) === null || _13 === void 0 ? void 0 : _13.value) !== null && _14 !== void 0 ? _14 : 0,
1061
- weeklyViewCount: (_15 = result.week) === null || _15 === void 0 ? void 0 : _15.value,
1062
- loginRequired,
1063
- contentWarning,
1064
- });
1065
- });
1066
- datasource[pageNumber] = tiles;
1067
- this.dataSource = datasource;
1068
- const visiblePages = this.currentVisiblePageNumbers;
1069
- const needsReload = visiblePages.includes(pageNumber);
1070
- if (needsReload) {
1071
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
1072
- }
1073
- }
1074
- /** Fetches the aggregation buckets for the given prefix filter type. */
1075
- async fetchPrefixFilterBuckets(filterType) {
1076
- var _a, _b, _c, _d, _e, _f;
1077
- if (!this.fullQueryWithoutAlphaFilters)
1078
- return [];
1079
- const filterAggregationKey = prefixFilterAggregationKeys[filterType];
1080
- const params = {
1081
- query: this.fullQueryWithoutAlphaFilters,
1082
- rows: 0,
1083
- // Only fetch the firstTitle or firstCreator aggregation
1084
- aggregations: { simpleParams: [filterAggregationKey] },
1085
- // Fetch all 26 letter buckets
1086
- aggregationsSize: 26,
1087
- };
1088
- const searchResponse = await ((_a = this.searchService) === null || _a === void 0 ? void 0 : _a.search(params, this.searchType));
1089
- return ((_f = (_e = (_d = (_c = (_b = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.success) === null || _b === void 0 ? void 0 : _b.response) === null || _c === void 0 ? void 0 : _c.aggregations) === null || _d === void 0 ? void 0 : _d[filterAggregationKey]) === null || _e === void 0 ? void 0 : _e.buckets) !== null && _f !== void 0 ? _f : []);
1090
- }
1091
- /** Fetches and caches the prefix filter counts for the given filter type. */
1092
- async updatePrefixFilterCounts(filterType) {
1093
- const buckets = await this.fetchPrefixFilterBuckets(filterType);
1094
- // Unpack the aggregation buckets into a simple map like { 'A': 50, 'B': 25, ... }
1095
- this.prefixFilterCountMap = { ...this.prefixFilterCountMap }; // Clone the object to trigger an update
1096
- this.prefixFilterCountMap[filterType] = buckets.reduce((acc, bucket) => {
1097
- acc[bucket.key.toUpperCase()] = bucket.doc_count;
1098
- return acc;
1099
- }, {});
1100
- }
1101
- /**
1102
- * Fetches and caches the prefix filter counts for the current sort type,
1103
- * provided it is one that permits prefix filtering. (If not, this does nothing).
1104
- */
1105
- async updatePrefixFiltersForCurrentSort() {
1106
- if (['title', 'creator'].includes(this.selectedSort)) {
1107
- const filterType = this.selectedSort;
1108
- if (!this.prefixFilterCountMap[filterType]) {
1109
- this.updatePrefixFilterCounts(filterType);
1110
- }
1111
- }
1112
- }
1113
- /**
1114
- * Clears the cached letter counts for both title and creator, and
1115
- * fetches a new set of counts for whichever of them is the currently
1116
- * selected sort option (which may be neither).
1117
- *
1118
- * Call this whenever the counts are invalidated (e.g., by a query change).
1119
- */
1120
- refreshLetterCounts() {
1121
- this.prefixFilterCountMap = {};
1122
- this.updatePrefixFiltersForCurrentSort();
1123
- }
1124
- /*
1125
- * Convert etree titles
1126
- * "[Creator] Live at [Place] on [Date]" => "[Date]: [Place]"
1127
- *
1128
- * Todo: Check collection(s) for etree, need to get as array.
1129
- * Current search-service only returns first collection as string.
1130
- */
1131
- etreeTitle(title, mediatype, collections) {
1132
- if (mediatype === 'etree' || (collections === null || collections === void 0 ? void 0 : collections.includes('etree'))) {
1133
- const regex = /^(.*) Live at (.*) on (\d\d\d\d-\d\d-\d\d)$/;
1134
- const newTitle = title === null || title === void 0 ? void 0 : title.replace(regex, '$3: $2');
1135
- if (newTitle) {
1136
- return `${newTitle}`;
1137
- }
1138
- }
1139
- return title !== null && title !== void 0 ? title : '';
1140
- }
1141
- /**
1142
- * Callback when a result is selected
1143
- */
1144
- resultSelected(event) {
1145
- var _a, _b;
1146
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
1147
- category: this.searchContext,
1148
- action: analyticsActions.resultSelected,
1149
- label: event.detail.mediatype,
1150
- });
1151
- (_b = this.analyticsHandler) === null || _b === void 0 ? void 0 : _b.sendEvent({
1152
- category: this.searchContext,
1153
- action: analyticsActions.resultSelected,
1154
- label: `page-${this.currentPage}`,
1155
- });
1156
- }
1157
- cellForIndex(index) {
1158
- const model = this.tileModelAtCellIndex(index);
1159
- if (!model)
1160
- return undefined;
421
+ `;
422
+ }
423
+ histogramDateRangeUpdated(e) {
424
+ var _a;
425
+ const { minDate, maxDate } = e.detail;
426
+ [this.minSelectedDate, this.maxSelectedDate] = [minDate, maxDate];
427
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
428
+ category: this.searchContext,
429
+ action: analyticsActions.histogramChanged,
430
+ label: this.dateRangeQueryClause,
431
+ });
432
+ }
433
+ get dateRangeQueryClause() {
434
+ if (!this.minSelectedDate || !this.maxSelectedDate) {
435
+ return undefined;
436
+ }
437
+ return `year:[${this.minSelectedDate} TO ${this.maxSelectedDate}]`;
438
+ }
439
+ firstUpdated() {
440
+ this.setupStateRestorationObserver();
441
+ this.restoreState();
442
+ }
443
+ updated(changed) {
444
+ var _a;
445
+ if (changed.has('displayMode') ||
446
+ changed.has('baseNavigationUrl') ||
447
+ changed.has('baseImageUrl') ||
448
+ changed.has('loggedIn')) {
449
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
450
+ }
451
+ if (changed.has('baseQuery')) {
452
+ this.emitBaseQueryChanged();
453
+ }
454
+ if (changed.has('searchType')) {
455
+ this.emitSearchTypeChanged();
456
+ }
457
+ if (changed.has('currentPage') || changed.has('displayMode')) {
458
+ this.persistState();
459
+ }
460
+ if (changed.has('baseQuery') ||
461
+ changed.has('titleQuery') ||
462
+ changed.has('creatorQuery') ||
463
+ changed.has('minSelectedDate') ||
464
+ changed.has('maxSelectedDate') ||
465
+ changed.has('sortParam') ||
466
+ changed.has('selectedFacets') ||
467
+ changed.has('searchService')) {
468
+ this.handleQueryChange();
469
+ }
470
+ if (changed.has('baseQuery') ||
471
+ changed.has('minSelectedDate') ||
472
+ changed.has('maxSelectedDate') ||
473
+ changed.has('selectedFacets')) {
474
+ this.refreshLetterCounts();
475
+ }
476
+ if (changed.has('selectedSort') || changed.has('sortDirection')) {
477
+ const prevSortDirection = changed.get('sortDirection');
478
+ this.sendSortByAnalytics(prevSortDirection);
479
+ this.selectedSortChanged();
480
+ }
481
+ if (changed.has('selectedTitleFilter')) {
482
+ this.sendFilterByTitleAnalytics(changed.get('selectedTitleFilter'));
483
+ this.selectedTitleLetterChanged();
484
+ }
485
+ if (changed.has('selectedCreatorFilter')) {
486
+ this.sendFilterByCreatorAnalytics(changed.get('selectedCreatorFilter'));
487
+ this.selectedCreatorLetterChanged();
488
+ }
489
+ if (changed.has('pagesToRender')) {
490
+ if (!this.endOfDataReached && this.infiniteScroller) {
491
+ this.infiniteScroller.itemCount = this.estimatedTileCount;
492
+ }
493
+ }
494
+ if (changed.has('resizeObserver')) {
495
+ const oldObserver = changed.get('resizeObserver');
496
+ if (oldObserver)
497
+ this.disconnectResizeObserver(oldObserver);
498
+ this.setupResizeObserver();
499
+ }
500
+ }
501
+ disconnectedCallback() {
502
+ if (this.resizeObserver) {
503
+ this.disconnectResizeObserver(this.resizeObserver);
504
+ }
505
+ if (this.boundNavigationHandler) {
506
+ window.removeEventListener('popstate', this.boundNavigationHandler);
507
+ }
508
+ }
509
+ handleResize(entry) {
510
+ const previousView = this.mobileView;
511
+ if (entry.target === this.contentContainer) {
512
+ this.mobileView = entry.contentRect.width < this.mobileBreakpoint;
513
+ // If changing from desktop to mobile disable transition
514
+ if (this.mobileView && !previousView) {
515
+ this.isResizeToMobile = true;
516
+ }
517
+ }
518
+ }
519
+ emitBaseQueryChanged() {
520
+ this.dispatchEvent(new CustomEvent('baseQueryChanged', {
521
+ detail: {
522
+ baseQuery: this.baseQuery,
523
+ },
524
+ }));
525
+ }
526
+ emitSearchTypeChanged() {
527
+ this.dispatchEvent(new CustomEvent('searchTypeChanged', {
528
+ detail: this.searchType,
529
+ }));
530
+ }
531
+ disconnectResizeObserver(resizeObserver) {
532
+ resizeObserver.removeObserver({
533
+ target: this.contentContainer,
534
+ handler: this,
535
+ });
536
+ }
537
+ setupResizeObserver() {
538
+ if (!this.resizeObserver)
539
+ return;
540
+ this.resizeObserver.addObserver({
541
+ target: this.contentContainer,
542
+ handler: this,
543
+ });
544
+ }
545
+ /**
546
+ * When the visible cells change from the infinite scroller, we want to emit
547
+ * which page is currently visible so the consumer can update its UI or the URL
548
+ *
549
+ * @param e
550
+ * @returns
551
+ */
552
+ visibleCellsChanged(e) {
553
+ if (this.isScrollingToCell)
554
+ return;
555
+ const { visibleCellIndices } = e.detail;
556
+ if (visibleCellIndices.length === 0)
557
+ return;
558
+ const lastVisibleCellIndex = visibleCellIndices[visibleCellIndices.length - 1];
559
+ const lastVisibleCellPage = Math.floor(lastVisibleCellIndex / this.pageSize) + 1;
560
+ if (this.currentPage !== lastVisibleCellPage) {
561
+ this.currentPage = lastVisibleCellPage;
562
+ }
563
+ const event = new CustomEvent('visiblePageChanged', {
564
+ detail: {
565
+ pageNumber: lastVisibleCellPage,
566
+ },
567
+ });
568
+ this.dispatchEvent(event);
569
+ }
570
+ async handleQueryChange() {
571
+ var _a;
572
+ // only reset if the query has actually changed
573
+ if (!this.searchService || this.pageFetchQueryKey === this.previousQueryKey)
574
+ return;
575
+ this.previousQueryKey = this.pageFetchQueryKey;
576
+ this.dataSource = {};
577
+ this.totalResults = undefined;
578
+ this.aggregations = undefined;
579
+ this.fullYearsHistogramAggregation = undefined;
580
+ this.pageFetchesInProgress = {};
581
+ this.endOfDataReached = false;
582
+ this.pagesToRender = this.initialPageNumber;
583
+ // Reset the infinite scroller's item count, so that it
584
+ // shows tile placeholders until the new query's results load in
585
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
586
+ if (!this.initialQueryChangeHappened && this.initialPageNumber > 1) {
587
+ this.scrollToPage(this.initialPageNumber);
588
+ }
589
+ this.initialQueryChangeHappened = true;
590
+ // if the query changed as part of a window.history pop event, we don't want to
591
+ // persist the state because it overwrites the forward history
592
+ if (!this.historyPopOccurred) {
593
+ this.persistState();
594
+ this.historyPopOccurred = false;
595
+ }
596
+ await Promise.all([this.doInitialPageFetch(), this.fetchFacets()]);
597
+ }
598
+ setupStateRestorationObserver() {
599
+ if (this.boundNavigationHandler)
600
+ return;
601
+ this.boundNavigationHandler = this.historyNavigationHandler.bind(this);
602
+ // when the user navigates back, we want to update the UI to match the URL
603
+ window.addEventListener('popstate', this.boundNavigationHandler);
604
+ }
605
+ historyNavigationHandler() {
606
+ this.historyPopOccurred = true;
607
+ this.restoreState();
608
+ }
609
+ restoreState() {
610
+ var _a, _b, _c, _d, _e, _f;
611
+ const restorationState = this.restorationStateHandler.getRestorationState();
612
+ this.displayMode = restorationState.displayMode;
613
+ if (restorationState.searchType != null)
614
+ this.searchType = restorationState.searchType;
615
+ this.selectedSort = (_a = restorationState.selectedSort) !== null && _a !== void 0 ? _a : SortField.relevance;
616
+ this.sortDirection = (_b = restorationState.sortDirection) !== null && _b !== void 0 ? _b : null;
617
+ this.selectedTitleFilter = (_c = restorationState.selectedTitleFilter) !== null && _c !== void 0 ? _c : null;
618
+ this.selectedCreatorFilter = (_d = restorationState.selectedCreatorFilter) !== null && _d !== void 0 ? _d : null;
619
+ this.selectedFacets = restorationState.selectedFacets;
620
+ this.baseQuery = restorationState.baseQuery;
621
+ this.titleQuery = restorationState.titleQuery;
622
+ this.creatorQuery = restorationState.creatorQuery;
623
+ this.sortParam = (_e = restorationState.sortParam) !== null && _e !== void 0 ? _e : null;
624
+ this.currentPage = (_f = restorationState.currentPage) !== null && _f !== void 0 ? _f : 1;
625
+ this.minSelectedDate = restorationState.minSelectedDate;
626
+ this.maxSelectedDate = restorationState.maxSelectedDate;
627
+ if (this.currentPage > 1) {
628
+ this.goToPage(this.currentPage);
629
+ }
630
+ }
631
+ persistState() {
632
+ var _a, _b, _c, _d, _e;
633
+ const restorationState = {
634
+ displayMode: this.displayMode,
635
+ searchType: this.searchType,
636
+ sortParam: (_a = this.sortParam) !== null && _a !== void 0 ? _a : undefined,
637
+ selectedSort: this.selectedSort,
638
+ sortDirection: (_b = this.sortDirection) !== null && _b !== void 0 ? _b : undefined,
639
+ selectedFacets: (_c = this.selectedFacets) !== null && _c !== void 0 ? _c : defaultSelectedFacets,
640
+ baseQuery: this.baseQuery,
641
+ currentPage: this.currentPage,
642
+ titleQuery: this.titleQuery,
643
+ creatorQuery: this.creatorQuery,
644
+ minSelectedDate: this.minSelectedDate,
645
+ maxSelectedDate: this.maxSelectedDate,
646
+ selectedTitleFilter: (_d = this.selectedTitleFilter) !== null && _d !== void 0 ? _d : undefined,
647
+ selectedCreatorFilter: (_e = this.selectedCreatorFilter) !== null && _e !== void 0 ? _e : undefined,
648
+ };
649
+ this.restorationStateHandler.persistState(restorationState);
650
+ }
651
+ async doInitialPageFetch() {
652
+ this.searchResultsLoading = true;
653
+ await this.fetchPage(this.initialPageNumber);
654
+ this.searchResultsLoading = false;
655
+ }
656
+ get filterMap() {
657
+ const builder = new FilterMapBuilder();
658
+ // Add the date range, if applicable
659
+ if (this.minSelectedDate) {
660
+ builder.addFilter('year', this.minSelectedDate, FilterConstraint.GREATER_OR_EQUAL);
661
+ }
662
+ if (this.maxSelectedDate) {
663
+ builder.addFilter('year', this.maxSelectedDate, FilterConstraint.LESS_OR_EQUAL);
664
+ }
665
+ // Add any selected facets
666
+ if (this.selectedFacets) {
667
+ for (const [facetName, facetValues] of Object.entries(this.selectedFacets)) {
668
+ const { name, values } = this.prepareFacetForFetch(facetName, facetValues);
669
+ for (const [value, bucket] of Object.entries(values)) {
670
+ let constraint;
671
+ if (bucket.state === 'selected') {
672
+ constraint = FilterConstraint.INCLUDE;
673
+ }
674
+ else if (bucket.state === 'hidden') {
675
+ constraint = FilterConstraint.EXCLUDE;
676
+ }
677
+ if (constraint) {
678
+ builder.addFilter(name, value, constraint);
679
+ }
680
+ }
681
+ }
682
+ }
683
+ const filterMap = builder.build();
684
+ // TEMP: At present, the backend search engine incorrectly returns 0 results if
685
+ // the _first_ language filter contains a space, so let's try to avoid that if possible.
686
+ if (filterMap.language) {
687
+ for (const [value, constraint] of Object.entries(filterMap.language)) {
688
+ if (value.includes(' ')) {
689
+ // Delete and re-add this filter to make it the last one on the parent object
690
+ // (Technically this isn't in the standard, but most browser impls output
691
+ // object keys in the order they were added.)
692
+ delete filterMap.language[value];
693
+ filterMap.language[value] = constraint;
694
+ }
695
+ else {
696
+ // As soon as we reach one without a space, we're done
697
+ break;
698
+ }
699
+ }
700
+ }
701
+ return filterMap;
702
+ }
703
+ /** The base query joined with any title/creator letter filters */
704
+ get filteredQuery() {
705
+ if (!this.baseQuery)
706
+ return undefined;
707
+ let filteredQuery = this.baseQuery;
708
+ const { sortFilterQueries } = this;
709
+ if (sortFilterQueries) {
710
+ filteredQuery += ` AND ${sortFilterQueries}`;
711
+ }
712
+ return filteredQuery;
713
+ }
714
+ /** The full query, including year facets and date range clauses */
715
+ get fullQuery() {
716
+ if (!this.baseQuery)
717
+ return undefined;
718
+ let fullQuery = this.baseQuery;
719
+ const { facetQuery, dateRangeQueryClause, sortFilterQueries } = this;
720
+ if (facetQuery) {
721
+ fullQuery += ` AND ${facetQuery}`;
722
+ }
723
+ if (dateRangeQueryClause) {
724
+ fullQuery += ` AND ${dateRangeQueryClause}`;
725
+ }
726
+ if (sortFilterQueries) {
727
+ fullQuery += ` AND ${sortFilterQueries}`;
728
+ }
729
+ return fullQuery;
730
+ }
731
+ /** The full query without any title/creator letter filters */
732
+ get fullQueryWithoutAlphaFilters() {
733
+ if (!this.baseQuery)
734
+ return undefined;
735
+ let fullQuery = this.baseQuery;
736
+ const { facetQuery, dateRangeQueryClause } = this;
737
+ if (facetQuery) {
738
+ fullQuery += ` AND ${facetQuery}`;
739
+ }
740
+ if (dateRangeQueryClause) {
741
+ fullQuery += ` AND ${dateRangeQueryClause}`;
742
+ }
743
+ return fullQuery;
744
+ }
745
+ /**
746
+ * Generates a query string for the given facets
747
+ *
748
+ * Example: `mediatype:("collection" OR "audio" OR -"etree") AND year:("2000" OR "2001")`
749
+ */
750
+ get facetQuery() {
751
+ if (!this.selectedFacets)
752
+ return undefined;
753
+ const facetClauses = [];
754
+ for (const [facetName, facetValues] of Object.entries(this.selectedFacets)) {
755
+ facetClauses.push(this.buildFacetClause(facetName, facetValues));
756
+ }
757
+ return this.joinFacetClauses(facetClauses);
758
+ }
759
+ /**
760
+ * Builds an OR-joined facet clause for the given facet name and values.
761
+ *
762
+ * E.g., for name `subject` and values
763
+ * `{ foo: { state: 'selected' }, bar: { state: 'hidden' } }`
764
+ * this will produce the clause
765
+ * `subject:("foo" OR -"bar")`.
766
+ *
767
+ * @param facetName The facet type (e.g., 'collection')
768
+ * @param facetValues The facet buckets, mapped by their keys
769
+ */
770
+ buildFacetClause(facetName, facetValues) {
771
+ const { name: facetQueryName, values } = this.prepareFacetForFetch(facetName, facetValues);
772
+ const facetEntries = Object.entries(values);
773
+ if (facetEntries.length === 0)
774
+ return '';
775
+ const facetValuesArray = [];
776
+ for (const [key, facetData] of facetEntries) {
777
+ const plusMinusPrefix = facetData.state === 'hidden' ? '-' : '';
778
+ facetValuesArray.push(`${plusMinusPrefix}"${key}"`);
779
+ }
780
+ const valueQuery = facetValuesArray.join(` OR `);
781
+ return `${facetQueryName}:(${valueQuery})`;
782
+ }
783
+ /**
784
+ * Handles some special pre-request normalization steps for certain facet types
785
+ * that require them.
786
+ *
787
+ * @param facetName The name of the facet type (e.g., 'language')
788
+ * @param facetValues An array of values for that facet type
789
+ */
790
+ prepareFacetForFetch(facetName, facetValues) {
791
+ let [normalizedName, normalizedValues] = [facetName, facetValues];
792
+ // The full "search engine" name of the lending field is "lending___status"
793
+ if (facetName === 'lending') {
794
+ normalizedName = 'lending___status';
795
+ }
796
+ // Language codes like "en-US|en-GB|en" need to be broken apart into individual values
797
+ if (facetName === 'language') {
798
+ normalizedValues = {};
799
+ for (const [facetValue, facetData] of Object.entries(facetValues)) {
800
+ const languages = this.languageCodeHandler.getCodeArrayFromCodeString(facetValue);
801
+ for (const lang of languages) {
802
+ normalizedValues[lang] = { ...facetData };
803
+ }
804
+ }
805
+ }
806
+ return {
807
+ name: normalizedName,
808
+ values: normalizedValues,
809
+ };
810
+ }
811
+ /**
812
+ * Takes an array of facet clauses, and combines them into a
813
+ * full AND-joined facet query string. Empty clauses are ignored.
814
+ */
815
+ joinFacetClauses(facetClauses) {
816
+ const nonEmptyFacetClauses = facetClauses.filter(clause => clause.length > 0);
817
+ return nonEmptyFacetClauses.length > 0
818
+ ? `(${nonEmptyFacetClauses.join(' AND ')})`
819
+ : undefined;
820
+ }
821
+ facetsChanged(e) {
822
+ this.selectedFacets = e.detail;
823
+ }
824
+ facetClickHandler(name, facetSelected, negative) {
825
+ var _a, _b;
826
+ if (negative) {
827
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
828
+ category: this.searchContext,
829
+ action: facetSelected
830
+ ? analyticsActions.facetNegativeSelected
831
+ : analyticsActions.facetNegativeDeselected,
832
+ label: name,
833
+ });
834
+ }
835
+ else {
836
+ (_b = this.analyticsHandler) === null || _b === void 0 ? void 0 : _b.sendEvent({
837
+ category: this.searchContext,
838
+ action: facetSelected
839
+ ? analyticsActions.facetSelected
840
+ : analyticsActions.facetDeselected,
841
+ label: name,
842
+ });
843
+ }
844
+ }
845
+ async fetchFacets() {
846
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
847
+ if (!this.filteredQuery)
848
+ return;
849
+ const params = {
850
+ query: this.filteredQuery,
851
+ rows: 0,
852
+ filters: this.filterMap,
853
+ // Fetch a few extra buckets beyond the 6 we show, in case some get suppressed
854
+ aggregationsSize: 10,
855
+ // Note: we don't need an aggregations param to fetch the default aggregations from the PPS.
856
+ // The default aggregations for the search_results page type should be what we need here.
857
+ };
858
+ this.facetsLoading = true;
859
+ this.previousSearchType = this.searchType;
860
+ const results = await ((_a = this.searchService) === null || _a === void 0 ? void 0 : _a.search(params, this.searchType));
861
+ this.facetsLoading = false;
862
+ this.aggregations = (_b = results === null || results === void 0 ? void 0 : results.success) === null || _b === void 0 ? void 0 : _b.response.aggregations;
863
+ this.fullYearsHistogramAggregation =
864
+ (_f = (_e = (_d = (_c = results === null || results === void 0 ? void 0 : results.success) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.aggregations) === null || _e === void 0 ? void 0 : _e.year_histogram) !== null && _f !== void 0 ? _f : (_j = (_h = (_g = results === null || results === void 0 ? void 0 : results.success) === null || _g === void 0 ? void 0 : _g.response) === null || _h === void 0 ? void 0 : _h.aggregations) === null || _j === void 0 ? void 0 : _j['year-histogram']; // Temp fix until PPS FTS key is fixed to use underscore
865
+ }
866
+ scrollToPage(pageNumber) {
867
+ return new Promise(resolve => {
868
+ const cellIndexToScrollTo = this.pageSize * (pageNumber - 1);
869
+ // without this setTimeout, Safari just pauses until the `fetchPage` is complete
870
+ // then scrolls to the cell
871
+ setTimeout(() => {
872
+ var _a;
873
+ this.isScrollingToCell = true;
874
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.scrollToCell(cellIndexToScrollTo, true);
875
+ // This timeout is to give the scroll animation time to finish
876
+ // then updating the infinite scroller once we're done scrolling
877
+ // There's no scroll animation completion callback so we're
878
+ // giving it 0.5s to finish.
879
+ setTimeout(() => {
880
+ var _a;
881
+ this.isScrollingToCell = false;
882
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
883
+ resolve();
884
+ }, 500);
885
+ }, 0);
886
+ });
887
+ }
888
+ /**
889
+ * The query key is a string that uniquely identifies the current search.
890
+ * It consists of:
891
+ * - The current base query
892
+ * - The current search type
893
+ * - Any currently-applied facets
894
+ * - Any currently-applied date range
895
+ * - Any currently-applied prefix filters
896
+ * - The current sort options
897
+ *
898
+ * This lets us keep track of queries so we don't persist data that's
899
+ * no longer relevant.
900
+ */
901
+ get pageFetchQueryKey() {
902
+ var _a, _b;
903
+ return `${this.fullQuery}-${this.searchType}-${(_a = this.sortParam) === null || _a === void 0 ? void 0 : _a.field}-${(_b = this.sortParam) === null || _b === void 0 ? void 0 : _b.direction}`;
904
+ }
905
+ async fetchPage(pageNumber) {
906
+ var _a, _b, _c, _d, _e;
907
+ if (!this.filteredQuery)
908
+ return;
909
+ // if we already have data, don't fetch again
910
+ if (this.dataSource[pageNumber])
911
+ return;
912
+ if (this.endOfDataReached)
913
+ return;
914
+ // if a fetch is already in progress for this query and page, don't fetch again
915
+ const { pageFetchQueryKey } = this;
916
+ const pageFetches = (_a = this.pageFetchesInProgress[pageFetchQueryKey]) !== null && _a !== void 0 ? _a : new Set();
917
+ if (pageFetches.has(pageNumber))
918
+ return;
919
+ pageFetches.add(pageNumber);
920
+ this.pageFetchesInProgress[pageFetchQueryKey] = pageFetches;
921
+ const sortParams = this.sortParam ? [this.sortParam] : [];
922
+ const params = {
923
+ query: this.filteredQuery,
924
+ page: pageNumber,
925
+ rows: this.pageSize,
926
+ sort: sortParams,
927
+ filters: this.filterMap,
928
+ aggregations: { omit: true },
929
+ };
930
+ const searchResponse = await ((_b = this.searchService) === null || _b === void 0 ? void 0 : _b.search(params, this.searchType));
931
+ const success = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.success;
932
+ if (!success)
933
+ return;
934
+ this.totalResults = success.response.totalResults;
935
+ // this is checking to see if the query has changed since the data was fetched
936
+ // if so, we just want to discard the data since there should be a new query
937
+ // right behind it
938
+ const searchQuery = success.request.clientParameters.user_query;
939
+ const searchSort = success.request.clientParameters.sort;
940
+ let sortChanged = false;
941
+ if (!searchSort || searchSort.length === 0) {
942
+ // if we went from no sort to sort, the sort has changed
943
+ if (this.sortParam) {
944
+ sortChanged = true;
945
+ }
946
+ }
947
+ else {
948
+ // check if the sort has changed
949
+ for (const sortType of searchSort) {
950
+ const [field, direction] = sortType.split(':');
951
+ if (field !== ((_c = this.sortParam) === null || _c === void 0 ? void 0 : _c.field) ||
952
+ direction !== ((_d = this.sortParam) === null || _d === void 0 ? void 0 : _d.direction)) {
953
+ sortChanged = true;
954
+ break;
955
+ }
956
+ }
957
+ }
958
+ const queryChangedSinceFetch = searchQuery !== this.filteredQuery || sortChanged;
959
+ if (queryChangedSinceFetch)
960
+ return;
961
+ const { results } = success.response;
962
+ if (results && results.length > 0) {
963
+ this.preloadCollectionNames(results);
964
+ this.updateDataSource(pageNumber, results);
965
+ }
966
+ // When we reach the end of the data, we can set the infinite scroller's
967
+ // item count to the real total number of results (rather than the
968
+ // temporary estimates based on pages rendered so far).
969
+ if (results.length < this.pageSize) {
970
+ this.endOfDataReached = true;
971
+ if (this.infiniteScroller) {
972
+ this.infiniteScroller.itemCount = this.totalResults;
973
+ }
974
+ }
975
+ (_e = this.pageFetchesInProgress[pageFetchQueryKey]) === null || _e === void 0 ? void 0 : _e.delete(pageNumber);
976
+ this.searchResultsLoading = false;
977
+ }
978
+ preloadCollectionNames(results) {
979
+ var _a;
980
+ const collectionIds = results
981
+ .map(result => { var _a; return (_a = result.collection) === null || _a === void 0 ? void 0 : _a.values; })
982
+ .flat();
983
+ const collectionIdsArray = Array.from(new Set(collectionIds));
984
+ (_a = this.collectionNameCache) === null || _a === void 0 ? void 0 : _a.preloadIdentifiers(collectionIdsArray);
985
+ }
986
+ /**
987
+ * This is useful for determining whether we need to reload the scroller.
988
+ *
989
+ * When the fetch completes, we need to reload the scroller if the cells for that
990
+ * page are visible, but if the page is not currenlty visible, we don't need to reload
991
+ */
992
+ get currentVisiblePageNumbers() {
993
+ var _a, _b;
994
+ const visibleCells = (_b = (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.getVisibleCellIndices()) !== null && _b !== void 0 ? _b : [];
995
+ const visiblePages = new Set();
996
+ visibleCells.forEach(cellIndex => {
997
+ const visiblePage = Math.floor(cellIndex / this.pageSize) + 1;
998
+ visiblePages.add(visiblePage);
999
+ });
1000
+ return Array.from(visiblePages);
1001
+ }
1002
+ /**
1003
+ * Update the datasource from the fetch response
1004
+ *
1005
+ * @param pageNumber
1006
+ * @param results
1007
+ */
1008
+ updateDataSource(pageNumber, results) {
1009
+ var _a;
1010
+ // copy our existing datasource so when we set it below, it gets set
1011
+ // instead of modifying the existing dataSource since object changes
1012
+ // don't trigger a re-render
1013
+ const datasource = { ...this.dataSource };
1014
+ const tiles = [];
1015
+ results === null || results === void 0 ? void 0 : results.forEach(result => {
1016
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
1017
+ if (!result.identifier)
1018
+ return;
1019
+ let loginRequired = false;
1020
+ let contentWarning = false;
1021
+ // Check if item and item in "modifying" collection, setting above flags
1022
+ if (((_a = result.collection) === null || _a === void 0 ? void 0 : _a.values.length) &&
1023
+ ((_b = result.mediatype) === null || _b === void 0 ? void 0 : _b.value) !== 'collection') {
1024
+ for (const collection of (_d = (_c = result.collection) === null || _c === void 0 ? void 0 : _c.values) !== null && _d !== void 0 ? _d : []) {
1025
+ if (collection === 'loggedin') {
1026
+ loginRequired = true;
1027
+ if (contentWarning)
1028
+ break;
1029
+ }
1030
+ if (collection === 'no-preview') {
1031
+ contentWarning = true;
1032
+ if (loginRequired)
1033
+ break;
1034
+ }
1035
+ }
1036
+ }
1037
+ tiles.push({
1038
+ averageRating: (_e = result.avg_rating) === null || _e === void 0 ? void 0 : _e.value,
1039
+ collections: (_g = (_f = result.collection) === null || _f === void 0 ? void 0 : _f.values) !== null && _g !== void 0 ? _g : [],
1040
+ collectionFilesCount: (_j = (_h = result.collection_files_count) === null || _h === void 0 ? void 0 : _h.value) !== null && _j !== void 0 ? _j : 0,
1041
+ collectionSize: (_l = (_k = result.collection_size) === null || _k === void 0 ? void 0 : _k.value) !== null && _l !== void 0 ? _l : 0,
1042
+ commentCount: (_o = (_m = result.num_reviews) === null || _m === void 0 ? void 0 : _m.value) !== null && _o !== void 0 ? _o : 0,
1043
+ creator: (_p = result.creator) === null || _p === void 0 ? void 0 : _p.value,
1044
+ creators: (_r = (_q = result.creator) === null || _q === void 0 ? void 0 : _q.values) !== null && _r !== void 0 ? _r : [],
1045
+ dateAdded: (_s = result.addeddate) === null || _s === void 0 ? void 0 : _s.value,
1046
+ dateArchived: (_t = result.publicdate) === null || _t === void 0 ? void 0 : _t.value,
1047
+ datePublished: (_u = result.date) === null || _u === void 0 ? void 0 : _u.value,
1048
+ dateReviewed: (_v = result.reviewdate) === null || _v === void 0 ? void 0 : _v.value,
1049
+ description: (_w = result.description) === null || _w === void 0 ? void 0 : _w.values.join('\n'),
1050
+ favCount: (_y = (_x = result.num_favorites) === null || _x === void 0 ? void 0 : _x.value) !== null && _y !== void 0 ? _y : 0,
1051
+ identifier: result.identifier,
1052
+ issue: (_z = result.issue) === null || _z === void 0 ? void 0 : _z.value,
1053
+ itemCount: (_1 = (_0 = result.item_count) === null || _0 === void 0 ? void 0 : _0.value) !== null && _1 !== void 0 ? _1 : 0,
1054
+ mediatype: (_3 = (_2 = result.mediatype) === null || _2 === void 0 ? void 0 : _2.value) !== null && _3 !== void 0 ? _3 : 'data',
1055
+ snippets: (_5 = (_4 = result.highlight) === null || _4 === void 0 ? void 0 : _4.values) !== null && _5 !== void 0 ? _5 : [],
1056
+ source: (_6 = result.source) === null || _6 === void 0 ? void 0 : _6.value,
1057
+ subjects: (_8 = (_7 = result.subject) === null || _7 === void 0 ? void 0 : _7.values) !== null && _8 !== void 0 ? _8 : [],
1058
+ title: this.etreeTitle((_9 = result.title) === null || _9 === void 0 ? void 0 : _9.value, (_10 = result.mediatype) === null || _10 === void 0 ? void 0 : _10.value, (_11 = result.collection) === null || _11 === void 0 ? void 0 : _11.values),
1059
+ volume: (_12 = result.volume) === null || _12 === void 0 ? void 0 : _12.value,
1060
+ viewCount: (_14 = (_13 = result.downloads) === null || _13 === void 0 ? void 0 : _13.value) !== null && _14 !== void 0 ? _14 : 0,
1061
+ weeklyViewCount: (_15 = result.week) === null || _15 === void 0 ? void 0 : _15.value,
1062
+ loginRequired,
1063
+ contentWarning,
1064
+ });
1065
+ });
1066
+ datasource[pageNumber] = tiles;
1067
+ this.dataSource = datasource;
1068
+ const visiblePages = this.currentVisiblePageNumbers;
1069
+ const needsReload = visiblePages.includes(pageNumber);
1070
+ if (needsReload) {
1071
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
1072
+ }
1073
+ }
1074
+ /** Fetches the aggregation buckets for the given prefix filter type. */
1075
+ async fetchPrefixFilterBuckets(filterType) {
1076
+ var _a, _b, _c, _d, _e, _f;
1077
+ if (!this.fullQueryWithoutAlphaFilters)
1078
+ return [];
1079
+ const filterAggregationKey = prefixFilterAggregationKeys[filterType];
1080
+ const params = {
1081
+ query: this.fullQueryWithoutAlphaFilters,
1082
+ rows: 0,
1083
+ // Only fetch the firstTitle or firstCreator aggregation
1084
+ aggregations: { simpleParams: [filterAggregationKey] },
1085
+ // Fetch all 26 letter buckets
1086
+ aggregationsSize: 26,
1087
+ };
1088
+ const searchResponse = await ((_a = this.searchService) === null || _a === void 0 ? void 0 : _a.search(params, this.searchType));
1089
+ return ((_f = (_e = (_d = (_c = (_b = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.success) === null || _b === void 0 ? void 0 : _b.response) === null || _c === void 0 ? void 0 : _c.aggregations) === null || _d === void 0 ? void 0 : _d[filterAggregationKey]) === null || _e === void 0 ? void 0 : _e.buckets) !== null && _f !== void 0 ? _f : []);
1090
+ }
1091
+ /** Fetches and caches the prefix filter counts for the given filter type. */
1092
+ async updatePrefixFilterCounts(filterType) {
1093
+ const buckets = await this.fetchPrefixFilterBuckets(filterType);
1094
+ // Unpack the aggregation buckets into a simple map like { 'A': 50, 'B': 25, ... }
1095
+ this.prefixFilterCountMap = { ...this.prefixFilterCountMap }; // Clone the object to trigger an update
1096
+ this.prefixFilterCountMap[filterType] = buckets.reduce((acc, bucket) => {
1097
+ acc[bucket.key.toUpperCase()] = bucket.doc_count;
1098
+ return acc;
1099
+ }, {});
1100
+ }
1101
+ /**
1102
+ * Fetches and caches the prefix filter counts for the current sort type,
1103
+ * provided it is one that permits prefix filtering. (If not, this does nothing).
1104
+ */
1105
+ async updatePrefixFiltersForCurrentSort() {
1106
+ if (['title', 'creator'].includes(this.selectedSort)) {
1107
+ const filterType = this.selectedSort;
1108
+ if (!this.prefixFilterCountMap[filterType]) {
1109
+ this.updatePrefixFilterCounts(filterType);
1110
+ }
1111
+ }
1112
+ }
1113
+ /**
1114
+ * Clears the cached letter counts for both title and creator, and
1115
+ * fetches a new set of counts for whichever of them is the currently
1116
+ * selected sort option (which may be neither).
1117
+ *
1118
+ * Call this whenever the counts are invalidated (e.g., by a query change).
1119
+ */
1120
+ refreshLetterCounts() {
1121
+ this.prefixFilterCountMap = {};
1122
+ this.updatePrefixFiltersForCurrentSort();
1123
+ }
1124
+ /*
1125
+ * Convert etree titles
1126
+ * "[Creator] Live at [Place] on [Date]" => "[Date]: [Place]"
1127
+ *
1128
+ * Todo: Check collection(s) for etree, need to get as array.
1129
+ * Current search-service only returns first collection as string.
1130
+ */
1131
+ etreeTitle(title, mediatype, collections) {
1132
+ if (mediatype === 'etree' || (collections === null || collections === void 0 ? void 0 : collections.includes('etree'))) {
1133
+ const regex = /^(.*) Live at (.*) on (\d\d\d\d-\d\d-\d\d)$/;
1134
+ const newTitle = title === null || title === void 0 ? void 0 : title.replace(regex, '$3: $2');
1135
+ if (newTitle) {
1136
+ return `${newTitle}`;
1137
+ }
1138
+ }
1139
+ return title !== null && title !== void 0 ? title : '';
1140
+ }
1141
+ /**
1142
+ * Callback when a result is selected
1143
+ */
1144
+ resultSelected(event) {
1145
+ var _a, _b;
1146
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
1147
+ category: this.searchContext,
1148
+ action: analyticsActions.resultSelected,
1149
+ label: event.detail.mediatype,
1150
+ });
1151
+ (_b = this.analyticsHandler) === null || _b === void 0 ? void 0 : _b.sendEvent({
1152
+ category: this.searchContext,
1153
+ action: analyticsActions.resultSelected,
1154
+ label: `page-${this.currentPage}`,
1155
+ });
1156
+ }
1157
+ cellForIndex(index) {
1158
+ const model = this.tileModelAtCellIndex(index);
1159
+ if (!model)
1160
+ return undefined;
1161
1161
  return html `
1162
1162
  <tile-dispatcher
1163
1163
  .baseNavigationUrl=${this.baseNavigationUrl}
@@ -1173,19 +1173,19 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
1173
1173
  @resultSelected=${(e) => this.resultSelected(e)}
1174
1174
  >
1175
1175
  </tile-dispatcher>
1176
- `;
1177
- }
1178
- /**
1179
- * When the user scrolls near to the bottom of the page, fetch the next page
1180
- * increase the number of pages to render and start fetching data for the new page
1181
- */
1182
- scrollThresholdReached() {
1183
- if (!this.endOfDataReached) {
1184
- this.pagesToRender += 1;
1185
- this.fetchPage(this.pagesToRender);
1186
- }
1187
- }
1188
- };
1176
+ `;
1177
+ }
1178
+ /**
1179
+ * When the user scrolls near to the bottom of the page, fetch the next page
1180
+ * increase the number of pages to render and start fetching data for the new page
1181
+ */
1182
+ scrollThresholdReached() {
1183
+ if (!this.endOfDataReached) {
1184
+ this.pagesToRender += 1;
1185
+ this.fetchPage(this.pagesToRender);
1186
+ }
1187
+ }
1188
+ };
1189
1189
  CollectionBrowser.styles = css `
1190
1190
  :host {
1191
1191
  display: block;
@@ -1407,138 +1407,138 @@ CollectionBrowser.styles = css `
1407
1407
  infinite-scroller.hidden {
1408
1408
  display: none;
1409
1409
  }
1410
- `;
1411
- __decorate([
1412
- property({ type: String })
1413
- ], CollectionBrowser.prototype, "baseNavigationUrl", void 0);
1414
- __decorate([
1415
- property({ type: String })
1416
- ], CollectionBrowser.prototype, "baseImageUrl", void 0);
1417
- __decorate([
1418
- property({ type: Object })
1419
- ], CollectionBrowser.prototype, "searchService", void 0);
1420
- __decorate([
1421
- property({ type: String })
1422
- ], CollectionBrowser.prototype, "searchType", void 0);
1423
- __decorate([
1424
- property({ type: String })
1425
- ], CollectionBrowser.prototype, "baseQuery", void 0);
1426
- __decorate([
1427
- property({ type: String })
1428
- ], CollectionBrowser.prototype, "displayMode", void 0);
1429
- __decorate([
1430
- property({ type: Object })
1431
- ], CollectionBrowser.prototype, "sortParam", void 0);
1432
- __decorate([
1433
- property({ type: String })
1434
- ], CollectionBrowser.prototype, "selectedSort", void 0);
1435
- __decorate([
1436
- property({ type: String })
1437
- ], CollectionBrowser.prototype, "selectedTitleFilter", void 0);
1438
- __decorate([
1439
- property({ type: String })
1440
- ], CollectionBrowser.prototype, "selectedCreatorFilter", void 0);
1441
- __decorate([
1442
- property({ type: String })
1443
- ], CollectionBrowser.prototype, "sortDirection", void 0);
1444
- __decorate([
1445
- property({ type: Number })
1446
- ], CollectionBrowser.prototype, "pageSize", void 0);
1447
- __decorate([
1448
- property({ type: Object })
1449
- ], CollectionBrowser.prototype, "resizeObserver", void 0);
1450
- __decorate([
1451
- property({ type: String })
1452
- ], CollectionBrowser.prototype, "titleQuery", void 0);
1453
- __decorate([
1454
- property({ type: String })
1455
- ], CollectionBrowser.prototype, "creatorQuery", void 0);
1456
- __decorate([
1457
- property({ type: Number })
1458
- ], CollectionBrowser.prototype, "currentPage", void 0);
1459
- __decorate([
1460
- property({ type: String })
1461
- ], CollectionBrowser.prototype, "minSelectedDate", void 0);
1462
- __decorate([
1463
- property({ type: String })
1464
- ], CollectionBrowser.prototype, "maxSelectedDate", void 0);
1465
- __decorate([
1466
- property({ type: Object })
1467
- ], CollectionBrowser.prototype, "selectedFacets", void 0);
1468
- __decorate([
1469
- property({ type: Boolean })
1470
- ], CollectionBrowser.prototype, "showHistogramDatePicker", void 0);
1471
- __decorate([
1472
- property({ type: String, reflect: true })
1473
- ], CollectionBrowser.prototype, "searchContext", void 0);
1474
- __decorate([
1475
- property({ type: Object })
1476
- ], CollectionBrowser.prototype, "collectionNameCache", void 0);
1477
- __decorate([
1478
- property({ type: String })
1479
- ], CollectionBrowser.prototype, "pageContext", void 0);
1480
- __decorate([
1481
- property({ type: Object })
1482
- ], CollectionBrowser.prototype, "restorationStateHandler", void 0);
1483
- __decorate([
1484
- property({ type: Number })
1485
- ], CollectionBrowser.prototype, "mobileBreakpoint", void 0);
1486
- __decorate([
1487
- property({ type: Boolean })
1488
- ], CollectionBrowser.prototype, "loggedIn", void 0);
1489
- __decorate([
1490
- property({ type: Object })
1491
- ], CollectionBrowser.prototype, "modalManager", void 0);
1492
- __decorate([
1493
- property({ type: Boolean })
1494
- ], CollectionBrowser.prototype, "isManageView", void 0);
1495
- __decorate([
1496
- state()
1497
- ], CollectionBrowser.prototype, "pagesToRender", void 0);
1498
- __decorate([
1499
- state()
1500
- ], CollectionBrowser.prototype, "searchResultsLoading", void 0);
1501
- __decorate([
1502
- state()
1503
- ], CollectionBrowser.prototype, "facetsLoading", void 0);
1504
- __decorate([
1505
- state()
1506
- ], CollectionBrowser.prototype, "fullYearAggregationLoading", void 0);
1507
- __decorate([
1508
- state()
1509
- ], CollectionBrowser.prototype, "aggregations", void 0);
1510
- __decorate([
1511
- state()
1512
- ], CollectionBrowser.prototype, "fullYearsHistogramAggregation", void 0);
1513
- __decorate([
1514
- state()
1515
- ], CollectionBrowser.prototype, "previousSearchType", void 0);
1516
- __decorate([
1517
- state()
1518
- ], CollectionBrowser.prototype, "totalResults", void 0);
1519
- __decorate([
1520
- state()
1521
- ], CollectionBrowser.prototype, "mobileView", void 0);
1522
- __decorate([
1523
- state()
1524
- ], CollectionBrowser.prototype, "mobileFacetsVisible", void 0);
1525
- __decorate([
1526
- state()
1527
- ], CollectionBrowser.prototype, "placeholderType", void 0);
1528
- __decorate([
1529
- state()
1530
- ], CollectionBrowser.prototype, "prefixFilterCountMap", void 0);
1531
- __decorate([
1532
- query('#content-container')
1533
- ], CollectionBrowser.prototype, "contentContainer", void 0);
1534
- __decorate([
1535
- property({ type: Object, attribute: false })
1536
- ], CollectionBrowser.prototype, "analyticsHandler", void 0);
1537
- __decorate([
1538
- query('infinite-scroller')
1539
- ], CollectionBrowser.prototype, "infiniteScroller", void 0);
1540
- CollectionBrowser = __decorate([
1541
- customElement('collection-browser')
1542
- ], CollectionBrowser);
1543
- export { CollectionBrowser };
1410
+ `;
1411
+ __decorate([
1412
+ property({ type: String })
1413
+ ], CollectionBrowser.prototype, "baseNavigationUrl", void 0);
1414
+ __decorate([
1415
+ property({ type: String })
1416
+ ], CollectionBrowser.prototype, "baseImageUrl", void 0);
1417
+ __decorate([
1418
+ property({ type: Object })
1419
+ ], CollectionBrowser.prototype, "searchService", void 0);
1420
+ __decorate([
1421
+ property({ type: String })
1422
+ ], CollectionBrowser.prototype, "searchType", void 0);
1423
+ __decorate([
1424
+ property({ type: String })
1425
+ ], CollectionBrowser.prototype, "baseQuery", void 0);
1426
+ __decorate([
1427
+ property({ type: String })
1428
+ ], CollectionBrowser.prototype, "displayMode", void 0);
1429
+ __decorate([
1430
+ property({ type: Object })
1431
+ ], CollectionBrowser.prototype, "sortParam", void 0);
1432
+ __decorate([
1433
+ property({ type: String })
1434
+ ], CollectionBrowser.prototype, "selectedSort", void 0);
1435
+ __decorate([
1436
+ property({ type: String })
1437
+ ], CollectionBrowser.prototype, "selectedTitleFilter", void 0);
1438
+ __decorate([
1439
+ property({ type: String })
1440
+ ], CollectionBrowser.prototype, "selectedCreatorFilter", void 0);
1441
+ __decorate([
1442
+ property({ type: String })
1443
+ ], CollectionBrowser.prototype, "sortDirection", void 0);
1444
+ __decorate([
1445
+ property({ type: Number })
1446
+ ], CollectionBrowser.prototype, "pageSize", void 0);
1447
+ __decorate([
1448
+ property({ type: Object })
1449
+ ], CollectionBrowser.prototype, "resizeObserver", void 0);
1450
+ __decorate([
1451
+ property({ type: String })
1452
+ ], CollectionBrowser.prototype, "titleQuery", void 0);
1453
+ __decorate([
1454
+ property({ type: String })
1455
+ ], CollectionBrowser.prototype, "creatorQuery", void 0);
1456
+ __decorate([
1457
+ property({ type: Number })
1458
+ ], CollectionBrowser.prototype, "currentPage", void 0);
1459
+ __decorate([
1460
+ property({ type: String })
1461
+ ], CollectionBrowser.prototype, "minSelectedDate", void 0);
1462
+ __decorate([
1463
+ property({ type: String })
1464
+ ], CollectionBrowser.prototype, "maxSelectedDate", void 0);
1465
+ __decorate([
1466
+ property({ type: Object })
1467
+ ], CollectionBrowser.prototype, "selectedFacets", void 0);
1468
+ __decorate([
1469
+ property({ type: Boolean })
1470
+ ], CollectionBrowser.prototype, "showHistogramDatePicker", void 0);
1471
+ __decorate([
1472
+ property({ type: String, reflect: true })
1473
+ ], CollectionBrowser.prototype, "searchContext", void 0);
1474
+ __decorate([
1475
+ property({ type: Object })
1476
+ ], CollectionBrowser.prototype, "collectionNameCache", void 0);
1477
+ __decorate([
1478
+ property({ type: String })
1479
+ ], CollectionBrowser.prototype, "pageContext", void 0);
1480
+ __decorate([
1481
+ property({ type: Object })
1482
+ ], CollectionBrowser.prototype, "restorationStateHandler", void 0);
1483
+ __decorate([
1484
+ property({ type: Number })
1485
+ ], CollectionBrowser.prototype, "mobileBreakpoint", void 0);
1486
+ __decorate([
1487
+ property({ type: Boolean })
1488
+ ], CollectionBrowser.prototype, "loggedIn", void 0);
1489
+ __decorate([
1490
+ property({ type: Object })
1491
+ ], CollectionBrowser.prototype, "modalManager", void 0);
1492
+ __decorate([
1493
+ property({ type: Boolean })
1494
+ ], CollectionBrowser.prototype, "isManageView", void 0);
1495
+ __decorate([
1496
+ state()
1497
+ ], CollectionBrowser.prototype, "pagesToRender", void 0);
1498
+ __decorate([
1499
+ state()
1500
+ ], CollectionBrowser.prototype, "searchResultsLoading", void 0);
1501
+ __decorate([
1502
+ state()
1503
+ ], CollectionBrowser.prototype, "facetsLoading", void 0);
1504
+ __decorate([
1505
+ state()
1506
+ ], CollectionBrowser.prototype, "fullYearAggregationLoading", void 0);
1507
+ __decorate([
1508
+ state()
1509
+ ], CollectionBrowser.prototype, "aggregations", void 0);
1510
+ __decorate([
1511
+ state()
1512
+ ], CollectionBrowser.prototype, "fullYearsHistogramAggregation", void 0);
1513
+ __decorate([
1514
+ state()
1515
+ ], CollectionBrowser.prototype, "previousSearchType", void 0);
1516
+ __decorate([
1517
+ state()
1518
+ ], CollectionBrowser.prototype, "totalResults", void 0);
1519
+ __decorate([
1520
+ state()
1521
+ ], CollectionBrowser.prototype, "mobileView", void 0);
1522
+ __decorate([
1523
+ state()
1524
+ ], CollectionBrowser.prototype, "mobileFacetsVisible", void 0);
1525
+ __decorate([
1526
+ state()
1527
+ ], CollectionBrowser.prototype, "placeholderType", void 0);
1528
+ __decorate([
1529
+ state()
1530
+ ], CollectionBrowser.prototype, "prefixFilterCountMap", void 0);
1531
+ __decorate([
1532
+ query('#content-container')
1533
+ ], CollectionBrowser.prototype, "contentContainer", void 0);
1534
+ __decorate([
1535
+ property({ type: Object, attribute: false })
1536
+ ], CollectionBrowser.prototype, "analyticsHandler", void 0);
1537
+ __decorate([
1538
+ query('infinite-scroller')
1539
+ ], CollectionBrowser.prototype, "infiniteScroller", void 0);
1540
+ CollectionBrowser = __decorate([
1541
+ customElement('collection-browser')
1542
+ ], CollectionBrowser);
1543
+ export { CollectionBrowser };
1544
1544
  //# sourceMappingURL=collection-browser.js.map