@tiptap/vue-2 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +5 -1
  3. package/dist/index.cjs +340 -349
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +79 -0
  6. package/dist/index.d.ts +79 -0
  7. package/dist/index.js +298 -337
  8. package/dist/index.js.map +1 -1
  9. package/dist/menus/index.cjs +2273 -0
  10. package/dist/menus/index.cjs.map +1 -0
  11. package/dist/menus/index.d.cts +139 -0
  12. package/dist/menus/index.d.ts +139 -0
  13. package/dist/menus/index.js +2245 -0
  14. package/dist/menus/index.js.map +1 -0
  15. package/package.json +28 -16
  16. package/src/Editor.ts +1 -1
  17. package/src/EditorContent.ts +7 -5
  18. package/src/NodeViewContent.ts +3 -2
  19. package/src/NodeViewWrapper.ts +6 -5
  20. package/src/VueNodeViewRenderer.ts +80 -27
  21. package/src/VueRenderer.ts +5 -7
  22. package/src/index.ts +0 -2
  23. package/src/menus/BubbleMenu.ts +85 -0
  24. package/src/{FloatingMenu.ts → menus/FloatingMenu.ts} +24 -15
  25. package/src/menus/index.ts +2 -0
  26. package/dist/index.umd.js +0 -379
  27. package/dist/index.umd.js.map +0 -1
  28. package/dist/packages/core/src/CommandManager.d.ts +0 -20
  29. package/dist/packages/core/src/Editor.d.ts +0 -161
  30. package/dist/packages/core/src/EventEmitter.d.ts +0 -11
  31. package/dist/packages/core/src/Extension.d.ts +0 -343
  32. package/dist/packages/core/src/ExtensionManager.d.ts +0 -55
  33. package/dist/packages/core/src/InputRule.d.ts +0 -42
  34. package/dist/packages/core/src/Mark.d.ts +0 -451
  35. package/dist/packages/core/src/Node.d.ts +0 -611
  36. package/dist/packages/core/src/NodePos.d.ts +0 -44
  37. package/dist/packages/core/src/NodeView.d.ts +0 -31
  38. package/dist/packages/core/src/PasteRule.d.ts +0 -50
  39. package/dist/packages/core/src/Tracker.d.ts +0 -11
  40. package/dist/packages/core/src/commands/blur.d.ts +0 -13
  41. package/dist/packages/core/src/commands/clearContent.d.ts +0 -14
  42. package/dist/packages/core/src/commands/clearNodes.d.ts +0 -13
  43. package/dist/packages/core/src/commands/command.d.ts +0 -18
  44. package/dist/packages/core/src/commands/createParagraphNear.d.ts +0 -13
  45. package/dist/packages/core/src/commands/cut.d.ts +0 -20
  46. package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +0 -13
  47. package/dist/packages/core/src/commands/deleteNode.d.ts +0 -15
  48. package/dist/packages/core/src/commands/deleteRange.d.ts +0 -14
  49. package/dist/packages/core/src/commands/deleteSelection.d.ts +0 -13
  50. package/dist/packages/core/src/commands/enter.d.ts +0 -13
  51. package/dist/packages/core/src/commands/exitCode.d.ts +0 -13
  52. package/dist/packages/core/src/commands/extendMarkRange.d.ts +0 -25
  53. package/dist/packages/core/src/commands/first.d.ts +0 -14
  54. package/dist/packages/core/src/commands/focus.d.ts +0 -27
  55. package/dist/packages/core/src/commands/forEach.d.ts +0 -14
  56. package/dist/packages/core/src/commands/index.d.ts +0 -55
  57. package/dist/packages/core/src/commands/insertContent.d.ts +0 -34
  58. package/dist/packages/core/src/commands/insertContentAt.d.ts +0 -47
  59. package/dist/packages/core/src/commands/join.d.ts +0 -41
  60. package/dist/packages/core/src/commands/joinItemBackward.d.ts +0 -13
  61. package/dist/packages/core/src/commands/joinItemForward.d.ts +0 -13
  62. package/dist/packages/core/src/commands/joinTextblockBackward.d.ts +0 -12
  63. package/dist/packages/core/src/commands/joinTextblockForward.d.ts +0 -12
  64. package/dist/packages/core/src/commands/keyboardShortcut.d.ts +0 -14
  65. package/dist/packages/core/src/commands/lift.d.ts +0 -17
  66. package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +0 -13
  67. package/dist/packages/core/src/commands/liftListItem.d.ts +0 -15
  68. package/dist/packages/core/src/commands/newlineInCode.d.ts +0 -13
  69. package/dist/packages/core/src/commands/resetAttributes.d.ts +0 -16
  70. package/dist/packages/core/src/commands/scrollIntoView.d.ts +0 -13
  71. package/dist/packages/core/src/commands/selectAll.d.ts +0 -13
  72. package/dist/packages/core/src/commands/selectNodeBackward.d.ts +0 -13
  73. package/dist/packages/core/src/commands/selectNodeForward.d.ts +0 -13
  74. package/dist/packages/core/src/commands/selectParentNode.d.ts +0 -13
  75. package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +0 -13
  76. package/dist/packages/core/src/commands/selectTextblockStart.d.ts +0 -13
  77. package/dist/packages/core/src/commands/setContent.d.ts +0 -40
  78. package/dist/packages/core/src/commands/setMark.d.ts +0 -15
  79. package/dist/packages/core/src/commands/setMeta.d.ts +0 -15
  80. package/dist/packages/core/src/commands/setNode.d.ts +0 -16
  81. package/dist/packages/core/src/commands/setNodeSelection.d.ts +0 -14
  82. package/dist/packages/core/src/commands/setTextSelection.d.ts +0 -14
  83. package/dist/packages/core/src/commands/sinkListItem.d.ts +0 -15
  84. package/dist/packages/core/src/commands/splitBlock.d.ts +0 -17
  85. package/dist/packages/core/src/commands/splitListItem.d.ts +0 -15
  86. package/dist/packages/core/src/commands/toggleList.d.ts +0 -18
  87. package/dist/packages/core/src/commands/toggleMark.d.ts +0 -30
  88. package/dist/packages/core/src/commands/toggleNode.d.ts +0 -17
  89. package/dist/packages/core/src/commands/toggleWrap.d.ts +0 -16
  90. package/dist/packages/core/src/commands/undoInputRule.d.ts +0 -13
  91. package/dist/packages/core/src/commands/unsetAllMarks.d.ts +0 -13
  92. package/dist/packages/core/src/commands/unsetMark.d.ts +0 -25
  93. package/dist/packages/core/src/commands/updateAttributes.d.ts +0 -24
  94. package/dist/packages/core/src/commands/wrapIn.d.ts +0 -16
  95. package/dist/packages/core/src/commands/wrapInList.d.ts +0 -16
  96. package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +0 -5
  97. package/dist/packages/core/src/extensions/commands.d.ts +0 -3
  98. package/dist/packages/core/src/extensions/editable.d.ts +0 -2
  99. package/dist/packages/core/src/extensions/focusEvents.d.ts +0 -2
  100. package/dist/packages/core/src/extensions/index.d.ts +0 -6
  101. package/dist/packages/core/src/extensions/keymap.d.ts +0 -2
  102. package/dist/packages/core/src/extensions/tabindex.d.ts +0 -2
  103. package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +0 -10
  104. package/dist/packages/core/src/helpers/createChainableState.d.ts +0 -10
  105. package/dist/packages/core/src/helpers/createDocument.d.ts +0 -12
  106. package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +0 -15
  107. package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +0 -7
  108. package/dist/packages/core/src/helpers/findChildren.d.ts +0 -9
  109. package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +0 -10
  110. package/dist/packages/core/src/helpers/findParentNode.d.ts +0 -16
  111. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +0 -17
  112. package/dist/packages/core/src/helpers/generateHTML.d.ts +0 -8
  113. package/dist/packages/core/src/helpers/generateJSON.d.ts +0 -8
  114. package/dist/packages/core/src/helpers/generateText.d.ts +0 -12
  115. package/dist/packages/core/src/helpers/getAttributes.d.ts +0 -9
  116. package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +0 -6
  117. package/dist/packages/core/src/helpers/getChangedRanges.d.ts +0 -11
  118. package/dist/packages/core/src/helpers/getDebugJSON.d.ts +0 -8
  119. package/dist/packages/core/src/helpers/getExtensionField.d.ts +0 -9
  120. package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +0 -2
  121. package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +0 -3
  122. package/dist/packages/core/src/helpers/getMarkRange.d.ts +0 -3
  123. package/dist/packages/core/src/helpers/getMarkType.d.ts +0 -2
  124. package/dist/packages/core/src/helpers/getMarksBetween.d.ts +0 -3
  125. package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +0 -11
  126. package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +0 -3
  127. package/dist/packages/core/src/helpers/getNodeType.d.ts +0 -2
  128. package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +0 -3
  129. package/dist/packages/core/src/helpers/getSchema.d.ts +0 -4
  130. package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +0 -10
  131. package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +0 -8
  132. package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +0 -8
  133. package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +0 -9
  134. package/dist/packages/core/src/helpers/getText.d.ts +0 -15
  135. package/dist/packages/core/src/helpers/getTextBetween.d.ts +0 -14
  136. package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +0 -8
  137. package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +0 -8
  138. package/dist/packages/core/src/helpers/index.d.ts +0 -50
  139. package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +0 -9
  140. package/dist/packages/core/src/helpers/isActive.d.ts +0 -2
  141. package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +0 -2
  142. package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +0 -2
  143. package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +0 -2
  144. package/dist/packages/core/src/helpers/isList.d.ts +0 -2
  145. package/dist/packages/core/src/helpers/isMarkActive.d.ts +0 -3
  146. package/dist/packages/core/src/helpers/isNodeActive.d.ts +0 -3
  147. package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +0 -2
  148. package/dist/packages/core/src/helpers/isNodeSelection.d.ts +0 -2
  149. package/dist/packages/core/src/helpers/isTextSelection.d.ts +0 -2
  150. package/dist/packages/core/src/helpers/posToDOMRect.d.ts +0 -2
  151. package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +0 -4
  152. package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +0 -2
  153. package/dist/packages/core/src/helpers/splitExtensions.d.ts +0 -9
  154. package/dist/packages/core/src/index.d.ts +0 -24
  155. package/dist/packages/core/src/inputRules/index.d.ts +0 -5
  156. package/dist/packages/core/src/inputRules/markInputRule.d.ts +0 -13
  157. package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -23
  158. package/dist/packages/core/src/inputRules/textInputRule.d.ts +0 -10
  159. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +0 -15
  160. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +0 -28
  161. package/dist/packages/core/src/pasteRules/index.d.ts +0 -3
  162. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +0 -13
  163. package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +0 -13
  164. package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +0 -10
  165. package/dist/packages/core/src/style.d.ts +0 -1
  166. package/dist/packages/core/src/types.d.ts +0 -255
  167. package/dist/packages/core/src/utilities/callOrReturn.d.ts +0 -9
  168. package/dist/packages/core/src/utilities/createStyleTag.d.ts +0 -1
  169. package/dist/packages/core/src/utilities/deleteProps.d.ts +0 -6
  170. package/dist/packages/core/src/utilities/elementFromString.d.ts +0 -1
  171. package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +0 -1
  172. package/dist/packages/core/src/utilities/findDuplicates.d.ts +0 -1
  173. package/dist/packages/core/src/utilities/fromString.d.ts +0 -1
  174. package/dist/packages/core/src/utilities/index.d.ts +0 -20
  175. package/dist/packages/core/src/utilities/isAndroid.d.ts +0 -1
  176. package/dist/packages/core/src/utilities/isEmptyObject.d.ts +0 -1
  177. package/dist/packages/core/src/utilities/isFunction.d.ts +0 -1
  178. package/dist/packages/core/src/utilities/isMacOS.d.ts +0 -1
  179. package/dist/packages/core/src/utilities/isNumber.d.ts +0 -1
  180. package/dist/packages/core/src/utilities/isPlainObject.d.ts +0 -1
  181. package/dist/packages/core/src/utilities/isRegExp.d.ts +0 -1
  182. package/dist/packages/core/src/utilities/isString.d.ts +0 -1
  183. package/dist/packages/core/src/utilities/isiOS.d.ts +0 -1
  184. package/dist/packages/core/src/utilities/mergeAttributes.d.ts +0 -1
  185. package/dist/packages/core/src/utilities/mergeDeep.d.ts +0 -1
  186. package/dist/packages/core/src/utilities/minMax.d.ts +0 -1
  187. package/dist/packages/core/src/utilities/objectIncludes.d.ts +0 -8
  188. package/dist/packages/core/src/utilities/removeDuplicates.d.ts +0 -8
  189. package/dist/packages/extension-bubble-menu/src/bubble-menu-plugin.d.ts +0 -76
  190. package/dist/packages/extension-bubble-menu/src/bubble-menu.d.ts +0 -15
  191. package/dist/packages/extension-bubble-menu/src/index.d.ts +0 -4
  192. package/dist/packages/extension-floating-menu/src/floating-menu-plugin.d.ts +0 -66
  193. package/dist/packages/extension-floating-menu/src/floating-menu.d.ts +0 -15
  194. package/dist/packages/extension-floating-menu/src/index.d.ts +0 -4
  195. package/dist/packages/vue-2/src/BubbleMenu.d.ts +0 -10
  196. package/dist/packages/vue-2/src/Editor.d.ts +0 -5
  197. package/dist/packages/vue-2/src/EditorContent.d.ts +0 -6
  198. package/dist/packages/vue-2/src/FloatingMenu.d.ts +0 -9
  199. package/dist/packages/vue-2/src/NodeViewContent.d.ts +0 -5
  200. package/dist/packages/vue-2/src/NodeViewWrapper.d.ts +0 -9
  201. package/dist/packages/vue-2/src/VueNodeViewRenderer.d.ts +0 -37
  202. package/dist/packages/vue-2/src/VueRenderer.d.ts +0 -12
  203. package/dist/packages/vue-2/src/index.d.ts +0 -9
  204. package/src/BubbleMenu.ts +0 -70
