@uvalib/web-components 1.1.1 → 1.2.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 (111) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +515 -47
  3. package/dist/base/url-param.d.ts +23 -0
  4. package/dist/base/url-param.js +49 -0
  5. package/dist/base/url-param.js.map +1 -0
  6. package/dist/base.css +289 -1
  7. package/dist/components/uvalib-card/UvalibCard.d.ts +19 -5
  8. package/dist/components/uvalib-card/UvalibCard.js +112 -9
  9. package/dist/components/uvalib-card/UvalibCard.js.map +1 -1
  10. package/dist/components/uvalib-chip-group/UvalibChipGroup.d.ts +156 -0
  11. package/dist/components/uvalib-chip-group/UvalibChipGroup.js +747 -0
  12. package/dist/components/uvalib-chip-group/UvalibChipGroup.js.map +1 -0
  13. package/dist/components/uvalib-chip-group/uvalib-chip-group.d.ts +1 -0
  14. package/dist/components/uvalib-chip-group/uvalib-chip-group.js +4 -0
  15. package/dist/components/uvalib-chip-group/uvalib-chip-group.js.map +1 -0
  16. package/dist/components/uvalib-date-histogram/UvalibDateHistogram.d.ts +148 -0
  17. package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js +1248 -0
  18. package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js.map +1 -0
  19. package/dist/components/uvalib-date-histogram/uvalib-date-histogram.d.ts +1 -0
  20. package/dist/components/uvalib-date-histogram/uvalib-date-histogram.js +4 -0
  21. package/dist/components/uvalib-date-histogram/uvalib-date-histogram.js.map +1 -0
  22. package/dist/components/uvalib-lightbox/UvalibLightbox.js +8 -1
  23. package/dist/components/uvalib-lightbox/UvalibLightbox.js.map +1 -1
  24. package/dist/components/uvalib-lightbox/media.d.ts +1 -18
  25. package/dist/components/uvalib-lightbox/media.js +1 -42
  26. package/dist/components/uvalib-lightbox/media.js.map +1 -1
  27. package/dist/components/uvalib-pager/UvalibPager.d.ts +58 -4
  28. package/dist/components/uvalib-pager/UvalibPager.js +232 -8
  29. package/dist/components/uvalib-pager/UvalibPager.js.map +1 -1
  30. package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.d.ts +27 -1
  31. package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js +192 -26
  32. package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js.map +1 -1
  33. package/dist/components/uvalib-results-count/UvalibResultsCount.d.ts +62 -0
  34. package/dist/components/uvalib-results-count/UvalibResultsCount.js +208 -0
  35. package/dist/components/uvalib-results-count/UvalibResultsCount.js.map +1 -0
  36. package/dist/components/uvalib-results-count/uvalib-results-count.d.ts +1 -0
  37. package/dist/components/uvalib-results-count/uvalib-results-count.js +4 -0
  38. package/dist/components/uvalib-results-count/uvalib-results-count.js.map +1 -0
  39. package/dist/components/uvalib-tabs/UvalibTabs.d.ts +127 -0
  40. package/dist/components/uvalib-tabs/UvalibTabs.js +821 -0
  41. package/dist/components/uvalib-tabs/UvalibTabs.js.map +1 -0
  42. package/dist/components/uvalib-tabs/uvalib-tabs.d.ts +1 -0
  43. package/dist/components/uvalib-tabs/uvalib-tabs.js +4 -0
  44. package/dist/components/uvalib-tabs/uvalib-tabs.js.map +1 -0
  45. package/dist/components/uvalib-tag-list/UvalibTagList.d.ts +89 -0
  46. package/dist/components/uvalib-tag-list/UvalibTagList.js +411 -0
  47. package/dist/components/uvalib-tag-list/UvalibTagList.js.map +1 -0
  48. package/dist/components/uvalib-tag-list/uvalib-tag-list.d.ts +1 -0
  49. package/dist/components/uvalib-tag-list/uvalib-tag-list.js +4 -0
  50. package/dist/components/uvalib-tag-list/uvalib-tag-list.js.map +1 -0
  51. package/dist/custom-elements.json +7140 -2630
  52. package/dist/index.d.ts +8 -0
  53. package/dist/index.js +5 -0
  54. package/dist/index.js.map +1 -1
  55. package/dist/styles/base.js +35 -1
  56. package/dist/styles/base.js.map +1 -1
  57. package/dist/styles/color-scheme.js +4 -0
  58. package/dist/styles/color-scheme.js.map +1 -1
  59. package/dist/styles/controls.js +2 -0
  60. package/dist/styles/controls.js.map +1 -1
  61. package/dist/styles/results.d.ts +1 -0
  62. package/dist/styles/results.js +257 -0
  63. package/dist/styles/results.js.map +1 -0
  64. package/dist/tokens.css +4 -0
  65. package/dist-cdn/base.css +289 -1
  66. package/dist-cdn/chunks/{base-CAFQWnZG.js → base-p5pk0vb2.js} +36 -2
  67. package/dist-cdn/chunks/{base-CAFQWnZG.js.map → base-p5pk0vb2.js.map} +1 -1
  68. package/dist-cdn/chunks/inline-copy-BANQSMIR.js +69 -0
  69. package/dist-cdn/chunks/inline-copy-BANQSMIR.js.map +1 -0
  70. package/dist-cdn/chunks/{site-header-C9V7Wuw2.js → site-header-BlOYvQg1.js} +5 -1
  71. package/dist-cdn/chunks/site-header-BlOYvQg1.js.map +1 -0
  72. package/dist-cdn/chunks/source-children-BHsDwCvL.js +53 -0
  73. package/dist-cdn/chunks/source-children-BHsDwCvL.js.map +1 -0
  74. package/dist-cdn/chunks/url-param-C1sk_F1d.js +28 -0
  75. package/dist-cdn/chunks/url-param-C1sk_F1d.js.map +1 -0
  76. package/dist-cdn/custom-elements.json +7140 -2630
  77. package/dist-cdn/manifest.json +7 -2
  78. package/dist-cdn/site-header.js +1 -1
  79. package/dist-cdn/site-page.js +2 -2
  80. package/dist-cdn/site-style.js +1 -1
  81. package/dist-cdn/skills/uvalib-web-components/SKILL.md +179 -19
  82. package/dist-cdn/skills/uvalib-web-components/reference/components.md +220 -6
  83. package/dist-cdn/tokens.css +4 -0
  84. package/dist-cdn/uvalib-card.js +94 -20
  85. package/dist-cdn/uvalib-card.js.map +1 -1
  86. package/dist-cdn/uvalib-chip-group.js +496 -0
  87. package/dist-cdn/uvalib-chip-group.js.map +1 -0
  88. package/dist-cdn/uvalib-contents.js +2 -1
  89. package/dist-cdn/uvalib-contents.js.map +1 -1
  90. package/dist-cdn/uvalib-date-histogram.js +850 -0
  91. package/dist-cdn/uvalib-date-histogram.js.map +1 -0
  92. package/dist-cdn/uvalib-lightbox.js +26 -48
  93. package/dist-cdn/uvalib-lightbox.js.map +1 -1
  94. package/dist-cdn/uvalib-metadata.js +2 -1
  95. package/dist-cdn/uvalib-metadata.js.map +1 -1
  96. package/dist-cdn/uvalib-pager.js +141 -7
  97. package/dist-cdn/uvalib-pager.js.map +1 -1
  98. package/dist-cdn/uvalib-photo-grid.js +121 -19
  99. package/dist-cdn/uvalib-photo-grid.js.map +1 -1
  100. package/dist-cdn/uvalib-results-count.js +101 -0
  101. package/dist-cdn/uvalib-results-count.js.map +1 -0
  102. package/dist-cdn/uvalib-tabs.js +436 -0
  103. package/dist-cdn/uvalib-tabs.js.map +1 -0
  104. package/dist-cdn/uvalib-tag-list.js +267 -0
  105. package/dist-cdn/uvalib-tag-list.js.map +1 -0
  106. package/package.json +24 -3
  107. package/skills/uvalib-web-components/SKILL.md +179 -19
  108. package/skills/uvalib-web-components/reference/components.md +220 -6
  109. package/dist-cdn/chunks/site-header-C9V7Wuw2.js.map +0 -1
  110. package/dist-cdn/chunks/source-children-RuAec527.js +0 -119
  111. package/dist-cdn/chunks/source-children-RuAec527.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"site-header-BlOYvQg1.js","names":["unsafeCSS","nothing","ifDefined","_decorate","property","state","n","i","r$1","b","define","__decorate","r","installLightDomStyles","UvalibElement","o","normalizeItems","readItemsMarkup","SiteMainNav","trackEvent","siteLink","accessible","dark","preFooterLinks","colorScheme","COLOR_SCHEME_STORAGE_KEY","COLOR_SCHEME_ATTR","CHANGE","DARK_QUERY","memory","asPreference","v","colorSchemeSupported","css","doc","readPreference","kept","systemIsDark","resolvePreference","pref","applyPreference","html","inline","clearPreference","setPreference","storage","installColorSchemeStyles","owners","ownersOf","set","FORCED_QUERY","rootColorScheme","attr","ColorSchemeController","host","enabled","renders","supported","root","next","changed","k","update","level","forced","ACCOUNT_URL","TAG","FULL_LINKS","VENDOR_LINKS","l","menuCounter","schemeCounter","DARK_LOGO_URL","SCHEME_OPTIONS","SITE_LINKS","isSiteLinksChild","MAIN_NAV","isMainNavChild","ALERTS","isAlertsChild","LINK_ATTRS","stopEvent","SiteHeader","path","a","link","menu","popover","brand","header","row","edge","items","top","crowded","li","was","keep","holder","logo","name","input","hint","systemDark","where","preference","A","sources","moved","raw","s","result","incoming","ref","invalid","el","text","content","vendor","id","anchor","mainNav","mainNavEl","label","own","classic","classicHidden","accordion","withMainNav","withMainNavHidden","end","hidden","registered"],"sources":["../../src/styles/color-scheme.ts","../../src/base/color-scheme.ts","../../src/components/site-header/SiteHeader.ts","../../src/components/site-header/site-header.ts"],"sourcesContent":["import { css, unsafeCSS } from 'lit';\n\n// Hand-written (not generated): the opt-in dark mode. Nothing here applies until the page's\n// root element has `data-uva-color-scheme` (set by `color-scheme-switch` or the documented\n// inline snippet), and only in browsers with light-dark(); everywhere else the role tokens are\n// undefined and every component falls back to its palette token or hex value, exactly as\n// before. The palette tokens in tokens.ts are untouched.\n//\n// Role tokens are light-dark() pairs; the light half reads the palette token, so a host's\n// own `:root { --uva-brand-*: … }` still applies in light mode. They are resolved where they\n// are used, against that element's `color-scheme`, which every component sets from\n// `--uva-color-scheme` (default `light`). Tokens with no single light value (the decorative\n// border) are set in dark only.\n\n/** Dark values for properties that have no one light value: each reader keeps its own. */\nconst darkOnly = `\n --uva-color-border: #7a84a0;\n`;\n\nconst dark = unsafeCSS(darkOnly);\n\n/**\n * Links in the pre-footer band are the site's own content: unstyled ones would keep the\n * browser's dark link colours (#9e9eff is 3.37:1 on the band). White is 8.05:1, visited too.\n * Layered like the rest of this sheet, so a site's own link colours still win.\n */\nconst preFooterLinks = 'color: var(--uva-color-pre-footer-text, #ffffff);';\n\nexport const colorScheme = css`\n @supports (color: light-dark(#000, #fff)) {\n :root[data-uva-color-scheme] {\n --uva-color-surface: light-dark(#ffffff, #10172b);\n --uva-color-surface-raised: light-dark(#ffffff, #232d4b);\n --uva-color-surface-hover: light-dark(var(--uva-grey-100, #dadada), #2c3858);\n --uva-color-text: light-dark(var(--uva-grey-darkest, #2b2b2b), #e8e8e8);\n --uva-color-text-muted: light-dark(#4b5563, #adadad);\n --uva-color-link: light-dark(var(--uva-brand-blue, #232d4b), #87b9d9);\n --uva-color-utility-link: light-dark(var(--uva-blue-alt-dark, #005679), #91d8f2);\n --uva-color-focus: light-dark(var(--uva-brand-orange, #e57200), #ffb370);\n --uva-color-current: light-dark(var(--uva-brand-orange, #e57200), #e57200);\n --uva-color-accent-bg: light-dark(var(--uva-brand-blue, #232d4b), #87b9d9);\n --uva-color-on-accent: light-dark(#ffffff, #10172b);\n --uva-color-control-border: light-dark(var(--uva-grey, #808080), #7a84a0);\n --uva-color-input-text: light-dark(#1f2937, #e8e8e8);\n --uva-color-track: light-dark(#e5e7eb, #2c3858);\n --uva-color-shadow: light-dark(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.6));\n --uva-color-pre-footer-bg: light-dark(var(--uva-blue-alt-300, #bfe7f7), #005679);\n --uva-color-pre-footer-text: light-dark(var(--uva-grey-darkest, #2b2b2b), #ffffff);\n /* base.css's .uvalib-button family: library.virginia.edu's blue-alt button, and a\n light-blue one on the dark surface (dark text 8.9:1). */\n --uva-color-button-bg: light-dark(var(--uva-blue-alt, #007bac), #55c4ec);\n --uva-color-button-text: light-dark(#ffffff, #10172b);\n --uva-color-button-hover-bg: light-dark(var(--uva-blue-alt-A, #005679), #91d8f2);\n --uva-color-button-subtle-bg: light-dark(var(--uva-blue-alt-300, #bfe7f7), #0d3247);\n --uva-color-button-subtle-hover-bg: light-dark(var(--uva-blue-alt-200, #91d8f2), #134a66);\n /* <site-alerts>: library.virginia.edu's alert colours, and a muted dark palette. Text\n is 7:1 or more (WCAG AAA) on every alert background in both schemes. */\n --uva-color-alert-text: light-dark(var(--uva-grey-darkest, #2b2b2b), #e8e8e8);\n --uva-color-alert-link: light-dark(var(--uva-blue-alt-B, #141e3c), #ffffff);\n --uva-color-alert-header-bg: light-dark(var(--uva-teal, #25cad3), #0e4a57);\n --uva-color-alert-header-text: light-dark(#000000, #e8e8e8);\n --uva-color-alert-critical-bg: light-dark(var(--uva-red-100, #fbcfda), #4a1622);\n --uva-color-alert-critical-border: light-dark(var(--uva-red-B, #b30000), #ef3f6b);\n --uva-color-alert-warning-bg: light-dark(var(--uva-yellow-100, #fef6c8), #3d3510);\n --uva-color-alert-warning-border: light-dark(var(--uva-yellow, #ecc602), #ecc602);\n --uva-color-alert-info-bg: light-dark(var(--uva-blue-alt-300, #bfe7f7), #0d3247);\n --uva-color-alert-info-border: light-dark(var(--uva-blue-alt, #007bac), #55c4ec);\n --uva-color-alert-regional-bg: light-dark(var(--uva-yellow-100, #fef6c8), #3d3510);\n --uva-color-alert-regional-border: light-dark(var(--uva-yellow, #ecc602), #ecc602);\n --uva-color-alert-regional-info-bg: light-dark(var(--uva-teal-200, #c8f2f4), #0f3a3d);\n --uva-color-alert-regional-info-border: light-dark(var(--uva-teal, #25cad3), #25cad3);\n /* base.css's success badge (.uvalib-badge--success), beside the alert colours the other\n status badges read: text (--uva-color-alert-text) is 7:1 or more in both schemes. */\n --uva-color-status-success-bg: light-dark(var(--uva-green-200, #ddefdc), #173d1c);\n --uva-color-status-success-border: light-dark(var(--uva-green-A, #4e9737), #62bb46);\n }\n :root[data-uva-color-scheme='system'] {\n color-scheme: light dark;\n --uva-color-scheme: light dark;\n }\n :root[data-uva-color-scheme='light'] {\n color-scheme: light;\n --uva-color-scheme: light;\n }\n :root[data-uva-color-scheme='dark'] {\n color-scheme: dark;\n --uva-color-scheme: dark;\n ${dark}\n }\n :root[data-uva-color-scheme='dark'] [slot='pre-footer'] a {\n ${unsafeCSS(preFooterLinks)}\n }\n @media (prefers-color-scheme: dark) {\n :root[data-uva-color-scheme='system'] {\n ${dark}\n }\n :root[data-uva-color-scheme='system'] [slot='pre-footer'] a {\n ${unsafeCSS(preFooterLinks)}\n }\n }\n }\n`;\n","import type { ReactiveController, ReactiveControllerHost } from 'lit';\nimport { colorScheme } from '../styles/color-scheme.js';\nimport { installLightDomStyles } from './light-dom-styles.js';\n\n/** The visitor's choice: follow the OS (`system`, the default) or pin `light` or `dark`. */\nexport type ColorSchemePreference = 'light' | 'dark' | 'system';\n/** What is shown: the preference, with `system` resolved from `prefers-color-scheme`. */\nexport type ResolvedColorScheme = 'light' | 'dark';\n\n/** localStorage key, per site (origin): `light` or `dark`; absent means `system`. */\nexport const COLOR_SCHEME_STORAGE_KEY = 'uvalib-color-scheme';\n/** Attribute on the root element that turns the opt-in dark-mode rules on. */\nexport const COLOR_SCHEME_ATTR = 'data-uva-color-scheme';\n/** Fired on the document whenever a control changes the preference. */\nconst CHANGE = 'uvalib-color-scheme-change';\nconst DARK_QUERY = '(prefers-color-scheme: dark)';\n\n/** Choices made while storage is unavailable, kept for the page's lifetime. */\nconst memory = new WeakMap<Document, ColorSchemePreference>();\n\nconst asPreference = (v: unknown): ColorSchemePreference =>\n v === 'light' || v === 'dark' ? v : 'system';\n\n/** Dark mode needs light-dark(); without it nothing is shown or set, and the page stays light. */\nexport function colorSchemeSupported(doc: Document = document): boolean {\n const css = doc.defaultView?.CSS;\n try {\n return !!css?.supports?.('color', 'light-dark(#000, #fff)');\n } catch {\n return false;\n }\n}\n\n/** The stored preference: this page's in-memory choice if storage failed, else localStorage. */\nexport function readPreference(doc: Document = document): ColorSchemePreference {\n const kept = memory.get(doc);\n if (kept) return kept;\n try {\n return asPreference(doc.defaultView?.localStorage.getItem(COLOR_SCHEME_STORAGE_KEY));\n } catch {\n return 'system';\n }\n}\n\n/** Whether the OS asks for dark. */\nexport function systemIsDark(doc: Document = document): boolean {\n return !!doc.defaultView?.matchMedia?.(DARK_QUERY).matches;\n}\n\nexport function resolvePreference(\n pref: ColorSchemePreference,\n doc: Document = document,\n): ResolvedColorScheme {\n return pref === 'system' ? (systemIsDark(doc) ? 'dark' : 'light') : pref;\n}\n\n/**\n * Show `pref` on the page: `data-uva-color-scheme` on the root element, and with `inline`\n * (for `no-style`, where no stylesheet maps the attribute) `color-scheme` as an inline style.\n */\nexport function applyPreference(doc: Document, pref: ColorSchemePreference, inline = false): void {\n const html = doc.documentElement;\n if (html.getAttribute(COLOR_SCHEME_ATTR) !== pref) html.setAttribute(COLOR_SCHEME_ATTR, pref);\n if (inline) html.style.colorScheme = pref === 'system' ? 'light dark' : pref;\n}\n\n/** Turn dark mode off again: remove the attribute and any inline `color-scheme`. */\nexport function clearPreference(doc: Document): void {\n const html = doc.documentElement;\n html.removeAttribute(COLOR_SCHEME_ATTR);\n html.style.removeProperty('color-scheme');\n if (!html.getAttribute('style')) html.removeAttribute('style');\n}\n\n/**\n * Remember and show `pref`. `system` removes the stored value; storage that throws keeps the\n * choice in memory for this page. Every connected control is told.\n */\nexport function setPreference(doc: Document, pref: ColorSchemePreference, inline = false): void {\n try {\n const storage = doc.defaultView!.localStorage;\n if (pref === 'system') storage.removeItem(COLOR_SCHEME_STORAGE_KEY);\n else storage.setItem(COLOR_SCHEME_STORAGE_KEY, pref);\n memory.delete(doc);\n } catch {\n memory.set(doc, pref);\n }\n applyPreference(doc, pref, inline);\n doc.dispatchEvent(new CustomEvent(CHANGE));\n}\n\n/** The opt-in rules on the document (layered, so host CSS wins), for pages without tokens.css. */\nexport function installColorSchemeStyles(doc: Document): void {\n installLightDomStyles('uvalib-color-scheme', [colorScheme], { root: doc, scope: false });\n}\n\n/** Per document, the controllers that currently own `data-uva-color-scheme`. */\nconst owners = new WeakMap<Document, Set<ColorSchemeController>>();\nconst ownersOf = (doc: Document): Set<ColorSchemeController> => {\n let set = owners.get(doc);\n if (!set) owners.set(doc, (set = new Set()));\n return set;\n};\n\nconst FORCED_QUERY = '(forced-colors: active)';\n\n/** The scheme the root element shows: from `data-uva-color-scheme`, or null when dark mode is off. */\nexport function rootColorScheme(doc: Document = document): ResolvedColorScheme | null {\n const attr = doc.documentElement.getAttribute(COLOR_SCHEME_ATTR);\n if (attr === null || !colorSchemeSupported(doc)) return null;\n return resolvePreference(asPreference(attr), doc);\n}\n\n/**\n * A component's view of dark mode. While `enabled()` and supported (`active`), it owns\n * `data-uva-color-scheme` on the root element: it sets it, keeps it current with the\n * stored preference (any control on the page, another tab through the `storage` event) and\n * removes it when the last owner in the document is turned off or disconnected. A connected\n * controller that is not enabled removes a stray attribute (for example from the inline\n * snippet on a page without the switch) unless another one owns it.\n *\n * Every connected controller also follows the root's scheme (`rootDark`) and the OS\n * preference (`systemDark`), so a header without the switch never shows the navy logo on a\n * dark page. A controller that is off on a page where dark mode is off stays inert: it reads\n * no storage and queries no media, and listens only for the controllers' own change event.\n */\nexport class ColorSchemeController implements ReactiveController {\n preference: ColorSchemePreference = 'system';\n /** What \"System\" resolves to: the OS preference. */\n systemDark = false;\n /** Whether the root element currently shows the dark scheme. */\n rootDark = false;\n /** Whether forced colors (a contrast theme) are on. */\n forcedColors = false;\n /** Whether the root element has `data-uva-color-scheme` (dark mode is on for the page). */\n rootOn = false;\n /** Enabled and supported: this controller owns the root attribute. */\n active = false;\n /** Set while sync() runs, so its own change events do not request a second update. */\n private syncing = false;\n\n private listening?: {\n doc: Document;\n level: 'change' | 'full';\n dark?: MediaQueryList;\n forced?: MediaQueryList;\n };\n\n constructor(\n private readonly host: ReactiveControllerHost & HTMLElement,\n private readonly enabled: () => boolean,\n private readonly inline: () => boolean,\n /** Whether the host renders anything from this state (and so needs updates). */\n private readonly renders = true,\n ) {\n host.addController(this);\n }\n\n hostConnected(): void {\n this.sync();\n }\n\n hostDisconnected(): void {\n this.listen('none');\n this.release(this.host.ownerDocument);\n }\n\n /** Call when `enabled()` may have changed (from the host's `willUpdate`). */\n sync(): void {\n const doc = this.host.ownerDocument;\n if (!this.host.isConnected) return;\n this.syncing = true;\n const supported = colorSchemeSupported(doc);\n this.active = this.enabled() && supported;\n if (this.active) {\n ownersOf(doc).add(this);\n if (!this.inline()) installColorSchemeStyles(doc);\n this.preference = readPreference(doc);\n applyPreference(doc, this.preference, this.inline());\n doc.dispatchEvent(new CustomEvent(CHANGE));\n } else {\n this.release(doc);\n // Not ours, and nobody owns it: a stray attribute (the snippet without the switch).\n if (!ownersOf(doc).size && doc.documentElement.hasAttribute(COLOR_SCHEME_ATTR)) {\n clearPreference(doc);\n doc.dispatchEvent(new CustomEvent(CHANGE));\n }\n }\n this.syncing = false;\n this.refresh(false);\n this.listen(supported ? this.listenLevel() : 'none');\n }\n\n /**\n * Whether to show the reversed (white) logo: only while the page shows dark mode, and under\n * forced colors (a contrast theme repaints the header) only when the OS theme is dark.\n */\n get logoDark(): boolean {\n return this.rootOn && (this.forcedColors ? this.systemDark : this.rootDark);\n }\n\n /** The visitor picked `pref` in a control. */\n choose(pref: ColorSchemePreference): void {\n setPreference(this.host.ownerDocument, pref, this.inline());\n }\n\n /** Stop owning the attribute; the last owner to go removes it. */\n private release(doc: Document): void {\n const set = ownersOf(doc);\n if (!set.delete(this)) return;\n this.active = false;\n if (!set.size) {\n clearPreference(doc);\n doc.dispatchEvent(new CustomEvent(CHANGE));\n }\n }\n\n private readonly onChange = (): void => this.refresh(!this.syncing);\n\n private readonly onStorage = (e: StorageEvent): void => {\n if (e.key !== null && e.key !== COLOR_SCHEME_STORAGE_KEY) return;\n if (this.active)\n applyPreference(\n this.host.ownerDocument,\n readPreference(this.host.ownerDocument),\n this.inline(),\n );\n this.refresh(true);\n };\n\n private refresh(update: boolean): void {\n const doc = this.host.ownerDocument;\n const root = rootColorScheme(doc);\n // A controller that is off, on a page where dark mode is off, stays inert: no storage\n // read and no media queries, only the cheap root-attribute check above.\n const engaged = this.active || root !== null;\n const next = engaged\n ? {\n preference: readPreference(doc),\n systemDark: systemIsDark(doc),\n rootDark: root === 'dark',\n rootOn: root !== null,\n forcedColors: !!doc.defaultView?.matchMedia?.(FORCED_QUERY).matches,\n }\n : {\n preference: 'system' as const,\n systemDark: false,\n rootDark: false,\n rootOn: false,\n forcedColors: false,\n };\n const changed = (Object.keys(next) as (keyof typeof next)[]).some((k) => next[k] !== this[k]);\n Object.assign(this, next);\n if (this.listening) this.listen(this.listenLevel());\n if (changed && update && this.renders) this.host.requestUpdate();\n }\n\n /**\n * What to listen to: nothing without `light-dark()` support; everything (storage, the OS\n * and forced-colors queries) while this controller owns the attribute or the page shows\n * dark mode; otherwise only the controllers' own change event, which tells an inert\n * controller that another one turned dark mode on.\n */\n private listenLevel(): 'none' | 'change' | 'full' {\n if (!colorSchemeSupported(this.host.ownerDocument)) return 'none';\n return this.active || this.rootOn ? 'full' : 'change';\n }\n\n private listen(level: 'none' | 'change' | 'full'): void {\n if (level === (this.listening?.level ?? 'none')) return;\n if (this.listening) {\n const { doc, dark, forced } = this.listening;\n doc.removeEventListener(CHANGE, this.onChange);\n doc.defaultView?.removeEventListener('storage', this.onStorage);\n dark?.removeEventListener('change', this.onChange);\n forced?.removeEventListener('change', this.onChange);\n this.listening = undefined;\n }\n if (level === 'none') return;\n const doc = this.host.ownerDocument;\n doc.addEventListener(CHANGE, this.onChange);\n if (level === 'change') {\n this.listening = { doc, level };\n return;\n }\n const dark = doc.defaultView?.matchMedia?.(DARK_QUERY);\n const forced = doc.defaultView?.matchMedia?.(FORCED_QUERY);\n doc.defaultView?.addEventListener('storage', this.onStorage);\n dark?.addEventListener('change', this.onChange);\n forced?.addEventListener('change', this.onChange);\n this.listening = { doc, level, dark, forced };\n }\n}\n","import { html, css, nothing, type PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { siteLink } from '../link.js';\nimport { accessible } from '../../styles/accessible.js';\nimport { ColorSchemeController, type ColorSchemePreference } from '../../base/color-scheme.js';\nimport {\n normalizeItems,\n readItemsMarkup,\n type MainNavItem,\n} from '../site-main-nav/main-nav-items.js';\n\nconst ACCOUNT_URL = 'https://search.lib.virginia.edu/account';\n/** The analytics category. */\nconst TAG = 'site-header';\n\nconst FULL_LINKS: ReadonlyArray<{ label: string; path: string }> = [\n { label: 'My account', path: ACCOUNT_URL },\n { label: 'Ask a Librarian', path: '/askalibrarian' },\n { label: 'Hours', path: '/hours' },\n { label: 'Give', path: '/support-library' },\n { label: 'Alerts', path: '/status#alerts' },\n { label: 'Search', path: '/search' },\n];\n\nconst VENDOR_LINKS = FULL_LINKS.filter((l) => l.label === 'Ask a Librarian');\n\n/** Light-DOM instances share the document id space, so each gets its own popover id. */\nlet menuCounter = 0;\n/** Radio group names are per instance and per control (two controls per header). */\nlet schemeCounter = 0;\n\n/** The reversed (white) library logo, for dark mode. Same aspect ratio as the navy one. */\nexport const DARK_LOGO_URL =\n 'https://static.lib.virginia.edu/files/downloads/LibraryLogos/UVALIB_primary_color_white_web.png';\nconst SCHEME_OPTIONS: ReadonlyArray<{ value: ColorSchemePreference; label: string }> = [\n { value: 'light', label: 'Light' },\n { value: 'dark', label: 'Dark' },\n { value: 'system', label: 'System' },\n];\n\n/** A site's own link, read from an `<a slot=\"site-links\">` child. */\ninterface SiteLinkItem {\n href: string;\n text: string;\n current?: string;\n target?: string;\n rel?: string;\n hreflang?: string;\n}\n\nconst SITE_LINKS = 'site-links';\nconst isSiteLinksChild = (n: Node): n is Element =>\n n instanceof Element && n.getAttribute('slot') === SITE_LINKS;\nconst MAIN_NAV = 'main-nav';\nconst isMainNavChild = (n: Node): n is Element =>\n n instanceof Element && n.getAttribute('slot') === MAIN_NAV;\nconst ALERTS = 'alerts';\nconst isAlertsChild = (n: Node | null): n is Element =>\n n instanceof Element && n.getAttribute('slot') === ALERTS;\n/** Attributes of a source anchor that change what the header renders. */\nconst LINK_ATTRS = ['href', 'aria-current', 'target', 'rel', 'hreflang'];\n/** Swallows the popover accordion's copy of an `items-src` error the bar also reports. */\nconst stopEvent = (e: Event) => e.stopPropagation();\n\n/**\n * UVA Library site header: logo, utility navigation, and a popover menu on narrow screens.\n *\n * A site can replace the library utility links (My account, Ask a Librarian, Hours, Give,\n * Alerts, Search) with its own: give the header `<a slot=\"site-links\" href=\"…\">` children.\n * They are shown, in order, in the inline nav and the Menu popover, with `href` as written\n * (not joined to `root-link-domain`) and their `aria-current`, `target`, `rel` and\n * `hreflang`. The source anchors themselves stay hidden. Children that are not `<a href>`\n * with text (empty or whitespace-only text counts as none) are ignored with one console\n * warning. The `vendor` variant ignores site links and keeps\n * its own reduced link set.\n *\n * The full header also shows the UVA Library main navigation (`<site-main-nav>`): a row\n * under the logo row on wide screens, and an accordion at the top of the Menu popover on\n * narrow ones (992px and below), above the utility or site links. `no-main-nav` turns it\n * off, leaving the header exactly as it was without it; the `vendor` variant never shows it.\n * A `<nav slot=\"main-nav\">` child replaces its links (see `<site-main-nav>`), and\n * `main-nav-src` loads them from JSON; `main-nav-current` sets the URL marked current.\n *\n * `color-scheme-switch` opts in to dark mode (off by default; see the README's \"Dark mode\"):\n * a Light / Dark / System radio group (\"Theme\") at the end of the utility-links row on wide\n * screens and at the bottom of the Menu popover on narrow ones. The `vendor` variant, which\n * has no Menu, shows it after its inline link, on a row of its own under the logo row on\n * narrow screens. In dark mode the logo is the reversed (white) one.\n *\n * `site-name` shows a sub-site's name after the logo, past a thin divider, as a link to the\n * site's home (`site-name-href`, default `/`); the logo still links to library.virginia.edu.\n * The name is not a heading (the page keeps its own `<h1>`) and its link is named\n * \"<name> home\". On wide screens it sits in the logo row, wrapping to at most two lines (keep\n * it short), so the header is no taller, while the links (and theme control) fit beside it on\n * one line; when they would not, and at 992px and below, it gets its own lines under the\n * logo, so the links are laid out exactly as without it. The `vendor` variant shows it too.\n *\n * @tagname site-header\n * @slot skip-link - Shadow mode only: optional skip link, rendered first inside `<header>` (`<site-page>` uses it).\n * @slot alerts - Optional alert banner (`<site-page>` passes its `<site-alerts show=\"header\">`), shown as a full-bleed row at the very top of `<header>` (flush with its top and both edges, outside its padding), after the skip link and before the logo row. In light mode the children are moved to the start of `<header>`. The header never loads alerts itself.\n * @slot main-nav - Optional `<nav>` whose `<ul>` replaces the main navigation's links in both layouts: `<li><a href>` for a direct link, `<li><span>Group</span><ul><li><a href>…</a></li></ul></li>` for a group. Invalid entries are skipped with one console warning. Never shown itself; in light mode it is moved into a hidden holder. Ignored with `no-main-nav` and by the `vendor` variant.\n * @slot site-links - Optional `<a href>` elements with text that replace the library utility links in the inline nav and the Menu popover (ignored by the `vendor` variant). In light mode they are moved into a hidden holder.\n * @csspart header - The `<header>` element.\n * @fires site-main-nav-error - `main-nav-src` could not be loaded; the bundled main navigation is shown. `detail` is `{ src, message }`. Fired once, from the bar's `<site-main-nav>`; bubbles and is composed.\n * @fires uvalib-analytics-event - For `<site-analytics>`: the visitor picked a colour scheme, `['site-header', 'color-scheme', 'light' | 'dark' | 'system']` (not the initial value); `['site-header', 'link-click', <label>]` for a utility or site link, `['site-header', 'logo-click']`, `['site-header', 'site-name-click']` (the `site-name` link), `['site-header', 'skip-link']` (a slotted skip link) and `['site-header', 'menu-open']` when the Menu popover opens; and the main navigation's menu opens and link clicks (see `<site-main-nav>`). Never a URL. Bubbles and is composed.\n * @cssprop [--uva-blue-alt-dark=#005679] - Utility link colour.\n * @cssprop [--uva-grey-darkest=#2b2b2b] - Menu button colour.\n * @cssprop [--uva-brand-orange=#e57200] - Focus ring colour (focus-visible outline), and the underline colour of an `aria-current` link (also bold, with a 3px underline).\n * @cssprop [--uva-brand-blue=#232d4b] - Skip-link background for a skip link slotted into `skip-link` (shadow mode, shared accessibility sheet).\n * @cssprop --uva-color-surface-raised - Dark-mode role token: header, Menu popover and theme control background (else #ffffff).\n * @cssprop --uva-color-utility-link - Dark-mode role token: utility and site link colour (else `--uva-blue-alt-dark`).\n * @cssprop --uva-color-text - Dark-mode role token: Menu button and theme control text (else `--uva-grey-darkest`).\n * @cssprop --uva-color-border - Dark-mode role token: popover border and rules (else #ccc).\n * @cssprop --uva-color-control-border - Dark-mode role token: theme control border (else `--uva-grey`, #808080).\n * @cssprop --uva-color-accent-bg - Dark-mode role token: selected theme option and skip-link background (else `--uva-brand-blue`).\n * @cssprop --uva-color-on-accent - Dark-mode role token: selected theme option and skip-link text (else #fff).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n * @cssprop --uva-color-current - Dark-mode role token: current-page underline (else `--uva-brand-orange`).\n */\nexport class SiteHeader extends UvalibElement {\n static styles = [\n accessible,\n // site-name (.brand, .site-name): the logo, a divider and the site's name, centred on the\n // logo, at most two lines (10em, 18em from 1200px), so the logo row is no taller and the\n // utility links keep their room down to 993px. At 992px and below the name gets its own lines\n // under the logo, no wider than it, so the logo column is exactly as wide as before and the\n // Menu button (or vendor link) keeps its place.\n css`\n :host {\n display: block;\n width: 100%;\n }\n /* Logo on the start, everything else on the end, as one row. A grid (not a wrapping\n flex row) so an alerts row can span the top without changing where the logo row\n breaks: flex wrapping decides lines on max-content sizes before anything shrinks. */\n header {\n display: grid;\n grid-template-columns: auto minmax(0, 1fr);\n align-items: start;\n position: relative;\n background-color: var(--uva-color-surface-raised, #ffffff);\n --_pad-block: 0.5rem;\n --_pad-inline: 16px; /* old: .w3-container 16px side padding */\n padding: var(--_pad-block) var(--_pad-inline);\n }\n header > :not(.logo, .brand) {\n grid-column: 2;\n justify-self: end;\n }\n /* The alerts (slot=\"alerts\") are a full-bleed row above the logo row, as in Virgo:\n negative margins equal to the header's padding put them flush with the top and both\n edges, and the bottom margin gives the logo row back its top padding. With no\n alerts content they take no space, so the logo row is exactly where it was. */\n ::slotted([slot='alerts']),\n header > [slot='alerts'] {\n grid-column: 1 / -1;\n justify-self: stretch;\n min-inline-size: 0;\n margin: calc(-1 * var(--_pad-block)) calc(-1 * var(--_pad-inline)) var(--_pad-block);\n }\n .logo {\n display: block;\n text-decoration: none;\n }\n .logo img {\n display: block;\n max-width: 225px;\n height: auto;\n }\n .brand {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 0.25rem 0.625rem;\n min-inline-size: 0;\n }\n .site-name {\n max-inline-size: 10em;\n padding-inline-start: 0.625rem;\n border-inline-start: 1px solid var(--uva-color-control-border, var(--uva-grey, #808080));\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n font-size: 1.125rem;\n font-weight: 700;\n line-height: 1.2;\n text-decoration: none;\n overflow-wrap: anywhere;\n }\n .site-name:hover {\n text-decoration: underline;\n }\n @media screen and (min-width: 1200px) {\n .site-name {\n max-inline-size: 18em;\n }\n }\n nav ul {\n list-style-type: none;\n margin: 0;\n padding: 0;\n }\n /* Old nav hung from the top of the header below the default 1em list margin. */\n nav.inline ul {\n margin: 1em 0;\n display: flex;\n gap: 1.5rem;\n }\n a {\n color: var(--uva-color-utility-link, var(--uva-blue-alt-dark, #005679));\n }\n /* Current page: bold with a thick underline, so it does not rely on colour alone. */\n nav a[aria-current]:not([aria-current='false']) {\n font-weight: 700;\n text-decoration-line: underline;\n text-decoration-thickness: 3px;\n text-decoration-color: var(--uva-color-current, var(--uva-brand-orange, #e57200));\n text-underline-offset: 0.3em;\n }\n .menu-toggle {\n display: none;\n align-items: center;\n gap: 0.25rem;\n background: none;\n border: none;\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n font: inherit;\n cursor: pointer;\n }\n /* Old shared sheet sized every inline svg at 17px. */\n .menu-toggle svg {\n width: 17px;\n height: 17px;\n }\n [popover] {\n position: fixed;\n inset: auto;\n /* Fallback offset (about the header height) for engines without anchor(). */\n top: 4.75rem;\n inset-inline-end: 1rem;\n inline-size: min(80dvw, 24rem);\n max-inline-size: calc(100dvw - 2rem);\n block-size: fit-content;\n max-block-size: calc(100dvh - 6rem);\n overflow: auto;\n box-sizing: border-box;\n margin: 0.5rem 0 0;\n padding: 0.5rem 1rem;\n border: 1px solid var(--uva-color-border, #ccc);\n background: var(--uva-color-surface-raised, #ffffff);\n }\n nav.menu li {\n padding: 0.375rem 0;\n }\n /* The main navigation: a full-bleed row under the logo row, flush with the header's\n bottom (its 5px rule is the header's bottom edge), 0.5rem below the logo row. */\n header > site-main-nav.bar {\n grid-column: 1 / -1;\n justify-self: stretch;\n min-inline-size: 0;\n margin: var(--_pad-block) calc(-1 * var(--_pad-inline)) calc(-1 * var(--_pad-block));\n }\n /* Narrow screens: the main navigation leads the Menu popover, then a rule, then the\n utility or site links. */\n .menu-popover > site-main-nav + nav.menu > ul,\n .menu-popover > .color-scheme {\n margin-block-start: 0.5rem;\n padding-block-start: 0.5rem;\n border-block-start: 1px solid var(--uva-color-border, #ccc);\n }\n nav.menu {\n display: contents;\n }\n @supports (top: anchor(--x bottom)) {\n [popover] {\n top: anchor(var(--menu-anchor) bottom);\n }\n }\n /* One line: the links wrap within their own space, the control stays at the end. */\n .utility-row {\n display: flex;\n align-items: center;\n justify-content: flex-end;\n column-gap: 1.5rem;\n min-inline-size: 0;\n }\n .utility-row > nav.inline {\n min-inline-size: 0;\n }\n .utility-row > nav.inline ul {\n flex-wrap: wrap;\n justify-content: flex-end;\n row-gap: 0.25rem;\n }\n .utility-row > .color-scheme {\n flex: none;\n }\n .color-scheme {\n min-inline-size: 0;\n margin: 0;\n padding: 0;\n border: 0;\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n }\n .color-scheme legend {\n padding: 0;\n font-weight: 700;\n }\n .segments {\n display: flex;\n border: 1px solid var(--uva-color-control-border, var(--uva-grey, #808080));\n border-radius: 0.3rem;\n background: var(--uva-color-surface-raised, #ffffff);\n }\n .segments label {\n position: relative;\n display: flex;\n flex: 1;\n min-inline-size: 28px;\n font-size: 0.875rem;\n cursor: pointer;\n }\n .segments label + label {\n border-inline-start: 1px solid var(--uva-color-control-border, var(--uva-grey, #808080));\n }\n .segment {\n display: flex;\n flex: 1;\n align-items: center;\n justify-content: center;\n min-block-size: 28px;\n padding: 0.125rem 0.625rem;\n }\n .segments input {\n position: absolute;\n inset: 0;\n inline-size: 100%;\n block-size: 100%;\n margin: 0;\n opacity: 0;\n cursor: pointer;\n }\n .segments input:checked + .segment {\n background: var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b));\n color: var(--uva-color-on-accent, #ffffff);\n font-weight: 700;\n }\n .segments input:focus-visible + .segment {\n position: relative;\n z-index: 1;\n outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));\n outline-offset: 2px;\n }\n /* Floated, so it is not drawn into the fieldset's top border (the popover rule). */\n .menu-popover > .color-scheme legend {\n float: inline-start;\n inline-size: 100%;\n margin-block-end: 0.375rem;\n }\n .menu-popover > .color-scheme .segments {\n clear: both;\n }\n @media (forced-colors: active) {\n .segments input:checked + .segment {\n forced-color-adjust: none;\n background: Highlight;\n color: HighlightText;\n }\n }\n @media screen and (max-width: 992px) {\n header:not(.vendor) nav.inline,\n header:not(.vendor) .utility-row,\n header > site-main-nav.bar {\n display: none;\n }\n header.vendor .utility-row {\n display: contents;\n }\n header.vendor .utility-row > nav.inline {\n grid-column: 2;\n justify-self: end;\n }\n header.vendor .utility-row > .color-scheme {\n grid-column: 1 / -1;\n justify-self: end;\n margin-block-end: 0.5rem;\n }\n .menu-toggle {\n display: inline-flex;\n }\n .brand {\n max-inline-size: 225px;\n }\n .site-name {\n flex-basis: 100%;\n max-inline-size: none;\n padding: 0;\n border: 0;\n }\n }\n .brand.stacked {\n max-inline-size: 225px;\n }\n .stacked > .site-name {\n flex-basis: 100%;\n max-inline-size: none;\n padding: 0;\n border: 0;\n }\n @media screen and (min-width: 993px) {\n .menu-toggle,\n [popover] {\n display: none;\n }\n }\n `,\n ];\n\n @property({ type: String, attribute: 'root-link-domain' }) rootLinkDomain =\n 'https://www.library.virginia.edu';\n @property({ type: String, reflect: true }) variant: 'full' | 'vendor' = 'full';\n /** Accessible name of the nav when site links replace the utility links (default \"Site\"; the popover nav's name adds \" menu\"). */\n @property({ type: String, attribute: 'site-links-label' }) siteLinksLabel?: string;\n\n /**\n * The sub-site's name, shown after the library logo as a link to the site's home\n * (`site-name-href`). The logo still links to library.virginia.edu. Not a heading.\n */\n @property({ type: String, attribute: 'site-name' }) siteName?: string;\n /** Where the site name links (default `/`, the site's own home). */\n @property({ type: String, attribute: 'site-name-href' }) siteNameHref?: string;\n\n /** Hide the UVA Library main navigation (the row under the logo and the popover accordion). */\n @property({ type: Boolean, attribute: 'no-main-nav' }) noMainNav = false;\n /** Accessible name of the main navigation (default \"Main\"). */\n @property({ type: String, attribute: 'main-nav-label' }) mainNavLabel?: string;\n /** URL of JSON main navigation items (`MainNavItem[]`, needs CORS), passed to `<site-main-nav items-src>`. */\n @property({ type: String, attribute: 'main-nav-src' }) mainNavSrc?: string;\n /**\n * The URL whose main-navigation link is marked current, passed to `<site-main-nav current>`.\n * Default: the page location, followed through same-document navigations.\n */\n @property({ type: String, attribute: 'main-nav-current' }) mainNavCurrent?: string;\n\n /**\n * Opt in to dark mode: the page follows the OS light or dark preference (\"System\"), and a\n * Light / Dark / System control (at the end of the utility-links row on wide screens, at\n * the bottom of the Menu popover on narrow ones) lets the visitor override it, remembered\n * per site in localStorage (`uvalib-color-scheme`). Sets `data-uva-color-scheme` on the root\n * element, and swaps in the reversed logo while dark. Ignored (the page stays light and no\n * control is shown) in browsers without CSS `light-dark()`.\n */\n @property({ type: Boolean, attribute: 'color-scheme-switch' }) colorSchemeSwitch = false;\n\n private readonly scheme = new ColorSchemeController(\n this,\n () => this.colorSchemeSwitch,\n () => this.noStyle,\n );\n private readonly schemeName = `uva-color-scheme-${++schemeCounter}`;\n\n /** Main navigation items from `slot=\"main-nav\"` markup, or null for the default. */\n @state() private mainNavItems: MainNavItem[] | null = null;\n private warnedMainNav = false;\n /** Light mode: hidden container this element owns for the `slot=\"main-nav\"` children. */\n private mainNavHolder?: HTMLDivElement;\n\n /** The site's own links, or null to show the library utility links. */\n @state() private siteLinks: SiteLinkItem[] | null = null;\n private warnedInvalid = false;\n private observer?: MutationObserver;\n /** Light mode: hidden container this element owns for the `slot=\"site-links\"` children. */\n private holder?: HTMLDivElement;\n\n constructor() {\n super();\n this.addEventListener('click', this.onMenuLinkClick);\n this.addEventListener('click', this.trackClick);\n }\n\n /**\n * Analytics for the header's own links (never their URLs): the logo, the utility or site\n * links by label, and a skip link slotted into `skip-link`. Links inside the main\n * navigation (it reports its own) and the alerts are left alone.\n */\n private trackClick = (e: Event): void => {\n const path = e.composedPath();\n const a = path.find((n): n is HTMLAnchorElement => n instanceof HTMLAnchorElement);\n if (\n !a ||\n path.some((n) => n instanceof Element && /^site-(main-nav|alerts)$/.test(n.localName))\n )\n return;\n if (a.slot === 'skip-link' && a.parentNode === this) trackEvent(this, [TAG, 'skip-link']);\n else if (a.matches('.logo')) trackEvent(this, [TAG, 'logo-click']);\n else if (a.matches('.site-name')) trackEvent(this, [TAG, 'site-name-click']);\n else if (a.closest('nav.inline, nav.menu') && this.renderRoot.contains(a))\n trackEvent(this, [TAG, 'link-click', a.textContent!.replace(/\\s+/g, ' ').trim()]);\n };\n\n /** The Menu popover opening (not closing). */\n private trackToggle = (e: Event): void => {\n const t = e.composedPath()[0];\n if (t instanceof HTMLElement && t.id === this.menuId && (e as ToggleEvent).newState === 'open')\n trackEvent(this, [TAG, 'menu-open']);\n };\n\n /**\n * A plain click on a link in the Menu popover closes it, so a single-page app that handles\n * the navigation in place does not leave the menu open. Modified clicks (a new tab or\n * window) keep it open.\n */\n private onMenuLinkClick = (e: MouseEvent): void => {\n if (e.button !== 0 || e.ctrlKey || e.metaKey || e.shiftKey || e.altKey) return;\n const path = e.composedPath();\n const link = path.findIndex((n) => n instanceof Element && n.localName === 'a');\n const menu = path.findIndex((n) => n instanceof HTMLElement && n.id === this.menuId);\n if (link < 0 || menu < link) return;\n const popover = path[menu] as HTMLElement;\n if (popover.matches(':popover-open')) popover.hidePopover();\n };\n\n override connectedCallback(): void {\n super.connectedCallback();\n // Fitted on the next frame, outside the observer's callback: the fit changes the height.\n this.resizeObserver ??= new ResizeObserver(() =>\n requestAnimationFrame(() => {\n if (this.getBoundingClientRect().width !== this.fittedWidth) this.fitName();\n }),\n );\n this.resizeObserver.observe(this);\n // The web font is narrower than its fallback: fit again once it has loaded.\n void this.ownerDocument.fonts?.ready.then(() => this.fitName());\n // `toggle` neither bubbles nor leaves the shadow root: capture it on the render root\n // (adding the same listener again on a reconnect does nothing).\n this.renderRoot.addEventListener('toggle', this.trackToggle, true);\n // Reconnect after a disconnect; the first connect reads the links in firstUpdated().\n if (this.hasUpdated) this.syncChildren();\n // The main-nav markup is read before the first render too, so it costs no second update.\n else this.syncMainNav();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.resizeObserver?.disconnect();\n this.observer?.disconnect();\n }\n\n /** Which header template render() uses: with dark mode, with a site name, or neither. */\n private get template(): string {\n return this.scheme.active ? 'scheme' : this.name ? 'named' : 'plain';\n }\n private renderedTemplate?: string;\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has('colorSchemeSwitch')) this.scheme.sync();\n // Light mode: turning dark mode or the site name on or off swaps the header template, and\n // Lit clears everything after its start marker: the alerts moved into the old <header>\n // and the hidden source holders. Move them before the marker; updated() re-adopts the\n // alerts.\n const was = this.renderedTemplate;\n this.renderedTemplate = this.template;\n if (this.lightDom && this.hasUpdated && was !== this.renderedTemplate) {\n const header = this.querySelector(':scope > header');\n const keep = [...(header?.children ?? [])].filter(isAlertsChild);\n for (const holder of [this.holder, this.mainNavHolder]) if (holder) keep.push(holder);\n this.prepend(...keep);\n this.templateSwapped = true;\n }\n }\n private templateSwapped = false;\n\n protected override updated(): void {\n this.fitName();\n if (!this.templateSwapped) return;\n this.templateSwapped = false;\n this.adoptAlerts();\n }\n\n /** Watches the host's width, so the site name is re-fitted when it changes. */\n private resizeObserver?: ResizeObserver;\n private fittedWidth = -1;\n\n /**\n * Wide screens: the site name shares the logo row only while the links (and the theme\n * control) still fit on one line beside it; otherwise it goes under the logo, as on narrow\n * screens, so nothing overflows or wraps. Always measured with the name in the row, so the\n * result depends on the width alone and never flips back and forth.\n */\n private fitName = (): void => {\n const brand = this.renderRoot.querySelector<HTMLElement>('.brand');\n if (!brand) return;\n this.fittedWidth = this.getBoundingClientRect().width;\n brand.classList.remove('stacked');\n if (!matchMedia('screen and (min-width: 993px)').matches) return;\n const header = brand.parentElement!;\n const row = header.querySelector<HTMLElement>(':scope > .utility-row, :scope > nav.inline');\n if (!row) return;\n const edge =\n header.getBoundingClientRect().right - parseFloat(getComputedStyle(header).paddingRight);\n const items = [...row.querySelectorAll('nav.inline li')];\n const top = items[0]?.getBoundingClientRect().top;\n const crowded =\n row.getBoundingClientRect().right > edge + 0.5 ||\n row.scrollWidth > row.clientWidth + 0.5 ||\n items.some(\n (li) =>\n Math.abs(li.getBoundingClientRect().top - top!) > 0.5 ||\n li.querySelector('a')!.getClientRects().length > 1,\n );\n brand.classList.toggle('stacked', crowded);\n };\n\n protected override firstUpdated(): void {\n this.syncChildren();\n }\n\n /** The site name, trimmed, or empty for none. */\n private get name(): string {\n return (this.siteName ?? '').replace(/\\s+/g, ' ').trim();\n }\n\n /**\n * The logo, and with `site-name` the site's name after it. Their link names differ (\"UVA\n * Library home\", \"<name> home\"), and each starts with its visible text, for voice control.\n */\n private brand() {\n const logo = html`<a class=\"logo\" href=${siteLink(this.rootLinkDomain, '/')}\n ><img src=${this.logoSrc()} alt=\"UVA Library home\" width=\"304\" height=\"69\"\n /></a>`;\n const name = this.name;\n if (!name) return logo;\n return html`<div class=\"brand\">\n ${logo}<a class=\"site-name\" href=${this.siteNameHref || '/'} aria-label=${`${name} home`}\n >${name}</a\n >\n </div>`;\n }\n\n /** The navy logo, or the reversed (white) one while the page shows dark mode. */\n private logoSrc(): string {\n return this.scheme.logoDark\n ? DARK_LOGO_URL\n : siteLink(this.rootLinkDomain, '/sites/default/files/2022-09/library_rgb.png');\n }\n\n private onSchemeChange(e: Event): void {\n const input = e.target as HTMLInputElement;\n if (!input.checked) return;\n this.scheme.choose(input.value as ColorSchemePreference);\n trackEvent(this, [TAG, 'color-scheme', input.value]);\n }\n\n /**\n * The Light / Dark / System radio group. `inline` sits in the utility-links row, with its\n * legend visually hidden; `menu` closes the Menu popover, legend shown. \"System\" names\n * what it resolves to (the OS preference, whichever option is chosen), for screen readers.\n * Each option's look is on the span after its radio (no `:has()`, which Firefox 120 lacks).\n */\n private schemeControl(where: 'inline' | 'menu') {\n const { preference, systemDark } = this.scheme;\n const hint = ` (currently ${systemDark ? 'dark' : 'light'})`;\n const name = `${this.schemeName}-${where}`;\n return html`<fieldset class=\"color-scheme ${where}\">\n <legend class=${where === 'inline' ? 'visually-hidden' : ''}>Theme</legend>\n <div class=\"segments\">\n ${SCHEME_OPTIONS.map(\n (o) =>\n html`<label\n ><input\n type=\"radio\"\n name=${name}\n value=${o.value}\n .checked=${preference === o.value}\n @change=${this.onSchemeChange}\n /><span class=\"segment\"\n >${o.label}${\n o.value === 'system'\n ? html`<span class=\"visually-hidden\">${hint}</span>`\n : nothing\n }</span\n ></label\n >`,\n )}\n </div>\n </fieldset>`;\n }\n\n /** Light mode: place slotted alerts in `<header>`, then read the site links and main nav. */\n private syncChildren(): void {\n this.adoptAlerts();\n this.syncSources();\n }\n\n /** Read the site links and the main-nav markup, and watch both. */\n private syncSources(): void {\n const sources = [...this.syncSiteLinks(), ...this.syncMainNav()];\n this.watch(sources);\n }\n\n /**\n * Shadow mode: the `slot=\"main-nav\"` children, with a forwarded `<slot>` (from\n * `<site-page>`) replaced by what is assigned to it. Needs no rendered slot.\n */\n private get slottedMainNav(): Element[] {\n return [...this.children]\n .filter(isMainNavChild)\n .flatMap((k) => (k instanceof HTMLSlotElement ? k.assignedElements({ flatten: true }) : [k]));\n }\n\n /** Light mode: move `slot=\"main-nav\"` children into their own hidden holder. */\n private adoptMainNav(): Element[] {\n const moved = [...this.children].filter(isMainNavChild);\n if (moved.length && !this.mainNavHolder) {\n this.mainNavHolder = document.createElement('div');\n this.mainNavHolder.hidden = true;\n this.mainNavHolder.className = 'main-nav-source';\n }\n if (this.mainNavHolder) {\n this.mainNavHolder.append(...moved);\n if (this.mainNavHolder.parentNode !== this) this.append(this.mainNavHolder);\n }\n return this.mainNavHolder ? [...this.mainNavHolder.children] : [];\n }\n\n /** Read the `slot=\"main-nav\"` markup once, for both main-nav instances. */\n private syncMainNav(): Element[] {\n const sources = this.lightDom ? this.adoptMainNav() : this.slottedMainNav;\n if (!sources.length) {\n if (this.mainNavItems) this.mainNavItems = null;\n return sources;\n }\n const raw = sources.flatMap((s, i) => (i === 0 ? readItemsMarkup(s) : [{}]));\n const result = normalizeItems(raw);\n if ((result.invalid || result.flattened) && !this.warnedMainNav) {\n this.warnedMainNav = true;\n console.warn(\n `${this.localName}: ignoring invalid slot=\"${MAIN_NAV}\" entries (each needs a label, and an href or links; deeper levels are shown in their group).`,\n );\n }\n const next = result.items.length ? result.items : null;\n // Only a real change re-renders the header and both navs.\n if (JSON.stringify(next) !== JSON.stringify(this.mainNavItems)) this.mainNavItems = next;\n return sources;\n }\n\n /**\n * Light mode has no slots: move `slot=\"alerts\"` children to the start of `<header>`, after\n * any alerts already there. That is before every Lit part in the header, so re-renders\n * never touch them.\n */\n private adoptAlerts(): void {\n if (!this.lightDom) return;\n const header = this.querySelector(':scope > header');\n const incoming = [...this.children].filter(isAlertsChild);\n if (!header || !incoming.length) return;\n let ref = header.firstChild;\n while (isAlertsChild(ref)) ref = ref.nextSibling;\n for (const n of incoming) header.insertBefore(n, ref);\n }\n\n /** Shadow mode: the elements assigned to the site-links slot, through forwarded slots. */\n private get slotted(): Element[] {\n const slot = this.renderRoot.querySelector<HTMLSlotElement>(`slot[name=\"${SITE_LINKS}\"]`);\n return slot?.assignedElements({ flatten: true }) ?? [];\n }\n\n /** Light mode has no slots: move `slot=\"site-links\"` children into the hidden holder. */\n private adoptSiteLinks(): Element[] {\n const moved = [...this.children].filter(isSiteLinksChild);\n if (moved.length && !this.holder) {\n this.holder = document.createElement('div');\n this.holder.hidden = true;\n this.holder.className = 'site-links-source';\n }\n if (this.holder) {\n this.holder.append(...moved);\n if (this.holder.parentNode !== this) this.append(this.holder);\n }\n return this.holder ? [...this.holder.children] : [];\n }\n\n /** Read the source links and render them; returns the sources to watch. */\n private syncSiteLinks(): Element[] {\n const sources = this.lightDom ? this.adoptSiteLinks() : this.slotted;\n const items: SiteLinkItem[] = [];\n let invalid = false;\n for (const el of sources) {\n const text = (el.textContent ?? '').replace(/\\s+/g, ' ').trim();\n // A link with no text would have no accessible name.\n if (!(el instanceof HTMLAnchorElement) || !el.hasAttribute('href') || !text) {\n invalid = true;\n continue;\n }\n const attr = (name: string) => el.getAttribute(name) ?? undefined;\n items.push({\n href: el.getAttribute('href')!,\n text,\n current: attr('aria-current'),\n target: attr('target'),\n rel: attr('rel'),\n hreflang: attr('hreflang'),\n });\n }\n if (invalid && !this.warnedInvalid) {\n this.warnedInvalid = true;\n console.warn(\n `${this.localName}: ignoring slot=\"${SITE_LINKS}\" children that are not <a href> elements with text.`,\n );\n }\n this.siteLinks = items.length ? items : null;\n return sources;\n }\n\n /**\n * Shadow mode: slotchange reports added and removed links, and the observer watches the\n * assigned anchors' attributes and text. Light mode: the observer also watches the host\n * for new children and the holder for removals.\n */\n private watch(sources: Element[]): void {\n this.observer ??= new MutationObserver(() => this.syncChildren());\n this.observer.disconnect();\n const content = {\n attributes: true,\n attributeFilter: LINK_ATTRS,\n characterData: true,\n childList: true,\n subtree: true,\n };\n if (this.lightDom) {\n this.observer.observe(this, { childList: true });\n if (this.holder) this.observer.observe(this.holder, content);\n if (this.mainNavHolder)\n this.observer.observe(this.mainNavHolder, { ...content, attributeFilter: ['href'] });\n } else {\n for (const el of sources) this.observer.observe(el, content);\n }\n }\n\n private onSourcesChange(): void {\n this.syncSources();\n }\n\n private _menuId?: string;\n private get menuId(): string {\n this._menuId ??= this.lightDom ? `utility-menu-${++menuCounter}` : 'utility-menu';\n return this._menuId;\n }\n\n /**\n * The header with dark mode on: the inline nav and the control share the utility row, the\n * Menu popover ends with the control, and the logo follows the scheme. A template of its\n * own, so the header without the switch renders exactly what it did before dark mode.\n */\n private renderWithScheme(\n items: unknown,\n label: string,\n mainNav: boolean,\n mainNavEl: (accordion: boolean) => unknown,\n ) {\n const vendor = this.variant === 'vendor';\n const id = this.menuId;\n const anchor = `--${id}`;\n const menu = html`<button\n popovertarget=${id}\n aria-controls=${id}\n class=\"menu-toggle\"\n style=\"anchor-name: ${anchor}\"\n >\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"28\"\n height=\"28\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"butt\"\n stroke-linejoin=\"bevel\"\n >\n <line x1=\"3\" y1=\"12\" x2=\"21\" y2=\"12\"></line>\n <line x1=\"3\" y1=\"6\" x2=\"21\" y2=\"6\"></line>\n <line x1=\"3\" y1=\"18\" x2=\"21\" y2=\"18\"></line>\n </svg>\n Menu\n </button>\n <div id=${id} popover class=\"menu-popover\" style=\"--menu-anchor: ${anchor}\">\n ${mainNav ? mainNavEl(true) : nothing}\n <nav class=\"menu\" aria-label=${`${label} menu`}>\n <ul>\n ${items}\n </ul>\n </nav>\n ${this.schemeControl('menu')}\n </div>\n ${mainNav ? mainNavEl(false) : nothing}`;\n return html`\n <header part=\"header\" class=${vendor ? 'vendor' : ''}>\n ${this.lightDom ? nothing : html`<slot name=\"skip-link\"></slot><slot name=\"alerts\"></slot>`}\n ${this.brand()}\n <div class=\"utility-row\">\n <nav class=\"inline\" aria-label=${label}>\n <ul>\n ${items}\n </ul>\n </nav>\n ${this.schemeControl('inline')}\n </div>\n ${vendor ? nothing : menu}\n </header>\n ${\n this.lightDom\n ? nothing\n : html`<div hidden>\n <slot name=\"site-links\" @slotchange=${this.onSourcesChange}></slot>\n </div>\n <div hidden>\n <slot name=\"main-nav\" @slotchange=${this.onSourcesChange}></slot>\n </div>`\n }\n `;\n }\n\n render() {\n const root = this.rootLinkDomain;\n const vendor = this.variant === 'vendor';\n const own = vendor ? null : this.siteLinks;\n const items = own\n ? own.map(\n (l) =>\n html`<li>\n <a\n href=${l.href}\n aria-current=${ifDefined(l.current)}\n target=${ifDefined(l.target)}\n rel=${ifDefined(l.rel)}\n hreflang=${ifDefined(l.hreflang)}\n >${l.text}</a\n >\n </li>`,\n )\n : (vendor ? VENDOR_LINKS : FULL_LINKS).map(\n (l) => html`<li><a href=${siteLink(root, l.path)}>${l.label}</a></li>`,\n );\n const label = own ? this.siteLinksLabel || 'Site' : 'Utility';\n const id = this.menuId;\n const anchor = `--${id}`;\n const mainNav = !vendor && !this.noMainNav;\n // Without the main navigation the header renders exactly what it did before it existed,\n // whitespace included: these two templates are kept verbatim (prettier-ignore).\n // prettier-ignore\n const classic = html`<button\n popovertarget=${id}\n aria-controls=${id}\n class=\"menu-toggle\"\n style=\"anchor-name: ${anchor}\"\n >\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"28\"\n height=\"28\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"butt\"\n stroke-linejoin=\"bevel\"\n >\n <line x1=\"3\" y1=\"12\" x2=\"21\" y2=\"12\"></line>\n <line x1=\"3\" y1=\"6\" x2=\"21\" y2=\"6\"></line>\n <line x1=\"3\" y1=\"18\" x2=\"21\" y2=\"18\"></line>\n </svg>\n Menu\n </button>\n <nav class=\"menu\" aria-label=${`${label} menu`}>\n <ul id=${id} popover style=\"--menu-anchor: ${anchor}\">\n ${items}\n </ul>\n </nav>`;\n // prettier-ignore\n const classicHidden = html`<div hidden>\n <slot name=\"site-links\" @slotchange=${this.onSourcesChange}></slot>\n </div>`;\n const mainNavEl = (accordion: boolean) =>\n html`<site-main-nav\n class=${accordion ? 'accordion' : 'bar'}\n layout=${ifDefined(accordion ? 'accordion' : undefined)}\n ?no-shadow-dom=${this.lightDom}\n ?no-style=${this.noStyle}\n label=${this.mainNavLabel || 'Main'}\n root-link-domain=${root}\n items-src=${ifDefined(this.mainNavSrc || undefined)}\n current=${ifDefined(this.mainNavCurrent || undefined)}\n .items=${this.mainNavItems ?? undefined}\n @site-main-nav-error=${accordion ? stopEvent : nothing}\n ></site-main-nav>`;\n // With it: the Menu popover holds the accordion and then the utility links, and the bar\n // is the header's last child, a row of its own.\n const withMainNav = html`<button\n popovertarget=${id}\n aria-controls=${id}\n class=\"menu-toggle\"\n style=\"anchor-name: ${anchor}\"\n >\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"28\"\n height=\"28\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"butt\"\n stroke-linejoin=\"bevel\"\n >\n <line x1=\"3\" y1=\"12\" x2=\"21\" y2=\"12\"></line>\n <line x1=\"3\" y1=\"6\" x2=\"21\" y2=\"6\"></line>\n <line x1=\"3\" y1=\"18\" x2=\"21\" y2=\"18\"></line>\n </svg>\n Menu\n </button>\n <div id=${id} popover class=\"menu-popover\" style=\"--menu-anchor: ${anchor}\">\n ${mainNavEl(true)}\n <nav class=\"menu\" aria-label=${`${label} menu`}>\n <ul>\n ${items}\n </ul>\n </nav>\n </div>\n ${mainNavEl(false)}`;\n const withMainNavHidden = html`<div hidden>\n <slot name=\"site-links\" @slotchange=${this.onSourcesChange}></slot>\n </div>\n <div hidden>\n <slot name=\"main-nav\" @slotchange=${this.onSourcesChange}></slot>\n </div>`;\n if (this.scheme.active) return this.renderWithScheme(items, label, mainNav, mainNavEl);\n const end = vendor ? nothing : mainNav ? withMainNav : classic;\n const hidden = this.lightDom ? nothing : mainNav ? withMainNavHidden : classicHidden;\n // A template of its own, so the header without a site name stays byte-identical.\n if (this.name)\n return html`\n <header part=\"header\" class=${vendor ? 'vendor' : ''}>\n ${this.lightDom ? nothing : html`<slot name=\"skip-link\"></slot><slot name=\"alerts\"></slot>`}\n ${this.brand()}\n <nav class=\"inline\" aria-label=${label}>\n <ul>\n ${items}\n </ul>\n </nav>\n ${end}\n </header>\n ${hidden}\n `;\n return html`\n <header part=\"header\" class=${vendor ? 'vendor' : ''}>\n ${this.lightDom ? nothing : html`<slot name=\"skip-link\"></slot><slot name=\"alerts\"></slot>`}\n <a class=\"logo\" href=${siteLink(root, '/')}\n ><img src=${this.logoSrc()} alt=\"UVA Library home\" width=\"304\" height=\"69\"\n /></a>\n <nav class=\"inline\" aria-label=${label}>\n <ul>\n ${items}\n </ul>\n </nav>\n ${end}\n </header>\n ${hidden}\n `;\n }\n}\n","import { define } from '../../base/define.js';\nimport { SiteHeader } from './SiteHeader.js';\nimport { SiteMainNav } from '../site-main-nav/SiteMainNav.js';\nimport '../site-main-nav/site-main-nav.js';\n\ndefine('site-header', SiteHeader);\n\n// Another build (a second copy of the package, or the CDN and npm on one page) registered\n// <site-main-nav> first: the header then renders that version, which may not match it.\nconst registered = customElements.get('site-main-nav');\nif (registered && registered !== SiteMainNav) {\n console.warn(\n 'site-header: <site-main-nav> is already defined by another copy of @uvalib/web-components; the header uses that one. Load the components from one source only.',\n );\n}\n"],"mappings":";;;;;;AAmBA,IAAMsB,IAAOtB,EAAU,oCAAQ,GAOzBuB,IAAiB,qDAEVC,IAAc,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA2DtBF,EAAK;;;QAGLtB,EAAUuB,CAAc,EAAE;;;;UAIxBD,EAAK;;;UAGLtB,EAAUuB,CAAc,EAAE;;;;GCvFvBE,IAA2B,uBAE3BC,IAAoB,yBAE3BC,IAAS,8BACTC,IAAa,gCAGbC,oBAAS,IAAI,QAAyC,GAEtDC,KAAgB,MACpBC,MAAM,WAAWA,MAAM,SAASA,IAAI;AAGtC,SAAgBC,EAAqB,IAAgB,UAAmB;CACtE,IAAMC,IAAMC,EAAI,aAAa;CAC7B,IAAI;EACF,OAAO,CAAC,CAACD,GAAK,WAAW,SAAS,wBAAwB;CAC5D,QAAQ;EACN,OAAO;CACT;AACF;AAGA,SAAgBE,EAAe,IAAgB,UAAiC;CAC9E,IAAMC,IAAOP,EAAO,IAAIK,CAAG;CAC3B,IAAIE,GAAM,OAAOA;CACjB,IAAI;EACF,OAAON,EAAaI,EAAI,aAAa,aAAa,QAAQT,CAAwB,CAAC;CACrF,QAAQ;EACN,OAAO;CACT;AACF;AAGA,SAAgBY,EAAa,IAAgB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AE,MAAM;CAAS,WAAW;AAAc,CAAC,CAAA,GAAA8E,EAAA,WAAA,aAAA,KAAA,CAAA,GAEpD/E,EAAA,CAAAC,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAiB,CAAC,CAAA,GAAA8E,EAAA,WAAA,gBAAA,KAAA,CAAA,GAEtD/E,EAAA,CAAAC,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAe,CAAC,CAAA,GAAA8E,EAAA,WAAA,cAAA,KAAA,CAAA,GAKpD/E,EAAA,CAAAC,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAmB,CAAC,CAAA,GAAA8E,EAAA,WAAA,kBAAA,KAAA,CAAA,GAUxD/E,EAAA,CAAAC,EAAS;CAAE,MAAM;CAAS,WAAW;AAAsB,CAAC,CAAA,GAAA8E,EAAA,WAAA,qBAAA,KAAA,CAAA,GAU5D/E,EAAA,CAAAE,EAAM,CAAA,GAAA6E,EAAA,WAAA,gBAAA,KAAA,CAAA,GAMN/E,EAAA,CAAAE,EAAM,CAAA,GAAA6E,EAAA,WAAA,aAAA,KAAA,CAAA,GChdTxE,EAAO,eAAewE,CAAU;AAIhC,IAAMkD,IAAa,eAAe,IAAI,eAAe;AACjDA,KAAcA,MAAelH,KAC/B,QAAQ,KACN,gKACF"}
