mirror of
https://github.com/tenrok/OverlayScrollbars.git
synced 2026-06-21 02:10:37 +03:00
1 line
25 KiB
JavaScript
1 line
25 KiB
JavaScript
function t(e,n){if(g(e))for(let t=0;t<e.length&&!1!==n(e[t],t,e);t++);else e&&t(Object.keys(e),(t=>n(e[t],t,e)));return e}function e(e,n){const o=d(n);if(f(n)||o){let t=o?"":{};if(e){const r=window.getComputedStyle(e,null);t=o?mt(e,r,n):n.reduce(((t,n)=>(t[n]=mt(e,r,n),t)),t)}return t}t(L(n),(t=>xt(e,t,n[t])))}const n=(t,e)=>{const{o:n,u:o,_:r}=t;let i,s=n;const l=(t,e)=>{const n=s,l=t,c=e||(o?!o(n,l):n!==l);return(c||r)&&(s=l,i=n),[s,c,i]};return[e?t=>l(e(s,i),t):l,t=>[s,!!t,i]]},o=Node.ELEMENT_NODE,{toString:r,hasOwnProperty:i}=Object.prototype,s=t=>void 0===t,l=t=>null===t,c=t=>s(t)||l(t)?`${t}`:r.call(t).replace(/^\[object (.+)\]$/,"$1").toLowerCase(),a=t=>"number"==typeof t,d=t=>"string"==typeof t,u=t=>"boolean"==typeof t,h=t=>"function"==typeof t,f=t=>Array.isArray(t),p=t=>"object"==typeof t&&!f(t)&&!l(t),g=t=>{const e=!!t&&t.length,n=a(e)&&e>-1&&e%1==0;return!(!(f(t)||!h(t)&&n)||e>0&&p(t)&&!(e-1 in t))},w=t=>{if(!t||!p(t)||"object"!==c(t))return!1;let e;const n="constructor",o=t[n],r=o&&o.prototype,l=i.call(t,n),a=r&&i.call(r,"isPrototypeOf");if(o&&!l&&!a)return!1;for(e in t);return s(e)||i.call(t,e)},b=t=>{const e=HTMLElement;return!!t&&(e?t instanceof e:t.nodeType===o)},v=t=>{const e=Element;return!!t&&(e?t instanceof e:t.nodeType===o)},y=(t,e,n)=>t.indexOf(e,n),m=(t,e,n)=>(n||d(e)||!g(e)?t.push(e):Array.prototype.push.apply(t,e),t),x=e=>{const n=Array.from,o=[];return n&&e?n(e):(e instanceof Set?e.forEach((t=>{m(o,t)})):t(e,(t=>{m(o,t)})),o)},$=t=>!!t&&0===t.length,O=(e,n,o)=>{t(e,(t=>t&&t.apply(void 0,n||[]))),!o&&(e.length=0)},S=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),L=t=>t?Object.keys(t):[],C=(e,n,o,r,i,s,c)=>{const a=[n,o,r,i,s,c];return"object"==typeof e&&!l(e)||h(e)||(e={}),t(a,(n=>{t(L(n),(t=>{const o=n[t];if(e===o)return!0;const r=f(o);if(o&&(w(o)||r)){const n=e[t];let i=n;r&&!f(n)?i=[]:r||w(n)||(i={}),e[t]=C(i,o)}else e[t]=o}))})),e},B=t=>{for(const e in t)return!1;return!0},A=(t,e,n,o)=>{if(s(o))return n?n[t]:e;n&&!l(o)&&!1!==o&&(n[t]=o)},E=(t,e,n)=>{if(s(n))return t?t.getAttribute(e):null;t&&t.setAttribute(e,n)},M=(t,e,n,o)=>{if(n){const r=E(t,e)||"",i=new Set(r.split(" "));i[o?"add":"delete"](n),E(t,e,x(i).join(" ").trim())}},R=(t,e)=>{t&&t.removeAttribute(e)},P=(t,e)=>A("scrollLeft",0,t,e),z=(t,e)=>A("scrollTop",0,t,e),H=Element.prototype,T=(t,e)=>{const n=[],o=e?v(e)?e:null:document;return o?m(n,o.querySelectorAll(t)):n},k=(t,e)=>!!v(t)&&(H.matches||H.msMatchesSelector).call(t,e),D=t=>t?x(t.childNodes):[],_=t=>t?t.parentElement:null,j=(t,e)=>{if(v(t)){const n=H.closest;if(n)return n.call(t,e);do{if(k(t,e))return t;t=_(t)}while(t)}return null},I=(e,n,o)=>{if(o){let r,i=n;e&&(g(o)?(r=document.createDocumentFragment(),t(o,(t=>{t===i&&(i=t.previousSibling),r.appendChild(t)}))):r=o,n&&(i?i!==n&&(i=i.nextSibling):i=e.firstChild),e.insertBefore(r,i||null))}},X=(t,e)=>{I(t,null,e)},N=(t,e)=>{I(t,t&&t.firstChild,e)},V=(t,e)=>{I(_(t),t&&t.nextSibling,e)},F=e=>{if(g(e))t(x(e),(t=>F(t)));else if(e){const t=_(e);t&&t.removeChild(e)}},W=t=>{const e=document.createElement("div");return t&&E(e,"class",t),e},Y=e=>{const n=W();return n.innerHTML=e.trim(),t(D(n),(t=>F(t)))},K=t=>t.charAt(0).toUpperCase()+t.slice(1),Z=["-webkit-","-moz-","-o-","-ms-"],q=["WebKit","Moz","O","MS","webkit","moz","o","ms"],U={},G={},J=e=>{let n=G[e];if(S(G,e))return n;const o=K(e),r=W().style;return t(Z,(t=>{const i=t.replace(/-/g,""),s=[e,t+e,i+o,K(i)+o];return!(n=s.find((t=>void 0!==r[t])))})),G[e]=n||""},Q=e=>{let n=U[e]||window[e];return S(U,e)||(t(q,(t=>(n=n||window[t+K(e)],!n))),U[e]=n),n},tt=Q("MutationObserver"),et=Q("IntersectionObserver"),nt=Q("ResizeObserver"),ot=Q("cancelAnimationFrame"),rt=Q("requestAnimationFrame"),it=window.setTimeout,st=window.clearTimeout,lt=/[^\x20\t\r\n\f]+/g,ct=(t,e,n)=>{const o=t&&t.classList;let r,i=0,s=!1;if(o&&e&&d(e)){const t=e.match(lt)||[];for(s=t.length>0;r=t[i++];)s=!!n(o,r)&&s}return s},at=(t,e)=>{ct(t,e,((t,e)=>t.remove(e)))},dt=(t,e)=>(ct(t,e,((t,e)=>t.add(e))),at.bind(0,t,e)),ut=(e,n,o,r)=>{if(e&&n){let i=!0;return t(o,(t=>{(r?r(e[t]):e[t])!==(r?r(n[t]):n[t])&&(i=!1)})),i}return!1},ht=(t,e)=>ut(t,e,["w","h"]),ft=(t,e)=>ut(t,e,["x","y"]),pt=(t,e)=>ut(t,e,["t","r","b","l"]),gt=(t,e,n)=>ut(t,e,["width","height"],n&&(t=>Math.round(t))),wt=()=>{},bt=(t,e)=>{let n,o,r,i=wt;const{g:s,v:l,p:c}=e||{},d=function(e){i(),st(n),n=o=void 0,i=wt,t.apply(this,e)},u=t=>c&&o?c(o,t):t,f=()=>{i!==wt&&d(u(r)||r)},p=function(){const t=x(arguments),e=h(s)?s():s,c=a(e)&&e>=0;if(c){const s=h(l)?l():l,c=a(s)&&s>=0,p=e>0?it:rt,g=e>0?st:ot,w=u(t)||t,b=d.bind(0,w);i();const v=p(b,e);i=()=>g(v),c&&!n&&(n=it(f,s)),o=r=w}else d(t)};return p.m=f,p},vt={opacity:1,zindex:1},yt=(t,e)=>{const n=e?parseFloat(t):parseInt(t,10);return n==n?n:0},mt=(t,e,n)=>null!=e?e[n]||e.getPropertyValue(n):t.style[n],xt=(t,e,n)=>{try{if(t){const{style:o}=t;s(o[e])?o.setProperty(e,n):o[e]=((t,e)=>!vt[t.toLowerCase()]&&a(e)?`${e}px`:e)(e,n)}}catch(H){}},$t=(t,n,o)=>{const r=n?`${n}-`:"",i=o?`-${o}`:"",s=`${r}top${i}`,l=`${r}right${i}`,c=`${r}bottom${i}`,a=`${r}left${i}`,d=e(t,[s,l,c,a]);return{t:yt(d[s]),r:yt(d[l]),b:yt(d[c]),l:yt(d[a])}},Ot={w:0,h:0},St=t=>t?{w:t.offsetWidth,h:t.offsetHeight}:Ot,Lt=t=>t?{w:t.clientWidth,h:t.clientHeight}:Ot,Ct=t=>t?{w:t.scrollWidth,h:t.scrollHeight}:Ot,Bt=t=>{const n=parseFloat(e(t,"height"))||0,o=parseFloat(e(t,"height"))||0;return{w:o-Math.round(o),h:n-Math.round(n)}},At=t=>t.getBoundingClientRect();let Et;const Mt=t=>t.split(" "),Rt=(e,n,o,r)=>{t(Mt(n),(t=>{e.removeEventListener(t,o,r)}))},Pt=(e,n,o,r)=>{var i;const l=(()=>{if(s(Et)){Et=!1;try{window.addEventListener("test",null,Object.defineProperty({},"passive",{get(){Et=!0}}))}catch(e){}}return Et})(),c=null!=(i=l&&r&&r.S)?i:l,a=r&&r.C||!1,d=r&&r.$||!1,u=[],h=l?{passive:c,capture:a}:a;return t(Mt(n),(t=>{const n=d?r=>{e.removeEventListener(t,n,a),o&&o(r)}:o;m(u,Rt.bind(null,e,t,n,a)),e.addEventListener(t,n,h)})),O.bind(0,u)},zt=t=>t.stopPropagation(),Ht={x:0,y:0},Tt=t=>{const e=t?At(t):0;return e?{x:e.left+window.pageYOffset,y:e.top+window.pageXOffset}:Ht},kt=(e,n)=>{t(f(n)?n:[n],e)},Dt=e=>{const n=new Map,o=(t,e)=>{if(t){const o=n.get(t);kt((t=>{o&&o[t?"delete":"clear"](t)}),e)}else n.forEach((t=>{t.clear()})),n.clear()},r=(t,e)=>{const r=n.get(t)||new Set;return n.set(t,r),kt((t=>{t&&r.add(t)}),e),o.bind(0,t,e)};return t(L(e),(t=>{r(t,e[t])})),[r,o,(e,o)=>{const r=n.get(e);t(x(r),(t=>{o&&!$(o)?t.apply(0,o):t()}))}]},_t=(t,e)=>t?e.split(".").reduce(((t,e)=>t&&S(t,e)?t[e]:void 0),t):void 0,jt=(t,e,n)=>o=>[_t(t,o),n||void 0!==_t(e,o)],It=t=>{let e=t;return[()=>e,t=>{e=C({},e,t)}]},Xt="os-environment",Nt=`${Xt}-flexbox-glue`,Vt=`${Nt}-max`,Ft="data-overlayscrollbars",Wt=`${Ft}-overflow-x`,Yt=`${Ft}-overflow-y`,Kt="overflowVisible",Zt="scrollbarHidden",qt="os-padding",Ut="os-viewport",Gt=`${Ut}-arrange`,Jt="os-content",Qt=`${Ut}-scrollbar-hidden`,te=`os-overflow-visible`,ee="os-size-observer",ne=`${ee}-appear`,oe=`${ee}-listener`,re=`${oe}-scroll`,ie=`${oe}-item`,se=`${ie}-final`,le="os-trinsic-observer",ce="os-scrollbar",ae=`${ce}-horizontal`,de=`${ce}-vertical`,ue="os-scrollbar-track",he="os-scrollbar-handle",fe=`${ce}-visible`,pe=`${ce}-cornerless`,ge=`${ce}-transitionless`,we=`${ce}-interaction`,be=`${ce}-auto-hidden`,ve=t=>JSON.stringify(t,((t,e)=>{if(h(e))throw new Error;return e})),ye={paddingAbsolute:!1,showNativeOverlaidScrollbars:!1,updating:{elementEvents:[["img","load"]],debounce:[0,33],attributes:null,ignoreMutation:null},overflow:{x:"scroll",y:"scroll"},scrollbars:{theme:"os-theme-dark",visibility:"auto",autoHide:"never",autoHideDelay:800,dragScroll:!0,clickScroll:!1,touch:!0}},me=(e,n)=>{const o={};return t(L(n).concat(L(e)),(t=>{const r=e[t],i=n[t];if(p(r)&&p(i))C(o[t]={},me(r,i));else if(S(n,t)&&i!==r){let e=!0;if(f(r)||f(i))try{ve(r)===ve(i)&&(e=!1)}catch(U){}e&&(o[t]=i)}})),o},xe={},$e=()=>C({},xe),Oe="__osOptionsValidationPlugin",Se=3333333,Le="scroll",Ce="__osSizeObserverPlugin",Be={[Ce]:{O:(t,n,o)=>{const r=Y(`<div class="${ie}" dir="ltr"><div class="${ie}"><div class="${se}"></div></div><div class="${ie}"><div class="${se}" style="width: 200%; height: 200%"></div></div></div>`);X(t,r),dt(t,re);const i=r[0],s=i.lastChild,l=i.firstChild,c=null==l?void 0:l.firstChild;let a,d=St(i),u=d,h=!1;const f=()=>{P(l,Se),z(l,Se),P(s,Se),z(s,Se)},p=t=>{a=0,h&&(d=u,n(!0===t))},g=t=>{u=St(i),h=!t||!ht(u,d),t?(zt(t),h&&!a&&(ot(a),a=rt(p))):p(!1===t),f()},w=m([],[Pt(l,Le,g),Pt(s,Le,g)]);return e(c,{width:Se,height:Se}),f(),[o?g.bind(0,!1):f,w]}}};let Ae=0;const{round:Ee,abs:Me}=Math,Re="__osScrollbarsHidingPlugin",Pe={[Re]:{I:t=>{const{A:e,T:n,D:o}=t,r=!(o||e||!n.x&&!n.y)&&document.createElement("style");return r&&(E(r,"id",`${Gt}-${Ae}`),Ae++),r},P:(n,o,r,i,s,l,c)=>[(t,o,l,c)=>{if(n){const{H:n}=s(),{L:a,M:d}=t,{x:u,y:h}=d,{x:f,y:p}=a,g=n[c?"paddingRight":"paddingLeft"],w=n.paddingTop,b=o.w+l.w,v=o.h+l.h,y={w:p&&h?`${p+b-g}px`:"",h:f&&u?`${f+v-w}px`:""};if(i){const{sheet:t}=i;if(t){const{cssRules:e}=t;if(e){e.length||t.insertRule(`#${E(i,"id")} + .${Gt}::before {}`,0);const n=e[0].style;n.width=y.w,n.height=y.h}}}else e(r,{"--os-vaw":y.w,"--os-vah":y.h})}return n},(i,a,d)=>{if(n){const u=d||l(i),{H:h}=s(),{M:f}=u,{x:p,y:g}=f,w={},b=e=>t(e.split(" "),(t=>{w[t]=h[t]}));p&&b("marginBottom paddingTop paddingBottom"),g&&b("marginLeft marginRight paddingLeft paddingRight");const v=e(r,L(w));return at(r,Gt),o||(w.height=""),e(r,w),[()=>{c(u,a,n,v),e(r,v),dt(r,Gt)},u]}return[wt]}],R:()=>{let t={w:0,h:0},e=0;return(n,o,r)=>{const i={w:window.innerWidth,h:window.innerHeight},s={w:i.w-t.w,h:i.h-t.h};if(0===s.w&&0===s.h)return;const l=Me(s.w),c=Me(s.h),a={w:Me(Ee(i.w/(t.w/100))),h:Me(Ee(i.h/(t.h/100)))},d=(()=>{const t=window.screen.deviceXDPI||0,e=window.screen.logicalXDPI||1;return window.devicePixelRatio||t/e})(),u=l>2&&c>2,h=!((t,e)=>{const n=Me(t),o=Me(e);return!(n===o||n+1===o||n-1===o)})(a.w,a.h);if(u&&h&&d!==e&&d>0){const[t,e]=o();C(n.V,t),e&&r()}t=i,e=d}}}};let ze;const He=(t,e,n,o)=>{X(t,e);const r=Lt(e),i=St(e),s=Bt(n);return o&&F(e),{x:i.h-r.h+s.h,y:i.w-r.w+s.w}},Te=(t,n)=>{const o="hidden";e(t,{overflowX:o,overflowY:o,direction:"rtl"}),P(t,0);const r=Tt(t),i=Tt(n);P(t,-999);const s=Tt(n);return{i:r.x===i.x,n:i.x!==s.x}},ke=(t,e)=>{const n=dt(t,Nt),o=At(t),r=At(e),i=gt(r,o,!0),s=dt(t,Vt),l=At(t),c=At(e),a=gt(c,l,!0);return n(),s(),i&&a},De=()=>(ze||(ze=(()=>{const{body:t}=document,o=Y(`<div class="${Xt}"><div></div></div>`)[0],r=o.firstChild,[i,,s]=Dt(),[l,c]=n({o:He(t,o,r),u:ft},He.bind(0,t,o,r,!0)),[a]=c(),d=(t=>{let n=!1;const o=dt(t,Qt);try{n="none"===e(t,J("scrollbar-width"))||"none"===window.getComputedStyle(t,"::-webkit-scrollbar").getPropertyValue("display")}catch(r){}return o(),n})(o),u={x:0===a.x,y:0===a.y},h={padding:!d,content:!1,cancel:{nativeScrollbarsOverlaid:!0,body:null}},f=C({},ye),p={V:a,T:u,A:d,D:"-1"===e(o,"zIndex"),k:Te(o,r),B:ke(o,r),j:t=>i("_",t),Y:C.bind(0,{},h),q(t){C(h,t)},F:C.bind(0,{},f),G(t){C(f,t)},N:C({},h),U:C({},f)};if(R(o,"style"),F(o),!(d||u.x&&u.y)){let t;window.addEventListener("resize",(()=>{const e=$e()[Re];t=t||e&&e.R(),t&&t(p,l,s.bind(0,"_"))}))}return p})()),ze),_e=(t,e)=>h(t)?t.apply(0,e):t,je=(t,e,n,o)=>_e(o||_e(n,t),t)||e.apply(0,t),Ie=(t,e,n,o)=>{let r=_e(o,t);return(l(r)||s(r))&&(r=_e(n,t)),!0===r||l(r)||s(r)?e.apply(0,t):r},Xe=W.bind(0,""),Ne=t=>{X(_(t),D(t)),F(t)},Ve=t=>{const e=De(),{Y:n,A:o}=e,r=$e()[Re],i=r&&r.I,{host:s,viewport:l,padding:c,content:a}=n(),d=b(t),u=d?{}:t,{host:h,padding:f,viewport:p,content:g}=u,w=d?t:u.target,v=k(w,"textarea"),x=w.ownerDocument,$=w===x.body,C=x.defaultView,B=($||!!nt&&!v)&&o,A=je.bind(0,[w]),P=Ie.bind(0,[w]),z=[A(Xe,l,$&&!S(u,"viewport")?w:p),A(Xe,l),A(Xe)].filter((t=>!!B||t!==w))[0],H=z===w,T={J:w,K:v?A(Xe,s,h):w,Z:z,tt:!H&&P(Xe,c,f),nt:!H&&P(Xe,a,g),ot:!H&&!o&&i&&i(e),st:C,et:x,ct:v,W:$,rt:d,X:H,it:(t,e)=>H?((t,e,n)=>{const o=E(t,Ft)||"";return new Set(o.split(" ")).has(n)})(z,0,e):((t,e)=>ct(t,e,((t,e)=>t.contains(e))))(z,t),lt:(t,e,n)=>H?M(z,Ft,e,n):(n?dt:at)(z,t)},j=L(T).reduce(((t,e)=>{const n=T[e];return m(t,!(!n||_(n))&&n)}),[]),N=t=>t?y(j,t)>-1:null,{J:W,K:Y,tt:K,Z,nt:q,ot:U}=T,G=[],J=v&&N(Y),Q=v?W:D([q,Z,K,Y,W].find((t=>!1===N(t)))),tt=q||Z;return[T,()=>{const t=((t,e)=>(E(t,Ft,e),R.bind(0,t,Ft)))(Y,H?"viewport":"host"),e=dt(K,qt),n=dt(Z,!H&&Ut),r=dt(q,Jt),i=$?dt(_(w),Qt):wt;J&&(V(W,Y),m(G,(()=>{V(Y,W),F(Y)}))),X(tt,Q),X(Y,K),X(K||Y,!H&&Z),X(Z,q),m(G,(()=>{i(),t(),R(Z,Wt),R(Z,Yt),N(q)&&Ne(q),N(Z)&&Ne(Z),N(K)&&Ne(K),e(),n(),r()})),o&&!H&&m(G,at.bind(0,Z,Qt)),U&&(((t,e)=>{I(_(t),t,e)})(Z,U),m(G,F.bind(0,U)))},O.bind(0,G)]},Fe=(t,n)=>{const{nt:o}=t,[r]=n;return t=>{const{B:n}=De(),{ut:i}=r(),{dt:s}=t,l=(o||!n)&&s;return l&&e(o,{height:i?"":"100%"}),{ft:l,_t:l}}},We=(t,o)=>{const[r,i]=o,{K:s,tt:l,Z:c,X:a}=t,[d,u]=n({u:pt,o:$t()},$t.bind(0,s,"padding",""));return(t,n,o)=>{let[s,h]=u(o);const{A:f,B:p}=De(),{ht:g}=r(),{ft:w,_t:b,gt:v}=t,[y,m]=n("paddingAbsolute");(w||h||!p&&b)&&([s,h]=d(o));const x=!a&&(m||v||h);if(x){const t=!y||!l&&!f,n=s.r+s.l,o=s.t+s.b,r={marginRight:t&&!g?-n:0,marginBottom:t?-o:0,marginLeft:t&&g?-n:0,top:t?-s.t:0,right:t?g?-s.r:"auto":0,left:t?g?"auto":-s.l:0,width:t?`calc(100% + ${n}px)`:""},a={paddingTop:t?s.t:0,paddingRight:t?s.r:0,paddingBottom:t?s.b:0,paddingLeft:t?s.l:0};e(l||c,r),e(c,a),i({tt:s,vt:!t,H:l?a:C({},r,a)})}return{wt:x}}},{max:Ye}=Math,Ke=Ye.bind(0,0),Ze="visible",qe="hidden",Ue=42,Ge={u:ht,o:{w:0,h:0}},Je={u:ft,o:{x:qe,y:qe}},Qe=(t,e,n)=>n?dt(t,e):at(t,e),tn=t=>0===t.indexOf(Ze),en=(t,o)=>{const[r,i]=o,{K:s,tt:l,Z:c,ot:a,X:d,lt:u}=t,{V:h,B:f,A:p,T:g}=De(),w=$e()[Re],b=!d&&!p&&(g.x||g.y),[v,y]=n(Ge,Bt.bind(0,c)),[m,x]=n(Ge,Ct.bind(0,c)),[$,O]=n(Ge),[S,L]=n(Ge),[C]=n(Je),B=(t,n)=>{if(e(c,{height:""}),n){const{vt:n,tt:o}=r(),{bt:i,L:l}=t,a=Bt(s),d=Lt(s),u="content-box"===e(c,"boxSizing"),h=n||u?o.b+o.t:0,f=!(g.x&&u);e(c,{height:d.h+a.h+(i.x&&f?l.x:0)-h})}},A=(t,n)=>{const o=p||t?0:Ue,r=(t,r,i)=>{const s=e(c,t),l="scroll"===(n?n[t]:s);return[s,l,l&&!p?r?o:i:0,r&&!!o]},[i,s,l,a]=r("overflowX",g.x,h.x),[d,u,f,w]=r("overflowY",g.y,h.y);return{yt:{x:i,y:d},bt:{x:s,y:u},L:{x:l,y:f},M:{x:a,y:w}}},R=(t,e,n,o)=>{const{L:i,M:s}=t,{x:l,y:c}=s,{x:a,y:d}=i,{H:u}=r(),h=e?"marginLeft":"marginRight",f=e?"paddingLeft":"paddingRight",p=u[h],g=u.marginBottom,w=u[f],b=u.paddingBottom;o.width=`calc(100% + ${d+-1*p}px)`,o[h]=-d+p,o.marginBottom=-a+g,n&&(o[f]=w+(c?d:0),o.paddingBottom=b+(l?a:0))},[P,z]=w?w.P(b,f,c,a,r,A,R):[()=>b,()=>[wt]];return(t,n,o)=>{const{ft:a,St:h,_t:w,wt:b,dt:H,gt:T}=t,{ut:k,ht:D}=r(),[_,j]=n("showNativeOverlaidScrollbars"),[I,X]=n("overflow"),N=_&&g.x&&g.y,V=!d&&!f&&(a||w||h||j||H),F=tn(I.x),W=tn(I.y),Y=F||W;let K,Z=y(o),q=x(o),U=O(o),G=L(o);if(j&&p&&u(Qt,Zt,!N),V&&(K=A(N),B(K,k)),a||b||w||T||j){Y&&u(te,Kt,!1);const[t,e]=z(N,D,K),[n,r]=Z=v(o),[i,s]=q=m(o),l=Lt(c);let a=i,d=l;t(),(s||r||j)&&e&&!N&&P(e,i,n,D)&&(d=Lt(c),a=Ct(c));const h={w:Ke(Ye(i.w,a.w)+n.w),h:Ke(Ye(i.h,a.h)+n.h)},f={w:Ke(d.w+Ke(l.w-i.w)+n.w),h:Ke(d.h+Ke(l.h-i.h)+n.h)};G=S(f),U=$(((t,e)=>{const n=window.devicePixelRatio%1!=0?1:0,o={w:Ke(t.w-e.w),h:Ke(t.h-e.h)};return{w:o.w>n?o.w:0,h:o.h>n?o.h:0}})(h,f),o)}const[J,Q]=G,[tt,et]=U,[nt,ot]=q,[rt,it]=Z,st={x:tt.w>0,y:tt.h>0},lt=F&&W&&(st.x||st.y)||F&&st.x&&!st.y||W&&st.y&&!st.x;if(b||T||it||ot||Q||et||X||j||V){const t={marginRight:0,marginBottom:0,marginLeft:0,width:"",overflowY:"",overflowX:""},n=((t,e,n,o)=>{const r=(t,e)=>{const n=tn(t),o=e&&n&&t.replace(`${Ze}-`,"")||"";return[e&&!n?t:"",tn(o)?"hidden":o]},[i,s]=r(n.x,e.x),[l,c]=r(n.y,e.y);return o.overflowX=s&&l?s:i,o.overflowY=c&&i?c:l,A(t,o)})(N,st,I,t),o=P(n,nt,rt,D);d||R(n,D,o,t),V&&B(n,k),d?(E(s,Wt,t.overflowX),E(s,Yt,t.overflowY)):e(c,t)}M(s,Ft,Kt,lt),Qe(l,te,lt),!d&&Qe(c,te,Y);const[ct,at]=C(A(N).yt);return i({yt:ct,Ct:{x:J.w,y:J.h},xt:{x:tt.w,y:tt.h},$t:st}),{Ot:at,zt:Q,It:et}}},nn=(e,n,o)=>{const r={},i=n||{};return t(L(e).concat(L(i)),(t=>{const n=e[t],s=i[t];r[t]=!!(o||n||s)})),r},on=3333333,rn=t=>"rtl"===e(t,"direction"),sn=t=>t&&(t.height||t.width),ln=(t,e,o)=>{const{At:r=!1,Tt:i=!1}=o||{},s=$e()[Ce],{k:l}=De(),c=Y(`<div class="${ee}"><div class="${oe}"></div></div>`)[0],a=c.firstChild,d=rn.bind(0,c),[h]=n({o:void 0,_:!0,u:(t,e)=>!(!t||!sn(t)&&sn(e))}),g=t=>{const n=f(t)&&t.length>0&&p(t[0]),o=!n&&u(t[0]);let i=!1,s=!1,a=!0;if(n){const[e,,n]=h(t.pop().contentRect),o=sn(e),r=sn(n);i=!n||!o,s=!r&&o,a=!i}else o?[,a]=t:s=!0===t;if(r&&a){const e=o?t[0]:rn(c);P(c,e?l.n?-on:l.i?0:on:on),z(c,on)}i||e({ft:!o,Dt:o?t:void 0,Tt:!!s})},w=[];let b,v=!!i&&g;if(nt){const t=new nt(g);t.observe(a),m(w,(()=>{t.disconnect()}))}else if(s){const[t,e]=s.O(a,g,i);v=t,m(w,e)}if(r){b=n({o:!d()},d);const[t]=b;m(w,Pt(c,"scroll",(e=>{const n=t(),[o,r]=n;r&&(at(a,"ltr rtl"),dt(a,o?"rtl":"ltr"),g(n)),zt(e)})))}return v&&(dt(c,ne),m(w,Pt(c,"animationstart",v,{$:!!nt}))),N(t,c),()=>{O(w),F(c)}},cn=(t,e)=>{let o;const r=W(le),i=[],[s]=n({o:!1}),l=(t,n)=>{if(t){const o=s((t=>0===t.h||t.isIntersecting||t.intersectionRatio>0)(t)),[,r]=o;if(r)return!n&&e(o),[o]}},c=(t,e)=>{if(t&&t.length>0)return l(t.pop(),e)};if(et)o=new et((t=>c(t)),{root:t}),o.observe(r),m(i,(()=>{o.disconnect()}));else{const t=()=>{const t=St(r);l(t)};m(i,ln(r,t)),t()}return N(t,r),[()=>{O(i),F(r)},()=>{if(o)return c(o.takeRecords(),!0)}]},an=(e,n,o,r)=>{let i=!1;const{Et:s,Pt:l,Ht:c,Lt:a,Mt:u,Rt:h}=r||{},f=bt((()=>{i&&o(!0)}),{g:33,v:99}),[p,g]=((e,n,o)=>{let r,i=!1;const s=s=>{if(o){const l=o.reduce(((t,n)=>{if(n){const o=n[0],r=n[1],i=r&&o&&(s?s(o):T(o,e));i&&i.length&&r&&d(r)&&m(t,[i,r.trim()],!0)}return t}),[]);t(l,(e=>t(e[0],(t=>{const o=e[1],s=r.get(t);if(s){const t=s[0],e=s[1];t===o&&e()}const l=e=>{i?(Rt(t,o,l),r.delete(t)):n(e)};Pt(t,o,l),r.set(t,[o,()=>Rt(t,o,l)])}))))}};return o&&(r=new WeakMap,s()),[()=>{i=!0},s]})(e,f,c),w=l||[],b=(s||[]).concat(w),v=(i,s)=>{const l=u||wt,c=h||wt,f=[],p=[];let b=!1,v=!1,x=!1;return t(i,(t=>{const{attributeName:o,target:i,type:s,oldValue:u,addedNodes:h}=t,g="attributes"===s,$="childList"===s,O=e===i,S=g&&d(o)?E(i,o):0,L=0!==S&&u!==S,C=y(w,o)>-1&&L;if(n&&!O){const n=!g,s=g&&C,d=s&&a&&k(i,a),f=(d?!l(i,o,u,S):n||s)&&!c(t,!!d,e,r);m(p,h),v=v||f,x=x||$}!n&&O&&L&&!l(i,o,u,S)&&(m(f,o),b=b||C)})),x&&!$(p)&&g((t=>p.reduce(((e,n)=>(m(e,T(t,n)),k(n,t)?m(e,n):e)),[]))),n?(!s&&v&&o(!1),[!1]):!$(f)||b?(!s&&o(f,b),[f,b]):void 0},x=new tt((t=>v(t)));return x.observe(e,{attributes:!0,attributeOldValue:!0,attributeFilter:b,subtree:n,childList:n,characterData:n}),i=!0,[()=>{i&&(p(),x.disconnect(),i=!1)},()=>{if(i){f.m();const t=x.takeRecords();return!$(t)&&v(t,!0)}}]},dn=`[${Ft}]`,un=`.${Ut}`,hn=["tabindex"],fn=["wrap","cols","rows"],pn=["id","class","style","open"],gn=(e,o,r)=>{let i,s,l;const[,c]=o,{K:u,Z:p,nt:g,ct:w,X:b,it:x,lt:$}=e,{A:O,B:S}=De(),[B]=n({u:ht,o:{w:0,h:0}},(()=>{const t=x(te,Kt),e=x(Gt,""),n=e&&P(p),o=e&&z(p);$(te,Kt),$(Gt,"");const r=Ct(g),i=Ct(p),s=Bt(p);return $(te,Kt,t),$(Gt,"",e),P(p,n),z(p,o),{w:i.w+r.w+s.w,h:i.h+r.h+s.h}})),A=w?fn:pn.concat(fn),M=bt(r,{g:()=>i,v:()=>s,p(t,e){const[n]=t,[o]=e;return[L(n).concat(L(o)).reduce(((t,e)=>(t[e]=n[e]||o[e],t)),{})]}}),H=e=>{t(e||hn,(t=>{if(y(hn,t)>-1){const e=E(u,t);d(e)?E(p,t,e):R(p,t)}}))},T=(t,e)=>{const[n,o]=t,i={dt:o};return c({ut:n}),!e&&r(i),i},k=({ft:t,Dt:e,Tt:n})=>{const o=!t||n?r:M;let i=!1;if(e){const[t,n]=e;i=n,c({ht:t})}o({ft:t,gt:i})},D=(t,e)=>{const[,n]=B(),o={_t:n};return n&&!e&&(t?r:M)(o),o},_=(t,e,n)=>{const o={St:e};return e?!n&&M(o):b||H(t),o},I=(g||!S)&&cn(u,T),X=!b&&ln(u,k,{Tt:!0,At:!O}),[N,V]=an(u,!1,_,{Pt:pn,Et:pn.concat(hn)}),F=b&&new nt(k.bind(0,{ft:!0}));return F&&F.observe(u),H(),[()=>{l&&l[0](),I&&I[0](),X&&X(),F&&F.disconnect(),N()},()=>{const t={},e=V(),n=l&&l[1](),o=I&&I[1]();return e&&C(t,_.apply(0,m(e,!0))),n&&C(t,D.apply(0,m(n,!0))),o&&C(t,T.apply(0,m(o,!0))),t},t=>{const[e]=t("updating.ignoreMutation"),[n,o]=t("updating.attributes"),[r,c]=t("updating.elementEvents"),[d,u]=t("updating.debounce"),w=t=>h(e)&&e(t);if((c||o)&&(l&&(l[1](),l[0]()),l=an(g||p,!0,D,{Pt:A.concat(n||[]),Et:A.concat(n||[]),Ht:r,Lt:dn,Rt:(t,e)=>{const{target:n,attributeName:o}=t;return!(e||!o)&&((t,e,n)=>{const o=t&&j(t,e),r=t&&((t,e)=>{const n=e?v(e)?e:null:document;return n?n.querySelector(t):null})(n,o);return!(!o||!r||o!==t&&r!==t&&j(j(t,n),e)===o)})(n,dn,un)||!!j(n,`.${ce}`)||!!w(t)}})),u)if(M.m(),f(d)){const t=d[0],e=d[1];i=!!a(t)&&t,s=!!a(e)&&e}else a(d)?(i=d,s=!1):(i=!1,s=!1)}]},wn={x:0,y:0},bn={tt:{t:0,r:0,b:0,l:0},vt:!1,H:{marginRight:0,marginBottom:0,marginLeft:0,paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0},Ct:wn,xt:wn,yt:{x:"hidden",y:"hidden"},$t:{x:!1,y:!1},ut:!1,ht:!1},vn="touchstart mouseenter",yn="touchend touchcancel mouseleave",mn=(t,e)=>Pt(t,"mousedown",Pt.bind(0,e,"click",zt,{$:!0,C:!0}),{C:!0}),xn=(n,o)=>{const{Y:r}=De(),{scrollbarsSlot:i}=r(),{et:s,J:l,K:c,Z:a,rt:d}=o,u=d?null:n.scrollbarsSlot,h=Ie([l,c,a],(()=>c),i,u),f=(e,n,o,r)=>{const i=o?dt:at;t(e,(t=>{i((r||wt)(t)||t.jt,n)}))},p=(n,o)=>{t(n,(t=>{const[n,r]=o(t);e(n,r)}))},g=[],w=[],b=[],v=f.bind(0,w),y=f.bind(0,b),x=t=>{const e=t?ae:de,n=t?w:b,o=$(n)?ge:"",r=W(`${ce} ${e} ${o}`),i=W(ue),l=W(he),c={jt:r,Yt:i,qt:l};return X(r,i),X(i,l),m(n,c),m(g,[F.bind(0,r),Pt(r,vn,(()=>{v(we,!0),y(we,!0)})),Pt(r,yn,(()=>{v(we),y(we)})),mn(r,s)]),c},S=x.bind(0,!0),L=x.bind(0,!1);return S(),L(),[{Ft:{Gt:w,Nt:S,Ut:v,Wt:p.bind(0,w)},Xt:{Gt:b,Nt:L,Ut:y,Wt:p.bind(0,b)}},()=>{X(h,w[0].jt),X(h,b[0].jt),it((()=>{v(ge),y(ge)}),300)},O.bind(0,g)]},{min:$n}=Math,On=t=>{let e;const n=t?it:rt,o=t?st:ot;return[r=>{o(e),e=n(r,h(t)?t():t)},()=>o(e)]},Sn=(t,e,n)=>{const{xt:o,Ct:r}=e,i=n?"x":"y",s=r[i],l=o[i],c=$n(1,s/(s+l));t((t=>[t.qt,{[n?"width":"height"]:`${(100*c).toFixed(3)}%`}]))},Ln=new Set,Cn=new WeakMap,Bn=(e,n,o)=>{let r=!1;const{F:i,j:s}=De(),c=$e(),a=b(e),d=a?e:e.target,f=(t=>Cn.get(t))(d);if(f)return f;const p=c[Oe],g=t=>{const e=t||{},n=p&&p.O;return n?n(e,!0):e},w=C({},i(),g(n)),[v,y,m]=Dt(o),[x,$,S]=((e,n)=>{const o=jt(n,{}),r=It(bn),[i,s,l]=Dt(),[c]=r,[a,d,u]=Ve(e),h=((e,n)=>{const{Z:o}=e,{A:r,T:i,B:s}=De(),l=!r&&(i.x||i.y),c=[Fe(e,n),We(e,n),en(e,n)];return(e,n,r)=>{const i=nn(C({ft:!1,wt:!1,gt:!1,dt:!1,zt:!1,It:!1,Ot:!1,St:!1,_t:!1},n),{},r),a=l||!s,d=a&&P(o),u=a&&z(o);let h=i;return t(c,(t=>{h=nn(h,t(h,e,!!r)||{},r)})),P(o,d),z(o,u),h}})(a,r),f=(t,e,n)=>{const o=L(t).some((e=>t[e]));(o||!B(e)||n)&&l("u",[t,e,n])},[p,g,w]=gn(a,r,(t=>{f(h(o,t),{},!1)})),b=c.bind(0);return b.Vt=t=>{i("u",t)},b.kt=d,b.Bt=a,[(t,e)=>{const o=jt(n,t,e);w(o),f(h(o,g(),e),t,!!e)},b,()=>{s(),p(),u()}]})(e,w),[A,E,M]=((t,e,n)=>{let o,r,i,s,l,c=0;const a=It({}),[d]=a,[u,h]=On(),[f,p]=On(),[g,w]=On(100),[b,v]=On(100),[y,m]=On((()=>c)),[x,$,S]=xn(t,n.Bt),{K:L,Z:C}=n.Bt,{Ft:B,Xt:A}=x,{Ut:E,Wt:M}=B,{Ut:R,Wt:P}=A,z=(t,e)=>{if(m(),t)E(be),R(be);else{const t=()=>{E(be,!0),R(be,!0)};c>0&&!e?y(t):t()}},H=()=>{s=r,s&&z(!0)},T=[w,m,v,p,h,S,Pt(L,"mouseover",H,{$:!0}),Pt(L,"mouseenter",H),Pt(L,"mouseleave",(()=>{s=!1,r&&z(!1)})),Pt(L,"mousemove",(()=>{o&&u((()=>{w(),z(!0),b((()=>{o&&z(!1)}))}))})),Pt(C,"scroll",(()=>{i&&f((()=>{z(!0),g((()=>{i&&!s&&z(!1)}))}))}))],k=d.bind(0);return k.Bt=x,k.kt=$,[(t,s,a)=>{const{zt:d,It:u,Ot:h}=a,f=jt(e,t,s),p=n(),[g,w]=f("scrollbars.theme"),[b,v]=f("scrollbars.visibility"),[y,m]=f("scrollbars.autoHide"),[x]=f("scrollbars.autoHideDelay");f("scrollbars.dragScrolling"),f("scrollbars.touchSupport");const $=d||u,O=(t,e)=>{const n="visible"===b||"auto"===b&&"scroll"===t;return e(fe,n),n};if(c=x,h||v){const{yt:t}=p,e=O(t.x,E),n=O(t.y,R),o=e&&n;E(pe,!o),R(pe,!o)}w&&(E(l),R(l),E(g,!0),R(g,!0),l=g),m&&(o="move"===y,r="leave"===y,i="never"!==y,z(!i,!0)),$&&(Sn(M,p,!0),Sn(P,p))},k,O.bind(0,T)]})(e,w,$),R=(t,e)=>{x(t,!!e)},H=s(R.bind(0,{},!0)),T=t=>{(t=>{Cn.delete(t),Ln.delete(t)})(d),H(),M(),S(),r=!0,m("destroyed",[k,!!t]),y()},k={options(t){if(t){const e=me(w,g(t));B(e)||(C(w,e),R(e))}return C({},w)},on:v,off:(t,e)=>{t&&e&&y(t,e)},state(){const{Ct:t,xt:e,yt:n,$t:o,tt:i,vt:s}=$();return C({},{overflowEdge:t,overflowAmount:e,overflowStyle:n,hasOverflow:o,padding:i,paddingAbsolute:s,destroyed:r})},elements(){const{J:t,K:e,tt:n,Z:o,nt:r}=$.Bt;return C({},{target:t,host:e,padding:n||o,viewport:o,content:r||o})},update:t=>(R({},t),k),destroy:T.bind(0)};return $.Vt(((t,e,n)=>{A(e,n,t)})),t(L(c),(t=>{const e=c[t];h(e)&&e(Bn,k)})),((t,e)=>{const{nativeScrollbarsOverlaid:n,body:o}=t||{},{W:r,X:i}=e,{Y:s,T:c}=De(),{nativeScrollbarsOverlaid:a,body:d}=s().cancel,h=null!=n?n:a,f=u(o)||l(o)?o:d,p=(c.x||c.y)&&h,g=r&&(l(f)?!i:f);return!!p||!!g})(!a&&e.cancel,$.Bt)?(T(!0),k):($.kt(),E.kt(),((t,e)=>{Cn.set(t,e),Ln.add(t)})(d,k),m("initialized",[k]),$.Vt(((t,e,n)=>{const{ft:o,gt:r,dt:i,zt:s,It:l,Ot:c,_t:a,St:d}=t;m("updated",[k,{updateHints:{sizeChanged:o,directionChanged:r,heightIntrinsicChanged:i,overflowEdgeChanged:s,overflowAmountChanged:l,overflowStyleChanged:c,contentMutation:a,hostMutation:d},changedOptions:e,force:n}])})),k.update(!0))};Bn.plugin=e=>{t(f(e)?e:[e],(e=>{t(L(e),(t=>{xe[t]=e[t]}))}))},Bn.env=()=>{const{V:t,T:e,A:n,k:o,B:r,D:i,N:s,U:l,Y:c,q:a,F:d,G:u}=De();return C({},{scrollbarsSize:t,scrollbarsOverlaid:e,scrollbarsHiding:n,rtlScrollBehavior:o,flexboxGlue:r,cssCustomProperties:i,staticDefaultInitialization:s,staticDefaultOptions:l,getDefaultInitialization:c,setDefaultInitialization:a,getDefaultOptions:d,setDefaultOptions:u})};export{Bn as OverlayScrollbars,Pe as scrollbarsHidingPlugin,Be as sizeObserverPlugin}; |