@uvalib/web-components 1.11.1 → 1.12.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.
- package/CHANGELOG.md +21 -0
- package/README.md +192 -54
- package/dist/base.css +56 -2
- package/dist/components/uvalib-audio/UvalibAudio.d.ts +186 -0
- package/dist/components/uvalib-audio/UvalibAudio.js +1154 -0
- package/dist/components/uvalib-audio/UvalibAudio.js.map +1 -0
- package/dist/components/uvalib-audio/uvalib-audio.d.ts +1 -0
- package/dist/components/uvalib-audio/uvalib-audio.js +4 -0
- package/dist/components/uvalib-audio/uvalib-audio.js.map +1 -0
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.d.ts +25 -5
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +62 -9
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -1
- package/dist/custom-elements.json +8486 -7187
- package/dist/edition-epub.css +511 -0
- package/dist/edition-print.css +51 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/styles/base.js +55 -1
- package/dist/styles/base.js.map +1 -1
- package/dist/styles/edition.d.ts +6 -0
- package/dist/styles/edition.js +20 -0
- package/dist/styles/edition.js.map +1 -1
- package/dist-cdn/base.css +56 -2
- package/dist-cdn/chunks/{base-DtkA4Pgg.js → base-D_oPO5cX.js} +56 -2
- package/dist-cdn/chunks/{base-DtkA4Pgg.js.map → base-D_oPO5cX.js.map} +1 -1
- package/dist-cdn/custom-elements.json +8486 -7187
- package/dist-cdn/edition-epub.css +511 -0
- package/dist-cdn/edition-print.css +51 -0
- package/dist-cdn/manifest.json +6 -3
- package/dist-cdn/site-page.js +1 -1
- package/dist-cdn/site-style.js +1 -1
- package/dist-cdn/skills/uvalib-web-components/SKILL.md +35 -4
- package/dist-cdn/skills/uvalib-web-components/reference/components.md +53 -1
- package/dist-cdn/uvalib-audio.js +747 -0
- package/dist-cdn/uvalib-audio.js.map +1 -0
- package/dist-cdn/uvalib-pagefind-search.js +70 -44
- package/dist-cdn/uvalib-pagefind-search.js.map +1 -1
- package/package.json +7 -1
- package/skills/uvalib-web-components/SKILL.md +35 -4
- package/skills/uvalib-web-components/reference/components.md +53 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uvalib-audio.js","names":["unsafeCSS","nothing","_decorate","property","state","n","w","i","r$1","b","define","__decorate","A","r","installLightDomStyles","UvalibElement","trackEvent","trackError","inlineCopy","normalize","safeHref","SourceChildren","accessible","TAG","uid","SPEEDS","SKIP","audioTiming","CLEAR_MS","parseDuration","text","sum","part","clock","s","seconds","h","m","ss","unit","word","spoken","parts","formatSize","value","units","v","mediaHref","href","base","u","KEPT_LINK_ATTRS","players","PLAY","PAUSE","BACK","FORWARD","structuralRules","host","shadowStructure","TEXT","MUTED","LINK","BUTTON_BG","BUTTON_HOVER","BUTTON_TEXT","RAISED","RULE","ACCENT","ON_ACCENT","CURRENT","BORDER","UvalibAudio","c","a","t","p","next","name","nodes","root","sheet","node","kind","message","list","doc","chapters","key","li","links","title","extras","x","xh","attrs","copy","download","dh","duration","extra","raw","changed","saved","index","from","at","e","resumeAt","max","to","by","ms","set","d","media","say","debounced","size","rc","state","id","total","time","playing","current","failed","attr"],"sources":["../src/components/uvalib-audio/UvalibAudio.ts","../src/components/uvalib-audio/uvalib-audio.ts"],"sourcesContent":["import { css, html, nothing, svg, unsafeCSS, type PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { trackError, trackEvent } from '../../base/analytics.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { inlineCopy } from '../../base/inline-copy.js';\nimport { normalize, safeHref, SourceChildren } from '../../base/source-children.js';\nimport { accessible } from '../../styles/accessible.js';\n\nconst TAG = 'uvalib-audio';\nlet uid = 0;\n\n/** The playback speeds offered, slowest first. */\nexport const SPEEDS = [0.75, 1, 1.25, 1.5, 1.75, 2] as const;\n/** Back and Forward, in seconds: the podcast convention (a missed phrase back, a skip ahead). */\nexport const SKIP = { back: 15, forward: 30 } as const;\n/**\n * How long (ms) to wait before announcing (a burst of skips is announced once, where it\n * ends), saving the position while playing, and reporting a speed change to analytics.\n * Tests may shorten them.\n */\nexport const audioTiming = { announce: 600, save: 5000, speed: 1000 };\n/** How long an announcement stays in the live region before it is cleared. */\nconst CLEAR_MS = 5000;\n\n/** A link kept from a chapter's item (a transcript, the text), drawn after it. */\ninterface Extra {\n href: string;\n nodes: Node[];\n attrs: [string, string][];\n}\n\n/** A chapter as read from its `<li>`. */\ninterface Chapter {\n /** The audio file's URL, resolved. */\n src: string;\n /** The `href` as written, for the direct link when it fails. */\n href: string;\n title: string;\n nodes: Node[];\n /** Seconds from `data-duration`, if given. */\n duration?: number;\n extras: Extra[];\n download?: { href: string; size: string };\n}\n\n/** What is kept in localStorage for a page: the chapter (by file and place), position, speed. */\ninterface Saved {\n src?: string;\n chapter: number;\n time: number;\n speed?: number;\n}\n\n/** `12:31`, `1:02:03` or `751` (seconds) to seconds; undefined when unreadable. */\nexport function parseDuration(text: string | null | undefined): number | undefined {\n const t = normalize(text);\n if (!t) return undefined;\n if (/^\\d+(\\.\\d+)?$/.test(t)) return Number(t);\n if (!/^\\d+(:\\d{1,2}){1,2}$/.test(t)) return undefined;\n return t.split(':').reduce((sum, part) => sum * 60 + Number(part), 0);\n}\n\n/** 754 → `12:34`, 3723 → `1:02:03`. */\nexport function clock(seconds: number): string {\n const s = Math.max(0, Math.floor(seconds || 0));\n const h = Math.floor(s / 3600);\n const m = Math.floor((s % 3600) / 60);\n const ss = String(s % 60).padStart(2, '0');\n return h ? `${h}:${String(m).padStart(2, '0')}:${ss}` : `${m}:${ss}`;\n}\n\nconst unit = (n: number, word: string) => `${n} ${word}${n === 1 ? '' : 's'}`;\n\n/** 750 → `12 minutes 30 seconds`, 3600 → `1 hour`, 0 → `0 seconds`. */\nexport function spoken(seconds: number): string {\n const s = Math.max(0, Math.floor(seconds || 0));\n const parts: string[] = [];\n const h = Math.floor(s / 3600);\n const m = Math.floor((s % 3600) / 60);\n if (h) parts.push(unit(h, 'hour'));\n if (m) parts.push(unit(m, 'minute'));\n if (s % 60 || !parts.length) parts.push(unit(s % 60, 'second'));\n return parts.join(' ');\n}\n\n/**\n * A size as written (`312 MB`), or a number of bytes made readable in decimal units, as\n * operating systems show file sizes: `312000000` → `312 MB`, `1500000` → `1.5 MB`.\n */\nexport function formatSize(value: string | null | undefined): string {\n const t = normalize(value);\n if (!/^\\d+$/.test(t)) return t;\n const n = Number(t);\n const units = ['bytes', 'KB', 'MB', 'GB', 'TB'];\n let i = 0;\n let v = n;\n while (v >= 1000 && i < units.length - 1) {\n v /= 1000;\n i++;\n }\n if (i === 0) return `${n} ${n === 1 ? 'byte' : 'bytes'}`;\n const shown = v < 10 ? Math.round(v * 10) / 10 : Math.round(v);\n return `${shown.toLocaleString('en-US')} ${units[i]}`;\n}\n\n/** Media files may also be blob: URLs (made in script) and data:audio URLs. */\nconst mediaHref = (href: string, base: string): boolean => {\n if (safeHref(href, base)) return true;\n try {\n const u = new URL(href, base);\n return u.protocol === 'blob:' || (u.protocol === 'data:' && /^data:audio\\//i.test(href));\n } catch {\n return false;\n }\n};\n\nconst KEPT_LINK_ATTRS = ['hreflang', 'type', 'target', 'rel', 'download', 'lang'];\n\n/** Every instance on the page: starting one pauses the others. */\nconst players = new Set<UvalibAudio>();\n\nconst PLAY = svg`<svg class=\"icon\" viewBox=\"0 0 16 16\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M4 2.5v11l9.5-5.5z\" fill=\"currentColor\"/></svg>`;\nconst PAUSE = svg`<svg class=\"icon\" viewBox=\"0 0 16 16\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M3.5 2.5h3v11h-3zM9.5 2.5h3v11h-3z\" fill=\"currentColor\"/></svg>`;\nconst BACK = svg`<svg class=\"icon\" viewBox=\"0 0 16 16\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M3 8a5 5 0 1 0 1.6-3.7\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\"/><path d=\"M2.2 1.8v3.6h3.6\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>`;\nconst FORWARD = svg`<svg class=\"icon\" viewBox=\"0 0 16 16\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M13 8a5 5 0 1 1-1.6-3.7\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\"/><path d=\"M13.8 1.8v3.6h-3.6\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>`;\n\n/**\n * Kept with `no-style`: the player's rows and 44px controls, the chapter rows' 44px buttons,\n * the visually hidden text, and `[hidden]`. Shared with base.css's pre-upgrade hold: keep the\n * heights in step with `audioHold` in src/styles/base.ts. `host` is `:host` or the tag.\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; container-type: inline-size; font-size: 1rem; line-height: 1.5; }\n ${host} .player {\n box-sizing: border-box;\n display: grid;\n gap: 0.5rem;\n margin: 0 0 1rem;\n padding: 0.75rem;\n border: 1px solid transparent;\n }\n ${host} .now { display: flex; align-items: center; min-block-size: 44px; margin: 0; overflow-wrap: anywhere; }\n ${host} .controls {\n display: grid;\n grid-template-columns: auto minmax(6rem, 1fr) auto;\n grid-template-areas: 'buttons seek speed';\n gap: 0.5rem 0.75rem;\n align-items: center;\n }\n ${host} .buttons { grid-area: buttons; display: flex; gap: 0.5rem; }\n ${host} .seek { grid-area: seek; display: flex; align-items: center; gap: 0.5rem; min-inline-size: 0; block-size: 44px; }\n ${host} .seek input { flex: 1; min-inline-size: 0; block-size: 44px; margin: 0; }\n ${host} .time { white-space: nowrap; font-variant-numeric: tabular-nums; }\n ${host} .speed { grid-area: speed; display: flex; align-items: center; gap: 0.5rem; block-size: 44px; }\n ${host} .speed select { box-sizing: border-box; min-block-size: 44px; font: inherit; }\n ${host} button, ${host} .link-button {\n box-sizing: border-box;\n min-block-size: 44px;\n min-inline-size: 44px;\n margin: 0;\n font: inherit;\n line-height: 1.2;\n cursor: pointer;\n }\n ${host} .ctl { display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem; padding: 0.25rem 0.5rem; white-space: nowrap; }\n ${host} .ctl.play { min-inline-size: 5.5rem; }\n ${host} .icon { flex: none; inline-size: 1em; block-size: 1em; }\n ${host} .download { margin: 0 0 1rem; }\n /* One inner span keeps the spaces around “·” (a flex container would drop them). */\n ${host} .download a, ${host} .chapter a { display: inline-flex; align-items: center; min-block-size: 44px; }\n ${host} .chapters { margin: 0; padding: 0; list-style: none; }\n ${host} .chapter {\n display: grid;\n grid-template-columns: minmax(0, 1fr) auto;\n align-items: center;\n column-gap: 0.75rem;\n box-sizing: border-box;\n margin: 0;\n padding: 0.25rem 0;\n border-block-end: 1px solid transparent;\n }\n ${host} .chapter-play {\n display: flex;\n align-items: center;\n gap: 0.75rem;\n min-inline-size: 0;\n padding: 0.25rem 0.5rem;\n border: 0;\n background: none;\n color: inherit;\n text-align: start;\n }\n ${host} .chip { display: inline-flex; flex: none; align-items: center; justify-content: center; gap: 0.375rem; box-sizing: border-box; inline-size: 5rem; min-block-size: 2rem; }\n ${host} .chapter-title { min-inline-size: 0; overflow-wrap: anywhere; }\n ${host} .duration { white-space: nowrap; font-variant-numeric: tabular-nums; }\n ${host} .more { grid-column: 1 / -1; display: flex; flex-wrap: wrap; column-gap: 1rem; padding-inline-start: calc(0.5rem + 5rem + 0.75rem); }\n ${host} .error { grid-column: 1 / -1; margin: 0; padding-inline: 0.5rem; }\n ${host} .visually-hidden {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n @container (width < 44rem) {\n ${host} .controls {\n grid-template-columns: auto auto;\n grid-template-areas: 'seek seek' 'buttons speed';\n justify-content: space-between;\n }\n }\n @container (width < 26rem) {\n ${host} .controls { grid-template-columns: auto; grid-template-areas: 'seek' 'buttons' 'speed'; justify-content: stretch; }\n ${host} .more { padding-inline-start: 0.5rem; }\n }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\nconst TEXT = unsafeCSS('var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b))');\nconst MUTED = unsafeCSS('var(--uva-color-text-muted, #4b5563)');\nconst LINK = unsafeCSS('var(--uva-color-link, var(--uva-brand-blue, #232d4b))');\nconst BUTTON_BG = unsafeCSS('var(--uva-color-button-bg, var(--uva-blue-alt, #007bac))');\nconst BUTTON_HOVER = unsafeCSS('var(--uva-color-button-hover-bg, var(--uva-blue-alt-A, #005679))');\nconst BUTTON_TEXT = unsafeCSS('var(--uva-color-button-text, #ffffff)');\nconst RAISED = unsafeCSS('var(--uva-color-surface-raised, #ffffff)');\nconst RULE = unsafeCSS('var(--uva-color-table-border, var(--uva-grey-100, #dadada))');\nconst ACCENT = unsafeCSS('var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b))');\nconst ON_ACCENT = unsafeCSS('var(--uva-color-on-accent, #ffffff)');\nconst CURRENT = unsafeCSS('var(--uva-color-current, var(--uva-brand-orange, #e57200))');\nconst BORDER = unsafeCSS('var(--uva-color-control-border, var(--uva-grey, #808080))');\n\n/**\n * A long recording played by chapter: an audiobook, an oral history's sessions. One player\n * for the whole list, so starting a chapter stops the one playing.\n *\n * Give the chapters as a list of links to their files, so the page works before (and\n * without) the script: `<ol><li><a href=\"ch1.mp3\" data-duration=\"12:31\">Chapter 1. Down the\n * Rabbit-Hole</a></li>…</ol>`. The first link in each item is the chapter (its text is the\n * title; inline markup such as `<i>` or `lang` is kept); `data-duration` (`12:31`, `1:02:03` or\n * seconds) is shown beside it and gives the slider its length before the file loads. Other\n * links in the item (the chapter's text, a transcript) are kept as links after it.\n * `data-download` on the `<li>` adds a Download link for that chapter (its own file, or the\n * URL given), with `data-size` (bytes or text) after it.\n *\n * Upgraded, each chapter is a real button (“Play Chapter 1. Down the Rabbit-Hole”, its\n * visible text), with its duration; the current chapter gets `aria-current=\"true\"` and says\n * “Now playing” or “Paused” in text, beside an orange bar. Above the list, a player for the\n * current chapter: what is playing (as text, not a live region), Back 15 s, Play/Pause,\n * Forward 30 s, a position slider (a native range, read as “12 minutes 30 seconds of 41\n * minutes”), the elapsed and total time, and a native Speed select (0.75× to 2×). One\n * `<audio preload=\"none\">` plays everything: nothing loads until the visitor presses Play,\n * and nothing ever plays without a press.\n *\n * `continuous` plays the next chapter when one ends. The position is remembered per page in\n * localStorage (the page's path, plus `storage-key` when a page has more than one\n * recording): on the next visit a “Resume “Chapter 4” at 12:30” button offers to carry on,\n * never playing by itself. Saved on pause, every few seconds while playing, and when the page\n * is left; cleared when the last chapter ends. `no-resume` turns it off. Without storage it\n * simply forgets.\n *\n * Chapter changes, pauses, speed changes and skips are announced politely in one status\n * (a burst of skips once, where it ends); the time is never announced as it runs. A chapter\n * that fails to load says so in text, with a direct link to its file. `download-href` adds a\n * link to the whole recording (an M4B audiobook), with `download-label` and `download-size`\n * (bytes, shown as “312 MB”, or text). Where the browser has the Media Session API, the\n * system's media keys and lock screen show the chapter and can play, pause, seek and change\n * chapter.\n *\n * Before it upgrades, `base.css` holds the player's height above the list and gives each\n * item the height of its upgraded row, so the list does not move.\n *\n * @tagname uvalib-audio\n * @fires uvalib-analytics-event - For `<site-analytics>`, on the visitor's actions only, never titles or URLs: `['uvalib-audio', 'play', 'chapter <N>', N]` the first time each chapter plays in a page view (N is its place in the list), `['uvalib-audio', 'complete', 'chapter <N>', N]` when it plays to its end, `['uvalib-audio', 'speed', '<speed>', speed]` once the visitor settles on a speed, `['uvalib-audio', 'resume', 'chapter <N>', N]`, and `['uvalib-audio', 'download', 'recording' | 'chapter <N>']`. Bubbles and is composed.\n * @csspart player - The player box above the list.\n * @csspart now - The line saying what is playing (or the Resume button).\n * @csspart controls - The player's buttons, slider, time and speed.\n * @csspart download - The whole recording's download line.\n * @csspart list - The list of chapters.\n * @csspart chapter - Each chapter's row.\n * @cssprop --uva-color-text - Dark-mode role token: text (else `--uva-grey-darkest`).\n * @cssprop --uva-color-text-muted - Dark-mode role token: durations (else #4b5563).\n * @cssprop --uva-color-link - Dark-mode role token: links and the outline buttons (else `--uva-brand-blue`).\n * @cssprop --uva-color-button-bg - Dark-mode role token: Play/Pause and the slider (else `--uva-blue-alt`).\n * @cssprop --uva-color-button-text - Dark-mode role token: Play/Pause text (else #fff).\n * @cssprop --uva-color-surface-raised - Dark-mode role token: the player's and the controls' background (else #fff).\n * @cssprop --uva-color-table-border - Dark-mode role token: the player's border and the rules between chapters (else #dadada).\n * @cssprop --uva-color-accent-bg - Dark-mode role token: the “Now playing” marker (else `--uva-brand-blue`).\n * @cssprop --uva-color-on-accent - Dark-mode role token: the marker's text (else #fff).\n * @cssprop --uva-color-current - Dark-mode role token: the current chapter's bar (else `--uva-brand-orange`).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n */\nexport class UvalibAudio extends UvalibElement {\n static styles = [\n accessible,\n shadowStructure,\n css`\n :host {\n color: ${TEXT};\n }\n .player {\n border-color: ${RULE};\n border-radius: 5px;\n background: ${RAISED};\n }\n .now .state {\n font-weight: 700;\n }\n .ctl {\n border: 2px solid ${BUTTON_BG};\n border-radius: 5px;\n background: ${RAISED};\n color: ${LINK};\n }\n .ctl.play {\n background: ${BUTTON_BG};\n color: ${BUTTON_TEXT};\n }\n .ctl:hover {\n border-color: ${BUTTON_HOVER};\n text-decoration: underline;\n }\n .ctl.play:hover {\n background: ${BUTTON_HOVER};\n }\n .resume {\n padding: 0.25rem 0.75rem;\n border: 2px solid ${BUTTON_BG};\n border-radius: 5px;\n background: ${BUTTON_BG};\n color: ${BUTTON_TEXT};\n text-align: start;\n }\n .resume:hover {\n background: ${BUTTON_HOVER};\n border-color: ${BUTTON_HOVER};\n }\n .seek input {\n accent-color: ${BUTTON_BG};\n }\n .speed label {\n font-weight: 600;\n }\n .speed select {\n padding: 0.25rem 0.5rem;\n border: 1px solid ${BORDER};\n border-radius: 5px;\n background: ${RAISED};\n color: ${TEXT};\n }\n a {\n color: ${LINK};\n }\n .chapter {\n border-block-end-color: ${RULE};\n padding-inline-start: 4px;\n border-inline-start: 4px solid transparent;\n }\n .chapter[aria-current] {\n border-inline-start-color: ${CURRENT};\n }\n .chapter-play {\n border-radius: 5px;\n }\n .chip {\n padding: 0.125rem 0.5rem;\n border: 2px solid ${BUTTON_BG};\n border-radius: 5px;\n color: ${LINK};\n font-weight: 600;\n }\n .chapter-play:hover .chip {\n border-color: ${BUTTON_HOVER};\n }\n .chapter-play:hover .chapter-title {\n text-decoration: underline;\n }\n .chapter[aria-current] .chip {\n background: ${BUTTON_BG};\n color: ${BUTTON_TEXT};\n }\n .marker {\n display: inline-block;\n margin-inline-start: 0.5rem;\n padding: 0 0.375rem;\n border: 1px solid transparent;\n border-radius: 3px;\n background: ${ACCENT};\n color: ${ON_ACCENT};\n font-size: 0.875rem;\n font-weight: 700;\n white-space: nowrap;\n }\n .duration {\n color: ${MUTED};\n }\n .error {\n font-weight: 600;\n }\n @media (forced-colors: active) {\n .player,\n .ctl,\n .resume,\n .chip {\n border-color: ButtonText;\n }\n .ctl,\n .chip {\n color: ButtonText;\n }\n .chapter[aria-current] {\n border-inline-start-color: Highlight;\n }\n .chapter[aria-current] .chip,\n .marker {\n forced-color-adjust: none;\n border-color: Highlight;\n background: Highlight;\n color: HighlightText;\n }\n }\n @media (prefers-reduced-motion: reduce) {\n * {\n transition: none !important;\n animation: none !important;\n }\n }\n `,\n ];\n\n /** The player's accessible name, such as the book's title (default “Player”). */\n @property({ type: String }) label = '';\n\n /** Play the next chapter when one ends. */\n @property({ type: Boolean, reflect: true }) continuous = false;\n\n /** Don't remember the position (nothing is read from or written to localStorage). */\n @property({ type: Boolean, attribute: 'no-resume' }) noResume = false;\n\n /** Added to the page's path to name what is remembered, for a page with several recordings. */\n @property({ type: String, attribute: 'storage-key' }) storageKey = '';\n\n /** The whole recording to download (an M4B audiobook with chapters, an MP3). */\n @property({ type: String, attribute: 'download-href' }) downloadHref = '';\n\n /** The download link's text. */\n @property({ type: String, attribute: 'download-label' }) downloadLabel =\n 'Download the whole recording';\n\n /** The download's size: bytes (shown as “312 MB”) or text. */\n @property({ type: String, attribute: 'download-size' }) downloadSize = '';\n\n @state() private chapters: Chapter[] = [];\n /** The current chapter's index, or -1 before any. */\n @state() private currentIndex = -1;\n @state() private isPlaying = false;\n @state() private finished = false;\n /** Whole seconds into the current chapter. */\n @state() private time = 0;\n @state() private speed = 1;\n @state() private resume?: { index: number; time: number };\n @state() private failed = new Set<number>();\n /** Durations read from the files once loaded, by index. */\n @state() private loaded = new Map<number, number>();\n @state() private announcement = '';\n\n private readonly uid = `${TAG}-${++uid}`;\n private readonly source: SourceChildren;\n private sourceKey = '';\n private restored = false;\n /** The chapter whose file is in the audio element, or -1. */\n private srcIndex = -1;\n /** A position to seek to once the current file's metadata is in. */\n private pendingTime?: number;\n private played = new Set<number>();\n private completed = new Set<number>();\n private lastSave = 0;\n private announceTimer?: ReturnType<typeof setTimeout>;\n private clearTimer?: ReturnType<typeof setTimeout>;\n private speedTimer?: ReturnType<typeof setTimeout>;\n private reportedSpeed = 1;\n private warned = new Set<string>();\n\n constructor() {\n super();\n this.source = new SourceChildren(\n this,\n () => this.lightDom,\n (nodes) => this.read(nodes),\n );\n }\n\n /** The current chapter's index (0-based), or -1 before any is chosen. */\n get current(): number {\n return this.currentIndex;\n }\n\n /** Whether a chapter is playing. */\n get playing(): boolean {\n return this.isPlaying;\n }\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (root instanceof ShadowRoot && this.noStyle) {\n const sheet = shadowStructure.styleSheet;\n if (sheet) root.adoptedStyleSheets = [sheet];\n }\n return root;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (this.lightDom && this.noStyle) {\n const node = this.getRootNode();\n installLightDomStyles(`${TAG}::structure`, unsafeCSS(structuralRules(TAG)), {\n root: node instanceof ShadowRoot || node instanceof Document ? node : undefined,\n scope: false,\n });\n }\n players.add(this);\n window.addEventListener('pagehide', this.save);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n players.delete(this);\n window.removeEventListener('pagehide', this.save);\n this.save();\n this.audio?.pause();\n this.releaseMediaSession();\n clearTimeout(this.announceTimer);\n clearTimeout(this.clearTimer);\n this.flushSpeed();\n }\n\n private warnOnce(kind: string, message: string): void {\n if (this.warned.has(kind)) return;\n this.warned.add(kind);\n console.warn(`${TAG}: ${message}`);\n }\n\n // ---- the chapters, from the page's list\n\n private read(nodes: Node[]): void {\n const list = nodes.find(\n (n): n is HTMLOListElement | HTMLUListElement =>\n n instanceof Element && (n.localName === 'ol' || n.localName === 'ul'),\n );\n const doc = this.ownerDocument;\n const base = doc.baseURI;\n const chapters: Chapter[] = [];\n let key = '';\n for (const li of list ? [...list.children] : []) {\n if (li.localName !== 'li') continue;\n const links = [...li.querySelectorAll('a[href]')];\n const a = links[0];\n const href = a?.getAttribute('href') ?? '';\n if (!a || !mediaHref(href, base)) {\n this.warnOnce('chapter', 'ignoring a list item without a link to its audio file.');\n continue;\n }\n const title = inlineCopy(a.childNodes, doc);\n const extras: Extra[] = [];\n for (const x of links.slice(1)) {\n const xh = x.getAttribute('href') ?? '';\n if (!safeHref(xh, base)) continue;\n const attrs = KEPT_LINK_ATTRS.flatMap((n): [string, string][] => {\n const v = x.getAttribute(n);\n return v === null ? [] : [[n, v]];\n });\n const copy = inlineCopy(x.childNodes, doc);\n extras.push({ href: xh, nodes: copy.nodes, attrs });\n key += `|x${xh}${copy.key}${JSON.stringify(attrs)}`;\n }\n let download: Chapter['download'];\n if (li.hasAttribute('data-download')) {\n const dh = normalize(li.getAttribute('data-download')) || href;\n if (mediaHref(dh, base))\n download = { href: dh, size: formatSize(li.getAttribute('data-size')) };\n }\n const duration = parseDuration(a.getAttribute('data-duration'));\n chapters.push({\n src: new URL(href, base).href,\n href,\n title: normalize(a.textContent) || `Chapter ${chapters.length + 1}`,\n nodes: title.nodes,\n duration,\n extras,\n download,\n });\n key += `|${href}${title.key}${duration}${download?.href}${download?.size}`;\n }\n if (key === this.sourceKey) return;\n this.sourceKey = key;\n this.chapters = chapters;\n }\n\n // ---- the remembered position\n\n private get storeKey(): string {\n const extra = normalize(this.storageKey);\n return `${TAG}:${location.pathname}${extra ? `#${extra}` : ''}`;\n }\n\n private readSaved(): Saved | undefined {\n if (this.noResume) return undefined;\n try {\n const raw = localStorage.getItem(this.storeKey);\n const v = raw ? (JSON.parse(raw) as Saved) : undefined;\n return v && typeof v.chapter === 'number' && typeof v.time === 'number' ? v : undefined;\n } catch {\n return undefined;\n }\n }\n\n private write(v: Saved | null): void {\n if (this.noResume) return;\n try {\n if (v) localStorage.setItem(this.storeKey, JSON.stringify(v));\n else localStorage.removeItem(this.storeKey);\n } catch {\n // Storage blocked or full: the position lasts for this visit only.\n }\n }\n\n /** Save the current chapter and position (nothing before the visitor has played one). */\n private save = (): void => {\n const i = this.currentIndex;\n const c = this.chapters[i];\n if (!c || this.finished || this.failed.has(i)) return;\n const a = this.audio;\n const t = this.srcIndex === i && a ? a.currentTime : (this.pendingTime ?? this.time);\n this.lastSave = Date.now();\n this.write({ src: c.src, chapter: i, time: Math.floor(t || 0), speed: this.speed });\n };\n\n protected override willUpdate(changed: PropertyValues): void {\n super.willUpdate(changed);\n if (this.restored || !this.chapters.length) return;\n this.restored = true;\n const saved = this.readSaved();\n if (!saved) return;\n if (SPEEDS.includes(saved.speed as (typeof SPEEDS)[number]))\n this.speed = this.reportedSpeed = saved.speed!;\n // The chapter by its file (the list may have changed since), else by its place.\n let index = saved.src ? this.chapters.findIndex((c) => c.src === saved.src) : -1;\n if (index < 0 && !saved.src && saved.chapter < this.chapters.length) index = saved.chapter;\n if (index < 0 || (index === 0 && saved.time < 1)) return;\n this.resume = { index, time: Math.max(0, saved.time) };\n }\n\n // ---- playing\n\n private get audio(): HTMLAudioElement | null {\n return (this.renderRoot as ParentNode | undefined)?.querySelector?.('audio') ?? null;\n }\n\n private durationOf(i: number): number | undefined {\n return this.loaded.get(i) ?? this.chapters[i]?.duration;\n }\n\n /** Play chapter `index` (0-based; default the current one, else the first) from where it was. */\n async play(index = this.currentIndex < 0 ? 0 : this.currentIndex, at?: number): Promise<void> {\n await this.updateComplete;\n const c = this.chapters[index];\n const a = this.audio;\n if (!c || !a) return;\n this.resume = undefined;\n this.finished = false;\n if (index !== this.srcIndex) {\n // The current chapter not loaded yet (skipped or seeked before playing): from there.\n const from = at ?? (index === this.currentIndex ? (this.pendingTime ?? this.time) : 0);\n this.currentIndex = index;\n this.srcIndex = index;\n this.time = Math.floor(from);\n this.pendingTime = from || undefined;\n if (this.failed.has(index)) {\n this.failed.delete(index);\n this.failed = new Set(this.failed);\n }\n a.src = c.src;\n a.defaultPlaybackRate = a.playbackRate = this.speed;\n } else if (at !== undefined) this.seek(at);\n else if (a.ended) this.seek(0);\n this.currentIndex = index;\n try {\n await a.play();\n } catch (e) {\n const name = (e as Error)?.name;\n // AbortError: another chapter was chosen before this one started.\n if (name !== 'AbortError' && name !== 'NotAllowedError') this.fail(index);\n }\n }\n\n /** Pause the chapter playing. */\n pause(): void {\n this.audio?.pause();\n }\n\n private toggle(index: number): void {\n if (index === this.currentIndex && this.isPlaying) this.pause();\n else {\n const resumeAt =\n index !== this.currentIndex && this.resume?.index === index ? this.resume.time : undefined;\n void this.play(index, resumeAt);\n }\n }\n\n private seek(t: number): void {\n const i = this.currentIndex;\n const max = this.durationOf(i);\n const to = Math.max(0, max ? Math.min(t, max) : t);\n const a = this.audio;\n if (a && this.srcIndex === i && a.readyState >= 1) a.currentTime = to;\n else this.pendingTime = to;\n this.time = Math.floor(to);\n }\n\n private currentPosition(): number {\n const a = this.audio;\n return a && this.srcIndex === this.currentIndex && this.srcIndex >= 0\n ? a.currentTime\n : this.time;\n }\n\n /** Before any chapter is current, the controls act on the one Resume offers, else the first. */\n private adoptResume(): void {\n if (this.currentIndex >= 0) return;\n this.currentIndex = this.resume?.index ?? 0;\n this.time = this.resume?.time ?? 0;\n this.pendingTime = this.time || undefined;\n this.resume = undefined;\n }\n\n private skip(by: number): void {\n this.adoptResume();\n this.resume = undefined;\n this.seek(this.currentPosition() + by);\n this.announce(`At ${spoken(this.time)}`, true);\n this.save();\n }\n\n private onSeekInput = (e: Event): void => {\n this.adoptResume();\n this.resume = undefined;\n this.seek(Number((e.target as HTMLInputElement).value));\n };\n\n private onSpeed = (e: Event): void => {\n const v = Number((e.target as HTMLSelectElement).value);\n if (!SPEEDS.includes(v as (typeof SPEEDS)[number])) return;\n this.speed = v;\n const a = this.audio;\n if (a) a.defaultPlaybackRate = a.playbackRate = v;\n this.announce(`Speed ${v} times`);\n this.save();\n clearTimeout(this.speedTimer);\n this.speedTimer = setTimeout(() => this.flushSpeed(), audioTiming.speed);\n };\n\n private flushSpeed(): void {\n clearTimeout(this.speedTimer);\n this.speedTimer = undefined;\n if (this.speed === this.reportedSpeed) return;\n this.reportedSpeed = this.speed;\n trackEvent(this, [TAG, 'speed', String(this.speed), this.speed]);\n }\n\n private onResume = (): void => {\n const r = this.resume;\n if (!r) return;\n trackEvent(this, [TAG, 'resume', `chapter ${r.index + 1}`, r.index + 1]);\n void this.play(r.index, r.time);\n };\n\n private fail(index: number): void {\n if (this.failed.has(index)) return;\n this.failed = new Set(this.failed).add(index);\n if (index === this.currentIndex) this.isPlaying = false;\n this.announce('This chapter could not be played');\n trackError(this, TAG, 'chapter-load');\n }\n\n // ---- the audio element's events\n\n private onPlay = (): void => {\n for (const p of players) if (p !== this) p.pause();\n const i = this.currentIndex;\n const c = this.chapters[i];\n this.isPlaying = true;\n if (!c) return;\n if (!this.played.has(i)) {\n this.played.add(i);\n trackEvent(this, [TAG, 'play', `chapter ${i + 1}`, i + 1]);\n }\n this.announce(`Playing ${c.title}`);\n this.claimMediaSession(c);\n };\n\n private onPause = (): void => {\n this.isPlaying = false;\n const a = this.audio;\n // Removed from the page: disconnectedCallback saved already.\n if (a?.ended || !this.isConnected || this.failed.has(this.srcIndex)) return;\n this.save();\n this.announce('Paused');\n this.setPlaybackState('paused');\n };\n\n private onTime = (): void => {\n const a = this.audio;\n if (!a || this.srcIndex !== this.currentIndex) return;\n const t = Math.floor(a.currentTime);\n if (t !== this.time) this.time = t;\n if (this.isPlaying && Date.now() - this.lastSave >= audioTiming.save) this.save();\n };\n\n private onMeta = (): void => {\n const a = this.audio;\n const i = this.srcIndex;\n if (!a || i < 0) return;\n if (Number.isFinite(a.duration) && a.duration > 0)\n this.loaded = new Map(this.loaded).set(i, a.duration);\n a.playbackRate = this.speed;\n if (this.pendingTime !== undefined) {\n a.currentTime = Math.min(this.pendingTime, a.duration || this.pendingTime);\n this.pendingTime = undefined;\n }\n };\n\n private onEnded = (): void => {\n const i = this.currentIndex;\n const c = this.chapters[i];\n this.isPlaying = false;\n if (!c) return;\n if (!this.completed.has(i)) {\n this.completed.add(i);\n trackEvent(this, [TAG, 'complete', `chapter ${i + 1}`, i + 1]);\n }\n const next = this.chapters[i + 1];\n if (!next) {\n this.finished = true;\n this.write(null);\n this.announce('Finished');\n this.setPlaybackState('none');\n return;\n }\n if (this.continuous) {\n void this.play(i + 1, 0);\n return;\n }\n // Not continuing: the next visit offers the next chapter from its start.\n this.write({ src: next.src, chapter: i + 1, time: 0, speed: this.speed });\n this.announce(`Finished ${c.title}`);\n this.setPlaybackState('paused');\n };\n\n private onError = (): void => {\n if (this.srcIndex >= 0 && this.audio?.error) this.fail(this.srcIndex);\n };\n\n // ---- the Media Session (media keys, lock screen), for the instance playing\n\n private claimMediaSession(c: Chapter): void {\n const ms = navigator.mediaSession;\n if (!ms) return;\n try {\n if (typeof MediaMetadata === 'function')\n ms.metadata = new MediaMetadata({\n title: c.title,\n album: normalize(this.label) || normalize(this.ownerDocument.title),\n });\n ms.playbackState = 'playing';\n const set = (a: MediaSessionAction, h: MediaSessionActionHandler | null) => {\n try {\n ms.setActionHandler(a, h);\n } catch {\n // An action this browser does not know.\n }\n };\n const i = this.currentIndex;\n set('play', () => void this.play());\n set('pause', () => this.pause());\n set('seekbackward', (d) => this.skip(-(d.seekOffset ?? SKIP.back)));\n set('seekforward', (d) => this.skip(d.seekOffset ?? SKIP.forward));\n set('seekto', (d) => d.seekTime !== undefined && this.seek(d.seekTime));\n set('previoustrack', i > 0 ? () => void this.play(i - 1, 0) : null);\n set('nexttrack', i < this.chapters.length - 1 ? () => void this.play(i + 1, 0) : null);\n media.owner = this;\n } catch {\n // No Media Session here.\n }\n }\n\n private setPlaybackState(s: MediaSessionPlaybackState): void {\n if (media.owner !== this || !navigator.mediaSession) return;\n try {\n navigator.mediaSession.playbackState = s;\n } catch {\n // ignore\n }\n }\n\n private releaseMediaSession(): void {\n const ms = navigator.mediaSession;\n if (media.owner !== this || !ms) return;\n media.owner = undefined;\n for (const a of [\n 'play',\n 'pause',\n 'seekbackward',\n 'seekforward',\n 'seekto',\n 'previoustrack',\n 'nexttrack',\n ] as MediaSessionAction[])\n try {\n ms.setActionHandler(a, null);\n } catch {\n // ignore\n }\n try {\n ms.metadata = null;\n ms.playbackState = 'none';\n } catch {\n // ignore\n }\n }\n\n // ---- announcements: one polite status\n\n private announce(text: string, debounced = false): void {\n clearTimeout(this.announceTimer);\n const say = () => {\n clearTimeout(this.clearTimer);\n // The same words still in the region would not be read again: empty it first.\n if (this.announcement === text) {\n this.announcement = '';\n void this.updateComplete.then(() =>\n requestAnimationFrame(() => (this.announcement = text)),\n );\n } else this.announcement = text;\n this.clearTimer = setTimeout(() => (this.announcement = ''), CLEAR_MS);\n };\n this.announceTimer = setTimeout(say, debounced ? audioTiming.announce : 0);\n }\n\n // ---- drawing\n\n private onDownload = (name: string) => () => trackEvent(this, [TAG, 'download', name]);\n\n private sizeText(size: string) {\n return size\n ? html`<span aria-hidden=\"true\"> · </span><span class=\"visually-hidden\">, </span>${size}`\n : nothing;\n }\n\n private renderNow() {\n const r = this.resume;\n const rc = r && this.chapters[r.index];\n if (rc)\n return html`<button type=\"button\" class=\"resume\" @click=${this.onResume}>\n Resume “${rc.title}” ${r.time >= 1 ? `at ${clock(r.time)}` : 'from the start'}\n </button>`;\n const c = this.chapters[this.currentIndex];\n if (!c) return html`<span class=\"state\">Not playing</span>`;\n const failed = this.failed.has(this.currentIndex);\n const state = failed\n ? 'Could not play'\n : this.finished\n ? 'Finished'\n : this.isPlaying\n ? 'Now playing'\n : 'Paused';\n return html`<span><span class=\"state\">${state}:</span> ${c.title}</span>`;\n }\n\n private renderPlayer() {\n const id = this.uid;\n const i = this.currentIndex < 0 ? (this.resume?.index ?? 0) : this.currentIndex;\n const total = this.durationOf(i) ?? 0;\n const time = this.currentIndex < 0 ? (this.resume?.time ?? 0) : this.time;\n const playing = this.isPlaying;\n return html`<div\n class=\"player\"\n part=\"player\"\n role=\"group\"\n aria-label=${normalize(this.label) || 'Player'}\n >\n <p class=\"now\" part=\"now\">${this.renderNow()}</p>\n <div class=\"controls\" part=\"controls\">\n <div class=\"buttons\">\n <button type=\"button\" class=\"ctl back\" @click=${() => this.skip(-SKIP.back)}>\n ${BACK}<span class=\"visually-hidden\">Back </span>${SKIP.back}<span\n class=\"visually-hidden\"\n >\n seconds</span\n >\n </button>\n <button\n type=\"button\"\n class=\"ctl play\"\n @click=${() => (playing ? this.pause() : this.toggle(i))}\n >\n ${playing ? PAUSE : PLAY}<span>${playing ? 'Pause' : 'Play'}</span>\n </button>\n <button type=\"button\" class=\"ctl forward\" @click=${() => this.skip(SKIP.forward)}>\n <span class=\"visually-hidden\">Forward </span>${SKIP.forward}<span\n class=\"visually-hidden\"\n >\n seconds</span\n >${FORWARD}\n </button>\n </div>\n <div class=\"seek\">\n <label class=\"visually-hidden\" for=\"${id}-seek\">Position</label>\n <input\n id=\"${id}-seek\"\n type=\"range\"\n min=\"0\"\n max=${Math.max(1, Math.ceil(total))}\n step=\"1\"\n .value=${String(Math.min(time, Math.ceil(total) || time))}\n aria-valuetext=\"${spoken(time)} of ${total ? spoken(total) : 'unknown length'}\"\n ?disabled=${!total}\n @input=${this.onSeekInput}\n @change=${(e: Event) => e.stopPropagation()}\n />\n <span class=\"time\"\n >${clock(time)}<span aria-hidden=\"true\"> / </span\n ><span class=\"visually-hidden\"> of </span>${total ? clock(total) : '–:––'}</span\n >\n </div>\n <div class=\"speed\">\n <label for=\"${id}-speed\">Speed</label>\n <select\n id=\"${id}-speed\"\n @change=${(e: Event) => {\n e.stopPropagation();\n this.onSpeed(e);\n }}\n @input=${(e: Event) => e.stopPropagation()}\n >\n ${SPEEDS.map(\n (s) => html`<option value=${s} ?selected=${s === this.speed}>${s}×</option>`,\n )}\n </select>\n </div>\n </div>\n </div>`;\n }\n\n private renderDownload() {\n const href = normalize(this.downloadHref);\n if (!href) return nothing;\n if (!mediaHref(href, this.ownerDocument.baseURI)) {\n this.warnOnce('download', 'ignoring download-href: it is not http(s), blob: or relative.');\n return nothing;\n }\n return html`<p class=\"download\" part=\"download\">\n <a href=${href} download @click=${this.onDownload('recording')}\n ><span\n >${normalize(this.downloadLabel) || 'Download the whole recording'}${this.sizeText(\n formatSize(this.downloadSize),\n )}</span\n ></a\n >\n </p>`;\n }\n\n private renderChapter(c: Chapter, i: number) {\n const current = i === this.currentIndex;\n const playing = current && this.isPlaying;\n const failed = this.failed.has(i);\n const d = this.chapters[i]?.duration;\n return html`<li class=\"chapter\" part=\"chapter\" aria-current=${current ? 'true' : nothing}>\n <button type=\"button\" class=\"chapter-play\" @click=${() => this.toggle(i)}>\n <span class=\"chip\"\n >${playing ? PAUSE : PLAY}<span>${playing ? 'Pause' : 'Play'}</span></span\n >\n <span class=\"chapter-title\"\n >${c.nodes}${\n current\n ? html` <span class=\"marker\"\n >${failed ? 'Not played' : playing ? 'Now playing' : this.finished ? 'Finished' : 'Paused'}</span\n >`\n : nothing\n }</span\n >\n </button>\n <span class=\"duration\"\n >${\n d !== undefined\n ? html`<span aria-hidden=\"true\">${clock(d)}</span\n ><span class=\"visually-hidden\">${spoken(d)}</span>`\n : nothing\n }</span\n >\n ${\n c.extras.length || c.download\n ? html`<span class=\"more\"\n >${c.extras.map(\n (x) =>\n html`<a\n href=${x.href}\n hreflang=${attr(x, 'hreflang')}\n type=${attr(x, 'type')}\n target=${attr(x, 'target')}\n rel=${attr(x, 'rel')}\n lang=${attr(x, 'lang')}\n download=${attr(x, 'download')}\n ><span>${x.nodes}</span></a\n >`,\n )}${\n c.download\n ? html`<a\n href=${c.download.href}\n download\n @click=${this.onDownload(`chapter ${i + 1}`)}\n ><span\n >Download<span class=\"visually-hidden\"> ${c.title}</span>${this.sizeText(\n c.download.size,\n )}</span\n ></a\n >`\n : nothing\n }</span\n >`\n : nothing\n }\n ${\n failed\n ? html`<p class=\"error\" role=\"note\">\n This chapter could not be played.\n <a href=${c.href}>Open its file<span class=\"visually-hidden\"> (${c.title})</span></a>\n </p>`\n : nothing\n }\n </li>`;\n }\n\n protected override render() {\n const chapters = this.chapters;\n if (!chapters.length) return nothing;\n return html`${this.renderPlayer()}${this.renderDownload()}\n <ol class=\"chapters\" part=\"list\">\n ${chapters.map((c, i) => this.renderChapter(c, i))}\n </ol>\n <audio\n preload=\"none\"\n @play=${this.onPlay}\n @pause=${this.onPause}\n @timeupdate=${this.onTime}\n @loadedmetadata=${this.onMeta}\n @ended=${this.onEnded}\n @error=${this.onError}\n ></audio>\n <span class=\"visually-hidden\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n >${this.announcement}</span\n >`;\n }\n}\n\n/** The instance whose handlers the Media Session has. */\nconst media: { owner?: UvalibAudio } = {};\n\nconst attr = (x: Extra, name: string): string | typeof nothing =>\n x.attrs.find(([n]) => n === name)?.[1] ?? nothing;\n","import { define } from '../../base/define.js';\nimport { UvalibAudio } from './UvalibAudio.js';\n\ndefine('uvalib-audio', UvalibAudio);\n"],"mappings":";;;;;;A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MAAM7E;;AClpC5CS,EAAO,gBAAgB8D,CAAW"}
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import { a as e, i as t, o as n } from "./chunks/analytics-DTTihuBD.js";
|
|
2
2
|
// src/components/uvalib-pagefind-search/UvalibPagefindSearch.ts
|
|
3
|
-
var r = "uvalib-pagefind-search", i = 1e3, a = 1e4, o = 15e3, s = 25, c = /* @__PURE__ */ new
|
|
4
|
-
|
|
3
|
+
var r = "uvalib-pagefind-search", i = 1e3, a = 1e4, o = 15e3, s = 25, c = /* @__PURE__ */ new Set([
|
|
4
|
+
"0",
|
|
5
|
+
"false",
|
|
6
|
+
"no",
|
|
7
|
+
"off"
|
|
8
|
+
]), l = (e) => e.some((e) => !c.has(e.trim().toLowerCase())), u = /* @__PURE__ */ new Map();
|
|
9
|
+
function d(e) {
|
|
5
10
|
let t = window;
|
|
6
11
|
if (t.PagefindUI) return Promise.resolve(t.PagefindUI);
|
|
7
|
-
let n =
|
|
12
|
+
let n = u.get(e);
|
|
8
13
|
return n || (n = new Promise((n, r) => {
|
|
9
14
|
let i = document.createElement("script");
|
|
10
15
|
i.src = e, i.onload = () => t.PagefindUI ? n(t.PagefindUI) : r(/* @__PURE__ */ Error("no PagefindUI")), i.onerror = () => r(/* @__PURE__ */ Error(`could not load ${e}`)), document.head.append(i);
|
|
11
|
-
}), n.catch(() =>
|
|
16
|
+
}), n.catch(() => u.delete(e)), u.set(e, n)), n;
|
|
12
17
|
}
|
|
13
|
-
function
|
|
18
|
+
function f(e, t) {
|
|
14
19
|
let n = (e) => `<span class="uvalib-skeleton-text ${r}__skeleton-${e}"></span>`, i = `<div class="${r}__skeleton-sub">${n("title")}${n("line")}${n("short")}</div>`, a = `<div class="${r}__skeleton-result">${n("title")}${n("line")}${n("line")}${n("short")}${t ? i + i : ""}</div>`, o = document.createElement("div");
|
|
15
20
|
return o.className = `${r}__skeleton`, o.setAttribute("aria-hidden", "true"), o.innerHTML = n("message") + a.repeat(e), o;
|
|
16
21
|
}
|
|
17
|
-
var
|
|
22
|
+
var p = {
|
|
18
23
|
position: "absolute",
|
|
19
24
|
width: "1px",
|
|
20
25
|
height: "1px",
|
|
@@ -24,18 +29,18 @@ var d = {
|
|
|
24
29
|
clipPath: "inset(50%)",
|
|
25
30
|
whiteSpace: "nowrap",
|
|
26
31
|
border: "0"
|
|
27
|
-
},
|
|
32
|
+
}, m = 0, h = (e) => typeof e == "object" && !!e && Object.getPrototypeOf(e) === Object.prototype, g = (e, t, n) => {
|
|
28
33
|
if (!e) return t;
|
|
29
34
|
try {
|
|
30
35
|
let t = JSON.parse(e);
|
|
31
36
|
if (n(t)) return t;
|
|
32
37
|
} catch {}
|
|
33
38
|
return console.warn(`${r}: ignoring an attribute that is not the expected JSON`, e), t;
|
|
34
|
-
},
|
|
35
|
-
function
|
|
39
|
+
}, _ = (e) => e.endsWith("/") ? e : `${e}/`, v = "[COUNT] results for [SEARCH_TERM]", y = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
40
|
+
function b(e, t, n) {
|
|
36
41
|
let r;
|
|
37
42
|
if (n?.includes("[COUNT]")) {
|
|
38
|
-
let i = RegExp(`^${
|
|
43
|
+
let i = RegExp(`^${y(n).replace(y("[COUNT]"), "(.+?)").replace(y("[SEARCH_TERM]"), y(t))}$`);
|
|
39
44
|
r = e.match(i)?.[1];
|
|
40
45
|
}
|
|
41
46
|
if (r === void 0) {
|
|
@@ -45,9 +50,9 @@ function v(e, t, n) {
|
|
|
45
50
|
let i = r.match(/\d[\d.,\s\u00a0\u202f]*/);
|
|
46
51
|
return i ? Number(i[0].replace(/\D/g, "")) : void 0;
|
|
47
52
|
}
|
|
48
|
-
var
|
|
53
|
+
var x = class extends HTMLElement {
|
|
49
54
|
constructor(...e) {
|
|
50
|
-
super(...e), this.generation = 0, this.started = !1, this._ready = this.newReady(), this.uid = `${r}-${++
|
|
55
|
+
super(...e), this.generation = 0, this.started = !1, this._ready = this.newReady(), this.uid = `${r}-${++m}`, this.container = document.createElement("div"), this.status = document.createElement("p"), this.lastAnnounced = "", this.lastTracked = "", this.onPopState = () => this.followUrl(), this.warned = /* @__PURE__ */ new Set();
|
|
51
56
|
}
|
|
52
57
|
newReady() {
|
|
53
58
|
let { promise: e, resolve: t } = Promise.withResolvers();
|
|
@@ -65,19 +70,30 @@ var y = class extends HTMLElement {
|
|
|
65
70
|
get queryParam() {
|
|
66
71
|
return this.getAttribute("query-param") ?? "q";
|
|
67
72
|
}
|
|
73
|
+
names(e) {
|
|
74
|
+
return (this.getAttribute(e) ?? "").split(/\s+/).filter(Boolean);
|
|
75
|
+
}
|
|
68
76
|
get filterParams() {
|
|
69
|
-
return (this.
|
|
77
|
+
return [.../* @__PURE__ */ new Set([...this.names("filter-params"), ...this.names("filter-flags")])];
|
|
78
|
+
}
|
|
79
|
+
get flags() {
|
|
80
|
+
return this.names("filter-flags");
|
|
81
|
+
}
|
|
82
|
+
flagValue(e) {
|
|
83
|
+
let t = [...new Set(this.boxes.filter((t) => t.name === e).map((e) => e.value))];
|
|
84
|
+
if (t.length === 1) return t[0];
|
|
85
|
+
this.warned.has(e) || (this.warned.add(e), console.warn(`${r}: filter-flags "${e}" has ${t.length} values in the index, not one; reading it as filter-params (exact values)`));
|
|
70
86
|
}
|
|
71
87
|
get boxes() {
|
|
72
88
|
return [...this.container.querySelectorAll(".pagefind-ui__filter-checkbox")];
|
|
73
89
|
}
|
|
74
90
|
urlFilters() {
|
|
75
|
-
let e = new URLSearchParams(location.search), t = {};
|
|
76
|
-
for (let
|
|
77
|
-
let
|
|
78
|
-
|
|
91
|
+
let e = new URLSearchParams(location.search), t = this.flags, n = {};
|
|
92
|
+
for (let r of this.filterParams) {
|
|
93
|
+
let i = e.getAll(r), a = t.includes(r) ? l(i) ? i : [] : i.filter(Boolean);
|
|
94
|
+
a.length && (n[r] = a);
|
|
79
95
|
}
|
|
80
|
-
return
|
|
96
|
+
return n;
|
|
81
97
|
}
|
|
82
98
|
connectedCallback() {
|
|
83
99
|
this.started || (this.started = !0, this.start(++this.generation));
|
|
@@ -95,11 +111,11 @@ var y = class extends HTMLElement {
|
|
|
95
111
|
this._ui && (this._ready = this.newReady()), this._ui = void 0, this.container.remove(), this.container = document.createElement("div"), this.querySelector(`:scope > .${r}__label`)?.remove(), this.status.remove(), this.status.textContent = "", this.lastAnnounced = this.lastTracked = "", this.focusIndex = void 0;
|
|
96
112
|
}
|
|
97
113
|
async start(e) {
|
|
98
|
-
let n =
|
|
99
|
-
o.className = `${r}__label`, o.htmlFor = `${this.uid}-input`, o.textContent = this.getAttribute("label") || i, this.hasAttribute("label-hidden") && Object.assign(o.style,
|
|
114
|
+
let n = _(this.getAttribute("bundle-path") || "/pagefind/"), i = this.getAttribute("placeholder") || "Search", o = document.createElement("label");
|
|
115
|
+
o.className = `${r}__label`, o.htmlFor = `${this.uid}-input`, o.textContent = this.getAttribute("label") || i, this.hasAttribute("label-hidden") && Object.assign(o.style, p), this.container.className = `${r}__ui`, this.status.className = `${r}__status`, this.status.setAttribute("role", "status"), Object.assign(this.status.style, p), this.append(o, this.container, this.status), this.urlQuery() && this.hasAttribute("searching") ? this.hold() : this.removeAttribute("searching");
|
|
100
116
|
let s;
|
|
101
117
|
try {
|
|
102
|
-
s = await
|
|
118
|
+
s = await d(`${n}pagefind-ui.js`);
|
|
103
119
|
} catch {
|
|
104
120
|
if (e !== this.generation) return;
|
|
105
121
|
this.release(), t(this, r, "load"), o.remove();
|
|
@@ -108,35 +124,35 @@ var y = class extends HTMLElement {
|
|
|
108
124
|
return;
|
|
109
125
|
}
|
|
110
126
|
if (e !== this.generation) return;
|
|
111
|
-
let c = this.urlFilters(),
|
|
127
|
+
let c = this.urlFilters(), l = (e, t) => {
|
|
112
128
|
let n = Number.parseInt(this.getAttribute(e) ?? "", 10);
|
|
113
129
|
return Number.isFinite(n) && n > 0 ? n : t;
|
|
114
|
-
},
|
|
130
|
+
}, u = g(this.getAttribute("merge-index"), [], Array.isArray).filter((e) => h(e) && typeof e.bundlePath == "string").map((e) => ({
|
|
115
131
|
...e,
|
|
116
|
-
bundlePath:
|
|
117
|
-
})),
|
|
132
|
+
bundlePath: _(e.bundlePath)
|
|
133
|
+
})), f = {
|
|
118
134
|
placeholder: i,
|
|
119
|
-
...
|
|
120
|
-
},
|
|
135
|
+
...g(this.getAttribute("translations"), {}, h)
|
|
136
|
+
}, m = g(this.getAttribute("options"), {}, h), y = {
|
|
121
137
|
bundlePath: n,
|
|
122
|
-
mergeIndex:
|
|
123
|
-
pageSize:
|
|
138
|
+
mergeIndex: u,
|
|
139
|
+
pageSize: l("page-size", 10),
|
|
124
140
|
showSubResults: this.hasAttribute("show-sub-results"),
|
|
125
141
|
showImages: this.hasAttribute("show-images"),
|
|
126
|
-
...
|
|
127
|
-
translations:
|
|
142
|
+
...m,
|
|
143
|
+
translations: f,
|
|
128
144
|
element: this.container
|
|
129
145
|
};
|
|
130
|
-
typeof y.bundlePath == "string" && (y.bundlePath =
|
|
146
|
+
typeof y.bundlePath == "string" && (y.bundlePath = _(y.bundlePath));
|
|
131
147
|
let b = Object.keys(c);
|
|
132
148
|
if (b.length) {
|
|
133
149
|
let e = Array.isArray(y.openFilters) ? y.openFilters : [];
|
|
134
150
|
y.openFilters = [.../* @__PURE__ */ new Set([...e, ...b])];
|
|
135
151
|
}
|
|
136
|
-
let x =
|
|
152
|
+
let x = l("excerpt-length");
|
|
137
153
|
x && (y.excerptLength ??= x);
|
|
138
154
|
let S = (document.documentElement.lang || "en").toLowerCase();
|
|
139
|
-
this.manyResults = typeof
|
|
155
|
+
this.manyResults = typeof f.many_results == "string" ? f.many_results : S === "en" || S.startsWith("en-") ? v : void 0;
|
|
140
156
|
let C = new s(y);
|
|
141
157
|
this._ui = C;
|
|
142
158
|
let w = this.input;
|
|
@@ -154,8 +170,13 @@ var y = class extends HTMLElement {
|
|
|
154
170
|
known(e) {
|
|
155
171
|
let t = this.boxes, n = {};
|
|
156
172
|
for (let [r, i] of Object.entries(e)) {
|
|
157
|
-
let e =
|
|
158
|
-
|
|
173
|
+
let e = this.flags.includes(r) ? this.flagValue(r) : void 0;
|
|
174
|
+
if (e !== void 0) {
|
|
175
|
+
n[r] = [e];
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
let a = t.filter((e) => e.name === r).map((e) => e.value), o = i.filter(Boolean).map((e) => a.find((t) => t === e) ?? a.find((t) => t.toLowerCase() === e.toLowerCase())).filter((e) => e !== void 0);
|
|
179
|
+
o.length && (n[r] = [...new Set(o)]);
|
|
159
180
|
}
|
|
160
181
|
return n;
|
|
161
182
|
}
|
|
@@ -198,7 +219,7 @@ var y = class extends HTMLElement {
|
|
|
198
219
|
}
|
|
199
220
|
this.release(), this.unkeep();
|
|
200
221
|
let e = Number.parseInt(this.getAttribute("page-size") ?? "", 10), t = Math.min(Number.isFinite(e) && e > 0 ? e : 10, s);
|
|
201
|
-
this.skeleton =
|
|
222
|
+
this.skeleton = f(t, this.hasAttribute("show-sub-results")), this.heldList = this.container.querySelector(".pagefind-ui__results"), this.container.after(this.skeleton), this.setAttribute("searching", ""), this.holdTimer = setTimeout(() => this.release(), o);
|
|
202
223
|
}
|
|
203
224
|
release(e = !1) {
|
|
204
225
|
if (clearTimeout(this.holdTimer), e && this.skeleton) {
|
|
@@ -255,7 +276,7 @@ var y = class extends HTMLElement {
|
|
|
255
276
|
settled() {
|
|
256
277
|
let e = this.container, t = (this.input?.value ?? "").trim(), n = e.querySelector(".pagefind-ui__results-area"), r = n?.querySelector(".pagefind-ui__results");
|
|
257
278
|
if (!t || !r || r.querySelector(".pagefind-ui__loading")) return;
|
|
258
|
-
let i = n.querySelector(".pagefind-ui__message")?.textContent?.trim() ?? "", a = r.children.length, o = n.querySelector(".pagefind-ui__button") ?
|
|
279
|
+
let i = n.querySelector(".pagefind-ui__message")?.textContent?.trim() ?? "", a = r.children.length, o = n.querySelector(".pagefind-ui__button") ? b(i, t, this.manyResults) ?? a : a, s = [...e.querySelectorAll(".pagefind-ui__filter-checkbox")].filter((e) => e.checked).map((e) => `${e.name}:${e.value}`).sort();
|
|
259
280
|
return {
|
|
260
281
|
query: t,
|
|
261
282
|
count: o,
|
|
@@ -287,11 +308,16 @@ var y = class extends HTMLElement {
|
|
|
287
308
|
(n.searchParams.get(t) ?? "") !== e && (e ? n.searchParams.set(t, e) : n.searchParams.delete(t), this.replaceUrl(n));
|
|
288
309
|
}
|
|
289
310
|
writeFilters(e) {
|
|
290
|
-
let t = new URL(location.href), n = t.searchParams, r = this.
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
311
|
+
let t = new URL(location.href), n = t.searchParams, r = this.flags, i = (t) => {
|
|
312
|
+
let i = e[t] ?? [];
|
|
313
|
+
if (!r.includes(t) || !i.length && !n.has(t)) return i;
|
|
314
|
+
let a = this.flagValue(t);
|
|
315
|
+
return a === void 0 ? i : i.includes(a) ? ["1"] : [];
|
|
316
|
+
}, a = new Map(this.filterParams.map((e) => [e, i(e)])), o = [...a.keys()].filter((e) => JSON.stringify(n.getAll(e)) !== JSON.stringify(a.get(e)));
|
|
317
|
+
if (o.length) {
|
|
318
|
+
for (let e of o) {
|
|
319
|
+
n.delete(e);
|
|
320
|
+
for (let t of a.get(e)) n.append(e, t);
|
|
295
321
|
}
|
|
296
322
|
this.replaceUrl(t);
|
|
297
323
|
}
|
|
@@ -303,6 +329,6 @@ var y = class extends HTMLElement {
|
|
|
303
329
|
}
|
|
304
330
|
};
|
|
305
331
|
// src/components/uvalib-pagefind-search/uvalib-pagefind-search.ts
|
|
306
|
-
customElements.get("uvalib-pagefind-search") || customElements.define("uvalib-pagefind-search",
|
|
332
|
+
customElements.get("uvalib-pagefind-search") || customElements.define("uvalib-pagefind-search", x);
|
|
307
333
|
|
|
308
334
|
//# sourceMappingURL=uvalib-pagefind-search.js.map
|