@internetarchive/collection-browser 4.7.0 → 4.8.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 (453) hide show
  1. package/.husky/pre-commit +0 -0
  2. package/dist/src/app-root.js +0 -2
  3. package/dist/src/app-root.js.map +1 -1
  4. package/dist/src/assets/img/icons/check.d.ts +2 -0
  5. package/dist/src/assets/img/icons/check.js +5 -0
  6. package/dist/src/assets/img/icons/check.js.map +1 -0
  7. package/dist/src/collection-facets/facet-row-template.d.ts +38 -0
  8. package/dist/src/collection-facets/facet-row-template.js +200 -0
  9. package/dist/src/collection-facets/facet-row-template.js.map +1 -0
  10. package/dist/src/collection-facets/facet-row.js +11 -186
  11. package/dist/src/collection-facets/facet-row.js.map +1 -1
  12. package/dist/src/collection-facets/models.d.ts +7 -2
  13. package/dist/src/collection-facets/models.js +7 -2
  14. package/dist/src/collection-facets/models.js.map +1 -1
  15. package/dist/src/collection-facets/more-facets-content.d.ts +87 -21
  16. package/dist/src/collection-facets/more-facets-content.js +477 -200
  17. package/dist/src/collection-facets/more-facets-content.js.map +1 -1
  18. package/dist/src/collection-facets/more-facets-scroller.d.ts +85 -0
  19. package/dist/src/collection-facets/more-facets-scroller.js +428 -0
  20. package/dist/src/collection-facets/more-facets-scroller.js.map +1 -0
  21. package/dist/src/collection-facets/page-window.d.ts +73 -0
  22. package/dist/src/collection-facets/page-window.js +202 -0
  23. package/dist/src/collection-facets/page-window.js.map +1 -0
  24. package/dist/src/collection-facets/toggle-switch.js +1 -0
  25. package/dist/src/collection-facets/toggle-switch.js.map +1 -1
  26. package/dist/src/models.d.ts +4 -0
  27. package/dist/src/models.js +16 -0
  28. package/dist/src/models.js.map +1 -1
  29. package/dist/src/utils/log.d.ts +1 -4
  30. package/dist/src/utils/normalize-filter-text.d.ts +28 -0
  31. package/dist/src/utils/normalize-filter-text.js +35 -0
  32. package/dist/src/utils/normalize-filter-text.js.map +1 -0
  33. package/dist/test/collection-facets/more-facets-content.test.js +367 -17
  34. package/dist/test/collection-facets/more-facets-content.test.js.map +1 -1
  35. package/dist/test/collection-facets/more-facets-scroller.test.d.ts +1 -0
  36. package/dist/test/collection-facets/more-facets-scroller.test.js +288 -0
  37. package/dist/test/collection-facets/more-facets-scroller.test.js.map +1 -0
  38. package/dist/test/collection-facets/page-window.test.d.ts +1 -0
  39. package/dist/test/collection-facets/page-window.test.js +175 -0
  40. package/dist/test/collection-facets/page-window.test.js.map +1 -0
  41. package/dist/test/mocks/mock-search-responses.d.ts +6 -0
  42. package/dist/test/mocks/mock-search-responses.js +52 -0
  43. package/dist/test/mocks/mock-search-responses.js.map +1 -1
  44. package/dist/test/mocks/mock-search-service.js +2 -1
  45. package/dist/test/mocks/mock-search-service.js.map +1 -1
  46. package/dist/test/utils/normalize-filter-text.test.d.ts +1 -0
  47. package/dist/test/utils/normalize-filter-text.test.js +69 -0
  48. package/dist/test/utils/normalize-filter-text.test.js.map +1 -0
  49. package/docs/design/column-virtualization.md +214 -0
  50. package/package.json +20 -16
  51. package/src/app-root.ts +0 -2
  52. package/src/assets/img/icons/check.ts +5 -0
  53. package/src/collection-facets/facet-row-template.ts +242 -0
  54. package/src/collection-facets/facet-row.ts +15 -202
  55. package/src/collection-facets/models.ts +8 -2
  56. package/src/collection-facets/more-facets-content.ts +528 -221
  57. package/src/collection-facets/more-facets-scroller.ts +485 -0
  58. package/src/collection-facets/page-window.ts +247 -0
  59. package/src/collection-facets/toggle-switch.ts +1 -0
  60. package/src/models.ts +17 -0
  61. package/src/utils/normalize-filter-text.ts +54 -0
  62. package/test/collection-facets/more-facets-content.test.ts +509 -24
  63. package/test/collection-facets/more-facets-scroller.test.ts +401 -0
  64. package/test/collection-facets/page-window.test.ts +208 -0
  65. package/test/mocks/mock-search-responses.ts +56 -0
  66. package/test/mocks/mock-search-service.ts +2 -0
  67. package/test/utils/normalize-filter-text.test.ts +87 -0
  68. package/web-test-runner.config.mjs +7 -2
  69. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/.editorconfig +0 -29
  70. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/.github/workflows/ci.yml +0 -27
  71. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/.github/workflows/gh-pages-main.yml +0 -39
  72. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/.github/workflows/npm-publish.yml +0 -39
  73. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/.github/workflows/pr-preview.yml +0 -38
  74. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/.husky/pre-commit +0 -1
  75. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/.prettierignore +0 -1
  76. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/LICENSE +0 -661
  77. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/README.md +0 -84
  78. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/eslint.config.mjs +0 -53
  79. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/index.html +0 -24
  80. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/index.ts +0 -29
  81. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/local.archive.org.cert +0 -86
  82. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/local.archive.org.key +0 -27
  83. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/package.json +0 -120
  84. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/renovate.json +0 -6
  85. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/app-root.ts +0 -1284
  86. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/arrow-left.ts +0 -10
  87. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/arrow-right.ts +0 -10
  88. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/chevron.ts +0 -4
  89. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/close-circle-dark.ts +0 -5
  90. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/contract.ts +0 -9
  91. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/empty-query.ts +0 -5
  92. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/expand.ts +0 -9
  93. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/eye-closed.ts +0 -5
  94. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/eye.ts +0 -5
  95. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/favorite-filled.ts +0 -10
  96. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/favorite-unfilled.ts +0 -9
  97. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/filter.ts +0 -10
  98. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/login-required.ts +0 -18
  99. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/account.ts +0 -14
  100. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/audio.ts +0 -14
  101. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/collection.ts +0 -12
  102. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/data.ts +0 -15
  103. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/etree.ts +0 -14
  104. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/film.ts +0 -14
  105. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/images.ts +0 -13
  106. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/radio.ts +0 -15
  107. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/search.ts +0 -14
  108. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/software.ts +0 -13
  109. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/texts.ts +0 -13
  110. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/tv-commercial.ts +0 -12
  111. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/tv-fact-check.ts +0 -12
  112. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/tv-quote.ts +0 -12
  113. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/tv.ts +0 -14
  114. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/video.ts +0 -14
  115. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/web.ts +0 -13
  116. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/null-result.ts +0 -5
  117. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/quote.ts +0 -7
  118. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/restricted.ts +0 -13
  119. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/reviews.ts +0 -11
  120. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/upload.ts +0 -12
  121. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/views.ts +0 -11
  122. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/circular-activity-indicator.ts +0 -64
  123. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-browser.ts +0 -3165
  124. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/facet-row.ts +0 -309
  125. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/facet-tombstone-row.ts +0 -40
  126. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/facets-template.ts +0 -85
  127. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/models.ts +0 -10
  128. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/more-facets-content.ts +0 -644
  129. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/more-facets-pagination.ts +0 -294
  130. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/dedupe.ts +0 -44
  131. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/heuristics/browser-language/browser-language-heuristic.ts +0 -27
  132. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/heuristics/index.ts +0 -3
  133. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-heuristic.ts +0 -17
  134. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-map.ts +0 -70
  135. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-entity-map.ts +0 -79
  136. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.ts +0 -93
  137. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/models.ts +0 -36
  138. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/smart-facet-bar.ts +0 -437
  139. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/smart-facet-button.ts +0 -145
  140. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/smart-facet-dropdown.ts +0 -185
  141. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/smart-facet-equals.ts +0 -16
  142. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/smart-facet-heuristics.ts +0 -26
  143. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/toggle-switch.ts +0 -174
  144. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets.ts +0 -1013
  145. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/data-source/collection-browser-data-source-interface.ts +0 -351
  146. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/data-source/collection-browser-data-source.ts +0 -1474
  147. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/data-source/collection-browser-query-state.ts +0 -60
  148. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/data-source/models.ts +0 -56
  149. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/empty-placeholder.ts +0 -192
  150. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/expanded-date-picker.ts +0 -191
  151. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/language-code-handler/language-code-handler.ts +0 -64
  152. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/language-code-handler/language-code-mapping.ts +0 -564
  153. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/manage/manage-bar.ts +0 -276
  154. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/manage/remove-items-modal-content.ts +0 -102
  155. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/mediatype/mediatype-config.ts +0 -146
  156. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/models.ts +0 -895
  157. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/restoration-state-handler.ts +0 -550
  158. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/sort-filter-bar/alpha-bar-tooltip.ts +0 -53
  159. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/sort-filter-bar/alpha-bar.ts +0 -252
  160. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/sort-filter-bar/img/compact.ts +0 -5
  161. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/sort-filter-bar/img/list.ts +0 -5
  162. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/sort-filter-bar/img/sort-toggle-disabled.ts +0 -15
  163. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/sort-filter-bar/img/sort-toggle-down.ts +0 -17
  164. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/sort-filter-bar/img/sort-toggle-up.ts +0 -17
  165. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/sort-filter-bar/img/sort-triangle.ts +0 -5
  166. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/sort-filter-bar/img/tile.ts +0 -5
  167. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/sort-filter-bar/sort-filter-bar.ts +0 -733
  168. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/styles/ia-button.ts +0 -139
  169. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/styles/item-image-styles.ts +0 -124
  170. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/styles/sr-only.ts +0 -18
  171. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/styles/tile-action-styles.ts +0 -59
  172. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/base-tile-component.ts +0 -124
  173. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/collection-browser-loading-tile.ts +0 -26
  174. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/grid/account-tile.ts +0 -113
  175. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/grid/collection-tile.ts +0 -184
  176. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/grid/item-tile.ts +0 -347
  177. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/grid/search-tile.ts +0 -90
  178. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/grid/styles/tile-grid-shared-styles.ts +0 -130
  179. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/grid/tile-stats.ts +0 -211
  180. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/hover/hover-pane-controller.ts +0 -638
  181. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/hover/tile-hover-pane.ts +0 -184
  182. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/image-block.ts +0 -162
  183. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/item-image.ts +0 -214
  184. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/list/tile-list-compact-header.ts +0 -112
  185. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/list/tile-list-compact.ts +0 -278
  186. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/list/tile-list.ts +0 -718
  187. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/models.ts +0 -21
  188. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/overlay/icon-overlay.ts +0 -57
  189. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/overlay/text-overlay.ts +0 -79
  190. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/review-block.ts +0 -130
  191. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/text-snippet-block.ts +0 -132
  192. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/tile-dispatcher.ts +0 -637
  193. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/tile-display-value-provider.ts +0 -133
  194. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/tile-mediatype-icon.ts +0 -133
  195. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/utils/analytics-events.ts +0 -29
  196. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/utils/array-equals.ts +0 -8
  197. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/utils/collapse-repeated-quotes.ts +0 -13
  198. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/utils/date-filter-field.ts +0 -11
  199. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/utils/facet-utils.ts +0 -183
  200. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/utils/format-count.ts +0 -95
  201. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/utils/format-date.ts +0 -62
  202. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/utils/format-unit-size.ts +0 -43
  203. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/utils/local-date-from-utc.ts +0 -15
  204. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/utils/log.ts +0 -14
  205. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/utils/resolve-mediatype.ts +0 -26
  206. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/utils/sha1.ts +0 -9
  207. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/collection-browser.test.ts +0 -2639
  208. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/collection-facets/facet-row.test.ts +0 -421
  209. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/collection-facets/facets-template.test.ts +0 -139
  210. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/collection-facets/more-facets-content.test.ts +0 -231
  211. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/collection-facets/more-facets-pagination.test.ts +0 -201
  212. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/collection-facets/toggle-switch.test.ts +0 -164
  213. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/collection-facets.test.ts +0 -928
  214. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/data-source/collection-browser-data-source.test.ts +0 -193
  215. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/empty-placeholder.test.ts +0 -88
  216. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/expanded-date-picker.test.ts +0 -201
  217. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/icon-overlay.test.ts +0 -38
  218. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/image-block.test.ts +0 -247
  219. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/item-image.test.ts +0 -220
  220. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/manage/manage-bar.test.ts +0 -347
  221. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/manage/remove-items-modal-content.test.ts +0 -81
  222. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/mediatype-config.test.ts +0 -11
  223. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/mocks/mock-analytics-handler.ts +0 -30
  224. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/mocks/mock-search-responses.ts +0 -1364
  225. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/mocks/mock-search-service.ts +0 -134
  226. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/restoration-state-handler.test.ts +0 -480
  227. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/review-block.test.ts +0 -62
  228. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/sort-filter-bar/alpha-bar-tooltip.test.ts +0 -17
  229. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/sort-filter-bar/alpha-bar.test.ts +0 -101
  230. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/sort-filter-bar/sort-filter-bar.test.ts +0 -443
  231. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/text-overlay.test.ts +0 -55
  232. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/text-snippet-block.test.ts +0 -85
  233. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tile-stats.test.ts +0 -191
  234. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tiles/grid/account-tile.test.ts +0 -121
  235. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tiles/grid/collection-tile.test.ts +0 -114
  236. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tiles/grid/item-tile.test.ts +0 -520
  237. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tiles/grid/search-tile.test.ts +0 -75
  238. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tiles/hover/hover-pane-controller.test.ts +0 -482
  239. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tiles/hover/tile-hover-pane.test.ts +0 -80
  240. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tiles/list/tile-list-compact-header.test.ts +0 -43
  241. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tiles/list/tile-list-compact.test.ts +0 -282
  242. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tiles/list/tile-list.test.ts +0 -576
  243. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tiles/tile-dispatcher.test.ts +0 -320
  244. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tiles/tile-display-value-provider.test.ts +0 -172
  245. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tiles/tile-mediatype-icon.test.ts +0 -160
  246. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/utils/array-equals.test.ts +0 -31
  247. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/utils/format-count.test.ts +0 -32
  248. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/utils/format-date.test.ts +0 -89
  249. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/utils/format-unit-size.test.ts +0 -21
  250. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/utils/local-date-from-utc.test.ts +0 -37
  251. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/tsconfig.json +0 -25
  252. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/types/dompurify.d.ts +0 -1
  253. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/vite.config.ts +0 -29
  254. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/web-dev-server.config.mjs +0 -30
  255. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/web-test-runner.config.mjs +0 -52
  256. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/yarn.lock +0 -5965
  257. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/.editorconfig +0 -29
  258. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/.github/workflows/ci.yml +0 -29
  259. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/.github/workflows/gh-pages-main.yml +0 -41
  260. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/.github/workflows/npm-publish.yml +0 -49
  261. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/.github/workflows/pr-preview.yml +0 -40
  262. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/.husky/pre-commit +0 -1
  263. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/.prettierignore +0 -1
  264. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/LICENSE +0 -661
  265. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/README.md +0 -68
  266. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/eslint.config.mjs +0 -53
  267. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/index.html +0 -24
  268. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/index.ts +0 -29
  269. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/local.archive.org.cert +0 -86
  270. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/local.archive.org.key +0 -27
  271. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/package.json +0 -129
  272. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/pnpm-lock.yaml +0 -7366
  273. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/pnpm-workspace.yaml +0 -46
  274. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/renovate.json +0 -6
  275. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/app-root.ts +0 -1284
  276. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/arrow-left.ts +0 -10
  277. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/arrow-right.ts +0 -10
  278. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/chevron.ts +0 -4
  279. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/close-circle-dark.ts +0 -5
  280. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/contract.ts +0 -9
  281. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/empty-query.ts +0 -5
  282. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/expand.ts +0 -9
  283. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/eye-closed.ts +0 -5
  284. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/eye.ts +0 -5
  285. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/favorite-filled.ts +0 -10
  286. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/favorite-unfilled.ts +0 -9
  287. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/filter.ts +0 -10
  288. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/login-required.ts +0 -18
  289. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/mediatype/account.ts +0 -14
  290. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/mediatype/audio.ts +0 -14
  291. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/mediatype/collection.ts +0 -12
  292. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/mediatype/data.ts +0 -15
  293. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/mediatype/etree.ts +0 -14
  294. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/mediatype/film.ts +0 -14
  295. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/mediatype/images.ts +0 -13
  296. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/mediatype/radio.ts +0 -15
  297. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/mediatype/search.ts +0 -14
  298. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/mediatype/software.ts +0 -13
  299. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/mediatype/texts.ts +0 -13
  300. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/mediatype/tv-commercial.ts +0 -12
  301. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/mediatype/tv-fact-check.ts +0 -12
  302. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/mediatype/tv-quote.ts +0 -12
  303. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/mediatype/tv.ts +0 -14
  304. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/mediatype/video.ts +0 -14
  305. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/mediatype/web.ts +0 -13
  306. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/null-result.ts +0 -5
  307. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/quote.ts +0 -7
  308. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/restricted.ts +0 -13
  309. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/reviews.ts +0 -11
  310. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/upload.ts +0 -12
  311. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/assets/img/icons/views.ts +0 -11
  312. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/circular-activity-indicator.ts +0 -64
  313. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/collection-browser.ts +0 -3165
  314. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/collection-facets/facet-row.ts +0 -309
  315. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/collection-facets/facet-tombstone-row.ts +0 -40
  316. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/collection-facets/facets-template.ts +0 -85
  317. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/collection-facets/models.ts +0 -10
  318. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/collection-facets/more-facets-content.ts +0 -644
  319. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/collection-facets/more-facets-pagination.ts +0 -294
  320. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/collection-facets/smart-facets/dedupe.ts +0 -44
  321. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/collection-facets/smart-facets/heuristics/browser-language/browser-language-heuristic.ts +0 -27
  322. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/collection-facets/smart-facets/heuristics/index.ts +0 -3
  323. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-heuristic.ts +0 -17
  324. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-map.ts +0 -70
  325. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-entity-map.ts +0 -79
  326. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.ts +0 -93
  327. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/collection-facets/smart-facets/models.ts +0 -36
  328. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/collection-facets/smart-facets/smart-facet-bar.ts +0 -437
  329. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/collection-facets/smart-facets/smart-facet-button.ts +0 -145
  330. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/collection-facets/smart-facets/smart-facet-dropdown.ts +0 -185
  331. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/collection-facets/smart-facets/smart-facet-equals.ts +0 -16
  332. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/collection-facets/smart-facets/smart-facet-heuristics.ts +0 -26
  333. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/collection-facets/toggle-switch.ts +0 -174
  334. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/collection-facets.ts +0 -1013
  335. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/data-source/collection-browser-data-source-interface.ts +0 -351
  336. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/data-source/collection-browser-data-source.ts +0 -1474
  337. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/data-source/collection-browser-query-state.ts +0 -60
  338. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/data-source/models.ts +0 -56
  339. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/empty-placeholder.ts +0 -192
  340. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/expanded-date-picker.ts +0 -191
  341. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/language-code-handler/language-code-handler.ts +0 -64
  342. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/language-code-handler/language-code-mapping.ts +0 -564
  343. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/manage/manage-bar.ts +0 -276
  344. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/manage/remove-items-modal-content.ts +0 -102
  345. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/mediatype/mediatype-config.ts +0 -146
  346. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/models.ts +0 -895
  347. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/restoration-state-handler.ts +0 -550
  348. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/sort-filter-bar/alpha-bar-tooltip.ts +0 -53
  349. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/sort-filter-bar/alpha-bar.ts +0 -252
  350. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/sort-filter-bar/img/compact.ts +0 -5
  351. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/sort-filter-bar/img/list.ts +0 -5
  352. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/sort-filter-bar/img/sort-toggle-disabled.ts +0 -15
  353. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/sort-filter-bar/img/sort-toggle-down.ts +0 -17
  354. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/sort-filter-bar/img/sort-toggle-up.ts +0 -17
  355. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/sort-filter-bar/img/sort-triangle.ts +0 -5
  356. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/sort-filter-bar/img/tile.ts +0 -5
  357. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/sort-filter-bar/sort-filter-bar.ts +0 -733
  358. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/styles/ia-button.ts +0 -139
  359. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/styles/item-image-styles.ts +0 -124
  360. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/styles/sr-only.ts +0 -18
  361. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/styles/tile-action-styles.ts +0 -59
  362. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/tiles/base-tile-component.ts +0 -124
  363. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/tiles/collection-browser-loading-tile.ts +0 -26
  364. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/tiles/grid/account-tile.ts +0 -113
  365. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/tiles/grid/collection-tile.ts +0 -184
  366. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/tiles/grid/item-tile.ts +0 -347
  367. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/tiles/grid/search-tile.ts +0 -90
  368. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/tiles/grid/styles/tile-grid-shared-styles.ts +0 -130
  369. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/tiles/grid/tile-stats.ts +0 -211
  370. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/tiles/hover/hover-pane-controller.ts +0 -638
  371. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/tiles/hover/tile-hover-pane.ts +0 -184
  372. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/tiles/image-block.ts +0 -162
  373. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/tiles/item-image.ts +0 -214
  374. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/tiles/list/tile-list-compact-header.ts +0 -112
  375. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/tiles/list/tile-list-compact.ts +0 -278
  376. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/tiles/list/tile-list.ts +0 -718
  377. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/tiles/models.ts +0 -21
  378. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/tiles/overlay/icon-overlay.ts +0 -57
  379. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/tiles/overlay/text-overlay.ts +0 -79
  380. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/tiles/review-block.ts +0 -130
  381. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/tiles/text-snippet-block.ts +0 -132
  382. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/tiles/tile-dispatcher.ts +0 -637
  383. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/tiles/tile-display-value-provider.ts +0 -133
  384. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/tiles/tile-mediatype-icon.ts +0 -133
  385. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/utils/analytics-events.ts +0 -29
  386. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/utils/array-equals.ts +0 -8
  387. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/utils/collapse-repeated-quotes.ts +0 -13
  388. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/utils/date-filter-field.ts +0 -11
  389. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/utils/facet-utils.ts +0 -183
  390. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/utils/format-count.ts +0 -95
  391. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/utils/format-date.ts +0 -62
  392. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/utils/format-unit-size.ts +0 -43
  393. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/utils/local-date-from-utc.ts +0 -15
  394. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/utils/log.ts +0 -14
  395. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/utils/resolve-mediatype.ts +0 -26
  396. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/src/utils/sha1.ts +0 -9
  397. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/collection-browser.test.ts +0 -2639
  398. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/collection-facets/facet-row.test.ts +0 -421
  399. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/collection-facets/facets-template.test.ts +0 -139
  400. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/collection-facets/more-facets-content.test.ts +0 -231
  401. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/collection-facets/more-facets-pagination.test.ts +0 -201
  402. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/collection-facets/toggle-switch.test.ts +0 -164
  403. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/collection-facets.test.ts +0 -928
  404. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/data-source/collection-browser-data-source.test.ts +0 -193
  405. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/empty-placeholder.test.ts +0 -88
  406. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/expanded-date-picker.test.ts +0 -201
  407. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/icon-overlay.test.ts +0 -38
  408. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/image-block.test.ts +0 -247
  409. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/item-image.test.ts +0 -220
  410. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/manage/manage-bar.test.ts +0 -347
  411. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/manage/remove-items-modal-content.test.ts +0 -81
  412. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/mediatype-config.test.ts +0 -11
  413. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/mocks/mock-analytics-handler.ts +0 -30
  414. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/mocks/mock-search-responses.ts +0 -1364
  415. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/mocks/mock-search-service.ts +0 -134
  416. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/restoration-state-handler.test.ts +0 -480
  417. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/review-block.test.ts +0 -62
  418. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/sort-filter-bar/alpha-bar-tooltip.test.ts +0 -17
  419. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/sort-filter-bar/alpha-bar.test.ts +0 -101
  420. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/sort-filter-bar/sort-filter-bar.test.ts +0 -443
  421. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/text-overlay.test.ts +0 -55
  422. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/text-snippet-block.test.ts +0 -85
  423. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/tile-stats.test.ts +0 -191
  424. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/tiles/grid/account-tile.test.ts +0 -121
  425. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/tiles/grid/collection-tile.test.ts +0 -114
  426. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/tiles/grid/item-tile.test.ts +0 -520
  427. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/tiles/grid/search-tile.test.ts +0 -75
  428. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/tiles/hover/hover-pane-controller.test.ts +0 -482
  429. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/tiles/hover/tile-hover-pane.test.ts +0 -80
  430. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/tiles/list/tile-list-compact-header.test.ts +0 -43
  431. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/tiles/list/tile-list-compact.test.ts +0 -282
  432. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/tiles/list/tile-list.test.ts +0 -576
  433. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/tiles/tile-dispatcher.test.ts +0 -320
  434. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/tiles/tile-display-value-provider.test.ts +0 -172
  435. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/tiles/tile-mediatype-icon.test.ts +0 -160
  436. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/utils/array-equals.test.ts +0 -31
  437. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/utils/format-count.test.ts +0 -32
  438. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/utils/format-date.test.ts +0 -89
  439. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/utils/format-unit-size.test.ts +0 -21
  440. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/test/utils/local-date-from-utc.test.ts +0 -37
  441. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/tsconfig.json +0 -25
  442. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/types/dompurify.d.ts +0 -1
  443. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/vite.config.ts +0 -29
  444. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/web-dev-server.config.mjs +0 -30
  445. package/.claude/worktrees/WEBDEV-9127-fix-publish-dist-tag/web-test-runner.config.mjs +0 -52
  446. package/dist/src/collection-facets/more-facets-pagination.d.ts +0 -36
  447. package/dist/src/collection-facets/more-facets-pagination.js +0 -260
  448. package/dist/src/collection-facets/more-facets-pagination.js.map +0 -1
  449. package/dist/test/collection-facets/more-facets-pagination.test.d.ts +0 -1
  450. package/dist/test/collection-facets/more-facets-pagination.test.js +0 -126
  451. package/dist/test/collection-facets/more-facets-pagination.test.js.map +0 -1
  452. package/src/collection-facets/more-facets-pagination.ts +0 -294
  453. package/test/collection-facets/more-facets-pagination.test.ts +0 -201
