@mattisvensson/strapi-plugin-webatlas 0.9.5 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/README.md +24 -36
  2. package/dist/_chunks/FullLoader-Cmsf8xS6.js +0 -1
  3. package/dist/_chunks/FullLoader-CrPED_dY.mjs +0 -1
  4. package/dist/_chunks/{SettingTitle-CiMKrd_1.mjs → SettingTitle-CdR3SVn_.mjs} +1 -2
  5. package/dist/_chunks/{SettingTitle-CAoYbTar.js → SettingTitle-RU1azFIM.js} +1 -1
  6. package/dist/_chunks/{de-C-uxto84.mjs → de-B5pRvs13.mjs} +13 -8
  7. package/dist/_chunks/{de-CGXL_3o_.js → de-CqU1FU8C.js} +13 -8
  8. package/dist/_chunks/{en-B1CHnIH7.mjs → en-BE-zzIv8.mjs} +13 -8
  9. package/dist/_chunks/{en-DWEd5BXK.js → en-C7I90FwV.js} +13 -8
  10. package/dist/_chunks/{index-Bqsd7oPS.mjs → index-B07UVUOa.mjs} +387 -230
  11. package/dist/_chunks/{index-DJBnQbrp.mjs → index-BmyxSosC.mjs} +3 -3
  12. package/dist/_chunks/{index-BOZDZiAv.js → index-BucL4va6.js} +38 -82
  13. package/dist/_chunks/{index-DU58LJ2w.mjs → index-BvcX9hcc.mjs} +61 -25
  14. package/dist/_chunks/{index-ezabqLEP.js → index-BxpDM360.js} +386 -228
  15. package/dist/_chunks/{index-qrC_n9-7.mjs → index-CIM-JzLK.mjs} +38 -82
  16. package/dist/_chunks/{index-qrrfKpw1.mjs → index-CNKWb8pn.mjs} +615 -321
  17. package/dist/_chunks/{index-m2ivL3ht.js → index-D-vJE_K8.js} +3 -3
  18. package/dist/_chunks/{index-BkB1x9Sn.js → index-IRSCe8PX.js} +610 -316
  19. package/dist/_chunks/{index-CC073vGB.js → index-d09V61nm.js} +61 -24
  20. package/dist/admin/index.js +1 -2
  21. package/dist/admin/index.mjs +1 -2
  22. package/dist/admin/src/components/CMEditViewAside/NewPathInfo.d.ts +2 -0
  23. package/dist/admin/src/components/CMEditViewAside/OverrideCheckbox.d.ts +7 -0
  24. package/dist/admin/src/components/CMEditViewAside/Panel.d.ts +5 -0
  25. package/dist/admin/src/components/CMEditViewAside/PathInput.d.ts +11 -0
  26. package/dist/admin/src/components/CMEditViewAside/RouteStructure.d.ts +3 -0
  27. package/dist/admin/src/components/CMEditViewAside/UidPathDisplay.d.ts +4 -0
  28. package/dist/admin/src/components/PathInfo.d.ts +2 -3
  29. package/dist/admin/src/components/modals/externalItem/index.d.ts +1 -1
  30. package/dist/admin/src/components/modals/internalItem/ItemDetails.d.ts +13 -0
  31. package/dist/admin/src/components/modals/internalItem/internalItemCreate.d.ts +1 -1
  32. package/dist/admin/src/components/modals/internalItem/internalItemEdit.d.ts +1 -1
  33. package/dist/admin/src/components/modals/useModalSharedLogic.d.ts +1 -1
  34. package/dist/admin/src/components/modals/wrapperItem/index.d.ts +1 -1
  35. package/dist/admin/src/hooks/useApi.d.ts +4 -3
  36. package/dist/admin/src/pages/Navigation/RouteItem.d.ts +1 -15
  37. package/dist/admin/src/pages/Navigation/RouteItemBadge.d.ts +4 -0
  38. package/dist/admin/src/pages/Navigation/RouteItemIcon.d.ts +5 -0
  39. package/dist/admin/src/pages/Navigation/RouteItemMenu.d.ts +10 -0
  40. package/dist/admin/src/pages/Navigation/RouteItemStatus.d.ts +5 -0
  41. package/dist/admin/src/pages/Navigation/SortableRouteItem.d.ts +1 -1
  42. package/dist/admin/src/types/index.d.ts +3 -0
  43. package/dist/admin/src/types/modal.d.ts +56 -0
  44. package/dist/admin/src/types/navigation.d.ts +18 -0
  45. package/dist/admin/src/types/panel.d.ts +41 -0
  46. package/dist/admin/src/types/route.d.ts +1 -1
  47. package/dist/admin/src/utils/buildBreadcrumbString.d.ts +16 -0
  48. package/dist/admin/src/utils/createTempNavItemObject.d.ts +6 -8
  49. package/dist/admin/src/utils/duplicateCheck.d.ts +10 -4
  50. package/dist/admin/src/utils/findParentNavItem.d.ts +13 -0
  51. package/dist/admin/src/utils/index.d.ts +3 -2
  52. package/dist/server/index.js +636 -209
  53. package/dist/server/index.mjs +636 -209
  54. package/dist/server/src/content-types/index.d.ts +18 -0
  55. package/dist/server/src/content-types/route/index.d.ts +18 -0
  56. package/dist/server/src/content-types/route/schema.d.ts +18 -0
  57. package/dist/server/src/controllers/admin.d.ts +3 -2
  58. package/dist/server/src/controllers/index.d.ts +3 -2
  59. package/dist/server/src/index.d.ts +24 -4
  60. package/dist/server/src/migrations/001-canonical-path.d.ts +7 -0
  61. package/dist/server/src/migrations/index.d.ts +3 -0
  62. package/dist/server/src/services/admin.d.ts +3 -2
  63. package/dist/server/src/services/index.d.ts +3 -2
  64. package/dist/server/src/utils/buildCanonicalPath.d.ts +1 -0
  65. package/dist/server/src/utils/buildNavigationPath.d.ts +5 -0
  66. package/dist/server/src/utils/cascadeCanonicalPathUpdates.d.ts +1 -0
  67. package/dist/server/src/utils/getNonInternalRouteIds.d.ts +1 -0
  68. package/dist/server/src/utils/getRouteAncestors.d.ts +1 -0
  69. package/dist/server/src/utils/getRouteDescendants.d.ts +1 -0
  70. package/dist/server/src/utils/index.d.ts +10 -2
  71. package/dist/server/src/utils/navigationItemStructure.d.ts +27 -0
  72. package/dist/server/src/utils/routeHandler.d.ts +4 -2
  73. package/dist/server/src/utils/validateRouteDependencies.d.ts +4 -0
  74. package/dist/types/index.d.ts +0 -1
  75. package/dist/types/navigation.d.ts +13 -12
  76. package/dist/types/route.d.ts +7 -2
  77. package/dist/types/strapi.d.ts +1 -2
  78. package/dist/utils/index.d.ts +1 -2
  79. package/package.json +1 -1
  80. package/dist/_chunks/FullLoader-Cmsf8xS6.js.map +0 -1
  81. package/dist/_chunks/FullLoader-CrPED_dY.mjs.map +0 -1
  82. package/dist/_chunks/SettingTitle-ByAhjihc.js +0 -68
  83. package/dist/_chunks/SettingTitle-ByAhjihc.js.map +0 -1
  84. package/dist/_chunks/SettingTitle-CiMKrd_1.mjs.map +0 -1
  85. package/dist/_chunks/SettingTitle-ZM5Yf2b4.mjs +0 -68
  86. package/dist/_chunks/de-C-uxto84.mjs.map +0 -1
  87. package/dist/_chunks/de-CGXL_3o_.js.map +0 -1
  88. package/dist/_chunks/en-B1CHnIH7.mjs.map +0 -1
  89. package/dist/_chunks/en-DWEd5BXK.js.map +0 -1
  90. package/dist/_chunks/index-BqceJPRl.js +0 -235
  91. package/dist/_chunks/index-BqceJPRl.js.map +0 -1
  92. package/dist/_chunks/index-Bqsd7oPS.mjs.map +0 -1
  93. package/dist/_chunks/index-CK1wisw5.mjs +0 -129
  94. package/dist/_chunks/index-CK1wisw5.mjs.map +0 -1
  95. package/dist/_chunks/index-CQ2raqxe.js +0 -129
  96. package/dist/_chunks/index-CQ2raqxe.js.map +0 -1
  97. package/dist/_chunks/index-Ca9T36AU.mjs +0 -263
  98. package/dist/_chunks/index-Ca9T36AU.mjs.map +0 -1
  99. package/dist/_chunks/index-DDN4T6c7.mjs +0 -4188
  100. package/dist/_chunks/index-DH4Rd7aA.mjs +0 -8311
  101. package/dist/_chunks/index-DH4Rd7aA.mjs.map +0 -1
  102. package/dist/_chunks/index-DU58LJ2w.mjs.map +0 -1
  103. package/dist/_chunks/index-DnE_cDwy.js +0 -8311
  104. package/dist/_chunks/index-DnE_cDwy.js.map +0 -1
  105. package/dist/_chunks/index-DzpXVfQ_.js +0 -263
  106. package/dist/_chunks/index-DzpXVfQ_.js.map +0 -1
  107. package/dist/_chunks/index-R7qsEu2N.js +0 -4205
  108. package/dist/_chunks/index-R7qsEu2N.js.map +0 -1
  109. package/dist/_chunks/index-fbC3magu.mjs +0 -234
  110. package/dist/admin/index.js.map +0 -1
  111. package/dist/admin/index.mjs.map +0 -1
  112. package/dist/admin/src/components/CMEditViewAside/Path.d.ts +0 -5
  113. package/dist/admin/src/utils/countChildren.d.ts +0 -2
  114. package/dist/server/index.js.map +0 -1
  115. package/dist/server/index.mjs.map +0 -1
  116. package/dist/types/modal.d.ts +0 -36
  117. package/dist/utils/getPath.d.ts +0 -1
