vanilla-breeze 0.6.2 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +6768 -6425
- 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 +6 -6
- package/dist/cdn/components/ai-summary.js +2 -2
- package/dist/cdn/components/analytics-panel.js +2 -2
- package/dist/cdn/components/audio-player.js +4 -4
- package/dist/cdn/components/audio-visualizer.js +2 -2
- 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 -1
- package/dist/cdn/components/chart-wc.js +13 -13
- 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 +35 -35
- package/dist/cdn/components/comment-thread.js +38 -38
- 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 +3 -3
- 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/icon-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 +58 -54
- package/dist/cdn/components/markdown-editor.js +25 -25
- package/dist/cdn/components/markdown-viewer.js +27 -27
- 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 +23 -23
- package/dist/cdn/components/page-info.js +6 -6
- package/dist/cdn/components/page-stats.js +1 -1
- package/dist/cdn/components/page-toc.js +1 -1
- package/dist/cdn/components/page-tools.js +1 -1
- package/dist/cdn/components/page-tour.js +1 -1
- package/dist/cdn/components/pager-wc.js +1 -1
- package/dist/cdn/components/poll-wc.js +1 -1
- package/dist/cdn/components/pop-over.js +1 -1
- package/dist/cdn/components/popularity-index.js +1 -1
- 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/reading-progress.js +1 -1
- package/dist/cdn/components/recently-visited.js +1 -1
- 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 +6 -6
- package/dist/cdn/components/share-wc.js +2 -2
- package/dist/cdn/components/short-cuts.js +1 -1
- package/dist/cdn/components/site-index.js +1 -1
- package/dist/cdn/components/site-map.js +1 -1
- package/dist/cdn/components/site-search.js +1 -1
- package/dist/cdn/components/slide-accept.js +1 -1
- package/dist/cdn/components/social-embed.js +1 -1
- package/dist/cdn/components/social-links.js +2 -0
- 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 +20 -20
- package/dist/cdn/components/time-index.js +1 -1
- package/dist/cdn/components/time-picker.js +1 -1
- package/dist/cdn/components/toast-msg.js +2 -2
- package/dist/cdn/components/tool-tip.js +1 -1
- package/dist/cdn/components/topic-map.js +4 -4
- package/dist/cdn/components/trust-filter.js +1 -1
- package/dist/cdn/components/version-switcher.js +6 -6
- package/dist/cdn/components/video-player.js +4 -4
- 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/fonts/barlow-condensed-latin-400-italic.woff2 +0 -0
- package/dist/cdn/fonts/barlow-condensed-latin-700-italic.woff2 +0 -0
- package/dist/cdn/fonts/barlow-condensed-latin-ext-400-italic.woff2 +0 -0
- package/dist/cdn/fonts/barlow-condensed-latin-ext-700-italic.woff2 +0 -0
- package/dist/cdn/fonts/dm-sans-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/dm-sans-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/dm-serif-display-latin-400-italic.woff2 +0 -0
- package/dist/cdn/fonts/dm-serif-display-latin-ext-400-italic.woff2 +0 -0
- package/dist/cdn/fonts/exo-2-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/exo-2-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/inter-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/inter-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/jetbrains-mono-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/jetbrains-mono-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/josefin-sans-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/josefin-sans-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/lora-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/lora-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/merriweather-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/merriweather-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/nunito-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/nunito-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/packs/effects.full.js +1 -1
- package/dist/cdn/packs/kawaii/fonts/nunito-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/packs/kawaii/fonts/nunito-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/packs/kawaii.full.css +1 -1
- package/dist/cdn/packs/kawaii.theme.css +1 -1
- package/dist/cdn/packs/manifest.json +4 -4
- package/dist/cdn/packs/prototype.full.js +1 -1
- package/dist/cdn/packs/ui.full.js +19 -19
- package/dist/cdn/themes/8bit.tokens.json +8 -37
- package/dist/cdn/themes/alpha1999-dark.tokens.json +1 -1
- package/dist/cdn/themes/alpha1999.css +1 -1
- package/dist/cdn/themes/alpha1999.tokens.json +3 -6
- package/dist/cdn/themes/art-deco-dark.tokens.json +3 -27
- package/dist/cdn/themes/art-deco.css +1 -1
- package/dist/cdn/themes/art-deco.tokens.json +5 -11
- package/dist/cdn/themes/bauhaus-dark.tokens.json +1 -1
- package/dist/cdn/themes/bauhaus.css +1 -1
- package/dist/cdn/themes/bauhaus.tokens.json +13 -7
- package/dist/cdn/themes/brutalist-dark.tokens.json +3 -27
- package/dist/cdn/themes/brutalist.tokens.json +5 -11
- package/dist/cdn/themes/catppuccin-frappe.css +1 -1
- package/dist/cdn/themes/catppuccin-frappe.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-latte-dark.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-latte.css +1 -1
- package/dist/cdn/themes/catppuccin-latte.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-macchiato.css +1 -1
- package/dist/cdn/themes/catppuccin-macchiato.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-mocha.css +1 -1
- package/dist/cdn/themes/catppuccin-mocha.tokens.json +1 -1
- package/dist/cdn/themes/classic-dark.tokens.json +41 -41
- package/dist/cdn/themes/classic.tokens.json +25 -31
- package/dist/cdn/themes/claymorphism-dark.tokens.json +533 -161
- package/dist/cdn/themes/claymorphism.css +1 -1
- package/dist/cdn/themes/claymorphism.tokens.json +531 -135
- 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 +5 -11
- package/dist/cdn/themes/dawn-dark.tokens.json +3 -27
- package/dist/cdn/themes/dawn.css +1 -1
- package/dist/cdn/themes/dawn.tokens.json +1 -1
- package/dist/cdn/themes/dracula.tokens.json +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.tokens.json +19 -16
- package/dist/cdn/themes/financial-dark.tokens.json +1 -1
- package/dist/cdn/themes/financial.css +1 -1
- package/dist/cdn/themes/financial.tokens.json +1 -1
- package/dist/cdn/themes/genai.css +1 -1
- package/dist/cdn/themes/genai.tokens.json +1 -1
- package/dist/cdn/themes/glassmorphism-dark.tokens.json +233 -116
- package/dist/cdn/themes/glassmorphism.css +1 -1
- package/dist/cdn/themes/glassmorphism.tokens.json +233 -116
- 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.css +1 -1
- package/dist/cdn/themes/gruvbox.tokens.json +1 -1
- package/dist/cdn/themes/high-noon-dark.tokens.json +1 -1
- package/dist/cdn/themes/high-noon.tokens.json +1 -1
- package/dist/cdn/themes/journal-dark.tokens.json +3 -27
- package/dist/cdn/themes/journal.css +1 -1
- package/dist/cdn/themes/journal.tokens.json +21 -21
- package/dist/cdn/themes/kawaii-dark.tokens.json +1 -1
- package/dist/cdn/themes/kawaii.css +1 -1
- package/dist/cdn/themes/kawaii.tokens.json +1 -1
- package/dist/cdn/themes/magna-dark.tokens.json +1 -1
- package/dist/cdn/themes/magna.css +1 -1
- package/dist/cdn/themes/magna.tokens.json +2 -14
- package/dist/cdn/themes/manifest.json +25 -25
- 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 +25 -27
- package/dist/cdn/themes/modern-dark.tokens.json +41 -41
- package/dist/cdn/themes/modern.css +1 -1
- package/dist/cdn/themes/modern.tokens.json +21 -21
- package/dist/cdn/themes/nes-dark.tokens.json +3 -27
- package/dist/cdn/themes/nes.tokens.json +10 -39
- package/dist/cdn/themes/neumorphism-dark.tokens.json +266 -134
- package/dist/cdn/themes/neumorphism.css +1 -1
- package/dist/cdn/themes/neumorphism.tokens.json +266 -134
- package/dist/cdn/themes/nord-dark.tokens.json +3 -27
- package/dist/cdn/themes/nord.css +1 -1
- package/dist/cdn/themes/nord.tokens.json +1 -1
- package/dist/cdn/themes/organic-dark.tokens.json +1 -1
- package/dist/cdn/themes/organic.tokens.json +5 -14
- package/dist/cdn/themes/rose-pine-dark.tokens.json +1 -1
- package/dist/cdn/themes/rose-pine.css +1 -1
- package/dist/cdn/themes/rose-pine.tokens.json +1 -1
- package/dist/cdn/themes/rough-dark.tokens.json +1 -1
- package/dist/cdn/themes/rough.tokens.json +1 -1
- package/dist/cdn/themes/solarized-dark.tokens.json +1 -1
- package/dist/cdn/themes/solarized.tokens.json +1 -1
- package/dist/cdn/themes/startup-dark.tokens.json +1 -1
- package/dist/cdn/themes/startup.css +1 -1
- package/dist/cdn/themes/startup.tokens.json +1 -1
- package/dist/cdn/themes/super2026-dark.tokens.json +6 -30
- package/dist/cdn/themes/super2026.css +1 -1
- package/dist/cdn/themes/super2026.tokens.json +1 -1
- package/dist/cdn/themes/swiss-dark.tokens.json +4 -40
- package/dist/cdn/themes/swiss.tokens.json +34 -68
- package/dist/cdn/themes/terminal.tokens.json +286 -120
- package/dist/cdn/themes/tokyo-night-dark.tokens.json +3 -27
- package/dist/cdn/themes/tokyo-night.css +1 -1
- package/dist/cdn/themes/tokyo-night.tokens.json +1 -1
- package/dist/cdn/themes/vaporwave-dark.tokens.json +3 -27
- package/dist/cdn/themes/vaporwave.tokens.json +1 -1
- package/dist/cdn/themes/win9x-dark.tokens.json +5 -29
- package/dist/cdn/themes/win9x.tokens.json +9 -9
- package/dist/cdn/vanilla-breeze-autoload.js +113 -108
- package/dist/cdn/vanilla-breeze-charts.js +13 -13
- package/dist/cdn/vanilla-breeze-core.css +1 -1
- package/dist/cdn/vanilla-breeze-core.js +80 -75
- package/dist/cdn/vanilla-breeze-extras.js +31 -31
- package/dist/cdn/vanilla-breeze.css +1 -1
- package/dist/cdn/vanilla-breeze.js +133 -133
- package/package.json +3 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var ut=window.matchMedia("(prefers-reduced-motion: reduce)");var v=new Map;function b(r,t,e={}){let s=e.priority??10,o={impl:t,bundle:e.bundle,contract:e.contract,priority:s},n=v.get(r);if(customElements.get(r)){if(!n||n.priority>=s){n&&n.priority===s&&n.impl!==t&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${r}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=s){n.priority===s&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${n.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}v.set(r,o),customElements.define(r,t)}var m=class extends HTMLElement{#t=[];#e;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,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)}#r(){return this.constructor.formAssociated&&this.#e?this.#e:null}get validity(){return this.#r()?.validity}get validationMessage(){return this.#r()?.validationMessage??""}get willValidate(){return this.#r()?.willValidate??!1}get form(){return this.#r()?.form??null}checkValidity(){return this.#r()?.checkValidity()??!0}reportValidity(){return this.#r()?.reportValidity()??!0}};var w=new Map;function D(r){let t=w.get(r);if(t)return t;let e=document.createElement("script"),s=new Promise((o,n)=>{e.src=r,e.async=!0,e.onload=()=>o(void 0),e.onerror=()=>{w.delete(r),e.remove(),n(new Error(`Failed to load script: ${r}`))},document.head.appendChild(e)});return w.set(r,s),s}async function I(r,t,e={}){let s=new URLSearchParams({url:t,format:"json",...e}),o=await fetch(`${r}?${s}`);if(!o.ok)throw new Error(`oEmbed error ${o.status}`);return o.json()}function c(r,t){let e;try{e=new URL(String(r??"").trim())}catch{return null}return e.protocol!=="https:"||e.username||e.password||e.port||t&&!t.has(e.hostname)?null:e}var S=new WeakMap,$=r=>S.get(r),z=5e3;function d(r){if(typeof r=="string")try{return JSON.parse(r)}catch{return null}return r&&typeof r=="object"?r:null}function x(r,t){let e=Number(t);!Number.isFinite(e)||e<=0||(r.height=String(Math.ceil(Math.min(e,z))))}function l({src:r,title:t,sandbox:e,allow:s="",height:o=400,measure:n,onload:i}){if(!(r instanceof URL)||r.protocol!=="https:")throw new Error("social-embed: embed frames must use an https URL");let a=document.createElement("iframe");return a.setAttribute("sandbox",e.join(" ")),a.setAttribute("referrerpolicy","strict-origin"),a.setAttribute("loading","lazy"),a.setAttribute("title",t),s&&a.setAttribute("allow",s),a.setAttribute("data-embed-frame",""),a.height=String(o),i&&a.addEventListener("load",()=>i(a)),a.src=r.href,S.set(a,{origin:r.origin,measure:n}),a}var f=Object.freeze(["allow-scripts","allow-same-origin","allow-popups","allow-popups-to-escape-sandbox"]),g=()=>String(crypto.getRandomValues(new Uint32Array(1))[0]);var V=new Set(["x.com","www.x.com","mobile.x.com","twitter.com","www.twitter.com","mobile.twitter.com"]),Z=/^\/([A-Za-z0-9_]{1,15})\/status(?:es)?\/(\d{1,25})\/?$/,k="platform.twitter.com";function L(r){let t=c(r,V),e=t&&Z.exec(t.pathname);return e?{user:e[1],id:e[2]}:null}var M={label:"X",themeable:!0,canHandle:r=>!!L(r),frameHost:()=>k,async render(r,t,{theme:e,title:s}){let o=L(t);if(!o)throw new Error("Not an X post URL");let n=new URL(`https://${k}/embed/Tweet.html`);return n.searchParams.set("id",o.id),n.searchParams.set("theme",e),n.searchParams.set("dnt","true"),l({src:n,title:s,sandbox:[...f],allow:"fullscreen",height:360,measure(i){let a=d(i)?.["twttr.embed"];return a?.method==="twttr.private.resize"?a.params?.[0]?.height:null}})}};var j=new Set(["instagram.com","www.instagram.com"]),X=/^\/(?:[A-Za-z0-9_.]{1,30}\/)?(?:p|reel|tv)\/([A-Za-z0-9_-]{5,64})\/?$/,H="www.instagram.com";function T(r){let t=c(r,j),e=t&&X.exec(t.pathname);return e?{id:e[1]}:null}var P={label:"Instagram",canHandle:r=>!!T(r),frameHost:()=>H,async render(r,t,{title:e}){let s=T(t);if(!s)throw new Error("Not an Instagram post URL");return l({src:new URL(`https://${H}/p/${s.id}/embed/`),title:e,sandbox:[...f],height:560,measure(o){let n=d(o);return n?.type==="MEASURE"?n.details?.height:null}})}};var Y=new Set(["bsky.app"]),W=/^\/profile\/([^/]{1,253})\/post\/([A-Za-z0-9._~:-]{1,512})\/?$/,N=/^did:(?:plc:[a-z2-7]{24}|web:[A-Za-z0-9.-]{1,253})$/,J=/^(?=.{1,253}$)(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?\.)+[A-Za-z][A-Za-z0-9-]{0,62}$/,U="embed.bsky.app",G="https://public.api.bsky.app/xrpc/com.atproto.identity.resolveHandle";function O(r){let t=c(r,Y),e=t&&W.exec(t.pathname);if(!e)return null;let s=decodeURIComponent(e[1]);return N.test(s)?{actor:s,did:s,rkey:e[2]}:J.test(s)?{actor:s,did:null,rkey:e[2]}:null}async function K(r){let t=await fetch(`${G}?${new URLSearchParams({handle:r})}`);if(!t.ok)throw new Error(`Bluesky handle lookup failed (${t.status})`);let{did:e}=await t.json();if(typeof e!="string"||!N.test(e))throw new Error("Bluesky handle lookup returned no DID");return e}var _={label:"Bluesky",themeable:!0,canHandle:r=>!!O(r),frameHost:()=>U,async render(r,t,{theme:e,title:s}){let o=O(t);if(!o)throw new Error("Not a Bluesky post URL");let n=o.did??await K(o.actor),i=g(),a=new URL(`https://${U}/embed/${n}/app.bsky.feed.post/${o.rkey}`);return a.searchParams.set("id",i),a.searchParams.set("colorMode",e),l({src:a,title:s,sandbox:[...f],height:320,measure(p){let h=d(p);return h?.id===i?h.height:null}})}};var Q='<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>',tt={hq:"hqdefault",mq:"mqdefault",sd:"sddefault",maxres:"maxresdefault"},C="YouTube video",et="Play {title}",rt=/^\d+$/;function R(r){return String(r).replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t])}function st(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches||document.documentElement.hasAttribute("data-motion-reduced")}var y=class extends m{#t="";#e=C;setup(){let t=this.getAttribute("video-id");return this.#e=this.getAttribute("title")||C,t?/^[A-Za-z0-9_-]{6,20}$/.test(t)?(this.#t=t,this.hasAttribute("autoplay")&&!st()?this.#c(!1):this.#a(),!0):(console.warn(`youtube-player: invalid video-id ${JSON.stringify(t)}`),!1):(console.warn("youtube-player: missing required video-id attribute"),!1)}#r(t){let e=this.getAttribute(t);return e===null||e===""?null:rt.test(e.trim())?e.trim():(console.warn(`youtube-player: ${t} must be whole seconds, got ${JSON.stringify(e)}`),null)}#i(){let t=new URLSearchParams({autoplay:"1"}),e=this.#r("start");e&&t.set("start",e);let s=this.#r("end");s&&t.set("end",s);let o=this.getAttribute("list");o&&t.set("list",o);let n=this.getAttribute("params");return n&&new URLSearchParams(n).forEach((i,a)=>t.set(a,i)),`https://www.youtube-nocookie.com/embed/${this.#t}?${t}`}#s(t){return`https://i.ytimg.com/vi/${this.#t}/${tt[t]??"hqdefault"}.jpg`}#o(){return(this.getAttribute("data-label-play")||et).replace(/\{title\}/g,this.#e)}#a(){this.setAttribute("state","ready");let t=document.createElement("img");t.alt="",t.loading="lazy",t.decoding="async";let e=this.getAttribute("poster");if(e)t.src=e;else{let o=this.getAttribute("thumbnail")??"hq";if(t.referrerPolicy="no-referrer",t.src=this.#s(o),o==="sd"||o==="maxres"){let n=()=>{t.src=this.#s("hq")};t.addEventListener("error",n,{once:!0}),t.addEventListener("load",()=>{t.naturalWidth<=120&&n()},{once:!0})}}let s=document.createElement("button");s.type="button",s.setAttribute("aria-label",this.#o()),s.innerHTML=Q,s.addEventListener("click",()=>this.#c(!0),{once:!0}),this.replaceChildren(t,s)}#c(t){this.setAttribute("state","active"),this.innerHTML=`<iframe src="${R(this.#i())}" title="${R(this.#e)}" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen loading="lazy"></iframe>`,t&&this.querySelector("iframe")?.focus(),this.dispatchEvent(new CustomEvent("youtube-player:activate",{bubbles:!0,detail:{videoId:this.#t,fromUser:t}}))}};b("youtube-player",y);var ot=new Set(["youtube.com","www.youtube.com","m.youtube.com","music.youtube.com","youtube-nocookie.com","www.youtube-nocookie.com","youtu.be"]),nt=/^[A-Za-z0-9_-]{11}$/;function it(r){if(!r)return null;if(/^\d+s?$/.test(r))return parseInt(r,10);let t=/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/.exec(r);return!t||!t[0]?null:+(t[1]||0)*3600+ +(t[2]||0)*60+ +(t[3]||0)}function q(r){let t=c(r,ot);if(!t)return null;let e=null;return t.hostname==="youtu.be"?e=t.pathname.slice(1).replace(/\/$/,""):t.pathname==="/watch"?e=t.searchParams.get("v"):e=/^\/(?:shorts|embed|live)\/([^/]+)\/?$/.exec(t.pathname)?.[1]??null,!e||!nt.test(e)?null:{id:e,start:it(t.searchParams.get("t")??t.searchParams.get("start"))}}var F={label:"YouTube",noun:"video",delegatesActivation:!0,canHandle:r=>!!q(r),frameHost:()=>"www.youtube-nocookie.com",async render(r,t,{title:e}){let s=q(t);if(!s)throw new Error("Could not parse YouTube video ID");let o=document.createElement("youtube-player");o.setAttribute("video-id",s.id),o.setAttribute("title",e.replace(/["<>]/g,"")),s.start&&o.setAttribute("start",String(s.start));let n=r.getAttribute("poster");return n&&o.setAttribute("poster",n),o}};var at=/^\/@([A-Za-z0-9_]{1,30})\/(\d{1,25})\/?$/;function A(r){let t=c(r,null);if(!t||!t.hostname.includes("."))return null;let e=at.exec(t.pathname);return e?{origin:t.origin,host:t.hostname,user:e[1],id:e[2]}:null}var B={label:"Mastodon",canHandle:r=>!!A(r),frameHost:r=>A(r)?.host??"",async render(r,t,{title:e}){let s=A(t);if(!s)throw new Error("Not a Mastodon post URL");let o=Number(g());return l({src:new URL(`${s.origin}/@${s.user}/${s.id}/embed`),title:e,sandbox:["allow-scripts","allow-same-origin","allow-popups"],allow:"fullscreen",height:320,onload(n){n.contentWindow?.postMessage({type:"setHeight",id:o},s.origin)},measure(n){let i=d(n);return i?.type==="setHeight"&&i.id===o?i.height:null}})}};var u=new Map;u.set("x",M);u.set("instagram",P);u.set("bluesky",_);u.set("youtube",F);u.set("mastodon",B);var ct={load:"Load {provider} {noun}",loading:"Loading {provider} {noun}\u2026",error:"{provider} {noun} failed to load.",note:"Loads content from {host}"};function lt(r,t){if(r==="light"||r==="dark")return r;let e=getComputedStyle(t).colorScheme||"";if(/\bdark\b/.test(e)&&!/\blight\b/.test(e))return"dark";if(/\blight\b/.test(e)&&!/\bdark\b/.test(e))return"light";let s=document.documentElement.dataset.mode;return s==="dark"||s==="light"?s:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var E=class r extends m{static register(t,e){u.set(t,e);for(let s of document.querySelectorAll('social-embed[state="unsupported"]'))s instanceof r&&s._reinit()}#t=null;#e=null;#r=null;#i="";#s=null;#o=null;#a=!1;setup(){this.#e||(this.#e=[...this.childNodes].filter(i=>!(i instanceof Element&&i.matches("[data-embed-live], [data-embed-facade]"))).map(i=>i.cloneNode(!0)));let t=this.getAttribute("url");if(!t)return console.warn("social-embed: missing required url attribute"),!1;let e=this.getAttribute("state");if(this.#r&&(e==="loaded"||e==="loading"))return this.#c(),!0;let s=this.getAttribute("provider"),o=s?u.get(s):[...u.values()].find(i=>i.canHandle?.(t));if(o&&s&&o.canHandle&&!o.canHandle(t)&&(o=void 0),this.#h(),!o)return this.setAttribute("state","unsupported"),!0;if(this.#i=s||[...u].find(([,i])=>i===o)?.[0]||"",o.delegatesActivation)return this.#l(o,!1),!0;this.setAttribute("state","idle"),this.#d(o,t);let n=this.getAttribute("activate")??"click";return n==="eager"?this.#l(o,!1):n==="visible"&&(this.#t=new IntersectionObserver(i=>{i.some(a=>a.isIntersecting)&&(this.#t?.disconnect(),this.#t=null,this.#l(o,!1))},{rootMargin:"200px"}),this.#t.observe(this)),!0}teardown(){this.#t?.disconnect(),this.#t=null,this.#s&&(clearTimeout(this.#s),this.#s=null),this.#a=!1}#c(){this.#a||(this.#a=!0,this.listen(window,"message",t=>{for(let e of this.querySelectorAll("iframe[data-embed-frame]")){let s=e,o=$(s);!o?.measure||t.source!==s.contentWindow||t.origin!==o.origin||x(s,o.measure(t.data))}}),this.listen(window,"vb:theme-change",()=>{this.#r?.themeable&&(this.#s&&clearTimeout(this.#s),this.#s=setTimeout(()=>{this.#s=null,this.#r?.themeable&&this.getAttribute("state")==="loaded"&&this.#l(this.#r,!1)},100))}))}#n(t,e,s={}){let o={provider:e.label??this.#i,noun:e.noun??"post",...s};return(this.getAttribute(`data-label-${t}`)??ct[t]).replace(/\{(\w+)\}/g,(i,a)=>a in o?o[a]:i)}#d(t,e,s=!1){this.#h();let o=document.createElement("p");o.setAttribute("data-embed-facade","");let n=document.createElement("button");n.type="button",n.setAttribute("data-embed-load",""),n.textContent=this.#n("load",t),n.addEventListener("click",()=>this.#l(t,!0));let i=document.createElement("small");i.setAttribute("data-embed-note","");let a="";try{a=t.frameHost?.(e)??""}catch{}i.textContent=s?this.#n("error",t):a?this.#n("note",t,{host:a}):"",o.append(n," ",i),this.append(o),this.#o=n}#h(){for(let t of this.querySelectorAll(":scope > [data-embed-facade]"))t.remove();this.#o=null}async#l(t,e){if(this.getAttribute("state")==="loading")return;let s=this.getAttribute("state")!=="loaded";this.#r=t,this.#c(),this.#t?.disconnect(),this.#t=null;let o=this.getAttribute("url"),n=e||this.contains(document.activeElement);this.setAttribute("state","loading"),this.#o&&(this.#o.setAttribute("aria-disabled","true"),this.#o.textContent=this.#n("loading",t)),s&&!t.delegatesActivation&&this.#u(this.#n("loading",t));try{let i=this.dataset.title||`${t.label??this.#i} ${t.noun??"post"}`,a=lt(this.getAttribute("theme")??"auto",this),p=await t.render(this,o,{theme:a,title:i});if(p instanceof Node&&this.replaceChildren(...[this.querySelector(":scope > [data-embed-live]")].filter(h=>!!h),p),this.#o=null,this.setAttribute("state","loaded"),s&&!t.delegatesActivation&&this.#u(""),n){let h=this.querySelector("iframe, youtube-player button");h?h.focus():(this.setAttribute("tabindex","-1"),this.focus())}}catch(i){console.warn("[social-embed] render failed:",i),this.replaceChildren(...(this.#e??[]).map(a=>a.cloneNode(!0))),this.setAttribute("state","error"),this.#d(t,o,!0),this.#u(this.#n("error",t)),n&&this.#o?.focus()}}#u(t){let e=this.querySelector(":scope > [data-embed-live]");e||(e=document.createElement("span"),e.setAttribute("data-embed-live",""),e.setAttribute("role","status"),this.prepend(e)),e.textContent=t}};b("social-embed",E);export{u as PROVIDERS,E as SocialEmbed,l as createEmbedFrame,I as fetchOEmbed,D as loadScript};
|
|
1
|
+
var ft=window.matchMedia("(prefers-reduced-motion: reduce)");var E=new Map;function b(r,t,e={}){let s=e.priority??10,n={impl:t,bundle:e.bundle,contract:e.contract,priority:s},o=E.get(r);if(customElements.get(r)){if(!o||o.priority>=s){o&&o.priority===s&&o.impl!==t&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${o.bundle}" (priority ${o.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${r}> defined by "${o.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(o&&o.priority>=s){o.priority===s&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${o.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}E.set(r,n),customElements.define(r,t)}var f=class extends HTMLElement{#t=[];#e;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,s,n){t.addEventListener(e,s,n),this.#t.push(()=>t.removeEventListener(e,s,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,e){this.#e||(this.#e=this.attachInternals());let s=this.#e.states;try{e?s.add(t):s.delete(t)}catch{let n=`--${t}`;e?s.add(n):s.delete(n)}}_adoptInternals(t){this.#e||(this.#e=t)}#r(){return this.constructor.formAssociated&&this.#e?this.#e:null}get validity(){return this.#r()?.validity}get validationMessage(){return this.#r()?.validationMessage??""}get willValidate(){return this.#r()?.willValidate??!1}get form(){return this.#r()?.form??null}checkValidity(){return this.#r()?.checkValidity()??!0}reportValidity(){return this.#r()?.reportValidity()??!0}};var w=new Map;function D(r){let t=w.get(r);if(t)return t;let e=document.createElement("script"),s=new Promise((n,o)=>{e.src=r,e.async=!0,e.onload=()=>n(void 0),e.onerror=()=>{w.delete(r),e.remove(),o(new Error(`Failed to load script: ${r}`))},document.head.appendChild(e)});return w.set(r,s),s}async function z(r,t,e={}){let s=new URLSearchParams({url:t,format:"json",...e}),n=await fetch(`${r}?${s}`);if(!n.ok)throw new Error(`oEmbed error ${n.status}`);return n.json()}function c(r,t){let e;try{e=new URL(String(r??"").trim())}catch{return null}return e.protocol!=="https:"||e.username||e.password||e.port||t&&!t.has(e.hostname)?null:e}var S=new WeakMap,$=r=>S.get(r),j=5e3;function d(r){if(typeof r=="string")try{return JSON.parse(r)}catch{return null}return r&&typeof r=="object"?r:null}function x(r,t){let e=Number(t);!Number.isFinite(e)||e<=0||(r.height=String(Math.ceil(Math.min(e,j))))}function l({src:r,title:t,sandbox:e,allow:s="",height:n=400,measure:o,onload:i}){if(!(r instanceof URL)||r.protocol!=="https:")throw new Error("social-embed: embed frames must use an https URL");let a=document.createElement("iframe");return a.setAttribute("sandbox",e.join(" ")),a.setAttribute("referrerpolicy","strict-origin"),a.setAttribute("loading","lazy"),a.setAttribute("title",t),s&&a.setAttribute("allow",s),a.setAttribute("data-embed-frame",""),a.height=String(n),i&&a.addEventListener("load",()=>i(a)),a.src=r.href,S.set(a,{origin:r.origin,measure:o}),a}var m=Object.freeze(["allow-scripts","allow-same-origin","allow-popups","allow-popups-to-escape-sandbox"]),g=()=>String(crypto.getRandomValues(new Uint32Array(1))[0]);var V=new Set(["x.com","www.x.com","mobile.x.com","twitter.com","www.twitter.com","mobile.twitter.com"]),Z=/^\/([A-Za-z0-9_]{1,15})\/status(?:es)?\/(\d{1,25})\/?$/,T="platform.twitter.com";function k(r){let t=c(r,V),e=t&&Z.exec(t.pathname);return e?{user:e[1],id:e[2]}:null}var L={label:"X",themeable:!0,canHandle:r=>!!k(r),frameHost:()=>T,async render(r,t,{theme:e,title:s}){let n=k(t);if(!n)throw new Error("Not an X post URL");let o=new URL(`https://${T}/embed/Tweet.html`);return o.searchParams.set("id",n.id),o.searchParams.set("theme",e),o.searchParams.set("dnt","true"),l({src:o,title:s,sandbox:[...m],allow:"fullscreen",height:360,measure(i){let a=d(i)?.["twttr.embed"];return a?.method==="twttr.private.resize"?a.params?.[0]?.height:null}})}};var X=new Set(["instagram.com","www.instagram.com"]),Y=/^\/(?:[A-Za-z0-9_.]{1,30}\/)?(?:p|reel|tv)\/([A-Za-z0-9_-]{5,64})\/?$/,M="www.instagram.com";function H(r){let t=c(r,X),e=t&&Y.exec(t.pathname);return e?{id:e[1]}:null}var P={label:"Instagram",canHandle:r=>!!H(r),frameHost:()=>M,async render(r,t,{title:e}){let s=H(t);if(!s)throw new Error("Not an Instagram post URL");return l({src:new URL(`https://${M}/p/${s.id}/embed/`),title:e,sandbox:[...m],height:560,measure(n){let o=d(n);return o?.type==="MEASURE"?o.details?.height:null}})}};var W=new Set(["bsky.app"]),J=/^\/profile\/([^/]{1,253})\/post\/([A-Za-z0-9._~:-]{1,512})\/?$/,O=/^did:(?:plc:[a-z2-7]{24}|web:[A-Za-z0-9.-]{1,253})$/,G=/^(?=.{1,253}$)(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?\.)+[A-Za-z][A-Za-z0-9-]{0,62}$/,C="embed.bsky.app",K="https://public.api.bsky.app/xrpc/com.atproto.identity.resolveHandle";function _(r){let t=c(r,W),e=t&&J.exec(t.pathname);if(!e)return null;let s=decodeURIComponent(e[1]);return O.test(s)?{actor:s,did:s,rkey:e[2]}:G.test(s)?{actor:s,did:null,rkey:e[2]}:null}async function Q(r){let t=await fetch(`${K}?${new URLSearchParams({handle:r})}`);if(!t.ok)throw new Error(`Bluesky handle lookup failed (${t.status})`);let{did:e}=await t.json();if(typeof e!="string"||!O.test(e))throw new Error("Bluesky handle lookup returned no DID");return e}var U={label:"Bluesky",themeable:!0,canHandle:r=>!!_(r),frameHost:()=>C,async render(r,t,{theme:e,title:s}){let n=_(t);if(!n)throw new Error("Not a Bluesky post URL");let o=n.did??await Q(n.actor),i=g(),a=new URL(`https://${C}/embed/${o}/app.bsky.feed.post/${n.rkey}`);return a.searchParams.set("id",i),a.searchParams.set("colorMode",e),l({src:a,title:s,sandbox:[...m],height:320,measure(p){let h=d(p);return h?.id===i?h.height:null}})}};var N='<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>',tt={hq:"hqdefault",mq:"mqdefault",sd:"sddefault",maxres:"maxresdefault"},B="YouTube video",et="Play {title}",rt=/^\d+$/;function F(r){return String(r).replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t])}function st(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches||document.documentElement.hasAttribute("data-motion-reduced")}var y=class extends f{#t="";#e=B;setup(){let t=this.getAttribute("video-id");return this.#e=this.getAttribute("title")||B,t?/^[A-Za-z0-9_-]{6,20}$/.test(t)?(this.#t=t,this.hasAttribute("autoplay")&&!st()?this.#c(!1):this.#a(),!0):(console.warn(`youtube-player: invalid video-id ${JSON.stringify(t)}`),!1):(console.warn("youtube-player: missing required video-id attribute"),!1)}#r(t){let e=this.getAttribute(t);return e===null||e===""?null:rt.test(e.trim())?e.trim():(console.warn(`youtube-player: ${t} must be whole seconds, got ${JSON.stringify(e)}`),null)}#i(){let t=new URLSearchParams({autoplay:"1"}),e=this.#r("start");e&&t.set("start",e);let s=this.#r("end");s&&t.set("end",s);let n=this.getAttribute("list");n&&t.set("list",n);let o=this.getAttribute("params");return o&&new URLSearchParams(o).forEach((i,a)=>t.set(a,i)),`https://www.youtube-nocookie.com/embed/${this.#t}?${t}`}#s(t){return`https://i.ytimg.com/vi/${this.#t}/${tt[t]??"hqdefault"}.jpg`}#n(){return(this.getAttribute("data-label-play")||et).replace(/\{title\}/g,this.#e)}#a(){this.setAttribute("state","ready");let t=document.createElement("img");t.alt="",t.loading="lazy",t.decoding="async";let e=this.getAttribute("poster");if(e)t.src=e;else{let n=this.getAttribute("thumbnail")??"hq";if(t.referrerPolicy="no-referrer",t.src=this.#s(n),n==="sd"||n==="maxres"){let o=()=>{t.src=this.#s("hq")};t.addEventListener("error",o,{once:!0}),t.addEventListener("load",()=>{t.naturalWidth<=120&&o()},{once:!0})}}let s=document.createElement("button");s.type="button",s.setAttribute("aria-label",this.#n()),s.innerHTML=N,s.addEventListener("click",()=>this.#c(!0),{once:!0}),this.replaceChildren(t,s)}#c(t){this.setAttribute("state","active"),this.innerHTML=`<iframe src="${F(this.#i())}" title="${F(this.#e)}" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen loading="lazy"></iframe>`,t&&this.querySelector("iframe")?.focus(),this.dispatchEvent(new CustomEvent("youtube-player:activate",{bubbles:!0,detail:{videoId:this.#t,fromUser:t}}))}};b("youtube-player",y);var nt=new Set(["youtube.com","www.youtube.com","m.youtube.com","music.youtube.com","youtube-nocookie.com","www.youtube-nocookie.com","youtu.be"]),ot=/^[A-Za-z0-9_-]{11}$/;function it(r){if(!r)return null;if(/^\d+s?$/.test(r))return parseInt(r,10);let t=/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/.exec(r);return!t||!t[0]?null:+(t[1]||0)*3600+ +(t[2]||0)*60+ +(t[3]||0)}function q(r){let t=c(r,nt);if(!t)return null;let e=null;return t.hostname==="youtu.be"?e=t.pathname.slice(1).replace(/\/$/,""):t.pathname==="/watch"?e=t.searchParams.get("v"):e=/^\/(?:shorts|embed|live)\/([^/]+)\/?$/.exec(t.pathname)?.[1]??null,!e||!ot.test(e)?null:{id:e,start:it(t.searchParams.get("t")??t.searchParams.get("start"))}}var R={label:"YouTube",noun:"video",delegatesActivation:!0,canHandle:r=>!!q(r),frameHost:()=>"www.youtube-nocookie.com",async render(r,t,{title:e}){let s=q(t);if(!s)throw new Error("Could not parse YouTube video ID");let n=document.createElement("youtube-player");n.setAttribute("video-id",s.id),n.setAttribute("title",e.replace(/["<>]/g,"")),s.start&&n.setAttribute("start",String(s.start));let o=r.getAttribute("poster");return o&&n.setAttribute("poster",o),n}};var at=/^\/@([A-Za-z0-9_]{1,30})\/(\d{1,25})\/?$/;function A(r){let t=c(r,null);if(!t||!t.hostname.includes("."))return null;let e=at.exec(t.pathname);return e?{origin:t.origin,host:t.hostname,user:e[1],id:e[2]}:null}var I={label:"Mastodon",canHandle:r=>!!A(r),frameHost:r=>A(r)?.host??"",async render(r,t,{title:e}){let s=A(t);if(!s)throw new Error("Not a Mastodon post URL");let n=Number(g());return l({src:new URL(`${s.origin}/@${s.user}/${s.id}/embed`),title:e,sandbox:["allow-scripts","allow-same-origin","allow-popups"],allow:"fullscreen",height:320,onload(o){o.contentWindow?.postMessage({type:"setHeight",id:n},s.origin)},measure(o){let i=d(o);return i?.type==="setHeight"&&i.id===n?i.height:null}})}};var u=new Map;u.set("x",L);u.set("instagram",P);u.set("bluesky",U);u.set("youtube",R);u.set("mastodon",I);var ct={load:"Load {provider} {noun}",loading:"Loading {provider} {noun}\u2026",error:"{provider} {noun} failed to load.",note:"Loads content from {host}"};function lt(r,t){if(r==="light"||r==="dark")return r;let e=getComputedStyle(t).colorScheme||"";if(/\bdark\b/.test(e)&&!/\blight\b/.test(e))return"dark";if(/\blight\b/.test(e)&&!/\bdark\b/.test(e))return"light";let s=document.documentElement.dataset.mode;return s==="dark"||s==="light"?s:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var v=class r extends f{static register(t,e){u.set(t,e);for(let s of document.querySelectorAll('social-embed[state="unsupported"]'))s instanceof r&&s._reinit()}#t=null;#e=null;#r=null;#i="";#s=null;#n=null;#a=!1;setup(){this.#e||(this.#e=[...this.childNodes].filter(i=>!(i instanceof Element&&i.matches("[data-embed-live], [data-embed-facade]"))).map(i=>i.cloneNode(!0)));let t=this.getAttribute("url");if(!t)return console.warn("social-embed: missing required url attribute"),!1;let e=this.getAttribute("state");if(this.#r&&(e==="loaded"||e==="loading"))return this.#c(),!0;let s=this.getAttribute("provider"),n=s?u.get(s):[...u.values()].find(i=>i.canHandle?.(t));if(n&&s&&n.canHandle&&!n.canHandle(t)&&(n=void 0),this.#h(),!n)return this.setAttribute("state","unsupported"),!0;if(this.#i=s||[...u].find(([,i])=>i===n)?.[0]||"",n.delegatesActivation)return this.#l(n,!1),!0;this.setAttribute("state","idle"),this.#d(n,t);let o=this.getAttribute("activate")??"click";return o==="eager"?this.#l(n,!1):o==="visible"&&(this.#t=new IntersectionObserver(i=>{i.some(a=>a.isIntersecting)&&(this.#t?.disconnect(),this.#t=null,this.#l(n,!1))},{rootMargin:"200px"}),this.#t.observe(this)),!0}teardown(){this.#t?.disconnect(),this.#t=null,this.#s&&(clearTimeout(this.#s),this.#s=null),this.#a=!1}#c(){this.#a||(this.#a=!0,this.listen(window,"message",t=>{for(let e of this.querySelectorAll("iframe[data-embed-frame]")){let s=e,n=$(s);!n?.measure||t.source!==s.contentWindow||t.origin!==n.origin||x(s,n.measure(t.data))}}),this.listen(window,"vb:theme-change",()=>{this.#r?.themeable&&(this.#s&&clearTimeout(this.#s),this.#s=setTimeout(()=>{this.#s=null,this.#r?.themeable&&this.getAttribute("state")==="loaded"&&this.#l(this.#r,!1)},100))}))}#o(t,e,s={}){let n={provider:e.label??this.#i,noun:e.noun??"post",...s};return(this.getAttribute(`data-label-${t}`)??ct[t]).replace(/\{(\w+)\}/g,(i,a)=>a in n?n[a]:i)}#d(t,e,s=!1){this.#h();let n=document.createElement("p");n.setAttribute("data-embed-facade","");let o=document.createElement("button");o.type="button",o.setAttribute("data-embed-load",""),o.textContent=this.#o("load",t),o.addEventListener("click",()=>this.#l(t,!0));let i=document.createElement("small");i.setAttribute("data-embed-note","");let a="";try{a=t.frameHost?.(e)??""}catch{}i.textContent=s?this.#o("error",t):a?this.#o("note",t,{host:a}):"",n.append(o," ",i),this.append(n),this.#n=o}#h(){for(let t of this.querySelectorAll(":scope > [data-embed-facade]"))t.remove();this.#n=null}async#l(t,e){if(this.getAttribute("state")==="loading")return;let s=this.getAttribute("state")!=="loaded";this.#r=t,this.#c(),this.#t?.disconnect(),this.#t=null;let n=this.getAttribute("url"),o=e||this.contains(document.activeElement);this.setAttribute("state","loading"),this.#n&&(this.#n.setAttribute("aria-disabled","true"),this.#n.textContent=this.#o("loading",t)),s&&!t.delegatesActivation&&this.#u(this.#o("loading",t));try{let i=this.dataset.title||`${t.label??this.#i} ${t.noun??"post"}`,a=lt(this.getAttribute("theme")??"auto",this),p=await t.render(this,n,{theme:a,title:i});if(p instanceof Node&&this.replaceChildren(...[this.querySelector(":scope > [data-embed-live]")].filter(h=>!!h),p),this.#n=null,this.setAttribute("state","loaded"),s&&!t.delegatesActivation&&this.#u(""),o){let h=this.querySelector("iframe, youtube-player button");h?h.focus():(this.setAttribute("tabindex","-1"),this.focus())}}catch(i){console.warn("[social-embed] render failed:",i),this.replaceChildren(...(this.#e??[]).map(a=>a.cloneNode(!0))),this.setAttribute("state","error"),this.#d(t,n,!0),this.#u(this.#o("error",t)),o&&this.#n?.focus()}}#u(t){let e=this.querySelector(":scope > [data-embed-live]");e||(e=document.createElement("span"),e.setAttribute("data-embed-live",""),e.setAttribute("role","status"),this.prepend(e)),e.textContent=t}};b("social-embed",v);export{u as PROVIDERS,v as SocialEmbed,l as createEmbedFrame,z as fetchOEmbed,D as loadScript};
|
|
2
2
|
//# sourceMappingURL=social-embed.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var f=window.matchMedia("(prefers-reduced-motion: reduce)");var i=new Map;function c(t,o,r={}){let n=r.priority??10,a={impl:o,bundle:r.bundle,contract:r.contract,priority:n},e=i.get(t);if(customElements.get(t)){if(!e||e.priority>=n){e&&e.priority===n&&e.impl!==o&&console.warn(`[VB Bundle] Tag <${t}> already registered by "${e.bundle}" (priority ${e.priority}). Skipping "${r.bundle}".`);return}console.warn(`[VB Bundle] Tag <${t}> defined by "${e.bundle}" cannot be replaced (customElements.define is permanent). "${r.bundle}" has higher priority but arrived late.`);return}if(e&&e.priority>=n){e.priority===n&&console.warn(`[VB Bundle] Tag <${t}> already registered by "${e.bundle}". Skipping "${r.bundle}" (first wins at equal priority).`);return}i.set(t,a),customElements.define(t,o)}var s=class extends HTMLElement{static observedAttributes=["services","variant","color"]};c("social-links",s);export{s as SocialLinks};
|
|
2
|
+
//# sourceMappingURL=social-links.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var $=window.matchMedia("(prefers-reduced-motion: reduce)");var y=new Map;function m(i,t,e={}){let s=e.priority??10,r={impl:t,bundle:e.bundle,contract:e.contract,priority:s},n=y.get(i);if(customElements.get(i)){if(!n||n.priority>=s){n&&n.priority===s&&n.impl!==t&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${i}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=s){n.priority===s&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${n.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}y.set(i,r),customElements.define(i,t)}var u=class extends HTMLElement{#t=[];#i;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,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.#i||(this.#i=this.attachInternals());let s=this.#i.states;try{e?s.add(t):s.delete(t)}catch{let r=`--${t}`;e?s.add(r):s.delete(r)}}_adoptInternals(t){this.#i||(this.#i=t)}#s(){return this.constructor.formAssociated&&this.#i?this.#i:null}get validity(){return this.#s()?.validity}get validationMessage(){return this.#s()?.validationMessage??""}get willValidate(){return this.#s()?.willValidate??!1}get form(){return this.#s()?.form??null}checkValidity(){return this.#s()?.checkValidity()??!0}reportValidity(){return this.#s()?.reportValidity()??!0}};function w(){let i=globalThis.localStorage;if(!i)throw new Error("VBStore: localStorage is not available in this environment");return{async getRaw(t){return i.getItem(t)},async setRaw(t,e){i.setItem(t,e)},async removeRaw(t){i.removeItem(t)},async keys(t){let e=[];for(let s=0;s<i.length;s++){let r=i.key(s);r&&r.startsWith(t)&&e.push(r)}return e}}}var d="__vbStoreBackend",h=globalThis;function a(){return h[d]||(h[d]=w()),h[d]}function f(i,t){if(typeof i!="string"||!i)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:${i}:${t}`}function v(i){if(typeof i!="string"||!i)throw new TypeError("VBStore: namespace must be a non-empty string");return`vb:${i}:`}function g(i){try{let t=JSON.parse(i);if(t&&typeof t=="object"&&typeof t.timestamp=="number")return t}catch{}return null}var l={configure(i={}){h[d]=i.backend??null},async set(i,t,e){let s={data:e,timestamp:Date.now()};await a().setRaw(f(i,t),JSON.stringify(s))},async get(i,t,e){let s=await a().getRaw(f(i,t));if(s==null)return null;let r=g(s);return!r||e?.maxAge!=null&&Date.now()-r.timestamp>e.maxAge?null:r.data},async remove(i,t){await a().removeRaw(f(i,t))},async list(i){let t=v(i),e=await a().keys(t),s=[];for(let r of e){let n=await a().getRaw(r);if(n==null)continue;let o=g(n);o&&s.push({key:r.slice(t.length),data:o.data,timestamp:o.timestamp})}return s},async clear(i){let t=v(i),e=await a().keys(t);for(let s of e)await a().removeRaw(s)},async clearAll(){let i=await a().keys("vb:");for(let t of i)await a().removeRaw(t)},async setMany(i,t){for(let[e,s]of t)await l.set(i,e,s)}};if(typeof window<"u"){let i=window.VB??(window.VB={});i.store??=l}var E=0;function p(i,t){if(i===null||i.trim()==="")return t;let e=Number(i);return Number.isFinite(e)?e:t}var b=class extends u{static observedAttributes=["position","min","max","direction","collapsible","data-label-resize","data-label-collapsed"];#t=null;#i;#s;#r=50;#e=!1;#a=50;#b=!1;#n={};#y=0;get#u(){return this.getAttribute("direction")==="vertical"}get#A(){return getComputedStyle(this).direction==="rtl"}get#m(){return p(this.getAttribute("min"),10)}get#v(){return p(this.getAttribute("max"),90)}get#d(){return this.hasAttribute("collapsible")}get#h(){return p(this.getAttribute("position"),50)}get position(){return this.#t?this.#r:this.#n.position??this.#r}set position(t){let e=Number(t);if(Number.isFinite(e)){if(!this.#t){this.#n.position=e,delete this.#n.reset;return}this.#e&&this.#c(),this.#o(e,"api")}}get collapsed(){return this.#t?this.#e:this.#n.collapsed??this.#e}set collapsed(t){if(!this.#t){this.#n.collapsed=!!t;return}t?this.#E("api"):this.#f("api")}reset(){if(!this.#t){this.#n={reset:!0},this.#C();return}this.#e&&this.#c(),this.#o(this.#h,"api"),this.#C()}setup(){for(let e of this.querySelectorAll(":scope > .split-divider"))e.remove();let t=[...this.children].filter(e=>!e.classList.contains("split-divider"));return t.length<2?!1:(this.#i=t[0],this.#s=t[1],this.#x(++this.#y),!0)}async#x(t){let e=null;if(this.#b||(e=await this.#L()),t!==this.#y||!this.isConnected)return!1;let s=this.#i,r=document.createElement("div");r.className="split-divider",r.setAttribute("role","separator"),s.id||(s.id=`vb-split-panel-${++E}`),r.setAttribute("aria-controls",s.id),r.setAttribute("tabindex","0"),this.#t=r,this.#S(),this.insertBefore(r,this.#s),this.listen(r,"pointerdown",this.#P),this.listen(r,"keydown",this.#B),this.listen(r,"dblclick",this.#M);let n=this.#e?this.#a:this.#r,o=this.#e;this.#b||(n=e?.position??this.#h,o=!!e?.collapsed&&this.#d);let c=this.#n;return this.#n={},c.reset&&(n=this.#h,o=!1),c.position!==void 0&&(n=c.position,o=!1),c.collapsed!==void 0&&(o=c.collapsed),this.#b=!0,this.#c(),o?(this.#a=this.#g(n),this.#$()):this.#o(n,null),!0}teardown(){this.#y++,this.#t&&(this.#t.remove(),this.#t=null)}attributeChangedCallback(t,e,s){if(!(e===s||!this.#t)){if(t==="position"){this.#e?this.#a=this.#g(this.#h):this.#o(this.#h,"attribute");return}t==="collapsible"&&!this.#d&&this.#e&&this.#f("attribute"),this.#S(),!this.#e&&(t==="min"||t==="max")&&this.#o(this.#r,"attribute")}}#g(t){return Math.min(this.#v,Math.max(this.#m,t))}#S(){let t=this.#t;t&&(t.setAttribute("aria-orientation",this.#u?"horizontal":"vertical"),t.setAttribute("aria-valuemin",String(this.#d?0:this.#m)),t.setAttribute("aria-valuemax",String(this.#v)),t.setAttribute("aria-label",this.getAttribute("data-label-resize")||"Resize panels"),this.#w())}#w(){let t=this.#t;if(!t)return;let e=Math.round(this.#r);t.setAttribute("aria-valuenow",String(e)),t.setAttribute("aria-valuetext",this.#e?this.getAttribute("data-label-collapsed")||"Collapsed":`${e}%`)}#P=t=>{if(t.button!==0)return;t.preventDefault();let e=this.#t;this.setState("divider-dragging",!0);try{e.setPointerCapture(t.pointerId)}catch{}e.addEventListener("pointermove",this.#k),e.addEventListener("pointerup",this.#l),e.addEventListener("pointercancel",this.#l),e.addEventListener("lostpointercapture",this.#l)};#k=t=>{if(!this.matches(":state(divider-dragging)"))return;let e=this.getBoundingClientRect(),s;this.#u?s=(t.clientY-e.top)/e.height*100:s=(this.#A?e.right-t.clientX:t.clientX-e.left)/e.width*100,this.#e&&this.#c(),this.#o(s,"pointer")};#l=t=>{if(!this.#t)return;let e=this.matches(":state(divider-dragging)");this.setState("divider-dragging",!1),this.#t.hasPointerCapture(t.pointerId)&&this.#t.releasePointerCapture(t.pointerId),this.#t.removeEventListener("pointermove",this.#k),this.#t.removeEventListener("pointerup",this.#l),this.#t.removeEventListener("pointercancel",this.#l),this.#t.removeEventListener("lostpointercapture",this.#l),e&&this.#p()};#B=t=>{if(t.key==="Enter"){if(!this.#d)return;t.preventDefault(),this.#e?this.#f("keyboard"):this.#E("keyboard"),this.#p();return}let e=t.shiftKey?10:1,s=!this.#u&&this.#A,r=this.#u?"ArrowUp":s?"ArrowRight":"ArrowLeft",n=this.#u?"ArrowDown":s?"ArrowLeft":"ArrowRight",o=null;t.key===r?o=this.#r-e:t.key===n?o=this.#r+e:t.key==="Home"?o=this.#m:t.key==="End"&&(o=this.#v),o!==null&&(t.preventDefault(),this.#e&&(this.#c(),this.dispatchEvent(new CustomEvent("split-surface:collapse",{detail:{collapsed:!1,source:"keyboard"},bubbles:!0}))),this.#o(o,"keyboard"),this.#p())};#M=()=>{this.#d&&(this.#e?this.#f("pointer"):this.#E("pointer"),this.#p())};#E(t){this.#e||!this.#t||(this.#a=this.#r,this.#$(),this.dispatchEvent(new CustomEvent("split-surface:collapse",{detail:{collapsed:!0,source:t},bubbles:!0})))}#$(){let t=this.#i;this.#e=!0,this.#r=0,t.style.flexBasis="0%",t.style.flexGrow="0",t.style.flexShrink="0",t.style.overflow="hidden",t.inert=!0,this.setState("collapsed",!0),this.#w()}#c(){this.#e=!1,this.#i&&(this.#i.inert=!1),this.setState("collapsed",!1)}#f(t){!this.#e||!this.#t||(this.#c(),this.#o(this.#a,null),this.dispatchEvent(new CustomEvent("split-surface:collapse",{detail:{collapsed:!1,source:t},bubbles:!0})))}#o(t,e){if(!Number.isFinite(t)||!this.#i||!this.#s)return;let s=this.#g(t);this.#r=s,this.#i.style.flexBasis=`${s}%`,this.#i.style.flexGrow="0",this.#i.style.flexShrink="0",this.#i.style.overflow="auto",this.#s.style.flexGrow="1",this.#s.style.overflow="auto",this.#w(),e!==null&&this.dispatchEvent(new CustomEvent("split-surface:resize",{detail:{position:s,source:e},bubbles:!0}))}async#L(){let t=this.getAttribute("persist");if(!t)return null;try{let e=await l.get("layout",`split:${t}`);if(e&&typeof e=="object"&&typeof e.position=="number")return e}catch{}return null}#p(){let t=this.getAttribute("persist");if(!t)return;let e=this.#e?{position:Math.round(this.#a),collapsed:!0}:{position:Math.round(this.#r),collapsed:!1};l.set("layout",`split:${t}`,e).catch(()=>{})}#C(){let t=this.getAttribute("persist");t&&l.remove("layout",`split:${t}`).catch(()=>{})}};m("split-surface",b);export{b as SplitSurface};
|
|
2
2
|
//# sourceMappingURL=split-surface.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var k=window.matchMedia("(prefers-reduced-motion: reduce)");var g=new Map;function v(a,t,e={}){let r=e.priority??10,i={impl:t,bundle:e.bundle,contract:e.contract,priority:r},n=g.get(a);if(customElements.get(a)){if(!n||n.priority>=r){n&&n.priority===r&&n.impl!==t&&console.warn(`[VB Bundle] Tag <${a}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${a}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=r){n.priority===r&&console.warn(`[VB Bundle] Tag <${a}> already registered by "${n.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}g.set(a,i),customElements.define(a,t)}var p=class extends HTMLElement{#r=[];#e;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#r)t();this.#r=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,r,i){t.addEventListener(e,r,i),this.#r.push(()=>t.removeEventListener(e,r,i))}_reinit(){for(let t of this.#r)t();this.#r=[],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 r=this.#e.states;try{e?r.add(t):r.delete(t)}catch{let i=`--${t}`;e?r.add(i):r.delete(i)}}_adoptInternals(t){this.#e||(this.#e=t)}#t(){return this.constructor.formAssociated&&this.#e?this.#e:null}get validity(){return this.#t()?.validity}get validationMessage(){return this.#t()?.validationMessage??""}get willValidate(){return this.#t()?.willValidate??!1}get form(){return this.#t()?.form??null}checkValidity(){return this.#t()?.checkValidity()??!0}reportValidity(){return this.#t()?.reportValidity()??!0}};var A="_star-rating-detached",E=new Set(["max","label","readonly","allow-half","icon","data-label-one","data-label-other","data-label-readonly","data-label-cleared"]),m={one:"{n} star",other:"{n} stars",readonly:"{label}: {value} out of {max}",required:"Please select a rating"},w=0;function d(a){let t=Number(a);return Number.isFinite(t)&&t>0?t:0}var y=class extends p{static formAssociated=!0;static get observedAttributes(){return["value","required",...E]}#r;#e=0;#t=null;#n=null;#l=0;#h=`_sr_${++w}`;constructor(){super(),this.#r=this.attachInternals(),this._adoptInternals(this.#r)}setup(){let t=this.querySelector(":scope > fieldset[data-rating]");if(!t||t!==this.#t){if(t){let r=t.querySelector("input:checked");r&&(this.#n??=d(r.value)),t.remove()}this.#f()}let e=this.#t;e&&!this.#i()&&(this.listen(e,"rating:change",()=>this.#s()),this.listen(e,"change",r=>{let i=r.target;i.type==="radio"&&i.checked&&this.#s()})),this.#s()}attributeChangedCallback(t,e,r){e!==r&&(t==="value"&&(this.#e=d(r)),this.#t&&(t==="value"?this.value=d(r):t==="required"?this.#u():this.#c(this.value)))}#i(){return this.hasAttribute("readonly")}#f(){this.#e=d(this.getAttribute("value"));let t=this.#n??this.#e;this.#n=null;let e=Math.max(1,Math.round(d(this.getAttribute("max"))||5)),r=this.getAttribute("label")||"Rating",i=this.getAttribute("icon");this.#i()?(this.#l=t,this.#p(t,e,r,i)):this.#b(t,e,r,this.hasAttribute("allow-half"),i)}#c(t){this.#t?.remove(),this.#t=null,this.#n=t,this.hasAttribute("data-upgraded")&&this._reinit()}#b(t,e,r,i,n){let l=document.createElement("fieldset");l.setAttribute("data-rating",""),i&&l.setAttribute("data-rating-half",""),l.setAttribute("data-effect","rating");let b=this.getAttribute("data-label-cleared");b&&l.setAttribute("data-label-cleared",b);let h=document.createElement("legend");h.textContent=r,l.appendChild(h);let f=(s,o)=>{let c=document.createElement("label");o&&c.setAttribute("data-half",o);let u=document.createElement("input");u.type="radio",u.name=this.#h,u.setAttribute("form",A),u.value=String(s),u.setAttribute("aria-label",this.#m(s)),t===s&&(u.checked=!0),c.appendChild(u),c.append(this.#a(n)),l.appendChild(c)};for(let s=1;s<=e;s++)i?(f(s-.5,"left"),f(s,"right")):f(s,null);this.appendChild(l),this.#t=l}#p(t,e,r,i){let n=document.createElement("fieldset");n.setAttribute("data-rating",""),n.setAttribute("data-rating-readonly",""),n.setAttribute("role","img");let l=this.getAttribute("data-label-readonly")??m.readonly;n.setAttribute("aria-label",l.replaceAll("{label}",r).replaceAll("{value}",this.#o(t)).replaceAll("{max}",this.#o(e)));let b=document.createElement("legend");b.textContent=r,n.appendChild(b);let h=Math.floor(t),f=t-h;for(let s=1;s<=e;s++){let o=document.createElement("span");if(o.setAttribute("aria-hidden","true"),s<=h)o.classList.add("star-filled");else if(s===h+1&&f>0){o.classList.add("star-partial"),o.style.setProperty("--_star-fill",`${f*100}%`);let c=document.createElement("span");c.classList.add("star-partial-fill"),c.append(this.#a(i)),o.appendChild(c)}else o.classList.add("star-empty");o.append(this.#a(i)),n.appendChild(o)}this.appendChild(n),this.#t=n}#a(t){if(t){let e=document.createElement("icon-wc");return e.setAttribute("name",t),e}return document.createTextNode("\u2605")}#d(){return this.closest("[lang]")?.lang||void 0}#o(t){try{return new Intl.NumberFormat(this.#d()).format(t)}catch{return String(t)}}#m(t){let e="other";try{e=new Intl.PluralRules(this.#d()).select(t)}catch{}return(this.getAttribute(`data-label-${e}`)??this.getAttribute("data-label-other")??(e==="one"?m.one:m.other)).replaceAll("{n}",this.#o(t))}#s(){let t=this.value;this.#r.setFormValue(t>0?String(t):null),this.#u()}#u(){let t=this.#t;if(this.hasAttribute("required")&&!this.#i()&&t&&!t.querySelector('input[type="radio"]:checked')){let e=t.querySelector('input[type="radio"]');this.#r.setValidity({valueMissing:!0},this.getAttribute("data-label-required")||m.required,e||t)}else this.#r.setValidity({})}#y(t){let e=this.#t;if(e)for(let r of e.querySelectorAll('input[type="radio"]'))r.checked=t>0&&Number(r.value)===t}formResetCallback(){this.value=this.#e}formStateRestoreCallback(t){typeof t=="string"&&(this.value=d(t))}get value(){let t=this.#t;if(!t)return this.#n??d(this.getAttribute("value"));if(this.#i())return this.#l;let e=t.querySelector('input[type="radio"]:checked');return e?Number(e.value):0}set value(t){let e=d(t);if(!this.#t){this.#n=e;return}if(this.value!==e){if(this.#i()){this.#c(e);return}this.#y(e),this.#s()}}};v("star-rating",y);export{y as StarRating};
|
|
2
2
|
//# sourceMappingURL=star-rating.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var b=window.matchMedia("(prefers-reduced-motion: reduce)");var d=new Map;function c(i,t,r={}){let e=r.priority??10,n={impl:t,bundle:r.bundle,contract:r.contract,priority:e},s=d.get(i);if(customElements.get(i)){if(!s||s.priority>=e){s&&s.priority===e&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${r.bundle}".`);return}console.warn(`[VB Bundle] Tag <${i}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${r.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=e){s.priority===e&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${s.bundle}". Skipping "${r.bundle}" (first wins at equal priority).`);return}d.set(i,n),customElements.define(i,t)}var o=class extends HTMLElement{#r=[];#t;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#r)t();this.#r=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,r,e,n){t.addEventListener(r,e,n),this.#r.push(()=>t.removeEventListener(r,e,n))}_reinit(){for(let t of this.#r)t();this.#r=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,r){this.#t||(this.#t=this.attachInternals());let e=this.#t.states;try{r?e.add(t):e.delete(t)}catch{let n=`--${t}`;r?e.add(n):e.delete(n)}}_adoptInternals(t){this.#t||(this.#t=t)}#e(){return this.constructor.formAssociated&&this.#t?this.#t:null}get validity(){return this.#e()?.validity}get validationMessage(){return this.#e()?.validationMessage??""}get willValidate(){return this.#e()?.willValidate??!1}get form(){return this.#e()?.form??null}checkValidity(){return this.#e()?.checkValidity()??!0}reportValidity(){return this.#e()?.reportValidity()??!0}};var u={live:"Live",recording:"Recording",streaming:"Streaming",error:"Error",online:"Online",running:"Running",away:"Away",paused:"Paused",busy:"Busy",offline:"Offline",stopped:"Stopped"},a=class extends o{static get observedAttributes(){return["data-variant","data-live","aria-label"]}#r=null;#t=null;#e=!1;setup(){let t=this.querySelector(":scope > .status-dot"),r=this.querySelector(":scope > .status-label"),e=this.querySelector(":scope > .status-default-label");t||(t=document.createElement("span"),t.className="status-dot",t.setAttribute("aria-hidden","true")),r||(r=document.createElement("span"),r.className="status-label"),e||(e=document.createElement("span"),e.className="status-default-label");for(let n of[...this.childNodes])n===t||n===r||n===e||r.appendChild(n);this.append(t,r,e),this.#r=r,this.#t=e,this.#s(),this.#n()}attributeChangedCallback(t,r,e){r!==e&&(!this.isConnected||!this.hasAttribute("data-upgraded")||(t==="data-variant"?(this.#n(),this.dispatchEvent(new CustomEvent("status-wc:change",{bubbles:!0,detail:{variant:e,previousVariant:r}}))):t==="data-live"?this.#s():t==="aria-label"&&this.#n()))}#s(){this.getAttribute("data-live")==="off"?this.#e&&(this.removeAttribute("role"),this.removeAttribute("aria-live"),this.#e=!1):!this.hasAttribute("role")&&!this.hasAttribute("aria-live")&&(this.setAttribute("role","status"),this.setAttribute("aria-live","polite"),this.#e=!0)}#n(){let t=this.#t;if(!t)return;let r=!!this.#r?.textContent?.trim(),e="";if(!r){let n=this.getAttribute("data-variant")||"";e=this.getAttribute("aria-label")||n&&this.getAttribute(`data-label-${n}`)||u[n]||n}t.textContent!==e&&(t.textContent=e)}get variant(){return this.getAttribute("data-variant")}set variant(t){t?this.setAttribute("data-variant",t):this.removeAttribute("data-variant")}};c("status-wc",a);export{a as StatusWc};
|
|
2
2
|
//# sourceMappingURL=status-wc.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var I=window.matchMedia("(prefers-reduced-motion: reduce)");var m=new Map;function b(n,t,e={}){let i=e.priority??10,s={impl:t,bundle:e.bundle,contract:e.contract,priority:i},r=m.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}m.set(n,s),customElements.define(n,t)}var l=class extends HTMLElement{#n=[];#e;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#n)t();this.#n=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,s){t.addEventListener(e,i,s),this.#n.push(()=>t.removeEventListener(e,i,s))}_reinit(){for(let t of this.#n)t();this.#n=[],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)}#s(){return this.constructor.formAssociated&&this.#e?this.#e:null}get validity(){return this.#s()?.validity}get validationMessage(){return this.#s()?.validationMessage??""}get willValidate(){return this.#s()?.willValidate??!1}get form(){return this.#s()?.form??null}checkValidity(){return this.#s()?.checkValidity()??!0}reportValidity(){return this.#s()?.reportValidity()??!0}};var y='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><line x1="5" y1="12" x2="19" y2="12"/></svg>',v='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>';function x(n){if(!n)return[];let t=n.trim();if(t.startsWith("["))try{return JSON.parse(t).map(i=>({value:String(i.value),label:String(i.label??i.value)}))}catch{return[]}return t.split(",").map(e=>{let i=e.trim();return{value:i,label:i}})}function A(n){return n?n.split(",").map(t=>t.trim()).filter(Boolean):[]}function w(n){let t=Math.max(0,Math.round(n)),e=Math.floor(t/3600),i=Math.floor(t%3600/60),s=t%60,r=a=>String(a).padStart(2,"0");return e>0?`${e}:${r(i)}:${r(s)}`:`${i}:${r(s)}`}function S(n,t){let e=Number(n)||0,i=["B","KB","MB","GB","TB","PB"],s=0,r=Math.abs(e);for(;r>=1e3&&s<i.length-1;)r/=1e3,s+=1;let a=new Intl.NumberFormat(t,{minimumFractionDigits:s===0?0:1,maximumFractionDigits:s===0?0:2});return`${e<0?"-":""}${a.format(r)} ${i[s]}`}function k(){return document.documentElement.lang||void 0}function c(n){let t=String(n),e=t.indexOf(".");return e<0?0:t.length-e-1}var p=!1,N=0,f=class extends l{static formAssociated=!0;static observedAttributes=["value","disabled","readonly","aria-label","aria-labelledby","data-label-decrease","data-label-increase"];#n;#e;#s=-1/0;#a=1/0;#p=1;#h=[];#r=[];#o;#F;#c="";#B=!1;#T=!1;#g;#i;#V;#L=!1;#_=!1;#t;#y;#x;#u;#l;#I;#A=0;#v=0;#M=!1;#w=!1;constructor(){super(),this.#n=this.attachInternals(),this._adoptInternals(this.#n)}setup(){this.#G(),this.#z(),this.#J();let t=this.getAttribute("value");this.#L||(this.#V=t,this.#L=!0),this.#d(t??this.#k(),"init"),this.#S(),requestAnimationFrame(()=>{this.isConnected&&this.#S()}),this.listen(this.#t,"focus",()=>this.#S()),this.listen(this,"click",e=>{e.target===this&&!this.#C()&&this.#t.focus()})}teardown(){this.#E(),this.#w=!1}attributeChangedCallback(t,e,i){!this.isConnected||!this.#t||(t==="value"?this.#d(i??this.#k(),"attr"):t==="disabled"||t==="readonly"?this.#$():t==="aria-label"||t==="aria-labelledby"?this.#S():this.#q())}#S(){let t=[],e=[];try{e=[...this.#n.labels||[]]}catch{}for(let a of e)a.id||(a.id=`stepper-wc-label-${++N}`),t.push(a.id);let i=(this.getAttribute("aria-labelledby")||"").trim();i&&t.push(...i.split(/\s+/));let s=[...new Set(t)];s.length?this.#t.setAttribute("aria-labelledby",s.join(" ")):this.#t.removeAttribute("aria-labelledby");let r=this.getAttribute("aria-label");r?this.#t.setAttribute("aria-label",r):this.#t.removeAttribute("aria-label")}#q(){this.#u.setAttribute("aria-label",this.getAttribute("data-label-decrease")||"Decrease"),this.#l.setAttribute("aria-label",this.getAttribute("data-label-increase")||"Increase")}#G(){if(this.hasAttribute("data-options"))this.#e="enum";else if(this.hasAttribute("data-values"))this.#e="token";else if(this.hasAttribute("data-format")||this.hasAttribute("data-suffix"))this.#e="formatted";else{if(this.#e="numeric",p)return;p=!0,console.info('[stepper-wc] No mode attribute set. Plain numeric stepping is better served by `<input type="number" data-stepper>`. See /docs/interaction/numeric-inputs/')}}#z(){this.#s=this.hasAttribute("data-min")?Number(this.getAttribute("data-min")):-1/0,this.#a=this.hasAttribute("data-max")?Number(this.getAttribute("data-max")):1/0,this.#p=Number(this.getAttribute("data-step"))||1,this.#h=A(this.getAttribute("data-values")),this.#r=x(this.getAttribute("data-options")),this.#o=this.getAttribute("data-format")||(this.hasAttribute("data-suffix")?"number":null),this.#F=this.getAttribute("data-currency")||"USD",this.#c=this.getAttribute("data-suffix")||"",this.#B=this.hasAttribute("data-show-label"),this.#T=this.hasAttribute("data-accelerate"),this.#g=k(),this.#I=this.#K()}#K(){if(!this.#o)return null;let t=c(this.#p);return this.#o==="number"?new Intl.NumberFormat(this.#g,{minimumFractionDigits:t,maximumFractionDigits:t}):this.#o==="currency"?new Intl.NumberFormat(this.#g,{style:"currency",currency:this.#F}):this.#o==="percent"?new Intl.NumberFormat(this.#g,{style:"percent",minimumFractionDigits:t,maximumFractionDigits:t}):null}#k(){return this.#e==="enum"?this.#r[0]?.value??"":this.#e==="token"?this.#h[0]??"":"0"}#J(){this.replaceChildren(),this.#u=document.createElement("button"),this.#u.type="button",this.#u.className="stepper-dec",this.#u.setAttribute("tabindex","-1"),this.#u.innerHTML=y,this.#l=document.createElement("button"),this.#l.type="button",this.#l.className="stepper-inc",this.#l.setAttribute("tabindex","-1"),this.#l.innerHTML=v,this.#t=document.createElement("span"),this.#t.className="stepper-value",this.#t.setAttribute("role","spinbutton"),this.#t.setAttribute("tabindex","0"),this.#y=document.createElement("span"),this.#y.className="stepper-value-display",this.#t.appendChild(this.#y),this.#x=new Set;for(let t of this.#P())this.#D(t);this.appendChild(this.#u),this.appendChild(this.#t),this.appendChild(this.#l),this.#O(this.#u,-1),this.#O(this.#l,1),this.listen(this.#t,"keydown",this.#W),this.#q(),this.#$()}#O(t,e){if(this.listen(t,"click",s=>{if(this.#w){this.#w=!1,s.preventDefault();return}this.#f(e,1)}),!this.#T)return;this.listen(t,"pointerdown",s=>{let r=s;r.pointerType==="mouse"&&r.button!==0||this.#b()||(this.#M=!1,this.#A=window.setTimeout(()=>{this.#M=!0,this.#v=window.setInterval(()=>this.#f(e,1),100),this.#A=window.setTimeout(()=>{window.clearInterval(this.#v),this.#v=window.setInterval(()=>this.#f(e,5),50)},1e3)},500))});let i=()=>{this.#E(),this.#M&&(this.#w=!0)};this.listen(t,"pointerup",i),this.listen(t,"pointerleave",i),this.listen(t,"pointercancel",i)}#E(){window.clearTimeout(this.#A),window.clearInterval(this.#v),this.#A=0,this.#v=0}#W=t=>{if(this.#b())return;let e=getComputedStyle(this).direction==="rtl";switch(e&&t.key==="ArrowLeft"?"ArrowRight":e&&t.key==="ArrowRight"?"ArrowLeft":t.key){case"ArrowUp":case"ArrowRight":t.preventDefault(),this.#f(1,1);break;case"ArrowDown":case"ArrowLeft":t.preventDefault(),this.#f(-1,1);break;case"PageUp":t.preventDefault(),this.#f(1,10);break;case"PageDown":t.preventDefault(),this.#f(-1,10);break;case"Home":t.preventDefault(),this.#H("min");break;case"End":t.preventDefault(),this.#H("max");break;default:}};#C(){return this.hasAttribute("disabled")||this.#_}#b(){return this.#C()||this.hasAttribute("readonly")}#$(){let t=this.#C();this.#t.setAttribute("aria-disabled",String(t)),this.hasAttribute("readonly")?this.#t.setAttribute("aria-readonly","true"):this.#t.removeAttribute("aria-readonly"),t?(this.#t.removeAttribute("tabindex"),this.#E()):this.#t.setAttribute("tabindex","0"),this.#i!==void 0?this.#R():(this.#u.disabled=this.#b(),this.#l.disabled=this.#b())}#f(t,e){if(this.#b())return;let i=this.#Q(t,e);i===null||i===this.#i||this.#d(i,"step")}#H(t){if(this.#e==="enum"){let i=t==="min"?0:this.#r.length-1;this.#d(this.#r[i]?.value,"step");return}if(this.#e==="token"){let i=t==="min"?0:this.#h.length-1;this.#d(this.#h[i],"step");return}let e=t==="min"?this.#s===-1/0?this.#i:this.#s:this.#a===1/0?this.#i:this.#a;this.#d(String(e),"step")}#Q(t,e){if(this.#e==="enum"){let h=this.#r.findIndex(g=>g.value===this.#i),o=h===-1?0:h,d=Math.min(this.#r.length-1,Math.max(0,o+t*e));return this.#r[d]?.value}if(this.#e==="token"){let o=this.#N(this.#i);o===-1&&(o=this.#X(this.#i));let d=Math.min(this.#h.length-1,Math.max(0,o+t*e));return this.#h[d]}let i=Number(this.#i)||0,s=c(this.#p),r=i+t*this.#p*e,a=Number(r.toFixed(s)),u=Math.min(this.#a,Math.max(this.#s,a));return String(u)}#N(t){if(t==null)return-1;let e=this.#h.indexOf(String(t));if(e!==-1)return e;let i=Number(t);if(Number.isFinite(i)){let s=this.#h.findIndex(r=>Number(r)===i);if(s!==-1)return s}return-1}#X(t){let e=Number(t);if(!Number.isFinite(e))return 0;let i=0,s=1/0;return this.#h.forEach((r,a)=>{let u=Number(r);if(!Number.isFinite(u))return;let h=Math.abs(u-e);h<s&&(s=h,i=a)}),i}#d(t,e){let i=this.#Y(t),s=i!==this.#i;this.#i=i,this.getAttribute("value")!==String(i)&&this.setAttribute("value",String(i)),this.#Z(),this.#tt(),this.#R(),this.#et(),this.#it(),s&&e!=="init"&&(this.dispatchEvent(new Event("input",{bubbles:!0})),this.dispatchEvent(new Event("change",{bubbles:!0})))}#Y(t){if(t==null)return this.#k();if(this.#e==="enum"){let s=String(t);return this.#r.find(a=>a.value===s)?s:this.#r[0]?.value??""}if(this.#e==="token")return String(t);let e=Number(t);if(!Number.isFinite(e))return String(this.#s===-1/0?0:this.#s);let i=c(this.#p);return String(Number(Math.min(this.#a,Math.max(this.#s,e)).toFixed(i)))}#Z(){let t=this.#m();this.#y.textContent=t,this.#D(t)}#m(t=this.#i){if(this.#e==="enum")return this.#r.find(i=>i.value===t)?.label??t??"";if(this.#e==="token"){let e=this.#B?String(t).replace(/^--/,""):String(t);return this.#c?`${e}${this.#c}`:e}if(this.#e==="formatted"){let e=Number(t)||0;if(this.#o==="duration")return w(e);if(this.#o==="bytes")return S(e,this.#g);if(this.#I){let i=this.#o==="percent"?e/100:e,s=this.#I.format(i);return this.#c&&this.#o==="number"?`${s}${this.#c}`:s}return this.#c?`${e}${this.#c}`:String(e)}return String(t??"")}#P(){if(this.#e==="enum")return this.#r.map(i=>this.#m(i.value));if(this.#e==="token")return this.#h.map(i=>this.#m(i));let t=new Set,e=i=>{Number.isFinite(i)&&t.add(i)};if(this.#s!==-1/0&&e(this.#s),this.#a!==1/0&&e(this.#a),e(Number(this.getAttribute("value"))||0),this.#a===1/0){let i=[10,100,1e3,1e4];for(let s of i)e(s);if(this.#o==="bytes")for(let s of[999,999e3,999e6,999e9])e(s)}return[...t].map(i=>this.#m(String(i)))}#D(t){let e=String(t??"");if(!e||this.#x.has(e))return;this.#x.add(e);let i=document.createElement("span");i.className="stepper-value-reserve",i.setAttribute("aria-hidden","true"),i.textContent=e,this.#t.appendChild(i)}recomputeWidth(){if(this.#t){this.#t.querySelectorAll(".stepper-value-reserve").forEach(t=>t.remove()),this.#x=new Set;for(let t of this.#P())this.#D(t)}}#tt(){if(this.#e==="enum"){let e=this.#r.findIndex(i=>i.value===this.#i);this.#t.setAttribute("aria-valuemin","1"),this.#t.setAttribute("aria-valuemax",String(this.#r.length)),this.#t.setAttribute("aria-valuenow",String((e===-1?0:e)+1)),this.#t.setAttribute("aria-valuetext",this.#m());return}if(this.#e==="token"){let e=this.#N(this.#i);this.#t.setAttribute("aria-valuemin","1"),this.#t.setAttribute("aria-valuemax",String(this.#h.length)),this.#t.setAttribute("aria-valuenow",String((e===-1?0:e)+1)),this.#t.setAttribute("aria-valuetext",this.#m());return}let t=Number(this.#i)||0;this.#s!==-1/0?this.#t.setAttribute("aria-valuemin",String(this.#s)):this.#t.removeAttribute("aria-valuemin"),this.#a!==1/0?this.#t.setAttribute("aria-valuemax",String(this.#a)):this.#t.removeAttribute("aria-valuemax"),this.#t.setAttribute("aria-valuenow",String(t)),this.#t.setAttribute("aria-valuetext",this.#m())}#R(){let t=this.#j(),e=this.#U(),i=this.#b();this.#u.disabled=t||i,this.#l.disabled=e||i}#j(){return this.#e==="enum"?this.#i===this.#r[0]?.value:this.#e==="token"?this.#N(this.#i)===0:this.#s!==-1/0&&Number(this.#i)<=this.#s}#U(){return this.#e==="enum"?this.#i===this.#r[this.#r.length-1]?.value:this.#e==="token"?this.#N(this.#i)===this.#h.length-1:this.#a!==1/0&&Number(this.#i)>=this.#a}#et(){this.#n.setFormValue(String(this.#i??""))}#it(){this.setState("at-min",this.#j()),this.setState("at-max",this.#U())}formResetCallback(){this.#d(this.#V??this.#k(),"reset")}formDisabledCallback(t){this.#_=t,this.#t&&this.#$()}formStateRestoreCallback(t){t!=null&&this.#d(t,"restore")}get displayText(){return this.#y?.textContent??""}get value(){return this.#i==null?"":String(this.#i)}set value(t){String(t)!==String(this.#i)&&this.#d(t,"api")}get form(){return this.#n.form}get name(){return this.getAttribute("name")}get type(){return this.localName}get validity(){return this.#n.validity}get validationMessage(){return this.#n.validationMessage}checkValidity(){return this.#n.checkValidity()}reportValidity(){return this.#n.reportValidity()}};b("stepper-wc",f);export{f as StepperWc};
|
|
1
|
+
var I=window.matchMedia("(prefers-reduced-motion: reduce)");var b=new Map;function m(n,t,e={}){let i=e.priority??10,s={impl:t,bundle:e.bundle,contract:e.contract,priority:i},r=b.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}b.set(n,s),customElements.define(n,t)}var l=class extends HTMLElement{#n=[];#e;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#n)t();this.#n=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,s){t.addEventListener(e,i,s),this.#n.push(()=>t.removeEventListener(e,i,s))}_reinit(){for(let t of this.#n)t();this.#n=[],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)}#s(){return this.constructor.formAssociated&&this.#e?this.#e:null}get validity(){return this.#s()?.validity}get validationMessage(){return this.#s()?.validationMessage??""}get willValidate(){return this.#s()?.willValidate??!1}get form(){return this.#s()?.form??null}checkValidity(){return this.#s()?.checkValidity()??!0}reportValidity(){return this.#s()?.reportValidity()??!0}};var v='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><line x1="5" y1="12" x2="19" y2="12"/></svg>',g='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>';function A(n){if(!n)return[];let t=n.trim();if(t.startsWith("["))try{return JSON.parse(t).map(i=>({value:String(i.value),label:String(i.label??i.value)}))}catch{return[]}return t.split(",").map(e=>{let i=e.trim();return{value:i,label:i}})}function x(n){return n?n.split(",").map(t=>t.trim()).filter(Boolean):[]}function w(n){let t=Math.max(0,Math.round(n)),e=Math.floor(t/3600),i=Math.floor(t%3600/60),s=t%60,r=a=>String(a).padStart(2,"0");return e>0?`${e}:${r(i)}:${r(s)}`:`${i}:${r(s)}`}function S(n,t){let e=Number(n)||0,i=["B","KB","MB","GB","TB","PB"],s=0,r=Math.abs(e);for(;r>=1e3&&s<i.length-1;)r/=1e3,s+=1;let a=new Intl.NumberFormat(t,{minimumFractionDigits:s===0?0:1,maximumFractionDigits:s===0?0:2});return`${e<0?"-":""}${a.format(r)} ${i[s]}`}function E(){return document.documentElement.lang||void 0}function c(n){let t=String(n),e=t.indexOf(".");return e<0?0:t.length-e-1}var p=!1,k=0,f=class extends l{static formAssociated=!0;static observedAttributes=["value","disabled","readonly","aria-label","aria-labelledby","data-label-decrease","data-label-increase"];#n;#e;#s=-1/0;#a=1/0;#p=1;#o=[];#r=[];#h;#F;#c="";#L=!1;#D=!1;#y;#i;#_;#V=!1;#P=!1;#t;#v;#A;#u;#l;#$;#x=0;#g=0;#C=!1;#w=!1;constructor(){super(),this.#n=this.attachInternals(),this._adoptInternals(this.#n)}setup(){this.#z(),this.#G(),this.#J();let t=this.getAttribute("value");this.#V||(this.#_=t,this.#V=!0),this.#d(t??this.#E(),"init"),this.#S(),requestAnimationFrame(()=>{this.isConnected&&this.#S()}),this.listen(this.#t,"focus",()=>this.#S()),this.listen(this,"click",e=>{e.target===this&&!this.#I()&&this.#t.focus()})}teardown(){this.#M(),this.#w=!1}attributeChangedCallback(t,e,i){!this.isConnected||!this.#t||(t==="value"?this.#d(i??this.#E(),"attr"):t==="disabled"||t==="readonly"?this.#T():t==="aria-label"||t==="aria-labelledby"?this.#S():this.#H())}#S(){let t=[],e=[];try{e=[...this.#n.labels||[]]}catch{}for(let a of e)a.id||(a.id=`stepper-wc-label-${++k}`),t.push(a.id);let i=(this.getAttribute("aria-labelledby")||"").trim();i&&t.push(...i.split(/\s+/));let s=[...new Set(t)];s.length?this.#t.setAttribute("aria-labelledby",s.join(" ")):this.#t.removeAttribute("aria-labelledby");let r=this.getAttribute("aria-label");r?this.#t.setAttribute("aria-label",r):this.#t.removeAttribute("aria-label")}#H(){this.#u.setAttribute("aria-label",this.getAttribute("data-label-decrease")||"Decrease"),this.#l.setAttribute("aria-label",this.getAttribute("data-label-increase")||"Increase")}#z(){if(this.hasAttribute("data-options"))this.#e="enum";else if(this.hasAttribute("data-values"))this.#e="token";else if(this.hasAttribute("data-format")||this.hasAttribute("data-suffix"))this.#e="formatted";else{if(this.#e="numeric",p)return;p=!0,console.info('[stepper-wc] No mode attribute set. Plain numeric stepping is better served by `<input type="number" data-stepper>`. See /docs/interaction/numeric-inputs/')}}#G(){this.#s=this.hasAttribute("data-min")?Number(this.getAttribute("data-min")):-1/0,this.#a=this.hasAttribute("data-max")?Number(this.getAttribute("data-max")):1/0,this.#p=Number(this.getAttribute("data-step"))||1,this.#o=x(this.getAttribute("data-values")),this.#r=A(this.getAttribute("data-options")),this.#h=this.getAttribute("data-format")||(this.hasAttribute("data-suffix")?"number":null),this.#F=this.getAttribute("data-currency")||"USD",this.#c=this.getAttribute("data-suffix")||"",this.#L=this.hasAttribute("data-show-label"),this.#D=this.hasAttribute("data-accelerate"),this.#y=E(),this.#$=this.#K()}#K(){if(!this.#h)return null;let t=c(this.#p);return this.#h==="number"?new Intl.NumberFormat(this.#y,{minimumFractionDigits:t,maximumFractionDigits:t}):this.#h==="currency"?new Intl.NumberFormat(this.#y,{style:"currency",currency:this.#F}):this.#h==="percent"?new Intl.NumberFormat(this.#y,{style:"percent",minimumFractionDigits:t,maximumFractionDigits:t}):null}#E(){return this.#e==="enum"?this.#r[0]?.value??"":this.#e==="token"?this.#o[0]??"":"0"}#J(){this.replaceChildren(),this.#u=document.createElement("button"),this.#u.type="button",this.#u.className="stepper-dec",this.#u.setAttribute("tabindex","-1"),this.#u.innerHTML=v,this.#l=document.createElement("button"),this.#l.type="button",this.#l.className="stepper-inc",this.#l.setAttribute("tabindex","-1"),this.#l.innerHTML=g,this.#t=document.createElement("span"),this.#t.className="stepper-value",this.#t.setAttribute("role","spinbutton"),this.#t.setAttribute("tabindex","0"),this.#v=document.createElement("span"),this.#v.className="stepper-value-display",this.#t.appendChild(this.#v),this.#A=new Set;for(let t of this.#j())this.#B(t);this.appendChild(this.#u),this.appendChild(this.#t),this.appendChild(this.#l),this.#q(this.#u,-1),this.#q(this.#l,1),this.listen(this.#t,"keydown",this.#W),this.#H(),this.#T()}#q(t,e){if(this.listen(t,"click",s=>{if(this.#w){this.#w=!1,s.preventDefault();return}this.#f(e,1)}),!this.#D)return;this.listen(t,"pointerdown",s=>{let r=s;r.pointerType==="mouse"&&r.button!==0||this.#m()||(this.#C=!1,this.#x=window.setTimeout(()=>{this.#C=!0,this.#g=window.setInterval(()=>this.#f(e,1),100),this.#x=window.setTimeout(()=>{window.clearInterval(this.#g),this.#g=window.setInterval(()=>this.#f(e,5),50)},1e3)},500))});let i=()=>{this.#M(),this.#C&&(this.#w=!0)};this.listen(t,"pointerup",i),this.listen(t,"pointerleave",i),this.listen(t,"pointercancel",i)}#M(){window.clearTimeout(this.#x),window.clearInterval(this.#g),this.#x=0,this.#g=0}#W=t=>{if(this.#m())return;let e=getComputedStyle(this).direction==="rtl";switch(e&&t.key==="ArrowLeft"?"ArrowRight":e&&t.key==="ArrowRight"?"ArrowLeft":t.key){case"ArrowUp":case"ArrowRight":t.preventDefault(),this.#f(1,1);break;case"ArrowDown":case"ArrowLeft":t.preventDefault(),this.#f(-1,1);break;case"PageUp":t.preventDefault(),this.#f(1,10);break;case"PageDown":t.preventDefault(),this.#f(-1,10);break;case"Home":t.preventDefault(),this.#O("min");break;case"End":t.preventDefault(),this.#O("max");break;default:}};#I(){return this.hasAttribute("disabled")||this.#P}#m(){return this.#I()||this.hasAttribute("readonly")}#T(){let t=this.#I();this.#t.setAttribute("aria-disabled",String(t)),this.hasAttribute("readonly")?this.#t.setAttribute("aria-readonly","true"):this.#t.removeAttribute("aria-readonly"),t?(this.#t.removeAttribute("tabindex"),this.#M()):this.#t.setAttribute("tabindex","0"),this.#i!==void 0?this.#N():(this.#u.disabled=this.#m(),this.#l.disabled=this.#m())}#f(t,e){if(this.#m())return;let i=this.#Q(t,e);i===null||i===this.#i||this.#d(i,"step")}#O(t){if(this.#e==="enum"){let i=t==="min"?0:this.#r.length-1;this.#d(this.#r[i]?.value,"step");return}if(this.#e==="token"){let i=t==="min"?0:this.#o.length-1;this.#d(this.#o[i],"step");return}let e=t==="min"?this.#s===-1/0?this.#i:this.#s:this.#a===1/0?this.#i:this.#a;this.#d(String(e),"step")}#Q(t,e){if(this.#e==="enum"){let o=this.#r.findIndex(y=>y.value===this.#i),h=o===-1?0:o,d=Math.min(this.#r.length-1,Math.max(0,h+t*e));return this.#r[d]?.value}if(this.#e==="token"){let h=this.#k(this.#i);h===-1&&(h=this.#X(this.#i));let d=Math.min(this.#o.length-1,Math.max(0,h+t*e));return this.#o[d]}let i=Number(this.#i)||0,s=c(this.#p),r=i+t*this.#p*e,a=Number(r.toFixed(s)),u=Math.min(this.#a,Math.max(this.#s,a));return String(u)}#k(t){if(t==null)return-1;let e=this.#o.indexOf(String(t));if(e!==-1)return e;let i=Number(t);if(Number.isFinite(i)){let s=this.#o.findIndex(r=>Number(r)===i);if(s!==-1)return s}return-1}#X(t){let e=Number(t);if(!Number.isFinite(e))return 0;let i=0,s=1/0;return this.#o.forEach((r,a)=>{let u=Number(r);if(!Number.isFinite(u))return;let o=Math.abs(u-e);o<s&&(s=o,i=a)}),i}#d(t,e){let i=this.#Y(t),s=i!==this.#i;this.#i=i,this.getAttribute("value")!==String(i)&&this.setAttribute("value",String(i)),this.#Z(),this.#tt(),this.#N(),this.#et(),this.#it(),s&&e!=="init"&&(this.dispatchEvent(new Event("input",{bubbles:!0})),this.dispatchEvent(new Event("change",{bubbles:!0})))}#Y(t){if(t==null)return this.#E();if(this.#e==="enum"){let s=String(t);return this.#r.find(a=>a.value===s)?s:this.#r[0]?.value??""}if(this.#e==="token")return String(t);let e=Number(t);if(!Number.isFinite(e))return String(this.#s===-1/0?0:this.#s);let i=c(this.#p);return String(Number(Math.min(this.#a,Math.max(this.#s,e)).toFixed(i)))}#Z(){let t=this.#b();this.#v.textContent=t,this.#B(t)}#b(t=this.#i){if(this.#e==="enum")return this.#r.find(i=>i.value===t)?.label??t??"";if(this.#e==="token"){let e=this.#L?String(t).replace(/^--/,""):String(t);return this.#c?`${e}${this.#c}`:e}if(this.#e==="formatted"){let e=Number(t)||0;if(this.#h==="duration")return w(e);if(this.#h==="bytes")return S(e,this.#y);if(this.#$){let i=this.#h==="percent"?e/100:e,s=this.#$.format(i);return this.#c&&this.#h==="number"?`${s}${this.#c}`:s}return this.#c?`${e}${this.#c}`:String(e)}return String(t??"")}#j(){if(this.#e==="enum")return this.#r.map(i=>this.#b(i.value));if(this.#e==="token")return this.#o.map(i=>this.#b(i));let t=new Set,e=i=>{Number.isFinite(i)&&t.add(i)};if(this.#s!==-1/0&&e(this.#s),this.#a!==1/0&&e(this.#a),e(Number(this.getAttribute("value"))||0),this.#a===1/0){let i=[10,100,1e3,1e4];for(let s of i)e(s);if(this.#h==="bytes")for(let s of[999,999e3,999e6,999e9])e(s)}return[...t].map(i=>this.#b(String(i)))}#B(t){let e=String(t??"");if(!e||this.#A.has(e))return;this.#A.add(e);let i=document.createElement("span");i.className="stepper-value-reserve",i.setAttribute("aria-hidden","true"),i.textContent=e,this.#t.appendChild(i)}recomputeWidth(){if(this.#t){this.#t.querySelectorAll(".stepper-value-reserve").forEach(t=>t.remove()),this.#A=new Set;for(let t of this.#j())this.#B(t)}}#tt(){if(this.#e==="enum"){let e=this.#r.findIndex(i=>i.value===this.#i);this.#t.setAttribute("aria-valuemin","1"),this.#t.setAttribute("aria-valuemax",String(this.#r.length)),this.#t.setAttribute("aria-valuenow",String((e===-1?0:e)+1)),this.#t.setAttribute("aria-valuetext",this.#b());return}if(this.#e==="token"){let e=this.#k(this.#i);this.#t.setAttribute("aria-valuemin","1"),this.#t.setAttribute("aria-valuemax",String(this.#o.length)),this.#t.setAttribute("aria-valuenow",String((e===-1?0:e)+1)),this.#t.setAttribute("aria-valuetext",this.#b());return}let t=Number(this.#i)||0;this.#s!==-1/0?this.#t.setAttribute("aria-valuemin",String(this.#s)):this.#t.removeAttribute("aria-valuemin"),this.#a!==1/0?this.#t.setAttribute("aria-valuemax",String(this.#a)):this.#t.removeAttribute("aria-valuemax"),this.#t.setAttribute("aria-valuenow",String(t)),this.#t.setAttribute("aria-valuetext",this.#b())}#N(){let t=this.#R(),e=this.#U(),i=this.#m();this.#u.disabled=t||i,this.#l.disabled=e||i}#R(){return this.#e==="enum"?this.#i===this.#r[0]?.value:this.#e==="token"?this.#k(this.#i)===0:this.#s!==-1/0&&Number(this.#i)<=this.#s}#U(){return this.#e==="enum"?this.#i===this.#r[this.#r.length-1]?.value:this.#e==="token"?this.#k(this.#i)===this.#o.length-1:this.#a!==1/0&&Number(this.#i)>=this.#a}#et(){this.#n.setFormValue(String(this.#i??""))}#it(){this.setState("at-min",this.#R()),this.setState("at-max",this.#U())}formResetCallback(){this.#d(this.#_??this.#E(),"reset")}formDisabledCallback(t){this.#P=t,this.#t&&this.#T()}formStateRestoreCallback(t){t!=null&&this.#d(t,"restore")}get displayText(){return this.#v?.textContent??""}get value(){return this.#i==null?"":String(this.#i)}set value(t){String(t)!==String(this.#i)&&this.#d(t,"api")}get form(){return this.#n.form}get name(){return this.getAttribute("name")}get type(){return this.localName}get validity(){return this.#n.validity}get validationMessage(){return this.#n.validationMessage}checkValidity(){return this.#n.checkValidity()}reportValidity(){return this.#n.reportValidity()}};m("stepper-wc",f);export{f as StepperWc};
|
|
2
2
|
//# sourceMappingURL=stepper-wc.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
1
|
+
function l(i){return document.startViewTransition?document.startViewTransition(i):i()}var w=window.matchMedia("(prefers-reduced-motion: reduce)");var h=new Map;function f(i,t,e={}){let r=e.priority??10,n={impl:t,bundle:e.bundle,contract:e.contract,priority:r},s=h.get(i);if(customElements.get(i)){if(!s||s.priority>=r){s&&s.priority===r&&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>=r){s.priority===r&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}h.set(i,n),customElements.define(i,t)}var d=class extends HTMLElement{#t=[];#e;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,r,n){t.addEventListener(e,r,n),this.#t.push(()=>t.removeEventListener(e,r,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,e){this.#e||(this.#e=this.attachInternals());let r=this.#e.states;try{e?r.add(t):r.delete(t)}catch{let n=`--${t}`;e?r.add(n):r.delete(n)}}_adoptInternals(t){this.#e||(this.#e=t)}#r(){return this.constructor.formAssociated&&this.#e?this.#e:null}get validity(){return this.#r()?.validity}get validationMessage(){return this.#r()?.validationMessage??""}get willValidate(){return this.#r()?.willValidate??!1}get form(){return this.#r()?.form??null}checkValidity(){return this.#r()?.checkValidity()??!0}reportValidity(){return this.#r()?.reportValidity()??!0}};var p=0,b=0,u=class extends d{#t=[];#e=[];#r=!1;#s=0;#n=!1;setup(){return this.#t=[...this.querySelectorAll(":scope > details")],this.#e=this.#t.map(t=>t.querySelector(":scope > summary")),this.#t.length===0?!1:(this.style.setProperty("--_tab-count",String(this.#t.length)),!this.hasAttribute("role")&&(this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby"))&&(this.setAttribute("role","group"),this.#n=!0),this.#a(),this.#d(),this.#u(),this.#s=Math.max(0,this.#t.findIndex(t=>t.open)),this.#o(),this.#c(),!0)}teardown(){this.style.removeProperty("--_tab-count"),this.#n&&this.removeAttribute("role"),this.#n=!1,this.#t=[],this.#e=[],this.#r=!1}get tabs(){return this.#t.map((t,e)=>({id:t.id||void 0,label:t.querySelector(":scope > summary")?.textContent?.trim()||`Tab ${e+1}`,content:t.querySelector(":scope > :not(summary)")?.innerHTML||"",active:t.hasAttribute("open")}))}set tabs(t){let e=Array.isArray(t)?t:[];for(;this.firstChild;)this.firstChild.remove();let r=!1;for(let n of e){let s=document.createElement("details");n.id&&(s.id=n.id),n.active&&!r&&(s.setAttribute("open",""),r=!0);let c=document.createElement("summary");c.textContent=n.label||"",s.appendChild(c);let o=document.createElement("section");o.innerHTML=n.content||"",s.appendChild(o),this.appendChild(s)}!r&&this.firstElementChild&&this.firstElementChild.setAttribute("open",""),this._reinit(),this.dispatchEvent(new CustomEvent("tab-set:tabs-changed",{detail:{tabs:e,source:"property"},bubbles:!0}))}#a(){let t=new Set(this.#t.map(r=>r.getAttribute("name")||"")),e=t.size===1?[...t][0]:"";if(e){let n=this.getRootNode().querySelectorAll?.(`details[name="${CSS.escape(e)}"]`)??[];for(let s of n)if(!this.#t.includes(s)){e="";break}}if(!e){e=`tab-set-${++b}`;for(let r of this.#t)r.setAttribute("name",e)}}#c(){if(!this.hasAttribute("transition")||!document.startViewTransition)return;this.#r=!0;let t=++p,e=this.getAttribute("transition")||"fade",r=e==="slide"?"vt-tabs-slide":e==="scale"?"vt-tabs-scale":"vt-tabs";this.#t.forEach(n=>{let s=n.querySelector(":scope > :not(summary)");s&&(s.style.viewTransitionName=`tabs-${t}`,s.style.viewTransitionClass=r)})}#i(t){if(t===this.#s)return;let e=t>this.#s?"forward":"backward";document.documentElement.dataset.vtDirection=e,l(()=>{this.#t[t].open=!0}).finished?.then(()=>{delete document.documentElement.dataset.vtDirection})}#d(){this.#t.forEach((t,e)=>{let r=this.#e[e],n=t.querySelector(":scope > :not(summary)");if(this.listen(t,"toggle",()=>this.#l(e)),!r||!n)return;let s=r.id||`tab-${crypto.randomUUID().slice(0,8)}`,c=n.id||`panel-${crypto.randomUUID().slice(0,8)}`;r.id=s,r.setAttribute("aria-controls",c),n.id=c,n.setAttribute("aria-labelledby",s),this.listen(r,"click",o=>{if(t.open){o.preventDefault();return}this.#r&&(o.preventDefault(),this.#i(e))}),this.listen(r,"keydown",o=>this.#h(o,e))})}#u(){this.#t.some(t=>t.open)||(this.#t[0].open=!0)}#l(t){let e=this.#t[t];if(this.#o(),!e?.open)return;let r=this.#s;r!==t&&(this.#s=t,this.dispatchEvent(new CustomEvent("tab-set:change",{detail:{index:t,previousIndex:r,tab:e,panel:e.querySelector(":scope > :not(summary)")},bubbles:!0})))}#o(){this.#t.forEach((t,e)=>{let r=this.#e[e];r&&r.setAttribute("aria-expanded",t.open?"true":"false")})}#h(t,e){let r=this.#t.length,n=(e+1)%r,s=(e-1+r)%r,c=getComputedStyle(this).direction==="rtl",o=this.getAttribute("data-orientation")==="vertical",a;switch(t.key){case"ArrowRight":if(o)return;a=c?s:n;break;case"ArrowLeft":if(o)return;a=c?n:s;break;case"ArrowDown":if(!o)return;a=n;break;case"ArrowUp":if(!o)return;a=s;break;case"Home":a=0;break;case"End":a=r-1;break;default:return}t.preventDefault(),this.#r?this.#i(a):this.#t[a].open=!0,this.#e[a]?.focus()}};f("tab-set",u);export{u as TabSet};
|
|
2
2
|
//# sourceMappingURL=tab-set.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var E=window.matchMedia("(prefers-reduced-motion: reduce)");var m=new Map;function b(l,t,e={}){let s=e.priority??10,i={impl:t,bundle:e.bundle,contract:e.contract,priority:s},n=m.get(l);if(customElements.get(l)){if(!n||n.priority>=s){n&&n.priority===s&&n.impl!==t&&console.warn(`[VB Bundle] Tag <${l}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${l}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=s){n.priority===s&&console.warn(`[VB Bundle] Tag <${l}> already registered by "${n.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}m.set(l,i),customElements.define(l,t)}var p=class extends HTMLElement{#h=[];#t;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#h)t();this.#h=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,s,i){t.addEventListener(e,s,i),this.#h.push(()=>t.removeEventListener(e,s,i))}_reinit(){for(let t of this.#h)t();this.#h=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#t||(this.#t=this.attachInternals());let s=this.#t.states;try{e?s.add(t):s.delete(t)}catch{let i=`--${t}`;e?s.add(i):s.delete(i)}}_adoptInternals(t){this.#t||(this.#t=t)}#n(){return this.constructor.formAssociated&&this.#t?this.#t:null}get validity(){return this.#n()?.validity}get validationMessage(){return this.#n()?.validationMessage??""}get willValidate(){return this.#n()?.willValidate??!1}get form(){return this.#n()?.form??null}checkValidity(){return this.#n()?.checkValidity()??!0}reportValidity(){return this.#n()?.reportValidity()??!0}};var y={play:"Play",pause:"Pause",stop:"Stop",reader:"Article reader",controls:"Reader controls",voice:"Voice","loading-voices":"Loading voices\u2026",speed:"Speed",slower:"Slower",faster:"Faster"},v='[aria-hidden="true"], [hidden], script, style, template, text-reader',S=()=>typeof HTMLElement<"u"&&Object.prototype.hasOwnProperty.call(HTMLElement.prototype,"popover"),f=()=>typeof window<"u"&&"speechSynthesis"in window,u=l=>(l||"").toLowerCase().split(/[-_]/)[0],g=class extends p{#h=null;#t=null;#n=[];#c="";#g=0;#S=null;#x=null;#$=null;#C=null;#i=!1;#a=!1;#B=0;#r=null;#u=null;#p=null;#m=null;#b=null;#v=null;#L=null;#k=!1;#o=null;#e=null;#E=[];#V=[];static get observedAttributes(){return["speed","voice","for"]}attributeChangedCallback(t,e,s){if(e!==s&&(t==="for"&&e!==null&&this.hasAttribute("data-upgraded")&&(this.#i&&this.stop(),this.#P(),this.#D(this.#V)),(t==="speed"||t==="voice")&&this.#i&&this.#T(),t==="speed")){let i=this.#y(parseFloat(s)||1);this.#b&&(this.#b.value=String(i)),this.#v&&(this.#v.textContent=`${i}\xD7`)}}setup(){return f()?(this.getAttribute("variant")==="icon"?this.#J():this.#G(),this.#P(),this.#st(),this.#C=this.#_(),this.#C.then(t=>{this.#V=t,this.#D(t)}),this.listen(window,"beforeunload",this.#ot),!0):(this.style.display="none",!1)}teardown(){this.#i&&this.stop(),this.#it(),this.#L?.remove(),this.#e?.remove(),this.#o?.remove(),this.#L=null,this.#e=null,this.#o=null,this.#r=this.#u=this.#p=null,this.#m=null,this.#b=null,this.#v=null,this.#k=!1;for(let{icon:t,slot:e}of this.#E)t.setAttribute("slot",e),this.append(t);this.#E=[]}play(){if(f()){if(this.#a){this.resume();return}this.#i||(this.#H(),this.#R(0))}}pause(){!this.#i||this.#a||(speechSynthesis.pause(),this.#a=!0,this.#K(!0),this.#d("text-reader:pause"))}resume(){this.#a&&(speechSynthesis.resume(),this.#a=!1,this.#K(!1),this.#d("text-reader:resume"))}stop(){!f()||!this.#i||(this.#t=null,speechSynthesis.cancel(),this.#A(),this.#d("text-reader:stop"))}get voices(){return this.#C||this.#_()}get speaking(){return this.#i}get paused(){return this.#a}get progress(){return this.#c.length?Math.min(this.#g/this.#c.length,1):0}#G(){let t=document.createElement("div");t.setAttribute("part","controls"),t.setAttribute("role","group"),t.setAttribute("aria-label",this.#s("reader"));let e=this.#l("play",this.#s("play"),"\u25B6");e.addEventListener("click",()=>this.play());let s=this.#l("pause",this.#s("pause"),"\u23F8");s.hidden=!0,s.addEventListener("click",()=>this.pause());let i=this.#l("stop",this.#s("stop"),"\u23F9");i.disabled=!0,i.addEventListener("click",()=>this.stop());let n=document.createElement("select");n.setAttribute("aria-label",this.#s("voice"));let o=document.createElement("option");o.textContent=this.#s("loading-voices"),n.append(o),n.addEventListener("change",()=>{this.#i&&this.#T()});let h=document.createElement("label");h.setAttribute("data-speed-group","");let r=document.createElement("span");r.setAttribute("data-speed-value","");let a=this.#y(parseFloat(this.getAttribute("speed")??"1")||1);r.textContent=`${a}\xD7`;let c=document.createElement("input");c.type="range",c.min="0.5",c.max="2",c.step="0.1",c.value=String(a),c.setAttribute("aria-label",this.#s("speed")),c.addEventListener("input",()=>{let d=parseFloat(c.value);r.textContent=`${d}\xD7`,this.#i&&this.#T()}),h.append(r,c),this.#f("icon-play",e),this.#f("icon-pause",s),this.#f("icon-stop",i),t.append(e,s,i,n,h),this.prepend(t),this.#L=t,this.#r=e,this.#u=s,this.#p=i,this.#m=n,this.#b=c,this.#v=r}#l(t,e,s){let i=document.createElement("button");return i.type="button",i.setAttribute("part",`button ${t}`),i.setAttribute("aria-label",e),i.textContent=s,i}#s(t){return this.getAttribute(`data-label-${t}`)||y[t]}#f(t,e){let s=this.querySelector(`:scope > [slot="${t}"]`);s&&(s.removeAttribute("slot"),e.textContent="",e.append(s),this.#E.push({icon:s,slot:t}))}#J(){this.#k=!0;for(let s of this.querySelectorAll(':scope > [part="trigger"]'))s.remove();let t=document.createElement("button");t.type="button",t.setAttribute("part","trigger"),t.setAttribute("aria-label",this.#s("reader")),t.setAttribute("aria-pressed","false");let e=this.querySelector(':scope > [slot="icon-trigger"]');if(e)e.removeAttribute("slot"),t.append(e),this.#E.push({icon:e,slot:"icon-trigger"});else{let s=document.createElement("icon-wc");s.setAttribute("name","volume-2"),s.setAttribute("aria-hidden","true"),t.append(s)}t.addEventListener("click",()=>this.#z()),this.append(t),this.#o=t,this.#X()}#X(){let t=document.createElement("div");t.setAttribute("data-text-reader-toolbar",""),t.setAttribute("role","group"),t.setAttribute("aria-label",this.#s("controls")),t.hidden=!0,S()&&(t.popover="manual");let e=this.#l("play",this.#s("play"),"\u25B6");e.addEventListener("click",()=>this.play());let s=this.#l("pause",this.#s("pause"),"\u23F8");s.hidden=!0,s.addEventListener("click",()=>this.pause());let i=this.#l("stop",this.#s("stop"),"\u23F9");i.addEventListener("click",()=>this.stop());let n=this.#l("speed-down",this.#s("slower"),"\u2212");n.addEventListener("click",()=>this.#I(-.1));let o=document.createElement("span");o.setAttribute("data-speed-value","");let h=this.#y(parseFloat(this.getAttribute("speed")??"1")||1);o.textContent=`${h}\xD7`;let r=this.#l("speed-up",this.#s("faster"),"+");r.addEventListener("click",()=>this.#I(.1)),this.#f("icon-play",e),this.#f("icon-pause",s),this.#f("icon-stop",i),t.append(e,s,i,n,o,r),this.append(t),this.#r=e,this.#u=s,this.#p=i,this.#v=o,this.#e=t,this.listen(document,"pointerdown",this.#Y),this.listen(document,"keydown",this.#Z)}#z(){if(!this.#i){this.play();return}this.#e?.hidden&&this.#F(),this.#a?this.resume():this.pause()}#F(){if(!this.#e||!this.#o)return;let t=this.#e;t.hidden=!1,t.popover&&!t.matches(":popover-open")&&t.showPopover(),t.style.visibility="hidden",requestAnimationFrame(()=>{this.#Q(),t.style.visibility=""})}#M(){let t=this.#e;if(!t||t.hidden)return;let e=t.contains(document.activeElement);t.popover&&t.matches(":popover-open")&&t.hidePopover(),t.hidden=!0,e&&this.#o?.focus()}#Q(){let t=this.#e,e=this.#o;if(!t||!e)return;let s=e.getBoundingClientRect(),i=t.offsetWidth,n=t.offsetHeight,o=8,h=8,r=s.top-n-o;r<h&&(r=s.bottom+o);let a=s.left+s.width/2-i/2,c=window.innerWidth-i-h;a=Math.max(h,Math.min(a,c)),t.style.top=`${r}px`,t.style.left=`${a}px`}#I(t){let e=parseFloat(this.getAttribute("speed")??"1")||1,s=this.#y(e+t);this.setAttribute("speed",String(s))}#Y=t=>{!this.#e||this.#e.hidden||this.#e.contains(t.target)||this.#o?.contains(t.target)||this.#M()};#Z=t=>{if(t.key==="Escape"&&this.#e&&!this.#e.hidden){let e=this.#e.contains(document.activeElement)||this.#o===document.activeElement;this.#M(),e&&this.#o?.focus()}};#P(){let t=this.getAttribute("for");if(!t){console.warn('<text-reader>: missing "for" attribute'),this.#q();return}if(this.#h=document.getElementById(t),!this.#h){console.warn(`<text-reader>: no element found with id="${t}"`),this.#q();return}this.#H(),this.#tt()}#q(){this.#r&&(this.#r.disabled=!0),this.#p&&(this.#p.disabled=!0)}#tt(){this.#r&&(this.#r.disabled=!1)}#H(){let t=this.#h;if(!t)return;let e=this.getAttribute("selectors")||"p,li",s=[...t.querySelectorAll(e)],i=o=>o.closest("pre")||o.closest("code")||o.closest(v);this.#n=[];let n=0;for(let o of s){if(i(o))continue;let h=[],r="",a=document.createTreeWalker(o,NodeFilter.SHOW_TEXT,{acceptNode:c=>c.parentElement?.closest(v)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT});for(;a.nextNode();){let c=a.currentNode,d=c.data;d&&(h.push({node:c,start:r.length,end:r.length+d.length}),r+=d)}r.trim()&&(this.#n.push({element:o,text:r,speechStart:n,speechEnd:n+r.length,segments:h}),n+=r.length+1)}this.#c=this.#n.map(o=>o.text).join(" ")}#N(){return this.#h?.closest("[lang]")?.getAttribute("lang")||document.documentElement.lang||""}#R(t){if(!this.#c)return;let e=t>0?this.#c.slice(t):this.#c;if(!e.trim())return;let s=e.replace(/[<>]/g," "),i=new SpeechSynthesisUtterance(s),n=this.#N();n&&(i.lang=n),i.rate=this.#y(parseFloat(this.#b?.value??this.getAttribute("speed")??"1")||1);let o=this.#m?.selectedOptions[0];if(o?.dataset.voiceUri){let h=speechSynthesis.getVoices().find(r=>r.voiceURI===o.dataset.voiceUri);h&&(i.voice=h)}else if(n){let h=u(n),r=speechSynthesis.getVoices(),a=r.find(c=>c.lang.toLowerCase()===n.toLowerCase())||r.find(c=>u(c.lang)===h&&c.default)||r.find(c=>u(c.lang)===h);a&&(i.voice=a)}i.onboundary=h=>{if(this.#t!==i||h.name!=="word")return;let r=t+h.charIndex;this.#g=r;let a=h.charLength;if(!a){let d=this.#c.slice(r).match(/^\S+/);a=d?d[0].length:1}this.#nt(r,a),this.#d("text-reader:word",{word:this.#c.slice(r,r+a),charIndex:r,element:this.#O(r)?.element})},i.onend=()=>{if(this.#t!==i)return;let h=Date.now()-this.#B;this.#A(),this.#d("text-reader:end",{duration:h})},i.onerror=h=>{if(this.#t===i){if(h.error==="interrupted"||h.error==="canceled"){this.#A(),this.#d("text-reader:stop");return}console.warn("<text-reader>: SpeechSynthesisUtterance error:",h.error),this.#A(),this.#d("text-reader:error",{error:h.error})}},this.#t=i,this.#i=!0,this.#a=!1,this.#B=Date.now(),this.#g=t,this.#W(!0),speechSynthesis.cancel(),speechSynthesis.speak(i),this.#et(),this.#d("text-reader:play",{voice:i.voice?.name,speed:i.rate})}#T(){let t=this.#g;this.#t=null,speechSynthesis.cancel(),this.#w(),requestAnimationFrame(()=>this.#R(t))}#et(){this.#w(),this.#S=setInterval(()=>{if(!speechSynthesis.speaking){this.#w();return}speechSynthesis.pause(),speechSynthesis.resume()},1e4)}#w(){this.#S&&clearInterval(this.#S),this.#S=null}#st(){if(!CSS.highlights)return;let t=new CSSStyleSheet;t.replaceSync(`
|
|
1
|
+
var x=window.matchMedia("(prefers-reduced-motion: reduce)");var b=new Map;function m(l,t,e={}){let s=e.priority??10,i={impl:t,bundle:e.bundle,contract:e.contract,priority:s},n=b.get(l);if(customElements.get(l)){if(!n||n.priority>=s){n&&n.priority===s&&n.impl!==t&&console.warn(`[VB Bundle] Tag <${l}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${l}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=s){n.priority===s&&console.warn(`[VB Bundle] Tag <${l}> already registered by "${n.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}b.set(l,i),customElements.define(l,t)}var p=class extends HTMLElement{#o=[];#t;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#o)t();this.#o=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,s,i){t.addEventListener(e,s,i),this.#o.push(()=>t.removeEventListener(e,s,i))}_reinit(){for(let t of this.#o)t();this.#o=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#t||(this.#t=this.attachInternals());let s=this.#t.states;try{e?s.add(t):s.delete(t)}catch{let i=`--${t}`;e?s.add(i):s.delete(i)}}_adoptInternals(t){this.#t||(this.#t=t)}#n(){return this.constructor.formAssociated&&this.#t?this.#t:null}get validity(){return this.#n()?.validity}get validationMessage(){return this.#n()?.validationMessage??""}get willValidate(){return this.#n()?.willValidate??!1}get form(){return this.#n()?.form??null}checkValidity(){return this.#n()?.checkValidity()??!0}reportValidity(){return this.#n()?.reportValidity()??!0}};var y={play:"Play",pause:"Pause",stop:"Stop",reader:"Article reader",controls:"Reader controls",voice:"Voice","loading-voices":"Loading voices\u2026",speed:"Speed",slower:"Slower",faster:"Faster"},v='[aria-hidden="true"], [hidden], script, style, template, text-reader',S=()=>typeof HTMLElement<"u"&&Object.prototype.hasOwnProperty.call(HTMLElement.prototype,"popover"),f=()=>typeof window<"u"&&"speechSynthesis"in window,u=l=>(l||"").toLowerCase().split(/[-_]/)[0],g=class extends p{#o=null;#t=null;#n=[];#h="";#g=0;#S=null;#x=null;#M=null;#C=null;#s=!1;#c=!1;#P=0;#r=null;#u=null;#p=null;#b=null;#m=null;#v=null;#$=null;#L=!1;#a=null;#i=null;#w=[];#B=[];static get observedAttributes(){return["speed","voice","for"]}attributeChangedCallback(t,e,s){if(e!==s&&(t==="for"&&e!==null&&this.hasAttribute("data-upgraded")&&(this.#s&&this.stop(),this.#H(),this.#D(this.#B)),(t==="speed"||t==="voice")&&this.#s&&this.#k(),t==="speed")){let i=this.#y(parseFloat(s)||1);this.#m&&(this.#m.value=String(i)),this.#v&&(this.#v.textContent=`${i}\xD7`)}}setup(){return f()?(this.getAttribute("variant")==="icon"?this.#J():this.#z(),this.#H(),this.#st(),this.#C=this.#U(),this.#C.then(t=>{this.#B=t,this.#D(t)}),this.listen(window,"beforeunload",this.#ot),!0):(this.style.display="none",!1)}teardown(){this.#s&&this.stop(),this.#it(),this.#$?.remove(),this.#i?.remove(),this.#a?.remove(),this.#$=null,this.#i=null,this.#a=null,this.#r=this.#u=this.#p=null,this.#b=null,this.#m=null,this.#v=null,this.#L=!1;for(let{icon:t,slot:e}of this.#w)t.setAttribute("slot",e),this.append(t);this.#w=[]}play(){if(f()){if(this.#c){this.resume();return}this.#s||(this.#_(),this.#R(0))}}pause(){!this.#s||this.#c||(speechSynthesis.pause(),this.#c=!0,this.#G(!0),this.#d("text-reader:pause"))}resume(){this.#c&&(speechSynthesis.resume(),this.#c=!1,this.#G(!1),this.#d("text-reader:resume"))}stop(){!f()||!this.#s||(this.#t=null,speechSynthesis.cancel(),this.#A(),this.#d("text-reader:stop"))}get voices(){return this.#C||this.#U()}get speaking(){return this.#s}get paused(){return this.#c}get progress(){return this.#h.length?Math.min(this.#g/this.#h.length,1):0}#z(){let t=document.createElement("div");t.setAttribute("part","controls"),t.setAttribute("role","group"),t.setAttribute("aria-label",this.#e("reader"));let e=this.#l("play",this.#e("play"),"\u25B6");e.addEventListener("click",()=>this.play());let s=this.#l("pause",this.#e("pause"),"\u23F8");s.hidden=!0,s.addEventListener("click",()=>this.pause());let i=this.#l("stop",this.#e("stop"),"\u23F9");i.disabled=!0,i.addEventListener("click",()=>this.stop());let n=document.createElement("select");n.setAttribute("aria-label",this.#e("voice"));let o=document.createElement("option");o.textContent=this.#e("loading-voices"),n.append(o),n.addEventListener("change",()=>{this.#s&&this.#k()});let a=document.createElement("label");a.setAttribute("data-speed-group","");let r=document.createElement("span");r.setAttribute("data-speed-value","");let c=this.#y(parseFloat(this.getAttribute("speed")??"1")||1);r.textContent=`${c}\xD7`;let h=document.createElement("input");h.type="range",h.min="0.5",h.max="2",h.step="0.1",h.value=String(c),h.setAttribute("aria-label",this.#e("speed")),h.addEventListener("input",()=>{let d=parseFloat(h.value);r.textContent=`${d}\xD7`,this.#s&&this.#k()}),a.append(r,h),this.#f("icon-play",e),this.#f("icon-pause",s),this.#f("icon-stop",i),t.append(e,s,i,n,a),this.prepend(t),this.#$=t,this.#r=e,this.#u=s,this.#p=i,this.#b=n,this.#m=h,this.#v=r}#l(t,e,s){let i=document.createElement("button");return i.type="button",i.setAttribute("part",`button ${t}`),i.setAttribute("aria-label",e),i.textContent=s,i}#e(t){return this.getAttribute(`data-label-${t}`)||y[t]}#f(t,e){let s=this.querySelector(`:scope > [slot="${t}"]`);s&&(s.removeAttribute("slot"),e.textContent="",e.append(s),this.#w.push({icon:s,slot:t}))}#J(){this.#L=!0;for(let s of this.querySelectorAll(':scope > [part="trigger"]'))s.remove();let t=document.createElement("button");t.type="button",t.setAttribute("part","trigger"),t.setAttribute("aria-label",this.#e("reader")),t.setAttribute("aria-pressed","false");let e=this.querySelector(':scope > [slot="icon-trigger"]');if(e)e.removeAttribute("slot"),t.append(e),this.#w.push({icon:e,slot:"icon-trigger"});else{let s=document.createElement("icon-wc");s.setAttribute("name","volume-2"),s.setAttribute("aria-hidden","true"),t.append(s)}t.addEventListener("click",()=>this.#Q()),this.append(t),this.#a=t,this.#X()}#X(){let t=document.createElement("div");t.setAttribute("data-text-reader-toolbar",""),t.setAttribute("role","group"),t.setAttribute("aria-label",this.#e("controls")),t.hidden=!0,S()&&(t.popover="manual");let e=this.#l("play",this.#e("play"),"\u25B6");e.addEventListener("click",()=>this.play());let s=this.#l("pause",this.#e("pause"),"\u23F8");s.hidden=!0,s.addEventListener("click",()=>this.pause());let i=this.#l("stop",this.#e("stop"),"\u23F9");i.addEventListener("click",()=>this.stop());let n=this.#l("speed-down",this.#e("slower"),"\u2212");n.addEventListener("click",()=>this.#V(-.1));let o=document.createElement("span");o.setAttribute("data-speed-value","");let a=this.#y(parseFloat(this.getAttribute("speed")??"1")||1);o.textContent=`${a}\xD7`;let r=this.#l("speed-up",this.#e("faster"),"+");r.addEventListener("click",()=>this.#V(.1)),this.#f("icon-play",e),this.#f("icon-pause",s),this.#f("icon-stop",i),t.append(e,s,i,n,o,r),this.append(t),this.#r=e,this.#u=s,this.#p=i,this.#v=o,this.#i=t,this.listen(document,"pointerdown",this.#Z),this.listen(this,"keydown",this.#N)}#Q(){if(!this.#s){this.play();return}this.#i?.hidden&&this.#F(),this.#c?this.resume():this.pause()}#F(){if(!this.#i||!this.#a)return;let t=this.#i;t.hidden=!1,t.popover&&!t.matches(":popover-open")&&t.showPopover(),t.style.visibility="hidden",requestAnimationFrame(()=>{this.#Y(),t.style.visibility=""})}#T(){let t=this.#i;if(!t||t.hidden)return;let e=t.contains(document.activeElement);t.popover&&t.matches(":popover-open")&&t.hidePopover(),t.hidden=!0,e&&this.#a?.focus()}#Y(){let t=this.#i,e=this.#a;if(!t||!e)return;let s=e.getBoundingClientRect(),i=t.offsetWidth,n=t.offsetHeight,o=8,a=8,r=s.top-n-o;r<a&&(r=s.bottom+o);let c=s.left+s.width/2-i/2,h=window.innerWidth-i-a;c=Math.max(a,Math.min(c,h)),t.style.top=`${r}px`,t.style.left=`${c}px`}#V(t){let e=parseFloat(this.getAttribute("speed")??"1")||1,s=this.#y(e+t);this.setAttribute("speed",String(s))}#Z=t=>{!this.#i||this.#i.hidden||this.#i.contains(t.target)||this.#a?.contains(t.target)||this.#T()};#N=t=>{t.key!=="Escape"||t.defaultPrevented||!this.#i||this.#i.hidden||this.contains(t.target)&&(t.preventDefault(),this.#T(),this.#a?.focus())};#H(){let t=this.getAttribute("for");if(!t){console.warn('<text-reader>: missing "for" attribute'),this.#I();return}if(this.#o=document.getElementById(t),!this.#o){console.warn(`<text-reader>: no element found with id="${t}"`),this.#I();return}this.#_(),this.#tt()}#I(){this.#r&&(this.#r.disabled=!0),this.#p&&(this.#p.disabled=!0)}#tt(){this.#r&&(this.#r.disabled=!1)}#_(){let t=this.#o;if(!t)return;let e=this.getAttribute("selectors")||"p,li",s=[...t.querySelectorAll(e)],i=o=>o.closest("pre")||o.closest("code")||o.closest(v);this.#n=[];let n=0;for(let o of s){if(i(o))continue;let a=[],r="",c=document.createTreeWalker(o,NodeFilter.SHOW_TEXT,{acceptNode:h=>h.parentElement?.closest(v)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT});for(;c.nextNode();){let h=c.currentNode,d=h.data;d&&(a.push({node:h,start:r.length,end:r.length+d.length}),r+=d)}r.trim()&&(this.#n.push({element:o,text:r,speechStart:n,speechEnd:n+r.length,segments:a}),n+=r.length+1)}this.#h=this.#n.map(o=>o.text).join(" ")}#q(){return this.#o?.closest("[lang]")?.getAttribute("lang")||document.documentElement.lang||""}#R(t){if(!this.#h)return;let e=t>0?this.#h.slice(t):this.#h;if(!e.trim())return;let s=e.replace(/[<>]/g," "),i=new SpeechSynthesisUtterance(s),n=this.#q();n&&(i.lang=n),i.rate=this.#y(parseFloat(this.#m?.value??this.getAttribute("speed")??"1")||1);let o=this.#b?.selectedOptions[0];if(o?.dataset.voiceUri){let a=speechSynthesis.getVoices().find(r=>r.voiceURI===o.dataset.voiceUri);a&&(i.voice=a)}else if(n){let a=u(n),r=speechSynthesis.getVoices(),c=r.find(h=>h.lang.toLowerCase()===n.toLowerCase())||r.find(h=>u(h.lang)===a&&h.default)||r.find(h=>u(h.lang)===a);c&&(i.voice=c)}i.onboundary=a=>{if(this.#t!==i||a.name!=="word")return;let r=t+a.charIndex;this.#g=r;let c=a.charLength;if(!c){let d=this.#h.slice(r).match(/^\S+/);c=d?d[0].length:1}this.#nt(r,c),this.#d("text-reader:word",{word:this.#h.slice(r,r+c),charIndex:r,element:this.#O(r)?.element})},i.onend=()=>{if(this.#t!==i)return;let a=Date.now()-this.#P;this.#A(),this.#d("text-reader:end",{duration:a})},i.onerror=a=>{if(this.#t===i){if(a.error==="interrupted"||a.error==="canceled"){this.#A(),this.#d("text-reader:stop");return}console.warn("<text-reader>: SpeechSynthesisUtterance error:",a.error),this.#A(),this.#d("text-reader:error",{error:a.error})}},this.#t=i,this.#s=!0,this.#c=!1,this.#P=Date.now(),this.#g=t,this.#W(!0),speechSynthesis.cancel(),speechSynthesis.speak(i),this.#et(),this.#d("text-reader:play",{voice:i.voice?.name,speed:i.rate})}#k(){let t=this.#g;this.#t=null,speechSynthesis.cancel(),this.#E(),requestAnimationFrame(()=>this.#R(t))}#et(){this.#E(),this.#S=setInterval(()=>{if(!speechSynthesis.speaking){this.#E();return}speechSynthesis.pause(),speechSynthesis.resume()},1e4)}#E(){this.#S&&clearInterval(this.#S),this.#S=null}#st(){if(!CSS.highlights)return;let t=new CSSStyleSheet;t.replaceSync(`
|
|
2
2
|
::highlight(text-reader-word) {
|
|
3
3
|
background-color: var(--text-reader-highlight, Mark);
|
|
4
4
|
color: var(--text-reader-highlight-text, MarkText);
|
|
5
5
|
}
|
|
6
|
-
`),this.#x=t,document.adoptedStyleSheets=[...document.adoptedStyleSheets,t]}#it(){let t=this.#x;t&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(e=>e!==t),this.#x=null),this.#
|
|
6
|
+
`),this.#x=t,document.adoptedStyleSheets=[...document.adoptedStyleSheets,t]}#it(){let t=this.#x;t&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(e=>e!==t),this.#x=null),this.#j()}#nt(t,e){if(!CSS.highlights||this.getAttribute("highlight")==="false")return;let s=this.#O(t);if(!s)return;let i=t-s.speechStart,n=this.#rt(s,i,e);if(!n)return;let o=new Highlight(n);if(CSS.highlights.set("text-reader-word",o),this.#M=o,this.getAttribute("scroll")!=="false"){let a=n.getBoundingClientRect(),r=window.innerHeight;if(a.top<0||a.bottom>r){let c=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;s.element.scrollIntoView({behavior:c?"auto":"smooth",block:"nearest"})}}}#j(){CSS.highlights&&CSS.highlights.delete("text-reader-word"),this.#M=null}#O(t){let e=this.#n,s=0,i=e.length-1;for(;s<=i;){let n=s+i>>>1,o=e[n];if(t<o.speechStart)i=n-1;else if(t>=o.speechEnd)s=n+1;else return o}return null}#rt(t,e,s){let i=t.segments,n=e+s,o=i.find(c=>e>=c.start&&e<c.end);if(!o||!o.node.isConnected)return null;let a=i.find(c=>n>c.start&&n<=c.end)||o,r=document.createRange();return r.setStart(o.node,e-o.start),a.node.isConnected&&a.start>=o.start?r.setEnd(a.node,Math.min(n-a.start,a.node.length)):r.setEnd(o.node,o.node.length),r}async#U(){let t=speechSynthesis.getVoices();return t.length>0?t:new Promise(e=>{let s=()=>{speechSynthesis.removeEventListener("voiceschanged",s),e(speechSynthesis.getVoices())};speechSynthesis.addEventListener("voiceschanged",s),setTimeout(()=>{speechSynthesis.removeEventListener("voiceschanged",s),e(speechSynthesis.getVoices())},3e3)})}#D(t){if(!this.#b||!t.length)return;let e=this.#b;e.innerHTML="";let s=u(this.#q()||"en"),i=c=>u(c.lang)===s,n=t.filter(i),o=t.filter(c=>!i(c)),a=[...n,...o],r=this.getAttribute("voice");for(let c of a){let h=document.createElement("option");h.textContent=`${c.name} (${c.lang})`,h.dataset.voiceUri=c.voiceURI,r&&c.voiceURI===r&&(h.selected=!0),e.append(h)}if(!r){let c=n.find(h=>h.default)||n[0];if(c){let h=[...e.options].find(d=>d.dataset.voiceUri===c.voiceURI);h&&(h.selected=!0)}}}#K(t,e){let s=document.activeElement;t();for(let[i,n]of e)if(i&&n&&s===i&&!n.hidden&&!n.disabled){n.focus();return}}#W(t){if(!this.#r||!this.#u||!this.#p)return;let e=this.#r,s=this.#u,i=this.#p;this.#K(()=>{e.hidden=t,s.hidden=!t,i.disabled=!t},t?[[e,s]]:[[s,e],[i,e]]),this.#L&&(this.#a&&this.#a.setAttribute("aria-pressed",String(t)),t?this.#F():this.#T())}#G(t){if(!this.#r||!this.#u)return;let e=this.#r,s=this.#u;this.#K(()=>{e.hidden=!t,s.hidden=t},t?[[s,e]]:[[e,s]])}#A(){this.#s=!1,this.#c=!1,this.#g=0,this.#t=null,this.#E(),this.#j(),this.#W(!1)}#y(t){return Math.round(Math.max(.5,Math.min(2,t))*10)/10}#d(t,e={}){this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0}))}#ot=()=>{this.#s&&speechSynthesis.cancel()}};m("text-reader",g);export{g as TextReader};
|
|
7
7
|
//# sourceMappingURL=text-reader.js.map
|