UNPKG

@ktt45678/vidstack

Version:

UI component library for building high-quality, accessible video and audio experiences on the web.

2 lines (1 loc) 3.89 kB
import{ai as w,G as k,o as x,R as C,X as S,q as h,e as c,l as o,b as T,a7 as M,z as P,ak as $,al as F,am as O,an as V,_ as b,s as m,v as L,A as q}from"./vidstack-DgnIG4vb.js";function H(t,e,n){if(t)return o(t,e,n)}function I(t,e){const n=e.composedPath()[0];return C(n)&&t.contains(n)}const d=new Set;{let t=function(){for(const e of d)try{e()}catch{}window.requestAnimationFrame(t)};t()}function N(t){return d.add(t),()=>d.delete(t)}function R(t,e,n){t.hasAttribute(e)||t.setAttribute(e,n)}function D(t,e){if(t.hasAttribute("aria-label")||t.hasAttribute("data-no-label"))return;if(!S(e)){h(t,"aria-label",e);return}function n(){h(t,"aria-label",e())}c(n)}function y(t){const e=getComputedStyle(t);return e.display!=="none"&&parseInt(e.opacity)>0}function z(t){return!!t&&("checkVisibility"in t?t.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0}):y(t))}function j(t,e){return N(()=>e(z(t)))}function B(t,e,n){for(;e;){if(e===t)return!0;if(n?.(e))break;e=e.parentElement}return!1}function G(t,e){o(t,"pointerup",n=>{n.button===0&&!n.defaultPrevented&&e(n)}),o(t,"keydown",n=>{T(n)&&e(n)})}function J(t){return M(t)&&(t.touches.length>1||t.changedTouches.length>1)}function K(t){let e=w(),n=window.requestAnimationFrame(()=>{k(t,e),n=-1});return()=>void window.cancelAnimationFrame(n)}function U(t,e,n){let s,i=t,f=t.parentElement,l=t.content.firstElementChild,u=[];!l&&t.firstElementChild&&(t.innerHTML=t.firstElementChild.outerHTML,t.firstElementChild.remove(),l=t.content.firstElementChild);for(let r=0;r<e;r++)s=document.importNode(l,!0),n?.(s,r),f.insertBefore(s,i.nextSibling),u.push(s),i=s;return x(()=>{for(let r=0;r<u.length;r++)u[r].remove()}),u}function W(t){const e=document.createElement("template");return e.innerHTML=t,e.content}function X(t){return t.cloneNode(!0).firstElementChild}function _(t,e,n,{offsetVarName:s,xOffset:i,yOffset:f,...l}){if(!t)return;const u=n.replace(" ","-").replace("-center","");if(P(t,"visibility",e?null:"hidden"),!e)return;let r=n.includes("top");const E=a=>n.includes("left")?`calc(-1 * ${a})`:a,v=a=>r?`calc(-1 * ${a})`:a;return $(e,t,()=>{F(e,t,{placement:u,middleware:[...l.middleware??[],O({fallbackAxisSideDirection:"start",crossAxis:!1}),V()],...l}).then(({x:a,y:A,middlewareData:g})=>{const p=!!g.flip?.index;r=n.includes(p?"bottom":"top"),t.setAttribute("data-placement",p?n.startsWith("top")?n.replace("top","bottom"):n.replace("bottom","top"):n),Object.assign(t.style,{top:`calc(${A+"px"} + ${v(f?f+"px":`var(--${s}-y-offset, 0px)`)})`,left:`calc(${a+"px"} + ${E(i?i+"px":`var(--${s}-x-offset, 0px)`)})`})})})}function Q(t){return getComputedStyle(t).animationName!=="none"}function Y(t){const e=document.createElement("slot");return e.name=t,e}function Z(t){const e=m(!1);return c(()=>{const n=t();n&&(o(n,"transitionstart",()=>e.set(!0)),o(n,"transitionend",()=>e.set(!1)))}),e}function tt(t,e){function n(){const s=t();if(!s)return;e();const i=new ResizeObserver(L(e));return i.observe(s),()=>i.disconnect()}c(n)}function et(t){const e=nt(t),n=st(t);let s=!1;return q(()=>{const i=e();return s&&!i?!1:(s=i,i||n())})}function nt(t){const e=m(!1);return c(()=>{const n=t();if(!n){e.set(!1);return}o(n,"mouseenter",()=>e.set(!0)),o(n,"mouseleave",()=>e.set(!1))}),e}function st(t){const e=m(!1);return c(()=>{const n=t();if(!n){e.set(!1);return}o(n,"focusin",()=>e.set(!0)),o(n,"focusout",()=>e.set(!1))}),e}function it(t){return t instanceof HTMLElement}function rt(){const t=m("dark"),e=window.matchMedia("(prefers-color-scheme: light)");function n(){t.set(e.matches?"light":"dark")}return n(),o(e,"change",n),t}function ot(t,e){c(()=>{const s=e();if(s==="system"){const i=rt();c(()=>n(i()));return}n(s)});function n(s){b(t,"light",s==="light"),b(t,"dark",s==="dark")}}export{it as a,et as b,Z as c,Y as d,D as e,U as f,B as g,Q as h,J as i,I as j,y as k,_ as l,j as m,W as n,G as o,X as p,H as q,K as r,R as s,tt as u,ot as w};