const t=Math.min,e=Math.max,n=Math.round,o=Math.floor,i=t=>({x:t,y:t});function r(){return"undefined"!=typeof window}function c(t){return s(t)?(t.nodeName||"").toLowerCase():"#document"}function u(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function l(t){var e;return null==(e=(s(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function s(t){return!!r()&&(t instanceof Node||t instanceof u(t).Node)}function a(t){return!!r()&&(t instanceof HTMLElement||t instanceof u(t).HTMLElement)}function f(t){return!(!r()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof u(t).ShadowRoot)}const d=new Set(["inline","contents"]);function h(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=v(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!d.has(i)}const m=new Set(["html","body","#document"]);function v(t){return u(t).getComputedStyle(t)}function w(t){const e=function(t){if("html"===c(t))return t;const e=t.assignedSlot||t.parentNode||f(t)&&t.host||l(t);return f(e)?e.host:e}(t);return function(t){return m.has(c(t))}(e)?t.ownerDocument?t.ownerDocument.body:t.body:a(e)&&h(e)?e:w(e)}function g(t,e,n){var o;void 0===e&&(e=[]),void 0===n&&(n=!0);const i=w(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),c=u(i);if(r){const t=p(c);return e.concat(c,c.visualViewport||[],h(i)?i:[],t&&n?g(t):[])}return e.concat(i,g(i,[],n))}function p(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function y(t){return e=t,r()&&(e instanceof Element||e instanceof u(e).Element)?t:t.contextElement;var e}function x(t){const e=y(t);if(!a(e))return i(1);const o=e.getBoundingClientRect(),{width:r,height:c,$:u}=function(t){const e=v(t);let o=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=a(t),c=r?t.offsetWidth:o,u=r?t.offsetHeight:i,l=n(o)!==c||n(i)!==u;return l&&(o=c,i=u),{width:o,height:i,$:l}}(e);let l=(u?n(o.width):o.width)/r,s=(u?n(o.height):o.height)/c;return l&&Number.isFinite(l)||(l=1),s&&Number.isFinite(s)||(s=1),{x:l,y:s}}function b(t,e,n,o){void 0===e&&(e=!1);const r=t.getBoundingClientRect(),c=y(t);let l=i(1);e&&(l=x(t));const s=i(0);let a=(r.left+s.x)/l.x,f=(r.top+s.y)/l.y,d=r.width/l.x,h=r.height/l.y;if(c){const t=o;let e=u(c),n=p(e);for(;n&&o&&t!==e;){const t=x(n),o=n.getBoundingClientRect(),i=v(n),r=o.left+(n.clientLeft+parseFloat(i.paddingLeft))*t.x,c=o.top+(n.clientTop+parseFloat(i.paddingTop))*t.y;a*=t.x,f*=t.y,d*=t.x,h*=t.y,a+=r,f+=c,e=u(n),n=p(e)}}return function(t){const{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}}({width:d,height:h,x:a,y:f})}function E(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function R(n,i,r,c){void 0===c&&(c={});const{ancestorScroll:u=!0,ancestorResize:s=!0,elementResize:a="function"==typeof ResizeObserver,layoutShift:f="function"==typeof IntersectionObserver,animationFrame:d=!1}=c,h=y(n),m=u||s?[...h?g(h):[],...g(i)]:[];m.forEach(t=>{u&&t.addEventListener("scroll",r,{passive:!0}),s&&t.addEventListener("resize",r)});const v=h&&f?function(n,i){let r,c=null;const u=l(n);function s(){var t;clearTimeout(r),null==(t=c)||t.disconnect(),c=null}return function l(a,f){void 0===a&&(a=!1),void 0===f&&(f=1),s();const d=n.getBoundingClientRect(),{left:h,top:m,width:v,height:w}=d;if(a||i(),!v||!w)return;const g={rootMargin:-o(m)+"px "+-o(u.clientWidth-(h+v))+"px "+-o(u.clientHeight-(m+w))+"px "+-o(h)+"px",threshold:e(0,t(1,f))||1};let p=!0;function y(t){const e=t[0].intersectionRatio;if(e!==f){if(!p)return l();e?l(!1,e):r=setTimeout(()=>{l(!1,1e-7)},1e3)}1!==e||E(d,n.getBoundingClientRect())||l(),p=!1}try{c=new IntersectionObserver(y,{...g,root:u.ownerDocument})}catch(x){c=new IntersectionObserver(y,g)}c.observe(n)}(!0),s}(h,r):null;let w,p=-1,x=null;a&&(x=new ResizeObserver(t=>{let[e]=t;e&&e.target===h&&x&&(x.unobserve(i),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var t;null==(t=x)||t.observe(i)})),r()}),h&&!d&&x.observe(h),x.observe(i));let R=d?b(n):null;return d&&function t(){const e=b(n);R&&!E(R,e)&&r();R=e,w=requestAnimationFrame(t)}(),r(),()=>{var t;m.forEach(t=>{u&&t.removeEventListener("scroll",r),s&&t.removeEventListener("resize",r)}),null==v||v(),null==(t=x)||t.disconnect(),x=null,d&&cancelAnimationFrame(w)}}export{R as a};
