vanilla-breeze 0.4.0 → 0.5.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 +13966 -11505
- 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 +49 -49
- package/dist/cdn/components/comment-thread.js +32 -32
- 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 +4 -4
- 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 +2 -2
- 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 +100 -100
- package/dist/cdn/components/markdown-editor.js +1 -1
- package/dist/cdn/components/markdown-viewer.js +11 -11
- package/dist/cdn/components/nav-bar.js +1 -1
- package/dist/cdn/components/note-wc.js +2 -2
- package/dist/cdn/components/notification-wc.js +4 -4
- package/dist/cdn/components/page-info.js +2 -2
- 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 +5 -5
- 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 +4 -4
- 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 +3 -3
- package/dist/cdn/components/reading-progress.js +1 -1
- package/dist/cdn/components/recently-visited.js +7 -7
- package/dist/cdn/components/score-card.js +2 -2
- package/dist/cdn/components/selection-menu.js +1 -1
- package/dist/cdn/components/settings-panel.js +4 -4
- 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 +6 -6
- package/dist/cdn/components/site-map.js +1 -1
- package/dist/cdn/components/site-search.js +3 -3
- 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 +44 -44
- package/dist/cdn/components/time-index.js +2 -2
- package/dist/cdn/components/time-picker.js +1 -1
- package/dist/cdn/components/toast-msg.js +1 -1
- package/dist/cdn/components/tool-tip.js +1 -1
- package/dist/cdn/components/topic-map.js +3 -3
- package/dist/cdn/components/trust-filter.js +3 -3
- package/dist/cdn/components/version-switcher.js +3 -13
- package/dist/cdn/components/video-player.js +1 -1
- package/dist/cdn/components/watch-wc.js +2 -2
- package/dist/cdn/components/week-view.js +1 -1
- package/dist/cdn/components/youtube-player.js +1 -1
- package/dist/cdn/packs/effects.full.js +1 -1
- package/dist/cdn/packs/kawaii.effects.css +1 -1
- package/dist/cdn/packs/kawaii.full.css +1 -1
- package/dist/cdn/packs/kawaii.full.js +4 -4
- package/dist/cdn/packs/manifest.json +7 -7
- package/dist/cdn/packs/memphis.full.css +1 -1
- package/dist/cdn/packs/memphis.theme.css +1 -1
- package/dist/cdn/packs/ui.full.js +46 -46
- 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.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.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-latte-dark.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-latte.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-macchiato.tokens.json +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.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 +23 -1
- package/dist/cdn/themes/clinical-dark.tokens.json +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.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.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.tokens.json +1 -1
- package/dist/cdn/themes/government-dark.tokens.json +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.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 +33 -1
- package/dist/cdn/themes/journal.css +1 -1
- package/dist/cdn/themes/journal.tokens.json +23 -1
- 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.tokens.json +1 -1
- package/dist/cdn/themes/manifest.json +26 -50
- package/dist/cdn/themes/midnight.tokens.json +1 -1
- package/dist/cdn/themes/minimal-dark.tokens.json +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.tokens.json +1 -1
- package/dist/cdn/themes/nes-dark.tokens.json +1 -1
- 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.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.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 +15 -4
- package/dist/cdn/themes/win9x.css +1 -1
- package/dist/cdn/themes/win9x.tokens.json +1 -1
- package/dist/cdn/vanilla-breeze-autoload.js +663 -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 +78 -80
- package/dist/cdn/vanilla-breeze-dev.css +1 -1
- package/dist/cdn/vanilla-breeze-extras.js +47 -37
- package/dist/cdn/vanilla-breeze.css +1 -1
- package/dist/cdn/vanilla-breeze.js +180 -177
- package/package.json +12 -7
- 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,2 +1,2 @@
|
|
|
1
|
-
var r=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 t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,
|
|
1
|
+
var r=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 t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,s,o){t.addEventListener(e,s,o),this.#t.push(()=>t.removeEventListener(e,s,o))}_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 s=this.#e.states;try{e?s.add(t):s.delete(t)}catch{let o=`--${t}`;e?s.add(o):s.delete(o)}}_adoptInternals(t){this.#e||(this.#e=t)}};var w=window.matchMedia("(prefers-reduced-motion: reduce)");var p=new Map;function a(n,t,e={}){let s=e.priority??10,o={impl:t,bundle:e.bundle,contract:e.contract,priority:s},i=p.get(n);if(customElements.get(n)){if(!i||i.priority>=s){i&&i.priority===s&&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>=s){i.priority===s&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${i.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}p.set(n,o),customElements.define(n,t)}var c=CSS.supports("anchor-name","--x"),b=CSS.supports("position-area","bottom"),v=0,d=class extends r{#t=null;#e=null;#s=null;#i=null;setup(){this.id||(this.id=`pop-over-${++v}`);let t=this.dataset.mode||"auto";this.hasAttribute("popover")||this.setAttribute("popover",t),this.#n(),this.#o(),this.#s=e=>{let s=e.newState==="open"?"show":"hide";this.dispatchEvent(new CustomEvent(`pop-over:${s}`,{detail:{state:e.newState},bubbles:!0,composed:!0})),!c&&e.newState==="open"&&this.#t&&this.#a()},this.listen(this,"beforetoggle",this.#s),c||(this.#i=()=>{this.matches(":popover-open")&&this.#t&&this.#a()},this.listen(window,"resize",this.#i),this.listen(window,"scroll",this.#i,{capture:!0,passive:!0}))}show(){this.matches(":popover-open")||this.showPopover()}hide(){this.matches(":popover-open")&&this.hidePopover()}toggle(){this.matches(":popover-open")?this.hide():this.show()}get open(){return this.matches(":popover-open")}#n(){let t=this.dataset.anchor;t?this.#t=document.getElementById(t)||document.querySelector(t):this.#t=document.querySelector(`[popovertarget="${CSS.escape(this.id)}"]`)}#o(){if(!(!this.#t||!c)&&(this.#e=`--pop-over-anchor-${this.id}`,this.#t.style.setProperty("anchor-name",this.#e),this.style.setProperty("position-anchor",this.#e),this.setAttribute("data-anchor-name",this.#e||""),!b)){let t=this.dataset.position||"bottom";this.#r(t)}}#r(t){let e="var(--_pop-over-offset, var(--size-xs))",s={top:{bottom:`calc(anchor(top) + ${e})`,left:"anchor(left)"},bottom:{top:`calc(anchor(bottom) + ${e})`,left:"anchor(left)"},left:{right:`calc(anchor(left) + ${e})`,top:"anchor(top)"},right:{left:`calc(anchor(right) + ${e})`,top:"anchor(top)"}},o=t.split("-")[0],i=s[o]||s.bottom;Object.entries(i).forEach(([h,m])=>this.style.setProperty(h,m))}#a(){if(!this.#t)return;let t=this.#t.getBoundingClientRect(),e=this.dataset.position||"bottom",s=this.#l(),o,i;switch(e.split("-")[0]){case"top":o=t.top-this.offsetHeight-s,i=t.left;break;case"left":o=t.top,i=t.left-this.offsetWidth-s;break;case"right":o=t.top,i=t.right+s;break;default:o=t.bottom+s,i=t.left;break}e.endsWith("-end")&&(e.startsWith("top")||e.startsWith("bottom")?i=t.right-this.offsetWidth:o=t.bottom-this.offsetHeight),this.style.position="fixed",this.style.top=`${Math.round(o)}px`,this.style.left=`${Math.round(i)}px`,this.style.margin="0"}#l(){let t={none:0,xs:4,s:8,m:16,l:24};return t[this.dataset.offset]??t.xs}};a("pop-over",d);var y=new Set(["BUTTON","A","AREA"]);function f(n){return document.documentElement.hasAttribute("data-interest-polyfill")?!0:"interestForElement"in HTMLButtonElement.prototype?y.has(n.tagName):!1}var l=0,u=class extends r{#t=null;#e=null;#s;#i;#n=!1;#o=!1;#r;setup(){this.#n=this.getAttribute("variant")==="card",this.#n?this.#l():this.#a()}#a(){if(this.#t=this.querySelector(":scope > :not(template)"),!this.#t)return;this.#o=f(this.#t);let t=this.querySelector(":scope > template[data-tooltip]"),e=this.getAttribute("content"),s=this.#t.getAttribute("title");if(!t&&!e&&!s)return;s&&(this.#r=s,this.#t.removeAttribute("title"));let o=this.getAttribute("position")||"top";this.#t.id||(this.#t.id=`tooltip-trigger-${++l}`);let i=document.createElement("pop-over");i.className="tooltip",i.setAttribute("role","tooltip"),i.dataset.mode="hint",i.dataset.anchor=this.#t.id,i.dataset.tooltipPosition=o,i.id=`tooltip-${++l}`,t?i.innerHTML=t.innerHTML:i.textContent=e||s;let h=document.createElement("span");h.className="tooltip-arrow",h.setAttribute("aria-hidden","true"),i.appendChild(h),this.appendChild(i),this.#e=i,this.#o?(this.#t.setAttribute("interestfor",i.id),this.#t.hasAttribute("aria-describedby")||this.#t.setAttribute("aria-describedby",i.id)):(this.#t.setAttribute("aria-describedby",i.id),this.listen(this.#t,"mouseenter",this.#c),this.listen(this.#t,"mouseleave",this.#h),this.listen(this.#t,"focus",this.#d),this.listen(this.#t,"blur",this.#p),this.listen(i,"mouseenter",this.#u),this.listen(i,"mouseleave",this.#h)),this.listen(i,"pop-over:show",()=>{this.dispatchEvent(new CustomEvent("tool-tip:show",{bubbles:!0}))}),this.listen(i,"pop-over:hide",()=>{this.dispatchEvent(new CustomEvent("tool-tip:hide",{bubbles:!0}))})}#l(){this.#t=this.querySelector(":scope > [data-trigger]");let t=this.querySelector(":scope > [data-content]");if(!this.#t||!t)return;this.#o=f(this.#t),this.#t.id||(this.#t.id=`tooltip-trigger-${++l}`);let e=document.createElement("pop-over");e.className="hover-card",e.dataset.mode="manual",e.dataset.anchor=this.#t.id,e.dataset.position=this.getAttribute("position")||"bottom",e.id=`hc-${++l}`,e.appendChild(t),t.removeAttribute("data-content"),t.hidden=!1,this.appendChild(e),this.#e=e,this.#o?this.#t.setAttribute("interestfor",e.id):(this.listen(this.#t,"mouseenter",this.#c),this.listen(this.#t,"mouseleave",this.#h),this.listen(this.#t,"focus",this.#d),this.listen(this.#t,"blur",this.#h),this.listen(e,"mouseenter",this.#u),this.listen(e,"mouseleave",this.#h),this.listen(document,"keydown",this.#f)),this.listen(e,"pop-over:show",()=>{this.dispatchEvent(new CustomEvent("tool-tip:show",{bubbles:!0}))}),this.listen(e,"pop-over:hide",()=>{this.dispatchEvent(new CustomEvent("tool-tip:hide",{bubbles:!0}))})}teardown(){this.#t&&(this.#o&&this.#t.removeAttribute("interestfor"),this.#r&&(this.#t.setAttribute("title",this.#r),this.#r=void 0)),this.#e&&(this.#e.remove(),this.#e=null),clearTimeout(this.#s),clearTimeout(this.#i)}#c=()=>{clearTimeout(this.#i);let t=this.#n?300:200,e=parseInt(this.getAttribute("delay")||String(t),10);this.setState("show-pending",!0),this.#s=setTimeout(()=>{this.setState("show-pending",!1),this.show()},e)};#h=()=>{clearTimeout(this.#s),this.setState("show-pending",!1);let t=this.#n?200:100;this.#i=setTimeout(()=>this.hide(),t)};#d=()=>{clearTimeout(this.#i),this.show()};#p=()=>{clearTimeout(this.#s),this.setState("show-pending",!1),this.hide()};#u=()=>{clearTimeout(this.#i)};#f=t=>{t.key==="Escape"&&this.isVisible&&this.hide()};show(){!this.#e||this.isVisible||(typeof this.#e.show=="function"?this.#e.show():this.#e.showPopover())}hide(){!this.#e||!this.isVisible||(typeof this.#e.hide=="function"?this.#e.hide():this.#e.hidePopover())}get isVisible(){return this.#e?.matches(":popover-open")??!1}};a("tool-tip",u);export{u as ToolTip};
|
|
2
2
|
//# sourceMappingURL=tool-tip.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _=window.matchMedia("(prefers-reduced-motion: reduce)");var L=new Map;function v(a,t,s={}){let
|
|
2
|
-
`)}#
|
|
3
|
-
`)}#n(t){if(this.children.length>0)return;let s=document.createElement("p");s.setAttribute("data-topic-map-error",""),s.textContent=t,this.append(s)}#s(){}};function T(a){return a==null?[]:Array.isArray(a)?a:[a]}function
|
|
1
|
+
var _=window.matchMedia("(prefers-reduced-motion: reduce)");var L=new Map;function v(a,t,s={}){let r=s.priority??10,i={impl:t,bundle:s.bundle,contract:s.contract,priority:r},o=L.get(a);if(customElements.get(a)){if(!o||o.priority>=r){o&&o.priority===r&&o.impl!==t&&console.warn(`[VB Bundle] Tag <${a}> already registered by "${o.bundle}" (priority ${o.priority}). Skipping "${s.bundle}".`);return}console.warn(`[VB Bundle] Tag <${a}> defined by "${o.bundle}" cannot be replaced (customElements.define is permanent). "${s.bundle}" has higher priority but arrived late.`);return}if(o&&o.priority>=r){o.priority===r&&console.warn(`[VB Bundle] Tag <${a}> already registered by "${o.bundle}". Skipping "${s.bundle}" (first wins at equal priority).`);return}L.set(a,i),customElements.define(a,t)}var k=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,s,r,i){t.addEventListener(s,r,i),this.#e.push(()=>t.removeEventListener(s,r,i))}_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,s){this.#t||(this.#t=this.attachInternals());let r=this.#t.states;try{s?r.add(t):r.delete(t)}catch{let i=`--${t}`;s?r.add(i):r.delete(i)}}_adoptInternals(t){this.#t||(this.#t=t)}};var S=class extends k{setup(){let t=this.getAttribute("data-lens-src")||this.getAttribute("src"),s=this.getAttribute("data-vocabulary-src")||"/vocabulary.json";t?this.#e(t,s).catch(()=>{}):this.#s()}get data(){return this.__data||null}set data(t){if(!t||typeof t!="object")return;let s=Array.isArray(t.pages)?t.pages:[],r=t.vocabulary||{};this.__data={pages:s,vocabulary:r},this.#r(s,r),this.#s(),this.dispatchEvent(new CustomEvent("topic-map:data-changed",{detail:{pages:s,vocabulary:r,source:"property"},bubbles:!0}))}async#e(t,s){let[r,i]=await Promise.all([this.#t(t),this.#t(s)]);if(r.error){this.#n(`Could not load ${t}: ${r.error}`);return}if(i.error){this.#n(`Could not load ${s}: ${i.error}`);return}let o=Array.isArray(r.data)?r.data:r.data.pages||[],u=i.data;this.#r(o,u),this.#s()}async#t(t){try{let s=await fetch(t);if(!s.ok)throw new Error(`status ${s.status}`);return{data:await s.json()}}catch(s){return{error:s.message}}}#r(t,s){let r=Array.isArray(s?.concepts)?s.concepts:[],i=Array.isArray(s?.["skos:hasTopConcept"])?s["skos:hasTopConcept"]:[],o=new Map;for(let e of r)e&&e["@id"]&&o.set(e["@id"],e);let u=new Map,p=new Map;function $(e,n){!e||!n||!o.has(e)||!o.has(n)||(u.has(e)||u.set(e,new Set),u.get(e).add(n),p.has(n)||p.set(n,new Set),p.get(n).add(e))}for(let e of r){let n=e["@id"],y=T(e["skos:broader"]);for(let w of y)$(w,n);let d=T(e["skos:narrower"]);for(let w of d)$(n,w)}let h=new Map,m=[];for(let e of t){let n=Array.isArray(e.concepts)?e.concepts:[];if(n.length===0){m.push(e);continue}let y=!1;for(let d of n)o.has(d)&&(h.has(d)||h.set(d,[]),h.get(d).push(e),y=!0);y||m.push(e)}let b=new Map,g=new Set;function A(e){if(b.has(e))return b.get(e);if(g.has(e))return 0;g.add(e);let n=(h.get(e)||[]).length,y=0,d=u.get(e);if(d)for(let x of d)y+=A(x);g.delete(e);let w=n+y;return b.set(e,w),w}let c=i.filter(e=>o.has(e));c.length===0&&(c=r.map(e=>e["@id"]).filter(e=>e&&!p.has(e)));let f=this.hasAttribute("expand-all"),l=[`<h2 class="topic-map-heading">Topics <small>(${t.length} pages)</small></h2>`];for(let e of c)l.push(this.#o(e,o,u,h,A,f,0));if(m.length){let e=f?" open":"";l.push(`<details${e} data-topic-node="__uncategorized">`),l.push(`<summary><span class="topic-name">Uncategorized</span> <span class="topic-count">${m.length}</span></summary>`),l.push('<ul class="topic-pages">');for(let n of m)l.push(`<li><a href="${C(n.url)}">${M(n.title||n.url)}</a></li>`);l.push("</ul>"),l.push("</details>")}this.innerHTML=l.join(`
|
|
2
|
+
`)}#o(t,s,r,i,o,u,p){let $=s.get(t);if(!$)return"";let h=$["skos:prefLabel"]||t,m=o(t),b=i.get(t)||[],g=r.get(t),A=u||p<1?" open":"",c=[];if(c.push(`<details${A} data-topic-node="${C(t)}">`),c.push(`<summary><a class="topic-name" href="/topics/${C(t)}/">${M(h)}</a> <span class="topic-count">${m}</span></summary>`),b.length){c.push('<ul class="topic-pages">');for(let f of b)c.push(`<li><a href="${C(f.url)}">${M(f.title||f.url)}</a></li>`);c.push("</ul>")}if(g&&g.size){let f=[...g].sort((E,l)=>{let e=(s.get(E)?.["skos:prefLabel"]||E).toLowerCase(),n=(s.get(l)?.["skos:prefLabel"]||l).toLowerCase();return e.localeCompare(n)});for(let E of f)c.push(this.#o(E,s,r,i,o,u,p+1))}return c.push("</details>"),c.join(`
|
|
3
|
+
`)}#n(t){if(this.children.length>0)return;let s=document.createElement("p");s.setAttribute("data-topic-map-error",""),s.textContent=t,this.append(s)}#s(){}};function T(a){return a==null?[]:Array.isArray(a)?a:[a]}function M(a){return String(a??"").replace(/[&<>]/g,t=>({"&":"&","<":"<",">":">"})[t])}function C(a){return String(a??"").replace(/[&<>"]/g,t=>({"&":"&","<":"<",">":">",'"':"""})[t])}v("topic-map",S);export{S as TopicMap};
|
|
4
4
|
//# sourceMappingURL=topic-map.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var g=window.matchMedia("(prefers-reduced-motion: reduce)");var h=new Map;function p(i,
|
|
2
|
-
`);let n=this.querySelector("form");n.addEventListener("change",r=>{let
|
|
3
|
-
`);let r={};for(let[
|
|
1
|
+
var g=window.matchMedia("(prefers-reduced-motion: reduce)");var h=new Map;function p(i,t,e={}){let n=e.priority??10,r={impl:t,bundle:e.bundle,contract:e.contract,priority:n},s=h.get(i);if(customElements.get(i)){if(!s||s.priority>=n){s&&s.priority===n&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${i}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=n){s.priority===n&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}h.set(i,r),customElements.define(i,t)}var l=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 t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,n,r){t.addEventListener(e,n,r),this.#t.push(()=>t.removeEventListener(e,n,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.#e||(this.#e=this.attachInternals());let n=this.#e.states;try{e?n.add(t):n.delete(t)}catch{let r=`--${t}`;e?n.add(r):n.delete(r)}}_adoptInternals(t){this.#e||(this.#e=t)}};var d=class extends l{#t=[];#e={provenance:new Set,review:new Set,status:new Set,signed:new Set};setup(){let t=this.getAttribute("data-lens-src")||this.getAttribute("src");if(!t){this.#r("No data source \u2014 set data-lens-src or src to a pages.json URL.");return}this.#i(t).catch(()=>{})}async#i(t){let e;try{let n=await fetch(t);if(!n.ok)throw new Error(`status ${n.status}`);e=await n.json()}catch(n){this.#r(`Could not load ${t}: ${n.message}`);return}this.#t=Array.isArray(e)?e:e.pages||[],this.#o(),this.#n()}#o(){let t=[{key:"provenance",label:"How was it made",values:this.#s("provenance")},{key:"review",label:"Review",values:this.#s("review")},{key:"status",label:"Status",values:this.#s("status")},{key:"signed",label:"Signed",values:["yes","no"]}],e=['<form data-trust-filter-controls aria-label="Filter pages">'];for(let r of t)if(r.values.length!==0){e.push(`<fieldset data-dim="${r.key}"><legend>${a(r.label)}</legend>`);for(let s of r.values){let o=`tf-${r.key}-${m(s)}`;e.push(`<label for="${o}"><input type="checkbox" id="${o}" data-dim="${c(r.key)}" value="${c(s)}"> <span>${a(b(s))}</span></label>`)}e.push("</fieldset>")}e.push('<button type="reset" class="ghost">Clear all</button>'),e.push("</form>"),e.push('<output data-trust-filter-results aria-live="polite"></output>'),this.innerHTML=e.join(`
|
|
2
|
+
`);let n=this.querySelector("form");n.addEventListener("change",r=>{let s=r.target;if(s&&s.matches('input[type="checkbox"]')){let o=s.getAttribute("data-dim"),f=s.value,u=o?this.#e[o]:null;if(!u)return;s.checked?u.add(f):u.delete(f),this.#n()}}),n.addEventListener("reset",()=>{for(let r of Object.values(this.#e))r.clear();setTimeout(()=>this.#n(),0)})}#s(t){let e=new Set;for(let n of this.#t){let r=n[t];if(r)if(t==="provenance")for(let s of String(r).split(/\s+/).filter(Boolean))e.add(s);else e.add(r)}return[...e].sort()}#a(t){if(this.#e.provenance.size&&!(t.provenance||"").split(/\s+/).filter(Boolean).some(n=>this.#e.provenance.has(n))||this.#e.review.size&&!this.#e.review.has(t.review)||this.#e.status.size&&!this.#e.status.has(t.status))return!1;if(this.#e.signed.size){let e=this.#e.signed,n=!!t.signed;if(e.has("yes")&&!n||e.has("no")&&n)return!1;e.has("yes")&&e.has("no")}return!0}#n(){let t=this.querySelector("[data-trust-filter-results]");if(!t)return;let e=this.#t.filter(s=>this.#a(s)),n=[];if(n.push(`<p class="trust-filter-count">${e.length} of ${this.#t.length} pages</p>`),e.length){n.push('<ul class="trust-filter-list">');for(let s of e){let o=[s.provenance?`<span class="trust-filter-prov" data-provenance="${c(s.provenance)}">${a(s.provenance)}</span>`:"",s.review&&s.review!=="unreviewed"?`<span>${a(s.review)}</span>`:"",s.status&&s.status!=="published"?`<span>${a(s.status)}</span>`:"",s.signed?'<span class="trust-filter-signed">signed</span>':""].filter(Boolean).join(" \xB7 ");n.push(`<li><a href="${c(s.url)}">${a(s.title||s.url)}</a>${o?`<small>${o}</small>`:""}</li>`)}n.push("</ul>")}t.innerHTML=n.join(`
|
|
3
|
+
`);let r={};for(let[s,o]of Object.entries(this.#e))r[s]=[...o];this.dispatchEvent(new CustomEvent("trust-filter:change",{detail:{selected:r,count:e.length},bubbles:!0}))}#r(t){let e=document.createElement("p");e.setAttribute("data-trust-filter-error",""),e.textContent=t,this.innerHTML="",this.append(e)}};function a(i){return String(i??"").replace(/[&<>]/g,t=>({"&":"&","<":"<",">":">"})[t])}function c(i){return String(i??"").replace(/[&<>"]/g,t=>({"&":"&","<":"<",">":">",'"':"""})[t])}function m(i){return String(i).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function b(i){return String(i).replace(/-/g," ").replace(/\b\w/g,t=>t.toUpperCase())}p("trust-filter",d);export{d as TrustFilter};
|
|
4
4
|
//# sourceMappingURL=trust-filter.js.map
|
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
<button type="button" data-action="tracking" aria-pressed="true">
|
|
3
|
-
Tracking
|
|
4
|
-
</button>
|
|
5
|
-
<button type="button" data-action="final" aria-pressed="false">
|
|
6
|
-
Final
|
|
7
|
-
</button>
|
|
8
|
-
<button type="button" data-action="original" aria-pressed="false">
|
|
9
|
-
Original
|
|
10
|
-
</button>
|
|
11
|
-
`,this.prepend(t),t.addEventListener("click",e=>{let s=e.target.closest("[data-action]")?.dataset.action;if(s){s==="tracking"?this.removeAttribute("view"):this.setAttribute("view",s);for(let r of t.querySelectorAll("button"))r.setAttribute("aria-pressed",String(r.dataset.action===s));this.dispatchEvent(new CustomEvent("change-set:view",{detail:{view:s},bubbles:!0}))}})}get view(){return this.getAttribute("view")??"tracking"}set view(t){if(this.view===t)return;t==="tracking"?this.removeAttribute("view"):this.setAttribute("view",t);let i=this.querySelector("[data-controls]");if(i)for(let s of i.querySelectorAll("button"))s.setAttribute("aria-pressed",String(s.dataset.action===t));this.dispatchEvent(new CustomEvent("change-set:view",{detail:{view:t,source:"api"},bubbles:!0}))}};p("change-set",b);function w(h,t){let e=String(h??"").split(`
|
|
1
|
+
var S=window.matchMedia("(prefers-reduced-motion: reduce)");var w=new Map;function p(h,t,e={}){let i=e.priority??10,s={impl:t,bundle:e.bundle,contract:e.contract,priority:i},n=w.get(h);if(customElements.get(h)){if(!n||n.priority>=i){n&&n.priority===i&&n.impl!==t&&console.warn(`[VB Bundle] Tag <${h}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${h}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=i){n.priority===i&&console.warn(`[VB Bundle] Tag <${h}> already registered by "${n.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}w.set(h,s),customElements.define(h,t)}var u=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 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)}};var f=CSS.supports("anchor-name","--x"),y=CSS.supports("position-area","bottom"),x=0,m=class extends u{#t=null;#e=null;#i=null;#s=null;setup(){this.id||(this.id=`pop-over-${++x}`);let t=this.dataset.mode||"auto";this.hasAttribute("popover")||this.setAttribute("popover",t),this.#n(),this.#o(),this.#i=e=>{let i=e.newState==="open"?"show":"hide";this.dispatchEvent(new CustomEvent(`pop-over:${i}`,{detail:{state:e.newState},bubbles:!0,composed:!0})),!f&&e.newState==="open"&&this.#t&&this.#a()},this.listen(this,"beforetoggle",this.#i),f||(this.#s=()=>{this.matches(":popover-open")&&this.#t&&this.#a()},this.listen(window,"resize",this.#s),this.listen(window,"scroll",this.#s,{capture:!0,passive:!0}))}show(){this.matches(":popover-open")||this.showPopover()}hide(){this.matches(":popover-open")&&this.hidePopover()}toggle(){this.matches(":popover-open")?this.hide():this.show()}get open(){return this.matches(":popover-open")}#n(){let t=this.dataset.anchor;t?this.#t=document.getElementById(t)||document.querySelector(t):this.#t=document.querySelector(`[popovertarget="${CSS.escape(this.id)}"]`)}#o(){if(!(!this.#t||!f)&&(this.#e=`--pop-over-anchor-${this.id}`,this.#t.style.setProperty("anchor-name",this.#e),this.style.setProperty("position-anchor",this.#e),this.setAttribute("data-anchor-name",this.#e||""),!y)){let t=this.dataset.position||"bottom";this.#c(t)}}#c(t){let e="var(--_pop-over-offset, var(--size-xs))",i={top:{bottom:`calc(anchor(top) + ${e})`,left:"anchor(left)"},bottom:{top:`calc(anchor(bottom) + ${e})`,left:"anchor(left)"},left:{right:`calc(anchor(left) + ${e})`,top:"anchor(top)"},right:{left:`calc(anchor(right) + ${e})`,top:"anchor(top)"}},s=t.split("-")[0],n=i[s]||i.bottom;Object.entries(n).forEach(([r,a])=>this.style.setProperty(r,a))}#a(){if(!this.#t)return;let t=this.#t.getBoundingClientRect(),e=this.dataset.position||"bottom",i=this.#l(),s,n;switch(e.split("-")[0]){case"top":s=t.top-this.offsetHeight-i,n=t.left;break;case"left":s=t.top,n=t.left-this.offsetWidth-i;break;case"right":s=t.top,n=t.right+i;break;default:s=t.bottom+i,n=t.left;break}e.endsWith("-end")&&(e.startsWith("top")||e.startsWith("bottom")?n=t.right-this.offsetWidth:s=t.bottom-this.offsetHeight),this.style.position="fixed",this.style.top=`${Math.round(s)}px`,this.style.left=`${Math.round(n)}px`,this.style.margin="0"}#l(){let t={none:0,xs:4,s:8,m:16,l:24};return t[this.dataset.offset]??t.xs}};p("pop-over",m);var b=["tracking","final","original"],$={tracking:"Tracking",final:"Final",original:"Original"},v=class extends u{static observedAttributes=["view","author","datetime","controls"];setup(){this.#t(),this.listen(this,"click",this.#o)}attributeChangedCallback(t,e,i){!this.hasAttribute("data-upgraded")||e===i||(t==="view"?this.#n():this.#t())}#t(){this.querySelector(":scope > [data-change-caption]")?.remove(),this.querySelector(":scope > [data-controls]")?.remove();let t=this.#e(),e=[];t&&e.push(t),this.getAttribute("controls")!=="none"&&e.push(this.#i(t)),this.prepend(...e),this.#n()}#e(){let t=this.getAttribute("author"),e=this.getAttribute("datetime");if(!t&&!e)return null;let i=document.createElement("p");if(i.setAttribute("data-change-caption",""),i.append(t?`Changes by ${t}`:"Changes"),e){i.append(t?", ":" from ");let s=document.createElement("time");s.setAttribute("datetime",e),s.textContent=this.#s(e),i.append(s)}return i}#i(t){let e=document.createElement("div");e.setAttribute("data-controls",""),e.setAttribute("role","group");let i=t?`, ${t.textContent}`:"";e.setAttribute("aria-label",`Change view${i}`);for(let s of b){let n=document.createElement("button");n.type="button",n.dataset.action=s,n.textContent=$[s],e.append(n)}return e}#s(t){let e=new Date(t);if(Number.isNaN(e.getTime()))return t;let i=this.closest("[lang]")?.lang||void 0,s=/^\d{4}-\d{2}-\d{2}$/.test(t);return new Intl.DateTimeFormat(i,{dateStyle:"medium",...s?{timeZone:"UTC"}:{timeStyle:"short"}}).format(e)}#n(){let t=this.view;for(let e of this.querySelectorAll(":scope > [data-controls] > button[data-action]"))e.setAttribute("aria-pressed",String(e.dataset.action===t))}#o=t=>{let e=t.target.closest?.("[data-action]");if(!e||e.parentElement?.parentElement!==this||!e.parentElement.hasAttribute("data-controls"))return;let i=e.dataset.action;!i||!b.includes(i)||i!==this.view&&(this.#c(i),this.dispatchEvent(new CustomEvent("change-set:view",{detail:{view:i},bubbles:!0})))};#c(t){t==="tracking"?this.removeAttribute("view"):this.setAttribute("view",t),this.#n()}get view(){let t=this.getAttribute("view");return t==="final"||t==="original"?t:"tracking"}set view(t){!b.includes(t)||this.view===t||(this.#c(t),this.dispatchEvent(new CustomEvent("change-set:view",{detail:{view:t,source:"api"},bubbles:!0})))}};p("change-set",v);function E(h,t){let e=String(h??"").split(`
|
|
12
2
|
`),i=String(t??"").split(`
|
|
13
|
-
`),s=e.length,
|
|
3
|
+
`),s=e.length,n=i.length,r=Array.from({length:s+1},()=>new Array(n+1).fill(0));for(let l=1;l<=s;l++)for(let d=1;d<=n;d++)e[l-1]===i[d-1]?r[l][d]=r[l-1][d-1]+1:r[l][d]=Math.max(r[l-1][d],r[l][d-1]);let a=[],c=s,o=n;for(;c>0||o>0;)c>0&&o>0&&e[c-1]===i[o-1]?(a.unshift({type:"eq",text:e[c-1]}),c-=1,o-=1):o>0&&(c===0||r[c][o-1]>=r[c-1][o])?(a.unshift({type:"add",text:i[o-1]}),o-=1):(a.unshift({type:"del",text:e[c-1]}),c-=1);return a}function C(h){let t=document.createDocumentFragment(),e=document.createElement("pre");e.className="text-diff";for(let i of h)if(i.type==="eq")e.appendChild(document.createTextNode(`${i.text}
|
|
14
4
|
`));else if(i.type==="add"){let s=document.createElement("ins");s.textContent=`${i.text}
|
|
15
5
|
`,e.appendChild(s)}else if(i.type==="del"){let s=document.createElement("del");s.textContent=`${i.text}
|
|
16
|
-
`,e.appendChild(s)}return t.appendChild(e),t}var x=0,v=class extends u{static observedAttributes=["data-versions","data-src"];#t=[];#e=null;#i;#s;#n;#a=null;#h=null;#o=null;setup(){this.#l(),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Version"),this.#$(),this.#N(),this.#c(),this.#d(),this.#p(),this.hasAttribute("data-page-info-target")&&this.#x(),this.#t.length===0&&(this.getAttribute("data-src")||this.#g())&&this.#w()}attributeChangedCallback(t,e,i){!this.isConnected||e===i||(t==="data-versions"&&this.refresh(),t==="data-src"&&this.#w())}#l(){let t=null,e=this.getAttribute("data-versions");if(e)try{t=JSON.parse(e)}catch(i){this.#r("Failed to parse data-versions JSON",{error:i})}if(!t){let i=this.querySelector(':scope > script[type="application/json"][data-versions]');if(i?.textContent.trim())try{t=JSON.parse(i.textContent)}catch(s){this.#r("Failed to parse <script data-versions> JSON",{error:s})}}Array.isArray(t)||(t=[]),this.#t=t.filter(i=>i&&typeof i.id=="string"),this.#e=this.#b()}#b(){if(this.#t.length===0)return null;let t=this.#t.find(i=>i.current===!0);if(t)return t.id;let e=document.querySelector('meta[itemprop="version"]')?.getAttribute("content");if(e){let i=this.#t.find(s=>s.id===e);if(i)return i.id}return this.#t[0].id}#v(){let t=this.getAttribute("data-mode");return t==="releases"||t==="history"?t:new Set(this.#t.map(i=>i.url).filter(Boolean)).size>1?"releases":"history"}#g(){return document.querySelector('meta[name="vb:versions-manifest"]')?.getAttribute("content")}async#w(){let t=this.getAttribute("data-src")||this.#g();if(!t)return;this.#o=t,this.#c();let e;try{let i=await fetch(t,{credentials:"same-origin"});if(!i.ok)throw new Error(`Fetch failed (${i.status}) for ${t}`);e=await i.json()}catch(i){this.#o=null,this.#r(`Failed to load versions manifest: ${i.message}`,{error:i}),this.#c();return}if(this.#o===t){if(this.#o=null,!Array.isArray(e)){this.#r(`Manifest is not a JSON array: ${t}`),this.#c();return}this.#t=e.filter(i=>i&&typeof i.id=="string"),this.#e=this.#b(),this.#c(),this.#d(),this.#p(),this.#a&&this.#f()}}#p(){if(!this.hasAttribute("data-banner"))return;let t=this.#t.find(n=>n.id===this.#e),e=this.#t.find(n=>!n.archived&&!n.draft);if(this.#h?.remove(),this.#h=null,!t?.archived||!e||e.id===t.id)return;let i=document.createElement("aside");i.className="version-switcher-banner",i.setAttribute("role","region"),i.setAttribute("aria-live","polite"),i.setAttribute("aria-label","Archived version notice");let s=document.createElement("span");s.className="version-switcher-banner-text",s.textContent=`You're viewing ${t.label||t.id} (archived).`;let r=document.createElement("a");r.className="version-switcher-banner-link",e.url&&(r.href=e.url),r.textContent=`Latest: ${e.label||e.id} \u2192`,i.append(s," ",r),this.prepend(i),this.#h=i}#x(){let t=this.getAttribute("data-page-info-target");if(!t)return;let e=document.getElementById(t);if(!e||e.localName!=="page-info"){this.#r(`data-page-info-target: no <page-info id="${t}"> found.`);return}this.#i.hidden=!0;let i=()=>{let r=e.querySelector(".page-info-panel");return r?(this.#f(r),!0):!1};if(i())return;let s=new MutationObserver(()=>{i()&&s.disconnect()});s.observe(e,{childList:!0,subtree:!0}),setTimeout(()=>{this.#a||(s.disconnect(),this.#r(`<page-info id="${t}"> never rendered .page-info-panel within 5s.`))},5e3)}#f(t){let e=t||this.#a?.parentNode;if(!e)return;let i=this.#a;if(!i){i=document.createElement("section"),i.className="version-switcher-panel-section",i.setAttribute("aria-label",this.getAttribute("aria-label")||"Versions");let r=document.createElement("h3");r.className="version-switcher-panel-heading",r.textContent=this.#v()==="history"?"History":"Versions",i.appendChild(r),e.appendChild(i),this.#a=i}let s=i.querySelector("ul.version-switcher-panel-list");if(s||(s=document.createElement("ul"),s.className="version-switcher-panel-list",i.appendChild(s)),s.replaceChildren(),this.#t.length===0){let r=document.createElement("li");r.className="version-switcher-empty",r.textContent=this.#o?"Loading versions\u2026":"No versions available.",s.appendChild(r);return}for(let r of this.#t)s.appendChild(this.#E(r))}#$(){this.#i?.parentNode!==this&&(this.#i=document.createElement("button"),this.#i.type="button",this.#i.className="version-switcher-trigger",this.#i.setAttribute("aria-haspopup","dialog"),this.#i.setAttribute("aria-expanded","false"),this.appendChild(this.#i))}#N(){if(this.#s?.parentNode===this)return;let t=`version-switcher-${++x}`;this.#i.setAttribute("popovertarget",t),this.#s=document.createElement("pop-over"),this.#s.id=t,this.#s.className="version-switcher-popover",this.#s.dataset.position="bottom-end",this.#s.setAttribute("role","dialog"),this.#s.setAttribute("aria-label",this.getAttribute("aria-label")||"Version");let e=document.createElement("h3");e.className="version-switcher-heading",e.textContent=this.#v()==="history"?"History":"Versions",this.#n=document.createElement("ul"),this.#n.className="version-switcher-list",this.#n.setAttribute("role","list"),this.#s.append(e,this.#n),this.appendChild(this.#s),this.listen(this.#s,"pop-over:show",()=>{this.#i.setAttribute("aria-expanded","true"),this.dispatchEvent(new CustomEvent("version-switcher:open",{bubbles:!0}));let i=this.#n.querySelector('[data-current="true"] button')||this.#n.querySelector("button");requestAnimationFrame(()=>i?.focus())}),this.listen(this.#s,"pop-over:hide",()=>{this.#i.setAttribute("aria-expanded","false"),this.dispatchEvent(new CustomEvent("version-switcher:close",{bubbles:!0}))}),this.listen(this.#n,"keydown",this.#S)}#c(){let t=this.#t.find(n=>n.id===this.#e),e=!!this.#o&&this.#t.length===0,i=e?"Loading\u2026":t?.label||t?.id||"Version";this.#i.replaceChildren();let s=document.createElement("span");s.className="version-switcher-trigger-label",s.textContent=i;let r=document.createElement("span");r.className="version-switcher-trigger-chevron",r.setAttribute("aria-hidden","true"),r.textContent="\u25BE",this.#i.append(s,r),this.#t.length===0?(this.#i.disabled=!0,this.#i.setAttribute("title",e?"Loading versions\u2026":"No versions available")):(this.#i.disabled=!1,this.#i.removeAttribute("title"))}#d(){if(this.#n){if(this.#n.replaceChildren(),this.#t.length===0){let t=document.createElement("li");t.className="version-switcher-empty",t.textContent="No versions available.",this.#n.appendChild(t);return}for(let t of this.#t)this.#n.appendChild(this.#E(t))}}#E(t){let e=document.createElement("li");e.setAttribute("role","listitem"),e.dataset.versionId=t.id,t.id===this.#e&&(e.dataset.current="true"),t.archived&&(e.dataset.archived=""),t.draft&&(e.dataset.draft="");let i=document.createElement("button");i.type="button",i.className="version-switcher-entry",i.setAttribute("aria-current",t.id===this.#e?"true":"false");let s=document.createElement("span");if(s.className="version-switcher-entry-label",s.textContent=t.label||t.id,t.archived){let n=document.createElement("span");n.className="version-switcher-badge version-switcher-badge-archived",n.textContent="archived",s.appendChild(n)}if(t.draft){let n=document.createElement("span");n.className="version-switcher-badge version-switcher-badge-draft",n.textContent="draft",s.appendChild(n)}if(t.id===this.#e){let n=document.createElement("span");n.className="version-switcher-badge version-switcher-badge-current",n.textContent="current",s.appendChild(n)}if(i.appendChild(s),t.date){let n=document.createElement("time");n.className="version-switcher-entry-date",n.setAttribute("datetime",t.date);try{n.title=new Date(t.date).toLocaleString()}catch{}n.textContent=C(t.date)||t.date,i.appendChild(n)}if(t.author){let n=document.createElement("span");n.className="version-switcher-entry-author",n.textContent=`by ${t.author}`,i.appendChild(n)}if(t.summary){let n=document.createElement("span");n.className="version-switcher-entry-summary",n.textContent=t.summary,i.appendChild(n)}if(t.versionUrl){let n=document.createElement("a");n.className="version-switcher-entry-changelog",n.href=t.versionUrl,n.textContent="Changelog \u2192",this.listen(n,"click",a=>a.stopPropagation()),i.appendChild(n)}let r=[t.label||t.id];return t.date&&r.push(`released ${C(t.date)||t.date}`),t.archived&&r.push("archived"),t.draft&&r.push("draft"),t.id===this.#e&&r.push("current"),i.setAttribute("aria-label",r.join(", ")),this.listen(i,"click",()=>this.#k(t)),e.appendChild(i),e}#S=t=>{let e=[...this.#n.querySelectorAll("button.version-switcher-entry")],i=e.indexOf(document.activeElement);if(i===-1)return;let s=i;switch(t.key){case"ArrowDown":t.preventDefault(),s=Math.min(e.length-1,i+1);break;case"ArrowUp":t.preventDefault(),s=Math.max(0,i-1);break;case"Home":t.preventDefault(),s=0;break;case"End":t.preventDefault(),s=e.length-1;break;default:return}e[s]?.focus()};#k(t){this.dispatchEvent(new CustomEvent("version-switcher:select",{bubbles:!0,detail:{entry:t}})),this.#C(t)}#C(t){let e=this.getAttribute("data-action")||"navigate";if(e==="navigate")return this.#A(t);if(e==="swap")return this.#M(t);if(e==="diff")return this.#q(t);this.#r(`Unknown action "${e}"; falling back to navigate.`),this.#A(t)}#A(t){if(!t?.url){this.#r("Cannot navigate: entry has no url.",{entry:t});return}let e=new CustomEvent("version-switcher:before-navigate",{bubbles:!0,cancelable:!0,detail:{entry:t}});this.dispatchEvent(e)&&(this.closePicker(),location.href=t.url)}#u(){return this.getAttribute("data-versioned-region")||"[data-versioned], main"}#m(t){return t.querySelector(this.#u())}async#y(t){let e=await fetch(t,{credentials:"same-origin"});if(!e.ok)throw new Error(`Fetch failed (${e.status}) for ${t}`);let i=await e.text(),s=new DOMParser().parseFromString(i,"text/html"),r=this.#m(s);if(!r)throw new Error(`No versioned region (${this.#u()}) found in ${t}`);return r}async#M(t){if(!t?.url){this.#r("Cannot swap: entry has no url.",{entry:t});return}let e=this.#m(document);if(!e){this.#r(`No versioned region (${this.#u()}) on this page to swap.`,{entry:t});return}let i=new CustomEvent("version-switcher:before-swap",{bubbles:!0,cancelable:!0,detail:{entry:t}});if(!this.dispatchEvent(i))return;this.closePicker();let s=this.#e,r=async()=>{try{let a=await this.#y(t.url);e.replaceChildren(...a.childNodes)}catch(a){throw this.#r(a.message,{entry:t,error:a}),a}};try{"startViewTransition"in document?await document.startViewTransition(r).updateCallbackDone:await r()}catch{return}let n=document.querySelector('meta[itemprop="version"]');n||(n=document.createElement("meta"),n.setAttribute("itemprop","version"),document.head.appendChild(n)),n.setAttribute("content",t.id),this.#e=t.id,this.#c(),this.#d(),this.dispatchEvent(new CustomEvent("version-switcher:swap",{bubbles:!0,detail:{entry:t,previousId:s}}))}async#q(t){if(!t?.url){this.#r("Cannot diff: entry has no url.",{entry:t});return}let e=this.#m(document);if(!e){this.#r(`No versioned region (${this.#u()}) on this page to diff against.`,{entry:t});return}if(t.id===this.#e){this.#r("Cannot diff against the current version.",{entry:t});return}let i=new CustomEvent("version-switcher:before-diff",{bubbles:!0,cancelable:!0,detail:{entry:t}});if(!this.dispatchEvent(i))return;this.closePicker();let s;try{s=await this.#y(t.url)}catch(c){this.#r(c.message,{entry:t,error:c});return}document.querySelectorAll(".version-switcher-diff-host").forEach(c=>c.remove());let r=w(e.textContent.trim(),s.textContent.trim()),n=document.createElement("change-set");n.classList.add("version-switcher-diff-host"),n.dataset.versionFrom=this.#e??"",n.dataset.versionTo=t.id,n.appendChild(E(r)),(this.getAttribute("data-diff-position")||"before")==="after"?e.parentNode.insertBefore(n,e.nextSibling):e.parentNode.insertBefore(n,e),n.setAttribute("tabindex","-1"),n.focus({preventScroll:!1}),this.dispatchEvent(new CustomEvent("version-switcher:diff",{bubbles:!0,detail:{entry:t,previousId:this.#e,diffElement:n,opCount:r.length}}))}get versions(){return this.#t.slice()}get currentId(){return this.#e}openPicker(){this.#s?.show()}closePicker(){this.#s?.hide()}switchTo(t){let e=this.#t.find(i=>i.id===t);if(!e){this.#r(`switchTo: no entry with id "${t}"`);return}this.dispatchEvent(new CustomEvent("version-switcher:select",{bubbles:!0,detail:{entry:e}})),this.#C(e)}refresh(){this.#l(),!(!this.#i||!this.#n)&&(this.#c(),this.#d(),this.#p(),this.#a&&this.#f())}#r(t,e={}){this.dispatchEvent(new CustomEvent("version-switcher:error",{bubbles:!0,detail:{message:t,...e}}))}};function C(h){let t=new Date(h);if(isNaN(t.getTime()))return null;let e=(Date.now()-t.getTime())/1e3;if(e<0)return null;let i=60,s=3600,r=86400,n=2592e3,a=31536e3;if(e<i)return"just now";if(e<s){let o=Math.floor(e/i);return`${o} minute${o!==1?"s":""} ago`}if(e<r){let o=Math.floor(e/s);return`${o} hour${o!==1?"s":""} ago`}if(e<n){let o=Math.floor(e/r);return`${o} day${o!==1?"s":""} ago`}if(e<a){let o=Math.floor(e/n);return`${o} month${o!==1?"s":""} ago`}let c=Math.floor(e/a);return`${c} year${c!==1?"s":""} ago`}p("version-switcher",v);export{v as VersionSwitcher};
|
|
6
|
+
`,e.appendChild(s)}return t.appendChild(e),t}var N=0,g=class extends u{static observedAttributes=["data-versions","data-src"];#t=[];#e=null;#i;#s;#n;#o=null;#c=null;#a=null;setup(){this.#l(),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Version"),this.#$(),this.#N(),this.#h(),this.#d(),this.#p(),this.hasAttribute("data-page-info-target")&&this.#x(),this.#t.length===0&&(this.getAttribute("data-src")||this.#g())&&this.#w()}attributeChangedCallback(t,e,i){!this.isConnected||e===i||(t==="data-versions"&&this.refresh(),t==="data-src"&&this.#w())}#l(){let t=null,e=this.getAttribute("data-versions");if(e)try{t=JSON.parse(e)}catch(i){this.#r("Failed to parse data-versions JSON",{error:i})}if(!t){let i=this.querySelector(':scope > script[type="application/json"][data-versions]');if(i?.textContent.trim())try{t=JSON.parse(i.textContent)}catch(s){this.#r("Failed to parse <script data-versions> JSON",{error:s})}}Array.isArray(t)||(t=[]),this.#t=t.filter(i=>i&&typeof i.id=="string"),this.#e=this.#b()}#b(){if(this.#t.length===0)return null;let t=this.#t.find(i=>i.current===!0);if(t)return t.id;let e=document.querySelector('meta[itemprop="version"]')?.getAttribute("content");if(e){let i=this.#t.find(s=>s.id===e);if(i)return i.id}return this.#t[0].id}#v(){let t=this.getAttribute("data-mode");return t==="releases"||t==="history"?t:new Set(this.#t.map(i=>i.url).filter(Boolean)).size>1?"releases":"history"}#g(){return document.querySelector('meta[name="vb:versions-manifest"]')?.getAttribute("content")}async#w(){let t=this.getAttribute("data-src")||this.#g();if(!t)return;this.#a=t,this.#h();let e;try{let i=await fetch(t,{credentials:"same-origin"});if(!i.ok)throw new Error(`Fetch failed (${i.status}) for ${t}`);e=await i.json()}catch(i){this.#a=null,this.#r(`Failed to load versions manifest: ${i.message}`,{error:i}),this.#h();return}if(this.#a===t){if(this.#a=null,!Array.isArray(e)){this.#r(`Manifest is not a JSON array: ${t}`),this.#h();return}this.#t=e.filter(i=>i&&typeof i.id=="string"),this.#e=this.#b(),this.#h(),this.#d(),this.#p(),this.#o&&this.#f()}}#p(){if(!this.hasAttribute("data-banner"))return;let t=this.#t.find(r=>r.id===this.#e),e=this.#t.find(r=>!r.archived&&!r.draft);if(this.#c?.remove(),this.#c=null,!t?.archived||!e||e.id===t.id)return;let i=document.createElement("aside");i.className="version-switcher-banner",i.setAttribute("role","region"),i.setAttribute("aria-live","polite"),i.setAttribute("aria-label","Archived version notice");let s=document.createElement("span");s.className="version-switcher-banner-text",s.textContent=`You're viewing ${t.label||t.id} (archived).`;let n=document.createElement("a");n.className="version-switcher-banner-link",e.url&&(n.href=e.url),n.textContent=`Latest: ${e.label||e.id} \u2192`,i.append(s," ",n),this.prepend(i),this.#c=i}#x(){let t=this.getAttribute("data-page-info-target");if(!t)return;let e=document.getElementById(t);if(!e||e.localName!=="page-info"){this.#r(`data-page-info-target: no <page-info id="${t}"> found.`);return}this.#i.hidden=!0;let i=()=>{let n=e.querySelector(".page-info-panel");return n?(this.#f(n),!0):!1};if(i())return;let s=new MutationObserver(()=>{i()&&s.disconnect()});s.observe(e,{childList:!0,subtree:!0}),setTimeout(()=>{this.#o||(s.disconnect(),this.#r(`<page-info id="${t}"> never rendered .page-info-panel within 5s.`))},5e3)}#f(t){let e=t||this.#o?.parentNode;if(!e)return;let i=this.#o;if(!i){i=document.createElement("section"),i.className="version-switcher-panel-section",i.setAttribute("aria-label",this.getAttribute("aria-label")||"Versions");let n=document.createElement("h3");n.className="version-switcher-panel-heading",n.textContent=this.#v()==="history"?"History":"Versions",i.appendChild(n),e.appendChild(i),this.#o=i}let s=i.querySelector("ul.version-switcher-panel-list");if(s||(s=document.createElement("ul"),s.className="version-switcher-panel-list",i.appendChild(s)),s.replaceChildren(),this.#t.length===0){let n=document.createElement("li");n.className="version-switcher-empty",n.textContent=this.#a?"Loading versions\u2026":"No versions available.",s.appendChild(n);return}for(let n of this.#t)s.appendChild(this.#E(n))}#$(){this.#i?.parentNode!==this&&(this.#i=document.createElement("button"),this.#i.type="button",this.#i.className="version-switcher-trigger",this.#i.setAttribute("aria-haspopup","dialog"),this.#i.setAttribute("aria-expanded","false"),this.appendChild(this.#i))}#N(){if(this.#s?.parentNode===this)return;let t=`version-switcher-${++N}`;this.#i.setAttribute("popovertarget",t),this.#s=document.createElement("pop-over"),this.#s.id=t,this.#s.className="version-switcher-popover",this.#s.dataset.position="bottom-end",this.#s.setAttribute("role","dialog"),this.#s.setAttribute("aria-label",this.getAttribute("aria-label")||"Version");let e=document.createElement("h3");e.className="version-switcher-heading",e.textContent=this.#v()==="history"?"History":"Versions",this.#n=document.createElement("ul"),this.#n.className="version-switcher-list",this.#n.setAttribute("role","list"),this.#s.append(e,this.#n),this.appendChild(this.#s),this.listen(this.#s,"pop-over:show",()=>{this.#i.setAttribute("aria-expanded","true"),this.dispatchEvent(new CustomEvent("version-switcher:open",{bubbles:!0}));let i=this.#n.querySelector('[data-current="true"] button')||this.#n.querySelector("button");requestAnimationFrame(()=>i?.focus())}),this.listen(this.#s,"pop-over:hide",()=>{this.#i.setAttribute("aria-expanded","false"),this.dispatchEvent(new CustomEvent("version-switcher:close",{bubbles:!0}))}),this.listen(this.#n,"keydown",this.#S)}#h(){let t=this.#t.find(r=>r.id===this.#e),e=!!this.#a&&this.#t.length===0,i=e?"Loading\u2026":t?.label||t?.id||"Version";this.#i.replaceChildren();let s=document.createElement("span");s.className="version-switcher-trigger-label",s.textContent=i;let n=document.createElement("span");n.className="version-switcher-trigger-chevron",n.setAttribute("aria-hidden","true"),n.textContent="\u25BE",this.#i.append(s,n),this.#t.length===0?(this.#i.disabled=!0,this.#i.setAttribute("title",e?"Loading versions\u2026":"No versions available")):(this.#i.disabled=!1,this.#i.removeAttribute("title"))}#d(){if(this.#n){if(this.#n.replaceChildren(),this.#t.length===0){let t=document.createElement("li");t.className="version-switcher-empty",t.textContent="No versions available.",this.#n.appendChild(t);return}for(let t of this.#t)this.#n.appendChild(this.#E(t))}}#E(t){let e=document.createElement("li");e.setAttribute("role","listitem"),e.dataset.versionId=t.id,t.id===this.#e&&(e.dataset.current="true"),t.archived&&(e.dataset.archived=""),t.draft&&(e.dataset.draft="");let i=document.createElement("button");i.type="button",i.className="version-switcher-entry",i.setAttribute("aria-current",t.id===this.#e?"true":"false");let s=document.createElement("span");if(s.className="version-switcher-entry-label",s.textContent=t.label||t.id,t.archived){let r=document.createElement("span");r.className="version-switcher-badge version-switcher-badge-archived",r.textContent="archived",s.appendChild(r)}if(t.draft){let r=document.createElement("span");r.className="version-switcher-badge version-switcher-badge-draft",r.textContent="draft",s.appendChild(r)}if(t.id===this.#e){let r=document.createElement("span");r.className="version-switcher-badge version-switcher-badge-current",r.textContent="current",s.appendChild(r)}if(i.appendChild(s),t.date){let r=document.createElement("time");r.className="version-switcher-entry-date",r.setAttribute("datetime",t.date);try{r.title=new Date(t.date).toLocaleString()}catch{}r.textContent=A(t.date)||t.date,i.appendChild(r)}if(t.author){let r=document.createElement("span");r.className="version-switcher-entry-author",r.textContent=`by ${t.author}`,i.appendChild(r)}if(t.summary){let r=document.createElement("span");r.className="version-switcher-entry-summary",r.textContent=t.summary,i.appendChild(r)}if(t.versionUrl){let r=document.createElement("a");r.className="version-switcher-entry-changelog",r.href=t.versionUrl,r.textContent="Changelog \u2192",this.listen(r,"click",a=>a.stopPropagation()),i.appendChild(r)}let n=[t.label||t.id];return t.date&&n.push(`released ${A(t.date)||t.date}`),t.archived&&n.push("archived"),t.draft&&n.push("draft"),t.id===this.#e&&n.push("current"),i.setAttribute("aria-label",n.join(", ")),this.listen(i,"click",()=>this.#k(t)),e.appendChild(i),e}#S=t=>{let e=[...this.#n.querySelectorAll("button.version-switcher-entry")],i=e.indexOf(document.activeElement);if(i===-1)return;let s=i;switch(t.key){case"ArrowDown":t.preventDefault(),s=Math.min(e.length-1,i+1);break;case"ArrowUp":t.preventDefault(),s=Math.max(0,i-1);break;case"Home":t.preventDefault(),s=0;break;case"End":t.preventDefault(),s=e.length-1;break;default:return}e[s]?.focus()};#k(t){this.dispatchEvent(new CustomEvent("version-switcher:select",{bubbles:!0,detail:{entry:t}})),this.#C(t)}#C(t){let e=this.getAttribute("data-action")||"navigate";if(e==="navigate")return this.#A(t);if(e==="swap")return this.#M(t);if(e==="diff")return this.#q(t);this.#r(`Unknown action "${e}"; falling back to navigate.`),this.#A(t)}#A(t){if(!t?.url){this.#r("Cannot navigate: entry has no url.",{entry:t});return}let e=new CustomEvent("version-switcher:before-navigate",{bubbles:!0,cancelable:!0,detail:{entry:t}});this.dispatchEvent(e)&&(this.closePicker(),location.href=t.url)}#u(){return this.getAttribute("data-versioned-region")||"[data-versioned], main"}#m(t){return t.querySelector(this.#u())}async#y(t){let e=await fetch(t,{credentials:"same-origin"});if(!e.ok)throw new Error(`Fetch failed (${e.status}) for ${t}`);let i=await e.text(),s=new DOMParser().parseFromString(i,"text/html"),n=this.#m(s);if(!n)throw new Error(`No versioned region (${this.#u()}) found in ${t}`);return n}async#M(t){if(!t?.url){this.#r("Cannot swap: entry has no url.",{entry:t});return}let e=this.#m(document);if(!e){this.#r(`No versioned region (${this.#u()}) on this page to swap.`,{entry:t});return}let i=new CustomEvent("version-switcher:before-swap",{bubbles:!0,cancelable:!0,detail:{entry:t}});if(!this.dispatchEvent(i))return;this.closePicker();let s=this.#e,n=async()=>{try{let a=await this.#y(t.url);e.replaceChildren(...a.childNodes)}catch(a){throw this.#r(a.message,{entry:t,error:a}),a}};try{"startViewTransition"in document?await document.startViewTransition(n).updateCallbackDone:await n()}catch{return}let r=document.querySelector('meta[itemprop="version"]');r||(r=document.createElement("meta"),r.setAttribute("itemprop","version"),document.head.appendChild(r)),r.setAttribute("content",t.id),this.#e=t.id,this.#h(),this.#d(),this.dispatchEvent(new CustomEvent("version-switcher:swap",{bubbles:!0,detail:{entry:t,previousId:s}}))}async#q(t){if(!t?.url){this.#r("Cannot diff: entry has no url.",{entry:t});return}let e=this.#m(document);if(!e){this.#r(`No versioned region (${this.#u()}) on this page to diff against.`,{entry:t});return}if(t.id===this.#e){this.#r("Cannot diff against the current version.",{entry:t});return}let i=new CustomEvent("version-switcher:before-diff",{bubbles:!0,cancelable:!0,detail:{entry:t}});if(!this.dispatchEvent(i))return;this.closePicker();let s;try{s=await this.#y(t.url)}catch(c){this.#r(c.message,{entry:t,error:c});return}document.querySelectorAll(".version-switcher-diff-host").forEach(c=>c.remove());let n=E(e.textContent.trim(),s.textContent.trim()),r=document.createElement("change-set");r.classList.add("version-switcher-diff-host"),r.dataset.versionFrom=this.#e??"",r.dataset.versionTo=t.id,r.appendChild(C(n)),(this.getAttribute("data-diff-position")||"before")==="after"?e.parentNode.insertBefore(r,e.nextSibling):e.parentNode.insertBefore(r,e),r.setAttribute("tabindex","-1"),r.focus({preventScroll:!1}),this.dispatchEvent(new CustomEvent("version-switcher:diff",{bubbles:!0,detail:{entry:t,previousId:this.#e,diffElement:r,opCount:n.length}}))}get versions(){return this.#t.slice()}get currentId(){return this.#e}openPicker(){this.#s?.show()}closePicker(){this.#s?.hide()}switchTo(t){let e=this.#t.find(i=>i.id===t);if(!e){this.#r(`switchTo: no entry with id "${t}"`);return}this.dispatchEvent(new CustomEvent("version-switcher:select",{bubbles:!0,detail:{entry:e}})),this.#C(e)}refresh(){this.#l(),!(!this.#i||!this.#n)&&(this.#h(),this.#d(),this.#p(),this.#o&&this.#f())}#r(t,e={}){this.dispatchEvent(new CustomEvent("version-switcher:error",{bubbles:!0,detail:{message:t,...e}}))}};function A(h){let t=new Date(h);if(isNaN(t.getTime()))return null;let e=(Date.now()-t.getTime())/1e3;if(e<0)return null;let i=60,s=3600,n=86400,r=2592e3,a=31536e3;if(e<i)return"just now";if(e<s){let o=Math.floor(e/i);return`${o} minute${o!==1?"s":""} ago`}if(e<n){let o=Math.floor(e/s);return`${o} hour${o!==1?"s":""} ago`}if(e<r){let o=Math.floor(e/n);return`${o} day${o!==1?"s":""} ago`}if(e<a){let o=Math.floor(e/r);return`${o} month${o!==1?"s":""} ago`}let c=Math.floor(e/a);return`${c} year${c!==1?"s":""} ago`}p("version-switcher",g);export{g as VersionSwitcher};
|
|
17
7
|
//# sourceMappingURL=version-switcher.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var v=window.matchMedia("(prefers-reduced-motion: reduce)");var u=new Map;function d(n,t,e={}){let s=e.priority??10,r={impl:t,bundle:e.bundle,contract:e.contract,priority:s},i=u.get(n);if(customElements.get(n)){if(!i||i.priority>=s){i&&i.priority===s&&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>=s){i.priority===s&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${i.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}u.set(n,r),customElements.define(n,t)}var l=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 t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,s,r){t.addEventListener(e,s,r),this.#t.push(()=>t.removeEventListener(e,s,r))}setup(){}teardown(){}setState(t,e){this.#e||(this.#e=this.attachInternals());let s=this.#e.states;try{e?s.add(t):s.delete(t)}catch{let r=`--${t}`;e?s.add(r):s.delete(r)}}_adoptInternals(t){this.#e||(this.#e=t)}};var h=[.5,.75,1,1.25,1.5,2],p=3e3,c=class extends l{#t=null;#e=null;#a=!1;#p=null;#l=null;#y=null;#c=null;#g=null;#k=null;#i=null;#x=null;#w=null;#u=null;#o=null;#v=null;#_=null;#f=null;#r=null;#m=2;#E=null;#S=null;setup(){if(this.#t=this.querySelector("video"),!this.#t)return!1;this.#e=this.querySelector(".track-list"),this.#t.removeAttribute("controls");let t=!this.shadowRoot;return this.#C(),t&&(this.#z(),this.#L(),this.#$(),this.#q()),this.hasAttribute("muted")&&(this.#t.muted=!0,this.setAttribute("muted","")),this.hasAttribute("autoplay")&&this.#t.play().catch(()=>{}),this.#s(),this.#E=()=>{let e=this.shadowRoot?.querySelector(".player");e&&(e.style.display="none",e.offsetHeight,e.style.display="")},this.listen(window,"vb:theme-change",this.#E),this.#S=()=>{let e=!!document.fullscreenElement;this.toggleAttribute("data-fullscreen",e),this.#v.setAttribute("aria-label",e?"Exit fullscreen":"Fullscreen"),this.#n("video-player:fullscreen",{active:e})},this.listen(document,"fullscreenchange",this.#S),this.setAttribute("state","idle"),!0}teardown(){this.#t&&this.#t.setAttribute("controls",""),this.#r!=null&&clearTimeout(this.#r)}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.dispatchEvent(new CustomEvent("video-player:src-changed",{detail:{src:e,source:"property"},bubbles:!0})))}get currentTime(){return this.#t?.currentTime??0}set currentTime(t){this.#t&&(this.#t.currentTime=Number(t)||0)}#C(){if(this.shadowRoot)return;let t=this.attachShadow({mode:"open"});t.innerHTML=`
|
|
1
|
+
var v=window.matchMedia("(prefers-reduced-motion: reduce)");var u=new Map;function d(n,t,e={}){let s=e.priority??10,r={impl:t,bundle:e.bundle,contract:e.contract,priority:s},i=u.get(n);if(customElements.get(n)){if(!i||i.priority>=s){i&&i.priority===s&&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>=s){i.priority===s&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${i.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}u.set(n,r),customElements.define(n,t)}var l=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 t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,s,r){t.addEventListener(e,s,r),this.#t.push(()=>t.removeEventListener(e,s,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.#e||(this.#e=this.attachInternals());let s=this.#e.states;try{e?s.add(t):s.delete(t)}catch{let r=`--${t}`;e?s.add(r):s.delete(r)}}_adoptInternals(t){this.#e||(this.#e=t)}};var h=[.5,.75,1,1.25,1.5,2],p=3e3,c=class extends l{#t=null;#e=null;#a=!1;#p=null;#l=null;#y=null;#c=null;#g=null;#k=null;#i=null;#x=null;#w=null;#u=null;#o=null;#v=null;#_=null;#f=null;#r=null;#m=2;#E=null;#S=null;setup(){if(this.#t=this.querySelector("video"),!this.#t)return!1;this.#e=this.querySelector(".track-list"),this.#t.removeAttribute("controls");let t=!this.shadowRoot;return this.#C(),t&&(this.#z(),this.#L(),this.#$(),this.#q()),this.hasAttribute("muted")&&(this.#t.muted=!0,this.setAttribute("muted","")),this.hasAttribute("autoplay")&&this.#t.play().catch(()=>{}),this.#s(),this.#E=()=>{let e=this.shadowRoot?.querySelector(".player");e&&(e.style.display="none",e.offsetHeight,e.style.display="")},this.listen(window,"vb:theme-change",this.#E),this.#S=()=>{let e=!!document.fullscreenElement;this.toggleAttribute("data-fullscreen",e),this.#v.setAttribute("aria-label",e?"Exit fullscreen":"Fullscreen"),this.#n("video-player:fullscreen",{active:e})},this.listen(document,"fullscreenchange",this.#S),this.setAttribute("state","idle"),!0}teardown(){this.#t&&this.#t.setAttribute("controls",""),this.#r!=null&&clearTimeout(this.#r)}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.dispatchEvent(new CustomEvent("video-player:src-changed",{detail:{src:e,source:"property"},bubbles:!0})))}get currentTime(){return this.#t?.currentTime??0}set currentTime(t){this.#t&&(this.#t.currentTime=Number(t)||0)}#C(){if(this.shadowRoot)return;let t=this.attachShadow({mode:"open"});t.innerHTML=`
|
|
2
2
|
<style>${this.#M()}</style>
|
|
3
3
|
<div part="player" class="player">
|
|
4
4
|
<slot></slot>
|
|
@@ -1,3 +1,3 @@
|
|
|
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 dt=Object.defineProperty;var A=(n,t)=>()=>(n&&(t=n(n=0)),t);var ut=(n,t)=>{for(var e in t)dt(n,e,{get:t[e],enumerable:!0})};function ft(){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 s=n.key(i);s&&s.startsWith(t)&&e.push(s)}return e}}}function l(){return x[O]||(x[O]=ft()),x[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 K(n){try{let t=JSON.parse(n);if(t&&typeof t=="object"&&typeof t.timestamp=="number")return t}catch{}return null}var O,x,d,L=A(()=>{O="__vbStoreBackend",x=globalThis;d={configure(n={}){x[O]=n.backend??null},async set(n,t,e){let i={data:e,timestamp:Date.now()};await l().setRaw($(n,t),JSON.stringify(i))},async get(n,t,e){let i=await l().getRaw($(n,t));if(i==null)return null;let s=K(i);return!s||e?.maxAge!=null&&Date.now()-s.timestamp>e.maxAge?null:s.data},async remove(n,t){await l().removeRaw($(n,t))},async list(n){let t=G(n),e=await l().keys(t),i=[];for(let s of e){let o=await l().getRaw(s);if(o==null)continue;let r=K(o);r&&i.push({key:s.slice(t.length),data:r.data,timestamp:r.timestamp})}return i},async clear(n){let t=G(n),e=await l().keys(t);for(let i of e)await l().removeRaw(i)},async clearAll(){let n=await l().keys("vb:");for(let t of n)await l().removeRaw(t)},async setMany(n,t){for(let[e,i]of t)await d.set(n,e,i)}};if(typeof window<"u"){let n=window.VB??(window.VB={});n.store??=d}});function gt(n,t){if(!t)return n;let e=n??new URLSearchParams;for(let[i,s]of Object.entries(t))s!=null&&e.set(i,String(s));return e}async function pt(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 J(n){return n.endsWith("/")?n.slice(0,-1):n}var b,v,Y,R,g,y,Q=A(()=>{b="__vbServiceConfig",v=globalThis,Y=()=>({baseUrl:"/go",headers:{},services:{}});v[b]||(v[b]=Y());R=()=>v[b],g=class extends Error{constructor(t,e,i,s){super(`VBService(${i}): ${t} ${s}`),this.name="VBServiceError",this.status=t,this.body=e,this.role=i,this.path=s}};y=class n{static configure(t={}){let e=R();v[b]={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=R();return e.services[t]?J(e.services[t]):e.baseUrl?`${J(e.baseUrl)}/${t}`:`/go/${t}`}static _reset(){v[b]=Y()}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 s=n.resolve(this.role),o=e?e.startsWith("/")?e:`/${e}`:"",r=new URL(`${s}${o}`,globalThis.location?.origin??"http://localhost"),c=gt(r.searchParams,i.params);c&&(r.search=c.toString());let a={method:t,headers:{...R().headers}};i.body!==void 0&&(a.body=JSON.stringify(i.body),a.headers["content-type"]="application/json");let h=r.toString(),f=await fetch(h,a),X=await pt(f);if(!f.ok)throw new g(f.status,X,this.role,`${o||"/"}`);return X}};if(typeof window<"u"){let n=window.VB??(window.VB={});n.service??=y,n.ServiceError??=g}});function N(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 wt(){return"hn-"+crypto.randomUUID().slice(0,8)}function tt(n){return typeof n=="string"&&bt.test(n)}function st(){if(m.size===0){p&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(t=>t!==p),p=null);return}p||(p=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets,p]);let n=[...m.keys()].map(t=>`::highlight(hn-${t}) { background-color: var(--highlight-${t}); text-decoration-line: underline; text-decoration-color: var(--highlight-${t}); text-underline-offset: 2px; }`).join(`
|
|
2
|
+
`);p.replaceSync(n)}function vt(n){for(let t of n)m.set(t,(m.get(t)??0)+1);st()}function St(n){for(let t of n){let e=(m.get(t)??0)-1;e>0?m.set(t,e):m.delete(t)}st()}function Et(n){let t=S.get(n),e=t?[...t.values()].flat():[];e.length===0?(CSS.highlights.delete(`hn-${n}`),S.delete(n)):CSS.highlights.set(`hn-${n}`,new Highlight(...e))}function et(n,t){let e=new Set(t.keys());for(let[i,s]of S)s.has(n)&&e.add(i);for(let i of e){let s=t.get(i)??[],o=S.get(i);s.length?(o||S.set(i,o=new Map),o.set(n,s)):o?.delete(n),Et(i)}}function B(n){u||(u=document.createElement("div"),u.setAttribute("aria-live","polite"),u.setAttribute("aria-atomic","true"),u.className="hn-sr-only",document.body.appendChild(u)),u.textContent="",requestAnimationFrame(()=>{u.textContent=n})}function nt(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 w(n,t,e){let i=document.createTreeWalker(n,NodeFilter.SHOW_TEXT),s=0,o=null,r=0,c=null,a=0;for(;i.nextNode();){let h=i.currentNode,f=(h.textContent??"").length;if(!o&&s+f>t&&(o=h,r=t-s),s+f>=e){c=h,a=e-s;break}s+=f}if(!o||!c)return null;try{let h=document.createRange();return h.setStart(o,Math.min(r,(o.textContent??"").length)),h.setEnd(c,Math.min(a,(c.textContent??"").length)),h}catch{return null}}function _(n){if(M.has(n))return M.get(n);let t=new I(n);return M.set(n,t),t}function it(n=document){n.querySelectorAll(H).forEach(t=>{t.hasAttribute("data-highlights-init")||_(t)})}var H,Z,mt,yt,bt,p,m,S,u,I,M,Ct,ot=A(()=>{L();H="[data-highlights]",Z="highlights",mt=["yellow","green","blue","pink"],yt=typeof CSS<"u"&&"highlights"in CSS;bt=/^[a-z0-9_-]+$/i;p=null,m=new Map,S=new Map;u=null;I=class{#t;#n;#s;#a;#e=[];#c=!yt;#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,s=i?i.split(",").map(o=>o.trim()).filter(tt):[...mt];this.#s=[...new Set(s)],this.#c||vt(this.#s),this.#r(),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.#w().then(()=>{this.#d||this.#r()})}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.#o(),this.#r(),this.#i("highlights:removed",{id:t}),B("Highlight removed"))}clearAll(){this.#e=[],this.#o(),this.#r()}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.#o(),this.#r()}catch{}}destroy(){this.#d||(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()}):(et(this,new Map),St(this.#s)),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,o=this.#e.find(r=>r.id===s);if(o){this.#i("highlights:clicked",{id:s,highlight:{...o}}),this.#i("highlights:request-note",{id:s,highlight:{...o},controller:this});return}}let i=t.target.closest?.("mark[data-hn-id]");if(i){let s=i.dataset.hnId,o=this.#e.find(r=>r.id===s);if(o){this.#i("highlights:clicked",{id:s,highlight:{...o}});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(o=>o.id===t);if(!e)return null;let i=w(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=w(this.#t,i.startOffset,i.endOffset);if(!s)continue;let o=s.getClientRects();for(let r of o)if(t>=r.left&&t<=r.right&&e>=r.top&&e<=r.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=nt(this.#t,i.startContainer,i.startOffset),o=nt(this.#t,i.endContainer,i.endOffset);if(s<0||o<0||s>=o)return;let r=e.toString().trim(),c={id:wt(),startOffset:s,endOffset:o,text:r,color:t,note:"",created:Date.now()};this.#e.push(c),this.#o(),this.#r(),e.removeAllRanges(),this.#i("highlights:added",{id:c.id,text:r,color:t,note:""}),B("Highlight added")}_changeColor(t,e){let i=this.#e.find(s=>s.id===t);i&&(i.color=e,this.#o(),this.#r())}_updateNote(t,e){let i=this.#e.find(s=>s.id===t);i&&(i.note=e,this.#o(),this.#g(),this.#i("highlights:note-changed",{id:t,note:e}),B("Note saved"))}async#w(){let t=await d.get(Z,this.#n);if(!t||!Array.isArray(t.highlights))return;let e=N(this.#t.textContent);t.contentHash&&t.contentHash!==e?(this.#e=t.highlights.filter(i=>{let s=w(this.#t,i.startOffset,i.endOffset);return s?s.toString().trim()===i.text:!1}),this.#o()):this.#e=t.highlights}#o(){let t={version:1,contentHash:N(this.#t.textContent),highlights:this.#e};d.set(Z,this.#n,t).catch(()=>{})}#r(){this.#c?this.#v():this.#b(),this.#g()}#b(){let t=new Map;for(let e of this.#s)t.set(e,[]);for(let e of this.#e){let i=w(this.#t,e.startOffset,e.endOffset);i&&t.has(e.color)&&t.get(e.color).push(i)}et(this,t)}#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=w(this.#t,e.startOffset,e.endOffset);if(!i)continue;let s=document.createElement("mark");s.dataset.hnId=e.id,tt(e.color)&&(s.dataset.hnColor=e.color,s.style.setProperty("--_hn-color",`var(--highlight-${e.color})`));try{i.surroundContents(s)}catch{let o=i.extractContents();s.appendChild(o),i.insertNode(s)}}}#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=w(this.#t,e.startOffset,e.endOffset);if(!i)continue;let s=i.getClientRects();if(s.length===0)continue;let o=s[0],r=this.#t.getBoundingClientRect(),c=o.top-r.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}))}},M=new WeakMap;document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>it()):it();Ct=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.querySelectorAll(H).forEach(s=>{s.hasAttribute("data-highlights-init")||_(s)})}});Ct.observe(document.documentElement,{childList:!0,subtree:!0})});var ct={};ut(ct,{currentHash:()=>V,initPageWatch:()=>D,readWatch:()=>T,removeWatch:()=>at,writeWatch:()=>E});function rt(){return typeof window<"u"&&window.vbPageWatch?.serverSync===!0?!0:document.querySelector('meta[name="vb-page-watch-server"]')?.getAttribute("content")==="true"}async function At(n){if(!rt())return null;try{let t=new y("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 kt(n){if(!(!n||!rt()))try{await new y("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 Ot(){return document.querySelector("main")||document.querySelector("article")||document.body}function C(){return location.pathname||"/"}function V(){let n=Ot();return n?N(n.textContent||""):""}function xt(){return document.title||C()}async function T(){return await d.get(F,C())}async function E(n){await d.set(F,C(),n)}async function at(){await d.remove(F,C())}function P(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 q(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 T();P(n,!!t),n.addEventListener("click",async e=>{e.preventDefault();let i=await T();if(i)await at(),P(n,!1),n.dispatchEvent(new CustomEvent("page-watch:remove",{bubbles:!0,composed:!0,detail:{url:i.url,subscriptionId:i.subscriptionId}})),kt(i.subscriptionId);else{let s={url:C(),title:xt(),contentHash:V(),watchedAt:new Date().toISOString(),lastChecked:new Date().toISOString(),lastChanged:null,subscriptionId:null};await E(s),P(n,!0),n.dispatchEvent(new CustomEvent("page-watch:add",{bubbles:!0,composed:!0,detail:{entry:s}}));let o=await At(s);o&&await E({...s,subscriptionId:o})}})}async function Nt(){let n=await T();if(!n)return;let t=V(),e=new Date().toISOString(),i=n.contentHash,s={...n,lastChecked:e};if(t&&t!==i){s.contentHash=t,s.lastChanged=e,await E(s);let o={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:o}}))}else await E(s)}function D(n=document){for(let t of n.querySelectorAll(W))q(t);Nt()}var W,F,Tt,ht=A(()=>{L();Q();ot();W="[data-watch-page]",F="watches";document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>D()):D();Tt=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?.(W)&&q(i),i.querySelectorAll?.(W).forEach(s=>q(s))}});Tt.observe(document.documentElement,{childList:!0,subtree:!0})});var Rt=window.matchMedia("(prefers-reduced-motion: reduce)");var j=new Map;function z(n,t,e={}){let i=e.priority??10,s={impl:t,bundle:e.bundle,contract:e.contract,priority:i},o=j.get(n);if(customElements.get(n)){if(!o||o.priority>=i){o&&o.priority===i&&o.impl!==t&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${o.bundle}" (priority ${o.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> defined by "${o.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(o&&o.priority>=i){o.priority===i&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${o.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}j.set(n,s),customElements.define(n,t)}var k=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))}_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.#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 lt="Watch for updates",$t="Watching",U=class extends k{#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")??lt;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(()=>(ht(),ct)),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 o=this.#t.querySelector("span");if(o&&this.#n()!=="icon"){let r=this.getAttribute("label");o.textContent=r||(i?$t:lt)}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}};z("watch-wc",U);export{U as WatchWc};
|
|
3
3
|
//# sourceMappingURL=watch-wc.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var N=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))}_reinit(){for(let e of this.#t)e();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}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 j=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 R(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 F=class extends N{#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),f=[];for(let c=0;c<t;c++){let i=new Date(u);i.setDate(i.getDate()+c),f.push(i)}let y=f.map(R),m=new Map,g=new Set;e.forEach(c=>{let i=c,p=i.dataset.date;if(!p||!y.includes(p))return;let S=i.querySelector("time[datetime]");if(!S)return;let M=S.getAttribute("datetime");if(!M)return;let D=M.split(":"),A=parseInt(D[0],10),L=parseInt(D[1]||"0",10);if(isNaN(A))return;L>=30&&!i.dataset.start&&(i.dataset.start="30");let $=String(A).padStart(2,"0"),b=`${p}:${$}`;m.has(b)||m.set(b,[]),m.get(b).push(i),g.add(A)});let l=[...g].sort((c,i)=>c-i),o=this.dataset.startHour==="auto"||!this.dataset.startHour,d=o?l.length>0?Math.max(0,l[0]-1):7:parseInt(this.dataset.startHour??"",10),C=o?l.length>0?Math.min(23,l[l.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"}),I=new Intl.DateTimeFormat(v,{hour:"numeric"});this.style.setProperty("--wv-days",String(t));let w=document.createElement("table"),T=document.createElement("thead"),x=document.createElement("tr"),k=document.createElement("th");k.setAttribute("aria-label","Time"),x.appendChild(k),f.forEach(c=>{let i=document.createElement("th");i.setAttribute("scope","col");let p=document.createElement("time");p.setAttribute("datetime",R(c)),p.textContent=E.format(c),i.appendChild(p),x.appendChild(i)}),T.appendChild(x),w.appendChild(T);let q=document.createElement("tbody");for(let c=d;c<=C;c++){let i=document.createElement("tr"),p=document.createElement("th");p.setAttribute("scope","row");let S=document.createElement("time"),M=String(c).padStart(2,"0");S.setAttribute("datetime",`${M}:00`),S.textContent=I.format(new Date(2026,0,1,c)),p.appendChild(S),i.appendChild(p),y.forEach(D=>{let A=document.createElement("td"),L=`${D}:${M}`,$=m.get(L)||[];if($.length>0){let b=document.createElement("hour-view");$.length>1&&(b.dataset.overlap=""),$.forEach(O=>b.appendChild(O)),A.appendChild(b)}i.appendChild(A)}),q.appendChild(i)}w.appendChild(q),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 f=parseInt(u.split(":")[0],10),y=s.getBoundingClientRect();r.set(f,{top:y.top-t.top,height:y.height})}),n.forEach(s=>{let a=s,u=a.closest("td"),f=u?.closest("tr");if(!u||!f)return;let m=f.querySelector("th time[datetime]")?.getAttribute("datetime");if(!m)return;let g=parseInt(m.split(":")[0],10),l=parseInt(a.dataset.start||"0",10),o=a.dataset.duration??"",d=60,C=o.match(/(\d+)h/),v=o.match(/(\d+)m/);(C||v)&&(d=(C?parseInt(C[1],10)*60:0)+(v?parseInt(v[1],10):0));let E=r.get(g);if(!E)return;let I=u.getBoundingClientRect(),w=l/60,T=E.top+E.height*w,x=E.height*(d/60);a.style.position="absolute",a.style.top=T+"px",a.style.height=x+"px";let k=I.left-t.left+2,q=t.right-I.right+2,c=getComputedStyle(e).direction==="rtl";a.style.insetInlineStart=(c?q:k)+"px",a.style.insetInlineEnd=(c?k:q)+"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 f=[...u.parentElement.children],y=f.indexOf(u),m=[...u.children],g=m.indexOf(a),l=null;if(t.key==="ArrowDown")for(let o=y+1;o<f.length;o++){let d=f[o].children[g]?.querySelector("calendar-event");if(d){l=d;break}}else if(t.key==="ArrowUp")for(let o=y-1;o>=0;o--){let d=f[o].children[g]?.querySelector("calendar-event");if(d){l=d;break}}else if(t.key==="ArrowRight")for(let o=g+1;o<m.length;o++){let d=m[o]?.querySelector("calendar-event");if(d){l=d;break}}else if(t.key==="ArrowLeft")for(let o=g-1;o>=1;o--){let d=m[o]?.querySelector("calendar-event");if(d){l=d;break}}l&&(t.preventDefault(),l.setAttribute("tabindex","0"),s.setAttribute("tabindex","-1"),l.focus())})}};B("week-view",F);export{F as WeekView};
|
|
2
2
|
//# sourceMappingURL=week-view.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var o=class extends HTMLElement{#
|
|
1
|
+
var o=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 t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,i,e,n){t.addEventListener(i,e,n),this.#t.push(()=>t.removeEventListener(i,e,n))}_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,i){this.#e||(this.#e=this.attachInternals());let e=this.#e.states;try{i?e.add(t):e.delete(t)}catch{let n=`--${t}`;i?e.add(n):e.delete(n)}}_adoptInternals(t){this.#e||(this.#e=t)}};var f=window.matchMedia("(prefers-reduced-motion: reduce)");var c=new Map;function d(s,t,i={}){let e=i.priority??10,n={impl:t,bundle:i.bundle,contract:i.contract,priority:e},r=c.get(s);if(customElements.get(s)){if(!r||r.priority>=e){r&&r.priority===e&&r.impl!==t&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${r.bundle}" (priority ${r.priority}). Skipping "${i.bundle}".`);return}console.warn(`[VB Bundle] Tag <${s}> defined by "${r.bundle}" cannot be replaced (customElements.define is permanent). "${i.bundle}" has higher priority but arrived late.`);return}if(r&&r.priority>=e){r.priority===e&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${r.bundle}". Skipping "${i.bundle}" (first wins at equal priority).`);return}c.set(s,n),customElements.define(s,t)}var l='<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>',u={hq:"hqdefault",mq:"mqdefault",sd:"sddefault",maxres:"maxresdefault"},a=class extends o{#t;#e;setup(){return this.#t=this.getAttribute("video-id"),this.#e=this.getAttribute("title")??"Play video",this.#t?(this.hasAttribute("autoplay")?this.#i():this.#a(),!0):(console.warn("youtube-player: missing required video-id attribute"),!1)}#n(){let t=new URLSearchParams({autoplay:"1"}),i=this.getAttribute("start");i&&t.set("start",i);let e=this.getAttribute("list");return e&&t.set("list",e),this.getAttribute("params")&&new URLSearchParams(this.getAttribute("params")||"").forEach((n,r)=>t.set(r,n)),`https://www.youtube-nocookie.com/embed/${this.#t}?${t}`}#o(){let t=this.getAttribute("thumbnail")??"hq";return`https://i.ytimg.com/vi/${this.#t}/${u[t]??"hqdefault"}.jpg`}#a(){this.setAttribute("state","ready"),this.setAttribute("tabindex","0"),this.setAttribute("role","button"),this.setAttribute("aria-label",`Play ${this.#e}`),this.innerHTML=`<img src="${this.#o()}" alt="" loading="lazy" decoding="async"><button type="button" aria-label="Play ${this.#e}">${l}</button>`,this.addEventListener("click",this.#r,{once:!0}),this.addEventListener("keydown",this.#s)}#r=()=>{this.removeEventListener("keydown",this.#s),this.#i()};#s=t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.removeEventListener("click",this.#r),this.#i())};#i(){this.setAttribute("state","active"),this.removeAttribute("tabindex"),this.removeAttribute("role"),this.removeAttribute("aria-label"),this.innerHTML=`<iframe src="${this.#n()}" title="${this.#e}" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen loading="lazy"></iframe>`,this.querySelector("iframe")?.focus()}};d("youtube-player",a);export{a as YouTubePlayer};
|
|
2
2
|
//# sourceMappingURL=youtube-player.js.map
|