@getflip/swirl-components 0.491.0 → 0.491.1-beta-20260515134527

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.
package/components.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "timestamp": "2026-05-13T07:56:02",
2
+ "timestamp": "2026-05-15T13:44:43",
3
3
  "compiler": {
4
4
  "name": "@stencil/core",
5
5
  "version": "4.43.1",
@@ -19,10 +19,6 @@ const oppositeSideMap = {
19
19
  bottom: 'top',
20
20
  top: 'bottom'
21
21
  };
22
- const oppositeAlignmentMap = {
23
- start: 'end',
24
- end: 'start'
25
- };
26
22
  function clamp(start, value, end) {
27
23
  return max(start, min(value, end));
28
24
  }
@@ -41,9 +37,9 @@ function getOppositeAxis(axis) {
41
37
  function getAxisLength(axis) {
42
38
  return axis === 'y' ? 'height' : 'width';
43
39
  }
44
- const yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']);
45
40
  function getSideAxis(placement) {
46
- return yAxisSides.has(getSide(placement)) ? 'y' : 'x';
41
+ const firstChar = placement[0];
42
+ return firstChar === 't' || firstChar === 'b' ? 'y' : 'x';
47
43
  }
48
44
  function getAlignmentAxis(placement) {
49
45
  return getOppositeAxis(getSideAxis(placement));
@@ -66,7 +62,7 @@ function getExpandedPlacements(placement) {
66
62
  return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
67
63
  }
68
64
  function getOppositeAlignmentPlacement(placement) {
69
- return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
65
+ return placement.includes('start') ? placement.replace('start', 'end') : placement.replace('end', 'start');
70
66
  }
71
67
  const lrPlacement = ['left', 'right'];
72
68
  const rlPlacement = ['right', 'left'];
@@ -97,7 +93,8 @@ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
97
93
  return list;
98
94
  }
99
95
  function getOppositePlacement(placement) {
100
- return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
96
+ const side = getSide(placement);
97
+ return oppositeSideMap[side] + placement.slice(side.length);
101
98
  }
102
99
  function expandPaddingObject(padding) {
103
100
  return {
@@ -256,6 +253,9 @@ async function detectOverflow(state, options) {
256
253
  };
257
254
  }
258
255
 
256
+ // Maximum number of resets that can occur before bailing to avoid infinite reset loops.
257
+ const MAX_RESET_COUNT = 50;
258
+
259
259
  /**
260
260
  * Computes the `x` and `y` coordinates that will place the floating element
261
261
  * next to a given reference element.
@@ -270,7 +270,10 @@ const computePosition$1 = async (reference, floating, config) => {
270
270
  middleware = [],
271
271
  platform
272
272
  } = config;
273
- const validMiddleware = middleware.filter(Boolean);
273
+ const platformWithDetectOverflow = platform.detectOverflow ? platform : {
274
+ ...platform,
275
+ detectOverflow
276
+ };
274
277
  const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
275
278
  let rects = await platform.getElementRects({
276
279
  reference,
@@ -282,14 +285,17 @@ const computePosition$1 = async (reference, floating, config) => {
282
285
  y
283
286
  } = computeCoordsFromPlacement(rects, placement, rtl);
284
287
  let statefulPlacement = placement;
285
- let middlewareData = {};
286
288
  let resetCount = 0;
287
- for (let i = 0; i < validMiddleware.length; i++) {
288
- var _platform$detectOverf;
289
+ const middlewareData = {};
290
+ for (let i = 0; i < middleware.length; i++) {
291
+ const currentMiddleware = middleware[i];
292
+ if (!currentMiddleware) {
293
+ continue;
294
+ }
289
295
  const {
290
296
  name,
291
297
  fn
292
- } = validMiddleware[i];
298
+ } = currentMiddleware;
293
299
  const {
294
300
  x: nextX,
295
301
  y: nextY,
@@ -303,10 +309,7 @@ const computePosition$1 = async (reference, floating, config) => {
303
309
  strategy,
304
310
  middlewareData,
305
311
  rects,
306
- platform: {
307
- ...platform,
308
- detectOverflow: (_platform$detectOverf = platform.detectOverflow) != null ? _platform$detectOverf : detectOverflow
309
- },
312
+ platform: platformWithDetectOverflow,
310
313
  elements: {
311
314
  reference,
312
315
  floating
@@ -314,14 +317,11 @@ const computePosition$1 = async (reference, floating, config) => {
314
317
  });
315
318
  x = nextX != null ? nextX : x;
316
319
  y = nextY != null ? nextY : y;
317
- middlewareData = {
318
- ...middlewareData,
319
- [name]: {
320
- ...middlewareData[name],
321
- ...data
322
- }
320
+ middlewareData[name] = {
321
+ ...middlewareData[name],
322
+ ...data
323
323
  };
324
- if (reset && resetCount <= 50) {
324
+ if (reset && resetCount < MAX_RESET_COUNT) {
325
325
  resetCount++;
326
326
  if (typeof reset === 'object') {
327
327
  if (reset.placement) {
@@ -774,7 +774,6 @@ function isShadowRoot(value) {
774
774
  }
775
775
  return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
776
776
  }
777
- const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
778
777
  function isOverflowElement(element) {
779
778
  const {
780
779
  overflow,
@@ -782,32 +781,35 @@ function isOverflowElement(element) {
782
781
  overflowY,
783
782
  display
784
783
  } = getComputedStyle$1(element);
785
- return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
784
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== 'inline' && display !== 'contents';
786
785
  }
787
- const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
788
786
  function isTableElement(element) {
789
- return tableElements.has(getNodeName(element));
787
+ return /^(table|td|th)$/.test(getNodeName(element));
790
788
  }
791
- const topLayerSelectors = [':popover-open', ':modal'];
792
789
  function isTopLayer(element) {
793
- return topLayerSelectors.some(selector => {
794
- try {
795
- return element.matches(selector);
796
- } catch (_e) {
797
- return false;
790
+ try {
791
+ if (element.matches(':popover-open')) {
792
+ return true;
798
793
  }
799
- });
794
+ } catch (_e) {
795
+ // no-op
796
+ }
797
+ try {
798
+ return element.matches(':modal');
799
+ } catch (_e) {
800
+ return false;
801
+ }
800
802
  }
801
- const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
802
- const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
803
- const containValues = ['paint', 'layout', 'strict', 'content'];
803
+ const willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
804
+ const containRe = /paint|layout|strict|content/;
805
+ const isNotNone = value => !!value && value !== 'none';
806
+ let isWebKitValue;
804
807
  function isContainingBlock(elementOrCss) {
805
- const webkit = isWebKit();
806
808
  const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
807
809
 
808
810
  // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
809
811
  // https://drafts.csswg.org/css-transforms-2/#individual-transforms
810
- return transformProperties.some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || willChangeValues.some(value => (css.willChange || '').includes(value)) || containValues.some(value => (css.contain || '').includes(value));
812
+ return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || '') || containRe.test(css.contain || '');
811
813
  }
812
814
  function getContainingBlock(element) {
813
815
  let currentNode = getParentNode(element);
@@ -822,12 +824,13 @@ function getContainingBlock(element) {
822
824
  return null;
823
825
  }
824
826
  function isWebKit() {
825
- if (typeof CSS === 'undefined' || !CSS.supports) return false;
826
- return CSS.supports('-webkit-backdrop-filter', 'none');
827
+ if (isWebKitValue == null) {
828
+ isWebKitValue = typeof CSS !== 'undefined' && CSS.supports && CSS.supports('-webkit-backdrop-filter', 'none');
829
+ }
830
+ return isWebKitValue;
827
831
  }
828
- const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
829
832
  function isLastTraversableNode(node) {
830
- return lastTraversableNodeNames.has(getNodeName(node));
833
+ return /^(html|body|#document)$/.test(getNodeName(node));
831
834
  }
832
835
  function getComputedStyle$1(element) {
833
836
  return getWindow(element).getComputedStyle(element);
@@ -883,8 +886,9 @@ function getOverflowAncestors(node, list, traverseIframes) {
883
886
  if (isBody) {
884
887
  const frameElement = getFrameElement(win);
885
888
  return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
889
+ } else {
890
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
886
891
  }
887
- return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
888
892
  }
889
893
  function getFrameElement(win) {
890
894
  return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
@@ -1061,7 +1065,7 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1061
1065
  if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1062
1066
  scroll = getNodeScroll(offsetParent);
1063
1067
  }
1064
- if (isHTMLElement(offsetParent)) {
1068
+ if (isOffsetParentAnElement) {
1065
1069
  const offsetRect = getBoundingClientRect(offsetParent);
1066
1070
  scale = getScale(offsetParent);
1067
1071
  offsets.x = offsetRect.x + offsetParent.clientLeft;
@@ -1149,7 +1153,6 @@ function getViewportRect(element, strategy) {
1149
1153
  };
1150
1154
  }
1151
1155
 
1152
- const absoluteOrFixed = /*#__PURE__*/new Set(['absolute', 'fixed']);
1153
1156
  // Returns the inner client rect, subtracting scrollbars if present.
1154
1157
  function getInnerBoundingClientRect(element, strategy) {
1155
1158
  const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
@@ -1214,7 +1217,7 @@ function getClippingElementAncestors(element, cache) {
1214
1217
  if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1215
1218
  currentContainingBlockComputedStyle = null;
1216
1219
  }
1217
- const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1220
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === 'absolute' || currentContainingBlockComputedStyle.position === 'fixed') || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1218
1221
  if (shouldDropCurrentNode) {
1219
1222
  // Drop non-containing blocks.
1220
1223
  result = result.filter(ancestor => ancestor !== currentNode);
@@ -1239,20 +1242,23 @@ function getClippingRect(_ref) {
1239
1242
  } = _ref;
1240
1243
  const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
1241
1244
  const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1242
- const firstClippingAncestor = clippingAncestors[0];
1243
- const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1244
- const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1245
- accRect.top = max(rect.top, accRect.top);
1246
- accRect.right = min(rect.right, accRect.right);
1247
- accRect.bottom = min(rect.bottom, accRect.bottom);
1248
- accRect.left = max(rect.left, accRect.left);
1249
- return accRect;
1250
- }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1245
+ const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
1246
+ let top = firstRect.top;
1247
+ let right = firstRect.right;
1248
+ let bottom = firstRect.bottom;
1249
+ let left = firstRect.left;
1250
+ for (let i = 1; i < clippingAncestors.length; i++) {
1251
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i], strategy);
1252
+ top = max(rect.top, top);
1253
+ right = min(rect.right, right);
1254
+ bottom = min(rect.bottom, bottom);
1255
+ left = max(rect.left, left);
1256
+ }
1251
1257
  return {
1252
- width: clippingRect.right - clippingRect.left,
1253
- height: clippingRect.bottom - clippingRect.top,
1254
- x: clippingRect.left,
1255
- y: clippingRect.top
1258
+ width: right - left,
1259
+ height: bottom - top,
1260
+ x: left,
1261
+ y: top
1256
1262
  };
1257
1263
  }
