@vielzeug/orbit 2.1.3 → 26.10.0

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.
Files changed (57) hide show
  1. package/README.md +15 -14
  2. package/dist/devtools.cjs +1 -1
  3. package/dist/devtools.cjs.map +1 -1
  4. package/dist/devtools.d.ts.map +1 -1
  5. package/dist/devtools.js +1 -1
  6. package/dist/devtools.js.map +1 -1
  7. package/dist/float.cjs +1 -1
  8. package/dist/float.cjs.map +1 -1
  9. package/dist/float.d.ts +3 -4
  10. package/dist/float.d.ts.map +1 -1
  11. package/dist/float.js +1 -1
  12. package/dist/float.js.map +1 -1
  13. package/dist/index.cjs +1 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/inline.cjs.map +1 -1
  18. package/dist/inline.d.ts +0 -1
  19. package/dist/inline.d.ts.map +1 -1
  20. package/dist/inline.js.map +1 -1
  21. package/dist/middleware/arrow.cjs +1 -1
  22. package/dist/middleware/arrow.cjs.map +1 -1
  23. package/dist/middleware/arrow.d.ts.map +1 -1
  24. package/dist/middleware/arrow.js +1 -1
  25. package/dist/middleware/arrow.js.map +1 -1
  26. package/dist/middleware/shift.cjs +1 -1
  27. package/dist/middleware/shift.cjs.map +1 -1
  28. package/dist/middleware/shift.d.ts.map +1 -1
  29. package/dist/middleware/shift.js +1 -1
  30. package/dist/middleware/shift.js.map +1 -1
  31. package/dist/middleware/size.cjs.map +1 -1
  32. package/dist/middleware/size.d.ts +0 -1
  33. package/dist/middleware/size.d.ts.map +1 -1
  34. package/dist/middleware/size.js.map +1 -1
  35. package/dist/orbit.cjs +1 -1
  36. package/dist/orbit.cjs.map +1 -1
  37. package/dist/orbit.iife.js +1 -1
  38. package/dist/orbit.iife.js.map +1 -1
  39. package/dist/orbit.js +1 -1
  40. package/dist/orbit.js.map +1 -1
  41. package/dist/presets.cjs.map +1 -1
  42. package/dist/presets.d.ts +0 -4
  43. package/dist/presets.d.ts.map +1 -1
  44. package/dist/presets.js.map +1 -1
  45. package/dist/reactive.cjs +1 -1
  46. package/dist/reactive.cjs.map +1 -1
  47. package/dist/reactive.d.ts +1 -1
  48. package/dist/reactive.d.ts.map +1 -1
  49. package/dist/reactive.js +1 -1
  50. package/dist/reactive.js.map +1 -1
  51. package/dist/utils.cjs +1 -1
  52. package/dist/utils.cjs.map +1 -1
  53. package/dist/utils.d.ts +0 -1
  54. package/dist/utils.d.ts.map +1 -1
  55. package/dist/utils.js +1 -1
  56. package/dist/utils.js.map +1 -1
  57. package/package.json +12 -9
