vanilla-breeze 0.4.1 → 0.6.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/custom-elements.json +23012 -11383
- package/dist/cdn/components/accordion-wc.js +1 -1
- package/dist/cdn/components/activity-feed.js +1 -1
- package/dist/cdn/components/ai-chat.js +9 -6
- package/dist/cdn/components/ai-summary.js +4 -2
- package/dist/cdn/components/analytics-panel.js +19 -21
- package/dist/cdn/components/audio-player.js +17 -7
- package/dist/cdn/components/audio-visualizer.js +3 -3
- package/dist/cdn/components/author-index.js +2 -2
- package/dist/cdn/components/brand-mark.js +1 -1
- package/dist/cdn/components/bread-crumb.js +1 -1
- package/dist/cdn/components/calendar-wc.js +2 -2
- package/dist/cdn/components/card-list.js +1 -1
- package/dist/cdn/components/carousel-wc.js +1 -1
- package/dist/cdn/components/change-set.js +1 -11
- package/dist/cdn/components/chart-wc.js +32 -32
- package/dist/cdn/components/chat-input.js +1 -1
- package/dist/cdn/components/chat-window.js +1 -1
- package/dist/cdn/components/color-picker.js +1 -1
- package/dist/cdn/components/combo-box.js +1 -1
- package/dist/cdn/components/command-palette.js +1 -1
- package/dist/cdn/components/comment-box.js +50 -49
- package/dist/cdn/components/comment-thread.js +50 -49
- package/dist/cdn/components/comment-wc.js +1 -1
- package/dist/cdn/components/compare-surface.js +1 -1
- package/dist/cdn/components/consent-banner.js +1 -1
- package/dist/cdn/components/content-lens.js +1 -1
- package/dist/cdn/components/content-swap.js +1 -1
- package/dist/cdn/components/context-menu.js +1 -1
- package/dist/cdn/components/data-table.js +1 -1
- package/dist/cdn/components/date-picker.js +1 -1
- package/dist/cdn/components/day-view.js +1 -1
- package/dist/cdn/components/diagram-wc.js +2 -2
- package/dist/cdn/components/drag-surface.js +1 -1
- package/dist/cdn/components/drop-down.js +1 -1
- package/dist/cdn/components/emoji-picker.js +1 -1
- package/dist/cdn/components/flow-diagram.js +1 -1
- package/dist/cdn/components/foot-notes.js +1 -1
- package/dist/cdn/components/form-field.js +1 -1
- package/dist/cdn/components/geo-map.js +170 -54
- package/dist/cdn/components/glossary-index.js +1 -1
- package/dist/cdn/components/glossary-wc.js +1 -1
- package/dist/cdn/components/heading-links.js +1 -1
- package/dist/cdn/components/highlight-wc.js +6 -2
- package/dist/cdn/components/icon-wc.js +11 -10
- package/dist/cdn/components/image-gallery.js +1 -1
- package/dist/cdn/components/image-map.js +1 -1
- package/dist/cdn/components/include-file.js +1 -1
- package/dist/cdn/components/manifest.json +101 -101
- package/dist/cdn/components/markdown-editor.js +60 -1
- package/dist/cdn/components/markdown-viewer.js +50 -49
- package/dist/cdn/components/nav-bar.js +1 -1
- package/dist/cdn/components/note-wc.js +6 -2
- package/dist/cdn/components/notification-wc.js +33 -32
- package/dist/cdn/components/page-info.js +6 -72
- package/dist/cdn/components/page-stats.js +1 -1
- package/dist/cdn/components/page-toc.js +1 -1
- package/dist/cdn/components/page-tools.js +1 -1
- package/dist/cdn/components/page-tour.js +1 -38
- package/dist/cdn/components/pager-wc.js +1 -1
- package/dist/cdn/components/poll-wc.js +1 -1
- package/dist/cdn/components/pop-over.js +1 -1
- package/dist/cdn/components/popularity-index.js +1 -8
- package/dist/cdn/components/print-page.js +1 -1
- package/dist/cdn/components/progress-tracker.js +1 -1
- package/dist/cdn/components/qr-code.js +1 -1
- package/dist/cdn/components/reaction-bar.js +1 -1
- package/dist/cdn/components/reader-view.js +25 -25
- package/dist/cdn/components/reading-progress.js +1 -1
- package/dist/cdn/components/recently-visited.js +1 -26
- package/dist/cdn/components/score-card.js +21 -5
- package/dist/cdn/components/selection-menu.js +1 -1
- package/dist/cdn/components/settings-panel.js +88 -142
- package/dist/cdn/components/share-wc.js +2 -2
- package/dist/cdn/components/short-cuts.js +1 -1
- package/dist/cdn/components/site-index.js +1 -10
- package/dist/cdn/components/site-map.js +1 -1
- package/dist/cdn/components/site-search.js +1 -51
- package/dist/cdn/components/slide-accept.js +1 -1
- package/dist/cdn/components/social-embed.js +1 -1
- package/dist/cdn/components/split-surface.js +1 -1
- package/dist/cdn/components/star-rating.js +1 -1
- package/dist/cdn/components/status-wc.js +1 -1
- package/dist/cdn/components/stepper-wc.js +1 -1
- package/dist/cdn/components/tab-set.js +1 -1
- package/dist/cdn/components/text-reader.js +2 -2
- package/dist/cdn/components/theme-picker.js +84 -81
- package/dist/cdn/components/time-index.js +1 -11
- package/dist/cdn/components/time-picker.js +1 -1
- package/dist/cdn/components/toast-msg.js +6 -6
- package/dist/cdn/components/tool-tip.js +1 -1
- package/dist/cdn/components/topic-map.js +6 -3
- package/dist/cdn/components/trust-filter.js +1 -3
- package/dist/cdn/components/version-switcher.js +5 -15
- package/dist/cdn/components/video-player.js +67 -9
- package/dist/cdn/components/watch-wc.js +6 -2
- package/dist/cdn/components/week-view.js +1 -1
- package/dist/cdn/components/youtube-player.js +1 -1
- package/dist/cdn/emoji-extended.js +2 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-OFL.txt +93 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-latin-400-italic.woff2 +0 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-latin-400-normal.woff2 +0 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-latin-700-italic.woff2 +0 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-latin-700-normal.woff2 +0 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-latin-ext-400-italic.woff2 +0 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-latin-ext-400-normal.woff2 +0 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-latin-ext-700-italic.woff2 +0 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-latin-ext-700-normal.woff2 +0 -0
- package/dist/cdn/fonts/latinmodern-math-GUST-LICENSE.txt +30 -0
- package/dist/cdn/fonts/latinmodern-math.woff2 +0 -0
- package/dist/cdn/fonts/math-fonts.css +14 -0
- package/dist/cdn/packs/effects.full.css +1 -1
- package/dist/cdn/packs/effects.full.js +1 -1
- package/dist/cdn/packs/fonts-display.full.css +1 -1
- package/dist/cdn/packs/fonts-display.theme.css +1 -1
- package/dist/cdn/packs/icons.bundle.js +1 -1
- package/dist/cdn/packs/icons.full.css +1 -1
- package/dist/cdn/packs/icons.theme.css +1 -1
- package/dist/cdn/packs/journal.effects.css +1 -1
- package/dist/cdn/packs/journal.full.css +1 -1
- package/dist/cdn/packs/kawaii.effects.css +1 -1
- package/dist/cdn/packs/kawaii.full.css +2 -2
- package/dist/cdn/packs/kawaii.full.js +6 -6
- package/dist/cdn/packs/kawaii.theme.css +1 -1
- package/dist/cdn/packs/manifest.json +17 -17
- package/dist/cdn/packs/memphis.full.css +1 -1
- package/dist/cdn/packs/memphis.theme.css +1 -1
- package/dist/cdn/packs/ui.full.css +1 -1
- package/dist/cdn/packs/ui.full.js +88 -85
- package/dist/cdn/themes/8bit.css +1 -1
- package/dist/cdn/themes/8bit.tokens.json +1 -1
- package/dist/cdn/themes/alpha1999-dark.tokens.json +1 -1
- package/dist/cdn/themes/alpha1999.css +1 -1
- package/dist/cdn/themes/alpha1999.tokens.json +1 -1
- package/dist/cdn/themes/art-deco-dark.tokens.json +33 -1
- package/dist/cdn/themes/art-deco.css +1 -1
- package/dist/cdn/themes/art-deco.tokens.json +23 -1
- package/dist/cdn/themes/bauhaus-dark.tokens.json +23 -1
- package/dist/cdn/themes/bauhaus.css +1 -1
- package/dist/cdn/themes/bauhaus.tokens.json +1 -1
- package/dist/cdn/themes/brutalist-dark.tokens.json +33 -1
- package/dist/cdn/themes/brutalist.css +1 -1
- package/dist/cdn/themes/brutalist.tokens.json +23 -1
- package/dist/cdn/themes/catppuccin-frappe.css +1 -1
- package/dist/cdn/themes/catppuccin-frappe.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-latte-dark.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-latte.css +1 -1
- package/dist/cdn/themes/catppuccin-latte.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-macchiato.css +1 -1
- package/dist/cdn/themes/catppuccin-macchiato.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-mocha.css +1 -1
- package/dist/cdn/themes/catppuccin-mocha.tokens.json +1 -1
- package/dist/cdn/themes/classic-dark.tokens.json +1 -1
- package/dist/cdn/themes/classic.css +1 -1
- package/dist/cdn/themes/classic.tokens.json +1 -1
- package/dist/cdn/themes/claymorphism-dark.tokens.json +33 -1
- package/dist/cdn/themes/claymorphism.css +1 -1
- package/dist/cdn/themes/claymorphism.tokens.json +24 -1
- package/dist/cdn/themes/clinical-dark.tokens.json +1 -1
- package/dist/cdn/themes/clinical.css +1 -1
- package/dist/cdn/themes/clinical.tokens.json +1 -1
- package/dist/cdn/themes/cottagecore-dark.tokens.json +1 -1
- package/dist/cdn/themes/cottagecore.css +1 -1
- package/dist/cdn/themes/cottagecore.tokens.json +1 -1
- package/dist/cdn/themes/cyber.css +1 -1
- package/dist/cdn/themes/cyber.tokens.json +1 -1
- package/dist/cdn/themes/dawn-dark.tokens.json +33 -1
- package/dist/cdn/themes/dawn.css +1 -1
- package/dist/cdn/themes/dawn.tokens.json +23 -1
- package/dist/cdn/themes/dracula.css +1 -1
- package/dist/cdn/themes/dracula.tokens.json +1 -1
- package/dist/cdn/themes/dusk.css +1 -1
- package/dist/cdn/themes/dusk.tokens.json +1 -1
- package/dist/cdn/themes/editorial-dark.tokens.json +1 -1
- package/dist/cdn/themes/editorial.css +1 -1
- package/dist/cdn/themes/editorial.tokens.json +1 -1
- package/dist/cdn/themes/financial-dark.tokens.json +1 -1
- package/dist/cdn/themes/financial.css +1 -1
- package/dist/cdn/themes/financial.tokens.json +1 -1
- package/dist/cdn/themes/genai.css +1 -1
- package/dist/cdn/themes/genai.tokens.json +1 -1
- package/dist/cdn/themes/glassmorphism-dark.tokens.json +1 -1
- package/dist/cdn/themes/glassmorphism.css +1 -1
- package/dist/cdn/themes/glassmorphism.tokens.json +1 -1
- package/dist/cdn/themes/government-dark.tokens.json +1 -1
- package/dist/cdn/themes/government.css +1 -1
- package/dist/cdn/themes/government.tokens.json +1 -1
- package/dist/cdn/themes/gruvbox-dark.tokens.json +1 -1
- package/dist/cdn/themes/gruvbox.css +1 -1
- package/dist/cdn/themes/gruvbox.tokens.json +1 -1
- package/dist/cdn/themes/high-noon-dark.tokens.json +23 -1
- package/dist/cdn/themes/high-noon.css +1 -1
- package/dist/cdn/themes/high-noon.tokens.json +1 -1
- package/dist/cdn/themes/journal-dark.tokens.json +36 -2
- package/dist/cdn/themes/journal.css +1 -1
- package/dist/cdn/themes/journal.tokens.json +26 -2
- package/dist/cdn/themes/kawaii-dark.tokens.json +1 -1
- package/dist/cdn/themes/kawaii.css +1 -1
- package/dist/cdn/themes/kawaii.tokens.json +1 -1
- package/dist/cdn/themes/magna-dark.tokens.json +1 -1
- package/dist/cdn/themes/magna.css +1 -1
- package/dist/cdn/themes/magna.tokens.json +1 -1
- package/dist/cdn/themes/manifest.json +44 -68
- package/dist/cdn/themes/midnight.css +1 -1
- package/dist/cdn/themes/midnight.tokens.json +1 -1
- package/dist/cdn/themes/minimal-dark.tokens.json +1 -1
- package/dist/cdn/themes/minimal.css +1 -1
- package/dist/cdn/themes/minimal.tokens.json +1 -1
- package/dist/cdn/themes/modern-dark.tokens.json +1 -1
- package/dist/cdn/themes/modern.css +1 -1
- package/dist/cdn/themes/modern.tokens.json +1 -1
- package/dist/cdn/themes/nes-dark.tokens.json +7 -2
- package/dist/cdn/themes/nes.css +1 -1
- package/dist/cdn/themes/nes.tokens.json +1 -1
- package/dist/cdn/themes/neumorphism-dark.tokens.json +1 -1
- package/dist/cdn/themes/neumorphism.css +1 -1
- package/dist/cdn/themes/neumorphism.tokens.json +1 -1
- package/dist/cdn/themes/nord-dark.tokens.json +33 -1
- package/dist/cdn/themes/nord.css +1 -1
- package/dist/cdn/themes/nord.tokens.json +23 -1
- package/dist/cdn/themes/organic-dark.tokens.json +1 -1
- package/dist/cdn/themes/organic.css +1 -1
- package/dist/cdn/themes/organic.tokens.json +1 -1
- package/dist/cdn/themes/rose-pine-dark.tokens.json +1 -1
- package/dist/cdn/themes/rose-pine.css +1 -1
- package/dist/cdn/themes/rose-pine.tokens.json +1 -1
- package/dist/cdn/themes/rough-dark.tokens.json +1 -1
- package/dist/cdn/themes/rough.css +1 -1
- package/dist/cdn/themes/rough.tokens.json +1 -1
- package/dist/cdn/themes/solarized-dark.tokens.json +23 -1
- package/dist/cdn/themes/solarized.css +1 -1
- package/dist/cdn/themes/solarized.tokens.json +23 -1
- package/dist/cdn/themes/startup-dark.tokens.json +1 -1
- package/dist/cdn/themes/startup.css +1 -1
- package/dist/cdn/themes/startup.tokens.json +1 -1
- package/dist/cdn/themes/super2026-dark.tokens.json +33 -1
- package/dist/cdn/themes/super2026.css +1 -1
- package/dist/cdn/themes/super2026.tokens.json +23 -1
- package/dist/cdn/themes/swiss-dark.tokens.json +1 -1
- package/dist/cdn/themes/swiss.css +1 -1
- package/dist/cdn/themes/swiss.tokens.json +1 -1
- package/dist/cdn/themes/terminal.css +1 -1
- package/dist/cdn/themes/terminal.tokens.json +1 -1
- package/dist/cdn/themes/tokyo-night-dark.tokens.json +33 -1
- package/dist/cdn/themes/tokyo-night.css +1 -1
- package/dist/cdn/themes/tokyo-night.tokens.json +23 -1
- package/dist/cdn/themes/vaporwave-dark.tokens.json +33 -1
- package/dist/cdn/themes/vaporwave.css +1 -1
- package/dist/cdn/themes/vaporwave.tokens.json +23 -1
- package/dist/cdn/themes/win9x-dark.tokens.json +20 -5
- package/dist/cdn/themes/win9x.css +1 -1
- package/dist/cdn/themes/win9x.tokens.json +3 -1
- package/dist/cdn/vanilla-breeze-autoload.js +553 -0
- package/dist/cdn/vanilla-breeze-charts.css +1 -1
- package/dist/cdn/vanilla-breeze-charts.js +32 -32
- package/dist/cdn/vanilla-breeze-core.css +1 -1
- package/dist/cdn/vanilla-breeze-core.js +183 -281
- package/dist/cdn/vanilla-breeze-dev.css +1 -1
- package/dist/cdn/vanilla-breeze-dev.js +1 -1
- package/dist/cdn/vanilla-breeze-extras.js +286 -134
- package/dist/cdn/vanilla-breeze.css +1 -1
- package/dist/cdn/vanilla-breeze.js +574 -656
- package/dist/cdn/view-transitions.css +2 -0
- package/package.json +17 -9
- package/dist/cdn/themes/amber.css +0 -2
- package/dist/cdn/themes/anthropic.css +0 -2
- package/dist/cdn/themes/anthropic.tokens.json +0 -564
- package/dist/cdn/themes/coral.css +0 -2
- package/dist/cdn/themes/emerald.css +0 -2
- package/dist/cdn/themes/forest.css +0 -2
- package/dist/cdn/themes/ibm.css +0 -2
- package/dist/cdn/themes/ibm.tokens.json +0 -568
- package/dist/cdn/themes/indigo.css +0 -2
- package/dist/cdn/themes/lavender.css +0 -2
- package/dist/cdn/themes/mcdonalds.css +0 -2
- package/dist/cdn/themes/mcdonalds.tokens.json +0 -533
- package/dist/cdn/themes/ocean.css +0 -2
- package/dist/cdn/themes/rose.css +0 -2
- package/dist/cdn/themes/slate.css +0 -2
- package/dist/cdn/themes/starbucks.css +0 -2
- package/dist/cdn/themes/starbucks.tokens.json +0 -593
- package/dist/cdn/themes/sunset.css +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
<style>${this.#
|
|
1
|
+
var A=window.matchMedia("(prefers-reduced-motion: reduce)");var v=new Map;function m(o,t,e={}){let i=e.priority??10,s={impl:t,bundle:e.bundle,contract:e.contract,priority:i},r=v.get(o);if(customElements.get(o)){if(!r||r.priority>=i){r&&r.priority===i&&r.impl!==t&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${r.bundle}" (priority ${r.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${o}> defined by "${r.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(r&&r.priority>=i){r.priority===i&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${r.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}v.set(o,s),customElements.define(o,t)}var l=class extends HTMLElement{#t=[];#e;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,s){t.addEventListener(e,i,s),this.#t.push(()=>t.removeEventListener(e,i,s))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#e||(this.#e=this.attachInternals());let i=this.#e.states;try{e?i.add(t):i.delete(t)}catch{let s=`--${t}`;e?i.add(s):i.delete(s)}}_adoptInternals(t){this.#e||(this.#e=t)}#i(){return this.constructor.formAssociated&&this.#e?this.#e:null}get validity(){return this.#i()?.validity}get validationMessage(){return this.#i()?.validationMessage??""}get willValidate(){return this.#i()?.willValidate??!1}get form(){return this.#i()?.form??null}checkValidity(){return this.#i()?.checkValidity()??!0}reportValidity(){return this.#i()?.reportValidity()??!0}};function b(o){return g(o&&o.closest("[lang]")?.lang||document.documentElement.lang||navigator.language||"en")}function g(o,t="en-US"){try{if(o)return Intl.getCanonicalLocales(o),o}catch{}try{return Intl.getCanonicalLocales(t),t}catch{return"en-US"}}var d=[.5,.75,1,1.25,1.5,2],y=3e3,c=10,k=5,x='input, button, a[href], summary, select, textarea, video[controls], [contenteditable]:not([contenteditable="false"])',w={player:"Video player",controls:"Video controls","play-video":"Play video",play:"Play",pause:"Pause",seek:"Seek","skip-back":"Skip back 10 seconds","skip-forward":"Skip forward 10 seconds",mute:"Mute",volume:"Volume",speed:"Playback speed {rate}",captions:"Captions",fullscreen:"Fullscreen","exit-fullscreen":"Exit fullscreen",playing:"Playing",paused:"Paused",ended:"Ended",buffering:"Buffering","time-of":"{current} of {duration}"},p=class extends l{#t=null;#e=null;#i=!1;#p=null;#c=null;#v=null;#h=null;#V=null;#B=null;#u=null;#$=null;#F=null;#m=null;#n=null;#b=null;#U=null;#_=null;#r=null;#y=2;#N=null;#I=null;#g=null;#H=!1;#k="en";#x=null;#w=null;setup(){if(this.#t=this.querySelector("video"),!this.#t)return!1;this.#e=this.querySelector(".track-list"),this.#t.removeAttribute("controls"),this.#G(),this.#Y(),this.#Q(),this.#W(),this.#et(),this.#tt(),this.#J(),this.#P(),this.hasAttribute("muted")&&(this.#t.muted=!0),this.#l(),!this.#e&&this.hasAttribute("loop")&&(this.#t.loop=!0),this.#H||(this.#H=!0,globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches?this.#t.autoplay&&(this.#t.autoplay=!1,this.#t.pause()):this.hasAttribute("autoplay")&&this.#t.play().catch(()=>{})),this.#a(),this.#N=()=>{let e=this.shadowRoot?.querySelector(".player");e&&(e.style.display="none",e.offsetHeight,e.style.display="")},this.listen(window,"vb:theme-change",this.#N),this.#I=()=>{let e=this.#T();e!==this.hasAttribute("data-fullscreen")&&(this.#j(e),this.#b.setAttribute("aria-label",this.#s(e?"exit-fullscreen":"fullscreen")),this.#o("video-player:fullscreen",{active:e}))},this.listen(document,"fullscreenchange",this.#I),this.#j(this.#T());let t=this.#L();return t&&this.hasAttribute("captions")&&(t.mode="showing"),this.#O(),this.listen(this.#t.textTracks,"change",()=>this.#O()),this.#i=!this.#t.paused&&!this.#t.ended,this.#d(this.#t.ended?"ended":this.#i?"playing":this.#t.currentTime>0?"paused":"idle"),this.#c.setAttribute("aria-label",this.#s(this.#i?"pause":"play")),this.#q(),this.#S(),!0}teardown(){this.#t&&this.#t.setAttribute("controls",""),this.#r!=null&&clearTimeout(this.#r),this.#r=null}get src(){return this.#t?.getAttribute("src")||this.#t?.currentSrc||""}set src(t){if(!this.#t)return;let e=t==null?"":String(t);this.#t.getAttribute("src")!==e&&(this.#t.setAttribute("src",e),this.#t.load?.(),this.#o("video-player:src-changed",{src:e,source:"property"}))}get currentTime(){return this.#t?.currentTime??0}set currentTime(t){this.#t&&(this.#t.currentTime=Number(t)||0)}#G(){if(this.shadowRoot)return;let t=this.attachShadow({mode:"open"});t.innerHTML=`
|
|
2
|
+
<style>${this.#X()}</style>
|
|
3
3
|
<div part="player" class="player">
|
|
4
4
|
<slot></slot>
|
|
5
5
|
<button part="play-overlay" class="play-overlay" type="button" aria-label="Play video">
|
|
@@ -18,7 +18,7 @@ var v=window.matchMedia("(prefers-reduced-motion: reduce)");var u=new Map;functi
|
|
|
18
18
|
<div class="timeline-wrap">
|
|
19
19
|
<input part="timeline" type="range" class="timeline"
|
|
20
20
|
min="0" max="100" value="0" step="0.1"
|
|
21
|
-
aria-label="Seek">
|
|
21
|
+
aria-label="Seek" aria-valuetext="0:00 of 0:00">
|
|
22
22
|
<div class="timeline-buffer"></div>
|
|
23
23
|
<div class="timeline-fill"></div>
|
|
24
24
|
</div>
|
|
@@ -44,7 +44,7 @@ var v=window.matchMedia("(prefers-reduced-motion: reduce)");var u=new Map;functi
|
|
|
44
44
|
</svg>
|
|
45
45
|
</button>
|
|
46
46
|
<div class="volume-wrap">
|
|
47
|
-
<button class="mute-btn" type="button" aria-label="Mute">
|
|
47
|
+
<button part="mute-button" class="mute-btn" type="button" aria-label="Mute" aria-pressed="false">
|
|
48
48
|
<svg class="icon-vol" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" width="18" height="18">
|
|
49
49
|
<path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3A4.5 4.5 0 0 0 14 7.97v8.05c1.48-.73 2.5-2.25 2.5-4.02z"/>
|
|
50
50
|
</svg>
|
|
@@ -53,8 +53,8 @@ var v=window.matchMedia("(prefers-reduced-motion: reduce)");var u=new Map;functi
|
|
|
53
53
|
</svg>
|
|
54
54
|
</button>
|
|
55
55
|
<input part="volume" type="range" class="volume"
|
|
56
|
-
min="0" max="1" value="1" step="0.
|
|
57
|
-
aria-label="Volume">
|
|
56
|
+
min="0" max="1" value="1" step="0.05"
|
|
57
|
+
aria-label="Volume" aria-valuetext="100%">
|
|
58
58
|
</div>
|
|
59
59
|
<span part="time-display" class="time-display">
|
|
60
60
|
<time class="current-time">0:00</time>
|
|
@@ -82,11 +82,10 @@ var v=window.matchMedia("(prefers-reduced-motion: reduce)");var u=new Map;functi
|
|
|
82
82
|
</div>
|
|
83
83
|
<div class="sr-status" role="status" aria-live="polite"></div>
|
|
84
84
|
</div>
|
|
85
|
-
`,this.#p=t.querySelector(".controls"),this.#
|
|
85
|
+
`,this.#p=t.querySelector(".controls"),this.#c=t.querySelector(".play-btn"),this.#v=t.querySelector(".play-overlay"),this.#h=t.querySelector(".timeline"),this.#V=t.querySelector(".timeline-fill"),this.#B=t.querySelector(".timeline-buffer"),this.#u=t.querySelector(".volume"),this.#$=t.querySelector(".current-time"),this.#F=t.querySelector(".duration"),this.#m=t.querySelector(".speed-btn"),this.#n=t.querySelector(".captions-btn"),this.#b=t.querySelector(".fullscreen-btn"),this.#U=t.querySelector(".buffer-indicator"),this.#_=t.querySelector(".sr-status"),this.#g=t.querySelector(".mute-btn")}#P(){let t=this.#t.querySelector('track[kind="captions"], track[kind="subtitles"]');this.#n.hidden=!t}#s(t,e={}){let i=this.getAttribute(`data-label-${t}`)??w[t]??t;for(let[s,r]of Object.entries(e))i=i.replaceAll(`{${s}}`,r);return i}#Y(){this.#k=b(this);try{this.#x=new Intl.NumberFormat(this.#k,{useGrouping:!1})}catch{this.#x=new Intl.NumberFormat("en",{useGrouping:!1})}let t=Intl.DurationFormat;try{this.#w=t?new t(this.#k,{style:"digital",hoursDisplay:"auto"}):null}catch{this.#w=null}}#J(){let t=this.shadowRoot,e=(i,s)=>t.querySelector(i)?.setAttribute("aria-label",this.#s(s));e(".controls","controls"),e(".play-overlay","play-video"),e(".timeline","seek"),e(".skip-back-btn","skip-back"),e(".skip-forward-btn","skip-forward"),e(".mute-btn","mute"),e(".volume","volume"),e(".captions-btn","captions"),this.#b.setAttribute("aria-label",this.#s(this.#T()?"exit-fullscreen":"fullscreen")),this.#D(),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.hasAttribute("role")||this.setAttribute("role","group"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label",this.#s("player")),this.hasAttribute("aria-keyshortcuts")||this.setAttribute("aria-keyshortcuts","Space K ArrowLeft ArrowRight ArrowUp ArrowDown M F C")}#D(){let t=d[this.#y],e=`${this.#x?.format(t)??t}x`,i=this.#m.querySelector("span");i.textContent=e,this.#m.setAttribute("aria-label",this.#s("speed",{rate:e}))}#X(){return`
|
|
86
86
|
:host {
|
|
87
87
|
display: block;
|
|
88
88
|
--_accent: var(--video-player-accent, var(--color-primary, oklch(55% 0.2 260)));
|
|
89
|
-
--_controls-bg: var(--video-player-controls-bg, oklch(0% 0 0 / 0.75));
|
|
90
89
|
--_controls-text: var(--video-player-controls-text, #fff);
|
|
91
90
|
--_radius: var(--video-player-radius, var(--radius-m, 0.5rem));
|
|
92
91
|
--_border: var(--video-player-border, none);
|
|
@@ -208,7 +207,11 @@ var v=window.matchMedia("(prefers-reduced-motion: reduce)");var u=new Map;functi
|
|
|
208
207
|
}
|
|
209
208
|
|
|
210
209
|
/* \u2500\u2500 Controls overlay \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
210
|
+
/* Media transport controls stay left-to-right in RTL pages (the
|
|
211
|
+
timeline runs start\u2192end of the media, like every platform player);
|
|
212
|
+
the fill/buffer bars and the volume gradient rely on this. */
|
|
211
213
|
.controls {
|
|
214
|
+
direction: ltr;
|
|
212
215
|
position: absolute;
|
|
213
216
|
bottom: 0;
|
|
214
217
|
left: 0;
|
|
@@ -474,6 +477,61 @@ var v=window.matchMedia("(prefers-reduced-motion: reduce)");var u=new Map;functi
|
|
|
474
477
|
border: 0;
|
|
475
478
|
}
|
|
476
479
|
|
|
480
|
+
/* \u2500\u2500 Forced colors \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
481
|
+
/* Background-only bars vanish under forced colors (backgrounds become
|
|
482
|
+
Canvas). Paint progress with system colours and outline the tracks. */
|
|
483
|
+
@media (forced-colors: active) {
|
|
484
|
+
.timeline-fill {
|
|
485
|
+
forced-color-adjust: none;
|
|
486
|
+
background: Highlight;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
.timeline-buffer {
|
|
490
|
+
forced-color-adjust: none;
|
|
491
|
+
background: GrayText;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
.timeline::-webkit-slider-runnable-track {
|
|
495
|
+
border: 1px solid CanvasText;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
.timeline::-moz-range-track {
|
|
499
|
+
border: 1px solid CanvasText;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
.volume {
|
|
503
|
+
forced-color-adjust: none;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
.volume::-webkit-slider-runnable-track {
|
|
507
|
+
border: 1px solid CanvasText;
|
|
508
|
+
background: linear-gradient(to right,
|
|
509
|
+
Highlight calc(var(--_vol, 1) * 100%),
|
|
510
|
+
Canvas calc(var(--_vol, 1) * 100%));
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
.volume::-moz-range-track {
|
|
514
|
+
border: 1px solid CanvasText;
|
|
515
|
+
background: Canvas;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
.volume::-moz-range-progress {
|
|
519
|
+
background: Highlight;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
.volume::-webkit-slider-thumb {
|
|
523
|
+
background: CanvasText;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
.volume::-moz-range-thumb {
|
|
527
|
+
background: CanvasText;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
.play-overlay svg {
|
|
531
|
+
border: 1px solid CanvasText;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
477
535
|
/* \u2500\u2500 Reduced motion \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
478
536
|
@media (prefers-reduced-motion: reduce) {
|
|
479
537
|
.play-overlay svg,
|
|
@@ -508,5 +566,5 @@ var v=window.matchMedia("(prefers-reduced-motion: reduce)");var u=new Map;functi
|
|
|
508
566
|
cursor: auto;
|
|
509
567
|
}
|
|
510
568
|
}
|
|
511
|
-
`}#
|
|
569
|
+
`}#Q(){let t=this.#t;this.listen(t,"timeupdate",()=>this.#S()),this.listen(t,"loadedmetadata",()=>{this.#q(),this.#S()}),this.listen(t,"durationchange",()=>this.#q()),this.listen(t,"progress",()=>this.#rt()),this.listen(t,"volumechange",()=>this.#l()),this.listen(t,"play",()=>{this.#i=!0,this.#d("playing"),this.#c.setAttribute("aria-label",this.#s("pause")),this.#E(this.#s("playing")),this.#o("video-player:play",{currentTime:t.currentTime,src:t.currentSrc})}),this.listen(t,"pause",()=>{this.#i=!1,t.ended||this.#d("paused"),this.#c.setAttribute("aria-label",this.#s("play")),this.#a(),this.#E(this.#s("paused")),this.#o("video-player:pause",{currentTime:t.currentTime})}),this.listen(t,"ended",()=>{this.#i=!1,this.#d("ended"),this.#c.setAttribute("aria-label",this.#s("play")),this.#a();let e=this.#e?.querySelector("li[data-video-active]");e&&e.setAttribute("data-video-played",""),this.#e&&this.#st(),this.#E(this.#s("ended")),this.#o("video-player:ended",{src:t.currentSrc})}),this.listen(t,"waiting",()=>{this.#i&&(this.#d("buffering"),this.#E(this.#s("buffering")))}),this.listen(t,"playing",()=>{this.getAttribute("state")==="buffering"&&this.#d("playing")})}#d(t){this.setAttribute("state",t),this.#v&&(this.#v.inert=!(t==="idle"||t==="ended"))}#W(){let t=this.shadowRoot,e=()=>{this.#i?this.#t.pause():this.#t.play().catch(()=>{})};this.listen(this.#v,"click",s=>{s.stopPropagation(),this.#t.play().catch(()=>{})});let i=t.querySelector(".player");this.listen(i,"click",s=>{let r=s.target;r.closest(".controls")||r.closest(".play-overlay")||r!==this.#t&&r!==i||e()}),this.listen(this.#c,"click",e),this.listen(this.#h,"input",()=>{this.#t.duration&&(this.#t.currentTime=Number(this.#h.value)/100*this.#t.duration,this.#M())}),this.listen(this.#h,"keydown",s=>{let r=s;if(r.altKey||r.ctrlKey||r.metaKey)return;let a={ArrowLeft:-1,ArrowDown:-1,ArrowRight:1,ArrowUp:1}[r.key];a&&(r.preventDefault(),this.#f(a*k))}),this.listen(t.querySelector(".skip-back-btn"),"click",()=>this.#f(-c)),this.listen(t.querySelector(".skip-forward-btn"),"click",()=>this.#f(c)),this.listen(this.#u,"input",()=>{this.#t.volume=Number(this.#u.value),this.#t.muted=!1,this.#l()}),this.listen(this.#g,"click",()=>{this.#t.muted=!this.#t.muted,this.#l()}),this.listen(this.#m,"click",()=>{this.#y=(this.#y+1)%d.length;let s=d[this.#y];this.#t.playbackRate=s,this.#D(),this.#o("video-player:speed",{rate:s})}),this.listen(this.#n,"click",()=>{let s=this.#L();if(!s)return;let r=s.mode==="showing";s.mode=r?"hidden":"showing";let a=!r;this.toggleAttribute("captions",a),this.#n.setAttribute("aria-pressed",String(a)),this.#o("video-player:captions",{active:a,label:s.label})}),this.listen(this.#b,"click",()=>this.#K()),this.listen(this,"keydown",s=>this.#at(s))}#Z(t){for(let e of t.composedPath()){if(e===this)return!1;if(e instanceof Element&&e.matches(x))return!0}return!1}#f(t){let e=this.#t.duration||0;this.#t.currentTime=Math.min(e,Math.max(0,this.#t.currentTime+t)),this.#a(),this.#S()}#tt(){let t=this.shadowRoot?.querySelector(".player"),e=()=>{this.#a(),this.#z(y)};this.listen(t,"mousemove",e),this.listen(t,"mouseenter",e),this.listen(t,"mouseleave",()=>this.#z(500)),this.listen(t,"touchstart",()=>{this.hasAttribute("controls")?this.#R():e()},{passive:!0}),this.listen(this.#p,"mouseenter",()=>{this.#r!=null&&clearTimeout(this.#r),this.#a()}),this.listen(this.#p,"focusin",()=>{this.#r!=null&&clearTimeout(this.#r),this.#a()}),this.listen(this.#p,"focusout",()=>this.#z(y))}#z(t){this.#r!=null&&clearTimeout(this.#r),this.#r=null,this.#i&&(this.#r=setTimeout(()=>this.#R(),t))}#a(){this.setAttribute("controls","")}#R(){let t=this.shadowRoot?.activeElement;t&&this.#p?.contains(t)||this.removeAttribute("controls")}#et(){this.#e&&this.listen(this.#e,"click",t=>{let e=t.target.closest("a[href]");e&&(t.preventDefault(),this.#A(e.href,e.closest("li"),e))})}#A(t,e,i){this.#e.querySelectorAll("li").forEach(n=>n.removeAttribute("data-video-active")),e&&e.setAttribute("data-video-active",""),this.#t.src=t;let r=i?.getAttribute("data-poster");r&&(this.#t.poster=r);let a=i?.getAttribute("data-captions");this.#it(a),this.#t.play().catch(()=>{}),this.#o("video-player:track-change",{src:t,title:i?.textContent??""})}#it(t){if(this.#t.querySelectorAll("track[data-dynamic]").forEach(i=>i.remove()),t){let i=document.createElement("track");i.kind="captions",i.src=t,i.default=!0,i.setAttribute("data-dynamic",""),this.#t.appendChild(i),this.hasAttribute("captions")&&(i.track.mode="showing")}this.#P()}#st(){if(!this.#e)return;let t=[...this.#e.querySelectorAll("li")],e=t.findIndex(s=>s.hasAttribute("data-video-active"));if(this.hasAttribute("shuffle")){let s=t.filter((r,a)=>a!==e);if(s.length){let r=s[Math.floor(Math.random()*s.length)],a=r.querySelector("a[href]");a&&this.#A(a.href,r,a)}return}let i=e+1;if(i<t.length){let s=t[i].querySelector("a[href]");s&&this.#A(s.href,t[i],s)}else if(this.hasAttribute("loop")){let s=t[0]?.querySelector("a[href]");s&&this.#A(s.href,t[0],s)}}#S(){let t=this.#t.currentTime,e=this.#t.duration||0,i=e?t/e*100:0;this.#$.textContent=this.#C(t),this.#h.value=String(i),this.#M(),this.#V.style.width=`${i}%`}#M(){this.#h.setAttribute("aria-valuetext",this.#s("time-of",{current:this.#C(this.#t.currentTime),duration:this.#C(this.#t.duration||0)}))}#q(){let t=this.#t.duration||0;this.#F.textContent=this.#C(t),this.#M()}#rt(){let t=this.#t.buffered,e=this.#t.duration||0;if(t.length>0&&e){let i=t.end(t.length-1);this.#B.style.width=`${i/e*100}%`}}#T(){let t=document.fullscreenElement;return!!t&&(t===this||t===this.#t)}#j(t){t?this.setAttribute("data-fullscreen",""):this.removeAttribute("data-fullscreen")}#K(){this.#T()?document.exitFullscreen().catch(()=>{}):this.requestFullscreen().catch(()=>{this.#t.requestFullscreen?.().catch(()=>{})})}#O(){let t=this.#L();if(!t||!this.#n)return;let e=t.mode==="showing";this.toggleAttribute("captions",e),this.#n.setAttribute("aria-pressed",String(e))}#L(){let t=this.#t.textTracks;for(let e=0;e<t.length;e++)if(t[e].kind==="captions"||t[e].kind==="subtitles")return t[e];return null}#at(t){if(!(t.defaultPrevented||t.altKey||t.ctrlKey||t.metaKey)&&!this.#Z(t))switch(t.key){case" ":case"k":case"K":t.preventDefault(),this.#i?this.#t.pause():this.#t.play().catch(()=>{});break;case"ArrowLeft":t.preventDefault(),this.#f(-c);break;case"ArrowRight":t.preventDefault(),this.#f(c);break;case"ArrowUp":t.preventDefault(),this.#t.volume=Math.min(1,this.#t.volume+.05),this.#l(),this.#a();break;case"ArrowDown":t.preventDefault(),this.#t.volume=Math.max(0,this.#t.volume-.05),this.#l(),this.#a();break;case"m":case"M":this.#t.muted=!this.#t.muted,this.#l();break;case"f":case"F":this.#K();break;case"c":case"C":this.#n.click();break}}#l(){if(!this.#t||!this.#g)return;let t=this.#t.muted;this.toggleAttribute("muted",t),this.#g.setAttribute("aria-pressed",String(t));let e=this.#t.volume;this.#u.value=String(e),this.#u.style.setProperty("--_vol",t?"0":String(e));let i;try{i=new Intl.NumberFormat(this.#k,{style:"percent"}).format(e)}catch{i=`${Math.round(e*100)}%`}this.#u.setAttribute("aria-valuetext",i)}#C(t){let e=Number.isFinite(t)&&t>0?Math.floor(t):0,i=Math.floor(e/3600),s=Math.floor(e%3600/60),r=e%60,a=this.#x??new Intl.NumberFormat("en",{useGrouping:!1});if(this.#w)try{let h=this.#w.formatToParts({hours:i,minutes:s,seconds:r}),f=!0;return h.map(u=>f&&u.type==="integer"?(f=!1,a.format(u.unit==="hour"?i:s)):u.value).join("")}catch{}let n=h=>a.format(h).padStart(2,a.format(0));return i>0?`${a.format(i)}:${n(s)}:${n(r)}`:`${a.format(s)}:${n(r)}`}#E(t){this.#_&&(this.#_.textContent=t)}#o(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}};m("video-player",p);export{p as VideoPlayerElement};
|
|
512
570
|
//# sourceMappingURL=video-player.js.map
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
`);p.replaceSync(t),document.adoptedStyleSheets=[...document.adoptedStyleSheets,p],w=1}function ft(){w--,w<=0&&p&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(n=>n!==p),p=null,w=0)}function $(n){f||(f=document.createElement("div"),f.setAttribute("aria-live","polite"),f.setAttribute("aria-atomic","true"),f.className="hn-sr-only",document.body.appendChild(f)),f.textContent="",requestAnimationFrame(()=>{f.textContent=n})}function J(n,t,e){let i=document.createTreeWalker(n,NodeFilter.SHOW_TEXT),s=0;for(;i.nextNode();){if(i.currentNode===t)return s+e;s+=(i.currentNode.textContent??"").length}return-1}function y(n,t,e){let i=document.createTreeWalker(n,NodeFilter.SHOW_TEXT),s=0,r=null,o=0,c=null,a=0;for(;i.nextNode();){let l=i.currentNode,g=(l.textContent??"").length;if(!r&&s+g>t&&(r=l,o=t-s),s+g>=e){c=l,a=e-s;break}s+=g}if(!r||!c)return null;try{let l=document.createRange();return l.setStart(r,Math.min(o,(r.textContent??"").length)),l.setEnd(c,Math.min(a,(c.textContent??"").length)),l}catch{return null}}function M(n){if(N.has(n))return N.get(n);let t=new R(n);return N.set(n,t),t}function K(n=document){n.querySelectorAll(L).forEach(t=>{t.hasAttribute("data-highlights-init")||M(t)})}var L,z,ct,ht,p,w,f,R,N,gt,Y=E(()=>{T();L="[data-highlights]",z="highlights",ct=["yellow","green","blue","pink"],ht=typeof CSS<"u"&&"highlights"in CSS;p=null,w=0;f=null;R=class{#t;#n;#s;#a;#e=[];#c=!ht;#h;#l;#d=!1;#u=[];constructor(t){this.#t=t,this.#a=t.hasAttribute("data-highlights-readonly");let e=t.dataset.highlights;this.#n=e&&e!==""?e:location.pathname;let i=t.dataset.highlightsColors;this.#s=i?i.split(",").map(s=>s.trim()).filter(Boolean):[...ct],this.#c||ut(this.#s),this.#o(),this.#a||(this.#h=this.#p.bind(this),this.#l=this.#m.bind(this),t.addEventListener("pointerup",this.#h),t.addEventListener("click",this.#l)),t.setAttribute("data-highlights-init",""),this.#b().then(()=>{this.#d||this.#o()})}get colors(){return[...this.#s]}get element(){return this.#t}getHighlights(){return this.#e.map(t=>({...t}))}removeHighlight(t){let e=this.#e.findIndex(i=>i.id===t);e<0||(this.#e.splice(e,1),this.#r(),this.#o(),this.#i("highlights:removed",{id:t}),$("Highlight removed"))}clearAll(){this.#e=[],this.#r(),this.#o()}exportHighlights(){return JSON.stringify({version:1,highlights:this.#e})}importHighlights(t){try{let e=typeof t=="string"?JSON.parse(t):t;if(!e.highlights||!Array.isArray(e.highlights))return;this.#e=e.highlights,this.#r(),this.#o()}catch{}}destroy(){if(!this.#d){if(this.#d=!0,this.#h&&this.#t.removeEventListener("pointerup",this.#h),this.#l&&this.#t.removeEventListener("click",this.#l),this.#c)this.#t.querySelectorAll("mark[data-hn-id]").forEach(t=>{let e=t.parentNode;for(;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t),e.normalize()});else{for(let t of this.#s)CSS.highlights.delete(`hn-${t}`);ft()}this.#f(),this.#t.removeAttribute("data-highlights-init")}}#p(){requestAnimationFrame(()=>{if(this.#d)return;let t=window.getSelection();if(!t||t.isCollapsed||!t.toString().trim())return;let e=t.getRangeAt(0);this.#t.contains(e.commonAncestorContainer)&&this.#i("highlights:selected",{text:t.toString().trim(),rect:e.getBoundingClientRect()})})}#m(t){let e=t.target.closest?.(".hn-margin-annotation");if(e){let s=e.dataset.hnId,r=this.#e.find(o=>o.id===s);if(r){this.#i("highlights:clicked",{id:s,highlight:{...r}}),this.#i("highlights:request-note",{id:s,highlight:{...r},controller:this});return}}let i=t.target.closest?.("mark[data-hn-id]");if(i){let s=i.dataset.hnId,r=this.#e.find(o=>o.id===s);if(r){this.#i("highlights:clicked",{id:s,highlight:{...r}});return}}if(!this.#c){let s=this.#y(t.clientX,t.clientY);s&&this.#i("highlights:clicked",{id:s.id,highlight:{...s}})}}findHighlightRect(t){let e=this.#e.find(r=>r.id===t);if(!e)return null;let i=y(this.#t,e.startOffset,e.endOffset);if(!i)return null;let s=i.getClientRects();return s.length?s[0]:null}#y(t,e){for(let i of this.#e){let s=y(this.#t,i.startOffset,i.endOffset);if(!s)continue;let r=s.getClientRects();for(let o of r)if(t>=o.left&&t<=o.right&&e>=o.top&&e<=o.bottom)return i}return null}_createFromSelection(t){let e=window.getSelection();if(!e||e.isCollapsed)return;let i=e.getRangeAt(0);if(!this.#t.contains(i.commonAncestorContainer))return;let s=J(this.#t,i.startContainer,i.startOffset),r=J(this.#t,i.endContainer,i.endOffset);if(s<0||r<0||s>=r)return;let o=e.toString().trim(),c={id:lt(),startOffset:s,endOffset:r,text:o,color:t,note:"",created:Date.now()};this.#e.push(c),this.#r(),this.#o(),e.removeAllRanges(),this.#i("highlights:added",{id:c.id,text:o,color:t,note:""}),$("Highlight added")}_changeColor(t,e){let i=this.#e.find(s=>s.id===t);i&&(i.color=e,this.#r(),this.#o())}_updateNote(t,e){let i=this.#e.find(s=>s.id===t);i&&(i.note=e,this.#r(),this.#g(),this.#i("highlights:note-changed",{id:t,note:e}),$("Note saved"))}async#b(){let t=await u.get(z,this.#n);if(!t||!Array.isArray(t.highlights))return;let e=k(this.#t.textContent);t.contentHash&&t.contentHash!==e?(this.#e=t.highlights.filter(i=>{let s=y(this.#t,i.startOffset,i.endOffset);return s?s.toString().trim()===i.text:!1}),this.#r()):this.#e=t.highlights}#r(){let t={version:1,contentHash:k(this.#t.textContent),highlights:this.#e};u.set(z,this.#n,t).catch(()=>{})}#o(){this.#c?this.#v():this.#w(),this.#g()}#w(){let t=new Map;for(let e of this.#s)t.set(e,[]);for(let e of this.#e){let i=y(this.#t,e.startOffset,e.endOffset);i&&t.has(e.color)&&t.get(e.color).push(i)}for(let[e,i]of t){let s=`hn-${e}`;i.length===0?CSS.highlights.delete(s):CSS.highlights.set(s,new Highlight(...i))}}#v(){this.#t.querySelectorAll("mark[data-hn-id]").forEach(e=>{let i=e.parentNode;for(;e.firstChild;)i.insertBefore(e.firstChild,e);i.removeChild(e)}),this.#t.normalize();let t=[...this.#e].sort((e,i)=>i.startOffset-e.startOffset);for(let e of t){let i=y(this.#t,e.startOffset,e.endOffset);if(!i)continue;let s=dt(this.#t,e.color),r=document.createElement("mark");r.dataset.hnId=e.id,r.dataset.hnColor=e.color,s&&(r.style.backgroundColor=s,r.style.textDecorationColor=s);try{i.surroundContents(r)}catch{let o=i.extractContents();r.appendChild(o),i.insertNode(r)}}}#f(){for(let t of this.#u)t.remove();this.#u=[]}#g(){if(this.#f(),this.#e.length===0)return;getComputedStyle(this.#t).position==="static"&&(this.#t.style.position="relative");for(let e of this.#e){let i=y(this.#t,e.startOffset,e.endOffset);if(!i)continue;let s=i.getClientRects();if(s.length===0)continue;let r=s[0],o=this.#t.getBoundingClientRect(),c=r.top-o.top,a=document.createElement("span");a.className="hn-margin-annotation",a.dataset.hnId=e.id,a.setAttribute("aria-hidden","true"),a.style.top=`${c}px`,e.note?(a.innerHTML='<span class="hn-note-indicator">*</span> You highlighted',a.classList.add("hn-has-note")):a.textContent="You highlighted",this.#t.appendChild(a),this.#u.push(a)}}#i(t,e={}){this.#t.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0}))}},N=new WeakMap;document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>K()):K();gt=new MutationObserver(n=>{for(let t of n)for(let e of t.addedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;let i=e;i.matches(L)&&M(i),i.querySelectorAll(L).forEach(s=>{s.hasAttribute("data-highlights-init")||M(s)})}});gt.observe(document.documentElement,{childList:!0,subtree:!0})});var tt={};st(tt,{currentHash:()=>q,initPageWatch:()=>P,readWatch:()=>x,removeWatch:()=>Z,writeWatch:()=>v});function Q(){return typeof window<"u"&&window.vbPageWatch?.serverSync===!0?!0:document.querySelector('meta[name="vb-page-watch-server"]')?.getAttribute("content")==="true"}async function pt(n){if(!Q())return null;try{let t=new b("notify"),e={url:n.url,type:"page-watch",notify:["panel"]},i=await t.post("/subscribe",e);return typeof i?.id=="string"?i.id:null}catch(t){let e=t instanceof m?`${t.status}`:String(t);return console.warn("[page-watch] server subscribe failed; client-only watch in effect.",e),null}}async function mt(n){if(!(!n||!Q()))try{await new b("notify").delete(`/subscribe/${encodeURIComponent(n)}`)}catch(t){let e=t instanceof m?`${t.status}`:String(t);console.warn("[page-watch] server unsubscribe failed; local state already cleared.",e)}}function yt(){return document.querySelector("main")||document.querySelector("article")||document.body}function S(){return location.pathname||"/"}function q(){let n=yt();return n?k(n.textContent||""):""}function bt(){return document.title||S()}async function x(){return await u.get(W,S())}async function v(n){await u.set(W,S(),n)}async function Z(){await u.remove(W,S())}function B(n,t){n.setAttribute("aria-pressed",t?"true":"false"),n.dataset.watching="",t||delete n.dataset.watching;let e=n.querySelector("icon-wc");e&&e.setAttribute("name",t?"bookmark-check":"bookmark");let i=[...n.childNodes].find(s=>s.nodeType===Node.TEXT_NODE&&(s.textContent||"").trim());i&&!n.hasAttribute("data-watch-label-locked")&&(i.textContent=t?"Watching":"Watch for updates"),n.setAttribute("title",t?"Stop watching this page":"Watch this page for content updates")}async function I(n){if(n.hasAttribute("data-watch-page-init"))return;n.setAttribute("data-watch-page-init",""),n.setAttribute("type",n.getAttribute("type")||"button");let t=await x();B(n,!!t),n.addEventListener("click",async e=>{e.preventDefault();let i=await x();if(i)await Z(),B(n,!1),n.dispatchEvent(new CustomEvent("page-watch:remove",{bubbles:!0,composed:!0,detail:{url:i.url,subscriptionId:i.subscriptionId}})),mt(i.subscriptionId);else{let s={url:S(),title:bt(),contentHash:q(),watchedAt:new Date().toISOString(),lastChecked:new Date().toISOString(),lastChanged:null,subscriptionId:null};await v(s),B(n,!0),n.dispatchEvent(new CustomEvent("page-watch:add",{bubbles:!0,composed:!0,detail:{entry:s}}));let r=await pt(s);r&&await v({...s,subscriptionId:r})}})}async function wt(){let n=await x();if(!n)return;let t=q(),e=new Date().toISOString(),i=n.contentHash,s={...n,lastChecked:e};if(t&&t!==i){s.contentHash=t,s.lastChanged=e,await v(s);let r={id:`page-watch:${n.url}:${t}`,type:"watch",title:`Updated: ${n.title}`,body:"Content changed since your last visit.",url:n.url,date:e,read:!1,dismissed:!1,priority:"normal"};document.dispatchEvent(new CustomEvent("notification-wc:new",{bubbles:!0,composed:!0,detail:{notification:r}}))}else await v(s)}function P(n=document){for(let t of n.querySelectorAll(H))I(t);wt()}var H,W,vt,et=E(()=>{T();G();Y();H="[data-watch-page]",W="watches";document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>P()):P();vt=new MutationObserver(n=>{for(let t of n)for(let e of t.addedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;let i=e;i.matches?.(H)&&I(i),i.querySelectorAll?.(H).forEach(s=>I(s))}});vt.observe(document.documentElement,{childList:!0,subtree:!0})});var Ct=window.matchMedia("(prefers-reduced-motion: reduce)");var U=new Map;function _(n,t,e={}){let i=e.priority??10,s={impl:t,bundle:e.bundle,contract:e.contract,priority:i},r=U.get(n);if(customElements.get(n)){if(!r||r.priority>=i){r&&r.priority===i&&r.impl!==t&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${r.bundle}" (priority ${r.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> defined by "${r.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(r&&r.priority>=i){r.priority===i&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${r.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}U.set(n,s),customElements.define(n,t)}var C=class extends HTMLElement{#t=[];#n;connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,s){t.addEventListener(e,i,s),this.#t.push(()=>t.removeEventListener(e,i,s))}setup(){}teardown(){}setState(t,e){this.#n||(this.#n=this.attachInternals());let i=this.#n.states;try{e?i.add(t):i.delete(t)}catch{let s=`--${t}`;e?i.add(s):i.delete(s)}}_adoptInternals(t){this.#n||(this.#n=t)}};var nt="Watch for updates",St="Watching",D=class extends C{#t=null;setup(){if(this.hasAttribute("server-sync")){let e=window;e.vbPageWatch={...e.vbPageWatch??{},serverSync:!0}}let t=this.#n();this.dataset.variant=t;for(let e of Array.from(this.children))e.hasAttribute?.("data-watch-page")&&e.remove();this.#t=this.#s(t),this.appendChild(this.#t),this.listen(document,"page-watch:add",this.#a),this.listen(document,"page-watch:remove",this.#a)}teardown(){this.#t&&(this.#t.remove(),this.#t=null)}#n(){let t=this.getAttribute("variant");return t==="compact"||t==="button"?t:"icon"}#s(t){let e=document.createElement("button");e.type="button",e.setAttribute("data-watch-page",""),e.className="ghost",e.setAttribute("aria-label","Watch this page for updates");let i=t==="icon"?"sm":"xs",s=this.getAttribute("label")??nt;return t==="icon"?e.innerHTML=`<icon-wc name="bookmark" size="${i}"></icon-wc>`:(e.innerHTML=`<icon-wc name="bookmark" size="${i}"></icon-wc><span>${this.#e(s)}</span>`,e.setAttribute("data-watch-label-locked","")),e}#a=async()=>{if(this.#t)try{let{readWatch:t}=await Promise.resolve().then(()=>(et(),tt)),i=!!await t();this.#t.setAttribute("aria-pressed",i?"true":"false");let s=this.#t.querySelector("icon-wc");s&&s.setAttribute("name",i?"bookmark-check":"bookmark");let r=this.#t.querySelector("span");if(r&&this.#n()!=="icon"){let o=this.getAttribute("label");r.textContent=o||(i?St:nt)}this.#t.setAttribute("title",i?"Stop watching this page":"Watch this page for content updates")}catch{}};#e(t){let e=document.createElement("div");return e.textContent=t,e.innerHTML}};_("watch-wc",D);export{D as WatchWc};
|
|
1
|
+
var St=Object.defineProperty;var b=(n,t)=>()=>(n&&(t=n(n=0)),t);var Et=(n,t)=>{for(var e in t)St(n,e,{get:t[e],enumerable:!0})};function At(){let n=globalThis.localStorage;if(!n)throw new Error("VBStore: localStorage is not available in this environment");return{async getRaw(t){return n.getItem(t)},async setRaw(t,e){n.setItem(t,e)},async removeRaw(t){n.removeItem(t)},async keys(t){let e=[];for(let i=0;i<n.length;i++){let r=n.key(i);r&&r.startsWith(t)&&e.push(r)}return e}}}function d(){return O[$]||(O[$]=At()),O[$]}function _(n,t){if(typeof n!="string"||!n)throw new TypeError("VBStore: namespace must be a non-empty string");if(typeof t!="string"||!t)throw new TypeError("VBStore: key must be a non-empty string");return`vb:${n}:${t}`}function G(n){if(typeof n!="string"||!n)throw new TypeError("VBStore: namespace must be a non-empty string");return`vb:${n}:`}function J(n){try{let t=JSON.parse(n);if(t&&typeof t=="object"&&typeof t.timestamp=="number")return t}catch{}return null}var $,O,l,D=b(()=>{$="__vbStoreBackend",O=globalThis;l={configure(n={}){O[$]=n.backend??null},async set(n,t,e){let i={data:e,timestamp:Date.now()};await d().setRaw(_(n,t),JSON.stringify(i))},async get(n,t,e){let i=await d().getRaw(_(n,t));if(i==null)return null;let r=J(i);return!r||e?.maxAge!=null&&Date.now()-r.timestamp>e.maxAge?null:r.data},async remove(n,t){await d().removeRaw(_(n,t))},async list(n){let t=G(n),e=await d().keys(t),i=[];for(let r of e){let s=await d().getRaw(r);if(s==null)continue;let o=J(s);o&&i.push({key:r.slice(t.length),data:o.data,timestamp:o.timestamp})}return i},async clear(n){let t=G(n),e=await d().keys(t);for(let i of e)await d().removeRaw(i)},async clearAll(){let n=await d().keys("vb:");for(let t of n)await d().removeRaw(t)},async setMany(n,t){for(let[e,i]of t)await l.set(n,e,i)}};if(typeof window<"u"){let n=window.VB??(window.VB={});n.store??=l}});function Ct(n,t){if(!t)return n;let e=n??new URLSearchParams;for(let[i,r]of Object.entries(t))r!=null&&e.set(i,String(r));return e}async function kt(n){if((n.headers.get("content-type")??"").includes("application/json"))try{return await n.json()}catch{return null}try{return await n.text()}catch{return null}}function Q(n){return n.endsWith("/")?n.slice(0,-1):n}var v,S,Z,P,g,w,tt=b(()=>{v="__vbServiceConfig",S=globalThis,Z=()=>({baseUrl:"/go",headers:{},services:{}});S[v]||(S[v]=Z());P=()=>S[v],g=class extends Error{constructor(t,e,i,r){super(`VBService(${i}): ${t} ${r}`),this.name="VBServiceError",this.status=t,this.body=e,this.role=i,this.path=r}};w=class n{static configure(t={}){let e=P();S[v]={baseUrl:t.baseUrl??e.baseUrl,headers:{...e.headers,...t.headers??{}},services:{...e.services,...t.services??{}}}}static resolve(t){if(!t||typeof t!="string")throw new TypeError("VBService: role must be a non-empty string");let e=P();return e.services[t]?Q(e.services[t]):e.baseUrl?`${Q(e.baseUrl)}/${t}`:`/go/${t}`}static _reset(){S[v]=Z()}constructor(t){if(!t||typeof t!="string")throw new TypeError("VBService: role must be a non-empty string");this.role=t}async get(t,e){return this.#t("GET",t,{params:e})}async post(t,e){return this.#t("POST",t,{body:e})}async patch(t,e){return this.#t("PATCH",t,{body:e})}async delete(t){return this.#t("DELETE",t,{})}async#t(t,e,i){let r=n.resolve(this.role),s=e?e.startsWith("/")?e:`/${e}`:"",o=new URL(`${r}${s}`,globalThis.location?.origin??"http://localhost"),c=Ct(o.searchParams,i.params);c&&(o.search=c.toString());let a={method:t,headers:{...P().headers}};i.body!==void 0&&(a.body=JSON.stringify(i.body),a.headers["content-type"]="application/json");let h=o.toString(),f=await fetch(h,a),X=await kt(f);if(!f.ok)throw new g(f.status,X,this.role,`${s||"/"}`);return X}};if(typeof window<"u"){let n=window.VB??(window.VB={});n.service??=w,n.ServiceError??=g}});function $t(n,t){let e=et.get(t);e||et.set(t,e=new Map);let i=e.get(n);if(!i||!i.region.isConnected){let s=(t.ownerDocument||document).createElement("span");s.setAttribute("data-vb-announcer",n),s.setAttribute("role",n==="assertive"?"alert":"status"),s.setAttribute("aria-live",n),s.setAttribute("aria-atomic","true"),s.style.cssText=xt,t.appendChild(s),i={region:s},e.set(n,i)}return i}function T(n,{politeness:t="polite",root:e}={}){let i=String(n??"").trim();if(!i||typeof document>"u")return null;let r=e||document.body;if(!r)return null;let o=$t(t==="assertive"?"assertive":"polite",r);return clearTimeout(o.write),clearTimeout(o.clear),o.region.textContent="",o.write=setTimeout(()=>{o.region.textContent=i,o.clear=setTimeout(()=>{o.region.textContent=""},7e3)},50),o.region}var xt,et,nt=b(()=>{xt=["position:absolute","inline-size:1px","block-size:1px","padding:0","margin:-1px","overflow:hidden","clip-path:inset(50%)","white-space:nowrap","border:0"].join(";"),et=new WeakMap});function M(n){let t=2166136261;for(let e=0;e<n.length;e++)t^=n.charCodeAt(e),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function ct(){return"hn-"+crypto.randomUUID().slice(0,8)}function N(n,t){let e="highlightsLabel"+t[0].toUpperCase()+t.slice(1);return n.dataset[e]||Lt[t]}function Rt(n,{textLength:t,colors:e}){if(!n||typeof n!="object")return null;let i=n,{startOffset:r,endOffset:s,color:o}=i;if(!Number.isInteger(r)||!Number.isInteger(s))return null;let c=r,a=s;return c<0||a<=c||a>t||!F(o)||!e.includes(o)||i.id!=null&&(typeof i.id!="string"||!/^[\w-]{1,64}$/.test(i.id))||i.text!=null&&typeof i.text!="string"||i.note!=null&&typeof i.note!="string"?null:{id:i.id||ct(),startOffset:c,endOffset:a,text:i.text??"",color:o,note:i.note??"",created:Number.isFinite(i.created)?i.created:Date.now()}}function F(n){return typeof n=="string"&&Nt.test(n)}function lt(){if(m.size===0){p&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(i=>i!==p),p=null);return}p||(p=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets,p]);let n=[...m.keys()],t=n.map(i=>`::highlight(hn-${i}) { background-color: var(--highlight-${i}); color: var(--highlight-${i}-ink, var(--highlight-ink, CanvasText)); text-decoration-line: underline; text-decoration-color: var(--highlight-${i}); text-underline-offset: 2px; }`),e=n.map((i,r)=>`::highlight(hn-${i}) { background-color: Mark; color: MarkText; text-decoration-line: underline; text-decoration-color: MarkText; text-decoration-style: ${rt[r%rt.length]}; text-decoration-thickness: 2px; }`);p.replaceSync(`${t.join(`
|
|
2
|
+
`)}
|
|
3
|
+
@media (forced-colors: active) {
|
|
4
|
+
${e.join(`
|
|
5
|
+
`)}
|
|
6
|
+
}`)}function Mt(n){for(let t of n)m.set(t,(m.get(t)??0)+1);lt()}function Bt(n){for(let t of n){let e=(m.get(t)??0)-1;e>0?m.set(t,e):m.delete(t)}lt()}function It(n){let t=E.get(n),e=t?[...t.values()].flat():[];e.length===0?(CSS.highlights.delete(`hn-${n}`),E.delete(n)):CSS.highlights.set(`hn-${n}`,new Highlight(...e))}function st(n,t){let e=new Set(t.keys());for(let[i,r]of E)r.has(n)&&e.add(i);for(let i of e){let r=t.get(i)??[],s=E.get(i);r.length?(s||E.set(i,s=new Map),s.set(n,r)):s?.delete(n),It(i)}}function ot(n,t,e){let i=document.createTreeWalker(n,NodeFilter.SHOW_TEXT),r=0;for(;i.nextNode();){if(i.currentNode===t)return r+e;r+=(i.currentNode.textContent??"").length}return-1}function L(n,t,e){let i=document.createTreeWalker(n,NodeFilter.SHOW_TEXT),r=0,s=null,o=0,c=null,a=0;for(;i.nextNode();){let h=i.currentNode,f=(h.textContent??"").length;if(!s&&r+f>t&&(s=h,o=t-r),r+f>=e){c=h,a=e-r;break}r+=f}if(!s||!c)return null;try{let h=document.createRange();return h.setStart(s,Math.min(o,(s.textContent??"").length)),h.setEnd(c,Math.min(a,(c.textContent??"").length)),h}catch{return null}}function q(n){let t=R.get(n);if(t&&!t.destroyed)return t;let e=new V(n);return R.set(n,e),e}function at(n=document){n.querySelectorAll(H).forEach(t=>{t.hasAttribute("data-highlights-init")||q(t)})}var H,it,Ot,Tt,R,Nt,rt,Lt,p,m,E,V,_t,ht=b(()=>{D();nt();H="[data-highlights]",it="highlights",Ot=["yellow","green","blue","pink"],Tt=typeof CSS<"u"&&"highlights"in CSS,R=new WeakMap;Nt=/^[a-z0-9_-]+$/i,rt=["solid","double","dotted","dashed","wavy"],Lt={annotation:"You highlighted",added:"Highlight added",removed:"Highlight removed",noteSaved:"Note saved"};p=null,m=new Map,E=new Map;V=class{#t;#i;#n;#h;#e=[];#s=!Tt;#d;#u;#l=!1;#f=[];#o=new Map;constructor(t){this.#t=t,this.#h=t.hasAttribute("data-highlights-readonly");let e=t.dataset.highlights;this.#i=e&&e!==""?e:location.pathname;let i=t.dataset.highlightsColors,r=i?i.split(",").map(s=>s.trim()).filter(F):[...Ot];this.#n=[...new Set(r)],this.#s||Mt(this.#n),this.#c(),this.#h||(this.#d=this.#y.bind(this),this.#u=this.#b.bind(this),t.addEventListener("pointerup",this.#d),t.addEventListener("click",this.#u)),t.setAttribute("data-highlights-init",""),this.#E().then(()=>{this.#l||this.#c()})}get colors(){return[...this.#n]}get destroyed(){return this.#l}get element(){return this.#t}getHighlights(){return this.#e.map(t=>({...t}))}removeHighlight(t){let e=this.#e.findIndex(i=>i.id===t);e<0||(this.#e.splice(e,1),this.#a(),this.#c(),this.#r("highlights:removed",{id:t}),T(N(this.#t,"removed")))}clearAll(){this.#e=[],this.#a(),this.#c()}exportHighlights(){return JSON.stringify({version:1,highlights:this.#e})}importHighlights(t){let e;try{e=typeof t=="string"?JSON.parse(t):t}catch{return{imported:0,rejected:0}}if(!e||!Array.isArray(e.highlights))return{imported:0,rejected:0};let i=this.#g(e.highlights);return this.#e=i,this.#a(),this.#c(),{imported:i.length,rejected:e.highlights.length-i.length}}#g(t){let e={textLength:(this.#t.textContent??"").length,colors:this.#n},i=new Set,r=[];for(let s of t){let o=Rt(s,e);!o||i.has(o.id)||(i.add(o.id),r.push(o))}return r}destroy(){this.#l||(this.#l=!0,this.#d&&this.#t.removeEventListener("pointerup",this.#d),this.#u&&this.#t.removeEventListener("click",this.#u),this.#s?this.#t.querySelectorAll("mark[data-hn-id]").forEach(t=>{let e=t.parentNode;for(;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t),e.normalize()}):(st(this,new Map),Bt(this.#n)),this.#m(),this.#o.clear(),this.#t.removeAttribute("data-highlights-init"),R.get(this.#t)===this&&R.delete(this.#t))}#y(){requestAnimationFrame(()=>{if(this.#l)return;let t=window.getSelection();if(!t||t.isCollapsed||!t.toString().trim())return;let e=t.getRangeAt(0);this.#t.contains(e.commonAncestorContainer)&&this.#r("highlights:selected",{text:t.toString().trim(),rect:e.getBoundingClientRect()})})}#b(t){let e=t.target.closest?.(".hn-margin-annotation");if(e){let r=e.dataset.hnId,s=this.#e.find(o=>o.id===r);if(s){this.#r("highlights:clicked",{id:r,highlight:{...s}}),this.#r("highlights:request-note",{id:r,highlight:{...s},controller:this});return}}let i=t.target.closest?.("mark[data-hn-id]");if(i){let r=i.dataset.hnId,s=this.#e.find(o=>o.id===r);if(s){this.#r("highlights:clicked",{id:r,highlight:{...s}});return}}if(!this.#s){let r=this.#S(t.clientX,t.clientY);r&&this.#r("highlights:clicked",{id:r.id,highlight:{...r}})}}findHighlightRect(t){let e=this.#e.find(s=>s.id===t);if(!e)return null;let i=this.#v(e);if(!i)return null;let r=i.getClientRects();return r.length?r[0]:null}#v(t){return this.#o.get(t.id)??L(this.#t,t.startOffset,t.endOffset)}#p(){this.#o.clear();for(let t of this.#e){let e=L(this.#t,t.startOffset,t.endOffset);e&&this.#o.set(t.id,e)}}#S(t,e){for(let i of this.#e){let r=this.#o.get(i.id);if(!r)continue;let s=r.getClientRects();for(let o of s)if(t>=o.left&&t<=o.right&&e>=o.top&&e<=o.bottom)return i}return null}_createFromSelection(t){let e=window.getSelection();if(!e||e.isCollapsed)return;let i=e.getRangeAt(0);if(!this.#t.contains(i.commonAncestorContainer))return;let r=ot(this.#t,i.startContainer,i.startOffset),s=ot(this.#t,i.endContainer,i.endOffset);if(r<0||s<0||r>=s)return;let o=e.toString().trim(),c={id:ct(),startOffset:r,endOffset:s,text:o,color:t,note:"",created:Date.now()};this.#e.push(c),this.#a(),this.#c(),e.removeAllRanges(),this.#r("highlights:added",{id:c.id,text:o,color:t,note:""}),T(N(this.#t,"added"))}_changeColor(t,e){let i=this.#e.find(r=>r.id===t);i&&(i.color=e,this.#a(),this.#c())}_updateNote(t,e){let i=this.#e.find(r=>r.id===t);i&&(i.note=e,this.#a(),this.#w(),this.#r("highlights:note-changed",{id:t,note:e}),T(N(this.#t,"noteSaved")))}async#E(){let t=await l.get(it,this.#i);if(!t||!Array.isArray(t.highlights)||this.#l)return;let e=this.#g(t.highlights),i=M(this.#t.textContent);t.contentHash&&t.contentHash!==i?(this.#e=e.filter(r=>{let s=L(this.#t,r.startOffset,r.endOffset);return s?s.toString().trim()===r.text:!1}),this.#a()):this.#e=e}#a(){let t={version:1,contentHash:M(this.#t.textContent),highlights:this.#e};l.set(it,this.#i,t).catch(()=>{})}#c(){this.#s?(this.#C(),this.#p()):(this.#p(),this.#A()),this.#w()}#A(){let t=new Map;for(let e of this.#n)t.set(e,[]);for(let e of this.#e){let i=this.#o.get(e.id);i&&t.has(e.color)&&t.get(e.color).push(i)}st(this,t)}#C(){this.#t.querySelectorAll("mark[data-hn-id]").forEach(e=>{let i=e.parentNode;for(;e.firstChild;)i.insertBefore(e.firstChild,e);i.removeChild(e)}),this.#t.normalize();let t=[...this.#e].sort((e,i)=>i.startOffset-e.startOffset);for(let e of t){let i=L(this.#t,e.startOffset,e.endOffset);if(!i)continue;let r=document.createElement("mark");r.dataset.hnId=e.id,F(e.color)&&(r.dataset.hnColor=e.color,r.style.setProperty("--_hn-color",`var(--highlight-${e.color})`),r.style.setProperty("--_hn-ink",`var(--highlight-${e.color}-ink, var(--highlight-ink))`));try{i.surroundContents(r)}catch{let s=i.extractContents();r.appendChild(s),i.insertNode(r)}}}#m(){for(let t of this.#f)t.remove();this.#f=[]}#w(){if(this.#m(),this.#e.length===0)return;getComputedStyle(this.#t).position==="static"&&(this.#t.style.position="relative");let e=this.#t.getBoundingClientRect(),i=N(this.#t,"annotation");for(let r of this.#e){let s=this.#o.get(r.id);if(!s)continue;let o=s.getClientRects();if(o.length===0)continue;let c=o[0].top-e.top,a=document.createElement("span");if(a.className="hn-margin-annotation",a.dataset.hnId=r.id,a.setAttribute("aria-hidden","true"),a.style.insetBlockStart=`${c}px`,r.note){let h=document.createElement("span");h.className="hn-note-indicator",h.textContent="*",a.append(h,` ${i}`),a.classList.add("hn-has-note")}else a.textContent=i;this.#t.appendChild(a),this.#f.push(a)}}#r(t,e={}){this.#t.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0}))}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>at()):at();_t=new MutationObserver(n=>{for(let t of n)for(let e of t.addedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;let i=e;i.matches(H)&&q(i),i.querySelectorAll(H).forEach(r=>{r.hasAttribute("data-highlights-init")||q(r)})}});_t.observe(document.documentElement,{childList:!0,subtree:!0})});var bt={};Et(bt,{currentHash:()=>j,initPageWatch:()=>U,normalisePath:()=>wt,pageKey:()=>y,readWatch:()=>C,removeWatch:()=>yt,writeWatch:()=>k});function pt(){return typeof window<"u"&&window.vbPageWatch?.serverSync===!0?!0:document.querySelector('meta[name="vb-page-watch-server"]')?.getAttribute("content")==="true"}async function Dt(n){if(!pt())return null;try{let t=new w("notify"),e={url:n.url,type:"page-watch",notify:["panel"]},i=await t.post("/subscribe",e);return typeof i?.id=="string"?i.id:null}catch(t){let e=t instanceof g?`${t.status}`:String(t);return console.warn("[page-watch] server subscribe failed; client-only watch in effect.",e),null}}async function mt(n){if(!(!n||!pt()))try{await new w("notify").delete(`/subscribe/${encodeURIComponent(n)}`)}catch(t){let e=t instanceof g?`${t.status}`:String(t);console.warn("[page-watch] server unsubscribe failed; local state already cleared.",e)}}function Pt(){return document.querySelector("main")||document.querySelector("article")||document.body}function wt(n){let t=(n||"/").replace(/\/index\.html?$/i,"/");return t.length>1&&(t=t.replace(/\/+$/,"")),t||"/"}function y(){return wt(location.pathname)}async function Ht(){let n=y(),t=location.pathname||"/",e=n==="/"?"":n,i=new Set([t,`${e}/`,`${e}/index.html`]);if(i.delete(n),await l.get(u,n)){for(let r of i)await l.remove(u,r);return}for(let r of i){let s=await l.get(u,r);if(s){await l.set(u,n,s),await l.remove(u,r);return}}}function j(){let n=Pt();return n?M(n.textContent||""):""}function Ft(){return document.title||y()}async function C(){return dt??=Ht().catch(()=>{}),await dt,await l.get(u,y())}async function k(n){await l.set(u,y(),n)}async function yt(){await l.remove(u,y())}function B(n,t,e){return n.getAttribute(`data-label-${t}`)??e}function I(n,t){n.setAttribute("aria-pressed",t?"true":"false"),n.dataset.watching="",t||delete n.dataset.watching;let e=n.querySelector("icon-wc");if(e&&e.setAttribute("name",t?"bookmark-check":"bookmark"),n.hasAttribute("data-watch-label-locked"))return;let i=[...n.childNodes].find(r=>r.nodeType===Node.TEXT_NODE&&(r.textContent||"").trim());i&&(i.textContent=t?B(n,"watching","Watching"):B(n,"watch","Watch for updates")),n.setAttribute("title",t?B(n,"stop","Stop watching this page"):B(n,"action","Watch this page for content updates"))}async function Vt(){let n=!!await C();for(let t of document.querySelectorAll(`${A}[data-watch-page-init]`))I(t,n)}async function W(n){if(n.hasAttribute("data-watch-page-init"))return;n.setAttribute("data-watch-page-init",""),n.setAttribute("type",n.getAttribute("type")||"button");let t=await C();I(n,!!t),n.addEventListener("click",async e=>{e.preventDefault();let i=await C();if(i)await yt(),I(n,!1),n.dispatchEvent(new CustomEvent("page-watch:remove",{bubbles:!0,composed:!0,detail:{url:i.url,subscriptionId:i.subscriptionId}})),mt(i.subscriptionId);else{let r={url:location.pathname||"/",title:Ft(),contentHash:j(),watchedAt:new Date().toISOString(),lastChecked:new Date().toISOString(),lastChanged:null,subscriptionId:null};await k(r),I(n,!0),n.dispatchEvent(new CustomEvent("page-watch:add",{bubbles:!0,composed:!0,detail:{entry:r}}));let s=await Dt(r);s&&await k({...r,subscriptionId:s})}})}async function qt(){let n=await C();if(!n)return;let t=j(),e=new Date().toISOString(),i=n.contentHash,r={...n,lastChecked:e};if(t&&t!==i){r.contentHash=t,r.lastChanged=e,await k(r);let s={id:`page-watch:${n.url}:${t}`,type:"watch",title:`Updated: ${n.title}`,body:"Content changed since your last visit.",url:n.url,date:e,read:!1,dismissed:!1,priority:"normal"};document.querySelector("notification-wc")&&!customElements.get("notification-wc")&&await customElements.whenDefined("notification-wc"),document.dispatchEvent(new CustomEvent("notification-wc:new",{bubbles:!0,composed:!0,detail:{notification:s}}))}else await k(r)}function U(n=document){for(let t of n.querySelectorAll(A))W(t);qt()}function ut(n){if(Vt(),n.type!=="page-watch:remove")return;if(!(n.target instanceof Element&&n.target.matches(A))){let e=n.detail;mt(e?.subscriptionId??null)}}var A,u,dt,ft,gt,vt=b(()=>{D();tt();ht();A="[data-watch-page]",u="watches";dt=null;ft=Symbol.for("vb.page-watch-init"),gt=globalThis;gt[ft]||(gt[ft]=!0,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>U()):U(),document.addEventListener("page-watch:add",ut),document.addEventListener("page-watch:remove",ut),new MutationObserver(t=>{for(let e of t)for(let i of e.addedNodes){if(i.nodeType!==Node.ELEMENT_NODE)continue;let r=i;r.matches?.(A)&&W(r),r.querySelectorAll?.(A).forEach(s=>W(s))}}).observe(document.documentElement,{childList:!0,subtree:!0}))});var jt=window.matchMedia("(prefers-reduced-motion: reduce)");var K=new Map;function Y(n,t,e={}){let i=e.priority??10,r={impl:t,bundle:e.bundle,contract:e.contract,priority:i},s=K.get(n);if(customElements.get(n)){if(!s||s.priority>=i){s&&s.priority===i&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=i){s.priority===i&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}K.set(n,r),customElements.define(n,t)}var x=class extends HTMLElement{#t=[];#i;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,r){t.addEventListener(e,i,r),this.#t.push(()=>t.removeEventListener(e,i,r))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#i||(this.#i=this.attachInternals());let i=this.#i.states;try{e?i.add(t):i.delete(t)}catch{let r=`--${t}`;e?i.add(r):i.delete(r)}}_adoptInternals(t){this.#i||(this.#i=t)}#n(){return this.constructor.formAssociated&&this.#i?this.#i:null}get validity(){return this.#n()?.validity}get validationMessage(){return this.#n()?.validationMessage??""}get willValidate(){return this.#n()?.willValidate??!1}get form(){return this.#n()?.form??null}checkValidity(){return this.#n()?.checkValidity()??!0}reportValidity(){return this.#n()?.reportValidity()??!0}};var Wt={watch:"Watch for updates",watching:"Watching",action:"Watch this page for updates",stop:"Stop watching this page"},z=class extends x{static observedAttributes=["variant","label","data-label-watch","data-label-watching","data-label-action","data-label-stop"];#t=null;#i=null;setup(){if(this.hasAttribute("server-sync")){let i=window;i.vbPageWatch={...i.vbPageWatch??{},serverSync:!0}}let t=this.#h();this.dataset.variant=t,this.querySelectorAll(":scope > [data-watch-wc]").forEach(i=>i.remove());let e=this.#e(t);this.#t=e,this.appendChild(e),this.#s(),this.#i=new MutationObserver(()=>this.#s()),this.#i.observe(e,{attributes:!0,attributeFilter:["aria-pressed"]}),Promise.resolve().then(()=>(vt(),bt)).catch(()=>{})}teardown(){this.#i?.disconnect(),this.#i=null,this.#t?.remove(),this.#t=null}attributeChangedCallback(t,e,i){e===i||!this.hasAttribute("data-upgraded")||this._reinit()}#n(t){return this.getAttribute(`data-label-${t}`)??Wt[t]}#h(){let t=this.getAttribute("variant");return t==="compact"||t==="button"?t:"icon"}#e(t){let e=document.createElement("button");e.type="button",e.className="ghost",e.setAttribute("data-watch-page",""),e.setAttribute("data-watch-wc",""),e.setAttribute("data-watch-label-locked",""),e.setAttribute("aria-pressed","false");let i=document.createElement("icon-wc");return i.setAttribute("name","bookmark"),i.setAttribute("size",t==="icon"?"sm":"xs"),i.setAttribute("aria-hidden","true"),e.appendChild(i),t==="icon"?e.setAttribute("aria-label",this.#n("action")):e.appendChild(document.createElement("span")),e}#s(){let t=this.#t;if(!t)return;let e=t.getAttribute("aria-pressed")==="true";t.querySelector("icon-wc")?.setAttribute("name",e?"bookmark-check":"bookmark");let i=t.querySelector(":scope > span");i?(i.textContent=this.getAttribute("label")??this.#n(e?"watching":"watch"),t.removeAttribute("title")):t.setAttribute("title",e?this.#n("stop"):this.#n("action"))}};Y("watch-wc",z);export{z as WatchWc};
|
|
3
7
|
//# sourceMappingURL=watch-wc.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var I=class extends HTMLElement{#t=[];#e;connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let e of this.#t)e();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,n,t,r){e.addEventListener(n,t,r),this.#t.push(()=>e.removeEventListener(n,t,r))}setup(){}teardown(){}setState(e,n){this.#e||(this.#e=this.attachInternals());let t=this.#e.states;try{n?t.add(e):t.delete(e)}catch{let r=`--${e}`;n?t.add(r):t.delete(r)}}_adoptInternals(e){this.#e||(this.#e=e)}};var P=window.matchMedia("(prefers-reduced-motion: reduce)");var H=new Map;function B(h,e,n={}){let t=n.priority??10,r={impl:e,bundle:n.bundle,contract:n.contract,priority:t},s=H.get(h);if(customElements.get(h)){if(!s||s.priority>=t){s&&s.priority===t&&s.impl!==e&&console.warn(`[VB Bundle] Tag <${h}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${n.bundle}".`);return}console.warn(`[VB Bundle] Tag <${h}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${n.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=t){s.priority===t&&console.warn(`[VB Bundle] Tag <${h}> already registered by "${s.bundle}". Skipping "${n.bundle}" (first wins at equal priority).`);return}H.set(h,r),customElements.define(h,e)}function O(h){let e=h.getFullYear(),n=String(h.getMonth()+1).padStart(2,"0"),t=String(h.getDate()).padStart(2,"0");return`${e}-${n}-${t}`}var N=class extends I{#t=null;setup(){if(this.#t=this.querySelector("table"),this.#t||this.#e(),!this.#t)return!1;this.#n(),this.listen(this.#t,"click",n=>{let r=n.target?.closest("calendar-event");if(!r)return;let a=r.closest("tr")?.querySelector("th time[datetime]");this.dispatchEvent(new CustomEvent("week-view:event-click",{bubbles:!0,detail:{date:r.dataset.date,time:r.querySelector("time[datetime]")?.getAttribute("datetime")||a?.getAttribute("datetime"),text:r.textContent?.trim()??"",element:r,category:r.dataset.category,duration:r.dataset.duration}}))}),this.#r();let e=this.#t.querySelector("calendar-event");return e&&e.setAttribute("tabindex","0"),!0}teardown(){this.querySelectorAll("calendar-event.wv-spanning").forEach(e=>{e.style.cssText="",e.classList.remove("wv-spanning")})}refresh(){this.teardown(),this.#n()}get events(){return[...this.querySelectorAll("calendar-event")].map(e=>{let n=e;return{date:n.dataset.date||void 0,time:n.querySelector("time[datetime]")?.getAttribute("datetime")||void 0,text:n.textContent?.trim()??"",category:n.dataset.category||void 0,duration:n.dataset.duration||void 0}})}set events(e){let n=Array.isArray(e)?e:[];for(;this.firstChild;)this.firstChild.remove();for(let t of n){let r=document.createElement("calendar-event");if(t.date&&(r.dataset.date=t.date),t.category&&(r.dataset.category=t.category),t.duration&&(r.dataset.duration=String(t.duration)),t.time){let s=document.createElement("time");s.setAttribute("datetime",t.time),s.textContent=t.time,r.appendChild(s),r.appendChild(document.createTextNode(" "))}r.appendChild(document.createTextNode(t.text||"")),this.appendChild(r)}this.teardown(),this.removeAttribute("data-upgraded"),this.setup(),this.dispatchEvent(new CustomEvent("week-view:events-changed",{detail:{events:n,source:"property"},bubbles:!0}))}#e(){let e=[...this.querySelectorAll(":scope > calendar-event")];if(e.length===0)return;let n=this.dataset.startDate;if(!n)return;let t=parseInt(this.dataset.days||"7",10),[r,s,a]=n.split("-").map(Number),u=new Date(r,s-1,a),m=[];for(let l=0;l<t;l++){let i=new Date(u);i.setDate(i.getDate()+l),m.push(i)}let y=m.map(O),f=new Map,g=new Set;e.forEach(l=>{let i=l,p=i.dataset.date;if(!p||!y.includes(p))return;let S=i.querySelector("time[datetime]");if(!S)return;let k=S.getAttribute("datetime");if(!k)return;let T=k.split(":"),A=parseInt(T[0],10),D=parseInt(T[1]||"0",10);if(isNaN(A))return;D>=30&&!i.dataset.start&&(i.dataset.start="30");let q=String(A).padStart(2,"0"),b=`${p}:${q}`;f.has(b)||f.set(b,[]),f.get(b).push(i),g.add(A)});let d=[...g].sort((l,i)=>l-i),o=this.dataset.startHour==="auto"||!this.dataset.startHour,c=o?d.length>0?Math.max(0,d[0]-1):7:parseInt(this.dataset.startHour??"",10),C=o?d.length>0?Math.min(23,d[d.length-1]+1):19:parseInt(this.dataset.endHour||"19",10),v=this.closest("[lang]")?.lang||navigator.language,E=new Intl.DateTimeFormat(v,{weekday:"short",day:"numeric"}),M=new Intl.DateTimeFormat(v,{hour:"numeric"});this.style.setProperty("--wv-days",String(t));let w=document.createElement("table"),$=document.createElement("thead"),x=document.createElement("tr"),F=document.createElement("th");F.setAttribute("aria-label","Time"),x.appendChild(F),m.forEach(l=>{let i=document.createElement("th");i.setAttribute("scope","col");let p=document.createElement("time");p.setAttribute("datetime",O(l)),p.textContent=E.format(l),i.appendChild(p),x.appendChild(i)}),$.appendChild(x),w.appendChild($);let L=document.createElement("tbody");for(let l=c;l<=C;l++){let i=document.createElement("tr"),p=document.createElement("th");p.setAttribute("scope","row");let S=document.createElement("time"),k=String(l).padStart(2,"0");S.setAttribute("datetime",`${k}:00`),S.textContent=M.format(new Date(2026,0,1,l)),p.appendChild(S),i.appendChild(p),y.forEach(T=>{let A=document.createElement("td"),D=`${T}:${k}`,q=f.get(D)||[];if(q.length>0){let b=document.createElement("hour-view");q.length>1&&(b.dataset.overlap=""),q.forEach(R=>b.appendChild(R)),A.appendChild(b)}i.appendChild(A)}),L.appendChild(i)}w.appendChild(L),this.appendChild(w),this.#t=w}#n(){let e=this.#t?.querySelector("tbody");if(!e)return;let n=e.querySelectorAll("calendar-event[data-duration]");n.length!==0&&requestAnimationFrame(()=>{let t=e.getBoundingClientRect(),r=new Map;e.querySelectorAll(":scope > tr").forEach(s=>{let a=s.querySelector("th time[datetime]");if(!a)return;let u=a.getAttribute("datetime");if(!u)return;let m=parseInt(u.split(":")[0],10),y=s.getBoundingClientRect();r.set(m,{top:y.top-t.top,height:y.height})}),n.forEach(s=>{let a=s,u=a.closest("td"),m=u?.closest("tr");if(!u||!m)return;let f=m.querySelector("th time[datetime]")?.getAttribute("datetime");if(!f)return;let g=parseInt(f.split(":")[0],10),d=parseInt(a.dataset.start||"0",10),o=a.dataset.duration??"",c=60,C=o.match(/(\d+)h/),v=o.match(/(\d+)m/);(C||v)&&(c=(C?parseInt(C[1],10)*60:0)+(v?parseInt(v[1],10):0));let E=r.get(g);if(!E)return;let M=u.getBoundingClientRect(),w=d/60,$=E.top+E.height*w,x=E.height*(c/60);a.style.position="absolute",a.style.top=$+"px",a.style.height=x+"px",a.style.left=M.left-t.left+2+"px",a.style.right=t.right-M.right+2+"px",a.classList.add("wv-spanning")})})}#r(){let e=this.#t;e&&this.listen(e,"keydown",n=>{let t=n;if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(t.key))return;let s=t.target?.closest("calendar-event");if(!s)return;let a=s.closest("td"),u=a?.closest("tr");if(!a||!u||!u.parentElement)return;let m=[...u.parentElement.children],y=m.indexOf(u),f=[...u.children],g=f.indexOf(a),d=null;if(t.key==="ArrowDown")for(let o=y+1;o<m.length;o++){let c=m[o].children[g]?.querySelector("calendar-event");if(c){d=c;break}}else if(t.key==="ArrowUp")for(let o=y-1;o>=0;o--){let c=m[o].children[g]?.querySelector("calendar-event");if(c){d=c;break}}else if(t.key==="ArrowRight")for(let o=g+1;o<f.length;o++){let c=f[o]?.querySelector("calendar-event");if(c){d=c;break}}else if(t.key==="ArrowLeft")for(let o=g-1;o>=1;o--){let c=f[o]?.querySelector("calendar-event");if(c){d=c;break}}d&&(t.preventDefault(),d.setAttribute("tabindex","0"),s.setAttribute("tabindex","-1"),d.focus())})}};B("week-view",N);export{N as WeekView};
|
|
1
|
+
var I=class extends HTMLElement{#t=[];#e;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,n,e,s){t.addEventListener(n,e,s),this.#t.push(()=>t.removeEventListener(n,e,s))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,n){this.#e||(this.#e=this.attachInternals());let e=this.#e.states;try{n?e.add(t):e.delete(t)}catch{let s=`--${t}`;n?e.add(s):e.delete(s)}}_adoptInternals(t){this.#e||(this.#e=t)}#n(){return this.constructor.formAssociated&&this.#e?this.#e:null}get validity(){return this.#n()?.validity}get validationMessage(){return this.#n()?.validationMessage??""}get willValidate(){return this.#n()?.willValidate??!1}get form(){return this.#n()?.form??null}checkValidity(){return this.#n()?.checkValidity()??!0}reportValidity(){return this.#n()?.reportValidity()??!0}};var dt=window.matchMedia("(prefers-reduced-motion: reduce)");var Y=new Map;function j(o,t,n={}){let e=n.priority??10,s={impl:t,bundle:n.bundle,contract:n.contract,priority:e},r=Y.get(o);if(customElements.get(o)){if(!r||r.priority>=e){r&&r.priority===e&&r.impl!==t&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${r.bundle}" (priority ${r.priority}). Skipping "${n.bundle}".`);return}console.warn(`[VB Bundle] Tag <${o}> defined by "${r.bundle}" cannot be replaced (customElements.define is permanent). "${n.bundle}" has higher priority but arrived late.`);return}if(r&&r.priority>=e){r.priority===e&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${r.bundle}". Skipping "${n.bundle}" (first wins at equal priority).`);return}Y.set(o,s),customElements.define(o,t)}function z(o,t="en-US"){try{if(o)return Intl.getCanonicalLocales(o),o}catch{}try{return Intl.getCanonicalLocales(t),t}catch{return"en-US"}}function x(o){if(!o)return null;let t=/(?:^|T|\s)(\d{1,2}):(\d{2})/.exec(String(o).trim());if(!t)return null;let n=Math.min(23,Math.max(0,parseInt(t[1],10))),e=Math.min(59,Math.max(0,parseInt(t[2],10)));return{hour:n,minute:e}}var G=60,k="(\\d+(?:\\.\\d+)?)",tt=new RegExp(`^PT(?:${k}H)?(?:${k}M)?(?:${k}S)?$`,"i"),et=new RegExp(`^(?:${k}\\s*h(?:ours?|rs?)?)?\\s*(?:${k}\\s*m(?:in(?:utes?|s)?)?)?$`,"i"),nt=new RegExp(`^${k}$`);function K(o){if(o==null)return null;let t=String(o).trim();if(!t)return null;let n=null,e;return(e=nt.exec(t))?n=parseFloat(e[1]):(e=tt.exec(t))&&(e[1]||e[2]||e[3])?n=(e[1]?parseFloat(e[1])*60:0)+(e[2]?parseFloat(e[2]):0)+(e[3]?parseFloat(e[3])/60:0):(e=et.exec(t))&&(e[1]||e[2])&&(n=(e[1]?parseFloat(e[1])*60:0)+(e[2]?parseFloat(e[2]):0)),n===null||!Number.isFinite(n)?null:(n=Math.round(n),n>0?n:null)}function _(o){let t=[...o].sort((c,l)=>c.start-l.start||l.end-c.end),n=[],e=[],s=[],r=-1/0,d=()=>{for(let c of e)c.columns=s.length;e=[],s=[]};for(let c of t){c.start>=r&&(d(),r=-1/0);let l=s.findIndex(f=>f<=c.start);l===-1?(l=s.length,s.push(c.end)):s[l]=c.end;let b={...c,column:l,columns:1};e.push(b),n.push(b),r=Math.max(r,c.end)}return d(),n}function W(o){let t=o.filter(n=>!n.dataset.duration).map(n=>{let e=n.dataset.start==="30"?30:0;return{start:e,end:e+30}});return _(t).some(n=>n.columns>1)}function J(o){let t=o.cloneNode(!0);return t.querySelectorAll('details, time[datetime^="PT"]').forEach(n=>n.remove()),(t.textContent||"").replace(/\s+/g," ").trim()}var X=["position","top","height","inset-inline-start","inset-inline-end"];var st=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End"],rt=["data-start-date","data-days","data-start-hour","data-end-hour","data-label-time","data-label-continues"],ot=new Set(["US","CA","MX","BR","JP","KR","TW","HK","PH","IL","IN","ZA","SA","PE","CO","VE","GT","HN","NI","PA","PR","DO","AR"]);function P(o){let t=o.getFullYear(),n=String(o.getMonth()+1).padStart(2,"0"),e=String(o.getDate()).padStart(2,"0");return`${t}-${n}-${e}`}function it(o){try{let t=new Intl.Locale(o),n=typeof t.getWeekInfo=="function"?t.getWeekInfo():t.weekInfo;if(n&&Number.isInteger(n.firstDay))return n.firstDay;let e=t.maximize?.().region;return e&&ot.has(e)?7:1}catch{return 1}}function at(o,t){let n=it(o)%7,e=new Date(t.getFullYear(),t.getMonth(),t.getDate());return e.setDate(e.getDate()-(e.getDay()-n+7)%7),e}function ct(o){let t=parseInt(o??"",10);return Number.isNaN(t)?7:Math.min(14,Math.max(1,t))}function Z(o,t){let n=parseInt(o??"",10);return Number.isNaN(n)?t:Math.min(23,Math.max(0,n))}var L=new WeakMap,U=class extends I{static observedAttributes=rt;#t=null;#e=0;#n=null;setup(){if(this.#t=this.querySelector(":scope > table"),this.#t||this.#m(),!this.#t)return!1;let t=this.#t;return this.#h(),this.listen(t,"click",n=>{let e=this.#i(n.target);e&&this.#a(e)}),this.#f(),typeof ResizeObserver<"u"&&(this.#n=new ResizeObserver(()=>this.#c()),this.#n.observe(t)),this.#c(),!0}attributeChangedCallback(t,n,e){n===e||!this.hasAttribute("data-upgraded")||this.#t?.hasAttribute("data-wv-generated")&&(this.#u(),this._reinit())}#u(){let t=this.#t;if(t){this.#r();for(let n of this.#s())this.appendChild(n);t.remove(),this.#t=null}}teardown(){this.#e&&cancelAnimationFrame(this.#e),this.#e=0,this.#n?.disconnect(),this.#n=null,this.#r()}refresh(){this.#e&&cancelAnimationFrame(this.#e),this.#e=0,this.#l()}get events(){return[...this.querySelectorAll("calendar-event")].filter(n=>n.closest("week-view")===this).map(n=>({date:n.dataset.date||void 0,time:n.querySelector("time[datetime]")?.getAttribute("datetime")||void 0,text:n.textContent?.trim()??"",category:n.dataset.category||void 0,duration:n.dataset.duration||void 0}))}set events(t){let n=Array.isArray(t)?t:[];for(;this.firstChild;)this.firstChild.remove();let e=new Intl.DateTimeFormat(this.#o(),{hour:"numeric",minute:"2-digit"});for(let s of n){let r=document.createElement("calendar-event"),d=s.date||/^\d{4}-\d{2}-\d{2}(?=T)/.exec(s.time||"")?.[0];if(d&&(r.dataset.date=d),s.category&&(r.dataset.category=s.category),s.duration&&(r.dataset.duration=String(s.duration)),s.time){let c=document.createElement("time");c.setAttribute("datetime",s.time);let l=x(s.time);c.textContent=l?e.format(new Date(2026,0,1,l.hour,l.minute)):s.time,r.appendChild(c),r.appendChild(document.createTextNode(" "))}r.appendChild(document.createTextNode(s.text||"")),this.appendChild(r)}this._reinit(),this.dispatchEvent(new CustomEvent("week-view:events-changed",{detail:{events:n,source:"property"},bubbles:!0}))}#o(){return z(this.closest("[lang]")?.lang||navigator.language)}#s(){return[...(this.#t??this).querySelectorAll("calendar-event")].filter(n=>n.closest("week-view")===this)}#i(t){let e=(t instanceof Element?t:null)?.closest("calendar-event")??null;return e&&e.closest("week-view")===this?e:null}#a(t){let e=t.closest("tr")?.querySelector("th time[datetime]");this.dispatchEvent(new CustomEvent("week-view:event-click",{bubbles:!0,detail:{date:t.dataset.date,time:t.querySelector("time[datetime]")?.getAttribute("datetime")||e?.getAttribute("datetime"),text:t.textContent?.trim()??"",element:t,category:t.dataset.category,duration:t.dataset.duration}}))}#h(){let t=this.#s(),n=t.find(s=>s.getAttribute("tabindex")==="0");for(let s of t){if(s.hasAttribute("role")||s.setAttribute("role","group"),!s.hasAttribute("aria-label")||L.has(s)){let r=J(s);L.set(s,r),s.setAttribute("aria-label",r)}s.setAttribute("tabindex","-1")}let e=n??this.#d()[0]?.el;e&&e.setAttribute("tabindex","0")}#m(){let t=[...this.querySelectorAll(":scope > calendar-event")],n=this.#o(),e=new Date,s=ct(this.dataset.days),r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(this.dataset.startDate||""),d=r?new Date(Number(r[1]),Number(r[2])-1,Number(r[3])):at(n,e),c=P(e),l=[];for(let u=0;u<s;u++){let h=new Date(d);h.setDate(h.getDate()+u),l.push(h)}let b=l.map(P),f=new Map,C=new Set;for(let u of t){let h=u.dataset.date;if(!h||!b.includes(h))continue;let E=x(u.querySelector("time[datetime]")?.getAttribute("datetime"));if(!E)continue;E.minute>=30&&!u.dataset.start&&(u.dataset.start="30");let v=`${h}:${String(E.hour).padStart(2,"0")}`,S=f.get(v)??[];S.push(u),f.set(v,S),C.add(E.hour)}let a=[...C].sort((u,h)=>u-h),i=a[0],y=a[a.length-1],p=this.dataset.startHour==="auto"||!this.dataset.startHour,g,w;p?(g=a.length>0?Math.max(0,i-1):7,w=a.length>0?Math.min(23,y+1):19):(g=Z(this.dataset.startHour,7),w=Math.max(g,Z(this.dataset.endHour,19)),a.length>0&&(g=Math.min(g,i),w=Math.max(w,y)));let A=l[0].getMonth()!==l[l.length-1].getMonth(),N=new Intl.DateTimeFormat(n,A?{weekday:"short",day:"numeric",month:"short"}:{weekday:"short",day:"numeric"}),M=new Intl.DateTimeFormat(n,{dateStyle:"full"}),D=new Intl.DateTimeFormat(n,{hour:"numeric"});this.style.setProperty("--wv-days",String(s));let m=document.createElement("table");m.setAttribute("data-wv-generated","");let T=document.createElement("thead"),R=document.createElement("tr"),F=document.createElement("th");F.setAttribute("scope","col");let q=document.createElement("span");q.className="visually-hidden",q.textContent=this.dataset.labelTime||"Time",F.appendChild(q),R.appendChild(F),l.forEach(u=>{let h=document.createElement("th");h.setAttribute("scope","col");let E=P(u);E===c&&h.setAttribute("aria-current","date");let v=document.createElement("time");v.setAttribute("datetime",E);let S=document.createElement("span");S.setAttribute("aria-hidden","true"),S.textContent=N.format(u);let $=document.createElement("span");$.className="visually-hidden",$.textContent=M.format(u),v.append(S,$),h.appendChild(v),R.appendChild(h)}),T.appendChild(R),m.appendChild(T);let B=document.createElement("tbody");for(let u=g;u<=w;u++){let h=document.createElement("tr"),E=document.createElement("th");E.setAttribute("scope","row");let v=document.createElement("time"),S=String(u).padStart(2,"0");v.setAttribute("datetime",`${S}:00`),v.textContent=D.format(new Date(2026,0,1,u)),E.appendChild(v),h.appendChild(E),b.forEach($=>{let V=document.createElement("td"),H=f.get(`${$}:${S}`)||[];if(H.length>0){let O=document.createElement("hour-view");W(H)&&(O.dataset.overlap=""),H.forEach(Q=>O.appendChild(Q)),V.appendChild(O)}h.appendChild(V)}),B.appendChild(h)}m.appendChild(B),this.appendChild(m),this.#t=m}#c(){this.#e||(this.#e=requestAnimationFrame(()=>{this.#e=0,this.#l()}))}#r(){this.querySelectorAll("calendar-event.wv-spanning").forEach(t=>{let n=t;for(let s of X)n.style.removeProperty(s);n.classList.remove("wv-spanning"),n.removeAttribute("data-continues");let e=L.get(n);e!==void 0&&n.setAttribute("aria-label",e)})}#l(){this.#r();let t=this.#t?.querySelector("tbody");if(!t||!t.isConnected)return;let n=[...t.querySelectorAll("calendar-event[data-duration]")];if(n.length===0)return;let e=t.getBoundingClientRect(),s=getComputedStyle(t).direction==="rtl",r=new Map,d=-1,c=0;if(t.querySelectorAll(":scope > tr").forEach(a=>{let i=x(a.querySelector("th time[datetime]")?.getAttribute("datetime"));if(!i)return;let y=a.getBoundingClientRect(),p=y.top-e.top;r.set(i.hour,{top:p,height:y.height}),i.hour>d&&(d=i.hour,c=p+y.height)}),r.size===0)return;let l=(d+1)*60,b=a=>{let i=r.get(Math.floor(a/60));return i?i.top+i.height*(a%60/60):null},f=new Map;for(let a of n){let i=a.closest("td"),y=i?.closest("tr");if(!i||!y)continue;let p=x(y.querySelector("th time[datetime]")?.getAttribute("datetime"));if(!p||!r.has(p.hour))continue;let g=x(a.querySelector("time[datetime]")?.getAttribute("datetime")),w=a.dataset.start?parseInt(a.dataset.start,10)||0:g&&g.hour===p.hour?g.minute:0,A=p.hour*60+Math.min(59,Math.max(0,w)),N=K(a.dataset.duration)??G,M=f.get(i.cellIndex)??[];M.push({event:a,td:i,start:A,end:A+N}),f.set(i.cellIndex,M)}let C=this.dataset.labelContinues||"continues after the visible hours";for(let a of f.values())for(let i of _(a)){let y=r.get(Math.floor(i.start/60)),p=b(i.start),g=i.end>l,w=g||i.end===l?c:b(i.end);w===null&&(w=p+y.height*((i.end-i.start)/60));let A=i.td.getBoundingClientRect(),N=(s?e.right-A.right:A.left-e.left)+2,M=(s?A.left-e.left:e.right-A.right)+2,D=Math.max(0,A.width-4)/i.columns,{event:m}=i;if(m.style.position="absolute",m.style.top=`${p}px`,m.style.height=`${Math.max(w-p,1)}px`,m.style.insetInlineStart=`${N+i.column*D}px`,m.style.insetInlineEnd=`${M+(i.columns-1-i.column)*D}px`,m.classList.add("wv-spanning"),g){m.setAttribute("data-continues","");let T=L.get(m);T!==void 0&&m.setAttribute("aria-label",`${T}, ${C}`)}}}#d(){return this.#s().map((t,n)=>{let e=t.closest("td"),s=x(e?.closest("tr")?.querySelector("th time[datetime]")?.getAttribute("datetime")),r=x(t.querySelector("time[datetime]")?.getAttribute("datetime")),d=r?r.hour*60+r.minute:(s?s.hour*60:0)+(parseInt(t.dataset.start||"0",10)||0);return{el:t,col:e?.cellIndex??0,min:d,i:n}}).sort((t,n)=>t.col-n.col||t.min-n.min||t.i-n.i).map(({el:t,col:n,min:e})=>({el:t,col:n,min:e}))}#f(){let t=this.#t;t&&this.listen(t,"keydown",n=>{let e=n,s=this.#i(e.target);if(!s)return;if((e.key==="Enter"||e.key===" ")&&e.target===s){e.preventDefault(),this.#a(s);return}if(!st.includes(e.key))return;let r=null,d=this.#d(),c=d.find(l=>l.el===s);if(c){if(e.key==="Home"||e.key==="End")r=(e.key==="Home"?d[0]:d[d.length-1])?.el;else if(e.key==="ArrowDown"||e.key==="ArrowUp"){let l=d.filter(f=>f.col===c.col),b=l.indexOf(c)+(e.key==="ArrowDown"?1:-1);r=l[b]?.el}else{let l=getComputedStyle(t).direction==="rtl",b=e.key==="ArrowRight"!==l,f=[...new Set(d.map(a=>a.col))],C=b?f.find(a=>a>c.col):f.filter(a=>a<c.col).pop();if(C!==void 0){let a=null;for(let i of d)i.col===C&&(!a||Math.abs(i.min-c.min)<Math.abs(a.min-c.min))&&(a=i);r=a?.el}}r&&r!==s&&(e.preventDefault(),s.setAttribute("tabindex","-1"),r.setAttribute("tabindex","0"),r.focus())}})}};j("week-view",U);export{U as WeekView};
|
|
2
2
|
//# sourceMappingURL=week-view.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var o=class extends HTMLElement{#e=[];#t;connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#e)t();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,
|
|
1
|
+
var o=class extends HTMLElement{#e=[];#t;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#e)t();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,r,s){t.addEventListener(e,r,s),this.#e.push(()=>t.removeEventListener(e,r,s))}_reinit(){for(let t of this.#e)t();this.#e=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#t||(this.#t=this.attachInternals());let r=this.#t.states;try{e?r.add(t):r.delete(t)}catch{let s=`--${t}`;e?r.add(s):r.delete(s)}}_adoptInternals(t){this.#t||(this.#t=t)}#r(){return this.constructor.formAssociated&&this.#t?this.#t:null}get validity(){return this.#r()?.validity}get validationMessage(){return this.#r()?.validationMessage??""}get willValidate(){return this.#r()?.willValidate??!1}get form(){return this.#r()?.form??null}checkValidity(){return this.#r()?.checkValidity()??!0}reportValidity(){return this.#r()?.reportValidity()??!0}};var E=window.matchMedia("(prefers-reduced-motion: reduce)");var c=new Map;function d(n,t,e={}){let r=e.priority??10,s={impl:t,bundle:e.bundle,contract:e.contract,priority:r},i=c.get(n);if(customElements.get(n)){if(!i||i.priority>=r){i&&i.priority===r&&i.impl!==t&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${i.bundle}" (priority ${i.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> defined by "${i.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(i&&i.priority>=r){i.priority===r&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${i.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}c.set(n,s),customElements.define(n,t)}var p='<svg viewBox="0 0 68 48" width="68" height="48" aria-hidden="true" focusable="false"><path d="M66.52 7.74c-.78-2.93-2.49-5.41-5.42-6.19C55.79.13 34 0 34 0S12.21.13 6.9 1.55c-2.93.78-4.64 3.26-5.42 6.19C.06 13.05 0 24 0 24s.06 10.95 1.48 16.26c.78 2.93 2.49 5.41 5.42 6.19C12.21 47.87 34 48 34 48s21.79-.13 27.1-1.55c2.93-.78 4.64-3.26 5.42-6.19C67.94 34.95 68 24 68 24s-.06-10.95-1.48-16.26z" fill="var(--color-error, #f00)"/><path d="M45 24 27 14v20z" fill="#fff"/></svg>',m={hq:"hqdefault",mq:"mqdefault",sd:"sddefault",maxres:"maxresdefault"},l="YouTube video",b="Play {title}",y=/^\d+$/;function u(n){return String(n).replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t])}function g(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches||document.documentElement.hasAttribute("data-motion-reduced")}var a=class extends o{#e="";#t=l;setup(){let t=this.getAttribute("video-id");return this.#t=this.getAttribute("title")||l,t?/^[A-Za-z0-9_-]{6,20}$/.test(t)?(this.#e=t,this.hasAttribute("autoplay")&&!g()?this.#s(!1):this.#a(),!0):(console.warn(`youtube-player: invalid video-id ${JSON.stringify(t)}`),!1):(console.warn("youtube-player: missing required video-id attribute"),!1)}#r(t){let e=this.getAttribute(t);return e===null||e===""?null:y.test(e.trim())?e.trim():(console.warn(`youtube-player: ${t} must be whole seconds, got ${JSON.stringify(e)}`),null)}#n(){let t=new URLSearchParams({autoplay:"1"}),e=this.#r("start");e&&t.set("start",e);let r=this.#r("end");r&&t.set("end",r);let s=this.getAttribute("list");s&&t.set("list",s);let i=this.getAttribute("params");return i&&new URLSearchParams(i).forEach((h,f)=>t.set(f,h)),`https://www.youtube-nocookie.com/embed/${this.#e}?${t}`}#i(t){return`https://i.ytimg.com/vi/${this.#e}/${m[t]??"hqdefault"}.jpg`}#o(){return(this.getAttribute("data-label-play")||b).replace(/\{title\}/g,this.#t)}#a(){this.setAttribute("state","ready");let t=document.createElement("img");t.alt="",t.loading="lazy",t.decoding="async";let e=this.getAttribute("poster");if(e)t.src=e;else{let s=this.getAttribute("thumbnail")??"hq";if(t.referrerPolicy="no-referrer",t.src=this.#i(s),s==="sd"||s==="maxres"){let i=()=>{t.src=this.#i("hq")};t.addEventListener("error",i,{once:!0}),t.addEventListener("load",()=>{t.naturalWidth<=120&&i()},{once:!0})}}let r=document.createElement("button");r.type="button",r.setAttribute("aria-label",this.#o()),r.innerHTML=p,r.addEventListener("click",()=>this.#s(!0),{once:!0}),this.replaceChildren(t,r)}#s(t){this.setAttribute("state","active"),this.innerHTML=`<iframe src="${u(this.#n())}" title="${u(this.#t)}" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen loading="lazy"></iframe>`,t&&this.querySelector("iframe")?.focus(),this.dispatchEvent(new CustomEvent("youtube-player:activate",{bubbles:!0,detail:{videoId:this.#e,fromUser:t}}))}};d("youtube-player",a);export{a as YouTubePlayer};
|
|
2
2
|
//# sourceMappingURL=youtube-player.js.map
|