@@ -0,0 +1,53 @@
1
+ // src/base/source-children.ts
2
+ var e = {
3
+ attributes: !0,
4
+ characterData: !0,
5
+ childList: !0,
6
+ subtree: !0
7
+ }, t = class {
8
+ constructor(e, t, n) {
9
+ this.host = e, this.light = t, this.read = n, this.own = /* @__PURE__ */ new WeakSet(), this.marked = !1, e.addController(this);
10
+ }
11
+ hostConnected() {
12
+ this.sync(), this.host.hasUpdated && this.watch();
13
+ }
14
+ hostDisconnected() {
15
+ this.observer?.disconnect();
16
+ }
17
+ hostUpdate() {
18
+ this.light() && this.adopt();
19
+ }
20
+ hostUpdated() {
21
+ if (this.light()) for (let e of this.host.childNodes) e !== this.holder && this.own.add(e);
22
+ this.marked || (this.marked = !0, this.sync(), this.watch());
23
+ }
24
+ nodes() {
25
+ return this.light() ? this.adopt() : [...this.host.childNodes];
26
+ }
27
+ sync() {
28
+ this.read(this.nodes());
29
+ }
30
+ adopt() {
31
+ let t = this.host, n = [...t.childNodes].filter((e) => e !== this.holder && !this.own.has(e));
32
+ return n.length && !this.holder && (this.holder = t.ownerDocument.createElement("div"), this.holder.hidden = !0, this.holder.className = `${t.localName}-source`, this.observer && this.marked && this.observer.observe(this.holder, e)), this.holder && (this.holder.append(...n), this.holder.parentNode !== t && t.prepend(this.holder)), this.holder ? [...this.holder.childNodes] : [];
33
+ }
34
+ watch() {
35
+ this.observer ??= new MutationObserver(() => this.sync()), this.observer.disconnect(), this.light() ? (this.observer.observe(this.host, { childList: !0 }), this.holder && this.observer.observe(this.holder, e)) : this.observer.observe(this.host, e);
36
+ }
37
+ }, n = /* @__PURE__ */ new Set([
38
+ "http:",
39
+ "https:",
40
+ "mailto:",
41
+ "tel:"
42
+ ]);
43
+ function r(e, t) {
44
+ try {
45
+ return n.has(new URL(e, t).protocol);
46
+ } catch {
47
+ return !1;
48
+ }
49
+ }
50
+ var i = (e) => String(e ?? "").replace(/\s+/g, " ").trim();
51
+ export { i as n, r, t };
52
+
53
+ //# sourceMappingURL=source-children-BHsDwCvL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-children-BHsDwCvL.js","names":["CONTENT","SourceChildren","host","light","read","n","incoming","SAFE_SCHEMES","safeHref","href","base","normalize","s"],"sources":["../../src/base/source-children.ts"],"sourcesContent":["import type { ReactiveController, ReactiveElement } from 'lit';\n\n/** What is watched in the author's children: elements, their attributes and text. */\nconst CONTENT: MutationObserverInit = {\n attributes: true,\n characterData: true,\n childList: true,\n subtree: true,\n};\n\n/**\n * The author's children of an element that draws its own copy of them (a list of links, a\n * description list), in shadow or light DOM, and their later changes.\n *\n * Shadow mode: the children stay where they are (with no slot they are not shown) and are\n * watched. Light mode has no slots: the children are moved into a hidden holder `<div>`\n * that this element owns, and nodes the element renders itself are never adopted.\n *\n * `read` gets the source nodes on connect, after the first render and on every change; the\n * element compares them with what it has and only asks for an update on a real change.\n */\nexport class SourceChildren implements ReactiveController {\n private observer?: MutationObserver;\n private holder?: HTMLDivElement;\n /** Light mode: nodes the element rendered itself (incl. Lit markers), never adopted. */\n private own = new WeakSet<Node>();\n private marked = false;\n\n constructor(\n private host: ReactiveElement,\n private light: () => boolean,\n private read: (nodes: Node[]) => void,\n ) {\n host.addController(this);\n }\n\n hostConnected(): void {\n // Read before the first render, so it costs no second update.\n this.sync();\n if (this.host.hasUpdated) this.watch();\n }\n\n hostDisconnected(): void {\n this.observer?.disconnect();\n }\n\n /**\n * Light mode, before each render: adopt any author children still on the host, so that\n * after it every other child of the host is the element's own output.\n */\n hostUpdate(): void {\n if (this.light()) this.adopt();\n }\n\n /**\n * Light mode, after each render: mark everything on the host but the holder as the\n * element's own (Lit's markers and whatever it rendered, also on later renders), so its\n * output is never adopted as author content.\n */\n hostUpdated(): void {\n if (this.light()) for (const n of this.host.childNodes) if (n !== this.holder) this.own.add(n);\n if (this.marked) return;\n this.marked = true;\n this.sync();\n this.watch();\n }\n\n /** The source nodes now (in light mode, adopting any new children first). */\n nodes(): Node[] {\n return this.light() ? this.adopt() : [...this.host.childNodes];\n }\n\n private sync(): void {\n this.read(this.nodes());\n }\n\n private adopt(): Node[] {\n const host = this.host;\n const incoming = [...host.childNodes].filter((n) => n !== this.holder && !this.own.has(n));\n if (incoming.length && !this.holder) {\n this.holder = host.ownerDocument.createElement('div');\n this.holder.hidden = true;\n this.holder.className = `${host.localName}-source`;\n // Created after watch() ran (children added later): watch it too.\n if (this.observer && this.marked) this.observer.observe(this.holder, CONTENT);\n }\n if (this.holder) {\n this.holder.append(...incoming);\n if (this.holder.parentNode !== host) host.prepend(this.holder);\n }\n return this.holder ? [...this.holder.childNodes] : [];\n }\n\n /** Shadow mode: the children, subtree included. Light mode: the host's new children and the holder. */\n private watch(): void {\n this.observer ??= new MutationObserver(() => this.sync());\n this.observer.disconnect();\n if (this.light()) {\n this.observer.observe(this.host, { childList: true });\n if (this.holder) this.observer.observe(this.holder, CONTENT);\n } else {\n this.observer.observe(this.host, CONTENT);\n }\n }\n}\n\n/** Schemes a component may link to; anything else (javascript:, data:, …) is shown as text. */\nconst SAFE_SCHEMES = new Set(['http:', 'https:', 'mailto:', 'tel:']);\n\n/** Whether `href` may be a link: relative, hash, http(s), mailto and tel. */\nexport function safeHref(href: string, base: string): boolean {\n try {\n return SAFE_SCHEMES.has(new URL(href, base).protocol);\n } catch {\n return false;\n }\n}\n\n/** Collapse whitespace and trim. */\nexport const normalize = (s: unknown): string =>\n String(s ?? '')\n .replace(/\\s+/g, ' ')\n .trim();\n"],"mappings":";AAGA,IAAMA,IAAgC;CACpC,YAAY;CACZ,eAAe;CACf,WAAW;CACX,SAAS;AACX,GAaaC,IAAb,MAA0D;CAOxD,YACE,GACA,GACA,GACA;EACA,AAJQ,KAAA,OAAAC,GACA,KAAA,QAAAC,GACA,KAAA,OAAAC,GANI,KAAA,sBAAA,IAAI,QAAc,GACf,KAAA,SAAA,IAOfF,EAAK,cAAc,IAAI;CACzB;CAEA,gBAAsB;EAGpB,AADA,KAAK,KAAK,GACN,KAAK,KAAK,cAAY,KAAK,MAAM;CACvC;CAEA,mBAAyB;EACvB,KAAK,UAAU,WAAW;CAC5B;CAMA,aAAmB;EACjB,AAAI,KAAK,MAAM,KAAG,KAAK,MAAM;CAC/B;CAOA,cAAoB;EAClB,IAAI,KAAK,MAAM,GAAQ,KAAA,IAAMG,KAAK,KAAK,KAAK,YAAY,AAAIA,MAAM,KAAK,UAAQ,KAAK,IAAI,IAAIA,CAAC;EAC7F,AAAI,KAAK,WACT,KAAK,SAAS,IACd,KAAK,KAAK,GACV,KAAK,MAAM;CACb;CAGA,QAAgB;EACd,OAAO,KAAK,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC,GAAG,KAAK,KAAK,UAAU;CAC/D;CAEA,OAAqB;EACnB,KAAK,KAA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) {
3
+ return e.startsWith("#/") || e.startsWith("#!/") || e.includes("?");
4
+ }
5
+ function t(t, n) {
6
+ if (!n) return null;
7
+ if (e(t.hash)) {
8
+ let e = t.hash.indexOf("?");
9
+ return new URLSearchParams(e >= 0 ? t.hash.slice(e + 1) : "").get(n);
10
+ }
11
+ return new URLSearchParams(t.search).get(n);
12
+ }
13
+ function n(t, n, r, i, a = !1) {
14
+ let o = r !== null && (r !== "" || a);
15
+ if (i ?? e(t.hash)) {
16
+ let e = t.hash.indexOf("?"), i = e >= 0 ? t.hash.slice(0, e) : t.hash, a = new URLSearchParams(e >= 0 ? t.hash.slice(e + 1) : "");
17
+ o ? a.set(n, r) : a.delete(n);
18
+ let s = a.toString();
19
+ return t.pathname + t.search + (s ? `${i}?${s}` : i);
20
+ }
21
+ let s = new URLSearchParams(t.search);
22
+ o ? s.set(n, r) : s.delete(n);
23
+ let c = s.toString();
24
+ return t.pathname + (c ? `?${c}` : "") + t.hash;
25
+ }
26
+ export { t as n, e as r, n as t };
27
+
28
+ //# sourceMappingURL=url-param-C1sk_F1d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-param-C1sk_F1d.js","names":["usesHashParam","hash","paramFromLocation","name","loc","q","hrefWithParam","set","id","keepEmpty","hashMode","path","params","qs"],"sources":["../../src/base/url-param.ts"],"sourcesContent":["/**\n * Keep a query parameter in the address, in the search string or, on a hash route, inside the\n * hash. Shared by `<uvalib-lightbox url-param>` and `<uvalib-chip-group url-param>`.\n */\n\n/** Location pieces the deep-link helpers read and write. `search` includes the leading `?`. */\nexport interface PageLocation {\n pathname: string;\n search: string;\n hash: string;\n}\n\n/** A hash used as a route (`#/…`, `#!/…`) or that already carries a query string. */\nexport function usesHashParam(hash: string): boolean {\n return hash.startsWith('#/') || hash.startsWith('#!/') || hash.includes('?');\n}\n\n/** The deep-link id in `loc`, from the hash query on a hash route and the search string otherwise. */\nexport function paramFromLocation(loc: PageLocation, name: string): string | null {\n if (!name) return null;\n if (usesHashParam(loc.hash)) {\n const q = loc.hash.indexOf('?');\n const params = new URLSearchParams(q >= 0 ? loc.hash.slice(q + 1) : '');\n return params.get(name);\n }\n return new URLSearchParams(loc.search).get(name);\n}\n\n/**\n * `loc` with `name` set to `id`, or removed when `id` is null. Hash routes keep the param in\n * the hash (`#/text/d9?photo=2`) and leave `search` alone; every other URL uses `search` and\n * keeps the hash. The hash is written as text so a `?` in it is not percent-encoded.\n * `hashMode` forces the hash (or the search) when the caller is mid-rewrite and the hash no\n * longer shows that it was a route, as when `?photo=` was just removed from `#chapter?photo=1`.\n * `keepEmpty` writes an empty `id` as `?name=` instead of removing the parameter.\n */\nexport function hrefWithParam(\n loc: PageLocation,\n name: string,\n id: string | null,\n hashMode?: boolean,\n keepEmpty = false,\n): string {\n const set = id !== null && (id !== '' || keepEmpty);\n if (hashMode ?? usesHashParam(loc.hash)) {\n const q = loc.hash.indexOf('?');\n const path = q >= 0 ? loc.hash.slice(0, q) : loc.hash;\n const params = new URLSearchParams(q >= 0 ? loc.hash.slice(q + 1) : '');\n if (set) params.set(name, id);\n else params.delete(name);\n const qs = params.toString();\n return loc.pathname + loc.search + (qs ? `${path}?${qs}` : path);\n }\n const params = new URLSearchParams(loc.search);\n if (set) params.set(name, id);\n else params.delete(name);\n const qs = params.toString();\n return loc.pathname + (qs ? `?${qs}` : '') + loc.hash;\n}\n"],"mappings":";AAaA,SAAgBA,EAAc,GAAuB;CACnD,OAAOC,EAAK,WAAW,IAAI,KAAKA,EAAK,WAAW,KAAK,KAAKA,EAAK,SAAS,GAAG;AAC7E;AAGA,SAAgBC,EAAkB,GAAmB,GAA6B;CAChF,IAAI,CAACC,GAAM,OAAO;CAClB,IAAIH,EAAcI,EAAI,IAAI,GAAG;EAC3B,IAAMC,IAAID,EAAI,KAAK,QAAQ,GAAG;EAE9B,OAAO,IADY,gBAAgBC,KAAK,IAAID,EAAI,KAAK,MAAMC,IAAI,CAAC,IAAI,EAC7D,CAAA,CAAO,IAAIF,CAAI;CACxB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