@zag-js/tooltip 0.0.0-dev-20220413174154 → 0.0.0-dev-20220416104915

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/dist/index.js CHANGED
@@ -19,18 +19,6 @@ var __spreadValues = (a, b) => {
19
19
  return a;
20
20
  };
21
21
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
- var __objRest = (source, exclude) => {
23
- var target = {};
24
- for (var prop in source)
25
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
26
- target[prop] = source[prop];
27
- if (source != null && __getOwnPropSymbols)
28
- for (var prop of __getOwnPropSymbols(source)) {
29
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
30
- target[prop] = source[prop];
31
- }
32
- return target;
33
- };
34
22
  var __export = (target, all) => {
35
23
  for (var name in all)
36
24
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -44,26 +32,6 @@ var __copyProps = (to, from, except, desc) => {
44
32
  return to;
45
33
  };
46
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
47
- var __async = (__this, __arguments, generator) => {
48
- return new Promise((resolve, reject) => {
49
- var fulfilled = (value) => {
50
- try {
51
- step(generator.next(value));
52
- } catch (e) {
53
- reject(e);
54
- }
55
- };
56
- var rejected = (value) => {
57
- try {
58
- step(generator.throw(value));
59
- } catch (e) {
60
- reject(e);
61
- }
62
- };
63
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
64
- step((generator = generator.apply(__this, __arguments)).next());
65
- });
66
- };
67
35
 
68
36
  // src/index.ts
69
37
  var src_exports = {};
@@ -73,116 +41,76 @@ __export(src_exports, {
73
41
  });
74
42
  module.exports = __toCommonJS(src_exports);
75
43
 
76
- // ../../utilities/dom/src/attrs.ts
44
+ // ../../utilities/dom/dist/index.mjs
77
45
  var dataAttr = (guard) => {
78
46
  return guard ? "" : void 0;
79
47
  };
80
-
81
- // ../../utilities/dom/src/computed-style.ts
82
- var styleCache = /* @__PURE__ */ new WeakMap();
48
+ function getStyleCache() {
49
+ ;
50
+ globalThis.__styleCache__ = globalThis.__styleCache__ || /* @__PURE__ */ new WeakMap();
51
+ return globalThis.__styleCache__;
52
+ }
83
53
  function getComputedStyle2(el) {
84
54
  var _a;
85
55
  if (!el)
86
56
  return {};
87
- let style = styleCache.get(el);
57
+ const cache = getStyleCache();
58
+ let style = cache.get(el);
88
59
  if (!style) {
89
60
  const win = (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
90
61
  style = win.getComputedStyle(el);
91
- styleCache.set(el, style);
62
+ cache.set(el, style);
92
63
  }
93
64
  return style;
94
65
  }
95
-
96
- // ../../utilities/dom/src/next-tick.ts
97
66
  function raf(fn) {
98
67
  const id = globalThis.requestAnimationFrame(fn);
99
68
  return function cleanup() {
100
69
  globalThis.cancelAnimationFrame(id);
101
70
  };
102
71
  }
103
-
104
- // ../../utilities/core/src/array.ts
105
- function clear(v) {
106
- while (v.length > 0)
107
- v.pop();
108
- return v;
109
- }
110
-
111
- // ../../utilities/core/src/functions.ts
112
- var runIfFn = (v, ...a) => {
113
- const res = typeof v === "function" ? v(...a) : v;
114
- return res != null ? res : void 0;
115
- };
116
- var cast = (v) => v;
117
72
  var noop = () => {
118
73
  };
119
- var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
120
- var uuid = /* @__PURE__ */ (() => {
121
- let id = 0;
122
- return () => {
123
- id++;
124
- return id.toString(36);
125
- };
126
- })();
127
-
128
- // ../../utilities/core/src/guard.ts
129
- var ua = (v) => isDom() && v.test(navigator.userAgent);
130
- var isDom = () => !!(typeof window !== "undefined");
131
- var isSafari = () => ua(/^((?!chrome|android).)*safari/i);
132
- var isArray = (v) => Array.isArray(v);
133
- var isBoolean = (v) => v === true || v === false;
134
- var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
135
- var isNumber = (v) => typeof v === "number" && !Number.isNaN(v);
136
- var isString = (v) => typeof v === "string";
137
- var isFunction = (v) => typeof v === "function";
138
-
139
- // ../../utilities/core/src/warning.ts
140
- function warn(...a) {
141
- const m = a.length === 1 ? a[0] : a[1];
142
- const c = a.length === 2 ? a[0] : true;
143
- if (c && void 0 !== "production") {
144
- console.warn(m);
145
- }
74
+ function getListenerElements() {
75
+ ;
76
+ globalThis.__listenerElements__ = globalThis.__listenerElements__ || /* @__PURE__ */ new Map();
77
+ return globalThis.__listenerElements__;
146
78
  }
147
- function invariant(...a) {
148
- const m = a.length === 1 ? a[0] : a[1];
149
- const c = a.length === 2 ? a[0] : true;
150
- if (c && void 0 !== "production") {
151
- throw new Error(m);
152
- }
79
+ function getListenerCache() {
80
+ ;
81
+ globalThis.__listenerCache__ = globalThis.__listenerCache__ || /* @__PURE__ */ new Map();
82
+ return globalThis.__listenerCache__;
153
83
  }
154
-
155
- // ../../utilities/dom/src/event-bus.ts
156
- var listenerElements = /* @__PURE__ */ new Map();
157
- var listenerCache = /* @__PURE__ */ new Map();
158
84
  function globalEventBus(node, type, handler, options) {
159
85
  var _a;
160
86
  if (!node)
161
87
  return noop;
162
- const hash2 = JSON.stringify({ type, options });
88
+ const hash = JSON.stringify({ type, options });
89
+ const listenerElements = getListenerElements();
90
+ const listenerCache = getListenerCache();
163
91
  const group = listenerElements.get(node);
164
92
  if (!listenerElements.has(node)) {
165
- const group2 = /* @__PURE__ */ new Map([[hash2, /* @__PURE__ */ new Set([handler])]]);
93
+ const group2 = /* @__PURE__ */ new Map([[hash, /* @__PURE__ */ new Set([handler])]]);
166
94
  listenerElements.set(node, group2);
167
- } else if (group == null ? void 0 : group.has(hash2)) {
168
- (_a = group == null ? void 0 : group.get(hash2)) == null ? void 0 : _a.add(handler);
95
+ } else if (group == null ? void 0 : group.has(hash)) {
96
+ (_a = group == null ? void 0 : group.get(hash)) == null ? void 0 : _a.add(handler);
169
97
  } else {
170
- group == null ? void 0 : group.set(hash2, /* @__PURE__ */ new Set([handler]));
98
+ group == null ? void 0 : group.set(hash, /* @__PURE__ */ new Set([handler]));
171
99
  }
172
100
  function attach(node2) {
173
101
  var _a2, _b;
174
102
  function listener(event) {
175
103
  var _a3;
176
104
  const group2 = listenerElements.get(node2);
177
- (_a3 = group2 == null ? void 0 : group2.get(hash2)) == null ? void 0 : _a3.forEach((fn) => fn(event));
105
+ (_a3 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a3.forEach((fn) => fn(event));
178
106
  }
179
107
  if (!(listenerCache == null ? void 0 : listenerCache.has(node2))) {
180
- listenerCache.set(node2, /* @__PURE__ */ new Map([[hash2, listener]]));
108
+ listenerCache.set(node2, /* @__PURE__ */ new Map([[hash, listener]]));
181
109
  node2.addEventListener(type, listener, options);
182
110
  return;
183
111
  }
184
- if (!((_a2 = listenerCache == null ? void 0 : listenerCache.get(node2)) == null ? void 0 : _a2.has(hash2))) {
185
- (_b = listenerCache.get(node2)) == null ? void 0 : _b.set(hash2, listener);
112
+ if (!((_a2 = listenerCache == null ? void 0 : listenerCache.get(node2)) == null ? void 0 : _a2.has(hash))) {
113
+ (_b = listenerCache.get(node2)) == null ? void 0 : _b.set(hash, listener);
186
114
  node2.addEventListener(type, listener, options);
187
115
  }
188
116
  }
@@ -192,12 +120,12 @@ function globalEventBus(node, type, handler, options) {
192
120
  if (!listenerElements.has(node))
193
121
  return;
194
122
  const group2 = listenerElements.get(node);
195
- (_a2 = group2 == null ? void 0 : group2.get(hash2)) == null ? void 0 : _a2.delete(handler);
196
- if (((_b = group2 == null ? void 0 : group2.get(hash2)) == null ? void 0 : _b.size) === 0) {
197
- const listener = (_c = listenerCache.get(node)) == null ? void 0 : _c.get(hash2);
123
+ (_a2 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a2.delete(handler);
124
+ if (((_b = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _b.size) === 0) {
125
+ const listener = (_c = listenerCache.get(node)) == null ? void 0 : _c.get(hash);
198
126
  node.removeEventListener(type, listener, options);
199
- group2 == null ? void 0 : group2.delete(hash2);
200
- (_d = listenerCache.get(node)) == null ? void 0 : _d.delete(hash2);
127
+ group2 == null ? void 0 : group2.delete(hash);
128
+ (_d = listenerCache.get(node)) == null ? void 0 : _d.delete(hash);
201
129
  if ((group2 == null ? void 0 : group2.size) === 0) {
202
130
  listenerElements.delete(node);
203
131
  listenerCache.delete(node);
@@ -205,11 +133,9 @@ function globalEventBus(node, type, handler, options) {
205
133
  }
206
134
  };
207
135
  }
208
-
209
- // ../../utilities/dom/src/listener.ts
210
136
  var t = (v) => Object.prototype.toString.call(v).slice(8, -1);
211
137
  var isRef = (v) => t(v) === "Object" && "current" in v;
212
- var runIfFn2 = (fn) => t(fn) === "Function" ? fn() : fn;
138
+ var runIfFn = (fn) => t(fn) === "Function" ? fn() : fn;
213
139
  var isTouchEvent = (v) => t(v) === "Object" && !!v.touches;
214
140
  var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
215
141
  function extractInfo(event, type = "page") {
@@ -222,7 +148,7 @@ function extractInfo(event, type = "page") {
222
148
  };
223
149
  }
224
150
  function addDomEvent(target, event, listener, options) {
225
- const node = isRef(target) ? target.current : runIfFn2(target);
151
+ const node = isRef(target) ? target.current : runIfFn(target);
226
152
  return globalEventBus(node, event, listener, options);
227
153
  }
228
154
  function addPointerEvent(target, event, listener, options) {
@@ -240,8 +166,8 @@ function filterPrimaryPointer(fn) {
240
166
  return (event) => {
241
167
  var _a;
242
168
  const win = (_a = event.view) != null ? _a : window;
243
- const isMouseEvent = event instanceof win.MouseEvent;
244
- const isPrimary = !isMouseEvent || isMouseEvent && event.button === 0;
169
+ const isMouseEvent2 = event instanceof win.MouseEvent;
170
+ const isPrimary = !isMouseEvent2 || isMouseEvent2 && event.button === 0;
245
171
  if (isPrimary)
246
172
  fn(event);
247
173
  };
@@ -274,8 +200,6 @@ function getEventName(evt) {
274
200
  return mouseEventNames[evt];
275
201
  return evt;
276
202
  }
277
-
278
- // ../../utilities/dom/src/query.ts
279
203
  function getOwnerDocument(el) {
280
204
  var _a;
281
205
  if (isWindow(el))
@@ -301,8 +225,6 @@ function isHTMLElement(v) {
301
225
  function isWindow(value) {
302
226
  return (value == null ? void 0 : value.toString()) === "[object Window]";
303
227
  }
304
-
305
- // ../../utilities/dom/src/scrollable.ts
306
228
  function isScrollParent(el) {
307
229
  const { overflow, overflowX, overflowY } = getComputedStyle2(el);
308
230
  return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
@@ -326,8 +248,6 @@ function getScrollParents(el, list = []) {
326
248
  return parents;
327
249
  return parents.concat(getScrollParents(getParent(target)));
328
250
  }
329
-
330
- // ../../utilities/dom/src/visually-hidden.ts
331
251
  var visuallyHiddenStyle = {
332
252
  border: "0",
333
253
  clip: "rect(0 0 0 0)",
@@ -340,1247 +260,14 @@ var visuallyHiddenStyle = {
340
260
  whiteSpace: "nowrap",
341
261
  wordWrap: "normal"
342
262
  };
343
-
344
- // ../../utilities/dom/src/pointerlock.ts
345
263
  function addPointerlockChangeListener(doc, fn) {
346
264
  return addDomEvent(doc, "pointerlockchange", fn, false);
347
265
  }
348
266
 
349
- // ../../utilities/dom/src/rect-observer.ts
350
- var observedElements = /* @__PURE__ */ new Map();
351
- function observeElementRect(el, fn) {
352
- const data = observedElements.get(el);
353
- if (!data) {
354
- observedElements.set(el, { rect: {}, callbacks: [fn] });
355
- if (observedElements.size === 1) {
356
- rafId = requestAnimationFrame(runLoop);
357
- }
358
- } else {
359
- data.callbacks.push(fn);
360
- fn(el.getBoundingClientRect());
361
- }
362
- return function unobserve() {
363
- const data2 = observedElements.get(el);
364
- if (!data2)
365
- return;
366
- const index = data2.callbacks.indexOf(fn);
367
- if (index > -1) {
368
- data2.callbacks.splice(index, 1);
369
- }
370
- if (data2.callbacks.length === 0) {
371
- observedElements.delete(el);
372
- if (observedElements.size === 0) {
373
- cancelAnimationFrame(rafId);
374
- }
375
- }
376
- };
377
- }
378
- var rafId;
379
- function runLoop() {
380
- const changedRectsData = [];
381
- observedElements.forEach((data, element) => {
382
- const newRect = element.getBoundingClientRect();
383
- if (!isEqual(data.rect, newRect)) {
384
- data.rect = newRect;
385
- changedRectsData.push(data);
386
- }
387
- });
388
- changedRectsData.forEach((data) => {
389
- data.callbacks.forEach((callback) => callback(data.rect));
390
- });
391
- rafId = requestAnimationFrame(runLoop);
392
- }
393
- function isEqual(rect1, rect2) {
394
- return rect1.width === rect2.width && rect1.height === rect2.height && rect1.top === rect2.top && rect1.right === rect2.right && rect1.bottom === rect2.bottom && rect1.left === rect2.left;
395
- }
396
-
397
- // ../../../node_modules/@floating-ui/core/dist/floating-ui.core.esm.js
398
- function getSide(placement) {
399
- return placement.split("-")[0];
400
- }
401
- function getAlignment(placement) {
402
- return placement.split("-")[1];
403
- }
404
- function getMainAxisFromPlacement(placement) {
405
- return ["top", "bottom"].includes(getSide(placement)) ? "x" : "y";
406
- }
407
- function getLengthFromAxis(axis) {
408
- return axis === "y" ? "height" : "width";
409
- }
410
- function computeCoordsFromPlacement(_ref, placement, rtl) {
411
- let {
412
- reference,
413
- floating
414
- } = _ref;
415
- const commonX = reference.x + reference.width / 2 - floating.width / 2;
416
- const commonY = reference.y + reference.height / 2 - floating.height / 2;
417
- const mainAxis = getMainAxisFromPlacement(placement);
418
- const length = getLengthFromAxis(mainAxis);
419
- const commonAlign = reference[length] / 2 - floating[length] / 2;
420
- const side = getSide(placement);
421
- const isVertical = mainAxis === "x";
422
- let coords;
423
- switch (side) {
424
- case "top":
425
- coords = {
426
- x: commonX,
427
- y: reference.y - floating.height
428
- };
429
- break;
430
- case "bottom":
431
- coords = {
432
- x: commonX,
433
- y: reference.y + reference.height
434
- };
435
- break;
436
- case "right":
437
- coords = {
438
- x: reference.x + reference.width,
439
- y: commonY
440
- };
441
- break;
442
- case "left":
443
- coords = {
444
- x: reference.x - floating.width,
445
- y: commonY
446
- };
447
- break;
448
- default:
449
- coords = {
450
- x: reference.x,
451
- y: reference.y
452
- };
453
- }
454
- switch (getAlignment(placement)) {
455
- case "start":
456
- coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
457
- break;
458
- case "end":
459
- coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
460
- break;
461
- }
462
- return coords;
463
- }
464
- var computePosition = (reference, floating, config) => __async(void 0, null, function* () {
465
- const {
466
- placement = "bottom",
467
- strategy = "absolute",
468
- middleware = [],
469
- platform: platform2
470
- } = config;
471
- const rtl = yield platform2.isRTL == null ? void 0 : platform2.isRTL(floating);
472
- if (void 0 !== "production") {
473
- if (platform2 == null) {
474
- console.error(["Floating UI: `platform` property was not passed to config. If you", "want to use Floating UI on the web, install @floating-ui/dom", "instead of the /core package. Otherwise, you can create your own", "`platform`: https://floating-ui.com/docs/platform"].join(" "));
475
- }
476
- if (middleware.filter((_ref) => {
477
- let {
478
- name
479
- } = _ref;
480
- return name === "autoPlacement" || name === "flip";
481
- }).length > 1) {
482
- throw new Error(["Floating UI: duplicate `flip` and/or `autoPlacement`", "middleware detected. This will lead to an infinite loop. Ensure only", "one of either has been passed to the `middleware` array."].join(" "));
483
- }
484
- }
485
- let rects = yield platform2.getElementRects({
486
- reference,
487
- floating,
488
- strategy
489
- });
490
- let {
491
- x,
492
- y
493
- } = computeCoordsFromPlacement(rects, placement, rtl);
494
- let statefulPlacement = placement;
495
- let middlewareData = {};
496
- let _debug_loop_count_ = 0;
497
- for (let i = 0; i < middleware.length; i++) {
498
- if (void 0 !== "production") {
499
- _debug_loop_count_++;
500
- if (_debug_loop_count_ > 100) {
501
- throw new Error(["Floating UI: The middleware lifecycle appears to be", "running in an infinite loop. This is usually caused by a `reset`", "continually being returned without a break condition."].join(" "));
502
- }
503
- }
504
- const {
505
- name,
506
- fn
507
- } = middleware[i];
508
- const {
509
- x: nextX,
510
- y: nextY,
511
- data,
512
- reset
513
- } = yield fn({
514
- x,
515
- y,
516
- initialPlacement: placement,
517
- placement: statefulPlacement,
518
- strategy,
519
- middlewareData,
520
- rects,
521
- platform: platform2,
522
- elements: {
523
- reference,
524
- floating
525
- }
526
- });
527
- x = nextX != null ? nextX : x;
528
- y = nextY != null ? nextY : y;
529
- middlewareData = __spreadProps(__spreadValues({}, middlewareData), {
530
- [name]: __spreadValues(__spreadValues({}, middlewareData[name]), data)
531
- });
532
- if (reset) {
533
- if (typeof reset === "object") {
534
- if (reset.placement) {
535
- statefulPlacement = reset.placement;
536
- }
537
- if (reset.rects) {
538
- rects = reset.rects === true ? yield platform2.getElementRects({
539
- reference,
540
- floating,
541
- strategy
542
- }) : reset.rects;
543
- }
544
- ({
545
- x,
546
- y
547
- } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
548
- }
549
- i = -1;
550
- continue;
551
- }
552
- }
553
- return {
554
- x,
555
- y,
556
- placement: statefulPlacement,
557
- strategy,
558
- middlewareData
559
- };
560
- });
561
- function expandPaddingObject(padding) {
562
- return __spreadValues({
563
- top: 0,
564
- right: 0,
565
- bottom: 0,
566
- left: 0
567
- }, padding);
568
- }
569
- function getSideObjectFromPadding(padding) {
570
- return typeof padding !== "number" ? expandPaddingObject(padding) : {
571
- top: padding,
572
- right: padding,
573
- bottom: padding,
574
- left: padding
575
- };
576
- }
577
- function rectToClientRect(rect) {
578
- return __spreadProps(__spreadValues({}, rect), {
579
- top: rect.y,
580
- left: rect.x,
581
- right: rect.x + rect.width,
582
- bottom: rect.y + rect.height
583
- });
584
- }
585
- function detectOverflow(middlewareArguments, options) {
586
- return __async(this, null, function* () {
587
- var _await$platform$isEle;
588
- if (options === void 0) {
589
- options = {};
590
- }
591
- const {
592
- x,
593
- y,
594
- platform: platform2,
595
- rects,
596
- elements,
597
- strategy
598
- } = middlewareArguments;
599
- const {
600
- boundary = "clippingAncestors",
601
- rootBoundary = "viewport",
602
- elementContext = "floating",
603
- altBoundary = false,
604
- padding = 0
605
- } = options;
606
- const paddingObject = getSideObjectFromPadding(padding);
607
- const altContext = elementContext === "floating" ? "reference" : "floating";
608
- const element = elements[altBoundary ? altContext : elementContext];
609
- const clippingClientRect = rectToClientRect(yield platform2.getClippingRect({
610
- element: ((_await$platform$isEle = yield platform2.isElement == null ? void 0 : platform2.isElement(element)) != null ? _await$platform$isEle : true) ? element : element.contextElement || (yield platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
611
- boundary,
612
- rootBoundary,
613
- strategy
614
- }));
615
- const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? yield platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
616
- rect: elementContext === "floating" ? __spreadProps(__spreadValues({}, rects.floating), {
617
- x,
618
- y
619
- }) : rects.reference,
620
- offsetParent: yield platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating),
621
- strategy
622
- }) : rects[elementContext]);
623
- return {
624
- top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
625
- bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
626
- left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
627
- right: elementClientRect.right - clippingClientRect.right + paddingObject.right
628
- };
629
- });
630
- }
631
- var min = Math.min;
632
- var max = Math.max;
633
- function within(min$1, value, max$1) {
634
- return max(min$1, min(value, max$1));
635
- }
636
- var arrow = (options) => ({
637
- name: "arrow",
638
- options,
639
- fn(middlewareArguments) {
640
- return __async(this, null, function* () {
641
- const {
642
- element,
643
- padding = 0
644
- } = options != null ? options : {};
645
- const {
646
- x,
647
- y,
648
- placement,
649
- rects,
650
- platform: platform2
651
- } = middlewareArguments;
652
- if (element == null) {
653
- if (void 0 !== "production") {
654
- console.warn("Floating UI: No `element` was passed to the `arrow` middleware.");
655
- }
656
- return {};
657
- }
658
- const paddingObject = getSideObjectFromPadding(padding);
659
- const coords = {
660
- x,
661
- y
662
- };
663
- const axis = getMainAxisFromPlacement(placement);
664
- const length = getLengthFromAxis(axis);
665
- const arrowDimensions = yield platform2.getDimensions(element);
666
- const minProp = axis === "y" ? "top" : "left";
667
- const maxProp = axis === "y" ? "bottom" : "right";
668
- const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
669
- const startDiff = coords[axis] - rects.reference[axis];
670
- const arrowOffsetParent = yield platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element);
671
- const clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
672
- const centerToReference = endDiff / 2 - startDiff / 2;
673
- const min3 = paddingObject[minProp];
674
- const max3 = clientSize - arrowDimensions[length] - paddingObject[maxProp];
675
- const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
676
- const offset2 = within(min3, center, max3);
677
- return {
678
- data: {
679
- [axis]: offset2,
680
- centerOffset: center - offset2
681
- }
682
- };
683
- });
684
- }
685
- });
686
- var hash$1 = {
687
- left: "right",
688
- right: "left",
689
- bottom: "top",
690
- top: "bottom"
691
- };
692
- function getOppositePlacement(placement) {
693
- return placement.replace(/left|right|bottom|top/g, (matched) => hash$1[matched]);
694
- }
695
- function getAlignmentSides(placement, rects, rtl) {
696
- if (rtl === void 0) {
697
- rtl = false;
698
- }
699
- const alignment = getAlignment(placement);
700
- const mainAxis = getMainAxisFromPlacement(placement);
701
- const length = getLengthFromAxis(mainAxis);
702
- let mainAlignmentSide = mainAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
703
- if (rects.reference[length] > rects.floating[length]) {
704
- mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
705
- }
706
- return {
707
- main: mainAlignmentSide,
708
- cross: getOppositePlacement(mainAlignmentSide)
709
- };
710
- }
711
- var hash = {
712
- start: "end",
713
- end: "start"
714
- };
715
- function getOppositeAlignmentPlacement(placement) {
716
- return placement.replace(/start|end/g, (matched) => hash[matched]);
717
- }
718
- function getExpandedPlacements(placement) {
719
- const oppositePlacement = getOppositePlacement(placement);
720
- return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
721
- }
722
- var flip = function(options) {
723
- if (options === void 0) {
724
- options = {};
725
- }
726
- return {
727
- name: "flip",
728
- options,
729
- fn(middlewareArguments) {
730
- return __async(this, null, function* () {
731
- var _middlewareData$flip;
732
- const {
733
- placement,
734
- middlewareData,
735
- rects,
736
- initialPlacement,
737
- platform: platform2,
738
- elements
739
- } = middlewareArguments;
740
- const _a2 = options, {
741
- mainAxis: checkMainAxis = true,
742
- crossAxis: checkCrossAxis = true,
743
- fallbackPlacements: specifiedFallbackPlacements,
744
- fallbackStrategy = "bestFit",
745
- flipAlignment = true
746
- } = _a2, detectOverflowOptions = __objRest(_a2, [
747
- "mainAxis",
748
- "crossAxis",
749
- "fallbackPlacements",
750
- "fallbackStrategy",
751
- "flipAlignment"
752
- ]);
753
- const side = getSide(placement);
754
- const isBasePlacement = side === initialPlacement;
755
- const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
756
- const placements = [initialPlacement, ...fallbackPlacements];
757
- const overflow = yield detectOverflow(middlewareArguments, detectOverflowOptions);
758
- const overflows = [];
759
- let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
760
- if (checkMainAxis) {
761
- overflows.push(overflow[side]);
762
- }
763
- if (checkCrossAxis) {
764
- const {
765
- main,
766
- cross
767
- } = getAlignmentSides(placement, rects, yield platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
768
- overflows.push(overflow[main], overflow[cross]);
769
- }
770
- overflowsData = [...overflowsData, {
771
- placement,
772
- overflows
773
- }];
774
- if (!overflows.every((side2) => side2 <= 0)) {
775
- var _middlewareData$flip$, _middlewareData$flip2;
776
- const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
777
- const nextPlacement = placements[nextIndex];
778
- if (nextPlacement) {
779
- return {
780
- data: {
781
- index: nextIndex,
782
- overflows: overflowsData
783
- },
784
- reset: {
785
- placement: nextPlacement
786
- }
787
- };
788
- }
789
- let resetPlacement = "bottom";
790
- switch (fallbackStrategy) {
791
- case "bestFit": {
792
- var _overflowsData$slice$;
793
- const placement2 = (_overflowsData$slice$ = overflowsData.slice().sort((a, b) => a.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0) - b.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0))[0]) == null ? void 0 : _overflowsData$slice$.placement;
794
- if (placement2) {
795
- resetPlacement = placement2;
796
- }
797
- break;
798
- }
799
- case "initialPlacement":
800
- resetPlacement = initialPlacement;
801
- break;
802
- }
803
- if (placement !== resetPlacement) {
804
- return {
805
- reset: {
806
- placement: resetPlacement
807
- }
808
- };
809
- }
810
- }
811
- return {};
812
- });
813
- }
814
- };
815
- };
816
- function convertValueToCoords(placement, rects, value, rtl) {
817
- if (rtl === void 0) {
818
- rtl = false;
819
- }
820
- const side = getSide(placement);
821
- const alignment = getAlignment(placement);
822
- const isVertical = getMainAxisFromPlacement(placement) === "x";
823
- const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1;
824
- const crossAxisMulti = rtl && isVertical ? -1 : 1;
825
- const rawValue = typeof value === "function" ? value(__spreadProps(__spreadValues({}, rects), {
826
- placement
827
- })) : value;
828
- const isNumber2 = typeof rawValue === "number";
829
- let {
830
- mainAxis,
831
- crossAxis,
832
- alignmentAxis
833
- } = isNumber2 ? {
834
- mainAxis: rawValue,
835
- crossAxis: 0,
836
- alignmentAxis: null
837
- } : __spreadValues({
838
- mainAxis: 0,
839
- crossAxis: 0,
840
- alignmentAxis: null
841
- }, rawValue);
842
- if (alignment && typeof alignmentAxis === "number") {
843
- crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
844
- }
845
- return isVertical ? {
846
- x: crossAxis * crossAxisMulti,
847
- y: mainAxis * mainAxisMulti
848
- } : {
849
- x: mainAxis * mainAxisMulti,
850
- y: crossAxis * crossAxisMulti
851
- };
852
- }
853
- var offset = function(value) {
854
- if (value === void 0) {
855
- value = 0;
856
- }
857
- return {
858
- name: "offset",
859
- options: value,
860
- fn(middlewareArguments) {
861
- return __async(this, null, function* () {
862
- const {
863
- x,
864
- y,
865
- placement,
866
- rects,
867
- platform: platform2,
868
- elements
869
- } = middlewareArguments;
870
- const diffCoords = convertValueToCoords(placement, rects, value, yield platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
871
- return {
872
- x: x + diffCoords.x,
873
- y: y + diffCoords.y,
874
- data: diffCoords
875
- };
876
- });
877
- }
878
- };
879
- };
880
- function getCrossAxis(axis) {
881
- return axis === "x" ? "y" : "x";
882
- }
883
- var shift = function(options) {
884
- if (options === void 0) {
885
- options = {};
886
- }
887
- return {
888
- name: "shift",
889
- options,
890
- fn(middlewareArguments) {
891
- return __async(this, null, function* () {
892
- const {
893
- x,
894
- y,
895
- placement
896
- } = middlewareArguments;
897
- const _a2 = options, {
898
- mainAxis: checkMainAxis = true,
899
- crossAxis: checkCrossAxis = false,
900
- limiter = {
901
- fn: (_ref) => {
902
- let {
903
- x: x2,
904
- y: y2
905
- } = _ref;
906
- return {
907
- x: x2,
908
- y: y2
909
- };
910
- }
911
- }
912
- } = _a2, detectOverflowOptions = __objRest(_a2, [
913
- "mainAxis",
914
- "crossAxis",
915
- "limiter"
916
- ]);
917
- const coords = {
918
- x,
919
- y
920
- };
921
- const overflow = yield detectOverflow(middlewareArguments, detectOverflowOptions);
922
- const mainAxis = getMainAxisFromPlacement(getSide(placement));
923
- const crossAxis = getCrossAxis(mainAxis);
924
- let mainAxisCoord = coords[mainAxis];
925
- let crossAxisCoord = coords[crossAxis];
926
- if (checkMainAxis) {
927
- const minSide = mainAxis === "y" ? "top" : "left";
928
- const maxSide = mainAxis === "y" ? "bottom" : "right";
929
- const min3 = mainAxisCoord + overflow[minSide];
930
- const max3 = mainAxisCoord - overflow[maxSide];
931
- mainAxisCoord = within(min3, mainAxisCoord, max3);
932
- }
933
- if (checkCrossAxis) {
934
- const minSide = crossAxis === "y" ? "top" : "left";
935
- const maxSide = crossAxis === "y" ? "bottom" : "right";
936
- const min3 = crossAxisCoord + overflow[minSide];
937
- const max3 = crossAxisCoord - overflow[maxSide];
938
- crossAxisCoord = within(min3, crossAxisCoord, max3);
939
- }
940
- const limitedCoords = limiter.fn(__spreadProps(__spreadValues({}, middlewareArguments), {
941
- [mainAxis]: mainAxisCoord,
942
- [crossAxis]: crossAxisCoord
943
- }));
944
- return __spreadProps(__spreadValues({}, limitedCoords), {
945
- data: {
946
- x: limitedCoords.x - x,
947
- y: limitedCoords.y - y
948
- }
949
- });
950
- });
951
- }
952
- };
953
- };
954
- var size = function(options) {
955
- if (options === void 0) {
956
- options = {};
957
- }
958
- return {
959
- name: "size",
960
- options,
961
- fn(middlewareArguments) {
962
- return __async(this, null, function* () {
963
- const {
964
- placement,
965
- rects,
966
- platform: platform2,
967
- elements
968
- } = middlewareArguments;
969
- const _a2 = options, {
970
- apply
971
- } = _a2, detectOverflowOptions = __objRest(_a2, [
972
- "apply"
973
- ]);
974
- const overflow = yield detectOverflow(middlewareArguments, detectOverflowOptions);
975
- const side = getSide(placement);
976
- const alignment = getAlignment(placement);
977
- let heightSide;
978
- let widthSide;
979
- if (side === "top" || side === "bottom") {
980
- heightSide = side;
981
- widthSide = alignment === ((yield platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
982
- } else {
983
- widthSide = side;
984
- heightSide = alignment === "end" ? "top" : "bottom";
985
- }
986
- const xMin = max(overflow.left, 0);
987
- const xMax = max(overflow.right, 0);
988
- const yMin = max(overflow.top, 0);
989
- const yMax = max(overflow.bottom, 0);
990
- const dimensions = {
991
- height: rects.floating.height - (["left", "right"].includes(placement) ? 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)) : overflow[heightSide]),
992
- width: rects.floating.width - (["top", "bottom"].includes(placement) ? 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)) : overflow[widthSide])
993
- };
994
- const prevDimensions = yield platform2.getDimensions(elements.floating);
995
- apply == null ? void 0 : apply(__spreadValues(__spreadValues({}, dimensions), rects));
996
- const nextDimensions = yield platform2.getDimensions(elements.floating);
997
- if (prevDimensions.width !== nextDimensions.width || prevDimensions.height !== nextDimensions.height) {
998
- return {
999
- reset: {
1000
- rects: true
1001
- }
1002
- };
1003
- }
1004
- return {};
1005
- });
1006
- }
1007
- };
1008
- };
1009
-
1010
- // ../../../node_modules/@floating-ui/dom/dist/floating-ui.dom.esm.js
1011
- function isWindow2(value) {
1012
- return value && value.document && value.location && value.alert && value.setInterval;
1013
- }
1014
- function getWindow(node) {
1015
- if (node == null) {
1016
- return window;
1017
- }
1018
- if (!isWindow2(node)) {
1019
- const ownerDocument = node.ownerDocument;
1020
- return ownerDocument ? ownerDocument.defaultView || window : window;
1021
- }
1022
- return node;
1023
- }
1024
- function getComputedStyle$1(element) {
1025
- return getWindow(element).getComputedStyle(element);
1026
- }
1027
- function getNodeName2(node) {
1028
- return isWindow2(node) ? "" : node ? (node.nodeName || "").toLowerCase() : "";
1029
- }
1030
- function isHTMLElement2(value) {
1031
- return value instanceof getWindow(value).HTMLElement;
1032
- }
1033
- function isElement(value) {
1034
- return value instanceof getWindow(value).Element;
1035
- }
1036
- function isNode(value) {
1037
- return value instanceof getWindow(value).Node;
1038
- }
1039
- function isShadowRoot(node) {
1040
- const OwnElement = getWindow(node).ShadowRoot;
1041
- return node instanceof OwnElement || node instanceof ShadowRoot;
1042
- }
1043
- function isOverflowElement(element) {
1044
- const {
1045
- overflow,
1046
- overflowX,
1047
- overflowY
1048
- } = getComputedStyle$1(element);
1049
- return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
1050
- }
1051
- function isTableElement(element) {
1052
- return ["table", "td", "th"].includes(getNodeName2(element));
1053
- }
1054
- function isContainingBlock(element) {
1055
- const isFirefox = navigator.userAgent.toLowerCase().includes("firefox");
1056
- const css = getComputedStyle$1(element);
1057
- return css.transform !== "none" || css.perspective !== "none" || css.contain === "paint" || ["transform", "perspective"].includes(css.willChange) || isFirefox && css.willChange === "filter" || isFirefox && (css.filter ? css.filter !== "none" : false);
1058
- }
1059
- function isLayoutViewport() {
1060
- return !/^((?!chrome|android).)*safari/i.test(navigator.userAgent);
1061
- }
1062
- var min2 = Math.min;
1063
- var max2 = Math.max;
1064
- var round = Math.round;
1065
- function getBoundingClientRect(element, includeScale, isFixedStrategy) {
1066
- if (includeScale === void 0) {
1067
- includeScale = false;
1068
- }
1069
- if (isFixedStrategy === void 0) {
1070
- isFixedStrategy = false;
1071
- }
1072
- const clientRect = element.getBoundingClientRect();
1073
- let scaleX = 1;
1074
- let scaleY = 1;
1075
- if (includeScale && isHTMLElement2(element)) {
1076
- scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
1077
- scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
1078
- }
1079
- const win = isElement(element) ? getWindow(element) : window;
1080
- const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
1081
- const x = (clientRect.left + (addVisualOffsets ? win.visualViewport.offsetLeft : 0)) / scaleX;
1082
- const y = (clientRect.top + (addVisualOffsets ? win.visualViewport.offsetTop : 0)) / scaleY;
1083
- const width = clientRect.width / scaleX;
1084
- const height = clientRect.height / scaleY;
1085
- return {
1086
- width,
1087
- height,
1088
- top: y,
1089
- right: x + width,
1090
- bottom: y + height,
1091
- left: x,
1092
- x,
1093
- y
1094
- };
1095
- }
1096
- function getDocumentElement(node) {
1097
- return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
1098
- }
1099
- function getNodeScroll(element) {
1100
- if (isElement(element)) {
1101
- return {
1102
- scrollLeft: element.scrollLeft,
1103
- scrollTop: element.scrollTop
1104
- };
1105
- }
1106
- return {
1107
- scrollLeft: element.pageXOffset,
1108
- scrollTop: element.pageYOffset
1109
- };
1110
- }
1111
- function getWindowScrollBarX(element) {
1112
- return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
1113
- }
1114
- function isScaled(element) {
1115
- const rect = getBoundingClientRect(element);
1116
- return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
1117
- }
1118
- function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1119
- const isOffsetParentAnElement = isHTMLElement2(offsetParent);
1120
- const documentElement = getDocumentElement(offsetParent);
1121
- const rect = getBoundingClientRect(element, isOffsetParentAnElement && isScaled(offsetParent), strategy === "fixed");
1122
- let scroll = {
1123
- scrollLeft: 0,
1124
- scrollTop: 0
1125
- };
1126
- const offsets = {
1127
- x: 0,
1128
- y: 0
1129
- };
1130
- if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") {
1131
- if (getNodeName2(offsetParent) !== "body" || isOverflowElement(documentElement)) {
1132
- scroll = getNodeScroll(offsetParent);
1133
- }
1134
- if (isHTMLElement2(offsetParent)) {
1135
- const offsetRect = getBoundingClientRect(offsetParent, true);
1136
- offsets.x = offsetRect.x + offsetParent.clientLeft;
1137
- offsets.y = offsetRect.y + offsetParent.clientTop;
1138
- } else if (documentElement) {
1139
- offsets.x = getWindowScrollBarX(documentElement);
1140
- }
1141
- }
1142
- return {
1143
- x: rect.left + scroll.scrollLeft - offsets.x,
1144
- y: rect.top + scroll.scrollTop - offsets.y,
1145
- width: rect.width,
1146
- height: rect.height
1147
- };
1148
- }
1149
- function getParentNode(node) {
1150
- if (getNodeName2(node) === "html") {
1151
- return node;
1152
- }
1153
- return node.assignedSlot || node.parentNode || (isShadowRoot(node) ? node.host : null) || getDocumentElement(node);
1154
- }
1155
- function getTrueOffsetParent(element) {
1156
- if (!isHTMLElement2(element) || getComputedStyle(element).position === "fixed") {
1157
- return null;
1158
- }
1159
- return element.offsetParent;
1160
- }
1161
- function getContainingBlock(element) {
1162
- let currentNode = getParentNode(element);
1163
- if (isShadowRoot(currentNode)) {
1164
- currentNode = currentNode.host;
1165
- }
1166
- while (isHTMLElement2(currentNode) && !["html", "body"].includes(getNodeName2(currentNode))) {
1167
- if (isContainingBlock(currentNode)) {
1168
- return currentNode;
1169
- } else {
1170
- currentNode = currentNode.parentNode;
1171
- }
1172
- }
1173
- return null;
1174
- }
1175
- function getOffsetParent(element) {
1176
- const window2 = getWindow(element);
1177
- let offsetParent = getTrueOffsetParent(element);
1178
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") {
1179
- offsetParent = getTrueOffsetParent(offsetParent);
1180
- }
1181
- if (offsetParent && (getNodeName2(offsetParent) === "html" || getNodeName2(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static" && !isContainingBlock(offsetParent))) {
1182
- return window2;
1183
- }
1184
- return offsetParent || getContainingBlock(element) || window2;
1185
- }
1186
- function getDimensions(element) {
1187
- if (isHTMLElement2(element)) {
1188
- return {
1189
- width: element.offsetWidth,
1190
- height: element.offsetHeight
1191
- };
1192
- }
1193
- const rect = getBoundingClientRect(element);
1194
- return {
1195
- width: rect.width,
1196
- height: rect.height
1197
- };
1198
- }
1199
- function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1200
- let {
1201
- rect,
1202
- offsetParent,
1203
- strategy
1204
- } = _ref;
1205
- const isOffsetParentAnElement = isHTMLElement2(offsetParent);
1206
- const documentElement = getDocumentElement(offsetParent);
1207
- if (offsetParent === documentElement) {
1208
- return rect;
1209
- }
1210
- let scroll = {
1211
- scrollLeft: 0,
1212
- scrollTop: 0
1213
- };
1214
- const offsets = {
1215
- x: 0,
1216
- y: 0
1217
- };
1218
- if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") {
1219
- if (getNodeName2(offsetParent) !== "body" || isOverflowElement(documentElement)) {
1220
- scroll = getNodeScroll(offsetParent);
1221
- }
1222
- if (isHTMLElement2(offsetParent)) {
1223
- const offsetRect = getBoundingClientRect(offsetParent, true);
1224
- offsets.x = offsetRect.x + offsetParent.clientLeft;
1225
- offsets.y = offsetRect.y + offsetParent.clientTop;
1226
- }
1227
- }
1228
- return __spreadProps(__spreadValues({}, rect), {
1229
- x: rect.x - scroll.scrollLeft + offsets.x,
1230
- y: rect.y - scroll.scrollTop + offsets.y
1231
- });
1232
- }
1233
- function getViewportRect(element, strategy) {
1234
- const win = getWindow(element);
1235
- const html = getDocumentElement(element);
1236
- const visualViewport = win.visualViewport;
1237
- let width = html.clientWidth;
1238
- let height = html.clientHeight;
1239
- let x = 0;
1240
- let y = 0;
1241
- if (visualViewport) {
1242
- width = visualViewport.width;
1243
- height = visualViewport.height;
1244
- const layoutViewport = isLayoutViewport();
1245
- if (layoutViewport || !layoutViewport && strategy === "fixed") {
1246
- x = visualViewport.offsetLeft;
1247
- y = visualViewport.offsetTop;
1248
- }
1249
- }
1250
- return {
1251
- width,
1252
- height,
1253
- x,
1254
- y
1255
- };
1256
- }
1257
- function getDocumentRect(element) {
1258
- var _element$ownerDocumen;
1259
- const html = getDocumentElement(element);
1260
- const scroll = getNodeScroll(element);
1261
- const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
1262
- const width = max2(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
1263
- const height = max2(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
1264
- let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1265
- const y = -scroll.scrollTop;
1266
- if (getComputedStyle$1(body || html).direction === "rtl") {
1267
- x += max2(html.clientWidth, body ? body.clientWidth : 0) - width;
1268
- }
1269
- return {
1270
- width,
1271
- height,
1272
- x,
1273
- y
1274
- };
1275
- }
1276
- function getNearestOverflowAncestor(node) {
1277
- const parentNode = getParentNode(node);
1278
- if (["html", "body", "#document"].includes(getNodeName2(parentNode))) {
1279
- return node.ownerDocument.body;
1280
- }
1281
- if (isHTMLElement2(parentNode) && isOverflowElement(parentNode)) {
1282
- return parentNode;
1283
- }
1284
- return getNearestOverflowAncestor(parentNode);
1285
- }
1286
- function getOverflowAncestors(node, list) {
1287
- var _node$ownerDocument;
1288
- if (list === void 0) {
1289
- list = [];
1290
- }
1291
- const scrollableAncestor = getNearestOverflowAncestor(node);
1292
- const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
1293
- const win = getWindow(scrollableAncestor);
1294
- const target = isBody ? [win].concat(win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []) : scrollableAncestor;
1295
- const updatedList = list.concat(target);
1296
- return isBody ? updatedList : updatedList.concat(getOverflowAncestors(getParentNode(target)));
1297
- }
1298
- function contains(parent, child) {
1299
- const rootNode = child.getRootNode == null ? void 0 : child.getRootNode();
1300
- if (parent.contains(child)) {
1301
- return true;
1302
- } else if (rootNode && isShadowRoot(rootNode)) {
1303
- let next = child;
1304
- do {
1305
- if (next && parent === next) {
1306
- return true;
1307
- }
1308
- next = next.parentNode || next.host;
1309
- } while (next);
1310
- }
1311
- return false;
1312
- }
1313
- function getInnerBoundingClientRect(element, strategy) {
1314
- const clientRect = getBoundingClientRect(element, false, strategy === "fixed");
1315
- const top = clientRect.top + element.clientTop;
1316
- const left = clientRect.left + element.clientLeft;
1317
- return {
1318
- top,
1319
- left,
1320
- x: left,
1321
- y: top,
1322
- right: left + element.clientWidth,
1323
- bottom: top + element.clientHeight,
1324
- width: element.clientWidth,
1325
- height: element.clientHeight
1326
- };
1327
- }
1328
- function getClientRectFromClippingAncestor(element, clippingParent, strategy) {
1329
- if (clippingParent === "viewport") {
1330
- return rectToClientRect(getViewportRect(element, strategy));
1331
- }
1332
- if (isElement(clippingParent)) {
1333
- return getInnerBoundingClientRect(clippingParent, strategy);
1334
- }
1335
- return rectToClientRect(getDocumentRect(getDocumentElement(element)));
1336
- }
1337
- function getClippingAncestors(element) {
1338
- const clippingAncestors = getOverflowAncestors(element);
1339
- const canEscapeClipping = ["absolute", "fixed"].includes(getComputedStyle$1(element).position);
1340
- const clipperElement = canEscapeClipping && isHTMLElement2(element) ? getOffsetParent(element) : element;
1341
- if (!isElement(clipperElement)) {
1342
- return [];
1343
- }
1344
- return clippingAncestors.filter((clippingAncestors2) => isElement(clippingAncestors2) && contains(clippingAncestors2, clipperElement) && getNodeName2(clippingAncestors2) !== "body");
1345
- }
1346
- function getClippingRect(_ref) {
1347
- let {
1348
- element,
1349
- boundary,
1350
- rootBoundary,
1351
- strategy
1352
- } = _ref;
1353
- const mainClippingAncestors = boundary === "clippingAncestors" ? getClippingAncestors(element) : [].concat(boundary);
1354
- const clippingAncestors = [...mainClippingAncestors, rootBoundary];
1355
- const firstClippingAncestor = clippingAncestors[0];
1356
- const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1357
- const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1358
- accRect.top = max2(rect.top, accRect.top);
1359
- accRect.right = min2(rect.right, accRect.right);
1360
- accRect.bottom = min2(rect.bottom, accRect.bottom);
1361
- accRect.left = max2(rect.left, accRect.left);
1362
- return accRect;
1363
- }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1364
- return {
1365
- width: clippingRect.right - clippingRect.left,
1366
- height: clippingRect.bottom - clippingRect.top,
1367
- x: clippingRect.left,
1368
- y: clippingRect.top
1369
- };
1370
- }
1371
- var platform = {
1372
- getClippingRect,
1373
- convertOffsetParentRelativeRectToViewportRelativeRect,
1374
- isElement,
1375
- getDimensions,
1376
- getOffsetParent,
1377
- getDocumentElement,
1378
- getElementRects: (_ref) => {
1379
- let {
1380
- reference,
1381
- floating,
1382
- strategy
1383
- } = _ref;
1384
- return {
1385
- reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
1386
- floating: __spreadProps(__spreadValues({}, getDimensions(floating)), {
1387
- x: 0,
1388
- y: 0
1389
- })
1390
- };
1391
- },
1392
- getClientRects: (element) => Array.from(element.getClientRects()),
1393
- isRTL: (element) => getComputedStyle$1(element).direction === "rtl"
1394
- };
1395
- var computePosition2 = (reference, floating, options) => computePosition(reference, floating, __spreadValues({
1396
- platform
1397
- }, options));
1398
-
1399
- // ../../utilities/popper/src/auto-update.ts
1400
- function resolveOptions(option) {
1401
- if (isBoolean(option))
1402
- return { ancestorResize: option, ancestorScroll: option, referenceResize: option };
1403
- return Object.assign({ ancestorResize: true, ancestorScroll: true, referenceResize: true }, option);
1404
- }
1405
- function autoUpdate(reference, floating, update, options = false) {
1406
- const { ancestorScroll, ancestorResize, referenceResize } = resolveOptions(options);
1407
- const useAncestors = ancestorScroll || ancestorResize;
1408
- const ancestors = [];
1409
- if (useAncestors && isHTMLElement(reference)) {
1410
- ancestors.push(...getOverflowAncestors(reference));
1411
- }
1412
- function addResizeListeners() {
1413
- let cleanups = [observeElementRect(floating, update)];
1414
- if (referenceResize && isHTMLElement(reference)) {
1415
- cleanups.push(observeElementRect(reference, update));
1416
- }
1417
- cleanups.push(pipe(...ancestors.map((el) => addDomEvent(el, "resize", update))));
1418
- return () => cleanups.forEach((fn) => fn());
1419
- }
1420
- function addScrollListeners() {
1421
- return pipe(...ancestors.map((el) => addDomEvent(el, "scroll", update, { passive: true })));
1422
- }
1423
- return pipe(addResizeListeners(), addScrollListeners());
1424
- }
1425
-
1426
- // ../../utilities/popper/src/middleware.ts
1427
- var toVar = (value) => ({ variable: value, reference: `var(${value})` });
1428
- var cssVars = {
1429
- arrowShadowColor: toVar("--arrow-shadow-color"),
1430
- arrowSize: toVar("--arrow-size"),
1431
- arrowSizeHalf: toVar("--arrow-size-half"),
1432
- arrowBg: toVar("--arrow-background"),
1433
- transformOrigin: toVar("--transform-origin"),
1434
- arrowOffset: toVar("--arrow-offset"),
1435
- boxShadow: toVar("--arrow-box-shadow")
1436
- };
1437
- var transforms = {
1438
- top: "bottom center",
1439
- "top-start": "bottom left",
1440
- "top-end": "bottom right",
1441
- bottom: "top center",
1442
- "bottom-start": "top left",
1443
- "bottom-end": "top right",
1444
- left: "right center",
1445
- "left-start": "right top",
1446
- "left-end": "right bottom",
1447
- right: "left center",
1448
- "right-start": "left top",
1449
- "right-end": "left bottom"
1450
- };
1451
- var transformOrigin = {
1452
- name: "transformOrigin",
1453
- fn({ placement, elements }) {
1454
- const { floating } = elements;
1455
- floating.style.setProperty(cssVars.transformOrigin.variable, transforms[placement]);
1456
- return {
1457
- data: { transformOrigin: transforms[placement] }
1458
- };
1459
- }
1460
- };
1461
- var shiftArrow = (opts) => ({
1462
- name: "shiftArrow",
1463
- fn({ placement, middlewareData }) {
1464
- var _a;
1465
- const { element: arrow2 } = opts;
1466
- const { x, y } = (_a = middlewareData.arrow) != null ? _a : { x: 0, y: 0 };
1467
- const staticSide = {
1468
- top: "bottom",
1469
- right: "left",
1470
- bottom: "top",
1471
- left: "right"
1472
- }[placement.split("-")[0]];
1473
- Object.assign(arrow2.style, {
1474
- top: `${y}px`,
1475
- left: `${x}px`,
1476
- [staticSide]: cssVars.arrowOffset.reference,
1477
- [cssVars.boxShadow.variable]: getBoxShadow(placement)
1478
- });
1479
- return {};
1480
- }
1481
- });
1482
- function getBoxShadow(placement) {
1483
- if (placement.includes("top"))
1484
- return `1px 1px 1px 0 ${cssVars.arrowShadowColor.reference}`;
1485
- if (placement.includes("bottom"))
1486
- return `-1px -1px 1px 0 ${cssVars.arrowShadowColor.reference}`;
1487
- if (placement.includes("right"))
1488
- return `-1px 1px 1px 0 ${cssVars.arrowShadowColor.reference}`;
1489
- if (placement.includes("left"))
1490
- return `1px -1px 1px 0 ${cssVars.arrowShadowColor.reference}`;
1491
- }
1492
-
1493
- // ../../utilities/popper/src/get-placement.ts
1494
- var defaultOptions = {
1495
- strategy: "absolute",
1496
- placement: "bottom",
1497
- listeners: true,
1498
- gutter: 8,
1499
- flip: true,
1500
- sameWidth: false
1501
- };
1502
- function getPlacement(reference, floating, options = {}) {
1503
- var _a;
1504
- if (reference == null || floating == null)
1505
- return noop;
1506
- options = Object.assign({}, defaultOptions, options);
1507
- const middleware = [transformOrigin];
1508
- if (options.flip) {
1509
- middleware.push(flip({ boundary: options.boundary, padding: 8 }));
1510
- }
1511
- if (options.gutter || options.offset) {
1512
- const data = options.gutter ? { mainAxis: options.gutter } : options.offset;
1513
- middleware.push(offset(data));
1514
- }
1515
- middleware.push(shift({ boundary: options.boundary }));
1516
- const doc = getOwnerDocument(floating);
1517
- const arrowEl = doc.querySelector("[data-part=arrow]");
1518
- if (arrowEl) {
1519
- middleware.push(arrow({ element: arrowEl, padding: 8 }), shiftArrow({ element: arrowEl }));
1520
- }
1521
- if (options.sameWidth) {
1522
- middleware.push(size({
1523
- apply(data) {
1524
- const { width } = data.reference;
1525
- Object.assign(floating.style, { width: `${width}px`, minWidth: "unset" });
1526
- }
1527
- }));
1528
- }
1529
- function compute() {
1530
- if (reference == null || floating == null)
1531
- return;
1532
- const { placement, strategy } = options;
1533
- computePosition2(reference, floating, { placement, middleware, strategy }).then((data) => {
1534
- const { x, y, strategy: strategy2 } = data;
1535
- Object.assign(floating.style, { left: `${x}px`, top: `${y}px`, position: strategy2 });
1536
- return data;
1537
- }).then((data) => {
1538
- var _a2;
1539
- (_a2 = options.onComplete) == null ? void 0 : _a2.call(options, data);
1540
- });
1541
- }
1542
- compute();
1543
- return pipe(autoUpdate(reference, floating, compute, options.listeners), (_a = options.onCleanup) != null ? _a : noop);
1544
- }
1545
-
1546
- // ../../utilities/popper/src/get-styles.ts
1547
- var UNMEASURED_FLOATING_STYLE = {
1548
- position: "fixed",
1549
- top: 0,
1550
- left: 0,
1551
- opacity: 0,
1552
- transform: "translate3d(0, -200%, 0)",
1553
- pointerEvents: "none"
1554
- };
1555
- function getPlacementStyles(options) {
1556
- const { measured, strategy = "absolute" } = options;
1557
- return {
1558
- arrow: {
1559
- position: "absolute",
1560
- width: cssVars.arrowSize.reference,
1561
- height: cssVars.arrowSize.reference,
1562
- [cssVars.arrowSizeHalf.variable]: `calc(${cssVars.arrowSize.reference} / 2)`,
1563
- [cssVars.arrowOffset.variable]: `calc(${cssVars.arrowSizeHalf.reference} * -1)`,
1564
- opacity: !measured ? 0 : void 0
1565
- },
1566
- innerArrow: {
1567
- transform: "rotate(45deg)",
1568
- background: cssVars.arrowBg.reference,
1569
- top: "0",
1570
- left: "0",
1571
- width: "100%",
1572
- height: "100%",
1573
- position: "absolute",
1574
- zIndex: "inherit"
1575
- },
1576
- floating: __spreadValues({
1577
- position: strategy,
1578
- minWidth: "max-content"
1579
- }, !measured && UNMEASURED_FLOATING_STYLE)
1580
- };
1581
- }
267
+ // src/tooltip.connect.ts
268
+ var import_popper = require("@zag-js/popper");
1582
269
 
1583
- // ../../types/src/prop-types.ts
270
+ // ../../types/dist/index.mjs
1584
271
  function createNormalizer(fn) {
1585
272
  return { button: fn, label: fn, input: fn, output: fn, element: fn };
1586
273
  }
@@ -1617,671 +304,9 @@ var dom = {
1617
304
  }
1618
305
  };
1619
306
 
1620
- // ../../../node_modules/@zag-js/core/src/index.ts
1621
- var import_vanilla3 = require("valtio/vanilla");
1622
-
1623
- // ../../core/src/action-utils.ts
1624
- function isGuardHelper(value) {
1625
- return isObject(value) && value.predicate != null;
1626
- }
1627
- function determineActionsFn(values, guardMap) {
1628
- return (context, event) => {
1629
- if (isGuardHelper(values))
1630
- return values.predicate(guardMap != null ? guardMap : {})(context, event);
1631
- return values;
1632
- };
1633
- }
1634
-
1635
- // ../../core/src/guard-utils.ts
1636
- function isGuardHelper2(value) {
1637
- return isObject(value) && value.predicate != null;
1638
- }
1639
- var TruthyGuard = () => true;
1640
- function determineGuardFn(guard, guardMap) {
1641
- guard = guard != null ? guard : TruthyGuard;
1642
- return (context, event) => {
1643
- if (isString(guard)) {
1644
- const value = guardMap == null ? void 0 : guardMap[guard];
1645
- return isFunction(value) ? value(context, event) : value;
1646
- }
1647
- if (isGuardHelper2(guard)) {
1648
- return guard.predicate(guardMap != null ? guardMap : {})(context, event);
1649
- }
1650
- return guard == null ? void 0 : guard(context, event);
1651
- };
1652
- }
1653
-
1654
- // ../../../node_modules/klona/json/index.mjs
1655
- function klona(val) {
1656
- var k, out, tmp;
1657
- if (Array.isArray(val)) {
1658
- out = Array(k = val.length);
1659
- while (k--)
1660
- out[k] = (tmp = val[k]) && typeof tmp === "object" ? klona(tmp) : tmp;
1661
- return out;
1662
- }
1663
- if (Object.prototype.toString.call(val) === "[object Object]") {
1664
- out = {};
1665
- for (k in val) {
1666
- if (k === "__proto__") {
1667
- Object.defineProperty(out, k, {
1668
- value: klona(val[k]),
1669
- configurable: true,
1670
- enumerable: true,
1671
- writable: true
1672
- });
1673
- } else {
1674
- out[k] = (tmp = val[k]) && typeof tmp === "object" ? klona(tmp) : tmp;
1675
- }
1676
- }
1677
- return out;
1678
- }
1679
- return val;
1680
- }
1681
-
1682
- // ../../core/src/machine.ts
1683
- var import_utils13 = require("valtio/utils");
1684
- var import_vanilla2 = require("valtio/vanilla");
1685
-
1686
- // ../../core/src/create-proxy.ts
1687
- var import_vanilla = require("valtio/vanilla");
1688
- function createProxy(config) {
1689
- var _a;
1690
- const state = (0, import_vanilla.proxy)({
1691
- value: "",
1692
- previousValue: "",
1693
- event: cast({}),
1694
- context: (_a = config.context) != null ? _a : cast({}),
1695
- done: false,
1696
- tags: [],
1697
- hasTag(tag) {
1698
- return this.tags.includes(tag);
1699
- },
1700
- matches(...value) {
1701
- return value.includes(this.value);
1702
- },
1703
- can(event) {
1704
- return cast(this).nextEvents.includes(event);
1705
- },
1706
- get nextEvents() {
1707
- var _a2, _b, _c, _d;
1708
- const stateEvents = (_c = (_b = (_a2 = config.states) == null ? void 0 : _a2[this.value]) == null ? void 0 : _b["on"]) != null ? _c : {};
1709
- const globalEvents = (_d = config == null ? void 0 : config.on) != null ? _d : {};
1710
- return Object.keys(__spreadValues(__spreadValues({}, stateEvents), globalEvents));
1711
- },
1712
- get changed() {
1713
- if (this.event.value === "machine.init" /* Init */ || !this.previousValue)
1714
- return false;
1715
- return this.value !== this.previousValue;
1716
- }
1717
- });
1718
- return cast(state);
1719
- }
1720
-
1721
- // ../../core/src/delay-utils.ts
1722
- function determineDelayFn(delay, delaysMap) {
1723
- return (context, event) => {
1724
- if (isNumber(delay))
1725
- return delay;
1726
- if (isFunction(delay)) {
1727
- return delay(context, event);
1728
- }
1729
- if (isString(delay)) {
1730
- const value = Number.parseFloat(delay);
1731
- if (!Number.isNaN(value)) {
1732
- return value;
1733
- }
1734
- if (delaysMap) {
1735
- const valueOrFn = delaysMap == null ? void 0 : delaysMap[delay];
1736
- if (valueOrFn == null) {
1737
- const msg = `[machine] Cannot determine delay for ${delay}. It doesn't exist in options.delays`;
1738
- throw new Error(msg);
1739
- }
1740
- return isFunction(valueOrFn) ? valueOrFn(context, event) : valueOrFn;
1741
- }
1742
- }
1743
- };
1744
- }
1745
-
1746
- // ../../core/src/utils.ts
1747
- function toEvent(event) {
1748
- const obj = isString(event) ? { type: event } : event;
1749
- return obj;
1750
- }
1751
- function toArray(value) {
1752
- if (!value)
1753
- return [];
1754
- return isArray(value) ? value : [value];
1755
- }
1756
-
1757
- // ../../core/src/transition-utils.ts
1758
- function toTarget(target) {
1759
- return isString(target) ? { target } : target;
1760
- }
1761
- function determineTransitionFn(transitions, guardMap) {
1762
- return (context, event) => {
1763
- return toArray(transitions).map(toTarget).find((transition) => {
1764
- var _a;
1765
- const determineGuard = determineGuardFn(transition.guard, guardMap);
1766
- const guard = determineGuard(context, event);
1767
- return (_a = guard != null ? guard : transition.target) != null ? _a : transition.actions;
1768
- });
1769
- };
1770
- }
1771
- function toTransition(transition, current) {
1772
- const _transition = isString(transition) ? toTarget(transition) : transition;
1773
- const fn = (t2) => {
1774
- const isTargetless = t2.actions && !t2.target;
1775
- if (isTargetless && current)
1776
- t2.target = current;
1777
- return t2;
1778
- };
1779
- if (isArray(_transition)) {
1780
- return _transition.map(fn);
1781
- }
1782
- if (isObject(_transition)) {
1783
- return fn(cast(_transition));
1784
- }
1785
- }
1786
-
1787
- // ../../core/src/machine.ts
1788
- var Machine = class {
1789
- constructor(config, options) {
1790
- this.config = config;
1791
- this.status = "Not Started" /* NotStarted */;
1792
- this.type = "machine" /* Machine */;
1793
- this.activityEvents = /* @__PURE__ */ new Map();
1794
- this.delayedEvents = /* @__PURE__ */ new Map();
1795
- this.stateListeners = /* @__PURE__ */ new Set();
1796
- this.eventListeners = /* @__PURE__ */ new Set();
1797
- this.doneListeners = /* @__PURE__ */ new Set();
1798
- this.contextWatchers = /* @__PURE__ */ new Set();
1799
- this.removeStateListener = noop;
1800
- this.removeEventListener = noop;
1801
- this.children = /* @__PURE__ */ new Map();
1802
- this.start = (init) => {
1803
- if (this.status === "Running" /* Running */) {
1804
- return this;
1805
- }
1806
- this.status = "Running" /* Running */;
1807
- const event = toEvent("machine.init" /* Init */);
1808
- if (init) {
1809
- const resolved = isObject(init) ? init : { context: this.config.context, value: init };
1810
- this.setState(resolved.value);
1811
- this.setContext(resolved.context);
1812
- }
1813
- const transition = {
1814
- target: !!init ? void 0 : this.config.initial
1815
- };
1816
- const info = this.getNextStateInfo(transition, event);
1817
- info.target = cast(info.target || transition.target);
1818
- this.initialState = info;
1819
- this.performStateChangeEffects(info.target, info, event);
1820
- this.removeStateListener = (0, import_vanilla2.subscribe)(this.state, () => {
1821
- this.stateListeners.forEach((listener) => {
1822
- listener(this.stateSnapshot);
1823
- });
1824
- }, this.sync);
1825
- this.removeEventListener = (0, import_utils13.subscribeKey)(this.state, "event", (value) => {
1826
- if (this.config.onEvent) {
1827
- this.executeActions(this.config.onEvent, value);
1828
- }
1829
- for (const listener of this.eventListeners) {
1830
- listener(value);
1831
- }
1832
- });
1833
- this.setupContextWatchers();
1834
- this.executeActivities(toEvent("machine.start" /* Start */), toArray(this.config.activities), "machine.start" /* Start */);
1835
- this.executeActions(this.config.entry, toEvent("machine.start" /* Start */));
1836
- return this;
1837
- };
1838
- this.setupContextWatchers = () => {
1839
- var _a;
1840
- for (const [key, fn] of Object.entries((_a = this.config.watch) != null ? _a : {})) {
1841
- this.contextWatchers.add((0, import_utils13.subscribeKey)(this.state.context, key, () => {
1842
- this.executeActions(fn, this.state.event);
1843
- }));
1844
- }
1845
- };
1846
- this.setupComputed = () => {
1847
- var _a;
1848
- const computed = cast((_a = this.config.computed) != null ? _a : {});
1849
- const deriveFns = Object.fromEntries(Object.entries(computed).map(([key, fn]) => [key, (get) => fn(get(this.state.context))]));
1850
- (0, import_utils13.derive)(deriveFns, { proxy: this.state.context });
1851
- };
1852
- this.detachComputed = () => {
1853
- (0, import_utils13.underive)(this.state.context, { delete: true });
1854
- };
1855
- this.stop = () => {
1856
- if (this.status === "Stopped" /* Stopped */)
1857
- return;
1858
- this.setState(null);
1859
- this.setEvent("machine.stop" /* Stop */);
1860
- if (this.config.context) {
1861
- this.setContext(this.config.context);
1862
- }
1863
- this.stopStateListeners();
1864
- this.stopChildren();
1865
- this.stopActivities();
1866
- this.stopDelayedEvents();
1867
- this.stopContextWatchers();
1868
- this.stopEventListeners();
1869
- this.detachComputed();
1870
- this.status = "Stopped" /* Stopped */;
1871
- this.executeActions(this.config.exit, toEvent("machine.stop" /* Stop */));
1872
- return this;
1873
- };
1874
- this.stopEventListeners = () => {
1875
- this.eventListeners.clear();
1876
- this.removeEventListener();
1877
- };
1878
- this.stopStateListeners = () => {
1879
- this.removeStateListener();
1880
- this.stateListeners.clear();
1881
- };
1882
- this.stopContextWatchers = () => {
1883
- this.contextWatchers.forEach((fn) => fn());
1884
- this.contextWatchers.clear();
1885
- };
1886
- this.stopDelayedEvents = () => {
1887
- this.delayedEvents.forEach((state) => {
1888
- state.forEach((stop) => stop());
1889
- });
1890
- this.delayedEvents.clear();
1891
- };
1892
- this.stopActivities = (state) => {
1893
- var _a, _b;
1894
- if (state) {
1895
- (_a = this.activityEvents.get(state)) == null ? void 0 : _a.forEach((stop) => stop());
1896
- (_b = this.activityEvents.get(state)) == null ? void 0 : _b.clear();
1897
- this.activityEvents.delete(state);
1898
- } else {
1899
- this.activityEvents.forEach((state2) => {
1900
- state2.forEach((stop) => stop());
1901
- state2.clear();
1902
- });
1903
- this.activityEvents.clear();
1904
- }
1905
- };
1906
- this.sendChild = (evt, to) => {
1907
- const event = toEvent(evt);
1908
- const id = runIfFn(to, this.contextSnapshot);
1909
- const child = this.children.get(id);
1910
- if (!child) {
1911
- invariant(`[machine/send-child] Cannot send '${event.type}' event to unknown child`);
1912
- }
1913
- child.send(event);
1914
- };
1915
- this.stopChild = (id) => {
1916
- if (!this.children.has(id)) {
1917
- invariant("[machine/stop-child] Cannot stop unknown child");
1918
- }
1919
- this.children.get(id).stop();
1920
- this.children.delete(id);
1921
- };
1922
- this.removeChild = (id) => {
1923
- this.children.delete(id);
1924
- };
1925
- this.stopChildren = () => {
1926
- this.children.forEach((child) => child.stop());
1927
- this.children.clear();
1928
- };
1929
- this.setParent = (parent) => {
1930
- this.parent = parent;
1931
- };
1932
- this.spawn = (src, id) => {
1933
- const actor = runIfFn(src);
1934
- if (id)
1935
- actor.id = id;
1936
- actor.type = "machine.actor" /* Actor */;
1937
- actor.setParent(this);
1938
- this.children.set(actor.id, cast(actor));
1939
- actor.onDone(() => {
1940
- this.removeChild(actor.id);
1941
- }).start();
1942
- return cast((0, import_vanilla2.ref)(actor));
1943
- };
1944
- this.addActivityCleanup = (state, cleanup) => {
1945
- var _a;
1946
- if (!state)
1947
- return;
1948
- if (!this.activityEvents.has(state)) {
1949
- this.activityEvents.set(state, /* @__PURE__ */ new Set([cleanup]));
1950
- } else {
1951
- (_a = this.activityEvents.get(state)) == null ? void 0 : _a.add(cleanup);
1952
- }
1953
- };
1954
- this.setState = (target) => {
1955
- this.state.previousValue = this.state.value;
1956
- this.state.value = target;
1957
- const stateNode = this.getStateNode(target);
1958
- if (target == null) {
1959
- clear(this.state.tags);
1960
- } else {
1961
- this.state.tags = toArray(stateNode == null ? void 0 : stateNode.tags);
1962
- }
1963
- };
1964
- this.setContext = (context) => {
1965
- for (const key in context) {
1966
- this.state.context[key] = context[key];
1967
- }
1968
- };
1969
- this.withContext = (context) => {
1970
- this.detachComputed();
1971
- const newContext = __spreadValues(__spreadValues({}, this.config.context), context);
1972
- return new Machine(__spreadProps(__spreadValues({}, this.config), { context: newContext }), this.options);
1973
- };
1974
- this.withOptions = (options) => {
1975
- this.detachComputed();
1976
- return new Machine(this.config, __spreadValues(__spreadValues({}, this.options), options));
1977
- };
1978
- this.setActions = (actions) => {
1979
- this.actionMap = __spreadValues(__spreadValues({}, this.actionMap), actions);
1980
- };
1981
- this.clone = () => {
1982
- this.detachComputed();
1983
- return new Machine(this.config, this.options);
1984
- };
1985
- this.getStateNode = (state) => {
1986
- var _a;
1987
- if (!state)
1988
- return;
1989
- return (_a = this.config.states) == null ? void 0 : _a[state];
1990
- };
1991
- this.getNextStateInfo = (transitions, event) => {
1992
- var _a;
1993
- const transition = this.determineTransition(transitions, event);
1994
- const target = (_a = transition == null ? void 0 : transition.target) != null ? _a : this.state.value;
1995
- const stateNode = this.getStateNode(target);
1996
- return {
1997
- transition,
1998
- stateNode,
1999
- target
2000
- };
2001
- };
2002
- this.getActionFromDelayedTransition = (transition) => {
2003
- const event = toEvent("machine.after" /* After */);
2004
- const determineDelay = determineDelayFn(transition.delay, this.delayMap);
2005
- const delay = determineDelay(this.contextSnapshot, event);
2006
- let id;
2007
- return {
2008
- entry: () => {
2009
- id = globalThis.setTimeout(() => {
2010
- const current = this.state.value;
2011
- const next = this.getNextStateInfo(transition, event);
2012
- this.performStateChangeEffects(current, next, event);
2013
- }, delay);
2014
- },
2015
- exit: () => {
2016
- globalThis.clearTimeout(id);
2017
- }
2018
- };
2019
- };
2020
- this.getDelayedEventActions = (state) => {
2021
- const stateNode = this.getStateNode(state);
2022
- const event = toEvent("machine.after" /* After */);
2023
- if (!stateNode || !stateNode.after)
2024
- return;
2025
- const entries = [];
2026
- const exits = [];
2027
- if (isArray(stateNode.after)) {
2028
- const transition = this.determineTransition(stateNode.after, event);
2029
- if (!transition)
2030
- return;
2031
- const actions = this.getActionFromDelayedTransition(transition);
2032
- entries.push(actions.entry);
2033
- exits.push(actions.exit);
2034
- } else if (isObject(stateNode.after)) {
2035
- for (const delay in stateNode.after) {
2036
- const transition = stateNode.after[delay];
2037
- let resolvedTransition = {};
2038
- if (isArray(transition)) {
2039
- const picked = this.determineTransition(transition, event);
2040
- if (picked)
2041
- resolvedTransition = picked;
2042
- } else if (isString(transition)) {
2043
- resolvedTransition = { target: transition, delay };
2044
- } else {
2045
- resolvedTransition = __spreadProps(__spreadValues({}, transition), { delay });
2046
- }
2047
- const actions = this.getActionFromDelayedTransition(resolvedTransition);
2048
- entries.push(actions.entry);
2049
- exits.push(actions.exit);
2050
- }
2051
- }
2052
- return { entries, exits };
2053
- };
2054
- this.executeActions = (actions, event) => {
2055
- var _a;
2056
- const _actions = determineActionsFn(actions, this.guardMap)(this.contextSnapshot, event);
2057
- for (const action of toArray(_actions)) {
2058
- const fn = isString(action) ? (_a = this.actionMap) == null ? void 0 : _a[action] : action;
2059
- warn(isString(action) && !fn, `[machine/exec-action] No implementation found for action: \`${action}\``);
2060
- fn == null ? void 0 : fn(this.state.context, event, this.meta);
2061
- }
2062
- };
2063
- this.executeActivities = (event, activities, state) => {
2064
- var _a;
2065
- for (const activity of activities) {
2066
- const fn = isString(activity) ? (_a = this.activityMap) == null ? void 0 : _a[activity] : activity;
2067
- if (!fn) {
2068
- warn(`[machine/exec-activity] No implementation found for activity: \`${activity}\``);
2069
- continue;
2070
- }
2071
- const cleanup = fn(this.state.context, event, this.meta);
2072
- if (cleanup) {
2073
- this.addActivityCleanup(state != null ? state : this.state.value, cleanup);
2074
- }
2075
- }
2076
- };
2077
- this.createEveryActivities = (every, callbackfn) => {
2078
- if (!every)
2079
- return;
2080
- const event = toEvent("machine.every" /* Every */);
2081
- if (isArray(every)) {
2082
- const picked = toArray(every).find((t2) => {
2083
- const determineDelay2 = determineDelayFn(t2.delay, this.delayMap);
2084
- t2.delay = determineDelay2(this.contextSnapshot, event);
2085
- const determineGuard = determineGuardFn(t2.guard, this.guardMap);
2086
- const guard = determineGuard(this.contextSnapshot, event);
2087
- return guard != null ? guard : t2.delay;
2088
- });
2089
- if (!picked)
2090
- return;
2091
- const determineDelay = determineDelayFn(picked.delay, this.delayMap);
2092
- const delay = determineDelay(this.contextSnapshot, event);
2093
- const activity = () => {
2094
- const id = globalThis.setInterval(() => {
2095
- this.executeActions(picked.actions, event);
2096
- }, delay);
2097
- return () => {
2098
- globalThis.clearInterval(id);
2099
- };
2100
- };
2101
- callbackfn(activity);
2102
- } else {
2103
- for (const interval in every) {
2104
- const actions = every == null ? void 0 : every[interval];
2105
- const determineDelay = determineDelayFn(interval, this.delayMap);
2106
- const delay = determineDelay(this.contextSnapshot, event);
2107
- const activity = () => {
2108
- const id = globalThis.setInterval(() => {
2109
- this.executeActions(actions, event);
2110
- }, delay);
2111
- return () => {
2112
- globalThis.clearInterval(id);
2113
- };
2114
- };
2115
- callbackfn(activity);
2116
- }
2117
- }
2118
- };
2119
- this.setEvent = (event) => {
2120
- this.state.event = (0, import_vanilla2.ref)(toEvent(event));
2121
- };
2122
- this.performExitEffects = (current, event) => {
2123
- const currentState = this.state.value;
2124
- const stateNode = current ? this.getStateNode(current) : void 0;
2125
- this.stopActivities(currentState);
2126
- const _exit = determineActionsFn(stateNode == null ? void 0 : stateNode.exit, this.guardMap)(this.contextSnapshot, event);
2127
- const exitActions = toArray(_exit);
2128
- const afterExitActions = this.delayedEvents.get(currentState);
2129
- if (afterExitActions) {
2130
- exitActions.push(...afterExitActions);
2131
- }
2132
- this.executeActions(exitActions, event);
2133
- this.eventListeners.clear();
2134
- };
2135
- this.performEntryEffects = (next, event) => {
2136
- const stateNode = this.getStateNode(next);
2137
- const activities = toArray(stateNode == null ? void 0 : stateNode.activities);
2138
- this.createEveryActivities(stateNode == null ? void 0 : stateNode.every, (activity) => {
2139
- activities.unshift(activity);
2140
- });
2141
- if (activities.length > 0) {
2142
- this.executeActivities(event, activities);
2143
- }
2144
- const _entry = determineActionsFn(stateNode == null ? void 0 : stateNode.entry, this.guardMap)(this.contextSnapshot, event);
2145
- const entryActions = toArray(_entry);
2146
- const afterActions = this.getDelayedEventActions(next);
2147
- if ((stateNode == null ? void 0 : stateNode.after) && afterActions) {
2148
- this.delayedEvents.set(next, afterActions == null ? void 0 : afterActions.exits);
2149
- entryActions.push(...afterActions.entries);
2150
- }
2151
- this.executeActions(entryActions, event);
2152
- if ((stateNode == null ? void 0 : stateNode.type) === "final") {
2153
- this.state.done = true;
2154
- this.doneListeners.forEach((listener) => {
2155
- listener(this.stateSnapshot);
2156
- });
2157
- this.stop();
2158
- }
2159
- };
2160
- this.performTransitionEffects = (transition, event) => {
2161
- const t2 = this.determineTransition(transition, event);
2162
- this.executeActions(t2 == null ? void 0 : t2.actions, event);
2163
- };
2164
- this.performStateChangeEffects = (current, next, event) => {
2165
- var _a, _b;
2166
- this.setEvent(event);
2167
- next.target = (_b = (_a = next.target) != null ? _a : this.state.value) != null ? _b : void 0;
2168
- const ok = next.target && next.target !== this.state.value;
2169
- if (ok) {
2170
- this.performExitEffects(current, event);
2171
- }
2172
- this.performTransitionEffects(next == null ? void 0 : next.transition, event);
2173
- this.setState(next.target);
2174
- if (ok) {
2175
- this.performEntryEffects(next.target, event);
2176
- }
2177
- };
2178
- this.determineTransition = (transition, event) => {
2179
- const fn = determineTransitionFn(transition, this.guardMap);
2180
- return fn == null ? void 0 : fn(this.contextSnapshot, event);
2181
- };
2182
- this.sendParent = (evt) => {
2183
- var _a;
2184
- if (!this.parent) {
2185
- invariant("[machine/send-parent] Cannot send event to an unknown parent");
2186
- }
2187
- const event = toEvent(evt);
2188
- (_a = this.parent) == null ? void 0 : _a.send(event);
2189
- };
2190
- this.send = (evt) => {
2191
- const event = toEvent(evt);
2192
- this.transition(this.state.value, event);
2193
- };
2194
- this.transition = (state, evt) => {
2195
- var _a, _b, _c;
2196
- const stateNode = isString(state) ? this.getStateNode(state) : state == null ? void 0 : state.stateNode;
2197
- const event = toEvent(evt);
2198
- if (!stateNode && !this.config.on) {
2199
- const msg = this.status === "Stopped" /* Stopped */ ? "[machine/transition] Cannot transition a stopped machine" : "[machine/transition] State does not have a definition";
2200
- warn(msg);
2201
- return;
2202
- }
2203
- const transitionConfig = (_c = (_a = stateNode == null ? void 0 : stateNode.on) == null ? void 0 : _a[event.type]) != null ? _c : (_b = this.config.on) == null ? void 0 : _b[event.type];
2204
- const transition = toTransition(transitionConfig, this.state.value);
2205
- if (!transition)
2206
- return;
2207
- const info = this.getNextStateInfo(transition, event);
2208
- this.performStateChangeEffects(this.state.value, info, event);
2209
- return info.stateNode;
2210
- };
2211
- this.subscribe = (listener) => {
2212
- this.stateListeners.add(listener);
2213
- if (this.status === "Running" /* Running */) {
2214
- listener(this.stateSnapshot);
2215
- }
2216
- return () => {
2217
- this.stateListeners.delete(listener);
2218
- };
2219
- };
2220
- this.onDone = (listener) => {
2221
- this.doneListeners.add(listener);
2222
- return this;
2223
- };
2224
- this.onTransition = (listener) => {
2225
- this.stateListeners.add(listener);
2226
- if (this.status === "Running" /* Running */) {
2227
- listener(this.stateSnapshot);
2228
- }
2229
- return this;
2230
- };
2231
- this.onEvent = (listener) => {
2232
- listener(this.state.event);
2233
- this.eventListeners.add(listener);
2234
- return this;
2235
- };
2236
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
2237
- this.options = klona(options);
2238
- this.id = (_a = config.id) != null ? _a : `machine-${uuid()}`;
2239
- this.guardMap = (_c = (_b = this.options) == null ? void 0 : _b.guards) != null ? _c : {};
2240
- this.actionMap = (_e = (_d = this.options) == null ? void 0 : _d.actions) != null ? _e : {};
2241
- this.delayMap = (_g = (_f = this.options) == null ? void 0 : _f.delays) != null ? _g : {};
2242
- this.activityMap = (_i = (_h = this.options) == null ? void 0 : _h.activities) != null ? _i : {};
2243
- this.sync = (_k = (_j = this.options) == null ? void 0 : _j.sync) != null ? _k : false;
2244
- this.state = createProxy(klona(config));
2245
- this.setupComputed();
2246
- const event = toEvent("machine.created" /* Created */);
2247
- this.executeActions(config == null ? void 0 : config.created, event);
2248
- }
2249
- get stateSnapshot() {
2250
- return cast((0, import_vanilla2.snapshot)(this.state));
2251
- }
2252
- get contextSnapshot() {
2253
- return this.stateSnapshot.context;
2254
- }
2255
- get self() {
2256
- const _self = this;
2257
- return {
2258
- id: this.id,
2259
- send: this.send.bind(this),
2260
- sendParent: this.sendParent.bind(this),
2261
- sendChild: this.sendChild.bind(this),
2262
- stop: this.stop.bind(this),
2263
- stopChild: this.stopChild.bind(this),
2264
- spawn: this.spawn.bind(this),
2265
- get state() {
2266
- return _self.stateSnapshot;
2267
- }
2268
- };
2269
- }
2270
- get meta() {
2271
- return {
2272
- state: this.stateSnapshot,
2273
- guards: this.guardMap,
2274
- send: this.send.bind(this),
2275
- listen: this.onEvent.bind(this),
2276
- self: this.self,
2277
- getState: () => this.stateSnapshot
2278
- };
2279
- }
2280
- };
2281
- var createMachine = (config, options) => new Machine(config, options);
2282
-
2283
307
  // src/tooltip.store.ts
2284
- var store = (0, import_vanilla3.proxy)({
308
+ var import_core = require("@zag-js/core");
309
+ var store = (0, import_core.proxy)({
2285
310
  id: null,
2286
311
  prevId: null,
2287
312
  setId(val) {
@@ -2297,7 +322,7 @@ function connect(state, send, normalize = normalizeProp) {
2297
322
  const isOpen = state.hasTag("open");
2298
323
  const triggerId = dom.getTriggerId(state.context);
2299
324
  const contentId = dom.getContentId(state.context);
2300
- const popperStyles = getPlacementStyles({
325
+ const popperStyles = (0, import_popper.getPlacementStyles)({
2301
326
  measured: !!state.context.isPlacementComplete
2302
327
  });
2303
328
  return {
@@ -2394,7 +419,18 @@ function connect(state, send, normalize = normalizeProp) {
2394
419
  }
2395
420
 
2396
421
  // src/tooltip.machine.ts
2397
- var machine = createMachine({
422
+ var import_core2 = require("@zag-js/core");
423
+ var import_popper2 = require("@zag-js/popper");
424
+
425
+ // ../../utilities/core/dist/index.mjs
426
+ var noop2 = () => {
427
+ };
428
+ var ua = (v) => isDom() && v.test(navigator.userAgent);
429
+ var isDom = () => !!(typeof window !== "undefined");
430
+ var isSafari = () => ua(/^((?!chrome|android).)*safari/i);
431
+
432
+ // src/tooltip.machine.ts
433
+ var machine = (0, import_core2.createMachine)({
2398
434
  id: "tooltip",
2399
435
  initial: "unknown",
2400
436
  context: {
@@ -2509,7 +545,7 @@ var machine = createMachine({
2509
545
  ctx.currentPlacement = ctx.positioning.placement;
2510
546
  let cleanup;
2511
547
  raf(() => {
2512
- cleanup = getPlacement(dom.getTriggerEl(ctx), dom.getPositionerEl(ctx), __spreadProps(__spreadValues({}, ctx.positioning), {
548
+ cleanup = (0, import_popper2.getPlacement)(dom.getTriggerEl(ctx), dom.getPositionerEl(ctx), __spreadProps(__spreadValues({}, ctx.positioning), {
2513
549
  onComplete(data) {
2514
550
  ctx.currentPlacement = data.placement;
2515
551
  ctx.isPlacementComplete = true;
@@ -2540,7 +576,7 @@ var machine = createMachine({
2540
576
  };
2541
577
  },
2542
578
  trackStore(ctx, _evt, { send }) {
2543
- return (0, import_vanilla3.subscribe)(store, () => {
579
+ return (0, import_core2.subscribe)(store, () => {
2544
580
  if (store.id !== ctx.id) {
2545
581
  send("FORCE_CLOSE");
2546
582
  }
@@ -2548,7 +584,7 @@ var machine = createMachine({
2548
584
  },
2549
585
  trackDisabledTriggerOnSafari(ctx, _evt, { send }) {
2550
586
  if (!isSafari())
2551
- return noop;
587
+ return noop2;
2552
588
  const doc = dom.getDoc(ctx);
2553
589
  return addPointerEvent(doc, "pointermove", (event) => {
2554
590
  const selector = "[data-part=trigger][data-expanded]";
@@ -2572,7 +608,7 @@ var machine = createMachine({
2572
608
  setupDocument(ctx, evt) {
2573
609
  ctx.id = evt.id;
2574
610
  if (evt.doc)
2575
- ctx.doc = (0, import_vanilla3.ref)(evt.doc);
611
+ ctx.doc = (0, import_core2.ref)(evt.doc);
2576
612
  },
2577
613
  setGlobalId(ctx) {
2578
614
  store.setId(ctx.id);