class LiteVimeo extends HTMLElement{constructor(){super()}connectedCallback(){this.videoId=encodeURIComponent(this.getAttribute("videoid"));let{width:e,height:t}=vimeoLiteGetThumbnailDimensions(this.getBoundingClientRect());const i=window.devicePixelRatio||1;e*=i,t*=i;let n=`https://lite-vimeo-embed.now.sh/thumb/${this.videoId}`;n+=`.${vimeoLiteCanUseWebP()?"webp":"jpg"}`,n+=`?mw=${e}&mh=${t}&q=${i>1?70:85}`,this.style.backgroundImage=`url("${n}")`;const o=document.createElement("button");o.type="button",o.classList.add("ltv-playbtn"),this.appendChild(o),this.addEventListener("pointerover",LiteVimeo._warmConnections,{once:!0}),this.addEventListener("click",()=>this._addIframe())}static _warmConnections(){LiteVimeo.preconnected||(vimeoLiteAddPrefetch("preconnect","https://player.vimeo.com"),vimeoLiteAddPrefetch("preconnect","https://i.vimeocdn.com"),vimeoLiteAddPrefetch("preconnect","https://f.vimeocdn.com"),vimeoLiteAddPrefetch("preconnect","https://fresnel.vimeocdn.com"),LiteVimeo.preconnected=!0)}_addIframe(){const e=`\n<iframe width="640" height="360" frameborder="0"\n  allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen\n  src="https://player.vimeo.com/video/${this.videoId}?autoplay=1"\n></iframe>`;this.insertAdjacentHTML("beforeend",e),this.classList.add("ltv-activated")}}function vimeoLiteAddPrefetch(e,t,i){const n=document.createElement("link");n.rel=e,n.href=t,i&&(n.as=i),n.crossorigin=!0,document.head.appendChild(n)}function vimeoLiteCanUseWebP(){var e=document.createElement("canvas");return!(!e.getContext||!e.getContext("2d"))&&0===e.toDataURL("image/webp").indexOf("data:image/webp")}function vimeoLiteGetThumbnailDimensions({width:e,height:t}){let i=e=e||960,n=t=t||540;return i%320!=0&&(i=100*Math.ceil(e/100),n=Math.round(i/e*t)),{width:i,height:n}}customElements.define("lite-vimeo",LiteVimeo);