@@ -1,4188 +0,0 @@
1
- import * as React from "react";
2
- import { useRef, useEffect, useState, useCallback, createContext, useMemo, createElement, useContext, Fragment, forwardRef, Children, isValidElement, cloneElement, useLayoutEffect, useReducer } from "react";
3
- import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
4
- import { Link, List, Information } from "@strapi/icons";
5
- import { useFetchClient, unstable_useContentManagerContext, useRBAC } from "@strapi/strapi/admin";
6
- import { Box, Typography, Flex, Divider, Field, Checkbox } from "@strapi/design-system";
7
- import * as ReactDOM from "react-dom";
8
- import ReactDOM__default, { flushSync } from "react-dom";
9
- import { useIntl } from "react-intl";
10
- const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
11
- const v = glob[path];
12
- if (v) {
13
- return typeof v === "function" ? v() : Promise.resolve(v);
14
- }
15
- return new Promise((_, reject) => {
16
- (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
17
- reject.bind(
18
- null,
19
- new Error(
20
- "Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
21
- )
22
- )
23
- );
24
- });
25
- };
26
- function transformToUrl(input) {
27
- const specialCharMap = {
28
- "ü": "ue",
29
- "ä": "ae",
30
- "ö": "oe"
31
- };
32
- if (!input || typeof input !== "string") return "";
33
- input = input.toLowerCase();
34
- input = input.replace(/\/+/g, "/");
35
- input = input.startsWith("/") ? input.slice(1) : input;
36
- input = input.endsWith("/") ? input.slice(0, -1) : input;
37
- for (const char in specialCharMap) {
38
- const regex = new RegExp(char, "g");
39
- input = input.replace(regex, specialCharMap[char]);
40
- }
41
- input = input.trim();
42
- input = input.replace(/\s+/g, "-");
43
- input = input.replace(/[^A-Za-z0-9$\-_.+!*'()/]/g, "");
44
- input = input.replace(/-+/g, "-");
45
- return input;
46
- }
47
- const version = "0.9.4";
48
- const keywords = [];
49
- const type = "commonjs";
50
- const exports = {
51
- "./package.json": "./package.json",
52
- "./strapi-admin": {
53
- types: "./dist/admin/src/index.d.ts",
54
- source: "./admin/src/index.tsx",
55
- "import": "./dist/admin/index.mjs",
56
- require: "./dist/admin/index.js",
57
- "default": "./dist/admin/index.js"
58
- },
59
- "./strapi-server": {
60
- types: "./dist/server/src/index.d.ts",
61
- source: "./server/src/index.ts",
62
- "import": "./dist/server/index.mjs",
63
- require: "./dist/server/index.js",
64
- "default": "./dist/server/index.js"
65
- }
66
- };
67
- const files = [
68
- "dist"
69
- ];
70
- const scripts = {
71
- build: "strapi-plugin build && yalc push --publish",
72
- watch: "strapi-plugin watch",
73
- "watch:link": "strapi-plugin watch:link",
74
- verify: "strapi-plugin verify",
75
- "test:ts:front": "tsc -p admin/tsconfig.json",
76
- "test:ts:back": "tsc -p server/tsconfig.json",
77
- "test:jest": "ENV_PATH=./playground/.env jest --verbose --runInBand --forceExit",
78
- "test:cypress": "cypress run",
79
- "test:cypress:open": "cypress open",
80
- preversion: "yarn build",
81
- postversion: "git push && git push --tags"
82
- };
83
- const dependencies = {
84
- "@dnd-kit/core": "^6.3.1",
85
- "@dnd-kit/sortable": "^10.0.0",
86
- "@dnd-kit/utilities": "^3.2.2",
87
- "@strapi/design-system": "^2.0.0-rc.14",
88
- "@strapi/icons": "^2.0.0-rc.14",
89
- "react-intl": "^7.1.0"
90
- };
91
- const devDependencies = {
92
- "@strapi/sdk-plugin": "^5.0.0",
93
- "@strapi/strapi": "^5.0.0",
94
- "@strapi/typescript-utils": "^5.0.0",
95
- "@types/react": "^19.0.0",
96
- "@types/react-dom": "^19.0.0",
97
- cypress: "^13.9.0",
98
- "cypress-terminal-report": "^6.0.2",
99
- jest: "^29.7.0",
100
- prettier: "^3.4.2",
101
- react: "^19.0.0",
102
- "react-router-dom": "^6.0.0",
103
- supertest: "^7.0.0",
104
- typescript: "^5.7.2"
105
- };
106
- const peerDependencies = {
107
- "@strapi/strapi": "^5.0.0",
108
- react: "^17.0.0 || ^18.0.0",
109
- "react-dom": "^17.0.0 || ^18.0.0",
110
- "react-router-dom": "^6.0.0",
111
- "styled-components": "^6.0.0"
112
- };
113
- const description = "A strapi plugin to manage URL routes and navigations.";
114
- const strapi = {
115
- name: "webatlas",
116
- displayName: "Webatlas",
117
- description: "A strapi plugin to manage URL routes and navigations.",
118
- kind: "plugin"
119
- };
120
- const name = "@mattisvensson/strapi-plugin-webatlas";
121
- const license = "MIT";
122
- const repository = {
123
- type: "git",
124
- url: "git+ssh://git@github.com:mattisvensson/strapi-plugin-webatlas.git"
125
- };
126
- const bugs = {
127
- url: "https://github.com/mattisvensson/strapi-plugin-webatlas/issues"
128
- };
129
- const homepage = "https://github.com/mattisvensson/strapi-plugin-webatlas#readme";
130
- const author = {
131
- name: "Matti Svensson",
132
- email: "mattisvensson@web.de",
133
- url: "https://mattisvensson.dev"
134
- };
135
- const maintainers = [
136
- {
137
- name: "Matti Svensson",
138
- email: "mattisvensson@web.de",
139
- url: "https://mattisvensson.dev"
140
- }
141
- ];
142
- const packageManager = "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e";
143
- const pluginPkg = {
144
- version,
145
- keywords,
146
- type,
147
- exports,
148
- files,
149
- scripts,
150
- dependencies,
151
- devDependencies,
152
- peerDependencies,
153
- description,
154
- strapi,
155
- name,
156
- license,
157
- repository,
158
- bugs,
159
- homepage,
160
- author,
161
- maintainers,
162
- packageManager
163
- };
164
- const PLUGIN_ID = pluginPkg.strapi.name.replace(/^(@[^-,.][\w,-]+\/|strapi-)plugin-/i, "") || "webatlas";
165
- const PLUGIN_NAME = pluginPkg.strapi.displayName;
166
- const PLUGIN_VERSION = pluginPkg.version;
167
- const Initializer = ({ setPlugin }) => {
168
- const ref = useRef(setPlugin);
169
- useEffect(() => {
170
- ref.current(PLUGIN_ID);
171
- }, []);
172
- return null;
173
- };
174
- const PathIcon = () => /* @__PURE__ */ jsx(Link, {});
175
- const NavigationIcon = () => /* @__PURE__ */ jsx(List, {});
176
- function useApi() {
177
- const { get, put, del, post } = useFetchClient();
178
- const fetchAllContentTypes = async () => {
179
- try {
180
- const { data } = await get("/content-manager/content-types");
181
- return data.data;
182
- } catch (error) {
183
- console.warn("Cannot fetch all content types:", error);
184
- return [];
185
- }
186
- };
187
- const fetchConfiguredContentTypes = async () => {
188
- try {
189
- const { data: config } = await get(`/${PLUGIN_ID}/config`);
190
- const configuredTypes = config?.selectedContentTypes || [];
191
- if (configuredTypes.length === 0) {
192
- return [];
193
- }
194
- const allContentTypes = await fetchAllContentTypes();
195
- const configuredUIDs = new Set(configuredTypes.map((ct) => ct.uid));
196
- return allContentTypes.filter((ct) => configuredUIDs.has(ct.uid));
197
- } catch (err) {
198
- console.error("Error fetching configured content types:", err);
199
- return [];
200
- }
201
- };
202
- const fetchAllEntities = async () => {
203
- try {
204
- const { data } = await get(`/${PLUGIN_ID}/config`);
205
- const contentTypes = data?.selectedContentTypes || [];
206
- if (!contentTypes || contentTypes.length === 0) {
207
- return [];
208
- }
209
- let entities = [];
210
- const entityResults = await Promise.allSettled(
211
- contentTypes.map(async (contentType) => {
212
- try {
213
- const { data: data2 } = await get(`/content-manager/collection-types/${contentType.uid}?pageSize=9999`);
214
- if (!data2 || !data2.results) {
215
- return null;
216
- }
217
- return {
218
- entities: data2.results,
219
- contentType
220
- };
221
- } catch (err) {
222
- console.warn(`Cannot access entities for ${contentType.uid}:`, err);
223
- return null;
224
- }
225
- })
226
- );
227
- entities = entityResults.map((result) => result.status === "fulfilled" ? result.value : null).filter(Boolean);
228
- return entities;
229
- } catch (err) {
230
- console.error("Error fetching entities:", err);
231
- throw err;
232
- }
233
- };
234
- const getRelatedRoute = async (relatedDocumentId) => {
235
- const { data } = await get(`/${PLUGIN_ID}/route/related?documentId=${relatedDocumentId}`);
236
- return data;
237
- };
238
- const getRoutes = async () => {
239
- const { data } = await get(`/${PLUGIN_ID}/route`);
240
- return data;
241
- };
242
- const updateRoute = async (body, documentId) => {
243
- const { data } = await put(`/${PLUGIN_ID}/route?documentId=${documentId}`, {
244
- data: {
245
- ...body
246
- }
247
- });
248
- return data;
249
- };
250
- const getNavigation = async ({ documentId, variant } = {}) => {
251
- const query = [];
252
- if (documentId) query.push(`documentId=${documentId}`);
253
- if (variant) query.push(`variant=${variant}`);
254
- const { data } = await get(`/${PLUGIN_ID}/navigation${query.length > 0 ? `?${query.join("&")}` : ""}`);
255
- return data;
256
- };
257
- const createNavigation = async (body) => {
258
- const { data } = await post(`/${PLUGIN_ID}/navigation`, {
259
- data: body
260
- });
261
- return data;
262
- };
263
- const deleteNavigation = async (documentId) => {
264
- const { data } = await del(`/${PLUGIN_ID}/navigation?documentId=${documentId}`);
265
- return data;
266
- };
267
- const updateNavigation = async (documentId, body) => {
268
- const { data } = await put(`/${PLUGIN_ID}/navigation?documentId=${documentId}`, {
269
- data: body
270
- });
271
- return data;
272
- };
273
- const updateNavigationItemStructure = async (documentId, navigationItems) => {
274
- const { data } = await put(`/${PLUGIN_ID}/navigation/items`, {
275
- navigationId: documentId,
276
- navigationItems
277
- });
278
- return data;
279
- };
280
- return {
281
- fetchAllContentTypes,
282
- fetchConfiguredContentTypes,
283
- fetchAllEntities,
284
- getRelatedRoute,
285
- getRoutes,
286
- updateRoute,
287
- getNavigation,
288
- createNavigation,
289
- deleteNavigation,
290
- updateNavigation,
291
- updateNavigationItemStructure
292
- };
293
- }
294
- const useAllContentTypes = () => {
295
- const { fetchAllContentTypes } = useApi();
296
- const [contentTypes, setContentTypes] = useState([]);
297
- const [loading, setLoading] = useState(true);
298
- const [error, setError] = useState(null);
299
- useEffect(() => {
300
- const fetchEntities = async () => {
301
- try {
302
- const result = await fetchAllContentTypes();
303
- setContentTypes(result);
304
- setLoading(false);
305
- } catch (err) {
306
- setError(err);
307
- setLoading(false);
308
- }
309
- };
310
- fetchEntities();
311
- }, []);
312
- return { contentTypes, loading, error };
313
- };
314
- function usePluginConfig() {
315
- const { put, get } = useFetchClient();
316
- const [config, setConfigData] = useState(null);
317
- const [loading, setLoading] = useState(true);
318
- const [fetchError, setFetchError] = useState(null);
319
- useEffect(() => {
320
- const fetchData = async () => {
321
- setLoading(true);
322
- setFetchError(null);
323
- try {
324
- const { data: { data: contentTypesArray } } = await get("/content-manager/content-types");
325
- let { data: config2 } = await get(`/${PLUGIN_ID}/config`);
326
- if (!config2 || !config2.selectedContentTypes) {
327
- throw new Error(`Couldn't fetch plugin config`);
328
- }
329
- const allowedContentTypes = contentTypesArray.filter(
330
- (type2) => type2.pluginOptions?.webatlas?.enabled === true
331
- );
332
- const contentTypeUids = new Set(allowedContentTypes.map((type2) => type2.uid));
333
- const activeContentTypes = config2.selectedContentTypes.filter((type2) => contentTypeUids.has(type2.uid));
334
- const displayConfig = {
335
- ...config2,
336
- selectedContentTypes: activeContentTypes
337
- };
338
- setConfigData(displayConfig);
339
- } catch (error) {
340
- setFetchError(error.message);
341
- } finally {
342
- setLoading(false);
343
- }
344
- };
345
- fetchData();
346
- }, []);
347
- async function setConfig(body) {
348
- try {
349
- await put(`/${PLUGIN_ID}/config`, { ...body });
350
- } catch (error) {
351
- throw error;
352
- }
353
- }
354
- return { config, loading, fetchError, setConfig };
355
- }
356
- function _extends() {
357
- return _extends = Object.assign ? Object.assign.bind() : function(n) {
358
- for (var e = 1; e < arguments.length; e++) {
359
- var t = arguments[e];
360
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
361
- }
362
- return n;
363
- }, _extends.apply(null, arguments);
364
- }
365
- function $e42e1063c40fb3ef$export$b9ecd428b558ff10(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
366
- return function handleEvent(event) {
367
- originalEventHandler === null || originalEventHandler === void 0 || originalEventHandler(event);
368
- if (checkForDefaultPrevented === false || !event.defaultPrevented) return ourEventHandler === null || ourEventHandler === void 0 ? void 0 : ourEventHandler(event);
369
- };
370
- }
371
- function $6ed0406888f73fc4$var$setRef(ref, value) {
372
- if (typeof ref === "function") ref(value);
373
- else if (ref !== null && ref !== void 0) ref.current = value;
374
- }
375
- function $6ed0406888f73fc4$export$43e446d32b3d21af(...refs) {
376
- return (node) => refs.forEach(
377
- (ref) => $6ed0406888f73fc4$var$setRef(ref, node)
378
- );
379
- }
380
- function $6ed0406888f73fc4$export$c7b2cbe3552a0d05(...refs) {
381
- return useCallback($6ed0406888f73fc4$export$43e446d32b3d21af(...refs), refs);
382
- }
383
- function $c512c27ab02ef895$export$50c7b4e9d9f19c1(scopeName, createContextScopeDeps = []) {
384
- let defaultContexts = [];
385
- function $c512c27ab02ef895$export$fd42f52fd3ae1109(rootComponentName, defaultContext) {
386
- const BaseContext = /* @__PURE__ */ createContext(defaultContext);
387
- const index2 = defaultContexts.length;
388
- defaultContexts = [
389
- ...defaultContexts,
390
- defaultContext
391
- ];
392
- function Provider(props) {
393
- const { scope, children, ...context } = props;
394
- const Context = (scope === null || scope === void 0 ? void 0 : scope[scopeName][index2]) || BaseContext;
395
- const value = useMemo(
396
- () => context,
397
- Object.values(context)
398
- );
399
- return /* @__PURE__ */ createElement(Context.Provider, {
400
- value
401
- }, children);
402
- }
403
- function useContext$1(consumerName, scope) {
404
- const Context = (scope === null || scope === void 0 ? void 0 : scope[scopeName][index2]) || BaseContext;
405
- const context = useContext(Context);
406
- if (context) return context;
407
- if (defaultContext !== void 0) return defaultContext;
408
- throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
409
- }
410
- Provider.displayName = rootComponentName + "Provider";
411
- return [
412
- Provider,
413
- useContext$1
414
- ];
415
- }
416
- const createScope = () => {
417
- const scopeContexts = defaultContexts.map((defaultContext) => {
418
- return /* @__PURE__ */ createContext(defaultContext);
419
- });
420
- return function useScope(scope) {
421
- const contexts = (scope === null || scope === void 0 ? void 0 : scope[scopeName]) || scopeContexts;
422
- return useMemo(
423
- () => ({
424
- [`__scope${scopeName}`]: {
425
- ...scope,
426
- [scopeName]: contexts
427
- }
428
- }),
429
- [
430
- scope,
431
- contexts
432
- ]
433
- );
434
- };
435
- };
436
- createScope.scopeName = scopeName;
437
- return [
438
- $c512c27ab02ef895$export$fd42f52fd3ae1109,
439
- $c512c27ab02ef895$var$composeContextScopes(createScope, ...createContextScopeDeps)
440
- ];
441
- }
442
- function $c512c27ab02ef895$var$composeContextScopes(...scopes) {
443
- const baseScope = scopes[0];
444
- if (scopes.length === 1) return baseScope;
445
- const createScope1 = () => {
446
- const scopeHooks = scopes.map(
447
- (createScope) => ({
448
- useScope: createScope(),
449
- scopeName: createScope.scopeName
450
- })
451
- );
452
- return function useComposedScopes(overrideScopes) {
453
- const nextScopes1 = scopeHooks.reduce((nextScopes, { useScope, scopeName }) => {
454
- const scopeProps = useScope(overrideScopes);
455
- const currentScope = scopeProps[`__scope${scopeName}`];
456
- return {
457
- ...nextScopes,
458
- ...currentScope
459
- };
460
- }, {});
461
- return useMemo(
462
- () => ({
463
- [`__scope${baseScope.scopeName}`]: nextScopes1
464
- }),
465
- [
466
- nextScopes1
467
- ]
468
- );
469
- };
470
- };
471
- createScope1.scopeName = baseScope.scopeName;
472
- return createScope1;
473
- }
474
- const $5e63c961fc1ce211$export$8c6ed5c666ac1360 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
475
- const { children, ...slotProps } = props;
476
- const childrenArray = Children.toArray(children);
477
- const slottable = childrenArray.find($5e63c961fc1ce211$var$isSlottable);
478
- if (slottable) {
479
- const newElement = slottable.props.children;
480
- const newChildren = childrenArray.map((child) => {
481
- if (child === slottable) {
482
- if (Children.count(newElement) > 1) return Children.only(null);
483
- return /* @__PURE__ */ isValidElement(newElement) ? newElement.props.children : null;
484
- } else return child;
485
- });
486
- return /* @__PURE__ */ createElement($5e63c961fc1ce211$var$SlotClone, _extends({}, slotProps, {
487
- ref: forwardedRef
488
- }), /* @__PURE__ */ isValidElement(newElement) ? /* @__PURE__ */ cloneElement(newElement, void 0, newChildren) : null);
489
- }
490
- return /* @__PURE__ */ createElement($5e63c961fc1ce211$var$SlotClone, _extends({}, slotProps, {
491
- ref: forwardedRef
492
- }), children);
493
- });
494
- $5e63c961fc1ce211$export$8c6ed5c666ac1360.displayName = "Slot";
495
- const $5e63c961fc1ce211$var$SlotClone = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
496
- const { children, ...slotProps } = props;
497
- if (/* @__PURE__ */ isValidElement(children)) return /* @__PURE__ */ cloneElement(children, {
498
- ...$5e63c961fc1ce211$var$mergeProps(slotProps, children.props),
499
- ref: forwardedRef ? $6ed0406888f73fc4$export$43e446d32b3d21af(forwardedRef, children.ref) : children.ref
500
- });
501
- return Children.count(children) > 1 ? Children.only(null) : null;
502
- });
503
- $5e63c961fc1ce211$var$SlotClone.displayName = "SlotClone";
504
- const $5e63c961fc1ce211$export$d9f1ccf0bdb05d45 = ({ children }) => {
505
- return /* @__PURE__ */ createElement(Fragment, null, children);
506
- };
507
- function $5e63c961fc1ce211$var$isSlottable(child) {
508
- return /* @__PURE__ */ isValidElement(child) && child.type === $5e63c961fc1ce211$export$d9f1ccf0bdb05d45;
509
- }
510
- function $5e63c961fc1ce211$var$mergeProps(slotProps, childProps) {
511
- const overrideProps = {
512
- ...childProps
513
- };
514
- for (const propName in childProps) {
515
- const slotPropValue = slotProps[propName];
516
- const childPropValue = childProps[propName];
517
- const isHandler = /^on[A-Z]/.test(propName);
518
- if (isHandler) {
519
- if (slotPropValue && childPropValue) overrideProps[propName] = (...args) => {
520
- childPropValue(...args);
521
- slotPropValue(...args);
522
- };
523
- else if (slotPropValue) overrideProps[propName] = slotPropValue;
524
- } else if (propName === "style") overrideProps[propName] = {
525
- ...slotPropValue,
526
- ...childPropValue
527
- };
528
- else if (propName === "className") overrideProps[propName] = [
529
- slotPropValue,
530
- childPropValue
531
- ].filter(Boolean).join(" ");
532
- }
533
- return {
534
- ...slotProps,
535
- ...overrideProps
536
- };
537
- }
538
- const $8927f6f2acc4f386$var$NODES = [
539
- "a",
540
- "button",
541
- "div",
542
- "form",
543
- "h2",
544
- "h3",
545
- "img",
546
- "input",
547
- "label",
548
- "li",
549
- "nav",
550
- "ol",
551
- "p",
552
- "span",
553
- "svg",
554
- "ul"
555
- ];
556
- const $8927f6f2acc4f386$export$250ffa63cdc0d034 = $8927f6f2acc4f386$var$NODES.reduce((primitive, node) => {
557
- const Node2 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
558
- const { asChild, ...primitiveProps } = props;
559
- const Comp = asChild ? $5e63c961fc1ce211$export$8c6ed5c666ac1360 : node;
560
- useEffect(() => {
561
- window[Symbol.for("radix-ui")] = true;
562
- }, []);
563
- return /* @__PURE__ */ createElement(Comp, _extends({}, primitiveProps, {
564
- ref: forwardedRef
565
- }));
566
- });
567
- Node2.displayName = `Primitive.${node}`;
568
- return {
569
- ...primitive,
570
- [node]: Node2
571
- };
572
- }, {});
573
- function $8927f6f2acc4f386$export$6d1a0317bde7de7f(target, event) {
574
- if (target) flushSync(
575
- () => target.dispatchEvent(event)
576
- );
577
- }
578
- function $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(callback) {
579
- const callbackRef = useRef(callback);
580
- useEffect(() => {
581
- callbackRef.current = callback;
582
- });
583
- return useMemo(
584
- () => (...args) => {
585
- var _callbackRef$current;
586
- return (_callbackRef$current = callbackRef.current) === null || _callbackRef$current === void 0 ? void 0 : _callbackRef$current.call(callbackRef, ...args);
587
- },
588
- []
589
- );
590
- }
591
- function $addc16e1bbe58fd0$export$3a72a57244d6e765(onEscapeKeyDownProp, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
592
- const onEscapeKeyDown = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onEscapeKeyDownProp);
593
- useEffect(() => {
594
- const handleKeyDown = (event) => {
595
- if (event.key === "Escape") onEscapeKeyDown(event);
596
- };
597
- ownerDocument.addEventListener("keydown", handleKeyDown);
598
- return () => ownerDocument.removeEventListener("keydown", handleKeyDown);
599
- }, [
600
- onEscapeKeyDown,
601
- ownerDocument
602
- ]);
603
- }
604
- const $5cb92bef7577960e$var$CONTEXT_UPDATE = "dismissableLayer.update";
605
- const $5cb92bef7577960e$var$POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
606
- const $5cb92bef7577960e$var$FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
607
- let $5cb92bef7577960e$var$originalBodyPointerEvents;
608
- const $5cb92bef7577960e$var$DismissableLayerContext = /* @__PURE__ */ createContext({
609
- layers: /* @__PURE__ */ new Set(),
610
- layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
611
- branches: /* @__PURE__ */ new Set()
612
- });
613
- const $5cb92bef7577960e$export$177fb62ff3ec1f22 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
614
- var _node$ownerDocument;
615
- const { disableOutsidePointerEvents = false, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, onDismiss, ...layerProps } = props;
616
- const context = useContext($5cb92bef7577960e$var$DismissableLayerContext);
617
- const [node1, setNode] = useState(null);
618
- const ownerDocument = (_node$ownerDocument = node1 === null || node1 === void 0 ? void 0 : node1.ownerDocument) !== null && _node$ownerDocument !== void 0 ? _node$ownerDocument : globalThis === null || globalThis === void 0 ? void 0 : globalThis.document;
619
- const [, force] = useState({});
620
- const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(
621
- forwardedRef,
622
- (node) => setNode(node)
623
- );
624
- const layers = Array.from(context.layers);
625
- const [highestLayerWithOutsidePointerEventsDisabled] = [
626
- ...context.layersWithOutsidePointerEventsDisabled
627
- ].slice(-1);
628
- const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
629
- const index2 = node1 ? layers.indexOf(node1) : -1;
630
- const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
631
- const isPointerEventsEnabled = index2 >= highestLayerWithOutsidePointerEventsDisabledIndex;
632
- const pointerDownOutside = $5cb92bef7577960e$var$usePointerDownOutside((event) => {
633
- const target = event.target;
634
- const isPointerDownOnBranch = [
635
- ...context.branches
636
- ].some(
637
- (branch) => branch.contains(target)
638
- );
639
- if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
640
- onPointerDownOutside === null || onPointerDownOutside === void 0 || onPointerDownOutside(event);
641
- onInteractOutside === null || onInteractOutside === void 0 || onInteractOutside(event);
642
- if (!event.defaultPrevented) onDismiss === null || onDismiss === void 0 || onDismiss();
643
- }, ownerDocument);
644
- const focusOutside = $5cb92bef7577960e$var$useFocusOutside((event) => {
645
- const target = event.target;
646
- const isFocusInBranch = [
647
- ...context.branches
648
- ].some(
649
- (branch) => branch.contains(target)
650
- );
651
- if (isFocusInBranch) return;
652
- onFocusOutside === null || onFocusOutside === void 0 || onFocusOutside(event);
653
- onInteractOutside === null || onInteractOutside === void 0 || onInteractOutside(event);
654
- if (!event.defaultPrevented) onDismiss === null || onDismiss === void 0 || onDismiss();
655
- }, ownerDocument);
656
- $addc16e1bbe58fd0$export$3a72a57244d6e765((event) => {
657
- const isHighestLayer = index2 === context.layers.size - 1;
658
- if (!isHighestLayer) return;
659
- onEscapeKeyDown === null || onEscapeKeyDown === void 0 || onEscapeKeyDown(event);
660
- if (!event.defaultPrevented && onDismiss) {
661
- event.preventDefault();
662
- onDismiss();
663
- }
664
- }, ownerDocument);
665
- useEffect(() => {
666
- if (!node1) return;
667
- if (disableOutsidePointerEvents) {
668
- if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
669
- $5cb92bef7577960e$var$originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
670
- ownerDocument.body.style.pointerEvents = "none";
671
- }
672
- context.layersWithOutsidePointerEventsDisabled.add(node1);
673
- }
674
- context.layers.add(node1);
675
- $5cb92bef7577960e$var$dispatchUpdate();
676
- return () => {
677
- if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) ownerDocument.body.style.pointerEvents = $5cb92bef7577960e$var$originalBodyPointerEvents;
678
- };
679
- }, [
680
- node1,
681
- ownerDocument,
682
- disableOutsidePointerEvents,
683
- context
684
- ]);
685
- useEffect(() => {
686
- return () => {
687
- if (!node1) return;
688
- context.layers.delete(node1);
689
- context.layersWithOutsidePointerEventsDisabled.delete(node1);
690
- $5cb92bef7577960e$var$dispatchUpdate();
691
- };
692
- }, [
693
- node1,
694
- context
695
- ]);
696
- useEffect(() => {
697
- const handleUpdate = () => force({});
698
- document.addEventListener($5cb92bef7577960e$var$CONTEXT_UPDATE, handleUpdate);
699
- return () => document.removeEventListener($5cb92bef7577960e$var$CONTEXT_UPDATE, handleUpdate);
700
- }, []);
701
- return /* @__PURE__ */ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({}, layerProps, {
702
- ref: composedRefs,
703
- style: {
704
- pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
705
- ...props.style
706
- },
707
- onFocusCapture: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onFocusCapture, focusOutside.onFocusCapture),
708
- onBlurCapture: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onBlurCapture, focusOutside.onBlurCapture),
709
- onPointerDownCapture: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onPointerDownCapture, pointerDownOutside.onPointerDownCapture)
710
- }));
711
- });
712
- function $5cb92bef7577960e$var$usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
713
- const handlePointerDownOutside = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onPointerDownOutside);
714
- const isPointerInsideReactTreeRef = useRef(false);
715
- const handleClickRef = useRef(() => {
716
- });
717
- useEffect(() => {
718
- const handlePointerDown = (event) => {
719
- if (event.target && !isPointerInsideReactTreeRef.current) {
720
- let handleAndDispatchPointerDownOutsideEvent = function() {
721
- $5cb92bef7577960e$var$handleAndDispatchCustomEvent($5cb92bef7577960e$var$POINTER_DOWN_OUTSIDE, handlePointerDownOutside, eventDetail, {
722
- discrete: true
723
- });
724
- };
725
- const eventDetail = {
726
- originalEvent: event
727
- };
728
- if (event.pointerType === "touch") {
729
- ownerDocument.removeEventListener("click", handleClickRef.current);
730
- handleClickRef.current = handleAndDispatchPointerDownOutsideEvent;
731
- ownerDocument.addEventListener("click", handleClickRef.current, {
732
- once: true
733
- });
734
- } else handleAndDispatchPointerDownOutsideEvent();
735
- } else
736
- ownerDocument.removeEventListener("click", handleClickRef.current);
737
- isPointerInsideReactTreeRef.current = false;
738
- };
739
- const timerId = window.setTimeout(() => {
740
- ownerDocument.addEventListener("pointerdown", handlePointerDown);
741
- }, 0);
742
- return () => {
743
- window.clearTimeout(timerId);
744
- ownerDocument.removeEventListener("pointerdown", handlePointerDown);
745
- ownerDocument.removeEventListener("click", handleClickRef.current);
746
- };
747
- }, [
748
- ownerDocument,
749
- handlePointerDownOutside
750
- ]);
751
- return {
752
- // ensures we check React component tree (not just DOM tree)
753
- onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
754
- };
755
- }
756
- function $5cb92bef7577960e$var$useFocusOutside(onFocusOutside, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
757
- const handleFocusOutside = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onFocusOutside);
758
- const isFocusInsideReactTreeRef = useRef(false);
759
- useEffect(() => {
760
- const handleFocus = (event) => {
761
- if (event.target && !isFocusInsideReactTreeRef.current) {
762
- const eventDetail = {
763
- originalEvent: event
764
- };
765
- $5cb92bef7577960e$var$handleAndDispatchCustomEvent($5cb92bef7577960e$var$FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
766
- discrete: false
767
- });
768
- }
769
- };
770
- ownerDocument.addEventListener("focusin", handleFocus);
771
- return () => ownerDocument.removeEventListener("focusin", handleFocus);
772
- }, [
773
- ownerDocument,
774
- handleFocusOutside
775
- ]);
776
- return {
777
- onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
778
- onBlurCapture: () => isFocusInsideReactTreeRef.current = false
779
- };
780
- }
781
- function $5cb92bef7577960e$var$dispatchUpdate() {
782
- const event = new CustomEvent($5cb92bef7577960e$var$CONTEXT_UPDATE);
783
- document.dispatchEvent(event);
784
- }
785
- function $5cb92bef7577960e$var$handleAndDispatchCustomEvent(name2, handler, detail, { discrete }) {
786
- const target = detail.originalEvent.target;
787
- const event = new CustomEvent(name2, {
788
- bubbles: false,
789
- cancelable: true,
790
- detail
791
- });
792
- if (handler) target.addEventListener(name2, handler, {
793
- once: true
794
- });
795
- if (discrete) $8927f6f2acc4f386$export$6d1a0317bde7de7f(target, event);
796
- else target.dispatchEvent(event);
797
- }
798
- const $9f79659886946c16$export$e5c5a5f917a5871c = Boolean(globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) ? useLayoutEffect : () => {
799
- };
800
- const $1746a345f3d73bb7$var$useReactId = React["useId".toString()] || (() => void 0);
801
- let $1746a345f3d73bb7$var$count = 0;
802
- function $1746a345f3d73bb7$export$f680877a34711e37(deterministicId) {
803
- const [id, setId] = React.useState($1746a345f3d73bb7$var$useReactId());
804
- $9f79659886946c16$export$e5c5a5f917a5871c(() => {
805
- setId(
806
- (reactId) => reactId !== null && reactId !== void 0 ? reactId : String($1746a345f3d73bb7$var$count++)
807
- );
808
- }, [
809
- deterministicId
810
- ]);
811
- return id ? `radix-${id}` : "";
812
- }
813
- const sides = ["top", "right", "bottom", "left"];
814
- const min = Math.min;
815
- const max = Math.max;
816
- const round = Math.round;
817
- const floor = Math.floor;
818
- const createCoords = (v) => ({
819
- x: v,
820
- y: v
821
- });
822
- const oppositeSideMap = {
823
- left: "right",
824
- right: "left",
825
- bottom: "top",
826
- top: "bottom"
827
- };
828
- const oppositeAlignmentMap = {
829
- start: "end",
830
- end: "start"
831
- };
832
- function clamp(start, value, end) {
833
- return max(start, min(value, end));
834
- }
835
- function evaluate(value, param) {
836
- return typeof value === "function" ? value(param) : value;
837
- }
838
- function getSide(placement) {
839
- return placement.split("-")[0];
840
- }
841
- function getAlignment(placement) {
842
- return placement.split("-")[1];
843
- }
844
- function getOppositeAxis(axis) {
845
- return axis === "x" ? "y" : "x";
846
- }
847
- function getAxisLength(axis) {
848
- return axis === "y" ? "height" : "width";
849
- }
850
- function getSideAxis(placement) {
851
- return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x";
852
- }
853
- function getAlignmentAxis(placement) {
854
- return getOppositeAxis(getSideAxis(placement));
855
- }
856
- function getAlignmentSides(placement, rects, rtl) {
857
- if (rtl === void 0) {
858
- rtl = false;
859
- }
860
- const alignment = getAlignment(placement);
861
- const alignmentAxis = getAlignmentAxis(placement);
862
- const length = getAxisLength(alignmentAxis);
863
- let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
864
- if (rects.reference[length] > rects.floating[length]) {
865
- mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
866
- }
867
- return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
868
- }
869
- function getExpandedPlacements(placement) {
870
- const oppositePlacement = getOppositePlacement(placement);
871
- return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
872
- }
873
- function getOppositeAlignmentPlacement(placement) {
874
- return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
875
- }
876
- function getSideList(side, isStart, rtl) {
877
- const lr = ["left", "right"];
878
- const rl = ["right", "left"];
879
- const tb = ["top", "bottom"];
880
- const bt = ["bottom", "top"];
881
- switch (side) {
882
- case "top":
883
- case "bottom":
884
- if (rtl) return isStart ? rl : lr;
885
- return isStart ? lr : rl;
886
- case "left":
887
- case "right":
888
- return isStart ? tb : bt;
889
- default:
890
- return [];
891
- }
892
- }
893
- function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
894
- const alignment = getAlignment(placement);
895
- let list = getSideList(getSide(placement), direction === "start", rtl);
896
- if (alignment) {
897
- list = list.map((side) => side + "-" + alignment);
898
- if (flipAlignment) {
899
- list = list.concat(list.map(getOppositeAlignmentPlacement));
900
- }
901
- }
902
- return list;
903
- }
904
- function getOppositePlacement(placement) {
905
- return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
906
- }
907
- function expandPaddingObject(padding) {
908
- return {
909
- top: 0,
910
- right: 0,
911
- bottom: 0,
912
- left: 0,
913
- ...padding
914
- };
915
- }
916
- function getPaddingObject(padding) {
917
- return typeof padding !== "number" ? expandPaddingObject(padding) : {
918
- top: padding,
919
- right: padding,
920
- bottom: padding,
921
- left: padding
922
- };
923
- }
924
- function rectToClientRect(rect) {
925
- const {
926
- x,
927
- y,
928
- width,
929
- height
930
- } = rect;
931
- return {
932
- width,
933
- height,
934
- top: y,
935
- left: x,
936
- right: x + width,
937
- bottom: y + height,
938
- x,
939
- y
940
- };
941
- }
942
- function computeCoordsFromPlacement(_ref, placement, rtl) {
943
- let {
944
- reference,
945
- floating
946
- } = _ref;
947
- const sideAxis = getSideAxis(placement);
948
- const alignmentAxis = getAlignmentAxis(placement);
949
- const alignLength = getAxisLength(alignmentAxis);
950
- const side = getSide(placement);
951
- const isVertical = sideAxis === "y";
952
- const commonX = reference.x + reference.width / 2 - floating.width / 2;
953
- const commonY = reference.y + reference.height / 2 - floating.height / 2;
954
- const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
955
- let coords;
956
- switch (side) {
957
- case "top":
958
- coords = {
959
- x: commonX,
960
- y: reference.y - floating.height
961
- };
962
- break;
963
- case "bottom":
964
- coords = {
965
- x: commonX,
966
- y: reference.y + reference.height
967
- };
968
- break;
969
- case "right":
970
- coords = {
971
- x: reference.x + reference.width,
972
- y: commonY
973
- };
974
- break;
975
- case "left":
976
- coords = {
977
- x: reference.x - floating.width,
978
- y: commonY
979
- };
980
- break;
981
- default:
982
- coords = {
983
- x: reference.x,
984
- y: reference.y
985
- };
986
- }
987
- switch (getAlignment(placement)) {
988
- case "start":
989
- coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
990
- break;
991
- case "end":
992
- coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
993
- break;
994
- }
995
- return coords;
996
- }
997
- const computePosition$1 = async (reference, floating, config) => {
998
- const {
999
- placement = "bottom",
1000
- strategy = "absolute",
1001
- middleware = [],
1002
- platform: platform2
1003
- } = config;
1004
- const validMiddleware = middleware.filter(Boolean);
1005
- const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
1006
- let rects = await platform2.getElementRects({
1007
- reference,
1008
- floating,
1009
- strategy
1010
- });
1011
- let {
1012
- x,
1013
- y
1014
- } = computeCoordsFromPlacement(rects, placement, rtl);
1015
- let statefulPlacement = placement;
1016
- let middlewareData = {};
1017
- let resetCount = 0;
1018
- for (let i = 0; i < validMiddleware.length; i++) {
1019
- const {
1020
- name: name2,
1021
- fn
1022
- } = validMiddleware[i];
1023
- const {
1024
- x: nextX,
1025
- y: nextY,
1026
- data,
1027
- reset
1028
- } = await fn({
1029
- x,
1030
- y,
1031
- initialPlacement: placement,
1032
- placement: statefulPlacement,
1033
- strategy,
1034
- middlewareData,
1035
- rects,
1036
- platform: platform2,
1037
- elements: {
1038
- reference,
1039
- floating
1040
- }
1041
- });
1042
- x = nextX != null ? nextX : x;
1043
- y = nextY != null ? nextY : y;
1044
- middlewareData = {
1045
- ...middlewareData,
1046
- [name2]: {
1047
- ...middlewareData[name2],
1048
- ...data
1049
- }
1050
- };
1051
- if (reset && resetCount <= 50) {
1052
- resetCount++;
1053
- if (typeof reset === "object") {
1054
- if (reset.placement) {
1055
- statefulPlacement = reset.placement;
1056
- }
1057
- if (reset.rects) {
1058
- rects = reset.rects === true ? await platform2.getElementRects({
1059
- reference,
1060
- floating,
1061
- strategy
1062
- }) : reset.rects;
1063
- }
1064
- ({
1065
- x,
1066
- y
1067
- } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
1068
- }
1069
- i = -1;
1070
- }
1071
- }
1072
- return {
1073
- x,
1074
- y,
1075
- placement: statefulPlacement,
1076
- strategy,
1077
- middlewareData
1078
- };
1079
- };
1080
- async function detectOverflow(state, options) {
1081
- var _await$platform$isEle;
1082
- if (options === void 0) {
1083
- options = {};
1084
- }
1085
- const {
1086
- x,
1087
- y,
1088
- platform: platform2,
1089
- rects,
1090
- elements,
1091
- strategy
1092
- } = state;
1093
- const {
1094
- boundary = "clippingAncestors",
1095
- rootBoundary = "viewport",
1096
- elementContext = "floating",
1097
- altBoundary = false,
1098
- padding = 0
1099
- } = evaluate(options, state);
1100
- const paddingObject = getPaddingObject(padding);
1101
- const altContext = elementContext === "floating" ? "reference" : "floating";
1102
- const element = elements[altBoundary ? altContext : elementContext];
1103
- const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
1104
- 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)),
1105
- boundary,
1106
- rootBoundary,
1107
- strategy
1108
- }));
1109
- const rect = elementContext === "floating" ? {
1110
- x,
1111
- y,
1112
- width: rects.floating.width,
1113
- height: rects.floating.height
1114
- } : rects.reference;
1115
- const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
1116
- const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
1117
- x: 1,
1118
- y: 1
1119
- } : {
1120
- x: 1,
1121
- y: 1
1122
- };
1123
- const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
1124
- elements,
1125
- rect,
1126
- offsetParent,
1127
- strategy
1128
- }) : rect);
1129
- return {
1130
- top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
1131
- bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
1132
- left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
1133
- right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
1134
- };
1135
- }
1136
- const arrow$3 = (options) => ({
1137
- name: "arrow",
1138
- options,
1139
- async fn(state) {
1140
- const {
1141
- x,
1142
- y,
1143
- placement,
1144
- rects,
1145
- platform: platform2,
1146
- elements,
1147
- middlewareData
1148
- } = state;
1149
- const {
1150
- element,
1151
- padding = 0
1152
- } = evaluate(options, state) || {};
1153
- if (element == null) {
1154
- return {};
1155
- }
1156
- const paddingObject = getPaddingObject(padding);
1157
- const coords = {
1158
- x,
1159
- y
1160
- };
1161
- const axis = getAlignmentAxis(placement);
1162
- const length = getAxisLength(axis);
1163
- const arrowDimensions = await platform2.getDimensions(element);
1164
- const isYAxis = axis === "y";
1165
- const minProp = isYAxis ? "top" : "left";
1166
- const maxProp = isYAxis ? "bottom" : "right";
1167
- const clientProp = isYAxis ? "clientHeight" : "clientWidth";
1168
- const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
1169
- const startDiff = coords[axis] - rects.reference[axis];
1170
- const arrowOffsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element));
1171
- let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
1172
- if (!clientSize || !await (platform2.isElement == null ? void 0 : platform2.isElement(arrowOffsetParent))) {
1173
- clientSize = elements.floating[clientProp] || rects.floating[length];
1174
- }
1175
- const centerToReference = endDiff / 2 - startDiff / 2;
1176
- const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
1177
- const minPadding = min(paddingObject[minProp], largestPossiblePadding);
1178
- const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
1179
- const min$1 = minPadding;
1180
- const max2 = clientSize - arrowDimensions[length] - maxPadding;
1181
- const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
1182
- const offset2 = clamp(min$1, center, max2);
1183
- const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset2 && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
1184
- const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max2 : 0;
1185
- return {
1186
- [axis]: coords[axis] + alignmentOffset,
1187
- data: {
1188
- [axis]: offset2,
1189
- centerOffset: center - offset2 - alignmentOffset,
1190
- ...shouldAddOffset && {
1191
- alignmentOffset
1192
- }
1193
- },
1194
- reset: shouldAddOffset
1195
- };
1196
- }
1197
- });
1198
- const flip$2 = function(options) {
1199
- if (options === void 0) {
1200
- options = {};
1201
- }
1202
- return {
1203
- name: "flip",
1204
- options,
1205
- async fn(state) {
1206
- var _middlewareData$arrow, _middlewareData$flip;
1207
- const {
1208
- placement,
1209
- middlewareData,
1210
- rects,
1211
- initialPlacement,
1212
- platform: platform2,
1213
- elements
1214
- } = state;
1215
- const {
1216
- mainAxis: checkMainAxis = true,
1217
- crossAxis: checkCrossAxis = true,
1218
- fallbackPlacements: specifiedFallbackPlacements,
1219
- fallbackStrategy = "bestFit",
1220
- fallbackAxisSideDirection = "none",
1221
- flipAlignment = true,
1222
- ...detectOverflowOptions
1223
- } = evaluate(options, state);
1224
- if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
1225
- return {};
1226
- }
1227
- const side = getSide(placement);
1228
- const initialSideAxis = getSideAxis(initialPlacement);
1229
- const isBasePlacement = getSide(initialPlacement) === initialPlacement;
1230
- const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
1231
- const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
1232
- const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
1233
- if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
1234
- fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
1235
- }
1236
- const placements = [initialPlacement, ...fallbackPlacements];
1237
- const overflow = await detectOverflow(state, detectOverflowOptions);
1238
- const overflows = [];
1239
- let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
1240
- if (checkMainAxis) {
1241
- overflows.push(overflow[side]);
1242
- }
1243
- if (checkCrossAxis) {
1244
- const sides2 = getAlignmentSides(placement, rects, rtl);
1245
- overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
1246
- }
1247
- overflowsData = [...overflowsData, {
1248
- placement,
1249
- overflows
1250
- }];
1251
- if (!overflows.every((side2) => side2 <= 0)) {
1252
- var _middlewareData$flip2, _overflowsData$filter;
1253
- const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
1254
- const nextPlacement = placements[nextIndex];
1255
- if (nextPlacement) {
1256
- return {
1257
- data: {
1258
- index: nextIndex,
1259
- overflows: overflowsData
1260
- },
1261
- reset: {
1262
- placement: nextPlacement
1263
- }
1264
- };
1265
- }
1266
- 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;
1267
- if (!resetPlacement) {
1268
- switch (fallbackStrategy) {
1269
- case "bestFit": {
1270
- var _overflowsData$filter2;
1271
- const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
1272
- if (hasFallbackAxisSideDirection) {
1273
- const currentSideAxis = getSideAxis(d.placement);
1274
- return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
1275
- // reading directions favoring greater width.
1276
- currentSideAxis === "y";
1277
- }
1278
- return true;
1279
- }).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];
1280
- if (placement2) {
1281
- resetPlacement = placement2;
1282
- }
1283
- break;
1284
- }
1285
- case "initialPlacement":
1286
- resetPlacement = initialPlacement;
1287
- break;
1288
- }
1289
- }
1290
- if (placement !== resetPlacement) {
1291
- return {
1292
- reset: {
1293
- placement: resetPlacement
1294
- }
1295
- };
1296
- }
1297
- }
1298
- return {};
1299
- }
1300
- };
1301
- };
1302
- function getSideOffsets(overflow, rect) {
1303
- return {
1304
- top: overflow.top - rect.height,
1305
- right: overflow.right - rect.width,
1306
- bottom: overflow.bottom - rect.height,
1307
- left: overflow.left - rect.width
1308
- };
1309
- }
1310
- function isAnySideFullyClipped(overflow) {
1311
- return sides.some((side) => overflow[side] >= 0);
1312
- }
1313
- const hide$2 = function(options) {
1314
- if (options === void 0) {
1315
- options = {};
1316
- }
1317
- return {
1318
- name: "hide",
1319
- options,
1320
- async fn(state) {
1321
- const {
1322
- rects
1323
- } = state;
1324
- const {
1325
- strategy = "referenceHidden",
1326
- ...detectOverflowOptions
1327
- } = evaluate(options, state);
1328
- switch (strategy) {
1329
- case "referenceHidden": {
1330
- const overflow = await detectOverflow(state, {
1331
- ...detectOverflowOptions,
1332
- elementContext: "reference"
1333
- });
1334
- const offsets = getSideOffsets(overflow, rects.reference);
1335
- return {
1336
- data: {
1337
- referenceHiddenOffsets: offsets,
1338
- referenceHidden: isAnySideFullyClipped(offsets)
1339
- }
1340
- };
1341
- }
1342
- case "escaped": {
1343
- const overflow = await detectOverflow(state, {
1344
- ...detectOverflowOptions,
1345
- altBoundary: true
1346
- });
1347
- const offsets = getSideOffsets(overflow, rects.floating);
1348
- return {
1349
- data: {
1350
- escapedOffsets: offsets,
1351
- escaped: isAnySideFullyClipped(offsets)
1352
- }
1353
- };
1354
- }
1355
- default: {
1356
- return {};
1357
- }
1358
- }
1359
- }
1360
- };
1361
- };
1362
- async function convertValueToCoords(state, options) {
1363
- const {
1364
- placement,
1365
- platform: platform2,
1366
- elements
1367
- } = state;
1368
- const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
1369
- const side = getSide(placement);
1370
- const alignment = getAlignment(placement);
1371
- const isVertical = getSideAxis(placement) === "y";
1372
- const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1;
1373
- const crossAxisMulti = rtl && isVertical ? -1 : 1;
1374
- const rawValue = evaluate(options, state);
1375
- let {
1376
- mainAxis,
1377
- crossAxis,
1378
- alignmentAxis
1379
- } = typeof rawValue === "number" ? {
1380
- mainAxis: rawValue,
1381
- crossAxis: 0,
1382
- alignmentAxis: null
1383
- } : {
1384
- mainAxis: rawValue.mainAxis || 0,
1385
- crossAxis: rawValue.crossAxis || 0,
1386
- alignmentAxis: rawValue.alignmentAxis
1387
- };
1388
- if (alignment && typeof alignmentAxis === "number") {
1389
- crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
1390
- }
1391
- return isVertical ? {
1392
- x: crossAxis * crossAxisMulti,
1393
- y: mainAxis * mainAxisMulti
1394
- } : {
1395
- x: mainAxis * mainAxisMulti,
1396
- y: crossAxis * crossAxisMulti
1397
- };
1398
- }
1399
- const offset$2 = function(options) {
1400
- if (options === void 0) {
1401
- options = 0;
1402
- }
1403
- return {
1404
- name: "offset",
1405
- options,
1406
- async fn(state) {
1407
- var _middlewareData$offse, _middlewareData$arrow;
1408
- const {
1409
- x,
1410
- y,
1411
- placement,
1412
- middlewareData
1413
- } = state;
1414
- const diffCoords = await convertValueToCoords(state, options);
1415
- if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
1416
- return {};
1417
- }
1418
- return {
1419
- x: x + diffCoords.x,
1420
- y: y + diffCoords.y,
1421
- data: {
1422
- ...diffCoords,
1423
- placement
1424
- }
1425
- };
1426
- }
1427
- };
1428
- };
1429
- const shift$2 = function(options) {
1430
- if (options === void 0) {
1431
- options = {};
1432
- }
1433
- return {
1434
- name: "shift",
1435
- options,
1436
- async fn(state) {
1437
- const {
1438
- x,
1439
- y,
1440
- placement
1441
- } = state;
1442
- const {
1443
- mainAxis: checkMainAxis = true,
1444
- crossAxis: checkCrossAxis = false,
1445
- limiter = {
1446
- fn: (_ref) => {
1447
- let {
1448
- x: x2,
1449
- y: y2
1450
- } = _ref;
1451
- return {
1452
- x: x2,
1453
- y: y2
1454
- };
1455
- }
1456
- },
1457
- ...detectOverflowOptions
1458
- } = evaluate(options, state);
1459
- const coords = {
1460
- x,
1461
- y
1462
- };
1463
- const overflow = await detectOverflow(state, detectOverflowOptions);
1464
- const crossAxis = getSideAxis(getSide(placement));
1465
- const mainAxis = getOppositeAxis(crossAxis);
1466
- let mainAxisCoord = coords[mainAxis];
1467
- let crossAxisCoord = coords[crossAxis];
1468
- if (checkMainAxis) {
1469
- const minSide = mainAxis === "y" ? "top" : "left";
1470
- const maxSide = mainAxis === "y" ? "bottom" : "right";
1471
- const min2 = mainAxisCoord + overflow[minSide];
1472
- const max2 = mainAxisCoord - overflow[maxSide];
1473
- mainAxisCoord = clamp(min2, mainAxisCoord, max2);
1474
- }
1475
- if (checkCrossAxis) {
1476
- const minSide = crossAxis === "y" ? "top" : "left";
1477
- const maxSide = crossAxis === "y" ? "bottom" : "right";
1478
- const min2 = crossAxisCoord + overflow[minSide];
1479
- const max2 = crossAxisCoord - overflow[maxSide];
1480
- crossAxisCoord = clamp(min2, crossAxisCoord, max2);
1481
- }
1482
- const limitedCoords = limiter.fn({
1483
- ...state,
1484
- [mainAxis]: mainAxisCoord,
1485
- [crossAxis]: crossAxisCoord
1486
- });
1487
- return {
1488
- ...limitedCoords,
1489
- data: {
1490
- x: limitedCoords.x - x,
1491
- y: limitedCoords.y - y,
1492
- enabled: {
1493
- [mainAxis]: checkMainAxis,
1494
- [crossAxis]: checkCrossAxis
1495
- }
1496
- }
1497
- };
1498
- }
1499
- };
1500
- };
1501
- const limitShift$2 = function(options) {
1502
- if (options === void 0) {
1503
- options = {};
1504
- }
1505
- return {
1506
- options,
1507
- fn(state) {
1508
- const {
1509
- x,
1510
- y,
1511
- placement,
1512
- rects,
1513
- middlewareData
1514
- } = state;
1515
- const {
1516
- offset: offset2 = 0,
1517
- mainAxis: checkMainAxis = true,
1518
- crossAxis: checkCrossAxis = true
1519
- } = evaluate(options, state);
1520
- const coords = {
1521
- x,
1522
- y
1523
- };
1524
- const crossAxis = getSideAxis(placement);
1525
- const mainAxis = getOppositeAxis(crossAxis);
1526
- let mainAxisCoord = coords[mainAxis];
1527
- let crossAxisCoord = coords[crossAxis];
1528
- const rawOffset = evaluate(offset2, state);
1529
- const computedOffset = typeof rawOffset === "number" ? {
1530
- mainAxis: rawOffset,
1531
- crossAxis: 0
1532
- } : {
1533
- mainAxis: 0,
1534
- crossAxis: 0,
1535
- ...rawOffset
1536
- };
1537
- if (checkMainAxis) {
1538
- const len = mainAxis === "y" ? "height" : "width";
1539
- const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
1540
- const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
1541
- if (mainAxisCoord < limitMin) {
1542
- mainAxisCoord = limitMin;
1543
- } else if (mainAxisCoord > limitMax) {
1544
- mainAxisCoord = limitMax;
1545
- }
1546
- }
1547
- if (checkCrossAxis) {
1548
- var _middlewareData$offse, _middlewareData$offse2;
1549
- const len = mainAxis === "y" ? "width" : "height";
1550
- const isOriginSide = ["top", "left"].includes(getSide(placement));
1551
- const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
1552
- const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
1553
- if (crossAxisCoord < limitMin) {
1554
- crossAxisCoord = limitMin;
1555
- } else if (crossAxisCoord > limitMax) {
1556
- crossAxisCoord = limitMax;
1557
- }
1558
- }
1559
- return {
1560
- [mainAxis]: mainAxisCoord,
1561
- [crossAxis]: crossAxisCoord
1562
- };
1563
- }
1564
- };
1565
- };
1566
- const size$2 = function(options) {
1567
- if (options === void 0) {
1568
- options = {};
1569
- }
1570
- return {
1571
- name: "size",
1572
- options,
1573
- async fn(state) {
1574
- var _state$middlewareData, _state$middlewareData2;
1575
- const {
1576
- placement,
1577
- rects,
1578
- platform: platform2,
1579
- elements
1580
- } = state;
1581
- const {
1582
- apply = () => {
1583
- },
1584
- ...detectOverflowOptions
1585
- } = evaluate(options, state);
1586
- const overflow = await detectOverflow(state, detectOverflowOptions);
1587
- const side = getSide(placement);
1588
- const alignment = getAlignment(placement);
1589
- const isYAxis = getSideAxis(placement) === "y";
1590
- const {
1591
- width,
1592
- height
1593
- } = rects.floating;
1594
- let heightSide;
1595
- let widthSide;
1596
- if (side === "top" || side === "bottom") {
1597
- heightSide = side;
1598
- widthSide = alignment === (await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
1599
- } else {
1600
- widthSide = side;
1601
- heightSide = alignment === "end" ? "top" : "bottom";
1602
- }
1603
- const maximumClippingHeight = height - overflow.top - overflow.bottom;
1604
- const maximumClippingWidth = width - overflow.left - overflow.right;
1605
- const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
1606
- const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
1607
- const noShift = !state.middlewareData.shift;
1608
- let availableHeight = overflowAvailableHeight;
1609
- let availableWidth = overflowAvailableWidth;
1610
- if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
1611
- availableWidth = maximumClippingWidth;
1612
- }
1613
- if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
1614
- availableHeight = maximumClippingHeight;
1615
- }
1616
- if (noShift && !alignment) {
1617
- const xMin = max(overflow.left, 0);
1618
- const xMax = max(overflow.right, 0);
1619
- const yMin = max(overflow.top, 0);
1620
- const yMax = max(overflow.bottom, 0);
1621
- if (isYAxis) {
1622
- availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
1623
- } else {
1624
- availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
1625
- }
1626
- }
1627
- await apply({
1628
- ...state,
1629
- availableWidth,
1630
- availableHeight
1631
- });
1632
- const nextDimensions = await platform2.getDimensions(elements.floating);
1633
- if (width !== nextDimensions.width || height !== nextDimensions.height) {
1634
- return {
1635
- reset: {
1636
- rects: true
1637
- }
1638
- };
1639
- }
1640
- return {};
1641
- }
1642
- };
1643
- };
1644
- function hasWindow() {
1645
- return typeof window !== "undefined";
1646
- }
1647
- function getNodeName(node) {
1648
- if (isNode(node)) {
1649
- return (node.nodeName || "").toLowerCase();
1650
- }
1651
- return "#document";
1652
- }
1653
- function getWindow(node) {
1654
- var _node$ownerDocument;
1655
- return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1656
- }
1657
- function getDocumentElement(node) {
1658
- var _ref;
1659
- return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1660
- }
1661
- function isNode(value) {
1662
- if (!hasWindow()) {
1663
- return false;
1664
- }
1665
- return value instanceof Node || value instanceof getWindow(value).Node;
1666
- }
1667
- function isElement(value) {
1668
- if (!hasWindow()) {
1669
- return false;
1670
- }
1671
- return value instanceof Element || value instanceof getWindow(value).Element;
1672
- }
1673
- function isHTMLElement(value) {
1674
- if (!hasWindow()) {
1675
- return false;
1676
- }
1677
- return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1678
- }
1679
- function isShadowRoot(value) {
1680
- if (!hasWindow() || typeof ShadowRoot === "undefined") {
1681
- return false;
1682
- }
1683
- return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1684
- }
1685
- function isOverflowElement(element) {
1686
- const {
1687
- overflow,
1688
- overflowX,
1689
- overflowY,
1690
- display
1691
- } = getComputedStyle$1(element);
1692
- return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
1693
- }
1694
- function isTableElement(element) {
1695
- return ["table", "td", "th"].includes(getNodeName(element));
1696
- }
1697
- function isTopLayer(element) {
1698
- return [":popover-open", ":modal"].some((selector) => {
1699
- try {
1700
- return element.matches(selector);
1701
- } catch (e) {
1702
- return false;
1703
- }
1704
- });
1705
- }
1706
- function isContainingBlock(elementOrCss) {
1707
- const webkit = isWebKit();
1708
- const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
1709
- return css.transform !== "none" || css.perspective !== "none" || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || ["transform", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value));
1710
- }
1711
- function getContainingBlock(element) {
1712
- let currentNode = getParentNode(element);
1713
- while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1714
- if (isContainingBlock(currentNode)) {
1715
- return currentNode;
1716
- } else if (isTopLayer(currentNode)) {
1717
- return null;
1718
- }
1719
- currentNode = getParentNode(currentNode);
1720
- }
1721
- return null;
1722
- }
1723
- function isWebKit() {
1724
- if (typeof CSS === "undefined" || !CSS.supports) return false;
1725
- return CSS.supports("-webkit-backdrop-filter", "none");
1726
- }
1727
- function isLastTraversableNode(node) {
1728
- return ["html", "body", "#document"].includes(getNodeName(node));
1729
- }
1730
- function getComputedStyle$1(element) {
1731
- return getWindow(element).getComputedStyle(element);
1732
- }
1733
- function getNodeScroll(element) {
1734
- if (isElement(element)) {
1735
- return {
1736
- scrollLeft: element.scrollLeft,
1737
- scrollTop: element.scrollTop
1738
- };
1739
- }
1740
- return {
1741
- scrollLeft: element.scrollX,
1742
- scrollTop: element.scrollY
1743
- };
1744
- }
1745
- function getParentNode(node) {
1746
- if (getNodeName(node) === "html") {
1747
- return node;
1748
- }
1749
- const result = (
1750
- // Step into the shadow DOM of the parent of a slotted node.
1751
- node.assignedSlot || // DOM Element detected.
1752
- node.parentNode || // ShadowRoot detected.
1753
- isShadowRoot(node) && node.host || // Fallback.
1754
- getDocumentElement(node)
1755
- );
1756
- return isShadowRoot(result) ? result.host : result;
1757
- }
1758
- function getNearestOverflowAncestor(node) {
1759
- const parentNode = getParentNode(node);
1760
- if (isLastTraversableNode(parentNode)) {
1761
- return node.ownerDocument ? node.ownerDocument.body : node.body;
1762
- }
1763
- if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1764
- return parentNode;
1765
- }
1766
- return getNearestOverflowAncestor(parentNode);
1767
- }
1768
- function getOverflowAncestors(node, list, traverseIframes) {
1769
- var _node$ownerDocument2;
1770
- if (list === void 0) {
1771
- list = [];
1772
- }
1773
- if (traverseIframes === void 0) {
1774
- traverseIframes = true;
1775
- }
1776
- const scrollableAncestor = getNearestOverflowAncestor(node);
1777
- const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1778
- const win = getWindow(scrollableAncestor);
1779
- if (isBody) {
1780
- const frameElement = getFrameElement(win);
1781
- return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1782
- }
1783
- return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1784
- }
1785
- function getFrameElement(win) {
1786
- return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1787
- }
1788
- function getCssDimensions(element) {
1789
- const css = getComputedStyle$1(element);
1790
- let width = parseFloat(css.width) || 0;
1791
- let height = parseFloat(css.height) || 0;
1792
- const hasOffset = isHTMLElement(element);
1793
- const offsetWidth = hasOffset ? element.offsetWidth : width;
1794
- const offsetHeight = hasOffset ? element.offsetHeight : height;
1795
- const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
1796
- if (shouldFallback) {
1797
- width = offsetWidth;
1798
- height = offsetHeight;
1799
- }
1800
- return {
1801
- width,
1802
- height,
1803
- $: shouldFallback
1804
- };
1805
- }
1806
- function unwrapElement(element) {
1807
- return !isElement(element) ? element.contextElement : element;
1808
- }
1809
- function getScale(element) {
1810
- const domElement = unwrapElement(element);
1811
- if (!isHTMLElement(domElement)) {
1812
- return createCoords(1);
1813
- }
1814
- const rect = domElement.getBoundingClientRect();
1815
- const {
1816
- width,
1817
- height,
1818
- $
1819
- } = getCssDimensions(domElement);
1820
- let x = ($ ? round(rect.width) : rect.width) / width;
1821
- let y = ($ ? round(rect.height) : rect.height) / height;
1822
- if (!x || !Number.isFinite(x)) {
1823
- x = 1;
1824
- }
1825
- if (!y || !Number.isFinite(y)) {
1826
- y = 1;
1827
- }
1828
- return {
1829
- x,
1830
- y
1831
- };
1832
- }
1833
- const noOffsets = /* @__PURE__ */ createCoords(0);
1834
- function getVisualOffsets(element) {
1835
- const win = getWindow(element);
1836
- if (!isWebKit() || !win.visualViewport) {
1837
- return noOffsets;
1838
- }
1839
- return {
1840
- x: win.visualViewport.offsetLeft,
1841
- y: win.visualViewport.offsetTop
1842
- };
1843
- }
1844
- function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
1845
- if (isFixed === void 0) {
1846
- isFixed = false;
1847
- }
1848
- if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
1849
- return false;
1850
- }
1851
- return isFixed;
1852
- }
1853
- function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
1854
- if (includeScale === void 0) {
1855
- includeScale = false;
1856
- }
1857
- if (isFixedStrategy === void 0) {
1858
- isFixedStrategy = false;
1859
- }
1860
- const clientRect = element.getBoundingClientRect();
1861
- const domElement = unwrapElement(element);
1862
- let scale = createCoords(1);
1863
- if (includeScale) {
1864
- if (offsetParent) {
1865
- if (isElement(offsetParent)) {
1866
- scale = getScale(offsetParent);
1867
- }
1868
- } else {
1869
- scale = getScale(element);
1870
- }
1871
- }
1872
- const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
1873
- let x = (clientRect.left + visualOffsets.x) / scale.x;
1874
- let y = (clientRect.top + visualOffsets.y) / scale.y;
1875
- let width = clientRect.width / scale.x;
1876
- let height = clientRect.height / scale.y;
1877
- if (domElement) {
1878
- const win = getWindow(domElement);
1879
- const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
1880
- let currentWin = win;
1881
- let currentIFrame = getFrameElement(currentWin);
1882
- while (currentIFrame && offsetParent && offsetWin !== currentWin) {
1883
- const iframeScale = getScale(currentIFrame);
1884
- const iframeRect = currentIFrame.getBoundingClientRect();
1885
- const css = getComputedStyle$1(currentIFrame);
1886
- const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
1887
- const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
1888
- x *= iframeScale.x;
1889
- y *= iframeScale.y;
1890
- width *= iframeScale.x;
1891
- height *= iframeScale.y;
1892
- x += left;
1893
- y += top;
1894
- currentWin = getWindow(currentIFrame);
1895
- currentIFrame = getFrameElement(currentWin);
1896
- }
1897
- }
1898
- return rectToClientRect({
1899
- width,
1900
- height,
1901
- x,
1902
- y
1903
- });
1904
- }
1905
- function getWindowScrollBarX(element, rect) {
1906
- const leftScroll = getNodeScroll(element).scrollLeft;
1907
- if (!rect) {
1908
- return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
1909
- }
1910
- return rect.left + leftScroll;
1911
- }
1912
- function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
1913
- if (ignoreScrollbarX === void 0) {
1914
- ignoreScrollbarX = false;
1915
- }
1916
- const htmlRect = documentElement.getBoundingClientRect();
1917
- const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 : (
1918
- // RTL <body> scrollbar.
1919
- getWindowScrollBarX(documentElement, htmlRect)
1920
- ));
1921
- const y = htmlRect.top + scroll.scrollTop;
1922
- return {
1923
- x,
1924
- y
1925
- };
1926
- }
1927
- function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1928
- let {
1929
- elements,
1930
- rect,
1931
- offsetParent,
1932
- strategy
1933
- } = _ref;
1934
- const isFixed = strategy === "fixed";
1935
- const documentElement = getDocumentElement(offsetParent);
1936
- const topLayer = elements ? isTopLayer(elements.floating) : false;
1937
- if (offsetParent === documentElement || topLayer && isFixed) {
1938
- return rect;
1939
- }
1940
- let scroll = {
1941
- scrollLeft: 0,
1942
- scrollTop: 0
1943
- };
1944
- let scale = createCoords(1);
1945
- const offsets = createCoords(0);
1946
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
1947
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1948
- if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
1949
- scroll = getNodeScroll(offsetParent);
1950
- }
1951
- if (isHTMLElement(offsetParent)) {
1952
- const offsetRect = getBoundingClientRect(offsetParent);
1953
- scale = getScale(offsetParent);
1954
- offsets.x = offsetRect.x + offsetParent.clientLeft;
1955
- offsets.y = offsetRect.y + offsetParent.clientTop;
1956
- }
1957
- }
1958
- const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
1959
- return {
1960
- width: rect.width * scale.x,
1961
- height: rect.height * scale.y,
1962
- x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
1963
- y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
1964
- };
1965
- }
1966
- function getClientRects(element) {
1967
- return Array.from(element.getClientRects());
1968
- }
1969
- function getDocumentRect(element) {
1970
- const html = getDocumentElement(element);
1971
- const scroll = getNodeScroll(element);
1972
- const body = element.ownerDocument.body;
1973
- const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
1974
- const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
1975
- let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1976
- const y = -scroll.scrollTop;
1977
- if (getComputedStyle$1(body).direction === "rtl") {
1978
- x += max(html.clientWidth, body.clientWidth) - width;
1979
- }
1980
- return {
1981
- width,
1982
- height,
1983
- x,
1984
- y
1985
- };
1986
- }
1987
- function getViewportRect(element, strategy) {
1988
- const win = getWindow(element);
1989
- const html = getDocumentElement(element);
1990
- const visualViewport = win.visualViewport;
1991
- let width = html.clientWidth;
1992
- let height = html.clientHeight;
1993
- let x = 0;
1994
- let y = 0;
1995
- if (visualViewport) {
1996
- width = visualViewport.width;
1997
- height = visualViewport.height;
1998
- const visualViewportBased = isWebKit();
1999
- if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
2000
- x = visualViewport.offsetLeft;
2001
- y = visualViewport.offsetTop;
2002
- }
2003
- }
2004
- return {
2005
- width,
2006
- height,
2007
- x,
2008
- y
2009
- };
2010
- }
2011
- function getInnerBoundingClientRect(element, strategy) {
2012
- const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
2013
- const top = clientRect.top + element.clientTop;
2014
- const left = clientRect.left + element.clientLeft;
2015
- const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
2016
- const width = element.clientWidth * scale.x;
2017
- const height = element.clientHeight * scale.y;
2018
- const x = left * scale.x;
2019
- const y = top * scale.y;
2020
- return {
2021
- width,
2022
- height,
2023
- x,
2024
- y
2025
- };
2026
- }
2027
- function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
2028
- let rect;
2029
- if (clippingAncestor === "viewport") {
2030
- rect = getViewportRect(element, strategy);
2031
- } else if (clippingAncestor === "document") {
2032
- rect = getDocumentRect(getDocumentElement(element));
2033
- } else if (isElement(clippingAncestor)) {
2034
- rect = getInnerBoundingClientRect(clippingAncestor, strategy);
2035
- } else {
2036
- const visualOffsets = getVisualOffsets(element);
2037
- rect = {
2038
- x: clippingAncestor.x - visualOffsets.x,
2039
- y: clippingAncestor.y - visualOffsets.y,
2040
- width: clippingAncestor.width,
2041
- height: clippingAncestor.height
2042
- };
2043
- }
2044
- return rectToClientRect(rect);
2045
- }
2046
- function hasFixedPositionAncestor(element, stopNode) {
2047
- const parentNode = getParentNode(element);
2048
- if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
2049
- return false;
2050
- }
2051
- return getComputedStyle$1(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
2052
- }
2053
- function getClippingElementAncestors(element, cache) {
2054
- const cachedResult = cache.get(element);
2055
- if (cachedResult) {
2056
- return cachedResult;
2057
- }
2058
- let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
2059
- let currentContainingBlockComputedStyle = null;
2060
- const elementIsFixed = getComputedStyle$1(element).position === "fixed";
2061
- let currentNode = elementIsFixed ? getParentNode(element) : element;
2062
- while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
2063
- const computedStyle = getComputedStyle$1(currentNode);
2064
- const currentNodeIsContaining = isContainingBlock(currentNode);
2065
- if (!currentNodeIsContaining && computedStyle.position === "fixed") {
2066
- currentContainingBlockComputedStyle = null;
2067
- }
2068
- const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
2069
- if (shouldDropCurrentNode) {
2070
- result = result.filter((ancestor) => ancestor !== currentNode);
2071
- } else {
2072
- currentContainingBlockComputedStyle = computedStyle;
2073
- }
2074
- currentNode = getParentNode(currentNode);
2075
- }
2076
- cache.set(element, result);
2077
- return result;
2078
- }
2079
- function getClippingRect(_ref) {
2080
- let {
2081
- element,
2082
- boundary,
2083
- rootBoundary,
2084
- strategy
2085
- } = _ref;
2086
- const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
2087
- const clippingAncestors = [...elementClippingAncestors, rootBoundary];
2088
- const firstClippingAncestor = clippingAncestors[0];
2089
- const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
2090
- const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
2091
- accRect.top = max(rect.top, accRect.top);
2092
- accRect.right = min(rect.right, accRect.right);
2093
- accRect.bottom = min(rect.bottom, accRect.bottom);
2094
- accRect.left = max(rect.left, accRect.left);
2095
- return accRect;
2096
- }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
2097
- return {
2098
- width: clippingRect.right - clippingRect.left,
2099
- height: clippingRect.bottom - clippingRect.top,
2100
- x: clippingRect.left,
2101
- y: clippingRect.top
2102
- };
2103
- }
2104
- function getDimensions(element) {
2105
- const {
2106
- width,
2107
- height
2108
- } = getCssDimensions(element);
2109
- return {
2110
- width,
2111
- height
2112
- };
2113
- }
2114
- function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
2115
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
2116
- const documentElement = getDocumentElement(offsetParent);
2117
- const isFixed = strategy === "fixed";
2118
- const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
2119
- let scroll = {
2120
- scrollLeft: 0,
2121
- scrollTop: 0
2122
- };
2123
- const offsets = createCoords(0);
2124
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2125
- if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
2126
- scroll = getNodeScroll(offsetParent);
2127
- }
2128
- if (isOffsetParentAnElement) {
2129
- const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
2130
- offsets.x = offsetRect.x + offsetParent.clientLeft;
2131
- offsets.y = offsetRect.y + offsetParent.clientTop;
2132
- } else if (documentElement) {
2133
- offsets.x = getWindowScrollBarX(documentElement);
2134
- }
2135
- }
2136
- const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
2137
- const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
2138
- const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
2139
- return {
2140
- x,
2141
- y,
2142
- width: rect.width,
2143
- height: rect.height
2144
- };
2145
- }
2146
- function isStaticPositioned(element) {
2147
- return getComputedStyle$1(element).position === "static";
2148
- }
2149
- function getTrueOffsetParent(element, polyfill) {
2150
- if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") {
2151
- return null;
2152
- }
2153
- if (polyfill) {
2154
- return polyfill(element);
2155
- }
2156
- let rawOffsetParent = element.offsetParent;
2157
- if (getDocumentElement(element) === rawOffsetParent) {
2158
- rawOffsetParent = rawOffsetParent.ownerDocument.body;
2159
- }
2160
- return rawOffsetParent;
2161
- }
2162
- function getOffsetParent(element, polyfill) {
2163
- const win = getWindow(element);
2164
- if (isTopLayer(element)) {
2165
- return win;
2166
- }
2167
- if (!isHTMLElement(element)) {
2168
- let svgOffsetParent = getParentNode(element);
2169
- while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
2170
- if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
2171
- return svgOffsetParent;
2172
- }
2173
- svgOffsetParent = getParentNode(svgOffsetParent);
2174
- }
2175
- return win;
2176
- }
2177
- let offsetParent = getTrueOffsetParent(element, polyfill);
2178
- while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
2179
- offsetParent = getTrueOffsetParent(offsetParent, polyfill);
2180
- }
2181
- if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
2182
- return win;
2183
- }
2184
- return offsetParent || getContainingBlock(element) || win;
2185
- }
2186
- const getElementRects = async function(data) {
2187
- const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
2188
- const getDimensionsFn = this.getDimensions;
2189
- const floatingDimensions = await getDimensionsFn(data.floating);
2190
- return {
2191
- reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
2192
- floating: {
2193
- x: 0,
2194
- y: 0,
2195
- width: floatingDimensions.width,
2196
- height: floatingDimensions.height
2197
- }
2198
- };
2199
- };
2200
- function isRTL(element) {
2201
- return getComputedStyle$1(element).direction === "rtl";
2202
- }
2203
- const platform = {
2204
- convertOffsetParentRelativeRectToViewportRelativeRect,
2205
- getDocumentElement,
2206
- getClippingRect,
2207
- getOffsetParent,
2208
- getElementRects,
2209
- getClientRects,
2210
- getDimensions,
2211
- getScale,
2212
- isElement,
2213
- isRTL
2214
- };
2215
- function observeMove(element, onMove) {
2216
- let io = null;
2217
- let timeoutId;
2218
- const root = getDocumentElement(element);
2219
- function cleanup() {
2220
- var _io;
2221
- clearTimeout(timeoutId);
2222
- (_io = io) == null || _io.disconnect();
2223
- io = null;
2224
- }
2225
- function refresh(skip, threshold) {
2226
- if (skip === void 0) {
2227
- skip = false;
2228
- }
2229
- if (threshold === void 0) {
2230
- threshold = 1;
2231
- }
2232
- cleanup();
2233
- const {
2234
- left,
2235
- top,
2236
- width,
2237
- height
2238
- } = element.getBoundingClientRect();
2239
- if (!skip) {
2240
- onMove();
2241
- }
2242
- if (!width || !height) {
2243
- return;
2244
- }
2245
- const insetTop = floor(top);
2246
- const insetRight = floor(root.clientWidth - (left + width));
2247
- const insetBottom = floor(root.clientHeight - (top + height));
2248
- const insetLeft = floor(left);
2249
- const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
2250
- const options = {
2251
- rootMargin,
2252
- threshold: max(0, min(1, threshold)) || 1
2253
- };
2254
- let isFirstUpdate = true;
2255
- function handleObserve(entries) {
2256
- const ratio = entries[0].intersectionRatio;
2257
- if (ratio !== threshold) {
2258
- if (!isFirstUpdate) {
2259
- return refresh();
2260
- }
2261
- if (!ratio) {
2262
- timeoutId = setTimeout(() => {
2263
- refresh(false, 1e-7);
2264
- }, 1e3);
2265
- } else {
2266
- refresh(false, ratio);
2267
- }
2268
- }
2269
- isFirstUpdate = false;
2270
- }
2271
- try {
2272
- io = new IntersectionObserver(handleObserve, {
2273
- ...options,
2274
- // Handle <iframe>s
2275
- root: root.ownerDocument
2276
- });
2277
- } catch (e) {
2278
- io = new IntersectionObserver(handleObserve, options);
2279
- }
2280
- io.observe(element);
2281
- }
2282
- refresh(true);
2283
- return cleanup;
2284
- }
2285
- function autoUpdate(reference, floating, update, options) {
2286
- if (options === void 0) {
2287
- options = {};
2288
- }
2289
- const {
2290
- ancestorScroll = true,
2291
- ancestorResize = true,
2292
- elementResize = typeof ResizeObserver === "function",
2293
- layoutShift = typeof IntersectionObserver === "function",
2294
- animationFrame = false
2295
- } = options;
2296
- const referenceEl = unwrapElement(reference);
2297
- const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
2298
- ancestors.forEach((ancestor) => {
2299
- ancestorScroll && ancestor.addEventListener("scroll", update, {
2300
- passive: true
2301
- });
2302
- ancestorResize && ancestor.addEventListener("resize", update);
2303
- });
2304
- const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
2305
- let reobserveFrame = -1;
2306
- let resizeObserver = null;
2307
- if (elementResize) {
2308
- resizeObserver = new ResizeObserver((_ref) => {
2309
- let [firstEntry] = _ref;
2310
- if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
2311
- resizeObserver.unobserve(floating);
2312
- cancelAnimationFrame(reobserveFrame);
2313
- reobserveFrame = requestAnimationFrame(() => {
2314
- var _resizeObserver;
2315
- (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
2316
- });
2317
- }
2318
- update();
2319
- });
2320
- if (referenceEl && !animationFrame) {
2321
- resizeObserver.observe(referenceEl);
2322
- }
2323
- resizeObserver.observe(floating);
2324
- }
2325
- let frameId;
2326
- let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
2327
- if (animationFrame) {
2328
- frameLoop();
2329
- }
2330
- function frameLoop() {
2331
- const nextRefRect = getBoundingClientRect(reference);
2332
- if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
2333
- update();
2334
- }
2335
- prevRefRect = nextRefRect;
2336
- frameId = requestAnimationFrame(frameLoop);
2337
- }
2338
- update();
2339
- return () => {
2340
- var _resizeObserver2;
2341
- ancestors.forEach((ancestor) => {
2342
- ancestorScroll && ancestor.removeEventListener("scroll", update);
2343
- ancestorResize && ancestor.removeEventListener("resize", update);
2344
- });
2345
- cleanupIo == null || cleanupIo();
2346
- (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
2347
- resizeObserver = null;
2348
- if (animationFrame) {
2349
- cancelAnimationFrame(frameId);
2350
- }
2351
- };
2352
- }
2353
- const offset$1 = offset$2;
2354
- const shift$1 = shift$2;
2355
- const flip$1 = flip$2;
2356
- const size$1 = size$2;
2357
- const hide$1 = hide$2;
2358
- const arrow$2 = arrow$3;
2359
- const limitShift$1 = limitShift$2;
2360
- const computePosition = (reference, floating, options) => {
2361
- const cache = /* @__PURE__ */ new Map();
2362
- const mergedOptions = {
2363
- platform,
2364
- ...options
2365
- };
2366
- const platformWithCache = {
2367
- ...mergedOptions.platform,
2368
- _c: cache
2369
- };
2370
- return computePosition$1(reference, floating, {
2371
- ...mergedOptions,
2372
- platform: platformWithCache
2373
- });
2374
- };
2375
- var index$1 = typeof document !== "undefined" ? useLayoutEffect : useEffect;
2376
- function deepEqual(a, b) {
2377
- if (a === b) {
2378
- return true;
2379
- }
2380
- if (typeof a !== typeof b) {
2381
- return false;
2382
- }
2383
- if (typeof a === "function" && a.toString() === b.toString()) {
2384
- return true;
2385
- }
2386
- let length;
2387
- let i;
2388
- let keys;
2389
- if (a && b && typeof a === "object") {
2390
- if (Array.isArray(a)) {
2391
- length = a.length;
2392
- if (length !== b.length) return false;
2393
- for (i = length; i-- !== 0; ) {
2394
- if (!deepEqual(a[i], b[i])) {
2395
- return false;
2396
- }
2397
- }
2398
- return true;
2399
- }
2400
- keys = Object.keys(a);
2401
- length = keys.length;
2402
- if (length !== Object.keys(b).length) {
2403
- return false;
2404
- }
2405
- for (i = length; i-- !== 0; ) {
2406
- if (!{}.hasOwnProperty.call(b, keys[i])) {
2407
- return false;
2408
- }
2409
- }
2410
- for (i = length; i-- !== 0; ) {
2411
- const key = keys[i];
2412
- if (key === "_owner" && a.$$typeof) {
2413
- continue;
2414
- }
2415
- if (!deepEqual(a[key], b[key])) {
2416
- return false;
2417
- }
2418
- }
2419
- return true;
2420
- }
2421
- return a !== a && b !== b;
2422
- }
2423
- function getDPR(element) {
2424
- if (typeof window === "undefined") {
2425
- return 1;
2426
- }
2427
- const win = element.ownerDocument.defaultView || window;
2428
- return win.devicePixelRatio || 1;
2429
- }
2430
- function roundByDPR(element, value) {
2431
- const dpr = getDPR(element);
2432
- return Math.round(value * dpr) / dpr;
2433
- }
2434
- function useLatestRef(value) {
2435
- const ref = React.useRef(value);
2436
- index$1(() => {
2437
- ref.current = value;
2438
- });
2439
- return ref;
2440
- }
2441
- function useFloating(options) {
2442
- if (options === void 0) {
2443
- options = {};
2444
- }
2445
- const {
2446
- placement = "bottom",
2447
- strategy = "absolute",
2448
- middleware = [],
2449
- platform: platform2,
2450
- elements: {
2451
- reference: externalReference,
2452
- floating: externalFloating
2453
- } = {},
2454
- transform = true,
2455
- whileElementsMounted,
2456
- open
2457
- } = options;
2458
- const [data, setData] = React.useState({
2459
- x: 0,
2460
- y: 0,
2461
- strategy,
2462
- placement,
2463
- middlewareData: {},
2464
- isPositioned: false
2465
- });
2466
- const [latestMiddleware, setLatestMiddleware] = React.useState(middleware);
2467
- if (!deepEqual(latestMiddleware, middleware)) {
2468
- setLatestMiddleware(middleware);
2469
- }
2470
- const [_reference, _setReference] = React.useState(null);
2471
- const [_floating, _setFloating] = React.useState(null);
2472
- const setReference = React.useCallback((node) => {
2473
- if (node !== referenceRef.current) {
2474
- referenceRef.current = node;
2475
- _setReference(node);
2476
- }
2477
- }, []);
2478
- const setFloating = React.useCallback((node) => {
2479
- if (node !== floatingRef.current) {
2480
- floatingRef.current = node;
2481
- _setFloating(node);
2482
- }
2483
- }, []);
2484
- const referenceEl = externalReference || _reference;
2485
- const floatingEl = externalFloating || _floating;
2486
- const referenceRef = React.useRef(null);
2487
- const floatingRef = React.useRef(null);
2488
- const dataRef = React.useRef(data);
2489
- const hasWhileElementsMounted = whileElementsMounted != null;
2490
- const whileElementsMountedRef = useLatestRef(whileElementsMounted);
2491
- const platformRef = useLatestRef(platform2);
2492
- const openRef = useLatestRef(open);
2493
- const update = React.useCallback(() => {
2494
- if (!referenceRef.current || !floatingRef.current) {
2495
- return;
2496
- }
2497
- const config = {
2498
- placement,
2499
- strategy,
2500
- middleware: latestMiddleware
2501
- };
2502
- if (platformRef.current) {
2503
- config.platform = platformRef.current;
2504
- }
2505
- computePosition(referenceRef.current, floatingRef.current, config).then((data2) => {
2506
- const fullData = {
2507
- ...data2,
2508
- // The floating element's position may be recomputed while it's closed
2509
- // but still mounted (such as when transitioning out). To ensure
2510
- // `isPositioned` will be `false` initially on the next open, avoid
2511
- // setting it to `true` when `open === false` (must be specified).
2512
- isPositioned: openRef.current !== false
2513
- };
2514
- if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
2515
- dataRef.current = fullData;
2516
- ReactDOM.flushSync(() => {
2517
- setData(fullData);
2518
- });
2519
- }
2520
- });
2521
- }, [latestMiddleware, placement, strategy, platformRef, openRef]);
2522
- index$1(() => {
2523
- if (open === false && dataRef.current.isPositioned) {
2524
- dataRef.current.isPositioned = false;
2525
- setData((data2) => ({
2526
- ...data2,
2527
- isPositioned: false
2528
- }));
2529
- }
2530
- }, [open]);
2531
- const isMountedRef = React.useRef(false);
2532
- index$1(() => {
2533
- isMountedRef.current = true;
2534
- return () => {
2535
- isMountedRef.current = false;
2536
- };
2537
- }, []);
2538
- index$1(() => {
2539
- if (referenceEl) referenceRef.current = referenceEl;
2540
- if (floatingEl) floatingRef.current = floatingEl;
2541
- if (referenceEl && floatingEl) {
2542
- if (whileElementsMountedRef.current) {
2543
- return whileElementsMountedRef.current(referenceEl, floatingEl, update);
2544
- }
2545
- update();
2546
- }
2547
- }, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
2548
- const refs = React.useMemo(() => ({
2549
- reference: referenceRef,
2550
- floating: floatingRef,
2551
- setReference,
2552
- setFloating
2553
- }), [setReference, setFloating]);
2554
- const elements = React.useMemo(() => ({
2555
- reference: referenceEl,
2556
- floating: floatingEl
2557
- }), [referenceEl, floatingEl]);
2558
- const floatingStyles = React.useMemo(() => {
2559
- const initialStyles = {
2560
- position: strategy,
2561
- left: 0,
2562
- top: 0
2563
- };
2564
- if (!elements.floating) {
2565
- return initialStyles;
2566
- }
2567
- const x = roundByDPR(elements.floating, data.x);
2568
- const y = roundByDPR(elements.floating, data.y);
2569
- if (transform) {
2570
- return {
2571
- ...initialStyles,
2572
- transform: "translate(" + x + "px, " + y + "px)",
2573
- ...getDPR(elements.floating) >= 1.5 && {
2574
- willChange: "transform"
2575
- }
2576
- };
2577
- }
2578
- return {
2579
- position: strategy,
2580
- left: x,
2581
- top: y
2582
- };
2583
- }, [strategy, transform, elements.floating, data.x, data.y]);
2584
- return React.useMemo(() => ({
2585
- ...data,
2586
- update,
2587
- refs,
2588
- elements,
2589
- floatingStyles
2590
- }), [data, update, refs, elements, floatingStyles]);
2591
- }
2592
- const arrow$1 = (options) => {
2593
- function isRef(value) {
2594
- return {}.hasOwnProperty.call(value, "current");
2595
- }
2596
- return {
2597
- name: "arrow",
2598
- options,
2599
- fn(state) {
2600
- const {
2601
- element,
2602
- padding
2603
- } = typeof options === "function" ? options(state) : options;
2604
- if (element && isRef(element)) {
2605
- if (element.current != null) {
2606
- return arrow$2({
2607
- element: element.current,
2608
- padding
2609
- }).fn(state);
2610
- }
2611
- return {};
2612
- }
2613
- if (element) {
2614
- return arrow$2({
2615
- element,
2616
- padding
2617
- }).fn(state);
2618
- }
2619
- return {};
2620
- }
2621
- };
2622
- };
2623
- const offset = (options, deps) => ({
2624
- ...offset$1(options),
2625
- options: [options, deps]
2626
- });
2627
- const shift = (options, deps) => ({
2628
- ...shift$1(options),
2629
- options: [options, deps]
2630
- });
2631
- const limitShift = (options, deps) => ({
2632
- ...limitShift$1(options),
2633
- options: [options, deps]
2634
- });
2635
- const flip = (options, deps) => ({
2636
- ...flip$1(options),
2637
- options: [options, deps]
2638
- });
2639
- const size = (options, deps) => ({
2640
- ...size$1(options),
2641
- options: [options, deps]
2642
- });
2643
- const hide = (options, deps) => ({
2644
- ...hide$1(options),
2645
- options: [options, deps]
2646
- });
2647
- const arrow = (options, deps) => ({
2648
- ...arrow$1(options),
2649
- options: [options, deps]
2650
- });
2651
- const $7e8f5cd07187803e$export$21b07c8f274aebd5 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
2652
- const { children, width = 10, height = 5, ...arrowProps } = props;
2653
- return /* @__PURE__ */ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.svg, _extends({}, arrowProps, {
2654
- ref: forwardedRef,
2655
- width,
2656
- height,
2657
- viewBox: "0 0 30 10",
2658
- preserveAspectRatio: "none"
2659
- }), props.asChild ? children : /* @__PURE__ */ createElement("polygon", {
2660
- points: "0,0 30,0 15,10"
2661
- }));
2662
- });
2663
- const $7e8f5cd07187803e$export$be92b6f5f03c0fe9 = $7e8f5cd07187803e$export$21b07c8f274aebd5;
2664
- function $db6c3485150b8e66$export$1ab7ae714698c4b8(element) {
2665
- const [size2, setSize] = useState(void 0);
2666
- $9f79659886946c16$export$e5c5a5f917a5871c(() => {
2667
- if (element) {
2668
- setSize({
2669
- width: element.offsetWidth,
2670
- height: element.offsetHeight
2671
- });
2672
- const resizeObserver = new ResizeObserver((entries) => {
2673
- if (!Array.isArray(entries)) return;
2674
- if (!entries.length) return;
2675
- const entry = entries[0];
2676
- let width;
2677
- let height;
2678
- if ("borderBoxSize" in entry) {
2679
- const borderSizeEntry = entry["borderBoxSize"];
2680
- const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
2681
- width = borderSize["inlineSize"];
2682
- height = borderSize["blockSize"];
2683
- } else {
2684
- width = element.offsetWidth;
2685
- height = element.offsetHeight;
2686
- }
2687
- setSize({
2688
- width,
2689
- height
2690
- });
2691
- });
2692
- resizeObserver.observe(element, {
2693
- box: "border-box"
2694
- });
2695
- return () => resizeObserver.unobserve(element);
2696
- } else
2697
- setSize(void 0);
2698
- }, [
2699
- element
2700
- ]);
2701
- return size2;
2702
- }
2703
- const $cf1ac5d9fe0e8206$var$POPPER_NAME = "Popper";
2704
- const [$cf1ac5d9fe0e8206$var$createPopperContext, $cf1ac5d9fe0e8206$export$722aac194ae923] = $c512c27ab02ef895$export$50c7b4e9d9f19c1($cf1ac5d9fe0e8206$var$POPPER_NAME);
2705
- const [$cf1ac5d9fe0e8206$var$PopperProvider, $cf1ac5d9fe0e8206$var$usePopperContext] = $cf1ac5d9fe0e8206$var$createPopperContext($cf1ac5d9fe0e8206$var$POPPER_NAME);
2706
- const $cf1ac5d9fe0e8206$export$badac9ada3a0bdf9 = (props) => {
2707
- const { __scopePopper, children } = props;
2708
- const [anchor, setAnchor] = useState(null);
2709
- return /* @__PURE__ */ createElement($cf1ac5d9fe0e8206$var$PopperProvider, {
2710
- scope: __scopePopper,
2711
- anchor,
2712
- onAnchorChange: setAnchor
2713
- }, children);
2714
- };
2715
- const $cf1ac5d9fe0e8206$var$ANCHOR_NAME = "PopperAnchor";
2716
- const $cf1ac5d9fe0e8206$export$ecd4e1ccab6ed6d = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
2717
- const { __scopePopper, virtualRef, ...anchorProps } = props;
2718
- const context = $cf1ac5d9fe0e8206$var$usePopperContext($cf1ac5d9fe0e8206$var$ANCHOR_NAME, __scopePopper);
2719
- const ref = useRef(null);
2720
- const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, ref);
2721
- useEffect(() => {
2722
- context.onAnchorChange((virtualRef === null || virtualRef === void 0 ? void 0 : virtualRef.current) || ref.current);
2723
- });
2724
- return virtualRef ? null : /* @__PURE__ */ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({}, anchorProps, {
2725
- ref: composedRefs
2726
- }));
2727
- });
2728
- const $cf1ac5d9fe0e8206$var$CONTENT_NAME = "PopperContent";
2729
- const [$cf1ac5d9fe0e8206$var$PopperContentProvider, $cf1ac5d9fe0e8206$var$useContentContext] = $cf1ac5d9fe0e8206$var$createPopperContext($cf1ac5d9fe0e8206$var$CONTENT_NAME);
2730
- const $cf1ac5d9fe0e8206$export$bc4ae5855d3c4fc = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
2731
- var _arrowSize$width, _arrowSize$height, _middlewareData$arrow, _middlewareData$arrow2, _middlewareData$arrow3, _middlewareData$trans, _middlewareData$trans2, _middlewareData$hide;
2732
- const { __scopePopper, side = "bottom", sideOffset = 0, align = "center", alignOffset = 0, arrowPadding = 0, avoidCollisions = true, collisionBoundary = [], collisionPadding: collisionPaddingProp = 0, sticky = "partial", hideWhenDetached = false, updatePositionStrategy = "optimized", onPlaced, ...contentProps } = props;
2733
- const context = $cf1ac5d9fe0e8206$var$usePopperContext($cf1ac5d9fe0e8206$var$CONTENT_NAME, __scopePopper);
2734
- const [content, setContent] = useState(null);
2735
- const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(
2736
- forwardedRef,
2737
- (node) => setContent(node)
2738
- );
2739
- const [arrow$12, setArrow] = useState(null);
2740
- const arrowSize = $db6c3485150b8e66$export$1ab7ae714698c4b8(arrow$12);
2741
- const arrowWidth = (_arrowSize$width = arrowSize === null || arrowSize === void 0 ? void 0 : arrowSize.width) !== null && _arrowSize$width !== void 0 ? _arrowSize$width : 0;
2742
- const arrowHeight = (_arrowSize$height = arrowSize === null || arrowSize === void 0 ? void 0 : arrowSize.height) !== null && _arrowSize$height !== void 0 ? _arrowSize$height : 0;
2743
- const desiredPlacement = side + (align !== "center" ? "-" + align : "");
2744
- const collisionPadding = typeof collisionPaddingProp === "number" ? collisionPaddingProp : {
2745
- top: 0,
2746
- right: 0,
2747
- bottom: 0,
2748
- left: 0,
2749
- ...collisionPaddingProp
2750
- };
2751
- const boundary = Array.isArray(collisionBoundary) ? collisionBoundary : [
2752
- collisionBoundary
2753
- ];
2754
- const hasExplicitBoundaries = boundary.length > 0;
2755
- const detectOverflowOptions = {
2756
- padding: collisionPadding,
2757
- boundary: boundary.filter($cf1ac5d9fe0e8206$var$isNotNull),
2758
- // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
2759
- altBoundary: hasExplicitBoundaries
2760
- };
2761
- const { refs, floatingStyles, placement, isPositioned, middlewareData } = useFloating({
2762
- // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
2763
- strategy: "fixed",
2764
- placement: desiredPlacement,
2765
- whileElementsMounted: (...args) => {
2766
- const cleanup = autoUpdate(...args, {
2767
- animationFrame: updatePositionStrategy === "always"
2768
- });
2769
- return cleanup;
2770
- },
2771
- elements: {
2772
- reference: context.anchor
2773
- },
2774
- middleware: [
2775
- offset({
2776
- mainAxis: sideOffset + arrowHeight,
2777
- alignmentAxis: alignOffset
2778
- }),
2779
- avoidCollisions && shift({
2780
- mainAxis: true,
2781
- crossAxis: false,
2782
- limiter: sticky === "partial" ? limitShift() : void 0,
2783
- ...detectOverflowOptions
2784
- }),
2785
- avoidCollisions && flip({
2786
- ...detectOverflowOptions
2787
- }),
2788
- size({
2789
- ...detectOverflowOptions,
2790
- apply: ({ elements, rects, availableWidth, availableHeight }) => {
2791
- const { width: anchorWidth, height: anchorHeight } = rects.reference;
2792
- const contentStyle = elements.floating.style;
2793
- contentStyle.setProperty("--radix-popper-available-width", `${availableWidth}px`);
2794
- contentStyle.setProperty("--radix-popper-available-height", `${availableHeight}px`);
2795
- contentStyle.setProperty("--radix-popper-anchor-width", `${anchorWidth}px`);
2796
- contentStyle.setProperty("--radix-popper-anchor-height", `${anchorHeight}px`);
2797
- }
2798
- }),
2799
- arrow$12 && arrow({
2800
- element: arrow$12,
2801
- padding: arrowPadding
2802
- }),
2803
- $cf1ac5d9fe0e8206$var$transformOrigin({
2804
- arrowWidth,
2805
- arrowHeight
2806
- }),
2807
- hideWhenDetached && hide({
2808
- strategy: "referenceHidden",
2809
- ...detectOverflowOptions
2810
- })
2811
- ]
2812
- });
2813
- const [placedSide, placedAlign] = $cf1ac5d9fe0e8206$var$getSideAndAlignFromPlacement(placement);
2814
- const handlePlaced = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onPlaced);
2815
- $9f79659886946c16$export$e5c5a5f917a5871c(() => {
2816
- if (isPositioned) handlePlaced === null || handlePlaced === void 0 || handlePlaced();
2817
- }, [
2818
- isPositioned,
2819
- handlePlaced
2820
- ]);
2821
- const arrowX = (_middlewareData$arrow = middlewareData.arrow) === null || _middlewareData$arrow === void 0 ? void 0 : _middlewareData$arrow.x;
2822
- const arrowY = (_middlewareData$arrow2 = middlewareData.arrow) === null || _middlewareData$arrow2 === void 0 ? void 0 : _middlewareData$arrow2.y;
2823
- const cannotCenterArrow = ((_middlewareData$arrow3 = middlewareData.arrow) === null || _middlewareData$arrow3 === void 0 ? void 0 : _middlewareData$arrow3.centerOffset) !== 0;
2824
- const [contentZIndex, setContentZIndex] = useState();
2825
- $9f79659886946c16$export$e5c5a5f917a5871c(() => {
2826
- if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
2827
- }, [
2828
- content
2829
- ]);
2830
- return /* @__PURE__ */ createElement("div", {
2831
- ref: refs.setFloating,
2832
- "data-radix-popper-content-wrapper": "",
2833
- style: {
2834
- ...floatingStyles,
2835
- transform: isPositioned ? floatingStyles.transform : "translate(0, -200%)",
2836
- // keep off the page when measuring
2837
- minWidth: "max-content",
2838
- zIndex: contentZIndex,
2839
- ["--radix-popper-transform-origin"]: [
2840
- (_middlewareData$trans = middlewareData.transformOrigin) === null || _middlewareData$trans === void 0 ? void 0 : _middlewareData$trans.x,
2841
- (_middlewareData$trans2 = middlewareData.transformOrigin) === null || _middlewareData$trans2 === void 0 ? void 0 : _middlewareData$trans2.y
2842
- ].join(" ")
2843
- },
2844
- dir: props.dir
2845
- }, /* @__PURE__ */ createElement($cf1ac5d9fe0e8206$var$PopperContentProvider, {
2846
- scope: __scopePopper,
2847
- placedSide,
2848
- onArrowChange: setArrow,
2849
- arrowX,
2850
- arrowY,
2851
- shouldHideArrow: cannotCenterArrow
2852
- }, /* @__PURE__ */ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
2853
- "data-side": placedSide,
2854
- "data-align": placedAlign
2855
- }, contentProps, {
2856
- ref: composedRefs,
2857
- style: {
2858
- ...contentProps.style,
2859
- // if the PopperContent hasn't been placed yet (not all measurements done)
2860
- // we prevent animations so that users's animation don't kick in too early referring wrong sides
2861
- animation: !isPositioned ? "none" : void 0,
2862
- // hide the content if using the hide middleware and should be hidden
2863
- opacity: (_middlewareData$hide = middlewareData.hide) !== null && _middlewareData$hide !== void 0 && _middlewareData$hide.referenceHidden ? 0 : void 0
2864
- }
2865
- }))));
2866
- });
2867
- const $cf1ac5d9fe0e8206$var$ARROW_NAME = "PopperArrow";
2868
- const $cf1ac5d9fe0e8206$var$OPPOSITE_SIDE = {
2869
- top: "bottom",
2870
- right: "left",
2871
- bottom: "top",
2872
- left: "right"
2873
- };
2874
- const $cf1ac5d9fe0e8206$export$79d62cd4e10a3fd0 = /* @__PURE__ */ forwardRef(function $cf1ac5d9fe0e8206$export$79d62cd4e10a3fd02(props, forwardedRef) {
2875
- const { __scopePopper, ...arrowProps } = props;
2876
- const contentContext = $cf1ac5d9fe0e8206$var$useContentContext($cf1ac5d9fe0e8206$var$ARROW_NAME, __scopePopper);
2877
- const baseSide = $cf1ac5d9fe0e8206$var$OPPOSITE_SIDE[contentContext.placedSide];
2878
- return (
2879
- // we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
2880
- // doesn't report size as we'd expect on SVG elements.
2881
- // it reports their bounding box which is effectively the largest path inside the SVG.
2882
- /* @__PURE__ */ createElement("span", {
2883
- ref: contentContext.onArrowChange,
2884
- style: {
2885
- position: "absolute",
2886
- left: contentContext.arrowX,
2887
- top: contentContext.arrowY,
2888
- [baseSide]: 0,
2889
- transformOrigin: {
2890
- top: "",
2891
- right: "0 0",
2892
- bottom: "center 0",
2893
- left: "100% 0"
2894
- }[contentContext.placedSide],
2895
- transform: {
2896
- top: "translateY(100%)",
2897
- right: "translateY(50%) rotate(90deg) translateX(-50%)",
2898
- bottom: `rotate(180deg)`,
2899
- left: "translateY(50%) rotate(-90deg) translateX(50%)"
2900
- }[contentContext.placedSide],
2901
- visibility: contentContext.shouldHideArrow ? "hidden" : void 0
2902
- }
2903
- }, /* @__PURE__ */ createElement($7e8f5cd07187803e$export$be92b6f5f03c0fe9, _extends({}, arrowProps, {
2904
- ref: forwardedRef,
2905
- style: {
2906
- ...arrowProps.style,
2907
- // ensures the element can be measured correctly (mostly for if SVG)
2908
- display: "block"
2909
- }
2910
- })))
2911
- );
2912
- });
2913
- /* @__PURE__ */ Object.assign($cf1ac5d9fe0e8206$export$79d62cd4e10a3fd0, {
2914
- displayName: $cf1ac5d9fe0e8206$var$ARROW_NAME
2915
- });
2916
- function $cf1ac5d9fe0e8206$var$isNotNull(value) {
2917
- return value !== null;
2918
- }
2919
- const $cf1ac5d9fe0e8206$var$transformOrigin = (options) => ({
2920
- name: "transformOrigin",
2921
- options,
2922
- fn(data) {
2923
- var _middlewareData$arrow4, _middlewareData$arrow5, _middlewareData$arrow6, _middlewareData$arrow7, _middlewareData$arrow8;
2924
- const { placement, rects, middlewareData } = data;
2925
- const cannotCenterArrow = ((_middlewareData$arrow4 = middlewareData.arrow) === null || _middlewareData$arrow4 === void 0 ? void 0 : _middlewareData$arrow4.centerOffset) !== 0;
2926
- const isArrowHidden = cannotCenterArrow;
2927
- const arrowWidth = isArrowHidden ? 0 : options.arrowWidth;
2928
- const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
2929
- const [placedSide, placedAlign] = $cf1ac5d9fe0e8206$var$getSideAndAlignFromPlacement(placement);
2930
- const noArrowAlign = {
2931
- start: "0%",
2932
- center: "50%",
2933
- end: "100%"
2934
- }[placedAlign];
2935
- const arrowXCenter = ((_middlewareData$arrow5 = (_middlewareData$arrow6 = middlewareData.arrow) === null || _middlewareData$arrow6 === void 0 ? void 0 : _middlewareData$arrow6.x) !== null && _middlewareData$arrow5 !== void 0 ? _middlewareData$arrow5 : 0) + arrowWidth / 2;
2936
- const arrowYCenter = ((_middlewareData$arrow7 = (_middlewareData$arrow8 = middlewareData.arrow) === null || _middlewareData$arrow8 === void 0 ? void 0 : _middlewareData$arrow8.y) !== null && _middlewareData$arrow7 !== void 0 ? _middlewareData$arrow7 : 0) + arrowHeight / 2;
2937
- let x = "";
2938
- let y = "";
2939
- if (placedSide === "bottom") {
2940
- x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
2941
- y = `${-arrowHeight}px`;
2942
- } else if (placedSide === "top") {
2943
- x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
2944
- y = `${rects.floating.height + arrowHeight}px`;
2945
- } else if (placedSide === "right") {
2946
- x = `${-arrowHeight}px`;
2947
- y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
2948
- } else if (placedSide === "left") {
2949
- x = `${rects.floating.width + arrowHeight}px`;
2950
- y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
2951
- }
2952
- return {
2953
- data: {
2954
- x,
2955
- y
2956
- }
2957
- };
2958
- }
2959
- });
2960
- function $cf1ac5d9fe0e8206$var$getSideAndAlignFromPlacement(placement) {
2961
- const [side, align = "center"] = placement.split("-");
2962
- return [
2963
- side,
2964
- align
2965
- ];
2966
- }
2967
- const $cf1ac5d9fe0e8206$export$be92b6f5f03c0fe9 = $cf1ac5d9fe0e8206$export$badac9ada3a0bdf9;
2968
- const $cf1ac5d9fe0e8206$export$b688253958b8dfe7 = $cf1ac5d9fe0e8206$export$ecd4e1ccab6ed6d;
2969
- const $cf1ac5d9fe0e8206$export$7c6e2c02157bb7d2 = $cf1ac5d9fe0e8206$export$bc4ae5855d3c4fc;
2970
- const $f1701beae083dbae$export$602eac185826482c = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
2971
- var _globalThis$document;
2972
- const { container = globalThis === null || globalThis === void 0 ? void 0 : (_globalThis$document = globalThis.document) === null || _globalThis$document === void 0 ? void 0 : _globalThis$document.body, ...portalProps } = props;
2973
- return container ? /* @__PURE__ */ ReactDOM__default.createPortal(/* @__PURE__ */ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({}, portalProps, {
2974
- ref: forwardedRef
2975
- })), container) : null;
2976
- });
2977
- function $fe963b355347cc68$export$3e6543de14f8614f(initialState, machine) {
2978
- return useReducer((state, event) => {
2979
- const nextState = machine[state][event];
2980
- return nextState !== null && nextState !== void 0 ? nextState : state;
2981
- }, initialState);
2982
- }
2983
- const $921a889cee6df7e8$export$99c2b779aa4e8b8b = (props) => {
2984
- const { present, children } = props;
2985
- const presence = $921a889cee6df7e8$var$usePresence(present);
2986
- const child = typeof children === "function" ? children({
2987
- present: presence.isPresent
2988
- }) : Children.only(children);
2989
- const ref = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(presence.ref, child.ref);
2990
- const forceMount = typeof children === "function";
2991
- return forceMount || presence.isPresent ? /* @__PURE__ */ cloneElement(child, {
2992
- ref
2993
- }) : null;
2994
- };
2995
- $921a889cee6df7e8$export$99c2b779aa4e8b8b.displayName = "Presence";
2996
- function $921a889cee6df7e8$var$usePresence(present) {
2997
- const [node1, setNode] = useState();
2998
- const stylesRef = useRef({});
2999
- const prevPresentRef = useRef(present);
3000
- const prevAnimationNameRef = useRef("none");
3001
- const initialState = present ? "mounted" : "unmounted";
3002
- const [state, send] = $fe963b355347cc68$export$3e6543de14f8614f(initialState, {
3003
- mounted: {
3004
- UNMOUNT: "unmounted",
3005
- ANIMATION_OUT: "unmountSuspended"
3006
- },
3007
- unmountSuspended: {
3008
- MOUNT: "mounted",
3009
- ANIMATION_END: "unmounted"
3010
- },
3011
- unmounted: {
3012
- MOUNT: "mounted"
3013
- }
3014
- });
3015
- useEffect(() => {
3016
- const currentAnimationName = $921a889cee6df7e8$var$getAnimationName(stylesRef.current);
3017
- prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
3018
- }, [
3019
- state
3020
- ]);
3021
- $9f79659886946c16$export$e5c5a5f917a5871c(() => {
3022
- const styles = stylesRef.current;
3023
- const wasPresent = prevPresentRef.current;
3024
- const hasPresentChanged = wasPresent !== present;
3025
- if (hasPresentChanged) {
3026
- const prevAnimationName = prevAnimationNameRef.current;
3027
- const currentAnimationName = $921a889cee6df7e8$var$getAnimationName(styles);
3028
- if (present) send("MOUNT");
3029
- else if (currentAnimationName === "none" || (styles === null || styles === void 0 ? void 0 : styles.display) === "none")
3030
- send("UNMOUNT");
3031
- else {
3032
- const isAnimating = prevAnimationName !== currentAnimationName;
3033
- if (wasPresent && isAnimating) send("ANIMATION_OUT");
3034
- else send("UNMOUNT");
3035
- }
3036
- prevPresentRef.current = present;
3037
- }
3038
- }, [
3039
- present,
3040
- send
3041
- ]);
3042
- $9f79659886946c16$export$e5c5a5f917a5871c(() => {
3043
- if (node1) {
3044
- const handleAnimationEnd = (event) => {
3045
- const currentAnimationName = $921a889cee6df7e8$var$getAnimationName(stylesRef.current);
3046
- const isCurrentAnimation = currentAnimationName.includes(event.animationName);
3047
- if (event.target === node1 && isCurrentAnimation)
3048
- flushSync(
3049
- () => send("ANIMATION_END")
3050
- );
3051
- };
3052
- const handleAnimationStart = (event) => {
3053
- if (event.target === node1)
3054
- prevAnimationNameRef.current = $921a889cee6df7e8$var$getAnimationName(stylesRef.current);
3055
- };
3056
- node1.addEventListener("animationstart", handleAnimationStart);
3057
- node1.addEventListener("animationcancel", handleAnimationEnd);
3058
- node1.addEventListener("animationend", handleAnimationEnd);
3059
- return () => {
3060
- node1.removeEventListener("animationstart", handleAnimationStart);
3061
- node1.removeEventListener("animationcancel", handleAnimationEnd);
3062
- node1.removeEventListener("animationend", handleAnimationEnd);
3063
- };
3064
- } else
3065
- send("ANIMATION_END");
3066
- }, [
3067
- node1,
3068
- send
3069
- ]);
3070
- return {
3071
- isPresent: [
3072
- "mounted",
3073
- "unmountSuspended"
3074
- ].includes(state),
3075
- ref: useCallback((node) => {
3076
- if (node) stylesRef.current = getComputedStyle(node);
3077
- setNode(node);
3078
- }, [])
3079
- };
3080
- }
3081
- function $921a889cee6df7e8$var$getAnimationName(styles) {
3082
- return (styles === null || styles === void 0 ? void 0 : styles.animationName) || "none";
3083
- }
3084
- function $71cd76cc60e0454e$export$6f32135080cb4c3({ prop, defaultProp, onChange = () => {
3085
- } }) {
3086
- const [uncontrolledProp, setUncontrolledProp] = $71cd76cc60e0454e$var$useUncontrolledState({
3087
- defaultProp,
3088
- onChange
3089
- });
3090
- const isControlled = prop !== void 0;
3091
- const value1 = isControlled ? prop : uncontrolledProp;
3092
- const handleChange = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onChange);
3093
- const setValue = useCallback((nextValue) => {
3094
- if (isControlled) {
3095
- const setter = nextValue;
3096
- const value = typeof nextValue === "function" ? setter(prop) : nextValue;
3097
- if (value !== prop) handleChange(value);
3098
- } else setUncontrolledProp(nextValue);
3099
- }, [
3100
- isControlled,
3101
- prop,
3102
- setUncontrolledProp,
3103
- handleChange
3104
- ]);
3105
- return [
3106
- value1,
3107
- setValue
3108
- ];
3109
- }
3110
- function $71cd76cc60e0454e$var$useUncontrolledState({ defaultProp, onChange }) {
3111
- const uncontrolledState = useState(defaultProp);
3112
- const [value] = uncontrolledState;
3113
- const prevValueRef = useRef(value);
3114
- const handleChange = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onChange);
3115
- useEffect(() => {
3116
- if (prevValueRef.current !== value) {
3117
- handleChange(value);
3118
- prevValueRef.current = value;
3119
- }
3120
- }, [
3121
- value,
3122
- prevValueRef,
3123
- handleChange
3124
- ]);
3125
- return uncontrolledState;
3126
- }
3127
- const $ea1ef594cf570d83$export$439d29a4e110a164 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
3128
- return /* @__PURE__ */ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({}, props, {
3129
- ref: forwardedRef,
3130
- style: {
3131
- // See: https://github.com/twbs/bootstrap/blob/master/scss/mixins/_screen-reader.scss
3132
- position: "absolute",
3133
- border: 0,
3134
- width: 1,
3135
- height: 1,
3136
- padding: 0,
3137
- margin: -1,
3138
- overflow: "hidden",
3139
- clip: "rect(0, 0, 0, 0)",
3140
- whiteSpace: "nowrap",
3141
- wordWrap: "normal",
3142
- ...props.style
3143
- }
3144
- }));
3145
- });
3146
- const $ea1ef594cf570d83$export$be92b6f5f03c0fe9 = $ea1ef594cf570d83$export$439d29a4e110a164;
3147
- const [$a093c7e1ec25a057$var$createTooltipContext, $a093c7e1ec25a057$export$1c540a2224f0d865] = $c512c27ab02ef895$export$50c7b4e9d9f19c1("Tooltip", [
3148
- $cf1ac5d9fe0e8206$export$722aac194ae923
3149
- ]);
3150
- const $a093c7e1ec25a057$var$usePopperScope = $cf1ac5d9fe0e8206$export$722aac194ae923();
3151
- const $a093c7e1ec25a057$var$PROVIDER_NAME = "TooltipProvider";
3152
- const $a093c7e1ec25a057$var$DEFAULT_DELAY_DURATION = 700;
3153
- const $a093c7e1ec25a057$var$TOOLTIP_OPEN = "tooltip.open";
3154
- const [$a093c7e1ec25a057$var$TooltipProviderContextProvider, $a093c7e1ec25a057$var$useTooltipProviderContext] = $a093c7e1ec25a057$var$createTooltipContext($a093c7e1ec25a057$var$PROVIDER_NAME);
3155
- const $a093c7e1ec25a057$export$f78649fb9ca566b8 = (props) => {
3156
- const { __scopeTooltip, delayDuration = $a093c7e1ec25a057$var$DEFAULT_DELAY_DURATION, skipDelayDuration = 300, disableHoverableContent = false, children } = props;
3157
- const [isOpenDelayed, setIsOpenDelayed] = useState(true);
3158
- const isPointerInTransitRef = useRef(false);
3159
- const skipDelayTimerRef = useRef(0);
3160
- useEffect(() => {
3161
- const skipDelayTimer = skipDelayTimerRef.current;
3162
- return () => window.clearTimeout(skipDelayTimer);
3163
- }, []);
3164
- return /* @__PURE__ */ createElement($a093c7e1ec25a057$var$TooltipProviderContextProvider, {
3165
- scope: __scopeTooltip,
3166
- isOpenDelayed,
3167
- delayDuration,
3168
- onOpen: useCallback(() => {
3169
- window.clearTimeout(skipDelayTimerRef.current);
3170
- setIsOpenDelayed(false);
3171
- }, []),
3172
- onClose: useCallback(() => {
3173
- window.clearTimeout(skipDelayTimerRef.current);
3174
- skipDelayTimerRef.current = window.setTimeout(
3175
- () => setIsOpenDelayed(true),
3176
- skipDelayDuration
3177
- );
3178
- }, [
3179
- skipDelayDuration
3180
- ]),
3181
- isPointerInTransitRef,
3182
- onPointerInTransitChange: useCallback((inTransit) => {
3183
- isPointerInTransitRef.current = inTransit;
3184
- }, []),
3185
- disableHoverableContent
3186
- }, children);
3187
- };
3188
- const $a093c7e1ec25a057$var$TOOLTIP_NAME = "Tooltip";
3189
- const [$a093c7e1ec25a057$var$TooltipContextProvider, $a093c7e1ec25a057$var$useTooltipContext] = $a093c7e1ec25a057$var$createTooltipContext($a093c7e1ec25a057$var$TOOLTIP_NAME);
3190
- const $a093c7e1ec25a057$export$28c660c63b792dea = (props) => {
3191
- const { __scopeTooltip, children, open: openProp, defaultOpen = false, onOpenChange, disableHoverableContent: disableHoverableContentProp, delayDuration: delayDurationProp } = props;
3192
- const providerContext = $a093c7e1ec25a057$var$useTooltipProviderContext($a093c7e1ec25a057$var$TOOLTIP_NAME, props.__scopeTooltip);
3193
- const popperScope = $a093c7e1ec25a057$var$usePopperScope(__scopeTooltip);
3194
- const [trigger, setTrigger] = useState(null);
3195
- const contentId = $1746a345f3d73bb7$export$f680877a34711e37();
3196
- const openTimerRef = useRef(0);
3197
- const disableHoverableContent = disableHoverableContentProp !== null && disableHoverableContentProp !== void 0 ? disableHoverableContentProp : providerContext.disableHoverableContent;
3198
- const delayDuration = delayDurationProp !== null && delayDurationProp !== void 0 ? delayDurationProp : providerContext.delayDuration;
3199
- const wasOpenDelayedRef = useRef(false);
3200
- const [open1 = false, setOpen] = $71cd76cc60e0454e$export$6f32135080cb4c3({
3201
- prop: openProp,
3202
- defaultProp: defaultOpen,
3203
- onChange: (open) => {
3204
- if (open) {
3205
- providerContext.onOpen();
3206
- document.dispatchEvent(new CustomEvent($a093c7e1ec25a057$var$TOOLTIP_OPEN));
3207
- } else providerContext.onClose();
3208
- onOpenChange === null || onOpenChange === void 0 || onOpenChange(open);
3209
- }
3210
- });
3211
- const stateAttribute = useMemo(() => {
3212
- return open1 ? wasOpenDelayedRef.current ? "delayed-open" : "instant-open" : "closed";
3213
- }, [
3214
- open1
3215
- ]);
3216
- const handleOpen = useCallback(() => {
3217
- window.clearTimeout(openTimerRef.current);
3218
- wasOpenDelayedRef.current = false;
3219
- setOpen(true);
3220
- }, [
3221
- setOpen
3222
- ]);
3223
- const handleClose = useCallback(() => {
3224
- window.clearTimeout(openTimerRef.current);
3225
- setOpen(false);
3226
- }, [
3227
- setOpen
3228
- ]);
3229
- const handleDelayedOpen = useCallback(() => {
3230
- window.clearTimeout(openTimerRef.current);
3231
- openTimerRef.current = window.setTimeout(() => {
3232
- wasOpenDelayedRef.current = true;
3233
- setOpen(true);
3234
- }, delayDuration);
3235
- }, [
3236
- delayDuration,
3237
- setOpen
3238
- ]);
3239
- useEffect(() => {
3240
- return () => window.clearTimeout(openTimerRef.current);
3241
- }, []);
3242
- return /* @__PURE__ */ createElement($cf1ac5d9fe0e8206$export$be92b6f5f03c0fe9, popperScope, /* @__PURE__ */ createElement($a093c7e1ec25a057$var$TooltipContextProvider, {
3243
- scope: __scopeTooltip,
3244
- contentId,
3245
- open: open1,
3246
- stateAttribute,
3247
- trigger,
3248
- onTriggerChange: setTrigger,
3249
- onTriggerEnter: useCallback(() => {
3250
- if (providerContext.isOpenDelayed) handleDelayedOpen();
3251
- else handleOpen();
3252
- }, [
3253
- providerContext.isOpenDelayed,
3254
- handleDelayedOpen,
3255
- handleOpen
3256
- ]),
3257
- onTriggerLeave: useCallback(() => {
3258
- if (disableHoverableContent) handleClose();
3259
- else
3260
- window.clearTimeout(openTimerRef.current);
3261
- }, [
3262
- handleClose,
3263
- disableHoverableContent
3264
- ]),
3265
- onOpen: handleOpen,
3266
- onClose: handleClose,
3267
- disableHoverableContent
3268
- }, children));
3269
- };
3270
- const $a093c7e1ec25a057$var$TRIGGER_NAME = "TooltipTrigger";
3271
- const $a093c7e1ec25a057$export$8c610744efcf8a1d = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
3272
- const { __scopeTooltip, ...triggerProps } = props;
3273
- const context = $a093c7e1ec25a057$var$useTooltipContext($a093c7e1ec25a057$var$TRIGGER_NAME, __scopeTooltip);
3274
- const providerContext = $a093c7e1ec25a057$var$useTooltipProviderContext($a093c7e1ec25a057$var$TRIGGER_NAME, __scopeTooltip);
3275
- const popperScope = $a093c7e1ec25a057$var$usePopperScope(__scopeTooltip);
3276
- const ref = useRef(null);
3277
- const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, ref, context.onTriggerChange);
3278
- const isPointerDownRef = useRef(false);
3279
- const hasPointerMoveOpenedRef = useRef(false);
3280
- const handlePointerUp = useCallback(
3281
- () => isPointerDownRef.current = false,
3282
- []
3283
- );
3284
- useEffect(() => {
3285
- return () => document.removeEventListener("pointerup", handlePointerUp);
3286
- }, [
3287
- handlePointerUp
3288
- ]);
3289
- return /* @__PURE__ */ createElement($cf1ac5d9fe0e8206$export$b688253958b8dfe7, _extends({
3290
- asChild: true
3291
- }, popperScope), /* @__PURE__ */ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.button, _extends({
3292
- // We purposefully avoid adding `type=button` here because tooltip triggers are also
3293
- // commonly anchors and the anchor `type` attribute signifies MIME type.
3294
- "aria-describedby": context.open ? context.contentId : void 0,
3295
- "data-state": context.stateAttribute
3296
- }, triggerProps, {
3297
- ref: composedRefs,
3298
- onPointerMove: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onPointerMove, (event) => {
3299
- if (event.pointerType === "touch") return;
3300
- if (!hasPointerMoveOpenedRef.current && !providerContext.isPointerInTransitRef.current) {
3301
- context.onTriggerEnter();
3302
- hasPointerMoveOpenedRef.current = true;
3303
- }
3304
- }),
3305
- onPointerLeave: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onPointerLeave, () => {
3306
- context.onTriggerLeave();
3307
- hasPointerMoveOpenedRef.current = false;
3308
- }),
3309
- onPointerDown: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onPointerDown, () => {
3310
- isPointerDownRef.current = true;
3311
- document.addEventListener("pointerup", handlePointerUp, {
3312
- once: true
3313
- });
3314
- }),
3315
- onFocus: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onFocus, () => {
3316
- if (!isPointerDownRef.current) context.onOpen();
3317
- }),
3318
- onBlur: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onBlur, context.onClose),
3319
- onClick: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onClick, context.onClose)
3320
- })));
3321
- });
3322
- const $a093c7e1ec25a057$var$PORTAL_NAME = "TooltipPortal";
3323
- const [$a093c7e1ec25a057$var$PortalProvider, $a093c7e1ec25a057$var$usePortalContext] = $a093c7e1ec25a057$var$createTooltipContext($a093c7e1ec25a057$var$PORTAL_NAME, {
3324
- forceMount: void 0
3325
- });
3326
- const $a093c7e1ec25a057$export$7b36b8f925ab7497 = (props) => {
3327
- const { __scopeTooltip, forceMount, children, container } = props;
3328
- const context = $a093c7e1ec25a057$var$useTooltipContext($a093c7e1ec25a057$var$PORTAL_NAME, __scopeTooltip);
3329
- return /* @__PURE__ */ createElement($a093c7e1ec25a057$var$PortalProvider, {
3330
- scope: __scopeTooltip,
3331
- forceMount
3332
- }, /* @__PURE__ */ createElement($921a889cee6df7e8$export$99c2b779aa4e8b8b, {
3333
- present: forceMount || context.open
3334
- }, /* @__PURE__ */ createElement($f1701beae083dbae$export$602eac185826482c, {
3335
- asChild: true,
3336
- container
3337
- }, children)));
3338
- };
3339
- const $a093c7e1ec25a057$var$CONTENT_NAME = "TooltipContent";
3340
- const $a093c7e1ec25a057$export$e9003e2be37ec060 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
3341
- const portalContext = $a093c7e1ec25a057$var$usePortalContext($a093c7e1ec25a057$var$CONTENT_NAME, props.__scopeTooltip);
3342
- const { forceMount = portalContext.forceMount, side = "top", ...contentProps } = props;
3343
- const context = $a093c7e1ec25a057$var$useTooltipContext($a093c7e1ec25a057$var$CONTENT_NAME, props.__scopeTooltip);
3344
- return /* @__PURE__ */ createElement($921a889cee6df7e8$export$99c2b779aa4e8b8b, {
3345
- present: forceMount || context.open
3346
- }, context.disableHoverableContent ? /* @__PURE__ */ createElement($a093c7e1ec25a057$var$TooltipContentImpl, _extends({
3347
- side
3348
- }, contentProps, {
3349
- ref: forwardedRef
3350
- })) : /* @__PURE__ */ createElement($a093c7e1ec25a057$var$TooltipContentHoverable, _extends({
3351
- side
3352
- }, contentProps, {
3353
- ref: forwardedRef
3354
- })));
3355
- });
3356
- const $a093c7e1ec25a057$var$TooltipContentHoverable = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
3357
- const context = $a093c7e1ec25a057$var$useTooltipContext($a093c7e1ec25a057$var$CONTENT_NAME, props.__scopeTooltip);
3358
- const providerContext = $a093c7e1ec25a057$var$useTooltipProviderContext($a093c7e1ec25a057$var$CONTENT_NAME, props.__scopeTooltip);
3359
- const ref = useRef(null);
3360
- const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, ref);
3361
- const [pointerGraceArea, setPointerGraceArea] = useState(null);
3362
- const { trigger, onClose } = context;
3363
- const content = ref.current;
3364
- const { onPointerInTransitChange } = providerContext;
3365
- const handleRemoveGraceArea = useCallback(() => {
3366
- setPointerGraceArea(null);
3367
- onPointerInTransitChange(false);
3368
- }, [
3369
- onPointerInTransitChange
3370
- ]);
3371
- const handleCreateGraceArea = useCallback((event, hoverTarget) => {
3372
- const currentTarget = event.currentTarget;
3373
- const exitPoint = {
3374
- x: event.clientX,
3375
- y: event.clientY
3376
- };
3377
- const exitSide = $a093c7e1ec25a057$var$getExitSideFromRect(exitPoint, currentTarget.getBoundingClientRect());
3378
- const paddedExitPoints = $a093c7e1ec25a057$var$getPaddedExitPoints(exitPoint, exitSide);
3379
- const hoverTargetPoints = $a093c7e1ec25a057$var$getPointsFromRect(hoverTarget.getBoundingClientRect());
3380
- const graceArea = $a093c7e1ec25a057$var$getHull([
3381
- ...paddedExitPoints,
3382
- ...hoverTargetPoints
3383
- ]);
3384
- setPointerGraceArea(graceArea);
3385
- onPointerInTransitChange(true);
3386
- }, [
3387
- onPointerInTransitChange
3388
- ]);
3389
- useEffect(() => {
3390
- return () => handleRemoveGraceArea();
3391
- }, [
3392
- handleRemoveGraceArea
3393
- ]);
3394
- useEffect(() => {
3395
- if (trigger && content) {
3396
- const handleTriggerLeave = (event) => handleCreateGraceArea(event, content);
3397
- const handleContentLeave = (event) => handleCreateGraceArea(event, trigger);
3398
- trigger.addEventListener("pointerleave", handleTriggerLeave);
3399
- content.addEventListener("pointerleave", handleContentLeave);
3400
- return () => {
3401
- trigger.removeEventListener("pointerleave", handleTriggerLeave);
3402
- content.removeEventListener("pointerleave", handleContentLeave);
3403
- };
3404
- }
3405
- }, [
3406
- trigger,
3407
- content,
3408
- handleCreateGraceArea,
3409
- handleRemoveGraceArea
3410
- ]);
3411
- useEffect(() => {
3412
- if (pointerGraceArea) {
3413
- const handleTrackPointerGrace = (event) => {
3414
- const target = event.target;
3415
- const pointerPosition = {
3416
- x: event.clientX,
3417
- y: event.clientY
3418
- };
3419
- const hasEnteredTarget = (trigger === null || trigger === void 0 ? void 0 : trigger.contains(target)) || (content === null || content === void 0 ? void 0 : content.contains(target));
3420
- const isPointerOutsideGraceArea = !$a093c7e1ec25a057$var$isPointInPolygon(pointerPosition, pointerGraceArea);
3421
- if (hasEnteredTarget) handleRemoveGraceArea();
3422
- else if (isPointerOutsideGraceArea) {
3423
- handleRemoveGraceArea();
3424
- onClose();
3425
- }
3426
- };
3427
- document.addEventListener("pointermove", handleTrackPointerGrace);
3428
- return () => document.removeEventListener("pointermove", handleTrackPointerGrace);
3429
- }
3430
- }, [
3431
- trigger,
3432
- content,
3433
- pointerGraceArea,
3434
- onClose,
3435
- handleRemoveGraceArea
3436
- ]);
3437
- return /* @__PURE__ */ createElement($a093c7e1ec25a057$var$TooltipContentImpl, _extends({}, props, {
3438
- ref: composedRefs
3439
- }));
3440
- });
3441
- const [$a093c7e1ec25a057$var$VisuallyHiddenContentContextProvider, $a093c7e1ec25a057$var$useVisuallyHiddenContentContext] = $a093c7e1ec25a057$var$createTooltipContext($a093c7e1ec25a057$var$TOOLTIP_NAME, {
3442
- isInside: false
3443
- });
3444
- const $a093c7e1ec25a057$var$TooltipContentImpl = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
3445
- const { __scopeTooltip, children, "aria-label": ariaLabel, onEscapeKeyDown, onPointerDownOutside, ...contentProps } = props;
3446
- const context = $a093c7e1ec25a057$var$useTooltipContext($a093c7e1ec25a057$var$CONTENT_NAME, __scopeTooltip);
3447
- const popperScope = $a093c7e1ec25a057$var$usePopperScope(__scopeTooltip);
3448
- const { onClose } = context;
3449
- useEffect(() => {
3450
- document.addEventListener($a093c7e1ec25a057$var$TOOLTIP_OPEN, onClose);
3451
- return () => document.removeEventListener($a093c7e1ec25a057$var$TOOLTIP_OPEN, onClose);
3452
- }, [
3453
- onClose
3454
- ]);
3455
- useEffect(() => {
3456
- if (context.trigger) {
3457
- const handleScroll = (event) => {
3458
- const target = event.target;
3459
- if (target !== null && target !== void 0 && target.contains(context.trigger)) onClose();
3460
- };
3461
- window.addEventListener("scroll", handleScroll, {
3462
- capture: true
3463
- });
3464
- return () => window.removeEventListener("scroll", handleScroll, {
3465
- capture: true
3466
- });
3467
- }
3468
- }, [
3469
- context.trigger,
3470
- onClose
3471
- ]);
3472
- return /* @__PURE__ */ createElement($5cb92bef7577960e$export$177fb62ff3ec1f22, {
3473
- asChild: true,
3474
- disableOutsidePointerEvents: false,
3475
- onEscapeKeyDown,
3476
- onPointerDownOutside,
3477
- onFocusOutside: (event) => event.preventDefault(),
3478
- onDismiss: onClose
3479
- }, /* @__PURE__ */ createElement($cf1ac5d9fe0e8206$export$7c6e2c02157bb7d2, _extends({
3480
- "data-state": context.stateAttribute
3481
- }, popperScope, contentProps, {
3482
- ref: forwardedRef,
3483
- style: {
3484
- ...contentProps.style,
3485
- "--radix-tooltip-content-transform-origin": "var(--radix-popper-transform-origin)",
3486
- "--radix-tooltip-content-available-width": "var(--radix-popper-available-width)",
3487
- "--radix-tooltip-content-available-height": "var(--radix-popper-available-height)",
3488
- "--radix-tooltip-trigger-width": "var(--radix-popper-anchor-width)",
3489
- "--radix-tooltip-trigger-height": "var(--radix-popper-anchor-height)"
3490
- }
3491
- }), /* @__PURE__ */ createElement($5e63c961fc1ce211$export$d9f1ccf0bdb05d45, null, children), /* @__PURE__ */ createElement($a093c7e1ec25a057$var$VisuallyHiddenContentContextProvider, {
3492
- scope: __scopeTooltip,
3493
- isInside: true
3494
- }, /* @__PURE__ */ createElement($ea1ef594cf570d83$export$be92b6f5f03c0fe9, {
3495
- id: context.contentId,
3496
- role: "tooltip"
3497
- }, ariaLabel || children))));
3498
- });
3499
- function $a093c7e1ec25a057$var$getExitSideFromRect(point, rect) {
3500
- const top = Math.abs(rect.top - point.y);
3501
- const bottom = Math.abs(rect.bottom - point.y);
3502
- const right = Math.abs(rect.right - point.x);
3503
- const left = Math.abs(rect.left - point.x);
3504
- switch (Math.min(top, bottom, right, left)) {
3505
- case left:
3506
- return "left";
3507
- case right:
3508
- return "right";
3509
- case top:
3510
- return "top";
3511
- case bottom:
3512
- return "bottom";
3513
- default:
3514
- throw new Error("unreachable");
3515
- }
3516
- }
3517
- function $a093c7e1ec25a057$var$getPaddedExitPoints(exitPoint, exitSide, padding = 5) {
3518
- const paddedExitPoints = [];
3519
- switch (exitSide) {
3520
- case "top":
3521
- paddedExitPoints.push({
3522
- x: exitPoint.x - padding,
3523
- y: exitPoint.y + padding
3524
- }, {
3525
- x: exitPoint.x + padding,
3526
- y: exitPoint.y + padding
3527
- });
3528
- break;
3529
- case "bottom":
3530
- paddedExitPoints.push({
3531
- x: exitPoint.x - padding,
3532
- y: exitPoint.y - padding
3533
- }, {
3534
- x: exitPoint.x + padding,
3535
- y: exitPoint.y - padding
3536
- });
3537
- break;
3538
- case "left":
3539
- paddedExitPoints.push({
3540
- x: exitPoint.x + padding,
3541
- y: exitPoint.y - padding
3542
- }, {
3543
- x: exitPoint.x + padding,
3544
- y: exitPoint.y + padding
3545
- });
3546
- break;
3547
- case "right":
3548
- paddedExitPoints.push({
3549
- x: exitPoint.x - padding,
3550
- y: exitPoint.y - padding
3551
- }, {
3552
- x: exitPoint.x - padding,
3553
- y: exitPoint.y + padding
3554
- });
3555
- break;
3556
- }
3557
- return paddedExitPoints;
3558
- }
3559
- function $a093c7e1ec25a057$var$getPointsFromRect(rect) {
3560
- const { top, right, bottom, left } = rect;
3561
- return [
3562
- {
3563
- x: left,
3564
- y: top
3565
- },
3566
- {
3567
- x: right,
3568
- y: top
3569
- },
3570
- {
3571
- x: right,
3572
- y: bottom
3573
- },
3574
- {
3575
- x: left,
3576
- y: bottom
3577
- }
3578
- ];
3579
- }
3580
- function $a093c7e1ec25a057$var$isPointInPolygon(point, polygon) {
3581
- const { x, y } = point;
3582
- let inside = false;
3583
- for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
3584
- const xi = polygon[i].x;
3585
- const yi = polygon[i].y;
3586
- const xj = polygon[j].x;
3587
- const yj = polygon[j].y;
3588
- const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
3589
- if (intersect) inside = !inside;
3590
- }
3591
- return inside;
3592
- }
3593
- function $a093c7e1ec25a057$var$getHull(points) {
3594
- const newPoints = points.slice();
3595
- newPoints.sort((a, b) => {
3596
- if (a.x < b.x) return -1;
3597
- else if (a.x > b.x) return 1;
3598
- else if (a.y < b.y) return -1;
3599
- else if (a.y > b.y) return 1;
3600
- else return 0;
3601
- });
3602
- return $a093c7e1ec25a057$var$getHullPresorted(newPoints);
3603
- }
3604
- function $a093c7e1ec25a057$var$getHullPresorted(points) {
3605
- if (points.length <= 1) return points.slice();
3606
- const upperHull = [];
3607
- for (let i = 0; i < points.length; i++) {
3608
- const p = points[i];
3609
- while (upperHull.length >= 2) {
3610
- const q = upperHull[upperHull.length - 1];
3611
- const r = upperHull[upperHull.length - 2];
3612
- if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) upperHull.pop();
3613
- else break;
3614
- }
3615
- upperHull.push(p);
3616
- }
3617
- upperHull.pop();
3618
- const lowerHull = [];
3619
- for (let i1 = points.length - 1; i1 >= 0; i1--) {
3620
- const p = points[i1];
3621
- while (lowerHull.length >= 2) {
3622
- const q = lowerHull[lowerHull.length - 1];
3623
- const r = lowerHull[lowerHull.length - 2];
3624
- if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) lowerHull.pop();
3625
- else break;
3626
- }
3627
- lowerHull.push(p);
3628
- }
3629
- lowerHull.pop();
3630
- if (upperHull.length === 1 && lowerHull.length === 1 && upperHull[0].x === lowerHull[0].x && upperHull[0].y === lowerHull[0].y) return upperHull;
3631
- else return upperHull.concat(lowerHull);
3632
- }
3633
- const $a093c7e1ec25a057$export$2881499e37b75b9a = $a093c7e1ec25a057$export$f78649fb9ca566b8;
3634
- const $a093c7e1ec25a057$export$be92b6f5f03c0fe9 = $a093c7e1ec25a057$export$28c660c63b792dea;
3635
- const $a093c7e1ec25a057$export$41fb9f06171c75f4 = $a093c7e1ec25a057$export$8c610744efcf8a1d;
3636
- const $a093c7e1ec25a057$export$602eac185826482c = $a093c7e1ec25a057$export$7b36b8f925ab7497;
3637
- const $a093c7e1ec25a057$export$7c6e2c02157bb7d2 = $a093c7e1ec25a057$export$e9003e2be37ec060;
3638
- function Tooltip({ description: description2 }) {
3639
- return /* @__PURE__ */ jsx($a093c7e1ec25a057$export$2881499e37b75b9a, { children: /* @__PURE__ */ jsxs($a093c7e1ec25a057$export$be92b6f5f03c0fe9, { children: [
3640
- /* @__PURE__ */ jsx($a093c7e1ec25a057$export$41fb9f06171c75f4, { asChild: true, children: /* @__PURE__ */ jsx(Information, { "aria-hidden": "true" }) }),
3641
- /* @__PURE__ */ jsx($a093c7e1ec25a057$export$602eac185826482c, { children: /* @__PURE__ */ jsx($a093c7e1ec25a057$export$7c6e2c02157bb7d2, { sideOffset: 5, style: { zIndex: 9999 }, children: /* @__PURE__ */ jsx(
3642
- Box,
3643
- {
3644
- padding: 2,
3645
- margin: 2,
3646
- background: "neutral1000",
3647
- hasRadius: true,
3648
- shadow: "filterShadow",
3649
- maxWidth: "300px",
3650
- children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral0", children: description2 })
3651
- }
3652
- ) }) })
3653
- ] }) });
3654
- }
3655
- function debounce(func, wait) {
3656
- let timeout;
3657
- return function executedFunction(...args) {
3658
- const later = () => {
3659
- clearTimeout(timeout);
3660
- func(...args);
3661
- };
3662
- clearTimeout(timeout);
3663
- timeout = setTimeout(later, wait);
3664
- };
3665
- }
3666
- async function duplicateCheck(get, url, routeDocumentId) {
3667
- if (!url) throw new Error("URL is required");
3668
- try {
3669
- const { data } = await get(`/${PLUGIN_ID}/checkUniquePath?path=${transformToUrl(url)}${routeDocumentId ? `&targetRouteDocumentId=${routeDocumentId}` : ""}`);
3670
- if (!data.uniquePath) {
3671
- throw new Error("Network response was not ok");
3672
- }
3673
- return data.uniquePath;
3674
- } catch (err) {
3675
- console.error("Error in duplicateCheck:", err);
3676
- throw new Error("Failed to check URL uniqueness");
3677
- }
3678
- }
3679
- const getTranslation = (id) => `${PLUGIN_ID}.${id}`;
3680
- function PathInfo({ validationState, replacement, setUrlStatus }) {
3681
- const [color, setColor] = useState(null);
3682
- const [text, setText] = useState(null);
3683
- const { formatMessage } = useIntl();
3684
- useEffect(() => {
3685
- if (validationState === "initial") return;
3686
- if (validationState === "checking") {
3687
- setColor("neutral800");
3688
- setText(formatMessage({
3689
- id: getTranslation("components.pathInfo.checking"),
3690
- defaultMessage: "Checking if path is available..."
3691
- }));
3692
- } else if (validationState === "done") {
3693
- setColor(replacement ? "danger500" : "success500");
3694
- setText(replacement ? `${formatMessage({
3695
- id: getTranslation("components.pathInfo.notAvailable"),
3696
- defaultMessage: "Path is not available. Replaced with"
3697
- })} "${replacement}".` : formatMessage({
3698
- id: getTranslation("components.pathInfo.available"),
3699
- defaultMessage: "Path is available."
3700
- }));
3701
- if (setUrlStatus) setUrlStatus(replacement ? "invalid" : "valid");
3702
- }
3703
- }, [validationState, replacement, formatMessage, setUrlStatus]);
3704
- return /* @__PURE__ */ jsx(Box, { paddingTop: 2, children: /* @__PURE__ */ jsx(Typography, { textColor: color, children: text }) });
3705
- }
3706
- function reducer(state, action) {
3707
- switch (action.type) {
3708
- case "DEFAULT":
3709
- return {
3710
- ...state,
3711
- value: transformToUrl(action.payload),
3712
- prevValue: state.value,
3713
- needsUrlCheck: true
3714
- };
3715
- case "NO_URL_CHECK":
3716
- return {
3717
- ...state,
3718
- value: transformToUrl(action.payload),
3719
- prevValue: state.value,
3720
- needsUrlCheck: false
3721
- };
3722
- case "NO_TRANSFORM_AND_CHECK":
3723
- return {
3724
- ...state,
3725
- value: action.payload,
3726
- prevValue: state.value,
3727
- needsUrlCheck: false
3728
- };
3729
- case "RESET_URL_CHECK_FLAG":
3730
- return { ...state, needsUrlCheck: false };
3731
- case "SET_UIDPATH":
3732
- return { ...state, uIdPath: action.payload };
3733
- default:
3734
- throw new Error();
3735
- }
3736
- }
3737
- const Path = ({ config }) => {
3738
- const { form, model } = unstable_useContentManagerContext();
3739
- const { initialValues, values, onChange } = form;
3740
- const { getRelatedRoute } = useApi();
3741
- const { formatMessage } = useIntl();
3742
- const { get } = useFetchClient();
3743
- const { allowedActions: {
3744
- canUpdate,
3745
- canCreate
3746
- } } = useRBAC([
3747
- {
3748
- action: "plugin::content-manager.explorer.update",
3749
- subject: model,
3750
- properties: {},
3751
- conditions: []
3752
- },
3753
- {
3754
- action: "plugin::content-manager.explorer.create",
3755
- subject: model,
3756
- properties: {},
3757
- conditions: []
3758
- }
3759
- ]);
3760
- const [routeId, setRouteId] = useState();
3761
- const [isOverride, setIsOverride] = useState(false);
3762
- const [validationState, setValidationState] = useState("initial");
3763
- const [replacement, setReplacement] = useState("");
3764
- const [initialLoadComplete, setInitialLoadComplete] = useState(false);
3765
- const [urlIsValid, setUrlIsValid] = useState(null);
3766
- const [path, dispatchPath] = useReducer(reducer, {
3767
- needsUrlCheck: false,
3768
- value: "",
3769
- prevValue: "",
3770
- uIdPath: ""
3771
- });
3772
- const hasUserChangedField = useRef(false);
3773
- const initialPath = useRef("");
3774
- const prevValueRef = useRef(null);
3775
- const debouncedCheckUrl = useCallback(debounce(checkUrl, 250), []);
3776
- useEffect(() => {
3777
- onChange("webatlas_path", path.value);
3778
- onChange("webatlas_override", isOverride);
3779
- }, [path.value, isOverride]);
3780
- const debouncedValueEffect = useMemo(() => debounce((currentValues) => {
3781
- const key = config?.default;
3782
- if (!key) return;
3783
- const currentValue = currentValues[key];
3784
- if (!currentValue) {
3785
- dispatchPath({ type: "NO_URL_CHECK", payload: "" });
3786
- return;
3787
- }
3788
- if (initialLoadComplete && (hasUserChangedField.current || !routeId) && prevValueRef.current !== currentValue && !isOverride) {
3789
- const path2 = config.pattern ? `${config.pattern}/${currentValue}` : `${currentValue}`;
3790
- if (currentValue === initialValues[key]) {
3791
- dispatchPath({ type: "NO_URL_CHECK", payload: path2 });
3792
- } else {
3793
- dispatchPath({ type: "DEFAULT", payload: path2 });
3794
- }
3795
- prevValueRef.current = currentValue;
3796
- }
3797
- }, 500), [config?.default, config?.pattern, initialValues, isOverride, initialLoadComplete, routeId]);
3798
- useEffect(() => {
3799
- const key = config?.default;
3800
- if (!key) return;
3801
- const currentValue = values[key];
3802
- const initialValue = initialValues[key];
3803
- if (currentValue && !isOverride) {
3804
- const path2 = config.pattern ? `${config.pattern}/${currentValue}` : `${currentValue}`;
3805
- onChange("webatlas_path", transformToUrl(path2));
3806
- }
3807
- if (!initialLoadComplete) return;
3808
- if (currentValue !== initialValue) {
3809
- hasUserChangedField.current = true;
3810
- }
3811
- debouncedValueEffect(values);
3812
- }, [values, debouncedValueEffect, initialLoadComplete]);
3813
- useEffect(() => {
3814
- if (path.needsUrlCheck && path.value) {
3815
- if (path.uIdPath === path.value || initialPath.current === path.value) return;
3816
- debouncedCheckUrl(path.value);
3817
- dispatchPath({ type: "RESET_URL_CHECK_FLAG" });
3818
- }
3819
- }, [path.needsUrlCheck]);
3820
- useEffect(() => {
3821
- async function getTypes() {
3822
- if (!initialValues.documentId) {
3823
- setInitialLoadComplete(true);
3824
- return;
3825
- }
3826
- try {
3827
- const route = await getRelatedRoute(initialValues.documentId);
3828
- if (!route) return;
3829
- initialPath.current = initialValues.webatlas_path || route.uidPath;
3830
- setRouteId(route.id);
3831
- setIsOverride(route.isOverride || false);
3832
- dispatchPath({ type: "NO_TRANSFORM_AND_CHECK", payload: route.path || "" });
3833
- dispatchPath({ type: "SET_UIDPATH", payload: route.uidPath || "" });
3834
- const key = config?.default;
3835
- if (key) {
3836
- prevValueRef.current = values[key];
3837
- }
3838
- } catch (err) {
3839
- setRouteId(null);
3840
- console.log(err);
3841
- }
3842
- setInitialLoadComplete(true);
3843
- }
3844
- getTypes();
3845
- }, [config]);
3846
- useEffect(() => {
3847
- if (initialValues.webatlas_path) dispatchPath({ type: "NO_URL_CHECK", payload: initialValues.webatlas_path });
3848
- if (initialValues.webatlas_override) setIsOverride(initialValues.webatlas_override);
3849
- }, []);
3850
- async function checkUrl(url) {
3851
- if (!url) return;
3852
- setValidationState("checking");
3853
- setReplacement("");
3854
- try {
3855
- const data = await duplicateCheck(get, url);
3856
- if (!data || data === url) return;
3857
- dispatchPath({ type: "NO_URL_CHECK", payload: data });
3858
- setReplacement(data);
3859
- } catch (err) {
3860
- console.log(err);
3861
- } finally {
3862
- setUrlIsValid(null);
3863
- setValidationState("done");
3864
- }
3865
- }
3866
- if (!initialLoadComplete) return /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: formatMessage({
3867
- id: getTranslation("loading"),
3868
- defaultMessage: "Loading..."
3869
- }) });
3870
- return /* @__PURE__ */ jsx(
3871
- Box,
3872
- {
3873
- as: "aside",
3874
- "aria-labelledby": "URL Route",
3875
- width: "100%",
3876
- children: /* @__PURE__ */ jsxs(
3877
- Flex,
3878
- {
3879
- direction: "column",
3880
- alignItems: "stretch",
3881
- gap: 4,
3882
- children: [
3883
- /* @__PURE__ */ jsxs(Box, { children: [
3884
- !routeId && /* @__PURE__ */ jsxs(Fragment$1, { children: [
3885
- /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", marginBottom: 2, children: formatMessage({
3886
- id: getTranslation("components.CMEditViewAside.path.newPathInfo"),
3887
- defaultMessage: "A new path will be created upon saving this entry."
3888
- }) }),
3889
- /* @__PURE__ */ jsx(Box, { paddingBottom: 2, paddingTop: 2, children: /* @__PURE__ */ jsx(Divider, {}) })
3890
- ] }),
3891
- /* @__PURE__ */ jsxs(
3892
- Field.Root,
3893
- {
3894
- hint: config.default ? formatMessage({
3895
- id: getTranslation("components.CMEditViewAside.path.input.start"),
3896
- defaultMessage: "Edit the"
3897
- }) + ' "' + config.default + '" ' + formatMessage({
3898
- id: getTranslation("components.CMEditViewAside.path.input.end"),
3899
- defaultMessage: "field to generate a path"
3900
- }) : formatMessage({
3901
- id: getTranslation("components.CMEditViewAside.path.input.noSourceField"),
3902
- defaultMessage: "Use the override option to set a custom path"
3903
- }),
3904
- children: [
3905
- /* @__PURE__ */ jsxs(Field.Label, { children: [
3906
- formatMessage({
3907
- id: getTranslation("components.CMEditViewAside.path.input.label"),
3908
- defaultMessage: "Path"
3909
- }),
3910
- /* @__PURE__ */ jsx(Tooltip, { description: formatMessage({
3911
- id: getTranslation("components.CMEditViewAside.path.input.tooltip"),
3912
- defaultMessage: "The following characters are valid: A-Z, a-z, 0-9, /, -, _, $, ., +, !, *, ', (, )"
3913
- }) })
3914
- ] }),
3915
- /* @__PURE__ */ jsx(
3916
- Field.Input,
3917
- {
3918
- id: "path-input",
3919
- value: path.value,
3920
- onChange: (e) => dispatchPath({ type: "NO_TRANSFORM_AND_CHECK", payload: e.target.value }),
3921
- disabled: !isOverride,
3922
- onBlur: (e) => {
3923
- if (e.target.value === path.prevValue) return;
3924
- dispatchPath({ type: "DEFAULT", payload: e.target.value });
3925
- },
3926
- style: { outline: urlIsValid !== null ? urlIsValid === "valid" ? "1px solid #5cb176" : "1px solid #ee5e52" : void 0 }
3927
- }
3928
- ),
3929
- /* @__PURE__ */ jsx(Field.Hint, {})
3930
- ]
3931
- }
3932
- ),
3933
- /* @__PURE__ */ jsx(PathInfo, { validationState, replacement, setUrlStatus: setUrlIsValid }),
3934
- /* @__PURE__ */ jsx(
3935
- Flex,
3936
- {
3937
- gap: 2,
3938
- paddingTop: 2,
3939
- children: /* @__PURE__ */ jsx(
3940
- Checkbox,
3941
- {
3942
- id: "path-override-checkbox",
3943
- checked: isOverride,
3944
- onCheckedChange: () => setIsOverride((prev) => !prev),
3945
- disabled: !routeId && !canCreate || routeId && !canUpdate,
3946
- children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: formatMessage({
3947
- id: getTranslation("components.CMEditViewAside.path.overrideCheckbox"),
3948
- defaultMessage: "Override automatic path generation"
3949
- }) })
3950
- }
3951
- )
3952
- }
3953
- )
3954
- ] }),
3955
- path.uIdPath && /* @__PURE__ */ jsxs(Fragment$1, { children: [
3956
- /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Divider, {}) }),
3957
- /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(
3958
- Field.Root,
3959
- {
3960
- hint: formatMessage({
3961
- id: getTranslation("components.CMEditViewAside.path.uidPath.hint"),
3962
- defaultMessage: "Permanent UID path, cannot be changed"
3963
- }),
3964
- children: [
3965
- /* @__PURE__ */ jsx(
3966
- Field.Input,
3967
- {
3968
- value: path.uIdPath,
3969
- disabled: true
3970
- }
3971
- ),
3972
- /* @__PURE__ */ jsx(Field.Hint, {})
3973
- ]
3974
- }
3975
- ) })
3976
- ] })
3977
- ]
3978
- }
3979
- )
3980
- }
3981
- );
3982
- };
3983
- const pluginPermissions = {
3984
- "cm.aside": [{ action: `plugin::${PLUGIN_ID}.cm.aside`, subject: null }],
3985
- "page.navigation": [{ action: `plugin::${PLUGIN_ID}.page.navigation`, subject: null }],
3986
- "page.routes": [{ action: `plugin::${PLUGIN_ID}.page.routes`, subject: null }],
3987
- "settings.general": [{ action: `plugin::${PLUGIN_ID}.settings.general`, subject: null }],
3988
- "settings.navigation": [{ action: `plugin::${PLUGIN_ID}.settings.navigation`, subject: null }]
3989
- };
3990
- const CMEditViewAside = ({
3991
- // activeTab,
3992
- // collectionType,
3993
- // document,
3994
- documentId,
3995
- // meta,
3996
- model
3997
- }) => {
3998
- const { contentTypes } = useAllContentTypes();
3999
- const { config } = usePluginConfig();
4000
- const { formatMessage } = useIntl();
4001
- const [isAllowedContentType, setIsAllowedContentType] = useState(false);
4002
- const [isLoading, setIsLoading] = useState(true);
4003
- const [contentTypeConfig, setContentTypeConfig] = useState(null);
4004
- const [isActiveContentType, setIsActiveContentType] = useState(false);
4005
- const panelTitle = PLUGIN_NAME;
4006
- useEffect(() => {
4007
- const contentType = contentTypes?.find((ct) => ct.uid === model);
4008
- setIsAllowedContentType(!!contentType?.pluginOptions?.webatlas?.enabled);
4009
- }, [contentTypes, model]);
4010
- useEffect(() => {
4011
- const isWebatlasLabel = (label) => label.textContent?.startsWith("webatlas_");
4012
- const cleanupLabels = () => {
4013
- const labels = document.querySelectorAll("label");
4014
- labels.forEach((label) => {
4015
- if (!isWebatlasLabel(label)) return;
4016
- const container = label.parentElement?.parentElement;
4017
- const parent = container?.parentElement;
4018
- const greatGrandParent = parent?.parentElement?.parentElement;
4019
- if (!container || !parent) return;
4020
- const parentWebatlasCount = Array.from(parent.querySelectorAll("label")).filter(isWebatlasLabel).length;
4021
- const childrenCount = parent.children.length;
4022
- if (greatGrandParent && greatGrandParent?.querySelectorAll("label").length === Array.from(greatGrandParent.querySelectorAll("label")).filter(isWebatlasLabel).length) {
4023
- greatGrandParent.remove();
4024
- } else if (childrenCount === 1 || childrenCount === 2 && parentWebatlasCount === 2) {
4025
- parent.remove();
4026
- } else {
4027
- container.remove();
4028
- }
4029
- });
4030
- };
4031
- const timeoutId = setTimeout(() => {
4032
- cleanupLabels();
4033
- const secondTimeoutId = setTimeout(cleanupLabels, 1e3);
4034
- return () => clearTimeout(secondTimeoutId);
4035
- }, 100);
4036
- return () => clearTimeout(timeoutId);
4037
- }, [documentId, model]);
4038
- useEffect(() => {
4039
- if (!config) return;
4040
- setIsActiveContentType(false);
4041
- setContentTypeConfig(null);
4042
- config?.selectedContentTypes?.forEach((type2) => {
4043
- if (type2.uid === model) {
4044
- setIsActiveContentType(true);
4045
- setContentTypeConfig(type2);
4046
- }
4047
- });
4048
- setIsLoading(false);
4049
- }, [config, model]);
4050
- const {
4051
- allowedActions: { canAside }
4052
- } = useRBAC({
4053
- cmAside: pluginPermissions["cm.aside"]
4054
- });
4055
- if (!canAside || !isAllowedContentType || !isActiveContentType || !contentTypeConfig) return null;
4056
- if (!config) {
4057
- console.error("CMEditViewAside: Plugin is not configured.");
4058
- return null;
4059
- }
4060
- if (isLoading) return {
4061
- title: panelTitle,
4062
- content: /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: formatMessage({
4063
- id: getTranslation("loading"),
4064
- defaultMessage: "Loading..."
4065
- }) })
4066
- };
4067
- return {
4068
- title: panelTitle,
4069
- content: /* @__PURE__ */ jsx(Path, { config: contentTypeConfig })
4070
- };
4071
- };
4072
- const index = {
4073
- register(app) {
4074
- app.addMenuLink({
4075
- to: `/plugins/${PLUGIN_ID}/paths`,
4076
- icon: PathIcon,
4077
- intlLabel: {
4078
- id: `${PLUGIN_ID}.link.paths`,
4079
- defaultMessage: "Paths"
4080
- },
4081
- Component: async () => {
4082
- const component = await import("./index-fbC3magu.mjs");
4083
- return { default: component.default };
4084
- },
4085
- permissions: [
4086
- pluginPermissions["page.routes"][0]
4087
- ]
4088
- });
4089
- app.addMenuLink({
4090
- to: `/plugins/${PLUGIN_ID}/navigation`,
4091
- icon: NavigationIcon,
4092
- intlLabel: {
4093
- id: `${PLUGIN_ID}.link.navigation`,
4094
- defaultMessage: "Navigation"
4095
- },
4096
- Component: async () => {
4097
- const component = await import("./index-qrrfKpw1.mjs");
4098
- return { default: component.default };
4099
- },
4100
- permissions: [
4101
- pluginPermissions["page.navigation"][0]
4102
- ]
4103
- });
4104
- app.addSettingsLink(
4105
- {
4106
- id: PLUGIN_ID,
4107
- intlLabel: {
4108
- id: `${PLUGIN_ID}.settings.section`,
4109
- defaultMessage: PLUGIN_NAME
4110
- }
4111
- },
4112
- {
4113
- intlLabel: {
4114
- id: `${PLUGIN_ID}.settings.section.general`,
4115
- defaultMessage: "General"
4116
- },
4117
- id: `${PLUGIN_ID}-general`,
4118
- to: `/settings/${PLUGIN_ID}/general`,
4119
- Component: async () => {
4120
- return await import(
4121
- /* webpackChunkName: "webatlas-settings-general-page" */
4122
- "./index-qrC_n9-7.mjs"
4123
- );
4124
- },
4125
- permissions: [
4126
- pluginPermissions["settings.general"][0]
4127
- ]
4128
- }
4129
- );
4130
- app.addSettingsLink(
4131
- PLUGIN_ID,
4132
- {
4133
- intlLabel: {
4134
- id: `${PLUGIN_ID}.settings.navigation`,
4135
- defaultMessage: "Navigation"
4136
- },
4137
- id: `${PLUGIN_ID}-navigation`,
4138
- to: `/settings/${PLUGIN_ID}/navigation`,
4139
- Component: async () => {
4140
- return await import(
4141
- /* webpackChunkName: "webatlas-settings-navigation-page" */
4142
- "./index-DJBnQbrp.mjs"
4143
- );
4144
- },
4145
- permissions: [
4146
- pluginPermissions["settings.navigation"][0]
4147
- ]
4148
- }
4149
- );
4150
- app.registerPlugin({
4151
- id: PLUGIN_ID,
4152
- initializer: Initializer,
4153
- isReady: false,
4154
- name: PLUGIN_ID
4155
- });
4156
- },
4157
- bootstrap(app) {
4158
- app.getPlugin("content-manager").apis.addEditViewSidePanel([CMEditViewAside]);
4159
- },
4160
- async registerTrads({ locales }) {
4161
- return Promise.all(
4162
- locales.map(async (locale) => {
4163
- try {
4164
- const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => import("./de-C-uxto84.mjs"), "./translations/en.json": () => import("./en-B1CHnIH7.mjs") }), `./translations/${locale}.json`, 3);
4165
- return { data, locale };
4166
- } catch {
4167
- return { data: {}, locale };
4168
- }
4169
- })
4170
- );
4171
- }
4172
- };
4173
- export {
4174
- PLUGIN_ID as P,
4175
- Tooltip as T,
4176
- duplicateCheck as a,
4177
- PathInfo as b,
4178
- usePluginConfig as c,
4179
- debounce as d,
4180
- useAllContentTypes as e,
4181
- PLUGIN_NAME as f,
4182
- getTranslation as g,
4183
- PLUGIN_VERSION as h,
4184
- index as i,
4185
- pluginPermissions as p,
4186
- transformToUrl as t,
4187
- useApi as u
4188
- };