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