package/dist/orbit.cjs CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e,t,n){return Math.min(Math.max(e,t),n)}var t={bottom:`top`,left:`right`,right:`left`,top:`bottom`};function n(e){return e.split(`-`)[0]}function r(e){return e.split(`-`)[1]??null}function i(e,t){return t?`${e}-${t}`:e}function a({height:e,width:t,x:n,y:r}){return{height:e,width:t,x:n,y:r}}function o(e=0){return typeof e==`number`?{bottom:e,left:e,right:e,top:e}:{bottom:e.bottom??0,left:e.left??0,right:e.right??0,top:e.top??0}}function s(e){return typeof Element<`u`&&e instanceof Element}function c(e){return e.assignedSlot?e.assignedSlot:e.parentElement??(e.getRootNode()instanceof ShadowRoot?e.getRootNode().host:null)}function l(e,t,n,r){return e===`start`?t:e===`end`?t+n-r:t+(n-r)/2}function u(e,t,i){let a=n(e),o=r(e);switch(a){case`bottom`:return{x:l(o,t.x,t.width,i.width),y:t.y+t.height};case`left`:return{x:t.x-i.width,y:l(o,t.y,t.height,i.height)};case`right`:return{x:t.x+t.width,y:l(o,t.y,t.height,i.height)};case`top`:return{x:l(o,t.x,t.width,i.width),y:t.y-i.height}}}function d(e,t){let n,r=0,i=(()=>{let i=Date.now(),a=t-(i-r);if(a<=0){n!==void 0&&clearTimeout(n),n=void 0,r=i,e();return}n===void 0&&(n=setTimeout(()=>{n=void 0,r=Date.now(),e()},a))});return i.cancel=()=>{n!==void 0&&clearTimeout(n),n=void 0},i}function f(e){let t=[],n=c(e);for(;n;){let e=getComputedStyle(n),r=e.overflow+e.overflowX+e.overflowY;/auto|scroll|overlay/.test(r)&&t.push(n),n=c(n)}return t}function p(e,t,n,{animationFrame:r=!1,observeAncestors:i=!0,observeFloating:a=!0,observeVisualViewport:o=!0,pauseWhenHidden:c=!0,throttle:l=0}={}){let u=l>0?d(n,l):null,p=u??n,m=!0,h=()=>{m&&p()};p();let g=[];if(c&&s(e)&&typeof IntersectionObserver<`u`){let t=new IntersectionObserver(e=>{m=e.at(-1)?.isIntersecting??!0,m&&p()});t.observe(e),g.push(()=>t.disconnect())}if(s(e)&&i){let t=f(e);for(let e of t)e.addEventListener(`scroll`,h,{passive:!0}),g.push(()=>e.removeEventListener(`scroll`,h));window.addEventListener(`scroll`,h,{passive:!0}),g.push(()=>window.removeEventListener(`scroll`,h))}else{let e=e=>{e.composedPath().includes(t)||h()};window.addEventListener(`scroll`,e,{capture:!0,passive:!0}),g.push(()=>window.removeEventListener(`scroll`,e,{capture:!0}))}window.addEventListener(`resize`,h,{passive:!0}),g.push(()=>window.removeEventListener(`resize`,h));let _=o?window.visualViewport:null;_&&(_.addEventListener(`resize`,h,{passive:!0}),_.addEventListener(`scroll`,h,{passive:!0}),g.push(()=>{_.removeEventListener(`resize`,h),_.removeEventListener(`scroll`,h)}));let v=new ResizeObserver(h);s(e)&&v.observe(e),a&&v.observe(t),g.push(()=>v.disconnect());let y=0;if(r){let e=()=>{h(),y=window.requestAnimationFrame(e)};y=window.requestAnimationFrame(e),g.push(()=>window.cancelAnimationFrame(y))}return()=>{u?.cancel();for(let e of g)e()}}var m=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},h=class extends m{};function g(e,t){return{floating:a(t.getBoundingClientRect()),reference:a(e.getBoundingClientRect())}}function _(e,t){return t?{...e,middlewareData:t.data?Object.assign(Object.create(null),e.middlewareData,t.data):e.middlewareData,placement:t.placement??e.placement,x:t.x??e.x,y:t.y??e.y}:e}var v=8;function y(e,t,{boundary:n,containingBlock:r,middleware:i=[],padding:a,placement:o=`bottom`}={}){let s=i,c=o,l={},d=g(e,t);for(let i=0;i<v;i+=1){let i={...u(c,d.reference,d.floating),boundary:n,elements:{floating:t,reference:e},initialPlacement:o,middlewareData:l,padding:a,placement:c,rects:d},f;for(let e of s){let t=e(i);if(i=_(i,t),l=i.middlewareData,f=t?.reset,f)break}if(!f){let e={middlewareData:i.middlewareData,placement:i.placement,x:i.x,y:i.y};if(r){let t=r.getBoundingClientRect();return{...e,x:e.x-t.x,y:e.y-t.y}}return e}f.remeasure?d=g(e,t):f.rects!=null&&(d=f.rects),c=f.placement??i.placement}throw new h(`Middleware triggered too many resets in a single compute cycle.`)}var b=[`transform`,`perspective`,`filter`],x=[`layout`,`paint`,`strict`,`content`];function S(e){return e.transform!==`none`||e.perspective!==`none`||e.filter!==`none`||e.backdropFilter&&e.backdropFilter!==`none`||e.willChange!==`auto`&&b.some(t=>e.willChange.includes(t))?!0:e.contain!==`none`&&x.some(t=>e.contain.includes(t))}function C(e){let t=c(e);for(;t;){if(S(getComputedStyle(t)))return t;t=c(t)}return null}function w(){let e=window.visualViewport;return e?{height:e.height,width:e.width,x:e.offsetLeft,y:e.offsetTop}:{height:window.innerHeight,width:window.innerWidth,x:0,y:0}}function T(e){if(!e)return w();if(e instanceof Element){let t=e.getBoundingClientRect();return{height:t.height,width:t.width,x:t.x,y:t.y}}return e}var E=/(hidden|clip|scroll|auto|overlay)/;function D(e,t){let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),i=Math.min(e.x+e.width,t.x+t.width),a=Math.min(e.y+e.height,t.y+t.height);return{height:Math.max(0,a-r),width:Math.max(0,i-n),x:n,y:r}}function O(e){let t=c(e),n=w();for(;t;){let e=getComputedStyle(t);if(E.test(`${e.overflow}${e.overflowX}${e.overflowY}`)){let e=t.getBoundingClientRect();n=D(n,{height:e.height,width:e.width,x:e.x,y:e.y})}t=c(t)}return n}function k(e,t){return{boundary:T(e.boundary??t.boundary),padding:o(e.padding??t.padding)}}function A(e){return{...e.rects.floating,x:e.x,y:e.y}}function j(e,t,n){return{bottom:e.y+e.height-(t.y+t.height-n.bottom),left:t.x+n.left-e.x,right:e.x+e.width-(t.x+t.width-n.right),top:t.y+n.top-e.y}}function M(e){return Math.max(e.top,0)+Math.max(e.right,0)+Math.max(e.bottom,0)+Math.max(e.left,0)}function N(e){return e.top>0||e.right>0||e.bottom>0||e.left>0}function P(e,t){return t.top>=e.height||t.right>=e.width||t.bottom>=e.height||t.left>=e.width}function F(e,t,r,i){let a=e.rects.reference;switch(n(t)){case`bottom`:return r.y+r.height-i.bottom-(a.y+a.height);case`left`:return a.x-(r.x+i.left);case`right`:return r.x+r.width-i.right-(a.x+a.width);case`top`:return a.y-(r.y+i.top)}}function I(e,t,n={}){let{x:r,y:i}=u(t,e.rects.reference,e.rects.floating),{boundary:a,padding:o}=k(n,e);return j({...e.rects.floating,x:r,y:i},a,o)}function L(e,t={}){let{boundary:n,padding:r}=k(t,e);return j(A(e),n,r)}function R(e,t){return t===`absolute`?e.offsetParent instanceof Element?e.offsetParent:null:C(e)}function z(e,t,n){t.style.position=n,t.style.left=`${e.x}px`,t.style.top=`${e.y}px`}function B(e,t,{apply:n,autoUpdate:r={},boundary:i=`clippingAncestors`,middleware:a,padding:o,placement:s=`bottom`,strategy:c=`fixed`}={}){let l=new AbortController,u=!0,d=!1,f,m=null,h=!1;function g(){if(!u)return;let r=R(t,c),l=y(e,t,{boundary:i===`clippingAncestors`?O(t):i,containingBlock:r,middleware:a,padding:o,placement:s});m=l,(n??(e=>z(e,t,c)))(l)}function _(){h||d||(h=!0,r===!1?g():f=p(e,t,g,r))}return{get disposalSignal(){return l.signal},dispose(){d||(d=!0,u=!1,l.abort(),f?.())},get disposed(){return d},getPosition:()=>m,start:_,[Symbol.dispose](){this.dispose()},update(){d||g()}}}function V(e){return!(`getClientRects`in e)||typeof e.getClientRects!=`function`?[]:Array.from(e.getClientRects()).map(a).filter(e=>e.width>0||e.height>0)}function H(e,t,n,r){return t>=e.x-r.left&&t<=e.x+e.width+r.right&&n>=e.y-r.top&&n<=e.y+e.height+r.bottom}function U(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function W(e={}){function t(t){let r=V(t.elements.reference);if(r.length<=1)return;let i=o(e.padding??2),a=n(t.placement),s=r[0];if(e.x!=null&&e.y!=null)s=r.find(t=>H(t,e.x,e.y,i))??s;else if(a===`top`||a===`bottom`){let e=t.x+t.rects.floating.width/2;s=r.reduce((t,n)=>{let r=Math.abs(t.x+t.width/2-e);return Math.abs(n.x+n.width/2-e)<r?n:t},s)}else{let e=t.y+t.rects.floating.height/2;s=r.reduce((t,n)=>{let r=Math.abs(t.y+t.height/2-e);return Math.abs(n.y+n.height/2-e)<r?n:t},s)}if(!U(s,t.rects.reference))return{reset:{rects:{...t.rects,reference:s}}}}return t}function G({element:t,padding:r=0}){function i(i){let s=n(i.placement),c=o(r),l=a(t.getBoundingClientRect());if(s===`top`||s===`bottom`){let t=i.rects.reference.x+i.rects.reference.width/2-i.x-l.width/2,n=c.left,r=e(t,n,Math.max(n,i.rects.floating.width-l.width-c.right));return{data:{arrow:{centerOffset:t-r,constrained:r!==t,x:r}}}}let u=i.rects.reference.y+i.rects.reference.height/2-i.y-l.height/2,d=c.top,f=e(u,d,Math.max(d,i.rects.floating.height-l.height-c.bottom));return{data:{arrow:{centerOffset:u-f,constrained:f!==u,y:f}}}}return i}var K=[`top`,`right`,`bottom`,`left`];function q(e){return e===void 0?K:e===null?K.flatMap(e=>[e,`${e}-start`,`${e}-end`]):K.map(t=>`${t}-${e}`)}function J(e={}){return function(t){let{boundary:n,padding:r}=k(e,t),i=e.allowedPlacements??q(e.alignment);i.length;let a=t.placement,o=1/0,s=-1/0;for(let c of i){let i=M(I(t,c,e)),l=F(t,c,n,r);(i<o||i===o&&l>s)&&(a=c,o=i,s=l)}if(a!==t.placement)return{reset:{placement:a}}}}function Y(e={}){function a(a){let o=L(a,e);if(!N(o))return;let s=n(a.placement),c=r(a.placement),l=e.fallbackPlacements??[i(t[s],c)],u=[a.placement],d=a.placement,f=M(o);for(let t of l){let n=I(a,t,e),r=M(n);if(!N(n))return{data:{flip:{skippedPlacements:u}},reset:{placement:t}};u.push(t),r<f&&(d=t,f=r)}if(d!==a.placement)return{data:{flip:{skippedPlacements:u}},reset:{placement:d}}}return a}function X(e={}){let t=e.strategy??`both`;function n(n){let{boundary:r,padding:i}=k(e,n),a={};if(t===`escaped`||t===`both`){let e=A(n),t=j(e,r,i);a.escaped=P(e,t),a.escapedOffsets=t}if(t===`referenceHidden`||t===`both`){let e=j(n.rects.reference,r,i);a.referenceHidden=P(n.rects.reference,e),a.referenceHiddenOffsets=e}return{data:{hide:a}}}return n}function Z(e,t){let n=typeof e==`function`?e(t):e;return typeof n==`number`?{crossAxis:0,mainAxis:n}:{crossAxis:n.crossAxis??0,mainAxis:n.mainAxis??0}}function Q(e){return function(t){let r=n(t.placement),{crossAxis:i,mainAxis:a}=Z(e,t);switch(r){case`bottom`:return{x:t.x+i,y:t.y+a};case`left`:return{x:t.x-a,y:t.y+i};case`right`:return{x:t.x+a,y:t.y+i};case`top`:return{x:t.x+i,y:t.y-a}}}}function $(t={}){return(r,i)=>{let{placement:a,rects:o,x:s,y:c}=r,l=n(a),u=l===`top`||l===`bottom`,d=typeof t.offset==`function`?t.offset(r):t.offset??0;if(u){let t=o.reference.x-d,n=o.reference.x+o.reference.width+d-o.floating.width,[r,a]=t<=n?[t,n]:[n,t],c=e(s+i.crossAxis,r,a);return{...i,crossAxis:c-s}}let f=o.reference.y-d,p=o.reference.y+o.reference.height+d-o.floating.height,[m,h]=f<=p?[f,p]:[p,f],g=e(c+i.crossAxis,m,h);return{...i,crossAxis:g-c}}}function ee(e={}){let{crossAxis:t=!0,limiter:r,mainAxis:i=!1}=e;function a(a){let o=L(a,e),s=n(a.placement),c=s===`top`||s===`bottom`,l=Math.max(o.left,0)-Math.max(o.right,0),u=Math.max(o.top,0)-Math.max(o.bottom,0),d=c?t:i,f=c?i:t,p=d?l:0,m=f?u:0;if(r){let e=r(a,{crossAxis:c?p:m,mainAxis:c?m:p});p=c?e.crossAxis:e.mainAxis,m=c?e.mainAxis:e.crossAxis}return{data:{shift:{x:p,y:m}},x:a.x+p,y:a.y+m}}return a}function te(e={}){function t(t){let{boundary:r,padding:i}=k(e,t),a=n(t.placement),o=r.y+i.top,s=r.x+r.width-i.right,c=r.y+r.height-i.bottom,l=r.x+i.left;return{data:{size:{availableHeight:a===`bottom`?Math.max(0,c-t.y):a===`top`?Math.max(0,t.rects.reference.y-o):Math.max(0,c-o),availableWidth:a===`right`?Math.max(0,s-t.x):a===`left`?Math.max(0,t.rects.reference.x-l):Math.max(0,s-l)}}}}return t}exports.OrbitConfigError=h,exports.OrbitError=m,exports.arrow=G,exports.autoPlacement=J,exports.autoUpdate=p,exports.computePosition=y,exports.createPositioner=B,exports.detectOverflow=L,exports.flip=Y,exports.getAlignment=r,exports.getClippingAncestorRect=O,exports.getSide=n,exports.hide=X,exports.inline=W,exports.limitShift=$,exports.offset=Q,exports.shift=ee,exports.size=te;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@vielzeug/arsenal");var t={bottom:`top`,left:`right`,right:`left`,top:`bottom`};function getSide(e){return e.split(`-`)[0]}function getAlignment(e){return e.split(`-`)[1]??null}function withPlacement(e,t){return t?`${e}-${t}`:e}function toRect({height:e,width:t,x:n,y:r}){return{height:e,width:t,x:n,y:r}}function toSideObject(e=0){return typeof e==`number`?{bottom:e,left:e,right:e,top:e}:{bottom:e.bottom??0,left:e.left??0,right:e.right??0,top:e.top??0}}function isElement(e){return typeof Element<`u`&&e instanceof Element}function flatTreeParent(e){return e.assignedSlot?e.assignedSlot:e.parentElement??(e.getRootNode()instanceof ShadowRoot?e.getRootNode().host:null)}function alignedOffset(e,t,n,r){return e===`start`?t:e===`end`?t+n-r:t+(n-r)/2}function baseCoords(e,t,n){let r=getSide(e),i=getAlignment(e);switch(r){case`bottom`:return{x:alignedOffset(i,t.x,t.width,n.width),y:t.y+t.height};case`left`:return{x:t.x-n.width,y:alignedOffset(i,t.y,t.height,n.height)};case`right`:return{x:t.x+t.width,y:alignedOffset(i,t.y,t.height,n.height)};case`top`:return{x:alignedOffset(i,t.x,t.width,n.width),y:t.y-n.height}}}function throttle(e,t){let n,r=0,throttled=(()=>{let i=Date.now(),a=t-(i-r);if(a<=0){n!==void 0&&clearTimeout(n),n=void 0,r=i,e();return}n===void 0&&(n=setTimeout(()=>{n=void 0,r=Date.now(),e()},a))});return throttled.cancel=()=>{n!==void 0&&clearTimeout(n),n=void 0},throttled}function getScrollAncestors(e){let t=[],n=flatTreeParent(e);for(;n;){let e=getComputedStyle(n),r=e.overflow+e.overflowX+e.overflowY;/auto|scroll|overlay/.test(r)&&t.push(n),n=flatTreeParent(n)}return t}function autoUpdate(e,t,n,{animationFrame:r=!1,observeAncestors:i=!0,observeFloating:a=!0,observeVisualViewport:o=!0,pauseWhenHidden:s=!0,throttle:c=0}={}){let l=c>0?throttle(n,c):null,u=l??n,d=!0,conditionalNotify=()=>{d&&u()};u();let f=[];if(s&&isElement(e)&&typeof IntersectionObserver<`u`){let t=new IntersectionObserver(e=>{d=e.at(-1)?.isIntersecting??!0,d&&u()});t.observe(e),f.push(()=>t.disconnect())}if(isElement(e)&&i){let t=getScrollAncestors(e);for(let e of t)e.addEventListener(`scroll`,conditionalNotify,{passive:!0}),f.push(()=>e.removeEventListener(`scroll`,conditionalNotify));window.addEventListener(`scroll`,conditionalNotify,{passive:!0}),f.push(()=>window.removeEventListener(`scroll`,conditionalNotify))}else{let scrollHandler=e=>{e.composedPath().includes(t)||conditionalNotify()};window.addEventListener(`scroll`,scrollHandler,{capture:!0,passive:!0}),f.push(()=>window.removeEventListener(`scroll`,scrollHandler,{capture:!0}))}window.addEventListener(`resize`,conditionalNotify,{passive:!0}),f.push(()=>window.removeEventListener(`resize`,conditionalNotify));let p=o?window.visualViewport:null;p&&(p.addEventListener(`resize`,conditionalNotify,{passive:!0}),p.addEventListener(`scroll`,conditionalNotify,{passive:!0}),f.push(()=>{p.removeEventListener(`resize`,conditionalNotify),p.removeEventListener(`scroll`,conditionalNotify)}));let m=new ResizeObserver(conditionalNotify);isElement(e)&&m.observe(e),a&&m.observe(t),f.push(()=>m.disconnect());let h=0;if(r){let frameLoop=()=>{conditionalNotify(),h=window.requestAnimationFrame(frameLoop)};h=window.requestAnimationFrame(frameLoop),f.push(()=>window.cancelAnimationFrame(h))}return()=>{l?.cancel();for(let e of f)e()}}var OrbitError=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},OrbitConfigError=class extends OrbitError{};function getRects(e,t){return{floating:toRect(t.getBoundingClientRect()),reference:toRect(e.getBoundingClientRect())}}function mergeState(e,t){return t?{...e,middlewareData:t.data?Object.assign(Object.create(null),e.middlewareData,t.data):e.middlewareData,placement:t.placement??e.placement,x:t.x??e.x,y:t.y??e.y}:e}var n=8;function computePosition(e,t,{boundary:r,containingBlock:i,middleware:a=[],padding:o,placement:s=`bottom`}={}){let c=a,l=s,u={},d=getRects(e,t);for(let a=0;a<n;a+=1){let n={...baseCoords(l,d.reference,d.floating),boundary:r,elements:{floating:t,reference:e},initialPlacement:s,middlewareData:u,padding:o,placement:l,rects:d},a;for(let e of c){let t=e(n);if(n=mergeState(n,t),u=n.middlewareData,a=t?.reset,a)break}if(!a){let e={middlewareData:n.middlewareData,placement:n.placement,x:n.x,y:n.y};if(i){let t=i.getBoundingClientRect();return{...e,x:e.x-t.x,y:e.y-t.y}}return e}a.remeasure?d=getRects(e,t):a.rects!=null&&(d=a.rects),l=a.placement??n.placement}throw new OrbitConfigError(`Middleware triggered too many resets in a single compute cycle.`)}var r=[`transform`,`perspective`,`filter`],i=[`layout`,`paint`,`strict`,`content`];function establishesFixedContainingBlock(e){return e.transform!==`none`||e.perspective!==`none`||e.filter!==`none`||e.backdropFilter&&e.backdropFilter!==`none`||e.willChange!==`auto`&&r.some(t=>e.willChange.includes(t))?!0:e.contain!==`none`&&i.some(t=>e.contain.includes(t))}function getContainingBlock(e){let t=flatTreeParent(e);for(;t;){if(establishesFixedContainingBlock(getComputedStyle(t)))return t;t=flatTreeParent(t)}return null}function getViewportRect(){let e=window.visualViewport;return e?{height:e.height,width:e.width,x:e.offsetLeft,y:e.offsetTop}:{height:window.innerHeight,width:window.innerWidth,x:0,y:0}}function getBoundaryRect(e){if(!e)return getViewportRect();if(e instanceof Element){let t=e.getBoundingClientRect();return{height:t.height,width:t.width,x:t.x,y:t.y}}return e}var a=/(hidden|clip|scroll|auto|overlay)/;function intersectRect(e,t){let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),i=Math.min(e.x+e.width,t.x+t.width),a=Math.min(e.y+e.height,t.y+t.height);return{height:Math.max(0,a-r),width:Math.max(0,i-n),x:n,y:r}}function getClippingAncestorRect(e){let t=flatTreeParent(e),n=getViewportRect();for(;t;){let e=getComputedStyle(t);if(a.test(`${e.overflow}${e.overflowX}${e.overflowY}`)){let e=t.getBoundingClientRect();n=intersectRect(n,{height:e.height,width:e.width,x:e.x,y:e.y})}t=flatTreeParent(t)}return n}function resolveBoundary(e,t){return{boundary:getBoundaryRect(e.boundary??t.boundary),padding:toSideObject(e.padding??t.padding)}}function getFloatingRect(e){return{...e.rects.floating,x:e.x,y:e.y}}function detectOverflowAtRect(e,t,n){return{bottom:e.y+e.height-(t.y+t.height-n.bottom),left:t.x+n.left-e.x,right:e.x+e.width-(t.x+t.width-n.right),top:t.y+n.top-e.y}}function totalOverflow(e){return Math.max(e.top,0)+Math.max(e.right,0)+Math.max(e.bottom,0)+Math.max(e.left,0)}function hasOverflow(e){return e.top>0||e.right>0||e.bottom>0||e.left>0}function isFullyClipped(e,t){return t.top>=e.height||t.right>=e.width||t.bottom>=e.height||t.left>=e.width}function getAvailableSpace(e,t,n,r){let i=e.rects.reference;switch(getSide(t)){case`bottom`:return n.y+n.height-r.bottom-(i.y+i.height);case`left`:return i.x-(n.x+r.left);case`right`:return n.x+n.width-r.right-(i.x+i.width);case`top`:return i.y-(n.y+r.top)}}function getPlacementOverflow(e,t,n={}){let{x:r,y:i}=baseCoords(t,e.rects.reference,e.rects.floating),{boundary:a,padding:o}=resolveBoundary(n,e);return detectOverflowAtRect({...e.rects.floating,x:r,y:i},a,o)}function detectOverflow(e,t={}){let{boundary:n,padding:r}=resolveBoundary(t,e);return detectOverflowAtRect(getFloatingRect(e),n,r)}function resolveContainingBlock(e,t){return t===`absolute`?e.offsetParent instanceof Element?e.offsetParent:null:getContainingBlock(e)}function applyDefault(e,t,n){t.style.position=n,t.style.left=`${e.x}px`,t.style.top=`${e.y}px`}function createPositioner(e,t,{apply:n,autoUpdate:r={},boundary:i=`clippingAncestors`,middleware:a,padding:o,placement:s=`bottom`,strategy:c=`fixed`}={}){let l=new AbortController,u=!0,d=!1,f,p;function update(){if(!u)return;let r=resolveContainingBlock(t,c),l=computePosition(e,t,{boundary:i===`clippingAncestors`?getClippingAncestorRect(t):i,containingBlock:r,middleware:a,padding:o,placement:s});p=l,(n??(e=>applyDefault(e,t,c)))(l)}let m={get disposalSignal(){return l.signal},dispose(){d||(d=!0,u=!1,l.abort(),f?.())},get disposed(){return d},getPosition:()=>p,[Symbol.dispose](){this.dispose()},update(){d||update()}};return r===!1?update():f=autoUpdate(e,t,update,r),m}function getClientRects(e){return!(`getClientRects`in e)||typeof e.getClientRects!=`function`?[]:Array.from(e.getClientRects()).map(toRect).filter(e=>e.width>0||e.height>0)}function rectContainsPoint(e,t,n,r){return t>=e.x-r.left&&t<=e.x+e.width+r.right&&n>=e.y-r.top&&n<=e.y+e.height+r.bottom}function sameRect(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function inline(e={}){function inlineMiddleware(t){let n=getClientRects(t.elements.reference);if(n.length<=1)return;let r=toSideObject(e.padding??2),i=getSide(t.placement),a=n[0];if(e.x!=null&&e.y!=null)a=n.find(t=>rectContainsPoint(t,e.x,e.y,r))??a;else if(i===`top`||i===`bottom`){let e=t.x+t.rects.floating.width/2;a=n.reduce((t,n)=>{let r=Math.abs(t.x+t.width/2-e);return Math.abs(n.x+n.width/2-e)<r?n:t},a)}else{let e=t.y+t.rects.floating.height/2;a=n.reduce((t,n)=>{let r=Math.abs(t.y+t.height/2-e);return Math.abs(n.y+n.height/2-e)<r?n:t},a)}if(!sameRect(a,t.rects.reference))return{reset:{rects:{...t.rects,reference:a}}}}return inlineMiddleware}function arrow({element:t,padding:n=0}){function arrowMiddleware(r){let i=getSide(r.placement),a=toSideObject(n),o=toRect(t.getBoundingClientRect());if(i===`top`||i===`bottom`){let t=r.rects.reference.x+r.rects.reference.width/2-r.x-o.width/2,n=a.left,i=Math.max(n,r.rects.floating.width-o.width-a.right),s=(0,e.clamp)(t,n,i);return{data:{arrow:{centerOffset:t-s,constrained:s!==t,x:s}}}}let s=r.rects.reference.y+r.rects.reference.height/2-r.y-o.height/2,c=a.top,l=Math.max(c,r.rects.floating.height-o.height-a.bottom),u=(0,e.clamp)(s,c,l);return{data:{arrow:{centerOffset:s-u,constrained:u!==s,y:u}}}}return arrowMiddleware}var o=[`top`,`right`,`bottom`,`left`];function getDefaultPlacements(e){return e===void 0?o:e===null?o.flatMap(e=>[e,`${e}-start`,`${e}-end`]):o.map(t=>`${t}-${e}`)}function autoPlacement(e={}){return function autoPlacementMiddleware(t){let{boundary:n,padding:r}=resolveBoundary(e,t),i=e.allowedPlacements??getDefaultPlacements(e.alignment);i.length;let a=t.placement,o=1/0,s=-1/0;for(let c of i){let i=totalOverflow(getPlacementOverflow(t,c,e)),l=getAvailableSpace(t,c,n,r);(i<o||i===o&&l>s)&&(a=c,o=i,s=l)}if(a!==t.placement)return{reset:{placement:a}}}}function flip(e={}){function flipMiddleware(n){let r=detectOverflow(n,e);if(!hasOverflow(r))return;let i=getSide(n.placement),a=getAlignment(n.placement),o=e.fallbackPlacements??[withPlacement(t[i],a)],s=[n.placement],c=n.placement,l=totalOverflow(r);for(let t of o){let r=getPlacementOverflow(n,t,e),i=totalOverflow(r);if(!hasOverflow(r))return{data:{flip:{skippedPlacements:s}},reset:{placement:t}};s.push(t),i<l&&(c=t,l=i)}if(c!==n.placement)return{data:{flip:{skippedPlacements:s}},reset:{placement:c}}}return flipMiddleware}function hide(e={}){let t=e.strategy??`both`;function hideMiddleware(n){let{boundary:r,padding:i}=resolveBoundary(e,n),a={};if(t===`escaped`||t===`both`){let e=getFloatingRect(n),t=detectOverflowAtRect(e,r,i);a.escaped=isFullyClipped(e,t),a.escapedOffsets=t}if(t===`referenceHidden`||t===`both`){let e=detectOverflowAtRect(n.rects.reference,r,i);a.referenceHidden=isFullyClipped(n.rects.reference,e),a.referenceHiddenOffsets=e}return{data:{hide:a}}}return hideMiddleware}function resolveOffsetConfig(e,t){let n=typeof e==`function`?e(t):e;return typeof n==`number`?{crossAxis:0,mainAxis:n}:{crossAxis:n.crossAxis??0,mainAxis:n.mainAxis??0}}function offset(e){return function offsetMiddleware(t){let n=getSide(t.placement),{crossAxis:r,mainAxis:i}=resolveOffsetConfig(e,t);switch(n){case`bottom`:return{x:t.x+r,y:t.y+i};case`left`:return{x:t.x-i,y:t.y+r};case`right`:return{x:t.x+i,y:t.y+r};case`top`:return{x:t.x+r,y:t.y-i}}}}function limitShift(t={}){return(n,r)=>{let{placement:i,rects:a,x:o,y:s}=n,c=getSide(i),l=c===`top`||c===`bottom`,u=typeof t.offset==`function`?t.offset(n):t.offset??0;if(l){let t=a.reference.x-u,n=a.reference.x+a.reference.width+u-a.floating.width,[i,s]=t<=n?[t,n]:[n,t],c=(0,e.clamp)(o+r.crossAxis,i,s);return{...r,crossAxis:c-o}}let d=a.reference.y-u,f=a.reference.y+a.reference.height+u-a.floating.height,[p,m]=d<=f?[d,f]:[f,d],h=(0,e.clamp)(s+r.crossAxis,p,m);return{...r,crossAxis:h-s}}}function shift(e={}){let{crossAxis:t=!0,limiter:n,mainAxis:r=!1}=e;function shiftMiddleware(i){let a=detectOverflow(i,e),o=getSide(i.placement),s=o===`top`||o===`bottom`,c=Math.max(a.left,0)-Math.max(a.right,0),l=Math.max(a.top,0)-Math.max(a.bottom,0),u=s?t:r,d=s?r:t,f=u?c:0,p=d?l:0;if(n){let e=n(i,{crossAxis:s?f:p,mainAxis:s?p:f});f=s?e.crossAxis:e.mainAxis,p=s?e.mainAxis:e.crossAxis}return{data:{shift:{x:f,y:p}},x:i.x+f,y:i.y+p}}return shiftMiddleware}function size(e={}){function sizeMiddleware(t){let{boundary:n,padding:r}=resolveBoundary(e,t),i=getSide(t.placement),a=n.y+r.top,o=n.x+n.width-r.right,s=n.y+n.height-r.bottom,c=n.x+r.left;return{data:{size:{availableHeight:i===`bottom`?Math.max(0,s-t.y):i===`top`?Math.max(0,t.rects.reference.y-a):Math.max(0,s-a),availableWidth:i===`right`?Math.max(0,o-t.x):i===`left`?Math.max(0,t.rects.reference.x-c):Math.max(0,o-c)}}}}return sizeMiddleware}exports.OrbitConfigError=OrbitConfigError,exports.OrbitError=OrbitError,exports.arrow=arrow,exports.autoPlacement=autoPlacement,exports.autoUpdate=autoUpdate,exports.computePosition=computePosition,exports.createPositioner=createPositioner,exports.detectOverflow=detectOverflow,exports.flip=flip,exports.getAlignment=getAlignment,exports.getBoundaryRect=getBoundaryRect,exports.getClippingAncestorRect=getClippingAncestorRect,exports.getSide=getSide,exports.hide=hide,exports.inline=inline,exports.limitShift=limitShift,exports.offset=offset,exports.shift=shift,exports.size=size;
2
2
  //# sourceMappingURL=orbit.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"orbit.cjs","names":[],"sources":["../src/utils.ts","../src/auto-update.ts","../src/_dev.ts","../src/errors.ts","../src/core.ts","../src/containing-block.ts","../src/overflow.ts","../src/float.ts","../src/inline.ts","../src/middleware/arrow.ts","../src/middleware/auto-placement.ts","../src/middleware/flip.ts","../src/middleware/hide.ts","../src/middleware/offset.ts","../src/middleware/shift.ts","../src/middleware/size.ts"],"sourcesContent":["import type { Alignment, Padding, Placement, Rect, Side, SideObject } from './types';\n\nexport function clamp(value: number, min: number, max: number): number {\n return Math.min(Math.max(value, min), max);\n}\n\nexport const OPPOSITE: Record<Side, Side> = { bottom: 'top', left: 'right', right: 'left', top: 'bottom' };\n\n/** Returns the primary side of a placement (`'top' | 'bottom' | 'left' | 'right'`). */\nexport function getSide(p: Placement): Side {\n return p.split('-')[0] as Side;\n}\n\n/** Returns the alignment of a placement (`'start' | 'end'`), or `null` for center placements. */\nexport function getAlignment(p: Placement): Alignment | null {\n return (p.split('-')[1] as Alignment) ?? null;\n}\n\n/** @internal */\nexport function withPlacement(side: Side, align: Alignment | null): Placement {\n return (align ? `${side}-${align}` : side) as Placement;\n}\n\n/** @internal */\nexport function toRect({ height, width, x, y }: DOMRect | Rect): Rect {\n return { height, width, x, y };\n}\n\n/** @internal */\nexport function toSideObject(padding: Padding = 0): SideObject {\n if (typeof padding === 'number') {\n return { bottom: padding, left: padding, right: padding, top: padding };\n }\n\n return {\n bottom: padding.bottom ?? 0,\n left: padding.left ?? 0,\n right: padding.right ?? 0,\n top: padding.top ?? 0,\n };\n}\n\n/** @internal */\nexport function isElement(value: unknown): value is Element {\n return typeof Element !== 'undefined' && value instanceof Element;\n}\n\n/**\n * Returns `node`'s parent in the flat (rendering) tree — the tree CSS layout, paint, and\n * containing-block rules actually walk, which is *not* the same as light-DOM `parentElement`:\n *\n * - If `node` is itself distributed into a `<slot>` (`node.assignedSlot` is set), its rendered\n * parent is that `<slot>`, which lives inside the shadow tree that projects it — not wherever\n * `node.parentElement` points in the light DOM. Skipping this check would walk straight past\n * the shadow host and out into *its* light-DOM ancestors, missing every ancestor between the\n * `<slot>` and the shadow root (a dialog's `.panel`, say) entirely.\n * - Otherwise, falls back to `parentElement`, or — once that's exhausted at a shadow root\n * boundary — the shadow root's host, so the walk continues past shadow boundaries instead of\n * stopping there.\n *\n * `null` once it reaches a true root.\n * @internal\n */\nexport function flatTreeParent(node: Element): Element | null {\n if (node.assignedSlot) return node.assignedSlot;\n\n return (\n node.parentElement ?? (node.getRootNode() instanceof ShadowRoot ? (node.getRootNode() as ShadowRoot).host : null)\n );\n}\n\n// ── Geometry ──────────────────────────────────────────────────────────────────\n\nfunction alignedOffset(align: Alignment | null, refStart: number, refSize: number, floatSize: number): number {\n if (align === 'start') return refStart;\n\n if (align === 'end') return refStart + refSize - floatSize;\n\n return refStart + (refSize - floatSize) / 2;\n}\n\n/**\n * Computes the base (un-shifted) x/y coordinates for a floating element\n * given the placement and the reference/floating rects.\n * @internal\n */\nexport function baseCoords(placement: Placement, ref: Rect, float: Rect): { x: number; y: number } {\n const side = getSide(placement);\n const align = getAlignment(placement);\n\n switch (side) {\n case 'bottom':\n return { x: alignedOffset(align, ref.x, ref.width, float.width), y: ref.y + ref.height };\n case 'left':\n return { x: ref.x - float.width, y: alignedOffset(align, ref.y, ref.height, float.height) };\n case 'right':\n return { x: ref.x + ref.width, y: alignedOffset(align, ref.y, ref.height, float.height) };\n case 'top':\n return { x: alignedOffset(align, ref.x, ref.width, float.width), y: ref.y - float.height };\n }\n}\n","import type { ReferenceElement } from './types';\n\nimport { flatTreeParent, isElement } from './utils';\n\ntype ThrottledUpdate = (() => void) & { cancel(): void };\n\nfunction throttle(update: () => void, delay: number): ThrottledUpdate {\n let timer: ReturnType<typeof setTimeout> | undefined;\n let lastCall = 0;\n\n const throttled = (() => {\n const now = Date.now();\n const remaining = delay - (now - lastCall);\n\n if (remaining <= 0) {\n if (timer !== undefined) clearTimeout(timer);\n\n timer = undefined;\n lastCall = now;\n update();\n\n return;\n }\n\n if (timer !== undefined) return;\n\n timer = setTimeout(() => {\n timer = undefined;\n lastCall = Date.now();\n update();\n }, remaining);\n }) as ThrottledUpdate;\n\n throttled.cancel = (): void => {\n if (timer !== undefined) clearTimeout(timer);\n\n timer = undefined;\n };\n\n return throttled;\n}\n\nexport interface AutoUpdateOptions {\n /** Re-position on every animation frame. Use only when the reference itself animates. Default: `false`. */\n animationFrame?: boolean;\n /**\n * Listen to scroll events on ancestor scroll containers of the reference element\n * in addition to the window. More efficient in deeply nested DOMs.\n * Set to `false` to use only a capture-phase window listener.\n * Default: `true`.\n */\n observeAncestors?: boolean;\n /** Watch the floating element for size changes. Default: `true`. */\n observeFloating?: boolean;\n /** Track visual viewport scroll and resize (useful for pinch-zoom). Default: `true`. */\n observeVisualViewport?: boolean;\n /**\n * Pause position updates while the reference element is scrolled out of the viewport.\n * Uses IntersectionObserver to detect visibility. When the reference becomes visible again,\n * one position update is fired immediately.\n * Default: `true`.\n */\n pauseWhenHidden?: boolean;\n /**\n * Throttle update calls to at most once every `throttle` milliseconds.\n * Uses a leading + trailing strategy: fires immediately, then once more after the interval.\n * Default: `0` (no throttling).\n */\n throttle?: number;\n}\n\n/**\n * Collects the ancestor scroll containers of an element (up to and including the\n * nearest scrollable ancestor). Used to scope scroll listeners to the minimal\n * set of elements rather than relying on a capture-phase window listener.\n *\n * Walks the flat (rendering) tree via `flatTreeParent` — not light-DOM `parentElement` alone —\n * so a scroll container that lives inside the shadow tree a component's light-DOM content is\n * *projected into* (e.g. a dialog's own internal scroll region, reached only by crossing its\n * `<slot>`) is still found, instead of silently skipped.\n */\nfunction getScrollAncestors(el: Element): Element[] {\n const ancestors: Element[] = [];\n let current: Element | null = flatTreeParent(el);\n\n while (current) {\n const style = getComputedStyle(current);\n const overflow = style.overflow + style.overflowX + style.overflowY;\n\n if (/auto|scroll|overlay/.test(overflow)) {\n ancestors.push(current);\n }\n\n current = flatTreeParent(current);\n }\n\n return ancestors;\n}\n\n/**\n * Calls `update` immediately and re-calls it whenever the reference or floating element\n * could have changed position: scroll, resize, ResizeObserver, or animation frames.\n *\n * By default, scroll listeners are attached to both ancestor scroll containers of the reference\n * AND the window (for document scroll). The ancestor listeners fire for nested container scrolls;\n * the window listener fires for page-level scroll. Set `observeAncestors: false` to use only a\n * capture-phase window listener.\n *\n * Returns a cleanup function that removes all listeners.\n *\n * @example\n * ```ts\n * const cleanup = autoUpdate(reference, floating, () => {\n * const { x, y } = computePosition(reference, floating, options);\n * floating.style.left = `${x}px`;\n * floating.style.top = `${y}px`;\n * });\n * // later:\n * cleanup();\n * ```\n */\nexport function autoUpdate(\n reference: ReferenceElement,\n floating: HTMLElement,\n update: () => void,\n {\n animationFrame = false,\n observeAncestors = true,\n observeFloating = true,\n observeVisualViewport = true,\n pauseWhenHidden = true,\n throttle: throttleMs = 0,\n }: AutoUpdateOptions = {},\n): () => void {\n const throttled = throttleMs > 0 ? throttle(update, throttleMs) : null;\n const notify = throttled ?? update;\n\n // ── Visibility guard ─────────────────────────────────────────────────────────\n let referenceVisible = true;\n const conditionalNotify = (): void => {\n if (referenceVisible) notify();\n };\n\n // Initial call always runs regardless of visibility state.\n notify();\n\n const cleanups: Array<() => void> = [];\n\n // IntersectionObserver: pause updates when reference is off-screen.\n if (pauseWhenHidden && isElement(reference) && typeof IntersectionObserver !== 'undefined') {\n const io = new IntersectionObserver((entries) => {\n referenceVisible = entries.at(-1)?.isIntersecting ?? true;\n\n if (referenceVisible) notify(); // Re-position immediately when becoming visible.\n });\n\n io.observe(reference);\n cleanups.push(() => io.disconnect());\n }\n\n // ── Scroll listeners ────────────────────────────────────────────────────────\n if (isElement(reference) && observeAncestors) {\n // Targeted ancestor listeners for nested container scroll.\n const ancestors = getScrollAncestors(reference);\n\n for (const ancestor of ancestors) {\n ancestor.addEventListener('scroll', conditionalNotify, { passive: true });\n cleanups.push(() => ancestor.removeEventListener('scroll', conditionalNotify));\n }\n\n // Always add window scroll for document-level scroll (non-capture, doesn't fire for nested containers).\n window.addEventListener('scroll', conditionalNotify, { passive: true });\n cleanups.push(() => window.removeEventListener('scroll', conditionalNotify));\n } else {\n // VirtualReference or observeAncestors: false — capture-phase window listener catches all scrolls.\n const scrollHandler = (e: Event): void => {\n if (e.composedPath().includes(floating)) return;\n\n conditionalNotify();\n };\n\n window.addEventListener('scroll', scrollHandler, { capture: true, passive: true });\n cleanups.push(() => window.removeEventListener('scroll', scrollHandler, { capture: true }));\n }\n\n window.addEventListener('resize', conditionalNotify, { passive: true });\n cleanups.push(() => window.removeEventListener('resize', conditionalNotify));\n\n const vv = observeVisualViewport ? window.visualViewport : null;\n\n if (vv) {\n vv.addEventListener('resize', conditionalNotify, { passive: true });\n vv.addEventListener('scroll', conditionalNotify, { passive: true });\n cleanups.push(() => {\n vv.removeEventListener('resize', conditionalNotify);\n vv.removeEventListener('scroll', conditionalNotify);\n });\n }\n\n const ro = new ResizeObserver(conditionalNotify);\n\n if (isElement(reference)) ro.observe(reference);\n\n if (observeFloating) ro.observe(floating);\n\n cleanups.push(() => ro.disconnect());\n\n let frameId = 0;\n\n if (animationFrame) {\n const frameLoop = (): void => {\n conditionalNotify();\n frameId = window.requestAnimationFrame(frameLoop);\n };\n\n frameId = window.requestAnimationFrame(frameLoop);\n cleanups.push(() => window.cancelAnimationFrame(frameId));\n }\n\n return (): void => {\n throttled?.cancel();\n\n for (const fn of cleanups) fn();\n };\n}\n","const isDev = !(globalThis as { __ORBIT_PROD__?: boolean }).__ORBIT_PROD__;\n\n/** @internal @security Messages may include user-supplied element dimensions or computed styles. */\nexport function warn(msg: string): void {\n if (isDev) console.warn(`[@vielzeug/orbit] ${msg}`);\n}\n\n/** @internal — Run fn only in dev builds. Use when dev-only logic goes beyond a single warn() / error() call. */\nexport function devOnly(fn: () => void): void {\n if (isDev) fn();\n}\n","/** Base class for all orbit errors. Use `instanceof OrbitError` to catch any orbit-originated error. */\nexport class OrbitError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Thrown when a middleware pipeline is configured incorrectly. */\nexport class OrbitConfigError extends OrbitError {}\n","import { devOnly, warn } from './_dev';\nimport { OrbitConfigError } from './errors';\nimport type {\n ComputePositionOptions,\n ComputePositionResult,\n MiddlewareData,\n MiddlewareReset,\n MiddlewareResult,\n MiddlewareState,\n ReferenceElement,\n} from './types';\nimport { baseCoords, toRect } from './utils';\n\n// ── DOM helpers ────────────────────────────────────────────────────────────────────────────────\n\n/** Reads the bounding rects of the reference and floating elements from the DOM. */\nfunction getRects(reference: ReferenceElement, floating: HTMLElement): MiddlewareState['rects'] {\n return {\n floating: toRect(floating.getBoundingClientRect()),\n reference: toRect(reference.getBoundingClientRect()),\n };\n}\n\n// ── Internal state helpers ───────────────────────────────────────────────────────────\n\nfunction mergeState(state: MiddlewareState, result: MiddlewareResult | undefined): MiddlewareState {\n if (!result) return state;\n\n return {\n ...state,\n middlewareData: result.data\n ? (Object.assign(Object.create(null), state.middlewareData, result.data) as MiddlewareData)\n : state.middlewareData,\n placement: result.placement ?? state.placement,\n x: result.x ?? state.x,\n y: result.y ?? state.y,\n };\n}\n\n// ── Constants ─────────────────────────────────────────────────────────────────────────────────\n\n/** Maximum number of pipeline restarts allowed per `computePosition` call before throwing. */\nconst MAX_RESETS = 8;\n\n// ── Public API ────────────────────────────────────────────────────────────────────────────────\n\n/**\n * Runs the middleware pipeline and returns the final position.\n *\n * Position is computed in viewport-relative coordinates assuming `position: fixed`.\n */\nexport function computePosition(\n reference: ReferenceElement,\n floating: HTMLElement,\n { boundary, containingBlock, middleware = [], padding, placement = 'bottom' }: ComputePositionOptions = {},\n): ComputePositionResult {\n const mws = middleware;\n\n if (reference === floating) {\n warn('computePosition: reference and floating are the same element.');\n }\n\n let currentPlacement = placement;\n let middlewareData: MiddlewareData = {};\n let rects = getRects(reference, floating);\n\n devOnly(() => {\n if (rects.floating.width === 0 && rects.floating.height === 0) {\n warn('computePosition: floating element has zero dimensions — is it hidden or detached from the DOM?');\n }\n\n const pos = getComputedStyle(floating).position;\n\n if (pos !== 'fixed' && pos !== 'absolute') {\n warn(\n `computePosition: floating element has \\`position: ${pos}\\`. ` +\n 'Orbit computes viewport-relative coordinates and expects position: fixed ' +\n '(or absolute for scoped stacking contexts).',\n );\n }\n });\n\n for (let resets = 0; resets < MAX_RESETS; resets += 1) {\n let state: MiddlewareState = {\n ...baseCoords(currentPlacement, rects.reference, rects.floating),\n boundary,\n elements: { floating, reference },\n initialPlacement: placement,\n middlewareData,\n padding,\n placement: currentPlacement,\n rects,\n };\n\n let reset: MiddlewareReset | undefined;\n\n for (const mw of mws) {\n const result = mw(state);\n\n state = mergeState(state, result);\n middlewareData = state.middlewareData;\n reset = result?.reset;\n\n if (reset) break;\n }\n\n if (!reset) {\n const result: ComputePositionResult = {\n middlewareData: state.middlewareData,\n placement: state.placement,\n x: state.x,\n y: state.y,\n };\n\n if (containingBlock) {\n const cb = containingBlock.getBoundingClientRect();\n\n return { ...result, x: result.x - cb.x, y: result.y - cb.y };\n }\n\n return result;\n }\n\n if (reset.remeasure) {\n rects = getRects(reference, floating);\n } else if (reset.rects != null) {\n rects = reset.rects;\n }\n\n currentPlacement = reset.placement ?? state.placement;\n }\n\n throw new OrbitConfigError('Middleware triggered too many resets in a single compute cycle.');\n}\n","/**\n * @vielzeug/orbit — containing-block detection for `position: fixed` elements.\n */\n\nimport { flatTreeParent } from './utils';\n\nconst WILL_CHANGE_TRAPS = ['transform', 'perspective', 'filter'];\nconst CONTAIN_TRAPS = ['layout', 'paint', 'strict', 'content'];\n\n/**\n * True if `style` makes its element a containing block for `position: fixed` descendants, per\n * the CSS Transforms spec: a non-`none` `transform`, `perspective`, or `filter`; a non-`none`\n * `backdrop-filter`; a `will-change` naming one of those three properties; or a `contain` value\n * that affects layout or paint.\n */\nfunction establishesFixedContainingBlock(style: CSSStyleDeclaration): boolean {\n if (style.transform !== 'none') return true;\n\n if (style.perspective !== 'none') return true;\n\n if (style.filter !== 'none') return true;\n\n if (style.backdropFilter && style.backdropFilter !== 'none') return true;\n\n if (style.willChange !== 'auto' && WILL_CHANGE_TRAPS.some((prop) => style.willChange.includes(prop))) return true;\n\n return style.contain !== 'none' && CONTAIN_TRAPS.some((keyword) => style.contain.includes(keyword));\n}\n\n/**\n * Walks up from `element` (crossing shadow boundaries via the flat tree) to find the nearest\n * ancestor that establishes a containing block for `position: fixed` descendants. Returns `null`\n * when none is found — the common case, meaning the true viewport is the containing block.\n *\n * `Element.offsetParent` can't answer this: browsers report it as `null` unconditionally for\n * `position: fixed` elements, without accounting for a transformed ancestor — even though the\n * CSS Transforms spec says that ancestor *does* become the containing block once it has a\n * non-`none` `transform`/`filter`/`perspective`/`backdrop-filter` (even a visually-identity one,\n * e.g. `transform: scale(1)` left over from an entrance transition that never resets to `none` at\n * rest). A `position: fixed` floating element nested inside such an ancestor — a modal dialog's\n * panel is the classic case — has its `left`/`top` resolved against *that* ancestor's box instead\n * of the viewport, silently mispositioning it even though the coordinates computed for it were\n * correct viewport-relative values.\n *\n * Pass the result as `containingBlock` to `computePosition()` to correct for this.\n *\n * @example\n * ```ts\n * const containingBlock = getContainingBlock(floatingEl);\n * computePosition(reference, floating, { containingBlock, placement: 'bottom-start' });\n * ```\n */\nexport function getContainingBlock(element: Element): Element | null {\n let node = flatTreeParent(element);\n\n while (node) {\n if (establishesFixedContainingBlock(getComputedStyle(node))) return node;\n\n node = flatTreeParent(node);\n }\n\n return null;\n}\n","/**\n * @vielzeug/orbit — overflow-detection helpers.\n *\n * Imported by both `core.ts` (for `detectOverflow`) and middleware modules.\n * Middleware should import from here instead of reaching into core internals.\n */\n\nimport type { DetectOverflowOptions, MiddlewareState, Placement, Rect, SideObject } from './types';\n\nimport { baseCoords, flatTreeParent, getSide, toSideObject } from './utils';\n\n// ── Boundary ──────────────────────────────────────────────────────────────────\n\nfunction getViewportRect(): Rect {\n const vv = window.visualViewport;\n\n if (vv) return { height: vv.height, width: vv.width, x: vv.offsetLeft, y: vv.offsetTop };\n\n return { height: window.innerHeight, width: window.innerWidth, x: 0, y: 0 };\n}\n\n/** Resolve a boundary option to a plain Rect. Defaults to the visual viewport. */\nexport function getBoundaryRect(boundary?: Element | Rect): Rect {\n if (!boundary) return getViewportRect();\n\n if (boundary instanceof Element) {\n const r = boundary.getBoundingClientRect();\n\n return { height: r.height, width: r.width, x: r.x, y: r.y };\n }\n\n return boundary as Rect;\n}\n\nconst CLIPPING_OVERFLOW = /(hidden|clip|scroll|auto|overlay)/;\n\nfunction intersectRect(a: Rect, b: Rect): Rect {\n const x = Math.max(a.x, b.x);\n const y = Math.max(a.y, b.y);\n const right = Math.min(a.x + a.width, b.x + b.width);\n const bottom = Math.min(a.y + a.height, b.y + b.height);\n\n return { height: Math.max(0, bottom - y), width: Math.max(0, right - x), x, y };\n}\n\n/**\n * Walks up from `element` (crossing shadow boundaries via the flat tree) collecting every\n * ancestor whose `overflow`/`overflow-x`/`overflow-y` clips content — `hidden`, `clip`, `scroll`,\n * `auto`, or `overlay` — intersecting each one's rect into a running result (the nearest,\n * most-restrictive ancestor wins, same model real CSS clipping uses). Always intersects with the\n * viewport too, so the result never exceeds it even when no clipping ancestor is found.\n *\n * Pass this as `boundary` to `flip`/`shift`/`size` so a floating element nested inside a\n * scrollable region or a dialog panel stays within *that* container — which is what a user\n * actually sees as \"the edge\" — instead of only avoiding the full page viewport, which the\n * floating element can still be well inside while visibly overhanging a much smaller ancestor.\n *\n * @example\n * ```ts\n * const boundary = getClippingAncestorRect(floatingEl);\n * computePosition(reference, floating, { boundary, middleware: [flip(), shift()] });\n * ```\n */\nexport function getClippingAncestorRect(element: Element): Rect {\n let node = flatTreeParent(element);\n let rect = getViewportRect();\n\n while (node) {\n const style = getComputedStyle(node);\n\n if (CLIPPING_OVERFLOW.test(`${style.overflow}${style.overflowX}${style.overflowY}`)) {\n const r = node.getBoundingClientRect();\n\n rect = intersectRect(rect, { height: r.height, width: r.width, x: r.x, y: r.y });\n }\n\n node = flatTreeParent(node);\n }\n\n return rect;\n}\n\n/**\n * Resolves the effective boundary and padding for a middleware, falling back from\n * per-middleware `options` to the global `state.boundary` / `state.padding` defaults.\n * @internal\n */\nexport function resolveBoundary(\n options: DetectOverflowOptions,\n state: Pick<MiddlewareState, 'boundary' | 'padding'>,\n): { boundary: Rect; padding: SideObject } {\n return {\n boundary: getBoundaryRect(options.boundary ?? state.boundary),\n padding: toSideObject(options.padding ?? state.padding),\n };\n}\n\n// ── Floating rect at current position ────────────────────────────────────────\n\n/** The floating element's rect using the current computed x/y from state. */\nexport function getFloatingRect(state: MiddlewareState): Rect {\n return { ...state.rects.floating, x: state.x, y: state.y };\n}\n\n// ── Per-side overflow ─────────────────────────────────────────────────────────\n\n/** How many pixels each side of `rect` overflows `boundary` (adjusted by `padding`). Negative = no overflow. */\nexport function detectOverflowAtRect(rect: Rect, boundary: Rect, padding: SideObject): SideObject {\n return {\n bottom: rect.y + rect.height - (boundary.y + boundary.height - padding.bottom),\n left: boundary.x + padding.left - rect.x,\n right: rect.x + rect.width - (boundary.x + boundary.width - padding.right),\n top: boundary.y + padding.top - rect.y,\n };\n}\n\n/** Sum of positive overflows on all sides. */\nexport function totalOverflow(overflow: SideObject): number {\n return (\n Math.max(overflow.top, 0) + Math.max(overflow.right, 0) + Math.max(overflow.bottom, 0) + Math.max(overflow.left, 0)\n );\n}\n\n/** True if any side has positive overflow. */\nexport function hasOverflow(overflow: SideObject): boolean {\n return overflow.top > 0 || overflow.right > 0 || overflow.bottom > 0 || overflow.left > 0;\n}\n\n/**\n * True if the rect is fully clipped (hidden) by the overflow on any axis.\n * Used by `hide` middleware.\n */\nexport function isFullyClipped(rect: Rect, overflow: SideObject): boolean {\n return (\n overflow.top >= rect.height ||\n overflow.right >= rect.width ||\n overflow.bottom >= rect.height ||\n overflow.left >= rect.width\n );\n}\n\n// ── Placement-specific helpers ────────────────────────────────────────────────\n\n/** Available space in pixels between the reference and the boundary on the given placement's side. */\nexport function getAvailableSpace(\n state: MiddlewareState,\n placement: Placement,\n boundary: Rect,\n padding: SideObject,\n): number {\n const ref = state.rects.reference;\n const side = getSide(placement);\n\n switch (side) {\n case 'bottom':\n return boundary.y + boundary.height - padding.bottom - (ref.y + ref.height);\n case 'left':\n return ref.x - (boundary.x + padding.left);\n case 'right':\n return boundary.x + boundary.width - padding.right - (ref.x + ref.width);\n case 'top':\n return ref.y - (boundary.y + padding.top);\n }\n}\n\n/**\n * Overflow of the floating element if it were positioned at `placement`\n * using base (un-shifted) coordinates, before any middleware adjustments.\n */\nexport function getPlacementOverflow(\n state: MiddlewareState,\n placement: Placement,\n options: DetectOverflowOptions = {},\n): SideObject {\n const { x, y } = baseCoords(placement, state.rects.reference, state.rects.floating);\n const { boundary, padding } = resolveBoundary(options, state);\n const rect = { ...state.rects.floating, x, y };\n\n return detectOverflowAtRect(rect, boundary, padding);\n}\n\n/** Overflow of the floating element at its current position in the middleware pipeline. */\nexport function detectOverflow(state: MiddlewareState, options: DetectOverflowOptions = {}): SideObject {\n const { boundary, padding } = resolveBoundary(options, state);\n\n return detectOverflowAtRect(getFloatingRect(state), boundary, padding);\n}\n","import { type AutoUpdateOptions, autoUpdate } from './auto-update';\nimport { getContainingBlock } from './containing-block';\nimport { computePosition } from './core';\nimport { getClippingAncestorRect } from './overflow';\nimport type { ComputePositionOptions, ComputePositionResult, ReferenceElement } from './types';\n\nexport type PositionStrategy = 'absolute' | 'fixed';\n\nexport interface PositionerOptions extends Omit<ComputePositionOptions, 'boundary' | 'containingBlock'> {\n apply?: (result: ComputePositionResult) => void;\n autoUpdate?: AutoUpdateOptions | false;\n boundary?: ComputePositionOptions['boundary'] | 'clippingAncestors';\n strategy?: PositionStrategy;\n}\n\nexport interface Positioner {\n readonly disposalSignal: AbortSignal;\n dispose(): void;\n readonly disposed: boolean;\n getPosition(): ComputePositionResult | null;\n start(): void;\n update(): void;\n [Symbol.dispose](): void;\n}\n\nfunction resolveContainingBlock(floating: HTMLElement, strategy: PositionStrategy): Element | null {\n if (strategy === 'absolute') return floating.offsetParent instanceof Element ? floating.offsetParent : null;\n\n return getContainingBlock(floating);\n}\n\n/** @internal — default apply: sets position, left, top on the floating element. */\nexport function applyDefault(result: ComputePositionResult, floating: HTMLElement, strategy: PositionStrategy): void {\n floating.style.position = strategy;\n floating.style.left = `${result.x}px`;\n floating.style.top = `${result.y}px`;\n}\n\n/**\n * Creates a lifecycle-owned floating positioner.\n *\n * The positioner owns coordinate strategy, clipping-boundary resolution, updates, and cleanup.\n * Call `start()` once the elements are mounted, then call `dispose()` when their owner ends.\n */\nexport function createPositioner(\n reference: ReferenceElement,\n floating: HTMLElement,\n {\n apply,\n autoUpdate: autoUpdateOptions = {},\n boundary: boundaryOption = 'clippingAncestors',\n middleware,\n padding,\n placement = 'bottom',\n strategy = 'fixed',\n }: PositionerOptions = {},\n): Positioner {\n const controller = new AbortController();\n let active = true;\n let disposed = false;\n let cleanup: (() => void) | undefined;\n let lastPosition: ComputePositionResult | null = null;\n let started = false;\n\n function update(): void {\n if (!active) return;\n\n const containingBlock = resolveContainingBlock(floating, strategy);\n const boundary = boundaryOption === 'clippingAncestors' ? getClippingAncestorRect(floating) : boundaryOption;\n const result = computePosition(reference, floating, { boundary, containingBlock, middleware, padding, placement });\n\n lastPosition = result;\n (apply ?? ((position) => applyDefault(position, floating, strategy)))(result);\n }\n\n function start(): void {\n if (started || disposed) return;\n\n started = true;\n\n if (autoUpdateOptions === false) update();\n else cleanup = autoUpdate(reference, floating, update, autoUpdateOptions);\n }\n\n return {\n get disposalSignal() {\n return controller.signal;\n },\n dispose() {\n if (disposed) return;\n\n disposed = true;\n active = false;\n controller.abort();\n cleanup?.();\n },\n get disposed() {\n return disposed;\n },\n getPosition: () => lastPosition,\n start,\n [Symbol.dispose]() {\n this.dispose();\n },\n update() {\n if (!disposed) update();\n },\n };\n}\n","import type { Middleware, Padding, Rect, ReferenceElement } from './types';\n\nimport { getSide, toRect, toSideObject } from './utils';\n\n// ── Private helpers (only used by inline) ────────────────────────────────────────────\n\nfunction getClientRects(reference: ReferenceElement): Rect[] {\n if (!('getClientRects' in reference) || typeof reference.getClientRects !== 'function') return [];\n\n return Array.from((reference.getClientRects as () => DOMRectList | DOMRect[])())\n .map(toRect)\n .filter((r) => r.width > 0 || r.height > 0);\n}\n\nfunction rectContainsPoint(rect: Rect, x: number, y: number, padding: ReturnType<typeof toSideObject>): boolean {\n return (\n x >= rect.x - padding.left &&\n x <= rect.x + rect.width + padding.right &&\n y >= rect.y - padding.top &&\n y <= rect.y + rect.height + padding.bottom\n );\n}\n\nfunction sameRect(a: Rect, b: Rect): boolean {\n return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;\n}\n\n// ── Inline middleware ─────────────────────────────────────────────────────────────────\n\nexport interface InlineOptions {\n /**\n * Padding used when hit-testing cursor coordinates against client rects.\n * Prevents snapping when the cursor is just outside a rect edge. Default: `2`.\n *\n * @remarks Only applies when both `x` and `y` are provided.\n */\n padding?: Padding;\n /**\n * Cursor x-coordinate. When provided alongside `y`, the middleware picks the\n * client rect that contains the cursor instead of the closest rect to the floating element.\n */\n x?: number;\n /** Cursor y-coordinate. */\n y?: number;\n}\n\n/**\n * Improves positioning accuracy for inline references that span multiple lines\n * (e.g. `<span>` wrapping across line breaks).\n *\n * Must be placed **before** `flip()` and other middleware in the pipeline.\n *\n * @example Tooltip on selected text:\n * ```ts\n * import { createPositioner, inline, flip, shift } from '@vielzeug/orbit';\n *\n * const positioner = createPositioner(selectionRef, tooltip, {\n * placement: 'top',\n * middleware: [inline({ x: cursorX, y: cursorY }), flip(), shift({ padding: 6 })],\n * });\n * positioner.start();\n * ```\n */\nexport function inline(options: InlineOptions = {}): Middleware {\n function inlineMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const rects = getClientRects(state.elements.reference);\n\n if (rects.length <= 1) return;\n\n const padding = toSideObject(options.padding ?? 2);\n const side = getSide(state.placement);\n let nextRect = rects[0]!;\n\n if (options.x != null && options.y != null) {\n nextRect = rects.find((rect) => rectContainsPoint(rect, options.x!, options.y!, padding)) ?? nextRect;\n } else if (side === 'top' || side === 'bottom') {\n const targetX = state.x + state.rects.floating.width / 2;\n\n nextRect = rects.reduce((best, rect) => {\n const bestDist = Math.abs(best.x + best.width / 2 - targetX);\n const rectDist = Math.abs(rect.x + rect.width / 2 - targetX);\n\n return rectDist < bestDist ? rect : best;\n }, nextRect);\n } else {\n const targetY = state.y + state.rects.floating.height / 2;\n\n nextRect = rects.reduce((best, rect) => {\n const bestDist = Math.abs(best.y + best.height / 2 - targetY);\n const rectDist = Math.abs(rect.y + rect.height / 2 - targetY);\n\n return rectDist < bestDist ? rect : best;\n }, nextRect);\n }\n\n if (sameRect(nextRect, state.rects.reference)) return;\n\n return { reset: { rects: { ...state.rects, reference: nextRect } } };\n }\n\n return inlineMiddleware;\n}\n","import type { Middleware, Padding } from '../types';\n\nimport { clamp, getSide, toRect, toSideObject } from '../utils';\n\nexport interface ArrowOptions {\n /** The arrow DOM element. Must be a child of the floating element. */\n element: HTMLElement;\n /** Padding to keep the arrow from the floating element's corners. */\n padding?: Padding;\n}\n\n/**\n * Positions an arrow element inside the floating element, pointed toward the reference.\n * Writes `{ x?, y?, centerOffset }` to `middlewareData.arrow`.\n *\n * Must come **after** flip(), shift(), and autoPlacement() in the middleware pipeline.\n *\n * @example\n * ```ts\n * const result = computePosition(ref, floating, {\n * middleware: [offset(8), flip(), shift(), arrow({ element: arrowEl })],\n * });\n * const { x, y } = result.middlewareData.arrow!;\n * arrowEl.style.left = x != null ? `${x}px` : '';\n * arrowEl.style.top = y != null ? `${y}px` : '';\n * ```\n */\nexport function arrow({ element, padding = 0 }: ArrowOptions): Middleware {\n function arrowMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const side = getSide(state.placement);\n const inset = toSideObject(padding);\n const arrowRect = toRect(element.getBoundingClientRect());\n\n if (side === 'top' || side === 'bottom') {\n const idealX = state.rects.reference.x + state.rects.reference.width / 2 - state.x - arrowRect.width / 2;\n const minX = inset.left;\n const maxX = Math.max(minX, state.rects.floating.width - arrowRect.width - inset.right);\n const x = clamp(idealX, minX, maxX);\n\n return { data: { arrow: { centerOffset: idealX - x, constrained: x !== idealX, x } } };\n }\n\n const idealY = state.rects.reference.y + state.rects.reference.height / 2 - state.y - arrowRect.height / 2;\n const minY = inset.top;\n const maxY = Math.max(minY, state.rects.floating.height - arrowRect.height - inset.bottom);\n const y = clamp(idealY, minY, maxY);\n\n return { data: { arrow: { centerOffset: idealY - y, constrained: y !== idealY, y } } };\n }\n\n return arrowMiddleware;\n}\n","import { warn } from '../_dev';\nimport { getAvailableSpace, getPlacementOverflow, resolveBoundary, totalOverflow } from '../overflow';\nimport type { Alignment, DetectOverflowOptions, Middleware, Placement, Side } from '../types';\n\nexport interface AutoPlacementOptions extends DetectOverflowOptions {\n /**\n * Constrains auto-placement to variants with the given alignment.\n *\n * - `'start'` — evaluates only `top-start`, `right-start`, `bottom-start`, `left-start`.\n * - `'end'` — evaluates only `top-end`, `right-end`, `bottom-end`, `left-end`.\n * - `null` — evaluates all 12 variants (4 cardinal + 4 start + 4 end).\n * - omitted (default) — evaluates the 4 cardinal sides only.\n */\n alignment?: Alignment | null;\n /**\n * Placements to evaluate. When provided, takes precedence over `alignment`.\n * Note: use either `flip` or `autoPlacement`, not both.\n */\n allowedPlacements?: Placement[];\n}\n\nconst SIDES: Side[] = ['top', 'right', 'bottom', 'left'];\n\nfunction getDefaultPlacements(alignment?: Alignment | null): Placement[] {\n if (alignment === undefined) return SIDES;\n\n if (alignment === null) {\n return SIDES.flatMap((side) => [side, `${side}-start`, `${side}-end`] as Placement[]);\n }\n\n return SIDES.map((side) => `${side}-${alignment}` as Placement);\n}\n\n/**\n * Automatically selects the placement with the most available space and least overflow.\n * Evaluates all allowed placements and picks the optimal one.\n *\n * Use the `alignment` option to restrict evaluation to aligned variants (e.g. `'start'`)\n * when you want to preserve a consistent alignment across all candidate sides.\n *\n * @see {@link flip} for simple opposite-side flipping.\n */\nexport function autoPlacement(options: AutoPlacementOptions = {}): Middleware {\n return function autoPlacementMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const { boundary, padding } = resolveBoundary(options, state);\n const placements = options.allowedPlacements ?? getDefaultPlacements(options.alignment);\n\n if (placements.length === 0) {\n warn('autoPlacement: allowedPlacements is empty — no placement will be evaluated.');\n }\n\n let bestPlacement = state.placement;\n let bestOverflow = Number.POSITIVE_INFINITY;\n let bestSpace = Number.NEGATIVE_INFINITY;\n\n for (const candidate of placements) {\n const overflow = getPlacementOverflow(state, candidate, options);\n const overflowScore = totalOverflow(overflow);\n const availableSpace = getAvailableSpace(state, candidate, boundary, padding);\n\n if (overflowScore < bestOverflow || (overflowScore === bestOverflow && availableSpace > bestSpace)) {\n bestPlacement = candidate;\n bestOverflow = overflowScore;\n bestSpace = availableSpace;\n }\n }\n\n if (bestPlacement !== state.placement) {\n return { reset: { placement: bestPlacement } };\n }\n };\n}\n","import { detectOverflow, getPlacementOverflow, hasOverflow, totalOverflow } from '../overflow';\nimport type { DetectOverflowOptions, Middleware, Placement } from '../types';\nimport { getAlignment, getSide, OPPOSITE, withPlacement } from '../utils';\n\nexport interface FlipOptions extends DetectOverflowOptions {\n /**\n * Ordered list of candidate placements to try when the floating element overflows.\n * Defaults to the opposite side, preserving the current alignment.\n */\n fallbackPlacements?: Placement[];\n}\n\n/**\n * Flips the floating element to the opposite side when it overflows the boundary.\n * Falls back to the candidate with the least total overflow when no candidate fits.\n */\nexport function flip(options: FlipOptions = {}): Middleware {\n function flipMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const currentOverflow = detectOverflow(state, options);\n\n if (!hasOverflow(currentOverflow)) return;\n\n const side = getSide(state.placement);\n const align = getAlignment(state.placement);\n const fallbackPlacements = options.fallbackPlacements ?? [withPlacement(OPPOSITE[side], align)];\n const skipped: Placement[] = [state.placement];\n let bestPlacement = state.placement;\n let bestScore = totalOverflow(currentOverflow);\n\n for (const candidate of fallbackPlacements) {\n const candidateOverflow = getPlacementOverflow(state, candidate, options);\n const score = totalOverflow(candidateOverflow);\n\n if (!hasOverflow(candidateOverflow)) {\n return {\n data: { flip: { skippedPlacements: skipped } },\n reset: { placement: candidate },\n };\n }\n\n skipped.push(candidate);\n\n if (score < bestScore) {\n bestPlacement = candidate;\n bestScore = score;\n }\n }\n\n if (bestPlacement !== state.placement) {\n return {\n data: { flip: { skippedPlacements: skipped } },\n reset: { placement: bestPlacement },\n };\n }\n }\n\n return flipMiddleware;\n}\n","import { detectOverflowAtRect, getFloatingRect, isFullyClipped, resolveBoundary } from '../overflow';\nimport type { DetectOverflowOptions, HideData, Middleware } from '../types';\n\nexport interface HideOptions extends DetectOverflowOptions {\n /**\n * Which hidden states to compute.\n * - `'referenceHidden'` — whether the reference itself is off-screen.\n * - `'escaped'` — whether the floating element has fully exited the boundary.\n * - `'both'` (default) — both of the above.\n */\n strategy?: 'referenceHidden' | 'escaped' | 'both';\n}\n\n/**\n * Detects when the reference or floating element is hidden outside the boundary.\n * Writes `{ referenceHidden, referenceHiddenOffsets, escaped, escapedOffsets }` to\n * `middlewareData.hide`.\n */\nexport function hide(options: HideOptions = {}): Middleware {\n const strategy = options.strategy ?? 'both';\n\n function hideMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const { boundary, padding } = resolveBoundary(options, state);\n const next: HideData = {};\n\n if (strategy === 'escaped' || strategy === 'both') {\n const floatingRect = getFloatingRect(state);\n const escapedOffsets = detectOverflowAtRect(floatingRect, boundary, padding);\n\n next.escaped = isFullyClipped(floatingRect, escapedOffsets);\n next.escapedOffsets = escapedOffsets;\n }\n\n if (strategy === 'referenceHidden' || strategy === 'both') {\n const referenceHiddenOffsets = detectOverflowAtRect(state.rects.reference, boundary, padding);\n\n next.referenceHidden = isFullyClipped(state.rects.reference, referenceHiddenOffsets);\n next.referenceHiddenOffsets = referenceHiddenOffsets;\n }\n\n return { data: { hide: next } };\n }\n\n return hideMiddleware;\n}\n","import type { Middleware, MiddlewareState } from '../types';\n\nimport { getSide } from '../utils';\n\nexport type OffsetConfig = {\n /** Offset perpendicular to the main axis. */\n crossAxis?: number;\n /** Offset along the axis away from the reference. */\n mainAxis?: number;\n};\n\nexport type OffsetValue = number | OffsetConfig | ((state: MiddlewareState) => number | OffsetConfig);\n\nfunction resolveOffsetConfig(value: OffsetValue, state: MiddlewareState): Required<OffsetConfig> {\n const raw = typeof value === 'function' ? value(state) : value;\n\n if (typeof raw === 'number') return { crossAxis: 0, mainAxis: raw };\n\n return { crossAxis: raw.crossAxis ?? 0, mainAxis: raw.mainAxis ?? 0 };\n}\n\n/**\n * Shifts the floating element along the main axis (away from reference) and/or\n * the cross axis. Accepts a number, config object, or a function for dynamic values.\n *\n * Must be the **first** middleware in the pipeline.\n */\nexport function offset(value: OffsetValue): Middleware {\n return function offsetMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const side = getSide(state.placement);\n const { crossAxis, mainAxis } = resolveOffsetConfig(value, state);\n\n switch (side) {\n case 'bottom':\n return { x: state.x + crossAxis, y: state.y + mainAxis };\n case 'left':\n return { x: state.x - mainAxis, y: state.y + crossAxis };\n case 'right':\n return { x: state.x + mainAxis, y: state.y + crossAxis };\n case 'top':\n return { x: state.x + crossAxis, y: state.y - mainAxis };\n }\n };\n}\n","import { detectOverflow } from '../overflow';\nimport type { DetectOverflowOptions, Middleware, MiddlewareState } from '../types';\nimport { clamp, getSide } from '../utils';\n\n/**\n * A limiter function passed to `shift()` that constrains the maximum allowed drift.\n * Receives the current middleware state and the proposed shift correction (as deltas),\n * and returns the clamped correction.\n */\nexport type ShiftLimiter = (\n state: MiddlewareState,\n correction: { crossAxis: number; mainAxis: number },\n) => { crossAxis: number; mainAxis: number };\n\nexport interface LimitShiftOptions {\n /**\n * Extra pixels of allowed drift past the reference's cross-axis extent before clamping kicks in.\n * Can be a static number or a function returning a number based on current state.\n * Default: `0`.\n */\n offset?: number | ((state: MiddlewareState) => number);\n}\n\n/**\n * Returns a {@link ShiftLimiter} that constrains `shift()` so the floating element\n * stays visually connected to the reference along the cross axis.\n *\n * Without a limiter, `shift()` will push the float as far as needed to fit in the boundary —\n * potentially sliding it far away from the reference. `limitShift` clamps the drift so the\n * float stays within the reference's cross-axis extent (± `offset` pixels).\n *\n * @example\n * ```ts\n * // Tooltip stays above the button even when viewport clips it.\n * shift({ padding: 6, limiter: limitShift() })\n *\n * // Allow up to 10px of drift beyond the reference's edges.\n * shift({ padding: 6, limiter: limitShift({ offset: 10 }) })\n * ```\n */\nexport function limitShift(options: LimitShiftOptions = {}): ShiftLimiter {\n return (state, correction) => {\n const { placement, rects, x, y } = state;\n const side = getSide(placement);\n const isVertical = side === 'top' || side === 'bottom';\n const extra = typeof options.offset === 'function' ? options.offset(state) : (options.offset ?? 0);\n\n if (isVertical) {\n // Cross axis is x. Clamp float.left to [ref.left-extra, ref.right+extra-float.width].\n const lo = rects.reference.x - extra;\n const hi = rects.reference.x + rects.reference.width + extra - rects.floating.width;\n const [min, max] = lo <= hi ? [lo, hi] : [hi, lo];\n const clamped = clamp(x + correction.crossAxis, min, max);\n\n return { ...correction, crossAxis: clamped - x };\n }\n\n // Cross axis is y. Clamp float.top to [ref.top-extra, ref.bottom+extra-float.height].\n const lo = rects.reference.y - extra;\n const hi = rects.reference.y + rects.reference.height + extra - rects.floating.height;\n const [min, max] = lo <= hi ? [lo, hi] : [hi, lo];\n const clamped = clamp(y + correction.crossAxis, min, max);\n\n return { ...correction, crossAxis: clamped - y };\n };\n}\n\nexport interface ShiftOptions extends DetectOverflowOptions {\n /**\n * Whether to shift along the cross axis (perpendicular to the reference direction).\n * Default: `true`.\n */\n crossAxis?: boolean;\n /**\n * Constrains how far `shift()` can move the floating element along the cross axis.\n * Pass `limitShift()` to keep the float within the reference's extent.\n */\n limiter?: ShiftLimiter;\n /**\n * Whether to shift along the main axis (the axis away from the reference).\n * Default: `false` — main-axis overflow is better handled by `flip`.\n */\n mainAxis?: boolean;\n}\n\n/**\n * Shifts the floating element along the cross axis to keep it inside the boundary.\n *\n * By default only the cross axis is corrected. Enable `mainAxis` to also shift\n * along the main axis (useful when `flip` is not in the pipeline).\n *\n * | Placement | Cross axis | Main axis |\n * |------------------|------------|-----------|\n * | `top` / `bottom` | horizontal | vertical |\n * | `left` / `right` | vertical | horizontal|\n */\nexport function shift(options: ShiftOptions = {}): Middleware {\n const { crossAxis = true, limiter, mainAxis = false } = options;\n\n function shiftMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const overflow = detectOverflow(state, options);\n const side = getSide(state.placement);\n const isVertical = side === 'top' || side === 'bottom';\n\n const xCorrection = Math.max(overflow.left, 0) - Math.max(overflow.right, 0);\n const yCorrection = Math.max(overflow.top, 0) - Math.max(overflow.bottom, 0);\n const applyX = isVertical ? crossAxis : mainAxis;\n const applyY = isVertical ? mainAxis : crossAxis;\n\n let dx = applyX ? xCorrection : 0;\n let dy = applyY ? yCorrection : 0;\n\n if (limiter) {\n const limited = limiter(state, {\n crossAxis: isVertical ? dx : dy,\n mainAxis: isVertical ? dy : dx,\n });\n\n dx = isVertical ? limited.crossAxis : limited.mainAxis;\n dy = isVertical ? limited.mainAxis : limited.crossAxis;\n }\n\n return { data: { shift: { x: dx, y: dy } }, x: state.x + dx, y: state.y + dy };\n }\n\n return shiftMiddleware;\n}\n","import { resolveBoundary } from '../overflow';\nimport type { DetectOverflowOptions, Middleware } from '../types';\nimport { getSide } from '../utils';\n\nexport type SizeOptions = DetectOverflowOptions;\n\n/**\n * Reports the available space between the reference and boundary edges.\n *\n * Available dimensions are written to `middlewareData.size`.\n *\n * Read `result.middlewareData.size` in the positioner `apply` option or after `computePosition()`\n * to constrain the floating element's dimensions.\n *\n * @example\n * ```ts\n * const positioner = createPositioner(ref, el, {\n * middleware: [offset(8), flip(), shift(), size()],\n * apply(result) {\n * el.style.maxHeight = `${(result.middlewareData.size as SizeData).availableHeight}px`;\n * },\n * });\n * positioner.start();\n * ```\n */\nexport function size(options: SizeOptions = {}): Middleware {\n function sizeMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const { boundary, padding } = resolveBoundary(options, state);\n const side = getSide(state.placement);\n const top = boundary.y + padding.top;\n const right = boundary.x + boundary.width - padding.right;\n const bottom = boundary.y + boundary.height - padding.bottom;\n const left = boundary.x + padding.left;\n\n const availableHeight =\n side === 'bottom'\n ? Math.max(0, bottom - state.y)\n : side === 'top'\n ? Math.max(0, state.rects.reference.y - top)\n : Math.max(0, bottom - top);\n\n const availableWidth =\n side === 'right'\n ? Math.max(0, right - state.x)\n : side === 'left'\n ? Math.max(0, state.rects.reference.x - left)\n : Math.max(0, right - left);\n\n return { data: { size: { availableHeight, availableWidth } } };\n }\n\n return sizeMiddleware;\n}\n"],"mappings":"mEAEA,SAAgB,EAAM,EAAe,EAAa,EAAqB,CACrE,OAAO,KAAK,IAAI,KAAK,IAAI,EAAO,CAAG,EAAG,CAAG,CAC3C,CAEA,IAAa,EAA+B,CAAE,OAAQ,MAAO,KAAM,QAAS,MAAO,OAAQ,IAAK,QAAS,EAGzG,SAAgB,EAAQ,EAAoB,CAC1C,OAAO,EAAE,MAAM,GAAG,CAAC,CAAC,EACtB,CAGA,SAAgB,EAAa,EAAgC,CAC3D,OAAQ,EAAE,MAAM,GAAG,CAAC,CAAC,IAAoB,IAC3C,CAGA,SAAgB,EAAc,EAAY,EAAoC,CAC5E,OAAQ,EAAQ,GAAG,EAAK,GAAG,IAAU,CACvC,CAGA,SAAgB,EAAO,CAAE,SAAQ,QAAO,IAAG,KAA2B,CACpE,MAAO,CAAE,SAAQ,QAAO,IAAG,GAAE,CAC/B,CAGA,SAAgB,EAAa,EAAmB,EAAe,CAK7D,OAJI,OAAO,GAAY,SACd,CAAE,OAAQ,EAAS,KAAM,EAAS,MAAO,EAAS,IAAK,CAAQ,EAGjE,CACL,OAAQ,EAAQ,QAAU,EAC1B,KAAM,EAAQ,MAAQ,EACtB,MAAO,EAAQ,OAAS,EACxB,IAAK,EAAQ,KAAO,CACtB,CACF,CAGA,SAAgB,EAAU,EAAkC,CAC1D,OAAO,OAAO,QAAY,KAAe,aAAiB,OAC5D,CAkBA,SAAgB,EAAe,EAA+B,CAG5D,OAFI,EAAK,aAAqB,EAAK,aAGjC,EAAK,gBAAkB,EAAK,YAAY,YAAa,WAAc,EAAK,YAAY,CAAC,CAAgB,KA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AAG,EAAS,EAAM,CAAC,EAC5B,IAAS,MACP,KAAK,IAAI,EAAG,EAAM,MAAM,UAAU,EAAI,CAAG,EACzC,KAAK,IAAI,EAAG,EAAS,CAAG,EASU,eANxC,IAAS,QACL,KAAK,IAAI,EAAG,EAAQ,EAAM,CAAC,EAC3B,IAAS,OACP,KAAK,IAAI,EAAG,EAAM,MAAM,UAAU,EAAI,CAAI,EAC1C,KAAK,IAAI,EAAG,EAAQ,CAAI,CAEyB,CAAE,CAAE,CAC/D,CAEA,OAAO,CACT"}
1
+ {"version":3,"file":"orbit.cjs","names":[],"sources":["../src/utils.ts","../src/auto-update.ts","../src/_dev.ts","../src/errors.ts","../src/core.ts","../src/containing-block.ts","../src/overflow.ts","../src/float.ts","../src/inline.ts","../src/middleware/arrow.ts","../src/middleware/auto-placement.ts","../src/middleware/flip.ts","../src/middleware/hide.ts","../src/middleware/offset.ts","../src/middleware/shift.ts","../src/middleware/size.ts"],"sourcesContent":["import type { Alignment, Padding, Placement, Rect, Side, SideObject } from './types';\n\nexport const OPPOSITE: Record<Side, Side> = { bottom: 'top', left: 'right', right: 'left', top: 'bottom' };\n\n/** Returns the primary side of a placement (`'top' | 'bottom' | 'left' | 'right'`). */\nexport function getSide(p: Placement): Side {\n return p.split('-')[0] as Side;\n}\n\n/** Returns the alignment of a placement (`'start' | 'end'`), or `null` for center placements. */\nexport function getAlignment(p: Placement): Alignment | null {\n return (p.split('-')[1] as Alignment) ?? null;\n}\n\n/** @internal */\nexport function withPlacement(side: Side, align: Alignment | null): Placement {\n return (align ? `${side}-${align}` : side) as Placement;\n}\n\n/** @internal */\nexport function toRect({ height, width, x, y }: DOMRect | Rect): Rect {\n return { height, width, x, y };\n}\n\n/** @internal */\nexport function toSideObject(padding: Padding = 0): SideObject {\n if (typeof padding === 'number') {\n return { bottom: padding, left: padding, right: padding, top: padding };\n }\n\n return {\n bottom: padding.bottom ?? 0,\n left: padding.left ?? 0,\n right: padding.right ?? 0,\n top: padding.top ?? 0,\n };\n}\n\n/** @internal */\nexport function isElement(value: unknown): value is Element {\n return typeof Element !== 'undefined' && value instanceof Element;\n}\n\n/**\n * Returns `node`'s parent in the flat (rendering) tree — the tree CSS layout, paint, and\n * containing-block rules actually walk, which is *not* the same as light-DOM `parentElement`:\n *\n * - If `node` is itself distributed into a `<slot>` (`node.assignedSlot` is set), its rendered\n * parent is that `<slot>`, which lives inside the shadow tree that projects it — not wherever\n * `node.parentElement` points in the light DOM. Skipping this check would walk straight past\n * the shadow host and out into *its* light-DOM ancestors, missing every ancestor between the\n * `<slot>` and the shadow root (a dialog's `.panel`, say) entirely.\n * - Otherwise, falls back to `parentElement`, or — once that's exhausted at a shadow root\n * boundary — the shadow root's host, so the walk continues past shadow boundaries instead of\n * stopping there.\n *\n * `null` once it reaches a true root.\n * @internal\n */\nexport function flatTreeParent(node: Element): Element | null {\n if (node.assignedSlot) return node.assignedSlot;\n\n return (\n node.parentElement ?? (node.getRootNode() instanceof ShadowRoot ? (node.getRootNode() as ShadowRoot).host : null)\n );\n}\n\n// ── Geometry ──────────────────────────────────────────────────────────────────\n\nfunction alignedOffset(align: Alignment | null, refStart: number, refSize: number, floatSize: number): number {\n if (align === 'start') return refStart;\n\n if (align === 'end') return refStart + refSize - floatSize;\n\n return refStart + (refSize - floatSize) / 2;\n}\n\n/**\n * Computes the base (un-shifted) x/y coordinates for a floating element\n * given the placement and the reference/floating rects.\n * @internal\n */\nexport function baseCoords(placement: Placement, ref: Rect, float: Rect): { x: number; y: number } {\n const side = getSide(placement);\n const align = getAlignment(placement);\n\n switch (side) {\n case 'bottom':\n return { x: alignedOffset(align, ref.x, ref.width, float.width), y: ref.y + ref.height };\n case 'left':\n return { x: ref.x - float.width, y: alignedOffset(align, ref.y, ref.height, float.height) };\n case 'right':\n return { x: ref.x + ref.width, y: alignedOffset(align, ref.y, ref.height, float.height) };\n case 'top':\n return { x: alignedOffset(align, ref.x, ref.width, float.width), y: ref.y - float.height };\n }\n}\n","import type { ReferenceElement } from './types';\n\nimport { flatTreeParent, isElement } from './utils';\n\ntype ThrottledUpdate = (() => void) & { cancel(): void };\n\nfunction throttle(update: () => void, delay: number): ThrottledUpdate {\n let timer: ReturnType<typeof setTimeout> | undefined;\n let lastCall = 0;\n\n const throttled = (() => {\n const now = Date.now();\n const remaining = delay - (now - lastCall);\n\n if (remaining <= 0) {\n if (timer !== undefined) clearTimeout(timer);\n\n timer = undefined;\n lastCall = now;\n update();\n\n return;\n }\n\n if (timer !== undefined) return;\n\n timer = setTimeout(() => {\n timer = undefined;\n lastCall = Date.now();\n update();\n }, remaining);\n }) as ThrottledUpdate;\n\n throttled.cancel = (): void => {\n if (timer !== undefined) clearTimeout(timer);\n\n timer = undefined;\n };\n\n return throttled;\n}\n\nexport interface AutoUpdateOptions {\n /** Re-position on every animation frame. Use only when the reference itself animates. Default: `false`. */\n animationFrame?: boolean;\n /**\n * Listen to scroll events on ancestor scroll containers of the reference element\n * in addition to the window. More efficient in deeply nested DOMs.\n * Set to `false` to use only a capture-phase window listener.\n * Default: `true`.\n */\n observeAncestors?: boolean;\n /** Watch the floating element for size changes. Default: `true`. */\n observeFloating?: boolean;\n /** Track visual viewport scroll and resize (useful for pinch-zoom). Default: `true`. */\n observeVisualViewport?: boolean;\n /**\n * Pause position updates while the reference element is scrolled out of the viewport.\n * Uses IntersectionObserver to detect visibility. When the reference becomes visible again,\n * one position update is fired immediately.\n * Default: `true`.\n */\n pauseWhenHidden?: boolean;\n /**\n * Throttle update calls to at most once every `throttle` milliseconds.\n * Uses a leading + trailing strategy: fires immediately, then once more after the interval.\n * Default: `0` (no throttling).\n */\n throttle?: number;\n}\n\n/**\n * Collects the ancestor scroll containers of an element (up to and including the\n * nearest scrollable ancestor). Used to scope scroll listeners to the minimal\n * set of elements rather than relying on a capture-phase window listener.\n *\n * Walks the flat (rendering) tree via `flatTreeParent` — not light-DOM `parentElement` alone —\n * so a scroll container that lives inside the shadow tree a component's light-DOM content is\n * *projected into* (e.g. a dialog's own internal scroll region, reached only by crossing its\n * `<slot>`) is still found, instead of silently skipped.\n */\nfunction getScrollAncestors(el: Element): Element[] {\n const ancestors: Element[] = [];\n let current: Element | null = flatTreeParent(el);\n\n while (current) {\n const style = getComputedStyle(current);\n const overflow = style.overflow + style.overflowX + style.overflowY;\n\n if (/auto|scroll|overlay/.test(overflow)) {\n ancestors.push(current);\n }\n\n current = flatTreeParent(current);\n }\n\n return ancestors;\n}\n\n/**\n * Calls `update` immediately and re-calls it whenever the reference or floating element\n * could have changed position: scroll, resize, ResizeObserver, or animation frames.\n *\n * By default, scroll listeners are attached to both ancestor scroll containers of the reference\n * AND the window (for document scroll). The ancestor listeners fire for nested container scrolls;\n * the window listener fires for page-level scroll. Set `observeAncestors: false` to use only a\n * capture-phase window listener.\n *\n * Returns a cleanup function that removes all listeners.\n *\n * @example\n * ```ts\n * const cleanup = autoUpdate(reference, floating, () => {\n * const { x, y } = computePosition(reference, floating, options);\n * floating.style.left = `${x}px`;\n * floating.style.top = `${y}px`;\n * });\n * // later:\n * cleanup();\n * ```\n */\nexport function autoUpdate(\n reference: ReferenceElement,\n floating: HTMLElement,\n update: () => void,\n {\n animationFrame = false,\n observeAncestors = true,\n observeFloating = true,\n observeVisualViewport = true,\n pauseWhenHidden = true,\n throttle: throttleMs = 0,\n }: AutoUpdateOptions = {},\n): () => void {\n const throttled = throttleMs > 0 ? throttle(update, throttleMs) : null;\n const notify = throttled ?? update;\n\n // ── Visibility guard ─────────────────────────────────────────────────────────\n let referenceVisible = true;\n const conditionalNotify = (): void => {\n if (referenceVisible) notify();\n };\n\n // Initial call always runs regardless of visibility state.\n notify();\n\n const cleanups: Array<() => void> = [];\n\n // IntersectionObserver: pause updates when reference is off-screen.\n if (pauseWhenHidden && isElement(reference) && typeof IntersectionObserver !== 'undefined') {\n const io = new IntersectionObserver((entries) => {\n referenceVisible = entries.at(-1)?.isIntersecting ?? true;\n\n if (referenceVisible) notify(); // Re-position immediately when becoming visible.\n });\n\n io.observe(reference);\n cleanups.push(() => io.disconnect());\n }\n\n // ── Scroll listeners ────────────────────────────────────────────────────────\n if (isElement(reference) && observeAncestors) {\n // Targeted ancestor listeners for nested container scroll.\n const ancestors = getScrollAncestors(reference);\n\n for (const ancestor of ancestors) {\n ancestor.addEventListener('scroll', conditionalNotify, { passive: true });\n cleanups.push(() => ancestor.removeEventListener('scroll', conditionalNotify));\n }\n\n // Always add window scroll for document-level scroll (non-capture, doesn't fire for nested containers).\n window.addEventListener('scroll', conditionalNotify, { passive: true });\n cleanups.push(() => window.removeEventListener('scroll', conditionalNotify));\n } else {\n // VirtualReference or observeAncestors: false — capture-phase window listener catches all scrolls.\n const scrollHandler = (e: Event): void => {\n if (e.composedPath().includes(floating)) return;\n\n conditionalNotify();\n };\n\n window.addEventListener('scroll', scrollHandler, { capture: true, passive: true });\n cleanups.push(() => window.removeEventListener('scroll', scrollHandler, { capture: true }));\n }\n\n window.addEventListener('resize', conditionalNotify, { passive: true });\n cleanups.push(() => window.removeEventListener('resize', conditionalNotify));\n\n const vv = observeVisualViewport ? window.visualViewport : null;\n\n if (vv) {\n vv.addEventListener('resize', conditionalNotify, { passive: true });\n vv.addEventListener('scroll', conditionalNotify, { passive: true });\n cleanups.push(() => {\n vv.removeEventListener('resize', conditionalNotify);\n vv.removeEventListener('scroll', conditionalNotify);\n });\n }\n\n const ro = new ResizeObserver(conditionalNotify);\n\n if (isElement(reference)) ro.observe(reference);\n\n if (observeFloating) ro.observe(floating);\n\n cleanups.push(() => ro.disconnect());\n\n let frameId = 0;\n\n if (animationFrame) {\n const frameLoop = (): void => {\n conditionalNotify();\n frameId = window.requestAnimationFrame(frameLoop);\n };\n\n frameId = window.requestAnimationFrame(frameLoop);\n cleanups.push(() => window.cancelAnimationFrame(frameId));\n }\n\n return (): void => {\n throttled?.cancel();\n\n for (const fn of cleanups) fn();\n };\n}\n","const isDev = !(globalThis as { __ORBIT_PROD__?: boolean }).__ORBIT_PROD__;\n\n/** @internal @security Messages may include user-supplied element dimensions or computed styles. */\nexport function warn(msg: string): void {\n if (isDev) console.warn(`[@vielzeug/orbit] ${msg}`);\n}\n\n/** @internal — Run fn only in dev builds. Use when dev-only logic goes beyond a single warn() / error() call. */\nexport function devOnly(fn: () => void): void {\n if (isDev) fn();\n}\n","/** Base class for all orbit errors. Use `instanceof OrbitError` to catch any orbit-originated error. */\nexport class OrbitError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Thrown when a middleware pipeline is configured incorrectly. */\nexport class OrbitConfigError extends OrbitError {}\n","import { devOnly, warn } from './_dev';\nimport { OrbitConfigError } from './errors';\nimport type {\n ComputePositionOptions,\n ComputePositionResult,\n MiddlewareData,\n MiddlewareReset,\n MiddlewareResult,\n MiddlewareState,\n ReferenceElement,\n} from './types';\nimport { baseCoords, toRect } from './utils';\n\n// ── DOM helpers ────────────────────────────────────────────────────────────────────────────────\n\n/** Reads the bounding rects of the reference and floating elements from the DOM. */\nfunction getRects(reference: ReferenceElement, floating: HTMLElement): MiddlewareState['rects'] {\n return {\n floating: toRect(floating.getBoundingClientRect()),\n reference: toRect(reference.getBoundingClientRect()),\n };\n}\n\n// ── Internal state helpers ───────────────────────────────────────────────────────────\n\nfunction mergeState(state: MiddlewareState, result: MiddlewareResult | undefined): MiddlewareState {\n if (!result) return state;\n\n return {\n ...state,\n middlewareData: result.data\n ? (Object.assign(Object.create(null), state.middlewareData, result.data) as MiddlewareData)\n : state.middlewareData,\n placement: result.placement ?? state.placement,\n x: result.x ?? state.x,\n y: result.y ?? state.y,\n };\n}\n\n// ── Constants ─────────────────────────────────────────────────────────────────────────────────\n\n/** Maximum number of pipeline restarts allowed per `computePosition` call before throwing. */\nconst MAX_RESETS = 8;\n\n// ── Public API ────────────────────────────────────────────────────────────────────────────────\n\n/**\n * Runs the middleware pipeline and returns the final position.\n *\n * Position is computed in viewport-relative coordinates assuming `position: fixed`.\n */\nexport function computePosition(\n reference: ReferenceElement,\n floating: HTMLElement,\n { boundary, containingBlock, middleware = [], padding, placement = 'bottom' }: ComputePositionOptions = {},\n): ComputePositionResult {\n const mws = middleware;\n\n if (reference === floating) {\n warn('computePosition: reference and floating are the same element.');\n }\n\n let currentPlacement = placement;\n let middlewareData: MiddlewareData = {};\n let rects = getRects(reference, floating);\n\n devOnly(() => {\n if (rects.floating.width === 0 && rects.floating.height === 0) {\n warn('computePosition: floating element has zero dimensions — is it hidden or detached from the DOM?');\n }\n\n const pos = getComputedStyle(floating).position;\n\n if (pos !== 'fixed' && pos !== 'absolute') {\n warn(\n `computePosition: floating element has \\`position: ${pos}\\`. ` +\n 'Orbit computes viewport-relative coordinates and expects position: fixed ' +\n '(or absolute for scoped stacking contexts).',\n );\n }\n });\n\n for (let resets = 0; resets < MAX_RESETS; resets += 1) {\n let state: MiddlewareState = {\n ...baseCoords(currentPlacement, rects.reference, rects.floating),\n boundary,\n elements: { floating, reference },\n initialPlacement: placement,\n middlewareData,\n padding,\n placement: currentPlacement,\n rects,\n };\n\n let reset: MiddlewareReset | undefined;\n\n for (const mw of mws) {\n const result = mw(state);\n\n state = mergeState(state, result);\n middlewareData = state.middlewareData;\n reset = result?.reset;\n\n if (reset) break;\n }\n\n if (!reset) {\n const result: ComputePositionResult = {\n middlewareData: state.middlewareData,\n placement: state.placement,\n x: state.x,\n y: state.y,\n };\n\n if (containingBlock) {\n const cb = containingBlock.getBoundingClientRect();\n\n return { ...result, x: result.x - cb.x, y: result.y - cb.y };\n }\n\n return result;\n }\n\n if (reset.remeasure) {\n rects = getRects(reference, floating);\n } else if (reset.rects != null) {\n rects = reset.rects;\n }\n\n currentPlacement = reset.placement ?? state.placement;\n }\n\n throw new OrbitConfigError('Middleware triggered too many resets in a single compute cycle.');\n}\n","/**\n * @vielzeug/orbit — containing-block detection for `position: fixed` elements.\n */\n\nimport { flatTreeParent } from './utils';\n\nconst WILL_CHANGE_TRAPS = ['transform', 'perspective', 'filter'];\nconst CONTAIN_TRAPS = ['layout', 'paint', 'strict', 'content'];\n\n/**\n * True if `style` makes its element a containing block for `position: fixed` descendants, per\n * the CSS Transforms spec: a non-`none` `transform`, `perspective`, or `filter`; a non-`none`\n * `backdrop-filter`; a `will-change` naming one of those three properties; or a `contain` value\n * that affects layout or paint.\n */\nfunction establishesFixedContainingBlock(style: CSSStyleDeclaration): boolean {\n if (style.transform !== 'none') return true;\n\n if (style.perspective !== 'none') return true;\n\n if (style.filter !== 'none') return true;\n\n if (style.backdropFilter && style.backdropFilter !== 'none') return true;\n\n if (style.willChange !== 'auto' && WILL_CHANGE_TRAPS.some((prop) => style.willChange.includes(prop))) return true;\n\n return style.contain !== 'none' && CONTAIN_TRAPS.some((keyword) => style.contain.includes(keyword));\n}\n\n/**\n * Walks up from `element` (crossing shadow boundaries via the flat tree) to find the nearest\n * ancestor that establishes a containing block for `position: fixed` descendants. Returns `null`\n * when none is found — the common case, meaning the true viewport is the containing block.\n *\n * `Element.offsetParent` can't answer this: browsers report it as `null` unconditionally for\n * `position: fixed` elements, without accounting for a transformed ancestor — even though the\n * CSS Transforms spec says that ancestor *does* become the containing block once it has a\n * non-`none` `transform`/`filter`/`perspective`/`backdrop-filter` (even a visually-identity one,\n * e.g. `transform: scale(1)` left over from an entrance transition that never resets to `none` at\n * rest). A `position: fixed` floating element nested inside such an ancestor — a modal dialog's\n * panel is the classic case — has its `left`/`top` resolved against *that* ancestor's box instead\n * of the viewport, silently mispositioning it even though the coordinates computed for it were\n * correct viewport-relative values.\n *\n * Pass the result as `containingBlock` to `computePosition()` to correct for this.\n *\n * @example\n * ```ts\n * const containingBlock = getContainingBlock(floatingEl);\n * computePosition(reference, floating, { containingBlock, placement: 'bottom-start' });\n * ```\n */\nexport function getContainingBlock(element: Element): Element | null {\n let node = flatTreeParent(element);\n\n while (node) {\n if (establishesFixedContainingBlock(getComputedStyle(node))) return node;\n\n node = flatTreeParent(node);\n }\n\n return null;\n}\n","/**\n * @vielzeug/orbit — overflow-detection helpers.\n *\n * Imported by both `core.ts` (for `detectOverflow`) and middleware modules.\n * Middleware should import from here instead of reaching into core internals.\n */\n\nimport type { DetectOverflowOptions, MiddlewareState, Placement, Rect, SideObject } from './types';\n\nimport { baseCoords, flatTreeParent, getSide, toSideObject } from './utils';\n\n// ── Boundary ──────────────────────────────────────────────────────────────────\n\nfunction getViewportRect(): Rect {\n const vv = window.visualViewport;\n\n if (vv) return { height: vv.height, width: vv.width, x: vv.offsetLeft, y: vv.offsetTop };\n\n return { height: window.innerHeight, width: window.innerWidth, x: 0, y: 0 };\n}\n\n/** Resolve a boundary option to a plain Rect. Defaults to the visual viewport. */\nexport function getBoundaryRect(boundary?: Element | Rect): Rect {\n if (!boundary) return getViewportRect();\n\n if (boundary instanceof Element) {\n const r = boundary.getBoundingClientRect();\n\n return { height: r.height, width: r.width, x: r.x, y: r.y };\n }\n\n return boundary as Rect;\n}\n\nconst CLIPPING_OVERFLOW = /(hidden|clip|scroll|auto|overlay)/;\n\nfunction intersectRect(a: Rect, b: Rect): Rect {\n const x = Math.max(a.x, b.x);\n const y = Math.max(a.y, b.y);\n const right = Math.min(a.x + a.width, b.x + b.width);\n const bottom = Math.min(a.y + a.height, b.y + b.height);\n\n return { height: Math.max(0, bottom - y), width: Math.max(0, right - x), x, y };\n}\n\n/**\n * Walks up from `element` (crossing shadow boundaries via the flat tree) collecting every\n * ancestor whose `overflow`/`overflow-x`/`overflow-y` clips content — `hidden`, `clip`, `scroll`,\n * `auto`, or `overlay` — intersecting each one's rect into a running result (the nearest,\n * most-restrictive ancestor wins, same model real CSS clipping uses). Always intersects with the\n * viewport too, so the result never exceeds it even when no clipping ancestor is found.\n *\n * Pass this as `boundary` to `flip`/`shift`/`size` so a floating element nested inside a\n * scrollable region or a dialog panel stays within *that* container — which is what a user\n * actually sees as \"the edge\" — instead of only avoiding the full page viewport, which the\n * floating element can still be well inside while visibly overhanging a much smaller ancestor.\n *\n * @example\n * ```ts\n * const boundary = getClippingAncestorRect(floatingEl);\n * computePosition(reference, floating, { boundary, middleware: [flip(), shift()] });\n * ```\n */\nexport function getClippingAncestorRect(element: Element): Rect {\n let node = flatTreeParent(element);\n let rect = getViewportRect();\n\n while (node) {\n const style = getComputedStyle(node);\n\n if (CLIPPING_OVERFLOW.test(`${style.overflow}${style.overflowX}${style.overflowY}`)) {\n const r = node.getBoundingClientRect();\n\n rect = intersectRect(rect, { height: r.height, width: r.width, x: r.x, y: r.y });\n }\n\n node = flatTreeParent(node);\n }\n\n return rect;\n}\n\n/**\n * Resolves the effective boundary and padding for a middleware, falling back from\n * per-middleware `options` to the global `state.boundary` / `state.padding` defaults.\n * @internal\n */\nexport function resolveBoundary(\n options: DetectOverflowOptions,\n state: Pick<MiddlewareState, 'boundary' | 'padding'>,\n): { boundary: Rect; padding: SideObject } {\n return {\n boundary: getBoundaryRect(options.boundary ?? state.boundary),\n padding: toSideObject(options.padding ?? state.padding),\n };\n}\n\n// ── Floating rect at current position ────────────────────────────────────────\n\n/** The floating element's rect using the current computed x/y from state. */\nexport function getFloatingRect(state: MiddlewareState): Rect {\n return { ...state.rects.floating, x: state.x, y: state.y };\n}\n\n// ── Per-side overflow ─────────────────────────────────────────────────────────\n\n/** How many pixels each side of `rect` overflows `boundary` (adjusted by `padding`). Negative = no overflow. */\nexport function detectOverflowAtRect(rect: Rect, boundary: Rect, padding: SideObject): SideObject {\n return {\n bottom: rect.y + rect.height - (boundary.y + boundary.height - padding.bottom),\n left: boundary.x + padding.left - rect.x,\n right: rect.x + rect.width - (boundary.x + boundary.width - padding.right),\n top: boundary.y + padding.top - rect.y,\n };\n}\n\n/** Sum of positive overflows on all sides. */\nexport function totalOverflow(overflow: SideObject): number {\n return (\n Math.max(overflow.top, 0) + Math.max(overflow.right, 0) + Math.max(overflow.bottom, 0) + Math.max(overflow.left, 0)\n );\n}\n\n/** True if any side has positive overflow. */\nexport function hasOverflow(overflow: SideObject): boolean {\n return overflow.top > 0 || overflow.right > 0 || overflow.bottom > 0 || overflow.left > 0;\n}\n\n/**\n * True if the rect is fully clipped (hidden) by the overflow on any axis.\n * Used by `hide` middleware.\n */\nexport function isFullyClipped(rect: Rect, overflow: SideObject): boolean {\n return (\n overflow.top >= rect.height ||\n overflow.right >= rect.width ||\n overflow.bottom >= rect.height ||\n overflow.left >= rect.width\n );\n}\n\n// ── Placement-specific helpers ────────────────────────────────────────────────\n\n/** Available space in pixels between the reference and the boundary on the given placement's side. */\nexport function getAvailableSpace(\n state: MiddlewareState,\n placement: Placement,\n boundary: Rect,\n padding: SideObject,\n): number {\n const ref = state.rects.reference;\n const side = getSide(placement);\n\n switch (side) {\n case 'bottom':\n return boundary.y + boundary.height - padding.bottom - (ref.y + ref.height);\n case 'left':\n return ref.x - (boundary.x + padding.left);\n case 'right':\n return boundary.x + boundary.width - padding.right - (ref.x + ref.width);\n case 'top':\n return ref.y - (boundary.y + padding.top);\n }\n}\n\n/**\n * Overflow of the floating element if it were positioned at `placement`\n * using base (un-shifted) coordinates, before any middleware adjustments.\n */\nexport function getPlacementOverflow(\n state: MiddlewareState,\n placement: Placement,\n options: DetectOverflowOptions = {},\n): SideObject {\n const { x, y } = baseCoords(placement, state.rects.reference, state.rects.floating);\n const { boundary, padding } = resolveBoundary(options, state);\n const rect = { ...state.rects.floating, x, y };\n\n return detectOverflowAtRect(rect, boundary, padding);\n}\n\n/** Overflow of the floating element at its current position in the middleware pipeline. */\nexport function detectOverflow(state: MiddlewareState, options: DetectOverflowOptions = {}): SideObject {\n const { boundary, padding } = resolveBoundary(options, state);\n\n return detectOverflowAtRect(getFloatingRect(state), boundary, padding);\n}\n","import { type AutoUpdateOptions, autoUpdate } from './auto-update';\nimport { getContainingBlock } from './containing-block';\nimport { computePosition } from './core';\nimport { getClippingAncestorRect } from './overflow';\nimport type { ComputePositionOptions, ComputePositionResult, ReferenceElement } from './types';\n\nexport type PositionStrategy = 'absolute' | 'fixed';\n\nexport interface PositionerOptions extends Omit<ComputePositionOptions, 'boundary' | 'containingBlock'> {\n apply?: (result: ComputePositionResult) => void;\n autoUpdate?: AutoUpdateOptions | false;\n boundary?: ComputePositionOptions['boundary'] | 'clippingAncestors';\n strategy?: PositionStrategy;\n}\n\nexport interface Positioner {\n readonly disposalSignal: AbortSignal;\n dispose(): void;\n readonly disposed: boolean;\n getPosition(): ComputePositionResult;\n update(): void;\n [Symbol.dispose](): void;\n}\n\nfunction resolveContainingBlock(floating: HTMLElement, strategy: PositionStrategy): Element | null {\n if (strategy === 'absolute') return floating.offsetParent instanceof Element ? floating.offsetParent : null;\n\n return getContainingBlock(floating);\n}\n\n/** @internal — default apply: sets position, left, top on the floating element. */\nexport function applyDefault(result: ComputePositionResult, floating: HTMLElement, strategy: PositionStrategy): void {\n floating.style.position = strategy;\n floating.style.left = `${result.x}px`;\n floating.style.top = `${result.y}px`;\n}\n\n/**\n * Creates a lifecycle-owned floating positioner.\n *\n * The positioner starts immediately and owns coordinate strategy, clipping-boundary resolution,\n * updates, and cleanup. Create it after the elements mount and dispose it when their owner ends.\n */\nexport function createPositioner(\n reference: ReferenceElement,\n floating: HTMLElement,\n {\n apply,\n autoUpdate: autoUpdateOptions = {},\n boundary: boundaryOption = 'clippingAncestors',\n middleware,\n padding,\n placement = 'bottom',\n strategy = 'fixed',\n }: PositionerOptions = {},\n): Positioner {\n const controller = new AbortController();\n let active = true;\n let disposed = false;\n let cleanup: (() => void) | undefined;\n let lastPosition: ComputePositionResult;\n\n function update(): void {\n if (!active) return;\n\n const containingBlock = resolveContainingBlock(floating, strategy);\n const boundary = boundaryOption === 'clippingAncestors' ? getClippingAncestorRect(floating) : boundaryOption;\n const result = computePosition(reference, floating, { boundary, containingBlock, middleware, padding, placement });\n\n lastPosition = result;\n (apply ?? ((position) => applyDefault(position, floating, strategy)))(result);\n }\n\n const positioner: Positioner = {\n get disposalSignal() {\n return controller.signal;\n },\n dispose() {\n if (disposed) return;\n\n disposed = true;\n active = false;\n controller.abort();\n cleanup?.();\n },\n get disposed() {\n return disposed;\n },\n getPosition: () => lastPosition,\n [Symbol.dispose]() {\n this.dispose();\n },\n update() {\n if (!disposed) update();\n },\n };\n\n if (autoUpdateOptions === false) update();\n else cleanup = autoUpdate(reference, floating, update, autoUpdateOptions);\n\n return positioner;\n}\n","import type { Middleware, Padding, Rect, ReferenceElement } from './types';\n\nimport { getSide, toRect, toSideObject } from './utils';\n\n// ── Private helpers (only used by inline) ────────────────────────────────────────────\n\nfunction getClientRects(reference: ReferenceElement): Rect[] {\n if (!('getClientRects' in reference) || typeof reference.getClientRects !== 'function') return [];\n\n return Array.from((reference.getClientRects as () => DOMRectList | DOMRect[])())\n .map(toRect)\n .filter((r) => r.width > 0 || r.height > 0);\n}\n\nfunction rectContainsPoint(rect: Rect, x: number, y: number, padding: ReturnType<typeof toSideObject>): boolean {\n return (\n x >= rect.x - padding.left &&\n x <= rect.x + rect.width + padding.right &&\n y >= rect.y - padding.top &&\n y <= rect.y + rect.height + padding.bottom\n );\n}\n\nfunction sameRect(a: Rect, b: Rect): boolean {\n return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;\n}\n\n// ── Inline middleware ─────────────────────────────────────────────────────────────────\n\nexport interface InlineOptions {\n /**\n * Padding used when hit-testing cursor coordinates against client rects.\n * Prevents snapping when the cursor is just outside a rect edge. Default: `2`.\n *\n * @remarks Only applies when both `x` and `y` are provided.\n */\n padding?: Padding;\n /**\n * Cursor x-coordinate. When provided alongside `y`, the middleware picks the\n * client rect that contains the cursor instead of the closest rect to the floating element.\n */\n x?: number;\n /** Cursor y-coordinate. */\n y?: number;\n}\n\n/**\n * Improves positioning accuracy for inline references that span multiple lines\n * (e.g. `<span>` wrapping across line breaks).\n *\n * Must be placed **before** `flip()` and other middleware in the pipeline.\n *\n * @example Tooltip on selected text:\n * ```ts\n * import { createPositioner, inline, flip, shift } from '@vielzeug/orbit';\n *\n * const positioner = createPositioner(selectionRef, tooltip, {\n * placement: 'top',\n * middleware: [inline({ x: cursorX, y: cursorY }), flip(), shift({ padding: 6 })],\n * });\n * ```\n */\nexport function inline(options: InlineOptions = {}): Middleware {\n function inlineMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const rects = getClientRects(state.elements.reference);\n\n if (rects.length <= 1) return;\n\n const padding = toSideObject(options.padding ?? 2);\n const side = getSide(state.placement);\n let nextRect = rects[0]!;\n\n if (options.x != null && options.y != null) {\n nextRect = rects.find((rect) => rectContainsPoint(rect, options.x!, options.y!, padding)) ?? nextRect;\n } else if (side === 'top' || side === 'bottom') {\n const targetX = state.x + state.rects.floating.width / 2;\n\n nextRect = rects.reduce((best, rect) => {\n const bestDist = Math.abs(best.x + best.width / 2 - targetX);\n const rectDist = Math.abs(rect.x + rect.width / 2 - targetX);\n\n return rectDist < bestDist ? rect : best;\n }, nextRect);\n } else {\n const targetY = state.y + state.rects.floating.height / 2;\n\n nextRect = rects.reduce((best, rect) => {\n const bestDist = Math.abs(best.y + best.height / 2 - targetY);\n const rectDist = Math.abs(rect.y + rect.height / 2 - targetY);\n\n return rectDist < bestDist ? rect : best;\n }, nextRect);\n }\n\n if (sameRect(nextRect, state.rects.reference)) return;\n\n return { reset: { rects: { ...state.rects, reference: nextRect } } };\n }\n\n return inlineMiddleware;\n}\n","import { clamp } from '@vielzeug/arsenal';\n\nimport type { Middleware, Padding } from '../types';\n\nimport { getSide, toRect, toSideObject } from '../utils';\n\nexport interface ArrowOptions {\n /** The arrow DOM element. Must be a child of the floating element. */\n element: HTMLElement;\n /** Padding to keep the arrow from the floating element's corners. */\n padding?: Padding;\n}\n\n/**\n * Positions an arrow element inside the floating element, pointed toward the reference.\n * Writes `{ x?, y?, centerOffset }` to `middlewareData.arrow`.\n *\n * Must come **after** flip(), shift(), and autoPlacement() in the middleware pipeline.\n *\n * @example\n * ```ts\n * const result = computePosition(ref, floating, {\n * middleware: [offset(8), flip(), shift(), arrow({ element: arrowEl })],\n * });\n * const { x, y } = result.middlewareData.arrow!;\n * arrowEl.style.left = x != null ? `${x}px` : '';\n * arrowEl.style.top = y != null ? `${y}px` : '';\n * ```\n */\nexport function arrow({ element, padding = 0 }: ArrowOptions): Middleware {\n function arrowMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const side = getSide(state.placement);\n const inset = toSideObject(padding);\n const arrowRect = toRect(element.getBoundingClientRect());\n\n if (side === 'top' || side === 'bottom') {\n const idealX = state.rects.reference.x + state.rects.reference.width / 2 - state.x - arrowRect.width / 2;\n const minX = inset.left;\n const maxX = Math.max(minX, state.rects.floating.width - arrowRect.width - inset.right);\n const x = clamp(idealX, minX, maxX);\n\n return { data: { arrow: { centerOffset: idealX - x, constrained: x !== idealX, x } } };\n }\n\n const idealY = state.rects.reference.y + state.rects.reference.height / 2 - state.y - arrowRect.height / 2;\n const minY = inset.top;\n const maxY = Math.max(minY, state.rects.floating.height - arrowRect.height - inset.bottom);\n const y = clamp(idealY, minY, maxY);\n\n return { data: { arrow: { centerOffset: idealY - y, constrained: y !== idealY, y } } };\n }\n\n return arrowMiddleware;\n}\n","import { warn } from '../_dev';\nimport { getAvailableSpace, getPlacementOverflow, resolveBoundary, totalOverflow } from '../overflow';\nimport type { Alignment, DetectOverflowOptions, Middleware, Placement, Side } from '../types';\n\nexport interface AutoPlacementOptions extends DetectOverflowOptions {\n /**\n * Constrains auto-placement to variants with the given alignment.\n *\n * - `'start'` — evaluates only `top-start`, `right-start`, `bottom-start`, `left-start`.\n * - `'end'` — evaluates only `top-end`, `right-end`, `bottom-end`, `left-end`.\n * - `null` — evaluates all 12 variants (4 cardinal + 4 start + 4 end).\n * - omitted (default) — evaluates the 4 cardinal sides only.\n */\n alignment?: Alignment | null;\n /**\n * Placements to evaluate. When provided, takes precedence over `alignment`.\n * Note: use either `flip` or `autoPlacement`, not both.\n */\n allowedPlacements?: Placement[];\n}\n\nconst SIDES: Side[] = ['top', 'right', 'bottom', 'left'];\n\nfunction getDefaultPlacements(alignment?: Alignment | null): Placement[] {\n if (alignment === undefined) return SIDES;\n\n if (alignment === null) {\n return SIDES.flatMap((side) => [side, `${side}-start`, `${side}-end`] as Placement[]);\n }\n\n return SIDES.map((side) => `${side}-${alignment}` as Placement);\n}\n\n/**\n * Automatically selects the placement with the most available space and least overflow.\n * Evaluates all allowed placements and picks the optimal one.\n *\n * Use the `alignment` option to restrict evaluation to aligned variants (e.g. `'start'`)\n * when you want to preserve a consistent alignment across all candidate sides.\n *\n * @see {@link flip} for simple opposite-side flipping.\n */\nexport function autoPlacement(options: AutoPlacementOptions = {}): Middleware {\n return function autoPlacementMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const { boundary, padding } = resolveBoundary(options, state);\n const placements = options.allowedPlacements ?? getDefaultPlacements(options.alignment);\n\n if (placements.length === 0) {\n warn('autoPlacement: allowedPlacements is empty — no placement will be evaluated.');\n }\n\n let bestPlacement = state.placement;\n let bestOverflow = Number.POSITIVE_INFINITY;\n let bestSpace = Number.NEGATIVE_INFINITY;\n\n for (const candidate of placements) {\n const overflow = getPlacementOverflow(state, candidate, options);\n const overflowScore = totalOverflow(overflow);\n const availableSpace = getAvailableSpace(state, candidate, boundary, padding);\n\n if (overflowScore < bestOverflow || (overflowScore === bestOverflow && availableSpace > bestSpace)) {\n bestPlacement = candidate;\n bestOverflow = overflowScore;\n bestSpace = availableSpace;\n }\n }\n\n if (bestPlacement !== state.placement) {\n return { reset: { placement: bestPlacement } };\n }\n };\n}\n","import { detectOverflow, getPlacementOverflow, hasOverflow, totalOverflow } from '../overflow';\nimport type { DetectOverflowOptions, Middleware, Placement } from '../types';\nimport { getAlignment, getSide, OPPOSITE, withPlacement } from '../utils';\n\nexport interface FlipOptions extends DetectOverflowOptions {\n /**\n * Ordered list of candidate placements to try when the floating element overflows.\n * Defaults to the opposite side, preserving the current alignment.\n */\n fallbackPlacements?: Placement[];\n}\n\n/**\n * Flips the floating element to the opposite side when it overflows the boundary.\n * Falls back to the candidate with the least total overflow when no candidate fits.\n */\nexport function flip(options: FlipOptions = {}): Middleware {\n function flipMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const currentOverflow = detectOverflow(state, options);\n\n if (!hasOverflow(currentOverflow)) return;\n\n const side = getSide(state.placement);\n const align = getAlignment(state.placement);\n const fallbackPlacements = options.fallbackPlacements ?? [withPlacement(OPPOSITE[side], align)];\n const skipped: Placement[] = [state.placement];\n let bestPlacement = state.placement;\n let bestScore = totalOverflow(currentOverflow);\n\n for (const candidate of fallbackPlacements) {\n const candidateOverflow = getPlacementOverflow(state, candidate, options);\n const score = totalOverflow(candidateOverflow);\n\n if (!hasOverflow(candidateOverflow)) {\n return {\n data: { flip: { skippedPlacements: skipped } },\n reset: { placement: candidate },\n };\n }\n\n skipped.push(candidate);\n\n if (score < bestScore) {\n bestPlacement = candidate;\n bestScore = score;\n }\n }\n\n if (bestPlacement !== state.placement) {\n return {\n data: { flip: { skippedPlacements: skipped } },\n reset: { placement: bestPlacement },\n };\n }\n }\n\n return flipMiddleware;\n}\n","import { detectOverflowAtRect, getFloatingRect, isFullyClipped, resolveBoundary } from '../overflow';\nimport type { DetectOverflowOptions, HideData, Middleware } from '../types';\n\nexport interface HideOptions extends DetectOverflowOptions {\n /**\n * Which hidden states to compute.\n * - `'referenceHidden'` — whether the reference itself is off-screen.\n * - `'escaped'` — whether the floating element has fully exited the boundary.\n * - `'both'` (default) — both of the above.\n */\n strategy?: 'referenceHidden' | 'escaped' | 'both';\n}\n\n/**\n * Detects when the reference or floating element is hidden outside the boundary.\n * Writes `{ referenceHidden, referenceHiddenOffsets, escaped, escapedOffsets }` to\n * `middlewareData.hide`.\n */\nexport function hide(options: HideOptions = {}): Middleware {\n const strategy = options.strategy ?? 'both';\n\n function hideMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const { boundary, padding } = resolveBoundary(options, state);\n const next: HideData = {};\n\n if (strategy === 'escaped' || strategy === 'both') {\n const floatingRect = getFloatingRect(state);\n const escapedOffsets = detectOverflowAtRect(floatingRect, boundary, padding);\n\n next.escaped = isFullyClipped(floatingRect, escapedOffsets);\n next.escapedOffsets = escapedOffsets;\n }\n\n if (strategy === 'referenceHidden' || strategy === 'both') {\n const referenceHiddenOffsets = detectOverflowAtRect(state.rects.reference, boundary, padding);\n\n next.referenceHidden = isFullyClipped(state.rects.reference, referenceHiddenOffsets);\n next.referenceHiddenOffsets = referenceHiddenOffsets;\n }\n\n return { data: { hide: next } };\n }\n\n return hideMiddleware;\n}\n","import type { Middleware, MiddlewareState } from '../types';\n\nimport { getSide } from '../utils';\n\nexport type OffsetConfig = {\n /** Offset perpendicular to the main axis. */\n crossAxis?: number;\n /** Offset along the axis away from the reference. */\n mainAxis?: number;\n};\n\nexport type OffsetValue = number | OffsetConfig | ((state: MiddlewareState) => number | OffsetConfig);\n\nfunction resolveOffsetConfig(value: OffsetValue, state: MiddlewareState): Required<OffsetConfig> {\n const raw = typeof value === 'function' ? value(state) : value;\n\n if (typeof raw === 'number') return { crossAxis: 0, mainAxis: raw };\n\n return { crossAxis: raw.crossAxis ?? 0, mainAxis: raw.mainAxis ?? 0 };\n}\n\n/**\n * Shifts the floating element along the main axis (away from reference) and/or\n * the cross axis. Accepts a number, config object, or a function for dynamic values.\n *\n * Must be the **first** middleware in the pipeline.\n */\nexport function offset(value: OffsetValue): Middleware {\n return function offsetMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const side = getSide(state.placement);\n const { crossAxis, mainAxis } = resolveOffsetConfig(value, state);\n\n switch (side) {\n case 'bottom':\n return { x: state.x + crossAxis, y: state.y + mainAxis };\n case 'left':\n return { x: state.x - mainAxis, y: state.y + crossAxis };\n case 'right':\n return { x: state.x + mainAxis, y: state.y + crossAxis };\n case 'top':\n return { x: state.x + crossAxis, y: state.y - mainAxis };\n }\n };\n}\n","import { clamp } from '@vielzeug/arsenal';\nimport { detectOverflow } from '../overflow';\n\nimport type { DetectOverflowOptions, Middleware, MiddlewareState } from '../types';\nimport { getSide } from '../utils';\n\n/**\n * A limiter function passed to `shift()` that constrains the maximum allowed drift.\n * Receives the current middleware state and the proposed shift correction (as deltas),\n * and returns the clamped correction.\n */\nexport type ShiftLimiter = (\n state: MiddlewareState,\n correction: { crossAxis: number; mainAxis: number },\n) => { crossAxis: number; mainAxis: number };\n\nexport interface LimitShiftOptions {\n /**\n * Extra pixels of allowed drift past the reference's cross-axis extent before clamping kicks in.\n * Can be a static number or a function returning a number based on current state.\n * Default: `0`.\n */\n offset?: number | ((state: MiddlewareState) => number);\n}\n\n/**\n * Returns a {@link ShiftLimiter} that constrains `shift()` so the floating element\n * stays visually connected to the reference along the cross axis.\n *\n * Without a limiter, `shift()` will push the float as far as needed to fit in the boundary —\n * potentially sliding it far away from the reference. `limitShift` clamps the drift so the\n * float stays within the reference's cross-axis extent (± `offset` pixels).\n *\n * @example\n * ```ts\n * // Tooltip stays above the button even when viewport clips it.\n * shift({ padding: 6, limiter: limitShift() })\n *\n * // Allow up to 10px of drift beyond the reference's edges.\n * shift({ padding: 6, limiter: limitShift({ offset: 10 }) })\n * ```\n */\nexport function limitShift(options: LimitShiftOptions = {}): ShiftLimiter {\n return (state, correction) => {\n const { placement, rects, x, y } = state;\n const side = getSide(placement);\n const isVertical = side === 'top' || side === 'bottom';\n const extra = typeof options.offset === 'function' ? options.offset(state) : (options.offset ?? 0);\n\n if (isVertical) {\n // Cross axis is x. Clamp float.left to [ref.left-extra, ref.right+extra-float.width].\n const lo = rects.reference.x - extra;\n const hi = rects.reference.x + rects.reference.width + extra - rects.floating.width;\n const [min, max] = lo <= hi ? [lo, hi] : [hi, lo];\n const clamped = clamp(x + correction.crossAxis, min, max);\n\n return { ...correction, crossAxis: clamped - x };\n }\n\n // Cross axis is y. Clamp float.top to [ref.top-extra, ref.bottom+extra-float.height].\n const lo = rects.reference.y - extra;\n const hi = rects.reference.y + rects.reference.height + extra - rects.floating.height;\n const [min, max] = lo <= hi ? [lo, hi] : [hi, lo];\n const clamped = clamp(y + correction.crossAxis, min, max);\n\n return { ...correction, crossAxis: clamped - y };\n };\n}\n\nexport interface ShiftOptions extends DetectOverflowOptions {\n /**\n * Whether to shift along the cross axis (perpendicular to the reference direction).\n * Default: `true`.\n */\n crossAxis?: boolean;\n /**\n * Constrains how far `shift()` can move the floating element along the cross axis.\n * Pass `limitShift()` to keep the float within the reference's extent.\n */\n limiter?: ShiftLimiter;\n /**\n * Whether to shift along the main axis (the axis away from the reference).\n * Default: `false` — main-axis overflow is better handled by `flip`.\n */\n mainAxis?: boolean;\n}\n\n/**\n * Shifts the floating element along the cross axis to keep it inside the boundary.\n *\n * By default only the cross axis is corrected. Enable `mainAxis` to also shift\n * along the main axis (useful when `flip` is not in the pipeline).\n *\n * | Placement | Cross axis | Main axis |\n * |------------------|------------|-----------|\n * | `top` / `bottom` | horizontal | vertical |\n * | `left` / `right` | vertical | horizontal|\n */\nexport function shift(options: ShiftOptions = {}): Middleware {\n const { crossAxis = true, limiter, mainAxis = false } = options;\n\n function shiftMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const overflow = detectOverflow(state, options);\n const side = getSide(state.placement);\n const isVertical = side === 'top' || side === 'bottom';\n\n const xCorrection = Math.max(overflow.left, 0) - Math.max(overflow.right, 0);\n const yCorrection = Math.max(overflow.top, 0) - Math.max(overflow.bottom, 0);\n const applyX = isVertical ? crossAxis : mainAxis;\n const applyY = isVertical ? mainAxis : crossAxis;\n\n let dx = applyX ? xCorrection : 0;\n let dy = applyY ? yCorrection : 0;\n\n if (limiter) {\n const limited = limiter(state, {\n crossAxis: isVertical ? dx : dy,\n mainAxis: isVertical ? dy : dx,\n });\n\n dx = isVertical ? limited.crossAxis : limited.mainAxis;\n dy = isVertical ? limited.mainAxis : limited.crossAxis;\n }\n\n return { data: { shift: { x: dx, y: dy } }, x: state.x + dx, y: state.y + dy };\n }\n\n return shiftMiddleware;\n}\n","import { resolveBoundary } from '../overflow';\nimport type { DetectOverflowOptions, Middleware } from '../types';\nimport { getSide } from '../utils';\n\nexport type SizeOptions = DetectOverflowOptions;\n\n/**\n * Reports the available space between the reference and boundary edges.\n *\n * Available dimensions are written to `middlewareData.size`.\n *\n * Read `result.middlewareData.size` in the positioner `apply` option or after `computePosition()`\n * to constrain the floating element's dimensions.\n *\n * @example\n * ```ts\n * const positioner = createPositioner(ref, el, {\n * middleware: [offset(8), flip(), shift(), size()],\n * apply(result) {\n * el.style.maxHeight = `${(result.middlewareData.size as SizeData).availableHeight}px`;\n * },\n * });\n * ```\n */\nexport function size(options: SizeOptions = {}): Middleware {\n function sizeMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const { boundary, padding } = resolveBoundary(options, state);\n const side = getSide(state.placement);\n const top = boundary.y + padding.top;\n const right = boundary.x + boundary.width - padding.right;\n const bottom = boundary.y + boundary.height - padding.bottom;\n const left = boundary.x + padding.left;\n\n const availableHeight =\n side === 'bottom'\n ? Math.max(0, bottom - state.y)\n : side === 'top'\n ? Math.max(0, state.rects.reference.y - top)\n : Math.max(0, bottom - top);\n\n const availableWidth =\n side === 'right'\n ? Math.max(0, right - state.x)\n : side === 'left'\n ? Math.max(0, state.rects.reference.x - left)\n : Math.max(0, right - left);\n\n return { data: { size: { availableHeight, availableWidth } } };\n }\n\n return sizeMiddleware;\n}\n"],"mappings":"sGAEA,IAAa,EAA+B,CAAE,OAAQ,MAAO,KAAM,QAAS,MAAO,OAAQ,IAAK,QAAS,EAGzG,SAAgB,QAAQ,EAAoB,CAC1C,OAAO,EAAE,MAAM,GAAG,CAAC,CAAC,EACtB,CAGA,SAAgB,aAAa,EAAgC,CAC3D,OAAQ,EAAE,MAAM,GAAG,CAAC,CAAC,IAAoB,IAC3C,CAGA,SAAgB,cAAc,EAAY,EAAoC,CAC5E,OAAQ,EAAQ,GAAG,EAAK,GAAG,IAAU,CACvC,CAGA,SAAgB,OAAO,CAAE,SAAQ,QAAO,IAAG,KAA2B,CACpE,MAAO,CAAE,SAAQ,QAAO,IAAG,GAAE,CAC/B,CAGA,SAAgB,aAAa,EAAmB,EAAe,CAK7D,OAJI,OAAO,GAAY,SACd,CAAE,OAAQ,EAAS,KAAM,EAAS,MA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,EAAI,EAAG,CAAG,CAAE,EAAG,EAAG,EAAM,EAAI,EAAI,EAAG,EAAM,EAAI,CAAG,CAC/E,CAEA,OAAO,eACT,CCxGA,SAAgB,KAAK,EAAuB,CAAC,EAAe,CAC1D,SAAS,eAAe,EAA0D,CAChF,GAAM,CAAE,WAAU,WAAY,gBAAgB,EAAS,CAAK,EACtD,EAAO,QAAQ,EAAM,SAAS,EAC9B,EAAM,EAAS,EAAI,EAAQ,IAC3B,EAAQ,EAAS,EAAI,EAAS,MAAQ,EAAQ,MAC9C,EAAS,EAAS,EAAI,EAAS,OAAS,EAAQ,OAChD,EAAO,EAAS,EAAI,EAAQ,KAgBlC,MAAO,CAAE,KAAM,CAAE,KAAM,CAAE,gBAbvB,IAAS,SACL,KAAK,IAAI,EAAG,EAAS,EAAM,CAAC,EAC5B,IAAS,MACP,KAAK,IAAI,EAAG,EAAM,MAAM,UAAU,EAAI,CAAG,EACzC,KAAK,IAAI,EAAG,EAAS,CAAG,EASU,eANxC,IAAS,QACL,KAAK,IAAI,EAAG,EAAQ,EAAM,CAAC,EAC3B,IAAS,OACP,KAAK,IAAI,EAAG,EAAM,MAAM,UAAU,EAAI,CAAI,EAC1C,KAAK,IAAI,EAAG,EAAQ,CAAI,CAEyB,CAAE,CAAE,CAC/D,CAEA,OAAO,cACT"}
@@ -1,2 +1,2 @@
1
- var Orbit=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e,t,n){return Math.min(Math.max(e,t),n)}var n={bottom:`top`,left:`right`,right:`left`,top:`bottom`};function r(e){return e.split(`-`)[0]}function i(e){return e.split(`-`)[1]??null}function a(e,t){return t?`${e}-${t}`:e}function o({height:e,width:t,x:n,y:r}){return{height:e,width:t,x:n,y:r}}function s(e=0){return typeof e==`number`?{bottom:e,left:e,right:e,top:e}:{bottom:e.bottom??0,left:e.left??0,right:e.right??0,top:e.top??0}}function c(e){return typeof Element<`u`&&e instanceof Element}function l(e){return e.assignedSlot?e.assignedSlot:e.parentElement??(e.getRootNode()instanceof ShadowRoot?e.getRootNode().host:null)}function u(e,t,n,r){return e===`start`?t:e===`end`?t+n-r:t+(n-r)/2}function d(e,t,n){let a=r(e),o=i(e);switch(a){case`bottom`:return{x:u(o,t.x,t.width,n.width),y:t.y+t.height};case`left`:return{x:t.x-n.width,y:u(o,t.y,t.height,n.height)};case`right`:return{x:t.x+t.width,y:u(o,t.y,t.height,n.height)};case`top`:return{x:u(o,t.x,t.width,n.width),y:t.y-n.height}}}function f(e,t){let n,r=0,i=(()=>{let i=Date.now(),a=t-(i-r);if(a<=0){n!==void 0&&clearTimeout(n),n=void 0,r=i,e();return}n===void 0&&(n=setTimeout(()=>{n=void 0,r=Date.now(),e()},a))});return i.cancel=()=>{n!==void 0&&clearTimeout(n),n=void 0},i}function p(e){let t=[],n=l(e);for(;n;){let e=getComputedStyle(n),r=e.overflow+e.overflowX+e.overflowY;/auto|scroll|overlay/.test(r)&&t.push(n),n=l(n)}return t}function m(e,t,n,{animationFrame:r=!1,observeAncestors:i=!0,observeFloating:a=!0,observeVisualViewport:o=!0,pauseWhenHidden:s=!0,throttle:l=0}={}){let u=l>0?f(n,l):null,d=u??n,m=!0,h=()=>{m&&d()};d();let g=[];if(s&&c(e)&&typeof IntersectionObserver<`u`){let t=new IntersectionObserver(e=>{m=e.at(-1)?.isIntersecting??!0,m&&d()});t.observe(e),g.push(()=>t.disconnect())}if(c(e)&&i){let t=p(e);for(let e of t)e.addEventListener(`scroll`,h,{passive:!0}),g.push(()=>e.removeEventListener(`scroll`,h));window.addEventListener(`scroll`,h,{passive:!0}),g.push(()=>window.removeEventListener(`scroll`,h))}else{let e=e=>{e.composedPath().includes(t)||h()};window.addEventListener(`scroll`,e,{capture:!0,passive:!0}),g.push(()=>window.removeEventListener(`scroll`,e,{capture:!0}))}window.addEventListener(`resize`,h,{passive:!0}),g.push(()=>window.removeEventListener(`resize`,h));let _=o?window.visualViewport:null;_&&(_.addEventListener(`resize`,h,{passive:!0}),_.addEventListener(`scroll`,h,{passive:!0}),g.push(()=>{_.removeEventListener(`resize`,h),_.removeEventListener(`scroll`,h)}));let v=new ResizeObserver(h);c(e)&&v.observe(e),a&&v.observe(t),g.push(()=>v.disconnect());let y=0;if(r){let e=()=>{h(),y=window.requestAnimationFrame(e)};y=window.requestAnimationFrame(e),g.push(()=>window.cancelAnimationFrame(y))}return()=>{u?.cancel();for(let e of g)e()}}var h=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},g=class extends h{};function _(e,t){return{floating:o(t.getBoundingClientRect()),reference:o(e.getBoundingClientRect())}}function v(e,t){return t?{...e,middlewareData:t.data?Object.assign(Object.create(null),e.middlewareData,t.data):e.middlewareData,placement:t.placement??e.placement,x:t.x??e.x,y:t.y??e.y}:e}var y=8;function b(e,t,{boundary:n,containingBlock:r,middleware:i=[],padding:a,placement:o=`bottom`}={}){let s=i,c=o,l={},u=_(e,t);for(let i=0;i<y;i+=1){let i={...d(c,u.reference,u.floating),boundary:n,elements:{floating:t,reference:e},initialPlacement:o,middlewareData:l,padding:a,placement:c,rects:u},f;for(let e of s){let t=e(i);if(i=v(i,t),l=i.middlewareData,f=t?.reset,f)break}if(!f){let e={middlewareData:i.middlewareData,placement:i.placement,x:i.x,y:i.y};if(r){let t=r.getBoundingClientRect();return{...e,x:e.x-t.x,y:e.y-t.y}}return e}f.remeasure?u=_(e,t):f.rects!=null&&(u=f.rects),c=f.placement??i.placement}throw new g(`Middleware triggered too many resets in a single compute cycle.`)}var x=[`transform`,`perspective`,`filter`],S=[`layout`,`paint`,`strict`,`content`];function C(e){return e.transform!==`none`||e.perspective!==`none`||e.filter!==`none`||e.backdropFilter&&e.backdropFilter!==`none`||e.willChange!==`auto`&&x.some(t=>e.willChange.includes(t))?!0:e.contain!==`none`&&S.some(t=>e.contain.includes(t))}function w(e){let t=l(e);for(;t;){if(C(getComputedStyle(t)))return t;t=l(t)}return null}function T(){let e=window.visualViewport;return e?{height:e.height,width:e.width,x:e.offsetLeft,y:e.offsetTop}:{height:window.innerHeight,width:window.innerWidth,x:0,y:0}}function E(e){if(!e)return T();if(e instanceof Element){let t=e.getBoundingClientRect();return{height:t.height,width:t.width,x:t.x,y:t.y}}return e}var D=/(hidden|clip|scroll|auto|overlay)/;function O(e,t){let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),i=Math.min(e.x+e.width,t.x+t.width),a=Math.min(e.y+e.height,t.y+t.height);return{height:Math.max(0,a-r),width:Math.max(0,i-n),x:n,y:r}}function k(e){let t=l(e),n=T();for(;t;){let e=getComputedStyle(t);if(D.test(`${e.overflow}${e.overflowX}${e.overflowY}`)){let e=t.getBoundingClientRect();n=O(n,{height:e.height,width:e.width,x:e.x,y:e.y})}t=l(t)}return n}function A(e,t){return{boundary:E(e.boundary??t.boundary),padding:s(e.padding??t.padding)}}function j(e){return{...e.rects.floating,x:e.x,y:e.y}}function M(e,t,n){return{bottom:e.y+e.height-(t.y+t.height-n.bottom),left:t.x+n.left-e.x,right:e.x+e.width-(t.x+t.width-n.right),top:t.y+n.top-e.y}}function N(e){return Math.max(e.top,0)+Math.max(e.right,0)+Math.max(e.bottom,0)+Math.max(e.left,0)}function P(e){return e.top>0||e.right>0||e.bottom>0||e.left>0}function F(e,t){return t.top>=e.height||t.right>=e.width||t.bottom>=e.height||t.left>=e.width}function I(e,t,n,i){let a=e.rects.reference;switch(r(t)){case`bottom`:return n.y+n.height-i.bottom-(a.y+a.height);case`left`:return a.x-(n.x+i.left);case`right`:return n.x+n.width-i.right-(a.x+a.width);case`top`:return a.y-(n.y+i.top)}}function L(e,t,n={}){let{x:r,y:i}=d(t,e.rects.reference,e.rects.floating),{boundary:a,padding:o}=A(n,e);return M({...e.rects.floating,x:r,y:i},a,o)}function R(e,t={}){let{boundary:n,padding:r}=A(t,e);return M(j(e),n,r)}function z(e,t){return t===`absolute`?e.offsetParent instanceof Element?e.offsetParent:null:w(e)}function B(e,t,n){t.style.position=n,t.style.left=`${e.x}px`,t.style.top=`${e.y}px`}function V(e,t,{apply:n,autoUpdate:r={},boundary:i=`clippingAncestors`,middleware:a,padding:o,placement:s=`bottom`,strategy:c=`fixed`}={}){let l=new AbortController,u=!0,d=!1,f,p=null,h=!1;function g(){if(!u)return;let r=z(t,c),l=b(e,t,{boundary:i===`clippingAncestors`?k(t):i,containingBlock:r,middleware:a,padding:o,placement:s});p=l,(n??(e=>B(e,t,c)))(l)}function _(){h||d||(h=!0,r===!1?g():f=m(e,t,g,r))}return{get disposalSignal(){return l.signal},dispose(){d||(d=!0,u=!1,l.abort(),f?.())},get disposed(){return d},getPosition:()=>p,start:_,[Symbol.dispose](){this.dispose()},update(){d||g()}}}function H(e){return!(`getClientRects`in e)||typeof e.getClientRects!=`function`?[]:Array.from(e.getClientRects()).map(o).filter(e=>e.width>0||e.height>0)}function U(e,t,n,r){return t>=e.x-r.left&&t<=e.x+e.width+r.right&&n>=e.y-r.top&&n<=e.y+e.height+r.bottom}function W(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function G(e={}){function t(t){let n=H(t.elements.reference);if(n.length<=1)return;let i=s(e.padding??2),a=r(t.placement),o=n[0];if(e.x!=null&&e.y!=null)o=n.find(t=>U(t,e.x,e.y,i))??o;else if(a===`top`||a===`bottom`){let e=t.x+t.rects.floating.width/2;o=n.reduce((t,n)=>{let r=Math.abs(t.x+t.width/2-e);return Math.abs(n.x+n.width/2-e)<r?n:t},o)}else{let e=t.y+t.rects.floating.height/2;o=n.reduce((t,n)=>{let r=Math.abs(t.y+t.height/2-e);return Math.abs(n.y+n.height/2-e)<r?n:t},o)}if(!W(o,t.rects.reference))return{reset:{rects:{...t.rects,reference:o}}}}return t}function K({element:e,padding:n=0}){function i(i){let a=r(i.placement),c=s(n),l=o(e.getBoundingClientRect());if(a===`top`||a===`bottom`){let e=i.rects.reference.x+i.rects.reference.width/2-i.x-l.width/2,n=c.left,r=t(e,n,Math.max(n,i.rects.floating.width-l.width-c.right));return{data:{arrow:{centerOffset:e-r,constrained:r!==e,x:r}}}}let u=i.rects.reference.y+i.rects.reference.height/2-i.y-l.height/2,d=c.top,f=t(u,d,Math.max(d,i.rects.floating.height-l.height-c.bottom));return{data:{arrow:{centerOffset:u-f,constrained:f!==u,y:f}}}}return i}var q=[`top`,`right`,`bottom`,`left`];function J(e){return e===void 0?q:e===null?q.flatMap(e=>[e,`${e}-start`,`${e}-end`]):q.map(t=>`${t}-${e}`)}function Y(e={}){return function(t){let{boundary:n,padding:r}=A(e,t),i=e.allowedPlacements??J(e.alignment);i.length;let a=t.placement,o=1/0,s=-1/0;for(let c of i){let i=N(L(t,c,e)),l=I(t,c,n,r);(i<o||i===o&&l>s)&&(a=c,o=i,s=l)}if(a!==t.placement)return{reset:{placement:a}}}}function X(e={}){function t(t){let o=R(t,e);if(!P(o))return;let s=r(t.placement),c=i(t.placement),l=e.fallbackPlacements??[a(n[s],c)],u=[t.placement],d=t.placement,f=N(o);for(let n of l){let r=L(t,n,e),i=N(r);if(!P(r))return{data:{flip:{skippedPlacements:u}},reset:{placement:n}};u.push(n),i<f&&(d=n,f=i)}if(d!==t.placement)return{data:{flip:{skippedPlacements:u}},reset:{placement:d}}}return t}function Z(e={}){let t=e.strategy??`both`;function n(n){let{boundary:r,padding:i}=A(e,n),a={};if(t===`escaped`||t===`both`){let e=j(n),t=M(e,r,i);a.escaped=F(e,t),a.escapedOffsets=t}if(t===`referenceHidden`||t===`both`){let e=M(n.rects.reference,r,i);a.referenceHidden=F(n.rects.reference,e),a.referenceHiddenOffsets=e}return{data:{hide:a}}}return n}function Q(e,t){let n=typeof e==`function`?e(t):e;return typeof n==`number`?{crossAxis:0,mainAxis:n}:{crossAxis:n.crossAxis??0,mainAxis:n.mainAxis??0}}function $(e){return function(t){let n=r(t.placement),{crossAxis:i,mainAxis:a}=Q(e,t);switch(n){case`bottom`:return{x:t.x+i,y:t.y+a};case`left`:return{x:t.x-a,y:t.y+i};case`right`:return{x:t.x+a,y:t.y+i};case`top`:return{x:t.x+i,y:t.y-a}}}}function ee(e={}){return(n,i)=>{let{placement:a,rects:o,x:s,y:c}=n,l=r(a),u=l===`top`||l===`bottom`,d=typeof e.offset==`function`?e.offset(n):e.offset??0;if(u){let e=o.reference.x-d,n=o.reference.x+o.reference.width+d-o.floating.width,[r,a]=e<=n?[e,n]:[n,e],c=t(s+i.crossAxis,r,a);return{...i,crossAxis:c-s}}let f=o.reference.y-d,p=o.reference.y+o.reference.height+d-o.floating.height,[m,h]=f<=p?[f,p]:[p,f],g=t(c+i.crossAxis,m,h);return{...i,crossAxis:g-c}}}function te(e={}){let{crossAxis:t=!0,limiter:n,mainAxis:i=!1}=e;function a(a){let o=R(a,e),s=r(a.placement),c=s===`top`||s===`bottom`,l=Math.max(o.left,0)-Math.max(o.right,0),u=Math.max(o.top,0)-Math.max(o.bottom,0),d=c?t:i,f=c?i:t,p=d?l:0,m=f?u:0;if(n){let e=n(a,{crossAxis:c?p:m,mainAxis:c?m:p});p=c?e.crossAxis:e.mainAxis,m=c?e.mainAxis:e.crossAxis}return{data:{shift:{x:p,y:m}},x:a.x+p,y:a.y+m}}return a}function ne(e={}){function t(t){let{boundary:n,padding:i}=A(e,t),a=r(t.placement),o=n.y+i.top,s=n.x+n.width-i.right,c=n.y+n.height-i.bottom,l=n.x+i.left;return{data:{size:{availableHeight:a===`bottom`?Math.max(0,c-t.y):a===`top`?Math.max(0,t.rects.reference.y-o):Math.max(0,c-o),availableWidth:a===`right`?Math.max(0,s-t.x):a===`left`?Math.max(0,t.rects.reference.x-l):Math.max(0,s-l)}}}}return t}return e.OrbitConfigError=g,e.OrbitError=h,e.arrow=K,e.autoPlacement=Y,e.autoUpdate=m,e.computePosition=b,e.createPositioner=V,e.detectOverflow=R,e.flip=X,e.getAlignment=i,e.getClippingAncestorRect=k,e.getSide=r,e.hide=Z,e.inline=G,e.limitShift=ee,e.offset=$,e.shift=te,e.size=ne,e})({});
1
+ var Orbit=(function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var n={bottom:`top`,left:`right`,right:`left`,top:`bottom`};function getSide(e){return e.split(`-`)[0]}function getAlignment(e){return e.split(`-`)[1]??null}function withPlacement(e,t){return t?`${e}-${t}`:e}function toRect({height:e,width:t,x:n,y:r}){return{height:e,width:t,x:n,y:r}}function toSideObject(e=0){return typeof e==`number`?{bottom:e,left:e,right:e,top:e}:{bottom:e.bottom??0,left:e.left??0,right:e.right??0,top:e.top??0}}function isElement(e){return typeof Element<`u`&&e instanceof Element}function flatTreeParent(e){return e.assignedSlot?e.assignedSlot:e.parentElement??(e.getRootNode()instanceof ShadowRoot?e.getRootNode().host:null)}function alignedOffset(e,t,n,r){return e===`start`?t:e===`end`?t+n-r:t+(n-r)/2}function baseCoords(e,t,n){let r=getSide(e),i=getAlignment(e);switch(r){case`bottom`:return{x:alignedOffset(i,t.x,t.width,n.width),y:t.y+t.height};case`left`:return{x:t.x-n.width,y:alignedOffset(i,t.y,t.height,n.height)};case`right`:return{x:t.x+t.width,y:alignedOffset(i,t.y,t.height,n.height)};case`top`:return{x:alignedOffset(i,t.x,t.width,n.width),y:t.y-n.height}}}function throttle(e,t){let n,r=0,throttled=(()=>{let i=Date.now(),a=t-(i-r);if(a<=0){n!==void 0&&clearTimeout(n),n=void 0,r=i,e();return}n===void 0&&(n=setTimeout(()=>{n=void 0,r=Date.now(),e()},a))});return throttled.cancel=()=>{n!==void 0&&clearTimeout(n),n=void 0},throttled}function getScrollAncestors(e){let t=[],n=flatTreeParent(e);for(;n;){let e=getComputedStyle(n),r=e.overflow+e.overflowX+e.overflowY;/auto|scroll|overlay/.test(r)&&t.push(n),n=flatTreeParent(n)}return t}function autoUpdate(e,t,n,{animationFrame:r=!1,observeAncestors:i=!0,observeFloating:a=!0,observeVisualViewport:o=!0,pauseWhenHidden:s=!0,throttle:c=0}={}){let l=c>0?throttle(n,c):null,u=l??n,d=!0,conditionalNotify=()=>{d&&u()};u();let f=[];if(s&&isElement(e)&&typeof IntersectionObserver<`u`){let t=new IntersectionObserver(e=>{d=e.at(-1)?.isIntersecting??!0,d&&u()});t.observe(e),f.push(()=>t.disconnect())}if(isElement(e)&&i){let t=getScrollAncestors(e);for(let e of t)e.addEventListener(`scroll`,conditionalNotify,{passive:!0}),f.push(()=>e.removeEventListener(`scroll`,conditionalNotify));window.addEventListener(`scroll`,conditionalNotify,{passive:!0}),f.push(()=>window.removeEventListener(`scroll`,conditionalNotify))}else{let scrollHandler=e=>{e.composedPath().includes(t)||conditionalNotify()};window.addEventListener(`scroll`,scrollHandler,{capture:!0,passive:!0}),f.push(()=>window.removeEventListener(`scroll`,scrollHandler,{capture:!0}))}window.addEventListener(`resize`,conditionalNotify,{passive:!0}),f.push(()=>window.removeEventListener(`resize`,conditionalNotify));let p=o?window.visualViewport:null;p&&(p.addEventListener(`resize`,conditionalNotify,{passive:!0}),p.addEventListener(`scroll`,conditionalNotify,{passive:!0}),f.push(()=>{p.removeEventListener(`resize`,conditionalNotify),p.removeEventListener(`scroll`,conditionalNotify)}));let m=new ResizeObserver(conditionalNotify);isElement(e)&&m.observe(e),a&&m.observe(t),f.push(()=>m.disconnect());let h=0;if(r){let frameLoop=()=>{conditionalNotify(),h=window.requestAnimationFrame(frameLoop)};h=window.requestAnimationFrame(frameLoop),f.push(()=>window.cancelAnimationFrame(h))}return()=>{l?.cancel();for(let e of f)e()}}var OrbitError=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},OrbitConfigError=class extends OrbitError{};function getRects(e,t){return{floating:toRect(t.getBoundingClientRect()),reference:toRect(e.getBoundingClientRect())}}function mergeState(e,t){return t?{...e,middlewareData:t.data?Object.assign(Object.create(null),e.middlewareData,t.data):e.middlewareData,placement:t.placement??e.placement,x:t.x??e.x,y:t.y??e.y}:e}var r=8;function computePosition(e,t,{boundary:n,containingBlock:i,middleware:a=[],padding:o,placement:s=`bottom`}={}){let c=a,l=s,u={},d=getRects(e,t);for(let a=0;a<r;a+=1){let r={...baseCoords(l,d.reference,d.floating),boundary:n,elements:{floating:t,reference:e},initialPlacement:s,middlewareData:u,padding:o,placement:l,rects:d},a;for(let e of c){let t=e(r);if(r=mergeState(r,t),u=r.middlewareData,a=t?.reset,a)break}if(!a){let e={middlewareData:r.middlewareData,placement:r.placement,x:r.x,y:r.y};if(i){let t=i.getBoundingClientRect();return{...e,x:e.x-t.x,y:e.y-t.y}}return e}a.remeasure?d=getRects(e,t):a.rects!=null&&(d=a.rects),l=a.placement??r.placement}throw new OrbitConfigError(`Middleware triggered too many resets in a single compute cycle.`)}var i=[`transform`,`perspective`,`filter`],a=[`layout`,`paint`,`strict`,`content`];function establishesFixedContainingBlock(e){return e.transform!==`none`||e.perspective!==`none`||e.filter!==`none`||e.backdropFilter&&e.backdropFilter!==`none`||e.willChange!==`auto`&&i.some(t=>e.willChange.includes(t))?!0:e.contain!==`none`&&a.some(t=>e.contain.includes(t))}function getContainingBlock(e){let t=flatTreeParent(e);for(;t;){if(establishesFixedContainingBlock(getComputedStyle(t)))return t;t=flatTreeParent(t)}return null}function getViewportRect(){let e=window.visualViewport;return e?{height:e.height,width:e.width,x:e.offsetLeft,y:e.offsetTop}:{height:window.innerHeight,width:window.innerWidth,x:0,y:0}}function getBoundaryRect(e){if(!e)return getViewportRect();if(e instanceof Element){let t=e.getBoundingClientRect();return{height:t.height,width:t.width,x:t.x,y:t.y}}return e}var o=/(hidden|clip|scroll|auto|overlay)/;function intersectRect(e,t){let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),i=Math.min(e.x+e.width,t.x+t.width),a=Math.min(e.y+e.height,t.y+t.height);return{height:Math.max(0,a-r),width:Math.max(0,i-n),x:n,y:r}}function getClippingAncestorRect(e){let t=flatTreeParent(e),n=getViewportRect();for(;t;){let e=getComputedStyle(t);if(o.test(`${e.overflow}${e.overflowX}${e.overflowY}`)){let e=t.getBoundingClientRect();n=intersectRect(n,{height:e.height,width:e.width,x:e.x,y:e.y})}t=flatTreeParent(t)}return n}function resolveBoundary(e,t){return{boundary:getBoundaryRect(e.boundary??t.boundary),padding:toSideObject(e.padding??t.padding)}}function getFloatingRect(e){return{...e.rects.floating,x:e.x,y:e.y}}function detectOverflowAtRect(e,t,n){return{bottom:e.y+e.height-(t.y+t.height-n.bottom),left:t.x+n.left-e.x,right:e.x+e.width-(t.x+t.width-n.right),top:t.y+n.top-e.y}}function totalOverflow(e){return Math.max(e.top,0)+Math.max(e.right,0)+Math.max(e.bottom,0)+Math.max(e.left,0)}function hasOverflow(e){return e.top>0||e.right>0||e.bottom>0||e.left>0}function isFullyClipped(e,t){return t.top>=e.height||t.right>=e.width||t.bottom>=e.height||t.left>=e.width}function getAvailableSpace(e,t,n,r){let i=e.rects.reference;switch(getSide(t)){case`bottom`:return n.y+n.height-r.bottom-(i.y+i.height);case`left`:return i.x-(n.x+r.left);case`right`:return n.x+n.width-r.right-(i.x+i.width);case`top`:return i.y-(n.y+r.top)}}function getPlacementOverflow(e,t,n={}){let{x:r,y:i}=baseCoords(t,e.rects.reference,e.rects.floating),{boundary:a,padding:o}=resolveBoundary(n,e);return detectOverflowAtRect({...e.rects.floating,x:r,y:i},a,o)}function detectOverflow(e,t={}){let{boundary:n,padding:r}=resolveBoundary(t,e);return detectOverflowAtRect(getFloatingRect(e),n,r)}function resolveContainingBlock(e,t){return t===`absolute`?e.offsetParent instanceof Element?e.offsetParent:null:getContainingBlock(e)}function applyDefault(e,t,n){t.style.position=n,t.style.left=`${e.x}px`,t.style.top=`${e.y}px`}function createPositioner(e,t,{apply:n,autoUpdate:r={},boundary:i=`clippingAncestors`,middleware:a,padding:o,placement:s=`bottom`,strategy:c=`fixed`}={}){let l=new AbortController,u=!0,d=!1,f,p;function update(){if(!u)return;let r=resolveContainingBlock(t,c),l=computePosition(e,t,{boundary:i===`clippingAncestors`?getClippingAncestorRect(t):i,containingBlock:r,middleware:a,padding:o,placement:s});p=l,(n??(e=>applyDefault(e,t,c)))(l)}let m={get disposalSignal(){return l.signal},dispose(){d||(d=!0,u=!1,l.abort(),f?.())},get disposed(){return d},getPosition:()=>p,[Symbol.dispose](){this.dispose()},update(){d||update()}};return r===!1?update():f=autoUpdate(e,t,update,r),m}function getClientRects(e){return!(`getClientRects`in e)||typeof e.getClientRects!=`function`?[]:Array.from(e.getClientRects()).map(toRect).filter(e=>e.width>0||e.height>0)}function rectContainsPoint(e,t,n,r){return t>=e.x-r.left&&t<=e.x+e.width+r.right&&n>=e.y-r.top&&n<=e.y+e.height+r.bottom}function sameRect(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function inline(e={}){function inlineMiddleware(t){let n=getClientRects(t.elements.reference);if(n.length<=1)return;let r=toSideObject(e.padding??2),i=getSide(t.placement),a=n[0];if(e.x!=null&&e.y!=null)a=n.find(t=>rectContainsPoint(t,e.x,e.y,r))??a;else if(i===`top`||i===`bottom`){let e=t.x+t.rects.floating.width/2;a=n.reduce((t,n)=>{let r=Math.abs(t.x+t.width/2-e);return Math.abs(n.x+n.width/2-e)<r?n:t},a)}else{let e=t.y+t.rects.floating.height/2;a=n.reduce((t,n)=>{let r=Math.abs(t.y+t.height/2-e);return Math.abs(n.y+n.height/2-e)<r?n:t},a)}if(!sameRect(a,t.rects.reference))return{reset:{rects:{...t.rects,reference:a}}}}return inlineMiddleware}function arrow({element:e,padding:n=0}){function arrowMiddleware(r){let i=getSide(r.placement),a=toSideObject(n),o=toRect(e.getBoundingClientRect());if(i===`top`||i===`bottom`){let e=r.rects.reference.x+r.rects.reference.width/2-r.x-o.width/2,n=a.left,i=Math.max(n,r.rects.floating.width-o.width-a.right),s=(0,t.clamp)(e,n,i);return{data:{arrow:{centerOffset:e-s,constrained:s!==e,x:s}}}}let s=r.rects.reference.y+r.rects.reference.height/2-r.y-o.height/2,c=a.top,l=Math.max(c,r.rects.floating.height-o.height-a.bottom),u=(0,t.clamp)(s,c,l);return{data:{arrow:{centerOffset:s-u,constrained:u!==s,y:u}}}}return arrowMiddleware}var s=[`top`,`right`,`bottom`,`left`];function getDefaultPlacements(e){return e===void 0?s:e===null?s.flatMap(e=>[e,`${e}-start`,`${e}-end`]):s.map(t=>`${t}-${e}`)}function autoPlacement(e={}){return function autoPlacementMiddleware(t){let{boundary:n,padding:r}=resolveBoundary(e,t),i=e.allowedPlacements??getDefaultPlacements(e.alignment);i.length;let a=t.placement,o=1/0,s=-1/0;for(let c of i){let i=totalOverflow(getPlacementOverflow(t,c,e)),l=getAvailableSpace(t,c,n,r);(i<o||i===o&&l>s)&&(a=c,o=i,s=l)}if(a!==t.placement)return{reset:{placement:a}}}}function flip(e={}){function flipMiddleware(t){let r=detectOverflow(t,e);if(!hasOverflow(r))return;let i=getSide(t.placement),a=getAlignment(t.placement),o=e.fallbackPlacements??[withPlacement(n[i],a)],s=[t.placement],c=t.placement,l=totalOverflow(r);for(let n of o){let r=getPlacementOverflow(t,n,e),i=totalOverflow(r);if(!hasOverflow(r))return{data:{flip:{skippedPlacements:s}},reset:{placement:n}};s.push(n),i<l&&(c=n,l=i)}if(c!==t.placement)return{data:{flip:{skippedPlacements:s}},reset:{placement:c}}}return flipMiddleware}function hide(e={}){let t=e.strategy??`both`;function hideMiddleware(n){let{boundary:r,padding:i}=resolveBoundary(e,n),a={};if(t===`escaped`||t===`both`){let e=getFloatingRect(n),t=detectOverflowAtRect(e,r,i);a.escaped=isFullyClipped(e,t),a.escapedOffsets=t}if(t===`referenceHidden`||t===`both`){let e=detectOverflowAtRect(n.rects.reference,r,i);a.referenceHidden=isFullyClipped(n.rects.reference,e),a.referenceHiddenOffsets=e}return{data:{hide:a}}}return hideMiddleware}function resolveOffsetConfig(e,t){let n=typeof e==`function`?e(t):e;return typeof n==`number`?{crossAxis:0,mainAxis:n}:{crossAxis:n.crossAxis??0,mainAxis:n.mainAxis??0}}function offset(e){return function offsetMiddleware(t){let n=getSide(t.placement),{crossAxis:r,mainAxis:i}=resolveOffsetConfig(e,t);switch(n){case`bottom`:return{x:t.x+r,y:t.y+i};case`left`:return{x:t.x-i,y:t.y+r};case`right`:return{x:t.x+i,y:t.y+r};case`top`:return{x:t.x+r,y:t.y-i}}}}function limitShift(e={}){return(n,r)=>{let{placement:i,rects:a,x:o,y:s}=n,c=getSide(i),l=c===`top`||c===`bottom`,u=typeof e.offset==`function`?e.offset(n):e.offset??0;if(l){let e=a.reference.x-u,n=a.reference.x+a.reference.width+u-a.floating.width,[i,s]=e<=n?[e,n]:[n,e],c=(0,t.clamp)(o+r.crossAxis,i,s);return{...r,crossAxis:c-o}}let d=a.reference.y-u,f=a.reference.y+a.reference.height+u-a.floating.height,[p,m]=d<=f?[d,f]:[f,d],h=(0,t.clamp)(s+r.crossAxis,p,m);return{...r,crossAxis:h-s}}}function shift(e={}){let{crossAxis:t=!0,limiter:n,mainAxis:r=!1}=e;function shiftMiddleware(i){let a=detectOverflow(i,e),o=getSide(i.placement),s=o===`top`||o===`bottom`,c=Math.max(a.left,0)-Math.max(a.right,0),l=Math.max(a.top,0)-Math.max(a.bottom,0),u=s?t:r,d=s?r:t,f=u?c:0,p=d?l:0;if(n){let e=n(i,{crossAxis:s?f:p,mainAxis:s?p:f});f=s?e.crossAxis:e.mainAxis,p=s?e.mainAxis:e.crossAxis}return{data:{shift:{x:f,y:p}},x:i.x+f,y:i.y+p}}return shiftMiddleware}function size(e={}){function sizeMiddleware(t){let{boundary:n,padding:r}=resolveBoundary(e,t),i=getSide(t.placement),a=n.y+r.top,o=n.x+n.width-r.right,s=n.y+n.height-r.bottom,c=n.x+r.left;return{data:{size:{availableHeight:i===`bottom`?Math.max(0,s-t.y):i===`top`?Math.max(0,t.rects.reference.y-a):Math.max(0,s-a),availableWidth:i===`right`?Math.max(0,o-t.x):i===`left`?Math.max(0,t.rects.reference.x-c):Math.max(0,o-c)}}}}return sizeMiddleware}return e.OrbitConfigError=OrbitConfigError,e.OrbitError=OrbitError,e.arrow=arrow,e.autoPlacement=autoPlacement,e.autoUpdate=autoUpdate,e.computePosition=computePosition,e.createPositioner=createPositioner,e.detectOverflow=detectOverflow,e.flip=flip,e.getAlignment=getAlignment,e.getBoundaryRect=getBoundaryRect,e.getClippingAncestorRect=getClippingAncestorRect,e.getSide=getSide,e.hide=hide,e.inline=inline,e.limitShift=limitShift,e.offset=offset,e.shift=shift,e.size=size,e})({},Arsenal);
2
2
  //# sourceMappingURL=orbit.iife.js.map