@mattisvensson/strapi-plugin-webatlas 0.8.0 → 0.8.2

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