@spscommerce/positioning 8.7.4 → 8.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var j=Object.defineProperty;var V=(e,r,s)=>r in e?j(e,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[r]=s;var k=(e,r,s)=>(V(e,typeof r!="symbol"?r+"":r,s),s);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const F=require("@spscommerce/utils");var A=(e=>(e.TOP_LEFT="top left",e.TOP_MIDDLE="top middle",e.TOP_RIGHT="top right",e.RIGHT_TOP="right top",e.RIGHT_MIDDLE="right middle",e.RIGHT_BOTTOM="right bottom",e.BOTTOM_RIGHT="bottom right",e.BOTTOM_MIDDLE="bottom middle",e.BOTTOM_LEFT="bottom left",e.LEFT_BOTTOM="left bottom",e.LEFT_MIDDLE="left middle",e.LEFT_TOP="left top",e))(A||{}),D=(e=>(e.TOP_LEFT="top left",e.TOP_RIGHT="top right",e.BOTTOM_LEFT="bottom left",e.BOTTOM_RIGHT="bottom right",e))(D||{});const N={anchor:D.TOP_LEFT,offsets:[],position:A.TOP_LEFT};(function(){if(typeof window!="object")return;if("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype){"isIntersecting"in window.IntersectionObserverEntry.prototype||Object.defineProperty(window.IntersectionObserverEntry.prototype,"isIntersecting",{get:function(){return this.intersectionRatio>0}});return}function e(t){try{return t.defaultView&&t.defaultView.frameElement||null}catch{return null}}var r=function(t){for(var n=t,o=e(n);o;)n=o.ownerDocument,o=e(n);return n}(window.document),s=[],f=null,g=null;function b(t){this.time=t.time,this.target=t.target,this.rootBounds=m(t.rootBounds),this.boundingClientRect=m(t.boundingClientRect),this.intersectionRect=m(t.intersectionRect||w()),this.isIntersecting=!!t.intersectionRect;var n=this.boundingClientRect,o=n.width*n.height,a=this.intersectionRect,c=a.width*a.height;o?this.intersectionRatio=Number((c/o).toFixed(4)):this.intersectionRatio=this.isIntersecting?1:0}function l(t,n){var o=n||{};if(typeof t!="function")throw new Error("callback must be a function");if(o.root&&o.root.nodeType!=1&&o.root.nodeType!=9)throw new Error("root must be a Document or Element");this._checkForIntersections=d(this._checkForIntersections.bind(this),this.THROTTLE_TIMEOUT),this._callback=t,this._observationTargets=[],this._queuedEntries=[],this._rootMarginValues=this._parseRootMargin(o.rootMargin),this.thresholds=this._initThresholds(o.threshold),this.root=o.root||null,this.rootMargin=this._rootMarginValues.map(function(a){return a.value+a.unit}).join(" "),this._monitoringDocuments=[],this._monitoringUnsubscribes=[]}l.prototype.THROTTLE_TIMEOUT=100,l.prototype.POLL_INTERVAL=null,l.prototype.USE_MUTATION_OBSERVER=!0,l._setupCrossOriginUpdater=function(){return f||(f=function(t,n){!t||!n?g=w():g=x(t,n),s.forEach(function(o){o._checkForIntersections()})}),f},l._resetCrossOriginUpdater=function(){f=null,g=null},l.prototype.observe=function(t){var n=this._observationTargets.some(function(o){return o.element==t});if(!n){if(!(t&&t.nodeType==1))throw new Error("target must be an Element");this._registerInstance(),this._observationTargets.push({element:t,entry:null}),this._monitorIntersections(t.ownerDocument),this._checkForIntersections()}},l.prototype.unobserve=function(t){this._observationTargets=this._observationTargets.filter(function(n){return n.element!=t}),this._unmonitorIntersections(t.ownerDocument),this._observationTargets.length==0&&this._unregisterInstance()},l.prototype.disconnect=function(){this._observationTargets=[],this._unmonitorAllIntersections(),this._unregisterInstance()},l.prototype.takeRecords=function(){var t=this._queuedEntries.slice();return this._queuedEntries=[],t},l.prototype._initThresholds=function(t){var n=t||[0];return Array.isArray(n)||(n=[n]),n.sort().filter(function(o,a,c){if(typeof o!="number"||isNaN(o)||o<0||o>1)throw new Error("threshold must be a number between 0 and 1 inclusively");return o!==c[a-1]})},l.prototype._parseRootMargin=function(t){var n=t||"0px",o=n.split(/\s+/).map(function(a){var c=/^(-?\d*\.?\d+)(px|%)$/.exec(a);if(!c)throw new Error("rootMargin must be specified in pixels or percent");return{value:parseFloat(c[1]),unit:c[2]}});return o[1]=o[1]||o[0],o[2]=o[2]||o[0],o[3]=o[3]||o[1],o},l.prototype._monitorIntersections=function(t){var n=t.defaultView;if(!!n&&this._monitoringDocuments.indexOf(t)==-1){var o=this._checkForIntersections,a=null,c=null;this.POLL_INTERVAL?a=n.setInterval(o,this.POLL_INTERVAL):(u(n,"resize",o,!0),u(t,"scroll",o,!0),this.USE_MUTATION_OBSERVER&&"MutationObserver"in n&&(c=new n.MutationObserver(o),c.observe(t,{attributes:!0,childList:!0,characterData:!0,subtree:!0}))),this._monitoringDocuments.push(t),this._monitoringUnsubscribes.push(function(){var O=t.defaultView;O&&(a&&O.clearInterval(a),p(O,"resize",o,!0)),p(t,"scroll",o,!0),c&&c.disconnect()});var E=this.root&&(this.root.ownerDocument||this.root)||r;if(t!=E){var y=e(t);y&&this._monitorIntersections(y.ownerDocument)}}},l.prototype._unmonitorIntersections=function(t){var n=this._monitoringDocuments.indexOf(t);if(n!=-1){var o=this.root&&(this.root.ownerDocument||this.root)||r,a=this._observationTargets.some(function(y){var O=y.element.ownerDocument;if(O==t)return!0;for(;O&&O!=o;){var R=e(O);if(O=R&&R.ownerDocument,O==t)return!0}return!1});if(!a){var c=this._monitoringUnsubscribes[n];if(this._monitoringDocuments.splice(n,1),this._monitoringUnsubscribes.splice(n,1),c(),t!=o){var E=e(t);E&&this._unmonitorIntersections(E.ownerDocument)}}}},l.prototype._unmonitorAllIntersections=function(){var t=this._monitoringUnsubscribes.slice(0);this._monitoringDocuments.length=0,this._monitoringUnsubscribes.length=0;for(var n=0;n<t.length;n++)t[n]()},l.prototype._checkForIntersections=function(){if(!(!this.root&&f&&!g)){var t=this._rootIsInDom(),n=t?this._getRootRect():w();this._observationTargets.forEach(function(o){var a=o.element,c=T(a),E=this._rootContainsTarget(a),y=o.entry,O=t&&E&&this._computeTargetAndRootIntersection(a,c,n),R=null;this._rootContainsTarget(a)?(!f||this.root)&&(R=n):R=w();var M=o.entry=new b({time:_(),target:a,boundingClientRect:c,rootBounds:R,intersectionRect:O});y?t&&E?this._hasCrossedThreshold(y,M)&&this._queuedEntries.push(M):y&&y.isIntersecting&&this._queuedEntries.push(M):this._queuedEntries.push(M)},this),this._queuedEntries.length&&this._callback(this.takeRecords(),this)}},l.prototype._computeTargetAndRootIntersection=function(t,n,o){if(window.getComputedStyle(t).display!="none"){for(var a=n,c=I(t),E=!1;!E&&c;){var y=null,O=c.nodeType==1?window.getComputedStyle(c):{};if(O.display=="none")return null;if(c==this.root||c.nodeType==9)if(E=!0,c==this.root||c==r)f&&!this.root?!g||g.width==0&&g.height==0?(c=null,y=null,a=null):y=g:y=o;else{var R=I(c),M=R&&T(R),C=R&&this._computeTargetAndRootIntersection(R,M,o);M&&C?(c=R,y=x(M,C)):(c=null,a=null)}else{var S=c.ownerDocument;c!=S.body&&c!=S.documentElement&&O.overflow!="visible"&&(y=T(c))}if(y&&(a=v(y,a)),!a)break;c=c&&I(c)}return a}},l.prototype._getRootRect=function(){var t;if(this.root&&!L(this.root))t=T(this.root);else{var n=L(this.root)?this.root:r,o=n.documentElement,a=n.body;t={top:0,left:0,right:o.clientWidth||a.clientWidth,width:o.clientWidth||a.clientWidth,bottom:o.clientHeight||a.clientHeight,height:o.clientHeight||a.clientHeight}}return this._expandRectByRootMargin(t)},l.prototype._expandRectByRootMargin=function(t){var n=this._rootMarginValues.map(function(a,c){return a.unit=="px"?a.value:a.value*(c%2?t.width:t.height)/100}),o={top:t.top-n[0],right:t.right+n[1],bottom:t.bottom+n[2],left:t.left-n[3]};return o.width=o.right-o.left,o.height=o.bottom-o.top,o},l.prototype._hasCrossedThreshold=function(t,n){var o=t&&t.isIntersecting?t.intersectionRatio||0:-1,a=n.isIntersecting?n.intersectionRatio||0:-1;if(o!==a)for(var c=0;c<this.thresholds.length;c++){var E=this.thresholds[c];if(E==o||E==a||E<o!=E<a)return!0}},l.prototype._rootIsInDom=function(){return!this.root||h(r,this.root)},l.prototype._rootContainsTarget=function(t){var n=this.root&&(this.root.ownerDocument||this.root)||r;return h(n,t)&&(!this.root||n==t.ownerDocument)},l.prototype._registerInstance=function(){s.indexOf(this)<0&&s.push(this)},l.prototype._unregisterInstance=function(){var t=s.indexOf(this);t!=-1&&s.splice(t,1)};function _(){return window.performance&&performance.now&&performance.now()}function d(t,n){var o=null;return function(){o||(o=setTimeout(function(){t(),o=null},n))}}function u(t,n,o,a){typeof t.addEventListener=="function"?t.addEventListener(n,o,a||!1):typeof t.attachEvent=="function"&&t.attachEvent("on"+n,o)}function p(t,n,o,a){typeof t.removeEventListener=="function"?t.removeEventListener(n,o,a||!1):typeof t.detatchEvent=="function"&&t.detatchEvent("on"+n,o)}function v(t,n){var o=Math.max(t.top,n.top),a=Math.min(t.bottom,n.bottom),c=Math.max(t.left,n.left),E=Math.min(t.right,n.right),y=E-c,O=a-o;return y>=0&&O>=0&&{top:o,bottom:a,left:c,right:E,width:y,height:O}||null}function T(t){var n;try{n=t.getBoundingClientRect()}catch{}return n?(n.width&&n.height||(n={top:n.top,right:n.right,bottom:n.bottom,left:n.left,width:n.right-n.left,height:n.bottom-n.top}),n):w()}function w(){return{top:0,bottom:0,left:0,right:0,width:0,height:0}}function m(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 x(t,n){var o=n.top-t.top,a=n.left-t.left;return{top:o,left:a,height:n.height,width:n.width,bottom:o+n.height,right:a+n.width}}function h(t,n){for(var o=n;o;){if(o==t)return!0;o=I(o)}return!1}function I(t){var n=t.parentNode;return t.nodeType==9&&t!=r?e(t):(n&&n.assignedSlot&&(n=n.assignedSlot.parentNode),n&&n.nodeType==11&&n.host?n.host:n)}function L(t){return t&&t.nodeType===9}window.IntersectionObserver=l,window.IntersectionObserverEntry=b})();var H={exports:{}};(function(e){var r=Object.prototype.hasOwnProperty,s="~";function f(){}Object.create&&(f.prototype=Object.create(null),new f().__proto__||(s=!1));function g(d,u,p){this.fn=d,this.context=u,this.once=p||!1}function b(d,u,p,v,T){if(typeof p!="function")throw new TypeError("The listener must be a function");var w=new g(p,v||d,T),m=s?s+u:u;return d._events[m]?d._events[m].fn?d._events[m]=[d._events[m],w]:d._events[m].push(w):(d._events[m]=w,d._eventsCount++),d}function l(d,u){--d._eventsCount===0?d._events=new f:delete d._events[u]}function _(){this._events=new f,this._eventsCount=0}_.prototype.eventNames=function(){var u=[],p,v;if(this._eventsCount===0)return u;for(v in p=this._events)r.call(p,v)&&u.push(s?v.slice(1):v);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(p)):u},_.prototype.listeners=function(u){var p=s?s+u:u,v=this._events[p];if(!v)return[];if(v.fn)return[v.fn];for(var T=0,w=v.length,m=new Array(w);T<w;T++)m[T]=v[T].fn;return m},_.prototype.listenerCount=function(u){var p=s?s+u:u,v=this._events[p];return v?v.fn?1:v.length:0},_.prototype.emit=function(u,p,v,T,w,m){var x=s?s+u:u;if(!this._events[x])return!1;var h=this._events[x],I=arguments.length,L,t;if(h.fn){switch(h.once&&this.removeListener(u,h.fn,void 0,!0),I){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,p),!0;case 3:return h.fn.call(h.context,p,v),!0;case 4:return h.fn.call(h.context,p,v,T),!0;case 5:return h.fn.call(h.context,p,v,T,w),!0;case 6:return h.fn.call(h.context,p,v,T,w,m),!0}for(t=1,L=new Array(I-1);t<I;t++)L[t-1]=arguments[t];h.fn.apply(h.context,L)}else{var n=h.length,o;for(t=0;t<n;t++)switch(h[t].once&&this.removeListener(u,h[t].fn,void 0,!0),I){case 1:h[t].fn.call(h[t].context);break;case 2:h[t].fn.call(h[t].context,p);break;case 3:h[t].fn.call(h[t].context,p,v);break;case 4:h[t].fn.call(h[t].context,p,v,T);break;default:if(!L)for(o=1,L=new Array(I-1);o<I;o++)L[o-1]=arguments[o];h[t].fn.apply(h[t].context,L)}}return!0},_.prototype.on=function(u,p,v){return b(this,u,p,v,!1)},_.prototype.once=function(u,p,v){return b(this,u,p,v,!0)},_.prototype.removeListener=function(u,p,v,T){var w=s?s+u:u;if(!this._events[w])return this;if(!p)return l(this,w),this;var m=this._events[w];if(m.fn)m.fn===p&&(!T||m.once)&&(!v||m.context===v)&&l(this,w);else{for(var x=0,h=[],I=m.length;x<I;x++)(m[x].fn!==p||T&&!m[x].once||v&&m[x].context!==v)&&h.push(m[x]);h.length?this._events[w]=h.length===1?h[0]:h:l(this,w)}return this},_.prototype.removeAllListeners=function(u){var p;return u?(p=s?s+u:u,this._events[p]&&l(this,p)):(this._events=new f,this._eventsCount=0),this},_.prototype.off=_.prototype.removeListener,_.prototype.addListener=_.prototype.on,_.prefixed=s,_.EventEmitter=_,e.exports=_})(H);var G=Object.defineProperty,z=Object.getOwnPropertyDescriptor,W=(e,r,s,f)=>{for(var g=f>1?void 0:f?z(r,s):r,b=e.length-1,l;b>=0;b--)(l=e[b])&&(g=(f?l(r,s,g):l(g))||g);return f&&g&&G(r,s,g),g};const B=60;var P;const i=(P=class{static on(e,r){i.events.on(e,r)}static off(e,r){i.events.off(e,r)}static once(e,r){i.events.once(e,r)}static checkCollisions(e,r){const s=r||Array.from(i.elements.keys()),f=e.getBoundingClientRect(),g=[];for(const b of s)if(b!==e){const l=b.getBoundingClientRect();l.left<=f.right&&l.right>=f.left&&l.top<=f.bottom&&l.bottom>=f.top&&g.push(b)}g.length&&i.onElementIntersection(e,g)}static isPositioned(e){return i.elements.has(e)}static getPositioningOptions(e){return i.elements.has(e)?i.elements.get(e):null}static position(e,r={}){const s={...N,...r};let f=e;for(;f!==document.body;)if(f=f.parentElement,f.classList.contains("sps-focused-task")){s.scrollParent=f,i.registeredScrollParents.has(f)||(i.registeredScrollParents.add(f),f.addEventListener("scroll",i.update));break}if(e.style.visibility="hidden",i.elements.size===0&&(window.addEventListener("resize",i.update),window.addEventListener("scroll",i.update)),!s.relativeTo)throw new Error("You must provide an element for the relativeTo option to position an element.");i.elements.set(e,s),F.onNextTick(()=>{i.fixElementPosition(e),i.viewportObserver.observe(e),e.style.visibility="",i.checkCollisions(e)})}static release(e){if(i.elements.has(e)){i.clearStyles(e);const r=i.elements.get(e);r.scrollParent&&(r.scrollParent.removeEventListener("scroll",i.update),i.registeredScrollParents.delete(r.scrollParent)),i.elements.delete(e),i.elements.size===0&&(window.removeEventListener("resize",i.update),window.removeEventListener("scroll",i.update)),i.viewportObserver.unobserve(e)}}static releaseAll(){for(const e of i.elements.keys())i.release(e)}static refresh(e){i.elements.has(e)&&(i.clearStyles(e),i.fixElementPosition(e),i.checkCollisions(e))}static refreshAll(){for(const e of i.elements.keys())i.refresh(e)}static reposition(e,r){if(i.elements.has(e)){const s=i.elements.get(e);i.elements.set(e,Object.assign(s,r)),i.refresh(e)}}static onViewportIntersection(e){for(const r of e){const s=Object.keys(IntersectionObserverEntry.prototype).reduce((f,g)=>({...f,[g]:r[g]}),{});s.rootBounds=s.rootBounds||i.getRootBounds(),i.events.emit("viewportIntersection",Object.freeze(s))}}static onElementIntersection(e,r){i.events.emit("elementIntersection",{target:e,intersectingWith:r})}static getRootBounds(){const e=Math.max(document.documentElement.clientWidth,window.innerWidth||0),r=Math.max(document.documentElement.clientHeight,window.innerHeight||0);return{x:0,y:B,left:0,top:B,right:e,bottom:r,height:r-B,width:e}}static clearStyles(e){Object.assign(e.style,{position:"",width:"",top:"",left:"",right:"",bottom:"",visibility:"",zIndex:""})}static fixElementPosition(e,r){if(!this.elements.has(e))return;const s=r||this.elements.get(e),f=this.getRootBounds(),g=e.getBoundingClientRect(),b=s.relativeTo.getBoundingClientRect(),{width:l}=s.useRelativeTargetWidth?b:g;Object.assign(e.style,{minWidth:`${l}px`,position:"fixed",zIndex:s.zIndex||""});let _,d;const u=s.position.split(" "),p=s.offsets[0]||0,v=s.offsets[1]||0;switch(_=0,d=0,u[0]){case"top":_=b.top-g.height-p;break;case"left":d=b.left-l-p;break;case"right":d=b.right+p;break;case"bottom":_=b.bottom+p;break;default:throw new Error(`${s.position} is not a valid position`)}switch(u[1]){case"left":d=b.left-v;break;case"top":_=b.top-v;break;case"middle":u[0]==="top"||u[0]==="bottom"?d=b.left+b.width/2-l/2+v:(u[0]==="left"||u[0]==="right")&&(_=b.top+b.height/2-g.height/2+v);break;case"bottom":_=b.bottom-g.height+v;break;case"right":d=b.right-l+v;break;default:throw new Error(`${s.position} is not a valid position`)}const T=_+g.height,w=d+g.width,m=`${Math.round(_)}px`,x=`${Math.round(f.bottom-T)}px`,h=`${Math.round(d)}px`,I=`${Math.round(f.right-w)}px`;switch(s.anchor){case D.TOP_LEFT:Object.assign(e.style,{top:m,bottom:"auto",left:h,right:"auto"});break;case D.TOP_RIGHT:Object.assign(e.style,{top:m,bottom:"auto",left:"auto",right:I});break;case D.BOTTOM_LEFT:Object.assign(e.style,{top:"auto",bottom:x,left:h,right:"auto"});break;case D.BOTTOM_RIGHT:Object.assign(e.style,{top:"auto",bottom:x,left:"auto",right:I});break}}static update(e){const r=i.elements.entries(),s=[];for(const[f,g]of r)(!e||e.target===document||e.target===g.scrollParent||e.target===window)&&(i.fixElementPosition(f,g),i.checkCollisions(f,s),s.push(f))}on(e,r){i.on(e,r)}off(e,r){i.off(e,r)}once(e,r){i.once(e,r)}isPositioned(e){return i.isPositioned(e)}getPositioningOptions(e){return i.getPositioningOptions(e)}position(e,r={}){i.position(e,r)}release(e){i.release(e)}releaseAll(){i.releaseAll()}refresh(e){i.refresh(e)}refreshAll(){i.refreshAll()}reposition(e,r){i.reposition(e,r)}},k(P,"elements",new Map),k(P,"registeredScrollParents",new Set),k(P,"events",new H.exports.EventEmitter),k(P,"viewportObserver",new IntersectionObserver(i.onViewportIntersection,{rootMargin:`-${B}px 0px 0px`,threshold:1})),P);let U=i;W([F.lockedToAnimationFrames],U,"update",1);exports.DEFAULT_POSITIONING_OPTIONS=N;exports.Position=A;exports.PositionAnchor=D;exports.PositioningService=U;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("@spscommerce/utils");var k=(g=>(g.TOP_LEFT="top left",g.TOP_MIDDLE="top middle",g.TOP_RIGHT="top right",g.RIGHT_TOP="right top",g.RIGHT_MIDDLE="right middle",g.RIGHT_BOTTOM="right bottom",g.BOTTOM_RIGHT="bottom right",g.BOTTOM_MIDDLE="bottom middle",g.BOTTOM_LEFT="bottom left",g.LEFT_BOTTOM="left bottom",g.LEFT_MIDDLE="left middle",g.LEFT_TOP="left top",g))(k||{}),M=(g=>(g.TOP_LEFT="top left",g.TOP_RIGHT="top right",g.BOTTOM_LEFT="bottom left",g.BOTTOM_RIGHT="bottom right",g))(M||{});const F={anchor:M.TOP_LEFT,offsets:[],position:k.TOP_LEFT};(function(){if(typeof window!="object")return;if("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype){"isIntersecting"in window.IntersectionObserverEntry.prototype||Object.defineProperty(window.IntersectionObserverEntry.prototype,"isIntersecting",{get:function(){return this.intersectionRatio>0}});return}function g(t){try{return t.defaultView&&t.defaultView.frameElement||null}catch{return null}}var n=function(t){for(var e=t,o=g(e);o;)e=o.ownerDocument,o=g(e);return e}(window.document),i=[],p=null,f=null;function w(t){this.time=t.time,this.target=t.target,this.rootBounds=b(t.rootBounds),this.boundingClientRect=b(t.boundingClientRect),this.intersectionRect=b(t.intersectionRect||y()),this.isIntersecting=!!t.intersectionRect;var e=this.boundingClientRect,o=e.width*e.height,s=this.intersectionRect,l=s.width*s.height;o?this.intersectionRatio=Number((l/o).toFixed(4)):this.intersectionRatio=this.isIntersecting?1:0}function a(t,e){var o=e||{};if(typeof t!="function")throw new Error("callback must be a function");if(o.root&&o.root.nodeType!=1&&o.root.nodeType!=9)throw new Error("root must be a Document or Element");this._checkForIntersections=d(this._checkForIntersections.bind(this),this.THROTTLE_TIMEOUT),this._callback=t,this._observationTargets=[],this._queuedEntries=[],this._rootMarginValues=this._parseRootMargin(o.rootMargin),this.thresholds=this._initThresholds(o.threshold),this.root=o.root||null,this.rootMargin=this._rootMarginValues.map(function(s){return s.value+s.unit}).join(" "),this._monitoringDocuments=[],this._monitoringUnsubscribes=[]}a.prototype.THROTTLE_TIMEOUT=100,a.prototype.POLL_INTERVAL=null,a.prototype.USE_MUTATION_OBSERVER=!0,a._setupCrossOriginUpdater=function(){return p||(p=function(t,e){!t||!e?f=y():f=x(t,e),i.forEach(function(o){o._checkForIntersections()})}),p},a._resetCrossOriginUpdater=function(){p=null,f=null},a.prototype.observe=function(t){var e=this._observationTargets.some(function(o){return o.element==t});if(!e){if(!(t&&t.nodeType==1))throw new Error("target must be an Element");this._registerInstance(),this._observationTargets.push({element:t,entry:null}),this._monitorIntersections(t.ownerDocument),this._checkForIntersections()}},a.prototype.unobserve=function(t){this._observationTargets=this._observationTargets.filter(function(e){return e.element!=t}),this._unmonitorIntersections(t.ownerDocument),this._observationTargets.length==0&&this._unregisterInstance()},a.prototype.disconnect=function(){this._observationTargets=[],this._unmonitorAllIntersections(),this._unregisterInstance()},a.prototype.takeRecords=function(){var t=this._queuedEntries.slice();return this._queuedEntries=[],t},a.prototype._initThresholds=function(t){var e=t||[0];return Array.isArray(e)||(e=[e]),e.sort().filter(function(o,s,l){if(typeof o!="number"||isNaN(o)||o<0||o>1)throw new Error("threshold must be a number between 0 and 1 inclusively");return o!==l[s-1]})},a.prototype._parseRootMargin=function(t){var e=t||"0px",o=e.split(/\s+/).map(function(s){var l=/^(-?\d*\.?\d+)(px|%)$/.exec(s);if(!l)throw new Error("rootMargin must be specified in pixels or percent");return{value:parseFloat(l[1]),unit:l[2]}});return o[1]=o[1]||o[0],o[2]=o[2]||o[0],o[3]=o[3]||o[1],o},a.prototype._monitorIntersections=function(t){var e=t.defaultView;if(e&&this._monitoringDocuments.indexOf(t)==-1){var o=this._checkForIntersections,s=null,l=null;this.POLL_INTERVAL?s=e.setInterval(o,this.POLL_INTERVAL):(c(e,"resize",o,!0),c(t,"scroll",o,!0),this.USE_MUTATION_OBSERVER&&"MutationObserver"in e&&(l=new e.MutationObserver(o),l.observe(t,{attributes:!0,childList:!0,characterData:!0,subtree:!0}))),this._monitoringDocuments.push(t),this._monitoringUnsubscribes.push(function(){var I=t.defaultView;I&&(s&&I.clearInterval(s),u(I,"resize",o,!0)),u(t,"scroll",o,!0),l&&l.disconnect()});var O=this.root&&(this.root.ownerDocument||this.root)||n;if(t!=O){var E=g(t);E&&this._monitorIntersections(E.ownerDocument)}}},a.prototype._unmonitorIntersections=function(t){var e=this._monitoringDocuments.indexOf(t);if(e!=-1){var o=this.root&&(this.root.ownerDocument||this.root)||n,s=this._observationTargets.some(function(E){var I=E.element.ownerDocument;if(I==t)return!0;for(;I&&I!=o;){var L=g(I);if(I=L&&L.ownerDocument,I==t)return!0}return!1});if(!s){var l=this._monitoringUnsubscribes[e];if(this._monitoringDocuments.splice(e,1),this._monitoringUnsubscribes.splice(e,1),l(),t!=o){var O=g(t);O&&this._unmonitorIntersections(O.ownerDocument)}}}},a.prototype._unmonitorAllIntersections=function(){var t=this._monitoringUnsubscribes.slice(0);this._monitoringDocuments.length=0,this._monitoringUnsubscribes.length=0;for(var e=0;e<t.length;e++)t[e]()},a.prototype._checkForIntersections=function(){if(!(!this.root&&p&&!f)){var t=this._rootIsInDom(),e=t?this._getRootRect():y();this._observationTargets.forEach(function(o){var s=o.element,l=T(s),O=this._rootContainsTarget(s),E=o.entry,I=t&&O&&this._computeTargetAndRootIntersection(s,l,e),L=null;this._rootContainsTarget(s)?(!p||this.root)&&(L=e):L=y();var D=o.entry=new w({time:m(),target:s,boundingClientRect:l,rootBounds:L,intersectionRect:I});E?t&&O?this._hasCrossedThreshold(E,D)&&this._queuedEntries.push(D):E&&E.isIntersecting&&this._queuedEntries.push(D):this._queuedEntries.push(D)},this),this._queuedEntries.length&&this._callback(this.takeRecords(),this)}},a.prototype._computeTargetAndRootIntersection=function(t,e,o){if(window.getComputedStyle(t).display!="none"){for(var s=e,l=_(t),O=!1;!O&&l;){var E=null,I=l.nodeType==1?window.getComputedStyle(l):{};if(I.display=="none")return null;if(l==this.root||l.nodeType==9)if(O=!0,l==this.root||l==n)p&&!this.root?!f||f.width==0&&f.height==0?(l=null,E=null,s=null):E=f:E=o;else{var L=_(l),D=L&&T(L),B=L&&this._computeTargetAndRootIntersection(L,D,o);D&&B?(l=L,E=x(D,B)):(l=null,s=null)}else{var A=l.ownerDocument;l!=A.body&&l!=A.documentElement&&I.overflow!="visible"&&(E=T(l))}if(E&&(s=v(E,s)),!s)break;l=l&&_(l)}return s}},a.prototype._getRootRect=function(){var t;if(this.root&&!R(this.root))t=T(this.root);else{var e=R(this.root)?this.root:n,o=e.documentElement,s=e.body;t={top:0,left:0,right:o.clientWidth||s.clientWidth,width:o.clientWidth||s.clientWidth,bottom:o.clientHeight||s.clientHeight,height:o.clientHeight||s.clientHeight}}return this._expandRectByRootMargin(t)},a.prototype._expandRectByRootMargin=function(t){var e=this._rootMarginValues.map(function(s,l){return s.unit=="px"?s.value:s.value*(l%2?t.width:t.height)/100}),o={top:t.top-e[0],right:t.right+e[1],bottom:t.bottom+e[2],left:t.left-e[3]};return o.width=o.right-o.left,o.height=o.bottom-o.top,o},a.prototype._hasCrossedThreshold=function(t,e){var o=t&&t.isIntersecting?t.intersectionRatio||0:-1,s=e.isIntersecting?e.intersectionRatio||0:-1;if(o!==s)for(var l=0;l<this.thresholds.length;l++){var O=this.thresholds[l];if(O==o||O==s||O<o!=O<s)return!0}},a.prototype._rootIsInDom=function(){return!this.root||h(n,this.root)},a.prototype._rootContainsTarget=function(t){var e=this.root&&(this.root.ownerDocument||this.root)||n;return h(e,t)&&(!this.root||e==t.ownerDocument)},a.prototype._registerInstance=function(){i.indexOf(this)<0&&i.push(this)},a.prototype._unregisterInstance=function(){var t=i.indexOf(this);t!=-1&&i.splice(t,1)};function m(){return window.performance&&performance.now&&performance.now()}function d(t,e){var o=null;return function(){o||(o=setTimeout(function(){t(),o=null},e))}}function c(t,e,o,s){typeof t.addEventListener=="function"?t.addEventListener(e,o,s):typeof t.attachEvent=="function"&&t.attachEvent("on"+e,o)}function u(t,e,o,s){typeof t.removeEventListener=="function"?t.removeEventListener(e,o,s):typeof t.detatchEvent=="function"&&t.detatchEvent("on"+e,o)}function v(t,e){var o=Math.max(t.top,e.top),s=Math.min(t.bottom,e.bottom),l=Math.max(t.left,e.left),O=Math.min(t.right,e.right),E=O-l,I=s-o;return E>=0&&I>=0&&{top:o,bottom:s,left:l,right:O,width:E,height:I}||null}function T(t){var e;try{e=t.getBoundingClientRect()}catch{}return e?(e.width&&e.height||(e={top:e.top,right:e.right,bottom:e.bottom,left:e.left,width:e.right-e.left,height:e.bottom-e.top}),e):y()}function y(){return{top:0,bottom:0,left:0,right:0,width:0,height:0}}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 x(t,e){var o=e.top-t.top,s=e.left-t.left;return{top:o,left:s,height:e.height,width:e.width,bottom:o+e.height,right:s+e.width}}function h(t,e){for(var o=e;o;){if(o==t)return!0;o=_(o)}return!1}function _(t){var e=t.parentNode;return t.nodeType==9&&t!=n?g(t):(e&&e.assignedSlot&&(e=e.assignedSlot.parentNode),e&&e.nodeType==11&&e.host?e.host:e)}function R(t){return t&&t.nodeType===9}window.IntersectionObserver=a,window.IntersectionObserverEntry=w})();var S={exports:{}};(function(g){var n=Object.prototype.hasOwnProperty,i="~";function p(){}Object.create&&(p.prototype=Object.create(null),new p().__proto__||(i=!1));function f(d,c,u){this.fn=d,this.context=c,this.once=u||!1}function w(d,c,u,v,T){if(typeof u!="function")throw new TypeError("The listener must be a function");var y=new f(u,v||d,T),b=i?i+c:c;return d._events[b]?d._events[b].fn?d._events[b]=[d._events[b],y]:d._events[b].push(y):(d._events[b]=y,d._eventsCount++),d}function a(d,c){--d._eventsCount===0?d._events=new p:delete d._events[c]}function m(){this._events=new p,this._eventsCount=0}m.prototype.eventNames=function(){var c=[],u,v;if(this._eventsCount===0)return c;for(v in u=this._events)n.call(u,v)&&c.push(i?v.slice(1):v);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(u)):c},m.prototype.listeners=function(c){var u=i?i+c:c,v=this._events[u];if(!v)return[];if(v.fn)return[v.fn];for(var T=0,y=v.length,b=new Array(y);T<y;T++)b[T]=v[T].fn;return b},m.prototype.listenerCount=function(c){var u=i?i+c:c,v=this._events[u];return v?v.fn?1:v.length:0},m.prototype.emit=function(c,u,v,T,y,b){var x=i?i+c:c;if(!this._events[x])return!1;var h=this._events[x],_=arguments.length,R,t;if(h.fn){switch(h.once&&this.removeListener(c,h.fn,void 0,!0),_){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,u),!0;case 3:return h.fn.call(h.context,u,v),!0;case 4:return h.fn.call(h.context,u,v,T),!0;case 5:return h.fn.call(h.context,u,v,T,y),!0;case 6:return h.fn.call(h.context,u,v,T,y,b),!0}for(t=1,R=new Array(_-1);t<_;t++)R[t-1]=arguments[t];h.fn.apply(h.context,R)}else{var e=h.length,o;for(t=0;t<e;t++)switch(h[t].once&&this.removeListener(c,h[t].fn,void 0,!0),_){case 1:h[t].fn.call(h[t].context);break;case 2:h[t].fn.call(h[t].context,u);break;case 3:h[t].fn.call(h[t].context,u,v);break;case 4:h[t].fn.call(h[t].context,u,v,T);break;default:if(!R)for(o=1,R=new Array(_-1);o<_;o++)R[o-1]=arguments[o];h[t].fn.apply(h[t].context,R)}}return!0},m.prototype.on=function(c,u,v){return w(this,c,u,v,!1)},m.prototype.once=function(c,u,v){return w(this,c,u,v,!0)},m.prototype.removeListener=function(c,u,v,T){var y=i?i+c:c;if(!this._events[y])return this;if(!u)return a(this,y),this;var b=this._events[y];if(b.fn)b.fn===u&&(!T||b.once)&&(!v||b.context===v)&&a(this,y);else{for(var x=0,h=[],_=b.length;x<_;x++)(b[x].fn!==u||T&&!b[x].once||v&&b[x].context!==v)&&h.push(b[x]);h.length?this._events[y]=h.length===1?h[0]:h:a(this,y)}return this},m.prototype.removeAllListeners=function(c){var u;return c?(u=i?i+c:c,this._events[u]&&a(this,u)):(this._events=new p,this._eventsCount=0),this},m.prototype.off=m.prototype.removeListener,m.prototype.addListener=m.prototype.on,m.prefixed=i,m.EventEmitter=m,g.exports=m})(S);var H=S.exports,U=Object.defineProperty,j=Object.getOwnPropertyDescriptor,V=(g,n,i,p)=>{for(var f=j(n,i),w=g.length-1,a;w>=0;w--)(a=g[w])&&(f=a(n,i,f)||f);return f&&U(n,i,f),f};const P=60;var r;const N=(r=class{static on(n,i){r.events.on(n,i)}static off(n,i){r.events.off(n,i)}static once(n,i){r.events.once(n,i)}static checkCollisions(n,i){const p=i||Array.from(r.elements.keys()),f=n.getBoundingClientRect(),w=[];for(const a of p)if(a!==n){const m=a.getBoundingClientRect();m.left<=f.right&&m.right>=f.left&&m.top<=f.bottom&&m.bottom>=f.top&&w.push(a)}w.length&&r.onElementIntersection(n,w)}static isPositioned(n){return r.elements.has(n)}static getPositioningOptions(n){return r.elements.has(n)?r.elements.get(n):null}static position(n,i={}){const p={...F,...i};let f=n;for(;f!==document.body;)if(f=f.parentElement,f.classList.contains("sps-focused-task")){p.scrollParent=f,r.registeredScrollParents.has(f)||(r.registeredScrollParents.add(f),f.addEventListener("scroll",r.update));break}if(n.style.visibility="hidden",r.elements.size===0&&(window.addEventListener("resize",r.update),window.addEventListener("scroll",r.update)),!p.relativeTo)throw new Error("You must provide an element for the relativeTo option to position an element.");r.elements.set(n,p),C.onNextTick(()=>{r.fixElementPosition(n),r.viewportObserver.observe(n),n.style.visibility="",r.checkCollisions(n)})}static release(n){if(r.elements.has(n)){r.clearStyles(n);const i=r.elements.get(n);i.scrollParent&&(i.scrollParent.removeEventListener("scroll",r.update),r.registeredScrollParents.delete(i.scrollParent)),r.elements.delete(n),r.elements.size===0&&(window.removeEventListener("resize",r.update),window.removeEventListener("scroll",r.update)),r.viewportObserver.unobserve(n)}}static releaseAll(){for(const n of r.elements.keys())r.release(n)}static refresh(n){r.elements.has(n)&&(r.clearStyles(n),r.fixElementPosition(n),r.checkCollisions(n))}static refreshAll(){for(const n of r.elements.keys())r.refresh(n)}static reposition(n,i){if(r.elements.has(n)){const p=r.elements.get(n);r.elements.set(n,Object.assign(p,i)),r.refresh(n)}}static onViewportIntersection(n){for(const i of n){const p=Object.keys(IntersectionObserverEntry.prototype).reduce((f,w)=>({...f,[w]:i[w]}),{});p.rootBounds=p.rootBounds||r.getRootBounds(),r.events.emit("viewportIntersection",Object.freeze(p))}}static onElementIntersection(n,i){r.events.emit("elementIntersection",{target:n,intersectingWith:i})}static getRootBounds(){const n=Math.max(document.documentElement.clientWidth,window.innerWidth||0),i=Math.max(document.documentElement.clientHeight,window.innerHeight||0);return{x:0,y:P,left:0,top:P,right:n,bottom:i,height:i-P,width:n}}static clearStyles(n){Object.assign(n.style,{position:"",width:"",top:"",left:"",right:"",bottom:"",visibility:"",zIndex:""})}static fixElementPosition(n,i){if(!this.elements.has(n))return;const p=i||this.elements.get(n),f=this.getRootBounds(),w=n.getBoundingClientRect(),a=p.relativeTo.getBoundingClientRect(),{width:m}=p.useRelativeTargetWidth?a:w;Object.assign(n.style,{minWidth:`${m}px`,position:"fixed",zIndex:p.zIndex||""});let d,c;const u=p.position.split(" "),v=p.offsets[0]||0,T=p.offsets[1]||0;switch(d=0,c=0,u[0]){case"top":d=a.top-w.height-v;break;case"left":c=a.left-m-v;break;case"right":c=a.right+v;break;case"bottom":d=a.bottom+v;break;default:throw new Error(`${p.position} is not a valid position`)}switch(u[1]){case"left":c=a.left-T;break;case"top":d=a.top-T;break;case"middle":u[0]==="top"||u[0]==="bottom"?c=a.left+a.width/2-m/2+T:(u[0]==="left"||u[0]==="right")&&(d=a.top+a.height/2-w.height/2+T);break;case"bottom":d=a.bottom-w.height+T;break;case"right":c=a.right-m+T;break;default:throw new Error(`${p.position} is not a valid position`)}const y=d+w.height,b=c+w.width,x=`${Math.round(d)}px`,h=`${Math.round(f.bottom-y)}px`,_=`${Math.round(c)}px`,R=`${Math.round(f.right-b)}px`;switch(p.anchor){case M.TOP_LEFT:Object.assign(n.style,{top:x,bottom:"auto",left:_,right:"auto"});break;case M.TOP_RIGHT:Object.assign(n.style,{top:x,bottom:"auto",left:"auto",right:R});break;case M.BOTTOM_LEFT:Object.assign(n.style,{top:"auto",bottom:h,left:_,right:"auto"});break;case M.BOTTOM_RIGHT:Object.assign(n.style,{top:"auto",bottom:h,left:"auto",right:R});break}}static update(n){const i=r.elements.entries(),p=[];for(const[f,w]of i)(!n||n.target===document||n.target===w.scrollParent||n.target===window)&&(r.fixElementPosition(f,w),r.checkCollisions(f,p),p.push(f))}on(n,i){r.on(n,i)}off(n,i){r.off(n,i)}once(n,i){r.once(n,i)}isPositioned(n){return r.isPositioned(n)}getPositioningOptions(n){return r.getPositioningOptions(n)}position(n,i={}){r.position(n,i)}release(n){r.release(n)}releaseAll(){r.releaseAll()}refresh(n){r.refresh(n)}refreshAll(){r.refreshAll()}reposition(n,i){r.reposition(n,i)}},r.elements=new Map,r.registeredScrollParents=new Set,r.events=new H.EventEmitter,r.viewportObserver=new IntersectionObserver(r.onViewportIntersection,{rootMargin:`-${P}px 0px 0px`,threshold:1}),r);V([C.lockedToAnimationFrames],N,"update");let G=N;exports.DEFAULT_POSITIONING_OPTIONS=F;exports.Position=k;exports.PositionAnchor=M;exports.PositioningService=G;
package/lib/index.es.js CHANGED
@@ -1,12 +1,9 @@
1
- var H = Object.defineProperty;
2
- var N = (e, r, s) => r in e ? H(e, r, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[r] = s;
3
- var k = (e, r, s) => (N(e, typeof r != "symbol" ? r + "" : r, s), s);
4
- import { onNextTick as U, lockedToAnimationFrames as j } from "@spscommerce/utils";
5
- var F = /* @__PURE__ */ ((e) => (e.TOP_LEFT = "top left", e.TOP_MIDDLE = "top middle", e.TOP_RIGHT = "top right", e.RIGHT_TOP = "right top", e.RIGHT_MIDDLE = "right middle", e.RIGHT_BOTTOM = "right bottom", e.BOTTOM_RIGHT = "bottom right", e.BOTTOM_MIDDLE = "bottom middle", e.BOTTOM_LEFT = "bottom left", e.LEFT_BOTTOM = "left bottom", e.LEFT_MIDDLE = "left middle", e.LEFT_TOP = "left top", e))(F || {}), P = /* @__PURE__ */ ((e) => (e.TOP_LEFT = "top left", e.TOP_RIGHT = "top right", e.BOTTOM_LEFT = "bottom left", e.BOTTOM_RIGHT = "bottom right", e))(P || {});
6
- const V = {
7
- anchor: P.TOP_LEFT,
1
+ import { onNextTick as H, lockedToAnimationFrames as S } from "@spscommerce/utils";
2
+ var C = /* @__PURE__ */ ((g) => (g.TOP_LEFT = "top left", g.TOP_MIDDLE = "top middle", g.TOP_RIGHT = "top right", g.RIGHT_TOP = "right top", g.RIGHT_MIDDLE = "right middle", g.RIGHT_BOTTOM = "right bottom", g.BOTTOM_RIGHT = "bottom right", g.BOTTOM_MIDDLE = "bottom middle", g.BOTTOM_LEFT = "bottom left", g.LEFT_BOTTOM = "left bottom", g.LEFT_MIDDLE = "left middle", g.LEFT_TOP = "left top", g))(C || {}), M = /* @__PURE__ */ ((g) => (g.TOP_LEFT = "top left", g.TOP_RIGHT = "top right", g.BOTTOM_LEFT = "bottom left", g.BOTTOM_RIGHT = "bottom right", g))(M || {});
3
+ const N = {
4
+ anchor: M.TOP_LEFT,
8
5
  offsets: [],
9
- position: F.TOP_LEFT
6
+ position: C.TOP_LEFT
10
7
  };
11
8
  (function() {
12
9
  if (typeof window != "object")
@@ -23,25 +20,25 @@ const V = {
23
20
  );
24
21
  return;
25
22
  }
26
- function e(t) {
23
+ function g(t) {
27
24
  try {
28
25
  return t.defaultView && t.defaultView.frameElement || null;
29
26
  } catch {
30
27
  return null;
31
28
  }
32
29
  }
33
- var r = function(t) {
34
- for (var n = t, o = e(n); o; )
35
- n = o.ownerDocument, o = e(n);
36
- return n;
37
- }(window.document), s = [], f = null, g = null;
38
- function b(t) {
39
- this.time = t.time, this.target = t.target, this.rootBounds = m(t.rootBounds), this.boundingClientRect = m(t.boundingClientRect), this.intersectionRect = m(t.intersectionRect || w()), this.isIntersecting = !!t.intersectionRect;
40
- var n = this.boundingClientRect, o = n.width * n.height, a = this.intersectionRect, c = a.width * a.height;
41
- o ? this.intersectionRatio = Number((c / o).toFixed(4)) : this.intersectionRatio = this.isIntersecting ? 1 : 0;
42
- }
43
- function l(t, n) {
44
- var o = n || {};
30
+ var n = function(t) {
31
+ for (var e = t, o = g(e); o; )
32
+ e = o.ownerDocument, o = g(e);
33
+ return e;
34
+ }(window.document), i = [], p = null, f = null;
35
+ function w(t) {
36
+ this.time = t.time, this.target = t.target, this.rootBounds = b(t.rootBounds), this.boundingClientRect = b(t.boundingClientRect), this.intersectionRect = b(t.intersectionRect || y()), this.isIntersecting = !!t.intersectionRect;
37
+ var e = this.boundingClientRect, o = e.width * e.height, s = this.intersectionRect, l = s.width * s.height;
38
+ o ? this.intersectionRatio = Number((l / o).toFixed(4)) : this.intersectionRatio = this.isIntersecting ? 1 : 0;
39
+ }
40
+ function a(t, e) {
41
+ var o = e || {};
45
42
  if (typeof t != "function")
46
43
  throw new Error("callback must be a function");
47
44
  if (o.root && o.root.nodeType != 1 && o.root.nodeType != 9)
@@ -49,225 +46,226 @@ const V = {
49
46
  this._checkForIntersections = d(
50
47
  this._checkForIntersections.bind(this),
51
48
  this.THROTTLE_TIMEOUT
52
- ), this._callback = t, this._observationTargets = [], this._queuedEntries = [], this._rootMarginValues = this._parseRootMargin(o.rootMargin), this.thresholds = this._initThresholds(o.threshold), this.root = o.root || null, this.rootMargin = this._rootMarginValues.map(function(a) {
53
- return a.value + a.unit;
49
+ ), this._callback = t, this._observationTargets = [], this._queuedEntries = [], this._rootMarginValues = this._parseRootMargin(o.rootMargin), this.thresholds = this._initThresholds(o.threshold), this.root = o.root || null, this.rootMargin = this._rootMarginValues.map(function(s) {
50
+ return s.value + s.unit;
54
51
  }).join(" "), this._monitoringDocuments = [], this._monitoringUnsubscribes = [];
55
52
  }
56
- l.prototype.THROTTLE_TIMEOUT = 100, l.prototype.POLL_INTERVAL = null, l.prototype.USE_MUTATION_OBSERVER = !0, l._setupCrossOriginUpdater = function() {
57
- return f || (f = function(t, n) {
58
- !t || !n ? g = w() : g = x(t, n), s.forEach(function(o) {
53
+ a.prototype.THROTTLE_TIMEOUT = 100, a.prototype.POLL_INTERVAL = null, a.prototype.USE_MUTATION_OBSERVER = !0, a._setupCrossOriginUpdater = function() {
54
+ return p || (p = function(t, e) {
55
+ !t || !e ? f = y() : f = x(t, e), i.forEach(function(o) {
59
56
  o._checkForIntersections();
60
57
  });
61
- }), f;
62
- }, l._resetCrossOriginUpdater = function() {
63
- f = null, g = null;
64
- }, l.prototype.observe = function(t) {
65
- var n = this._observationTargets.some(function(o) {
58
+ }), p;
59
+ }, a._resetCrossOriginUpdater = function() {
60
+ p = null, f = null;
61
+ }, a.prototype.observe = function(t) {
62
+ var e = this._observationTargets.some(function(o) {
66
63
  return o.element == t;
67
64
  });
68
- if (!n) {
65
+ if (!e) {
69
66
  if (!(t && t.nodeType == 1))
70
67
  throw new Error("target must be an Element");
71
68
  this._registerInstance(), this._observationTargets.push({ element: t, entry: null }), this._monitorIntersections(t.ownerDocument), this._checkForIntersections();
72
69
  }
73
- }, l.prototype.unobserve = function(t) {
74
- this._observationTargets = this._observationTargets.filter(function(n) {
75
- return n.element != t;
70
+ }, a.prototype.unobserve = function(t) {
71
+ this._observationTargets = this._observationTargets.filter(function(e) {
72
+ return e.element != t;
76
73
  }), this._unmonitorIntersections(t.ownerDocument), this._observationTargets.length == 0 && this._unregisterInstance();
77
- }, l.prototype.disconnect = function() {
74
+ }, a.prototype.disconnect = function() {
78
75
  this._observationTargets = [], this._unmonitorAllIntersections(), this._unregisterInstance();
79
- }, l.prototype.takeRecords = function() {
76
+ }, a.prototype.takeRecords = function() {
80
77
  var t = this._queuedEntries.slice();
81
78
  return this._queuedEntries = [], t;
82
- }, l.prototype._initThresholds = function(t) {
83
- var n = t || [0];
84
- return Array.isArray(n) || (n = [n]), n.sort().filter(function(o, a, c) {
79
+ }, a.prototype._initThresholds = function(t) {
80
+ var e = t || [0];
81
+ return Array.isArray(e) || (e = [e]), e.sort().filter(function(o, s, l) {
85
82
  if (typeof o != "number" || isNaN(o) || o < 0 || o > 1)
86
83
  throw new Error("threshold must be a number between 0 and 1 inclusively");
87
- return o !== c[a - 1];
84
+ return o !== l[s - 1];
88
85
  });
89
- }, l.prototype._parseRootMargin = function(t) {
90
- var n = t || "0px", o = n.split(/\s+/).map(function(a) {
91
- var c = /^(-?\d*\.?\d+)(px|%)$/.exec(a);
92
- if (!c)
86
+ }, a.prototype._parseRootMargin = function(t) {
87
+ var e = t || "0px", o = e.split(/\s+/).map(function(s) {
88
+ var l = /^(-?\d*\.?\d+)(px|%)$/.exec(s);
89
+ if (!l)
93
90
  throw new Error("rootMargin must be specified in pixels or percent");
94
- return { value: parseFloat(c[1]), unit: c[2] };
91
+ return { value: parseFloat(l[1]), unit: l[2] };
95
92
  });
96
93
  return o[1] = o[1] || o[0], o[2] = o[2] || o[0], o[3] = o[3] || o[1], o;
97
- }, l.prototype._monitorIntersections = function(t) {
98
- var n = t.defaultView;
99
- if (!!n && this._monitoringDocuments.indexOf(t) == -1) {
100
- var o = this._checkForIntersections, a = null, c = null;
101
- this.POLL_INTERVAL ? a = n.setInterval(o, this.POLL_INTERVAL) : (u(n, "resize", o, !0), u(t, "scroll", o, !0), this.USE_MUTATION_OBSERVER && "MutationObserver" in n && (c = new n.MutationObserver(o), c.observe(t, {
94
+ }, a.prototype._monitorIntersections = function(t) {
95
+ var e = t.defaultView;
96
+ if (e && this._monitoringDocuments.indexOf(t) == -1) {
97
+ var o = this._checkForIntersections, s = null, l = null;
98
+ this.POLL_INTERVAL ? s = e.setInterval(o, this.POLL_INTERVAL) : (c(e, "resize", o, !0), c(t, "scroll", o, !0), this.USE_MUTATION_OBSERVER && "MutationObserver" in e && (l = new e.MutationObserver(o), l.observe(t, {
102
99
  attributes: !0,
103
100
  childList: !0,
104
101
  characterData: !0,
105
102
  subtree: !0
106
103
  }))), this._monitoringDocuments.push(t), this._monitoringUnsubscribes.push(function() {
107
- var O = t.defaultView;
108
- O && (a && O.clearInterval(a), p(O, "resize", o, !0)), p(t, "scroll", o, !0), c && c.disconnect();
104
+ var I = t.defaultView;
105
+ I && (s && I.clearInterval(s), u(I, "resize", o, !0)), u(t, "scroll", o, !0), l && l.disconnect();
109
106
  });
110
- var E = this.root && (this.root.ownerDocument || this.root) || r;
111
- if (t != E) {
112
- var y = e(t);
113
- y && this._monitorIntersections(y.ownerDocument);
107
+ var O = this.root && (this.root.ownerDocument || this.root) || n;
108
+ if (t != O) {
109
+ var E = g(t);
110
+ E && this._monitorIntersections(E.ownerDocument);
114
111
  }
115
112
  }
116
- }, l.prototype._unmonitorIntersections = function(t) {
117
- var n = this._monitoringDocuments.indexOf(t);
118
- if (n != -1) {
119
- var o = this.root && (this.root.ownerDocument || this.root) || r, a = this._observationTargets.some(function(y) {
120
- var O = y.element.ownerDocument;
121
- if (O == t)
113
+ }, a.prototype._unmonitorIntersections = function(t) {
114
+ var e = this._monitoringDocuments.indexOf(t);
115
+ if (e != -1) {
116
+ var o = this.root && (this.root.ownerDocument || this.root) || n, s = this._observationTargets.some(function(E) {
117
+ var I = E.element.ownerDocument;
118
+ if (I == t)
122
119
  return !0;
123
- for (; O && O != o; ) {
124
- var R = e(O);
125
- if (O = R && R.ownerDocument, O == t)
120
+ for (; I && I != o; ) {
121
+ var L = g(I);
122
+ if (I = L && L.ownerDocument, I == t)
126
123
  return !0;
127
124
  }
128
125
  return !1;
129
126
  });
130
- if (!a) {
131
- var c = this._monitoringUnsubscribes[n];
132
- if (this._monitoringDocuments.splice(n, 1), this._monitoringUnsubscribes.splice(n, 1), c(), t != o) {
133
- var E = e(t);
134
- E && this._unmonitorIntersections(E.ownerDocument);
127
+ if (!s) {
128
+ var l = this._monitoringUnsubscribes[e];
129
+ if (this._monitoringDocuments.splice(e, 1), this._monitoringUnsubscribes.splice(e, 1), l(), t != o) {
130
+ var O = g(t);
131
+ O && this._unmonitorIntersections(O.ownerDocument);
135
132
  }
136
133
  }
137
134
  }
138
- }, l.prototype._unmonitorAllIntersections = function() {
135
+ }, a.prototype._unmonitorAllIntersections = function() {
139
136
  var t = this._monitoringUnsubscribes.slice(0);
140
137
  this._monitoringDocuments.length = 0, this._monitoringUnsubscribes.length = 0;
141
- for (var n = 0; n < t.length; n++)
142
- t[n]();
143
- }, l.prototype._checkForIntersections = function() {
144
- if (!(!this.root && f && !g)) {
145
- var t = this._rootIsInDom(), n = t ? this._getRootRect() : w();
138
+ for (var e = 0; e < t.length; e++)
139
+ t[e]();
140
+ }, a.prototype._checkForIntersections = function() {
141
+ if (!(!this.root && p && !f)) {
142
+ var t = this._rootIsInDom(), e = t ? this._getRootRect() : y();
146
143
  this._observationTargets.forEach(function(o) {
147
- var a = o.element, c = T(a), E = this._rootContainsTarget(a), y = o.entry, O = t && E && this._computeTargetAndRootIntersection(a, c, n), R = null;
148
- this._rootContainsTarget(a) ? (!f || this.root) && (R = n) : R = w();
149
- var D = o.entry = new b({
150
- time: _(),
151
- target: a,
152
- boundingClientRect: c,
153
- rootBounds: R,
154
- intersectionRect: O
144
+ var s = o.element, l = T(s), O = this._rootContainsTarget(s), E = o.entry, I = t && O && this._computeTargetAndRootIntersection(s, l, e), L = null;
145
+ this._rootContainsTarget(s) ? (!p || this.root) && (L = e) : L = y();
146
+ var D = o.entry = new w({
147
+ time: m(),
148
+ target: s,
149
+ boundingClientRect: l,
150
+ rootBounds: L,
151
+ intersectionRect: I
155
152
  });
156
- y ? t && E ? this._hasCrossedThreshold(y, D) && this._queuedEntries.push(D) : y && y.isIntersecting && this._queuedEntries.push(D) : this._queuedEntries.push(D);
153
+ E ? t && O ? this._hasCrossedThreshold(E, D) && this._queuedEntries.push(D) : E && E.isIntersecting && this._queuedEntries.push(D) : this._queuedEntries.push(D);
157
154
  }, this), this._queuedEntries.length && this._callback(this.takeRecords(), this);
158
155
  }
159
- }, l.prototype._computeTargetAndRootIntersection = function(t, n, o) {
156
+ }, a.prototype._computeTargetAndRootIntersection = function(t, e, o) {
160
157
  if (window.getComputedStyle(t).display != "none") {
161
- for (var a = n, c = I(t), E = !1; !E && c; ) {
162
- var y = null, O = c.nodeType == 1 ? window.getComputedStyle(c) : {};
163
- if (O.display == "none")
158
+ for (var s = e, l = _(t), O = !1; !O && l; ) {
159
+ var E = null, I = l.nodeType == 1 ? window.getComputedStyle(l) : {};
160
+ if (I.display == "none")
164
161
  return null;
165
- if (c == this.root || c.nodeType == 9)
166
- if (E = !0, c == this.root || c == r)
167
- f && !this.root ? !g || g.width == 0 && g.height == 0 ? (c = null, y = null, a = null) : y = g : y = o;
162
+ if (l == this.root || l.nodeType == /* DOCUMENT */
163
+ 9)
164
+ if (O = !0, l == this.root || l == n)
165
+ p && !this.root ? !f || f.width == 0 && f.height == 0 ? (l = null, E = null, s = null) : E = f : E = o;
168
166
  else {
169
- var R = I(c), D = R && T(R), C = R && this._computeTargetAndRootIntersection(R, D, o);
170
- D && C ? (c = R, y = x(D, C)) : (c = null, a = null);
167
+ var L = _(l), D = L && T(L), P = L && this._computeTargetAndRootIntersection(L, D, o);
168
+ D && P ? (l = L, E = x(D, P)) : (l = null, s = null);
171
169
  }
172
170
  else {
173
- var A = c.ownerDocument;
174
- c != A.body && c != A.documentElement && O.overflow != "visible" && (y = T(c));
171
+ var B = l.ownerDocument;
172
+ l != B.body && l != B.documentElement && I.overflow != "visible" && (E = T(l));
175
173
  }
176
- if (y && (a = v(y, a)), !a)
174
+ if (E && (s = v(E, s)), !s)
177
175
  break;
178
- c = c && I(c);
176
+ l = l && _(l);
179
177
  }
180
- return a;
178
+ return s;
181
179
  }
182
- }, l.prototype._getRootRect = function() {
180
+ }, a.prototype._getRootRect = function() {
183
181
  var t;
184
- if (this.root && !L(this.root))
182
+ if (this.root && !R(this.root))
185
183
  t = T(this.root);
186
184
  else {
187
- var n = L(this.root) ? this.root : r, o = n.documentElement, a = n.body;
185
+ var e = R(this.root) ? this.root : n, o = e.documentElement, s = e.body;
188
186
  t = {
189
187
  top: 0,
190
188
  left: 0,
191
- right: o.clientWidth || a.clientWidth,
192
- width: o.clientWidth || a.clientWidth,
193
- bottom: o.clientHeight || a.clientHeight,
194
- height: o.clientHeight || a.clientHeight
189
+ right: o.clientWidth || s.clientWidth,
190
+ width: o.clientWidth || s.clientWidth,
191
+ bottom: o.clientHeight || s.clientHeight,
192
+ height: o.clientHeight || s.clientHeight
195
193
  };
196
194
  }
197
195
  return this._expandRectByRootMargin(t);
198
- }, l.prototype._expandRectByRootMargin = function(t) {
199
- var n = this._rootMarginValues.map(function(a, c) {
200
- return a.unit == "px" ? a.value : a.value * (c % 2 ? t.width : t.height) / 100;
196
+ }, a.prototype._expandRectByRootMargin = function(t) {
197
+ var e = this._rootMarginValues.map(function(s, l) {
198
+ return s.unit == "px" ? s.value : s.value * (l % 2 ? t.width : t.height) / 100;
201
199
  }), o = {
202
- top: t.top - n[0],
203
- right: t.right + n[1],
204
- bottom: t.bottom + n[2],
205
- left: t.left - n[3]
200
+ top: t.top - e[0],
201
+ right: t.right + e[1],
202
+ bottom: t.bottom + e[2],
203
+ left: t.left - e[3]
206
204
  };
207
205
  return o.width = o.right - o.left, o.height = o.bottom - o.top, o;
208
- }, l.prototype._hasCrossedThreshold = function(t, n) {
209
- var o = t && t.isIntersecting ? t.intersectionRatio || 0 : -1, a = n.isIntersecting ? n.intersectionRatio || 0 : -1;
210
- if (o !== a)
211
- for (var c = 0; c < this.thresholds.length; c++) {
212
- var E = this.thresholds[c];
213
- if (E == o || E == a || E < o != E < a)
206
+ }, a.prototype._hasCrossedThreshold = function(t, e) {
207
+ var o = t && t.isIntersecting ? t.intersectionRatio || 0 : -1, s = e.isIntersecting ? e.intersectionRatio || 0 : -1;
208
+ if (o !== s)
209
+ for (var l = 0; l < this.thresholds.length; l++) {
210
+ var O = this.thresholds[l];
211
+ if (O == o || O == s || O < o != O < s)
214
212
  return !0;
215
213
  }
216
- }, l.prototype._rootIsInDom = function() {
217
- return !this.root || h(r, this.root);
218
- }, l.prototype._rootContainsTarget = function(t) {
219
- var n = this.root && (this.root.ownerDocument || this.root) || r;
220
- return h(n, t) && (!this.root || n == t.ownerDocument);
221
- }, l.prototype._registerInstance = function() {
222
- s.indexOf(this) < 0 && s.push(this);
223
- }, l.prototype._unregisterInstance = function() {
224
- var t = s.indexOf(this);
225
- t != -1 && s.splice(t, 1);
214
+ }, a.prototype._rootIsInDom = function() {
215
+ return !this.root || h(n, this.root);
216
+ }, a.prototype._rootContainsTarget = function(t) {
217
+ var e = this.root && (this.root.ownerDocument || this.root) || n;
218
+ return h(e, t) && (!this.root || e == t.ownerDocument);
219
+ }, a.prototype._registerInstance = function() {
220
+ i.indexOf(this) < 0 && i.push(this);
221
+ }, a.prototype._unregisterInstance = function() {
222
+ var t = i.indexOf(this);
223
+ t != -1 && i.splice(t, 1);
226
224
  };
227
- function _() {
225
+ function m() {
228
226
  return window.performance && performance.now && performance.now();
229
227
  }
230
- function d(t, n) {
228
+ function d(t, e) {
231
229
  var o = null;
232
230
  return function() {
233
231
  o || (o = setTimeout(function() {
234
232
  t(), o = null;
235
- }, n));
233
+ }, e));
236
234
  };
237
235
  }
238
- function u(t, n, o, a) {
239
- typeof t.addEventListener == "function" ? t.addEventListener(n, o, a || !1) : typeof t.attachEvent == "function" && t.attachEvent("on" + n, o);
236
+ function c(t, e, o, s) {
237
+ typeof t.addEventListener == "function" ? t.addEventListener(e, o, s) : typeof t.attachEvent == "function" && t.attachEvent("on" + e, o);
240
238
  }
241
- function p(t, n, o, a) {
242
- typeof t.removeEventListener == "function" ? t.removeEventListener(n, o, a || !1) : typeof t.detatchEvent == "function" && t.detatchEvent("on" + n, o);
239
+ function u(t, e, o, s) {
240
+ typeof t.removeEventListener == "function" ? t.removeEventListener(e, o, s) : typeof t.detatchEvent == "function" && t.detatchEvent("on" + e, o);
243
241
  }
244
- function v(t, n) {
245
- var o = Math.max(t.top, n.top), a = Math.min(t.bottom, n.bottom), c = Math.max(t.left, n.left), E = Math.min(t.right, n.right), y = E - c, O = a - o;
246
- return y >= 0 && O >= 0 && {
242
+ function v(t, e) {
243
+ var o = Math.max(t.top, e.top), s = Math.min(t.bottom, e.bottom), l = Math.max(t.left, e.left), O = Math.min(t.right, e.right), E = O - l, I = s - o;
244
+ return E >= 0 && I >= 0 && {
247
245
  top: o,
248
- bottom: a,
249
- left: c,
250
- right: E,
251
- width: y,
252
- height: O
246
+ bottom: s,
247
+ left: l,
248
+ right: O,
249
+ width: E,
250
+ height: I
253
251
  } || null;
254
252
  }
255
253
  function T(t) {
256
- var n;
254
+ var e;
257
255
  try {
258
- n = t.getBoundingClientRect();
256
+ e = t.getBoundingClientRect();
259
257
  } catch {
260
258
  }
261
- return n ? (n.width && n.height || (n = {
262
- top: n.top,
263
- right: n.right,
264
- bottom: n.bottom,
265
- left: n.left,
266
- width: n.right - n.left,
267
- height: n.bottom - n.top
268
- }), n) : w();
269
- }
270
- function w() {
259
+ return e ? (e.width && e.height || (e = {
260
+ top: e.top,
261
+ right: e.right,
262
+ bottom: e.bottom,
263
+ left: e.left,
264
+ width: e.right - e.left,
265
+ height: e.bottom - e.top
266
+ }), e) : y();
267
+ }
268
+ function y() {
271
269
  return {
272
270
  top: 0,
273
271
  bottom: 0,
@@ -277,7 +275,7 @@ const V = {
277
275
  height: 0
278
276
  };
279
277
  }
280
- function m(t) {
278
+ function b(t) {
281
279
  return !t || "x" in t ? t : {
282
280
  top: t.top,
283
281
  y: t.top,
@@ -289,250 +287,263 @@ const V = {
289
287
  height: t.height
290
288
  };
291
289
  }
292
- function x(t, n) {
293
- var o = n.top - t.top, a = n.left - t.left;
290
+ function x(t, e) {
291
+ var o = e.top - t.top, s = e.left - t.left;
294
292
  return {
295
293
  top: o,
296
- left: a,
297
- height: n.height,
298
- width: n.width,
299
- bottom: o + n.height,
300
- right: a + n.width
294
+ left: s,
295
+ height: e.height,
296
+ width: e.width,
297
+ bottom: o + e.height,
298
+ right: s + e.width
301
299
  };
302
300
  }
303
- function h(t, n) {
304
- for (var o = n; o; ) {
301
+ function h(t, e) {
302
+ for (var o = e; o; ) {
305
303
  if (o == t)
306
304
  return !0;
307
- o = I(o);
305
+ o = _(o);
308
306
  }
309
307
  return !1;
310
308
  }
311
- function I(t) {
312
- var n = t.parentNode;
313
- return t.nodeType == 9 && t != r ? e(t) : (n && n.assignedSlot && (n = n.assignedSlot.parentNode), n && n.nodeType == 11 && n.host ? n.host : n);
309
+ function _(t) {
310
+ var e = t.parentNode;
311
+ return t.nodeType == /* DOCUMENT */
312
+ 9 && t != n ? g(t) : (e && e.assignedSlot && (e = e.assignedSlot.parentNode), e && e.nodeType == 11 && e.host ? e.host : e);
314
313
  }
315
- function L(t) {
314
+ function R(t) {
316
315
  return t && t.nodeType === 9;
317
316
  }
318
- window.IntersectionObserver = l, window.IntersectionObserverEntry = b;
317
+ window.IntersectionObserver = a, window.IntersectionObserverEntry = w;
319
318
  })();
320
- var S = { exports: {} };
321
- (function(e) {
322
- var r = Object.prototype.hasOwnProperty, s = "~";
323
- function f() {
319
+ var A = { exports: {} };
320
+ (function(g) {
321
+ var n = Object.prototype.hasOwnProperty, i = "~";
322
+ function p() {
324
323
  }
325
- Object.create && (f.prototype = /* @__PURE__ */ Object.create(null), new f().__proto__ || (s = !1));
326
- function g(d, u, p) {
327
- this.fn = d, this.context = u, this.once = p || !1;
324
+ Object.create && (p.prototype = /* @__PURE__ */ Object.create(null), new p().__proto__ || (i = !1));
325
+ function f(d, c, u) {
326
+ this.fn = d, this.context = c, this.once = u || !1;
328
327
  }
329
- function b(d, u, p, v, T) {
330
- if (typeof p != "function")
328
+ function w(d, c, u, v, T) {
329
+ if (typeof u != "function")
331
330
  throw new TypeError("The listener must be a function");
332
- var w = new g(p, v || d, T), m = s ? s + u : u;
333
- return d._events[m] ? d._events[m].fn ? d._events[m] = [d._events[m], w] : d._events[m].push(w) : (d._events[m] = w, d._eventsCount++), d;
331
+ var y = new f(u, v || d, T), b = i ? i + c : c;
332
+ return d._events[b] ? d._events[b].fn ? d._events[b] = [d._events[b], y] : d._events[b].push(y) : (d._events[b] = y, d._eventsCount++), d;
334
333
  }
335
- function l(d, u) {
336
- --d._eventsCount === 0 ? d._events = new f() : delete d._events[u];
334
+ function a(d, c) {
335
+ --d._eventsCount === 0 ? d._events = new p() : delete d._events[c];
337
336
  }
338
- function _() {
339
- this._events = new f(), this._eventsCount = 0;
337
+ function m() {
338
+ this._events = new p(), this._eventsCount = 0;
340
339
  }
341
- _.prototype.eventNames = function() {
342
- var u = [], p, v;
340
+ m.prototype.eventNames = function() {
341
+ var c = [], u, v;
343
342
  if (this._eventsCount === 0)
344
- return u;
345
- for (v in p = this._events)
346
- r.call(p, v) && u.push(s ? v.slice(1) : v);
347
- return Object.getOwnPropertySymbols ? u.concat(Object.getOwnPropertySymbols(p)) : u;
348
- }, _.prototype.listeners = function(u) {
349
- var p = s ? s + u : u, v = this._events[p];
343
+ return c;
344
+ for (v in u = this._events)
345
+ n.call(u, v) && c.push(i ? v.slice(1) : v);
346
+ return Object.getOwnPropertySymbols ? c.concat(Object.getOwnPropertySymbols(u)) : c;
347
+ }, m.prototype.listeners = function(c) {
348
+ var u = i ? i + c : c, v = this._events[u];
350
349
  if (!v)
351
350
  return [];
352
351
  if (v.fn)
353
352
  return [v.fn];
354
- for (var T = 0, w = v.length, m = new Array(w); T < w; T++)
355
- m[T] = v[T].fn;
356
- return m;
357
- }, _.prototype.listenerCount = function(u) {
358
- var p = s ? s + u : u, v = this._events[p];
353
+ for (var T = 0, y = v.length, b = new Array(y); T < y; T++)
354
+ b[T] = v[T].fn;
355
+ return b;
356
+ }, m.prototype.listenerCount = function(c) {
357
+ var u = i ? i + c : c, v = this._events[u];
359
358
  return v ? v.fn ? 1 : v.length : 0;
360
- }, _.prototype.emit = function(u, p, v, T, w, m) {
361
- var x = s ? s + u : u;
359
+ }, m.prototype.emit = function(c, u, v, T, y, b) {
360
+ var x = i ? i + c : c;
362
361
  if (!this._events[x])
363
362
  return !1;
364
- var h = this._events[x], I = arguments.length, L, t;
363
+ var h = this._events[x], _ = arguments.length, R, t;
365
364
  if (h.fn) {
366
- switch (h.once && this.removeListener(u, h.fn, void 0, !0), I) {
365
+ switch (h.once && this.removeListener(c, h.fn, void 0, !0), _) {
367
366
  case 1:
368
367
  return h.fn.call(h.context), !0;
369
368
  case 2:
370
- return h.fn.call(h.context, p), !0;
369
+ return h.fn.call(h.context, u), !0;
371
370
  case 3:
372
- return h.fn.call(h.context, p, v), !0;
371
+ return h.fn.call(h.context, u, v), !0;
373
372
  case 4:
374
- return h.fn.call(h.context, p, v, T), !0;
373
+ return h.fn.call(h.context, u, v, T), !0;
375
374
  case 5:
376
- return h.fn.call(h.context, p, v, T, w), !0;
375
+ return h.fn.call(h.context, u, v, T, y), !0;
377
376
  case 6:
378
- return h.fn.call(h.context, p, v, T, w, m), !0;
377
+ return h.fn.call(h.context, u, v, T, y, b), !0;
379
378
  }
380
- for (t = 1, L = new Array(I - 1); t < I; t++)
381
- L[t - 1] = arguments[t];
382
- h.fn.apply(h.context, L);
379
+ for (t = 1, R = new Array(_ - 1); t < _; t++)
380
+ R[t - 1] = arguments[t];
381
+ h.fn.apply(h.context, R);
383
382
  } else {
384
- var n = h.length, o;
385
- for (t = 0; t < n; t++)
386
- switch (h[t].once && this.removeListener(u, h[t].fn, void 0, !0), I) {
383
+ var e = h.length, o;
384
+ for (t = 0; t < e; t++)
385
+ switch (h[t].once && this.removeListener(c, h[t].fn, void 0, !0), _) {
387
386
  case 1:
388
387
  h[t].fn.call(h[t].context);
389
388
  break;
390
389
  case 2:
391
- h[t].fn.call(h[t].context, p);
390
+ h[t].fn.call(h[t].context, u);
392
391
  break;
393
392
  case 3:
394
- h[t].fn.call(h[t].context, p, v);
393
+ h[t].fn.call(h[t].context, u, v);
395
394
  break;
396
395
  case 4:
397
- h[t].fn.call(h[t].context, p, v, T);
396
+ h[t].fn.call(h[t].context, u, v, T);
398
397
  break;
399
398
  default:
400
- if (!L)
401
- for (o = 1, L = new Array(I - 1); o < I; o++)
402
- L[o - 1] = arguments[o];
403
- h[t].fn.apply(h[t].context, L);
399
+ if (!R)
400
+ for (o = 1, R = new Array(_ - 1); o < _; o++)
401
+ R[o - 1] = arguments[o];
402
+ h[t].fn.apply(h[t].context, R);
404
403
  }
405
404
  }
406
405
  return !0;
407
- }, _.prototype.on = function(u, p, v) {
408
- return b(this, u, p, v, !1);
409
- }, _.prototype.once = function(u, p, v) {
410
- return b(this, u, p, v, !0);
411
- }, _.prototype.removeListener = function(u, p, v, T) {
412
- var w = s ? s + u : u;
413
- if (!this._events[w])
406
+ }, m.prototype.on = function(c, u, v) {
407
+ return w(this, c, u, v, !1);
408
+ }, m.prototype.once = function(c, u, v) {
409
+ return w(this, c, u, v, !0);
410
+ }, m.prototype.removeListener = function(c, u, v, T) {
411
+ var y = i ? i + c : c;
412
+ if (!this._events[y])
414
413
  return this;
415
- if (!p)
416
- return l(this, w), this;
417
- var m = this._events[w];
418
- if (m.fn)
419
- m.fn === p && (!T || m.once) && (!v || m.context === v) && l(this, w);
414
+ if (!u)
415
+ return a(this, y), this;
416
+ var b = this._events[y];
417
+ if (b.fn)
418
+ b.fn === u && (!T || b.once) && (!v || b.context === v) && a(this, y);
420
419
  else {
421
- for (var x = 0, h = [], I = m.length; x < I; x++)
422
- (m[x].fn !== p || T && !m[x].once || v && m[x].context !== v) && h.push(m[x]);
423
- h.length ? this._events[w] = h.length === 1 ? h[0] : h : l(this, w);
420
+ for (var x = 0, h = [], _ = b.length; x < _; x++)
421
+ (b[x].fn !== u || T && !b[x].once || v && b[x].context !== v) && h.push(b[x]);
422
+ h.length ? this._events[y] = h.length === 1 ? h[0] : h : a(this, y);
424
423
  }
425
424
  return this;
426
- }, _.prototype.removeAllListeners = function(u) {
427
- var p;
428
- return u ? (p = s ? s + u : u, this._events[p] && l(this, p)) : (this._events = new f(), this._eventsCount = 0), this;
429
- }, _.prototype.off = _.prototype.removeListener, _.prototype.addListener = _.prototype.on, _.prefixed = s, _.EventEmitter = _, e.exports = _;
430
- })(S);
431
- var G = Object.defineProperty, z = Object.getOwnPropertyDescriptor, W = (e, r, s, f) => {
432
- for (var g = f > 1 ? void 0 : f ? z(r, s) : r, b = e.length - 1, l; b >= 0; b--)
433
- (l = e[b]) && (g = (f ? l(r, s, g) : l(g)) || g);
434
- return f && g && G(r, s, g), g;
425
+ }, m.prototype.removeAllListeners = function(c) {
426
+ var u;
427
+ return c ? (u = i ? i + c : c, this._events[u] && a(this, u)) : (this._events = new p(), this._eventsCount = 0), this;
428
+ }, m.prototype.off = m.prototype.removeListener, m.prototype.addListener = m.prototype.on, m.prefixed = i, m.EventEmitter = m, g.exports = m;
429
+ })(A);
430
+ var U = A.exports, j = Object.defineProperty, V = Object.getOwnPropertyDescriptor, G = (g, n, i, p) => {
431
+ for (var f = V(n, i), w = g.length - 1, a; w >= 0; w--)
432
+ (a = g[w]) && (f = a(n, i, f) || f);
433
+ return f && j(n, i, f), f;
435
434
  };
436
- const B = 60;
437
- var M;
438
- const i = (M = class {
439
- static on(e, r) {
440
- i.events.on(e, r);
441
- }
442
- static off(e, r) {
443
- i.events.off(e, r);
444
- }
445
- static once(e, r) {
446
- i.events.once(e, r);
447
- }
448
- static checkCollisions(e, r) {
449
- const s = r || Array.from(i.elements.keys()), f = e.getBoundingClientRect(), g = [];
450
- for (const b of s)
451
- if (b !== e) {
452
- const l = b.getBoundingClientRect();
453
- l.left <= f.right && l.right >= f.left && l.top <= f.bottom && l.bottom >= f.top && g.push(b);
435
+ const k = 60;
436
+ var r;
437
+ const F = (r = class {
438
+ static on(n, i) {
439
+ r.events.on(n, i);
440
+ }
441
+ static off(n, i) {
442
+ r.events.off(n, i);
443
+ }
444
+ static once(n, i) {
445
+ r.events.once(n, i);
446
+ }
447
+ static checkCollisions(n, i) {
448
+ const p = i || Array.from(r.elements.keys()), f = n.getBoundingClientRect(), w = [];
449
+ for (const a of p)
450
+ if (a !== n) {
451
+ const m = a.getBoundingClientRect();
452
+ m.left <= f.right && m.right >= f.left && m.top <= f.bottom && m.bottom >= f.top && w.push(a);
454
453
  }
455
- g.length && i.onElementIntersection(e, g);
456
- }
457
- static isPositioned(e) {
458
- return i.elements.has(e);
459
- }
460
- static getPositioningOptions(e) {
461
- return i.elements.has(e) ? i.elements.get(e) : null;
462
- }
463
- static position(e, r = {}) {
464
- const s = {
465
- ...V,
466
- ...r
454
+ w.length && r.onElementIntersection(n, w);
455
+ }
456
+ /**
457
+ * Returns `true` if the element is currently being positioned by the service
458
+ * and `false` otherwise.
459
+ */
460
+ static isPositioned(n) {
461
+ return r.elements.has(n);
462
+ }
463
+ /**
464
+ * Returns the options currently beinng used for positioning the element,
465
+ * if it is indeed being positioned by the service.
466
+ */
467
+ static getPositioningOptions(n) {
468
+ return r.elements.has(n) ? r.elements.get(n) : null;
469
+ }
470
+ /** PositioningService will start controlling the position of the given element. */
471
+ static position(n, i = {}) {
472
+ const p = {
473
+ ...N,
474
+ ...i
467
475
  };
468
- let f = e;
476
+ let f = n;
469
477
  for (; f !== document.body; )
470
478
  if (f = f.parentElement, f.classList.contains("sps-focused-task")) {
471
- s.scrollParent = f, i.registeredScrollParents.has(f) || (i.registeredScrollParents.add(f), f.addEventListener("scroll", i.update));
479
+ p.scrollParent = f, r.registeredScrollParents.has(f) || (r.registeredScrollParents.add(f), f.addEventListener("scroll", r.update));
472
480
  break;
473
481
  }
474
- if (e.style.visibility = "hidden", i.elements.size === 0 && (window.addEventListener("resize", i.update), window.addEventListener("scroll", i.update)), !s.relativeTo)
482
+ if (n.style.visibility = "hidden", r.elements.size === 0 && (window.addEventListener("resize", r.update), window.addEventListener("scroll", r.update)), !p.relativeTo)
475
483
  throw new Error(
476
484
  "You must provide an element for the relativeTo option to position an element."
477
485
  );
478
- i.elements.set(e, s), U(() => {
479
- i.fixElementPosition(e), i.viewportObserver.observe(e), e.style.visibility = "", i.checkCollisions(e);
486
+ r.elements.set(n, p), H(() => {
487
+ r.fixElementPosition(n), r.viewportObserver.observe(n), n.style.visibility = "", r.checkCollisions(n);
480
488
  });
481
489
  }
482
- static release(e) {
483
- if (i.elements.has(e)) {
484
- i.clearStyles(e);
485
- const r = i.elements.get(e);
486
- r.scrollParent && (r.scrollParent.removeEventListener("scroll", i.update), i.registeredScrollParents.delete(r.scrollParent)), i.elements.delete(e), i.elements.size === 0 && (window.removeEventListener("resize", i.update), window.removeEventListener("scroll", i.update)), i.viewportObserver.unobserve(e);
490
+ /** PositioningService will stop controlling the position of the given element. */
491
+ static release(n) {
492
+ if (r.elements.has(n)) {
493
+ r.clearStyles(n);
494
+ const i = r.elements.get(n);
495
+ i.scrollParent && (i.scrollParent.removeEventListener("scroll", r.update), r.registeredScrollParents.delete(i.scrollParent)), r.elements.delete(n), r.elements.size === 0 && (window.removeEventListener("resize", r.update), window.removeEventListener("scroll", r.update)), r.viewportObserver.unobserve(n);
487
496
  }
488
497
  }
489
498
  static releaseAll() {
490
- for (const e of i.elements.keys())
491
- i.release(e);
499
+ for (const n of r.elements.keys())
500
+ r.release(n);
492
501
  }
493
- static refresh(e) {
494
- i.elements.has(e) && (i.clearStyles(e), i.fixElementPosition(e), i.checkCollisions(e));
502
+ /** PositioningService will refresh the positioning of the given element */
503
+ static refresh(n) {
504
+ r.elements.has(n) && (r.clearStyles(n), r.fixElementPosition(n), r.checkCollisions(n));
495
505
  }
496
506
  static refreshAll() {
497
- for (const e of i.elements.keys())
498
- i.refresh(e);
499
- }
500
- static reposition(e, r) {
501
- if (i.elements.has(e)) {
502
- const s = i.elements.get(e);
503
- i.elements.set(e, Object.assign(s, r)), i.refresh(e);
507
+ for (const n of r.elements.keys())
508
+ r.refresh(n);
509
+ }
510
+ /** Update the positioning options of a currently positioned element */
511
+ static reposition(n, i) {
512
+ if (r.elements.has(n)) {
513
+ const p = r.elements.get(n);
514
+ r.elements.set(n, Object.assign(p, i)), r.refresh(n);
504
515
  }
505
516
  }
506
- static onViewportIntersection(e) {
507
- for (const r of e) {
508
- const s = Object.keys(IntersectionObserverEntry.prototype).reduce(
509
- (f, g) => ({
517
+ static onViewportIntersection(n) {
518
+ for (const i of n) {
519
+ const p = Object.keys(IntersectionObserverEntry.prototype).reduce(
520
+ (f, w) => ({
510
521
  ...f,
511
- [g]: r[g]
522
+ [w]: i[w]
512
523
  }),
513
524
  {}
514
525
  );
515
- s.rootBounds = s.rootBounds || i.getRootBounds(), i.events.emit("viewportIntersection", Object.freeze(s));
526
+ p.rootBounds = p.rootBounds || r.getRootBounds(), r.events.emit("viewportIntersection", Object.freeze(p));
516
527
  }
517
528
  }
518
- static onElementIntersection(e, r) {
519
- i.events.emit("elementIntersection", { target: e, intersectingWith: r });
529
+ static onElementIntersection(n, i) {
530
+ r.events.emit("elementIntersection", { target: n, intersectingWith: i });
520
531
  }
521
532
  static getRootBounds() {
522
- const e = Math.max(document.documentElement.clientWidth, window.innerWidth || 0), r = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
533
+ const n = Math.max(document.documentElement.clientWidth, window.innerWidth || 0), i = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
523
534
  return {
524
535
  x: 0,
525
- y: B,
536
+ y: k,
526
537
  left: 0,
527
- top: B,
528
- right: e,
529
- bottom: r,
530
- height: r - B,
531
- width: e
538
+ top: k,
539
+ right: n,
540
+ bottom: i,
541
+ height: i - k,
542
+ width: n
532
543
  };
533
544
  }
534
- static clearStyles(e) {
535
- Object.assign(e.style, {
545
+ static clearStyles(n) {
546
+ Object.assign(n.style, {
536
547
  position: "",
537
548
  width: "",
538
549
  top: "",
@@ -543,140 +554,141 @@ const i = (M = class {
543
554
  zIndex: ""
544
555
  });
545
556
  }
546
- static fixElementPosition(e, r) {
547
- if (!this.elements.has(e))
557
+ static fixElementPosition(n, i) {
558
+ if (!this.elements.has(n))
548
559
  return;
549
- const s = r || this.elements.get(e), f = this.getRootBounds(), g = e.getBoundingClientRect(), b = s.relativeTo.getBoundingClientRect(), { width: l } = s.useRelativeTargetWidth ? b : g;
550
- Object.assign(e.style, {
551
- minWidth: `${l}px`,
560
+ const p = i || this.elements.get(n), f = this.getRootBounds(), w = n.getBoundingClientRect(), a = p.relativeTo.getBoundingClientRect(), { width: m } = p.useRelativeTargetWidth ? a : w;
561
+ Object.assign(n.style, {
562
+ minWidth: `${m}px`,
552
563
  position: "fixed",
553
- zIndex: s.zIndex || ""
564
+ zIndex: p.zIndex || ""
554
565
  });
555
- let _, d;
556
- const u = s.position.split(" "), p = s.offsets[0] || 0, v = s.offsets[1] || 0;
557
- switch (_ = 0, d = 0, u[0]) {
566
+ let d, c;
567
+ const u = p.position.split(" "), v = p.offsets[0] || 0, T = p.offsets[1] || 0;
568
+ switch (d = 0, c = 0, u[0]) {
558
569
  case "top":
559
- _ = b.top - g.height - p;
570
+ d = a.top - w.height - v;
560
571
  break;
561
572
  case "left":
562
- d = b.left - l - p;
573
+ c = a.left - m - v;
563
574
  break;
564
575
  case "right":
565
- d = b.right + p;
576
+ c = a.right + v;
566
577
  break;
567
578
  case "bottom":
568
- _ = b.bottom + p;
579
+ d = a.bottom + v;
569
580
  break;
570
581
  default:
571
- throw new Error(`${s.position} is not a valid position`);
582
+ throw new Error(`${p.position} is not a valid position`);
572
583
  }
573
584
  switch (u[1]) {
574
585
  case "left":
575
- d = b.left - v;
586
+ c = a.left - T;
576
587
  break;
577
588
  case "top":
578
- _ = b.top - v;
589
+ d = a.top - T;
579
590
  break;
580
591
  case "middle":
581
- u[0] === "top" || u[0] === "bottom" ? d = b.left + b.width / 2 - l / 2 + v : (u[0] === "left" || u[0] === "right") && (_ = b.top + b.height / 2 - g.height / 2 + v);
592
+ u[0] === "top" || u[0] === "bottom" ? c = a.left + a.width / 2 - m / 2 + T : (u[0] === "left" || u[0] === "right") && (d = a.top + a.height / 2 - w.height / 2 + T);
582
593
  break;
583
594
  case "bottom":
584
- _ = b.bottom - g.height + v;
595
+ d = a.bottom - w.height + T;
585
596
  break;
586
597
  case "right":
587
- d = b.right - l + v;
598
+ c = a.right - m + T;
588
599
  break;
589
600
  default:
590
- throw new Error(`${s.position} is not a valid position`);
601
+ throw new Error(`${p.position} is not a valid position`);
591
602
  }
592
- const T = _ + g.height, w = d + g.width, m = `${Math.round(_)}px`, x = `${Math.round(f.bottom - T)}px`, h = `${Math.round(d)}px`, I = `${Math.round(f.right - w)}px`;
593
- switch (s.anchor) {
594
- case P.TOP_LEFT:
595
- Object.assign(e.style, {
596
- top: m,
603
+ const y = d + w.height, b = c + w.width, x = `${Math.round(d)}px`, h = `${Math.round(f.bottom - y)}px`, _ = `${Math.round(c)}px`, R = `${Math.round(f.right - b)}px`;
604
+ switch (p.anchor) {
605
+ case M.TOP_LEFT:
606
+ Object.assign(n.style, {
607
+ top: x,
597
608
  bottom: "auto",
598
- left: h,
609
+ left: _,
599
610
  right: "auto"
600
611
  });
601
612
  break;
602
- case P.TOP_RIGHT:
603
- Object.assign(e.style, {
604
- top: m,
613
+ case M.TOP_RIGHT:
614
+ Object.assign(n.style, {
615
+ top: x,
605
616
  bottom: "auto",
606
617
  left: "auto",
607
- right: I
618
+ right: R
608
619
  });
609
620
  break;
610
- case P.BOTTOM_LEFT:
611
- Object.assign(e.style, {
621
+ case M.BOTTOM_LEFT:
622
+ Object.assign(n.style, {
612
623
  top: "auto",
613
- bottom: x,
614
- left: h,
624
+ bottom: h,
625
+ left: _,
615
626
  right: "auto"
616
627
  });
617
628
  break;
618
- case P.BOTTOM_RIGHT:
619
- Object.assign(e.style, {
629
+ case M.BOTTOM_RIGHT:
630
+ Object.assign(n.style, {
620
631
  top: "auto",
621
- bottom: x,
632
+ bottom: h,
622
633
  left: "auto",
623
- right: I
634
+ right: R
624
635
  });
625
636
  break;
626
637
  }
627
638
  }
628
- static update(e) {
629
- const r = i.elements.entries(), s = [];
630
- for (const [f, g] of r)
631
- (!e || e.target === document || e.target === g.scrollParent || e.target === window) && (i.fixElementPosition(f, g), i.checkCollisions(f, s), s.push(f));
639
+ static update(n) {
640
+ const i = r.elements.entries(), p = [];
641
+ for (const [f, w] of i)
642
+ (!n || n.target === document || n.target === w.scrollParent || n.target === window) && (r.fixElementPosition(f, w), r.checkCollisions(f, p), p.push(f));
632
643
  }
633
- on(e, r) {
634
- i.on(e, r);
644
+ /* eslint class-methods-use-this: "off" */
645
+ on(n, i) {
646
+ r.on(n, i);
635
647
  }
636
- off(e, r) {
637
- i.off(e, r);
648
+ off(n, i) {
649
+ r.off(n, i);
638
650
  }
639
- once(e, r) {
640
- i.once(e, r);
651
+ once(n, i) {
652
+ r.once(n, i);
641
653
  }
642
- isPositioned(e) {
643
- return i.isPositioned(e);
654
+ isPositioned(n) {
655
+ return r.isPositioned(n);
644
656
  }
645
- getPositioningOptions(e) {
646
- return i.getPositioningOptions(e);
657
+ getPositioningOptions(n) {
658
+ return r.getPositioningOptions(n);
647
659
  }
648
- position(e, r = {}) {
649
- i.position(e, r);
660
+ position(n, i = {}) {
661
+ r.position(n, i);
650
662
  }
651
- release(e) {
652
- i.release(e);
663
+ release(n) {
664
+ r.release(n);
653
665
  }
654
666
  releaseAll() {
655
- i.releaseAll();
667
+ r.releaseAll();
656
668
  }
657
- refresh(e) {
658
- i.refresh(e);
669
+ refresh(n) {
670
+ r.refresh(n);
659
671
  }
660
672
  refreshAll() {
661
- i.refreshAll();
673
+ r.refreshAll();
662
674
  }
663
- reposition(e, r) {
664
- i.reposition(e, r);
675
+ reposition(n, i) {
676
+ r.reposition(n, i);
665
677
  }
666
- }, k(M, "elements", /* @__PURE__ */ new Map()), k(M, "registeredScrollParents", /* @__PURE__ */ new Set()), k(M, "events", new S.exports.EventEmitter()), k(M, "viewportObserver", new IntersectionObserver(
667
- i.onViewportIntersection,
678
+ }, r.elements = /* @__PURE__ */ new Map(), r.registeredScrollParents = /* @__PURE__ */ new Set(), r.events = new U.EventEmitter(), r.viewportObserver = new IntersectionObserver(
679
+ r.onViewportIntersection,
668
680
  {
669
- rootMargin: `-${B}px 0px 0px`,
681
+ rootMargin: `-${k}px 0px 0px`,
670
682
  threshold: 1
671
683
  }
672
- )), M);
673
- let $ = i;
674
- W([
675
- j
676
- ], $, "update", 1);
684
+ ), r);
685
+ G([
686
+ S
687
+ ], F, "update");
688
+ let W = F;
677
689
  export {
678
- V as DEFAULT_POSITIONING_OPTIONS,
679
- F as Position,
680
- P as PositionAnchor,
681
- $ as PositioningService
690
+ N as DEFAULT_POSITIONING_OPTIONS,
691
+ C as Position,
692
+ M as PositionAnchor,
693
+ W as PositioningService
682
694
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@spscommerce/positioning",
3
3
  "description": "Service for positioning dropdown/popup elements.",
4
- "version": "8.7.4",
4
+ "version": "8.7.5",
5
5
  "author": "SPS Commerce",
6
6
  "license": "UNLICENSED",
7
7
  "repository": "https://github.com/spscommerce/woodland/tree/main/packages/@spscommerce/positioning",
File without changes