@esri/calcite-components
Version:
Web Components for Esri's Calcite Design System.
5 lines (4 loc) • 22.5 kB
JavaScript
/*! All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://github.com/Esri/calcite-design-system/blob/dev/LICENSE.md for details.
v3.2.1 */
import{a as Ft}from"./OQOKN4KP.js";import{e as Dt}from"./3ADX47DD.js";import{L as vt}from"./BJZTU5BQ.js";var bt=["top","right","bottom","left"],Mt=["start","end"],At=bt.reduce((t,e)=>t.concat(e,e+"-"+Mt[0],e+"-"+Mt[1]),[]),j=Math.min,V=Math.max,ct=Math.round,lt=Math.floor,D=t=>({x:t,y:t}),be={left:"right",right:"left",bottom:"top",top:"bottom"},Ae={start:"end",end:"start"};function dt(t,e,n){return V(t,j(e,n))}function Y(t,e){return typeof t=="function"?t(e):t}function W(t){return t.split("-")[0]}function F(t){return t.split("-")[1]}function Ot(t){return t==="x"?"y":"x"}function mt(t){return t==="y"?"height":"width"}function X(t){return["top","bottom"].includes(W(t))?"y":"x"}function gt(t){return Ot(X(t))}function Rt(t,e,n){n===void 0&&(n=!1);let o=F(t),i=gt(t),r=mt(i),s=i==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(s=rt(s)),[s,rt(s)]}function kt(t){let e=rt(t);return[st(t),e,st(e)]}function st(t){return t.replace(/start|end/g,e=>Ae[e])}function Oe(t,e,n){let o=["left","right"],i=["right","left"],r=["top","bottom"],s=["bottom","top"];switch(t){case"top":case"bottom":return n?e?i:o:e?o:i;case"left":case"right":return e?r:s;default:return[]}}function Nt(t,e,n,o){let i=F(t),r=Oe(W(t),n==="start",o);return i&&(r=r.map(s=>s+"-"+i),e&&(r=r.concat(r.map(st)))),r}function rt(t){return t.replace(/left|right|bottom|top/g,e=>be[e])}function Re(t){return{top:0,right:0,bottom:0,left:0,...t}}function Pt(t){return typeof t!="number"?Re(t):{top:t,right:t,bottom:t,left:t}}function G(t){let{x:e,y:n,width:o,height:i}=t;return{width:o,height:i,top:n,left:e,right:e+o,bottom:n+i,x:e,y:n}}function Bt(t,e,n){let{reference:o,floating:i}=t,r=X(e),s=gt(e),c=mt(s),l=W(e),a=r==="y",d=o.x+o.width/2-i.width/2,u=o.y+o.height/2-i.height/2,m=o[c]/2-i[c]/2,f;switch(l){case"top":f={x:d,y:o.y-i.height};break;case"bottom":f={x:d,y:o.y+o.height};break;case"right":f={x:o.x+o.width,y:u};break;case"left":f={x:o.x-i.width,y:u};break;default:f={x:o.x,y:o.y}}switch(F(e)){case"start":f[s]-=m*(n&&a?-1:1);break;case"end":f[s]+=m*(n&&a?-1:1);break}return f}var Ht=async(t,e,n)=>{let{placement:o="bottom",strategy:i="absolute",middleware:r=[],platform:s}=n,c=r.filter(Boolean),l=await(s.isRTL==null?void 0:s.isRTL(e)),a=await s.getElementRects({reference:t,floating:e,strategy:i}),{x:d,y:u}=Bt(a,o,l),m=o,f={},g=0;for(let h=0;h<c.length;h++){let{name:p,fn:w}=c[h],{x,y,data:b,reset:v}=await w({x:d,y:u,initialPlacement:o,placement:m,strategy:i,middlewareData:f,rects:a,platform:s,elements:{reference:t,floating:e}});d=x??d,u=y??u,f={...f,[p]:{...f[p],...b}},v&&g<=50&&(g++,typeof v=="object"&&(v.placement&&(m=v.placement),v.rects&&(a=v.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:i}):v.rects),{x:d,y:u}=Bt(a,m,l)),h=-1)}return{x:d,y:u,placement:m,strategy:i,middlewareData:f}};async function tt(t,e){var n;e===void 0&&(e={});let{x:o,y:i,platform:r,rects:s,elements:c,strategy:l}=t,{boundary:a="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:m=!1,padding:f=0}=Y(e,t),g=Pt(f),p=c[m?u==="floating"?"reference":"floating":u],w=G(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(p)))==null||n?p:p.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(c.floating)),boundary:a,rootBoundary:d,strategy:l})),x=u==="floating"?{x:o,y:i,width:s.floating.width,height:s.floating.height}:s.reference,y=await(r.getOffsetParent==null?void 0:r.getOffsetParent(c.floating)),b=await(r.isElement==null?void 0:r.isElement(y))?await(r.getScale==null?void 0:r.getScale(y))||{x:1,y:1}:{x:1,y:1},v=G(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:x,offsetParent:y,strategy:l}):x);return{top:(w.top-v.top+g.top)/b.y,bottom:(v.bottom-w.bottom+g.bottom)/b.y,left:(w.left-v.left+g.left)/b.x,right:(v.right-w.right+g.right)/b.x}}var Vt=t=>({name:"arrow",options:t,async fn(e){let{x:n,y:o,placement:i,rects:r,platform:s,elements:c,middlewareData:l}=e,{element:a,padding:d=0}=Y(t,e)||{};if(a==null)return{};let u=Pt(d),m={x:n,y:o},f=gt(i),g=mt(f),h=await s.getDimensions(a),p=f==="y",w=p?"top":"left",x=p?"bottom":"right",y=p?"clientHeight":"clientWidth",b=r.reference[g]+r.reference[f]-m[f]-r.floating[g],v=m[f]-r.reference[f],R=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a)),O=R?R[y]:0;(!O||!await(s.isElement==null?void 0:s.isElement(R)))&&(O=c.floating[y]||r.floating[g]);let _=b/2-v/2,C=O/2-h[g]/2-1,A=j(u[w],C),T=j(u[x],C),$=A,q=O-h[g]-T,N=O/2-h[g]/2+_,L=dt($,N,q),K=!l.arrow&&F(i)!=null&&N!==L&&r.reference[g]/2-(N<$?A:T)-h[g]/2<0,H=K?N<$?N-$:N-q:0;return{[f]:m[f]+H,data:{[f]:L,centerOffset:N-L-H,...K&&{alignmentOffset:H}},reset:K}}});function Pe(t,e,n){return(t?[...n.filter(i=>F(i)===t),...n.filter(i=>F(i)!==t)]:n.filter(i=>W(i)===i)).filter(i=>t?F(i)===t||(e?st(i)!==i:!1):!0)}var zt=function(t){return t===void 0&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,o,i;let{rects:r,middlewareData:s,placement:c,platform:l,elements:a}=e,{crossAxis:d=!1,alignment:u,allowedPlacements:m=At,autoAlignment:f=!0,...g}=Y(t,e),h=u!==void 0||m===At?Pe(u||null,f,m):m,p=await tt(e,g),w=((n=s.autoPlacement)==null?void 0:n.index)||0,x=h[w];if(x==null)return{};let y=Rt(x,r,await(l.isRTL==null?void 0:l.isRTL(a.floating)));if(c!==x)return{reset:{placement:h[0]}};let b=[p[W(x)],p[y[0]],p[y[1]]],v=[...((o=s.autoPlacement)==null?void 0:o.overflows)||[],{placement:x,overflows:b}],R=h[w+1];if(R)return{data:{index:w+1,overflows:v},reset:{placement:R}};let O=v.map(A=>{let T=F(A.placement);return[A.placement,T&&d?A.overflows.slice(0,2).reduce(($,q)=>$+q,0):A.overflows[0],A.overflows]}).sort((A,T)=>A[1]-T[1]),C=((i=O.filter(A=>A[2].slice(0,F(A[0])?2:3).every(T=>T<=0))[0])==null?void 0:i[0])||O[0][0];return C!==c?{data:{index:w+1,overflows:v},reset:{placement:C}}:{}}}},_t=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,o;let{placement:i,middlewareData:r,rects:s,initialPlacement:c,platform:l,elements:a}=e,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:h=!0,...p}=Y(t,e);if((n=r.arrow)!=null&&n.alignmentOffset)return{};let w=W(i),x=X(c),y=W(c)===c,b=await(l.isRTL==null?void 0:l.isRTL(a.floating)),v=m||(y||!h?[rt(c)]:kt(c)),R=g!=="none";!m&&R&&v.push(...Nt(c,h,g,b));let O=[c,...v],_=await tt(e,p),C=[],A=((o=r.flip)==null?void 0:o.overflows)||[];if(d&&C.push(_[w]),u){let L=Rt(i,s,b);C.push(_[L[0]],_[L[1]])}if(A=[...A,{placement:i,overflows:C}],!C.every(L=>L<=0)){var T,$;let L=(((T=r.flip)==null?void 0:T.index)||0)+1,K=O[L];if(K){var q;let I=u==="alignment"?x!==X(K):!1,B=((q=A[0])==null?void 0:q.overflows[0])>0;if(!I||B)return{data:{index:L,overflows:A},reset:{placement:K}}}let H=($=A.filter(I=>I.overflows[0]<=0).sort((I,B)=>I.overflows[1]-B.overflows[1])[0])==null?void 0:$.placement;if(!H)switch(f){case"bestFit":{var N;let I=(N=A.filter(B=>{if(R){let U=X(B.placement);return U===x||U==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(U=>U>0).reduce((U,ve)=>U+ve,0)]).sort((B,U)=>B[1]-U[1])[0])==null?void 0:N[0];I&&(H=I);break}case"initialPlacement":H=c;break}if(i!==H)return{reset:{placement:H}}}return{}}}};function Wt(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function $t(t){return bt.some(e=>t[e]>=0)}var It=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){let{rects:n}=e,{strategy:o="referenceHidden",...i}=Y(t,e);switch(o){case"referenceHidden":{let r=await tt(e,{...i,elementContext:"reference"}),s=Wt(r,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:$t(s)}}}case"escaped":{let r=await tt(e,{...i,altBoundary:!0}),s=Wt(r,n.floating);return{data:{escapedOffsets:s,escaped:$t(s)}}}default:return{}}}}};async function Ce(t,e){let{placement:n,platform:o,elements:i}=t,r=await(o.isRTL==null?void 0:o.isRTL(i.floating)),s=W(n),c=F(n),l=X(n)==="y",a=["left","top"].includes(s)?-1:1,d=r&&l?-1:1,u=Y(e,t),{mainAxis:m,crossAxis:f,alignmentAxis:g}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return c&&typeof g=="number"&&(f=c==="end"?g*-1:g),l?{x:f*d,y:m*a}:{x:m*a,y:f*d}}var Ut=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,o;let{x:i,y:r,placement:s,middlewareData:c}=e,l=await Ce(e,t);return s===((n=c.offset)==null?void 0:n.placement)&&(o=c.arrow)!=null&&o.alignmentOffset?{}:{x:i+l.x,y:r+l.y,data:{...l,placement:s}}}}},jt=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:n,y:o,placement:i}=e,{mainAxis:r=!0,crossAxis:s=!1,limiter:c={fn:p=>{let{x:w,y:x}=p;return{x:w,y:x}}},...l}=Y(t,e),a={x:n,y:o},d=await tt(e,l),u=X(W(i)),m=Ot(u),f=a[m],g=a[u];if(r){let p=m==="y"?"top":"left",w=m==="y"?"bottom":"right",x=f+d[p],y=f-d[w];f=dt(x,f,y)}if(s){let p=u==="y"?"top":"left",w=u==="y"?"bottom":"right",x=g+d[p],y=g-d[w];g=dt(x,g,y)}let h=c.fn({...e,[m]:f,[u]:g});return{...h,data:{x:h.x-n,y:h.y-o,enabled:{[m]:r,[u]:s}}}}}};function ht(){return typeof window<"u"}function J(t){return Xt(t)?(t.nodeName||"").toLowerCase():"#document"}function P(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function M(t){var e;return(e=(Xt(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Xt(t){return ht()?t instanceof Node||t instanceof P(t).Node:!1}function S(t){return ht()?t instanceof Element||t instanceof P(t).Element:!1}function k(t){return ht()?t instanceof HTMLElement||t instanceof P(t).HTMLElement:!1}function Yt(t){return!ht()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof P(t).ShadowRoot}function nt(t){let{overflow:e,overflowX:n,overflowY:o,display:i}=E(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(i)}function qt(t){return["table","td","th"].includes(J(t))}function at(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function ot(t){let e=pt(),n=S(t)?E(t):t;return["transform","translate","scale","rotate","perspective"].some(o=>n[o]?n[o]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(o=>(n.willChange||"").includes(o))||["paint","layout","strict","content"].some(o=>(n.contain||"").includes(o))}function Kt(t){let e=z(t);for(;k(e)&&!Q(e);){if(ot(e))return e;if(at(e))return null;e=z(e)}return null}function pt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Q(t){return["html","body","#document"].includes(J(t))}function E(t){return P(t).getComputedStyle(t)}function ft(t){return S(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function z(t){if(J(t)==="html")return t;let e=t.assignedSlot||t.parentNode||Yt(t)&&t.host||M(t);return Yt(e)?e.host:e}function Gt(t){let e=z(t);return Q(e)?t.ownerDocument?t.ownerDocument.body:t.body:k(e)&&nt(e)?e:Gt(e)}function et(t,e,n){var o;e===void 0&&(e=[]),n===void 0&&(n=!0);let i=Gt(t),r=i===((o=t.ownerDocument)==null?void 0:o.body),s=P(i);if(r){let c=wt(s);return e.concat(s,s.visualViewport||[],nt(i)?i:[],c&&n?et(c):[])}return e.concat(i,et(i,[],n))}function wt(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Zt(t){let e=E(t),n=parseFloat(e.width)||0,o=parseFloat(e.height)||0,i=k(t),r=i?t.offsetWidth:n,s=i?t.offsetHeight:o,c=ct(n)!==r||ct(o)!==s;return c&&(n=r,o=s),{width:n,height:o,$:c}}function St(t){return S(t)?t:t.contextElement}function it(t){let e=St(t);if(!k(e))return D(1);let n=e.getBoundingClientRect(),{width:o,height:i,$:r}=Zt(e),s=(r?ct(n.width):n.width)/o,c=(r?ct(n.height):n.height)/i;return(!s||!Number.isFinite(s))&&(s=1),(!c||!Number.isFinite(c))&&(c=1),{x:s,y:c}}var Se=D(0);function te(t){let e=P(t);return!pt()||!e.visualViewport?Se:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Ee(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==P(t)?!1:e}function Z(t,e,n,o){e===void 0&&(e=!1),n===void 0&&(n=!1);let i=t.getBoundingClientRect(),r=St(t),s=D(1);e&&(o?S(o)&&(s=it(o)):s=it(t));let c=Ee(r,n,o)?te(r):D(0),l=(i.left+c.x)/s.x,a=(i.top+c.y)/s.y,d=i.width/s.x,u=i.height/s.y;if(r){let m=P(r),f=o&&S(o)?P(o):o,g=m,h=wt(g);for(;h&&o&&f!==g;){let p=it(h),w=h.getBoundingClientRect(),x=E(h),y=w.left+(h.clientLeft+parseFloat(x.paddingLeft))*p.x,b=w.top+(h.clientTop+parseFloat(x.paddingTop))*p.y;l*=p.x,a*=p.y,d*=p.x,u*=p.y,l+=y,a+=b,g=P(h),h=wt(g)}}return G({width:d,height:u,x:l,y:a})}function Et(t,e){let n=ft(t).scrollLeft;return e?e.left+n:Z(M(t)).left+n}function ee(t,e,n){n===void 0&&(n=!1);let o=t.getBoundingClientRect(),i=o.left+e.scrollLeft-(n?0:Et(t,o)),r=o.top+e.scrollTop;return{x:i,y:r}}function Te(t){let{elements:e,rect:n,offsetParent:o,strategy:i}=t,r=i==="fixed",s=M(o),c=e?at(e.floating):!1;if(o===s||c&&r)return n;let l={scrollLeft:0,scrollTop:0},a=D(1),d=D(0),u=k(o);if((u||!u&&!r)&&((J(o)!=="body"||nt(s))&&(l=ft(o)),k(o))){let f=Z(o);a=it(o),d.x=f.x+o.clientLeft,d.y=f.y+o.clientTop}let m=s&&!u&&!r?ee(s,l,!0):D(0);return{width:n.width*a.x,height:n.height*a.y,x:n.x*a.x-l.scrollLeft*a.x+d.x+m.x,y:n.y*a.y-l.scrollTop*a.y+d.y+m.y}}function Le(t){return Array.from(t.getClientRects())}function De(t){let e=M(t),n=ft(t),o=t.ownerDocument.body,i=V(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),r=V(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight),s=-n.scrollLeft+Et(t),c=-n.scrollTop;return E(o).direction==="rtl"&&(s+=V(e.clientWidth,o.clientWidth)-i),{width:i,height:r,x:s,y:c}}function Fe(t,e){let n=P(t),o=M(t),i=n.visualViewport,r=o.clientWidth,s=o.clientHeight,c=0,l=0;if(i){r=i.width,s=i.height;let a=pt();(!a||a&&e==="fixed")&&(c=i.offsetLeft,l=i.offsetTop)}return{width:r,height:s,x:c,y:l}}function Me(t,e){let n=Z(t,!0,e==="fixed"),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=k(t)?it(t):D(1),s=t.clientWidth*r.x,c=t.clientHeight*r.y,l=i*r.x,a=o*r.y;return{width:s,height:c,x:l,y:a}}function Jt(t,e,n){let o;if(e==="viewport")o=Fe(t,n);else if(e==="document")o=De(M(t));else if(S(e))o=Me(e,n);else{let i=te(t);o={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return G(o)}function ne(t,e){let n=z(t);return n===e||!S(n)||Q(n)?!1:E(n).position==="fixed"||ne(n,e)}function ke(t,e){let n=e.get(t);if(n)return n;let o=et(t,[],!1).filter(c=>S(c)&&J(c)!=="body"),i=null,r=E(t).position==="fixed",s=r?z(t):t;for(;S(s)&&!Q(s);){let c=E(s),l=ot(s);!l&&c.position==="fixed"&&(i=null),(r?!l&&!i:!l&&c.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||nt(s)&&!l&&ne(t,s))?o=o.filter(d=>d!==s):i=c,s=z(s)}return e.set(t,o),o}function Ne(t){let{element:e,boundary:n,rootBoundary:o,strategy:i}=t,s=[...n==="clippingAncestors"?at(e)?[]:ke(e,this._c):[].concat(n),o],c=s[0],l=s.reduce((a,d)=>{let u=Jt(e,d,i);return a.top=V(u.top,a.top),a.right=j(u.right,a.right),a.bottom=j(u.bottom,a.bottom),a.left=V(u.left,a.left),a},Jt(e,c,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Be(t){let{width:e,height:n}=Zt(t);return{width:e,height:n}}function We(t,e,n){let o=k(e),i=M(e),r=n==="fixed",s=Z(t,!0,r,e),c={scrollLeft:0,scrollTop:0},l=D(0);function a(){l.x=Et(i)}if(o||!o&&!r)if((J(e)!=="body"||nt(i))&&(c=ft(e)),o){let f=Z(e,!0,r,e);l.x=f.x+e.clientLeft,l.y=f.y+e.clientTop}else i&&a();r&&!o&&i&&a();let d=i&&!o&&!r?ee(i,c):D(0),u=s.left+c.scrollLeft-l.x-d.x,m=s.top+c.scrollTop-l.y-d.y;return{x:u,y:m,width:s.width,height:s.height}}function Ct(t){return E(t).position==="static"}function Qt(t,e){if(!k(t)||E(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return M(t)===n&&(n=n.ownerDocument.body),n}function oe(t,e){let n=P(t);if(at(t))return n;if(!k(t)){let i=z(t);for(;i&&!Q(i);){if(S(i)&&!Ct(i))return i;i=z(i)}return n}let o=Qt(t,e);for(;o&&qt(o)&&Ct(o);)o=Qt(o,e);return o&&Q(o)&&Ct(o)&&!ot(o)?n:o||Kt(t)||n}var $e=async function(t){let e=this.getOffsetParent||oe,n=this.getDimensions,o=await n(t.floating);return{reference:We(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function He(t){return E(t).direction==="rtl"}var xt={convertOffsetParentRelativeRectToViewportRelativeRect:Te,getDocumentElement:M,getClippingRect:Ne,getOffsetParent:oe,getElementRects:$e,getClientRects:Le,getDimensions:Be,getScale:it,isElement:S,isRTL:He};function ie(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function Ve(t,e){let n=null,o,i=M(t);function r(){var c;clearTimeout(o),(c=n)==null||c.disconnect(),n=null}function s(c,l){c===void 0&&(c=!1),l===void 0&&(l=1),r();let a=t.getBoundingClientRect(),{left:d,top:u,width:m,height:f}=a;if(c||e(),!m||!f)return;let g=lt(u),h=lt(i.clientWidth-(d+m)),p=lt(i.clientHeight-(u+f)),w=lt(d),y={rootMargin:-g+"px "+-h+"px "+-p+"px "+-w+"px",threshold:V(0,j(1,l))||1},b=!0;function v(R){let O=R[0].intersectionRatio;if(O!==l){if(!b)return s();O?s(!1,O):o=setTimeout(()=>{s(!1,1e-7)},1e3)}O===1&&!ie(a,t.getBoundingClientRect())&&s(),b=!1}try{n=new IntersectionObserver(v,{...y,root:i.ownerDocument})}catch{n=new IntersectionObserver(v,y)}n.observe(t)}return s(!0),r}function se(t,e,n,o){o===void 0&&(o={});let{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:l=!1}=o,a=St(t),d=i||r?[...a?et(a):[],...et(e)]:[];d.forEach(w=>{i&&w.addEventListener("scroll",n,{passive:!0}),r&&w.addEventListener("resize",n)});let u=a&&c?Ve(a,n):null,m=-1,f=null;s&&(f=new ResizeObserver(w=>{let[x]=w;x&&x.target===a&&f&&(f.unobserve(e),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var y;(y=f)==null||y.observe(e)})),n()}),a&&!l&&f.observe(a),f.observe(e));let g,h=l?Z(t):null;l&&p();function p(){let w=Z(t);h&&!ie(h,w)&&n(),h=w,g=requestAnimationFrame(p)}return n(),()=>{var w;d.forEach(x=>{i&&x.removeEventListener("scroll",n),r&&x.removeEventListener("resize",n)}),u?.(),(w=f)==null||w.disconnect(),f=null,l&&cancelAnimationFrame(g)}}var re=Ut,ce=zt,le=jt,Tt=_t;var ae=It,fe=Vt;var ue=(t,e,n)=>{let o=new Map,i={platform:xt,...n},r={...i.platform,_c:o};return Ht(t,e,{...i,platform:r})};function de(t){return ze(t)}function Lt(t){return t.assignedSlot?t.assignedSlot:t.parentNode instanceof ShadowRoot?t.parentNode.host:t.parentNode}function ze(t){for(let e=t;e;e=Lt(e))if(e instanceof Element&&getComputedStyle(e).display==="none")return null;for(let e=Lt(t);e;e=Lt(e)){if(!(e instanceof Element))continue;let n=getComputedStyle(e);if(n.display!=="contents"&&(n.position!=="static"||ot(n)||e.tagName==="BODY"))return e}return null}(function(){if(!!1){let e=xt.getOffsetParent;xt.getOffsetParent=n=>e(n,de)}})();function me(t){let e=window.devicePixelRatio||1;return Math.round(t*e)/e}var xe=async(t,{referenceEl:e,floatingEl:n,overlayPositioning:o="absolute",placement:i,flipDisabled:r,flipPlacements:s,offsetDistance:c,offsetSkidding:l,arrowEl:a,type:d})=>{if(!e||!n)return;let u=Dt(n)==="rtl",{x:m,y:f,placement:g,strategy:h,middlewareData:p}=await ue(e,n,{strategy:o,placement:i==="auto"||i==="auto-start"||i==="auto-end"?void 0:he(i,u),middleware:Ie({placement:i,flipDisabled:r,flipPlacements:s?.map(b=>he(b,u)),offsetDistance:c,offsetSkidding:l,arrowEl:a,type:d})});if(a&&p.arrow){let{x:b,y:v}=p.arrow,R=g.split("-")[0],O=b!=null?"left":"top",_=je[R],C={left:"",top:"",bottom:"",right:""};"floatingLayout"in t&&(t.floatingLayout=R==="left"||R==="right"?"horizontal":"vertical"),Object.assign(a.style,{...C,[O]:`${O=="left"?b:v}px`,[R]:"100%",transform:_})}let x=p.hide?.referenceHidden?"hidden":null,y=x?"none":null;n.setAttribute(_e,g),Object.assign(n.style,{pointerEvents:y,position:h,transform:`translate(${me(m)}px,${me(f)}px)`,visibility:x})},_e="data-placement",ge=["top","bottom","right","left","top-start","top-end","bottom-start","bottom-end","right-start","right-end","left-start","left-end","leading","trailing","leading-start","leading-end","trailing-start","trailing-end"],hn="bottom-start",pn="bottom-end",wn={animation:"calcite-floating-ui-anim",animationActive:"calcite-floating-ui-anim--active"};function Ie({placement:t,flipDisabled:e,flipPlacements:n,offsetDistance:o,offsetSkidding:i,arrowEl:r,type:s}){let c=[le(),ae()];return s==="menu"&&c.push(Tt({fallbackPlacements:n||["top-start","top","top-end","bottom-start","bottom","bottom-end"]})),c.push(re({mainAxis:typeof o=="number"?o:0,crossAxis:typeof i=="number"?i:0})),t==="auto"||t==="auto-start"||t==="auto-end"?c.push(ce({alignment:t==="auto-start"?"start":t==="auto-end"?"end":null})):e||c.push(Tt(n?{fallbackPlacements:n}:{})),r&&c.push(fe({element:r})),c}function xn(t,e){let n=t.filter(o=>ge.includes(o));return n.length!==t.length&&console.warn(`${e.tagName}: Invalid value found in: flipPlacements. Try any of these: ${ge.map(o=>`"${o}"`).join(", ").trim()}`,{el:e}),n}function he(t,e=!1){let n=["left","right"];return e&&n.reverse(),t.replace(/leading/gi,n[0]).replace(/trailing/gi,n[1])}async function yn(t,e,n=!1){if(!t.open||!e.floatingEl||!e.referenceEl)return;if(Object.assign(e.floatingEl.style,{display:"block",position:e.overlayPositioning??"absolute"}),!ut.get(t))return ye(t);await(n?Ue(t):xe)(t,e)}function Ue(t){let e=yt.get(t);return e||(e=Ft(xe,vt.reposition,{leading:!0,maxWait:vt.reposition}),yt.set(t,e),e)}var je={top:"",left:"rotate(-90deg)",bottom:"rotate(180deg)",right:"rotate(90deg)"},ut=new WeakMap,yt=new WeakMap;async function ye(t){let{referenceEl:e,floatingEl:n}=t;if(!n.isConnected)return;let o=se;ut.set(t,{state:"pending"});let i,r=o(e,n,()=>{let s=t.reposition();i||(i=s)});return ut.set(t,{state:"active",cleanUp:r}),i}function Ye(t){let{floatingEl:e}=t;e&&Object.assign(e.style,{display:"",pointerEvents:"",position:"",transform:"",visibility:""})}async function vn(t){let{floatingEl:e,referenceEl:n}=t;if(Ye(t),!(!e||!n)&&(Xe(t),!!t.open))return ye(t)}function Xe(t){let e=ut.get(t);e?.state==="active"&&e.cleanUp(),ut.delete(t),yt.get(t)?.cancel(),yt.delete(t)}var pe=4,bn=Math.ceil(Math.hypot(pe,pe));export{hn as a,pn as b,wn as c,xn as d,yn as e,Ye as f,vn as g,Xe as h,bn as i};