@@ -1,1474 +0,0 @@
1
- import type { ReactiveControllerHost } from 'lit';
2
- import {
3
- AccountExtraInfo,
4
- Aggregation,
5
- Bucket,
6
- CollectionExtraInfo,
7
- FilterConstraint,
8
- FilterMap,
9
- FilterMapBuilder,
10
- PageElementMap,
11
- SearchParams,
12
- SearchResponseSessionContext,
13
- SearchResult,
14
- SearchType,
15
- } from '@internetarchive/search-service';
16
- import {
17
- prefixFilterAggregationKeys,
18
- type FacetBucket,
19
- type PrefixFilterType,
20
- TileModel,
21
- PrefixFilterCounts,
22
- RequestKind,
23
- SortField,
24
- SORT_OPTIONS,
25
- HitRequestSource,
26
- } from '../models';
27
- import {
28
- FACETLESS_PAGE_ELEMENTS,
29
- TVChannelMaps,
30
- type PageSpecifierParams,
31
- } from './models';
32
- import type { CollectionBrowserDataSourceInterface } from './collection-browser-data-source-interface';
33
- import type { CollectionBrowserSearchInterface } from './collection-browser-query-state';
34
- import { sha1 } from '../utils/sha1';
35
- import { mergeSelectedFacets } from '../utils/facet-utils';
36
- import { dateFilterField } from '../utils/date-filter-field';
37
-
38
- export class CollectionBrowserDataSource
39
- implements CollectionBrowserDataSourceInterface
40
- {
41
- /**
42
- * All pages of tile models that have been fetched so far, indexed by their page
43
- * number (with the first being page 1).
44
- */
45
- private pages: Record<string, TileModel[]> = {};
46
-
47
- /**
48
- * Tile offset to apply when looking up tiles in the pages, in order to maintain
49
- * page alignment after tiles are removed.
50
- */
51
- private offset = 0;
52
-
53
- /**
54
- * Total number of tile models stored in this data source's pages
55
- */
56
- private numTileModels = 0;
57
-
58
- /**
59
- * How many consecutive pages should be batched together on the initial page fetch.
60
- * Defaults to 2 pages.
61
- */
62
- private numInitialPages = 2;
63
-
64
- /**
65
- * A set of fetch IDs that are valid for the current query state
66
- */
67
- private fetchesInProgress = new Set<string>();
68
-
69
- /**
70
- * A record of the query key used for the last search.
71
- * If this changes, we need to load new results.
72
- */
73
- private previousQueryKey: string = '';
74
-
75
- /**
76
- * Whether the initial page of search results for the current query state
77
- * is presently being fetched.
78
- */
79
- private searchResultsLoading = false;
80
-
81
- /**
82
- * Whether the facets (aggregations) for the current query state are
83
- * presently being fetched.
84
- */
85
- private facetsLoading = false;
86
-
87
- /**
88
- * Whether the facets are actually visible -- if not, then we can delay any facet
89
- * fetches until they become visible.
90
- */
91
- private facetsReadyToLoad = false;
92
-
93
- /**
94
- * Whether further query changes should be ignored and not trigger fetches
95
- */
96
- private suppressFetches = false;
97
-
98
- /**
99
- * @inheritdoc
100
- */
101
- totalResults = 0;
102
-
103
- /**
104
- * @inheritdoc
105
- */
106
- endOfDataReached = false;
107
-
108
- /**
109
- * @inheritdoc
110
- */
111
- queryInitialized = false;
112
-
113
- /**
114
- * @inheritdoc
115
- */
116
- aggregations?: Record<string, Aggregation>;
117
-
118
- /**
119
- * @inheritdoc
120
- */
121
- histogramAggregation?: Aggregation;
122
-
123
- /**
124
- * @inheritdoc
125
- */
126
- collectionTitles = new Map<string, string>();
127
-
128
- /**
129
- * @inheritdoc
130
- */
131
- tvChannelMaps: TVChannelMaps = {};
132
-
133
- /**
134
- * @inheritdoc
135
- */
136
- tvChannelAliases = new Map<string, string>();
137
-
138
- /**
139
- * @inheritdoc
140
- */
141
- collectionExtraInfo?: CollectionExtraInfo;
142
-
143
- /**
144
- * @inheritdoc
145
- */
146
- accountExtraInfo?: AccountExtraInfo;
147
-
148
- /**
149
- * @inheritdoc
150
- */
151
- sessionContext?: SearchResponseSessionContext;
152
-
153
- /**
154
- * @inheritdoc
155
- */
156
- pageElements?: PageElementMap;
157
-
158
- /**
159
- * @inheritdoc
160
- */
161
- parentCollections?: string[] = [];
162
-
163
- /**
164
- * @inheritdoc
165
- */
166
- prefixFilterCountMap: Partial<Record<PrefixFilterType, PrefixFilterCounts>> =
167
- {};
168
-
169
- /**
170
- * @inheritdoc
171
- */
172
- queryErrorMessage?: string;
173
-
174
- /**
175
- * Internal property to store the promise for any current TV channel maps fetch.
176
- */
177
- private _tvMapsPromise?: Promise<TVChannelMaps>;
178
-
179
- /**
180
- * Internal property to store the private value backing the `initialSearchComplete` getter.
181
- */
182
- private _initialSearchCompletePromise: Promise<boolean> =
183
- Promise.resolve(true);
184
-
185
- /**
186
- * @inheritdoc
187
- */
188
- get initialSearchComplete(): Promise<boolean> {
189
- return this._initialSearchCompletePromise;
190
- }
191
-
192
- constructor(
193
- /** The host element to which this controller should attach listeners */
194
- private readonly host: ReactiveControllerHost &
195
- CollectionBrowserSearchInterface,
196
- /** Default size of result pages */
197
- private pageSize: number = 50,
198
- ) {
199
- // Just setting some property values
200
- }
201
-
202
- hostConnected(): void {
203
- this.setSearchResultsLoading(this.searchResultsLoading);
204
- this.setFacetsLoading(this.facetsLoading);
205
- }
206
-
207
- hostUpdate(): void {
208
- // This reactive controller hook is run whenever the host component (collection-browser) performs an update.
209
- // We check whether the host's state has changed in a way which should trigger a reset & new results fetch.
210
-
211
- // Only the currently-installed data source should react to the update
212
- if (!this.activeOnHost) return;
213
-
214
- // Copy loading states onto the host
215
- this.setSearchResultsLoading(this.searchResultsLoading);
216
- this.setFacetsLoading(this.facetsLoading);
217
-
218
- // Can't perform searches without a search service
219
- if (!this.host.searchService) return;
220
-
221
- // We should only reset if part of the full query state has changed
222
- const queryKeyChanged = this.pageFetchQueryKey !== this.previousQueryKey;
223
- if (!queryKeyChanged) return;
224
-
225
- // We should only reset if either:
226
- // (a) our state permits a valid search, or
227
- // (b) we have a blank query that we're showing a placeholder/message for
228
- const queryIsEmpty = !this.host.baseQuery;
229
- if (!(this.canPerformSearch || queryIsEmpty)) return;
230
-
231
- if (this.activeOnHost) this.host.emitQueryStateChanged();
232
- this.handleQueryChange();
233
- }
234
-
235
- /**
236
- * Returns whether this data source is the one currently installed on the host component.
237
- */
238
- private get activeOnHost(): boolean {
239
- return this.host.dataSource === this;
240
- }
241
-
242
- /**
243
- * @inheritdoc
244
- */
245
- get size(): number {
246
- return this.numTileModels;
247
- }
248
-
249
- /**
250
- * @inheritdoc
251
- */
252
- reset(): void {
253
- this.pages = {};
254
- this.aggregations = {};
255
- this.histogramAggregation = undefined;
256
- this.pageElements = undefined;
257
- this.parentCollections = [];
258
- this.previousQueryKey = '';
259
- this.queryErrorMessage = undefined;
260
-
261
- this.offset = 0;
262
- this.numTileModels = 0;
263
- this.endOfDataReached = false;
264
- this.queryInitialized = false;
265
- this.facetsLoading = false;
266
-
267
- // Invalidate any fetches in progress
268
- this.fetchesInProgress.clear();
269
-
270
- this.setTotalResultCount(0);
271
- this.requestHostUpdate();
272
- }
273
-
274
- /**
275
- * @inheritdoc
276
- */
277
- resetPages(): void {
278
- if (Object.keys(this.pages).length < this.host.maxPagesToManage) {
279
- this.pages = {};
280
-
281
- // Invalidate any page fetches in progress (keep facet fetches)
282
- this.fetchesInProgress.forEach(key => {
283
- if (!key.startsWith('facets-')) this.fetchesInProgress.delete(key);
284
- });
285
- this.requestHostUpdate();
286
- }
287
- }
288
-
289
- /**
290
- * @inheritdoc
291
- */
292
- addPage(pageNum: number, pageTiles: TileModel[]): void {
293
- this.pages[pageNum] = pageTiles;
294
- this.numTileModels += pageTiles.length;
295
- this.requestHostUpdate();
296
- }
297
-
298
- /**
299
- * @inheritdoc
300
- */
301
- addMultiplePages(firstPageNum: number, tiles: TileModel[]): void {
302
- const numPages = Math.ceil(tiles.length / this.pageSize);
303
- for (let i = 0; i < numPages; i += 1) {
304
- const pageStartIndex = this.pageSize * i;
305
- this.addPage(
306
- firstPageNum + i,
307
- tiles.slice(pageStartIndex, pageStartIndex + this.pageSize),
308
- );
309
- }
310
-
311
- const visiblePages = this.host.currentVisiblePageNumbers;
312
- const needsReload = visiblePages.some(
313
- page => page >= firstPageNum && page <= firstPageNum + numPages,
314
- );
315
- if (needsReload) {
316
- this.refreshVisibleResults();
317
- }
318
- }
319
-
320
- /**
321
- * @inheritdoc
322
- */
323
- getPage(pageNum: number): TileModel[] {
324
- return this.pages[pageNum];
325
- }
326
-
327
- /**
328
- * @inheritdoc
329
- */
330
- getAllPages(): Record<string, TileModel[]> {
331
- return this.pages;
332
- }
333
-
334
- /**
335
- * @inheritdoc
336
- */
337
- hasPage(pageNum: number): boolean {
338
- return !!this.pages[pageNum];
339
- }
340
-
341
- /**
342
- * @inheritdoc
343
- */
344
- getTileModelAt(index: number): TileModel | undefined {
345
- const offsetIndex = index + this.offset;
346
- const expectedPageNum = Math.floor(offsetIndex / this.pageSize) + 1;
347
- const expectedIndexOnPage = offsetIndex % this.pageSize;
348
-
349
- let page = 1;
350
- let tilesSeen = 0;
351
- while (tilesSeen <= offsetIndex) {
352
- if (!this.pages[page]) {
353
- // If we encounter a missing page, either we're past all the results or the page data is sparse.
354
- // So just return the tile at the expected position if it exists.
355
- return this.pages[expectedPageNum]?.[expectedIndexOnPage];
356
- }
357
-
358
- if (tilesSeen + this.pages[page].length > offsetIndex) {
359
- return this.pages[page][offsetIndex - tilesSeen];
360
- }
361
-
362
- tilesSeen += this.pages[page].length;
363
- page += 1;
364
- }
365
-
366
- return this.pages[expectedPageNum]?.[expectedIndexOnPage];
367
- }
368
-
369
- /**
370
- * @inheritdoc
371
- */
372
- indexOf(tile: TileModel): number {
373
- return Object.values(this.pages).flat().indexOf(tile) - this.offset;
374
- }
375
-
376
- /**
377
- * @inheritdoc
378
- */
379
- getPageSize(): number {
380
- return this.pageSize;
381
- }
382
-
383
- /**
384
- * @inheritdoc
385
- */
386
- setPageSize(pageSize: number): void {
387
- this.reset();
388
- this.pageSize = pageSize;
389
- }
390
-
391
- /**
392
- * @inheritdoc
393
- */
394
- setNumInitialPages(numPages: number): void {
395
- this.numInitialPages = numPages;
396
- }
397
-
398
- /**
399
- * @inheritdoc
400
- */
401
- setTotalResultCount(count: number): void {
402
- this.totalResults = count;
403
- if (this.activeOnHost) {
404
- this.host.setTotalResultCount(count);
405
- }
406
- }
407
-
408
- /**
409
- * @inheritdoc
410
- */
411
- setFetchesSuppressed(suppressed: boolean): void {
412
- this.suppressFetches = suppressed;
413
- }
414
-
415
- /**
416
- * @inheritdoc
417
- */
418
- setEndOfDataReached(reached: boolean): void {
419
- this.endOfDataReached = reached;
420
- }
421
-
422
- /**
423
- * @inheritdoc
424
- */
425
- async handleQueryChange(): Promise<void> {
426
- // Don't react to the change if fetches are suppressed for this data source
427
- if (this.suppressFetches) return;
428
-
429
- this.reset();
430
-
431
- // Reset the `initialSearchComplete` promise with a new value for the imminent search
432
- let initialSearchCompleteResolver: (value: boolean) => void;
433
- this._initialSearchCompletePromise = new Promise(res => {
434
- initialSearchCompleteResolver = res;
435
- });
436
-
437
- // Fire the initial page & facet requests
438
- this.queryInitialized = true;
439
- await Promise.all([
440
- this.doInitialPageFetch(),
441
- this.canFetchFacets ? this.fetchFacets() : null,
442
- ]);
443
-
444
- // Resolve the `initialSearchComplete` promise for this search
445
- initialSearchCompleteResolver!(true);
446
- }
447
-
448
- /**
449
- * @inheritdoc
450
- */
451
- async handleFacetReadinessChange(ready: boolean): Promise<void> {
452
- const facetsBecameReady = !this.facetsReadyToLoad && ready;
453
- this.facetsReadyToLoad = ready;
454
-
455
- const needsFetch = facetsBecameReady && this.canFetchFacets;
456
- if (needsFetch) {
457
- this.fetchFacets();
458
- }
459
- }
460
-
461
- /**
462
- * Whether the data source & its host are in a state where a facet request should be fired.
463
- * (i.e., they aren't suppressed or already loading, etc.)
464
- */
465
- private get canFetchFacets(): boolean {
466
- // Don't fetch facets if they are suppressed entirely or not required for the current profile page element
467
- if (this.host.facetLoadStrategy === 'off') return false;
468
- if (FACETLESS_PAGE_ELEMENTS.includes(this.host.profileElement!))
469
- return false;
470
-
471
- // If facets are to be lazy-loaded, don't fetch them if they are not going to be visible anyway
472
- // (wait until they become visible instead)
473
- if (this.host.facetLoadStrategy !== 'eager' && !this.facetsReadyToLoad)
474
- return false;
475
-
476
- // Don't fetch facets again if they are already fetched or pending
477
- const facetsAlreadyFetched =
478
- Object.keys(this.aggregations ?? {}).length > 0;
479
- if (this.facetsLoading || facetsAlreadyFetched) return false;
480
-
481
- return true;
482
- }
483
-
484
- /**
485
- * @inheritdoc
486
- */
487
- map(
488
- callback: (
489
- model: TileModel,
490
- index: number,
491
- array: TileModel[],
492
- ) => TileModel,
493
- ): void {
494
- if (!Object.keys(this.pages).length) return;
495
- this.pages = Object.fromEntries(
496
- Object.entries(this.pages).map(([page, tileModels]) => [
497
- page,
498
- tileModels.map((model, index, array) =>
499
- model ? callback(model, index, array) : model,
500
- ),
501
- ]),
502
- );
503
- this.requestHostUpdate();
504
- this.refreshVisibleResults();
505
- }
506
-
507
- /**
508
- * @inheritdoc
509
- */
510
- checkAllTiles = (): void => {
511
- this.map(model => {
512
- const cloned = model.clone();
513
- cloned.checked = true;
514
- return cloned;
515
- });
516
- };
517
-
518
- /**
519
- * @inheritdoc
520
- */
521
- uncheckAllTiles = (): void => {
522
- this.map(model => {
523
- const cloned = model.clone();
524
- cloned.checked = false;
525
- return cloned;
526
- });
527
- };
528
-
529
- /**
530
- * @inheritdoc
531
- */
532
- removeCheckedTiles = (): void => {
533
- // To make sure our data source remains page-aligned, we will offset our data source by
534
- // the number of removed tiles, so that we can just add the offset when the infinite
535
- // scroller queries for cell contents.
536
- // This only matters while we're still viewing the same set of results. If the user changes
537
- // their query/filters/sort, then the data source is overwritten and the offset cleared.
538
- const { checkedTileModels, uncheckedTileModels } = this;
539
- const numChecked = checkedTileModels.length;
540
- if (numChecked === 0) return;
541
- this.offset += numChecked;
542
- const newPages: typeof this.pages = {};
543
-
544
- // Which page the remaining tile models start on, post-offset
545
- let offsetPageNumber = Math.floor(this.offset / this.pageSize) + 1;
546
- let indexOnPage = this.offset % this.pageSize;
547
-
548
- // Fill the pages up to that point with empty models
549
- for (let page = 1; page <= offsetPageNumber; page += 1) {
550
- const remainingHidden = this.offset - this.pageSize * (page - 1);
551
- const offsetCellsOnPage = Math.min(this.pageSize, remainingHidden);
552
- newPages[page] = Array(offsetCellsOnPage).fill(undefined);
553
- }
554
-
555
- // Shift all the remaining tiles into their new positions in the data source
556
- for (const model of uncheckedTileModels) {
557
- if (!newPages[offsetPageNumber]) newPages[offsetPageNumber] = [];
558
- newPages[offsetPageNumber].push(model);
559
- indexOnPage += 1;
560
- if (indexOnPage >= this.pageSize) {
561
- offsetPageNumber += 1;
562
- indexOnPage = 0;
563
- }
564
- }
565
-
566
- // Swap in the new pages
567
- this.pages = newPages;
568
- this.numTileModels -= numChecked;
569
- this.totalResults -= numChecked;
570
- this.host.setTileCount(this.size);
571
- this.host.setTotalResultCount(this.totalResults);
572
- this.requestHostUpdate();
573
- this.refreshVisibleResults();
574
- };
575
-
576
- /**
577
- * @inheritdoc
578
- */
579
- get checkedTileModels(): TileModel[] {
580
- return this.getFilteredTileModels(model => model.checked);
581
- }
582
-
583
- /**
584
- * @inheritdoc
585
- */
586
- get uncheckedTileModels(): TileModel[] {
587
- return this.getFilteredTileModels(model => !model.checked);
588
- }
589
-
590
- /**
591
- * Returns a flattened, filtered array of all the tile models in the data source
592
- * for which the given predicate returns a truthy value.
593
- *
594
- * @param predicate A callback function to apply on each tile model, as with Array.filter
595
- * @returns A filtered array of tile models satisfying the predicate
596
- */
597
- private getFilteredTileModels(
598
- predicate: (model: TileModel, index: number, array: TileModel[]) => unknown,
599
- ): TileModel[] {
600
- return Object.values(this.pages)
601
- .flat()
602
- .filter((model, index, array) =>
603
- model ? predicate(model, index, array) : false,
604
- );
605
- }
606
-
607
- /**
608
- * Returns the search type to actually use for fetches.
609
- * When within a collection with an empty query and FTS selected,
610
- * falls back to metadata search since FTS requires a non-empty query
611
- * and we'd still like to show the unfiltered collection in that case.
612
- */
613
- private get effectiveSearchType(): SearchType {
614
- const trimmedQuery = this.host.baseQuery?.trim();
615
-
616
- const shouldUseMetadataSearch =
617
- !trimmedQuery &&
618
- this.host.withinCollection &&
619
- this.host.searchType === SearchType.FULLTEXT;
620
- if (shouldUseMetadataSearch) return SearchType.METADATA;
621
-
622
- return this.host.searchType;
623
- }
624
-
625
- /**
626
- * @inheritdoc
627
- */
628
- get canPerformSearch(): boolean {
629
- if (!this.host.searchService) return false;
630
-
631
- const trimmedQuery = this.host.baseQuery?.trim();
632
- const hasNonEmptyQuery = !!trimmedQuery;
633
- const hasIdentifiers = !!this.host.identifiers?.length;
634
- const isCollectionSearch = !!this.host.withinCollection;
635
- const isProfileSearch = !!this.host.withinProfile;
636
- const hasProfileElement = !!this.host.profileElement;
637
-
638
- const searchType = this.effectiveSearchType;
639
- const isDefaultedSearch = searchType === SearchType.DEFAULT;
640
- const isMetadataSearch = searchType === SearchType.METADATA;
641
- const isTvSearch = searchType === SearchType.TV;
642
-
643
- // Metadata/tv searches within a collection are allowed to have no query.
644
- const isValidForCollectionSearch =
645
- isDefaultedSearch || isMetadataSearch || isTvSearch;
646
-
647
- // Searches within a profile page may also be performed without a query, provided the profile element is set.
648
- const isValidForProfileSearch =
649
- hasProfileElement && (isDefaultedSearch || isMetadataSearch);
650
-
651
- // Otherwise, a non-empty query must be set.
652
- return (
653
- hasNonEmptyQuery ||
654
- hasIdentifiers ||
655
- (isCollectionSearch && isValidForCollectionSearch) ||
656
- (isProfileSearch && isValidForProfileSearch)
657
- );
658
- }
659
-
660
- /**
661
- * Sets the state for whether the initial set of search results for the
662
- * current query is loading
663
- */
664
- private setSearchResultsLoading(loading: boolean): void {
665
- this.searchResultsLoading = loading;
666
- if (this.activeOnHost) {
667
- this.host.setSearchResultsLoading(loading);
668
- }
669
- }
670
-
671
- /**
672
- * Sets the state for whether the facets for a query is loading
673
- */
674
- private setFacetsLoading(loading: boolean): void {
675
- this.facetsLoading = loading;
676
- if (this.activeOnHost) {
677
- this.host.setFacetsLoading(loading);
678
- }
679
- }
680
-
681
- /**
682
- * Requests that the host perform an update, provided this data
683
- * source is actively installed on it.
684
- */
685
- private requestHostUpdate(): void {
686
- if (this.activeOnHost) {
687
- this.host.requestUpdate();
688
- }
689
- }
690
-
691
- /**
692
- * Requests that the host refresh its visible tiles, provided this
693
- * data source is actively installed on it.
694
- */
695
- private refreshVisibleResults(): void {
696
- if (this.activeOnHost) {
697
- this.host.refreshVisibleResults();
698
- }
699
- }
700
-
701
- /**
702
- * The query key is a string that uniquely identifies the current search.
703
- * It consists of:
704
- * - The current base query
705
- * - The current collection/profile target & page element
706
- * - The current search type
707
- * - Any currently-applied facets
708
- * - Any currently-applied date range
709
- * - Any currently-applied prefix filters
710
- * - The current sort options
711
- *
712
- * This lets us internally keep track of queries so we don't persist data that's
713
- * no longer relevant. Not meant to be human-readable.
714
- */
715
- get pageFetchQueryKey(): string {
716
- const profileKey = `pf;${this.host.withinProfile}--pe;${this.host.profileElement}`;
717
- const pageTarget = this.host.withinCollection ?? profileKey;
718
- const sortField = this.host.selectedSort ?? 'none';
719
- const sortDirection = this.host.sortDirection ?? 'none';
720
- return `fq:${this.fullQuery}-pt:${pageTarget}-st:${this.effectiveSearchType}-sf:${sortField}-sd:${sortDirection}`;
721
- }
722
-
723
- /**
724
- * Similar to `pageFetchQueryKey` above, but excludes sort fields since they
725
- * are not relevant in determining aggregation queries.
726
- */
727
- get facetFetchQueryKey(): string {
728
- const profileKey = `pf;${this.host.withinProfile}--pe;${this.host.profileElement}`;
729
- const pageTarget = this.host.withinCollection ?? profileKey;
730
- return `facets-fq:${this.fullQuery}-pt:${pageTarget}-st:${this.effectiveSearchType}`;
731
- }
732
-
733
- /**
734
- * Constructs a search service FilterMap object from the combination of
735
- * all the currently-applied filters. This includes any facets, letter
736
- * filters, and date range.
737
- */
738
- get filterMap(): FilterMap {
739
- const builder = new FilterMapBuilder();
740
-
741
- const {
742
- minSelectedDate,
743
- maxSelectedDate,
744
- selectedFacets,
745
- internalFilters,
746
- selectedTitleFilter,
747
- selectedCreatorFilter,
748
- } = this.host;
749
-
750
- const dateField = dateFilterField(
751
- this.host.minSelectedDate,
752
- this.host.maxSelectedDate,
753
- );
754
-
755
- if (minSelectedDate) {
756
- builder.addFilter(
757
- dateField,
758
- minSelectedDate,
759
- FilterConstraint.GREATER_OR_EQUAL,
760
- );
761
- }
762
- if (maxSelectedDate) {
763
- builder.addFilter(
764
- dateField,
765
- maxSelectedDate,
766
- FilterConstraint.LESS_OR_EQUAL,
767
- );
768
- }
769
-
770
- // Add any selected facets and internal filters
771
- const combinedFilters = mergeSelectedFacets(
772
- internalFilters,
773
- selectedFacets,
774
- );
775
- if (combinedFilters) {
776
- for (const [facetName, facetValues] of Object.entries(combinedFilters)) {
777
- const { name, values } = this.prepareFacetForFetch(
778
- facetName,
779
- facetValues,
780
- );
781
- for (const [value, bucket] of Object.entries(values)) {
782
- let constraint;
783
- if (bucket.state === 'selected') {
784
- constraint = FilterConstraint.INCLUDE;
785
- } else if (bucket.state === 'hidden') {
786
- constraint = FilterConstraint.EXCLUDE;
787
- }
788
-
789
- if (constraint) {
790
- builder.addFilter(name, value, constraint);
791
- }
792
- }
793
- }
794
- }
795
-
796
- // Add any letter filters
797
- if (selectedTitleFilter) {
798
- builder.addFilter(
799
- 'firstTitle',
800
- selectedTitleFilter,
801
- FilterConstraint.INCLUDE,
802
- );
803
- }
804
- if (selectedCreatorFilter) {
805
- builder.addFilter(
806
- 'firstCreator',
807
- selectedCreatorFilter,
808
- FilterConstraint.INCLUDE,
809
- );
810
- }
811
-
812
- const filterMap = builder.build();
813
- return filterMap;
814
- }
815
-
816
- /**
817
- * Produces a compact unique ID for a search request that can help with debugging
818
- * on the backend by making related requests easier to trace through different services.
819
- * (e.g., tying the hits/aggregations requests for the same page back to a single hash).
820
- *
821
- * @param params The search service parameters for the request
822
- * @param kind The kind of request (hits-only, aggregations-only, or both)
823
- * @returns A Promise resolving to the uid to apply to the request
824
- */
825
- async requestUID(params: SearchParams, kind: RequestKind): Promise<string> {
826
- const paramsToHash = JSON.stringify({
827
- pageType: params.pageType,
828
- pageTarget: params.pageTarget,
829
- query: params.query,
830
- fields: params.fields,
831
- filters: params.filters,
832
- sort: params.sort,
833
- searchType: this.host.searchType,
834
- });
835
-
836
- const fullQueryHash = (await sha1(paramsToHash)).slice(0, 20); // First 80 bits of SHA-1 are plenty for this
837
- const sessionId = (await this.host.getSessionId()).slice(0, 20); // Likewise
838
- const page = params.page ?? 0;
839
- const kindPrefix = kind.charAt(0); // f = full, h = hits, a = aggregations
840
- const currentTime = Date.now();
841
-
842
- return `R:${fullQueryHash}-S:${sessionId}-P:${page}-K:${kindPrefix}-T:${currentTime}`;
843
- }
844
-
845
- /**
846
- * @inheritdoc
847
- */
848
- get pageSpecifierParams(): PageSpecifierParams | null {
849
- if (this.host.identifiers?.length) {
850
- return {
851
- pageType: 'client_document_fetch',
852
- };
853
- }
854
- if (this.host.withinCollection) {
855
- return {
856
- pageType: 'collection_details',
857
- pageTarget: this.host.withinCollection,
858
- };
859
- }
860
- if (this.host.withinProfile) {
861
- return {
862
- pageType: 'account_details',
863
- pageTarget: this.host.withinProfile,
864
- pageElements: this.host.profileElement
865
- ? [this.host.profileElement]
866
- : [],
867
- };
868
- }
869
- return null;
870
- }
871
-
872
- /**
873
- * The full query, including year facets and date range clauses
874
- */
875
- private get fullQuery(): string | undefined {
876
- const parts = [];
877
- const trimmedQuery = this.host.baseQuery?.trim();
878
- if (trimmedQuery) parts.push(trimmedQuery);
879
-
880
- if (this.host.identifiers) {
881
- parts.push(`identifier:(${this.host.identifiers.join(' OR ')})`);
882
- }
883
-
884
- const { facetQuery, dateRangeQueryClause, sortFilterQueries } = this;
885
- if (facetQuery) parts.push(facetQuery);
886
- if (dateRangeQueryClause) parts.push(dateRangeQueryClause);
887
- if (sortFilterQueries) parts.push(sortFilterQueries);
888
-
889
- return parts.join(' AND ').trim();
890
- }
891
-
892
- /**
893
- * Generates a query string representing the current set of applied facets
894
- *
895
- * Example: `mediatype:("collection" OR "audio" OR -"etree") AND year:("2000" OR "2001")`
896
- */
897
- private get facetQuery(): string | undefined {
898
- if (!this.host.selectedFacets) return undefined;
899
- const facetClauses = [];
900
- for (const [facetName, facetValues] of Object.entries(
901
- this.host.selectedFacets,
902
- )) {
903
- facetClauses.push(this.buildFacetClause(facetName, facetValues));
904
- }
905
- return this.joinFacetClauses(facetClauses)?.trim();
906
- }
907
-
908
- get dateRangeQueryClause(): string | undefined {
909
- if (!this.host.minSelectedDate || !this.host.maxSelectedDate) {
910
- return undefined;
911
- }
912
-
913
- const dateField = dateFilterField(
914
- this.host.minSelectedDate,
915
- this.host.maxSelectedDate,
916
- );
917
- return `${dateField}:[${this.host.minSelectedDate} TO ${this.host.maxSelectedDate}]`;
918
- }
919
-
920
- private get sortFilterQueries(): string {
921
- const queries = [this.titleQuery, this.creatorQuery];
922
- return queries.filter(q => q).join(' AND ');
923
- }
924
-
925
- /**
926
- * Returns a query clause identifying the currently selected title filter,
927
- * e.g., `firstTitle:X`.
928
- */
929
- private get titleQuery(): string | undefined {
930
- return this.host.selectedTitleFilter
931
- ? `firstTitle:${this.host.selectedTitleFilter}`
932
- : undefined;
933
- }
934
-
935
- /**
936
- * Returns a query clause identifying the currently selected creator filter,
937
- * e.g., `firstCreator:X`.
938
- */
939
- private get creatorQuery(): string | undefined {
940
- return this.host.selectedCreatorFilter
941
- ? `firstCreator:${this.host.selectedCreatorFilter}`
942
- : undefined;
943
- }
944
-
945
- /**
946
- * Builds an OR-joined facet clause for the given facet name and values.
947
- *
948
- * E.g., for name `subject` and values
949
- * `{ foo: { state: 'selected' }, bar: { state: 'hidden' } }`
950
- * this will produce the clause
951
- * `subject:("foo" OR -"bar")`.
952
- *
953
- * @param facetName The facet type (e.g., 'collection')
954
- * @param facetValues The facet buckets, mapped by their keys
955
- */
956
- private buildFacetClause(
957
- facetName: string,
958
- facetValues: Record<string, FacetBucket>,
959
- ): string {
960
- const { name: facetQueryName, values } = this.prepareFacetForFetch(
961
- facetName,
962
- facetValues,
963
- );
964
- const facetEntries = Object.entries(values);
965
- if (facetEntries.length === 0) return '';
966
-
967
- const facetValuesArray: string[] = [];
968
- for (const [key, facetData] of facetEntries) {
969
- const plusMinusPrefix = facetData.state === 'hidden' ? '-' : '';
970
- facetValuesArray.push(`${plusMinusPrefix}"${key}"`);
971
- }
972
-
973
- const valueQuery = facetValuesArray.join(` OR `);
974
- return `${facetQueryName}:(${valueQuery})`;
975
- }
976
-
977
- /**
978
- * Handles some special pre-request normalization steps for certain facet types
979
- * that require them.
980
- *
981
- * @param facetName The name of the facet type (e.g., 'language')
982
- * @param facetValues An array of values for that facet type
983
- */
984
- private prepareFacetForFetch(
985
- facetName: string,
986
- facetValues: Record<string, FacetBucket>,
987
- ): { name: string; values: Record<string, FacetBucket> } {
988
- // eslint-disable-next-line prefer-const
989
- let [normalizedName, normalizedValues] = [facetName, facetValues];
990
-
991
- // The full "search engine" name of the lending field is "lending___status"
992
- if (facetName === 'lending') {
993
- normalizedName = 'lending___status';
994
- }
995
-
996
- return {
997
- name: normalizedName,
998
- values: normalizedValues,
999
- };
1000
- }
1001
-
1002
- /**
1003
- * Takes an array of facet clauses, and combines them into a
1004
- * full AND-joined facet query string. Empty clauses are ignored.
1005
- */
1006
- private joinFacetClauses(facetClauses: string[]): string | undefined {
1007
- const nonEmptyFacetClauses = facetClauses.filter(
1008
- clause => clause.length > 0,
1009
- );
1010
- return nonEmptyFacetClauses.length > 0
1011
- ? `(${nonEmptyFacetClauses.join(' AND ')})`
1012
- : undefined;
1013
- }
1014
-
1015
- /**
1016
- * Fires a backend request to fetch a set of aggregations (representing UI facets) for
1017
- * the current search state.
1018
- */
1019
- private async fetchFacets(): Promise<void> {
1020
- const trimmedQuery = this.host.baseQuery?.trim();
1021
- if (!this.canPerformSearch) return;
1022
-
1023
- const { facetFetchQueryKey } = this;
1024
- if (this.fetchesInProgress.has(facetFetchQueryKey)) return;
1025
- this.fetchesInProgress.add(facetFetchQueryKey);
1026
-
1027
- this.setFacetsLoading(true);
1028
-
1029
- const sortParams = this.host.sortParam ? [this.host.sortParam] : [];
1030
- const params: SearchParams = {
1031
- ...this.pageSpecifierParams,
1032
- query: trimmedQuery || '',
1033
- identifiers: this.host.identifiers,
1034
- rows: 0,
1035
- filters: this.filterMap,
1036
- // Fetch a few extra buckets beyond the 6 we show, in case some get suppressed
1037
- aggregationsSize: 10,
1038
- // Note: we don't need an aggregations param to fetch the default aggregations from the PPS.
1039
- // The default aggregations for the search_results page type should be what we need here.
1040
- };
1041
- params.uid = await this.requestUID(
1042
- { ...params, sort: sortParams },
1043
- 'aggregations',
1044
- );
1045
-
1046
- const searchResponse = await this.host.searchService?.search(
1047
- params,
1048
- this.effectiveSearchType,
1049
- );
1050
- const success = searchResponse?.success;
1051
-
1052
- // This is checking to see if the query has changed since the data was fetched.
1053
- // If so, we just want to discard this set of aggregations because they are
1054
- // likely no longer valid for the newer query.
1055
- const queryChangedSinceFetch =
1056
- !this.fetchesInProgress.has(facetFetchQueryKey);
1057
- this.fetchesInProgress.delete(facetFetchQueryKey);
1058
- if (queryChangedSinceFetch) return;
1059
-
1060
- if (!success) {
1061
- const errorMsg = searchResponse?.error?.message;
1062
- const detailMsg = searchResponse?.error?.details?.message;
1063
-
1064
- if (!errorMsg && !detailMsg) {
1065
- // @ts-expect-error: Property 'Sentry' does not exist on type 'Window & typeof globalThis'
1066
- window?.Sentry?.captureMessage?.(
1067
- 'Missing or malformed facet response from backend',
1068
- 'error',
1069
- );
1070
- }
1071
-
1072
- this.setFacetsLoading(false);
1073
- return;
1074
- }
1075
-
1076
- const { aggregations, collectionTitles, tvChannelAliases } =
1077
- success.response;
1078
- this.aggregations = aggregations;
1079
-
1080
- const useDateHistogram =
1081
- this.host.searchType === SearchType.TV || this.host.isTVCollection;
1082
- this.histogramAggregation = useDateHistogram
1083
- ? (aggregations?.date_histogram ?? aggregations?.year_histogram)
1084
- : aggregations?.year_histogram;
1085
-
1086
- if (collectionTitles) {
1087
- for (const [id, title] of Object.entries(collectionTitles)) {
1088
- this.collectionTitles.set(id, title);
1089
- }
1090
- }
1091
- if (tvChannelAliases) {
1092
- for (const [channel, network] of Object.entries(tvChannelAliases)) {
1093
- this.tvChannelAliases.set(channel, network);
1094
- }
1095
- }
1096
-
1097
- this.setFacetsLoading(false);
1098
- this.requestHostUpdate();
1099
- }
1100
-
1101
- /**
1102
- * Performs the initial page fetch(es) for the current search state.
1103
- */
1104
- private async doInitialPageFetch(): Promise<void> {
1105
- this.setSearchResultsLoading(true);
1106
- // Try to batch 2 initial page requests when possible
1107
- await this.fetchPage(this.host.initialPageNumber, this.numInitialPages);
1108
- }
1109
-
1110
- /**
1111
- * Fetches one or more pages of results and updates the data source.
1112
- *
1113
- * @param pageNumber The page number to fetch
1114
- * @param numInitialPages If this is an initial page fetch (`pageNumber = 1`),
1115
- * specifies how many pages to batch together in one request. Ignored
1116
- * if `pageNumber != 1`, defaulting to a single page.
1117
- */
1118
- async fetchPage(pageNumber: number, numInitialPages = 1): Promise<void> {
1119
- const trimmedQuery = this.host.baseQuery?.trim();
1120
- // reset loading status
1121
- if (!this.canPerformSearch) {
1122
- this.setSearchResultsLoading(false);
1123
- return;
1124
- }
1125
-
1126
- // if we already have data, don't fetch again
1127
- if (this.hasPage(pageNumber)) return;
1128
-
1129
- if (this.endOfDataReached) return;
1130
-
1131
- // Batch multiple initial page requests together if needed (e.g., can request
1132
- // pages 1 and 2 together in a single request).
1133
- let numPages = pageNumber === 1 ? numInitialPages : 1;
1134
- const numRows = this.pageSize * numPages;
1135
-
1136
- // if a fetch is already in progress for this query and page, don't fetch again
1137
- const { pageFetchQueryKey } = this;
1138
- const currentPageKey = `${pageFetchQueryKey}-p:${pageNumber}`;
1139
- if (this.fetchesInProgress.has(currentPageKey)) return;
1140
-
1141
- for (let i = 0; i < numPages; i += 1) {
1142
- this.fetchesInProgress.add(`${pageFetchQueryKey}-p:${pageNumber + i}`);
1143
- }
1144
- this.previousQueryKey = pageFetchQueryKey;
1145
-
1146
- const { withinCollection, withinProfile } = this.host;
1147
-
1148
- let sortParams = this.host.sortParam ? [this.host.sortParam] : [];
1149
- // TODO eventually the PPS should handle these defaults natively
1150
- const isDefaultSort = this.host.selectedSort === SortField.default;
1151
- const isTVSearch = this.host.searchType === SearchType.TV;
1152
- const isDefaultTVSort = isTVSearch && isDefaultSort;
1153
- const isDefaultProfileSort = withinProfile && isDefaultSort;
1154
- if (
1155
- (isDefaultProfileSort || isDefaultTVSort) &&
1156
- this.host.defaultSortField
1157
- ) {
1158
- const sortOption = SORT_OPTIONS[this.host.defaultSortField];
1159
- const { searchServiceKey, handledBySearchService } = sortOption;
1160
- if (searchServiceKey && handledBySearchService) {
1161
- sortParams = [
1162
- {
1163
- field: searchServiceKey,
1164
- direction: this.host.defaultSortDirection ?? 'desc',
1165
- },
1166
- ];
1167
- }
1168
- }
1169
-
1170
- const params: SearchParams = {
1171
- ...this.pageSpecifierParams,
1172
- query: trimmedQuery || '',
1173
- identifiers: this.host.identifiers,
1174
- page: pageNumber,
1175
- rows: numRows,
1176
- sort: sortParams,
1177
- filters: this.filterMap,
1178
- aggregations: { omit: true },
1179
- };
1180
- params.uid = await this.requestUID(params, 'hits');
1181
-
1182
- // log('=== FIRING PAGE REQUEST ===', params);
1183
- const searchResponse = await this.host.searchService?.search(
1184
- params,
1185
- this.effectiveSearchType,
1186
- );
1187
- // log('=== RECEIVED PAGE RESPONSE IN CB ===', searchResponse);
1188
- const success = searchResponse?.success;
1189
-
1190
- // This is checking to see if the fetch has been invalidated since it was fired off.
1191
- // If so, we just want to discard the response since it is for an obsolete query state.
1192
- if (!this.fetchesInProgress.has(currentPageKey)) return;
1193
- for (let i = 0; i < numPages; i += 1) {
1194
- this.fetchesInProgress.delete(`${pageFetchQueryKey}-p:${pageNumber + i}`);
1195
- }
1196
-
1197
- if (!success) {
1198
- const errorMsg = searchResponse?.error?.message;
1199
- const detailMsg = searchResponse?.error?.details?.message;
1200
-
1201
- this.queryErrorMessage = `${errorMsg ?? ''}${
1202
- detailMsg ? `; ${detailMsg}` : ''
1203
- }`;
1204
-
1205
- if (!this.queryErrorMessage) {
1206
- this.queryErrorMessage = 'Missing or malformed response from backend';
1207
- // @ts-expect-error: Property 'Sentry' does not exist on type 'Window & typeof globalThis'
1208
- window?.Sentry?.captureMessage?.(this.queryErrorMessage, 'error');
1209
- }
1210
-
1211
- this.setSearchResultsLoading(false);
1212
- this.requestHostUpdate();
1213
- this.host.emitSearchError();
1214
- return;
1215
- }
1216
-
1217
- this.setTotalResultCount(success.response.totalResults - this.offset);
1218
- if (this.activeOnHost && this.totalResults === 0) {
1219
- // display event to offshoot when result count is zero.
1220
- this.host.emitEmptyResults();
1221
- }
1222
-
1223
- this.sessionContext = success.sessionContext;
1224
- if (withinCollection) {
1225
- this.collectionExtraInfo = success.response.collectionExtraInfo;
1226
-
1227
- // For collections, we want the UI to respect the default sort option
1228
- // which can be specified in metadata, or otherwise assumed to be week:desc
1229
- if (this.activeOnHost) {
1230
- this.host.applyDefaultCollectionSort(this.collectionExtraInfo);
1231
- }
1232
-
1233
- if (this.collectionExtraInfo) {
1234
- this.parentCollections = [].concat(
1235
- this.collectionExtraInfo.public_metadata?.collection ?? [],
1236
- );
1237
-
1238
- // Update the TV collection status now that we know the parent collections
1239
- this.host.isTVCollection =
1240
- this.host.withinCollection?.startsWith('TV-') ||
1241
- this.host.withinCollection === 'tvnews' ||
1242
- this.host.withinCollection === 'tvarchive' ||
1243
- this.parentCollections.includes('tvnews') ||
1244
- this.parentCollections.includes('tvarchive');
1245
- }
1246
- } else if (withinProfile) {
1247
- this.accountExtraInfo = success.response.accountExtraInfo;
1248
- this.pageElements = success.response.pageElements;
1249
- }
1250
-
1251
- const { results, collectionTitles, tvChannelAliases } = success.response;
1252
- if (results && results.length > 0) {
1253
- // Load any collection titles present on the response into the cache,
1254
- // or queue up preload fetches for them if none were present.
1255
- if (collectionTitles) {
1256
- for (const [id, title] of Object.entries(collectionTitles)) {
1257
- this.collectionTitles.set(id, title);
1258
- }
1259
-
1260
- // Also add the target collection's title if available
1261
- const targetTitle = this.collectionExtraInfo?.public_metadata?.title;
1262
- if (withinCollection && targetTitle) {
1263
- this.collectionTitles.set(withinCollection, targetTitle);
1264
- }
1265
- }
1266
-
1267
- if (tvChannelAliases) {
1268
- for (const [channel, network] of Object.entries(tvChannelAliases)) {
1269
- this.tvChannelAliases.set(channel, network);
1270
- }
1271
- }
1272
-
1273
- // Update the data source for each returned page.
1274
- // For loans and web archives, we must account for receiving more pages than we asked for.
1275
- const isUnpagedElement = ['lending', 'web_archives'].includes(
1276
- this.host.profileElement!,
1277
- );
1278
- if (isUnpagedElement) {
1279
- numPages = Math.ceil(results.length / this.pageSize);
1280
- this.endOfDataReached = true;
1281
- if (this.activeOnHost) this.host.setTileCount(this.totalResults);
1282
- }
1283
-
1284
- for (let i = 0; i < numPages; i += 1) {
1285
- const pageStartIndex = this.pageSize * i;
1286
- this.addFetchedResultsToDataSource(
1287
- pageNumber + i,
1288
- results.slice(pageStartIndex, pageStartIndex + this.pageSize),
1289
- !isUnpagedElement || i === numPages - 1,
1290
- );
1291
- }
1292
- }
1293
-
1294
- // When we reach the end of the data, we can set the infinite scroller's
1295
- // item count to the real total number of results (rather than the
1296
- // temporary estimates based on pages rendered so far).
1297
- if (this.size >= this.totalResults || results.length === 0) {
1298
- this.endOfDataReached = true;
1299
- if (this.activeOnHost) this.host.setTileCount(this.size);
1300
- }
1301
-
1302
- this.setSearchResultsLoading(false);
1303
- this.requestHostUpdate();
1304
- }
1305
-
1306
- /**
1307
- * Returns the type of request that produced the current set of hits,
1308
- * based on the presence of a search query or profile/collection target
1309
- * on the host.
1310
- */
1311
- private get hitRequestSource(): HitRequestSource {
1312
- const { host } = this;
1313
- if (host.baseQuery) return 'search_query';
1314
- if (host.withinProfile) return 'profile_tab';
1315
- if (host.withinCollection) return 'collection_members';
1316
- return 'unknown';
1317
- }
1318
-
1319
- /**
1320
- * Update the datasource from the fetch response
1321
- *
1322
- * @param pageNumber
1323
- * @param results
1324
- */
1325
- private addFetchedResultsToDataSource(
1326
- pageNumber: number,
1327
- results: SearchResult[],
1328
- needsReload = true,
1329
- ): void {
1330
- const tiles: TileModel[] = [];
1331
- const requestSource = this.hitRequestSource;
1332
- results?.forEach(result => {
1333
- if (!result.identifier) return;
1334
- tiles.push(new TileModel(result, requestSource));
1335
- });
1336
-
1337
- this.addPage(pageNumber, tiles);
1338
-
1339
- if (needsReload) {
1340
- this.refreshVisibleResults();
1341
- }
1342
- }
1343
-
1344
- /**
1345
- * Fetches the aggregation buckets for the given prefix filter type.
1346
- */
1347
- private async fetchPrefixFilterBuckets(
1348
- filterType: PrefixFilterType,
1349
- ): Promise<Bucket[]> {
1350
- const trimmedQuery = this.host.baseQuery?.trim();
1351
- if (!this.canPerformSearch) return [];
1352
-
1353
- const filterAggregationKey = prefixFilterAggregationKeys[filterType];
1354
- const sortParams = this.host.sortParam ? [this.host.sortParam] : [];
1355
-
1356
- const params: SearchParams = {
1357
- ...this.pageSpecifierParams,
1358
- query: trimmedQuery || '',
1359
- identifiers: this.host.identifiers,
1360
- rows: 0,
1361
- filters: this.filterMap,
1362
- // Only fetch the firstTitle or firstCreator aggregation
1363
- aggregations: { simpleParams: [filterAggregationKey] },
1364
- // Fetch all 26 letter buckets
1365
- aggregationsSize: 26,
1366
- };
1367
- params.uid = await this.requestUID(
1368
- { ...params, sort: sortParams },
1369
- 'aggregations',
1370
- );
1371
-
1372
- const searchResponse = await this.host.searchService?.search(
1373
- params,
1374
- this.effectiveSearchType,
1375
- );
1376
-
1377
- return (searchResponse?.success?.response?.aggregations?.[
1378
- filterAggregationKey
1379
- ]?.buckets ?? []) as Bucket[];
1380
- }
1381
-
1382
- /**
1383
- * Fetches and caches the prefix filter counts for the given filter type.
1384
- */
1385
- async updatePrefixFilterCounts(filterType: PrefixFilterType): Promise<void> {
1386
- const { facetFetchQueryKey } = this;
1387
- const buckets = await this.fetchPrefixFilterBuckets(filterType);
1388
-
1389
- // Don't update the filter counts for an outdated query (if it has been changed
1390
- // since we sent the request)
1391
- const queryChangedSinceFetch =
1392
- facetFetchQueryKey !== this.facetFetchQueryKey;
1393
- if (queryChangedSinceFetch) return;
1394
-
1395
- // Unpack the aggregation buckets into a simple map like { 'A': 50, 'B': 25, ... }
1396
- this.prefixFilterCountMap = { ...this.prefixFilterCountMap }; // Clone the object to trigger an update
1397
- this.prefixFilterCountMap[filterType] = buckets.reduce(
1398
- (acc: Record<string, number>, bucket: Bucket) => {
1399
- acc[(bucket.key as string).toUpperCase()] = bucket.doc_count;
1400
- return acc;
1401
- },
1402
- {},
1403
- );
1404
-
1405
- this.requestHostUpdate();
1406
- }
1407
-
1408
- /**
1409
- * @inheritdoc
1410
- */
1411
- async updatePrefixFiltersForCurrentSort(): Promise<void> {
1412
- if (['title', 'creator'].includes(this.host.selectedSort as SortField)) {
1413
- const filterType = this.host.selectedSort as PrefixFilterType;
1414
- if (!this.prefixFilterCountMap[filterType]) {
1415
- this.updatePrefixFilterCounts(filterType);
1416
- }
1417
- }
1418
- }
1419
-
1420
- /**
1421
- * @inheritdoc
1422
- */
1423
- refreshLetterCounts(): void {
1424
- if (Object.keys(this.prefixFilterCountMap).length > 0) {
1425
- this.prefixFilterCountMap = {};
1426
- }
1427
- this.updatePrefixFiltersForCurrentSort();
1428
- this.requestHostUpdate();
1429
- }
1430
-
1431
- /**
1432
- * @inheritdoc
1433
- */
1434
- populateTVChannelMaps(): Promise<TVChannelMaps> {
1435
- // To ensure that we only make these requests once, cache the Promise returned by the
1436
- // first call, and return the same Promise on repeated calls.
1437
- // Resolves once both maps have been retrieved and saved in the data source.
1438
- if (!this._tvMapsPromise) {
1439
- this._tvMapsPromise = this._fetchTVChannelMaps();
1440
- }
1441
-
1442
- return this._tvMapsPromise;
1443
- }
1444
-
1445
- /**
1446
- * Internal function implementing the actual fetches for TV channel mappings.
1447
- * This should only called by the public populateTVChannelMaps method, which is guarded so
1448
- * that we do not make extra requests for these rather large mappings.
1449
- */
1450
- private async _fetchTVChannelMaps(): Promise<TVChannelMaps> {
1451
- const baseURL = 'https://av.archive.org/etc';
1452
- const dateStr = new Date().toISOString().slice(0, 10); // YYYY-MM-DD
1453
- const chan2networkPromise = fetch(
1454
- `${baseURL}/chan2network.json?date=${dateStr}`,
1455
- );
1456
- const program2chansPromise = fetch(
1457
- `${baseURL}/program2chans.json?date=${dateStr}`,
1458
- );
1459
-
1460
- const [chan2networkResponse, program2chansResponse] = await Promise.all([
1461
- chan2networkPromise,
1462
- program2chansPromise,
1463
- ]);
1464
- this.tvChannelMaps.channelToNetwork = new Map(
1465
- Object.entries(await chan2networkResponse.json()),
1466
- );
1467
- this.tvChannelMaps.programToChannels = new Map(
1468
- Object.entries(await program2chansResponse.json()),
1469
- );
1470
-
1471
- this.requestHostUpdate();
1472
- return this.tvChannelMaps;
1473
- }
1474
- }