mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
2 lines
16 KiB
JavaScript
2 lines
16 KiB
JavaScript
var H=Math.min,B=Math.max,ot=Math.round,it=Math.floor,L=t=>({x:t,y:t}),qt={left:"right",right:"left",bottom:"top",top:"bottom"},Ut={start:"end",end:"start"};function lt(t,e,n){return B(t,H(e,n))}function U(t,e){return typeof t=="function"?t(e):t}function V(t){return t.split("-")[0]}function K(t){return t.split("-")[1]}function pt(t){return t==="x"?"y":"x"}function at(t){return t==="y"?"height":"width"}var Kt=new Set(["top","bottom"]);function W(t){return Kt.has(V(t))?"y":"x"}function ft(t){return pt(W(t))}function Ot(t,e,n){n===void 0&&(n=!1);let o=K(t),i=ft(t),r=at(i),s=i==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(s=nt(s)),[s,nt(s)]}function Rt(t){let e=nt(t);return[ct(t),e,ct(e)]}function ct(t){return t.replace(/start|end/g,e=>Ut[e])}var bt=["left","right"],At=["right","left"],Gt=["top","bottom"],Jt=["bottom","top"];function Qt(t,e,n){switch(t){case"top":case"bottom":return n?e?At:bt:e?bt:At;case"left":case"right":return e?Gt:Jt;default:return[]}}function St(t,e,n,o){let i=K(t),r=Qt(V(t),n==="start",o);return i&&(r=r.map(s=>s+"-"+i),e&&(r=r.concat(r.map(ct)))),r}function nt(t){return t.replace(/left|right|bottom|top/g,e=>qt[e])}function Zt(t){return{top:0,right:0,bottom:0,left:0,...t}}function wt(t){return typeof t!="number"?Zt(t):{top:t,right:t,bottom:t,left:t}}function X(t){let{x:e,y:n,width:o,height:i}=t;return{width:o,height:i,top:n,left:e,right:e+o,bottom:n+i,x:e,y:n}}function Ct(t,e,n){let{reference:o,floating:i}=t,r=W(e),s=ft(e),c=at(s),a=V(e),l=r==="y",d=o.x+o.width/2-i.width/2,u=o.y+o.height/2-i.height/2,g=o[c]/2-i[c]/2,f;switch(a){case"top":f={x:d,y:o.y-i.height};break;case"bottom":f={x:d,y:o.y+o.height};break;case"right":f={x:o.x+o.width,y:u};break;case"left":f={x:o.x-i.width,y:u};break;default:f={x:o.x,y:o.y}}switch(K(e)){case"start":f[s]-=g*(n&&l?-1:1);break;case"end":f[s]+=g*(n&&l?-1:1);break}return f}var Pt=async(t,e,n)=>{let{placement:o="bottom",strategy:i="absolute",middleware:r=[],platform:s}=n,c=r.filter(Boolean),a=await(s.isRTL==null?void 0:s.isRTL(e)),l=await s.getElementRects({reference:t,floating:e,strategy:i}),{x:d,y:u}=Ct(l,o,a),g=o,f={},m=0;for(let h=0;h<c.length;h++){let{name:w,fn:p}=c[h],{x,y,data:b,reset:v}=await p({x:d,y:u,initialPlacement:o,placement:g,strategy:i,middlewareData:f,rects:l,platform:s,elements:{reference:t,floating:e}});d=x??d,u=y??u,f={...f,[w]:{...f[w],...b}},v&&m<=50&&(m++,typeof v=="object"&&(v.placement&&(g=v.placement),v.rects&&(l=v.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:i}):v.rects),{x:d,y:u}=Ct(l,g,a)),h=-1)}return{x:d,y:u,placement:g,strategy:i,middlewareData:f}};async function xt(t,e){var n;e===void 0&&(e={});let{x:o,y:i,platform:r,rects:s,elements:c,strategy:a}=t,{boundary:l="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:g=!1,padding:f=0}=U(e,t),m=wt(f),w=c[g?u==="floating"?"reference":"floating":u],p=X(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(w)))==null||n?w:w.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(c.floating)),boundary:l,rootBoundary:d,strategy:a})),x=u==="floating"?{x:o,y:i,width:s.floating.width,height:s.floating.height}:s.reference,y=await(r.getOffsetParent==null?void 0:r.getOffsetParent(c.floating)),b=await(r.isElement==null?void 0:r.isElement(y))?await(r.getScale==null?void 0:r.getScale(y))||{x:1,y:1}:{x:1,y:1},v=X(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:x,offsetParent:y,strategy:a}):x);return{top:(p.top-v.top+m.top)/b.y,bottom:(v.bottom-p.bottom+m.bottom)/b.y,left:(p.left-v.left+m.left)/b.x,right:(v.right-p.right+m.right)/b.x}}var Tt=t=>({name:"arrow",options:t,async fn(e){let{x:n,y:o,placement:i,rects:r,platform:s,elements:c,middlewareData:a}=e,{element:l,padding:d=0}=U(t,e)||{};if(l==null)return{};let u=wt(d),g={x:n,y:o},f=ft(i),m=at(f),h=await s.getDimensions(l),w=f==="y",p=w?"top":"left",x=w?"bottom":"right",y=w?"clientHeight":"clientWidth",b=r.reference[m]+r.reference[f]-g[f]-r.floating[m],v=g[f]-r.reference[f],M=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l)),R=M?M[y]:0;(!R||!await(s.isElement==null?void 0:s.isElement(M)))&&(R=c.floating[y]||r.floating[m]);let Z=b/2-v/2,_=R/2-h[m]/2-1,F=H(u[p],_),tt=H(u[x],_),z=F,et=R-h[m]-tt,A=R/2-h[m]/2+Z,I=lt(z,A,et),k=!a.arrow&&K(i)!=null&&A!==I&&r.reference[m]/2-(A<z?F:tt)-h[m]/2<0,P=k?A<z?A-z:A-et:0;return{[f]:g[f]+P,data:{[f]:I,centerOffset:A-I-P,...k&&{alignmentOffset:P}},reset:k}}});var Lt=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,o;let{placement:i,middlewareData:r,rects:s,initialPlacement:c,platform:a,elements:l}=e,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:g,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:h=!0,...w}=U(t,e);if((n=r.arrow)!=null&&n.alignmentOffset)return{};let p=V(i),x=W(c),y=V(c)===c,b=await(a.isRTL==null?void 0:a.isRTL(l.floating)),v=g||(y||!h?[nt(c)]:Rt(c)),M=m!=="none";!g&&M&&v.push(...St(c,h,m,b));let R=[c,...v],Z=await xt(e,w),_=[],F=((o=r.flip)==null?void 0:o.overflows)||[];if(d&&_.push(Z[p]),u){let A=Ot(i,s,b);_.push(Z[A[0]],Z[A[1]])}if(F=[...F,{placement:i,overflows:_}],!_.every(A=>A<=0)){var tt,z;let A=(((tt=r.flip)==null?void 0:tt.index)||0)+1,I=R[A];if(I&&(!(u==="alignment"?x!==W(I):!1)||F.every(T=>W(T.placement)===x?T.overflows[0]>0:!0)))return{data:{index:A,overflows:F},reset:{placement:I}};let k=(z=F.filter(P=>P.overflows[0]<=0).sort((P,T)=>P.overflows[1]-T.overflows[1])[0])==null?void 0:z.placement;if(!k)switch(f){case"bestFit":{var et;let P=(et=F.filter(T=>{if(M){let $=W(T.placement);return $===x||$==="y"}return!0}).map(T=>[T.placement,T.overflows.filter($=>$>0).reduce(($,Yt)=>$+Yt,0)]).sort((T,$)=>T[1]-$[1])[0])==null?void 0:et[0];P&&(k=P);break}case"initialPlacement":k=c;break}if(i!==k)return{reset:{placement:k}}}return{}}}};var te=new Set(["left","top"]);async function ee(t,e){let{placement:n,platform:o,elements:i}=t,r=await(o.isRTL==null?void 0:o.isRTL(i.floating)),s=V(n),c=K(n),a=W(n)==="y",l=te.has(s)?-1:1,d=r&&a?-1:1,u=U(e,t),{mainAxis:g,crossAxis:f,alignmentAxis:m}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return c&&typeof m=="number"&&(f=c==="end"?m*-1:m),a?{x:f*d,y:g*l}:{x:g*l,y:f*d}}var Et=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,o;let{x:i,y:r,placement:s,middlewareData:c}=e,a=await ee(e,t);return s===((n=c.offset)==null?void 0:n.placement)&&(o=c.arrow)!=null&&o.alignmentOffset?{}:{x:i+a.x,y:r+a.y,data:{...a,placement:s}}}}},Dt=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:n,y:o,placement:i}=e,{mainAxis:r=!0,crossAxis:s=!1,limiter:c={fn:w=>{let{x:p,y:x}=w;return{x:p,y:x}}},...a}=U(t,e),l={x:n,y:o},d=await xt(e,a),u=W(V(i)),g=pt(u),f=l[g],m=l[u];if(r){let w=g==="y"?"top":"left",p=g==="y"?"bottom":"right",x=f+d[w],y=f-d[p];f=lt(x,f,y)}if(s){let w=u==="y"?"top":"left",p=u==="y"?"bottom":"right",x=m+d[w],y=m-d[p];m=lt(x,m,y)}let h=c.fn({...e,[g]:f,[u]:m});return{...h,data:{x:h.x-n,y:h.y-o,enabled:{[g]:r,[u]:s}}}}}};function ut(){return typeof window<"u"}function j(t){return Ft(t)?(t.nodeName||"").toLowerCase():"#document"}function O(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function E(t){var e;return(e=(Ft(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Ft(t){return ut()?t instanceof Node||t instanceof O(t).Node:!1}function S(t){return ut()?t instanceof Element||t instanceof O(t).Element:!1}function D(t){return ut()?t instanceof HTMLElement||t instanceof O(t).HTMLElement:!1}function Mt(t){return!ut()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof O(t).ShadowRoot}var ne=new Set(["inline","contents"]);function J(t){let{overflow:e,overflowX:n,overflowY:o,display:i}=C(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!ne.has(i)}var oe=new Set(["table","td","th"]);function kt(t){return oe.has(j(t))}var ie=[":popover-open",":modal"];function st(t){return ie.some(e=>{try{return t.matches(e)}catch{return!1}})}var se=["transform","translate","scale","rotate","perspective"],re=["transform","translate","scale","rotate","perspective","filter"],ce=["paint","layout","strict","content"];function dt(t){let e=mt(),n=S(t)?C(t):t;return se.some(o=>n[o]?n[o]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||re.some(o=>(n.willChange||"").includes(o))||ce.some(o=>(n.contain||"").includes(o))}function Bt(t){let e=N(t);for(;D(e)&&!Y(e);){if(dt(e))return e;if(st(e))return null;e=N(e)}return null}function mt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}var le=new Set(["html","body","#document"]);function Y(t){return le.has(j(t))}function C(t){return O(t).getComputedStyle(t)}function rt(t){return S(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function N(t){if(j(t)==="html")return t;let e=t.assignedSlot||t.parentNode||Mt(t)&&t.host||E(t);return Mt(e)?e.host:e}function Wt(t){let e=N(t);return Y(e)?t.ownerDocument?t.ownerDocument.body:t.body:D(e)&&J(e)?e:Wt(e)}function G(t,e,n){var o;e===void 0&&(e=[]),n===void 0&&(n=!0);let i=Wt(t),r=i===((o=t.ownerDocument)==null?void 0:o.body),s=O(i);if(r){let c=gt(s);return e.concat(s,s.visualViewport||[],J(i)?i:[],c&&n?G(c):[])}return e.concat(i,G(i,[],n))}function gt(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Vt(t){let e=C(t),n=parseFloat(e.width)||0,o=parseFloat(e.height)||0,i=D(t),r=i?t.offsetWidth:n,s=i?t.offsetHeight:o,c=ot(n)!==r||ot(o)!==s;return c&&(n=r,o=s),{width:n,height:o,$:c}}function vt(t){return S(t)?t:t.contextElement}function Q(t){let e=vt(t);if(!D(e))return L(1);let n=e.getBoundingClientRect(),{width:o,height:i,$:r}=Vt(e),s=(r?ot(n.width):n.width)/o,c=(r?ot(n.height):n.height)/i;return(!s||!Number.isFinite(s))&&(s=1),(!c||!Number.isFinite(c))&&(c=1),{x:s,y:c}}var ae=L(0);function _t(t){let e=O(t);return!mt()||!e.visualViewport?ae:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function fe(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==O(t)?!1:e}function q(t,e,n,o){e===void 0&&(e=!1),n===void 0&&(n=!1);let i=t.getBoundingClientRect(),r=vt(t),s=L(1);e&&(o?S(o)&&(s=Q(o)):s=Q(t));let c=fe(r,n,o)?_t(r):L(0),a=(i.left+c.x)/s.x,l=(i.top+c.y)/s.y,d=i.width/s.x,u=i.height/s.y;if(r){let g=O(r),f=o&&S(o)?O(o):o,m=g,h=gt(m);for(;h&&o&&f!==m;){let w=Q(h),p=h.getBoundingClientRect(),x=C(h),y=p.left+(h.clientLeft+parseFloat(x.paddingLeft))*w.x,b=p.top+(h.clientTop+parseFloat(x.paddingTop))*w.y;a*=w.x,l*=w.y,d*=w.x,u*=w.y,a+=y,l+=b,m=O(h),h=gt(m)}}return X({width:d,height:u,x:a,y:l})}function ht(t,e){let n=rt(t).scrollLeft;return e?e.left+n:q(E(t)).left+n}function zt(t,e){let n=t.getBoundingClientRect(),o=n.left+e.scrollLeft-ht(t,n),i=n.top+e.scrollTop;return{x:o,y:i}}function ue(t){let{elements:e,rect:n,offsetParent:o,strategy:i}=t,r=i==="fixed",s=E(o),c=e?st(e.floating):!1;if(o===s||c&&r)return n;let a={scrollLeft:0,scrollTop:0},l=L(1),d=L(0),u=D(o);if((u||!u&&!r)&&((j(o)!=="body"||J(s))&&(a=rt(o)),D(o))){let f=q(o);l=Q(o),d.x=f.x+o.clientLeft,d.y=f.y+o.clientTop}let g=s&&!u&&!r?zt(s,a):L(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-a.scrollLeft*l.x+d.x+g.x,y:n.y*l.y-a.scrollTop*l.y+d.y+g.y}}function de(t){return Array.from(t.getClientRects())}function me(t){let e=E(t),n=rt(t),o=t.ownerDocument.body,i=B(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),r=B(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight),s=-n.scrollLeft+ht(t),c=-n.scrollTop;return C(o).direction==="rtl"&&(s+=B(e.clientWidth,o.clientWidth)-i),{width:i,height:r,x:s,y:c}}var Nt=25;function ge(t,e){let n=O(t),o=E(t),i=n.visualViewport,r=o.clientWidth,s=o.clientHeight,c=0,a=0;if(i){r=i.width,s=i.height;let d=mt();(!d||d&&e==="fixed")&&(c=i.offsetLeft,a=i.offsetTop)}let l=ht(o);if(l<=0){let d=o.ownerDocument,u=d.body,g=getComputedStyle(u),f=d.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,m=Math.abs(o.clientWidth-u.clientWidth-f);m<=Nt&&(r-=m)}else l<=Nt&&(r+=l);return{width:r,height:s,x:c,y:a}}var he=new Set(["absolute","fixed"]);function pe(t,e){let n=q(t,!0,e==="fixed"),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=D(t)?Q(t):L(1),s=t.clientWidth*r.x,c=t.clientHeight*r.y,a=i*r.x,l=o*r.y;return{width:s,height:c,x:a,y:l}}function $t(t,e,n){let o;if(e==="viewport")o=ge(t,n);else if(e==="document")o=me(E(t));else if(S(e))o=pe(e,n);else{let i=_t(t);o={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return X(o)}function It(t,e){let n=N(t);return n===e||!S(n)||Y(n)?!1:C(n).position==="fixed"||It(n,e)}function we(t,e){let n=e.get(t);if(n)return n;let o=G(t,[],!1).filter(c=>S(c)&&j(c)!=="body"),i=null,r=C(t).position==="fixed",s=r?N(t):t;for(;S(s)&&!Y(s);){let c=C(s),a=dt(s);!a&&c.position==="fixed"&&(i=null),(r?!a&&!i:!a&&c.position==="static"&&!!i&&he.has(i.position)||J(s)&&!a&&It(t,s))?o=o.filter(d=>d!==s):i=c,s=N(s)}return e.set(t,o),o}function xe(t){let{element:e,boundary:n,rootBoundary:o,strategy:i}=t,s=[...n==="clippingAncestors"?st(e)?[]:we(e,this._c):[].concat(n),o],c=s[0],a=s.reduce((l,d)=>{let u=$t(e,d,i);return l.top=B(u.top,l.top),l.right=H(u.right,l.right),l.bottom=H(u.bottom,l.bottom),l.left=B(u.left,l.left),l},$t(e,c,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function ye(t){let{width:e,height:n}=Vt(t);return{width:e,height:n}}function ve(t,e,n){let o=D(e),i=E(e),r=n==="fixed",s=q(t,!0,r,e),c={scrollLeft:0,scrollTop:0},a=L(0);function l(){a.x=ht(i)}if(o||!o&&!r)if((j(e)!=="body"||J(i))&&(c=rt(e)),o){let f=q(e,!0,r,e);a.x=f.x+e.clientLeft,a.y=f.y+e.clientTop}else i&&l();r&&!o&&i&&l();let d=i&&!o&&!r?zt(i,c):L(0),u=s.left+c.scrollLeft-a.x-d.x,g=s.top+c.scrollTop-a.y-d.y;return{x:u,y:g,width:s.width,height:s.height}}function yt(t){return C(t).position==="static"}function Ht(t,e){if(!D(t)||C(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return E(t)===n&&(n=n.ownerDocument.body),n}function Xt(t,e){let n=O(t);if(st(t))return n;if(!D(t)){let i=N(t);for(;i&&!Y(i);){if(S(i)&&!yt(i))return i;i=N(i)}return n}let o=Ht(t,e);for(;o&&kt(o)&&yt(o);)o=Ht(o,e);return o&&Y(o)&&yt(o)&&!dt(o)?n:o||Bt(t)||n}var be=async function(t){let e=this.getOffsetParent||Xt,n=this.getDimensions,o=await n(t.floating);return{reference:ve(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function Ae(t){return C(t).direction==="rtl"}var Oe={convertOffsetParentRelativeRectToViewportRelativeRect:ue,getDocumentElement:E,getClippingRect:xe,getOffsetParent:Xt,getElementRects:be,getClientRects:de,getDimensions:ye,getScale:Q,isElement:S,isRTL:Ae};function jt(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function Re(t,e){let n=null,o,i=E(t);function r(){var c;clearTimeout(o),(c=n)==null||c.disconnect(),n=null}function s(c,a){c===void 0&&(c=!1),a===void 0&&(a=1),r();let l=t.getBoundingClientRect(),{left:d,top:u,width:g,height:f}=l;if(c||e(),!g||!f)return;let m=it(u),h=it(i.clientWidth-(d+g)),w=it(i.clientHeight-(u+f)),p=it(d),y={rootMargin:-m+"px "+-h+"px "+-w+"px "+-p+"px",threshold:B(0,H(1,a))||1},b=!0;function v(M){let R=M[0].intersectionRatio;if(R!==a){if(!b)return s();R?s(!1,R):o=setTimeout(()=>{s(!1,1e-7)},1e3)}R===1&&!jt(l,t.getBoundingClientRect())&&s(),b=!1}try{n=new IntersectionObserver(v,{...y,root:i.ownerDocument})}catch{n=new IntersectionObserver(v,y)}n.observe(t)}return s(!0),r}function Se(t,e,n,o){o===void 0&&(o={});let{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:a=!1}=o,l=vt(t),d=i||r?[...l?G(l):[],...G(e)]:[];d.forEach(p=>{i&&p.addEventListener("scroll",n,{passive:!0}),r&&p.addEventListener("resize",n)});let u=l&&c?Re(l,n):null,g=-1,f=null;s&&(f=new ResizeObserver(p=>{let[x]=p;x&&x.target===l&&f&&(f.unobserve(e),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var y;(y=f)==null||y.observe(e)})),n()}),l&&!a&&f.observe(l),f.observe(e));let m,h=a?q(t):null;a&&w();function w(){let p=q(t);h&&!jt(h,p)&&n(),h=p,m=requestAnimationFrame(w)}return n(),()=>{var p;d.forEach(x=>{i&&x.removeEventListener("scroll",n),r&&x.removeEventListener("resize",n)}),u?.(),(p=f)==null||p.disconnect(),f=null,a&&cancelAnimationFrame(m)}}var Ce=Et;var Pe=Dt,Te=Lt;var Le=Tt;var Ee=(t,e,n)=>{let o=new Map,i={platform:Oe,...n},r={...i.platform,_c:o};return Pt(t,e,{...i,platform:r})};export{Le as arrow,Se as autoUpdate,Ee as computePosition,Te as flip,Ce as offset,Pe as shift};
|