@internetarchive/collection-browser 2.4.1-e2e-test-2 → 2.5.1-alpha.0

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 (316) hide show
  1. package/.editorconfig +29 -29
  2. package/.husky/pre-commit +4 -4
  3. package/LICENSE +661 -661
  4. package/README.md +83 -83
  5. package/dist/index.d.ts +12 -12
  6. package/dist/index.js +12 -12
  7. package/dist/src/app-root.d.ts +91 -91
  8. package/dist/src/app-root.js +487 -487
  9. package/dist/src/assets/img/icons/arrow-left.d.ts +2 -2
  10. package/dist/src/assets/img/icons/arrow-left.js +2 -2
  11. package/dist/src/assets/img/icons/arrow-right.d.ts +2 -2
  12. package/dist/src/assets/img/icons/arrow-right.js +2 -2
  13. package/dist/src/assets/img/icons/chevron.d.ts +2 -2
  14. package/dist/src/assets/img/icons/chevron.js +2 -2
  15. package/dist/src/assets/img/icons/contract.d.ts +2 -2
  16. package/dist/src/assets/img/icons/contract.js +2 -2
  17. package/dist/src/assets/img/icons/empty-query.d.ts +2 -2
  18. package/dist/src/assets/img/icons/empty-query.js +2 -2
  19. package/dist/src/assets/img/icons/expand.d.ts +2 -2
  20. package/dist/src/assets/img/icons/expand.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/favorite-unfilled.d.ts +1 -1
  28. package/dist/src/assets/img/icons/favorite-unfilled.js +2 -2
  29. package/dist/src/assets/img/icons/login-required.d.ts +1 -1
  30. package/dist/src/assets/img/icons/login-required.js +2 -2
  31. package/dist/src/assets/img/icons/mediatype/account.d.ts +1 -1
  32. package/dist/src/assets/img/icons/mediatype/account.js +2 -2
  33. package/dist/src/assets/img/icons/mediatype/audio.d.ts +1 -1
  34. package/dist/src/assets/img/icons/mediatype/audio.js +2 -2
  35. package/dist/src/assets/img/icons/mediatype/collection.d.ts +1 -1
  36. package/dist/src/assets/img/icons/mediatype/collection.js +2 -2
  37. package/dist/src/assets/img/icons/mediatype/data.d.ts +1 -1
  38. package/dist/src/assets/img/icons/mediatype/data.js +2 -2
  39. package/dist/src/assets/img/icons/mediatype/etree.d.ts +1 -1
  40. package/dist/src/assets/img/icons/mediatype/etree.js +2 -2
  41. package/dist/src/assets/img/icons/mediatype/film.d.ts +1 -1
  42. package/dist/src/assets/img/icons/mediatype/film.js +2 -2
  43. package/dist/src/assets/img/icons/mediatype/images.d.ts +1 -1
  44. package/dist/src/assets/img/icons/mediatype/images.js +2 -2
  45. package/dist/src/assets/img/icons/mediatype/radio.d.ts +1 -1
  46. package/dist/src/assets/img/icons/mediatype/radio.js +2 -2
  47. package/dist/src/assets/img/icons/mediatype/search.d.ts +1 -1
  48. package/dist/src/assets/img/icons/mediatype/search.js +2 -2
  49. package/dist/src/assets/img/icons/mediatype/software.d.ts +1 -1
  50. package/dist/src/assets/img/icons/mediatype/software.js +2 -2
  51. package/dist/src/assets/img/icons/mediatype/texts.d.ts +1 -1
  52. package/dist/src/assets/img/icons/mediatype/texts.js +2 -2
  53. package/dist/src/assets/img/icons/mediatype/tv.d.ts +1 -1
  54. package/dist/src/assets/img/icons/mediatype/tv.js +2 -2
  55. package/dist/src/assets/img/icons/mediatype/video.d.ts +1 -1
  56. package/dist/src/assets/img/icons/mediatype/video.js +2 -2
  57. package/dist/src/assets/img/icons/mediatype/web.d.ts +1 -1
  58. package/dist/src/assets/img/icons/mediatype/web.js +2 -2
  59. package/dist/src/assets/img/icons/null-result.d.ts +2 -2
  60. package/dist/src/assets/img/icons/null-result.js +2 -2
  61. package/dist/src/assets/img/icons/restricted.d.ts +1 -1
  62. package/dist/src/assets/img/icons/restricted.js +2 -2
  63. package/dist/src/assets/img/icons/reviews.d.ts +1 -1
  64. package/dist/src/assets/img/icons/reviews.js +2 -2
  65. package/dist/src/assets/img/icons/upload.d.ts +1 -1
  66. package/dist/src/assets/img/icons/upload.js +2 -2
  67. package/dist/src/assets/img/icons/views.d.ts +1 -1
  68. package/dist/src/assets/img/icons/views.js +2 -2
  69. package/dist/src/circular-activity-indicator.d.ts +5 -5
  70. package/dist/src/circular-activity-indicator.js +17 -17
  71. package/dist/src/collection-browser.d.ts +564 -466
  72. package/dist/src/collection-browser.js +1568 -1479
  73. package/dist/src/collection-browser.js.map +1 -1
  74. package/dist/src/collection-facets/facet-row.d.ts +30 -30
  75. package/dist/src/collection-facets/facet-row.js +117 -116
  76. package/dist/src/collection-facets/facet-row.js.map +1 -1
  77. package/dist/src/collection-facets/facet-tombstone-row.d.ts +5 -5
  78. package/dist/src/collection-facets/facet-tombstone-row.js +15 -15
  79. package/dist/src/collection-facets/facets-template.d.ts +14 -17
  80. package/dist/src/collection-facets/facets-template.js +47 -144
  81. package/dist/src/collection-facets/facets-template.js.map +1 -1
  82. package/dist/src/collection-facets/more-facets-content.d.ts +106 -74
  83. package/dist/src/collection-facets/more-facets-content.js +425 -377
  84. package/dist/src/collection-facets/more-facets-content.js.map +1 -1
  85. package/dist/src/collection-facets/more-facets-pagination.d.ts +36 -36
  86. package/dist/src/collection-facets/more-facets-pagination.js +196 -196
  87. package/dist/src/collection-facets/toggle-switch.d.ts +41 -41
  88. package/dist/src/collection-facets/toggle-switch.js +94 -94
  89. package/dist/src/collection-facets.d.ts +103 -103
  90. package/dist/src/collection-facets.js +514 -514
  91. package/dist/src/collection-facets.js.map +1 -1
  92. package/dist/src/data-source/collection-browser-data-source-interface.d.ts +241 -241
  93. package/dist/src/data-source/collection-browser-data-source-interface.js +1 -1
  94. package/dist/src/data-source/collection-browser-data-source.d.ts +378 -378
  95. package/dist/src/data-source/collection-browser-data-source.js +985 -985
  96. package/dist/src/data-source/collection-browser-query-state.d.ts +43 -43
  97. package/dist/src/data-source/collection-browser-query-state.js +1 -1
  98. package/dist/src/data-source/models.d.ts +28 -28
  99. package/dist/src/data-source/models.js +8 -8
  100. package/dist/src/empty-placeholder.d.ts +23 -23
  101. package/dist/src/empty-placeholder.js +74 -74
  102. package/dist/src/expanded-date-picker.d.ts +43 -43
  103. package/dist/src/expanded-date-picker.js +109 -109
  104. package/dist/src/language-code-handler/language-code-handler.d.ts +37 -37
  105. package/dist/src/language-code-handler/language-code-handler.js +26 -26
  106. package/dist/src/language-code-handler/language-code-mapping.d.ts +1 -1
  107. package/dist/src/language-code-handler/language-code-mapping.js +562 -562
  108. package/dist/src/manage/manage-bar.d.ts +30 -30
  109. package/dist/src/manage/manage-bar.js +61 -61
  110. package/dist/src/mediatype/mediatype-config.d.ts +3 -3
  111. package/dist/src/mediatype/mediatype-config.js +91 -91
  112. package/dist/src/models.d.ts +209 -209
  113. package/dist/src/models.js +381 -381
  114. package/dist/src/restoration-state-handler.d.ts +70 -70
  115. package/dist/src/restoration-state-handler.js +357 -357
  116. package/dist/src/sort-filter-bar/alpha-bar-tooltip.d.ts +6 -6
  117. package/dist/src/sort-filter-bar/alpha-bar-tooltip.js +24 -24
  118. package/dist/src/sort-filter-bar/alpha-bar.d.ts +21 -21
  119. package/dist/src/sort-filter-bar/alpha-bar.js +128 -128
  120. package/dist/src/sort-filter-bar/img/compact.d.ts +1 -1
  121. package/dist/src/sort-filter-bar/img/compact.js +2 -2
  122. package/dist/src/sort-filter-bar/img/list.d.ts +1 -1
  123. package/dist/src/sort-filter-bar/img/list.js +2 -2
  124. package/dist/src/sort-filter-bar/img/sort-toggle-disabled.d.ts +1 -1
  125. package/dist/src/sort-filter-bar/img/sort-toggle-disabled.js +2 -2
  126. package/dist/src/sort-filter-bar/img/sort-toggle-down.d.ts +1 -1
  127. package/dist/src/sort-filter-bar/img/sort-toggle-down.js +2 -2
  128. package/dist/src/sort-filter-bar/img/sort-toggle-up.d.ts +1 -1
  129. package/dist/src/sort-filter-bar/img/sort-toggle-up.js +2 -2
  130. package/dist/src/sort-filter-bar/img/sort-triangle.d.ts +1 -1
  131. package/dist/src/sort-filter-bar/img/sort-triangle.js +2 -2
  132. package/dist/src/sort-filter-bar/img/tile.d.ts +1 -1
  133. package/dist/src/sort-filter-bar/img/tile.js +2 -2
  134. package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +222 -222
  135. package/dist/src/sort-filter-bar/sort-filter-bar.js +696 -696
  136. package/dist/src/styles/ia-button.d.ts +2 -2
  137. package/dist/src/styles/ia-button.js +16 -16
  138. package/dist/src/styles/item-image-styles.d.ts +8 -8
  139. package/dist/src/styles/item-image-styles.js +9 -9
  140. package/dist/src/styles/sr-only.d.ts +1 -1
  141. package/dist/src/styles/sr-only.js +2 -2
  142. package/dist/src/tiles/base-tile-component.d.ts +19 -19
  143. package/dist/src/tiles/base-tile-component.js +63 -63
  144. package/dist/src/tiles/collection-browser-loading-tile.d.ts +5 -5
  145. package/dist/src/tiles/collection-browser-loading-tile.js +15 -15
  146. package/dist/src/tiles/grid/account-tile.d.ts +18 -18
  147. package/dist/src/tiles/grid/account-tile.js +72 -72
  148. package/dist/src/tiles/grid/collection-tile.d.ts +15 -15
  149. package/dist/src/tiles/grid/collection-tile.js +80 -80
  150. package/dist/src/tiles/grid/item-tile.d.ts +30 -30
  151. package/dist/src/tiles/grid/item-tile.js +149 -149
  152. package/dist/src/tiles/grid/search-tile.d.ts +10 -10
  153. package/dist/src/tiles/grid/search-tile.js +51 -51
  154. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.d.ts +1 -1
  155. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +8 -8
  156. package/dist/src/tiles/grid/tile-stats.d.ts +11 -11
  157. package/dist/src/tiles/grid/tile-stats.js +53 -53
  158. package/dist/src/tiles/hover/hover-pane-controller.d.ts +219 -219
  159. package/dist/src/tiles/hover/hover-pane-controller.js +352 -352
  160. package/dist/src/tiles/hover/tile-hover-pane.d.ts +18 -18
  161. package/dist/src/tiles/hover/tile-hover-pane.js +69 -69
  162. package/dist/src/tiles/image-block.d.ts +17 -17
  163. package/dist/src/tiles/image-block.js +73 -73
  164. package/dist/src/tiles/item-image.d.ts +39 -39
  165. package/dist/src/tiles/item-image.js +154 -154
  166. package/dist/src/tiles/list/tile-list-compact-header.d.ts +6 -6
  167. package/dist/src/tiles/list/tile-list-compact-header.js +38 -38
  168. package/dist/src/tiles/list/tile-list-compact.d.ts +15 -15
  169. package/dist/src/tiles/list/tile-list-compact.js +114 -114
  170. package/dist/src/tiles/list/tile-list.d.ts +50 -50
  171. package/dist/src/tiles/list/tile-list.js +315 -315
  172. package/dist/src/tiles/mediatype-icon.d.ts +9 -9
  173. package/dist/src/tiles/mediatype-icon.js +47 -47
  174. package/dist/src/tiles/overlay/icon-overlay.d.ts +10 -10
  175. package/dist/src/tiles/overlay/icon-overlay.js +40 -40
  176. package/dist/src/tiles/overlay/icon-text-overlay.d.ts +9 -9
  177. package/dist/src/tiles/overlay/icon-text-overlay.js +38 -38
  178. package/dist/src/tiles/overlay/text-overlay.d.ts +10 -10
  179. package/dist/src/tiles/overlay/text-overlay.js +42 -42
  180. package/dist/src/tiles/review-block.d.ts +12 -12
  181. package/dist/src/tiles/review-block.js +56 -56
  182. package/dist/src/tiles/text-snippet-block.d.ts +27 -27
  183. package/dist/src/tiles/text-snippet-block.js +73 -73
  184. package/dist/src/tiles/tile-dispatcher.d.ts +64 -64
  185. package/dist/src/tiles/tile-dispatcher.js +229 -229
  186. package/dist/src/tiles/tile-display-value-provider.d.ts +47 -47
  187. package/dist/src/tiles/tile-display-value-provider.js +94 -94
  188. package/dist/src/utils/analytics-events.d.ts +28 -28
  189. package/dist/src/utils/analytics-events.js +30 -30
  190. package/dist/src/utils/array-equals.d.ts +4 -4
  191. package/dist/src/utils/array-equals.js +10 -10
  192. package/dist/src/utils/collapse-repeated-quotes.d.ts +11 -11
  193. package/dist/src/utils/collapse-repeated-quotes.js +13 -13
  194. package/dist/src/utils/facet-utils.d.ts +83 -0
  195. package/dist/src/utils/facet-utils.js +147 -0
  196. package/dist/src/utils/facet-utils.js.map +1 -0
  197. package/dist/src/utils/format-count.d.ts +7 -7
  198. package/dist/src/utils/format-count.js +76 -76
  199. package/dist/src/utils/format-date.d.ts +2 -2
  200. package/dist/src/utils/format-date.js +25 -25
  201. package/dist/src/utils/format-unit-size.d.ts +2 -2
  202. package/dist/src/utils/format-unit-size.js +33 -33
  203. package/dist/src/utils/local-date-from-utc.d.ts +9 -9
  204. package/dist/src/utils/local-date-from-utc.js +15 -15
  205. package/dist/src/utils/log.d.ts +7 -7
  206. package/dist/src/utils/log.js +15 -15
  207. package/dist/src/utils/resolve-mediatype.d.ts +8 -8
  208. package/dist/src/utils/resolve-mediatype.js +23 -23
  209. package/dist/src/utils/sha1.d.ts +2 -2
  210. package/dist/src/utils/sha1.js +8 -8
  211. package/dist/test/collection-browser.test.d.ts +1 -1
  212. package/dist/test/collection-browser.test.js +1294 -1293
  213. package/dist/test/collection-browser.test.js.map +1 -1
  214. package/dist/test/collection-facets/facet-row.test.d.ts +1 -1
  215. package/dist/test/collection-facets/facet-row.test.js +227 -203
  216. package/dist/test/collection-facets/facet-row.test.js.map +1 -1
  217. package/dist/test/collection-facets/facets-template.test.d.ts +1 -1
  218. package/dist/test/collection-facets/facets-template.test.js +91 -114
  219. package/dist/test/collection-facets/facets-template.test.js.map +1 -1
  220. package/dist/test/collection-facets/more-facets-content.test.d.ts +1 -1
  221. package/dist/test/collection-facets/more-facets-content.test.js +150 -141
  222. package/dist/test/collection-facets/more-facets-content.test.js.map +1 -1
  223. package/dist/test/collection-facets/more-facets-pagination.test.d.ts +1 -1
  224. package/dist/test/collection-facets/more-facets-pagination.test.js +117 -117
  225. package/dist/test/collection-facets/toggle-switch.test.d.ts +1 -1
  226. package/dist/test/collection-facets/toggle-switch.test.js +73 -73
  227. package/dist/test/collection-facets.test.d.ts +2 -2
  228. package/dist/test/collection-facets.test.js +652 -652
  229. package/dist/test/data-source/collection-browser-data-source.test.d.ts +1 -1
  230. package/dist/test/data-source/collection-browser-data-source.test.js +89 -89
  231. package/dist/test/empty-placeholder.test.d.ts +1 -1
  232. package/dist/test/empty-placeholder.test.js +63 -63
  233. package/dist/test/expanded-date-picker.test.d.ts +1 -1
  234. package/dist/test/expanded-date-picker.test.js +95 -95
  235. package/dist/test/icon-overlay.test.d.ts +1 -1
  236. package/dist/test/icon-overlay.test.js +24 -24
  237. package/dist/test/image-block.test.d.ts +1 -1
  238. package/dist/test/image-block.test.js +48 -48
  239. package/dist/test/item-image.test.d.ts +1 -1
  240. package/dist/test/item-image.test.js +85 -85
  241. package/dist/test/manage/manage-bar.test.d.ts +1 -1
  242. package/dist/test/manage/manage-bar.test.js +81 -81
  243. package/dist/test/mediatype-config.test.d.ts +1 -1
  244. package/dist/test/mediatype-config.test.js +16 -16
  245. package/dist/test/mocks/mock-analytics-handler.d.ts +10 -10
  246. package/dist/test/mocks/mock-analytics-handler.js +15 -15
  247. package/dist/test/mocks/mock-search-responses.d.ts +25 -24
  248. package/dist/test/mocks/mock-search-responses.js +942 -860
  249. package/dist/test/mocks/mock-search-responses.js.map +1 -1
  250. package/dist/test/mocks/mock-search-service.d.ts +15 -15
  251. package/dist/test/mocks/mock-search-service.js +54 -53
  252. package/dist/test/mocks/mock-search-service.js.map +1 -1
  253. package/dist/test/restoration-state-handler.test.d.ts +1 -1
  254. package/dist/test/restoration-state-handler.test.js +270 -270
  255. package/dist/test/review-block.test.d.ts +1 -1
  256. package/dist/test/review-block.test.js +44 -44
  257. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.d.ts +1 -1
  258. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js +12 -12
  259. package/dist/test/sort-filter-bar/alpha-bar.test.d.ts +1 -1
  260. package/dist/test/sort-filter-bar/alpha-bar.test.js +73 -73
  261. package/dist/test/sort-filter-bar/sort-filter-bar.test.d.ts +1 -1
  262. package/dist/test/sort-filter-bar/sort-filter-bar.test.js +426 -426
  263. package/dist/test/text-overlay.test.d.ts +1 -1
  264. package/dist/test/text-overlay.test.js +48 -48
  265. package/dist/test/text-snippet-block.test.d.ts +1 -1
  266. package/dist/test/text-snippet-block.test.js +57 -57
  267. package/dist/test/tile-stats.test.d.ts +1 -1
  268. package/dist/test/tile-stats.test.js +81 -81
  269. package/dist/test/tiles/grid/account-tile.test.d.ts +1 -1
  270. package/dist/test/tiles/grid/account-tile.test.js +76 -76
  271. package/dist/test/tiles/grid/collection-tile.test.d.ts +1 -1
  272. package/dist/test/tiles/grid/collection-tile.test.js +73 -73
  273. package/dist/test/tiles/grid/item-tile.test.d.ts +1 -1
  274. package/dist/test/tiles/grid/item-tile.test.js +312 -312
  275. package/dist/test/tiles/grid/search-tile.test.d.ts +1 -1
  276. package/dist/test/tiles/grid/search-tile.test.js +51 -51
  277. package/dist/test/tiles/hover/hover-pane-controller.test.d.ts +1 -1
  278. package/dist/test/tiles/hover/hover-pane-controller.test.js +259 -259
  279. package/dist/test/tiles/hover/tile-hover-pane.test.d.ts +1 -1
  280. package/dist/test/tiles/hover/tile-hover-pane.test.js +56 -56
  281. package/dist/test/tiles/list/tile-list-compact.test.d.ts +1 -1
  282. package/dist/test/tiles/list/tile-list-compact.test.js +143 -143
  283. package/dist/test/tiles/list/tile-list.test.d.ts +1 -1
  284. package/dist/test/tiles/list/tile-list.test.js +297 -297
  285. package/dist/test/tiles/tile-dispatcher.test.d.ts +1 -1
  286. package/dist/test/tiles/tile-dispatcher.test.js +100 -100
  287. package/dist/test/tiles/tile-display-value-provider.test.d.ts +1 -1
  288. package/dist/test/tiles/tile-display-value-provider.test.js +141 -141
  289. package/dist/test/utils/array-equals.test.d.ts +1 -1
  290. package/dist/test/utils/array-equals.test.js +26 -26
  291. package/dist/test/utils/format-count.test.d.ts +1 -1
  292. package/dist/test/utils/format-count.test.js +23 -23
  293. package/dist/test/utils/format-date.test.d.ts +1 -1
  294. package/dist/test/utils/format-date.test.js +17 -17
  295. package/dist/test/utils/format-unit-size.test.d.ts +1 -1
  296. package/dist/test/utils/format-unit-size.test.js +17 -17
  297. package/dist/test/utils/local-date-from-utc.test.d.ts +1 -1
  298. package/dist/test/utils/local-date-from-utc.test.js +26 -26
  299. package/local.archive.org.cert +86 -86
  300. package/local.archive.org.key +27 -27
  301. package/package.json +1 -1
  302. package/renovate.json +6 -6
  303. package/src/collection-browser.ts +106 -19
  304. package/src/collection-facets/facet-row.ts +5 -4
  305. package/src/collection-facets/facets-template.ts +12 -114
  306. package/src/collection-facets/more-facets-content.ts +220 -144
  307. package/src/collection-facets.ts +24 -12
  308. package/src/utils/facet-utils.ts +182 -0
  309. package/test/collection-browser.test.ts +1 -0
  310. package/test/collection-facets/facet-row.test.ts +30 -6
  311. package/test/collection-facets/facets-template.test.ts +6 -32
  312. package/test/collection-facets/more-facets-content.test.ts +46 -35
  313. package/test/mocks/mock-search-responses.ts +86 -0
  314. package/test/mocks/mock-search-service.ts +2 -0
  315. package/web-dev-server.config.mjs +30 -30
  316. package/web-test-runner.config.mjs +41 -41
