@esri/calcite-components
Version:
Web Components for Esri's Calcite Design System.
6 lines • 19.8 kB
JavaScript
/*!
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
* v1.5.0-next.4
*/
import{b as t}from"./p-68f223ec.js";import{g as n,a as e}from"./p-7fb6664e.js";import{d as o}from"./p-81620376.js";function r(t){return t.split("-")[1]}function i(t){return"y"===t?"height":"width"}function a(t){return t.split("-")[0]}function l(t){return["top","bottom"].includes(a(t))?"x":"y"}function s(t,n,e){let{reference:o,floating:s}=t;const c=o.x+o.width/2-s.width/2,f=o.y+o.height/2-s.height/2,u=l(n),d=i(u),m=o[d]/2-s[d]/2,p="x"===u;let y;switch(a(n)){case"top":y={x:c,y:o.y-s.height};break;case"bottom":y={x:c,y:o.y+o.height};break;case"right":y={x:o.x+o.width,y:f};break;case"left":y={x:o.x-s.width,y:f};break;default:y={x:o.x,y:o.y}}switch(r(n)){case"start":y[u]-=m*(e&&p?-1:1);break;case"end":y[u]+=m*(e&&p?-1:1)}return y}function c(t,n){return"function"==typeof t?t(n):t}function f(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function u(t){return{...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}async function d(t,n){var e;void 0===n&&(n={});const{x:o,y:r,platform:i,rects:a,elements:l,strategy:s}=t,{boundary:d="clippingAncestors",rootBoundary:m="viewport",elementContext:p="floating",altBoundary:y=!1,padding:g=0}=c(n,t),h=f(g),x=l[y?"floating"===p?"reference":"floating":p],w=u(await i.getClippingRect({element:null==(e=await(null==i.isElement?void 0:i.isElement(x)))||e?x:x.contextElement||await(null==i.getDocumentElement?void 0:i.getDocumentElement(l.floating)),boundary:d,rootBoundary:m,strategy:s})),v="floating"===p?{...a.floating,x:o,y:r}:a.reference,b=await(null==i.getOffsetParent?void 0:i.getOffsetParent(l.floating)),A=await(null==i.isElement?void 0:i.isElement(b))&&await(null==i.getScale?void 0:i.getScale(b))||{x:1,y:1},P=u(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({rect:v,offsetParent:b,strategy:s}):v);return{top:(w.top-P.top+h.top)/A.y,bottom:(P.bottom-w.bottom+h.bottom)/A.y,left:(w.left-P.left+h.left)/A.x,right:(P.right-w.right+h.right)/A.x}}const m=Math.min,p=Math.max;function y(t,n,e){return p(t,m(n,e))}const g=["top","right","bottom","left"],h=g.reduce(((t,n)=>t.concat(n,n+"-start",n+"-end")),[]),x={left:"right",right:"left",bottom:"top",top:"bottom"};function w(t){return t.replace(/left|right|bottom|top/g,(t=>x[t]))}function v(t,n,e){void 0===e&&(e=!1);const o=r(t),a=l(t),s=i(a);let c="x"===a?o===(e?"end":"start")?"right":"left":"start"===o?"bottom":"top";return n.reference[s]>n.floating[s]&&(c=w(c)),{main:c,cross:w(c)}}const b={start:"end",end:"start"};function A(t){return t.replace(/start|end/g,(t=>b[t]))}const P=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(n){var e;const{placement:o,middlewareData:i,rects:l,initialPlacement:s,platform:f,elements:u}=n,{mainAxis:m=!0,crossAxis:p=!0,fallbackPlacements:y,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:h="none",flipAlignment:x=!0,...b}=c(t,n),P=a(o),k=a(s)===s,S=await(null==f.isRTL?void 0:f.isRTL(u.floating)),D=y||(k||!x?[w(s)]:function(t){const n=w(t);return[A(t),n,A(n)]}(s));y||"none"===h||D.push(...function(t,n,e,o){const i=r(t);let l=function(t,n,e){const o=["left","right"],r=["right","left"],i=["top","bottom"],a=["bottom","top"];switch(t){case"top":case"bottom":return e?n?r:o:n?o:r;case"left":case"right":return n?i:a;default:return[]}}(a(t),"start"===e,o);return i&&(l=l.map((t=>t+"-"+i)),n&&(l=l.concat(l.map(A)))),l}(s,x,h,S));const M=[s,...D],R=await d(n,b),C=[];let F=(null==(e=i.flip)?void 0:e.overflows)||[];if(m&&C.push(R[P]),p){const{main:t,cross:n}=v(o,l,S);C.push(R[t],R[n])}if(F=[...F,{placement:o,overflows:C}],!C.every((t=>t<=0))){var O,E;const t=((null==(O=i.flip)?void 0:O.index)||0)+1,n=M[t];if(n)return{data:{index:t,overflows:F},reset:{placement:n}};let e=null==(E=F.filter((t=>t.overflows[0]<=0)).sort(((t,n)=>t.overflows[1]-n.overflows[1]))[0])?void 0:E.placement;if(!e)switch(g){case"bestFit":{var T;const t=null==(T=F.map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,n)=>t+n),0)])).sort(((t,n)=>t[1]-n[1]))[0])?void 0:T[0];t&&(e=t);break}case"initialPlacement":e=s}if(o!==e)return{reset:{placement:e}}}return{}}}};function k(t,n){return{top:t.top-n.height,right:t.right-n.width,bottom:t.bottom-n.height,left:t.left-n.width}}function S(t){return g.some((n=>t[n]>=0))}const D=function(t){return void 0===t&&(t={}),{name:"hide",options:t,async fn(n){const{rects:e}=n,{strategy:o="referenceHidden",...r}=c(t,n);switch(o){case"referenceHidden":{const t=k(await d(n,{...r,elementContext:"reference"}),e.reference);return{data:{referenceHiddenOffsets:t,referenceHidden:S(t)}}}case"escaped":{const t=k(await d(n,{...r,altBoundary:!0}),e.floating);return{data:{escapedOffsets:t,escaped:S(t)}}}default:return{}}}}},M=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(n){const{x:e,y:o}=n,i=await async function(t,n){const{placement:e,platform:o,elements:i}=t,s=await(null==o.isRTL?void 0:o.isRTL(i.floating)),f=a(e),u=r(e),d="x"===l(e),m=["left","top"].includes(f)?-1:1,p=s&&d?-1:1,y=c(n,t);let{mainAxis:g,crossAxis:h,alignmentAxis:x}="number"==typeof y?{mainAxis:y,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...y};return u&&"number"==typeof x&&(h="end"===u?-1*x:x),d?{x:h*p,y:g*m}:{x:g*m,y:h*p}}(n,t);return{x:e+i.x,y:o+i.y,data:i}}}};function R(t){var n;return(null==(n=t.ownerDocument)?void 0:n.defaultView)||window}function C(t){return R(t).getComputedStyle(t)}function F(t){return t instanceof R(t).Node}function O(t){return F(t)?(t.nodeName||"").toLowerCase():"#document"}function E(t){return t instanceof R(t).HTMLElement}function T(t){return t instanceof R(t).Element}function j(t){return"undefined"!=typeof ShadowRoot&&(t instanceof R(t).ShadowRoot||t instanceof ShadowRoot)}function $(t){const{overflow:n,overflowX:e,overflowY:o,display:r}=C(t);return/auto|scroll|overlay|hidden|clip/.test(n+o+e)&&!["inline","contents"].includes(r)}function z(t){return["table","td","th"].includes(O(t))}function B(t){const n=L(),e=C(t);return"none"!==e.transform||"none"!==e.perspective||!n&&!!e.backdropFilter&&"none"!==e.backdropFilter||!n&&!!e.filter&&"none"!==e.filter||["transform","perspective","filter"].some((t=>(e.willChange||"").includes(t)))||["paint","layout","strict","content"].some((t=>(e.contain||"").includes(t)))}function L(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function H(t){return["html","body","#document"].includes(O(t))}const I=Math.min,N=Math.max,W=Math.round,q=Math.floor,G=t=>({x:t,y:t});function U(t){const n=C(t);let e=parseFloat(n.width)||0,o=parseFloat(n.height)||0;const r=E(t),i=r?t.offsetWidth:e,a=r?t.offsetHeight:o,l=W(e)!==i||W(o)!==a;return l&&(e=i,o=a),{width:e,height:o,$:l}}function V(t){return T(t)?t:t.contextElement}function X(t){const n=V(t);if(!E(n))return G(1);const e=n.getBoundingClientRect(),{width:o,height:r,$:i}=U(n);let a=(i?W(e.width):e.width)/o,l=(i?W(e.height):e.height)/r;return a&&Number.isFinite(a)||(a=1),l&&Number.isFinite(l)||(l=1),{x:a,y:l}}const Y=G(0);function _(t,n,e){var o,r;if(void 0===n&&(n=!0),!L())return Y;const i=t?R(t):window;return!e||n&&e!==i?Y:{x:(null==(o=i.visualViewport)?void 0:o.offsetLeft)||0,y:(null==(r=i.visualViewport)?void 0:r.offsetTop)||0}}function J(t,n,e,o){void 0===n&&(n=!1),void 0===e&&(e=!1);const r=t.getBoundingClientRect(),i=V(t);let a=G(1);n&&(o?T(o)&&(a=X(o)):a=X(t));const l=_(i,e,o);let s=(r.left+l.x)/a.x,c=(r.top+l.y)/a.y,f=r.width/a.x,d=r.height/a.y;if(i){const t=R(i),n=o&&T(o)?R(o):o;let e=t.frameElement;for(;e&&o&&n!==t;){const t=X(e),n=e.getBoundingClientRect(),o=getComputedStyle(e),r=n.left+(e.clientLeft+parseFloat(o.paddingLeft))*t.x,i=n.top+(e.clientTop+parseFloat(o.paddingTop))*t.y;s*=t.x,c*=t.y,f*=t.x,d*=t.y,s+=r,c+=i,e=R(e).frameElement}}return u({width:f,height:d,x:s,y:c})}function K(t){return((F(t)?t.ownerDocument:t.document)||window.document).documentElement}function Q(t){return T(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function Z(t){return J(K(t)).left+Q(t).scrollLeft}function tt(t){if("html"===O(t))return t;const n=t.assignedSlot||t.parentNode||j(t)&&t.host||K(t);return j(n)?n.host:n}function nt(t){const n=tt(t);return H(n)?t.ownerDocument?t.ownerDocument.body:t.body:E(n)&&$(n)?n:nt(n)}function et(t,n){var e;void 0===n&&(n=[]);const o=nt(t),r=o===(null==(e=t.ownerDocument)?void 0:e.body),i=R(o);return r?n.concat(i,i.visualViewport||[],$(o)?o:[]):n.concat(o,et(o))}function ot(t,n,e){let o;if("viewport"===n)o=function(t,n){const e=R(t),o=K(t),r=e.visualViewport;let i=o.clientWidth,a=o.clientHeight,l=0,s=0;if(r){i=r.width,a=r.height;const t=L();(!t||t&&"fixed"===n)&&(l=r.offsetLeft,s=r.offsetTop)}return{width:i,height:a,x:l,y:s}}(t,e);else if("document"===n)o=function(t){const n=K(t),e=Q(t),o=t.ownerDocument.body,r=N(n.scrollWidth,n.clientWidth,o.scrollWidth,o.clientWidth),i=N(n.scrollHeight,n.clientHeight,o.scrollHeight,o.clientHeight);let a=-e.scrollLeft+Z(t);const l=-e.scrollTop;return"rtl"===C(o).direction&&(a+=N(n.clientWidth,o.clientWidth)-r),{width:r,height:i,x:a,y:l}}(K(t));else if(T(n))o=function(t,n){const e=J(t,!0,"fixed"===n),o=e.top+t.clientTop,r=e.left+t.clientLeft,i=E(t)?X(t):G(1);return{width:t.clientWidth*i.x,height:t.clientHeight*i.y,x:r*i.x,y:o*i.y}}(n,e);else{const e=_(t);o={...n,x:n.x-e.x,y:n.y-e.y}}return u(o)}function rt(t,n){const e=tt(t);return!(e===n||!T(e)||H(e))&&("fixed"===C(e).position||rt(e,n))}function it(t,n){return E(t)&&"fixed"!==C(t).position?n?n(t):t.offsetParent:null}function at(t,n){const e=R(t);if(!E(t))return e;let o=it(t,n);for(;o&&z(o)&&"static"===C(o).position;)o=it(o,n);return o&&("html"===O(o)||"body"===O(o)&&"static"===C(o).position&&!B(o))?e:o||function(t){let n=tt(t);for(;E(n)&&!H(n);){if(B(n))return n;n=tt(n)}return null}(t)||e}function lt(t,n,e){const o=E(n),r=K(n),i="fixed"===e,a=J(t,!0,i,n);let l={scrollLeft:0,scrollTop:0};const s=G(0);if(o||!o&&!i)if(("body"!==O(n)||$(r))&&(l=Q(n)),E(n)){const t=J(n,!0,i,n);s.x=t.x+n.clientLeft,s.y=t.y+n.clientTop}else r&&(s.x=Z(r));return{x:a.left+l.scrollLeft-s.x,y:a.top+l.scrollTop-s.y,width:a.width,height:a.height}}const st={getClippingRect:function(t){let{element:n,boundary:e,rootBoundary:o,strategy:r}=t;const i=[..."clippingAncestors"===e?function(t,n){const e=n.get(t);if(e)return e;let o=et(t).filter((t=>T(t)&&"body"!==O(t))),r=null;const i="fixed"===C(t).position;let a=i?tt(t):t;for(;T(a)&&!H(a);){const n=C(a),e=B(a);e||"fixed"!==n.position||(r=null),(i?!e&&!r:!e&&"static"===n.position&&r&&["absolute","fixed"].includes(r.position)||$(a)&&!e&&rt(t,a))?o=o.filter((t=>t!==a)):r=n,a=tt(a)}return n.set(t,o),o}(n,this._c):[].concat(e),o],a=i.reduce(((t,e)=>{const o=ot(n,e,r);return t.top=N(o.top,t.top),t.right=I(o.right,t.right),t.bottom=I(o.bottom,t.bottom),t.left=N(o.left,t.left),t}),ot(n,i[0],r));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:n,offsetParent:e,strategy:o}=t;const r=E(e),i=K(e);if(e===i)return n;let a={scrollLeft:0,scrollTop:0},l=G(1);const s=G(0);if((r||!r&&"fixed"!==o)&&(("body"!==O(e)||$(i))&&(a=Q(e)),E(e))){const t=J(e);l=X(e),s.x=t.x+e.clientLeft,s.y=t.y+e.clientTop}return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-a.scrollLeft*l.x+s.x,y:n.y*l.y-a.scrollTop*l.y+s.y}},isElement:T,getDimensions:function(t){return U(t)},getOffsetParent:at,getDocumentElement:K,getScale:X,async getElementRects(t){let{reference:n,floating:e,strategy:o}=t;const r=this.getOffsetParent||at,i=this.getDimensions;return{reference:lt(n,await r(e),o),floating:{x:0,y:0,...await i(e)}}},getClientRects:t=>Array.from(t.getClientRects()),isRTL:t=>"rtl"===C(t).direction};const ct={floatingUINonChromiumPositioningFix:!0,...globalThis.calciteComponentsConfig},ft=async function(){if(ct.floatingUINonChromiumPositioningFix&&(/firefox|safari/i.test(n())||function(){const t=e();return t?.brands?!!t.brands.find((({brand:t,version:n})=>("Google Chrome"===t||"Chromium"===t)&&Number(n)>=109)):!!navigator.userAgent.split(" ").find((t=>{const[n,e]=t.split("/");return"Chrome"===n&&parseInt(e)>=109}))}())){const{offsetParent:t}=await import("./p-0f4544f3.js"),n=st.getOffsetParent;st.getOffsetParent=e=>n(e,t)}}(),ut=async(t,{referenceEl:n,floatingEl:e,overlayPositioning:o="absolute",placement:r,flipDisabled:i,flipPlacements:a,offsetDistance:l,offsetSkidding:c,arrowEl:f,type:u})=>{if(!n||!e)return null;await ft;const{x:d,y:m,placement:p,strategy:y,middlewareData:g}=await((t,n,e)=>{const o=new Map,r={platform:st,...e},i={...r.platform,_c:o};return(async(t,n,e)=>{const{placement:o="bottom",strategy:r="absolute",middleware:i=[],platform:a}=e,l=i.filter(Boolean),c=await(null==a.isRTL?void 0:a.isRTL(n));let f=await a.getElementRects({reference:t,floating:n,strategy:r}),{x:u,y:d}=s(f,o,c),m=o,p={},y=0;for(let e=0;e<l.length;e++){const{name:i,fn:g}=l[e],{x:h,y:x,data:w,reset:v}=await g({x:u,y:d,initialPlacement:o,placement:m,strategy:r,middlewareData:p,rects:f,platform:a,elements:{reference:t,floating:n}});u=null!=h?h:u,d=null!=x?x:d,p={...p,[i]:{...p[i],...w}},v&&y<=50&&(y++,"object"==typeof v&&(v.placement&&(m=v.placement),v.rects&&(f=!0===v.rects?await a.getElementRects({reference:t,floating:n,strategy:r}):v.rects),({x:u,y:d}=s(f,m,c))),e=-1)}return{x:u,y:d,placement:m,strategy:r,middlewareData:p}})(t,n,{...r,platform:i})})(n,e,{strategy:o,placement:"auto"===r||"auto-start"===r||"auto-end"===r?void 0:xt(e,r),middleware:gt({placement:r,flipDisabled:i,flipPlacements:a,offsetDistance:l,offsetSkidding:c,arrowEl:f,type:u})});if(f&&g.arrow){const{x:n,y:e}=g.arrow,o=p.split("-")[0],r=null!=n?"left":"top",i=vt[o],a={left:"",top:"",bottom:"",right:""};"floatingLayout"in t&&(t.floatingLayout="left"===o||"right"===o?"horizontal":"vertical"),Object.assign(f.style,{...a,[r]:`${"left"==r?n:e}px`,[o]:"100%",transform:i})}const h=g.hide?.referenceHidden,x=h?"hidden":null,w=x?"none":null;e.setAttribute(dt,p);const v=`translate(${Math.round(d)}px,${Math.round(m)}px)`;Object.assign(e.style,{visibility:x,pointerEvents:w,position:y,top:"0",left:"0",transform:v})},dt="data-placement",mt=["top","bottom","right","left","top-start","top-end","bottom-start","bottom-end","right-start","right-end","left-start","left-end"],pt="bottom-start",yt={animation:"calcite-floating-ui-anim",animationActive:"calcite-floating-ui-anim--active"};function gt({placement:t,flipDisabled:n,flipPlacements:e,offsetDistance:o,offsetSkidding:s,arrowEl:u,type:p}){const g=[(void 0===x&&(x={}),{name:"shift",options:x,async fn(t){const{x:n,y:e,placement:o}=t,{mainAxis:r=!0,crossAxis:i=!1,limiter:s={fn:t=>{let{x:n,y:e}=t;return{x:n,y:e}}},...f}=c(x,t),u={x:n,y:e},m=await d(t,f),p=l(a(o)),g="x"===p?"y":"x";let h=u[p],w=u[g];r&&(h=y(h+m["y"===p?"top":"left"],h,h-m["y"===p?"bottom":"right"])),i&&(w=y(w+m["y"===g?"top":"left"],w,w-m["y"===g?"bottom":"right"]));const v=s.fn({...t,[p]:h,[g]:w});return{...v,data:{x:v.x-n,y:v.y-e}}}}),D()];var x;if("menu"===p)return[...g,P({fallbackPlacements:e||["top-start","top","top-end","bottom-start","bottom","bottom-end"]})];if("popover"===p||"tooltip"===p){const p=[...g,M({mainAxis:"number"==typeof o?o:0,crossAxis:"number"==typeof s?s:0})];return"auto"===t||"auto-start"===t||"auto-end"===t?p.push(function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(n){var e,o,i;const{rects:l,middlewareData:s,placement:f,platform:u,elements:m}=n,{crossAxis:p=!1,alignment:y,allowedPlacements:g=h,autoAlignment:x=!0,...w}=c(t,n),b=void 0!==y||g===h?function(t,n,e){return(t?[...e.filter((n=>r(n)===t)),...e.filter((n=>r(n)!==t))]:e.filter((t=>a(t)===t))).filter((e=>!t||r(e)===t||!!n&&A(e)!==e))}(y||null,x,g):g,P=await d(n,w),k=(null==(e=s.autoPlacement)?void 0:e.index)||0,S=b[k];if(null==S)return{};const{main:D,cross:M}=v(S,l,await(null==u.isRTL?void 0:u.isRTL(m.floating)));if(f!==S)return{reset:{placement:b[0]}};const R=[P[a(S)],P[D],P[M]],C=[...(null==(o=s.autoPlacement)?void 0:o.overflows)||[],{placement:S,overflows:R}],F=b[k+1];if(F)return{data:{index:k+1,overflows:C},reset:{placement:F}};const O=C.map((t=>{const n=r(t.placement);return[t.placement,n&&p?t.overflows.slice(0,2).reduce(((t,n)=>t+n),0):t.overflows[0],t.overflows]})).sort(((t,n)=>t[1]-n[1])),E=(null==(i=O.filter((t=>t[2].slice(0,r(t[0])?2:3).every((t=>t<=0))))[0])?void 0:i[0])||O[0][0];return E!==f?{data:{index:k+1,overflows:C},reset:{placement:E}}:{}}}}({alignment:"auto-start"===t?"start":"auto-end"===t?"end":null})):n||p.push(P(e?{fallbackPlacements:e}:{})),u&&p.push((t=>({name:"arrow",options:t,async fn(n){const{x:e,y:o,placement:a,rects:s,platform:u,elements:d}=n,{element:p,padding:g=0}=c(t,n)||{};if(null==p)return{};const h=f(g),x={x:e,y:o},w=l(a),v=i(w),b=await u.getDimensions(p),A="y"===w,P=A?"top":"left",k=A?"bottom":"right",S=A?"clientHeight":"clientWidth",D=s.reference[v]+s.reference[w]-x[w]-s.floating[v],M=x[w]-s.reference[w],R=await(null==u.getOffsetParent?void 0:u.getOffsetParent(p));let C=R?R[S]:0;C&&await(null==u.isElement?void 0:u.isElement(R))||(C=d.floating[S]||s.floating[v]);const F=D/2-M/2,O=C/2-b[v]/2-1,E=m(h[P],O),T=m(h[k],O),j=E,$=C-b[v]-T,z=C/2-b[v]/2+F,B=y(j,z,$),L=null!=r(a)&&z!=B&&s.reference[v]/2-(z<j?E:T)-b[v]/2<0?z<j?j-z:$-z:0;return{[w]:x[w]-L,data:{[w]:B,centerOffset:z-B+L}}}}))({element:u})),p}return[]}function ht(t,n){const e=t.filter((t=>mt.includes(t)));return e.length!==t.length&&console.warn(`${n.tagName}: Invalid value found in: flipPlacements. Try any of these: ${mt.map((t=>`"${t}"`)).join(", ").trim()}`,{el:n}),e}function xt(n,e){const o=["left","right"];return"rtl"===t(n)&&o.reverse(),e.replace(/leading/gi,o[0]).replace(/trailing/gi,o[1])}async function wt(t,n,e=!1){if(!t.open)return;const r=e?function(t){let n=At.get(t);return n||(n=o(ut,100,{leading:!0,maxWait:100}),At.set(t,n),n)}(t):ut;return r(t,n)}const vt={top:"",left:"rotate(-90deg)",bottom:"rotate(180deg)",right:"rotate(90deg)"},bt=new WeakMap,At=new WeakMap;function Pt(t,n,e){e&&n&&(kt(t,n,e),Object.assign(e.style,{visibility:"hidden",pointerEvents:"none",position:t.overlayPositioning,top:"0",left:"0"}),bt.set(t,function(t,n,e,o){void 0===o&&(o={});const{ancestorScroll:r=!0,ancestorResize:i=!0,elementResize:a=!0,layoutShift:l="function"==typeof IntersectionObserver,animationFrame:s=!1}=o,c=V(t),f=r||i?[...c?et(c):[],...et(n)]:[];f.forEach((t=>{r&&t.addEventListener("scroll",e,{passive:!0}),i&&t.addEventListener("resize",e)}));const u=c&&l?function(t,n){let e,o=null;const r=K(t);function i(){clearTimeout(e),o&&o.disconnect(),o=null}return function a(l,s){void 0===l&&(l=!1),void 0===s&&(s=1),i();const{left:c,top:f,width:u,height:d}=t.getBoundingClientRect();if(l||n(),!u||!d)return;const m=q(f),p=q(r.clientWidth-(c+u)),y=q(r.clientHeight-(f+d)),g=q(c);let h=!0;o=new IntersectionObserver((t=>{const n=t[0].intersectionRatio;if(n!==s){if(!h)return a();0===n?e=setTimeout((()=>{a(!1,1e-7)}),100):a(!1,n)}h=!1}),{rootMargin:-m+"px "+-p+"px "+-y+"px "+-g+"px",threshold:s}),o.observe(t)}(!0),i}(c,e):null;let d,m=null;a&&(m=new ResizeObserver(e),c&&!s&&m.observe(c),m.observe(n));let p=s?J(t):null;return s&&function n(){const o=J(t);!p||o.x===p.x&&o.y===p.y&&o.width===p.width&&o.height===p.height||e(),p=o,d=requestAnimationFrame(n)}(),e(),()=>{f.forEach((t=>{r&&t.removeEventListener("scroll",e),i&&t.removeEventListener("resize",e)})),u&&u(),m&&m.disconnect(),m=null,s&&cancelAnimationFrame(d)}}(n,e,(()=>t.reposition()))))}function kt(t,n,e){e&&n&&(bt.get(t)?.(),bt.delete(t),At.get(t)?.cancel(),At.delete(t))}const St=Math.ceil(Math.hypot(4,4));export{yt as F,kt as a,St as b,Pt as c,pt as d,ht as f,wt as r}