@@ -0,0 +1,2273 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/menus/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ BubbleMenu: () => BubbleMenu2,
24
+ FloatingMenu: () => FloatingMenu2
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+
28
+ // ../extension-bubble-menu/dist/index.js
29
+ var import_core2 = require("@tiptap/core");
30
+
31
+ // ../../node_modules/.pnpm/@floating-ui+utils@0.2.9/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
32
+ var sides = ["top", "right", "bottom", "left"];
33
+ var alignments = ["start", "end"];
34
+ var placements = /* @__PURE__ */ sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
35
+ var min = Math.min;
36
+ var max = Math.max;
37
+ var round = Math.round;
38
+ var createCoords = (v) => ({
39
+ x: v,
40
+ y: v
41
+ });
42
+ var oppositeSideMap = {
43
+ left: "right",
44
+ right: "left",
45
+ bottom: "top",
46
+ top: "bottom"
47
+ };
48
+ var oppositeAlignmentMap = {
49
+ start: "end",
50
+ end: "start"
51
+ };
52
+ function clamp(start, value, end) {
53
+ return max(start, min(value, end));
54
+ }
55
+ function evaluate(value, param) {
56
+ return typeof value === "function" ? value(param) : value;
57
+ }
58
+ function getSide(placement) {
59
+ return placement.split("-")[0];
60
+ }
61
+ function getAlignment(placement) {
62
+ return placement.split("-")[1];
63
+ }
64
+ function getOppositeAxis(axis) {
65
+ return axis === "x" ? "y" : "x";
66
+ }
67
+ function getAxisLength(axis) {
68
+ return axis === "y" ? "height" : "width";
69
+ }
70
+ function getSideAxis(placement) {
71
+ return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x";
72
+ }
73
+ function getAlignmentAxis(placement) {
74
+ return getOppositeAxis(getSideAxis(placement));
75
+ }
76
+ function getAlignmentSides(placement, rects, rtl) {
77
+ if (rtl === void 0) {
78
+ rtl = false;
79
+ }
80
+ const alignment = getAlignment(placement);
81
+ const alignmentAxis = getAlignmentAxis(placement);
82
+ const length = getAxisLength(alignmentAxis);
83
+ let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
84
+ if (rects.reference[length] > rects.floating[length]) {
85
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
86
+ }
87
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
88
+ }
89
+ function getExpandedPlacements(placement) {
90
+ const oppositePlacement = getOppositePlacement(placement);
91
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
92
+ }
93
+ function getOppositeAlignmentPlacement(placement) {
94
+ return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
95
+ }
96
+ function getSideList(side, isStart, rtl) {
97
+ const lr = ["left", "right"];
98
+ const rl = ["right", "left"];
99
+ const tb = ["top", "bottom"];
100
+ const bt = ["bottom", "top"];
101
+ switch (side) {
102
+ case "top":
103
+ case "bottom":
104
+ if (rtl) return isStart ? rl : lr;
105
+ return isStart ? lr : rl;
106
+ case "left":
107
+ case "right":
108
+ return isStart ? tb : bt;
109
+ default:
110
+ return [];
111
+ }
112
+ }
113
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
114
+ const alignment = getAlignment(placement);
115
+ let list = getSideList(getSide(placement), direction === "start", rtl);
116
+ if (alignment) {
117
+ list = list.map((side) => side + "-" + alignment);
118
+ if (flipAlignment) {
119
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
120
+ }
121
+ }
122
+ return list;
123
+ }
124
+ function getOppositePlacement(placement) {
125
+ return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
126
+ }
127
+ function expandPaddingObject(padding) {
128
+ return {
129
+ top: 0,
130
+ right: 0,
131
+ bottom: 0,
132
+ left: 0,
133
+ ...padding
134
+ };
135
+ }
136
+ function getPaddingObject(padding) {
137
+ return typeof padding !== "number" ? expandPaddingObject(padding) : {
138
+ top: padding,
139
+ right: padding,
140
+ bottom: padding,
141
+ left: padding
142
+ };
143
+ }
144
+ function rectToClientRect(rect) {
145
+ const {
146
+ x,
147
+ y,
148
+ width,
149
+ height
150
+ } = rect;
151
+ return {
152
+ width,
153
+ height,
154
+ top: y,
155
+ left: x,
156
+ right: x + width,
157
+ bottom: y + height,
158
+ x,
159
+ y
160
+ };
161
+ }
162
+
163
+ // ../../node_modules/.pnpm/@floating-ui+core@1.6.9/node_modules/@floating-ui/core/dist/floating-ui.core.mjs
164
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
165
+ let {
166
+ reference,
167
+ floating
168
+ } = _ref;
169
+ const sideAxis = getSideAxis(placement);
170
+ const alignmentAxis = getAlignmentAxis(placement);
171
+ const alignLength = getAxisLength(alignmentAxis);
172
+ const side = getSide(placement);
173
+ const isVertical = sideAxis === "y";
174
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
175
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
176
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
177
+ let coords;
178
+ switch (side) {
179
+ case "top":
180
+ coords = {
181
+ x: commonX,
182
+ y: reference.y - floating.height
183
+ };
184
+ break;
185
+ case "bottom":
186
+ coords = {
187
+ x: commonX,
188
+ y: reference.y + reference.height
189
+ };
190
+ break;
191
+ case "right":
192
+ coords = {
193
+ x: reference.x + reference.width,
194
+ y: commonY
195
+ };
196
+ break;
197
+ case "left":
198
+ coords = {
199
+ x: reference.x - floating.width,
200
+ y: commonY
201
+ };
202
+ break;
203
+ default:
204
+ coords = {
205
+ x: reference.x,
206
+ y: reference.y
207
+ };
208
+ }
209
+ switch (getAlignment(placement)) {
210
+ case "start":
211
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
212
+ break;
213
+ case "end":
214
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
215
+ break;
216
+ }
217
+ return coords;
218
+ }
219
+ var computePosition = async (reference, floating, config) => {
220
+ const {
221
+ placement = "bottom",
222
+ strategy = "absolute",
223
+ middleware = [],
224
+ platform: platform2
225
+ } = config;
226
+ const validMiddleware = middleware.filter(Boolean);
227
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
228
+ let rects = await platform2.getElementRects({
229
+ reference,
230
+ floating,
231
+ strategy
232
+ });
233
+ let {
234
+ x,
235
+ y
236
+ } = computeCoordsFromPlacement(rects, placement, rtl);
237
+ let statefulPlacement = placement;
238
+ let middlewareData = {};
239
+ let resetCount = 0;
240
+ for (let i = 0; i < validMiddleware.length; i++) {
241
+ const {
242
+ name,
243
+ fn
244
+ } = validMiddleware[i];
245
+ const {
246
+ x: nextX,
247
+ y: nextY,
248
+ data,
249
+ reset
250
+ } = await fn({
251
+ x,
252
+ y,
253
+ initialPlacement: placement,
254
+ placement: statefulPlacement,
255
+ strategy,
256
+ middlewareData,
257
+ rects,
258
+ platform: platform2,
259
+ elements: {
260
+ reference,
261
+ floating
262
+ }
263
+ });
264
+ x = nextX != null ? nextX : x;
265
+ y = nextY != null ? nextY : y;
266
+ middlewareData = {
267
+ ...middlewareData,
268
+ [name]: {
269
+ ...middlewareData[name],
270
+ ...data
271
+ }
272
+ };
273
+ if (reset && resetCount <= 50) {
274
+ resetCount++;
275
+ if (typeof reset === "object") {
276
+ if (reset.placement) {
277
+ statefulPlacement = reset.placement;
278
+ }
279
+ if (reset.rects) {
280
+ rects = reset.rects === true ? await platform2.getElementRects({
281
+ reference,
282
+ floating,
283
+ strategy
284
+ }) : reset.rects;
285
+ }
286
+ ({
287
+ x,
288
+ y
289
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
290
+ }
291
+ i = -1;
292
+ }
293
+ }
294
+ return {
295
+ x,
296
+ y,
297
+ placement: statefulPlacement,
298
+ strategy,
299
+ middlewareData
300
+ };
301
+ };
302
+ async function detectOverflow(state, options) {
303
+ var _await$platform$isEle;
304
+ if (options === void 0) {
305
+ options = {};
306
+ }
307
+ const {
308
+ x,
309
+ y,
310
+ platform: platform2,
311
+ rects,
312
+ elements,
313
+ strategy
314
+ } = state;
315
+ const {
316
+ boundary = "clippingAncestors",
317
+ rootBoundary = "viewport",
318
+ elementContext = "floating",
319
+ altBoundary = false,
320
+ padding = 0
321
+ } = evaluate(options, state);
322
+ const paddingObject = getPaddingObject(padding);
323
+ const altContext = elementContext === "floating" ? "reference" : "floating";
324
+ const element = elements[altBoundary ? altContext : elementContext];
325
+ const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
326
+ element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
327
+ boundary,
328
+ rootBoundary,
329
+ strategy
330
+ }));
331
+ const rect = elementContext === "floating" ? {
332
+ x,
333
+ y,
334
+ width: rects.floating.width,
335
+ height: rects.floating.height
336
+ } : rects.reference;
337
+ const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
338
+ const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
339
+ x: 1,
340
+ y: 1
341
+ } : {
342
+ x: 1,
343
+ y: 1
344
+ };
345
+ const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
346
+ elements,
347
+ rect,
348
+ offsetParent,
349
+ strategy
350
+ }) : rect);
351
+ return {
352
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
353
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
354
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
355
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
356
+ };
357
+ }
358
+ var arrow = (options) => ({
359
+ name: "arrow",
360
+ options,
361
+ async fn(state) {
362
+ const {
363
+ x,
364
+ y,
365
+ placement,
366
+ rects,
367
+ platform: platform2,
368
+ elements,
369
+ middlewareData
370
+ } = state;
371
+ const {
372
+ element,
373
+ padding = 0
374
+ } = evaluate(options, state) || {};
375
+ if (element == null) {
376
+ return {};
377
+ }
378
+ const paddingObject = getPaddingObject(padding);
379
+ const coords = {
380
+ x,
381
+ y
382
+ };
383
+ const axis = getAlignmentAxis(placement);
384
+ const length = getAxisLength(axis);
385
+ const arrowDimensions = await platform2.getDimensions(element);
386
+ const isYAxis = axis === "y";
387
+ const minProp = isYAxis ? "top" : "left";
388
+ const maxProp = isYAxis ? "bottom" : "right";
389
+ const clientProp = isYAxis ? "clientHeight" : "clientWidth";
390
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
391
+ const startDiff = coords[axis] - rects.reference[axis];
392
+ const arrowOffsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element));
393
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
394
+ if (!clientSize || !await (platform2.isElement == null ? void 0 : platform2.isElement(arrowOffsetParent))) {
395
+ clientSize = elements.floating[clientProp] || rects.floating[length];
396
+ }
397
+ const centerToReference = endDiff / 2 - startDiff / 2;
398
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
399
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
400
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
401
+ const min$1 = minPadding;
402
+ const max2 = clientSize - arrowDimensions[length] - maxPadding;
403
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
404
+ const offset3 = clamp(min$1, center, max2);
405
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset3 && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
406
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max2 : 0;
407
+ return {
408
+ [axis]: coords[axis] + alignmentOffset,
409
+ data: {
410
+ [axis]: offset3,
411
+ centerOffset: center - offset3 - alignmentOffset,
412
+ ...shouldAddOffset && {
413
+ alignmentOffset
414
+ }
415
+ },
416
+ reset: shouldAddOffset
417
+ };
418
+ }
419
+ });
420
+ function getPlacementList(alignment, autoAlignment, allowedPlacements) {
421
+ const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter((placement) => getAlignment(placement) === alignment), ...allowedPlacements.filter((placement) => getAlignment(placement) !== alignment)] : allowedPlacements.filter((placement) => getSide(placement) === placement);
422
+ return allowedPlacementsSortedByAlignment.filter((placement) => {
423
+ if (alignment) {
424
+ return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
425
+ }
426
+ return true;
427
+ });
428
+ }
429
+ var autoPlacement = function(options) {
430
+ if (options === void 0) {
431
+ options = {};
432
+ }
433
+ return {
434
+ name: "autoPlacement",
435
+ options,
436
+ async fn(state) {
437
+ var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
438
+ const {
439
+ rects,
440
+ middlewareData,
441
+ placement,
442
+ platform: platform2,
443
+ elements
444
+ } = state;
445
+ const {
446
+ crossAxis = false,
447
+ alignment,
448
+ allowedPlacements = placements,
449
+ autoAlignment = true,
450
+ ...detectOverflowOptions
451
+ } = evaluate(options, state);
452
+ const placements$1 = alignment !== void 0 || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
453
+ const overflow = await detectOverflow(state, detectOverflowOptions);
454
+ const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
455
+ const currentPlacement = placements$1[currentIndex];
456
+ if (currentPlacement == null) {
457
+ return {};
458
+ }
459
+ const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)));
460
+ if (placement !== currentPlacement) {
461
+ return {
462
+ reset: {
463
+ placement: placements$1[0]
464
+ }
465
+ };
466
+ }
467
+ const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
468
+ const allOverflows = [...((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || [], {
469
+ placement: currentPlacement,
470
+ overflows: currentOverflows
471
+ }];
472
+ const nextPlacement = placements$1[currentIndex + 1];
473
+ if (nextPlacement) {
474
+ return {
475
+ data: {
476
+ index: currentIndex + 1,
477
+ overflows: allOverflows
478
+ },
479
+ reset: {
480
+ placement: nextPlacement
481
+ }
482
+ };
483
+ }
484
+ const placementsSortedByMostSpace = allOverflows.map((d) => {
485
+ const alignment2 = getAlignment(d.placement);
486
+ return [d.placement, alignment2 && crossAxis ? (
487
+ // Check along the mainAxis and main crossAxis side.
488
+ d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0)
489
+ ) : (
490
+ // Check only the mainAxis.
491
+ d.overflows[0]
492
+ ), d.overflows];
493
+ }).sort((a, b) => a[1] - b[1]);
494
+ const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter((d) => d[2].slice(
495
+ 0,
496
+ // Aligned placements should not check their opposite crossAxis
497
+ // side.
498
+ getAlignment(d[0]) ? 2 : 3
499
+ ).every((v) => v <= 0));
500
+ const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
501
+ if (resetPlacement !== placement) {
502
+ return {
503
+ data: {
504
+ index: currentIndex + 1,
505
+ overflows: allOverflows
506
+ },
507
+ reset: {
508
+ placement: resetPlacement
509
+ }
510
+ };
511
+ }
512
+ return {};
513
+ }
514
+ };
515
+ };
516
+ var flip = function(options) {
517
+ if (options === void 0) {
518
+ options = {};
519
+ }
520
+ return {
521
+ name: "flip",
522
+ options,
523
+ async fn(state) {
524
+ var _middlewareData$arrow, _middlewareData$flip;
525
+ const {
526
+ placement,
527
+ middlewareData,
528
+ rects,
529
+ initialPlacement,
530
+ platform: platform2,
531
+ elements
532
+ } = state;
533
+ const {
534
+ mainAxis: checkMainAxis = true,
535
+ crossAxis: checkCrossAxis = true,
536
+ fallbackPlacements: specifiedFallbackPlacements,
537
+ fallbackStrategy = "bestFit",
538
+ fallbackAxisSideDirection = "none",
539
+ flipAlignment = true,
540
+ ...detectOverflowOptions
541
+ } = evaluate(options, state);
542
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
543
+ return {};
544
+ }
545
+ const side = getSide(placement);
546
+ const initialSideAxis = getSideAxis(initialPlacement);
547
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
548
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
549
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
550
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
551
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
552
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
553
+ }
554
+ const placements2 = [initialPlacement, ...fallbackPlacements];
555
+ const overflow = await detectOverflow(state, detectOverflowOptions);
556
+ const overflows = [];
557
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
558
+ if (checkMainAxis) {
559
+ overflows.push(overflow[side]);
560
+ }
561
+ if (checkCrossAxis) {
562
+ const sides2 = getAlignmentSides(placement, rects, rtl);
563
+ overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
564
+ }
565
+ overflowsData = [...overflowsData, {
566
+ placement,
567
+ overflows
568
+ }];
569
+ if (!overflows.every((side2) => side2 <= 0)) {
570
+ var _middlewareData$flip2, _overflowsData$filter;
571
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
572
+ const nextPlacement = placements2[nextIndex];
573
+ if (nextPlacement) {
574
+ return {
575
+ data: {
576
+ index: nextIndex,
577
+ overflows: overflowsData
578
+ },
579
+ reset: {
580
+ placement: nextPlacement
581
+ }
582
+ };
583
+ }
584
+ let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
585
+ if (!resetPlacement) {
586
+ switch (fallbackStrategy) {
587
+ case "bestFit": {
588
+ var _overflowsData$filter2;
589
+ const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
590
+ if (hasFallbackAxisSideDirection) {
591
+ const currentSideAxis = getSideAxis(d.placement);
592
+ return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
593
+ // reading directions favoring greater width.
594
+ currentSideAxis === "y";
595
+ }
596
+ return true;
597
+ }).map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
598
+ if (placement2) {
599
+ resetPlacement = placement2;
600
+ }
601
+ break;
602
+ }
603
+ case "initialPlacement":
604
+ resetPlacement = initialPlacement;
605
+ break;
606
+ }
607
+ }
608
+ if (placement !== resetPlacement) {
609
+ return {
610
+ reset: {
611
+ placement: resetPlacement
612
+ }
613
+ };
614
+ }
615
+ }
616
+ return {};
617
+ }
618
+ };
619
+ };
620
+ function getSideOffsets(overflow, rect) {
621
+ return {
622
+ top: overflow.top - rect.height,
623
+ right: overflow.right - rect.width,
624
+ bottom: overflow.bottom - rect.height,
625
+ left: overflow.left - rect.width
626
+ };
627
+ }
628
+ function isAnySideFullyClipped(overflow) {
629
+ return sides.some((side) => overflow[side] >= 0);
630
+ }
631
+ var hide = function(options) {
632
+ if (options === void 0) {
633
+ options = {};
634
+ }
635
+ return {
636
+ name: "hide",
637
+ options,
638
+ async fn(state) {
639
+ const {
640
+ rects
641
+ } = state;
642
+ const {
643
+ strategy = "referenceHidden",
644
+ ...detectOverflowOptions
645
+ } = evaluate(options, state);
646
+ switch (strategy) {
647
+ case "referenceHidden": {
648
+ const overflow = await detectOverflow(state, {
649
+ ...detectOverflowOptions,
650
+ elementContext: "reference"
651
+ });
652
+ const offsets = getSideOffsets(overflow, rects.reference);
653
+ return {
654
+ data: {
655
+ referenceHiddenOffsets: offsets,
656
+ referenceHidden: isAnySideFullyClipped(offsets)
657
+ }
658
+ };
659
+ }
660
+ case "escaped": {
661
+ const overflow = await detectOverflow(state, {
662
+ ...detectOverflowOptions,
663
+ altBoundary: true
664
+ });
665
+ const offsets = getSideOffsets(overflow, rects.floating);
666
+ return {
667
+ data: {
668
+ escapedOffsets: offsets,
669
+ escaped: isAnySideFullyClipped(offsets)
670
+ }
671
+ };
672
+ }
673
+ default: {
674
+ return {};
675
+ }
676
+ }
677
+ }
678
+ };
679
+ };
680
+ function getBoundingRect(rects) {
681
+ const minX = min(...rects.map((rect) => rect.left));
682
+ const minY = min(...rects.map((rect) => rect.top));
683
+ const maxX = max(...rects.map((rect) => rect.right));
684
+ const maxY = max(...rects.map((rect) => rect.bottom));
685
+ return {
686
+ x: minX,
687
+ y: minY,
688
+ width: maxX - minX,
689
+ height: maxY - minY
690
+ };
691
+ }
692
+ function getRectsByLine(rects) {
693
+ const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
694
+ const groups = [];
695
+ let prevRect = null;
696
+ for (let i = 0; i < sortedRects.length; i++) {
697
+ const rect = sortedRects[i];
698
+ if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
699
+ groups.push([rect]);
700
+ } else {
701
+ groups[groups.length - 1].push(rect);
702
+ }
703
+ prevRect = rect;
704
+ }
705
+ return groups.map((rect) => rectToClientRect(getBoundingRect(rect)));
706
+ }
707
+ var inline = function(options) {
708
+ if (options === void 0) {
709
+ options = {};
710
+ }
711
+ return {
712
+ name: "inline",
713
+ options,
714
+ async fn(state) {
715
+ const {
716
+ placement,
717
+ elements,
718
+ rects,
719
+ platform: platform2,
720
+ strategy
721
+ } = state;
722
+ const {
723
+ padding = 2,
724
+ x,
725
+ y
726
+ } = evaluate(options, state);
727
+ const nativeClientRects = Array.from(await (platform2.getClientRects == null ? void 0 : platform2.getClientRects(elements.reference)) || []);
728
+ const clientRects = getRectsByLine(nativeClientRects);
729
+ const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
730
+ const paddingObject = getPaddingObject(padding);
731
+ function getBoundingClientRect2() {
732
+ if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
733
+ return clientRects.find((rect) => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;
734
+ }
735
+ if (clientRects.length >= 2) {
736
+ if (getSideAxis(placement) === "y") {
737
+ const firstRect = clientRects[0];
738
+ const lastRect = clientRects[clientRects.length - 1];
739
+ const isTop = getSide(placement) === "top";
740
+ const top2 = firstRect.top;
741
+ const bottom2 = lastRect.bottom;
742
+ const left2 = isTop ? firstRect.left : lastRect.left;
743
+ const right2 = isTop ? firstRect.right : lastRect.right;
744
+ const width2 = right2 - left2;
745
+ const height2 = bottom2 - top2;
746
+ return {
747
+ top: top2,
748
+ bottom: bottom2,
749
+ left: left2,
750
+ right: right2,
751
+ width: width2,
752
+ height: height2,
753
+ x: left2,
754
+ y: top2
755
+ };
756
+ }
757
+ const isLeftSide = getSide(placement) === "left";
758
+ const maxRight = max(...clientRects.map((rect) => rect.right));
759
+ const minLeft = min(...clientRects.map((rect) => rect.left));
760
+ const measureRects = clientRects.filter((rect) => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
761
+ const top = measureRects[0].top;
762
+ const bottom = measureRects[measureRects.length - 1].bottom;
763
+ const left = minLeft;
764
+ const right = maxRight;
765
+ const width = right - left;
766
+ const height = bottom - top;
767
+ return {
768
+ top,
769
+ bottom,
770
+ left,
771
+ right,
772
+ width,
773
+ height,
774
+ x: left,
775
+ y: top
776
+ };
777
+ }
778
+ return fallback;
779
+ }
780
+ const resetRects = await platform2.getElementRects({
781
+ reference: {
782
+ getBoundingClientRect: getBoundingClientRect2
783
+ },
784
+ floating: elements.floating,
785
+ strategy
786
+ });
787
+ if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
788
+ return {
789
+ reset: {
790
+ rects: resetRects
791
+ }
792
+ };
793
+ }
794
+ return {};
795
+ }
796
+ };
797
+ };
798
+ async function convertValueToCoords(state, options) {
799
+ const {
800
+ placement,
801
+ platform: platform2,
802
+ elements
803
+ } = state;
804
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
805
+ const side = getSide(placement);
806
+ const alignment = getAlignment(placement);
807
+ const isVertical = getSideAxis(placement) === "y";
808
+ const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1;
809
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
810
+ const rawValue = evaluate(options, state);
811
+ let {
812
+ mainAxis,
813
+ crossAxis,
814
+ alignmentAxis
815
+ } = typeof rawValue === "number" ? {
816
+ mainAxis: rawValue,
817
+ crossAxis: 0,
818
+ alignmentAxis: null
819
+ } : {
820
+ mainAxis: rawValue.mainAxis || 0,
821
+ crossAxis: rawValue.crossAxis || 0,
822
+ alignmentAxis: rawValue.alignmentAxis
823
+ };
824
+ if (alignment && typeof alignmentAxis === "number") {
825
+ crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
826
+ }
827
+ return isVertical ? {
828
+ x: crossAxis * crossAxisMulti,
829
+ y: mainAxis * mainAxisMulti
830
+ } : {
831
+ x: mainAxis * mainAxisMulti,
832
+ y: crossAxis * crossAxisMulti
833
+ };
834
+ }
835
+ var offset = function(options) {
836
+ if (options === void 0) {
837
+ options = 0;
838
+ }
839
+ return {
840
+ name: "offset",
841
+ options,
842
+ async fn(state) {
843
+ var _middlewareData$offse, _middlewareData$arrow;
844
+ const {
845
+ x,
846
+ y,
847
+ placement,
848
+ middlewareData
849
+ } = state;
850
+ const diffCoords = await convertValueToCoords(state, options);
851
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
852
+ return {};
853
+ }
854
+ return {
855
+ x: x + diffCoords.x,
856
+ y: y + diffCoords.y,
857
+ data: {
858
+ ...diffCoords,
859
+ placement
860
+ }
861
+ };
862
+ }
863
+ };
864
+ };
865
+ var shift = function(options) {
866
+ if (options === void 0) {
867
+ options = {};
868
+ }
869
+ return {
870
+ name: "shift",
871
+ options,
872
+ async fn(state) {
873
+ const {
874
+ x,
875
+ y,
876
+ placement
877
+ } = state;
878
+ const {
879
+ mainAxis: checkMainAxis = true,
880
+ crossAxis: checkCrossAxis = false,
881
+ limiter = {
882
+ fn: (_ref) => {
883
+ let {
884
+ x: x2,
885
+ y: y2
886
+ } = _ref;
887
+ return {
888
+ x: x2,
889
+ y: y2
890
+ };
891
+ }
892
+ },
893
+ ...detectOverflowOptions
894
+ } = evaluate(options, state);
895
+ const coords = {
896
+ x,
897
+ y
898
+ };
899
+ const overflow = await detectOverflow(state, detectOverflowOptions);
900
+ const crossAxis = getSideAxis(getSide(placement));
901
+ const mainAxis = getOppositeAxis(crossAxis);
902
+ let mainAxisCoord = coords[mainAxis];
903
+ let crossAxisCoord = coords[crossAxis];
904
+ if (checkMainAxis) {
905
+ const minSide = mainAxis === "y" ? "top" : "left";
906
+ const maxSide = mainAxis === "y" ? "bottom" : "right";
907
+ const min2 = mainAxisCoord + overflow[minSide];
908
+ const max2 = mainAxisCoord - overflow[maxSide];
909
+ mainAxisCoord = clamp(min2, mainAxisCoord, max2);
910
+ }
911
+ if (checkCrossAxis) {
912
+ const minSide = crossAxis === "y" ? "top" : "left";
913
+ const maxSide = crossAxis === "y" ? "bottom" : "right";
914
+ const min2 = crossAxisCoord + overflow[minSide];
915
+ const max2 = crossAxisCoord - overflow[maxSide];
916
+ crossAxisCoord = clamp(min2, crossAxisCoord, max2);
917
+ }
918
+ const limitedCoords = limiter.fn({
919
+ ...state,
920
+ [mainAxis]: mainAxisCoord,
921
+ [crossAxis]: crossAxisCoord
922
+ });
923
+ return {
924
+ ...limitedCoords,
925
+ data: {
926
+ x: limitedCoords.x - x,
927
+ y: limitedCoords.y - y,
928
+ enabled: {
929
+ [mainAxis]: checkMainAxis,
930
+ [crossAxis]: checkCrossAxis
931
+ }
932
+ }
933
+ };
934
+ }
935
+ };
936
+ };
937
+ var size = function(options) {
938
+ if (options === void 0) {
939
+ options = {};
940
+ }
941
+ return {
942
+ name: "size",
943
+ options,
944
+ async fn(state) {
945
+ var _state$middlewareData, _state$middlewareData2;
946
+ const {
947
+ placement,
948
+ rects,
949
+ platform: platform2,
950
+ elements
951
+ } = state;
952
+ const {
953
+ apply = () => {
954
+ },
955
+ ...detectOverflowOptions
956
+ } = evaluate(options, state);
957
+ const overflow = await detectOverflow(state, detectOverflowOptions);
958
+ const side = getSide(placement);
959
+ const alignment = getAlignment(placement);
960
+ const isYAxis = getSideAxis(placement) === "y";
961
+ const {
962
+ width,
963
+ height
964
+ } = rects.floating;
965
+ let heightSide;
966
+ let widthSide;
967
+ if (side === "top" || side === "bottom") {
968
+ heightSide = side;
969
+ widthSide = alignment === (await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
970
+ } else {
971
+ widthSide = side;
972
+ heightSide = alignment === "end" ? "top" : "bottom";
973
+ }
974
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
975
+ const maximumClippingWidth = width - overflow.left - overflow.right;
976
+ const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
977
+ const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
978
+ const noShift = !state.middlewareData.shift;
979
+ let availableHeight = overflowAvailableHeight;
980
+ let availableWidth = overflowAvailableWidth;
981
+ if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
982
+ availableWidth = maximumClippingWidth;
983
+ }
984
+ if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
985
+ availableHeight = maximumClippingHeight;
986
+ }
987
+ if (noShift && !alignment) {
988
+ const xMin = max(overflow.left, 0);
989
+ const xMax = max(overflow.right, 0);
990
+ const yMin = max(overflow.top, 0);
991
+ const yMax = max(overflow.bottom, 0);
992
+ if (isYAxis) {
993
+ availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
994
+ } else {
995
+ availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
996
+ }
997
+ }
998
+ await apply({
999
+ ...state,
1000
+ availableWidth,
1001
+ availableHeight
1002
+ });
1003
+ const nextDimensions = await platform2.getDimensions(elements.floating);
1004
+ if (width !== nextDimensions.width || height !== nextDimensions.height) {
1005
+ return {
1006
+ reset: {
1007
+ rects: true
1008
+ }
1009
+ };
1010
+ }
1011
+ return {};
1012
+ }
1013
+ };
1014
+ };
1015
+
1016
+ // ../../node_modules/.pnpm/@floating-ui+utils@0.2.9/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
1017
+ function hasWindow() {
1018
+ return typeof window !== "undefined";
1019
+ }
1020
+ function getNodeName(node) {
1021
+ if (isNode(node)) {
1022
+ return (node.nodeName || "").toLowerCase();
1023
+ }
1024
+ return "#document";
1025
+ }
1026
+ function getWindow(node) {
1027
+ var _node$ownerDocument;
1028
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1029
+ }
1030
+ function getDocumentElement(node) {
1031
+ var _ref;
1032
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1033
+ }
1034
+ function isNode(value) {
1035
+ if (!hasWindow()) {
1036
+ return false;
1037
+ }
1038
+ return value instanceof Node || value instanceof getWindow(value).Node;
1039
+ }
1040
+ function isElement(value) {
1041
+ if (!hasWindow()) {
1042
+ return false;
1043
+ }
1044
+ return value instanceof Element || value instanceof getWindow(value).Element;
1045
+ }
1046
+ function isHTMLElement(value) {
1047
+ if (!hasWindow()) {
1048
+ return false;
1049
+ }
1050
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1051
+ }
1052
+ function isShadowRoot(value) {
1053
+ if (!hasWindow() || typeof ShadowRoot === "undefined") {
1054
+ return false;
1055
+ }
1056
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1057
+ }
1058
+ function isOverflowElement(element) {
1059
+ const {
1060
+ overflow,
1061
+ overflowX,
1062
+ overflowY,
1063
+ display
1064
+ } = getComputedStyle(element);
1065
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
1066
+ }
1067
+ function isTableElement(element) {
1068
+ return ["table", "td", "th"].includes(getNodeName(element));
1069
+ }
1070
+ function isTopLayer(element) {
1071
+ return [":popover-open", ":modal"].some((selector) => {
1072
+ try {
1073
+ return element.matches(selector);
1074
+ } catch (e) {
1075
+ return false;
1076
+ }
1077
+ });
1078
+ }
1079
+ function isContainingBlock(elementOrCss) {
1080
+ const webkit = isWebKit();
1081
+ const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
1082
+ return ["transform", "translate", "scale", "rotate", "perspective"].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) || ["transform", "translate", "scale", "rotate", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value));
1083
+ }
1084
+ function getContainingBlock(element) {
1085
+ let currentNode = getParentNode(element);
1086
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1087
+ if (isContainingBlock(currentNode)) {
1088
+ return currentNode;
1089
+ } else if (isTopLayer(currentNode)) {
1090
+ return null;
1091
+ }
1092
+ currentNode = getParentNode(currentNode);
1093
+ }
1094
+ return null;
1095
+ }
1096
+ function isWebKit() {
1097
+ if (typeof CSS === "undefined" || !CSS.supports) return false;
1098
+ return CSS.supports("-webkit-backdrop-filter", "none");
1099
+ }
1100
+ function isLastTraversableNode(node) {
1101
+ return ["html", "body", "#document"].includes(getNodeName(node));
1102
+ }
1103
+ function getComputedStyle(element) {
1104
+ return getWindow(element).getComputedStyle(element);
1105
+ }
1106
+ function getNodeScroll(element) {
1107
+ if (isElement(element)) {
1108
+ return {
1109
+ scrollLeft: element.scrollLeft,
1110
+ scrollTop: element.scrollTop
1111
+ };
1112
+ }
1113
+ return {
1114
+ scrollLeft: element.scrollX,
1115
+ scrollTop: element.scrollY
1116
+ };
1117
+ }
1118
+ function getParentNode(node) {
1119
+ if (getNodeName(node) === "html") {
1120
+ return node;
1121
+ }
1122
+ const result = (
1123
+ // Step into the shadow DOM of the parent of a slotted node.
1124
+ node.assignedSlot || // DOM Element detected.
1125
+ node.parentNode || // ShadowRoot detected.
1126
+ isShadowRoot(node) && node.host || // Fallback.
1127
+ getDocumentElement(node)
1128
+ );
1129
+ return isShadowRoot(result) ? result.host : result;
1130
+ }
1131
+ function getNearestOverflowAncestor(node) {
1132
+ const parentNode = getParentNode(node);
1133
+ if (isLastTraversableNode(parentNode)) {
1134
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
1135
+ }
1136
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1137
+ return parentNode;
1138
+ }
1139
+ return getNearestOverflowAncestor(parentNode);
1140
+ }
1141
+ function getOverflowAncestors(node, list, traverseIframes) {
1142
+ var _node$ownerDocument2;
1143
+ if (list === void 0) {
1144
+ list = [];
1145
+ }
1146
+ if (traverseIframes === void 0) {
1147
+ traverseIframes = true;
1148
+ }
1149
+ const scrollableAncestor = getNearestOverflowAncestor(node);
1150
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1151
+ const win = getWindow(scrollableAncestor);
1152
+ if (isBody) {
1153
+ const frameElement = getFrameElement(win);
1154
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1155
+ }
1156
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1157
+ }
1158
+ function getFrameElement(win) {
1159
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1160
+ }
1161
+
1162
+ // ../../node_modules/.pnpm/@floating-ui+dom@1.6.13/node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
1163
+ function getCssDimensions(element) {
1164
+ const css = getComputedStyle(element);
1165
+ let width = parseFloat(css.width) || 0;
1166
+ let height = parseFloat(css.height) || 0;
1167
+ const hasOffset = isHTMLElement(element);
1168
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
1169
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
1170
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
1171
+ if (shouldFallback) {
1172
+ width = offsetWidth;
1173
+ height = offsetHeight;
1174
+ }
1175
+ return {
1176
+ width,
1177
+ height,
1178
+ $: shouldFallback
1179
+ };
1180
+ }
1181
+ function unwrapElement(element) {
1182
+ return !isElement(element) ? element.contextElement : element;
1183
+ }
1184
+ function getScale(element) {
1185
+ const domElement = unwrapElement(element);
1186
+ if (!isHTMLElement(domElement)) {
1187
+ return createCoords(1);
1188
+ }
1189
+ const rect = domElement.getBoundingClientRect();
1190
+ const {
1191
+ width,
1192
+ height,
1193
+ $
1194
+ } = getCssDimensions(domElement);
1195
+ let x = ($ ? round(rect.width) : rect.width) / width;
1196
+ let y = ($ ? round(rect.height) : rect.height) / height;
1197
+ if (!x || !Number.isFinite(x)) {
1198
+ x = 1;
1199
+ }
1200
+ if (!y || !Number.isFinite(y)) {
1201
+ y = 1;
1202
+ }
1203
+ return {
1204
+ x,
1205
+ y
1206
+ };
1207
+ }
1208
+ var noOffsets = /* @__PURE__ */ createCoords(0);
1209
+ function getVisualOffsets(element) {
1210
+ const win = getWindow(element);
1211
+ if (!isWebKit() || !win.visualViewport) {
1212
+ return noOffsets;
1213
+ }
1214
+ return {
1215
+ x: win.visualViewport.offsetLeft,
1216
+ y: win.visualViewport.offsetTop
1217
+ };
1218
+ }
1219
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
1220
+ if (isFixed === void 0) {
1221
+ isFixed = false;
1222
+ }
1223
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
1224
+ return false;
1225
+ }
1226
+ return isFixed;
1227
+ }
1228
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
1229
+ if (includeScale === void 0) {
1230
+ includeScale = false;
1231
+ }
1232
+ if (isFixedStrategy === void 0) {
1233
+ isFixedStrategy = false;
1234
+ }
1235
+ const clientRect = element.getBoundingClientRect();
1236
+ const domElement = unwrapElement(element);
1237
+ let scale = createCoords(1);
1238
+ if (includeScale) {
1239
+ if (offsetParent) {
1240
+ if (isElement(offsetParent)) {
1241
+ scale = getScale(offsetParent);
1242
+ }
1243
+ } else {
1244
+ scale = getScale(element);
1245
+ }
1246
+ }
1247
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
1248
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
1249
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
1250
+ let width = clientRect.width / scale.x;
1251
+ let height = clientRect.height / scale.y;
1252
+ if (domElement) {
1253
+ const win = getWindow(domElement);
1254
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
1255
+ let currentWin = win;
1256
+ let currentIFrame = getFrameElement(currentWin);
1257
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
1258
+ const iframeScale = getScale(currentIFrame);
1259
+ const iframeRect = currentIFrame.getBoundingClientRect();
1260
+ const css = getComputedStyle(currentIFrame);
1261
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
1262
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
1263
+ x *= iframeScale.x;
1264
+ y *= iframeScale.y;
1265
+ width *= iframeScale.x;
1266
+ height *= iframeScale.y;
1267
+ x += left;
1268
+ y += top;
1269
+ currentWin = getWindow(currentIFrame);
1270
+ currentIFrame = getFrameElement(currentWin);
1271
+ }
1272
+ }
1273
+ return rectToClientRect({
1274
+ width,
1275
+ height,
1276
+ x,
1277
+ y
1278
+ });
1279
+ }
1280
+ function getWindowScrollBarX(element, rect) {
1281
+ const leftScroll = getNodeScroll(element).scrollLeft;
1282
+ if (!rect) {
1283
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
1284
+ }
1285
+ return rect.left + leftScroll;
1286
+ }
1287
+ function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
1288
+ if (ignoreScrollbarX === void 0) {
1289
+ ignoreScrollbarX = false;
1290
+ }
1291
+ const htmlRect = documentElement.getBoundingClientRect();
1292
+ const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 : (
1293
+ // RTL <body> scrollbar.
1294
+ getWindowScrollBarX(documentElement, htmlRect)
1295
+ ));
1296
+ const y = htmlRect.top + scroll.scrollTop;
1297
+ return {
1298
+ x,
1299
+ y
1300
+ };
1301
+ }
1302
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1303
+ let {
1304
+ elements,
1305
+ rect,
1306
+ offsetParent,
1307
+ strategy
1308
+ } = _ref;
1309
+ const isFixed = strategy === "fixed";
1310
+ const documentElement = getDocumentElement(offsetParent);
1311
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
1312
+ if (offsetParent === documentElement || topLayer && isFixed) {
1313
+ return rect;
1314
+ }
1315
+ let scroll = {
1316
+ scrollLeft: 0,
1317
+ scrollTop: 0
1318
+ };
1319
+ let scale = createCoords(1);
1320
+ const offsets = createCoords(0);
1321
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1322
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1323
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
1324
+ scroll = getNodeScroll(offsetParent);
1325
+ }
1326
+ if (isHTMLElement(offsetParent)) {
1327
+ const offsetRect = getBoundingClientRect(offsetParent);
1328
+ scale = getScale(offsetParent);
1329
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1330
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1331
+ }
1332
+ }
1333
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
1334
+ return {
1335
+ width: rect.width * scale.x,
1336
+ height: rect.height * scale.y,
1337
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
1338
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
1339
+ };
1340
+ }
1341
+ function getClientRects(element) {
1342
+ return Array.from(element.getClientRects());
1343
+ }
1344
+ function getDocumentRect(element) {
1345
+ const html = getDocumentElement(element);
1346
+ const scroll = getNodeScroll(element);
1347
+ const body = element.ownerDocument.body;
1348
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
1349
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
1350
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1351
+ const y = -scroll.scrollTop;
1352
+ if (getComputedStyle(body).direction === "rtl") {
1353
+ x += max(html.clientWidth, body.clientWidth) - width;
1354
+ }
1355
+ return {
1356
+ width,
1357
+ height,
1358
+ x,
1359
+ y
1360
+ };
1361
+ }
1362
+ function getViewportRect(element, strategy) {
1363
+ const win = getWindow(element);
1364
+ const html = getDocumentElement(element);
1365
+ const visualViewport = win.visualViewport;
1366
+ let width = html.clientWidth;
1367
+ let height = html.clientHeight;
1368
+ let x = 0;
1369
+ let y = 0;
1370
+ if (visualViewport) {
1371
+ width = visualViewport.width;
1372
+ height = visualViewport.height;
1373
+ const visualViewportBased = isWebKit();
1374
+ if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
1375
+ x = visualViewport.offsetLeft;
1376
+ y = visualViewport.offsetTop;
1377
+ }
1378
+ }
1379
+ return {
1380
+ width,
1381
+ height,
1382
+ x,
1383
+ y
1384
+ };
1385
+ }
1386
+ function getInnerBoundingClientRect(element, strategy) {
1387
+ const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
1388
+ const top = clientRect.top + element.clientTop;
1389
+ const left = clientRect.left + element.clientLeft;
1390
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
1391
+ const width = element.clientWidth * scale.x;
1392
+ const height = element.clientHeight * scale.y;
1393
+ const x = left * scale.x;
1394
+ const y = top * scale.y;
1395
+ return {
1396
+ width,
1397
+ height,
1398
+ x,
1399
+ y
1400
+ };
1401
+ }
1402
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1403
+ let rect;
1404
+ if (clippingAncestor === "viewport") {
1405
+ rect = getViewportRect(element, strategy);
1406
+ } else if (clippingAncestor === "document") {
1407
+ rect = getDocumentRect(getDocumentElement(element));
1408
+ } else if (isElement(clippingAncestor)) {
1409
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1410
+ } else {
1411
+ const visualOffsets = getVisualOffsets(element);
1412
+ rect = {
1413
+ x: clippingAncestor.x - visualOffsets.x,
1414
+ y: clippingAncestor.y - visualOffsets.y,
1415
+ width: clippingAncestor.width,
1416
+ height: clippingAncestor.height
1417
+ };
1418
+ }
1419
+ return rectToClientRect(rect);
1420
+ }
1421
+ function hasFixedPositionAncestor(element, stopNode) {
1422
+ const parentNode = getParentNode(element);
1423
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
1424
+ return false;
1425
+ }
1426
+ return getComputedStyle(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
1427
+ }
1428
+ function getClippingElementAncestors(element, cache) {
1429
+ const cachedResult = cache.get(element);
1430
+ if (cachedResult) {
1431
+ return cachedResult;
1432
+ }
1433
+ let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
1434
+ let currentContainingBlockComputedStyle = null;
1435
+ const elementIsFixed = getComputedStyle(element).position === "fixed";
1436
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
1437
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1438
+ const computedStyle = getComputedStyle(currentNode);
1439
+ const currentNodeIsContaining = isContainingBlock(currentNode);
1440
+ if (!currentNodeIsContaining && computedStyle.position === "fixed") {
1441
+ currentContainingBlockComputedStyle = null;
1442
+ }
1443
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1444
+ if (shouldDropCurrentNode) {
1445
+ result = result.filter((ancestor) => ancestor !== currentNode);
1446
+ } else {
1447
+ currentContainingBlockComputedStyle = computedStyle;
1448
+ }
1449
+ currentNode = getParentNode(currentNode);
1450
+ }
1451
+ cache.set(element, result);
1452
+ return result;
1453
+ }
1454
+ function getClippingRect(_ref) {
1455
+ let {
1456
+ element,
1457
+ boundary,
1458
+ rootBoundary,
1459
+ strategy
1460
+ } = _ref;
1461
+ const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
1462
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1463
+ const firstClippingAncestor = clippingAncestors[0];
1464
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1465
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1466
+ accRect.top = max(rect.top, accRect.top);
1467
+ accRect.right = min(rect.right, accRect.right);
1468
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1469
+ accRect.left = max(rect.left, accRect.left);
1470
+ return accRect;
1471
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1472
+ return {
1473
+ width: clippingRect.right - clippingRect.left,
1474
+ height: clippingRect.bottom - clippingRect.top,
1475
+ x: clippingRect.left,
1476
+ y: clippingRect.top
1477
+ };
1478
+ }
1479
+ function getDimensions(element) {
1480
+ const {
1481
+ width,
1482
+ height
1483
+ } = getCssDimensions(element);
1484
+ return {
1485
+ width,
1486
+ height
1487
+ };
1488
+ }
1489
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1490
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1491
+ const documentElement = getDocumentElement(offsetParent);
1492
+ const isFixed = strategy === "fixed";
1493
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1494
+ let scroll = {
1495
+ scrollLeft: 0,
1496
+ scrollTop: 0
1497
+ };
1498
+ const offsets = createCoords(0);
1499
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1500
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
1501
+ scroll = getNodeScroll(offsetParent);
1502
+ }
1503
+ if (isOffsetParentAnElement) {
1504
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1505
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1506
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1507
+ } else if (documentElement) {
1508
+ offsets.x = getWindowScrollBarX(documentElement);
1509
+ }
1510
+ }
1511
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1512
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
1513
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
1514
+ return {
1515
+ x,
1516
+ y,
1517
+ width: rect.width,
1518
+ height: rect.height
1519
+ };
1520
+ }
1521
+ function isStaticPositioned(element) {
1522
+ return getComputedStyle(element).position === "static";
1523
+ }
1524
+ function getTrueOffsetParent(element, polyfill) {
1525
+ if (!isHTMLElement(element) || getComputedStyle(element).position === "fixed") {
1526
+ return null;
1527
+ }
1528
+ if (polyfill) {
1529
+ return polyfill(element);
1530
+ }
1531
+ let rawOffsetParent = element.offsetParent;
1532
+ if (getDocumentElement(element) === rawOffsetParent) {
1533
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
1534
+ }
1535
+ return rawOffsetParent;
1536
+ }
1537
+ function getOffsetParent(element, polyfill) {
1538
+ const win = getWindow(element);
1539
+ if (isTopLayer(element)) {
1540
+ return win;
1541
+ }
1542
+ if (!isHTMLElement(element)) {
1543
+ let svgOffsetParent = getParentNode(element);
1544
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
1545
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
1546
+ return svgOffsetParent;
1547
+ }
1548
+ svgOffsetParent = getParentNode(svgOffsetParent);
1549
+ }
1550
+ return win;
1551
+ }
1552
+ let offsetParent = getTrueOffsetParent(element, polyfill);
1553
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
1554
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1555
+ }
1556
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
1557
+ return win;
1558
+ }
1559
+ return offsetParent || getContainingBlock(element) || win;
1560
+ }
1561
+ var getElementRects = async function(data) {
1562
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1563
+ const getDimensionsFn = this.getDimensions;
1564
+ const floatingDimensions = await getDimensionsFn(data.floating);
1565
+ return {
1566
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
1567
+ floating: {
1568
+ x: 0,
1569
+ y: 0,
1570
+ width: floatingDimensions.width,
1571
+ height: floatingDimensions.height
1572
+ }
1573
+ };
1574
+ };
1575
+ function isRTL(element) {
1576
+ return getComputedStyle(element).direction === "rtl";
1577
+ }
1578
+ var platform = {
1579
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1580
+ getDocumentElement,
1581
+ getClippingRect,
1582
+ getOffsetParent,
1583
+ getElementRects,
1584
+ getClientRects,
1585
+ getDimensions,
1586
+ getScale,
1587
+ isElement,
1588
+ isRTL
1589
+ };
1590
+ var offset2 = offset;
1591
+ var autoPlacement2 = autoPlacement;
1592
+ var shift2 = shift;
1593
+ var flip2 = flip;
1594
+ var size2 = size;
1595
+ var hide2 = hide;
1596
+ var arrow2 = arrow;
1597
+ var inline2 = inline;
1598
+ var computePosition2 = (reference, floating, options) => {
1599
+ const cache = /* @__PURE__ */ new Map();
1600
+ const mergedOptions = {
1601
+ platform,
1602
+ ...options
1603
+ };
1604
+ const platformWithCache = {
1605
+ ...mergedOptions.platform,
1606
+ _c: cache
1607
+ };
1608
+ return computePosition(reference, floating, {
1609
+ ...mergedOptions,
1610
+ platform: platformWithCache
1611
+ });
1612
+ };
1613
+
1614
+ // ../extension-bubble-menu/dist/index.js
1615
+ var import_core3 = require("@tiptap/core");
1616
+ var import_state = require("@tiptap/pm/state");
1617
+ var import_tables = require("@tiptap/pm/tables");
1618
+ function combineDOMRects(rect1, rect2) {
1619
+ const top = Math.min(rect1.top, rect2.top);
1620
+ const bottom = Math.max(rect1.bottom, rect2.bottom);
1621
+ const left = Math.min(rect1.left, rect2.left);
1622
+ const right = Math.max(rect1.right, rect2.right);
1623
+ const width = right - left;
1624
+ const height = bottom - top;
1625
+ const x = left;
1626
+ const y = top;
1627
+ return new DOMRect(x, y, width, height);
1628
+ }
1629
+ var BubbleMenuView = class {
1630
+ constructor({
1631
+ editor,
1632
+ element,
1633
+ view,
1634
+ updateDelay = 250,
1635
+ resizeDelay = 60,
1636
+ shouldShow,
1637
+ options
1638
+ }) {
1639
+ this.preventHide = false;
1640
+ this.isVisible = false;
1641
+ this.floatingUIOptions = {
1642
+ strategy: "absolute",
1643
+ placement: "top",
1644
+ offset: 8,
1645
+ flip: {},
1646
+ shift: {},
1647
+ arrow: false,
1648
+ size: false,
1649
+ autoPlacement: false,
1650
+ hide: false,
1651
+ inline: false,
1652
+ onShow: void 0,
1653
+ onHide: void 0,
1654
+ onUpdate: void 0,
1655
+ onDestroy: void 0
1656
+ };
1657
+ this.shouldShow = ({ view: view2, state, from, to }) => {
1658
+ const { doc, selection } = state;
1659
+ const { empty } = selection;
1660
+ const isEmptyTextBlock = !doc.textBetween(from, to).length && (0, import_core3.isTextSelection)(state.selection);
1661
+ const isChildOfMenu = this.element.contains(document.activeElement);
1662
+ const hasEditorFocus = view2.hasFocus() || isChildOfMenu;
1663
+ if (!hasEditorFocus || empty || isEmptyTextBlock || !this.editor.isEditable) {
1664
+ return false;
1665
+ }
1666
+ return true;
1667
+ };
1668
+ this.mousedownHandler = () => {
1669
+ this.preventHide = true;
1670
+ };
1671
+ this.dragstartHandler = () => {
1672
+ this.hide();
1673
+ };
1674
+ this.resizeHandler = () => {
1675
+ if (this.resizeDebounceTimer) {
1676
+ clearTimeout(this.resizeDebounceTimer);
1677
+ }
1678
+ this.resizeDebounceTimer = window.setTimeout(() => {
1679
+ this.updatePosition();
1680
+ }, this.resizeDelay);
1681
+ };
1682
+ this.focusHandler = () => {
1683
+ setTimeout(() => this.update(this.editor.view));
1684
+ };
1685
+ this.blurHandler = ({ event }) => {
1686
+ var _a;
1687
+ if (this.preventHide) {
1688
+ this.preventHide = false;
1689
+ return;
1690
+ }
1691
+ if ((event == null ? void 0 : event.relatedTarget) && ((_a = this.element.parentNode) == null ? void 0 : _a.contains(event.relatedTarget))) {
1692
+ return;
1693
+ }
1694
+ if ((event == null ? void 0 : event.relatedTarget) === this.editor.view.dom) {
1695
+ return;
1696
+ }
1697
+ this.hide();
1698
+ };
1699
+ this.handleDebouncedUpdate = (view2, oldState) => {
1700
+ const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view2.state.selection));
1701
+ const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view2.state.doc));
1702
+ if (!selectionChanged && !docChanged) {
1703
+ return;
1704
+ }
1705
+ if (this.updateDebounceTimer) {
1706
+ clearTimeout(this.updateDebounceTimer);
1707
+ }
1708
+ this.updateDebounceTimer = window.setTimeout(() => {
1709
+ this.updateHandler(view2, selectionChanged, docChanged, oldState);
1710
+ }, this.updateDelay);
1711
+ };
1712
+ this.updateHandler = (view2, selectionChanged, docChanged, oldState) => {
1713
+ const { composing } = view2;
1714
+ const isSame = !selectionChanged && !docChanged;
1715
+ if (composing || isSame) {
1716
+ return;
1717
+ }
1718
+ const shouldShow2 = this.getShouldShow(oldState);
1719
+ if (!shouldShow2) {
1720
+ this.hide();
1721
+ return;
1722
+ }
1723
+ this.updatePosition();
1724
+ this.show();
1725
+ };
1726
+ this.editor = editor;
1727
+ this.element = element;
1728
+ this.view = view;
1729
+ this.updateDelay = updateDelay;
1730
+ this.resizeDelay = resizeDelay;
1731
+ this.floatingUIOptions = {
1732
+ ...this.floatingUIOptions,
1733
+ ...options
1734
+ };
1735
+ this.element.tabIndex = 0;
1736
+ if (shouldShow) {
1737
+ this.shouldShow = shouldShow;
1738
+ }
1739
+ this.element.addEventListener("mousedown", this.mousedownHandler, { capture: true });
1740
+ this.view.dom.addEventListener("dragstart", this.dragstartHandler);
1741
+ this.editor.on("focus", this.focusHandler);
1742
+ this.editor.on("blur", this.blurHandler);
1743
+ window.addEventListener("resize", this.resizeHandler);
1744
+ this.update(view, view.state);
1745
+ if (this.getShouldShow()) {
1746
+ this.show();
1747
+ }
1748
+ }
1749
+ get middlewares() {
1750
+ const middlewares = [];
1751
+ if (this.floatingUIOptions.flip) {
1752
+ middlewares.push(flip2(typeof this.floatingUIOptions.flip !== "boolean" ? this.floatingUIOptions.flip : void 0));
1753
+ }
1754
+ if (this.floatingUIOptions.shift) {
1755
+ middlewares.push(
1756
+ shift2(typeof this.floatingUIOptions.shift !== "boolean" ? this.floatingUIOptions.shift : void 0)
1757
+ );
1758
+ }
1759
+ if (this.floatingUIOptions.offset) {
1760
+ middlewares.push(
1761
+ offset2(typeof this.floatingUIOptions.offset !== "boolean" ? this.floatingUIOptions.offset : void 0)
1762
+ );
1763
+ }
1764
+ if (this.floatingUIOptions.arrow) {
1765
+ middlewares.push(arrow2(this.floatingUIOptions.arrow));
1766
+ }
1767
+ if (this.floatingUIOptions.size) {
1768
+ middlewares.push(size2(typeof this.floatingUIOptions.size !== "boolean" ? this.floatingUIOptions.size : void 0));
1769
+ }
1770
+ if (this.floatingUIOptions.autoPlacement) {
1771
+ middlewares.push(
1772
+ autoPlacement2(
1773
+ typeof this.floatingUIOptions.autoPlacement !== "boolean" ? this.floatingUIOptions.autoPlacement : void 0
1774
+ )
1775
+ );
1776
+ }
1777
+ if (this.floatingUIOptions.hide) {
1778
+ middlewares.push(hide2(typeof this.floatingUIOptions.hide !== "boolean" ? this.floatingUIOptions.hide : void 0));
1779
+ }
1780
+ if (this.floatingUIOptions.inline) {
1781
+ middlewares.push(
1782
+ inline2(typeof this.floatingUIOptions.inline !== "boolean" ? this.floatingUIOptions.inline : void 0)
1783
+ );
1784
+ }
1785
+ return middlewares;
1786
+ }
1787
+ updatePosition() {
1788
+ const { selection } = this.editor.state;
1789
+ let virtualElement = {
1790
+ getBoundingClientRect: () => (0, import_core3.posToDOMRect)(this.view, selection.from, selection.to)
1791
+ };
1792
+ if (selection instanceof import_tables.CellSelection) {
1793
+ const { $anchorCell, $headCell } = selection;
1794
+ const from = $anchorCell ? $anchorCell.pos : $headCell.pos;
1795
+ const to = $headCell ? $headCell.pos : $anchorCell.pos;
1796
+ const fromDOM = this.view.nodeDOM(from);
1797
+ const toDOM = this.view.nodeDOM(to);
1798
+ if (!fromDOM || !toDOM) {
1799
+ return;
1800
+ }
1801
+ const clientRect = fromDOM === toDOM ? fromDOM.getBoundingClientRect() : combineDOMRects(
1802
+ fromDOM.getBoundingClientRect(),
1803
+ toDOM.getBoundingClientRect()
1804
+ );
1805
+ virtualElement = {
1806
+ getBoundingClientRect: () => clientRect
1807
+ };
1808
+ }
1809
+ computePosition2(virtualElement, this.element, {
1810
+ placement: this.floatingUIOptions.placement,
1811
+ strategy: this.floatingUIOptions.strategy,
1812
+ middleware: this.middlewares
1813
+ }).then(({ x, y, strategy }) => {
1814
+ this.element.style.width = "max-content";
1815
+ this.element.style.position = strategy;
1816
+ this.element.style.left = `${x}px`;
1817
+ this.element.style.top = `${y}px`;
1818
+ if (this.isVisible && this.floatingUIOptions.onUpdate) {
1819
+ this.floatingUIOptions.onUpdate();
1820
+ }
1821
+ });
1822
+ }
1823
+ update(view, oldState) {
1824
+ const { state } = view;
1825
+ const hasValidSelection = state.selection.from !== state.selection.to;
1826
+ if (this.updateDelay > 0 && hasValidSelection) {
1827
+ this.handleDebouncedUpdate(view, oldState);
1828
+ return;
1829
+ }
1830
+ const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view.state.selection));
1831
+ const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view.state.doc));
1832
+ this.updateHandler(view, selectionChanged, docChanged, oldState);
1833
+ }
1834
+ getShouldShow(oldState) {
1835
+ var _a;
1836
+ const { state } = this.view;
1837
+ const { selection } = state;
1838
+ const { ranges } = selection;
1839
+ const from = Math.min(...ranges.map((range) => range.$from.pos));
1840
+ const to = Math.max(...ranges.map((range) => range.$to.pos));
1841
+ const shouldShow = (_a = this.shouldShow) == null ? void 0 : _a.call(this, {
1842
+ editor: this.editor,
1843
+ element: this.element,
1844
+ view: this.view,
1845
+ state,
1846
+ oldState,
1847
+ from,
1848
+ to
1849
+ });
1850
+ return shouldShow;
1851
+ }
1852
+ show() {
1853
+ var _a;
1854
+ if (this.isVisible) {
1855
+ return;
1856
+ }
1857
+ this.element.style.visibility = "visible";
1858
+ this.element.style.opacity = "1";
1859
+ (_a = this.view.dom.parentElement) == null ? void 0 : _a.appendChild(this.element);
1860
+ if (this.floatingUIOptions.onShow) {
1861
+ this.floatingUIOptions.onShow();
1862
+ }
1863
+ this.isVisible = true;
1864
+ }
1865
+ hide() {
1866
+ if (!this.isVisible) {
1867
+ return;
1868
+ }
1869
+ this.element.style.visibility = "hidden";
1870
+ this.element.style.opacity = "0";
1871
+ this.element.remove();
1872
+ if (this.floatingUIOptions.onHide) {
1873
+ this.floatingUIOptions.onHide();
1874
+ }
1875
+ this.isVisible = false;
1876
+ }
1877
+ destroy() {
1878
+ this.hide();
1879
+ this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: true });
1880
+ this.view.dom.removeEventListener("dragstart", this.dragstartHandler);
1881
+ window.removeEventListener("resize", this.resizeHandler);
1882
+ this.editor.off("focus", this.focusHandler);
1883
+ this.editor.off("blur", this.blurHandler);
1884
+ if (this.floatingUIOptions.onDestroy) {
1885
+ this.floatingUIOptions.onDestroy();
1886
+ }
1887
+ }
1888
+ };
1889
+ var BubbleMenuPlugin = (options) => {
1890
+ return new import_state.Plugin({
1891
+ key: typeof options.pluginKey === "string" ? new import_state.PluginKey(options.pluginKey) : options.pluginKey,
1892
+ view: (view) => new BubbleMenuView({ view, ...options })
1893
+ });
1894
+ };
1895
+ var BubbleMenu = import_core2.Extension.create({
1896
+ name: "bubbleMenu",
1897
+ addOptions() {
1898
+ return {
1899
+ element: null,
1900
+ pluginKey: "bubbleMenu",
1901
+ updateDelay: void 0,
1902
+ shouldShow: null
1903
+ };
1904
+ },
1905
+ addProseMirrorPlugins() {
1906
+ if (!this.options.element) {
1907
+ return [];
1908
+ }
1909
+ return [
1910
+ BubbleMenuPlugin({
1911
+ pluginKey: this.options.pluginKey,
1912
+ editor: this.editor,
1913
+ element: this.options.element,
1914
+ updateDelay: this.options.updateDelay,
1915
+ shouldShow: this.options.shouldShow
1916
+ })
1917
+ ];
1918
+ }
1919
+ });
1920
+
1921
+ // src/menus/BubbleMenu.ts
1922
+ var BubbleMenu2 = {
1923
+ name: "BubbleMenu",
1924
+ props: {
1925
+ pluginKey: {
1926
+ type: [String, Object],
1927
+ default: "bubbleMenu"
1928
+ },
1929
+ editor: {
1930
+ type: Object,
1931
+ required: true
1932
+ },
1933
+ updateDelay: {
1934
+ type: Number
1935
+ },
1936
+ options: {
1937
+ type: Object,
1938
+ default: {}
1939
+ },
1940
+ resizeDelay: {
1941
+ type: Number
1942
+ },
1943
+ shouldShow: {
1944
+ type: Function,
1945
+ default: null
1946
+ }
1947
+ },
1948
+ watch: {
1949
+ editor: {
1950
+ immediate: true,
1951
+ handler(editor) {
1952
+ if (!editor) {
1953
+ return;
1954
+ }
1955
+ ;
1956
+ this.$el.style.visibility = "hidden";
1957
+ this.$el.style.position = "absolute";
1958
+ this.$el.remove();
1959
+ this.$nextTick(() => {
1960
+ editor.registerPlugin(
1961
+ BubbleMenuPlugin({
1962
+ updateDelay: this.updateDelay,
1963
+ resizeDelay: this.resizeDelay,
1964
+ options: this.options,
1965
+ editor,
1966
+ element: this.$el,
1967
+ pluginKey: this.pluginKey,
1968
+ shouldShow: this.shouldShow
1969
+ })
1970
+ );
1971
+ });
1972
+ }
1973
+ }
1974
+ },
1975
+ render(createElement) {
1976
+ return createElement("div", { style: { visibility: "hidden" } }, this.$slots.default);
1977
+ },
1978
+ beforeDestroy() {
1979
+ this.editor.unregisterPlugin(this.pluginKey);
1980
+ }
1981
+ };
1982
+
1983
+ // ../extension-floating-menu/dist/index.js
1984
+ var import_core4 = require("@tiptap/core");
1985
+ var import_core5 = require("@tiptap/core");
1986
+ var import_state2 = require("@tiptap/pm/state");
1987
+ var FloatingMenuView = class {
1988
+ constructor({ editor, element, view, options, shouldShow }) {
1989
+ this.preventHide = false;
1990
+ this.isVisible = false;
1991
+ this.shouldShow = ({ view: view2, state }) => {
1992
+ const { selection } = state;
1993
+ const { $anchor, empty } = selection;
1994
+ const isRootDepth = $anchor.depth === 1;
1995
+ const isEmptyTextBlock = $anchor.parent.isTextblock && !$anchor.parent.type.spec.code && !$anchor.parent.textContent && $anchor.parent.childCount === 0 && !this.getTextContent($anchor.parent);
1996
+ if (!view2.hasFocus() || !empty || !isRootDepth || !isEmptyTextBlock || !this.editor.isEditable) {
1997
+ return false;
1998
+ }
1999
+ return true;
2000
+ };
2001
+ this.floatingUIOptions = {
2002
+ strategy: "absolute",
2003
+ placement: "right",
2004
+ offset: 8,
2005
+ flip: {},
2006
+ shift: {},
2007
+ arrow: false,
2008
+ size: false,
2009
+ autoPlacement: false,
2010
+ hide: false,
2011
+ inline: false
2012
+ };
2013
+ this.updateHandler = (view2, selectionChanged, docChanged, oldState) => {
2014
+ const { composing } = view2;
2015
+ const isSame = !selectionChanged && !docChanged;
2016
+ if (composing || isSame) {
2017
+ return;
2018
+ }
2019
+ const shouldShow2 = this.getShouldShow(oldState);
2020
+ if (!shouldShow2) {
2021
+ this.hide();
2022
+ return;
2023
+ }
2024
+ this.updatePosition();
2025
+ this.show();
2026
+ };
2027
+ this.mousedownHandler = () => {
2028
+ this.preventHide = true;
2029
+ };
2030
+ this.focusHandler = () => {
2031
+ setTimeout(() => this.update(this.editor.view));
2032
+ };
2033
+ this.blurHandler = ({ event }) => {
2034
+ var _a;
2035
+ if (this.preventHide) {
2036
+ this.preventHide = false;
2037
+ return;
2038
+ }
2039
+ if ((event == null ? void 0 : event.relatedTarget) && ((_a = this.element.parentNode) == null ? void 0 : _a.contains(event.relatedTarget))) {
2040
+ return;
2041
+ }
2042
+ if ((event == null ? void 0 : event.relatedTarget) === this.editor.view.dom) {
2043
+ return;
2044
+ }
2045
+ this.hide();
2046
+ };
2047
+ this.editor = editor;
2048
+ this.element = element;
2049
+ this.view = view;
2050
+ this.floatingUIOptions = {
2051
+ ...this.floatingUIOptions,
2052
+ ...options
2053
+ };
2054
+ this.element.tabIndex = 0;
2055
+ if (shouldShow) {
2056
+ this.shouldShow = shouldShow;
2057
+ }
2058
+ this.element.addEventListener("mousedown", this.mousedownHandler, { capture: true });
2059
+ this.editor.on("focus", this.focusHandler);
2060
+ this.editor.on("blur", this.blurHandler);
2061
+ this.update(view, view.state);
2062
+ if (this.getShouldShow()) {
2063
+ this.show();
2064
+ }
2065
+ }
2066
+ getTextContent(node) {
2067
+ return (0, import_core5.getText)(node, { textSerializers: (0, import_core5.getTextSerializersFromSchema)(this.editor.schema) });
2068
+ }
2069
+ get middlewares() {
2070
+ const middlewares = [];
2071
+ if (this.floatingUIOptions.flip) {
2072
+ middlewares.push(flip2(typeof this.floatingUIOptions.flip !== "boolean" ? this.floatingUIOptions.flip : void 0));
2073
+ }
2074
+ if (this.floatingUIOptions.shift) {
2075
+ middlewares.push(
2076
+ shift2(typeof this.floatingUIOptions.shift !== "boolean" ? this.floatingUIOptions.shift : void 0)
2077
+ );
2078
+ }
2079
+ if (this.floatingUIOptions.offset) {
2080
+ middlewares.push(
2081
+ offset2(typeof this.floatingUIOptions.offset !== "boolean" ? this.floatingUIOptions.offset : void 0)
2082
+ );
2083
+ }
2084
+ if (this.floatingUIOptions.arrow) {
2085
+ middlewares.push(arrow2(this.floatingUIOptions.arrow));
2086
+ }
2087
+ if (this.floatingUIOptions.size) {
2088
+ middlewares.push(size2(typeof this.floatingUIOptions.size !== "boolean" ? this.floatingUIOptions.size : void 0));
2089
+ }
2090
+ if (this.floatingUIOptions.autoPlacement) {
2091
+ middlewares.push(
2092
+ autoPlacement2(
2093
+ typeof this.floatingUIOptions.autoPlacement !== "boolean" ? this.floatingUIOptions.autoPlacement : void 0
2094
+ )
2095
+ );
2096
+ }
2097
+ if (this.floatingUIOptions.hide) {
2098
+ middlewares.push(hide2(typeof this.floatingUIOptions.hide !== "boolean" ? this.floatingUIOptions.hide : void 0));
2099
+ }
2100
+ if (this.floatingUIOptions.inline) {
2101
+ middlewares.push(
2102
+ inline2(typeof this.floatingUIOptions.inline !== "boolean" ? this.floatingUIOptions.inline : void 0)
2103
+ );
2104
+ }
2105
+ return middlewares;
2106
+ }
2107
+ getShouldShow(oldState) {
2108
+ var _a;
2109
+ const { state } = this.view;
2110
+ const { selection } = state;
2111
+ const { ranges } = selection;
2112
+ const from = Math.min(...ranges.map((range) => range.$from.pos));
2113
+ const to = Math.max(...ranges.map((range) => range.$to.pos));
2114
+ const shouldShow = (_a = this.shouldShow) == null ? void 0 : _a.call(this, {
2115
+ editor: this.editor,
2116
+ view: this.view,
2117
+ state,
2118
+ oldState,
2119
+ from,
2120
+ to
2121
+ });
2122
+ return shouldShow;
2123
+ }
2124
+ updatePosition() {
2125
+ const { selection } = this.editor.state;
2126
+ const virtualElement = {
2127
+ getBoundingClientRect: () => (0, import_core5.posToDOMRect)(this.view, selection.from, selection.to)
2128
+ };
2129
+ computePosition2(virtualElement, this.element, {
2130
+ placement: this.floatingUIOptions.placement,
2131
+ strategy: this.floatingUIOptions.strategy,
2132
+ middleware: this.middlewares
2133
+ }).then(({ x, y, strategy }) => {
2134
+ this.element.style.width = "max-content";
2135
+ this.element.style.position = strategy;
2136
+ this.element.style.left = `${x}px`;
2137
+ this.element.style.top = `${y}px`;
2138
+ if (this.isVisible && this.floatingUIOptions.onUpdate) {
2139
+ this.floatingUIOptions.onUpdate();
2140
+ }
2141
+ });
2142
+ }
2143
+ update(view, oldState) {
2144
+ const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view.state.selection));
2145
+ const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view.state.doc));
2146
+ this.updateHandler(view, selectionChanged, docChanged, oldState);
2147
+ }
2148
+ show() {
2149
+ var _a;
2150
+ if (this.isVisible) {
2151
+ return;
2152
+ }
2153
+ this.element.style.visibility = "visible";
2154
+ this.element.style.opacity = "1";
2155
+ (_a = this.view.dom.parentElement) == null ? void 0 : _a.appendChild(this.element);
2156
+ if (this.floatingUIOptions.onShow) {
2157
+ this.floatingUIOptions.onShow();
2158
+ }
2159
+ this.isVisible = true;
2160
+ }
2161
+ hide() {
2162
+ if (!this.isVisible) {
2163
+ return;
2164
+ }
2165
+ this.element.style.visibility = "hidden";
2166
+ this.element.style.opacity = "0";
2167
+ this.element.remove();
2168
+ if (this.floatingUIOptions.onHide) {
2169
+ this.floatingUIOptions.onHide();
2170
+ }
2171
+ this.isVisible = false;
2172
+ }
2173
+ destroy() {
2174
+ this.hide();
2175
+ this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: true });
2176
+ this.editor.off("focus", this.focusHandler);
2177
+ this.editor.off("blur", this.blurHandler);
2178
+ if (this.floatingUIOptions.onDestroy) {
2179
+ this.floatingUIOptions.onDestroy();
2180
+ }
2181
+ }
2182
+ };
2183
+ var FloatingMenuPlugin = (options) => {
2184
+ return new import_state2.Plugin({
2185
+ key: typeof options.pluginKey === "string" ? new import_state2.PluginKey(options.pluginKey) : options.pluginKey,
2186
+ view: (view) => new FloatingMenuView({ view, ...options })
2187
+ });
2188
+ };
2189
+ var FloatingMenu = import_core4.Extension.create({
2190
+ name: "floatingMenu",
2191
+ addOptions() {
2192
+ return {
2193
+ element: null,
2194
+ options: {},
2195
+ pluginKey: "floatingMenu",
2196
+ shouldShow: null
2197
+ };
2198
+ },
2199
+ addProseMirrorPlugins() {
2200
+ if (!this.options.element) {
2201
+ return [];
2202
+ }
2203
+ return [
2204
+ FloatingMenuPlugin({
2205
+ pluginKey: this.options.pluginKey,
2206
+ editor: this.editor,
2207
+ element: this.options.element,
2208
+ options: this.options.options,
2209
+ shouldShow: this.options.shouldShow
2210
+ })
2211
+ ];
2212
+ }
2213
+ });
2214
+
2215
+ // src/menus/FloatingMenu.ts
2216
+ var FloatingMenu2 = {
2217
+ name: "FloatingMenu",
2218
+ props: {
2219
+ pluginKey: {
2220
+ type: [String, Object],
2221
+ default: "floatingMenu"
2222
+ },
2223
+ editor: {
2224
+ type: Object,
2225
+ required: true
2226
+ },
2227
+ options: {
2228
+ type: Object,
2229
+ default: () => ({})
2230
+ },
2231
+ shouldShow: {
2232
+ type: Function,
2233
+ default: null
2234
+ }
2235
+ },
2236
+ watch: {
2237
+ editor: {
2238
+ immediate: true,
2239
+ handler(editor) {
2240
+ if (!editor) {
2241
+ return;
2242
+ }
2243
+ ;
2244
+ this.$el.style.visibility = "hidden";
2245
+ this.$el.style.position = "absolute";
2246
+ this.$el.remove();
2247
+ this.$nextTick(() => {
2248
+ editor.registerPlugin(
2249
+ FloatingMenuPlugin({
2250
+ pluginKey: this.pluginKey,
2251
+ editor,
2252
+ element: this.$el,
2253
+ options: this.options,
2254
+ shouldShow: this.shouldShow
2255
+ })
2256
+ );
2257
+ });
2258
+ }
2259
+ }
2260
+ },
2261
+ render(createElement) {
2262
+ return createElement("div", { style: { visibility: "hidden" } }, this.$slots.default);
2263
+ },
2264
+ beforeDestroy() {
2265
+ this.editor.unregisterPlugin(this.pluginKey);
2266
+ }
2267
+ };
2268
+ // Annotate the CommonJS export names for ESM import in node:
2269
+ 0 && (module.exports = {
2270
+ BubbleMenu,
2271
+ FloatingMenu
2272
+ });
2273
+ //# sourceMappingURL=index.cjs.map