Files
OverlayScrollbars/packages/overlayscrollbars/dist/overlayscrollbars.esm.min.js
T
2022-07-28 16:57:46 +02:00

1 line
26 KiB
JavaScript

function t(e,n){if(w(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(p(n)||o){let t=o?"":{};if(e){const r=window.getComputedStyle(e,null);t=o?yt(e,r,n):n.reduce(((t,n)=>(t[n]=yt(e,r,n),t)),t)}return t}e&&t(L(n),(t=>mt(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,p=t=>Array.isArray(t),f=t=>"object"==typeof t&&!p(t)&&!l(t),w=t=>{const e=!!t&&t.length,n=a(e)&&e>-1&&e%1==0;return!(!(p(t)||!h(t)&&n)||e>0&&f(t)&&!(e-1 in t))},g=t=>{if(!t||!f(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)||!w(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=p(o);if(o&&(g(o)||r)){const n=e[t];let i=n;r&&!p(n)?i=[]:r||g(n)||(i={}),e[t]=C(i,o)}else e[t]=o}))})),e},P=t=>{for(const e in t)return!1;return!0},M=(t,e,n,o)=>{if(s(o))return n?n[t]:e;n&&!l(o)&&!1!==o&&(n[t]=o)},T=(t,e,n)=>{if(s(n))return t?t.getAttribute(e):null;t&&t.setAttribute(e,n)},E=(t,e,n,o)=>{if(n){const r=T(t,e)||"",i=new Set(r.split(" "));i[o?"add":"delete"](n),T(t,e,x(i).join(" ").trim())}},R=(t,e)=>{t&&t.removeAttribute(e)},D=(t,e)=>M("scrollLeft",0,t,e),z=(t,e)=>M("scrollTop",0,t,e),I=Element.prototype,A=(t,e)=>{const n=[],o=e?v(e)?e:null:document;return o?m(n,o.querySelectorAll(t)):n},B=(t,e)=>!!v(t)&&(I.matches||I.msMatchesSelector).call(t,e),k=t=>t?x(t.childNodes):[],H=t=>t?t.parentElement:null,Y=(t,e)=>{if(v(t)){const n=I.closest;if(n)return n.call(t,e);do{if(B(t,e))return t;t=H(t)}while(t)}return null},X=(e,n,o)=>{if(o){let r,i=n;e&&(w(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))}},V=(t,e)=>{X(t,null,e)},j=(t,e)=>{X(H(t),t&&t.nextSibling,e)},F=e=>{if(w(e))t(x(e),(t=>F(t)));else if(e){const t=H(e);t&&t.removeChild(e)}},_=t=>{const e=document.createElement("div");return t&&T(e,"class",t),e},N=e=>{const n=_();return n.innerHTML=e.trim(),t(k(n),(t=>F(t)))},Z=t=>t.charAt(0).toUpperCase()+t.slice(1),W=["-webkit-","-moz-","-o-","-ms-"],G=["WebKit","Moz","O","MS","webkit","moz","o","ms"],K={},q={},J=e=>{let n=q[e];if(S(q,e))return n;const o=Z(e),r=_().style;return t(W,(t=>{const i=t.replace(/-/g,""),s=[e,t+e,i+o,Z(i)+o];return!(n=s.find((t=>void 0!==r[t])))})),q[e]=n||""},U=e=>{let n=K[e]||window[e];return S(K,e)||(t(G,(t=>(n=n||window[t+Z(e)],!n))),K[e]=n),n},Q=U("MutationObserver"),tt=U("IntersectionObserver"),et=U("ResizeObserver"),nt=U("cancelAnimationFrame"),ot=U("requestAnimationFrame"),rt=window.setTimeout,it=window.clearTimeout,st=/[^\x20\t\r\n\f]+/g,lt=(t,e,n)=>{const o=t&&t.classList;let r,i=0,s=!1;if(o&&e&&d(e)){const t=e.match(st)||[];for(s=t.length>0;r=t[i++];)s=!!n(o,r)&&s}return s},ct=(t,e)=>{lt(t,e,((t,e)=>t.remove(e)))},at=(t,e)=>(lt(t,e,((t,e)=>t.add(e))),ct.bind(0,t,e)),dt=(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},ut=(t,e)=>dt(t,e,["w","h"]),ht=(t,e)=>dt(t,e,["x","y"]),pt=(t,e)=>dt(t,e,["t","r","b","l"]),ft=(t,e,n)=>dt(t,e,["width","height"],n&&(t=>Math.round(t))),wt=()=>{},gt=(t,e)=>{let n,o,r,i=wt;const{g:s,v:l,p:c}=e||{},d=function(e){i(),it(n),n=o=void 0,i=wt,t.apply(this,e)},u=t=>c&&o?c(o,t):t,p=()=>{i!==wt&&d(u(r)||r)},f=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,f=e>0?rt:ot,w=e>0?it:nt,g=u(t)||t,b=d.bind(0,g);i();const v=f(b,e);i=()=>w(v),c&&!n&&(n=rt(p,s)),o=r=g}else d(t)};return f.m=p,f},bt={opacity:1,zindex:1},vt=(t,e)=>{const n=e?parseFloat(t):parseInt(t,10);return n==n?n:0},yt=(t,e,n)=>null!=e?e[n]||e.getPropertyValue(n):t.style[n],mt=(t,e,n)=>{try{const{style:o}=t;s(o[e])?o.setProperty(e,n):o[e]=((t,e)=>!bt[t.toLowerCase()]&&a(e)?`${e}px`:e)(e,n)}catch(I){}},xt=t=>"rtl"===e(t,"direction"),$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:vt(d[s]),r:vt(d[l]),b:vt(d[c]),l:vt(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,Pt=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)}},Mt=t=>t.getBoundingClientRect();let Tt;const Et=t=>t.split(" "),Rt=(e,n,o,r)=>{t(Et(n),(t=>{e.removeEventListener(t,o,r)}))},Dt=(e,n,o,r)=>{var i;const l=(()=>{if(s(Tt)){Tt=!1;try{window.addEventListener("test",null,Object.defineProperty({},"passive",{get(){Tt=!0}}))}catch(e){}}return Tt})(),c=null!=(i=l&&r&&r.S)?i:l,a=r&&r.$||!1,d=r&&r.C||!1,u=[],h=l?{passive:c,capture:a}:a;return t(Et(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(),It={x:0,y:0},At=t=>{const e=t?Mt(t):0;return e?{x:e.left+window.pageYOffset,y:e.top+window.pageXOffset}:It},Bt=(e,n)=>{t(p(n)?n:[n],e)},kt=e=>{const n=new Map,o=(t,e)=>{if(t){const o=n.get(t);Bt((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),Bt((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()}))}]},Ht=(t,e)=>t?e.split(".").reduce(((t,e)=>t&&S(t,e)?t[e]:void 0),t):void 0,Yt=(t,e,n)=>o=>[Ht(t,o),n||void 0!==Ht(e,o)],Xt=t=>{let e=t;return[()=>e,t=>{e=C({},e,t)}]},Vt="os-environment",jt=`${Vt}-flexbox-glue`,Ft=`${jt}-max`,_t="data-overlayscrollbars",Nt=`${_t}-overflow-x`,Zt=`${_t}-overflow-y`,Wt="overflowVisible",Gt="scrollbarHidden",Kt="updating",qt="os-padding",Jt="os-viewport",Ut=`${Jt}-arrange`,Qt="os-content",te=`${Jt}-scrollbar-hidden`,ee=`os-overflow-visible`,ne="os-size-observer",oe=`${ne}-appear`,re=`${ne}-listener`,ie=`${re}-scroll`,se=`${re}-item`,le=`${se}-final`,ce="os-trinsic-observer",ae="os-scrollbar",de=`${ae}-rtl`,ue=`${ae}-horizontal`,he=`${ae}-vertical`,pe=`${ae}-track`,fe=`${ae}-handle`,we=`${ae}-visible`,ge=`${ae}-cornerless`,be=`${ae}-transitionless`,ve=`${ae}-interaction`,ye=`${ae}-unusable`,me=`${ae}-auto-hidden`,xe=`${pe}-interactive`,$e=`${fe}-interactive`,Oe=t=>JSON.stringify(t,((t,e)=>{if(h(e))throw new Error;return e})),Se={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,pointers:["mouse","touch","pen"]}},Le=(e,n)=>{const o={};return t(L(n).concat(L(e)),(t=>{const r=e[t],i=n[t];if(f(r)&&f(i))C(o[t]={},Le(r,i));else if(S(n,t)&&i!==r){let e=!0;if(p(r)||p(i))try{Oe(r)===Oe(i)&&(e=!1)}catch(K){}e&&(o[t]=i)}})),o},Ce={},Pe=()=>C({},Ce),Me="__osOptionsValidationPlugin",Te=3333333,Ee="scroll",Re="__osSizeObserverPlugin",De={[Re]:{O:(t,n,o)=>{const r=N(`<div class="${se}" dir="ltr"><div class="${se}"><div class="${le}"></div></div><div class="${se}"><div class="${le}" style="width: 200%; height: 200%"></div></div></div>`);V(t,r),at(t,ie);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 p=()=>{D(l,Te),z(l,Te),D(s,Te),z(s,Te)},f=t=>{a=0,h&&(d=u,n(!0===t))},w=t=>{u=St(i),h=!t||!ut(u,d),t?(zt(t),h&&!a&&(nt(a),a=ot(f))):f(!1===t),p()},g=m([],[Dt(l,Ee,w),Dt(s,Ee,w)]);return e(c,{width:Te,height:Te}),ot(p),[o?w.bind(0,!1):p,g]}}};let ze=0;const{round:Ie,abs:Ae}=Math,Be="__osScrollbarsHidingPlugin",ke={[Be]:{A:t=>{const{T:e,I:n,L:o}=t,r=!(o||e||!n.x&&!n.y)&&document.createElement("style");return r&&(T(r,"id",`${Ut}-${ze}`),ze++),r},H:(n,o,r,i,s,l,c)=>[(t,o,l,c)=>{if(n){const{P:n}=s(),{D:a,M:d}=t,{x:u,y:h}=d,{x:p,y:f}=a,w=n[c?"paddingRight":"paddingLeft"],g=n.paddingTop,b=o.w+l.w,v=o.h+l.h,y={w:f&&h?`${f+b-w}px`:"",h:p&&u?`${p+v-g}px`:""};if(i){const{sheet:t}=i;if(t){const{cssRules:e}=t;if(e){e.length||t.insertRule(`#${T(i,"id")} + .${Ut}::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),{P:h}=s(),{M:p}=u,{x:f,y:w}=p,g={},b=e=>t(e.split(" "),(t=>{g[t]=h[t]}));f&&b("marginBottom paddingTop paddingBottom"),w&&b("marginLeft marginRight paddingLeft paddingRight");const v=e(r,L(g));return ct(r,Ut),o||(g.height=""),e(r,g),[()=>{c(u,a,n,v),e(r,v),at(r,Ut)},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=Ae(s.w),c=Ae(s.h),a={w:Ae(Ie(i.w/(t.w/100))),h:Ae(Ie(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=Ae(t),o=Ae(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.k,t),e&&r()}t=i,e=d}}}};let He;const Ye=(t,e,n,o)=>{V(t,e);const r=Lt(e),i=St(e),s=Pt(n);return o&&F(e),{x:i.h-r.h+s.h,y:i.w-r.w+s.w}},Xe=(t,n)=>{const o="hidden";e(t,{overflowX:o,overflowY:o,direction:"rtl"}),D(t,0);const r=At(t),i=At(n);D(t,-999);const s=At(n);return{i:r.x===i.x,n:i.x!==s.x}},Ve=(t,e)=>{const n=at(t,jt),o=Mt(t),r=Mt(e),i=ft(r,o,!0),s=at(t,Ft),l=Mt(t),c=Mt(e),a=ft(c,l,!0);return n(),s(),i&&a},je=()=>(He||(He=(()=>{const{body:t}=document,o=N(`<div class="${Vt}"><div></div></div>`)[0],r=o.firstChild,[i,,s]=kt(),[l,c]=n({o:Ye(t,o,r),u:ht},Ye.bind(0,t,o,r,!0)),[a]=c(),d=(t=>{let n=!1;const o=at(t,te);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={host:null,padding:!d,viewport:t=>d&&t===t.ownerDocument.body&&t,content:!1,scrollbarsSlot:!0,cancel:{nativeScrollbarsOverlaid:!0,body:null}},p=C({},Se),f={k:a,I:u,T:d,L:"-1"===e(o,"zIndex"),B:Xe(o,r),V:Ve(o,r),j:t=>i("_",t),Y:C.bind(0,{},h),q(t){C(h,t)},F:C.bind(0,{},p),G(t){C(p,t)},N:C({},h),U:C({},p)};if(R(o,"style"),F(o),!(d||u.x&&u.y)){let t;window.addEventListener("resize",(()=>{const e=Pe()[Be];t=t||e&&e.R(),t&&t(f,l,s.bind(0,"_"))}))}return f})()),He),Fe=(t,e)=>h(t)?t.apply(0,e):t,_e=(t,e,n,o)=>{const r=s(o)?n:o;return Fe(r,t)||e()},Ne=(t,e,n,o)=>{const r=s(o)?n:o,i=Fe(r,t);return!!i&&(b(i)?i:e())},Ze=_.bind(0,""),We=t=>{V(H(t),k(t)),F(t)},Ge=t=>{const e=je(),{Y:n,T:o}=e,r=Pe()[Be],i=r&&r.A,{host:s,viewport:l,padding:c,content:a}=n(),d=b(t),u=d?{}:t,{host:h,padding:p,viewport:f,content:w}=u,g=d?t:u.target,v=B(g,"textarea"),x=g.ownerDocument,$=g===x.body,S=x.defaultView,C=_e.bind(0,[g]),P=Ne.bind(0,[g]),M=C(Ze,l,f),D=M===g,z={J:g,K:v?C(Ze,s,h):g,Z:M,tt:!D&&P(Ze,c,p),nt:!D&&P(Ze,a,w),ot:!D&&!o&&i&&i(e),st:$?x.documentElement:M,et:$?x:M,ct:S,rt:x,it:v,W:$,lt:d,X:D,ut:(t,e)=>D?((t,e,n)=>{const o=T(t,_t)||"";return new Set(o.split(" ")).has(n)})(M,0,e):((t,e)=>lt(t,e,((t,e)=>t.contains(e))))(M,t),dt:(t,e,n)=>D?E(M,_t,e,n):(n?at:ct)(M,t)},I=L(z).reduce(((t,e)=>{const n=z[e];return m(t,!(!n||H(n))&&n)}),[]),A=t=>t?y(I,t)>-1:null,{J:Y,K:_,tt:N,Z,nt:W,ot:G}=z,K=[],q=v&&A(_),J=v?Y:k([W,Z,N,_,Y].find((t=>!1===A(t)))),U=W||Z;return[z,()=>{const t=((t,e)=>(T(t,_t,e),R.bind(0,t,_t)))(_,D?"viewport":"host"),e=at(N,qt),n=at(Z,!D&&Jt),r=at(W,Qt),i=$?at(H(g),te):wt;q&&(j(Y,_),m(K,(()=>{j(_,Y),F(_)}))),V(U,J),V(_,N),V(N||_,!D&&Z),V(Z,W),m(K,(()=>{i(),t(),R(Z,Nt),R(Z,Zt),A(W)&&We(W),A(Z)&&We(Z),A(N)&&We(N),e(),n(),r()})),o&&!D&&m(K,ct.bind(0,Z,te)),G&&(((t,e)=>{X(H(t),t,e)})(Z,G),m(K,F.bind(0,G)))},O.bind(0,K)]},Ke=(t,n)=>{const{nt:o}=t,[r]=n;return t=>{const{V:n}=je(),{ft:i}=r(),{_t:s}=t,l=(o||!n)&&s;return l&&e(o,{height:i?"":"100%"}),{ht:l,gt:l}}},qe=(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{T:p,V:f}=je(),{vt:w}=r(),{ht:g,gt:b,wt:v}=t,[y,m]=n("paddingAbsolute");(g||h||!f&&b)&&([s,h]=d(o));const x=!a&&(m||v||h);if(x){const t=!y||!l&&!p,n=s.r+s.l,o=s.t+s.b,r={marginRight:t&&!w?-n:0,marginBottom:t?-o:0,marginLeft:t&&w?-n:0,top:t?-s.t:0,right:t?w?-s.r:"auto":0,left:t?w?"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,bt:!t,P:l?a:C({},r,a)})}return{yt:x}}},{max:Je}=Math,Ue=Je.bind(0,0),Qe="visible",tn="hidden",en=42,nn={u:ut,o:{w:0,h:0}},on={u:ht,o:{x:tn,y:tn}},rn=(t,e,n)=>n?at(t,e):ct(t,e),sn=t=>0===t.indexOf(Qe),ln=(t,o)=>{const[r,i]=o,{K:s,tt:l,Z:c,ot:a,X:d,dt:u}=t,{k:h,V:p,T:f,I:w}=je(),g=Pe()[Be],b=!d&&!f&&(w.x||w.y),[v,y]=n(nn,Pt.bind(0,c)),[m,x]=n(nn,Ct.bind(0,c)),[$,O]=n(nn),[S,L]=n(nn),[C]=n(on),P=(t,n)=>{if(e(c,{height:""}),n){const{bt:n,tt:o}=r(),{St:i,D:l}=t,a=Pt(s),d=Lt(s),u="content-box"===e(c,"boxSizing"),h=n||u?o.b+o.t:0,p=!(w.x&&u);e(c,{height:d.h+a.h+(i.x&&p?l.x:0)-h})}},M=(t,n)=>{const o=f||t?0:en,r=(t,r,i)=>{const s=e(c,t),l="scroll"===(n?n[t]:s);return[s,l,l&&!f?r?o:i:0,r&&!!o]},[i,s,l,a]=r("overflowX",w.x,h.x),[d,u,p,g]=r("overflowY",w.y,h.y);return{xt:{x:i,y:d},St:{x:s,y:u},D:{x:l,y:p},M:{x:a,y:g}}},R=(t,e,n,o)=>{const{D:i,M:s}=t,{x:l,y:c}=s,{x:a,y:d}=i,{P:u}=r(),h=e?"marginLeft":"marginRight",p=e?"paddingLeft":"paddingRight",f=u[h],w=u.marginBottom,g=u[p],b=u.paddingBottom;o.width=`calc(100% + ${d+-1*f}px)`,o[h]=-d+f,o.marginBottom=-a+w,n&&(o[p]=g+(c?d:0),o.paddingBottom=b+(l?a:0))},[D,z]=g?g.H(b,p,c,a,r,M,R):[()=>b,()=>[wt]];return(t,n,o)=>{const{ht:a,$t:h,gt:g,yt:b,_t:I,wt:A}=t,{ft:B,vt:k}=r(),[H,Y]=n("showNativeOverlaidScrollbars"),[X,V]=n("overflow"),j=H&&w.x&&w.y,F=!d&&!p&&(a||g||h||Y||I),_=sn(X.x),N=sn(X.y),Z=_||N;let W,G=y(o),K=x(o),q=O(o),J=L(o);if(Y&&f&&u(te,Gt,!j),F&&(W=M(j),P(W,B)),a||b||g||A||Y){Z&&u(ee,Wt,!1);const[t,e]=z(j,k,W),[n,r]=G=v(o),[i,s]=K=m(o),l=Lt(c);let a=i,d=l;t(),(s||r||Y)&&e&&!j&&D(e,i,n,k)&&(d=Lt(c),a=Ct(c));const h={w:Ue(Je(i.w,a.w)+n.w),h:Ue(Je(i.h,a.h)+n.h)},p={w:Ue(d.w+Ue(l.w-i.w)+n.w),h:Ue(d.h+Ue(l.h-i.h)+n.h)};J=S(p),q=$(((t,e)=>{const n=window.devicePixelRatio%1!=0?1:0,o={w:Ue(t.w-e.w),h:Ue(t.h-e.h)};return{w:o.w>n?o.w:0,h:o.h>n?o.h:0}})(h,p),o)}const[U,Q]=J,[tt,et]=q,[nt,ot]=K,[rt,it]=G,st={x:tt.w>0,y:tt.h>0},lt=_&&N&&(st.x||st.y)||_&&st.x&&!st.y||N&&st.y&&!st.x;if(b||A||it||ot||Q||et||V||Y||F){const t={marginRight:0,marginBottom:0,marginLeft:0,width:"",overflowY:"",overflowX:""},n=((t,e,n,o)=>{const r=(t,e)=>{const n=sn(t),o=e&&n&&t.replace(`${Qe}-`,"")||"";return[e&&!n?t:"",sn(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,M(t,o)})(j,st,X,t),o=D(n,nt,rt,k);d||R(n,k,o,t),F&&P(n,B),d?(T(s,Nt,t.overflowX),T(s,Zt,t.overflowY)):e(c,t)}E(s,_t,Wt,lt),rn(l,ee,lt),!d&&rn(c,ee,Z);const[ct,at]=C(M(j).xt);return i({xt:ct,Ct:{x:U.w,y:U.h},Ot:{x:tt.w,y:tt.h},At:st}),{Tt:at,It:Q,zt:et}}},cn=(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},an=3333333,dn=t=>t&&(t.height||t.width),un=(t,e,o)=>{const{Et:r=!1,Lt:i=!1}=o||{},s=Pe()[Re],{B:l}=je(),c=N(`<div class="${ne}"><div class="${re}"></div></div>`)[0],a=c.firstChild,d=xt.bind(0,t),[h]=n({o:void 0,_:!0,u:(t,e)=>!(!t||!dn(t)&&dn(e))}),w=t=>{const n=p(t)&&t.length>0&&f(t[0]),o=!n&&u(t[0]);let i=!1,s=!1,a=!0;if(n){const[e,,n]=h(t.pop().contentRect),o=dn(e),r=dn(n);i=!n||!o,s=!r&&o,a=!i}else o?[,a]=t:s=!0===t;if(r&&a){const e=o?t[0]:xt(c);D(c,e?l.n?-an:l.i?0:an:an),z(c,an)}i||e({ht:!o,Ht:o?t:void 0,Lt:!!s})},g=[];let b=!!i&&w;return[()=>{O(g),F(c)},()=>{if(et){const t=new et(w);t.observe(a),m(g,(()=>{t.disconnect()}))}else if(s){const[t,e]=s.O(a,w,i);b=t,m(g,e)}if(r){const[t]=n({o:!d()},d);m(g,Dt(c,"scroll",(e=>{const n=t(),[o,r]=n;r&&(ct(a,"ltr rtl"),at(a,o?"rtl":"ltr"),w(n)),zt(e)})))}b&&(at(c,oe),m(g,Dt(c,"animationstart",b,{C:!!et}))),V(t,c)}]},hn=(t,e)=>{let o;const r=_(ce),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)};return[()=>{O(i),F(r)},()=>{if(tt)o=new tt((t=>c(t)),{root:t}),o.observe(r),m(i,(()=>{o.disconnect()}));else{const t=()=>{const t=St(r);l(t)},[e,n]=un(r,t);m(i,e),n(),t()}V(t,r)},()=>{if(o)return c(o.takeRecords(),!0)}]},pn=(e,n,o,r)=>{let i=!1;const{Pt:s,Dt:l,Mt:c,Rt:a,kt:u,Bt:h}=r||{},p=gt((()=>{i&&o(!0)}),{g:33,v:99}),[f,w]=((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):A(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=Dt(t,o,(e=>{i?(l(),r.delete(t)):n(e)}));r.set(t,[o,l])}))))}};return o&&(r=new WeakMap,s()),[()=>{i=!0},s]})(e,p,c),g=l||[],b=(s||[]).concat(g),v=(i,s)=>{const l=u||wt,c=h||wt,p=[],f=[];let b=!1,v=!1,x=!1;return t(i,(t=>{const{attributeName:o,target:i,type:s,oldValue:u,addedNodes:h}=t,w="attributes"===s,$="childList"===s,O=e===i,S=w&&d(o)?T(i,o):0,L=0!==S&&u!==S,C=y(g,o)>-1&&L;if(n&&!O){const n=!w,s=w&&C,d=s&&a&&B(i,a),p=(d?!l(i,o,u,S):n||s)&&!c(t,!!d,e,r);m(f,h),v=v||p,x=x||$}!n&&O&&L&&!l(i,o,u,S)&&(m(p,o),b=b||C)})),x&&!$(f)&&w((t=>f.reduce(((e,n)=>(m(e,A(t,n)),B(n,t)?m(e,n):e)),[]))),n?(!s&&v&&o(!1),[!1]):!$(p)||b?(!s&&o(p,b),[p,b]):void 0},x=new Q((t=>v(t)));return x.observe(e,{attributes:!0,attributeOldValue:!0,attributeFilter:b,subtree:n,childList:n,characterData:n}),i=!0,[()=>{i&&(f(),x.disconnect(),i=!1)},()=>{if(i){p.m();const t=x.takeRecords();return!$(t)&&v(t,!0)}}]},fn=`[${_t}]`,wn=`.${Jt}`,gn=["tabindex"],bn=["wrap","cols","rows"],vn=["id","class","style","open"],yn=(e,o,r)=>{let i,s,l;const[,c]=o,{K:u,Z:f,nt:w,it:g,X:b,ut:x,dt:$}=e,{V:O}=je(),[S]=n({u:ut,o:{w:0,h:0}},(()=>{const t=x(ee,Wt),e=x(Ut,""),n=e&&D(f),o=e&&z(f);$(ee,Wt),$(Ut,""),$("",Kt,!0);const r=Ct(w),i=Ct(f),s=Pt(f);return $(ee,Wt,t),$(Ut,"",e),$("",Kt),D(f,n),z(f,o),{w:i.w+r.w+s.w,h:i.h+r.h+s.h}})),P=g?bn:vn.concat(bn),M=gt(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)),{})]}}),E=e=>{t(e||gn,(t=>{if(y(gn,t)>-1){const e=T(u,t);d(e)?T(f,t,e):R(f,t)}}))},I=(t,e)=>{const[n,o]=t,i={_t:o};return c({ft:n}),!e&&r(i),i},A=({ht:t,Ht:e,Lt:n})=>{const o=!t||n?r:M;let i=!1;if(e){const[t,n]=e;i=n,c({vt:t})}o({ht:t,wt:i})},B=(t,e)=>{const[,n]=S(),o={gt:n};return n&&!e&&(t?r:M)(o),o},k=(t,e,n)=>{const o={$t:e};return e?!n&&M(o):b||E(t),o},[H,X,V]=w||!O?hn(u,I):[wt,wt,wt],[j,F]=b?[wt,wt]:un(u,A,{Lt:!0,Et:!0}),[_,N]=pn(u,!1,k,{Dt:vn,Pt:vn.concat(gn)}),Z=b&&et&&new et(A.bind(0,{ht:!0}));return Z&&Z.observe(u),E(),[()=>{H(),j(),l&&l[0](),Z&&Z.disconnect(),_()},()=>{F(),X()},()=>{const t={},e=N(),n=V(),o=l&&l[1]();return e&&C(t,k.apply(0,m(e,!0))),n&&C(t,I.apply(0,m(n,!0))),o&&C(t,B.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"),g=t=>h(e)&&e(t);if((c||o)&&(l&&(l[1](),l[0]()),l=pn(w||f,!0,B,{Dt:P.concat(n||[]),Pt:P.concat(n||[]),Mt:r,Rt:fn,Bt:(t,e)=>{const{target:n,attributeName:o}=t;return!(e||!o)&&((t,e,n)=>{const o=t&&Y(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&&Y(Y(t,n),e)===o)})(n,fn,wn)||!!Y(n,`.${ae}`)||!!g(t)}})),u)if(M.m(),p(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)}]},mn={x:0,y:0},xn={tt:{t:0,r:0,b:0,l:0},bt:!1,P:{marginRight:0,marginBottom:0,marginLeft:0,paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0},Ct:mn,Ot:mn,xt:{x:"hidden",y:"hidden"},At:{x:!1,y:!1},ft:!1,vt:!1},{round:$n}=Math,On=t=>({x:t.clientX,y:t.clientY}),Sn=(t,e)=>Dt(t,"mousedown",Dt.bind(0,e,"click",zt,{C:!0,$:!0}),{$:!0}),Ln=(t,e,n,o,r,i)=>{const{B:s}=je(),{qt:l,Ft:c,Gt:a}=n,d=`scroll${i?"Left":"Top"}`,u=`${i?"x":"y"}`,h=`${i?"w":"h"}`,p=(t,e,n)=>p=>{const{Ot:f}=r(),w=(On(p)[u]-e)*n/(St(c)[h]-St(l)[h])*f[u],g=xt(a)&&i?s.n||s.i?1:-1:1;o[d]=t+w*g};return Dt(l,"pointerdown",(n=>{if(((t,e,n)=>{const o=e.scrollbars,{button:r,isPrimary:i,pointerType:s}=t,{pointers:l}=o;return 0===r&&i&&o["dragScroll"]&&(l||[]).includes(s)})(n,t)){const t=Dt(e,"selectstart",(t=>(t=>t.preventDefault())(t)),{S:!1}),r=Dt(l,"pointermove",p(o[d]||0,On(n)[u],1/(t=>{const{width:e,height:n}=Mt(t),{w:o,h:r}=St(t);return{x:$n(e)/o||1,y:$n(n)/r||1}})(o)[u]));Dt(l,"pointerup",(e=>{t(),r(),l.releasePointerCapture(e.pointerId)}),{C:!0}),l.setPointerCapture(n.pointerId)}}))},{min:Cn,max:Pn,abs:Mn,round:Tn}=Math,En=(t,e,n,o)=>{if(o){const t=n?"x":"y",{Ot:e,Ct:r}=o,i=r[t],s=e[t];return Pn(0,Cn(1,i/(i+s)))}const r=n?"w":"h",i=St(t)[r],s=St(e)[r];return Pn(0,Cn(1,i/s))},Rn=(n,o,r)=>{const{Y:i}=je(),{scrollbarsSlot:s}=i(),{rt:l,J:c,K:a,Z:d,lt:h,st:p}=o,{scrollbarsSlot:f}=h?{}:n,w=Ne([c,a,d],(()=>a),s,f),g=(e,n,o)=>{const r=o?at:ct;t(e,(t=>{r(t.Gt,n)}))},b=(n,o)=>{t(n,(t=>{const[n,r]=o(t);e(n,r)}))},v=(t,e,n)=>{b(t,(t=>{const{qt:o,Ft:r}=t;return[o,{[n?"width":"height"]:`${(100*En(o,r,n,e)).toFixed(5)}%`}]}))},y=(t,e,n)=>{const o=n?"X":"Y";b(t,(t=>{const{qt:r,Ft:i,Gt:s}=t,l=((t,e,n,o,r,i)=>{const{B:s}=je(),l=i?"x":"y",c=i?"Left":"Top",{Ot:a}=o,d=Tn(a[l]),u=Mn(n[`scroll${c}`]),h=i&&r,p=s.i?u:d-u,f=Cn(1,(h?p:u)/d),w=En(t,e,i);return 1/w*(1-w)*f})(r,i,p,e,xt(s),n);return[r,{transform:l==l?`translate${o}(${(100*l).toFixed(5)}%)`:""}]}))},x=[],S=[],L=[],C=(t,e,n)=>{const o=u(n),r=!o||!n;(!o||n)&&g(S,t,e),r&&g(L,t,e)},P=t=>{const e=t?ue:he,n=t?S:L,o=$(n)?be:"",i=_(`${ae} ${e} ${o}`),s=_(pe),c=_(fe),a={Gt:i,Ft:s,qt:c};return V(i,s),V(s,c),m(n,a),m(x,[F.bind(0,i),r(a,C,l,p,t)]),a},M=P.bind(0,!0),T=P.bind(0,!1);return M(),T(),[{Nt:t=>{v(S,t,!0),v(L,t)},Ut:t=>{y(S,t,!0),y(L,t)},Wt:C,Xt:{Jt:S,Kt:M,Zt:b.bind(0,S)},Qt:{Jt:L,Kt:T,Zt:b.bind(0,L)}},()=>{V(w,S[0].Gt),V(w,L[0].Gt),rt((()=>{C(be)}),300)},O.bind(0,x)]},Dn=t=>{let e;const n=t?rt:ot,o=t?it:nt;return[r=>{o(e),e=n(r,h(t)?t():t)},()=>o(e)]},zn=new Set,In=new WeakMap,An=(e,n,o)=>{let r=!1;const{F:i,j:c}=je(),a=Pe(),d=b(e),u=d?e:e.target,p=(t=>In.get(t))(u);if(p)return p;const f=a[Me],w=t=>{const e=t||{},n=f&&f.O;return n?n(e,!0):e},g=C({},i(),w(n)),[v,y,m]=kt(o),[x,$,S]=((e,n)=>{const o=Yt(n,{}),r=Xt(xn),[i,s,l]=kt(),[c]=r,[a,d,u]=Ge(e),h=((e,n)=>{const{Z:o,dt:r}=e,{T:i,I:s,V:l}=je(),c=!i&&(s.x||s.y),a=[Ke(e,n),qe(e,n),ln(e,n)];return(e,n,i)=>{const s=cn(C({ht:!1,yt:!1,wt:!1,_t:!1,It:!1,zt:!1,Tt:!1,$t:!1,gt:!1},n),{},i),d=c||!l,u=d&&D(o),h=d&&z(o);r("",Kt,!0);let p=s;return t(a,(t=>{p=cn(p,t(p,e,!!i)||{},i)})),D(o,u),z(o,h),r("",Kt),p}})(a,r),p=(t,e,n)=>{const o=L(t).some((e=>t[e]));(o||!P(e)||n)&&l("u",[t,e,n])},[f,w,g,b]=yn(a,r,(t=>{p(h(o,t),{},!1)})),v=c.bind(0);return v.Vt=t=>{i("u",t)},v.jt=()=>{w(),d()},v.Yt=a,[(t,e)=>{const o=Yt(n,t,e);b(o),p(h(o,g(),e),t,!!e)},v,()=>{s(),f(),u()}]})(e,g),[M,T,E]=((t,e,n)=>{let o,r,i,s,l,c=0;const a=Xt({}),[d]=a,[u,h]=Dn(),[p,f]=Dn(),[w,g]=Dn(100),[b,v]=Dn(100),[y,m]=Dn((()=>c)),[x,$,S]=Rn(t,n.Yt,((t,e)=>(n,o,r,i,s)=>{const{Gt:l}=n;return O.bind(0,[Dt(l,"pointerenter",(()=>{o(ve,!0)})),Dt(l,"pointerleave pointercancel",(()=>{o(ve)})),Sn(l,r),Ln(t,r,n,i,e,s)])})(e,n)),{K:L,Z:C,st:P,et:M,X:T,W:E}=n.Yt,{Xt:R,Qt:I,Wt:A,Nt:B,Ut:k}=x,{Zt:Y}=R,{Zt:X}=I,V=t=>{const{Gt:e}=t,n=T&&!E&&H(e)===C&&e;return[n,{transform:n?`translate(${D(P)}px, ${z(P)}px)`:""}]},j=(t,e)=>{if(m(),t)A(me);else{const t=()=>A(me,!0);c>0&&!e?y(t):t()}},F=()=>{s=r,s&&j(!0)},_=[g,m,v,f,h,S,Dt(L,"pointerover",F,{C:!0}),Dt(L,"pointerenter",F),Dt(L,"pointerleave",(()=>{s=!1,r&&j(!1)})),Dt(L,"pointermove",(()=>{o&&u((()=>{g(),j(!0),b((()=>{o&&j(!1)}))}))})),Dt(M,"scroll",(()=>{p((()=>{k(n()),i&&j(!0),w((()=>{i&&!s&&j(!1)}))})),T&&Y(V),T&&X(V)}))],N=d.bind(0);return N.Yt=x,N.jt=$,[(t,s,a)=>{const{It:d,zt:u,Tt:h,wt:p}=a,f=Yt(e,t,s),w=n(),{Ot:g,xt:b,vt:v}=w,[y,m]=f("scrollbars.theme"),[x,$]=f("scrollbars.visibility"),[O,S]=f("scrollbars.autoHide"),[L]=f("scrollbars.autoHideDelay"),[C,P]=f("scrollbars.dragScroll"),[M,T]=f("scrollbars.clickScroll"),R=d||u||p,D=h||$,z=(t,e)=>{const n="visible"===x||"auto"===x&&"scroll"===t;return A(we,n,e),n};if(c=L,m&&(A(l),A(y,!0),l=y),S&&(o="move"===O,r="leave"===O,i="never"!==O,j(!i,!0)),P&&A($e,C),T&&A(xe,M),D){const t=z(b.x,!0),e=z(b.y,!1);A(ge,!(t&&e))}R&&(B(w),k(w),A(ye,!g.x,!0),A(ye,!g.y,!1),A(de,v&&!E))},N,O.bind(0,_)]})(e,g,$),R=(t,e)=>{x(t,!!e)},I=c(R.bind(0,{},!0)),A=t=>{(t=>{In.delete(t),zn.delete(t)})(u),I(),E(),S(),r=!0,m("destroyed",[B,!!t]),y()},B={options(t){if(t){const e=Le(g,w(t));P(e)||(C(g,e),R(e))}return C({},g)},on:v,off:(t,e)=>{t&&e&&y(t,e)},state(){const{Ct:t,Ot:e,xt:n,At:o,tt:i,bt:s,vt:l}=$();return C({},{overflowEdge:t,overflowAmount:e,overflowStyle:n,hasOverflow:o,padding:i,paddingAbsolute:s,directionRTL:l,destroyed:r})},elements(){const{J:t,K:e,tt:n,Z:o,nt:r}=$.Yt;return C({},{target:t,host:e,padding:n||o,viewport:o,content:r||o})},update:t=>(R({},t),B),destroy:A.bind(0)};return $.Vt(((t,e,n)=>{M(e,n,t)})),t(L(a),(t=>{const e=a[t];h(e)&&e(An,B)})),((t,e)=>{const{nativeScrollbarsOverlaid:n,body:o}=t||{},{W:r,X:i}=e,{Y:c,I:a}=je(),{nativeScrollbarsOverlaid:d,body:u}=c().cancel,h=null!=n?n:d,p=s(o)?u:o,f=(a.x||a.y)&&h,w=r&&(l(p)?!i:p);return!!f||!!w})(!d&&e.cancel,$.Yt)?(A(!0),B):($.jt(),T.jt(),((t,e)=>{In.set(t,e),zn.add(t)})(u,B),m("initialized",[B]),$.Vt(((t,e,n)=>{const{ht:o,wt:r,_t:i,It:s,zt:l,Tt:c,gt:a,$t:d}=t;m("updated",[B,{updateHints:{sizeChanged:o,directionChanged:r,heightIntrinsicChanged:i,overflowEdgeChanged:s,overflowAmountChanged:l,overflowStyleChanged:c,contentMutation:a,hostMutation:d},changedOptions:e,force:n}])})),B.update(!0))};An.plugin=e=>{t(p(e)?e:[e],(e=>{t(L(e),(t=>{Ce[t]=e[t]}))}))},An.env=()=>{const{k:t,I:e,T:n,B:o,V:r,L:i,N:s,U:l,Y:c,q:a,F:d,G:u}=je();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{An as OverlayScrollbars,ke as scrollbarsHidingPlugin,De as sizeObserverPlugin};