@internetarchive/collection-browser 3.4.1-alpha-webdev7761.4 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/.editorconfig +29 -29
  2. package/.github/workflows/ci.yml +27 -27
  3. package/.github/workflows/gh-pages-main.yml +39 -39
  4. package/.github/workflows/npm-publish.yml +39 -39
  5. package/.github/workflows/pr-preview.yml +38 -38
  6. package/.husky/pre-commit +4 -4
  7. package/.prettierignore +1 -1
  8. package/LICENSE +661 -661
  9. package/README.md +83 -83
  10. package/dist/src/app-root.js +28 -19
  11. package/dist/src/app-root.js.map +1 -1
  12. package/dist/src/collection-browser.d.ts +4 -24
  13. package/dist/src/collection-browser.js +125 -286
  14. package/dist/src/collection-browser.js.map +1 -1
  15. package/dist/src/collection-facets/facet-row.js +143 -143
  16. package/dist/src/collection-facets/facet-row.js.map +1 -1
  17. package/dist/src/collection-facets/more-facets-content.d.ts +1 -1
  18. package/dist/src/collection-facets/more-facets-content.js +48 -34
  19. package/dist/src/collection-facets/more-facets-content.js.map +1 -1
  20. package/dist/src/collection-facets/more-facets-pagination.js +10 -6
  21. package/dist/src/collection-facets/more-facets-pagination.js.map +1 -1
  22. package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.js +21 -16
  23. package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.js.map +1 -1
  24. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +10 -7
  25. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +1 -1
  26. package/dist/src/collection-facets/smart-facets/smart-facet-button.js +2 -3
  27. package/dist/src/collection-facets/smart-facets/smart-facet-button.js.map +1 -1
  28. package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js +11 -9
  29. package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js.map +1 -1
  30. package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.js +7 -7
  31. package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.js.map +1 -1
  32. package/dist/src/collection-facets/toggle-switch.js +6 -4
  33. package/dist/src/collection-facets/toggle-switch.js.map +1 -1
  34. package/dist/src/collection-facets.js +310 -309
  35. package/dist/src/collection-facets.js.map +1 -1
  36. package/dist/src/data-source/collection-browser-data-source-interface.d.ts +1 -10
  37. package/dist/src/data-source/collection-browser-data-source-interface.js.map +1 -1
  38. package/dist/src/data-source/collection-browser-data-source.d.ts +1 -19
  39. package/dist/src/data-source/collection-browser-data-source.js +65 -71
  40. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  41. package/dist/src/data-source/collection-browser-query-state.d.ts +2 -1
  42. package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
  43. package/dist/src/data-source/models.d.ts +0 -11
  44. package/dist/src/data-source/models.js.map +1 -1
  45. package/dist/src/empty-placeholder.js +18 -19
  46. package/dist/src/empty-placeholder.js.map +1 -1
  47. package/dist/src/expanded-date-picker.js +10 -6
  48. package/dist/src/expanded-date-picker.js.map +1 -1
  49. package/dist/src/language-code-handler/language-code-handler.js +2 -2
  50. package/dist/src/language-code-handler/language-code-handler.js.map +1 -1
  51. package/dist/src/manage/manage-bar.js +15 -9
  52. package/dist/src/manage/manage-bar.js.map +1 -1
  53. package/dist/src/manage/remove-items-modal-content.js +2 -2
  54. package/dist/src/manage/remove-items-modal-content.js.map +1 -1
  55. package/dist/src/models.d.ts +6 -2
  56. package/dist/src/models.js +54 -46
  57. package/dist/src/models.js.map +1 -1
  58. package/dist/src/restoration-state-handler.d.ts +2 -1
  59. package/dist/src/restoration-state-handler.js +19 -12
  60. package/dist/src/restoration-state-handler.js.map +1 -1
  61. package/dist/src/sort-filter-bar/alpha-bar.js +14 -9
  62. package/dist/src/sort-filter-bar/alpha-bar.js.map +1 -1
  63. package/dist/src/sort-filter-bar/sort-filter-bar.js +24 -14
  64. package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
  65. package/dist/src/tiles/base-tile-component.js +2 -1
  66. package/dist/src/tiles/base-tile-component.js.map +1 -1
  67. package/dist/src/tiles/grid/account-tile.js +7 -5
  68. package/dist/src/tiles/grid/account-tile.js.map +1 -1
  69. package/dist/src/tiles/grid/collection-tile.js +6 -3
  70. package/dist/src/tiles/grid/collection-tile.js.map +1 -1
  71. package/dist/src/tiles/grid/item-tile.js +33 -23
  72. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  73. package/dist/src/tiles/grid/search-tile.js +2 -1
  74. package/dist/src/tiles/grid/search-tile.js.map +1 -1
  75. package/dist/src/tiles/grid/tile-stats.js +3 -2
  76. package/dist/src/tiles/grid/tile-stats.js.map +1 -1
  77. package/dist/src/tiles/hover/hover-pane-controller.js +28 -21
  78. package/dist/src/tiles/hover/hover-pane-controller.js.map +1 -1
  79. package/dist/src/tiles/hover/tile-hover-pane.js +4 -3
  80. package/dist/src/tiles/hover/tile-hover-pane.js.map +1 -1
  81. package/dist/src/tiles/image-block.js +8 -5
  82. package/dist/src/tiles/image-block.js.map +1 -1
  83. package/dist/src/tiles/item-image.js +19 -12
  84. package/dist/src/tiles/item-image.js.map +1 -1
  85. package/dist/src/tiles/list/tile-list-compact.js +25 -17
  86. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  87. package/dist/src/tiles/list/tile-list.js +55 -34
  88. package/dist/src/tiles/list/tile-list.js.map +1 -1
  89. package/dist/src/tiles/overlay/icon-overlay.js +2 -1
  90. package/dist/src/tiles/overlay/icon-overlay.js.map +1 -1
  91. package/dist/src/tiles/overlay/text-overlay.js +4 -2
  92. package/dist/src/tiles/overlay/text-overlay.js.map +1 -1
  93. package/dist/src/tiles/text-snippet-block.js +4 -2
  94. package/dist/src/tiles/text-snippet-block.js.map +1 -1
  95. package/dist/src/tiles/tile-dispatcher.js +30 -22
  96. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  97. package/dist/src/tiles/tile-display-value-provider.js +9 -5
  98. package/dist/src/tiles/tile-display-value-provider.js.map +1 -1
  99. package/dist/src/tiles/tile-mediatype-icon.js +19 -12
  100. package/dist/src/tiles/tile-mediatype-icon.js.map +1 -1
  101. package/dist/src/utils/collapse-repeated-quotes.js +1 -1
  102. package/dist/src/utils/collapse-repeated-quotes.js.map +1 -1
  103. package/dist/src/utils/facet-utils.js +5 -3
  104. package/dist/src/utils/facet-utils.js.map +1 -1
  105. package/dist/src/utils/format-count.js +10 -10
  106. package/dist/src/utils/format-count.js.map +1 -1
  107. package/dist/src/utils/resolve-mediatype.js +3 -2
  108. package/dist/src/utils/resolve-mediatype.js.map +1 -1
  109. package/dist/test/collection-browser.test.js +380 -336
  110. package/dist/test/collection-browser.test.js.map +1 -1
  111. package/dist/test/collection-facets/facet-row.test.js +52 -37
  112. package/dist/test/collection-facets/facet-row.test.js.map +1 -1
  113. package/dist/test/collection-facets/facets-template.test.js +23 -17
  114. package/dist/test/collection-facets/facets-template.test.js.map +1 -1
  115. package/dist/test/collection-facets/more-facets-content.test.js +32 -22
  116. package/dist/test/collection-facets/more-facets-content.test.js.map +1 -1
  117. package/dist/test/collection-facets/more-facets-pagination.test.js +22 -16
  118. package/dist/test/collection-facets/more-facets-pagination.test.js.map +1 -1
  119. package/dist/test/collection-facets/toggle-switch.test.js +19 -22
  120. package/dist/test/collection-facets/toggle-switch.test.js.map +1 -1
  121. package/dist/test/collection-facets.test.js +77 -60
  122. package/dist/test/collection-facets.test.js.map +1 -1
  123. package/dist/test/empty-placeholder.test.js +17 -11
  124. package/dist/test/empty-placeholder.test.js.map +1 -1
  125. package/dist/test/expanded-date-picker.test.js +14 -8
  126. package/dist/test/expanded-date-picker.test.js.map +1 -1
  127. package/dist/test/icon-overlay.test.js +6 -7
  128. package/dist/test/icon-overlay.test.js.map +1 -1
  129. package/dist/test/image-block.test.js +26 -16
  130. package/dist/test/image-block.test.js.map +1 -1
  131. package/dist/test/item-image.test.js +32 -23
  132. package/dist/test/item-image.test.js.map +1 -1
  133. package/dist/test/manage/manage-bar.test.js +33 -21
  134. package/dist/test/manage/manage-bar.test.js.map +1 -1
  135. package/dist/test/manage/remove-items-modal-content.test.js +15 -10
  136. package/dist/test/manage/remove-items-modal-content.test.js.map +1 -1
  137. package/dist/test/mocks/mock-search-service.js +3 -2
  138. package/dist/test/mocks/mock-search-service.js.map +1 -1
  139. package/dist/test/restoration-state-handler.test.js +54 -14
  140. package/dist/test/restoration-state-handler.test.js.map +1 -1
  141. package/dist/test/review-block.test.js +18 -16
  142. package/dist/test/review-block.test.js.map +1 -1
  143. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js +3 -2
  144. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js.map +1 -1
  145. package/dist/test/sort-filter-bar/alpha-bar.test.js +24 -18
  146. package/dist/test/sort-filter-bar/alpha-bar.test.js.map +1 -1
  147. package/dist/test/sort-filter-bar/sort-filter-bar.test.js +180 -178
  148. package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +1 -1
  149. package/dist/test/text-overlay.test.js +15 -16
  150. package/dist/test/text-overlay.test.js.map +1 -1
  151. package/dist/test/text-snippet-block.test.js +19 -14
  152. package/dist/test/text-snippet-block.test.js.map +1 -1
  153. package/dist/test/tile-stats.test.js +34 -73
  154. package/dist/test/tile-stats.test.js.map +1 -1
  155. package/dist/test/tiles/grid/account-tile.test.js +25 -25
  156. package/dist/test/tiles/grid/account-tile.test.js.map +1 -1
  157. package/dist/test/tiles/grid/collection-tile.test.js +19 -13
  158. package/dist/test/tiles/grid/collection-tile.test.js.map +1 -1
  159. package/dist/test/tiles/grid/item-tile.test.js +91 -64
  160. package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
  161. package/dist/test/tiles/grid/search-tile.test.js +13 -9
  162. package/dist/test/tiles/grid/search-tile.test.js.map +1 -1
  163. package/dist/test/tiles/hover/hover-pane-controller.test.js +35 -23
  164. package/dist/test/tiles/hover/hover-pane-controller.test.js.map +1 -1
  165. package/dist/test/tiles/hover/tile-hover-pane.test.js +16 -12
  166. package/dist/test/tiles/hover/tile-hover-pane.test.js.map +1 -1
  167. package/dist/test/tiles/list/tile-list-compact.test.js +48 -34
  168. package/dist/test/tiles/list/tile-list-compact.test.js.map +1 -1
  169. package/dist/test/tiles/list/tile-list.test.js +105 -76
  170. package/dist/test/tiles/list/tile-list.test.js.map +1 -1
  171. package/dist/test/tiles/tile-dispatcher.test.js +30 -17
  172. package/dist/test/tiles/tile-dispatcher.test.js.map +1 -1
  173. package/dist/test/tiles/tile-mediatype-icon.test.js +24 -12
  174. package/dist/test/tiles/tile-mediatype-icon.test.js.map +1 -1
  175. package/eslint.config.mjs +53 -53
  176. package/index.html +24 -24
  177. package/local.archive.org.cert +86 -86
  178. package/local.archive.org.key +27 -27
  179. package/package.json +118 -120
  180. package/renovate.json +6 -6
  181. package/src/collection-browser.ts +15 -246
  182. package/src/collection-facets/facet-row.ts +296 -299
  183. package/src/collection-facets/more-facets-content.ts +8 -5
  184. package/src/collection-facets.ts +995 -1010
  185. package/src/data-source/collection-browser-data-source-interface.ts +333 -345
  186. package/src/data-source/collection-browser-data-source.ts +1401 -1441
  187. package/src/data-source/collection-browser-query-state.ts +65 -59
  188. package/src/data-source/models.ts +43 -56
  189. package/src/models.ts +870 -866
  190. package/src/restoration-state-handler.ts +544 -546
  191. package/test/collection-browser.test.ts +2403 -2413
  192. package/test/restoration-state-handler.test.ts +510 -480
  193. package/tsconfig.json +20 -25
  194. package/vite.config.ts +22 -29
  195. package/web-dev-server.config.mjs +30 -30
  196. package/web-test-runner.config.mjs +41 -41
  197. package/dist/src/combo-box/caret-closed.d.ts +0 -2
  198. package/dist/src/combo-box/caret-closed.js +0 -7
  199. package/dist/src/combo-box/caret-closed.js.map +0 -1
  200. package/dist/src/combo-box/caret-open.d.ts +0 -2
  201. package/dist/src/combo-box/caret-open.js +0 -7
  202. package/dist/src/combo-box/caret-open.js.map +0 -1
  203. package/dist/src/combo-box/clear.d.ts +0 -2
  204. package/dist/src/combo-box/clear.js +0 -11
  205. package/dist/src/combo-box/clear.js.map +0 -1
  206. package/dist/src/combo-box/ia-combo-box.d.ts +0 -422
  207. package/dist/src/combo-box/ia-combo-box.js +0 -1203
  208. package/dist/src/combo-box/ia-combo-box.js.map +0 -1
  209. package/dist/src/combo-box/models.d.ts +0 -75
  210. package/dist/src/combo-box/models.js +0 -40
  211. package/dist/src/combo-box/models.js.map +0 -1
  212. package/src/combo-box/caret-closed.ts +0 -7
  213. package/src/combo-box/caret-open.ts +0 -7
  214. package/src/combo-box/clear.ts +0 -11
  215. package/src/combo-box/ia-combo-box.ts +0 -1288
  216. package/src/combo-box/models.ts +0 -113