@@ -1,364 +1,373 @@
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 { msg } from '@lit/localize';
7
- import { SearchType, } from '@internetarchive/search-service';
8
- import '@internetarchive/infinite-scroller';
9
- import { SortField, getDefaultSelectedFacets, sortOptionFromAPIString, SORT_OPTIONS, defaultProfileElementSorts, } from './models';
10
- import { RestorationStateHandler, } from './restoration-state-handler';
11
- import { CollectionBrowserDataSource } from './data-source/collection-browser-data-source';
12
- import { FACETLESS_PAGE_ELEMENTS } from './data-source/models';
13
- import { analyticsActions, analyticsCategories, } from './utils/analytics-events';
14
- import chevronIcon from './assets/img/icons/chevron';
15
- import { srOnlyStyle } from './styles/sr-only';
16
- import { sha1 } from './utils/sha1';
17
- import { formatDate } from './utils/format-date';
18
- import { log } from './utils/log';
19
- import './empty-placeholder';
20
- import './tiles/tile-dispatcher';
21
- import './tiles/collection-browser-loading-tile';
22
- import './sort-filter-bar/sort-filter-bar';
23
- import './manage/manage-bar';
24
- import './collection-facets';
25
- import './circular-activity-indicator';
26
- let CollectionBrowser = class CollectionBrowser extends LitElement {
27
- constructor() {
28
- super();
29
- this.baseImageUrl = 'https://archive.org';
30
- /**
31
- * Which backend should be targeted by searches (e.g., metadata or FTS)
32
- */
33
- this.searchType = SearchType.METADATA;
34
- this.defaultSortParam = null;
35
- this.selectedSort = SortField.default;
36
- this.selectedTitleFilter = null;
37
- this.selectedCreatorFilter = null;
38
- this.sortDirection = null;
39
- this.pageSize = 50;
40
- /**
41
- * Whether to show the date picker (above the facets)
42
- */
43
- this.showHistogramDatePicker = false;
44
- /**
45
- * Whether placeholder views should be suppressed. If true, searches that produce an
46
- * error or empty result set will simply show a blank results view instead of a placeholder.
47
- */
48
- this.suppressPlaceholders = false;
49
- /**
50
- * Whether the result count text should be suppressed.
51
- * If true, no "X Results" message will be shown.
52
- */
53
- this.suppressResultCount = false;
54
- /**
55
- * Whether the scrolling result view should be suppressed entirely.
56
- * If true, no infinite scroller (and thus no result tiles) will be rendered.
57
- */
58
- this.suppressResultTiles = false;
59
- /**
60
- * Whether to suppress persistence of the query to the URL.
61
- * If true, the `query` param will not be added to the URL or updated on query changes.
62
- */
63
- this.suppressURLQuery = false;
64
- /**
65
- * Whether to suppress display of the sort bar.
66
- * If true, the entire sort bar (incl. display modes) will be omitted from rendering.
67
- */
68
- this.suppressSortBar = false;
69
- /**
70
- * Whether to suppress showing the display mode options in the sort bar.
71
- * If true, those options will be omitted (though the rest of the sort bar may still render).
72
- */
73
- this.suppressDisplayModes = false;
74
- /**
75
- * What strategy to use for when/whether to load facet data for a search.
76
- *
77
- * Defaults to `eager`, always loading facets immediately alongside search results.
78
- *
79
- * To eliminate facets that are never seen, this can be reduced to `lazy-mobile`, which
80
- * will delay loading facets in the mobile view until the "Filters" accordion is opened.
81
- * Facets are still loaded eagerly when viewing the desktop layout.
82
- *
83
- * To further reduce facet requests for patrons who do not need to use them, this can be
84
- * again reduced to `opt-in`, which will also require desktop users to explicitly request
85
- * that they be loaded (in addition to the lazy mobile behavior described above).
86
- *
87
- * To entirely suppress facets from being loaded, this may be set to `off`.
88
- */
89
- this.facetLoadStrategy = 'eager';
90
- this.clearResultsOnEmptyQuery = false;
91
- this.collectionPagePath = '/details/';
92
- /** describes where this component is being used */
93
- this.searchContext = analyticsCategories.default;
94
- this.pageContext = 'search';
95
- this.restorationStateHandler = new RestorationStateHandler({
96
- context: this.pageContext,
97
- });
98
- this.mobileBreakpoint = 600;
99
- this.loggedIn = false;
100
- this.modalManager = undefined;
101
- /**
102
- * If item management UI active
103
- */
104
- this.isManageView = false;
105
- this.manageViewLabel = 'Select items to remove';
106
- /** Whether to replace the default sort options with a slot for customization (default: false) */
107
- this.enableSortOptionsSlot = false;
108
- /**
109
- * The results per page so we can paginate.
110
- *
111
- * This allows us to start in the middle of the search results and
112
- * fetch data before or after the current page. If we don't have a key
113
- * for the previous/next page, we'll fetch the next/previous page to populate it
114
- */
115
- this.dataSource = new CollectionBrowserDataSource(this, this.pageSize);
116
- /**
117
- * The page that the consumer wants to load.
118
- */
119
- this.initialPageNumber = 1;
120
- /**
121
- * This the the number of pages that we want to show.
122
- *
123
- * The data isn't necessarily loaded for all of the pages, but this lets us
124
- * know how many cells we should render.
125
- */
126
- this.pagesToRender = this.initialPageNumber;
127
- /**
128
- * Whether the initial page fetch for a new query is currently in progress.
129
- */
130
- this.searchResultsLoading = false;
131
- this.facetsLoading = false;
132
- this.mobileView = false;
133
- this.collapsibleFacetsVisible = false;
134
- this.defaultSortField = SortField.relevance;
135
- this.defaultSortDirection = null;
136
- this.placeholderType = null;
137
- /** Whether layout size analytics have been sent already. */
138
- this.layoutSizeAnalyticsSent = false;
139
- /**
140
- * When we're animated scrolling to the page, we don't want to fetch
141
- * all of the pages as it scrolls so this lets us know if we're scrolling
142
- */
143
- this.isScrollingToCell = false;
144
- /**
145
- * When page width resizes from desktop to mobile, set true to
146
- * disable expand/collapse transition when loading.
147
- */
148
- this.isResizeToMobile = false;
149
- /**
150
- * Flag indicating that a new data source is currently being installed.
151
- * During the install, any URL persistence operation should replace the current entry
152
- * instead of creating a new one.
153
- */
154
- this.dataSourceInstallInProgress = false;
155
- this.placeholderCellTemplate = html `<collection-browser-loading-tile></collection-browser-loading-tile>`;
156
- /**
157
- * How many tiles to offset the data source by, to account for any removed tiles.
158
- */
159
- this.tileModelOffset = 0;
160
- /**
161
- * Updates the height of the left column according to its position on the page.
162
- * Arrow function ensures proper `this` binding.
163
- */
164
- this.updateLeftColumnHeight = () => {
165
- var _a, _b, _c, _d, _e;
166
- if (this.mobileView) {
167
- (_b = (_a = this.leftColumn) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.removeProperty('height');
168
- }
169
- else {
170
- const clientTop = (_c = this.leftColumn) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect().top;
171
- (_e = (_d = this.leftColumn) === null || _d === void 0 ? void 0 : _d.style) === null || _e === void 0 ? void 0 : _e.setProperty('height', `${window.innerHeight - (clientTop !== null && clientTop !== void 0 ? clientTop : 0) - 3}px`);
172
- }
173
- };
174
- /**
175
- * Toggles whether the fade-out is visible at the bottom of the facets.
176
- * It should only be visible if the facets are not scrolled to the bottom.
177
- * Arrow function ensures proper `this` binding.
178
- */
179
- this.updateFacetFadeOut = (entries) => {
180
- var _a, _b;
181
- const fadeElmt = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.getElementById('facets-bottom-fade');
182
- fadeElmt === null || fadeElmt === void 0 ? void 0 : fadeElmt.classList.toggle('hidden', (_b = entries === null || entries === void 0 ? void 0 : entries[0]) === null || _b === void 0 ? void 0 : _b.isIntersecting);
183
- };
184
- // we only want to scroll on the very first query change
185
- // so this keeps track of whether we've already set the initial query
186
- this.initialQueryChangeHappened = false;
187
- this.historyPopOccurred = false;
188
- this.addController(this.dataSource);
189
- }
190
- tileModelAtCellIndex(index) {
191
- const model = this.dataSource.getTileModelAt(index);
192
- /**
193
- * If we encounter a model we don't have yet and we're not in the middle of an
194
- * automated scroll, fetch the page and just return undefined.
195
- * The datasource will be updated once the page is loaded and the cell will be rendered.
196
- *
197
- * We disable it during the automated scroll since we don't want to fetch pages for intervening cells the
198
- * user may never see.
199
- */
200
- if (!model && !this.isScrollingToCell && this.dataSource.queryInitialized) {
201
- const pageNumber = Math.floor(index / this.pageSize) + 1;
202
- this.dataSource.fetchPage(pageNumber);
203
- }
204
- return model;
205
- }
206
- // this is the total number of tiles we expect if
207
- // the data returned is a full page worth
208
- // this is useful for putting in placeholders for the expected number of tiles
209
- get estimatedTileCount() {
210
- return this.pagesToRender * this.pageSize;
211
- }
212
- /**
213
- * Returns a promise resolving to a unique string that persists for the current browser session.
214
- * Used in generating unique IDs for search requests, so that multiple requests coming from the
215
- * same browser session can be identified.
216
- */
217
- async getSessionId() {
218
- try {
219
- const storedSessionId = sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.getItem('cb-session');
220
- if (storedSessionId) {
221
- return storedSessionId;
222
- }
223
- // If we enter this method a second time while a first session ID is already being generated,
224
- // ensure we produce the same ID from both calls instead of generating another one.
225
- if (this.sessionIdGenPromise) {
226
- return this.sessionIdGenPromise;
227
- }
228
- this.sessionIdGenPromise = sha1(Math.random().toString());
229
- const newSessionId = await this.sessionIdGenPromise;
230
- sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.setItem('cb-session', newSessionId);
231
- return newSessionId;
232
- }
233
- catch (err) {
234
- // Either we can't generate the hash or we're restricted from accessing sessionStorage
235
- return '';
236
- }
237
- }
238
- /**
239
- * Go to the given page of results
240
- *
241
- * @param pageNumber
242
- */
243
- goToPage(pageNumber) {
244
- this.initialPageNumber = pageNumber;
245
- this.pagesToRender = pageNumber;
246
- return this.scrollToPage(pageNumber);
247
- }
248
- /**
249
- * Sets the state for whether the initial set of search results is loading in.
250
- */
251
- setSearchResultsLoading(loading) {
252
- this.searchResultsLoading = loading;
253
- }
254
- /**
255
- * Sets the state for whether facet data is loading in
256
- */
257
- setFacetsLoading(loading) {
258
- this.facetsLoading = loading;
259
- }
260
- /**
261
- * Sets the total number of results to be displayed for the current search
262
- */
263
- setTotalResultCount(totalResults) {
264
- this.totalResults = totalResults;
265
- }
266
- /**
267
- * Clears all selected/negated facets, date ranges, and letter filters.
268
- *
269
- * By default, the current sort field/direction are not cleared,
270
- * but this can be overridden by setting the `sort` option to `true`.
271
- *
272
- * Similarly, it is possible to finely control what is cleared by
273
- * setting any of the `facets`, `dateRange`, or `letterFilters` flags
274
- * in the options object.
275
- */
276
- clearFilters({ facets = true, dateRange = true, letterFilters = true, sort = false, } = {}) {
277
- // Don't bother clearing facets if none are checked, so that we don't
278
- // trigger unnecessary update cycles.
279
- if (facets && this.hasCheckedFacets) {
280
- this.selectedFacets = getDefaultSelectedFacets();
281
- }
282
- if (dateRange) {
283
- this.minSelectedDate = undefined;
284
- this.maxSelectedDate = undefined;
285
- }
286
- if (letterFilters) {
287
- this.selectedTitleFilter = null;
288
- this.selectedCreatorFilter = null;
289
- }
290
- if (sort) {
291
- this.sortDirection = null;
292
- this.selectedSort = SortField.default;
293
- }
294
- }
295
- /**
296
- * Returns true if the current value of `this.selectedFacets` contains
297
- * any facet buckets than have been selected or negated, or false otherwise.
298
- */
299
- get hasCheckedFacets() {
300
- if (!this.selectedFacets)
301
- return false;
302
- for (const facetGroup of Object.values(this.selectedFacets)) {
303
- for (const bucket of Object.values(facetGroup)) {
304
- if (bucket.state !== 'none')
305
- return true;
306
- }
307
- }
308
- return false;
309
- }
310
- /**
311
- * Returns true if there are any currently selected/negated facet buckets,
312
- * any selected date range, or any selected letter filters. False otherwise.
313
- *
314
- * Ignores sorting options.
315
- */
316
- get hasActiveFilters() {
317
- return !!(this.hasCheckedFacets ||
318
- this.minSelectedDate ||
319
- this.maxSelectedDate ||
320
- this.selectedTitleFilter ||
321
- this.selectedCreatorFilter);
322
- }
323
- render() {
324
- 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 { msg } from '@lit/localize';
7
+ import { SearchType, } from '@internetarchive/search-service';
8
+ import '@internetarchive/infinite-scroller';
9
+ import { SortField, getDefaultSelectedFacets, sortOptionFromAPIString, SORT_OPTIONS, defaultProfileElementSorts, } from './models';
10
+ import { RestorationStateHandler, } from './restoration-state-handler';
11
+ import { CollectionBrowserDataSource } from './data-source/collection-browser-data-source';
12
+ import { FACETLESS_PAGE_ELEMENTS } from './data-source/models';
13
+ import { analyticsActions, analyticsCategories, } from './utils/analytics-events';
14
+ import chevronIcon from './assets/img/icons/chevron';
15
+ import { srOnlyStyle } from './styles/sr-only';
16
+ import { sha1 } from './utils/sha1';
17
+ import { formatDate } from './utils/format-date';
18
+ import { log } from './utils/log';
19
+ import './empty-placeholder';
20
+ import './tiles/tile-dispatcher';
21
+ import './tiles/collection-browser-loading-tile';
22
+ import './sort-filter-bar/sort-filter-bar';
23
+ import './manage/manage-bar';
24
+ import './collection-facets';
25
+ import './circular-activity-indicator';
26
+ let CollectionBrowser = class CollectionBrowser extends LitElement {
27
+ constructor() {
28
+ super();
29
+ this.baseImageUrl = 'https://archive.org';
30
+ /**
31
+ * Which backend should be targeted by searches (e.g., metadata or FTS)
32
+ */
33
+ this.searchType = SearchType.METADATA;
34
+ this.defaultSortParam = null;
35
+ this.selectedSort = SortField.default;
36
+ this.selectedTitleFilter = null;
37
+ this.selectedCreatorFilter = null;
38
+ this.sortDirection = null;
39
+ this.pageSize = 50;
40
+ /**
41
+ * Whether to show the date picker (above the facets)
42
+ */
43
+ this.showHistogramDatePicker = false;
44
+ /**
45
+ * Whether placeholder views should be suppressed. If true, searches that produce an
46
+ * error or empty result set will simply show a blank results view instead of a placeholder.
47
+ */
48
+ this.suppressPlaceholders = false;
49
+ /**
50
+ * Whether the result count text should be suppressed.
51
+ * If true, no "X Results" message will be shown.
52
+ */
53
+ this.suppressResultCount = false;
54
+ /**
55
+ * Whether the scrolling result view should be suppressed entirely.
56
+ * If true, no infinite scroller (and thus no result tiles) will be rendered.
57
+ */
58
+ this.suppressResultTiles = false;
59
+ /**
60
+ * Whether to suppress persistence of the query to the URL.
61
+ * If true, the `query` param will not be added to the URL or updated on query changes.
62
+ */
63
+ this.suppressURLQuery = false;
64
+ /**
65
+ * Whether to suppress display of the sort bar.
66
+ * If true, the entire sort bar (incl. display modes) will be omitted from rendering.
67
+ */
68
+ this.suppressSortBar = false;
69
+ /**
70
+ * Whether to suppress showing the display mode options in the sort bar.
71
+ * If true, those options will be omitted (though the rest of the sort bar may still render).
72
+ */
73
+ this.suppressDisplayModes = false;
74
+ /**
75
+ * What strategy to use for when/whether to load facet data for a search.
76
+ *
77
+ * Defaults to `eager`, always loading facets immediately alongside search results.
78
+ *
79
+ * To eliminate facets that are never seen, this can be reduced to `lazy-mobile`, which
80
+ * will delay loading facets in the mobile view until the "Filters" accordion is opened.
81
+ * Facets are still loaded eagerly when viewing the desktop layout.
82
+ *
83
+ * To further reduce facet requests for patrons who do not need to use them, this can be
84
+ * again reduced to `opt-in`, which will also require desktop users to explicitly request
85
+ * that they be loaded (in addition to the lazy mobile behavior described above).
86
+ *
87
+ * To entirely suppress facets from being loaded, this may be set to `off`.
88
+ */
89
+ this.facetLoadStrategy = 'eager';
90
+ this.clearResultsOnEmptyQuery = false;
91
+ this.collectionPagePath = '/details/';
92
+ /** describes where this component is being used */
93
+ this.searchContext = analyticsCategories.default;
94
+ this.pageContext = 'search';
95
+ this.restorationStateHandler = new RestorationStateHandler({
96
+ context: this.pageContext,
97
+ });
98
+ this.mobileBreakpoint = 600;
99
+ this.loggedIn = false;
100
+ this.modalManager = undefined;
101
+ /**
102
+ * If item management UI active
103
+ */
104
+ this.isManageView = false;
105
+ this.manageViewLabel = 'Select items to remove';
106
+ /** Whether to replace the default sort options with a slot for customization (default: false) */
107
+ this.enableSortOptionsSlot = false;
108
+ /**
109
+ * The results per page so we can paginate.
110
+ *
111
+ * This allows us to start in the middle of the search results and
112
+ * fetch data before or after the current page. If we don't have a key
113
+ * for the previous/next page, we'll fetch the next/previous page to populate it
114
+ */
115
+ this.dataSource = new CollectionBrowserDataSource(this, this.pageSize);
116
+ /**
117
+ * The page that the consumer wants to load.
118
+ */
119
+ this.initialPageNumber = 1;
120
+ /**
121
+ * This the the number of pages that we want to show.
122
+ *
123
+ * The data isn't necessarily loaded for all of the pages, but this lets us
124
+ * know how many cells we should render.
125
+ */
126
+ this.pagesToRender = this.initialPageNumber;
127
+ /**
128
+ * Whether the initial page fetch for a new query is currently in progress.
129
+ */
130
+ this.searchResultsLoading = false;
131
+ this.facetsLoading = false;
132
+ this.mobileView = false;
133
+ this.collapsibleFacetsVisible = false;
134
+ this.defaultSortField = SortField.relevance;
135
+ this.defaultSortDirection = null;
136
+ this.placeholderType = null;
137
+ /** Whether layout size analytics have been sent already. */
138
+ this.layoutSizeAnalyticsSent = false;
139
+ /**
140
+ * When we're animated scrolling to the page, we don't want to fetch
141
+ * all of the pages as it scrolls so this lets us know if we're scrolling
142
+ */
143
+ this.isScrollingToCell = false;
144
+ /**
145
+ * When page width resizes from desktop to mobile, set true to
146
+ * disable expand/collapse transition when loading.
147
+ */
148
+ this.isResizeToMobile = false;
149
+ /**
150
+ * Flag indicating that a new data source is currently being installed.
151
+ * During the install, any URL persistence operation should replace the current entry
152
+ * instead of creating a new one.
153
+ */
154
+ this.dataSourceInstallInProgress = false;
155
+ this.placeholderCellTemplate = html `<collection-browser-loading-tile></collection-browser-loading-tile>`;
156
+ /**
157
+ * Updates the height of the left column according to its position on the page.
158
+ * Arrow function ensures proper `this` binding.
159
+ */
160
+ this.updateLeftColumnHeight = () => {
161
+ var _a, _b, _c, _d, _e;
162
+ if (this.mobileView) {
163
+ (_b = (_a = this.leftColumn) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.removeProperty('height');
164
+ }
165
+ else {
166
+ const clientTop = (_c = this.leftColumn) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect().top;
167
+ (_e = (_d = this.leftColumn) === null || _d === void 0 ? void 0 : _d.style) === null || _e === void 0 ? void 0 : _e.setProperty('height', `${window.innerHeight - (clientTop !== null && clientTop !== void 0 ? clientTop : 0) - 3}px`);
168
+ }
169
+ };
170
+ /**
171
+ * Toggles whether the fade-out is visible at the bottom of the facets.
172
+ * It should only be visible if the facets are not scrolled to the bottom.
173
+ * Arrow function ensures proper `this` binding.
174
+ */
175
+ this.updateFacetFadeOut = (entries) => {
176
+ var _a, _b;
177
+ const fadeElmt = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.getElementById('facets-bottom-fade');
178
+ fadeElmt === null || fadeElmt === void 0 ? void 0 : fadeElmt.classList.toggle('hidden', (_b = entries === null || entries === void 0 ? void 0 : entries[0]) === null || _b === void 0 ? void 0 : _b.isIntersecting);
179
+ };
180
+ // we only want to scroll on the very first query change
181
+ // so this keeps track of whether we've already set the initial query
182
+ this.initialQueryChangeHappened = false;
183
+ this.historyPopOccurred = false;
184
+ this.addController(this.dataSource);
185
+ }
186
+ tileModelAtCellIndex(index) {
187
+ const model = this.dataSource.getTileModelAt(index);
188
+ /**
189
+ * If we encounter a model we don't have yet and we're not in the middle of an
190
+ * automated scroll, fetch the page and just return undefined.
191
+ * The datasource will be updated once the page is loaded and the cell will be rendered.
192
+ *
193
+ * We disable it during the automated scroll since we don't want to fetch pages for intervening cells the
194
+ * user may never see.
195
+ */
196
+ if (!model && !this.isScrollingToCell && this.dataSource.queryInitialized) {
197
+ const pageNumber = Math.floor(index / this.pageSize) + 1;
198
+ this.dataSource.fetchPage(pageNumber);
199
+ }
200
+ return model;
201
+ }
202
+ // this is the total number of tiles we expect if
203
+ // the data returned is a full page worth
204
+ // this is useful for putting in placeholders for the expected number of tiles
205
+ get estimatedTileCount() {
206
+ return this.pagesToRender * this.pageSize;
207
+ }
208
+ /**
209
+ * Returns a promise resolving to a unique string that persists for the current browser session.
210
+ * Used in generating unique IDs for search requests, so that multiple requests coming from the
211
+ * same browser session can be identified.
212
+ */
213
+ async getSessionId() {
214
+ try {
215
+ const storedSessionId = sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.getItem('cb-session');
216
+ if (storedSessionId) {
217
+ return storedSessionId;
218
+ }
219
+ // If we enter this method a second time while a first session ID is already being generated,
220
+ // ensure we produce the same ID from both calls instead of generating another one.
221
+ if (this.sessionIdGenPromise) {
222
+ return this.sessionIdGenPromise;
223
+ }
224
+ this.sessionIdGenPromise = sha1(Math.random().toString());
225
+ const newSessionId = await this.sessionIdGenPromise;
226
+ sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.setItem('cb-session', newSessionId);
227
+ return newSessionId;
228
+ }
229
+ catch (err) {
230
+ // Either we can't generate the hash or we're restricted from accessing sessionStorage
231
+ return '';
232
+ }
233
+ }
234
+ /**
235
+ * Go to the given page of results
236
+ *
237
+ * @param pageNumber
238
+ */
239
+ goToPage(pageNumber) {
240
+ this.initialPageNumber = pageNumber;
241
+ this.pagesToRender = pageNumber;
242
+ return this.scrollToPage(pageNumber);
243
+ }
244
+ /**
245
+ * Sets the state for whether the initial set of search results is loading in.
246
+ */
247
+ setSearchResultsLoading(loading) {
248
+ this.searchResultsLoading = loading;
249
+ }
250
+ /**
251
+ * Sets the state for whether facet data is loading in
252
+ */
253
+ setFacetsLoading(loading) {
254
+ this.facetsLoading = loading;
255
+ }
256
+ /**
257
+ * Sets the total number of results to be displayed for the current search
258
+ */
259
+ setTotalResultCount(totalResults) {
260
+ this.totalResults = totalResults;
261
+ }
262
+ /**
263
+ * Clears all selected/negated facets, date ranges, and letter filters.
264
+ *
265
+ * By default, the current sort field/direction are not cleared,
266
+ * but this can be overridden by setting the `sort` option to `true`.
267
+ *
268
+ * Similarly, it is possible to finely control what is cleared by
269
+ * setting any of the `facets`, `dateRange`, or `letterFilters` flags
270
+ * in the options object.
271
+ */
272
+ clearFilters({ facets = true, dateRange = true, letterFilters = true, sort = false, } = {}) {
273
+ // Don't bother clearing facets if none are checked, so that we don't
274
+ // trigger unnecessary update cycles.
275
+ if (facets && this.hasCheckedFacets) {
276
+ this.selectedFacets = getDefaultSelectedFacets();
277
+ }
278
+ if (dateRange) {
279
+ this.minSelectedDate = undefined;
280
+ this.maxSelectedDate = undefined;
281
+ }
282
+ if (letterFilters) {
283
+ this.selectedTitleFilter = null;
284
+ this.selectedCreatorFilter = null;
285
+ }
286
+ if (sort) {
287
+ this.sortDirection = null;
288
+ this.selectedSort = SortField.default;
289
+ }
290
+ }
291
+ /**
292
+ * Returns true if the current value of `this.selectedFacets` contains
293
+ * any facet buckets than have been selected or negated, or false otherwise.
294
+ */
295
+ get hasCheckedFacets() {
296
+ if (!this.selectedFacets)
297
+ return false;
298
+ for (const facetGroup of Object.values(this.selectedFacets)) {
299
+ for (const bucket of Object.values(facetGroup)) {
300
+ if (bucket.state !== 'none')
301
+ return true;
302
+ }
303
+ }
304
+ return false;
305
+ }
306
+ /**
307
+ * Returns true if there are any currently selected/negated facet buckets,
308
+ * any selected date range, or any selected letter filters. False otherwise.
309
+ *
310
+ * Ignores sorting options.
311
+ */
312
+ get hasActiveFilters() {
313
+ return !!(this.hasCheckedFacets ||
314
+ this.minSelectedDate ||
315
+ this.maxSelectedDate ||
316
+ this.selectedTitleFilter ||
317
+ this.selectedCreatorFilter);
318
+ }
319
+ willUpdate() {
320
+ this.setPlaceholderType();
321
+ }
322
+ render() {
325
323
  return html `
326
324
  <div
327
325
  id="content-container"
328
326
  class=${this.mobileView ? 'mobile' : 'desktop'}
329
327
  >
330
- ${this.placeholderType
331
- ? this.emptyPlaceholderTemplate
328
+ ${this.placeholderType
329
+ ? this.emptyPlaceholderTemplate
332
330
  : this.collectionBrowserTemplate}
333
331
  </div>
334
- `;
335
- }
336
- setPlaceholderType() {
337
- var _a;
338
- const hasQuery = !!((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim());
339
- const isCollection = !!this.withinCollection;
340
- const isProfile = !!this.withinProfile;
341
- const noResults = !this.searchResultsLoading &&
342
- (this.dataSource.size === 0 || !this.searchService);
343
- this.placeholderType = null;
344
- if (this.suppressPlaceholders)
345
- return;
346
- if (!hasQuery && !isCollection && !isProfile) {
347
- this.placeholderType = 'empty-query';
348
- }
349
- else if (noResults) {
350
- // Within a collection, no query + no results means the collection simply has no viewable items.
351
- // Otherwise, we must have a user query that produced 0 results.
352
- this.placeholderType =
353
- !hasQuery && isCollection ? 'empty-collection' : 'no-results';
354
- }
355
- if (this.dataSource.queryErrorMessage) {
356
- this.placeholderType =
357
- !hasQuery && isCollection ? 'collection-error' : 'query-error';
358
- }
359
- }
360
- get emptyPlaceholderTemplate() {
361
- var _a;
332
+ `;
333
+ }
334
+ /**
335
+ * Determines what type of placeholder content should be shown instead of result tiles, if applicable.
336
+ * The placeholders indicate states where we have no results to show, which could be the result of:
337
+ * - No query is set (on the search page)
338
+ * - No results were returned for the most recent search
339
+ * - The collection being searched within has no viewable items
340
+ * - An error occurred on the most recent search attempt
341
+ */
342
+ setPlaceholderType() {
343
+ var _a;
344
+ const hasQuery = !!((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim());
345
+ const isCollection = !!this.withinCollection;
346
+ const isProfile = !!this.withinProfile;
347
+ const noResults = !this.searchResultsLoading &&
348
+ (this.dataSource.size === 0 || !this.searchService);
349
+ this.placeholderType = null;
350
+ if (this.suppressPlaceholders)
351
+ return;
352
+ if (!hasQuery && !isCollection && !isProfile) {
353
+ this.placeholderType = 'empty-query';
354
+ }
355
+ else if (noResults) {
356
+ // Within a collection, no query + no results means the collection simply has no viewable items.
357
+ // Otherwise, we must have a user query that produced 0 results.
358
+ this.placeholderType =
359
+ !hasQuery && isCollection ? 'empty-collection' : 'no-results';
360
+ }
361
+ if (this.dataSource.queryErrorMessage) {
362
+ this.placeholderType =
363
+ !hasQuery && isCollection ? 'collection-error' : 'query-error';
364
+ }
365
+ }
366
+ /**
367
+ * Template for the placeholder content to show when no results are available.
368
+ */
369
+ get emptyPlaceholderTemplate() {
370
+ var _a;
362
371
  return html `
363
372
  <empty-placeholder
364
373
  .placeholderType=${this.placeholderType}
@@ -367,33 +376,33 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
367
376
  .detailMessage=${(_a = this.dataSource.queryErrorMessage) !== null && _a !== void 0 ? _a : ''}
368
377
  .baseNavigationUrl=${this.baseNavigationUrl}
369
378
  ></empty-placeholder>
370
- `;
371
- }
372
- /**
373
- * Top-level template for rendering the left (facets) and right (results) columns.
374
- */
375
- get collectionBrowserTemplate() {
379
+ `;
380
+ }
381
+ /**
382
+ * Top-level template for rendering the left (facets) and right (results) columns.
383
+ */
384
+ get collectionBrowserTemplate() {
376
385
  return html `
377
386
  <div id="left-column-scroll-sentinel"></div>
378
387
  ${this.leftColumnTemplate} ${this.rightColumnTemplate}
379
- `;
380
- }
381
- /**
382
- * Template for either the mobile or desktop version of the left column, depending
383
- * on current component state.
384
- */
385
- get leftColumnTemplate() {
386
- if (this.mobileView) {
387
- return this.mobileLeftColumnTemplate;
388
- }
389
- return this.desktopLeftColumnTemplate;
390
- }
391
- /**
392
- * Template for the mobile version of the "left column" (which in this case, appears
393
- * *above* the search results rather than beside them), for rendering the
394
- * accordion-style facets.
395
- */
396
- get mobileLeftColumnTemplate() {
388
+ `;
389
+ }
390
+ /**
391
+ * Template for either the mobile or desktop version of the left column, depending
392
+ * on current component state.
393
+ */
394
+ get leftColumnTemplate() {
395
+ if (this.mobileView) {
396
+ return this.mobileLeftColumnTemplate;
397
+ }
398
+ return this.desktopLeftColumnTemplate;
399
+ }
400
+ /**
401
+ * Template for the mobile version of the "left column" (which in this case, appears
402
+ * *above* the search results rather than beside them), for rendering the
403
+ * accordion-style facets.
404
+ */
405
+ get mobileLeftColumnTemplate() {
397
406
  return html `
398
407
  <div
399
408
  id="left-column"
@@ -402,12 +411,12 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
402
411
  ${this.facetTopViewSlot} ${this.resultsCountTemplate}
403
412
  <div id="facets-header-container">${this.mobileFacetsTemplate}</div>
404
413
  </div>
405
- `;
406
- }
407
- /**
408
- * Template for the desktop version of the left column, displaying the facets sidebar.
409
- */
410
- get desktopLeftColumnTemplate() {
414
+ `;
415
+ }
416
+ /**
417
+ * Template for the desktop version of the left column, displaying the facets sidebar.
418
+ */
419
+ get desktopLeftColumnTemplate() {
411
420
  return html `
412
421
  <div id="left-column" class="column">
413
422
  ${this.facetTopViewSlot}
@@ -421,28 +430,28 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
421
430
  </div>
422
431
  <div id="facets-bottom-fade"></div>
423
432
  </div>
424
- `;
425
- }
426
- /**
427
- * Slot which is placed at top of the facets area for user-profile page
428
- * - mainly used to render userlists
429
- */
430
- get facetTopViewSlot() {
433
+ `;
434
+ }
435
+ /**
436
+ * Slot which is placed at top of the facets area for user-profile page
437
+ * - mainly used to render userlists
438
+ */
439
+ get facetTopViewSlot() {
431
440
  return html `<div id="facet-top-view">
432
441
  <slot name="facet-top-slot"></slot>
433
- </div>`;
434
- }
435
- /**
436
- * Template for the "X Results" count at the top of the search results.
437
- * Changes to the "Searching..." label if the search results are still loading.
438
- */
439
- get resultsCountTemplate() {
440
- var _a;
441
- if (this.suppressResultCount)
442
- return nothing;
443
- const shouldShowSearching = this.searchResultsLoading || this.totalResults === undefined;
444
- const resultsCount = (_a = this.totalResults) === null || _a === void 0 ? void 0 : _a.toLocaleString();
445
- const resultsLabel = this.totalResults === 1 ? 'Result' : 'Results';
442
+ </div>`;
443
+ }
444
+ /**
445
+ * Template for the "X Results" count at the top of the search results.
446
+ * Changes to the "Searching..." label if the search results are still loading.
447
+ */
448
+ get resultsCountTemplate() {
449
+ var _a;
450
+ if (this.suppressResultCount)
451
+ return nothing;
452
+ const shouldShowSearching = this.searchResultsLoading || this.totalResults === undefined;
453
+ const resultsCount = (_a = this.totalResults) === null || _a === void 0 ? void 0 : _a.toLocaleString();
454
+ const resultsLabel = this.totalResults === 1 ? 'Result' : 'Results';
446
455
  return html `
447
456
  <div id="results-total">
448
457
  <span id="big-results-count">
@@ -452,30 +461,33 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
452
461
  ${shouldShowSearching ? nothing : resultsLabel}
453
462
  </span>
454
463
  </div>
455
- `;
456
- }
457
- /**
458
- * Template for the right column of the collection browser, where the result
459
- * tiles and sort/filter bar are shown.
460
- */
461
- get rightColumnTemplate() {
464
+ `;
465
+ }
466
+ /**
467
+ * Template for the right column of the collection browser, where the result
468
+ * tiles and sort/filter bar are shown.
469
+ */
470
+ get rightColumnTemplate() {
462
471
  return html `
463
472
  <div id="right-column" class="column">
464
473
  <div id="cb-top-view">
465
474
  <slot name="cb-top-slot"></slot>
466
475
  </div>
467
- ${this.isManageView
468
- ? this.manageBarTemplate
476
+ ${this.isManageView
477
+ ? this.manageBarTemplate
469
478
  : this.sortFilterBarTemplate}
470
479
  <slot name="cb-results"></slot>
471
- ${this.displayMode === `list-compact` && this.totalResults
472
- ? this.listHeaderTemplate
480
+ ${this.displayMode === `list-compact` && this.totalResults
481
+ ? this.listHeaderTemplate
473
482
  : nothing}
474
483
  ${this.suppressResultTiles ? nothing : this.infiniteScrollerTemplate}
475
484
  </div>
476
- `;
477
- }
478
- get infiniteScrollerTemplate() {
485
+ `;
486
+ }
487
+ /**
488
+ * Template for the infinite scroller widget that contains the result tiles.
489
+ */
490
+ get infiniteScrollerTemplate() {
479
491
  return html `<infinite-scroller
480
492
  class=${this.infiniteScrollerClasses}
481
493
  itemCount=${this.placeholderType ? 0 : nothing}
@@ -484,22 +496,29 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
484
496
  .placeholderCellTemplate=${this.placeholderCellTemplate}
485
497
  @scrollThresholdReached=${this.scrollThresholdReached}
486
498
  @visibleCellsChanged=${this.visibleCellsChanged}
487
- >${this.displayMode === 'grid'
488
- ? html `<slot name="result-last-tile" slot="result-last-tile"></slot>`
499
+ >${this.displayMode === 'grid'
500
+ ? html `<slot name="result-last-tile" slot="result-last-tile"></slot>`
489
501
  : nothing}
490
- </infinite-scroller>`;
491
- }
492
- get infiniteScrollerClasses() {
493
- var _a;
494
- return classMap({
495
- [(_a = this.displayMode) !== null && _a !== void 0 ? _a : '']: !!this.displayMode,
496
- hidden: !!this.placeholderType,
497
- });
498
- }
499
- get sortFilterBarTemplate() {
500
- var _a;
501
- if (this.suppressSortBar)
502
- return nothing;
502
+ </infinite-scroller>`;
503
+ }
504
+ /**
505
+ * Produces a `classMap` indicating which classes the infinite scroller should have
506
+ * given the current display mode & placeholder case.
507
+ */
508
+ get infiniteScrollerClasses() {
509
+ var _a;
510
+ return classMap({
511
+ [(_a = this.displayMode) !== null && _a !== void 0 ? _a : '']: !!this.displayMode,
512
+ hidden: !!this.placeholderType,
513
+ });
514
+ }
515
+ /**
516
+ * Template for the sort & filtering bar that appears atop the search results.
517
+ */
518
+ get sortFilterBarTemplate() {
519
+ var _a;
520
+ if (this.suppressSortBar)
521
+ return nothing;
503
522
  return html `
504
523
  <sort-filter-bar
505
524
  .defaultSortField=${this.defaultSortField}
@@ -524,9 +543,13 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
524
543
  <slot name="sort-options" slot="sort-options"></slot>
525
544
  <slot name="sort-options-right" slot="sort-options-right"></slot>
526
545
  </sort-filter-bar>
527
- `;
528
- }
529
- get manageBarTemplate() {
546
+ `;
547
+ }
548
+ /**
549
+ * Template for the manage bar UI that appears atop the search results when we are
550
+ * showing the management view. This generally replaces the sort bar when present.
551
+ */
552
+ get manageBarTemplate() {
530
553
  return html `
531
554
  <manage-bar
532
555
  .label=${this.manageViewLabel}
@@ -536,172 +559,189 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
536
559
  @removeItems=${this.handleRemoveItems}
537
560
  @selectAll=${() => this.dataSource.checkAllTiles()}
538
561
  @unselectAll=${() => this.dataSource.uncheckAllTiles()}
539
- @cancel=${() => {
540
- this.isManageView = false;
541
- this.dataSource.uncheckAllTiles();
562
+ @cancel=${() => {
563
+ this.isManageView = false;
564
+ this.dataSource.uncheckAllTiles();
542
565
  }}
543
566
  ></manage-bar>
544
- `;
545
- }
546
- /**
547
- * Handler for when the user requests to remove all checked items via the manage bar.
548
- * Emits an `itemRemovalRequested` event with all checked tile models.
549
- */
550
- handleRemoveItems() {
551
- this.dispatchEvent(new CustomEvent('itemRemovalRequested', {
552
- detail: {
553
- items: this.dataSource.checkedTileModels.map(model => {
554
- const cloned = model.clone();
555
- cloned.dateStr = formatDate(model.datePublished, 'long');
556
- return cloned;
557
- }),
558
- },
559
- }));
560
- }
561
- /**
562
- * Removes all tile models that are currently checked & adjusts the paging
563
- * of the data source to account for any new gaps in the data.
564
- */
565
- removeCheckedTiles() {
566
- this.dataSource.removeCheckedTiles();
567
- }
568
- userChangedSort(e) {
569
- var _a;
570
- const { selectedSort, sortDirection } = e.detail;
571
- this.selectedSort = selectedSort;
572
- this.sortDirection = sortDirection;
573
- if (((_a = this.currentPage) !== null && _a !== void 0 ? _a : 1) > 1) {
574
- this.goToPage(1);
575
- }
576
- this.currentPage = 1;
577
- }
578
- sendSortByAnalytics(prevSortDirection) {
579
- var _a;
580
- const directionCleared = prevSortDirection && !this.sortDirection;
581
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
582
- category: this.searchContext,
583
- action: analyticsActions.sortBy,
584
- label: `${this.selectedSort}${this.sortDirection || directionCleared ? `-${this.sortDirection}` : ''}`,
585
- });
586
- }
587
- selectedSortChanged() {
588
- // Lazy-load the alphabet counts for title/creator sort bar as needed
589
- this.dataSource.updatePrefixFiltersForCurrentSort();
590
- }
591
- get sortParam() {
592
- var _a;
593
- const sortOption = SORT_OPTIONS[this.selectedSort];
594
- if (!(sortOption === null || sortOption === void 0 ? void 0 : sortOption.handledBySearchService)) {
595
- return null;
596
- }
597
- // If the sort option specified in the URL is unrecognized, we just use it as-is
598
- const urlSortParam = new URL(window.location.href).searchParams.get('sort');
599
- const sortField = (_a = sortOption.searchServiceKey) !== null && _a !== void 0 ? _a : urlSortParam === null || urlSortParam === void 0 ? void 0 : urlSortParam.replace(/^-/, '');
600
- // If the sort direction is still null at this point, then we assume ascending
601
- // (i.e., it was unrecognized and had no directional flag)
602
- if (!this.sortDirection)
603
- this.sortDirection = 'asc';
604
- if (!sortField)
605
- return null;
606
- return { field: sortField, direction: this.sortDirection };
607
- }
608
- displayModeChanged(e) {
609
- var _a;
610
- this.displayMode = e.detail.displayMode;
611
- if (this.displayMode) {
612
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
613
- category: this.searchContext,
614
- action: analyticsActions.displayMode,
615
- label: this.displayMode,
616
- });
617
- }
618
- }
619
- /**
620
- * Returns a query clause identifying the currently selected title filter,
621
- * e.g., `firstTitle:X`.
622
- */
623
- get titleQuery() {
624
- return this.selectedTitleFilter
625
- ? `firstTitle:${this.selectedTitleFilter}`
626
- : undefined;
627
- }
628
- /**
629
- * Returns a query clause identifying the currently selected creator filter,
630
- * e.g., `firstCreator:X`.
631
- */
632
- get creatorQuery() {
633
- return this.selectedCreatorFilter
634
- ? `firstCreator:${this.selectedCreatorFilter}`
635
- : undefined;
636
- }
637
- /**
638
- * Send Analytics when sorting by title's first letter
639
- * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
640
- */
641
- sendFilterByTitleAnalytics(prevSelectedLetter) {
642
- var _a;
643
- if (!prevSelectedLetter && !this.selectedTitleFilter) {
644
- return;
645
- }
646
- const cleared = prevSelectedLetter && !this.selectedTitleFilter;
647
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
648
- category: this.searchContext,
649
- action: analyticsActions.filterByTitle,
650
- label: cleared
651
- ? `clear-${prevSelectedLetter}`
652
- : `${prevSelectedLetter || 'start'}-${this.selectedTitleFilter}`,
653
- });
654
- }
655
- /**
656
- * Send Analytics when filtering by creator's first letter
657
- * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
658
- */
659
- sendFilterByCreatorAnalytics(prevSelectedLetter) {
660
- var _a;
661
- if (!prevSelectedLetter && !this.selectedCreatorFilter) {
662
- return;
663
- }
664
- const cleared = prevSelectedLetter && !this.selectedCreatorFilter;
665
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
666
- category: this.searchContext,
667
- action: analyticsActions.filterByCreator,
668
- label: cleared
669
- ? `clear-${prevSelectedLetter}`
670
- : `${prevSelectedLetter || 'start'}-${this.selectedCreatorFilter}`,
671
- });
672
- }
673
- /**
674
- * Handler for changes to which letter is selected in the title alphabet bar.
675
- */
676
- titleLetterSelected(e) {
677
- this.selectedCreatorFilter = null;
678
- this.selectedTitleFilter = e.detail.selectedLetter;
679
- }
680
- /**
681
- * Handler for changes to which letter is selected in the creator alphabet bar.
682
- */
683
- creatorLetterSelected(e) {
684
- this.selectedTitleFilter = null;
685
- this.selectedCreatorFilter = e.detail.selectedLetter;
686
- }
687
- /**
688
- * The full template for how the facets should be structured in mobile view,
689
- * including the collapsible container (with header) and the facets themselves.
690
- */
691
- get mobileFacetsTemplate() {
692
- if (FACETLESS_PAGE_ELEMENTS.includes(this.profileElement))
693
- return nothing;
694
- const toggleFacetsVisible = (e) => {
695
- var _a;
696
- const target = e.target;
697
- this.isResizeToMobile = false;
698
- this.collapsibleFacetsVisible = target.open;
699
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
700
- category: this.searchContext,
701
- action: analyticsActions.mobileFacetsToggled,
702
- label: target.open ? 'open' : 'closed',
703
- });
704
- };
567
+ `;
568
+ }
569
+ /**
570
+ * Handler for when the user requests to remove all checked items via the manage bar.
571
+ * Emits an `itemRemovalRequested` event with all checked tile models.
572
+ */
573
+ handleRemoveItems() {
574
+ this.dispatchEvent(new CustomEvent('itemRemovalRequested', {
575
+ detail: {
576
+ items: this.dataSource.checkedTileModels.map(model => {
577
+ const cloned = model.clone();
578
+ cloned.dateStr = formatDate(model.datePublished, 'long');
579
+ return cloned;
580
+ }),
581
+ },
582
+ }));
583
+ }
584
+ /**
585
+ * Removes all tile models that are currently checked & adjusts the paging
586
+ * of the data source to account for any new gaps in the data.
587
+ */
588
+ removeCheckedTiles() {
589
+ this.dataSource.removeCheckedTiles();
590
+ }
591
+ /**
592
+ * Handler for when the user changes the selected sort option or direction.
593
+ */
594
+ userChangedSort(e) {
595
+ var _a;
596
+ const { selectedSort, sortDirection } = e.detail;
597
+ this.selectedSort = selectedSort;
598
+ this.sortDirection = sortDirection;
599
+ if (((_a = this.currentPage) !== null && _a !== void 0 ? _a : 1) > 1) {
600
+ this.goToPage(1);
601
+ }
602
+ this.currentPage = 1;
603
+ }
604
+ /**
605
+ * Fires an analytics event for sorting changes.
606
+ * @param prevSortDirection Which sort direction was previously set.
607
+ */
608
+ sendSortByAnalytics(prevSortDirection) {
609
+ var _a;
610
+ const directionCleared = prevSortDirection && !this.sortDirection;
611
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
612
+ category: this.searchContext,
613
+ action: analyticsActions.sortBy,
614
+ label: `${this.selectedSort}${this.sortDirection || directionCleared ? `-${this.sortDirection}` : ''}`,
615
+ });
616
+ }
617
+ /**
618
+ * Handler for when the selected sort option is updated, whether by the user
619
+ * themselves or programmatically.
620
+ */
621
+ selectedSortChanged() {
622
+ // Lazy-load the alphabet counts for title/creator sort bar as needed
623
+ this.dataSource.updatePrefixFiltersForCurrentSort();
624
+ }
625
+ /**
626
+ * An object representing the current sort field & direction.
627
+ */
628
+ get sortParam() {
629
+ var _a;
630
+ const sortOption = SORT_OPTIONS[this.selectedSort];
631
+ if (!(sortOption === null || sortOption === void 0 ? void 0 : sortOption.handledBySearchService)) {
632
+ return null;
633
+ }
634
+ // If the sort option specified in the URL is unrecognized, we just use it as-is
635
+ const urlSortParam = new URL(window.location.href).searchParams.get('sort');
636
+ const sortField = (_a = sortOption.searchServiceKey) !== null && _a !== void 0 ? _a : urlSortParam === null || urlSortParam === void 0 ? void 0 : urlSortParam.replace(/^-/, '');
637
+ // If the sort direction is still null at this point, then we assume ascending
638
+ // (i.e., it was unrecognized and had no directional flag)
639
+ if (!this.sortDirection)
640
+ this.sortDirection = 'asc';
641
+ if (!sortField)
642
+ return null;
643
+ return { field: sortField, direction: this.sortDirection };
644
+ }
645
+ /**
646
+ * Handler for when the display mode option is changed (grid/list/compact-list views).
647
+ */
648
+ displayModeChanged(e) {
649
+ var _a;
650
+ this.displayMode = e.detail.displayMode;
651
+ if (this.displayMode) {
652
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
653
+ category: this.searchContext,
654
+ action: analyticsActions.displayMode,
655
+ label: this.displayMode,
656
+ });
657
+ }
658
+ }
659
+ /**
660
+ * Returns a query clause identifying the currently selected title filter,
661
+ * e.g., `firstTitle:X`.
662
+ */
663
+ get titleQuery() {
664
+ return this.selectedTitleFilter
665
+ ? `firstTitle:${this.selectedTitleFilter}`
666
+ : undefined;
667
+ }
668
+ /**
669
+ * Returns a query clause identifying the currently selected creator filter,
670
+ * e.g., `firstCreator:X`.
671
+ */
672
+ get creatorQuery() {
673
+ return this.selectedCreatorFilter
674
+ ? `firstCreator:${this.selectedCreatorFilter}`
675
+ : undefined;
676
+ }
677
+ /**
678
+ * Send Analytics when sorting by title's first letter
679
+ * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
680
+ */
681
+ sendFilterByTitleAnalytics(prevSelectedLetter) {
682
+ var _a;
683
+ if (!prevSelectedLetter && !this.selectedTitleFilter) {
684
+ return;
685
+ }
686
+ const cleared = prevSelectedLetter && !this.selectedTitleFilter;
687
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
688
+ category: this.searchContext,
689
+ action: analyticsActions.filterByTitle,
690
+ label: cleared
691
+ ? `clear-${prevSelectedLetter}`
692
+ : `${prevSelectedLetter || 'start'}-${this.selectedTitleFilter}`,
693
+ });
694
+ }
695
+ /**
696
+ * Send Analytics when filtering by creator's first letter
697
+ * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
698
+ */
699
+ sendFilterByCreatorAnalytics(prevSelectedLetter) {
700
+ var _a;
701
+ if (!prevSelectedLetter && !this.selectedCreatorFilter) {
702
+ return;
703
+ }
704
+ const cleared = prevSelectedLetter && !this.selectedCreatorFilter;
705
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
706
+ category: this.searchContext,
707
+ action: analyticsActions.filterByCreator,
708
+ label: cleared
709
+ ? `clear-${prevSelectedLetter}`
710
+ : `${prevSelectedLetter || 'start'}-${this.selectedCreatorFilter}`,
711
+ });
712
+ }
713
+ /**
714
+ * Handler for changes to which letter is selected in the title alphabet bar.
715
+ */
716
+ titleLetterSelected(e) {
717
+ this.selectedCreatorFilter = null;
718
+ this.selectedTitleFilter = e.detail.selectedLetter;
719
+ }
720
+ /**
721
+ * Handler for changes to which letter is selected in the creator alphabet bar.
722
+ */
723
+ creatorLetterSelected(e) {
724
+ this.selectedTitleFilter = null;
725
+ this.selectedCreatorFilter = e.detail.selectedLetter;
726
+ }
727
+ /**
728
+ * The full template for how the facets should be structured in mobile view,
729
+ * including the collapsible container (with header) and the facets themselves.
730
+ */
731
+ get mobileFacetsTemplate() {
732
+ if (FACETLESS_PAGE_ELEMENTS.includes(this.profileElement))
733
+ return nothing;
734
+ const toggleFacetsVisible = (e) => {
735
+ var _a;
736
+ const target = e.target;
737
+ this.isResizeToMobile = false;
738
+ this.collapsibleFacetsVisible = target.open;
739
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
740
+ category: this.searchContext,
741
+ action: analyticsActions.mobileFacetsToggled,
742
+ label: target.open ? 'open' : 'closed',
743
+ });
744
+ };
705
745
  return html `
