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