UNPKG

@public-ui/components

Version:

Contains all web components that belong to KoliBri - The accessible HTML-Standard.

4 lines 22.3 kB
/*! * KoliBri - The accessible HTML-Standard */ import{p as t}from"./reuse-32931294.js";const n=["top","right","bottom","left"],e=["start","end"],o=n.reduce(((t,n)=>t.concat(n,n+"-"+e[0],n+"-"+e[1])),[]),s=Math.min,r=Math.max,i=Math.round,c=Math.floor,l=t=>({x:t,y:t}),a={left:"right",right:"left",bottom:"top",top:"bottom"},f={start:"end",end:"start"};function u(t,e,n){return r(t,s(e,n))}function d(t,e){return"function"==typeof t?t(e):t}function m(t){return t.split("-")[0]}function p(t){return t.split("-")[1]}function h(t){return"x"===t?"y":"x"}function y(t){return"y"===t?"height":"width"}function w(t){return["top","bottom"].includes(m(t))?"y":"x"}function g(t){return h(w(t))}function x(t,e,n){void 0===n&&(n=!1);const o=p(t),i=g(t),r=y(i);let l="x"===i?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return e.reference[r]>e.floating[r]&&(l=R(l)),[l,R(l)]}function v(t){const e=R(t);return[b(t),e,b(e)]}function b(t){return t.replace(/start|end/g,(t=>f[t]))}function A(t,e,n){const o=["left","right"],i=["right","left"],r=["top","bottom"],l=["bottom","top"];switch(t){case"top":case"bottom":return n?e?i:o:e?o:i;case"left":case"right":return e?r:l;default:return[]}}function O(t,e,n,o){const i=p(t);let r=A(m(t),"start"===n,o);return i&&(r=r.map((t=>t+"-"+i)),e&&(r=r.concat(r.map(b)))),r}function R(t){return t.replace(/left|right|bottom|top/g,(t=>a[t]))}function k(t){return{top:0,right:0,bottom:0,left:0,...t}}function S(t){return"number"!=typeof t?k(t):{top:t,right:t,bottom:t,left:t}}function D(t){const{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 F(t,e,n){let{reference:o,floating:i}=t;const r=w(e),l=g(e),c=y(l),s=m(e),a="y"===r,f=o.x+o.width/2-i.width/2,u=o.y+o.height/2-i.height/2,d=o[c]/2-i[c]/2;let h;switch(s){case"top":h={x:f,y:o.y-i.height};break;case"bottom":h={x:f,y:o.y+o.height};break;case"right":h={x:o.x+o.width,y:u};break;case"left":h={x:o.x-i.width,y:u};break;default:h={x:o.x,y:o.y}}switch(p(e)){case"start":h[l]-=d*(n&&a?-1:1);break;case"end":h[l]+=d*(n&&a?-1:1)}return h}const P=async(t,e,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:r=[],platform:l}=n,c=r.filter(Boolean),s=await(null==l.isRTL?void 0:l.isRTL(e));let a=await l.getElementRects({reference:t,floating:e,strategy:i}),{x:f,y:u}=F(a,o,s),d=o,m={},h=0;for(let n=0;n<c.length;n++){const{name:r,fn:p}=c[n],{x:g,y:y,data:w,reset:x}=await p({x:f,y:u,initialPlacement:o,placement:d,strategy:i,middlewareData:m,rects:a,platform:l,elements:{reference:t,floating:e}});f=null!=g?g:f,u=null!=y?y:u,m={...m,[r]:{...m[r],...w}},x&&h<=50&&(h++,"object"==typeof x&&(x.placement&&(d=x.placement),x.rects&&(a=!0===x.rects?await l.getElementRects({reference:t,floating:e,strategy:i}):x.rects),({x:f,y:u}=F(a,d,s))),n=-1)}return{x:f,y:u,placement:d,strategy:i,middlewareData:m}};async function $(t,e){var n;void 0===e&&(e={});const{x:o,y:i,platform:r,rects:l,elements:c,strategy:s}=t,{boundary:a="clippingAncestors",rootBoundary:f="viewport",elementContext:u="floating",altBoundary:m=!1,padding:h=0}=d(e,t),p=S(h),g=c[m?"floating"===u?"reference":"floating":u],y=D(await r.getClippingRect({element:null==(n=await(null==r.isElement?void 0:r.isElement(g)))||n?g:g.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(c.floating)),boundary:a,rootBoundary:f,strategy:s})),w="floating"===u?{x:o,y:i,width:l.floating.width,height:l.floating.height}:l.reference,x=await(null==r.getOffsetParent?void 0:r.getOffsetParent(c.floating)),v=await(null==r.isElement?void 0:r.isElement(x))&&await(null==r.getScale?void 0:r.getScale(x))||{x:1,y:1},b=D(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:w,offsetParent:x,strategy:s}):w);return{top:(y.top-b.top+p.top)/v.y,bottom:(b.bottom-y.bottom+p.bottom)/v.y,left:(y.left-b.left+p.left)/v.x,right:(b.right-y.right+p.right)/v.x}}const T=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:o,placement:i,rects:r,platform:l,elements:c,middlewareData:a}=e,{element:f,padding:m=0}=d(t,e)||{};if(null==f)return{};const h=S(m),w={x:n,y:o},x=g(i),v=y(x),b=await l.getDimensions(f),R="y"===x,L=R?"top":"left",T=R?"bottom":"right",A=R?"clientHeight":"clientWidth",E=r.reference[v]+r.reference[x]-w[x]-r.floating[v],D=w[x]-r.reference[x],O=await(null==l.getOffsetParent?void 0:l.getOffsetParent(f));let C=O?O[A]:0;C&&await(null==l.isElement?void 0:l.isElement(O))||(C=c.floating[A]||r.floating[v]);const P=E/2-D/2,H=C/2-b[v]/2-1,F=s(h[L],H),B=s(h[T],H),W=F,k=C-b[v]-B,$=C/2-b[v]/2+P,G=u(W,$,k),z=!a.arrow&&null!=p(i)&&$!==G&&r.reference[v]/2-($<W?F:B)-b[v]/2<0,Q=z?$<W?$-W:$-k:0;return{[x]:w[x]+Q,data:{[x]:G,centerOffset:$-G-Q,...z&&{alignmentOffset:Q}},reset:z}}});function C(t,e,n){const o=t?[...n.filter((e=>p(e)===t)),...n.filter((e=>p(e)!==t))]:n.filter((t=>m(t)===t));return o.filter((n=>!t||(p(n)===t||!!e&&b(n)!==n)))}const E=function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,i,r;const{rects:l,middlewareData:c,placement:s,platform:a,elements:f}=e,{crossAxis:u=!1,alignment:h,allowedPlacements:g=o,autoAlignment:y=!0,...w}=d(t,e),v=void 0!==h||g===o?C(h||null,y,g):g,b=await $(e,w),R=(null==(n=c.autoPlacement)?void 0:n.index)||0,L=v[R];if(null==L)return{};const T=x(L,l,await(null==a.isRTL?void 0:a.isRTL(f.floating)));if(s!==L)return{reset:{placement:v[0]}};const A=[b[m(L)],b[T[0]],b[T[1]]],E=[...(null==(i=c.autoPlacement)?void 0:i.overflows)||[],{placement:L,overflows:A}],D=v[R+1];if(D)return{data:{index:R+1,overflows:E},reset:{placement:D}};const O=E.map((t=>{const e=p(t.placement);return[t.placement,e&&u?t.overflows.slice(0,2).reduce(((t,e)=>t+e),0):t.overflows[0],t.overflows]})).sort(((t,e)=>t[1]-e[1])),P=O.filter((t=>t[2].slice(0,p(t[0])?2:3).every((t=>t<=0)))),H=(null==(r=P[0])?void 0:r[0])||O[0][0];return H!==s?{data:{index:R+1,overflows:E},reset:{placement:H}}:{}}}},z=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,o;const{placement:i,middlewareData:r,rects:l,initialPlacement:c,platform:s,elements:a}=e,{mainAxis:f=!0,crossAxis:u=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:y=!0,...b}=d(t,e);if(null!=(n=r.arrow)&&n.alignmentOffset)return{};const L=m(i),T=w(c),A=m(c)===c,E=await(null==s.isRTL?void 0:s.isRTL(a.floating)),D=h||(A||!y?[R(c)]:v(c)),C="none"!==g;!h&&C&&D.push(...O(c,y,g,E));const P=[c,...D],H=await $(e,b),S=[];let F=(null==(o=r.flip)?void 0:o.overflows)||[];if(f&&S.push(H[L]),u){const t=x(i,l,E);S.push(H[t[0]],H[t[1]])}if(F=[...F,{placement:i,overflows:S}],!S.every((t=>t<=0))){var B,W;const t=((null==(B=r.flip)?void 0:B.index)||0)+1,e=P[t];if(e)return{data:{index:t,overflows:F},reset:{placement:e}};let n=null==(W=F.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:W.placement;if(!n)switch(p){case"bestFit":{var k;const t=null==(k=F.filter((t=>{if(C){const e=w(t.placement);return e===T||"y"===e}return!0})).map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)])).sort(((t,e)=>t[1]-e[1]))[0])?void 0:k[0];t&&(n=t);break}case"initialPlacement":n=c}if(i!==n)return{reset:{placement:n}}}return{}}}};function B(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function H(t){return n.some((e=>t[e]>=0))}const M=function(t){return void 0===t&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:o="referenceHidden",...i}=d(t,e);switch(o){case"referenceHidden":{const t=B(await $(e,{...i,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:t,referenceHidden:H(t)}}}case"escaped":{const t=B(await $(e,{...i,altBoundary:!0}),n.floating);return{data:{escapedOffsets:t,escaped:H(t)}}}default:return{}}}}};function j(t){const e=s(...t.map((t=>t.left))),n=s(...t.map((t=>t.top)));return{x:e,y:n,width:r(...t.map((t=>t.right)))-e,height:r(...t.map((t=>t.bottom)))-n}}function L(t){const e=t.slice().sort(((t,e)=>t.y-e.y)),n=[];let o=null;for(let t=0;t<e.length;t++){const i=e[t];!o||i.y-o.y>o.height/2?n.push([i]):n[n.length-1].push(i),o=i}return n.map((t=>D(j(t))))}const I=function(t){return void 0===t&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:o,rects:i,platform:l,strategy:c}=e,{padding:a=2,x:f,y:u}=d(t,e),h=Array.from(await(null==l.getClientRects?void 0:l.getClientRects(o.reference))||[]),p=L(h),g=D(j(h)),y=S(a);const x=await l.getElementRects({reference:{getBoundingClientRect:function(){if(2===p.length&&p[0].left>p[1].right&&null!=f&&null!=u)return p.find((t=>f>t.left-y.left&&f<t.right+y.right&&u>t.top-y.top&&u<t.bottom+y.bottom))||g;if(p.length>=2){if("y"===w(n)){const t=p[0],e=p[p.length-1],o="top"===m(n),i=t.top,r=e.bottom,l=o?t.left:e.left,c=o?t.right:e.right;return{top:i,bottom:r,left:l,right:c,width:c-l,height:r-i,x:l,y:i}}const t="left"===m(n),e=r(...p.map((t=>t.right))),o=s(...p.map((t=>t.left))),i=p.filter((n=>t?n.left===o:n.right===e)),l=i[0].top,c=i[i.length-1].bottom;return{top:l,bottom:c,left:o,right:e,width:e-o,height:c-l,x:o,y:l}}return g}},floating:o.floating,strategy:c});return i.reference.x!==x.reference.x||i.reference.y!==x.reference.y||i.reference.width!==x.reference.width||i.reference.height!==x.reference.height?{reset:{rects:x}}:{}}}};async function N(t,e){const{placement:n,platform:o,elements:i}=t,r=await(null==o.isRTL?void 0:o.isRTL(i.floating)),l=m(n),c=p(n),s="y"===w(n),a=["left","top"].includes(l)?-1:1,f=r&&s?-1:1,u=d(e,t);let{mainAxis:h,crossAxis:g,alignmentAxis:y}="number"==typeof u?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...u};return c&&"number"==typeof y&&(g="end"===c?-1*y:y),s?{x:g*f,y:h*a}:{x:h*a,y:g*f}}const q=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var n,o;const{x:i,y:r,placement:l,middlewareData:c}=e,s=await N(e,t);return l===(null==(n=c.offset)?void 0:n.placement)&&null!=(o=c.arrow)&&o.alignmentOffset?{}:{x:i+s.x,y:r+s.y,data:{...s,placement:l}}}}},W=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:o,placement:i}=e,{mainAxis:r=!0,crossAxis:l=!1,limiter:c={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...s}=d(t,e),a={x:n,y:o},f=await $(e,s),p=w(m(i)),g=h(p);let y=a[g],x=a[p];if(r){const t="y"===g?"bottom":"right";y=u(y+f["y"===g?"top":"left"],y,y-f[t])}if(l){const t="y"===p?"bottom":"right";x=u(x+f["y"===p?"top":"left"],x,x-f[t])}const v=c.fn({...e,[g]:y,[p]:x});return{...v,data:{x:v.x-n,y:v.y-o}}}}},V=function(t){return void 0===t&&(t={}),{options:t,fn(e){const{x:n,y:o,placement:i,rects:r,middlewareData:l}=e,{offset:c=0,mainAxis:s=!0,crossAxis:a=!0}=d(t,e),f={x:n,y:o},u=w(i),p=h(u);let g=f[p],y=f[u];const x=d(c,e),v="number"==typeof x?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(s){const t="y"===p?"height":"width",e=r.reference[p]-r.floating[t]+v.mainAxis,n=r.reference[p]+r.reference[t]-v.mainAxis;g<e?g=e:g>n&&(g=n)}if(a){var b,R;const t="y"===p?"width":"height",e=["top","left"].includes(m(i)),n=r.reference[u]-r.floating[t]+(e&&(null==(b=l.offset)?void 0:b[u])||0)+(e?0:v.crossAxis),o=r.reference[u]+r.reference[t]+(e?0:(null==(R=l.offset)?void 0:R[u])||0)-(e?v.crossAxis:0);y<n?y=n:y>o&&(y=o)}return{[p]:g,[u]:y}}}},X=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(e){const{placement:n,rects:o,platform:i,elements:l}=e,{apply:c=()=>{},...a}=d(t,e),f=await $(e,a),u=m(n),h=p(n),g="y"===w(n),{width:y,height:x}=o.floating;let v,b;"top"===u||"bottom"===u?(v=u,b=h===(await(null==i.isRTL?void 0:i.isRTL(l.floating))?"start":"end")?"left":"right"):(b=u,v="end"===h?"top":"bottom");const R=x-f.top-f.bottom,L=y-f.left-f.right,T=s(x-f[v],R),A=s(y-f[b],L),E=!e.middlewareData.shift;let D=T,O=A;if(g?O=h||E?s(A,L):L:D=h||E?s(T,R):R,E&&!h){const t=r(f.left,0),e=r(f.right,0),n=r(f.top,0),o=r(f.bottom,0);g?O=y-2*(0!==t||0!==e?t+e:r(f.left,f.right)):D=x-2*(0!==n||0!==o?n+o:r(f.top,f.bottom))}await c({...e,availableWidth:O,availableHeight:D});const C=await i.getDimensions(l.floating);return y!==C.width||x!==C.height?{reset:{rects:!0}}:{}}}};function Y(){return"undefined"!=typeof window}function _(t){return K(t)?(t.nodeName||"").toLowerCase():"#document"}function G(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function J(t){var e;return null==(e=(K(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function K(t){return!!Y()&&(t instanceof Node||t instanceof G(t).Node)}function Q(t){return!!Y()&&(t instanceof Element||t instanceof G(t).Element)}function U(t){return!!Y()&&(t instanceof HTMLElement||t instanceof G(t).HTMLElement)}function Z(t){return!(!Y()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof G(t).ShadowRoot)}function tt(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=ct(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(i)}function nt(t){return["table","td","th"].includes(_(t))}function et(t){return[":popover-open",":modal"].some((e=>{try{return t.matches(e)}catch(t){return!1}}))}function ot(t){const e=rt(),n=Q(t)?ct(t):t;return["transform","translate","scale","rotate","perspective"].some((t=>!!n[t]&&"none"!==n[t]))||!!n.containerType&&"normal"!==n.containerType||!e&&!!n.backdropFilter&&"none"!==n.backdropFilter||!e&&!!n.filter&&"none"!==n.filter||["transform","translate","scale","rotate","perspective","filter"].some((t=>(n.willChange||"").includes(t)))||["paint","layout","strict","content"].some((t=>(n.contain||"").includes(t)))}function st(t){let e=at(t);for(;U(e)&&!it(e);){if(ot(e))return e;if(et(e))return null;e=at(e)}return null}function rt(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function it(t){return["html","body","#document"].includes(_(t))}function ct(t){return G(t).getComputedStyle(t)}function lt(t){return Q(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function at(t){if("html"===_(t))return t;const e=t.assignedSlot||t.parentNode||Z(t)&&t.host||J(t);return Z(e)?e.host:e}function ft(t){const e=at(t);return it(e)?t.ownerDocument?t.ownerDocument.body:t.body:U(e)&&tt(e)?e:ft(e)}function ut(t,e,n){var o;void 0===e&&(e=[]),void 0===n&&(n=!0);const i=ft(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),l=G(i);if(r){const t=dt(l);return e.concat(l,l.visualViewport||[],tt(i)?i:[],t&&n?ut(t):[])}return e.concat(i,ut(i,[],n))}function dt(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function mt(t){const e=ct(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const r=U(t),l=r?t.offsetWidth:n,c=r?t.offsetHeight:o,s=i(n)!==l||i(o)!==c;return s&&(n=l,o=c),{width:n,height:o,$:s}}function pt(t){return Q(t)?t:t.contextElement}function ht(t){const e=pt(t);if(!U(e))return l(1);const n=e.getBoundingClientRect(),{width:o,height:r,$:c}=mt(e);let s=(c?i(n.width):n.width)/o,a=(c?i(n.height):n.height)/r;return s&&Number.isFinite(s)||(s=1),a&&Number.isFinite(a)||(a=1),{x:s,y:a}}const yt=l(0);function wt(t){const e=G(t);return rt()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:yt}function gt(t,e,n){return void 0===e&&(e=!1),!(!n||e&&n!==G(t))&&e}function xt(t,e,n,o){void 0===e&&(e=!1),void 0===n&&(n=!1);const i=t.getBoundingClientRect(),r=pt(t);let c=l(1);e&&(o?Q(o)&&(c=ht(o)):c=ht(t));const s=gt(r,n,o)?wt(r):l(0);let a=(i.left+s.x)/c.x,f=(i.top+s.y)/c.y,u=i.width/c.x,d=i.height/c.y;if(r){const t=G(r),e=o&&Q(o)?G(o):o;let n=t,i=dt(n);for(;i&&o&&e!==n;){const t=ht(i),e=i.getBoundingClientRect(),o=ct(i),r=e.left+(i.clientLeft+parseFloat(o.paddingLeft))*t.x,l=e.top+(i.clientTop+parseFloat(o.paddingTop))*t.y;a*=t.x,f*=t.y,u*=t.x,d*=t.y,a+=r,f+=l,n=G(i),i=dt(n)}}return D({width:u,height:d,x:a,y:f})}function vt(t,e){const n=lt(t).scrollLeft;return e?e.left+n:xt(J(t)).left+n}function bt(t,e,n){void 0===n&&(n=!1);const o=t.getBoundingClientRect();return{x:o.left+e.scrollLeft-(n?0:vt(t,o)),y:o.top+e.scrollTop}}function At(t){let{elements:e,rect:n,offsetParent:o,strategy:i}=t;const r="fixed"===i,c=J(o),s=!!e&&et(e.floating);if(o===c||s&&r)return n;let a={scrollLeft:0,scrollTop:0},f=l(1);const u=l(0),d=U(o);if((d||!d&&!r)&&(("body"!==_(o)||tt(c))&&(a=lt(o)),U(o))){const t=xt(o);f=ht(o),u.x=t.x+o.clientLeft,u.y=t.y+o.clientTop}const m=!c||d||r?l(0):bt(c,a,!0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-a.scrollLeft*f.x+u.x+m.x,y:n.y*f.y-a.scrollTop*f.y+u.y+m.y}}function Ot(t){return Array.from(t.getClientRects())}function Rt(t){const e=J(t),n=lt(t),o=t.ownerDocument.body,i=r(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),l=r(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let c=-n.scrollLeft+vt(t);const s=-n.scrollTop;return"rtl"===ct(o).direction&&(c+=r(e.clientWidth,o.clientWidth)-i),{width:i,height:l,x:c,y:s}}function kt(t,e){const n=G(t),o=J(t),i=n.visualViewport;let r=o.clientWidth,l=o.clientHeight,c=0,s=0;if(i){r=i.width,l=i.height;const t=rt();(!t||t&&"fixed"===e)&&(c=i.offsetLeft,s=i.offsetTop)}return{width:r,height:l,x:c,y:s}}function St(t,e){const n=xt(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=U(t)?ht(t):l(1);return{width:t.clientWidth*r.x,height:t.clientHeight*r.y,x:i*r.x,y:o*r.y}}function Dt(t,e,n){let o;if("viewport"===e)o=kt(t,n);else if("document"===e)o=Rt(J(t));else if(Q(e))o=St(e,n);else{const n=wt(t);o={x:e.x-n.x,y:e.y-n.y,width:e.width,height:e.height}}return D(o)}function Ft(t,e){const n=at(t);return!(n===e||!Q(n)||it(n))&&("fixed"===ct(n).position||Ft(n,e))}function Pt(t,e){const n=e.get(t);if(n)return n;let o=ut(t,[],!1).filter((t=>Q(t)&&"body"!==_(t))),i=null;const r="fixed"===ct(t).position;let l=r?at(t):t;for(;Q(l)&&!it(l);){const e=ct(l),n=ot(l);n||"fixed"!==e.position||(i=null);(r?!n&&!i:!n&&"static"===e.position&&!!i&&["absolute","fixed"].includes(i.position)||tt(l)&&!n&&Ft(t,l))?o=o.filter((t=>t!==l)):i=e,l=at(l)}return e.set(t,o),o}function $t(t){let{element:e,boundary:n,rootBoundary:o,strategy:i}=t;const l=[..."clippingAncestors"===n?et(e)?[]:Pt(e,this._c):[].concat(n),o],c=l[0],a=l.reduce(((t,n)=>{const o=Dt(e,n,i);return t.top=r(o.top,t.top),t.right=s(o.right,t.right),t.bottom=s(o.bottom,t.bottom),t.left=r(o.left,t.left),t}),Dt(e,c,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function Tt(t){const{width:e,height:n}=mt(t);return{width:e,height:n}}function Ct(t,e,n){const o=U(e),i=J(e),r="fixed"===n,c=xt(t,!0,r,e);let s={scrollLeft:0,scrollTop:0};const a=l(0);if(o||!o&&!r)if(("body"!==_(e)||tt(i))&&(s=lt(e)),o){const t=xt(e,!0,r,e);a.x=t.x+e.clientLeft,a.y=t.y+e.clientTop}else i&&(a.x=vt(i));const f=!i||o||r?l(0):bt(i,s);return{x:c.left+s.scrollLeft-a.x-f.x,y:c.top+s.scrollTop-a.y-f.y,width:c.width,height:c.height}}function Et(t){return"static"===ct(t).position}function zt(t,e){if(!U(t)||"fixed"===ct(t).position)return null;if(e)return e(t);let n=t.offsetParent;return J(t)===n&&(n=n.ownerDocument.body),n}function Bt(t,e){const n=G(t);if(et(t))return n;if(!U(t)){let e=at(t);for(;e&&!it(e);){if(Q(e)&&!Et(e))return e;e=at(e)}return n}let o=zt(t,e);for(;o&&nt(o)&&Et(o);)o=zt(o,e);return o&&it(o)&&Et(o)&&!ot(o)?n:o||st(t)||n}const Ht=async function(t){const e=this.getOffsetParent||Bt,n=this.getDimensions,o=await n(t.floating);return{reference:Ct(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function Mt(t){return"rtl"===ct(t).direction}const jt={convertOffsetParentRelativeRectToViewportRelativeRect:At,getDocumentElement:J,getClippingRect:$t,getOffsetParent:Bt,getElementRects:Ht,getClientRects:Ot,getDimensions:Tt,getScale:ht,isElement:Q,isRTL:Mt};function Lt(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function It(t,e){let n,o=null;const i=J(t);function l(){var t;clearTimeout(n),null==(t=o)||t.disconnect(),o=null}return function a(f,u){void 0===f&&(f=!1),void 0===u&&(u=1),l();const d=t.getBoundingClientRect(),{left:m,top:h,width:p,height:g}=d;if(f||e(),!p||!g)return;const y={rootMargin:-c(h)+"px "+-c(i.clientWidth-(m+p))+"px "+-c(i.clientHeight-(h+g))+"px "+-c(m)+"px",threshold:r(0,s(1,u))||1};let w=!0;function x(e){const o=e[0].intersectionRatio;if(o!==u){if(!w)return a();o?a(!1,o):n=setTimeout((()=>{a(!1,1e-7)}),1e3)}1!==o||Lt(d,t.getBoundingClientRect())||a(),w=!1}try{o=new IntersectionObserver(x,{...y,root:i.ownerDocument})}catch(t){o=new IntersectionObserver(x,y)}o.observe(t)}(!0),l}function Nt(t,e,n,o){void 0===o&&(o={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:l="function"==typeof ResizeObserver,layoutShift:c="function"==typeof IntersectionObserver,animationFrame:s=!1}=o,a=pt(t),f=i||r?[...a?ut(a):[],...ut(e)]:[];f.forEach((t=>{i&&t.addEventListener("scroll",n,{passive:!0}),r&&t.addEventListener("resize",n)}));const u=a&&c?It(a,n):null;let d,m=-1,h=null;l&&(h=new ResizeObserver((t=>{let[o]=t;o&&o.target===a&&h&&(h.unobserve(e),cancelAnimationFrame(m),m=requestAnimationFrame((()=>{var t;null==(t=h)||t.observe(e)}))),n()})),a&&!s&&h.observe(a),h.observe(e));let p=s?xt(t):null;return s&&function e(){const o=xt(t);p&&!Lt(p,o)&&n();p=o,d=requestAnimationFrame(e)}(),n(),()=>{var t;f.forEach((t=>{i&&t.removeEventListener("scroll",n),r&&t.removeEventListener("resize",n)})),null==u||u(),null==(t=h)||t.disconnect(),h=null,s&&cancelAnimationFrame(d)}}const qt=q,Wt=W,Vt=z,Xt=T,Yt=(t,e,n)=>{const o=new Map,i={platform:jt,...n},r={...i.platform,_c:o};return P(t,e,{...i,platform:r})},_t=async({floatingElement:e,referenceElement:n,arrowElement:o,align:i="top"})=>{var r,l,c;if("test"!==t){const t=[qt(null!==(r=null==o?void 0:o.offsetHeight)&&void 0!==r?r:10),Vt(),Wt()];o&&t.push(Xt({element:o}));const{x:s,y:a,middlewareData:f,placement:u}=await Yt(n,e,{placement:i,middleware:t,strategy:"fixed"});Object.assign(e.style,{left:`${s}px`,top:`${a}px`,visibility:"visible"}),o&&((null===(l=f.arrow)||void 0===l?void 0:l.x)?Object.assign(o.style,{left:`${f.arrow.x}px`,top:"bottom"===u?-o.offsetHeight/2+"px":"",bottom:"top"===u?-o.offsetHeight/2+"px":""}):(null===(c=f.arrow)||void 0===c?void 0:c.y)&&Object.assign(o.style,{left:"right"===u?-o.offsetWidth/2+"px":"",right:"left"===u?-o.offsetWidth/2+"px":"",top:`${f.arrow.y}px`}))}};export{_t as a,Nt as b};