706
746
  <details id="mobile-filter-collapse" @toggle=${toggleFacetsVisible}>
707
747
  <summary>
@@ -711,21 +751,21 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
711
751
  </summary>
712
752
  ${this.facetsTemplate}
713
753
  </details>
714
- `;
715
- }
716
- /**
717
- * The template for the facets component alone, without any surrounding wrappers.
718
- */
719
- get facetsTemplate() {
720
- if (FACETLESS_PAGE_ELEMENTS.includes(this.profileElement))
721
- return nothing;
722
- if (this.facetLoadStrategy === 'off') {
754
+ `;
755
+ }
756
+ /**
757
+ * The template for the facets component alone, without any surrounding wrappers.
758
+ */
759
+ get facetsTemplate() {
760
+ if (FACETLESS_PAGE_ELEMENTS.includes(this.profileElement))
761
+ return nothing;
762
+ if (this.facetLoadStrategy === 'off') {
723
763
  return html `
724
764
  <p class="facets-message">
725
765
  ${msg('Facets are temporarily unavailable.')}
726
766
  </p>
727
- `;
728
- }
767
+ `;
768
+ }
729
769
  const facets = html `
730
770
  <collection-facets
731
771
  @facetsChanged=${this.facetsChanged}
@@ -739,7 +779,7 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
739
779
  .resizeObserver=${this.resizeObserver}
740
780
  .searchType=${this.searchType}
741
781
  .aggregations=${this.dataSource.aggregations}
742
- .fullYearsHistogramAggregation=${this.dataSource
782
+ .fullYearsHistogramAggregation=${this.dataSource
743
783
  .yearHistogramAggregation}
744
784
  .minSelectedDate=${this.minSelectedDate}
745
785
  .maxSelectedDate=${this.maxSelectedDate}
@@ -760,16 +800,16 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
760
800
  .analyticsHandler=${this.analyticsHandler}
761
801
  >
762
802
  </collection-facets>
763
- `;
764
- // In the desktop facets opt-in case, wrap the facet sidebar in a <details> widget
765
- // that can be opened and closed as needed.
766
- if (this.facetLoadStrategy === 'opt-in' && !this.mobileView) {
803
+ `;
804
+ // In the desktop facets opt-in case, wrap the facet sidebar in a <details> widget
805
+ // that can be opened and closed as needed.
806
+ if (this.facetLoadStrategy === 'opt-in' && !this.mobileView) {
767
807
  return html `
768
808
  <details
769
809
  class="desktop-facets-dropdown"
770
- @toggle=${(e) => {
771
- const target = e.target;
772
- this.collapsibleFacetsVisible = target.open;
810
+ @toggle=${(e) => {
811
+ const target = e.target;
812
+ this.collapsibleFacetsVisible = target.open;
773
813
  }}
774
814
  >
775
815
  <summary>
@@ -778,44 +818,40 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
778
818
  </summary>
779
819
  ${facets}
780
820
  </button>
781
- `;
782
- }
783
- // Otherwise, just render the facets component bare
784
- return facets;
785
- }
786
- /**
787
- * The HTML template for the "Clear all filters" button, or `nothing` if no
788
- * filters are currently active.
789
- *
790
- * @param mobile Whether to style/shorten the button for mobile view
791
- */
792
- clearFiltersBtnTemplate(mobile) {
793
- if (!this.hasActiveFilters)
794
- return nothing;
795
- const buttonClasses = classMap({
796
- 'clear-filters-btn': true,
797
- mobile,
798
- });
799
- const buttonText = mobile ? 'Clear all' : 'Clear all filters';
821
+ `;
822
+ }
823
+ // Otherwise, just render the facets component bare
824
+ return facets;
825
+ }
826
+ /**
827
+ * The HTML template for the "Clear all filters" button, or `nothing` if no
828
+ * filters are currently active.
829
+ *
830
+ * @param mobile Whether to style/shorten the button for mobile view
831
+ */
832
+ clearFiltersBtnTemplate(mobile) {
833
+ if (!this.hasActiveFilters)
834
+ return nothing;
835
+ const buttonClasses = classMap({
836
+ 'clear-filters-btn': true,
837
+ mobile,
838
+ });
839
+ const buttonText = mobile ? 'Clear all' : 'Clear all filters';
800
840
  return html `
801
841
  <div class="clear-filters-btn-row">
802
- ${mobile
803
- ? html `<span class="clear-filters-btn-separator">&nbsp;</span>`
842
+ ${mobile
843
+ ? html `<span class="clear-filters-btn-separator">&nbsp;</span>`
804
844
  : nothing}
805
845
  <button class=${buttonClasses} @click=${this.clearFilters}>
806
846
  ${buttonText}
807
847
  </button>
808
848
  </div>
809
- `;
810
- }
811
- get loadingTemplate() {
812
- return html `
813
- <div class="loading-cover">
814
- <circular-activity-indicator></circular-activity-indicator>
815
- </div>
816
- `;
817
- }
818
- get listHeaderTemplate() {
849
+ `;
850
+ }
851
+ /**
852
+ * Template for the table header content that appears atop the compact list view.
853
+ */
854
+ get listHeaderTemplate() {
819
855
  return html `
820
856
  <div id="list-header">
821
857
  <tile-dispatcher
@@ -828,641 +864,694 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
828
864
  >
829
865
  </tile-dispatcher>
830
866
  </div>
831
- `;
832
- }
833
- histogramDateRangeUpdated(e) {
834
- var _a;
835
- const { minDate, maxDate } = e.detail;
836
- [this.minSelectedDate, this.maxSelectedDate] = [minDate, maxDate];
837
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
838
- category: this.searchContext,
839
- action: analyticsActions.histogramChanged,
840
- label: this.dateRangeQueryClause,
841
- });
842
- }
843
- get dateRangeQueryClause() {
844
- if (!this.minSelectedDate || !this.maxSelectedDate) {
845
- return undefined;
846
- }
847
- return `year:[${this.minSelectedDate} TO ${this.maxSelectedDate}]`;
848
- }
849
- /**
850
- * Emits an event indicating a change in whether the manage mode is shown.
851
- */
852
- emitManageModeChangedEvent() {
853
- this.dispatchEvent(new CustomEvent('manageModeChanged', {
854
- detail: this.isManageView,
855
- }));
856
- }
857
- async installDataSourceAndQueryState(dataSource, queryState) {
858
- var _a, _b;
859
- log('Installing data source & query state in CB:', dataSource, queryState);
860
- if (this.dataSource)
861
- this.removeController(this.dataSource);
862
- this.dataSource = dataSource;
863
- this.addController(this.dataSource);
864
- this.baseQuery = queryState.baseQuery;
865
- this.profileElement = queryState.profileElement;
866
- this.searchType = queryState.searchType;
867
- this.selectedFacets =
868
- (_a = queryState.selectedFacets) !== null && _a !== void 0 ? _a : getDefaultSelectedFacets();
869
- this.minSelectedDate = queryState.minSelectedDate;
870
- this.maxSelectedDate = queryState.maxSelectedDate;
871
- this.selectedSort = (_b = queryState.selectedSort) !== null && _b !== void 0 ? _b : SortField.default;
872
- this.sortDirection = queryState.sortDirection;
873
- this.selectedTitleFilter = queryState.selectedTitleFilter;
874
- this.selectedCreatorFilter = queryState.selectedCreatorFilter;
875
- // We set this flag during the update to prevent the URL state persistence
876
- // from creating an unwanted extra history entry.
877
- this.dataSourceInstallInProgress = true;
878
- this.requestUpdate();
879
- await this.updateComplete;
880
- this.dataSourceInstallInProgress = false;
881
- if (!this.searchResultsLoading) {
882
- this.setTotalResultCount(this.dataSource.totalResults);
883
- this.setTileCount(this.dataSource.size);
884
- }
885
- this.refreshVisibleResults();
886
- }
887
- firstUpdated() {
888
- this.restoreState();
889
- this.setInitialSize();
890
- }
891
- setInitialSize() {
892
- this.contentWidth = this.contentContainer.getBoundingClientRect().width;
893
- this.mobileView =
894
- this.contentWidth > 0 && this.contentWidth < this.mobileBreakpoint;
895
- this.sendLayoutSizeAnalytics();
896
- }
897
- sendLayoutSizeAnalytics() {
898
- if (this.analyticsHandler) {
899
- this.layoutSizeAnalyticsSent = true;
900
- this.analyticsHandler.sendEvent({
901
- category: this.searchContext,
902
- action: this.mobileView
903
- ? analyticsActions.loadMobileView
904
- : analyticsActions.loadDesktopView,
905
- });
906
- }
907
- }
908
- updated(changed) {
909
- var _a, _b;
910
- if (changed.has('placeholderType') && this.placeholderType === null) {
911
- if (!this.leftColIntersectionObserver) {
912
- this.setupLeftColumnScrollListeners();
913
- }
914
- if (!this.facetsIntersectionObserver) {
915
- this.setupFacetsScrollListeners();
916
- }
917
- this.updateLeftColumnHeight();
918
- }
919
- if (changed.has('analyticsHandler') && !this.layoutSizeAnalyticsSent) {
920
- this.sendLayoutSizeAnalytics();
921
- }
922
- if (changed.has('displayMode') ||
923
- changed.has('baseNavigationUrl') ||
924
- changed.has('baseImageUrl') ||
925
- changed.has('loggedIn')) {
926
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
927
- }
928
- if (changed.has('baseQuery') ||
929
- changed.has('searchType') ||
930
- changed.has('withinCollection')) {
931
- // Unless this query/search type update is from the initial page load or the
932
- // result of hitting the back button,
933
- // we need to clear any existing filters since they may no longer be valid for
934
- // the new set of search results.
935
- if (!this.historyPopOccurred && this.initialQueryChangeHappened) {
936
- // Ordinarily, we leave the sort param unchanged between searches.
937
- // However, if we are changing the target collection itself, we want the sort cleared too,
938
- // since different collections may have different sorting options available.
939
- const shouldClearSort = changed.has('withinCollection') &&
940
- !changed.has('selectedSort') &&
941
- !changed.has('sortDirection');
942
- // Otherwise, only clear filters that haven't been simultaneously applied in this update
943
- this.clearFilters({
944
- sort: shouldClearSort,
945
- facets: !changed.has('selectedFacets'),
946
- dateRange: !(changed.has('minSelectedDate') || changed.has('maxSelectedDate')),
947
- letterFilters: !(changed.has('selectedTitleFilter') ||
948
- changed.has('selectedCreatorFilter')),
949
- });
950
- }
951
- }
952
- if (changed.has('profileElement')) {
953
- this.applyDefaultProfileSort();
954
- }
955
- if (changed.has('baseQuery')) {
956
- this.emitBaseQueryChanged();
957
- }
958
- if (changed.has('searchType')) {
959
- this.emitSearchTypeChanged();
960
- }
961
- if (changed.has('currentPage') || changed.has('displayMode')) {
962
- this.persistState();
963
- }
964
- if (changed.has('baseQuery') ||
965
- changed.has('minSelectedDate') ||
966
- changed.has('maxSelectedDate') ||
967
- changed.has('selectedFacets') ||
968
- changed.has('searchService') ||
969
- changed.has('withinCollection') ||
970
- changed.has('withinProfile') ||
971
- changed.has('profileElement')) {
972
- this.dataSource.refreshLetterCounts();
973
- }
974
- if (changed.has('selectedSort') || changed.has('sortDirection')) {
975
- const prevSortDirection = changed.get('sortDirection');
976
- this.sendSortByAnalytics(prevSortDirection);
977
- this.selectedSortChanged();
978
- }
979
- if (changed.has('selectedTitleFilter')) {
980
- this.sendFilterByTitleAnalytics(changed.get('selectedTitleFilter'));
981
- }
982
- if (changed.has('selectedCreatorFilter')) {
983
- this.sendFilterByCreatorAnalytics(changed.get('selectedCreatorFilter'));
984
- }
985
- this.updateFacetReadiness();
986
- if (changed.has('baseQuery') ||
987
- changed.has('searchType') ||
988
- changed.has('selectedTitleFilter') ||
989
- changed.has('selectedCreatorFilter') ||
990
- changed.has('minSelectedDate') ||
991
- changed.has('maxSelectedDate') ||
992
- changed.has('selectedSort') ||
993
- changed.has('sortDirection') ||
994
- changed.has('selectedFacets') ||
995
- changed.has('searchService') ||
996
- changed.has('withinCollection') ||
997
- changed.has('withinProfile') ||
998
- changed.has('profileElement')) {
999
- this.handleQueryChange();
1000
- }
1001
- if (changed.has('searchResultsLoading')) {
1002
- this.emitSearchResultsLoadingChanged();
1003
- }
1004
- if (changed.has('facetsLoading') &&
1005
- this.facetsLoading &&
1006
- this.collectionFacets) {
1007
- this.collectionFacets.moreLinksVisible =
1008
- this.searchType !== SearchType.FULLTEXT;
1009
- }
1010
- if (changed.has('pagesToRender')) {
1011
- if (!this.dataSource.endOfDataReached && this.infiniteScroller) {
1012
- this.infiniteScroller.itemCount = this.estimatedTileCount;
1013
- }
1014
- }
1015
- if (changed.has('isManageView')) {
1016
- if (this.isManageView)
1017
- this.displayMode = 'grid';
1018
- (_b = this.infiniteScroller) === null || _b === void 0 ? void 0 : _b.refreshAllVisibleCells();
1019
- this.emitManageModeChangedEvent();
1020
- }
1021
- if (changed.has('resizeObserver')) {
1022
- const oldObserver = changed.get('resizeObserver');
1023
- if (oldObserver)
1024
- this.disconnectResizeObserver(oldObserver);
1025
- this.setupResizeObserver();
1026
- }
1027
- }
1028
- connectedCallback() {
1029
- var _a;
1030
- (_a = super.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
1031
- this.setupStateRestorationObserver();
1032
- this.setupResizeObserver();
1033
- }
1034
- disconnectedCallback() {
1035
- var _a, _b;
1036
- if (this.resizeObserver) {
1037
- this.disconnectResizeObserver(this.resizeObserver);
1038
- }
1039
- if (this.boundNavigationHandler) {
1040
- window.removeEventListener('popstate', this.boundNavigationHandler);
1041
- }
1042
- (_a = this.leftColIntersectionObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
1043
- (_b = this.facetsIntersectionObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
1044
- window.removeEventListener('resize', this.updateLeftColumnHeight);
1045
- }
1046
- handleResize(entry) {
1047
- const previousView = this.mobileView;
1048
- if (entry.target === this.contentContainer) {
1049
- this.contentWidth = entry.contentRect.width;
1050
- this.mobileView =
1051
- this.contentWidth > 0 && this.contentWidth < this.mobileBreakpoint;
1052
- // If changing from desktop to mobile disable transition
1053
- if (this.mobileView && !previousView) {
1054
- this.isResizeToMobile = true;
1055
- }
1056
- }
1057
- // Ensure the facet sidebar remains sized correctly
1058
- this.updateLeftColumnHeight();
1059
- }
1060
- /**
1061
- * Updates the data source with the current state of facet readiness for loading,
1062
- * so that they will begin to load in at the appropriate time according to the
1063
- * current facet loading strategy.
1064
- */
1065
- updateFacetReadiness() {
1066
- // In desktop view, we are always ready to load facets *unless* we are
1067
- // using the `opt-in` strategy and the facets dropdown is not open.
1068
- const desktopFacetsReady = !this.mobileView &&
1069
- (this.facetLoadStrategy !== 'opt-in' || this.collapsibleFacetsVisible);
1070
- // In mobile view, facets are considered ready provided they are currently visible (their dropdown is opened).
1071
- const mobileFacetsReady = this.mobileView && this.collapsibleFacetsVisible;
1072
- this.dataSource.handleFacetReadinessChange(desktopFacetsReady || mobileFacetsReady);
1073
- }
1074
- /**
1075
- * Sets up listeners for events that may require updating the left column height.
1076
- */
1077
- setupLeftColumnScrollListeners() {
1078
- var _a;
1079
- // We observe intersections between the left column's scroll sentinel and
1080
- // the viewport, so that we can ensure the left column is always sized to
1081
- // match the _available_ viewport height. This should generally be more
1082
- // performant than listening to scroll events on the page or column.
1083
- const leftColumnSentinel = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#left-column-scroll-sentinel');
1084
- if (leftColumnSentinel) {
1085
- this.leftColIntersectionObserver = new IntersectionObserver(this.updateLeftColumnHeight, {
1086
- threshold: [...Array(101).keys()].map(n => n / 100), // Threshold every 1%
1087
- });
1088
- this.leftColIntersectionObserver.observe(leftColumnSentinel);
1089
- }
1090
- // We also listen for window resize events, as they are not always captured
1091
- // by the resize observer and can affect the desired height of the left column.
1092
- window.addEventListener('resize', this.updateLeftColumnHeight);
1093
- }
1094
- /**
1095
- * Sets up listeners to control whether the facet sidebar shows its bottom fade-out.
1096
- * Note this uses a separate IntersectionObserver from the left column, because we
1097
- * don't need granular intersection thresholds for this.
1098
- */
1099
- setupFacetsScrollListeners() {
1100
- var _a;
1101
- const facetsSentinel = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#facets-scroll-sentinel');
1102
- if (facetsSentinel) {
1103
- this.facetsIntersectionObserver = new IntersectionObserver(this.updateFacetFadeOut);
1104
- this.facetsIntersectionObserver.observe(facetsSentinel);
1105
- }
1106
- }
1107
- emitBaseQueryChanged() {
1108
- this.dispatchEvent(new CustomEvent('baseQueryChanged', {
1109
- detail: {
1110
- baseQuery: this.baseQuery,
1111
- },
1112
- }));
1113
- }
1114
- emitSearchTypeChanged() {
1115
- this.dispatchEvent(new CustomEvent('searchTypeChanged', {
1116
- detail: this.searchType,
1117
- }));
1118
- }
1119
- emitQueryStateChanged() {
1120
- this.dispatchEvent(new CustomEvent('queryStateChanged', {
1121
- detail: {
1122
- baseQuery: this.baseQuery,
1123
- withinCollection: this.withinCollection,
1124
- withinProfile: this.withinProfile,
1125
- profileElement: this.profileElement,
1126
- searchType: this.searchType,
1127
- selectedFacets: this.selectedFacets,
1128
- minSelectedDate: this.minSelectedDate,
1129
- maxSelectedDate: this.maxSelectedDate,
1130
- selectedSort: this.selectedSort,
1131
- sortDirection: this.sortDirection,
1132
- selectedTitleFilter: this.selectedTitleFilter,
1133
- selectedCreatorFilter: this.selectedCreatorFilter,
1134
- },
1135
- }));
1136
- }
1137
- emitEmptyResults() {
1138
- this.dispatchEvent(new Event('emptyResults'));
1139
- }
1140
- disconnectResizeObserver(resizeObserver) {
1141
- resizeObserver.removeObserver({
1142
- target: this.contentContainer,
1143
- handler: this,
1144
- });
1145
- }
1146
- setupResizeObserver() {
1147
- if (!this.resizeObserver || !this.contentContainer)
1148
- return;
1149
- this.resizeObserver.addObserver({
1150
- target: this.contentContainer,
1151
- handler: this,
1152
- });
1153
- }
1154
- /**
1155
- * When the visible cells change from the infinite scroller, we want to emit
1156
- * which page is currently visible so the consumer can update its UI or the URL
1157
- *
1158
- * @param e
1159
- * @returns
1160
- */
1161
- visibleCellsChanged(e) {
1162
- if (this.isScrollingToCell)
1163
- return;
1164
- const { visibleCellIndices } = e.detail;
1165
- if (visibleCellIndices.length === 0)
1166
- return;
1167
- // For page determination, do not count more than a single page of visible cells,
1168
- // since otherwise patrons using very tall screens will be treated as one page
1169
- // further than they actually are.
1170
- const lastIndexWithinCurrentPage = Math.min(this.pageSize, visibleCellIndices.length) - 1;
1171
- const lastVisibleCellIndex = visibleCellIndices[lastIndexWithinCurrentPage];
1172
- const lastVisibleCellPage = Math.floor(lastVisibleCellIndex / this.pageSize) + 1;
1173
- if (this.currentPage !== lastVisibleCellPage) {
1174
- this.currentPage = lastVisibleCellPage;
1175
- }
1176
- const event = new CustomEvent('visiblePageChanged', {
1177
- detail: {
1178
- pageNumber: lastVisibleCellPage,
1179
- },
1180
- });
1181
- this.dispatchEvent(event);
1182
- }
1183
- /**
1184
- * A Promise which, after each query change, resolves once the fetches for the initial
1185
- * search have completed. Waits for *both* the hits and aggregations fetches to finish.
1186
- *
1187
- * Ensure you await this component's `updateComplete` promise before awaiting this
1188
- * one, to ensure you do not await an obsolete promise from the previous update.
1189
- */
1190
- get initialSearchComplete() {
1191
- return this.dataSource.initialSearchComplete;
1192
- }
1193
- async handleQueryChange() {
1194
- var _a;
1195
- // only reset if the query has actually changed
1196
- if (!this.searchService ||
1197
- this.dataSource.pageFetchQueryKey === this.previousQueryKey)
1198
- return;
1199
- // If the new state prevents us from updating the search results, don't reset
1200
- if (!this.dataSource.canPerformSearch &&
1201
- !(this.clearResultsOnEmptyQuery && this.baseQuery === ''))
1202
- return;
1203
- this.previousQueryKey = this.dataSource.pageFetchQueryKey;
1204
- // this.emitQueryStateChanged();
1205
- this.tileModelOffset = 0;
1206
- this.totalResults = undefined;
1207
- this.pagesToRender =
1208
- this.initialPageNumber === 1
1209
- ? 2 // First two pages are batched into one request when starting from page 1
1210
- : this.initialPageNumber;
1211
- // Reset the infinite scroller's item count, so that it
1212
- // shows tile placeholders until the new query's results load in
1213
- if (this.infiniteScroller) {
1214
- this.infiniteScroller.itemCount = this.estimatedTileCount;
1215
- this.infiniteScroller.reload();
1216
- }
1217
- if (this.withinCollection && ((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim())) {
1218
- this.defaultSortField = SortField.relevance;
1219
- this.defaultSortDirection = null;
1220
- }
1221
- if (!this.initialQueryChangeHappened && this.initialPageNumber > 1) {
1222
- this.scrollToPage(this.initialPageNumber);
1223
- }
1224
- this.initialQueryChangeHappened = true;
1225
- // if the query changed as part of a window.history pop event, we don't want to
1226
- // persist the state because it overwrites the forward history
1227
- if (!this.historyPopOccurred) {
1228
- this.persistState();
1229
- }
1230
- this.historyPopOccurred = false;
1231
- // Fire the initial page and facets requests
1232
- // await this.dataSource.handleQueryChange();
1233
- }
1234
- setupStateRestorationObserver() {
1235
- if (!this.boundNavigationHandler) {
1236
- this.boundNavigationHandler = this.historyNavigationHandler.bind(this);
1237
- }
1238
- // when the user navigates back, we want to update the UI to match the URL
1239
- window.addEventListener('popstate', this.boundNavigationHandler);
1240
- }
1241
- historyNavigationHandler() {
1242
- this.historyPopOccurred = true;
1243
- this.restoreState();
1244
- }
1245
- restoreState() {
1246
- var _a, _b, _c, _d, _e;
1247
- const restorationState = this.restorationStateHandler.getRestorationState();
1248
- this.displayMode = restorationState.displayMode;
1249
- if (restorationState.searchType != null)
1250
- this.searchType = restorationState.searchType;
1251
- this.selectedSort = (_a = restorationState.selectedSort) !== null && _a !== void 0 ? _a : SortField.default;
1252
- this.sortDirection = (_b = restorationState.sortDirection) !== null && _b !== void 0 ? _b : null;
1253
- this.selectedTitleFilter = (_c = restorationState.selectedTitleFilter) !== null && _c !== void 0 ? _c : null;
1254
- this.selectedCreatorFilter = (_d = restorationState.selectedCreatorFilter) !== null && _d !== void 0 ? _d : null;
1255
- this.selectedFacets = restorationState.selectedFacets;
1256
- if (!this.suppressURLQuery)
1257
- this.baseQuery = restorationState.baseQuery;
1258
- this.currentPage = (_e = restorationState.currentPage) !== null && _e !== void 0 ? _e : 1;
1259
- this.minSelectedDate = restorationState.minSelectedDate;
1260
- this.maxSelectedDate = restorationState.maxSelectedDate;
1261
- if (this.currentPage > 1) {
1262
- this.goToPage(this.currentPage);
1263
- }
1264
- }
1265
- persistState() {
1266
- var _a, _b, _c, _d;
1267
- const restorationState = {
1268
- displayMode: this.displayMode,
1269
- searchType: this.searchType,
1270
- selectedSort: this.selectedSort,
1271
- sortDirection: (_a = this.sortDirection) !== null && _a !== void 0 ? _a : undefined,
1272
- selectedFacets: (_b = this.selectedFacets) !== null && _b !== void 0 ? _b : getDefaultSelectedFacets(),
1273
- baseQuery: this.suppressURLQuery ? undefined : this.baseQuery,
1274
- currentPage: this.currentPage,
1275
- titleQuery: this.titleQuery,
1276
- creatorQuery: this.creatorQuery,
1277
- minSelectedDate: this.minSelectedDate,
1278
- maxSelectedDate: this.maxSelectedDate,
1279
- selectedTitleFilter: (_c = this.selectedTitleFilter) !== null && _c !== void 0 ? _c : undefined,
1280
- selectedCreatorFilter: (_d = this.selectedCreatorFilter) !== null && _d !== void 0 ? _d : undefined,
1281
- };
1282
- this.restorationStateHandler.persistState(restorationState, this.dataSourceInstallInProgress);
1283
- }
1284
- emitSearchResultsLoadingChanged() {
1285
- this.dispatchEvent(new CustomEvent('searchResultsLoadingChanged', {
1286
- detail: {
1287
- loading: this.searchResultsLoading,
1288
- },
1289
- }));
1290
- }
1291
- facetsChanged(e) {
1292
- this.selectedFacets = e.detail;
1293
- }
1294
- facetClickHandler({ detail: { facetType, bucket, negative }, }) {
1295
- var _a;
1296
- let action;
1297
- if (negative) {
1298
- action =
1299
- bucket.state !== 'none'
1300
- ? analyticsActions.facetNegativeSelected
1301
- : analyticsActions.facetNegativeDeselected;
1302
- }
1303
- else {
1304
- action =
1305
- bucket.state !== 'none'
1306
- ? analyticsActions.facetSelected
1307
- : analyticsActions.facetDeselected;
1308
- }
1309
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
1310
- category: this.searchContext,
1311
- action,
1312
- label: facetType,
1313
- });
1314
- }
1315
- scrollToPage(pageNumber) {
1316
- return new Promise(resolve => {
1317
- const cellIndexToScrollTo = this.pageSize * (pageNumber - 1);
1318
- // without this setTimeout, Safari just pauses until the `fetchPage` is complete
1319
- // then scrolls to the cell
1320
- setTimeout(() => {
1321
- var _a;
1322
- this.isScrollingToCell = true;
1323
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.scrollToCell(cellIndexToScrollTo, true);
1324
- // This timeout is to give the scroll animation time to finish
1325
- // then updating the infinite scroller once we're done scrolling
1326
- // There's no scroll animation completion callback so we're
1327
- // giving it 0.5s to finish.
1328
- setTimeout(() => {
1329
- var _a;
1330
- this.isScrollingToCell = false;
1331
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshAllVisibleCells();
1332
- resolve();
1333
- }, 500);
1334
- }, 0);
1335
- });
1336
- }
1337
- /**
1338
- * Whether sorting by relevance makes sense for the current state.
1339
- * Currently equivalent to having a non-empty query.
1340
- */
1341
- get isRelevanceSortAvailable() {
1342
- var _a;
1343
- return !!((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim());
1344
- }
1345
- /**
1346
- * Sets the total number of tiles displayed in the infinite scroller.
1347
- */
1348
- setTileCount(count) {
1349
- if (this.infiniteScroller) {
1350
- this.infiniteScroller.itemCount = count;
1351
- }
1352
- }
1353
- /**
1354
- * Applies any default sort option for the current collection, by checking
1355
- * for one in the collection's metadata. If none is found, defaults to sorting
1356
- * descending by:
1357
- * - Date Favorited for fav-* collections
1358
- * - Weekly views for all other collections
1359
- */
1360
- applyDefaultCollectionSort(collectionInfo) {
1361
- var _a, _b, _c;
1362
- if (this.baseQuery) {
1363
- // If there's a query set, then we default to relevance sorting regardless of
1364
- // the collection metadata-specified sort.
1365
- this.defaultSortField = SortField.relevance;
1366
- this.defaultSortDirection = null;
1367
- return;
1368
- }
1369
- // Favorite collections sort on Date Favorited by default.
1370
- // Other collections fall back to sorting on weekly views.
1371
- const baseDefaultSort = ((_b = (_a = collectionInfo === null || collectionInfo === void 0 ? void 0 : collectionInfo.public_metadata) === null || _a === void 0 ? void 0 : _a.identifier) === null || _b === void 0 ? void 0 : _b.startsWith('fav-'))
1372
- ? '-favoritedate'
1373
- : '-week';
1374
- // The collection metadata may override the default sorting with something else
1375
- const metadataSort = (_c = collectionInfo === null || collectionInfo === void 0 ? void 0 : collectionInfo.public_metadata) === null || _c === void 0 ? void 0 : _c['sort-by'];
1376
- // Prefer the metadata-specified sort if one exists
1377
- const defaultSortToApply = metadataSort !== null && metadataSort !== void 0 ? metadataSort : baseDefaultSort;
1378
- // Account for both -field and field:dir formats
1379
- let [field, dir] = defaultSortToApply.split(':');
1380
- if (field.startsWith('-')) {
1381
- field = field.slice(1);
1382
- dir = 'desc';
1383
- }
1384
- else if (!['asc', 'desc'].includes(dir)) {
1385
- dir = 'asc';
1386
- }
1387
- const sortOption = sortOptionFromAPIString(field);
1388
- const sortField = sortOption.field;
1389
- if (sortField && sortField !== SortField.default) {
1390
- this.defaultSortField = sortField;
1391
- this.defaultSortDirection = dir;
1392
- this.defaultSortParam = {
1393
- field: this.defaultSortField,
1394
- direction: this.defaultSortDirection,
1395
- };
1396
- }
1397
- }
1398
- /**
1399
- * Applies the default sort option for the current profile element
1400
- */
1401
- applyDefaultProfileSort() {
1402
- if (this.profileElement) {
1403
- const defaultSortField = defaultProfileElementSorts[this.profileElement];
1404
- this.defaultSortField = defaultSortField !== null && defaultSortField !== void 0 ? defaultSortField : SortField.weeklyview;
1405
- }
1406
- else {
1407
- this.defaultSortField = SortField.weeklyview;
1408
- }
1409
- this.defaultSortDirection = 'desc';
1410
- this.defaultSortParam = {
1411
- field: this.defaultSortField,
1412
- direction: this.defaultSortDirection,
1413
- };
1414
- }
1415
- /**
1416
- * This is useful for determining whether we need to reload the scroller.
1417
- *
1418
- * When the fetch completes, we need to reload the scroller if the cells for that
1419
- * page are visible, but if the page is not currenlty visible, we don't need to reload
1420
- */
1421
- get currentVisiblePageNumbers() {
1422
- var _a, _b;
1423
- const visibleCells = (_b = (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.getVisibleCellIndices()) !== null && _b !== void 0 ? _b : [];
1424
- const visiblePages = new Set();
1425
- visibleCells.forEach(cellIndex => {
1426
- const visiblePage = Math.floor(cellIndex / this.pageSize) + 1;
1427
- visiblePages.add(visiblePage);
1428
- });
1429
- return Array.from(visiblePages);
1430
- }
1431
- /**
1432
- * Refreshes all visible result cells in the infinite scroller.
1433
- */
1434
- refreshVisibleResults() {
1435
- var _a;
1436
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshAllVisibleCells();
1437
- }
1438
- /**
1439
- * Callback when a result is selected
1440
- */
1441
- resultSelected(event) {
1442
- var _a, _b, _c;
1443
- if (this.isManageView) {
1444
- // Checked/unchecked state change -- rerender to ensure it propagates
1445
- // this.mapDataSource(model => ({ ...model }));
1446
- const cellIndex = this.dataSource.indexOf(event.detail);
1447
- if (cellIndex >= 0)
1448
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshCell(cellIndex);
1449
- this.requestUpdate();
1450
- }
1451
- (_b = this.analyticsHandler) === null || _b === void 0 ? void 0 : _b.sendEvent({
1452
- category: this.searchContext,
1453
- action: analyticsActions.resultSelected,
1454
- label: event.detail.mediatype,
1455
- });
1456
- (_c = this.analyticsHandler) === null || _c === void 0 ? void 0 : _c.sendEvent({
1457
- category: this.searchContext,
1458
- action: analyticsActions.resultSelected,
1459
- label: `page-${this.currentPage}`,
1460
- });
1461
- }
1462
- cellForIndex(index) {
1463
- const model = this.tileModelAtCellIndex(index);
1464
- if (!model)
1465
- return undefined;
867
+ `;
868
+ }
869
+ /**
870
+ * Handler for when the date picker's date range is changed.
871
+ */
872
+ histogramDateRangeUpdated(e) {
873
+ var _a;
874
+ const { minDate, maxDate } = e.detail;
875
+ [this.minSelectedDate, this.maxSelectedDate] = [minDate, maxDate];
876
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
877
+ category: this.searchContext,
878
+ action: analyticsActions.histogramChanged,
879
+ label: this.dateRangeQueryClause,
880
+ });
881
+ }
882
+ /**
883
+ * The Lucene query corresponding to the current date range.
884
+ */
885
+ get dateRangeQueryClause() {
886
+ if (!this.minSelectedDate || !this.maxSelectedDate) {
887
+ return undefined;
888
+ }
889
+ return `year:[${this.minSelectedDate} TO ${this.maxSelectedDate}]`;
890
+ }
891
+ /**
892
+ * Emits an event indicating a change in whether the manage mode is shown.
893
+ */
894
+ emitManageModeChangedEvent() {
895
+ this.dispatchEvent(new CustomEvent('manageModeChanged', {
896
+ detail: this.isManageView,
897
+ }));
898
+ }
899
+ /**
900
+ * Installs a new data source component and associated query state parameters into
901
+ * this component, causing it to efficiently update its views to represent the
902
+ * newly-provided data. In this way, one can reuse a single instance of
903
+ * <collection-browser> to handle multiple different sets of search results on
904
+ * a single page, each set of results being loaded & updated by its own data
905
+ * source.
906
+ *
907
+ * @param dataSource The data source component containing (or prepared to fetch)
908
+ * the tile data to be displayed.
909
+ * @param queryState The new query-related state that this component should
910
+ * represent, such as the search query, sort option, and any filters applied.
911
+ */
912
+ async installDataSourceAndQueryState(dataSource, queryState) {
913
+ var _a, _b;
914
+ log('Installing data source & query state in CB:', dataSource, queryState);
915
+ if (this.dataSource)
916
+ this.removeController(this.dataSource);
917
+ this.dataSource = dataSource;
918
+ this.addController(this.dataSource);
919
+ this.baseQuery = queryState.baseQuery;
920
+ this.profileElement = queryState.profileElement;
921
+ this.searchType = queryState.searchType;
922
+ this.selectedFacets =
923
+ (_a = queryState.selectedFacets) !== null && _a !== void 0 ? _a : getDefaultSelectedFacets();
924
+ this.minSelectedDate = queryState.minSelectedDate;
925
+ this.maxSelectedDate = queryState.maxSelectedDate;
926
+ this.selectedSort = (_b = queryState.selectedSort) !== null && _b !== void 0 ? _b : SortField.default;
927
+ this.sortDirection = queryState.sortDirection;
928
+ this.selectedTitleFilter = queryState.selectedTitleFilter;
929
+ this.selectedCreatorFilter = queryState.selectedCreatorFilter;
930
+ // We set this flag during the update to prevent the URL state persistence
931
+ // from creating an unwanted extra history entry.
932
+ this.dataSourceInstallInProgress = true;
933
+ this.requestUpdate();
934
+ await this.updateComplete;
935
+ this.dataSourceInstallInProgress = false;
936
+ if (!this.searchResultsLoading) {
937
+ this.setTotalResultCount(this.dataSource.totalResults);
938
+ this.setTileCount(this.dataSource.size);
939
+ }
940
+ this.refreshVisibleResults();
941
+ }
942
+ firstUpdated() {
943
+ this.restoreState();
944
+ this.setInitialSize();
945
+ }
946
+ /**
947
+ * Determines the initial size of the content container and whether or not
948
+ * the mobile layout should be used.
949
+ */
950
+ setInitialSize() {
951
+ this.contentWidth = this.contentContainer.getBoundingClientRect().width;
952
+ this.mobileView =
953
+ this.contentWidth > 0 && this.contentWidth < this.mobileBreakpoint;
954
+ this.sendLayoutSizeAnalytics();
955
+ }
956
+ /**
957
+ * Fires an analytics event indicating which type of layout was rendered:
958
+ * mobile or desktop.
959
+ */
960
+ sendLayoutSizeAnalytics() {
961
+ if (this.analyticsHandler) {
962
+ this.layoutSizeAnalyticsSent = true;
963
+ this.analyticsHandler.sendEvent({
964
+ category: this.searchContext,
965
+ action: this.mobileView
966
+ ? analyticsActions.loadMobileView
967
+ : analyticsActions.loadDesktopView,
968
+ });
969
+ }
970
+ }
971
+ updated(changed) {
972
+ var _a, _b;
973
+ if (changed.has('placeholderType') && this.placeholderType === null) {
974
+ if (!this.leftColIntersectionObserver) {
975
+ this.setupLeftColumnScrollListeners();
976
+ }
977
+ if (!this.facetsIntersectionObserver) {
978
+ this.setupFacetsScrollListeners();
979
+ }
980
+ this.updateLeftColumnHeight();
981
+ }
982
+ if (changed.has('analyticsHandler') && !this.layoutSizeAnalyticsSent) {
983
+ this.sendLayoutSizeAnalytics();
984
+ }
985
+ if (changed.has('displayMode') ||
986
+ changed.has('baseNavigationUrl') ||
987
+ changed.has('baseImageUrl') ||
988
+ changed.has('loggedIn')) {
989
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
990
+ }
991
+ if (changed.has('baseQuery') ||
992
+ changed.has('searchType') ||
993
+ changed.has('withinCollection')) {
994
+ // Unless this query/search type update is from the initial page load or the
995
+ // result of hitting the back button,
996
+ // we need to clear any existing filters since they may no longer be valid for
997
+ // the new set of search results.
998
+ if (!this.historyPopOccurred && this.initialQueryChangeHappened) {
999
+ // Ordinarily, we leave the sort param unchanged between searches.
1000
+ // However, if we are changing the target collection itself, we want the sort cleared too,
1001
+ // since different collections may have different sorting options available.
1002
+ const shouldClearSort = changed.has('withinCollection') &&
1003
+ !changed.has('selectedSort') &&
1004
+ !changed.has('sortDirection');
1005
+ // Otherwise, only clear filters that haven't been simultaneously applied in this update
1006
+ this.clearFilters({
1007
+ sort: shouldClearSort,
1008
+ facets: !changed.has('selectedFacets'),
1009
+ dateRange: !(changed.has('minSelectedDate') || changed.has('maxSelectedDate')),
1010
+ letterFilters: !(changed.has('selectedTitleFilter') ||
1011
+ changed.has('selectedCreatorFilter')),
1012
+ });
1013
+ }
1014
+ }
1015
+ if (changed.has('profileElement')) {
1016
+ this.applyDefaultProfileSort();
1017
+ }
1018
+ if (changed.has('baseQuery')) {
1019
+ this.emitBaseQueryChanged();
1020
+ }
1021
+ if (changed.has('searchType')) {
1022
+ this.emitSearchTypeChanged();
1023
+ }
1024
+ if (changed.has('currentPage') || changed.has('displayMode')) {
1025
+ this.persistState();
1026
+ }
1027
+ if (changed.has('baseQuery') ||
1028
+ changed.has('minSelectedDate') ||
1029
+ changed.has('maxSelectedDate') ||
1030
+ changed.has('selectedFacets') ||
1031
+ changed.has('searchService') ||
1032
+ changed.has('withinCollection') ||
1033
+ changed.has('withinProfile') ||
1034
+ changed.has('profileElement')) {
1035
+ this.dataSource.refreshLetterCounts();
1036
+ }
1037
+ if (changed.has('selectedSort') || changed.has('sortDirection')) {
1038
+ const prevSortDirection = changed.get('sortDirection');
1039
+ this.sendSortByAnalytics(prevSortDirection);
1040
+ this.selectedSortChanged();
1041
+ }
1042
+ if (changed.has('selectedTitleFilter')) {
1043
+ this.sendFilterByTitleAnalytics(changed.get('selectedTitleFilter'));
1044
+ }
1045
+ if (changed.has('selectedCreatorFilter')) {
1046
+ this.sendFilterByCreatorAnalytics(changed.get('selectedCreatorFilter'));
1047
+ }
1048
+ this.updateFacetReadiness();
1049
+ if (changed.has('baseQuery') ||
1050
+ changed.has('searchType') ||
1051
+ changed.has('selectedTitleFilter') ||
1052
+ changed.has('selectedCreatorFilter') ||
1053
+ changed.has('minSelectedDate') ||
1054
+ changed.has('maxSelectedDate') ||
1055
+ changed.has('selectedSort') ||
1056
+ changed.has('sortDirection') ||
1057
+ changed.has('selectedFacets') ||
1058
+ changed.has('searchService') ||
1059
+ changed.has('withinCollection') ||
1060
+ changed.has('withinProfile') ||
1061
+ changed.has('profileElement')) {
1062
+ this.handleQueryChange();
1063
+ }
1064
+ if (changed.has('searchResultsLoading')) {
1065
+ this.emitSearchResultsLoadingChanged();
1066
+ }
1067
+ if (changed.has('facetsLoading') &&
1068
+ this.facetsLoading &&
1069
+ this.collectionFacets) {
1070
+ this.collectionFacets.moreLinksVisible =
1071
+ this.searchType !== SearchType.FULLTEXT;
1072
+ }
1073
+ if (changed.has('pagesToRender')) {
1074
+ if (!this.dataSource.endOfDataReached && this.infiniteScroller) {
1075
+ this.infiniteScroller.itemCount = this.estimatedTileCount;
1076
+ }
1077
+ }
1078
+ if (changed.has('isManageView')) {
1079
+ if (this.isManageView)
1080
+ this.displayMode = 'grid';
1081
+ (_b = this.infiniteScroller) === null || _b === void 0 ? void 0 : _b.refreshAllVisibleCells();
1082
+ this.emitManageModeChangedEvent();
1083
+ }
1084
+ if (changed.has('resizeObserver')) {
1085
+ const oldObserver = changed.get('resizeObserver');
1086
+ if (oldObserver)
1087
+ this.disconnectResizeObserver(oldObserver);
1088
+ this.setupResizeObserver();
1089
+ }
1090
+ }
1091
+ connectedCallback() {
1092
+ var _a;
1093
+ (_a = super.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
1094
+ this.setupStateRestorationObserver();
1095
+ this.setupResizeObserver();
1096
+ }
1097
+ disconnectedCallback() {
1098
+ var _a, _b;
1099
+ if (this.resizeObserver) {
1100
+ this.disconnectResizeObserver(this.resizeObserver);
1101
+ }
1102
+ if (this.boundNavigationHandler) {
1103
+ window.removeEventListener('popstate', this.boundNavigationHandler);
1104
+ }
1105
+ (_a = this.leftColIntersectionObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
1106
+ (_b = this.facetsIntersectionObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
1107
+ window.removeEventListener('resize', this.updateLeftColumnHeight);
1108
+ }
1109
+ handleResize(entry) {
1110
+ const previousView = this.mobileView;
1111
+ if (entry.target === this.contentContainer) {
1112
+ this.contentWidth = entry.contentRect.width;
1113
+ this.mobileView =
1114
+ this.contentWidth > 0 && this.contentWidth < this.mobileBreakpoint;
1115
+ // If changing from desktop to mobile disable transition
1116
+ if (this.mobileView && !previousView) {
1117
+ this.isResizeToMobile = true;
1118
+ }
1119
+ }
1120
+ // Ensure the facet sidebar remains sized correctly
1121
+ this.updateLeftColumnHeight();
1122
+ }
1123
+ /**
1124
+ * Updates the data source with the current state of facet readiness for loading,
1125
+ * so that they will begin to load in at the appropriate time according to the
1126
+ * current facet loading strategy.
1127
+ */
1128
+ updateFacetReadiness() {
1129
+ // In desktop view, we are always ready to load facets *unless* we are
1130
+ // using the `opt-in` strategy and the facets dropdown is not open.
1131
+ const desktopFacetsReady = !this.mobileView &&
1132
+ (this.facetLoadStrategy !== 'opt-in' || this.collapsibleFacetsVisible);
1133
+ // In mobile view, facets are considered ready provided they are currently visible (their dropdown is opened).
1134
+ const mobileFacetsReady = this.mobileView && this.collapsibleFacetsVisible;
1135
+ this.dataSource.handleFacetReadinessChange(desktopFacetsReady || mobileFacetsReady);
1136
+ }
1137
+ /**
1138
+ * Sets up listeners for events that may require updating the left column height.
1139
+ */
1140
+ setupLeftColumnScrollListeners() {
1141
+ var _a;
1142
+ // We observe intersections between the left column's scroll sentinel and
1143
+ // the viewport, so that we can ensure the left column is always sized to
1144
+ // match the _available_ viewport height. This should generally be more
1145
+ // performant than listening to scroll events on the page or column.
1146
+ const leftColumnSentinel = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#left-column-scroll-sentinel');
1147
+ if (leftColumnSentinel) {
1148
+ this.leftColIntersectionObserver = new IntersectionObserver(this.updateLeftColumnHeight, {
1149
+ threshold: [...Array(101).keys()].map(n => n / 100), // Threshold every 1%
1150
+ });
1151
+ this.leftColIntersectionObserver.observe(leftColumnSentinel);
1152
+ }
1153
+ // We also listen for window resize events, as they are not always captured
1154
+ // by the resize observer and can affect the desired height of the left column.
1155
+ window.addEventListener('resize', this.updateLeftColumnHeight);
1156
+ }
1157
+ /**
1158
+ * Sets up listeners to control whether the facet sidebar shows its bottom fade-out.
1159
+ * Note this uses a separate IntersectionObserver from the left column, because we
1160
+ * don't need granular intersection thresholds for this.
1161
+ */
1162
+ setupFacetsScrollListeners() {
1163
+ var _a;
1164
+ const facetsSentinel = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#facets-scroll-sentinel');
1165
+ if (facetsSentinel) {
1166
+ this.facetsIntersectionObserver = new IntersectionObserver(this.updateFacetFadeOut);
1167
+ this.facetsIntersectionObserver.observe(facetsSentinel);
1168
+ }
1169
+ }
1170
+ /**
1171
+ * Emits a `baseQueryChanged` event indicating an update to the search query.
1172
+ */
1173
+ emitBaseQueryChanged() {
1174
+ this.dispatchEvent(new CustomEvent('baseQueryChanged', {
1175
+ detail: {
1176
+ baseQuery: this.baseQuery,
1177
+ },
1178
+ }));
1179
+ }
1180
+ /**
1181
+ * Emits a `searchTypeChanged` event indicating an update to the search type
1182
+ * (e.g., metadata vs. full-text).
1183
+ */
1184
+ emitSearchTypeChanged() {
1185
+ this.dispatchEvent(new CustomEvent('searchTypeChanged', {
1186
+ detail: this.searchType,
1187
+ }));
1188
+ }
1189
+ /**
1190
+ * Emits a `queryStateChanged` event indicating that one or more of this component's
1191
+ * properties have changed in a way that could affect the set of search results.
1192
+ */
1193
+ emitQueryStateChanged() {
1194
+ this.dispatchEvent(new CustomEvent('queryStateChanged', {
1195
+ detail: {
1196
+ baseQuery: this.baseQuery,
1197
+ withinCollection: this.withinCollection,
1198
+ withinProfile: this.withinProfile,
1199
+ profileElement: this.profileElement,
1200
+ searchType: this.searchType,
1201
+ selectedFacets: this.selectedFacets,
1202
+ minSelectedDate: this.minSelectedDate,
1203
+ maxSelectedDate: this.maxSelectedDate,
1204
+ selectedSort: this.selectedSort,
1205
+ sortDirection: this.sortDirection,
1206
+ selectedTitleFilter: this.selectedTitleFilter,
1207
+ selectedCreatorFilter: this.selectedCreatorFilter,
1208
+ },
1209
+ }));
1210
+ }
1211
+ /**
1212
+ * Emits an `emptyResults` event indicating that we have received an empty result set
1213
+ * for the most recent query.
1214
+ */
1215
+ emitEmptyResults() {
1216
+ this.dispatchEvent(new Event('emptyResults'));
1217
+ }
1218
+ disconnectResizeObserver(resizeObserver) {
1219
+ resizeObserver.removeObserver({
1220
+ target: this.contentContainer,
1221
+ handler: this,
1222
+ });
1223
+ }
1224
+ setupResizeObserver() {
1225
+ if (!this.resizeObserver || !this.contentContainer)
1226
+ return;
1227
+ this.resizeObserver.addObserver({
1228
+ target: this.contentContainer,
1229
+ handler: this,
1230
+ });
1231
+ }
1232
+ /**
1233
+ * When the visible cells change from the infinite scroller, we want to emit
1234
+ * which page is currently visible so the consumer can update its UI or the URL
1235
+ *
1236
+ * @param e
1237
+ * @returns
1238
+ */
1239
+ visibleCellsChanged(e) {
1240
+ if (this.isScrollingToCell)
1241
+ return;
1242
+ const { visibleCellIndices } = e.detail;
1243
+ if (visibleCellIndices.length === 0)
1244
+ return;
1245
+ // For page determination, do not count more than a single page of visible cells,
1246
+ // since otherwise patrons using very tall screens will be treated as one page
1247
+ // further than they actually are.
1248
+ const lastIndexWithinCurrentPage = Math.min(this.pageSize, visibleCellIndices.length) - 1;
1249
+ const lastVisibleCellIndex = visibleCellIndices[lastIndexWithinCurrentPage];
1250
+ const lastVisibleCellPage = Math.floor(lastVisibleCellIndex / this.pageSize) + 1;
1251
+ if (this.currentPage !== lastVisibleCellPage) {
1252
+ this.currentPage = lastVisibleCellPage;
1253
+ }
1254
+ const event = new CustomEvent('visiblePageChanged', {
1255
+ detail: {
1256
+ pageNumber: lastVisibleCellPage,
1257
+ },
1258
+ });
1259
+ this.dispatchEvent(event);
1260
+ }
1261
+ /**
1262
+ * A Promise which, after each query change, resolves once the fetches for the initial
1263
+ * search have completed. Waits for *both* the hits and aggregations fetches to finish.
1264
+ *
1265
+ * Ensure you await this component's `updateComplete` promise before awaiting this
1266
+ * one, to ensure you do not await an obsolete promise from the previous update.
1267
+ */
1268
+ get initialSearchComplete() {
1269
+ return this.dataSource.initialSearchComplete;
1270
+ }
1271
+ /**
1272
+ * Handler for whenever the component's properties change in a way that may require
1273
+ * fetching new results.
1274
+ */
1275
+ async handleQueryChange() {
1276
+ var _a;
1277
+ // only reset if the query has actually changed
1278
+ if (!this.searchService ||
1279
+ this.dataSource.pageFetchQueryKey === this.previousQueryKey)
1280
+ return;
1281
+ // If the new state prevents us from updating the search results, don't reset
1282
+ if (!this.dataSource.canPerformSearch &&
1283
+ !(this.clearResultsOnEmptyQuery && this.baseQuery === ''))
1284
+ return;
1285
+ this.previousQueryKey = this.dataSource.pageFetchQueryKey;
1286
+ this.totalResults = undefined;
1287
+ this.pagesToRender =
1288
+ this.initialPageNumber === 1
1289
+ ? 2 // First two pages are batched into one request when starting from page 1
1290
+ : this.initialPageNumber;
1291
+ // Reset the infinite scroller's item count, so that it
1292
+ // shows tile placeholders until the new query's results load in
1293
+ if (this.infiniteScroller) {
1294
+ this.infiniteScroller.itemCount = this.estimatedTileCount;
1295
+ this.infiniteScroller.reload();
1296
+ }
1297
+ if (this.withinCollection && ((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim())) {
1298
+ this.defaultSortField = SortField.relevance;
1299
+ this.defaultSortDirection = null;
1300
+ }
1301
+ if (!this.initialQueryChangeHappened && this.initialPageNumber > 1) {
1302
+ this.scrollToPage(this.initialPageNumber);
1303
+ }
1304
+ this.initialQueryChangeHappened = true;
1305
+ // if the query changed as part of a window.history pop event, we don't want to
1306
+ // persist the state because it overwrites the forward history
1307
+ if (!this.historyPopOccurred) {
1308
+ this.persistState();
1309
+ }
1310
+ this.historyPopOccurred = false;
1311
+ }
1312
+ setupStateRestorationObserver() {
1313
+ if (!this.boundNavigationHandler) {
1314
+ this.boundNavigationHandler = this.historyNavigationHandler.bind(this);
1315
+ }
1316
+ // when the user navigates back, we want to update the UI to match the URL
1317
+ window.addEventListener('popstate', this.boundNavigationHandler);
1318
+ }
1319
+ historyNavigationHandler() {
1320
+ this.historyPopOccurred = true;
1321
+ this.restoreState();
1322
+ }
1323
+ restoreState() {
1324
+ var _a, _b, _c, _d, _e;
1325
+ const restorationState = this.restorationStateHandler.getRestorationState();
1326
+ this.displayMode = restorationState.displayMode;
1327
+ if (restorationState.searchType != null)
1328
+ this.searchType = restorationState.searchType;
1329
+ this.selectedSort = (_a = restorationState.selectedSort) !== null && _a !== void 0 ? _a : SortField.default;
1330
+ this.sortDirection = (_b = restorationState.sortDirection) !== null && _b !== void 0 ? _b : null;
1331
+ this.selectedTitleFilter = (_c = restorationState.selectedTitleFilter) !== null && _c !== void 0 ? _c : null;
1332
+ this.selectedCreatorFilter = (_d = restorationState.selectedCreatorFilter) !== null && _d !== void 0 ? _d : null;
1333
+ this.selectedFacets = restorationState.selectedFacets;
1334
+ if (!this.suppressURLQuery)
1335
+ this.baseQuery = restorationState.baseQuery;
1336
+ this.currentPage = (_e = restorationState.currentPage) !== null && _e !== void 0 ? _e : 1;
1337
+ this.minSelectedDate = restorationState.minSelectedDate;
1338
+ this.maxSelectedDate = restorationState.maxSelectedDate;
1339
+ if (this.currentPage > 1) {
1340
+ this.goToPage(this.currentPage);
1341
+ }
1342
+ }
1343
+ persistState() {
1344
+ var _a, _b, _c, _d;
1345
+ const restorationState = {
1346
+ displayMode: this.displayMode,
1347
+ searchType: this.searchType,
1348
+ selectedSort: this.selectedSort,
1349
+ sortDirection: (_a = this.sortDirection) !== null && _a !== void 0 ? _a : undefined,
1350
+ selectedFacets: (_b = this.selectedFacets) !== null && _b !== void 0 ? _b : getDefaultSelectedFacets(),
1351
+ baseQuery: this.suppressURLQuery ? undefined : this.baseQuery,
1352
+ currentPage: this.currentPage,
1353
+ titleQuery: this.titleQuery,
1354
+ creatorQuery: this.creatorQuery,
1355
+ minSelectedDate: this.minSelectedDate,
1356
+ maxSelectedDate: this.maxSelectedDate,
1357
+ selectedTitleFilter: (_c = this.selectedTitleFilter) !== null && _c !== void 0 ? _c : undefined,
1358
+ selectedCreatorFilter: (_d = this.selectedCreatorFilter) !== null && _d !== void 0 ? _d : undefined,
1359
+ };
1360
+ this.restorationStateHandler.persistState(restorationState, this.dataSourceInstallInProgress);
1361
+ }
1362
+ /**
1363
+ * Emits a `searchResultsLoadingChanged` event indicating that our loading state has
1364
+ * changed (either we have started loading new results, or we have finished loading them).
1365
+ */
1366
+ emitSearchResultsLoadingChanged() {
1367
+ this.dispatchEvent(new CustomEvent('searchResultsLoadingChanged', {
1368
+ detail: {
1369
+ loading: this.searchResultsLoading,
1370
+ },
1371
+ }));
1372
+ }
1373
+ /**
1374
+ * Handler for when the set of selected facets changes.
1375
+ */
1376
+ facetsChanged(e) {
1377
+ this.selectedFacets = e.detail;
1378
+ }
1379
+ /**
1380
+ * Handler for when any facet is selected/unselected/hidden/unhidden.
1381
+ * Fires analytics indicating the type of facet event that took place.
1382
+ */
1383
+ facetClickHandler({ detail: { facetType, bucket, negative }, }) {
1384
+ var _a;
1385
+ let action;
1386
+ if (negative) {
1387
+ action =
1388
+ bucket.state !== 'none'
1389
+ ? analyticsActions.facetNegativeSelected
1390
+ : analyticsActions.facetNegativeDeselected;
1391
+ }
1392
+ else {
1393
+ action =
1394
+ bucket.state !== 'none'
1395
+ ? analyticsActions.facetSelected
1396
+ : analyticsActions.facetDeselected;
1397
+ }
1398
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
1399
+ category: this.searchContext,
1400
+ action,
1401
+ label: facetType,
1402
+ });
1403
+ }
1404
+ scrollToPage(pageNumber) {
1405
+ return new Promise(resolve => {
1406
+ const cellIndexToScrollTo = this.pageSize * (pageNumber - 1);
1407
+ // without this setTimeout, Safari just pauses until the `fetchPage` is complete
1408
+ // then scrolls to the cell
1409
+ setTimeout(() => {
1410
+ var _a;
1411
+ this.isScrollingToCell = true;
1412
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.scrollToCell(cellIndexToScrollTo, true);
1413
+ // This timeout is to give the scroll animation time to finish
1414
+ // then updating the infinite scroller once we're done scrolling
1415
+ // There's no scroll animation completion callback so we're
1416
+ // giving it 0.5s to finish.
1417
+ setTimeout(() => {
1418
+ var _a;
1419
+ this.isScrollingToCell = false;
1420
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshAllVisibleCells();
1421
+ resolve();
1422
+ }, 500);
1423
+ }, 0);
1424
+ });
1425
+ }
1426
+ /**
1427
+ * Whether sorting by relevance makes sense for the current state.
1428
+ * Currently equivalent to having a non-empty query.
1429
+ */
1430
+ get isRelevanceSortAvailable() {
1431
+ var _a;
1432
+ return !!((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim());
1433
+ }
1434
+ /**
1435
+ * Sets the total number of tiles displayed in the infinite scroller.
1436
+ */
1437
+ setTileCount(count) {
1438
+ if (this.infiniteScroller) {
1439
+ this.infiniteScroller.itemCount = count;
1440
+ }
1441
+ }
1442
+ /**
1443
+ * Applies any default sort option for the current collection, by checking
1444
+ * for one in the collection's metadata. If none is found, defaults to sorting
1445
+ * descending by:
1446
+ * - Date Favorited for fav-* collections
1447
+ * - Weekly views for all other collections
1448
+ */
1449
+ applyDefaultCollectionSort(collectionInfo) {
1450
+ var _a, _b, _c;
1451
+ if (this.baseQuery) {
1452
+ // If there's a query set, then we default to relevance sorting regardless of
1453
+ // the collection metadata-specified sort.
1454
+ this.defaultSortField = SortField.relevance;
1455
+ this.defaultSortDirection = null;
1456
+ return;
1457
+ }
1458
+ // Favorite collections sort on Date Favorited by default.
1459
+ // Other collections fall back to sorting on weekly views.
1460
+ const baseDefaultSort = ((_b = (_a = collectionInfo === null || collectionInfo === void 0 ? void 0 : collectionInfo.public_metadata) === null || _a === void 0 ? void 0 : _a.identifier) === null || _b === void 0 ? void 0 : _b.startsWith('fav-'))
1461
+ ? '-favoritedate'
1462
+ : '-week';
1463
+ // The collection metadata may override the default sorting with something else
1464
+ const metadataSort = (_c = collectionInfo === null || collectionInfo === void 0 ? void 0 : collectionInfo.public_metadata) === null || _c === void 0 ? void 0 : _c['sort-by'];
1465
+ // Prefer the metadata-specified sort if one exists
1466
+ const defaultSortToApply = metadataSort !== null && metadataSort !== void 0 ? metadataSort : baseDefaultSort;
1467
+ // Account for both -field and field:dir formats
1468
+ let [field, dir] = defaultSortToApply.split(':');
1469
+ if (field.startsWith('-')) {
1470
+ field = field.slice(1);
1471
+ dir = 'desc';
1472
+ }
1473
+ else if (!['asc', 'desc'].includes(dir)) {
1474
+ dir = 'asc';
1475
+ }
1476
+ const sortOption = sortOptionFromAPIString(field);
1477
+ const sortField = sortOption.field;
1478
+ if (sortField && sortField !== SortField.default) {
1479
+ this.defaultSortField = sortField;
1480
+ this.defaultSortDirection = dir;
1481
+ this.defaultSortParam = {
1482
+ field: this.defaultSortField,
1483
+ direction: this.defaultSortDirection,
1484
+ };
1485
+ }
1486
+ }
1487
+ /**
1488
+ * Applies the default sort option for the current profile element
1489
+ */
1490
+ applyDefaultProfileSort() {
1491
+ if (this.profileElement) {
1492
+ const defaultSortField = defaultProfileElementSorts[this.profileElement];
1493
+ this.defaultSortField = defaultSortField !== null && defaultSortField !== void 0 ? defaultSortField : SortField.weeklyview;
1494
+ }
1495
+ else {
1496
+ this.defaultSortField = SortField.weeklyview;
1497
+ }
1498
+ this.defaultSortDirection = 'desc';
1499
+ this.defaultSortParam = {
1500
+ field: this.defaultSortField,
1501
+ direction: this.defaultSortDirection,
1502
+ };
1503
+ }
1504
+ /**
1505
+ * This is useful for determining whether we need to reload the scroller.
1506
+ *
1507
+ * When the fetch completes, we need to reload the scroller if the cells for that
1508
+ * page are visible, but if the page is not currenlty visible, we don't need to reload
1509
+ */
1510
+ get currentVisiblePageNumbers() {
1511
+ var _a, _b;
1512
+ const visibleCells = (_b = (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.getVisibleCellIndices()) !== null && _b !== void 0 ? _b : [];
1513
+ const visiblePages = new Set();
1514
+ visibleCells.forEach(cellIndex => {
1515
+ const visiblePage = Math.floor(cellIndex / this.pageSize) + 1;
1516
+ visiblePages.add(visiblePage);
1517
+ });
1518
+ return Array.from(visiblePages);
1519
+ }
1520
+ /**
1521
+ * Refreshes all visible result cells in the infinite scroller.
1522
+ */
1523
+ refreshVisibleResults() {
1524
+ var _a;
1525
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshAllVisibleCells();
1526
+ }
1527
+ /**
1528
+ * Callback when a result is selected
1529
+ */
1530
+ resultSelected(event) {
1531
+ var _a, _b, _c;
1532
+ if (this.isManageView) {
1533
+ // Checked/unchecked state change -- rerender to ensure it propagates
1534
+ // this.mapDataSource(model => ({ ...model }));
1535
+ const cellIndex = this.dataSource.indexOf(event.detail);
1536
+ if (cellIndex >= 0)
1537
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshCell(cellIndex);
1538
+ this.requestUpdate();
1539
+ }
1540
+ (_b = this.analyticsHandler) === null || _b === void 0 ? void 0 : _b.sendEvent({
1541
+ category: this.searchContext,
1542
+ action: analyticsActions.resultSelected,
1543
+ label: event.detail.mediatype,
1544
+ });
1545
+ (_c = this.analyticsHandler) === null || _c === void 0 ? void 0 : _c.sendEvent({
1546
+ category: this.searchContext,
1547
+ action: analyticsActions.resultSelected,
1548
+ label: `page-${this.currentPage}`,
1549
+ });
1550
+ }
1551
+ cellForIndex(index) {
1552
+ const model = this.tileModelAtCellIndex(index);
1553
+ if (!model)
1554
+ return undefined;
1466
1555
  return html `
1467
1556
  <tile-dispatcher
1468
1557
  .collectionPagePath=${this.collectionPagePath}
@@ -1482,21 +1571,21 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
1482
1571
  @resultSelected=${(e) => this.resultSelected(e)}
1483
1572
  >
1484
1573
  </tile-dispatcher>
1485
- `;
1486
- }
1487
- /**
1488
- * When the user scrolls near to the bottom of the page, fetch the next page
1489
- * increase the number of pages to render and start fetching data for the new page
1490
- */
1491
- scrollThresholdReached() {
1492
- if (!this.dataSource.endOfDataReached && this.dataSource.queryInitialized) {
1493
- this.pagesToRender += 1;
1494
- this.dataSource.fetchPage(this.pagesToRender);
1495
- }
1496
- }
1497
- static get styles() {
1498
- return [
1499
- srOnlyStyle,
1574
+ `;
1575
+ }
1576
+ /**
1577
+ * When the user scrolls near to the bottom of the page, fetch the next page
1578
+ * increase the number of pages to render and start fetching data for the new page
1579
+ */
1580
+ scrollThresholdReached() {
1581
+ if (!this.dataSource.endOfDataReached && this.dataSource.queryInitialized) {
1582
+ this.pagesToRender += 1;
1583
+ this.dataSource.fetchPage(this.pagesToRender);
1584
+ }
1585
+ }
1586
+ static get styles() {
1587
+ return [
1588
+ srOnlyStyle,
1500
1589
  css `
1501
1590
  :host {
1502
1591
  display: block;
@@ -1894,183 +1983,183 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
1894
1983
  infinite-scroller.hidden {
1895
1984
  display: none;
1896
1985
  }
1897
- `,
1898
- ];
1899
- }
1900
- };
1901
- __decorate([
1902
- property({ type: String })
1903
- ], CollectionBrowser.prototype, "baseNavigationUrl", void 0);
1904
- __decorate([
1905
- property({ type: String })
1906
- ], CollectionBrowser.prototype, "baseImageUrl", void 0);
1907
- __decorate([
1908
- property({ type: Object })
1909
- ], CollectionBrowser.prototype, "searchService", void 0);
1910
- __decorate([
1911
- property({ type: String })
1912
- ], CollectionBrowser.prototype, "searchType", void 0);
1913
- __decorate([
1914
- property({ type: String })
1915
- ], CollectionBrowser.prototype, "withinCollection", void 0);
1916
- __decorate([
1917
- property({ type: String })
1918
- ], CollectionBrowser.prototype, "withinProfile", void 0);
1919
- __decorate([
1920
- property({ type: String })
1921
- ], CollectionBrowser.prototype, "profileElement", void 0);
1922
- __decorate([
1923
- property({ type: String })
1924
- ], CollectionBrowser.prototype, "baseQuery", void 0);
1925
- __decorate([
1926
- property({ type: String })
1927
- ], CollectionBrowser.prototype, "displayMode", void 0);
1928
- __decorate([
1929
- property({ type: Object })
1930
- ], CollectionBrowser.prototype, "defaultSortParam", void 0);
1931
- __decorate([
1932
- property({ type: String })
1933
- ], CollectionBrowser.prototype, "selectedSort", void 0);
1934
- __decorate([
1935
- property({ type: String })
1936
- ], CollectionBrowser.prototype, "selectedTitleFilter", void 0);
1937
- __decorate([
1938
- property({ type: String })
1939
- ], CollectionBrowser.prototype, "selectedCreatorFilter", void 0);
1940
- __decorate([
1941
- property({ type: String })
1942
- ], CollectionBrowser.prototype, "sortDirection", void 0);
1943
- __decorate([
1944
- property({ type: Number })
1945
- ], CollectionBrowser.prototype, "pageSize", void 0);
1946
- __decorate([
1947
- property({ type: Number })
1948
- ], CollectionBrowser.prototype, "currentPage", void 0);
1949
- __decorate([
1950
- property({ type: String })
1951
- ], CollectionBrowser.prototype, "minSelectedDate", void 0);
1952
- __decorate([
1953
- property({ type: String })
1954
- ], CollectionBrowser.prototype, "maxSelectedDate", void 0);
1955
- __decorate([
1956
- property({ type: Object })
1957
- ], CollectionBrowser.prototype, "selectedFacets", void 0);
1958
- __decorate([
1959
- property({ type: Boolean })
1960
- ], CollectionBrowser.prototype, "showHistogramDatePicker", void 0);
1961
- __decorate([
1962
- property({ type: Boolean })
1963
- ], CollectionBrowser.prototype, "suppressPlaceholders", void 0);
1964
- __decorate([
1965
- property({ type: Boolean })
1966
- ], CollectionBrowser.prototype, "suppressResultCount", void 0);
1967
- __decorate([
1968
- property({ type: Boolean })
1969
- ], CollectionBrowser.prototype, "suppressResultTiles", void 0);
1970
- __decorate([
1971
- property({ type: Boolean })
1972
- ], CollectionBrowser.prototype, "suppressURLQuery", void 0);
1973
- __decorate([
1974
- property({ type: Boolean })
1975
- ], CollectionBrowser.prototype, "suppressSortBar", void 0);
1976
- __decorate([
1977
- property({ type: Boolean })
1978
- ], CollectionBrowser.prototype, "suppressDisplayModes", void 0);
1979
- __decorate([
1980
- property({ type: String })
1981
- ], CollectionBrowser.prototype, "facetLoadStrategy", void 0);
1982
- __decorate([
1983
- property({ type: Boolean })
1984
- ], CollectionBrowser.prototype, "clearResultsOnEmptyQuery", void 0);
1985
- __decorate([
1986
- property({ type: String })
1987
- ], CollectionBrowser.prototype, "collectionPagePath", void 0);
1988
- __decorate([
1989
- property({ type: String, reflect: true })
1990
- ], CollectionBrowser.prototype, "searchContext", void 0);
1991
- __decorate([
1992
- property({ type: String })
1993
- ], CollectionBrowser.prototype, "pageContext", void 0);
1994
- __decorate([
1995
- property({ type: Object })
1996
- ], CollectionBrowser.prototype, "restorationStateHandler", void 0);
1997
- __decorate([
1998
- property({ type: Number })
1999
- ], CollectionBrowser.prototype, "mobileBreakpoint", void 0);
2000
- __decorate([
2001
- property({ type: Boolean })
2002
- ], CollectionBrowser.prototype, "loggedIn", void 0);
2003
- __decorate([
2004
- property({ type: Object })
2005
- ], CollectionBrowser.prototype, "resizeObserver", void 0);
2006
- __decorate([
2007
- property({ type: Object })
2008
- ], CollectionBrowser.prototype, "modalManager", void 0);
2009
- __decorate([
2010
- property({ type: Object })
2011
- ], CollectionBrowser.prototype, "featureFeedbackService", void 0);
2012
- __decorate([
2013
- property({ type: Object })
2014
- ], CollectionBrowser.prototype, "recaptchaManager", void 0);
2015
- __decorate([
2016
- property({ type: Boolean })
2017
- ], CollectionBrowser.prototype, "isManageView", void 0);
2018
- __decorate([
2019
- property({ type: String })
2020
- ], CollectionBrowser.prototype, "manageViewLabel", void 0);
2021
- __decorate([
2022
- property({ type: Boolean })
2023
- ], CollectionBrowser.prototype, "enableSortOptionsSlot", void 0);
2024
- __decorate([
2025
- property({ type: Object })
2026
- ], CollectionBrowser.prototype, "dataSource", void 0);
2027
- __decorate([
2028
- state()
2029
- ], CollectionBrowser.prototype, "pagesToRender", void 0);
2030
- __decorate([
2031
- state()
2032
- ], CollectionBrowser.prototype, "searchResultsLoading", void 0);
2033
- __decorate([
2034
- state()
2035
- ], CollectionBrowser.prototype, "facetsLoading", void 0);
2036
- __decorate([
2037
- state()
2038
- ], CollectionBrowser.prototype, "totalResults", void 0);
2039
- __decorate([
2040
- state()
2041
- ], CollectionBrowser.prototype, "mobileView", void 0);
2042
- __decorate([
2043
- state()
2044
- ], CollectionBrowser.prototype, "collapsibleFacetsVisible", void 0);
2045
- __decorate([
2046
- state()
2047
- ], CollectionBrowser.prototype, "contentWidth", void 0);
2048
- __decorate([
2049
- state()
2050
- ], CollectionBrowser.prototype, "defaultSortField", void 0);
2051
- __decorate([
2052
- state()
2053
- ], CollectionBrowser.prototype, "defaultSortDirection", void 0);
2054
- __decorate([
2055
- state()
2056
- ], CollectionBrowser.prototype, "placeholderType", void 0);
2057
- __decorate([
2058
- query('#content-container')
2059
- ], CollectionBrowser.prototype, "contentContainer", void 0);
2060
- __decorate([
2061
- query('#left-column')
2062
- ], CollectionBrowser.prototype, "leftColumn", void 0);
2063
- __decorate([
2064
- query('collection-facets')
2065
- ], CollectionBrowser.prototype, "collectionFacets", void 0);
2066
- __decorate([
2067
- property({ type: Object, attribute: false })
2068
- ], CollectionBrowser.prototype, "analyticsHandler", void 0);
2069
- __decorate([
2070
- query('infinite-scroller')
2071
- ], CollectionBrowser.prototype, "infiniteScroller", void 0);
2072
- CollectionBrowser = __decorate([
2073
- customElement('collection-browser')
2074
- ], CollectionBrowser);
2075
- export { CollectionBrowser };
1986
+ `,
1987
+ ];
1988
+ }
1989
+ };
1990
+ __decorate([
1991
+ property({ type: String })
1992
+ ], CollectionBrowser.prototype, "baseNavigationUrl", void 0);
1993
+ __decorate([
1994
+ property({ type: String })
1995
+ ], CollectionBrowser.prototype, "baseImageUrl", void 0);
1996
+ __decorate([
1997
+ property({ type: Object })
1998
+ ], CollectionBrowser.prototype, "searchService", void 0);
1999
+ __decorate([
2000
+ property({ type: String })
2001
+ ], CollectionBrowser.prototype, "searchType", void 0);
2002
+ __decorate([
2003
+ property({ type: String })
2004
+ ], CollectionBrowser.prototype, "withinCollection", void 0);
2005
+ __decorate([
2006
+ property({ type: String })
2007
+ ], CollectionBrowser.prototype, "withinProfile", void 0);
2008
+ __decorate([
2009
+ property({ type: String })
2010
+ ], CollectionBrowser.prototype, "profileElement", void 0);
2011
+ __decorate([
2012
+ property({ type: String })
2013
+ ], CollectionBrowser.prototype, "baseQuery", void 0);
2014
+ __decorate([
2015
+ property({ type: String })
2016
+ ], CollectionBrowser.prototype, "displayMode", void 0);
2017
+ __decorate([
2018
+ property({ type: Object })
2019
+ ], CollectionBrowser.prototype, "defaultSortParam", void 0);
2020
+ __decorate([
2021
+ property({ type: String })
2022
+ ], CollectionBrowser.prototype, "selectedSort", void 0);
2023
+ __decorate([
2024
+ property({ type: String })
2025
+ ], CollectionBrowser.prototype, "selectedTitleFilter", void 0);
2026
+ __decorate([
2027
+ property({ type: String })
2028
+ ], CollectionBrowser.prototype, "selectedCreatorFilter", void 0);
2029
+ __decorate([
2030
+ property({ type: String })
2031
+ ], CollectionBrowser.prototype, "sortDirection", void 0);
2032
+ __decorate([
2033
+ property({ type: Number })
2034
+ ], CollectionBrowser.prototype, "pageSize", void 0);
2035
+ __decorate([
2036
+ property({ type: Number })
2037
+ ], CollectionBrowser.prototype, "currentPage", void 0);
2038
+ __decorate([
2039
+ property({ type: String })
2040
+ ], CollectionBrowser.prototype, "minSelectedDate", void 0);
2041
+ __decorate([
2042
+ property({ type: String })
2043
+ ], CollectionBrowser.prototype, "maxSelectedDate", void 0);
2044
+ __decorate([
2045
+ property({ type: Object })
2046
+ ], CollectionBrowser.prototype, "selectedFacets", void 0);
2047
+ __decorate([
2048
+ property({ type: Boolean })
2049
+ ], CollectionBrowser.prototype, "showHistogramDatePicker", void 0);
2050
+ __decorate([
2051
+ property({ type: Boolean })
2052
+ ], CollectionBrowser.prototype, "suppressPlaceholders", void 0);
2053
+ __decorate([
2054
+ property({ type: Boolean })
2055
+ ], CollectionBrowser.prototype, "suppressResultCount", void 0);
2056
+ __decorate([
2057
+ property({ type: Boolean })
2058
+ ], CollectionBrowser.prototype, "suppressResultTiles", void 0);
2059
+ __decorate([
2060
+ property({ type: Boolean })
2061
+ ], CollectionBrowser.prototype, "suppressURLQuery", void 0);
2062
+ __decorate([
2063
+ property({ type: Boolean })
2064
+ ], CollectionBrowser.prototype, "suppressSortBar", void 0);
2065
+ __decorate([
2066
+ property({ type: Boolean })
2067
+ ], CollectionBrowser.prototype, "suppressDisplayModes", void 0);
2068
+ __decorate([
2069
+ property({ type: String })
2070
+ ], CollectionBrowser.prototype, "facetLoadStrategy", void 0);
2071
+ __decorate([
2072
+ property({ type: Boolean })
2073
+ ], CollectionBrowser.prototype, "clearResultsOnEmptyQuery", void 0);
2074
+ __decorate([
2075
+ property({ type: String })
2076
+ ], CollectionBrowser.prototype, "collectionPagePath", void 0);
2077
+ __decorate([
2078
+ property({ type: String, reflect: true })
2079
+ ], CollectionBrowser.prototype, "searchContext", void 0);
2080
+ __decorate([
2081
+ property({ type: String })
2082
+ ], CollectionBrowser.prototype, "pageContext", void 0);
2083
+ __decorate([
2084
+ property({ type: Object })
2085
+ ], CollectionBrowser.prototype, "restorationStateHandler", void 0);
2086
+ __decorate([
2087
+ property({ type: Number })
2088
+ ], CollectionBrowser.prototype, "mobileBreakpoint", void 0);
2089
+ __decorate([
2090
+ property({ type: Boolean })
2091
+ ], CollectionBrowser.prototype, "loggedIn", void 0);
2092
+ __decorate([
2093
+ property({ type: Object })
2094
+ ], CollectionBrowser.prototype, "resizeObserver", void 0);
2095
+ __decorate([
2096
+ property({ type: Object })
2097
+ ], CollectionBrowser.prototype, "modalManager", void 0);
2098
+ __decorate([
2099
+ property({ type: Object })
2100
+ ], CollectionBrowser.prototype, "featureFeedbackService", void 0);
2101
+ __decorate([
2102
+ property({ type: Object })
2103
+ ], CollectionBrowser.prototype, "recaptchaManager", void 0);
2104
+ __decorate([
2105
+ property({ type: Boolean })
2106
+ ], CollectionBrowser.prototype, "isManageView", void 0);
2107
+ __decorate([
2108
+ property({ type: String })
2109
+ ], CollectionBrowser.prototype, "manageViewLabel", void 0);
2110
+ __decorate([
2111
+ property({ type: Boolean })
2112
+ ], CollectionBrowser.prototype, "enableSortOptionsSlot", void 0);
2113
+ __decorate([
2114
+ property({ type: Object })
2115
+ ], CollectionBrowser.prototype, "dataSource", void 0);
2116
+ __decorate([
2117
+ state()
2118
+ ], CollectionBrowser.prototype, "pagesToRender", void 0);
2119
+ __decorate([
2120
+ state()
2121
+ ], CollectionBrowser.prototype, "searchResultsLoading", void 0);
2122
+ __decorate([
2123
+ state()
2124
+ ], CollectionBrowser.prototype, "facetsLoading", void 0);
2125
+ __decorate([
2126
+ state()
2127
+ ], CollectionBrowser.prototype, "totalResults", void 0);
2128
+ __decorate([
2129
+ state()
2130
+ ], CollectionBrowser.prototype, "mobileView", void 0);
2131
+ __decorate([
2132
+ state()
2133
+ ], CollectionBrowser.prototype, "collapsibleFacetsVisible", void 0);
2134
+ __decorate([
2135
+ state()
2136
+ ], CollectionBrowser.prototype, "contentWidth", void 0);
2137
+ __decorate([
2138
+ state()
2139
+ ], CollectionBrowser.prototype, "defaultSortField", void 0);
2140
+ __decorate([
2141
+ state()
2142
+ ], CollectionBrowser.prototype, "defaultSortDirection", void 0);
2143
+ __decorate([
2144
+ state()
2145
+ ], CollectionBrowser.prototype, "placeholderType", void 0);
2146
+ __decorate([
2147
+ query('#content-container')
2148
+ ], CollectionBrowser.prototype, "contentContainer", void 0);
2149
+ __decorate([
2150
+ query('#left-column')
2151
+ ], CollectionBrowser.prototype, "leftColumn", void 0);
2152
+ __decorate([
2153
+ query('collection-facets')
2154
+ ], CollectionBrowser.prototype, "collectionFacets", void 0);
2155
+ __decorate([
2156
+ property({ type: Object, attribute: false })
2157
+ ], CollectionBrowser.prototype, "analyticsHandler", void 0);
2158
+ __decorate([
2159
+ query('infinite-scroller')
2160
+ ], CollectionBrowser.prototype, "infiniteScroller", void 0);
2161
+ CollectionBrowser = __decorate([
2162
+ customElement('collection-browser')
2163
+ ], CollectionBrowser);
2164
+ export { CollectionBrowser };
2076
2165
  //# sourceMappingURL=collection-browser.js.map