@@ -1,6 +1,6 @@
1
1
  import { FilterConstraint, FilterMapBuilder, SearchType, } from '@internetarchive/search-service';
2
2
  import { prefixFilterAggregationKeys, TileModel, SortField, SORT_OPTIONS, } from '../models';
3
- import { FACETLESS_PAGE_ELEMENTS, } from './models';
3
+ import { FACETLESS_PAGE_ELEMENTS } from './models';
4
4
  import { sha1 } from '../utils/sha1';
5
5
  import { log } from '../utils/log';
6
6
  import { mergeSelectedFacets } from '../utils/facet-utils';
@@ -81,10 +81,6 @@ export class CollectionBrowserDataSource {
81
81
  * @inheritdoc
82
82
  */
83
83
  this.collectionTitles = new Map();
84
- /**
85
- * @inheritdoc
86
- */
87
- this.tvChannelMaps = {};
88
84
  /**
89
85
  * @inheritdoc
90
86
  */
@@ -290,6 +286,7 @@ export class CollectionBrowserDataSource {
290
286
  * @inheritdoc
291
287
  */
292
288
  getTileModelAt(index) {
289
+ var _a, _b;
293
290
  const offsetIndex = index + this.offset;
294
291
  const expectedPageNum = Math.floor(offsetIndex / this.pageSize) + 1;
295
292
  const expectedIndexOnPage = offsetIndex % this.pageSize;
@@ -299,7 +296,7 @@ export class CollectionBrowserDataSource {
299
296
  if (!this.pages[page]) {
300
297
  // If we encounter a missing page, either we're past all the results or the page data is sparse.
301
298
  // So just return the tile at the expected position if it exists.
302
- return this.pages[expectedPageNum]?.[expectedIndexOnPage];
299
+ return (_a = this.pages[expectedPageNum]) === null || _a === void 0 ? void 0 : _a[expectedIndexOnPage];
303
300
  }
304
301
  if (tilesSeen + this.pages[page].length > offsetIndex) {
305
302
  return this.pages[page][offsetIndex - tilesSeen];
@@ -307,7 +304,7 @@ export class CollectionBrowserDataSource {
307
304
  tilesSeen += this.pages[page].length;
308
305
  page += 1;
309
306
  }
310
- return this.pages[expectedPageNum]?.[expectedIndexOnPage];
307
+ return (_b = this.pages[expectedPageNum]) === null || _b === void 0 ? void 0 : _b[expectedIndexOnPage];
311
308
  }
312
309
  /**
313
310
  * @inheritdoc
@@ -393,6 +390,7 @@ export class CollectionBrowserDataSource {
393
390
  * (i.e., they aren't suppressed or already loading, etc.)
394
391
  */
395
392
  get canFetchFacets() {
393
+ var _a;
396
394
  // Don't fetch facets if they are suppressed entirely or not required for the current profile page element
397
395
  if (this.host.facetLoadStrategy === 'off')
398
396
  return false;
@@ -403,7 +401,7 @@ export class CollectionBrowserDataSource {
403
401
  if (this.host.facetLoadStrategy !== 'eager' && !this.facetsReadyToLoad)
404
402
  return false;
405
403
  // Don't fetch facets again if they are already fetched or pending
406
- const facetsAlreadyFetched = Object.keys(this.aggregations ?? {}).length > 0;
404
+ const facetsAlreadyFetched = Object.keys((_a = this.aggregations) !== null && _a !== void 0 ? _a : {}).length > 0;
407
405
  if (this.facetsLoading || facetsAlreadyFetched)
408
406
  return false;
409
407
  return true;
@@ -449,11 +447,12 @@ export class CollectionBrowserDataSource {
449
447
  * @inheritdoc
450
448
  */
451
449
  get canPerformSearch() {
450
+ var _a, _b;
452
451
  if (!this.host.searchService)
453
452
  return false;
454
- const trimmedQuery = this.host.baseQuery?.trim();
453
+ const trimmedQuery = (_a = this.host.baseQuery) === null || _a === void 0 ? void 0 : _a.trim();
455
454
  const hasNonEmptyQuery = !!trimmedQuery;
456
- const hasIdentifiers = !!this.host.identifiers?.length;
455
+ const hasIdentifiers = !!((_b = this.host.identifiers) === null || _b === void 0 ? void 0 : _b.length);
457
456
  const isCollectionSearch = !!this.host.withinCollection;
458
457
  const isProfileSearch = !!this.host.withinProfile;
459
458
  const hasProfileElement = !!this.host.profileElement;
@@ -522,10 +521,11 @@ export class CollectionBrowserDataSource {
522
521
  * no longer relevant. Not meant to be human-readable.
523
522
  */
524
523
  get pageFetchQueryKey() {
524
+ var _a, _b, _c;
525
525
  const profileKey = `pf;${this.host.withinProfile}--pe;${this.host.profileElement}`;
526
- const pageTarget = this.host.withinCollection ?? profileKey;
527
- const sortField = this.host.selectedSort ?? 'none';
528
- const sortDirection = this.host.sortDirection ?? 'none';
526
+ const pageTarget = (_a = this.host.withinCollection) !== null && _a !== void 0 ? _a : profileKey;
527
+ const sortField = (_b = this.host.selectedSort) !== null && _b !== void 0 ? _b : 'none';
528
+ const sortDirection = (_c = this.host.sortDirection) !== null && _c !== void 0 ? _c : 'none';
529
529
  return `fq:${this.fullQuery}-pt:${pageTarget}-st:${this.host.searchType}-sf:${sortField}-sd:${sortDirection}`;
530
530
  }
531
531
  /**
@@ -533,8 +533,9 @@ export class CollectionBrowserDataSource {
533
533
  * are not relevant in determining aggregation queries.
534
534
  */
535
535
  get facetFetchQueryKey() {
536
+ var _a;
536
537
  const profileKey = `pf;${this.host.withinProfile}--pe;${this.host.profileElement}`;
537
- const pageTarget = this.host.withinCollection ?? profileKey;
538
+ const pageTarget = (_a = this.host.withinCollection) !== null && _a !== void 0 ? _a : profileKey;
538
539
  return `facets-fq:${this.fullQuery}-pt:${pageTarget}-st:${this.host.searchType}`;
539
540
  }
540
541
  /**
@@ -578,6 +579,23 @@ export class CollectionBrowserDataSource {
578
579
  if (selectedCreatorFilter) {
579
580
  builder.addFilter('firstCreator', selectedCreatorFilter, FilterConstraint.INCLUDE);
580
581
  }
582
+ // Add any TV clip type filter, if applicable
583
+ if (this.host.searchType === SearchType.TV) {
584
+ switch (this.host.tvClipFilter) {
585
+ case 'commercials':
586
+ builder.addFilter('ad_id', '*', FilterConstraint.INCLUDE);
587
+ break;
588
+ case 'factchecks':
589
+ builder.addFilter('factcheck', '*', FilterConstraint.INCLUDE);
590
+ break;
591
+ case 'quotes':
592
+ builder.addFilter('clip', '1', FilterConstraint.INCLUDE);
593
+ break;
594
+ case 'all':
595
+ default:
596
+ break;
597
+ }
598
+ }
581
599
  const filterMap = builder.build();
582
600
  return filterMap;
583
601
  }
@@ -591,6 +609,7 @@ export class CollectionBrowserDataSource {
591
609
  * @returns A Promise resolving to the uid to apply to the request
592
610
  */
593
611
  async requestUID(params, kind) {
612
+ var _a;
594
613
  const paramsToHash = JSON.stringify({
595
614
  pageType: params.pageType,
596
615
  pageTarget: params.pageTarget,
@@ -602,7 +621,7 @@ export class CollectionBrowserDataSource {
602
621
  });
603
622
  const fullQueryHash = (await sha1(paramsToHash)).slice(0, 20); // First 80 bits of SHA-1 are plenty for this
604
623
  const sessionId = (await this.host.getSessionId()).slice(0, 20); // Likewise
605
- const page = params.page ?? 0;
624
+ const page = (_a = params.page) !== null && _a !== void 0 ? _a : 0;
606
625
  const kindPrefix = kind.charAt(0); // f = full, h = hits, a = aggregations
607
626
  const currentTime = Date.now();
608
627
  return `R:${fullQueryHash}-S:${sessionId}-P:${page}-K:${kindPrefix}-T:${currentTime}`;
@@ -611,7 +630,8 @@ export class CollectionBrowserDataSource {
611
630
  * @inheritdoc
612
631
  */
613
632
  get pageSpecifierParams() {
614
- if (this.host.identifiers?.length) {
633
+ var _a;
634
+ if ((_a = this.host.identifiers) === null || _a === void 0 ? void 0 : _a.length) {
615
635
  return {
616
636
  pageType: 'client_document_fetch',
617
637
  };
@@ -637,8 +657,9 @@ export class CollectionBrowserDataSource {
637
657
  * The full query, including year facets and date range clauses
638
658
  */
639
659
  get fullQuery() {
660
+ var _a;
640
661
  const parts = [];
641
- const trimmedQuery = this.host.baseQuery?.trim();
662
+ const trimmedQuery = (_a = this.host.baseQuery) === null || _a === void 0 ? void 0 : _a.trim();
642
663
  if (trimmedQuery)
643
664
  parts.push(trimmedQuery);
644
665
  if (this.host.identifiers) {
@@ -659,13 +680,14 @@ export class CollectionBrowserDataSource {
659
680
  * Example: `mediatype:("collection" OR "audio" OR -"etree") AND year:("2000" OR "2001")`
660
681
  */
661
682
  get facetQuery() {
683
+ var _a;
662
684
  if (!this.host.selectedFacets)
663
685
  return undefined;
664
686
  const facetClauses = [];
665
687
  for (const [facetName, facetValues] of Object.entries(this.host.selectedFacets)) {
666
688
  facetClauses.push(this.buildFacetClause(facetName, facetValues));
667
689
  }
668
- return this.joinFacetClauses(facetClauses)?.trim();
690
+ return (_a = this.joinFacetClauses(facetClauses)) === null || _a === void 0 ? void 0 : _a.trim();
669
691
  }
670
692
  get dateRangeQueryClause() {
671
693
  if (!this.host.minSelectedDate || !this.host.maxSelectedDate) {
@@ -753,7 +775,8 @@ export class CollectionBrowserDataSource {
753
775
  * the current search state.
754
776
  */
755
777
  async fetchFacets() {
756
- const trimmedQuery = this.host.baseQuery?.trim();
778
+ var _a, _b, _c, _d, _e, _f, _g;
779
+ const trimmedQuery = (_a = this.host.baseQuery) === null || _a === void 0 ? void 0 : _a.trim();
757
780
  if (!this.canPerformSearch)
758
781
  return;
759
782
  const { facetFetchQueryKey } = this;
@@ -774,8 +797,8 @@ export class CollectionBrowserDataSource {
774
797
  // The default aggregations for the search_results page type should be what we need here.
775
798
  };
776
799
  params.uid = await this.requestUID({ ...params, sort: sortParams }, 'aggregations');
777
- const searchResponse = await this.host.searchService?.search(params, this.host.searchType);
778
- const success = searchResponse?.success;
800
+ const searchResponse = await ((_b = this.host.searchService) === null || _b === void 0 ? void 0 : _b.search(params, this.host.searchType));
801
+ const success = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.success;
779
802
  // This is checking to see if the query has changed since the data was fetched.
780
803
  // If so, we just want to discard this set of aggregations because they are
781
804
  // likely no longer valid for the newer query.
@@ -784,11 +807,11 @@ export class CollectionBrowserDataSource {
784
807
  if (queryChangedSinceFetch)
785
808
  return;
786
809
  if (!success) {
787
- const errorMsg = searchResponse?.error?.message;
788
- const detailMsg = searchResponse?.error?.details?.message;
810
+ const errorMsg = (_c = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.error) === null || _c === void 0 ? void 0 : _c.message;
811
+ const detailMsg = (_e = (_d = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.error) === null || _d === void 0 ? void 0 : _d.details) === null || _e === void 0 ? void 0 : _e.message;
789
812
  if (!errorMsg && !detailMsg) {
790
813
  // @ts-expect-error: Property 'Sentry' does not exist on type 'Window & typeof globalThis'
791
- window?.Sentry?.captureMessage?.('Missing or malformed facet response from backend', 'error');
814
+ (_g = (_f = window === null || window === void 0 ? void 0 : window.Sentry) === null || _f === void 0 ? void 0 : _f.captureMessage) === null || _g === void 0 ? void 0 : _g.call(_f, 'Missing or malformed facet response from backend', 'error');
792
815
  }
793
816
  this.setFacetsLoading(false);
794
817
  return;
@@ -797,8 +820,8 @@ export class CollectionBrowserDataSource {
797
820
  this.aggregations = aggregations;
798
821
  this.histogramAggregation =
799
822
  this.host.searchType === SearchType.TV
800
- ? aggregations?.date_histogram
801
- : aggregations?.year_histogram;
823
+ ? aggregations === null || aggregations === void 0 ? void 0 : aggregations.date_histogram
824
+ : aggregations === null || aggregations === void 0 ? void 0 : aggregations.year_histogram;
802
825
  if (collectionTitles) {
803
826
  for (const [id, title] of Object.entries(collectionTitles)) {
804
827
  this.collectionTitles.set(id, title);
@@ -829,7 +852,8 @@ export class CollectionBrowserDataSource {
829
852
  * if `pageNumber != 1`, defaulting to a single page.
830
853
  */
831
854
  async fetchPage(pageNumber, numInitialPages = 1) {
832
- const trimmedQuery = this.host.baseQuery?.trim();
855
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
856
+ const trimmedQuery = (_a = this.host.baseQuery) === null || _a === void 0 ? void 0 : _a.trim();
833
857
  // reset loading status
834
858
  if (!this.canPerformSearch) {
835
859
  this.setSearchResultsLoading(false);
@@ -880,9 +904,9 @@ export class CollectionBrowserDataSource {
880
904
  };
881
905
  params.uid = await this.requestUID(params, 'hits');
882
906
  // log('=== FIRING PAGE REQUEST ===', params);
883
- const searchResponse = await this.host.searchService?.search(params, this.host.searchType);
907
+ const searchResponse = await ((_b = this.host.searchService) === null || _b === void 0 ? void 0 : _b.search(params, this.host.searchType));
884
908
  // log('=== RECEIVED PAGE RESPONSE IN CB ===', searchResponse);
885
- const success = searchResponse?.success;
909
+ const success = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.success;
886
910
  // This is checking to see if the fetch has been invalidated since it was fired off.
887
911
  // If so, we just want to discard the response since it is for an obsolete query state.
888
912
  if (!this.fetchesInProgress.has(currentPageKey))
@@ -891,13 +915,13 @@ export class CollectionBrowserDataSource {
891
915
  this.fetchesInProgress.delete(`${pageFetchQueryKey}-p:${pageNumber + i}`);
892
916
  }
893
917
  if (!success) {
894
- const errorMsg = searchResponse?.error?.message;
895
- const detailMsg = searchResponse?.error?.details?.message;
896
- this.queryErrorMessage = `${errorMsg ?? ''}${detailMsg ? `; ${detailMsg}` : ''}`;
918
+ const errorMsg = (_c = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.error) === null || _c === void 0 ? void 0 : _c.message;
919
+ const detailMsg = (_e = (_d = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.error) === null || _d === void 0 ? void 0 : _d.details) === null || _e === void 0 ? void 0 : _e.message;
920
+ this.queryErrorMessage = `${errorMsg !== null && errorMsg !== void 0 ? errorMsg : ''}${detailMsg ? `; ${detailMsg}` : ''}`;
897
921
  if (!this.queryErrorMessage) {
898
922
  this.queryErrorMessage = 'Missing or malformed response from backend';
899
923
  // @ts-expect-error: Property 'Sentry' does not exist on type 'Window & typeof globalThis'
900
- window?.Sentry?.captureMessage?.(this.queryErrorMessage, 'error');
924
+ (_g = (_f = window === null || window === void 0 ? void 0 : window.Sentry) === null || _f === void 0 ? void 0 : _f.captureMessage) === null || _g === void 0 ? void 0 : _g.call(_f, this.queryErrorMessage, 'error');
901
925
  }
902
926
  this.setSearchResultsLoading(false);
903
927
  this.requestHostUpdate();
@@ -918,10 +942,10 @@ export class CollectionBrowserDataSource {
918
942
  this.host.applyDefaultCollectionSort(this.collectionExtraInfo);
919
943
  }
920
944
  if (this.collectionExtraInfo) {
921
- this.parentCollections = [].concat(this.collectionExtraInfo.public_metadata?.collection ?? []);
945
+ this.parentCollections = [].concat((_j = (_h = this.collectionExtraInfo.public_metadata) === null || _h === void 0 ? void 0 : _h.collection) !== null && _j !== void 0 ? _j : []);
922
946
  // Update the TV collection status now that we know the parent collections
923
947
  this.host.isTVCollection =
924
- this.host.withinCollection?.startsWith('TV-') ||
948
+ ((_k = this.host.withinCollection) === null || _k === void 0 ? void 0 : _k.startsWith('TV-')) ||
925
949
  this.host.withinCollection === 'tvnews' ||
926
950
  this.host.withinCollection === 'tvarchive' ||
927
951
  this.parentCollections.includes('tvnews') ||
@@ -941,7 +965,7 @@ export class CollectionBrowserDataSource {
941
965
  this.collectionTitles.set(id, title);
942
966
  }
943
967
  // Also add the target collection's title if available
944
- const targetTitle = this.collectionExtraInfo?.public_metadata?.title;
968
+ const targetTitle = (_m = (_l = this.collectionExtraInfo) === null || _l === void 0 ? void 0 : _l.public_metadata) === null || _m === void 0 ? void 0 : _m.title;
945
969
  if (withinCollection && targetTitle) {
946
970
  this.collectionTitles.set(withinCollection, targetTitle);
947
971
  }
@@ -1000,7 +1024,7 @@ export class CollectionBrowserDataSource {
1000
1024
  addFetchedResultsToDataSource(pageNumber, results, needsReload = true) {
1001
1025
  const tiles = [];
1002
1026
  const requestSource = this.hitRequestSource;
1003
- results?.forEach(result => {
1027
+ results === null || results === void 0 ? void 0 : results.forEach(result => {
1004
1028
  if (!result.identifier)
1005
1029
  return;
1006
1030
  tiles.push(new TileModel(result, requestSource));
@@ -1014,7 +1038,8 @@ export class CollectionBrowserDataSource {
1014
1038
  * Fetches the aggregation buckets for the given prefix filter type.
1015
1039
  */
1016
1040
  async fetchPrefixFilterBuckets(filterType) {
1017
- const trimmedQuery = this.host.baseQuery?.trim();
1041
+ var _a, _b, _c, _d, _e, _f, _g;
1042
+ const trimmedQuery = (_a = this.host.baseQuery) === null || _a === void 0 ? void 0 : _a.trim();
1018
1043
  if (!this.canPerformSearch)
1019
1044
  return [];
1020
1045
  const filterAggregationKey = prefixFilterAggregationKeys[filterType];
@@ -1031,8 +1056,8 @@ export class CollectionBrowserDataSource {
1031
1056
  aggregationsSize: 26,
1032
1057
  };
1033
1058
  params.uid = await this.requestUID({ ...params, sort: sortParams }, 'aggregations');
1034
- const searchResponse = await this.host.searchService?.search(params, this.host.searchType);
1035
- return (searchResponse?.success?.response?.aggregations?.[filterAggregationKey]?.buckets ?? []);
1059
+ const searchResponse = await ((_b = this.host.searchService) === null || _b === void 0 ? void 0 : _b.search(params, this.host.searchType));
1060
+ return ((_g = (_f = (_e = (_d = (_c = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.success) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.aggregations) === null || _e === void 0 ? void 0 : _e[filterAggregationKey]) === null || _f === void 0 ? void 0 : _f.buckets) !== null && _g !== void 0 ? _g : []);
1036
1061
  }
1037
1062
  /**
1038
1063
  * Fetches and caches the prefix filter counts for the given filter type.
@@ -1074,36 +1099,5 @@ export class CollectionBrowserDataSource {
1074
1099
  this.updatePrefixFiltersForCurrentSort();
1075
1100
  this.requestHostUpdate();
1076
1101
  }
1077
- /**
1078
- * @inheritdoc
1079
- */
1080
- populateTVChannelMaps() {
1081
- // To ensure that we only make these requests once, cache the Promise returned by the
1082
- // first call, and return the same Promise on repeated calls.
1083
- // Resolves once both maps have been retrieved and saved in the data source.
1084
- if (!this._tvMapsPromise) {
1085
- this._tvMapsPromise = this._fetchTVChannelMaps();
1086
- }
1087
- return this._tvMapsPromise;
1088
- }
1089
- /**
1090
- * Internal function implementing the actual fetches for TV channel mappings.
1091
- * This should only called by the public populateTVChannelMaps method, which is guarded so
1092
- * that we do not make extra requests for these rather large mappings.
1093
- */
1094
- async _fetchTVChannelMaps() {
1095
- const baseURL = 'https://av.archive.org/etc';
1096
- const dateStr = new Date().toISOString().slice(0, 10); // YYYY-MM-DD
1097
- const chan2networkPromise = fetch(`${baseURL}/chan2network.json?date=${dateStr}`);
1098
- const program2chansPromise = fetch(`${baseURL}/program2chans.json?date=${dateStr}`);
1099
- const [chan2networkResponse, program2chansResponse] = await Promise.all([
1100
- chan2networkPromise,
1101
- program2chansPromise,
1102
- ]);
1103
- this.tvChannelMaps.channelToNetwork = new Map(Object.entries(await chan2networkResponse.json()));
1104
- this.tvChannelMaps.programToChannels = new Map(Object.entries(await program2chansResponse.json()));
1105
- this.requestHostUpdate();
1106
- return this.tvChannelMaps;
1107
- }
1108
1102
  }
1109
1103
  //# sourceMappingURL=collection-browser-data-source.js.map