1258
1264
 
@@ -1503,7 +1509,7 @@ function autoUpdate(reference, floating, update, options) {
1503
1509
  animationFrame = false
1504
1510
  } = options;
1505
1511
  const referenceEl = unwrapElement(reference);
1506
- const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
1512
+ const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...(floating ? getOverflowAncestors(floating) : [])] : [];
1507
1513
  ancestors.forEach(ancestor => {
1508
1514
  ancestorScroll && ancestor.addEventListener('scroll', update, {
1509
1515
  passive: true
@@ -1516,7 +1522,7 @@ function autoUpdate(reference, floating, update, options) {
1516
1522
  if (elementResize) {
1517
1523
  resizeObserver = new ResizeObserver(_ref => {
1518
1524
  let [firstEntry] = _ref;
1519
- if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
1525
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
1520
1526
  // Prevent update loops when using the `size` middleware.
1521
1527
  // https://github.com/floating-ui/floating-ui/issues/1740
1522
1528
  resizeObserver.unobserve(floating);
@@ -1531,7 +1537,9 @@ function autoUpdate(reference, floating, update, options) {
1531
1537
  if (referenceEl && !animationFrame) {
1532
1538
  resizeObserver.observe(referenceEl);
1533
1539
  }
1534
- resizeObserver.observe(floating);
1540
+ if (floating) {
1541
+ resizeObserver.observe(floating);
1542
+ }
1535
1543
  }
1536
1544
  let frameId;
1537
1545
  let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var index = require('./index-DlHdtZvn.js');
4
- var floatingUi_dom = require('./floating-ui.dom-C8bqk2dV.js');
4
+ var floatingUi_dom = require('./floating-ui.dom-B0R5AR-j.js');
5
5
  var index$1 = require('./index-DcAhLZUH.js');
6
6
  var utils = require('./utils-UfZG-xPD.js');
7
7
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var index = require('./index-DlHdtZvn.js');
4
- var floatingUi_dom = require('./floating-ui.dom-C8bqk2dV.js');
4
+ var floatingUi_dom = require('./floating-ui.dom-B0R5AR-j.js');
5
5
  var index$1 = require('./index-DcAhLZUH.js');
6
6
  var utils = require('./utils-UfZG-xPD.js');
7
7
 
@@ -62,7 +62,7 @@ const SwirlMenu = class {
62
62
  this.position = await floatingUi_dom.computePosition(trigger, this.menuContainer, {
63
63
  placement: this.placement,
64
64
  strategy: "fixed",
65
- middleware: [floatingUi_dom.offset({ mainAxis: -10, crossAxis: 0 }), floatingUi_dom.shift(), floatingUi_dom.flip()],
65
+ middleware: [floatingUi_dom.offset({ mainAxis: -10, crossAxis: 0 }), floatingUi_dom.flip(), floatingUi_dom.shift()],
66
66
  });
67
67
  });
68
68
  };
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var index = require('./index-DlHdtZvn.js');
4
- var floatingUi_dom = require('./floating-ui.dom-C8bqk2dV.js');
4
+ var floatingUi_dom = require('./floating-ui.dom-B0R5AR-j.js');
5
5
  var bodyScrollLock = require('./body-scroll-lock-DVYwmTS6.js');
6
6
  var index$1 = require('./index-DcAhLZUH.js');
7
7
  var index_esm = require('./index.esm-D5HbQDBa.js');
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var index = require('./index-DlHdtZvn.js');
4
- var floatingUi_dom = require('./floating-ui.dom-C8bqk2dV.js');
4
+ var floatingUi_dom = require('./floating-ui.dom-B0R5AR-j.js');
5
5
  var index$1 = require('./index-DcAhLZUH.js');
6
6
  var utils = require('./utils-UfZG-xPD.js');
7
7
 
@@ -57,7 +57,7 @@ export class SwirlMenu {
57
57
  this.position = await computePosition(trigger, this.menuContainer, {
58
58
  placement: this.placement,
59
59
  strategy: "fixed",
60
- middleware: [offset({ mainAxis: -10, crossAxis: 0 }), shift(), flip()],
60
+ middleware: [offset({ mainAxis: -10, crossAxis: 0 }), flip(), shift()],
61
61
  });
62
62
  });
63
63
  };
@@ -1 +1 @@
1
- const t=Math.min,n=Math.max,e=Math.round,o=Math.floor,r=t=>({x:t,y:t}),i={left:"right",right:"left",bottom:"top",top:"bottom"},l={start:"end",end:"start"};function c(e,o,r){return n(e,t(o,r))}function a(t,n){return"function"==typeof t?t(n):t}function s(t){return t.split("-")[0]}function u(t){return t.split("-")[1]}function f(t){return"x"===t?"y":"x"}function d(t){return"y"===t?"height":"width"}const m=new Set(["top","bottom"]);function y(t){return m.has(s(t))?"y":"x"}function p(t){return f(y(t))}function h(t){return t.replace(/start|end/g,(t=>l[t]))}const w=["left","right"],g=["right","left"],x=["top","bottom"],v=["bottom","top"];function b(t){return t.replace(/left|right|bottom|top/g,(t=>i[t]))}function A(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function S(t){const{x:n,y:e,width:o,height:r}=t;return{width:o,height:r,top:e,left:n,right:n+o,bottom:e+r,x:n,y:e}}function R(t,n,e){let{reference:o,floating:r}=t;const i=y(n),l=p(n),c=d(l),a=s(n),f="y"===i,m=o.x+o.width/2-r.width/2,h=o.y+o.height/2-r.height/2,w=o[c]/2-r[c]/2;let g;switch(a){case"top":g={x:m,y:o.y-r.height};break;case"bottom":g={x:m,y:o.y+o.height};break;case"right":g={x:o.x+o.width,y:h};break;case"left":g={x:o.x-r.width,y:h};break;default:g={x:o.x,y:o.y}}switch(u(n)){case"start":g[l]-=w*(e&&f?-1:1);break;case"end":g[l]+=w*(e&&f?-1:1)}return g}async function F(t,n){var e;void 0===n&&(n={});const{x:o,y:r,platform:i,rects:l,elements:c,strategy:s}=t,{boundary:u="clippingAncestors",rootBoundary:f="viewport",elementContext:d="floating",altBoundary:m=!1,padding:y=0}=a(n,t),p=A(y),h=c[m?"floating"===d?"reference":"floating":d],w=S(await i.getClippingRect({element:null==(e=await(null==i.isElement?void 0:i.isElement(h)))||e?h:h.contextElement||await(null==i.getDocumentElement?void 0:i.getDocumentElement(c.floating)),boundary:u,rootBoundary:f,strategy:s})),g="floating"===d?{x:o,y:r,width:l.floating.width,height:l.floating.height}:l.reference,x=await(null==i.getOffsetParent?void 0:i.getOffsetParent(c.floating)),v=await(null==i.isElement?void 0:i.isElement(x))&&await(null==i.getScale?void 0:i.getScale(x))||{x:1,y:1},b=S(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:g,offsetParent:x,strategy:s}):g);return{top:(w.top-b.top+p.top)/v.y,bottom:(b.bottom-w.bottom+p.bottom)/v.y,left:(w.left-b.left+p.left)/v.x,right:(b.right-w.right+p.right)/v.x}}const k=new Set(["left","top"]);function O(){return"undefined"!=typeof window}function C(t){return M(t)?(t.nodeName||"").toLowerCase():"#document"}function T(t){var n;return(null==t||null==(n=t.ownerDocument)?void 0:n.defaultView)||window}function D(t){var n;return null==(n=(M(t)?t.ownerDocument:t.document)||window.document)?void 0:n.documentElement}function M(t){return!!O()&&(t instanceof Node||t instanceof T(t).Node)}function P(t){return!!O()&&(t instanceof Element||t instanceof T(t).Element)}function z(t){return!!O()&&(t instanceof HTMLElement||t instanceof T(t).HTMLElement)}function L(t){return!(!O()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof T(t).ShadowRoot)}const B=new Set(["inline","contents"]);function E(t){const{overflow:n,overflowX:e,overflowY:o,display:r}=G(t);return/auto|scroll|overlay|hidden|clip/.test(n+o+e)&&!B.has(r)}const I=new Set(["table","td","th"]);function N(t){return I.has(C(t))}const j=[":popover-open",":modal"];function q(t){return j.some((n=>{try{return t.matches(n)}catch(t){return!1}}))}const H=["transform","translate","scale","rotate","perspective"],$=["transform","translate","scale","rotate","perspective","filter"],V=["paint","layout","strict","content"];function W(t){const n=X(),e=P(t)?G(t):t;return H.some((t=>!!e[t]&&"none"!==e[t]))||!!e.containerType&&"normal"!==e.containerType||!n&&!!e.backdropFilter&&"none"!==e.backdropFilter||!n&&!!e.filter&&"none"!==e.filter||$.some((t=>(e.willChange||"").includes(t)))||V.some((t=>(e.contain||"").includes(t)))}function X(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const Y=new Set(["html","body","#document"]);function _(t){return Y.has(C(t))}function G(t){return T(t).getComputedStyle(t)}function J(t){return P(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function K(t){if("html"===C(t))return t;const n=t.assignedSlot||t.parentNode||L(t)&&t.host||D(t);return L(n)?n.host:n}function Q(t){const n=K(t);return _(n)?t.ownerDocument?t.ownerDocument.body:t.body:z(n)&&E(n)?n:Q(n)}function U(t,n,e){var o;void 0===n&&(n=[]),void 0===e&&(e=!0);const r=Q(t),i=r===(null==(o=t.ownerDocument)?void 0:o.body),l=T(r);if(i){const t=Z(l);return n.concat(l,l.visualViewport||[],E(r)?r:[],t&&e?U(t):[])}return n.concat(r,U(r,[],e))}function Z(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function tt(t){const n=G(t);let o=parseFloat(n.width)||0,r=parseFloat(n.height)||0;const i=z(t),l=i?t.offsetWidth:o,c=i?t.offsetHeight:r,a=e(o)!==l||e(r)!==c;return a&&(o=l,r=c),{width:o,height:r,$:a}}function nt(t){return P(t)?t:t.contextElement}function et(t){const n=nt(t);if(!z(n))return r(1);const o=n.getBoundingClientRect(),{width:i,height:l,$:c}=tt(n);let a=(c?e(o.width):o.width)/i,s=(c?e(o.height):o.height)/l;return a&&Number.isFinite(a)||(a=1),s&&Number.isFinite(s)||(s=1),{x:a,y:s}}const ot=r(0);function rt(t){const n=T(t);return X()&&n.visualViewport?{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}:ot}function it(t,n,e,o){void 0===n&&(n=!1),void 0===e&&(e=!1);const i=t.getBoundingClientRect(),l=nt(t);let c=r(1);n&&(o?P(o)&&(c=et(o)):c=et(t));const a=function(t,n,e){return void 0===n&&(n=!1),!(!e||n&&e!==T(t))&&n}(l,e,o)?rt(l):r(0);let s=(i.left+a.x)/c.x,u=(i.top+a.y)/c.y,f=i.width/c.x,d=i.height/c.y;if(l){const t=T(l),n=o&&P(o)?T(o):o;let e=t,r=Z(e);for(;r&&o&&n!==e;){const t=et(r),n=r.getBoundingClientRect(),o=G(r),i=n.left+(r.clientLeft+parseFloat(o.paddingLeft))*t.x,l=n.top+(r.clientTop+parseFloat(o.paddingTop))*t.y;s*=t.x,u*=t.y,f*=t.x,d*=t.y,s+=i,u+=l,e=T(r),r=Z(e)}}return S({width:f,height:d,x:s,y:u})}function lt(t,n){const e=J(t).scrollLeft;return n?n.left+e:it(D(t)).left+e}function ct(t,n){const e=t.getBoundingClientRect();return{x:e.left+n.scrollLeft-lt(t,e),y:e.top+n.scrollTop}}const at=new Set(["absolute","fixed"]);function st(t,e,o){let i;if("viewport"===e)i=function(t,n){const e=T(t),o=D(t),r=e.visualViewport;let i=o.clientWidth,l=o.clientHeight,c=0,a=0;if(r){i=r.width,l=r.height;const t=X();(!t||t&&"fixed"===n)&&(c=r.offsetLeft,a=r.offsetTop)}const s=lt(o);if(s<=0){const t=o.ownerDocument,n=t.body,e=getComputedStyle(n),r="CSS1Compat"===t.compatMode&&parseFloat(e.marginLeft)+parseFloat(e.marginRight)||0,l=Math.abs(o.clientWidth-n.clientWidth-r);l<=25&&(i-=l)}else s<=25&&(i+=s);return{width:i,height:l,x:c,y:a}}(t,o);else if("document"===e)i=function(t){const e=D(t),o=J(t),r=t.ownerDocument.body,i=n(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),l=n(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let c=-o.scrollLeft+lt(t);const a=-o.scrollTop;return"rtl"===G(r).direction&&(c+=n(e.clientWidth,r.clientWidth)-i),{width:i,height:l,x:c,y:a}}(D(t));else if(P(e))i=function(t,n){const e=it(t,!0,"fixed"===n),o=e.top+t.clientTop,i=e.left+t.clientLeft,l=z(t)?et(t):r(1);return{width:t.clientWidth*l.x,height:t.clientHeight*l.y,x:i*l.x,y:o*l.y}}(e,o);else{const n=rt(t);i={x:e.x-n.x,y:e.y-n.y,width:e.width,height:e.height}}return S(i)}function ut(t,n){const e=K(t);return!(e===n||!P(e)||_(e))&&("fixed"===G(e).position||ut(e,n))}function ft(t,n,e){const o=z(n),i=D(n),l="fixed"===e,c=it(t,!0,l,n);let a={scrollLeft:0,scrollTop:0};const s=r(0);function u(){s.x=lt(i)}if(o||!o&&!l)if(("body"!==C(n)||E(i))&&(a=J(n)),o){const t=it(n,!0,l,n);s.x=t.x+n.clientLeft,s.y=t.y+n.clientTop}else i&&u();l&&!o&&i&&u();const f=!i||o||l?r(0):ct(i,a);return{x:c.left+a.scrollLeft-s.x-f.x,y:c.top+a.scrollTop-s.y-f.y,width:c.width,height:c.height}}function dt(t){return"static"===G(t).position}function mt(t,n){if(!z(t)||"fixed"===G(t).position)return null;if(n)return n(t);let e=t.offsetParent;return D(t)===e&&(e=e.ownerDocument.body),e}function yt(t,n){const e=T(t);if(q(t))return e;if(!z(t)){let n=K(t);for(;n&&!_(n);){if(P(n)&&!dt(n))return n;n=K(n)}return e}let o=mt(t,n);for(;o&&N(o)&&dt(o);)o=mt(o,n);return o&&_(o)&&dt(o)&&!W(o)?e:o||function(t){let n=K(t);for(;z(n)&&!_(n);){if(W(n))return n;if(q(n))return null;n=K(n)}return null}(t)||e}const pt={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:n,rect:e,offsetParent:o,strategy:i}=t;const l="fixed"===i,c=D(o),a=!!n&&q(n.floating);if(o===c||a&&l)return e;let s={scrollLeft:0,scrollTop:0},u=r(1);const f=r(0),d=z(o);if((d||!d&&!l)&&(("body"!==C(o)||E(c))&&(s=J(o)),z(o))){const t=it(o);u=et(o),f.x=t.x+o.clientLeft,f.y=t.y+o.clientTop}const m=!c||d||l?r(0):ct(c,s);return{width:e.width*u.x,height:e.height*u.y,x:e.x*u.x-s.scrollLeft*u.x+f.x+m.x,y:e.y*u.y-s.scrollTop*u.y+f.y+m.y}},getDocumentElement:D,getClippingRect:function(e){let{element:o,boundary:r,rootBoundary:i,strategy:l}=e;const c=[..."clippingAncestors"===r?q(o)?[]:function(t,n){const e=n.get(t);if(e)return e;let o=U(t,[],!1).filter((t=>P(t)&&"body"!==C(t))),r=null;const i="fixed"===G(t).position;let l=i?K(t):t;for(;P(l)&&!_(l);){const n=G(l),e=W(l);e||"fixed"!==n.position||(r=null),(i?!e&&!r:!e&&"static"===n.position&&r&&at.has(r.position)||E(l)&&!e&&ut(t,l))?o=o.filter((t=>t!==l)):r=n,l=K(l)}return n.set(t,o),o}(o,this._c):[].concat(r),i],a=c.reduce(((e,r)=>{const i=st(o,r,l);return e.top=n(i.top,e.top),e.right=t(i.right,e.right),e.bottom=t(i.bottom,e.bottom),e.left=n(i.left,e.left),e}),st(o,c[0],l));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:yt,getElementRects:async function(t){const n=this.getOffsetParent||yt,e=this.getDimensions,o=await e(t.floating);return{reference:ft(t.reference,await n(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){const{width:n,height:e}=tt(t);return{width:n,height:e}},getScale:et,isElement:P,isRTL:function(t){return"rtl"===G(t).direction}};function ht(t,n){return t.x===n.x&&t.y===n.y&&t.width===n.width&&t.height===n.height}function wt(e,r,i,l){void 0===l&&(l={});const{ancestorScroll:c=!0,ancestorResize:a=!0,elementResize:s="function"==typeof ResizeObserver,layoutShift:u="function"==typeof IntersectionObserver,animationFrame:f=!1}=l,d=nt(e),m=c||a?[...d?U(d):[],...U(r)]:[];m.forEach((t=>{c&&t.addEventListener("scroll",i,{passive:!0}),a&&t.addEventListener("resize",i)}));const y=d&&u?function(e,r){let i,l=null;const c=D(e);function a(){var t;clearTimeout(i),null==(t=l)||t.disconnect(),l=null}return function s(u,f){void 0===u&&(u=!1),void 0===f&&(f=1),a();const d=e.getBoundingClientRect(),{left:m,top:y,width:p,height:h}=d;if(u||r(),!p||!h)return;const w={rootMargin:-o(y)+"px "+-o(c.clientWidth-(m+p))+"px "+-o(c.clientHeight-(y+h))+"px "+-o(m)+"px",threshold:n(0,t(1,f))||1};let g=!0;function x(t){const n=t[0].intersectionRatio;if(n!==f){if(!g)return s();n?s(!1,n):i=setTimeout((()=>{s(!1,1e-7)}),1e3)}1!==n||ht(d,e.getBoundingClientRect())||s(),g=!1}try{l=new IntersectionObserver(x,{...w,root:c.ownerDocument})}catch(t){l=new IntersectionObserver(x,w)}l.observe(e)}(!0),a}(d,i):null;let p,h=-1,w=null;s&&(w=new ResizeObserver((t=>{let[n]=t;n&&n.target===d&&w&&(w.unobserve(r),cancelAnimationFrame(h),h=requestAnimationFrame((()=>{var t;null==(t=w)||t.observe(r)}))),i()})),d&&!f&&w.observe(d),w.observe(r));let g=f?it(e):null;return f&&function t(){const n=it(e);g&&!ht(g,n)&&i(),g=n,p=requestAnimationFrame(t)}(),i(),()=>{var t;m.forEach((t=>{c&&t.removeEventListener("scroll",i),a&&t.removeEventListener("resize",i)})),null==y||y(),null==(t=w)||t.disconnect(),w=null,f&&cancelAnimationFrame(p)}}const gt=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(n){var e,o;const{x:r,y:i,placement:l,middlewareData:c}=n,f=await async function(t,n){const{placement:e,platform:o,elements:r}=t,i=await(null==o.isRTL?void 0:o.isRTL(r.floating)),l=s(e),c=u(e),f="y"===y(e),d=k.has(l)?-1:1,m=i&&f?-1:1,p=a(n,t);let{mainAxis:h,crossAxis:w,alignmentAxis:g}="number"==typeof p?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return c&&"number"==typeof g&&(w="end"===c?-1*g:g),f?{x:w*m,y:h*d}:{x:h*d,y:w*m}}(n,t);return l===(null==(e=c.offset)?void 0:e.placement)&&null!=(o=c.arrow)&&o.alignmentOffset?{}:{x:r+f.x,y:i+f.y,data:{...f,placement:l}}}}},xt=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(n){const{x:e,y:o,placement:r,platform:i}=n,{mainAxis:l=!0,crossAxis:u=!1,limiter:d={fn:t=>{let{x:n,y:e}=t;return{x:n,y:e}}},...m}=a(t,n),p={x:e,y:o},h=await i.detectOverflow(n,m),w=y(s(r)),g=f(w);let x=p[g],v=p[w];l&&(x=c(x+h["y"===g?"top":"left"],x,x-h["y"===g?"bottom":"right"])),u&&(v=c(v+h["y"===w?"top":"left"],v,v-h["y"===w?"bottom":"right"]));const b=d.fn({...n,[g]:x,[w]:v});return{...b,data:{x:b.x-e,y:b.y-o,enabled:{[g]:l,[w]:u}}}}}},vt=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(n){var e,o;const{placement:r,middlewareData:i,rects:l,initialPlacement:c,platform:f,elements:m}=n,{mainAxis:A=!0,crossAxis:S=!0,fallbackPlacements:R,fallbackStrategy:F="bestFit",fallbackAxisSideDirection:k="none",flipAlignment:O=!0,...C}=a(t,n);if(null!=(e=i.arrow)&&e.alignmentOffset)return{};const T=s(r),D=y(c),M=s(c)===c,P=await(null==f.isRTL?void 0:f.isRTL(m.floating)),z=R||(M||!O?[b(c)]:function(t){const n=b(t);return[h(t),n,h(n)]}(c)),L="none"!==k;!R&&L&&z.push(...function(t,n,e,o){const r=u(t);let i=function(t,n,e){switch(t){case"top":case"bottom":return e?n?g:w:n?w:g;case"left":case"right":return n?x:v;default:return[]}}(s(t),"start"===e,o);return r&&(i=i.map((t=>t+"-"+r)),n&&(i=i.concat(i.map(h)))),i}(c,O,k,P));const B=[c,...z],E=await f.detectOverflow(n,C),I=[];let N=(null==(o=i.flip)?void 0:o.overflows)||[];if(A&&I.push(E[T]),S){const t=function(t,n,e){void 0===e&&(e=!1);const o=u(t),r=p(t),i=d(r);let l="x"===r?o===(e?"end":"start")?"right":"left":"start"===o?"bottom":"top";return n.reference[i]>n.floating[i]&&(l=b(l)),[l,b(l)]}(r,l,P);I.push(E[t[0]],E[t[1]])}if(N=[...N,{placement:r,overflows:I}],!I.every((t=>t<=0))){var j,q;const t=((null==(j=i.flip)?void 0:j.index)||0)+1,n=B[t];if(n&&("alignment"!==S||D===y(n)||N.every((t=>y(t.placement)!==D||t.overflows[0]>0))))return{data:{index:t,overflows:N},reset:{placement:n}};let e=null==(q=N.filter((t=>t.overflows[0]<=0)).sort(((t,n)=>t.overflows[1]-n.overflows[1]))[0])?void 0:q.placement;if(!e)switch(F){case"bestFit":{var H;const t=null==(H=N.filter((t=>{if(L){const n=y(t.placement);return n===D||"y"===n}return!0})).map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,n)=>t+n),0)])).sort(((t,n)=>t[1]-n[1]))[0])?void 0:H[0];t&&(e=t);break}case"initialPlacement":e=c}if(r!==e)return{reset:{placement:e}}}return{}}}},bt=n=>({name:"arrow",options:n,async fn(e){const{x:o,y:r,placement:i,rects:l,platform:s,elements:f,middlewareData:m}=e,{element:y,padding:h=0}=a(n,e)||{};if(null==y)return{};const w=A(h),g={x:o,y:r},x=p(i),v=d(x),b=await s.getDimensions(y),S="y"===x,R=S?"top":"left",F=S?"bottom":"right",k=S?"clientHeight":"clientWidth",O=l.reference[v]+l.reference[x]-g[x]-l.floating[v],C=g[x]-l.reference[x],T=await(null==s.getOffsetParent?void 0:s.getOffsetParent(y));let D=T?T[k]:0;D&&await(null==s.isElement?void 0:s.isElement(T))||(D=f.floating[k]||l.floating[v]);const M=O/2-C/2,P=D/2-b[v]/2-1,z=t(w[R],P),L=t(w[F],P),B=z,E=D-b[v]-L,I=D/2-b[v]/2+M,N=c(B,I,E),j=!m.arrow&&null!=u(i)&&I!==N&&l.reference[v]/2-(I<B?z:L)-b[v]/2<0,q=j?I<B?I-B:I-E:0;return{[x]:g[x]+q,data:{[x]:N,centerOffset:I-N-q,...j&&{alignmentOffset:q}},reset:j}}}),At=(t,n,e)=>{const o=new Map,r={platform:pt,...e},i={...r.platform,_c:o};return(async(t,n,e)=>{const{placement:o="bottom",strategy:r="absolute",middleware:i=[],platform:l}=e,c=i.filter(Boolean),a=await(null==l.isRTL?void 0:l.isRTL(n));let s=await l.getElementRects({reference:t,floating:n,strategy:r}),{x:u,y:f}=R(s,o,a),d=o,m={},y=0;for(let e=0;e<c.length;e++){var p;const{name:i,fn:h}=c[e],{x:w,y:g,data:x,reset:v}=await h({x:u,y:f,initialPlacement:o,placement:d,strategy:r,middlewareData:m,rects:s,platform:{...l,detectOverflow:null!=(p=l.detectOverflow)?p:F},elements:{reference:t,floating:n}});u=null!=w?w:u,f=null!=g?g:f,m={...m,[i]:{...m[i],...x}},v&&y<=50&&(y++,"object"==typeof v&&(v.placement&&(d=v.placement),v.rects&&(s=!0===v.rects?await l.getElementRects({reference:t,floating:n,strategy:r}):v.rects),({x:u,y:f}=R(s,d,a))),e=-1)}return{x:u,y:f,placement:d,strategy:r,middlewareData:m}})(t,n,{...r,platform:i})};export{wt as a,bt as b,At as c,vt as f,gt as o,xt as s}
1
+ const t=Math.min,n=Math.max,e=Math.round,o=Math.floor,r=t=>({x:t,y:t}),i={left:"right",right:"left",bottom:"top",top:"bottom"};function c(e,o,r){return n(e,t(o,r))}function l(t,n){return"function"==typeof t?t(n):t}function a(t){return t.split("-")[0]}function s(t){return t.split("-")[1]}function u(t){return"x"===t?"y":"x"}function f(t){return"y"===t?"height":"width"}function d(t){const n=t[0];return"t"===n||"b"===n?"y":"x"}function m(t){return u(d(t))}function y(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const h=["left","right"],p=["right","left"],w=["top","bottom"],x=["bottom","top"];function g(t){const n=a(t);return i[n]+t.slice(n.length)}function v(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function b(t){const{x:n,y:e,width:o,height:r}=t;return{width:o,height:r,top:e,left:n,right:n+o,bottom:e+r,x:n,y:e}}function A(t,n,e){let{reference:o,floating:r}=t;const i=d(n),c=m(n),l=f(c),u=a(n),y="y"===i,h=o.x+o.width/2-r.width/2,p=o.y+o.height/2-r.height/2,w=o[l]/2-r[l]/2;let x;switch(u){case"top":x={x:h,y:o.y-r.height};break;case"bottom":x={x:h,y:o.y+o.height};break;case"right":x={x:o.x+o.width,y:p};break;case"left":x={x:o.x-r.width,y:p};break;default:x={x:o.x,y:o.y}}switch(s(n)){case"start":x[c]-=w*(e&&y?-1:1);break;case"end":x[c]+=w*(e&&y?-1:1)}return x}async function S(t,n){var e;void 0===n&&(n={});const{x:o,y:r,platform:i,rects:c,elements:a,strategy:s}=t,{boundary:u="clippingAncestors",rootBoundary:f="viewport",elementContext:d="floating",altBoundary:m=!1,padding:y=0}=l(n,t),h=v(y),p=a[m?"floating"===d?"reference":"floating":d],w=b(await i.getClippingRect({element:null==(e=await(null==i.isElement?void 0:i.isElement(p)))||e?p:p.contextElement||await(null==i.getDocumentElement?void 0:i.getDocumentElement(a.floating)),boundary:u,rootBoundary:f,strategy:s})),x="floating"===d?{x:o,y:r,width:c.floating.width,height:c.floating.height}:c.reference,g=await(null==i.getOffsetParent?void 0:i.getOffsetParent(a.floating)),A=await(null==i.isElement?void 0:i.isElement(g))&&await(null==i.getScale?void 0:i.getScale(g))||{x:1,y:1},S=b(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:x,offsetParent:g,strategy:s}):x);return{top:(w.top-S.top+h.top)/A.y,bottom:(S.bottom-w.bottom+h.bottom)/A.y,left:(w.left-S.left+h.left)/A.x,right:(S.right-w.right+h.right)/A.x}}const R=new Set(["left","top"]);function F(){return"undefined"!=typeof window}function k(t){return T(t)?(t.nodeName||"").toLowerCase():"#document"}function O(t){var n;return(null==t||null==(n=t.ownerDocument)?void 0:n.defaultView)||window}function C(t){var n;return null==(n=(T(t)?t.ownerDocument:t.document)||window.document)?void 0:n.documentElement}function T(t){return!!F()&&(t instanceof Node||t instanceof O(t).Node)}function D(t){return!!F()&&(t instanceof Element||t instanceof O(t).Element)}function M(t){return!!F()&&(t instanceof HTMLElement||t instanceof O(t).HTMLElement)}function P(t){return!(!F()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof O(t).ShadowRoot)}function z(t){const{overflow:n,overflowX:e,overflowY:o,display:r}=V(t);return/auto|scroll|overlay|hidden|clip/.test(n+o+e)&&"inline"!==r&&"contents"!==r}function L(t){return/^(table|td|th)$/.test(k(t))}function E(t){try{if(t.matches(":popover-open"))return!0}catch(t){}try{return t.matches(":modal")}catch(t){return!1}}const B=/transform|translate|scale|rotate|perspective|filter/,$=/paint|layout|strict|content/,I=t=>!!t&&"none"!==t;let N;function j(t){const n=D(t)?V(t):t;return I(n.transform)||I(n.translate)||I(n.scale)||I(n.rotate)||I(n.perspective)||!q()&&(I(n.backdropFilter)||I(n.filter))||B.test(n.willChange||"")||$.test(n.contain||"")}function q(){return null==N&&(N="undefined"!=typeof CSS&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),N}function H(t){return/^(html|body|#document)$/.test(k(t))}function V(t){return O(t).getComputedStyle(t)}function W(t){return D(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function X(t){if("html"===k(t))return t;const n=t.assignedSlot||t.parentNode||P(t)&&t.host||C(t);return P(n)?n.host:n}function Y(t){const n=X(t);return H(n)?t.ownerDocument?t.ownerDocument.body:t.body:M(n)&&z(n)?n:Y(n)}function _(t,n,e){var o;void 0===n&&(n=[]),void 0===e&&(e=!0);const r=Y(t),i=r===(null==(o=t.ownerDocument)?void 0:o.body),c=O(r);if(i){const t=G(c);return n.concat(c,c.visualViewport||[],z(r)?r:[],t&&e?_(t):[])}return n.concat(r,_(r,[],e))}function G(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function J(t){const n=V(t);let o=parseFloat(n.width)||0,r=parseFloat(n.height)||0;const i=M(t),c=i?t.offsetWidth:o,l=i?t.offsetHeight:r,a=e(o)!==c||e(r)!==l;return a&&(o=c,r=l),{width:o,height:r,$:a}}function K(t){return D(t)?t:t.contextElement}function Q(t){const n=K(t);if(!M(n))return r(1);const o=n.getBoundingClientRect(),{width:i,height:c,$:l}=J(n);let a=(l?e(o.width):o.width)/i,s=(l?e(o.height):o.height)/c;return a&&Number.isFinite(a)||(a=1),s&&Number.isFinite(s)||(s=1),{x:a,y:s}}const U=r(0);function Z(t){const n=O(t);return q()&&n.visualViewport?{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}:U}function tt(t,n,e,o){void 0===n&&(n=!1),void 0===e&&(e=!1);const i=t.getBoundingClientRect(),c=K(t);let l=r(1);n&&(o?D(o)&&(l=Q(o)):l=Q(t));const a=function(t,n,e){return void 0===n&&(n=!1),!(!e||n&&e!==O(t))&&n}(c,e,o)?Z(c):r(0);let s=(i.left+a.x)/l.x,u=(i.top+a.y)/l.y,f=i.width/l.x,d=i.height/l.y;if(c){const t=O(c),n=o&&D(o)?O(o):o;let e=t,r=G(e);for(;r&&o&&n!==e;){const t=Q(r),n=r.getBoundingClientRect(),o=V(r),i=n.left+(r.clientLeft+parseFloat(o.paddingLeft))*t.x,c=n.top+(r.clientTop+parseFloat(o.paddingTop))*t.y;s*=t.x,u*=t.y,f*=t.x,d*=t.y,s+=i,u+=c,e=O(r),r=G(e)}}return b({width:f,height:d,x:s,y:u})}function nt(t,n){const e=W(t).scrollLeft;return n?n.left+e:tt(C(t)).left+e}function et(t,n){const e=t.getBoundingClientRect();return{x:e.left+n.scrollLeft-nt(t,e),y:e.top+n.scrollTop}}function ot(t,e,o){let i;if("viewport"===e)i=function(t,n){const e=O(t),o=C(t),r=e.visualViewport;let i=o.clientWidth,c=o.clientHeight,l=0,a=0;if(r){i=r.width,c=r.height;const t=q();(!t||t&&"fixed"===n)&&(l=r.offsetLeft,a=r.offsetTop)}const s=nt(o);if(s<=0){const t=o.ownerDocument,n=t.body,e=getComputedStyle(n),r="CSS1Compat"===t.compatMode&&parseFloat(e.marginLeft)+parseFloat(e.marginRight)||0,c=Math.abs(o.clientWidth-n.clientWidth-r);c<=25&&(i-=c)}else s<=25&&(i+=s);return{width:i,height:c,x:l,y:a}}(t,o);else if("document"===e)i=function(t){const e=C(t),o=W(t),r=t.ownerDocument.body,i=n(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),c=n(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let l=-o.scrollLeft+nt(t);const a=-o.scrollTop;return"rtl"===V(r).direction&&(l+=n(e.clientWidth,r.clientWidth)-i),{width:i,height:c,x:l,y:a}}(C(t));else if(D(e))i=function(t,n){const e=tt(t,!0,"fixed"===n),o=e.top+t.clientTop,i=e.left+t.clientLeft,c=M(t)?Q(t):r(1);return{width:t.clientWidth*c.x,height:t.clientHeight*c.y,x:i*c.x,y:o*c.y}}(e,o);else{const n=Z(t);i={x:e.x-n.x,y:e.y-n.y,width:e.width,height:e.height}}return b(i)}function rt(t,n){const e=X(t);return!(e===n||!D(e)||H(e))&&("fixed"===V(e).position||rt(e,n))}function it(t,n,e){const o=M(n),i=C(n),c="fixed"===e,l=tt(t,!0,c,n);let a={scrollLeft:0,scrollTop:0};const s=r(0);function u(){s.x=nt(i)}if(o||!o&&!c)if(("body"!==k(n)||z(i))&&(a=W(n)),o){const t=tt(n,!0,c,n);s.x=t.x+n.clientLeft,s.y=t.y+n.clientTop}else i&&u();c&&!o&&i&&u();const f=!i||o||c?r(0):et(i,a);return{x:l.left+a.scrollLeft-s.x-f.x,y:l.top+a.scrollTop-s.y-f.y,width:l.width,height:l.height}}function ct(t){return"static"===V(t).position}function lt(t,n){if(!M(t)||"fixed"===V(t).position)return null;if(n)return n(t);let e=t.offsetParent;return C(t)===e&&(e=e.ownerDocument.body),e}function at(t,n){const e=O(t);if(E(t))return e;if(!M(t)){let n=X(t);for(;n&&!H(n);){if(D(n)&&!ct(n))return n;n=X(n)}return e}let o=lt(t,n);for(;o&&L(o)&&ct(o);)o=lt(o,n);return o&&H(o)&&ct(o)&&!j(o)?e:o||function(t){let n=X(t);for(;M(n)&&!H(n);){if(j(n))return n;if(E(n))return null;n=X(n)}return null}(t)||e}const st={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:n,rect:e,offsetParent:o,strategy:i}=t;const c="fixed"===i,l=C(o),a=!!n&&E(n.floating);if(o===l||a&&c)return e;let s={scrollLeft:0,scrollTop:0},u=r(1);const f=r(0),d=M(o);if((d||!d&&!c)&&(("body"!==k(o)||z(l))&&(s=W(o)),d)){const t=tt(o);u=Q(o),f.x=t.x+o.clientLeft,f.y=t.y+o.clientTop}const m=!l||d||c?r(0):et(l,s);return{width:e.width*u.x,height:e.height*u.y,x:e.x*u.x-s.scrollLeft*u.x+f.x+m.x,y:e.y*u.y-s.scrollTop*u.y+f.y+m.y}},getDocumentElement:C,getClippingRect:function(e){let{element:o,boundary:r,rootBoundary:i,strategy:c}=e;const l=[..."clippingAncestors"===r?E(o)?[]:function(t,n){const e=n.get(t);if(e)return e;let o=_(t,[],!1).filter((t=>D(t)&&"body"!==k(t))),r=null;const i="fixed"===V(t).position;let c=i?X(t):t;for(;D(c)&&!H(c);){const n=V(c),e=j(c);e||"fixed"!==n.position||(r=null),(i?!e&&!r:!e&&"static"===n.position&&r&&("absolute"===r.position||"fixed"===r.position)||z(c)&&!e&&rt(t,c))?o=o.filter((t=>t!==c)):r=n,c=X(c)}return n.set(t,o),o}(o,this._c):[].concat(r),i],a=ot(o,l[0],c);let s=a.top,u=a.right,f=a.bottom,d=a.left;for(let e=1;e<l.length;e++){const r=ot(o,l[e],c);s=n(r.top,s),u=t(r.right,u),f=t(r.bottom,f),d=n(r.left,d)}return{width:u-d,height:f-s,x:d,y:s}},getOffsetParent:at,getElementRects:async function(t){const n=this.getOffsetParent||at,e=this.getDimensions,o=await e(t.floating);return{reference:it(t.reference,await n(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){const{width:n,height:e}=J(t);return{width:n,height:e}},getScale:Q,isElement:D,isRTL:function(t){return"rtl"===V(t).direction}};function ut(t,n){return t.x===n.x&&t.y===n.y&&t.width===n.width&&t.height===n.height}function ft(e,r,i,c){void 0===c&&(c={});const{ancestorScroll:l=!0,ancestorResize:a=!0,elementResize:s="function"==typeof ResizeObserver,layoutShift:u="function"==typeof IntersectionObserver,animationFrame:f=!1}=c,d=K(e),m=l||a?[...d?_(d):[],...r?_(r):[]]:[];m.forEach((t=>{l&&t.addEventListener("scroll",i,{passive:!0}),a&&t.addEventListener("resize",i)}));const y=d&&u?function(e,r){let i,c=null;const l=C(e);function a(){var t;clearTimeout(i),null==(t=c)||t.disconnect(),c=null}return function s(u,f){void 0===u&&(u=!1),void 0===f&&(f=1),a();const d=e.getBoundingClientRect(),{left:m,top:y,width:h,height:p}=d;if(u||r(),!h||!p)return;const w={rootMargin:-o(y)+"px "+-o(l.clientWidth-(m+h))+"px "+-o(l.clientHeight-(y+p))+"px "+-o(m)+"px",threshold:n(0,t(1,f))||1};let x=!0;function g(t){const n=t[0].intersectionRatio;if(n!==f){if(!x)return s();n?s(!1,n):i=setTimeout((()=>{s(!1,1e-7)}),1e3)}1!==n||ut(d,e.getBoundingClientRect())||s(),x=!1}try{c=new IntersectionObserver(g,{...w,root:l.ownerDocument})}catch(t){c=new IntersectionObserver(g,w)}c.observe(e)}(!0),a}(d,i):null;let h,p=-1,w=null;s&&(w=new ResizeObserver((t=>{let[n]=t;n&&n.target===d&&w&&r&&(w.unobserve(r),cancelAnimationFrame(p),p=requestAnimationFrame((()=>{var t;null==(t=w)||t.observe(r)}))),i()})),d&&!f&&w.observe(d),r&&w.observe(r));let x=f?tt(e):null;return f&&function t(){const n=tt(e);x&&!ut(x,n)&&i(),x=n,h=requestAnimationFrame(t)}(),i(),()=>{var t;m.forEach((t=>{l&&t.removeEventListener("scroll",i),a&&t.removeEventListener("resize",i)})),null==y||y(),null==(t=w)||t.disconnect(),w=null,f&&cancelAnimationFrame(h)}}const dt=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(n){var e,o;const{x:r,y:i,placement:c,middlewareData:u}=n,f=await async function(t,n){const{placement:e,platform:o,elements:r}=t,i=await(null==o.isRTL?void 0:o.isRTL(r.floating)),c=a(e),u=s(e),f="y"===d(e),m=R.has(c)?-1:1,y=i&&f?-1:1,h=l(n,t);let{mainAxis:p,crossAxis:w,alignmentAxis:x}="number"==typeof h?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return u&&"number"==typeof x&&(w="end"===u?-1*x:x),f?{x:w*y,y:p*m}:{x:p*m,y:w*y}}(n,t);return c===(null==(e=u.offset)?void 0:e.placement)&&null!=(o=u.arrow)&&o.alignmentOffset?{}:{x:r+f.x,y:i+f.y,data:{...f,placement:c}}}}},mt=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(n){const{x:e,y:o,placement:r,platform:i}=n,{mainAxis:s=!0,crossAxis:f=!1,limiter:m={fn:t=>{let{x:n,y:e}=t;return{x:n,y:e}}},...y}=l(t,n),h={x:e,y:o},p=await i.detectOverflow(n,y),w=d(a(r)),x=u(w);let g=h[x],v=h[w];s&&(g=c(g+p["y"===x?"top":"left"],g,g-p["y"===x?"bottom":"right"])),f&&(v=c(v+p["y"===w?"top":"left"],v,v-p["y"===w?"bottom":"right"]));const b=m.fn({...n,[x]:g,[w]:v});return{...b,data:{x:b.x-e,y:b.y-o,enabled:{[x]:s,[w]:f}}}}}},yt=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(n){var e,o;const{placement:r,middlewareData:i,rects:c,initialPlacement:u,platform:v,elements:b}=n,{mainAxis:A=!0,crossAxis:S=!0,fallbackPlacements:R,fallbackStrategy:F="bestFit",fallbackAxisSideDirection:k="none",flipAlignment:O=!0,...C}=l(t,n);if(null!=(e=i.arrow)&&e.alignmentOffset)return{};const T=a(r),D=d(u),M=a(u)===u,P=await(null==v.isRTL?void 0:v.isRTL(b.floating)),z=R||(M||!O?[g(u)]:function(t){const n=g(t);return[y(t),n,y(n)]}(u)),L="none"!==k;!R&&L&&z.push(...function(t,n,e,o){const r=s(t);let i=function(t,n,e){switch(t){case"top":case"bottom":return e?n?p:h:n?h:p;case"left":case"right":return n?w:x;default:return[]}}(a(t),"start"===e,o);return r&&(i=i.map((t=>t+"-"+r)),n&&(i=i.concat(i.map(y)))),i}(u,O,k,P));const E=[u,...z],B=await v.detectOverflow(n,C),$=[];let I=(null==(o=i.flip)?void 0:o.overflows)||[];if(A&&$.push(B[T]),S){const t=function(t,n,e){void 0===e&&(e=!1);const o=s(t),r=m(t),i=f(r);let c="x"===r?o===(e?"end":"start")?"right":"left":"start"===o?"bottom":"top";return n.reference[i]>n.floating[i]&&(c=g(c)),[c,g(c)]}(r,c,P);$.push(B[t[0]],B[t[1]])}if(I=[...I,{placement:r,overflows:$}],!$.every((t=>t<=0))){var N,j;const t=((null==(N=i.flip)?void 0:N.index)||0)+1,n=E[t];if(n&&("alignment"!==S||D===d(n)||I.every((t=>d(t.placement)!==D||t.overflows[0]>0))))return{data:{index:t,overflows:I},reset:{placement:n}};let e=null==(j=I.filter((t=>t.overflows[0]<=0)).sort(((t,n)=>t.overflows[1]-n.overflows[1]))[0])?void 0:j.placement;if(!e)switch(F){case"bestFit":{var q;const t=null==(q=I.filter((t=>{if(L){const n=d(t.placement);return n===D||"y"===n}return!0})).map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,n)=>t+n),0)])).sort(((t,n)=>t[1]-n[1]))[0])?void 0:q[0];t&&(e=t);break}case"initialPlacement":e=u}if(r!==e)return{reset:{placement:e}}}return{}}}},ht=n=>({name:"arrow",options:n,async fn(e){const{x:o,y:r,placement:i,rects:a,platform:u,elements:d,middlewareData:y}=e,{element:h,padding:p=0}=l(n,e)||{};if(null==h)return{};const w=v(p),x={x:o,y:r},g=m(i),b=f(g),A=await u.getDimensions(h),S="y"===g,R=S?"top":"left",F=S?"bottom":"right",k=S?"clientHeight":"clientWidth",O=a.reference[b]+a.reference[g]-x[g]-a.floating[b],C=x[g]-a.reference[g],T=await(null==u.getOffsetParent?void 0:u.getOffsetParent(h));let D=T?T[k]:0;D&&await(null==u.isElement?void 0:u.isElement(T))||(D=d.floating[k]||a.floating[b]);const M=O/2-C/2,P=D/2-A[b]/2-1,z=t(w[R],P),L=t(w[F],P),E=z,B=D-A[b]-L,$=D/2-A[b]/2+M,I=c(E,$,B),N=!y.arrow&&null!=s(i)&&$!==I&&a.reference[b]/2-($<E?z:L)-A[b]/2<0,j=N?$<E?$-E:$-B:0;return{[g]:x[g]+j,data:{[g]:I,centerOffset:$-I-j,...N&&{alignmentOffset:j}},reset:N}}}),pt=(t,n,e)=>{const o=new Map,r={platform:st,...e},i={...r.platform,_c:o};return(async(t,n,e)=>{const{placement:o="bottom",strategy:r="absolute",middleware:i=[],platform:c}=e,l=c.detectOverflow?c:{...c,detectOverflow:S},a=await(null==c.isRTL?void 0:c.isRTL(n));let s=await c.getElementRects({reference:t,floating:n,strategy:r}),{x:u,y:f}=A(s,o,a),d=o,m=0;const y={};for(let e=0;e<i.length;e++){const h=i[e];if(!h)continue;const{name:p,fn:w}=h,{x,y:g,data:v,reset:b}=await w({x:u,y:f,initialPlacement:o,placement:d,strategy:r,middlewareData:y,rects:s,platform:l,elements:{reference:t,floating:n}});u=null!=x?x:u,f=null!=g?g:f,y[p]={...y[p],...v},b&&m<50&&(m++,"object"==typeof b&&(b.placement&&(d=b.placement),b.rects&&(s=!0===b.rects?await c.getElementRects({reference:t,floating:n,strategy:r}):b.rects),({x:u,y:f}=A(s,d,a))),e=-1)}return{x:u,y:f,placement:d,strategy:r,middlewareData:y}})(t,n,{...r,platform:i})};export{ft as a,ht as b,pt as c,yt as f,dt as o,mt as s}
@@ -1 +1 @@
1
- import{proxyCustomElement as t,HTMLElement as e,createEvent as i,h as s,Host as n,transformTag as o}from"@stencil/core/internal/client";import{c as a,a as h,o as l,s as r,f as m}from"./floating-ui.dom.js";import{c}from"./index2.js";import{q as u,l as d,m as b,i as f,k as p}from"./utils.js";import{d as w}from"./swirl-button2.js";import{d as v}from"./swirl-heading2.js";const y=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.done=i(this,"done",7),this.valueChange=i(this,"valueChange",7),this.active=!0,this.level=0,this.mobileBackButtonLabel="Back",this.mobileCloseMenuButtonLabel="Close menu",this.placement="right-start",this.mobileDoneButtonLabel="Done",this.variant="action",this.activeLevel=0,this.mobileMediaQuery=window.matchMedia("(min-width: 768px)"),this.mediaQueryHandler=()=>{this.updateMobileState()},this.resetMenu=()=>{this.items.forEach((t=>{t.tabIndex=-1})),this.level>0||setTimeout((()=>{this.activeLevel=0,u(this.el,"swirl-menu").forEach((t=>{t.active=!1,t.parentElement.expanded=!1}))}),this.mobile?200:60)},this.closeMenu=()=>{this.disableAutoUpdate&&this.disableAutoUpdate(),this.swirlPopover.close(),this.resetMenu()},this.reposition=async()=>{if(this.mobile||0===this.level)return void(this.position=void 0);const t=this.el.parentElement;t&&this.menuContainer&&requestAnimationFrame((async()=>{this.position=await a(t,this.menuContainer,{placement:this.placement,strategy:"fixed",middleware:[l({mainAxis:-10,crossAxis:0}),r(),m()]})}))},this.onKeyDown=t=>{if("ArrowDown"===t.code)t.preventDefault(),t.stopPropagation(),this.focusNextItem();else if("ArrowUp"===t.code)t.preventDefault(),t.stopPropagation(),this.focusPreviousItem();else if("ArrowLeft"===t.code)t.preventDefault(),t.stopPropagation(),this.rootMenu.goBack();else if("ArrowRight"===t.code){t.preventDefault();const e=d(this.items[this.getActiveItemIndex()],"swirl-menu-item");if(!e)return;this.rootMenu.activateMenuItem(e)}},this.onClose=()=>{this.closeMenu()},this.onDone=()=>{this.closeMenu(),this.done.emit()},this.onGoBack=()=>{this.rootMenu.goBack()}}componentWillLoad(){this.updateMobileState(),this.updateLevel(),this.observeSlotChanges()}componentDidLoad(){this.mobileMediaQuery.addEventListener("change",this.mediaQueryHandler),this.parentMenu=d(this.el.parentElement,"swirl-menu"),this.swirlPopover=d(this.el,"swirl-popover"),this.rootMenu=b(this.el,"swirl-menu").pop(),this.parentMenu&&queueMicrotask((()=>{this.active=!1})),this.swirlPopover.addEventListener("popoverClose",this.resetMenu),this.updateItems()}disconnectedCallback(){this.swirlPopover?.removeEventListener("popoverClose",this.resetMenu),this.mobileMediaQuery.removeEventListener?.("change",this.mediaQueryHandler),this.observer?.disconnect()}watchActive(){this.position=void 0,this.reposition(),this.disableAutoUpdate&&this.disableAutoUpdate(),this.disableAutoUpdate=h(this.el.parentElement,this.menuContainer,this.reposition)}watchValue(){this.updateActiveItem()}async activateMenuItem(t){if(this.parentMenu)return;const e=await t.getParentMenu(),i=u(this.el,"swirl-menu").filter((t=>t.level>=e.level&&t!==e));i.forEach((t=>{t.active=!1,t.parentElement.expanded=!1}));const s=await t.getSubMenu();s&&(t.expanded=!0,s.active=!0,this.activeLevel=s.level,setTimeout((()=>{s.focusFirstItem()}),this.mobile?200:60))}async close(){this.closeMenu()}async goBack(){if(this.parentMenu||0===this.activeLevel)return;const t=(u(this.el,"swirl-menu").find((t=>t.level===this.activeLevel&&t.active))||this.rootMenu).parentElement;t.expanded=!1,this.activeLevel=Math.max(this.activeLevel-1,0),u(this.el,"swirl-menu").filter((t=>t.level>this.activeLevel)).forEach((t=>{t.active=!1})),(u(this.el,"swirl-menu").find((t=>t.level===this.activeLevel&&t.active))||this.rootMenu).focusItemAtIndex(Array.from(t.parentElement.children).indexOf(t))}async focusFirstItem(){this.focusItem(this.items[0])}async focusItemAtIndex(t){this.focusItem(this.items[t])}async updateSelection(t){this.valueChange.emit(t.value)}async updateActiveItem(){u(this.el,"swirl-menu-item").filter((t=>d(t,"swirl-menu")===this.el)).forEach((t=>{t.updateValue()})),this.parentMenu&&"action"===this.parentMenu.variant&&this.parentMenu.updateActiveItem()}observeSlotChanges(){this.observer=new MutationObserver((()=>{requestAnimationFrame((()=>{this.updateItems()}))})),this.observer.observe(this.el,{childList:!0})}updateMobileState(){const t=f();t!==this.mobile&&(this.mobile=t)}updateItems(){this.items=[...u(this.el,'[role="menuitem"]'),...u(this.el,'[role="menuitemradio"]')].filter((t=>d(t,"swirl-menu")===this.el))}updateLevel(){const t=b(this.el.parentNode,"swirl-menu");this.level=t.length}focusItem(t){[...u(this.rootMenu,'[role="menuitem"]'),...u(this.rootMenu,'[role="menuitemradio"]')].forEach((t=>{t.tabIndex=-1})),t&&(t.tabIndex=0,t.focus())}focusNextItem(){const t=this.getActiveItemIndex();this.focusItem(this.items[(t+1)%this.items.length])}focusPreviousItem(){const t=this.getActiveItemIndex();this.focusItem(this.items[0===t?this.items.length-1:t-1])}getActiveItemIndex(){const t=p();return this.items.findIndex((e=>e===t||e===t?.querySelector('[role="menuitem"]')||e===t?.querySelector('[role="menuitemradio"]')))}render(){const t=!this.parentMenu,e=t&&this.mobile?void 0:this.label,i=t&&this.mobile?"menu-title":void 0,o=t?"menubar":"menu",a=c("menu","menu--level-"+this.level,{"menu--active":this.active,"menu--mobile":this.mobile,"menu--root":t});return s(n,{key:"90649ed93738daac024fb46d5b0096439f72d04d"},s("div",{key:"19197c74b8088d5e95c38167b964eb98c2060dcc",class:a},this.mobile&&t&&s("div",{key:"3e83380d07ca1fb260b9f0fc1c5d135ae4460f02",class:"menu__mobile-header"},0===this.activeLevel&&s("swirl-button",{key:"ddb263add38ceee511899f23f3f0401af642bb66",hideLabel:!0,icon:"<swirl-icon-close></swirl-icon-close>",label:this.mobileCloseMenuButtonLabel,onClick:this.onClose,variant:"plain"}),this.activeLevel>0&&s("swirl-button",{key:"bf7f50ea6cdf84c5522ffc14346ad816067004e4",hideLabel:!0,icon:"<swirl-icon-chevron-left></swirl-icon-chevron-left>",label:this.mobileBackButtonLabel,onClick:this.onGoBack,variant:"plain"}),s("span",{key:"fbcae6f2a3a5f52edf267d129f90384a2c6aaeb5",class:"menu__title",id:"menu-title"},s("swirl-heading",{key:"5f47dbd00900ca4652c48d9e8433cae7e1cd98d4",align:"center",as:"span",level:4,text:this.label,truncate:!0})),s("swirl-button",{key:"75e3348b5a732a5c4d2010beff9f21973bdffda2",class:"menu__done-button",intent:"primary",label:this.mobileDoneButtonLabel,onClick:this.onDone})),s("div",{key:"59ff09a67ba9c64402762ddc2d90f136c423cb99","aria-label":e,"aria-labelledby":i,"aria-orientation":"vertical",class:"menu__menu",onKeyDown:this.onKeyDown,ref:t=>this.menuContainer=t,role:o,style:!this.mobile&&this.level>0?{top:this.position?this.position?.y+"px":"",left:this.position?this.position?.x+"px":"",opacity:this.position?void 0:"0"}:this.mobile?{left:t?`calc(-100% * ${this.activeLevel})`:"100%"}:void 0},s("slot",{key:"b0434b4a52901a62b2d47e343c233309bdfcbc58"}))))}get el(){return this}static get watchers(){return{active:[{watchActive:0}],value:[{watchValue:0}]}}static get style(){return':host{display:block}:host *{box-sizing:border-box}.menu{width:100%}.menu--mobile.menu--root{position:relative}.menu--mobile.menu--root .menu__menu{top:3.5rem;transition:left 0.2s}.menu--mobile.menu--active .menu__menu{display:block}.menu--mobile .menu__menu{position:absolute;top:0;left:0;display:none;width:100%}:not(.menu--mobile).menu--root{position:relative}:not(.menu--mobile).menu--root .menu__menu{position:relative;padding-top:0;padding-bottom:0}:not(.menu--mobile):not(.menu--root) .menu__menu{z-index:1;max-width:22.5rem;border-radius:var(--s-border-radius-base);box-shadow:var(--s-shadow-level-1);padding:var(--s-space-4);outline:var(--s-border-width-default) solid var(--s-border-translucent-outline)}:not(.menu--mobile):not(.menu--root) .menu__menu:before{content:"";position:absolute;inset:0;z-index:-1;border-radius:inherit;background:var(--s-translucent-low-default);-webkit-backdrop-filter:blur(var(--s-blur-l));backdrop-filter:blur(var(--s-blur-l))}:not(.menu--mobile).menu--active .menu__menu{display:block}:not(.menu--mobile) .menu__menu{position:fixed;display:none}.menu__mobile-header{display:flex;height:3.5rem;padding-right:var(--s-space-16);padding-left:var(--s-space-16);justify-content:space-between;align-items:center;border-bottom:var(--s-border-width-default) solid var(--s-border-default);gap:var(--s-space-8)}.menu__mobile-header>*{display:inline-flex;flex-shrink:0}.menu__title{min-width:0;flex-grow:1;flex-shrink:1}.menu__title swirl-heading{min-width:0}.menu__done-button{margin-right:calc(-1 * var(--s-space-8))}'}},[257,"swirl-menu",{active:[1028],label:[1],level:[1026],mobileBackButtonLabel:[1,"mobile-back-button-label"],mobileCloseMenuButtonLabel:[1,"mobile-close-menu-button-label"],placement:[1],mobileDoneButtonLabel:[1,"mobile-done-button-label"],value:[1],variant:[1],activeLevel:[32],mobile:[32],position:[32],activateMenuItem:[64],close:[64],goBack:[64],focusFirstItem:[64],focusItemAtIndex:[64],updateSelection:[64],updateActiveItem:[64]},void 0,{active:[{watchActive:0}],value:[{watchValue:0}]}]),g=y,_=function(){"undefined"!=typeof customElements&&["swirl-menu","swirl-button","swirl-heading"].forEach((t=>{switch(t){case"swirl-menu":customElements.get(o(t))||customElements.define(o(t),y);break;case"swirl-button":customElements.get(o(t))||w();break;case"swirl-heading":customElements.get(o(t))||v()}}))};export{g as SwirlMenu,_ as defineCustomElement}
1
+ import{proxyCustomElement as t,HTMLElement as e,createEvent as i,h as s,Host as n,transformTag as o}from"@stencil/core/internal/client";import{c as a,a as h,o as l,f as r,s as m}from"./floating-ui.dom.js";import{c}from"./index2.js";import{q as u,l as d,m as b,i as f,k as p}from"./utils.js";import{d as w}from"./swirl-button2.js";import{d as v}from"./swirl-heading2.js";const y=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.done=i(this,"done",7),this.valueChange=i(this,"valueChange",7),this.active=!0,this.level=0,this.mobileBackButtonLabel="Back",this.mobileCloseMenuButtonLabel="Close menu",this.placement="right-start",this.mobileDoneButtonLabel="Done",this.variant="action",this.activeLevel=0,this.mobileMediaQuery=window.matchMedia("(min-width: 768px)"),this.mediaQueryHandler=()=>{this.updateMobileState()},this.resetMenu=()=>{this.items.forEach((t=>{t.tabIndex=-1})),this.level>0||setTimeout((()=>{this.activeLevel=0,u(this.el,"swirl-menu").forEach((t=>{t.active=!1,t.parentElement.expanded=!1}))}),this.mobile?200:60)},this.closeMenu=()=>{this.disableAutoUpdate&&this.disableAutoUpdate(),this.swirlPopover.close(),this.resetMenu()},this.reposition=async()=>{if(this.mobile||0===this.level)return void(this.position=void 0);const t=this.el.parentElement;t&&this.menuContainer&&requestAnimationFrame((async()=>{this.position=await a(t,this.menuContainer,{placement:this.placement,strategy:"fixed",middleware:[l({mainAxis:-10,crossAxis:0}),r(),m()]})}))},this.onKeyDown=t=>{if("ArrowDown"===t.code)t.preventDefault(),t.stopPropagation(),this.focusNextItem();else if("ArrowUp"===t.code)t.preventDefault(),t.stopPropagation(),this.focusPreviousItem();else if("ArrowLeft"===t.code)t.preventDefault(),t.stopPropagation(),this.rootMenu.goBack();else if("ArrowRight"===t.code){t.preventDefault();const e=d(this.items[this.getActiveItemIndex()],"swirl-menu-item");if(!e)return;this.rootMenu.activateMenuItem(e)}},this.onClose=()=>{this.closeMenu()},this.onDone=()=>{this.closeMenu(),this.done.emit()},this.onGoBack=()=>{this.rootMenu.goBack()}}componentWillLoad(){this.updateMobileState(),this.updateLevel(),this.observeSlotChanges()}componentDidLoad(){this.mobileMediaQuery.addEventListener("change",this.mediaQueryHandler),this.parentMenu=d(this.el.parentElement,"swirl-menu"),this.swirlPopover=d(this.el,"swirl-popover"),this.rootMenu=b(this.el,"swirl-menu").pop(),this.parentMenu&&queueMicrotask((()=>{this.active=!1})),this.swirlPopover.addEventListener("popoverClose",this.resetMenu),this.updateItems()}disconnectedCallback(){this.swirlPopover?.removeEventListener("popoverClose",this.resetMenu),this.mobileMediaQuery.removeEventListener?.("change",this.mediaQueryHandler),this.observer?.disconnect()}watchActive(){this.position=void 0,this.reposition(),this.disableAutoUpdate&&this.disableAutoUpdate(),this.disableAutoUpdate=h(this.el.parentElement,this.menuContainer,this.reposition)}watchValue(){this.updateActiveItem()}async activateMenuItem(t){if(this.parentMenu)return;const e=await t.getParentMenu(),i=u(this.el,"swirl-menu").filter((t=>t.level>=e.level&&t!==e));i.forEach((t=>{t.active=!1,t.parentElement.expanded=!1}));const s=await t.getSubMenu();s&&(t.expanded=!0,s.active=!0,this.activeLevel=s.level,setTimeout((()=>{s.focusFirstItem()}),this.mobile?200:60))}async close(){this.closeMenu()}async goBack(){if(this.parentMenu||0===this.activeLevel)return;const t=(u(this.el,"swirl-menu").find((t=>t.level===this.activeLevel&&t.active))||this.rootMenu).parentElement;t.expanded=!1,this.activeLevel=Math.max(this.activeLevel-1,0),u(this.el,"swirl-menu").filter((t=>t.level>this.activeLevel)).forEach((t=>{t.active=!1})),(u(this.el,"swirl-menu").find((t=>t.level===this.activeLevel&&t.active))||this.rootMenu).focusItemAtIndex(Array.from(t.parentElement.children).indexOf(t))}async focusFirstItem(){this.focusItem(this.items[0])}async focusItemAtIndex(t){this.focusItem(this.items[t])}async updateSelection(t){this.valueChange.emit(t.value)}async updateActiveItem(){u(this.el,"swirl-menu-item").filter((t=>d(t,"swirl-menu")===this.el)).forEach((t=>{t.updateValue()})),this.parentMenu&&"action"===this.parentMenu.variant&&this.parentMenu.updateActiveItem()}observeSlotChanges(){this.observer=new MutationObserver((()=>{requestAnimationFrame((()=>{this.updateItems()}))})),this.observer.observe(this.el,{childList:!0})}updateMobileState(){const t=f();t!==this.mobile&&(this.mobile=t)}updateItems(){this.items=[...u(this.el,'[role="menuitem"]'),...u(this.el,'[role="menuitemradio"]')].filter((t=>d(t,"swirl-menu")===this.el))}updateLevel(){const t=b(this.el.parentNode,"swirl-menu");this.level=t.length}focusItem(t){[...u(this.rootMenu,'[role="menuitem"]'),...u(this.rootMenu,'[role="menuitemradio"]')].forEach((t=>{t.tabIndex=-1})),t&&(t.tabIndex=0,t.focus())}focusNextItem(){const t=this.getActiveItemIndex();this.focusItem(this.items[(t+1)%this.items.length])}focusPreviousItem(){const t=this.getActiveItemIndex();this.focusItem(this.items[0===t?this.items.length-1:t-1])}getActiveItemIndex(){const t=p();return this.items.findIndex((e=>e===t||e===t?.querySelector('[role="menuitem"]')||e===t?.querySelector('[role="menuitemradio"]')))}render(){const t=!this.parentMenu,e=t&&this.mobile?void 0:this.label,i=t&&this.mobile?"menu-title":void 0,o=t?"menubar":"menu",a=c("menu","menu--level-"+this.level,{"menu--active":this.active,"menu--mobile":this.mobile,"menu--root":t});return s(n,{key:"90649ed93738daac024fb46d5b0096439f72d04d"},s("div",{key:"19197c74b8088d5e95c38167b964eb98c2060dcc",class:a},this.mobile&&t&&s("div",{key:"3e83380d07ca1fb260b9f0fc1c5d135ae4460f02",class:"menu__mobile-header"},0===this.activeLevel&&s("swirl-button",{key:"ddb263add38ceee511899f23f3f0401af642bb66",hideLabel:!0,icon:"<swirl-icon-close></swirl-icon-close>",label:this.mobileCloseMenuButtonLabel,onClick:this.onClose,variant:"plain"}),this.activeLevel>0&&s("swirl-button",{key:"bf7f50ea6cdf84c5522ffc14346ad816067004e4",hideLabel:!0,icon:"<swirl-icon-chevron-left></swirl-icon-chevron-left>",label:this.mobileBackButtonLabel,onClick:this.onGoBack,variant:"plain"}),s("span",{key:"fbcae6f2a3a5f52edf267d129f90384a2c6aaeb5",class:"menu__title",id:"menu-title"},s("swirl-heading",{key:"5f47dbd00900ca4652c48d9e8433cae7e1cd98d4",align:"center",as:"span",level:4,text:this.label,truncate:!0})),s("swirl-button",{key:"75e3348b5a732a5c4d2010beff9f21973bdffda2",class:"menu__done-button",intent:"primary",label:this.mobileDoneButtonLabel,onClick:this.onDone})),s("div",{key:"59ff09a67ba9c64402762ddc2d90f136c423cb99","aria-label":e,"aria-labelledby":i,"aria-orientation":"vertical",class:"menu__menu",onKeyDown:this.onKeyDown,ref:t=>this.menuContainer=t,role:o,style:!this.mobile&&this.level>0?{top:this.position?this.position?.y+"px":"",left:this.position?this.position?.x+"px":"",opacity:this.position?void 0:"0"}:this.mobile?{left:t?`calc(-100% * ${this.activeLevel})`:"100%"}:void 0},s("slot",{key:"b0434b4a52901a62b2d47e343c233309bdfcbc58"}))))}get el(){return this}static get watchers(){return{active:[{watchActive:0}],value:[{watchValue:0}]}}static get style(){return':host{display:block}:host *{box-sizing:border-box}.menu{width:100%}.menu--mobile.menu--root{position:relative}.menu--mobile.menu--root .menu__menu{top:3.5rem;transition:left 0.2s}.menu--mobile.menu--active .menu__menu{display:block}.menu--mobile .menu__menu{position:absolute;top:0;left:0;display:none;width:100%}:not(.menu--mobile).menu--root{position:relative}:not(.menu--mobile).menu--root .menu__menu{position:relative;padding-top:0;padding-bottom:0}:not(.menu--mobile):not(.menu--root) .menu__menu{z-index:1;max-width:22.5rem;border-radius:var(--s-border-radius-base);box-shadow:var(--s-shadow-level-1);padding:var(--s-space-4);outline:var(--s-border-width-default) solid var(--s-border-translucent-outline)}:not(.menu--mobile):not(.menu--root) .menu__menu:before{content:"";position:absolute;inset:0;z-index:-1;border-radius:inherit;background:var(--s-translucent-low-default);-webkit-backdrop-filter:blur(var(--s-blur-l));backdrop-filter:blur(var(--s-blur-l))}:not(.menu--mobile).menu--active .menu__menu{display:block}:not(.menu--mobile) .menu__menu{position:fixed;display:none}.menu__mobile-header{display:flex;height:3.5rem;padding-right:var(--s-space-16);padding-left:var(--s-space-16);justify-content:space-between;align-items:center;border-bottom:var(--s-border-width-default) solid var(--s-border-default);gap:var(--s-space-8)}.menu__mobile-header>*{display:inline-flex;flex-shrink:0}.menu__title{min-width:0;flex-grow:1;flex-shrink:1}.menu__title swirl-heading{min-width:0}.menu__done-button{margin-right:calc(-1 * var(--s-space-8))}'}},[257,"swirl-menu",{active:[1028],label:[1],level:[1026],mobileBackButtonLabel:[1,"mobile-back-button-label"],mobileCloseMenuButtonLabel:[1,"mobile-close-menu-button-label"],placement:[1],mobileDoneButtonLabel:[1,"mobile-done-button-label"],value:[1],variant:[1],activeLevel:[32],mobile:[32],position:[32],activateMenuItem:[64],close:[64],goBack:[64],focusFirstItem:[64],focusItemAtIndex:[64],updateSelection:[64],updateActiveItem:[64]},void 0,{active:[{watchActive:0}],value:[{watchValue:0}]}]),g=y,_=function(){"undefined"!=typeof customElements&&["swirl-menu","swirl-button","swirl-heading"].forEach((t=>{switch(t){case"swirl-menu":customElements.get(o(t))||customElements.define(o(t),y);break;case"swirl-button":customElements.get(o(t))||w();break;case"swirl-heading":customElements.get(o(t))||v()}}))};export{g as SwirlMenu,_ as defineCustomElement}