!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):(t=t||self).useIntersectionObserver=e(t.React)}(this,(function(t){"use strict";function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=new Array(e);e>n;n++)o[n]=t[n];return o}function n(){return this.intersectionRatio>0}function o(t){return t.value+t.unit}function r(t){t._checkForIntersections()}function i(t){if(!this._observationTargets.some((function(e){return e.element==t}))){if(!t||1!=t.nodeType)throw new Error("target must be an Element");this._registerInstance(),this._observationTargets.push({element:t,entry:null}),this._monitorIntersections(t.ownerDocument),this._checkForIntersections()}}function s(t){this._observationTargets=this._observationTargets.filter((function(e){return e.element!=t})),this._unmonitorIntersections(t.ownerDocument),0==this._observationTargets.length&&this._unregisterInstance()}function u(){this._observationTargets=[],this._unmonitorAllIntersections(),this._unregisterInstance()}function c(){var t=this._queuedEntries.slice();return this._queuedEntries=[],t}function h(t,e,n){if("number"!=typeof t||isNaN(t)||0>t||t>1)throw new Error("threshold must be a number between 0 and 1 inclusively");return t!==n[e-1]}function a(t){var e=t||[0];return Array.isArray(e)||(e=[e]),e.sort().filter(h)}function l(t){var e=/^(-?\d*\.?\d+)(px|%)$/.exec(t);if(!e)throw new Error("rootMargin must be specified in pixels or percent");return{value:parseFloat(e[1]),unit:e[2]}}function f(t){var e=(t||"0px").split(/\s+/).map(l);return e[1]=e[1]||e[0],e[2]=e[2]||e[0],e[3]=e[3]||e[1],e}function d(){var t=this._monitoringUnsubscribes.slice(0);this._monitoringDocuments.length=0,this._monitoringUnsubscribes.length=0;for(var e=0;ei!=o>i)return 1}}function g(t,e,n,o){"function"==typeof t.addEventListener?t.addEventListener(e,n,o||0):"function"==typeof t.attachEvent&&t.attachEvent("on"+e,n)}function m(t,e,n,o){"function"==typeof t.removeEventListener?t.removeEventListener(e,n,o||0):"function"==typeof t.detatchEvent&&t.detatchEvent("on"+e,n)}function b(t){return!t||"x"in t?t:{top:t.top,y:t.top,bottom:t.bottom,left:t.left,x:t.left,right:t.right,width:t.width,height:t.height}}function y(t,e){var n=e.top-t.top,o=e.left-t.left;return{top:n,left:o,height:e.height,width:e.width,bottom:n+e.height,right:o+e.width}}function _(t){try{return t.defaultView&&t.defaultView.frameElement||null}catch(t){return null}}function w(t){var n=t.root,o=function(t,e){if(null==t)return{};var n,o,r={},i=Object.keys(t);for(o=0;oe.indexOf(n)&&(r[n]=t[n]);return r}(t,["root"]),r=JSON.stringify(o),i=E.get(n);return i||(i={},E.set(n,i)),i[r]?i[r]:i[r]=function(t){var n=t.root,o=void 0===n?null:n,r=t.pollInterval,i=void 0===r?null:r,s=t.useMutationObserver,u=void 0===s?0:s,c=t.rootMargin,h=void 0===c?"0px 0px 0px 0px":c,a=t.threshold,l=void 0===a?0:a,f=new Set;if("undefined"==typeof IntersectionObserver)return null;var d=new IntersectionObserver((function(t){for(var n,o=function(t,n){var o;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(o=function(t){if(t){if("string"==typeof t)return e(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,void 0):void 0}}(t))||n&&t&&"number"==typeof t.length){o&&(t=o);var r=0;return function(){return r=0&&a>=0&&{top:i,bottom:s,left:u,right:c,width:h,height:a}||null),!f)break;d=d&&I(d)}return f}},e.prototype._getRootRect=function(){var t;if(this.root)t=l(this.root);else{var e=E.documentElement,n=E.body;t={top:0,left:0,right:e.clientWidth||n.clientWidth,width:e.clientWidth||n.clientWidth,bottom:e.clientHeight||n.clientHeight,height:e.clientHeight||n.clientHeight}}return this._expandRectByRootMargin(t)},e.prototype._expandRectByRootMargin=p,e.prototype._hasCrossedThreshold=v,e.prototype._rootIsInDom=function(){return!this.root||w(E,this.root)},e.prototype._rootContainsTarget=function(t){return w(this.root||E,t)&&(!this.root||this.root.ownerDocument==t.ownerDocument)},e.prototype._registerInstance=function(){0>R.indexOf(this)&&R.push(this)},e.prototype._unregisterInstance=function(){var t=R.indexOf(this);-1!=t&&R.splice(t,1)},window.IntersectionObserver=e,window.IntersectionObserverEntry=t}}();var I=t["undefined"!=typeof document&&void 0!==document.createElement?"useLayoutEffect":"useEffect"],E=new Map;return function(e,n){void 0===n&&(n={});var o=n,r=o.root,i=void 0===r?null:r,s=o.pollInterval,u=void 0===s?null:s,c=o.useMutationObserver,h=void 0===c?0:c,a=o.rootMargin,l=void 0===a?"0px 0px 0px 0px":a,f=o.threshold,d=void 0===f?0:f,p=o.initialIsIntersecting,v=void 0===p?0:p,g=t.useState((function(){return{boundingClientRect:null,intersectionRatio:0,intersectionRect:null,isIntersecting:v,rootBounds:null,target:null,time:0}})),m=g[0],b=g[1],y=t.useState((function(){return w({root:i,pollInterval:u,useMutationObserver:h,rootMargin:l,threshold:d})})),_=y[0],E=y[1];return t.useEffect((function(){var t=w({root:i,pollInterval:u,useMutationObserver:h,rootMargin:l,threshold:d});E(t)}),[i,l,u,h,JSON.stringify(d)]),I((function(){var t=e&&"current"in e?e.current:e;if(_&&t){var n=0;_.observer.observe(t);var o=function(e){if(!n)for(var o=0;o