@dotcms/react 0.0.1-alpha.9 → 0.0.1-beta.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 (79) hide show
  1. package/README.md +24 -4
  2. package/es.regexp.to-string.esm.js +1878 -0
  3. package/index.esm.d.ts +1 -0
  4. package/index.esm.js +3461 -0
  5. package/next.esm.d.ts +1 -0
  6. package/next.esm.js +665 -0
  7. package/package.json +34 -28
  8. package/src/index.d.ts +1 -0
  9. package/src/lib/deprecated/components/BlockEditorRenderer/BlockEditorRenderer.d.ts +37 -0
  10. package/src/lib/deprecated/components/BlockEditorRenderer/blocks/Code.d.ts +17 -0
  11. package/src/lib/deprecated/components/BlockEditorRenderer/blocks/Contentlet.d.ts +41 -0
  12. package/src/lib/deprecated/components/BlockEditorRenderer/blocks/Image.d.ts +8 -0
  13. package/src/lib/deprecated/components/BlockEditorRenderer/blocks/Lists.d.ts +22 -0
  14. package/src/lib/deprecated/components/BlockEditorRenderer/blocks/Table.d.ts +16 -0
  15. package/src/lib/deprecated/components/BlockEditorRenderer/blocks/Texts.d.ts +71 -0
  16. package/src/lib/deprecated/components/BlockEditorRenderer/blocks/Video.d.ts +8 -0
  17. package/src/lib/deprecated/components/BlockEditorRenderer/item/BlockEditorBlock.d.ts +12 -0
  18. package/src/lib/deprecated/components/Column/Column.d.ts +19 -0
  19. package/src/lib/deprecated/components/Container/Container.d.ts +19 -0
  20. package/src/lib/deprecated/components/DotEditableText/DotEditableText.d.ts +30 -0
  21. package/src/lib/deprecated/components/DotEditableText/utils.d.ts +36 -0
  22. package/src/lib/{components/DotcmsLayout/DotcmsLayout.tsx → deprecated/components/DotcmsLayout/DotcmsLayout.d.ts} +9 -23
  23. package/src/lib/deprecated/components/PageProvider/PageProvider.d.ts +14 -0
  24. package/src/lib/deprecated/components/Row/Row.d.ts +26 -0
  25. package/src/lib/deprecated/contexts/PageContext.d.ts +8 -0
  26. package/src/lib/deprecated/deprecated_api.d.ts +7 -0
  27. package/src/lib/deprecated/hooks/useCheckHaveContent.d.ts +5 -0
  28. package/src/lib/deprecated/hooks/useDotcmsEditor.d.ts +13 -0
  29. package/src/lib/deprecated/hooks/useDotcmsPageContext.d.ts +9 -0
  30. package/src/lib/deprecated/mocks/mockPageContext.d.ts +7 -0
  31. package/src/lib/deprecated/models/blocks.interface.d.ts +89 -0
  32. package/src/lib/deprecated/models/content-node.interface.d.ts +82 -0
  33. package/src/lib/deprecated/models/index.d.ts +127 -0
  34. package/src/lib/deprecated/utils/utils.d.ts +58 -0
  35. package/src/lib/next/__test__/mock.d.ts +11 -0
  36. package/src/lib/next/components/Column/Column.d.ts +37 -0
  37. package/src/lib/next/components/Container/Container.d.ts +32 -0
  38. package/src/lib/next/components/Container/ContainerFallbakcs.d.ts +24 -0
  39. package/src/lib/next/components/Contentlet/Contentlet.d.ts +32 -0
  40. package/src/lib/next/components/DotCMSLayoutBody/DotCMSLayoutBody.d.ts +36 -0
  41. package/src/lib/next/components/DotCMSLayoutBody/components/ErrorMessage.d.ts +9 -0
  42. package/src/lib/next/components/FallbackComponent/FallbackComponent.d.ts +41 -0
  43. package/src/lib/next/components/Row/Row.d.ts +21 -0
  44. package/src/lib/next/contexts/DotCMSPageContext.d.ts +23 -0
  45. package/src/lib/next/hooks/useCheckVisibleContent.d.ts +24 -0
  46. package/src/lib/next/hooks/useIsDevMode.d.ts +13 -0
  47. package/src/lib/next/types.d.ts +421 -0
  48. package/src/lib/next/utils/index.d.ts +136 -0
  49. package/src/next.d.ts +1 -0
  50. package/.babelrc +0 -12
  51. package/.eslintrc.json +0 -18
  52. package/jest.config.ts +0 -11
  53. package/project.json +0 -51
  54. package/src/index.ts +0 -4
  55. package/src/lib/components/Column/Column.module.css +0 -99
  56. package/src/lib/components/Column/Column.spec.tsx +0 -78
  57. package/src/lib/components/Column/Column.tsx +0 -45
  58. package/src/lib/components/Container/Container.module.css +0 -7
  59. package/src/lib/components/Container/Container.spec.tsx +0 -82
  60. package/src/lib/components/Container/Container.tsx +0 -105
  61. package/src/lib/components/DotcmsLayout/DotcmsLayout.module.css +0 -7
  62. package/src/lib/components/DotcmsLayout/DotcmsLayout.spec.tsx +0 -41
  63. package/src/lib/components/PageProvider/PageProvider.module.css +0 -7
  64. package/src/lib/components/PageProvider/PageProvider.spec.tsx +0 -54
  65. package/src/lib/components/PageProvider/PageProvider.tsx +0 -95
  66. package/src/lib/components/Row/Row.module.css +0 -5
  67. package/src/lib/components/Row/Row.spec.tsx +0 -92
  68. package/src/lib/components/Row/Row.tsx +0 -51
  69. package/src/lib/contexts/PageContext.tsx +0 -5
  70. package/src/lib/hooks/useDotcmsEditor.spec.ts +0 -56
  71. package/src/lib/hooks/useDotcmsEditor.ts +0 -29
  72. package/src/lib/hooks/useDotcmsPageContext.spec.tsx +0 -43
  73. package/src/lib/hooks/useDotcmsPageContext.tsx +0 -15
  74. package/src/lib/mocks/mockPageContext.tsx +0 -84
  75. package/src/lib/utils/utils.ts +0 -69
  76. package/tsconfig.json +0 -20
  77. package/tsconfig.lib.json +0 -23
  78. package/tsconfig.spec.json +0 -20
  79. /package/src/lib/{mocks/index.ts → deprecated/mocks/index.d.ts} +0 -0
package/index.esm.js ADDED
@@ -0,0 +1,3461 @@
1
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
+ import { s as styleInject, f as functionUncurryThis, t as toString$4, r as requireObjectCoercible$1, a as toIntegerOrInfinity$1, i as iteratorDefine, b as internalState, c as createIterResultObject$2, d as fails$2, w as wellKnownSymbol$4, e as descriptors, g as classofRaw$1, h as aCallable$2, j as functionBindNative, m as makeBuiltInExports, o as objectDefineProperty, k as objectIsPrototypeOf, l as functionCall, n as anObject$4, p as getMethod$2, q as iterators, u as getBuiltIn$1, v as isCallable$2, x as classof$3, y as inspectSource$1, z as createPropertyDescriptor$2, A as isNullOrUndefined$1, B as tryToString$1, C as toObject$1, D as lengthOfArrayLike$1, E as global$3, F as defineBuiltIn$5, G as arraySlice$2, _ as _export, H as setToStringTag$2, I as iteratorCreateConstructor, J as isObject$1, K as objectCreate, L as hasOwnProperty_1, M as objectAssign } from './es.regexp.to-string.esm.js';
3
+ import { useState, useEffect, createContext, useRef, useContext, createElement, forwardRef } from 'react';
4
+ import { isInsideEditor, initEditor, updateNavigation, destroyEditor, DotCmsClient, postMessageToEditor, CLIENT_ACTIONS, NOTIFY_CLIENT, initInlineEditing } from '@dotcms/client';
5
+ import { Editor } from '@tinymce/tinymce-react';
6
+
7
+ var isPure = false;
8
+
9
+ /**
10
+ * Custom Hook to handle the DotCMS editor interaction with the page.
11
+ *
12
+ * @category Hooks
13
+ * @param {DotcmsPageProps} props {
14
+ * pageContext,
15
+ * config,
16
+ * }
17
+ * @returns {DotCMSPageContext} The context for a DotCMS page provided by the editor.
18
+ */
19
+ const useDotcmsEditor = ({
20
+ pageContext,
21
+ config
22
+ }) => {
23
+ const {
24
+ pathname,
25
+ onReload,
26
+ editor
27
+ } = config;
28
+ const [state, setState] = useState(Object.assign({}, pageContext, {
29
+ isInsideEditor: false
30
+ }));
31
+ /**
32
+ * Initializes the DotCMS editor.
33
+ */
34
+ useEffect(() => {
35
+ if (!isInsideEditor()) {
36
+ return;
37
+ }
38
+ initEditor({
39
+ pathname
40
+ });
41
+ updateNavigation(pathname || '/');
42
+ setState(prevState => Object.assign({}, prevState, {
43
+ isInsideEditor: true
44
+ }));
45
+ return () => destroyEditor();
46
+ }, [pathname]);
47
+ /**
48
+ * Reloads the page when changes are made in the editor.
49
+ */
50
+ useEffect(() => {
51
+ const insideEditor = isInsideEditor();
52
+ const client = DotCmsClient.instance;
53
+ if (!insideEditor || !onReload) {
54
+ return;
55
+ }
56
+ client.editor.on('changes', () => onReload == null ? void 0 : onReload());
57
+ return () => client.editor.off('changes');
58
+ }, [onReload]);
59
+ /**
60
+ * Sends a message to the editor when the client is ready.
61
+ */
62
+ useEffect(() => {
63
+ if (!isInsideEditor()) {
64
+ return;
65
+ }
66
+ postMessageToEditor({
67
+ action: CLIENT_ACTIONS.CLIENT_READY,
68
+ payload: editor
69
+ });
70
+ }, [pathname, editor]);
71
+ /**
72
+ * Updates the page asset when changes are made in the editor.
73
+ */
74
+ useEffect(() => {
75
+ if (!isInsideEditor()) {
76
+ return;
77
+ }
78
+ const client = DotCmsClient.instance;
79
+ client.editor.on('changes', data => {
80
+ const pageAsset = data;
81
+ setState(state => Object.assign({}, state, {
82
+ pageAsset
83
+ }));
84
+ });
85
+ return () => client.editor.off('changes');
86
+ }, []);
87
+ return state;
88
+ };
89
+
90
+ /**
91
+ * The `PageContext` is a React context that provides access to the DotCMS page context.
92
+ *
93
+ * @category Contexts
94
+ */
95
+ const PageContext = /*#__PURE__*/createContext(null);
96
+
97
+ /**
98
+ * `PageProvider` is a functional component that provides a context for a DotCMS page.
99
+ * It takes a `PageProviderProps` object as a parameter and returns a JSX element.
100
+ *
101
+ * @category Components
102
+ * @param {PageProviderProps} props - The properties for the PageProvider. Includes an `entity` and `children`.
103
+ * @returns {JSX.Element} - A JSX element that provides a context for a DotCMS page.
104
+ */
105
+ function PageProvider(props) {
106
+ const {
107
+ pageContext,
108
+ children
109
+ } = props;
110
+ return jsx(PageContext.Provider, {
111
+ value: pageContext,
112
+ children: children
113
+ });
114
+ }
115
+
116
+ var css_248z$1 = ".Row-module_row__1QEdR {\n display: grid;\n grid-template-columns: repeat(12, 1fr);\n gap: 1rem;\n}\n";
117
+ var styles$1 = {"row":"Row-module_row__1QEdR"};
118
+ styleInject(css_248z$1);
119
+
120
+ var css_248z = ".Column-module_col-start-1__pAqyF {\n grid-column-start: 1;\n}\n\n.Column-module_col-start-2__WwVhl {\n grid-column-start: 2;\n}\n\n.Column-module_col-start-3__DAtqM {\n grid-column-start: 3;\n}\n\n.Column-module_col-start-4__KAXJl {\n grid-column-start: 4;\n}\n\n.Column-module_col-start-5__9yg8H {\n grid-column-start: 5;\n}\n\n.Column-module_col-start-6__L9Fl1 {\n grid-column-start: 6;\n}\n\n.Column-module_col-start-7__7GWMg {\n grid-column-start: 7;\n}\n\n.Column-module_col-start-8__VPNje {\n grid-column-start: 8;\n}\n\n.Column-module_col-start-9__TQinR {\n grid-column-start: 9;\n}\n\n.Column-module_col-start-10__WuD2n {\n grid-column-start: 10;\n}\n\n.Column-module_col-start-11__ZYzHu {\n grid-column-start: 11;\n}\n\n.Column-module_col-start-12__XupQX {\n grid-column-start: 12;\n}\n\n.Column-module_col-end-1__thNVg {\n grid-column-end: 1;\n}\n\n.Column-module_col-end-2__7vCsE {\n grid-column-end: 2;\n}\n\n.Column-module_col-end-3__TiQJe {\n grid-column-end: 3;\n}\n\n.Column-module_col-end-4__66z6K {\n grid-column-end: 4;\n}\n\n.Column-module_col-end-5__MLwPh {\n grid-column-end: 5;\n}\n\n.Column-module_col-end-6__dz6-q {\n grid-column-end: 6;\n}\n\n.Column-module_col-end-7__Loe0Q {\n grid-column-end: 7;\n}\n\n.Column-module_col-end-8__NePGi {\n grid-column-end: 8;\n}\n\n.Column-module_col-end-9__V0-is {\n grid-column-end: 9;\n}\n\n.Column-module_col-end-10__b-1ia {\n grid-column-end: 10;\n}\n\n.Column-module_col-end-11__QroWM {\n grid-column-end: 11;\n}\n\n.Column-module_col-end-12__j-YYw {\n grid-column-end: 12;\n}\n\n.Column-module_col-end-13__khBAA {\n grid-column-end: 13;\n}\n";
121
+ var styles = {"col-start-1":"Column-module_col-start-1__pAqyF","col-start-2":"Column-module_col-start-2__WwVhl","col-start-3":"Column-module_col-start-3__DAtqM","col-start-4":"Column-module_col-start-4__KAXJl","col-start-5":"Column-module_col-start-5__9yg8H","col-start-6":"Column-module_col-start-6__L9Fl1","col-start-7":"Column-module_col-start-7__7GWMg","col-start-8":"Column-module_col-start-8__VPNje","col-start-9":"Column-module_col-start-9__TQinR","col-start-10":"Column-module_col-start-10__WuD2n","col-start-11":"Column-module_col-start-11__ZYzHu","col-start-12":"Column-module_col-start-12__XupQX","col-end-1":"Column-module_col-end-1__thNVg","col-end-2":"Column-module_col-end-2__7vCsE","col-end-3":"Column-module_col-end-3__TiQJe","col-end-4":"Column-module_col-end-4__66z6K","col-end-5":"Column-module_col-end-5__MLwPh","col-end-6":"Column-module_col-end-6__dz6-q","col-end-7":"Column-module_col-end-7__Loe0Q","col-end-8":"Column-module_col-end-8__NePGi","col-end-9":"Column-module_col-end-9__V0-is","col-end-10":"Column-module_col-end-10__b-1ia","col-end-11":"Column-module_col-end-11__QroWM","col-end-12":"Column-module_col-end-12__j-YYw","col-end-13":"Column-module_col-end-13__khBAA"};
122
+ styleInject(css_248z);
123
+
124
+ const endClassMap = {
125
+ 1: 'col-end-1',
126
+ 2: 'col-end-2',
127
+ 3: 'col-end-3',
128
+ 4: 'col-end-4',
129
+ 5: 'col-end-5',
130
+ 6: 'col-end-6',
131
+ 7: 'col-end-7',
132
+ 8: 'col-end-8',
133
+ 9: 'col-end-9',
134
+ 10: 'col-end-10',
135
+ 11: 'col-end-11',
136
+ 12: 'col-end-12',
137
+ 13: 'col-end-13'
138
+ };
139
+ const startClassMap = {
140
+ 1: 'col-start-1',
141
+ 2: 'col-start-2',
142
+ 3: 'col-start-3',
143
+ 4: 'col-start-4',
144
+ 5: 'col-start-5',
145
+ 6: 'col-start-6',
146
+ 7: 'col-start-7',
147
+ 8: 'col-start-8',
148
+ 9: 'col-start-9',
149
+ 10: 'col-start-10',
150
+ 11: 'col-start-11',
151
+ 12: 'col-start-12'
152
+ };
153
+ /**
154
+ * Get the container data from the containers object using the current container reference obtained from the layout.
155
+ *
156
+ * @param {ContainerData} containers
157
+ * @param {DotCMSPageContext['pageAsset']['layout']['body']['rows'][0]['columns'][0]['containers'][0]} containerRef
158
+ * @returns {Object} Container with all the data it has.
159
+ */
160
+ const getContainersData = (containers, containerRef) => {
161
+ var _containers$identifie;
162
+ const {
163
+ identifier,
164
+ uuid
165
+ } = containerRef;
166
+ const {
167
+ containerStructures,
168
+ container
169
+ } = containers[identifier];
170
+ // Get the variant id
171
+ const {
172
+ variantId
173
+ } = (container == null ? void 0 : container.parentPermissionable) || {};
174
+ // Get accepts types of content types for this container
175
+ const acceptTypes = containerStructures.map(structure => structure.contentTypeVar).join(',');
176
+ // Get the contentlets for "this" container
177
+ const contentlets = (_containers$identifie = containers[identifier].contentlets[`uuid-${uuid}`]) != null ? _containers$identifie : containers[identifier].contentlets[`uuid-dotParser_${uuid}`];
178
+ if (!contentlets) {
179
+ console.warn(`We couldn't find the contentlets for the container with the identifier ${identifier} and the uuid ${uuid} becareful by adding content to this container.\nWe recommend to change the container in the layout and add the content again.`);
180
+ }
181
+ return Object.assign({}, containers[identifier].container, {
182
+ acceptTypes,
183
+ contentlets: contentlets != null ? contentlets : [],
184
+ variantId
185
+ });
186
+ };
187
+ /**
188
+ * Combine classes into a single string.
189
+ *
190
+ * @param {string[]} classes
191
+ * @returns {string} Combined classes
192
+ */
193
+ const combineClasses = classes => classes.filter(Boolean).join(' ');
194
+ /**
195
+ * Get the start and end classes for the column based on the left offset and width.
196
+ *
197
+ * @param {number} start
198
+ * @param {number} end
199
+ * @returns {Object} Start and end classes
200
+ */
201
+ const getPositionStyleClasses = (start, end) => {
202
+ const startClass = startClassMap[start];
203
+ const endClass = endClassMap[end];
204
+ return {
205
+ startClass,
206
+ endClass
207
+ };
208
+ };
209
+ /**
210
+ * Validates the structure of a Block Editor block.
211
+ *
212
+ * This function checks that:
213
+ * 1. The blocks parameter is a valid object
214
+ * 2. The block has a 'doc' type
215
+ * 3. The block has a valid content array that is not empty
216
+ *
217
+ * @param {Block} blocks - The blocks structure to validate
218
+ * @returns {BlockEditorState} Object containing validation state and any error message
219
+ * @property {boolean} BlockEditorState.isValid - Whether the blocks structure is valid
220
+ * @property {string | null} BlockEditorState.error - Error message if invalid, null if valid
221
+ */
222
+ const isValidBlocks = blocks => {
223
+ if (!blocks) {
224
+ return {
225
+ error: `Error: Blocks object is not defined`
226
+ };
227
+ }
228
+ if (typeof blocks !== 'object') {
229
+ return {
230
+ error: `Error: Blocks must be an object, but received: ${typeof blocks}`
231
+ };
232
+ }
233
+ if (blocks.type !== 'doc') {
234
+ return {
235
+ error: 'Error: Blocks must have a doc type'
236
+ };
237
+ }
238
+ if (!blocks.content || !Array.isArray(blocks.content)) {
239
+ return {
240
+ error: 'Error: Blocks must have a valid content array'
241
+ };
242
+ }
243
+ if (blocks.content.length === 0) {
244
+ return {
245
+ error: 'Error: Blocks content is empty'
246
+ };
247
+ }
248
+ return {
249
+ error: null
250
+ };
251
+ };
252
+
253
+ const useCheckHaveContent = () => {
254
+ const contentletDivRef = useRef(null);
255
+ const [haveContent, setHaveContent] = useState(false);
256
+ useEffect(() => {
257
+ if (!contentletDivRef.current) {
258
+ return;
259
+ }
260
+ const childElement = contentletDivRef.current.firstElementChild;
261
+ if (!childElement) {
262
+ return;
263
+ }
264
+ const height = childElement.getBoundingClientRect().height;
265
+ if (height > 0) {
266
+ setHaveContent(true);
267
+ return;
268
+ }
269
+ setHaveContent(false);
270
+ }, [contentletDivRef]);
271
+ return {
272
+ contentletDivRef,
273
+ haveContent
274
+ };
275
+ };
276
+
277
+ /**
278
+ * Component to render when there is no component for the content type.
279
+ *
280
+ * @param {{ readonly contentType: string }} { contentType }
281
+ * @return {*}
282
+ */
283
+ function NoComponent({
284
+ contentType
285
+ }) {
286
+ return jsxs("div", {
287
+ "data-testid": "no-component",
288
+ children: ["No Component for ", contentType]
289
+ });
290
+ }
291
+ /**
292
+ * Component to render when there is no content in the container.
293
+ *
294
+ * @return {*}
295
+ */
296
+ function EmptyContent() {
297
+ return null;
298
+ }
299
+ /**
300
+ * Renders a Container with its content using information provided by dotCMS Page API.
301
+ *
302
+ * @see {@link https://www.dotcms.com/docs/latest/page-rest-api-layout-as-a-service-laas}
303
+ * @export
304
+ * @param {ContainerProps} { containerRef }
305
+ * @return {JSX.Element} Rendered container with content
306
+ */
307
+ function Container({
308
+ containerRef
309
+ }) {
310
+ const {
311
+ isInsideEditor
312
+ } = useContext(PageContext);
313
+ const {
314
+ identifier,
315
+ uuid
316
+ } = containerRef;
317
+ const {
318
+ haveContent,
319
+ contentletDivRef
320
+ } = useCheckHaveContent();
321
+ // Get the containers from the global context
322
+ const {
323
+ pageAsset: {
324
+ containers
325
+ },
326
+ components
327
+ } = useContext(PageContext);
328
+ const {
329
+ acceptTypes,
330
+ contentlets,
331
+ maxContentlets,
332
+ variantId,
333
+ path
334
+ } = getContainersData(containers, containerRef);
335
+ const container = {
336
+ acceptTypes,
337
+ identifier: path != null ? path : identifier,
338
+ maxContentlets,
339
+ variantId,
340
+ uuid
341
+ };
342
+ const containerStyles = contentlets.length ? undefined : {
343
+ width: '100%',
344
+ backgroundColor: '#ECF0FD',
345
+ display: 'flex',
346
+ justifyContent: 'center',
347
+ alignItems: 'center',
348
+ color: '#030E32',
349
+ height: '10rem'
350
+ };
351
+ const ContainerChildren = contentlets.map(contentlet => {
352
+ const ContentTypeComponent = components[contentlet.contentType];
353
+ const DefaultComponent = components['CustomNoComponent'] || NoComponent;
354
+ const Component = isInsideEditor ? ContentTypeComponent || DefaultComponent : ContentTypeComponent || EmptyContent;
355
+ return isInsideEditor ? jsx("div", {
356
+ "data-testid": "dot-contentlet",
357
+ "data-dot-object": "contentlet",
358
+ "data-dot-identifier": contentlet.identifier,
359
+ "data-dot-basetype": contentlet.baseType,
360
+ "data-dot-title": contentlet.widgetTitle || contentlet.title,
361
+ "data-dot-inode": contentlet.inode,
362
+ "data-dot-type": contentlet.contentType,
363
+ "data-dot-container": JSON.stringify(container),
364
+ "data-dot-on-number-of-pages": contentlet.onNumberOfPages,
365
+ ref: contentletDivRef,
366
+ style: {
367
+ minHeight: haveContent ? undefined : '4rem'
368
+ },
369
+ children: jsx(Component, Object.assign({}, contentlet))
370
+ }, contentlet.identifier) : (/*#__PURE__*/createElement(Component, Object.assign({}, contentlet, {
371
+ key: contentlet.identifier
372
+ })));
373
+ });
374
+ return isInsideEditor ? jsx("div", {
375
+ "data-testid": "dot-container",
376
+ "data-dot-object": "container",
377
+ "data-dot-accept-types": acceptTypes,
378
+ "data-dot-identifier": path != null ? path : identifier,
379
+ "data-max-contentlets": maxContentlets,
380
+ "data-dot-uuid": uuid,
381
+ style: containerStyles,
382
+ children: ContainerChildren.length ? ContainerChildren : 'This container is empty.'
383
+ }) :
384
+ // eslint-disable-next-line react/jsx-no-useless-fragment
385
+ jsx(Fragment, {
386
+ children: ContainerChildren
387
+ });
388
+ }
389
+
390
+ /**
391
+ * Renders a Column with its containers using information provided by dotCMS Page API.
392
+ *
393
+ * @see {@link https://www.dotcms.com/docs/latest/page-rest-api-layout-as-a-service-laas}
394
+ * @export
395
+ * @param {ColumnProps} { column }
396
+ * @return {JSX.Element} Rendered column with containers
397
+ */
398
+ function Column({
399
+ column
400
+ }) {
401
+ const {
402
+ isInsideEditor
403
+ } = useContext(PageContext);
404
+ const {
405
+ startClass,
406
+ endClass
407
+ } = getPositionStyleClasses(column.leftOffset, column.width + column.leftOffset);
408
+ const combinedClasses = combineClasses([styles[endClass], styles[startClass]]);
409
+ const columnProps = isInsideEditor ? {
410
+ 'data-dot': 'column',
411
+ 'data-testid': 'column'
412
+ } : {};
413
+ return jsx("div", Object.assign({}, columnProps, {
414
+ className: combinedClasses,
415
+ children: jsx("div", {
416
+ className: column.styleClass,
417
+ children: column.containers.map(container => jsx(Container, {
418
+ containerRef: container
419
+ }, `${container.identifier}-${container.uuid}`))
420
+ })
421
+ }));
422
+ }
423
+
424
+ /**
425
+ * This component renders a row with all it's content using the layout provided by dotCMS Page API.
426
+ *
427
+ * @see {@link https://www.dotcms.com/docs/latest/page-rest-api-layout-as-a-service-laas}
428
+ * @category Components
429
+ * @param {React.ForwardedRef<HTMLDivElement, RowProps>} ref
430
+ * @return {JSX.Element} Rendered rows with columns
431
+ */
432
+ const Row = /*#__PURE__*/forwardRef((props, ref) => {
433
+ const {
434
+ isInsideEditor
435
+ } = useContext(PageContext);
436
+ const {
437
+ row
438
+ } = props;
439
+ const rowProps = isInsideEditor ? {
440
+ 'data-dot': 'row',
441
+ 'data-testid': 'row',
442
+ ref
443
+ } : {};
444
+ return jsx("div", {
445
+ className: row.styleClass,
446
+ children: jsx("div", {
447
+ className: "container",
448
+ children: jsx("div", Object.assign({}, rowProps, {
449
+ className: styles$1.row,
450
+ children: row.columns.map((column, index) => jsx(Column, {
451
+ column: column
452
+ }, index))
453
+ }))
454
+ })
455
+ });
456
+ });
457
+
458
+ /**
459
+ * `DotcmsLayout` is a functional component that renders a layout for a DotCMS page.
460
+ * It takes a `DotcmsPageProps` object as a parameter and returns a JSX element.
461
+ *
462
+ * @category Components
463
+ * @param {DotcmsPageProps} props - The properties for the DotCMS page.
464
+ * @returns {JSX.Element} - A JSX element that represents the layout for a DotCMS page.
465
+ * @deprecated Use {@link https://github.com/dotCMS/core/blob/main/core-web/libs/sdk/react/src/lib/next/components/DotCMSLayoutBody/DotCMSLayoutBody.tsx DotCMSLayoutBody} instead.
466
+ */
467
+ function DotcmsLayout(dotPageProps) {
468
+ var _pageContext$pageAsse;
469
+ const pageContext = useDotcmsEditor(dotPageProps);
470
+ return jsx(PageProvider, {
471
+ pageContext: pageContext,
472
+ children: (_pageContext$pageAsse = pageContext.pageAsset) == null || (_pageContext$pageAsse = _pageContext$pageAsse.layout) == null ? void 0 : _pageContext$pageAsse.body.rows.map((row, index) => jsx(Row, {
473
+ row: row
474
+ }, index))
475
+ });
476
+ }
477
+
478
+ var uncurryThis$9 = functionUncurryThis;
479
+ var toIntegerOrInfinity = toIntegerOrInfinity$1;
480
+ var toString$3 = toString$4;
481
+ var requireObjectCoercible = requireObjectCoercible$1;
482
+
483
+ var charAt$3 = uncurryThis$9(''.charAt);
484
+ var charCodeAt$1 = uncurryThis$9(''.charCodeAt);
485
+ var stringSlice$2 = uncurryThis$9(''.slice);
486
+
487
+ var createMethod = function (CONVERT_TO_STRING) {
488
+ return function ($this, pos) {
489
+ var S = toString$3(requireObjectCoercible($this));
490
+ var position = toIntegerOrInfinity(pos);
491
+ var size = S.length;
492
+ var first, second;
493
+ if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
494
+ first = charCodeAt$1(S, position);
495
+ return first < 0xD800 || first > 0xDBFF || position + 1 === size
496
+ || (second = charCodeAt$1(S, position + 1)) < 0xDC00 || second > 0xDFFF
497
+ ? CONVERT_TO_STRING
498
+ ? charAt$3(S, position)
499
+ : first
500
+ : CONVERT_TO_STRING
501
+ ? stringSlice$2(S, position, position + 2)
502
+ : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
503
+ };
504
+ };
505
+
506
+ var stringMultibyte = {
507
+ // `String.prototype.codePointAt` method
508
+ // https://tc39.es/ecma262/#sec-string.prototype.codepointat
509
+ codeAt: createMethod(false),
510
+ // `String.prototype.at` method
511
+ // https://github.com/mathiasbynens/String.prototype.at
512
+ charAt: createMethod(true)
513
+ };
514
+
515
+ var charAt$2 = stringMultibyte.charAt;
516
+ var toString$2 = toString$4;
517
+ var InternalStateModule$2 = internalState;
518
+ var defineIterator = iteratorDefine;
519
+ var createIterResultObject$1 = createIterResultObject$2;
520
+
521
+ var STRING_ITERATOR = 'String Iterator';
522
+ var setInternalState$2 = InternalStateModule$2.set;
523
+ var getInternalState = InternalStateModule$2.getterFor(STRING_ITERATOR);
524
+
525
+ // `String.prototype[@@iterator]` method
526
+ // https://tc39.es/ecma262/#sec-string.prototype-@@iterator
527
+ defineIterator(String, 'String', function (iterated) {
528
+ setInternalState$2(this, {
529
+ type: STRING_ITERATOR,
530
+ string: toString$2(iterated),
531
+ index: 0
532
+ });
533
+ // `%StringIteratorPrototype%.next` method
534
+ // https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next
535
+ }, function next() {
536
+ var state = getInternalState(this);
537
+ var string = state.string;
538
+ var index = state.index;
539
+ var point;
540
+ if (index >= string.length) return createIterResultObject$1(undefined, true);
541
+ point = charAt$2(string, index);
542
+ state.index += point.length;
543
+ return createIterResultObject$1(point, false);
544
+ });
545
+
546
+ var fails$1 = fails$2;
547
+ var wellKnownSymbol$3 = wellKnownSymbol$4;
548
+ var DESCRIPTORS$5 = descriptors;
549
+ var IS_PURE = isPure;
550
+
551
+ var ITERATOR$3 = wellKnownSymbol$3('iterator');
552
+
553
+ var urlConstructorDetection = !fails$1(function () {
554
+ // eslint-disable-next-line unicorn/relative-url-style -- required for testing
555
+ var url = new URL('b?a=1&b=2&c=3', 'http://a');
556
+ var params = url.searchParams;
557
+ var params2 = new URLSearchParams('a=1&a=2&b=3');
558
+ var result = '';
559
+ url.pathname = 'c%20d';
560
+ params.forEach(function (value, key) {
561
+ params['delete']('b');
562
+ result += key + value;
563
+ });
564
+ params2['delete']('a', 2);
565
+ // `undefined` case is a Chromium 117 bug
566
+ // https://bugs.chromium.org/p/v8/issues/detail?id=14222
567
+ params2['delete']('b', undefined);
568
+ return (IS_PURE && (!url.toJSON || !params2.has('a', 1) || params2.has('a', 2) || !params2.has('a', undefined) || params2.has('b')))
569
+ || (!params.size && (IS_PURE || !DESCRIPTORS$5))
570
+ || !params.sort
571
+ || url.href !== 'http://a/c%20d?a=1&c=3'
572
+ || params.get('c') !== '3'
573
+ || String(new URLSearchParams('?a=1')) !== 'a=1'
574
+ || !params[ITERATOR$3]
575
+ // throws in Edge
576
+ || new URL('https://a@b').username !== 'a'
577
+ || new URLSearchParams(new URLSearchParams('a=b')).get('a') !== 'b'
578
+ // not punycoded in Edge
579
+ || new URL('http://тест').host !== 'xn--e1aybc'
580
+ // not escaped in Chrome 62-
581
+ || new URL('http://a#б').hash !== '#%D0%B1'
582
+ // fails in Chrome 66-
583
+ || result !== 'a1c3'
584
+ // throws in Safari
585
+ || new URL('http://x', undefined).host !== 'x';
586
+ });
587
+
588
+ var classofRaw = classofRaw$1;
589
+ var uncurryThis$8 = functionUncurryThis;
590
+
591
+ var functionUncurryThisClause = function (fn) {
592
+ // Nashorn bug:
593
+ // https://github.com/zloirock/core-js/issues/1128
594
+ // https://github.com/zloirock/core-js/issues/1130
595
+ if (classofRaw(fn) === 'Function') return uncurryThis$8(fn);
596
+ };
597
+
598
+ var uncurryThis$7 = functionUncurryThisClause;
599
+ var aCallable$1 = aCallable$2;
600
+ var NATIVE_BIND = functionBindNative;
601
+
602
+ var bind$3 = uncurryThis$7(uncurryThis$7.bind);
603
+
604
+ // optional / simple context binding
605
+ var functionBindContext = function (fn, that) {
606
+ aCallable$1(fn);
607
+ return that === undefined ? fn : NATIVE_BIND ? bind$3(fn, that) : function (/* ...args */) {
608
+ return fn.apply(that, arguments);
609
+ };
610
+ };
611
+
612
+ var makeBuiltIn = makeBuiltInExports;
613
+ var defineProperty = objectDefineProperty;
614
+
615
+ var defineBuiltInAccessor$3 = function (target, name, descriptor) {
616
+ if (descriptor.get) makeBuiltIn(descriptor.get, name, { getter: true });
617
+ if (descriptor.set) makeBuiltIn(descriptor.set, name, { setter: true });
618
+ return defineProperty.f(target, name, descriptor);
619
+ };
620
+
621
+ var isPrototypeOf = objectIsPrototypeOf;
622
+
623
+ var $TypeError$2 = TypeError;
624
+
625
+ var anInstance$2 = function (it, Prototype) {
626
+ if (isPrototypeOf(Prototype, it)) return it;
627
+ throw new $TypeError$2('Incorrect invocation');
628
+ };
629
+
630
+ var call$4 = functionCall;
631
+ var anObject$3 = anObject$4;
632
+ var getMethod$1 = getMethod$2;
633
+
634
+ var iteratorClose$1 = function (iterator, kind, value) {
635
+ var innerResult, innerError;
636
+ anObject$3(iterator);
637
+ try {
638
+ innerResult = getMethod$1(iterator, 'return');
639
+ if (!innerResult) {
640
+ if (kind === 'throw') throw value;
641
+ return value;
642
+ }
643
+ innerResult = call$4(innerResult, iterator);
644
+ } catch (error) {
645
+ innerError = true;
646
+ innerResult = error;
647
+ }
648
+ if (kind === 'throw') throw value;
649
+ if (innerError) throw innerResult;
650
+ anObject$3(innerResult);
651
+ return value;
652
+ };
653
+
654
+ var anObject$2 = anObject$4;
655
+ var iteratorClose = iteratorClose$1;
656
+
657
+ // call something on iterator step with safe closing on error
658
+ var callWithSafeIterationClosing$1 = function (iterator, fn, value, ENTRIES) {
659
+ try {
660
+ return ENTRIES ? fn(anObject$2(value)[0], value[1]) : fn(value);
661
+ } catch (error) {
662
+ iteratorClose(iterator, 'throw', error);
663
+ }
664
+ };
665
+
666
+ var wellKnownSymbol$2 = wellKnownSymbol$4;
667
+ var Iterators$1 = iterators;
668
+
669
+ var ITERATOR$2 = wellKnownSymbol$2('iterator');
670
+ var ArrayPrototype = Array.prototype;
671
+
672
+ // check on default Array iterator
673
+ var isArrayIteratorMethod$1 = function (it) {
674
+ return it !== undefined && (Iterators$1.Array === it || ArrayPrototype[ITERATOR$2] === it);
675
+ };
676
+
677
+ var uncurryThis$6 = functionUncurryThis;
678
+ var fails = fails$2;
679
+ var isCallable$1 = isCallable$2;
680
+ var classof$2 = classof$3;
681
+ var getBuiltIn = getBuiltIn$1;
682
+ var inspectSource = inspectSource$1;
683
+
684
+ var noop = function () { /* empty */ };
685
+ var construct = getBuiltIn('Reflect', 'construct');
686
+ var constructorRegExp = /^\s*(?:class|function)\b/;
687
+ var exec$2 = uncurryThis$6(constructorRegExp.exec);
688
+ var INCORRECT_TO_STRING = !constructorRegExp.test(noop);
689
+
690
+ var isConstructorModern = function isConstructor(argument) {
691
+ if (!isCallable$1(argument)) return false;
692
+ try {
693
+ construct(noop, [], argument);
694
+ return true;
695
+ } catch (error) {
696
+ return false;
697
+ }
698
+ };
699
+
700
+ var isConstructorLegacy = function isConstructor(argument) {
701
+ if (!isCallable$1(argument)) return false;
702
+ switch (classof$2(argument)) {
703
+ case 'AsyncFunction':
704
+ case 'GeneratorFunction':
705
+ case 'AsyncGeneratorFunction': return false;
706
+ }
707
+ try {
708
+ // we can't check .prototype since constructors produced by .bind haven't it
709
+ // `Function#toString` throws on some built-it function in some legacy engines
710
+ // (for example, `DOMQuad` and similar in FF41-)
711
+ return INCORRECT_TO_STRING || !!exec$2(constructorRegExp, inspectSource(argument));
712
+ } catch (error) {
713
+ return true;
714
+ }
715
+ };
716
+
717
+ isConstructorLegacy.sham = true;
718
+
719
+ // `IsConstructor` abstract operation
720
+ // https://tc39.es/ecma262/#sec-isconstructor
721
+ var isConstructor$1 = !construct || fails(function () {
722
+ var called;
723
+ return isConstructorModern(isConstructorModern.call)
724
+ || !isConstructorModern(Object)
725
+ || !isConstructorModern(function () { called = true; })
726
+ || called;
727
+ }) ? isConstructorLegacy : isConstructorModern;
728
+
729
+ var DESCRIPTORS$4 = descriptors;
730
+ var definePropertyModule = objectDefineProperty;
731
+ var createPropertyDescriptor$1 = createPropertyDescriptor$2;
732
+
733
+ var createProperty$1 = function (object, key, value) {
734
+ if (DESCRIPTORS$4) definePropertyModule.f(object, key, createPropertyDescriptor$1(0, value));
735
+ else object[key] = value;
736
+ };
737
+
738
+ var classof$1 = classof$3;
739
+ var getMethod = getMethod$2;
740
+ var isNullOrUndefined = isNullOrUndefined$1;
741
+ var Iterators = iterators;
742
+ var wellKnownSymbol$1 = wellKnownSymbol$4;
743
+
744
+ var ITERATOR$1 = wellKnownSymbol$1('iterator');
745
+
746
+ var getIteratorMethod$3 = function (it) {
747
+ if (!isNullOrUndefined(it)) return getMethod(it, ITERATOR$1)
748
+ || getMethod(it, '@@iterator')
749
+ || Iterators[classof$1(it)];
750
+ };
751
+
752
+ var call$3 = functionCall;
753
+ var aCallable = aCallable$2;
754
+ var anObject$1 = anObject$4;
755
+ var tryToString = tryToString$1;
756
+ var getIteratorMethod$2 = getIteratorMethod$3;
757
+
758
+ var $TypeError$1 = TypeError;
759
+
760
+ var getIterator$2 = function (argument, usingIterator) {
761
+ var iteratorMethod = arguments.length < 2 ? getIteratorMethod$2(argument) : usingIterator;
762
+ if (aCallable(iteratorMethod)) return anObject$1(call$3(iteratorMethod, argument));
763
+ throw new $TypeError$1(tryToString(argument) + ' is not iterable');
764
+ };
765
+
766
+ var bind$2 = functionBindContext;
767
+ var call$2 = functionCall;
768
+ var toObject = toObject$1;
769
+ var callWithSafeIterationClosing = callWithSafeIterationClosing$1;
770
+ var isArrayIteratorMethod = isArrayIteratorMethod$1;
771
+ var isConstructor = isConstructor$1;
772
+ var lengthOfArrayLike = lengthOfArrayLike$1;
773
+ var createProperty = createProperty$1;
774
+ var getIterator$1 = getIterator$2;
775
+ var getIteratorMethod$1 = getIteratorMethod$3;
776
+
777
+ var $Array = Array;
778
+
779
+ // `Array.from` method implementation
780
+ // https://tc39.es/ecma262/#sec-array.from
781
+ var arrayFrom$1 = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
782
+ var O = toObject(arrayLike);
783
+ var IS_CONSTRUCTOR = isConstructor(this);
784
+ var argumentsLength = arguments.length;
785
+ var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
786
+ var mapping = mapfn !== undefined;
787
+ if (mapping) mapfn = bind$2(mapfn, argumentsLength > 2 ? arguments[2] : undefined);
788
+ var iteratorMethod = getIteratorMethod$1(O);
789
+ var index = 0;
790
+ var length, result, step, iterator, next, value;
791
+ // if the target is not iterable or it's an array with the default iterator - use a simple case
792
+ if (iteratorMethod && !(this === $Array && isArrayIteratorMethod(iteratorMethod))) {
793
+ result = IS_CONSTRUCTOR ? new this() : [];
794
+ iterator = getIterator$1(O, iteratorMethod);
795
+ next = iterator.next;
796
+ for (;!(step = call$2(next, iterator)).done; index++) {
797
+ value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
798
+ createProperty(result, index, value);
799
+ }
800
+ } else {
801
+ length = lengthOfArrayLike(O);
802
+ result = IS_CONSTRUCTOR ? new this(length) : $Array(length);
803
+ for (;length > index; index++) {
804
+ value = mapping ? mapfn(O[index], index) : O[index];
805
+ createProperty(result, index, value);
806
+ }
807
+ }
808
+ result.length = index;
809
+ return result;
810
+ };
811
+
812
+ // based on https://github.com/bestiejs/punycode.js/blob/master/punycode.js
813
+ var uncurryThis$5 = functionUncurryThis;
814
+
815
+ var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
816
+ var base = 36;
817
+ var tMin = 1;
818
+ var tMax = 26;
819
+ var skew = 38;
820
+ var damp = 700;
821
+ var initialBias = 72;
822
+ var initialN = 128; // 0x80
823
+ var delimiter = '-'; // '\x2D'
824
+ var regexNonASCII = /[^\0-\u007E]/; // non-ASCII chars
825
+ var regexSeparators = /[.\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
826
+ var OVERFLOW_ERROR = 'Overflow: input needs wider integers to process';
827
+ var baseMinusTMin = base - tMin;
828
+
829
+ var $RangeError = RangeError;
830
+ var exec$1 = uncurryThis$5(regexSeparators.exec);
831
+ var floor$2 = Math.floor;
832
+ var fromCharCode = String.fromCharCode;
833
+ var charCodeAt = uncurryThis$5(''.charCodeAt);
834
+ var join$2 = uncurryThis$5([].join);
835
+ var push$3 = uncurryThis$5([].push);
836
+ var replace$2 = uncurryThis$5(''.replace);
837
+ var split$2 = uncurryThis$5(''.split);
838
+ var toLowerCase$1 = uncurryThis$5(''.toLowerCase);
839
+
840
+ /**
841
+ * Creates an array containing the numeric code points of each Unicode
842
+ * character in the string. While JavaScript uses UCS-2 internally,
843
+ * this function will convert a pair of surrogate halves (each of which
844
+ * UCS-2 exposes as separate characters) into a single code point,
845
+ * matching UTF-16.
846
+ */
847
+ var ucs2decode = function (string) {
848
+ var output = [];
849
+ var counter = 0;
850
+ var length = string.length;
851
+ while (counter < length) {
852
+ var value = charCodeAt(string, counter++);
853
+ if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
854
+ // It's a high surrogate, and there is a next character.
855
+ var extra = charCodeAt(string, counter++);
856
+ if ((extra & 0xFC00) === 0xDC00) { // Low surrogate.
857
+ push$3(output, ((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
858
+ } else {
859
+ // It's an unmatched surrogate; only append this code unit, in case the
860
+ // next code unit is the high surrogate of a surrogate pair.
861
+ push$3(output, value);
862
+ counter--;
863
+ }
864
+ } else {
865
+ push$3(output, value);
866
+ }
867
+ }
868
+ return output;
869
+ };
870
+
871
+ /**
872
+ * Converts a digit/integer into a basic code point.
873
+ */
874
+ var digitToBasic = function (digit) {
875
+ // 0..25 map to ASCII a..z or A..Z
876
+ // 26..35 map to ASCII 0..9
877
+ return digit + 22 + 75 * (digit < 26);
878
+ };
879
+
880
+ /**
881
+ * Bias adaptation function as per section 3.4 of RFC 3492.
882
+ * https://tools.ietf.org/html/rfc3492#section-3.4
883
+ */
884
+ var adapt = function (delta, numPoints, firstTime) {
885
+ var k = 0;
886
+ delta = firstTime ? floor$2(delta / damp) : delta >> 1;
887
+ delta += floor$2(delta / numPoints);
888
+ while (delta > baseMinusTMin * tMax >> 1) {
889
+ delta = floor$2(delta / baseMinusTMin);
890
+ k += base;
891
+ }
892
+ return floor$2(k + (baseMinusTMin + 1) * delta / (delta + skew));
893
+ };
894
+
895
+ /**
896
+ * Converts a string of Unicode symbols (e.g. a domain name label) to a
897
+ * Punycode string of ASCII-only symbols.
898
+ */
899
+ var encode = function (input) {
900
+ var output = [];
901
+
902
+ // Convert the input in UCS-2 to an array of Unicode code points.
903
+ input = ucs2decode(input);
904
+
905
+ // Cache the length.
906
+ var inputLength = input.length;
907
+
908
+ // Initialize the state.
909
+ var n = initialN;
910
+ var delta = 0;
911
+ var bias = initialBias;
912
+ var i, currentValue;
913
+
914
+ // Handle the basic code points.
915
+ for (i = 0; i < input.length; i++) {
916
+ currentValue = input[i];
917
+ if (currentValue < 0x80) {
918
+ push$3(output, fromCharCode(currentValue));
919
+ }
920
+ }
921
+
922
+ var basicLength = output.length; // number of basic code points.
923
+ var handledCPCount = basicLength; // number of code points that have been handled;
924
+
925
+ // Finish the basic string with a delimiter unless it's empty.
926
+ if (basicLength) {
927
+ push$3(output, delimiter);
928
+ }
929
+
930
+ // Main encoding loop:
931
+ while (handledCPCount < inputLength) {
932
+ // All non-basic code points < n have been handled already. Find the next larger one:
933
+ var m = maxInt;
934
+ for (i = 0; i < input.length; i++) {
935
+ currentValue = input[i];
936
+ if (currentValue >= n && currentValue < m) {
937
+ m = currentValue;
938
+ }
939
+ }
940
+
941
+ // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>, but guard against overflow.
942
+ var handledCPCountPlusOne = handledCPCount + 1;
943
+ if (m - n > floor$2((maxInt - delta) / handledCPCountPlusOne)) {
944
+ throw new $RangeError(OVERFLOW_ERROR);
945
+ }
946
+
947
+ delta += (m - n) * handledCPCountPlusOne;
948
+ n = m;
949
+
950
+ for (i = 0; i < input.length; i++) {
951
+ currentValue = input[i];
952
+ if (currentValue < n && ++delta > maxInt) {
953
+ throw new $RangeError(OVERFLOW_ERROR);
954
+ }
955
+ if (currentValue === n) {
956
+ // Represent delta as a generalized variable-length integer.
957
+ var q = delta;
958
+ var k = base;
959
+ while (true) {
960
+ var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
961
+ if (q < t) break;
962
+ var qMinusT = q - t;
963
+ var baseMinusT = base - t;
964
+ push$3(output, fromCharCode(digitToBasic(t + qMinusT % baseMinusT)));
965
+ q = floor$2(qMinusT / baseMinusT);
966
+ k += base;
967
+ }
968
+
969
+ push$3(output, fromCharCode(digitToBasic(q)));
970
+ bias = adapt(delta, handledCPCountPlusOne, handledCPCount === basicLength);
971
+ delta = 0;
972
+ handledCPCount++;
973
+ }
974
+ }
975
+
976
+ delta++;
977
+ n++;
978
+ }
979
+ return join$2(output, '');
980
+ };
981
+
982
+ var stringPunycodeToAscii = function (input) {
983
+ var encoded = [];
984
+ var labels = split$2(replace$2(toLowerCase$1(input), regexSeparators, '\u002E'), '.');
985
+ var i, label;
986
+ for (i = 0; i < labels.length; i++) {
987
+ label = labels[i];
988
+ push$3(encoded, exec$1(regexNonASCII, label) ? 'xn--' + encode(label) : label);
989
+ }
990
+ return join$2(encoded, '.');
991
+ };
992
+
993
+ var $TypeError = TypeError;
994
+
995
+ var validateArgumentsLength$4 = function (passed, required) {
996
+ if (passed < required) throw new $TypeError('Not enough arguments');
997
+ return passed;
998
+ };
999
+
1000
+ var global$2 = global$3;
1001
+ var DESCRIPTORS$3 = descriptors;
1002
+
1003
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
1004
+ var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
1005
+
1006
+ // Avoid NodeJS experimental warning
1007
+ var safeGetBuiltIn$1 = function (name) {
1008
+ if (!DESCRIPTORS$3) return global$2[name];
1009
+ var descriptor = getOwnPropertyDescriptor(global$2, name);
1010
+ return descriptor && descriptor.value;
1011
+ };
1012
+
1013
+ var defineBuiltIn$4 = defineBuiltIn$5;
1014
+
1015
+ var defineBuiltIns$1 = function (target, src, options) {
1016
+ for (var key in src) defineBuiltIn$4(target, key, src[key], options);
1017
+ return target;
1018
+ };
1019
+
1020
+ var arraySlice$1 = arraySlice$2;
1021
+
1022
+ var floor$1 = Math.floor;
1023
+
1024
+ var sort = function (array, comparefn) {
1025
+ var length = array.length;
1026
+
1027
+ if (length < 8) {
1028
+ // insertion sort
1029
+ var i = 1;
1030
+ var element, j;
1031
+
1032
+ while (i < length) {
1033
+ j = i;
1034
+ element = array[i];
1035
+ while (j && comparefn(array[j - 1], element) > 0) {
1036
+ array[j] = array[--j];
1037
+ }
1038
+ if (j !== i++) array[j] = element;
1039
+ }
1040
+ } else {
1041
+ // merge sort
1042
+ var middle = floor$1(length / 2);
1043
+ var left = sort(arraySlice$1(array, 0, middle), comparefn);
1044
+ var right = sort(arraySlice$1(array, middle), comparefn);
1045
+ var llength = left.length;
1046
+ var rlength = right.length;
1047
+ var lindex = 0;
1048
+ var rindex = 0;
1049
+
1050
+ while (lindex < llength || rindex < rlength) {
1051
+ array[lindex + rindex] = (lindex < llength && rindex < rlength)
1052
+ ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++]
1053
+ : lindex < llength ? left[lindex++] : right[rindex++];
1054
+ }
1055
+ }
1056
+
1057
+ return array;
1058
+ };
1059
+
1060
+ var arraySort$1 = sort;
1061
+
1062
+ // TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`
1063
+
1064
+ var $$2 = _export;
1065
+ var global$1 = global$3;
1066
+ var safeGetBuiltIn = safeGetBuiltIn$1;
1067
+ var call$1 = functionCall;
1068
+ var uncurryThis$4 = functionUncurryThis;
1069
+ var DESCRIPTORS$2 = descriptors;
1070
+ var USE_NATIVE_URL$1 = urlConstructorDetection;
1071
+ var defineBuiltIn$3 = defineBuiltIn$5;
1072
+ var defineBuiltInAccessor$2 = defineBuiltInAccessor$3;
1073
+ var defineBuiltIns = defineBuiltIns$1;
1074
+ var setToStringTag$1 = setToStringTag$2;
1075
+ var createIteratorConstructor = iteratorCreateConstructor;
1076
+ var InternalStateModule$1 = internalState;
1077
+ var anInstance$1 = anInstance$2;
1078
+ var isCallable = isCallable$2;
1079
+ var hasOwn$1 = hasOwnProperty_1;
1080
+ var bind$1 = functionBindContext;
1081
+ var classof = classof$3;
1082
+ var anObject = anObject$4;
1083
+ var isObject = isObject$1;
1084
+ var $toString$1 = toString$4;
1085
+ var create = objectCreate;
1086
+ var createPropertyDescriptor = createPropertyDescriptor$2;
1087
+ var getIterator = getIterator$2;
1088
+ var getIteratorMethod = getIteratorMethod$3;
1089
+ var createIterResultObject = createIterResultObject$2;
1090
+ var validateArgumentsLength$3 = validateArgumentsLength$4;
1091
+ var wellKnownSymbol = wellKnownSymbol$4;
1092
+ var arraySort = arraySort$1;
1093
+
1094
+ var ITERATOR = wellKnownSymbol('iterator');
1095
+ var URL_SEARCH_PARAMS = 'URLSearchParams';
1096
+ var URL_SEARCH_PARAMS_ITERATOR = URL_SEARCH_PARAMS + 'Iterator';
1097
+ var setInternalState$1 = InternalStateModule$1.set;
1098
+ var getInternalParamsState = InternalStateModule$1.getterFor(URL_SEARCH_PARAMS);
1099
+ var getInternalIteratorState = InternalStateModule$1.getterFor(URL_SEARCH_PARAMS_ITERATOR);
1100
+
1101
+ var nativeFetch = safeGetBuiltIn('fetch');
1102
+ var NativeRequest = safeGetBuiltIn('Request');
1103
+ var Headers = safeGetBuiltIn('Headers');
1104
+ var RequestPrototype = NativeRequest && NativeRequest.prototype;
1105
+ var HeadersPrototype = Headers && Headers.prototype;
1106
+ var RegExp$1 = global$1.RegExp;
1107
+ var TypeError$2 = global$1.TypeError;
1108
+ var decodeURIComponent = global$1.decodeURIComponent;
1109
+ var encodeURIComponent$1 = global$1.encodeURIComponent;
1110
+ var charAt$1 = uncurryThis$4(''.charAt);
1111
+ var join$1 = uncurryThis$4([].join);
1112
+ var push$2 = uncurryThis$4([].push);
1113
+ var replace$1 = uncurryThis$4(''.replace);
1114
+ var shift$1 = uncurryThis$4([].shift);
1115
+ var splice = uncurryThis$4([].splice);
1116
+ var split$1 = uncurryThis$4(''.split);
1117
+ var stringSlice$1 = uncurryThis$4(''.slice);
1118
+
1119
+ var plus = /\+/g;
1120
+ var sequences = Array(4);
1121
+
1122
+ var percentSequence = function (bytes) {
1123
+ return sequences[bytes - 1] || (sequences[bytes - 1] = RegExp$1('((?:%[\\da-f]{2}){' + bytes + '})', 'gi'));
1124
+ };
1125
+
1126
+ var percentDecode = function (sequence) {
1127
+ try {
1128
+ return decodeURIComponent(sequence);
1129
+ } catch (error) {
1130
+ return sequence;
1131
+ }
1132
+ };
1133
+
1134
+ var deserialize = function (it) {
1135
+ var result = replace$1(it, plus, ' ');
1136
+ var bytes = 4;
1137
+ try {
1138
+ return decodeURIComponent(result);
1139
+ } catch (error) {
1140
+ while (bytes) {
1141
+ result = replace$1(result, percentSequence(bytes--), percentDecode);
1142
+ }
1143
+ return result;
1144
+ }
1145
+ };
1146
+
1147
+ var find = /[!'()~]|%20/g;
1148
+
1149
+ var replacements = {
1150
+ '!': '%21',
1151
+ "'": '%27',
1152
+ '(': '%28',
1153
+ ')': '%29',
1154
+ '~': '%7E',
1155
+ '%20': '+'
1156
+ };
1157
+
1158
+ var replacer = function (match) {
1159
+ return replacements[match];
1160
+ };
1161
+
1162
+ var serialize = function (it) {
1163
+ return replace$1(encodeURIComponent$1(it), find, replacer);
1164
+ };
1165
+
1166
+ var URLSearchParamsIterator = createIteratorConstructor(function Iterator(params, kind) {
1167
+ setInternalState$1(this, {
1168
+ type: URL_SEARCH_PARAMS_ITERATOR,
1169
+ target: getInternalParamsState(params).entries,
1170
+ index: 0,
1171
+ kind: kind
1172
+ });
1173
+ }, URL_SEARCH_PARAMS, function next() {
1174
+ var state = getInternalIteratorState(this);
1175
+ var target = state.target;
1176
+ var index = state.index++;
1177
+ if (!target || index >= target.length) {
1178
+ state.target = undefined;
1179
+ return createIterResultObject(undefined, true);
1180
+ }
1181
+ var entry = target[index];
1182
+ switch (state.kind) {
1183
+ case 'keys': return createIterResultObject(entry.key, false);
1184
+ case 'values': return createIterResultObject(entry.value, false);
1185
+ } return createIterResultObject([entry.key, entry.value], false);
1186
+ }, true);
1187
+
1188
+ var URLSearchParamsState = function (init) {
1189
+ this.entries = [];
1190
+ this.url = null;
1191
+
1192
+ if (init !== undefined) {
1193
+ if (isObject(init)) this.parseObject(init);
1194
+ else this.parseQuery(typeof init == 'string' ? charAt$1(init, 0) === '?' ? stringSlice$1(init, 1) : init : $toString$1(init));
1195
+ }
1196
+ };
1197
+
1198
+ URLSearchParamsState.prototype = {
1199
+ type: URL_SEARCH_PARAMS,
1200
+ bindURL: function (url) {
1201
+ this.url = url;
1202
+ this.update();
1203
+ },
1204
+ parseObject: function (object) {
1205
+ var entries = this.entries;
1206
+ var iteratorMethod = getIteratorMethod(object);
1207
+ var iterator, next, step, entryIterator, entryNext, first, second;
1208
+
1209
+ if (iteratorMethod) {
1210
+ iterator = getIterator(object, iteratorMethod);
1211
+ next = iterator.next;
1212
+ while (!(step = call$1(next, iterator)).done) {
1213
+ entryIterator = getIterator(anObject(step.value));
1214
+ entryNext = entryIterator.next;
1215
+ if (
1216
+ (first = call$1(entryNext, entryIterator)).done ||
1217
+ (second = call$1(entryNext, entryIterator)).done ||
1218
+ !call$1(entryNext, entryIterator).done
1219
+ ) throw new TypeError$2('Expected sequence with length 2');
1220
+ push$2(entries, { key: $toString$1(first.value), value: $toString$1(second.value) });
1221
+ }
1222
+ } else for (var key in object) if (hasOwn$1(object, key)) {
1223
+ push$2(entries, { key: key, value: $toString$1(object[key]) });
1224
+ }
1225
+ },
1226
+ parseQuery: function (query) {
1227
+ if (query) {
1228
+ var entries = this.entries;
1229
+ var attributes = split$1(query, '&');
1230
+ var index = 0;
1231
+ var attribute, entry;
1232
+ while (index < attributes.length) {
1233
+ attribute = attributes[index++];
1234
+ if (attribute.length) {
1235
+ entry = split$1(attribute, '=');
1236
+ push$2(entries, {
1237
+ key: deserialize(shift$1(entry)),
1238
+ value: deserialize(join$1(entry, '='))
1239
+ });
1240
+ }
1241
+ }
1242
+ }
1243
+ },
1244
+ serialize: function () {
1245
+ var entries = this.entries;
1246
+ var result = [];
1247
+ var index = 0;
1248
+ var entry;
1249
+ while (index < entries.length) {
1250
+ entry = entries[index++];
1251
+ push$2(result, serialize(entry.key) + '=' + serialize(entry.value));
1252
+ } return join$1(result, '&');
1253
+ },
1254
+ update: function () {
1255
+ this.entries.length = 0;
1256
+ this.parseQuery(this.url.query);
1257
+ },
1258
+ updateURL: function () {
1259
+ if (this.url) this.url.update();
1260
+ }
1261
+ };
1262
+
1263
+ // `URLSearchParams` constructor
1264
+ // https://url.spec.whatwg.org/#interface-urlsearchparams
1265
+ var URLSearchParamsConstructor = function URLSearchParams(/* init */) {
1266
+ anInstance$1(this, URLSearchParamsPrototype$3);
1267
+ var init = arguments.length > 0 ? arguments[0] : undefined;
1268
+ var state = setInternalState$1(this, new URLSearchParamsState(init));
1269
+ if (!DESCRIPTORS$2) this.size = state.entries.length;
1270
+ };
1271
+
1272
+ var URLSearchParamsPrototype$3 = URLSearchParamsConstructor.prototype;
1273
+
1274
+ defineBuiltIns(URLSearchParamsPrototype$3, {
1275
+ // `URLSearchParams.prototype.append` method
1276
+ // https://url.spec.whatwg.org/#dom-urlsearchparams-append
1277
+ append: function append(name, value) {
1278
+ var state = getInternalParamsState(this);
1279
+ validateArgumentsLength$3(arguments.length, 2);
1280
+ push$2(state.entries, { key: $toString$1(name), value: $toString$1(value) });
1281
+ if (!DESCRIPTORS$2) this.length++;
1282
+ state.updateURL();
1283
+ },
1284
+ // `URLSearchParams.prototype.delete` method
1285
+ // https://url.spec.whatwg.org/#dom-urlsearchparams-delete
1286
+ 'delete': function (name /* , value */) {
1287
+ var state = getInternalParamsState(this);
1288
+ var length = validateArgumentsLength$3(arguments.length, 1);
1289
+ var entries = state.entries;
1290
+ var key = $toString$1(name);
1291
+ var $value = length < 2 ? undefined : arguments[1];
1292
+ var value = $value === undefined ? $value : $toString$1($value);
1293
+ var index = 0;
1294
+ while (index < entries.length) {
1295
+ var entry = entries[index];
1296
+ if (entry.key === key && (value === undefined || entry.value === value)) {
1297
+ splice(entries, index, 1);
1298
+ if (value !== undefined) break;
1299
+ } else index++;
1300
+ }
1301
+ if (!DESCRIPTORS$2) this.size = entries.length;
1302
+ state.updateURL();
1303
+ },
1304
+ // `URLSearchParams.prototype.get` method
1305
+ // https://url.spec.whatwg.org/#dom-urlsearchparams-get
1306
+ get: function get(name) {
1307
+ var entries = getInternalParamsState(this).entries;
1308
+ validateArgumentsLength$3(arguments.length, 1);
1309
+ var key = $toString$1(name);
1310
+ var index = 0;
1311
+ for (; index < entries.length; index++) {
1312
+ if (entries[index].key === key) return entries[index].value;
1313
+ }
1314
+ return null;
1315
+ },
1316
+ // `URLSearchParams.prototype.getAll` method
1317
+ // https://url.spec.whatwg.org/#dom-urlsearchparams-getall
1318
+ getAll: function getAll(name) {
1319
+ var entries = getInternalParamsState(this).entries;
1320
+ validateArgumentsLength$3(arguments.length, 1);
1321
+ var key = $toString$1(name);
1322
+ var result = [];
1323
+ var index = 0;
1324
+ for (; index < entries.length; index++) {
1325
+ if (entries[index].key === key) push$2(result, entries[index].value);
1326
+ }
1327
+ return result;
1328
+ },
1329
+ // `URLSearchParams.prototype.has` method
1330
+ // https://url.spec.whatwg.org/#dom-urlsearchparams-has
1331
+ has: function has(name /* , value */) {
1332
+ var entries = getInternalParamsState(this).entries;
1333
+ var length = validateArgumentsLength$3(arguments.length, 1);
1334
+ var key = $toString$1(name);
1335
+ var $value = length < 2 ? undefined : arguments[1];
1336
+ var value = $value === undefined ? $value : $toString$1($value);
1337
+ var index = 0;
1338
+ while (index < entries.length) {
1339
+ var entry = entries[index++];
1340
+ if (entry.key === key && (value === undefined || entry.value === value)) return true;
1341
+ }
1342
+ return false;
1343
+ },
1344
+ // `URLSearchParams.prototype.set` method
1345
+ // https://url.spec.whatwg.org/#dom-urlsearchparams-set
1346
+ set: function set(name, value) {
1347
+ var state = getInternalParamsState(this);
1348
+ validateArgumentsLength$3(arguments.length, 1);
1349
+ var entries = state.entries;
1350
+ var found = false;
1351
+ var key = $toString$1(name);
1352
+ var val = $toString$1(value);
1353
+ var index = 0;
1354
+ var entry;
1355
+ for (; index < entries.length; index++) {
1356
+ entry = entries[index];
1357
+ if (entry.key === key) {
1358
+ if (found) splice(entries, index--, 1);
1359
+ else {
1360
+ found = true;
1361
+ entry.value = val;
1362
+ }
1363
+ }
1364
+ }
1365
+ if (!found) push$2(entries, { key: key, value: val });
1366
+ if (!DESCRIPTORS$2) this.size = entries.length;
1367
+ state.updateURL();
1368
+ },
1369
+ // `URLSearchParams.prototype.sort` method
1370
+ // https://url.spec.whatwg.org/#dom-urlsearchparams-sort
1371
+ sort: function sort() {
1372
+ var state = getInternalParamsState(this);
1373
+ arraySort(state.entries, function (a, b) {
1374
+ return a.key > b.key ? 1 : -1;
1375
+ });
1376
+ state.updateURL();
1377
+ },
1378
+ // `URLSearchParams.prototype.forEach` method
1379
+ forEach: function forEach(callback /* , thisArg */) {
1380
+ var entries = getInternalParamsState(this).entries;
1381
+ var boundFunction = bind$1(callback, arguments.length > 1 ? arguments[1] : undefined);
1382
+ var index = 0;
1383
+ var entry;
1384
+ while (index < entries.length) {
1385
+ entry = entries[index++];
1386
+ boundFunction(entry.value, entry.key, this);
1387
+ }
1388
+ },
1389
+ // `URLSearchParams.prototype.keys` method
1390
+ keys: function keys() {
1391
+ return new URLSearchParamsIterator(this, 'keys');
1392
+ },
1393
+ // `URLSearchParams.prototype.values` method
1394
+ values: function values() {
1395
+ return new URLSearchParamsIterator(this, 'values');
1396
+ },
1397
+ // `URLSearchParams.prototype.entries` method
1398
+ entries: function entries() {
1399
+ return new URLSearchParamsIterator(this, 'entries');
1400
+ }
1401
+ }, { enumerable: true });
1402
+
1403
+ // `URLSearchParams.prototype[@@iterator]` method
1404
+ defineBuiltIn$3(URLSearchParamsPrototype$3, ITERATOR, URLSearchParamsPrototype$3.entries, { name: 'entries' });
1405
+
1406
+ // `URLSearchParams.prototype.toString` method
1407
+ // https://url.spec.whatwg.org/#urlsearchparams-stringification-behavior
1408
+ defineBuiltIn$3(URLSearchParamsPrototype$3, 'toString', function toString() {
1409
+ return getInternalParamsState(this).serialize();
1410
+ }, { enumerable: true });
1411
+
1412
+ // `URLSearchParams.prototype.size` getter
1413
+ // https://github.com/whatwg/url/pull/734
1414
+ if (DESCRIPTORS$2) defineBuiltInAccessor$2(URLSearchParamsPrototype$3, 'size', {
1415
+ get: function size() {
1416
+ return getInternalParamsState(this).entries.length;
1417
+ },
1418
+ configurable: true,
1419
+ enumerable: true
1420
+ });
1421
+
1422
+ setToStringTag$1(URLSearchParamsConstructor, URL_SEARCH_PARAMS);
1423
+
1424
+ $$2({ global: true, constructor: true, forced: !USE_NATIVE_URL$1 }, {
1425
+ URLSearchParams: URLSearchParamsConstructor
1426
+ });
1427
+
1428
+ // Wrap `fetch` and `Request` for correct work with polyfilled `URLSearchParams`
1429
+ if (!USE_NATIVE_URL$1 && isCallable(Headers)) {
1430
+ var headersHas = uncurryThis$4(HeadersPrototype.has);
1431
+ var headersSet = uncurryThis$4(HeadersPrototype.set);
1432
+
1433
+ var wrapRequestOptions = function (init) {
1434
+ if (isObject(init)) {
1435
+ var body = init.body;
1436
+ var headers;
1437
+ if (classof(body) === URL_SEARCH_PARAMS) {
1438
+ headers = init.headers ? new Headers(init.headers) : new Headers();
1439
+ if (!headersHas(headers, 'content-type')) {
1440
+ headersSet(headers, 'content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
1441
+ }
1442
+ return create(init, {
1443
+ body: createPropertyDescriptor(0, $toString$1(body)),
1444
+ headers: createPropertyDescriptor(0, headers)
1445
+ });
1446
+ }
1447
+ } return init;
1448
+ };
1449
+
1450
+ if (isCallable(nativeFetch)) {
1451
+ $$2({ global: true, enumerable: true, dontCallGetSet: true, forced: true }, {
1452
+ fetch: function fetch(input /* , init */) {
1453
+ return nativeFetch(input, arguments.length > 1 ? wrapRequestOptions(arguments[1]) : {});
1454
+ }
1455
+ });
1456
+ }
1457
+
1458
+ if (isCallable(NativeRequest)) {
1459
+ var RequestConstructor = function Request(input /* , init */) {
1460
+ anInstance$1(this, RequestPrototype);
1461
+ return new NativeRequest(input, arguments.length > 1 ? wrapRequestOptions(arguments[1]) : {});
1462
+ };
1463
+
1464
+ RequestPrototype.constructor = RequestConstructor;
1465
+ RequestConstructor.prototype = RequestPrototype;
1466
+
1467
+ $$2({ global: true, constructor: true, dontCallGetSet: true, forced: true }, {
1468
+ Request: RequestConstructor
1469
+ });
1470
+ }
1471
+ }
1472
+
1473
+ var web_urlSearchParams_constructor = {
1474
+ URLSearchParams: URLSearchParamsConstructor,
1475
+ getState: getInternalParamsState
1476
+ };
1477
+
1478
+ // TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`
1479
+
1480
+ var $$1 = _export;
1481
+ var DESCRIPTORS$1 = descriptors;
1482
+ var USE_NATIVE_URL = urlConstructorDetection;
1483
+ var global = global$3;
1484
+ var bind = functionBindContext;
1485
+ var uncurryThis$3 = functionUncurryThis;
1486
+ var defineBuiltIn$2 = defineBuiltIn$5;
1487
+ var defineBuiltInAccessor$1 = defineBuiltInAccessor$3;
1488
+ var anInstance = anInstance$2;
1489
+ var hasOwn = hasOwnProperty_1;
1490
+ var assign = objectAssign;
1491
+ var arrayFrom = arrayFrom$1;
1492
+ var arraySlice = arraySlice$2;
1493
+ var codeAt = stringMultibyte.codeAt;
1494
+ var toASCII = stringPunycodeToAscii;
1495
+ var $toString = toString$4;
1496
+ var setToStringTag = setToStringTag$2;
1497
+ var validateArgumentsLength$2 = validateArgumentsLength$4;
1498
+ var URLSearchParamsModule = web_urlSearchParams_constructor;
1499
+ var InternalStateModule = internalState;
1500
+
1501
+ var setInternalState = InternalStateModule.set;
1502
+ var getInternalURLState = InternalStateModule.getterFor('URL');
1503
+ var URLSearchParams$1 = URLSearchParamsModule.URLSearchParams;
1504
+ var getInternalSearchParamsState = URLSearchParamsModule.getState;
1505
+
1506
+ var NativeURL = global.URL;
1507
+ var TypeError$1 = global.TypeError;
1508
+ var parseInt = global.parseInt;
1509
+ var floor = Math.floor;
1510
+ var pow = Math.pow;
1511
+ var charAt = uncurryThis$3(''.charAt);
1512
+ var exec = uncurryThis$3(/./.exec);
1513
+ var join = uncurryThis$3([].join);
1514
+ var numberToString = uncurryThis$3(1.0.toString);
1515
+ var pop = uncurryThis$3([].pop);
1516
+ var push$1 = uncurryThis$3([].push);
1517
+ var replace = uncurryThis$3(''.replace);
1518
+ var shift = uncurryThis$3([].shift);
1519
+ var split = uncurryThis$3(''.split);
1520
+ var stringSlice = uncurryThis$3(''.slice);
1521
+ var toLowerCase = uncurryThis$3(''.toLowerCase);
1522
+ var unshift = uncurryThis$3([].unshift);
1523
+
1524
+ var INVALID_AUTHORITY = 'Invalid authority';
1525
+ var INVALID_SCHEME = 'Invalid scheme';
1526
+ var INVALID_HOST = 'Invalid host';
1527
+ var INVALID_PORT = 'Invalid port';
1528
+
1529
+ var ALPHA = /[a-z]/i;
1530
+ // eslint-disable-next-line regexp/no-obscure-range -- safe
1531
+ var ALPHANUMERIC = /[\d+-.a-z]/i;
1532
+ var DIGIT = /\d/;
1533
+ var HEX_START = /^0x/i;
1534
+ var OCT = /^[0-7]+$/;
1535
+ var DEC = /^\d+$/;
1536
+ var HEX = /^[\da-f]+$/i;
1537
+ /* eslint-disable regexp/no-control-character -- safe */
1538
+ var FORBIDDEN_HOST_CODE_POINT = /[\0\t\n\r #%/:<>?@[\\\]^|]/;
1539
+ var FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT = /[\0\t\n\r #/:<>?@[\\\]^|]/;
1540
+ var LEADING_C0_CONTROL_OR_SPACE = /^[\u0000-\u0020]+/;
1541
+ var TRAILING_C0_CONTROL_OR_SPACE = /(^|[^\u0000-\u0020])[\u0000-\u0020]+$/;
1542
+ var TAB_AND_NEW_LINE = /[\t\n\r]/g;
1543
+ /* eslint-enable regexp/no-control-character -- safe */
1544
+ var EOF;
1545
+
1546
+ // https://url.spec.whatwg.org/#ipv4-number-parser
1547
+ var parseIPv4 = function (input) {
1548
+ var parts = split(input, '.');
1549
+ var partsLength, numbers, index, part, radix, number, ipv4;
1550
+ if (parts.length && parts[parts.length - 1] === '') {
1551
+ parts.length--;
1552
+ }
1553
+ partsLength = parts.length;
1554
+ if (partsLength > 4) return input;
1555
+ numbers = [];
1556
+ for (index = 0; index < partsLength; index++) {
1557
+ part = parts[index];
1558
+ if (part === '') return input;
1559
+ radix = 10;
1560
+ if (part.length > 1 && charAt(part, 0) === '0') {
1561
+ radix = exec(HEX_START, part) ? 16 : 8;
1562
+ part = stringSlice(part, radix === 8 ? 1 : 2);
1563
+ }
1564
+ if (part === '') {
1565
+ number = 0;
1566
+ } else {
1567
+ if (!exec(radix === 10 ? DEC : radix === 8 ? OCT : HEX, part)) return input;
1568
+ number = parseInt(part, radix);
1569
+ }
1570
+ push$1(numbers, number);
1571
+ }
1572
+ for (index = 0; index < partsLength; index++) {
1573
+ number = numbers[index];
1574
+ if (index === partsLength - 1) {
1575
+ if (number >= pow(256, 5 - partsLength)) return null;
1576
+ } else if (number > 255) return null;
1577
+ }
1578
+ ipv4 = pop(numbers);
1579
+ for (index = 0; index < numbers.length; index++) {
1580
+ ipv4 += numbers[index] * pow(256, 3 - index);
1581
+ }
1582
+ return ipv4;
1583
+ };
1584
+
1585
+ // https://url.spec.whatwg.org/#concept-ipv6-parser
1586
+ // eslint-disable-next-line max-statements -- TODO
1587
+ var parseIPv6 = function (input) {
1588
+ var address = [0, 0, 0, 0, 0, 0, 0, 0];
1589
+ var pieceIndex = 0;
1590
+ var compress = null;
1591
+ var pointer = 0;
1592
+ var value, length, numbersSeen, ipv4Piece, number, swaps, swap;
1593
+
1594
+ var chr = function () {
1595
+ return charAt(input, pointer);
1596
+ };
1597
+
1598
+ if (chr() === ':') {
1599
+ if (charAt(input, 1) !== ':') return;
1600
+ pointer += 2;
1601
+ pieceIndex++;
1602
+ compress = pieceIndex;
1603
+ }
1604
+ while (chr()) {
1605
+ if (pieceIndex === 8) return;
1606
+ if (chr() === ':') {
1607
+ if (compress !== null) return;
1608
+ pointer++;
1609
+ pieceIndex++;
1610
+ compress = pieceIndex;
1611
+ continue;
1612
+ }
1613
+ value = length = 0;
1614
+ while (length < 4 && exec(HEX, chr())) {
1615
+ value = value * 16 + parseInt(chr(), 16);
1616
+ pointer++;
1617
+ length++;
1618
+ }
1619
+ if (chr() === '.') {
1620
+ if (length === 0) return;
1621
+ pointer -= length;
1622
+ if (pieceIndex > 6) return;
1623
+ numbersSeen = 0;
1624
+ while (chr()) {
1625
+ ipv4Piece = null;
1626
+ if (numbersSeen > 0) {
1627
+ if (chr() === '.' && numbersSeen < 4) pointer++;
1628
+ else return;
1629
+ }
1630
+ if (!exec(DIGIT, chr())) return;
1631
+ while (exec(DIGIT, chr())) {
1632
+ number = parseInt(chr(), 10);
1633
+ if (ipv4Piece === null) ipv4Piece = number;
1634
+ else if (ipv4Piece === 0) return;
1635
+ else ipv4Piece = ipv4Piece * 10 + number;
1636
+ if (ipv4Piece > 255) return;
1637
+ pointer++;
1638
+ }
1639
+ address[pieceIndex] = address[pieceIndex] * 256 + ipv4Piece;
1640
+ numbersSeen++;
1641
+ if (numbersSeen === 2 || numbersSeen === 4) pieceIndex++;
1642
+ }
1643
+ if (numbersSeen !== 4) return;
1644
+ break;
1645
+ } else if (chr() === ':') {
1646
+ pointer++;
1647
+ if (!chr()) return;
1648
+ } else if (chr()) return;
1649
+ address[pieceIndex++] = value;
1650
+ }
1651
+ if (compress !== null) {
1652
+ swaps = pieceIndex - compress;
1653
+ pieceIndex = 7;
1654
+ while (pieceIndex !== 0 && swaps > 0) {
1655
+ swap = address[pieceIndex];
1656
+ address[pieceIndex--] = address[compress + swaps - 1];
1657
+ address[compress + --swaps] = swap;
1658
+ }
1659
+ } else if (pieceIndex !== 8) return;
1660
+ return address;
1661
+ };
1662
+
1663
+ var findLongestZeroSequence = function (ipv6) {
1664
+ var maxIndex = null;
1665
+ var maxLength = 1;
1666
+ var currStart = null;
1667
+ var currLength = 0;
1668
+ var index = 0;
1669
+ for (; index < 8; index++) {
1670
+ if (ipv6[index] !== 0) {
1671
+ if (currLength > maxLength) {
1672
+ maxIndex = currStart;
1673
+ maxLength = currLength;
1674
+ }
1675
+ currStart = null;
1676
+ currLength = 0;
1677
+ } else {
1678
+ if (currStart === null) currStart = index;
1679
+ ++currLength;
1680
+ }
1681
+ }
1682
+ if (currLength > maxLength) {
1683
+ maxIndex = currStart;
1684
+ maxLength = currLength;
1685
+ }
1686
+ return maxIndex;
1687
+ };
1688
+
1689
+ // https://url.spec.whatwg.org/#host-serializing
1690
+ var serializeHost = function (host) {
1691
+ var result, index, compress, ignore0;
1692
+ // ipv4
1693
+ if (typeof host == 'number') {
1694
+ result = [];
1695
+ for (index = 0; index < 4; index++) {
1696
+ unshift(result, host % 256);
1697
+ host = floor(host / 256);
1698
+ } return join(result, '.');
1699
+ // ipv6
1700
+ } else if (typeof host == 'object') {
1701
+ result = '';
1702
+ compress = findLongestZeroSequence(host);
1703
+ for (index = 0; index < 8; index++) {
1704
+ if (ignore0 && host[index] === 0) continue;
1705
+ if (ignore0) ignore0 = false;
1706
+ if (compress === index) {
1707
+ result += index ? ':' : '::';
1708
+ ignore0 = true;
1709
+ } else {
1710
+ result += numberToString(host[index], 16);
1711
+ if (index < 7) result += ':';
1712
+ }
1713
+ }
1714
+ return '[' + result + ']';
1715
+ } return host;
1716
+ };
1717
+
1718
+ var C0ControlPercentEncodeSet = {};
1719
+ var fragmentPercentEncodeSet = assign({}, C0ControlPercentEncodeSet, {
1720
+ ' ': 1, '"': 1, '<': 1, '>': 1, '`': 1
1721
+ });
1722
+ var pathPercentEncodeSet = assign({}, fragmentPercentEncodeSet, {
1723
+ '#': 1, '?': 1, '{': 1, '}': 1
1724
+ });
1725
+ var userinfoPercentEncodeSet = assign({}, pathPercentEncodeSet, {
1726
+ '/': 1, ':': 1, ';': 1, '=': 1, '@': 1, '[': 1, '\\': 1, ']': 1, '^': 1, '|': 1
1727
+ });
1728
+
1729
+ var percentEncode = function (chr, set) {
1730
+ var code = codeAt(chr, 0);
1731
+ return code > 0x20 && code < 0x7F && !hasOwn(set, chr) ? chr : encodeURIComponent(chr);
1732
+ };
1733
+
1734
+ // https://url.spec.whatwg.org/#special-scheme
1735
+ var specialSchemes = {
1736
+ ftp: 21,
1737
+ file: null,
1738
+ http: 80,
1739
+ https: 443,
1740
+ ws: 80,
1741
+ wss: 443
1742
+ };
1743
+
1744
+ // https://url.spec.whatwg.org/#windows-drive-letter
1745
+ var isWindowsDriveLetter = function (string, normalized) {
1746
+ var second;
1747
+ return string.length === 2 && exec(ALPHA, charAt(string, 0))
1748
+ && ((second = charAt(string, 1)) === ':' || (!normalized && second === '|'));
1749
+ };
1750
+
1751
+ // https://url.spec.whatwg.org/#start-with-a-windows-drive-letter
1752
+ var startsWithWindowsDriveLetter = function (string) {
1753
+ var third;
1754
+ return string.length > 1 && isWindowsDriveLetter(stringSlice(string, 0, 2)) && (
1755
+ string.length === 2 ||
1756
+ ((third = charAt(string, 2)) === '/' || third === '\\' || third === '?' || third === '#')
1757
+ );
1758
+ };
1759
+
1760
+ // https://url.spec.whatwg.org/#single-dot-path-segment
1761
+ var isSingleDot = function (segment) {
1762
+ return segment === '.' || toLowerCase(segment) === '%2e';
1763
+ };
1764
+
1765
+ // https://url.spec.whatwg.org/#double-dot-path-segment
1766
+ var isDoubleDot = function (segment) {
1767
+ segment = toLowerCase(segment);
1768
+ return segment === '..' || segment === '%2e.' || segment === '.%2e' || segment === '%2e%2e';
1769
+ };
1770
+
1771
+ // States:
1772
+ var SCHEME_START = {};
1773
+ var SCHEME = {};
1774
+ var NO_SCHEME = {};
1775
+ var SPECIAL_RELATIVE_OR_AUTHORITY = {};
1776
+ var PATH_OR_AUTHORITY = {};
1777
+ var RELATIVE = {};
1778
+ var RELATIVE_SLASH = {};
1779
+ var SPECIAL_AUTHORITY_SLASHES = {};
1780
+ var SPECIAL_AUTHORITY_IGNORE_SLASHES = {};
1781
+ var AUTHORITY = {};
1782
+ var HOST = {};
1783
+ var HOSTNAME = {};
1784
+ var PORT = {};
1785
+ var FILE = {};
1786
+ var FILE_SLASH = {};
1787
+ var FILE_HOST = {};
1788
+ var PATH_START = {};
1789
+ var PATH = {};
1790
+ var CANNOT_BE_A_BASE_URL_PATH = {};
1791
+ var QUERY = {};
1792
+ var FRAGMENT = {};
1793
+
1794
+ var URLState = function (url, isBase, base) {
1795
+ var urlString = $toString(url);
1796
+ var baseState, failure, searchParams;
1797
+ if (isBase) {
1798
+ failure = this.parse(urlString);
1799
+ if (failure) throw new TypeError$1(failure);
1800
+ this.searchParams = null;
1801
+ } else {
1802
+ if (base !== undefined) baseState = new URLState(base, true);
1803
+ failure = this.parse(urlString, null, baseState);
1804
+ if (failure) throw new TypeError$1(failure);
1805
+ searchParams = getInternalSearchParamsState(new URLSearchParams$1());
1806
+ searchParams.bindURL(this);
1807
+ this.searchParams = searchParams;
1808
+ }
1809
+ };
1810
+
1811
+ URLState.prototype = {
1812
+ type: 'URL',
1813
+ // https://url.spec.whatwg.org/#url-parsing
1814
+ // eslint-disable-next-line max-statements -- TODO
1815
+ parse: function (input, stateOverride, base) {
1816
+ var url = this;
1817
+ var state = stateOverride || SCHEME_START;
1818
+ var pointer = 0;
1819
+ var buffer = '';
1820
+ var seenAt = false;
1821
+ var seenBracket = false;
1822
+ var seenPasswordToken = false;
1823
+ var codePoints, chr, bufferCodePoints, failure;
1824
+
1825
+ input = $toString(input);
1826
+
1827
+ if (!stateOverride) {
1828
+ url.scheme = '';
1829
+ url.username = '';
1830
+ url.password = '';
1831
+ url.host = null;
1832
+ url.port = null;
1833
+ url.path = [];
1834
+ url.query = null;
1835
+ url.fragment = null;
1836
+ url.cannotBeABaseURL = false;
1837
+ input = replace(input, LEADING_C0_CONTROL_OR_SPACE, '');
1838
+ input = replace(input, TRAILING_C0_CONTROL_OR_SPACE, '$1');
1839
+ }
1840
+
1841
+ input = replace(input, TAB_AND_NEW_LINE, '');
1842
+
1843
+ codePoints = arrayFrom(input);
1844
+
1845
+ while (pointer <= codePoints.length) {
1846
+ chr = codePoints[pointer];
1847
+ switch (state) {
1848
+ case SCHEME_START:
1849
+ if (chr && exec(ALPHA, chr)) {
1850
+ buffer += toLowerCase(chr);
1851
+ state = SCHEME;
1852
+ } else if (!stateOverride) {
1853
+ state = NO_SCHEME;
1854
+ continue;
1855
+ } else return INVALID_SCHEME;
1856
+ break;
1857
+
1858
+ case SCHEME:
1859
+ if (chr && (exec(ALPHANUMERIC, chr) || chr === '+' || chr === '-' || chr === '.')) {
1860
+ buffer += toLowerCase(chr);
1861
+ } else if (chr === ':') {
1862
+ if (stateOverride && (
1863
+ (url.isSpecial() !== hasOwn(specialSchemes, buffer)) ||
1864
+ (buffer === 'file' && (url.includesCredentials() || url.port !== null)) ||
1865
+ (url.scheme === 'file' && !url.host)
1866
+ )) return;
1867
+ url.scheme = buffer;
1868
+ if (stateOverride) {
1869
+ if (url.isSpecial() && specialSchemes[url.scheme] === url.port) url.port = null;
1870
+ return;
1871
+ }
1872
+ buffer = '';
1873
+ if (url.scheme === 'file') {
1874
+ state = FILE;
1875
+ } else if (url.isSpecial() && base && base.scheme === url.scheme) {
1876
+ state = SPECIAL_RELATIVE_OR_AUTHORITY;
1877
+ } else if (url.isSpecial()) {
1878
+ state = SPECIAL_AUTHORITY_SLASHES;
1879
+ } else if (codePoints[pointer + 1] === '/') {
1880
+ state = PATH_OR_AUTHORITY;
1881
+ pointer++;
1882
+ } else {
1883
+ url.cannotBeABaseURL = true;
1884
+ push$1(url.path, '');
1885
+ state = CANNOT_BE_A_BASE_URL_PATH;
1886
+ }
1887
+ } else if (!stateOverride) {
1888
+ buffer = '';
1889
+ state = NO_SCHEME;
1890
+ pointer = 0;
1891
+ continue;
1892
+ } else return INVALID_SCHEME;
1893
+ break;
1894
+
1895
+ case NO_SCHEME:
1896
+ if (!base || (base.cannotBeABaseURL && chr !== '#')) return INVALID_SCHEME;
1897
+ if (base.cannotBeABaseURL && chr === '#') {
1898
+ url.scheme = base.scheme;
1899
+ url.path = arraySlice(base.path);
1900
+ url.query = base.query;
1901
+ url.fragment = '';
1902
+ url.cannotBeABaseURL = true;
1903
+ state = FRAGMENT;
1904
+ break;
1905
+ }
1906
+ state = base.scheme === 'file' ? FILE : RELATIVE;
1907
+ continue;
1908
+
1909
+ case SPECIAL_RELATIVE_OR_AUTHORITY:
1910
+ if (chr === '/' && codePoints[pointer + 1] === '/') {
1911
+ state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
1912
+ pointer++;
1913
+ } else {
1914
+ state = RELATIVE;
1915
+ continue;
1916
+ } break;
1917
+
1918
+ case PATH_OR_AUTHORITY:
1919
+ if (chr === '/') {
1920
+ state = AUTHORITY;
1921
+ break;
1922
+ } else {
1923
+ state = PATH;
1924
+ continue;
1925
+ }
1926
+
1927
+ case RELATIVE:
1928
+ url.scheme = base.scheme;
1929
+ if (chr === EOF) {
1930
+ url.username = base.username;
1931
+ url.password = base.password;
1932
+ url.host = base.host;
1933
+ url.port = base.port;
1934
+ url.path = arraySlice(base.path);
1935
+ url.query = base.query;
1936
+ } else if (chr === '/' || (chr === '\\' && url.isSpecial())) {
1937
+ state = RELATIVE_SLASH;
1938
+ } else if (chr === '?') {
1939
+ url.username = base.username;
1940
+ url.password = base.password;
1941
+ url.host = base.host;
1942
+ url.port = base.port;
1943
+ url.path = arraySlice(base.path);
1944
+ url.query = '';
1945
+ state = QUERY;
1946
+ } else if (chr === '#') {
1947
+ url.username = base.username;
1948
+ url.password = base.password;
1949
+ url.host = base.host;
1950
+ url.port = base.port;
1951
+ url.path = arraySlice(base.path);
1952
+ url.query = base.query;
1953
+ url.fragment = '';
1954
+ state = FRAGMENT;
1955
+ } else {
1956
+ url.username = base.username;
1957
+ url.password = base.password;
1958
+ url.host = base.host;
1959
+ url.port = base.port;
1960
+ url.path = arraySlice(base.path);
1961
+ url.path.length--;
1962
+ state = PATH;
1963
+ continue;
1964
+ } break;
1965
+
1966
+ case RELATIVE_SLASH:
1967
+ if (url.isSpecial() && (chr === '/' || chr === '\\')) {
1968
+ state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
1969
+ } else if (chr === '/') {
1970
+ state = AUTHORITY;
1971
+ } else {
1972
+ url.username = base.username;
1973
+ url.password = base.password;
1974
+ url.host = base.host;
1975
+ url.port = base.port;
1976
+ state = PATH;
1977
+ continue;
1978
+ } break;
1979
+
1980
+ case SPECIAL_AUTHORITY_SLASHES:
1981
+ state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
1982
+ if (chr !== '/' || charAt(buffer, pointer + 1) !== '/') continue;
1983
+ pointer++;
1984
+ break;
1985
+
1986
+ case SPECIAL_AUTHORITY_IGNORE_SLASHES:
1987
+ if (chr !== '/' && chr !== '\\') {
1988
+ state = AUTHORITY;
1989
+ continue;
1990
+ } break;
1991
+
1992
+ case AUTHORITY:
1993
+ if (chr === '@') {
1994
+ if (seenAt) buffer = '%40' + buffer;
1995
+ seenAt = true;
1996
+ bufferCodePoints = arrayFrom(buffer);
1997
+ for (var i = 0; i < bufferCodePoints.length; i++) {
1998
+ var codePoint = bufferCodePoints[i];
1999
+ if (codePoint === ':' && !seenPasswordToken) {
2000
+ seenPasswordToken = true;
2001
+ continue;
2002
+ }
2003
+ var encodedCodePoints = percentEncode(codePoint, userinfoPercentEncodeSet);
2004
+ if (seenPasswordToken) url.password += encodedCodePoints;
2005
+ else url.username += encodedCodePoints;
2006
+ }
2007
+ buffer = '';
2008
+ } else if (
2009
+ chr === EOF || chr === '/' || chr === '?' || chr === '#' ||
2010
+ (chr === '\\' && url.isSpecial())
2011
+ ) {
2012
+ if (seenAt && buffer === '') return INVALID_AUTHORITY;
2013
+ pointer -= arrayFrom(buffer).length + 1;
2014
+ buffer = '';
2015
+ state = HOST;
2016
+ } else buffer += chr;
2017
+ break;
2018
+
2019
+ case HOST:
2020
+ case HOSTNAME:
2021
+ if (stateOverride && url.scheme === 'file') {
2022
+ state = FILE_HOST;
2023
+ continue;
2024
+ } else if (chr === ':' && !seenBracket) {
2025
+ if (buffer === '') return INVALID_HOST;
2026
+ failure = url.parseHost(buffer);
2027
+ if (failure) return failure;
2028
+ buffer = '';
2029
+ state = PORT;
2030
+ if (stateOverride === HOSTNAME) return;
2031
+ } else if (
2032
+ chr === EOF || chr === '/' || chr === '?' || chr === '#' ||
2033
+ (chr === '\\' && url.isSpecial())
2034
+ ) {
2035
+ if (url.isSpecial() && buffer === '') return INVALID_HOST;
2036
+ if (stateOverride && buffer === '' && (url.includesCredentials() || url.port !== null)) return;
2037
+ failure = url.parseHost(buffer);
2038
+ if (failure) return failure;
2039
+ buffer = '';
2040
+ state = PATH_START;
2041
+ if (stateOverride) return;
2042
+ continue;
2043
+ } else {
2044
+ if (chr === '[') seenBracket = true;
2045
+ else if (chr === ']') seenBracket = false;
2046
+ buffer += chr;
2047
+ } break;
2048
+
2049
+ case PORT:
2050
+ if (exec(DIGIT, chr)) {
2051
+ buffer += chr;
2052
+ } else if (
2053
+ chr === EOF || chr === '/' || chr === '?' || chr === '#' ||
2054
+ (chr === '\\' && url.isSpecial()) ||
2055
+ stateOverride
2056
+ ) {
2057
+ if (buffer !== '') {
2058
+ var port = parseInt(buffer, 10);
2059
+ if (port > 0xFFFF) return INVALID_PORT;
2060
+ url.port = (url.isSpecial() && port === specialSchemes[url.scheme]) ? null : port;
2061
+ buffer = '';
2062
+ }
2063
+ if (stateOverride) return;
2064
+ state = PATH_START;
2065
+ continue;
2066
+ } else return INVALID_PORT;
2067
+ break;
2068
+
2069
+ case FILE:
2070
+ url.scheme = 'file';
2071
+ if (chr === '/' || chr === '\\') state = FILE_SLASH;
2072
+ else if (base && base.scheme === 'file') {
2073
+ switch (chr) {
2074
+ case EOF:
2075
+ url.host = base.host;
2076
+ url.path = arraySlice(base.path);
2077
+ url.query = base.query;
2078
+ break;
2079
+ case '?':
2080
+ url.host = base.host;
2081
+ url.path = arraySlice(base.path);
2082
+ url.query = '';
2083
+ state = QUERY;
2084
+ break;
2085
+ case '#':
2086
+ url.host = base.host;
2087
+ url.path = arraySlice(base.path);
2088
+ url.query = base.query;
2089
+ url.fragment = '';
2090
+ state = FRAGMENT;
2091
+ break;
2092
+ default:
2093
+ if (!startsWithWindowsDriveLetter(join(arraySlice(codePoints, pointer), ''))) {
2094
+ url.host = base.host;
2095
+ url.path = arraySlice(base.path);
2096
+ url.shortenPath();
2097
+ }
2098
+ state = PATH;
2099
+ continue;
2100
+ }
2101
+ } else {
2102
+ state = PATH;
2103
+ continue;
2104
+ } break;
2105
+
2106
+ case FILE_SLASH:
2107
+ if (chr === '/' || chr === '\\') {
2108
+ state = FILE_HOST;
2109
+ break;
2110
+ }
2111
+ if (base && base.scheme === 'file' && !startsWithWindowsDriveLetter(join(arraySlice(codePoints, pointer), ''))) {
2112
+ if (isWindowsDriveLetter(base.path[0], true)) push$1(url.path, base.path[0]);
2113
+ else url.host = base.host;
2114
+ }
2115
+ state = PATH;
2116
+ continue;
2117
+
2118
+ case FILE_HOST:
2119
+ if (chr === EOF || chr === '/' || chr === '\\' || chr === '?' || chr === '#') {
2120
+ if (!stateOverride && isWindowsDriveLetter(buffer)) {
2121
+ state = PATH;
2122
+ } else if (buffer === '') {
2123
+ url.host = '';
2124
+ if (stateOverride) return;
2125
+ state = PATH_START;
2126
+ } else {
2127
+ failure = url.parseHost(buffer);
2128
+ if (failure) return failure;
2129
+ if (url.host === 'localhost') url.host = '';
2130
+ if (stateOverride) return;
2131
+ buffer = '';
2132
+ state = PATH_START;
2133
+ } continue;
2134
+ } else buffer += chr;
2135
+ break;
2136
+
2137
+ case PATH_START:
2138
+ if (url.isSpecial()) {
2139
+ state = PATH;
2140
+ if (chr !== '/' && chr !== '\\') continue;
2141
+ } else if (!stateOverride && chr === '?') {
2142
+ url.query = '';
2143
+ state = QUERY;
2144
+ } else if (!stateOverride && chr === '#') {
2145
+ url.fragment = '';
2146
+ state = FRAGMENT;
2147
+ } else if (chr !== EOF) {
2148
+ state = PATH;
2149
+ if (chr !== '/') continue;
2150
+ } break;
2151
+
2152
+ case PATH:
2153
+ if (
2154
+ chr === EOF || chr === '/' ||
2155
+ (chr === '\\' && url.isSpecial()) ||
2156
+ (!stateOverride && (chr === '?' || chr === '#'))
2157
+ ) {
2158
+ if (isDoubleDot(buffer)) {
2159
+ url.shortenPath();
2160
+ if (chr !== '/' && !(chr === '\\' && url.isSpecial())) {
2161
+ push$1(url.path, '');
2162
+ }
2163
+ } else if (isSingleDot(buffer)) {
2164
+ if (chr !== '/' && !(chr === '\\' && url.isSpecial())) {
2165
+ push$1(url.path, '');
2166
+ }
2167
+ } else {
2168
+ if (url.scheme === 'file' && !url.path.length && isWindowsDriveLetter(buffer)) {
2169
+ if (url.host) url.host = '';
2170
+ buffer = charAt(buffer, 0) + ':'; // normalize windows drive letter
2171
+ }
2172
+ push$1(url.path, buffer);
2173
+ }
2174
+ buffer = '';
2175
+ if (url.scheme === 'file' && (chr === EOF || chr === '?' || chr === '#')) {
2176
+ while (url.path.length > 1 && url.path[0] === '') {
2177
+ shift(url.path);
2178
+ }
2179
+ }
2180
+ if (chr === '?') {
2181
+ url.query = '';
2182
+ state = QUERY;
2183
+ } else if (chr === '#') {
2184
+ url.fragment = '';
2185
+ state = FRAGMENT;
2186
+ }
2187
+ } else {
2188
+ buffer += percentEncode(chr, pathPercentEncodeSet);
2189
+ } break;
2190
+
2191
+ case CANNOT_BE_A_BASE_URL_PATH:
2192
+ if (chr === '?') {
2193
+ url.query = '';
2194
+ state = QUERY;
2195
+ } else if (chr === '#') {
2196
+ url.fragment = '';
2197
+ state = FRAGMENT;
2198
+ } else if (chr !== EOF) {
2199
+ url.path[0] += percentEncode(chr, C0ControlPercentEncodeSet);
2200
+ } break;
2201
+
2202
+ case QUERY:
2203
+ if (!stateOverride && chr === '#') {
2204
+ url.fragment = '';
2205
+ state = FRAGMENT;
2206
+ } else if (chr !== EOF) {
2207
+ if (chr === "'" && url.isSpecial()) url.query += '%27';
2208
+ else if (chr === '#') url.query += '%23';
2209
+ else url.query += percentEncode(chr, C0ControlPercentEncodeSet);
2210
+ } break;
2211
+
2212
+ case FRAGMENT:
2213
+ if (chr !== EOF) url.fragment += percentEncode(chr, fragmentPercentEncodeSet);
2214
+ break;
2215
+ }
2216
+
2217
+ pointer++;
2218
+ }
2219
+ },
2220
+ // https://url.spec.whatwg.org/#host-parsing
2221
+ parseHost: function (input) {
2222
+ var result, codePoints, index;
2223
+ if (charAt(input, 0) === '[') {
2224
+ if (charAt(input, input.length - 1) !== ']') return INVALID_HOST;
2225
+ result = parseIPv6(stringSlice(input, 1, -1));
2226
+ if (!result) return INVALID_HOST;
2227
+ this.host = result;
2228
+ // opaque host
2229
+ } else if (!this.isSpecial()) {
2230
+ if (exec(FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT, input)) return INVALID_HOST;
2231
+ result = '';
2232
+ codePoints = arrayFrom(input);
2233
+ for (index = 0; index < codePoints.length; index++) {
2234
+ result += percentEncode(codePoints[index], C0ControlPercentEncodeSet);
2235
+ }
2236
+ this.host = result;
2237
+ } else {
2238
+ input = toASCII(input);
2239
+ if (exec(FORBIDDEN_HOST_CODE_POINT, input)) return INVALID_HOST;
2240
+ result = parseIPv4(input);
2241
+ if (result === null) return INVALID_HOST;
2242
+ this.host = result;
2243
+ }
2244
+ },
2245
+ // https://url.spec.whatwg.org/#cannot-have-a-username-password-port
2246
+ cannotHaveUsernamePasswordPort: function () {
2247
+ return !this.host || this.cannotBeABaseURL || this.scheme === 'file';
2248
+ },
2249
+ // https://url.spec.whatwg.org/#include-credentials
2250
+ includesCredentials: function () {
2251
+ return this.username !== '' || this.password !== '';
2252
+ },
2253
+ // https://url.spec.whatwg.org/#is-special
2254
+ isSpecial: function () {
2255
+ return hasOwn(specialSchemes, this.scheme);
2256
+ },
2257
+ // https://url.spec.whatwg.org/#shorten-a-urls-path
2258
+ shortenPath: function () {
2259
+ var path = this.path;
2260
+ var pathSize = path.length;
2261
+ if (pathSize && (this.scheme !== 'file' || pathSize !== 1 || !isWindowsDriveLetter(path[0], true))) {
2262
+ path.length--;
2263
+ }
2264
+ },
2265
+ // https://url.spec.whatwg.org/#concept-url-serializer
2266
+ serialize: function () {
2267
+ var url = this;
2268
+ var scheme = url.scheme;
2269
+ var username = url.username;
2270
+ var password = url.password;
2271
+ var host = url.host;
2272
+ var port = url.port;
2273
+ var path = url.path;
2274
+ var query = url.query;
2275
+ var fragment = url.fragment;
2276
+ var output = scheme + ':';
2277
+ if (host !== null) {
2278
+ output += '//';
2279
+ if (url.includesCredentials()) {
2280
+ output += username + (password ? ':' + password : '') + '@';
2281
+ }
2282
+ output += serializeHost(host);
2283
+ if (port !== null) output += ':' + port;
2284
+ } else if (scheme === 'file') output += '//';
2285
+ output += url.cannotBeABaseURL ? path[0] : path.length ? '/' + join(path, '/') : '';
2286
+ if (query !== null) output += '?' + query;
2287
+ if (fragment !== null) output += '#' + fragment;
2288
+ return output;
2289
+ },
2290
+ // https://url.spec.whatwg.org/#dom-url-href
2291
+ setHref: function (href) {
2292
+ var failure = this.parse(href);
2293
+ if (failure) throw new TypeError$1(failure);
2294
+ this.searchParams.update();
2295
+ },
2296
+ // https://url.spec.whatwg.org/#dom-url-origin
2297
+ getOrigin: function () {
2298
+ var scheme = this.scheme;
2299
+ var port = this.port;
2300
+ if (scheme === 'blob') try {
2301
+ return new URLConstructor(scheme.path[0]).origin;
2302
+ } catch (error) {
2303
+ return 'null';
2304
+ }
2305
+ if (scheme === 'file' || !this.isSpecial()) return 'null';
2306
+ return scheme + '://' + serializeHost(this.host) + (port !== null ? ':' + port : '');
2307
+ },
2308
+ // https://url.spec.whatwg.org/#dom-url-protocol
2309
+ getProtocol: function () {
2310
+ return this.scheme + ':';
2311
+ },
2312
+ setProtocol: function (protocol) {
2313
+ this.parse($toString(protocol) + ':', SCHEME_START);
2314
+ },
2315
+ // https://url.spec.whatwg.org/#dom-url-username
2316
+ getUsername: function () {
2317
+ return this.username;
2318
+ },
2319
+ setUsername: function (username) {
2320
+ var codePoints = arrayFrom($toString(username));
2321
+ if (this.cannotHaveUsernamePasswordPort()) return;
2322
+ this.username = '';
2323
+ for (var i = 0; i < codePoints.length; i++) {
2324
+ this.username += percentEncode(codePoints[i], userinfoPercentEncodeSet);
2325
+ }
2326
+ },
2327
+ // https://url.spec.whatwg.org/#dom-url-password
2328
+ getPassword: function () {
2329
+ return this.password;
2330
+ },
2331
+ setPassword: function (password) {
2332
+ var codePoints = arrayFrom($toString(password));
2333
+ if (this.cannotHaveUsernamePasswordPort()) return;
2334
+ this.password = '';
2335
+ for (var i = 0; i < codePoints.length; i++) {
2336
+ this.password += percentEncode(codePoints[i], userinfoPercentEncodeSet);
2337
+ }
2338
+ },
2339
+ // https://url.spec.whatwg.org/#dom-url-host
2340
+ getHost: function () {
2341
+ var host = this.host;
2342
+ var port = this.port;
2343
+ return host === null ? ''
2344
+ : port === null ? serializeHost(host)
2345
+ : serializeHost(host) + ':' + port;
2346
+ },
2347
+ setHost: function (host) {
2348
+ if (this.cannotBeABaseURL) return;
2349
+ this.parse(host, HOST);
2350
+ },
2351
+ // https://url.spec.whatwg.org/#dom-url-hostname
2352
+ getHostname: function () {
2353
+ var host = this.host;
2354
+ return host === null ? '' : serializeHost(host);
2355
+ },
2356
+ setHostname: function (hostname) {
2357
+ if (this.cannotBeABaseURL) return;
2358
+ this.parse(hostname, HOSTNAME);
2359
+ },
2360
+ // https://url.spec.whatwg.org/#dom-url-port
2361
+ getPort: function () {
2362
+ var port = this.port;
2363
+ return port === null ? '' : $toString(port);
2364
+ },
2365
+ setPort: function (port) {
2366
+ if (this.cannotHaveUsernamePasswordPort()) return;
2367
+ port = $toString(port);
2368
+ if (port === '') this.port = null;
2369
+ else this.parse(port, PORT);
2370
+ },
2371
+ // https://url.spec.whatwg.org/#dom-url-pathname
2372
+ getPathname: function () {
2373
+ var path = this.path;
2374
+ return this.cannotBeABaseURL ? path[0] : path.length ? '/' + join(path, '/') : '';
2375
+ },
2376
+ setPathname: function (pathname) {
2377
+ if (this.cannotBeABaseURL) return;
2378
+ this.path = [];
2379
+ this.parse(pathname, PATH_START);
2380
+ },
2381
+ // https://url.spec.whatwg.org/#dom-url-search
2382
+ getSearch: function () {
2383
+ var query = this.query;
2384
+ return query ? '?' + query : '';
2385
+ },
2386
+ setSearch: function (search) {
2387
+ search = $toString(search);
2388
+ if (search === '') {
2389
+ this.query = null;
2390
+ } else {
2391
+ if (charAt(search, 0) === '?') search = stringSlice(search, 1);
2392
+ this.query = '';
2393
+ this.parse(search, QUERY);
2394
+ }
2395
+ this.searchParams.update();
2396
+ },
2397
+ // https://url.spec.whatwg.org/#dom-url-searchparams
2398
+ getSearchParams: function () {
2399
+ return this.searchParams.facade;
2400
+ },
2401
+ // https://url.spec.whatwg.org/#dom-url-hash
2402
+ getHash: function () {
2403
+ var fragment = this.fragment;
2404
+ return fragment ? '#' + fragment : '';
2405
+ },
2406
+ setHash: function (hash) {
2407
+ hash = $toString(hash);
2408
+ if (hash === '') {
2409
+ this.fragment = null;
2410
+ return;
2411
+ }
2412
+ if (charAt(hash, 0) === '#') hash = stringSlice(hash, 1);
2413
+ this.fragment = '';
2414
+ this.parse(hash, FRAGMENT);
2415
+ },
2416
+ update: function () {
2417
+ this.query = this.searchParams.serialize() || null;
2418
+ }
2419
+ };
2420
+
2421
+ // `URL` constructor
2422
+ // https://url.spec.whatwg.org/#url-class
2423
+ var URLConstructor = function URL(url /* , base */) {
2424
+ var that = anInstance(this, URLPrototype);
2425
+ var base = validateArgumentsLength$2(arguments.length, 1) > 1 ? arguments[1] : undefined;
2426
+ var state = setInternalState(that, new URLState(url, false, base));
2427
+ if (!DESCRIPTORS$1) {
2428
+ that.href = state.serialize();
2429
+ that.origin = state.getOrigin();
2430
+ that.protocol = state.getProtocol();
2431
+ that.username = state.getUsername();
2432
+ that.password = state.getPassword();
2433
+ that.host = state.getHost();
2434
+ that.hostname = state.getHostname();
2435
+ that.port = state.getPort();
2436
+ that.pathname = state.getPathname();
2437
+ that.search = state.getSearch();
2438
+ that.searchParams = state.getSearchParams();
2439
+ that.hash = state.getHash();
2440
+ }
2441
+ };
2442
+
2443
+ var URLPrototype = URLConstructor.prototype;
2444
+
2445
+ var accessorDescriptor = function (getter, setter) {
2446
+ return {
2447
+ get: function () {
2448
+ return getInternalURLState(this)[getter]();
2449
+ },
2450
+ set: setter && function (value) {
2451
+ return getInternalURLState(this)[setter](value);
2452
+ },
2453
+ configurable: true,
2454
+ enumerable: true
2455
+ };
2456
+ };
2457
+
2458
+ if (DESCRIPTORS$1) {
2459
+ // `URL.prototype.href` accessors pair
2460
+ // https://url.spec.whatwg.org/#dom-url-href
2461
+ defineBuiltInAccessor$1(URLPrototype, 'href', accessorDescriptor('serialize', 'setHref'));
2462
+ // `URL.prototype.origin` getter
2463
+ // https://url.spec.whatwg.org/#dom-url-origin
2464
+ defineBuiltInAccessor$1(URLPrototype, 'origin', accessorDescriptor('getOrigin'));
2465
+ // `URL.prototype.protocol` accessors pair
2466
+ // https://url.spec.whatwg.org/#dom-url-protocol
2467
+ defineBuiltInAccessor$1(URLPrototype, 'protocol', accessorDescriptor('getProtocol', 'setProtocol'));
2468
+ // `URL.prototype.username` accessors pair
2469
+ // https://url.spec.whatwg.org/#dom-url-username
2470
+ defineBuiltInAccessor$1(URLPrototype, 'username', accessorDescriptor('getUsername', 'setUsername'));
2471
+ // `URL.prototype.password` accessors pair
2472
+ // https://url.spec.whatwg.org/#dom-url-password
2473
+ defineBuiltInAccessor$1(URLPrototype, 'password', accessorDescriptor('getPassword', 'setPassword'));
2474
+ // `URL.prototype.host` accessors pair
2475
+ // https://url.spec.whatwg.org/#dom-url-host
2476
+ defineBuiltInAccessor$1(URLPrototype, 'host', accessorDescriptor('getHost', 'setHost'));
2477
+ // `URL.prototype.hostname` accessors pair
2478
+ // https://url.spec.whatwg.org/#dom-url-hostname
2479
+ defineBuiltInAccessor$1(URLPrototype, 'hostname', accessorDescriptor('getHostname', 'setHostname'));
2480
+ // `URL.prototype.port` accessors pair
2481
+ // https://url.spec.whatwg.org/#dom-url-port
2482
+ defineBuiltInAccessor$1(URLPrototype, 'port', accessorDescriptor('getPort', 'setPort'));
2483
+ // `URL.prototype.pathname` accessors pair
2484
+ // https://url.spec.whatwg.org/#dom-url-pathname
2485
+ defineBuiltInAccessor$1(URLPrototype, 'pathname', accessorDescriptor('getPathname', 'setPathname'));
2486
+ // `URL.prototype.search` accessors pair
2487
+ // https://url.spec.whatwg.org/#dom-url-search
2488
+ defineBuiltInAccessor$1(URLPrototype, 'search', accessorDescriptor('getSearch', 'setSearch'));
2489
+ // `URL.prototype.searchParams` getter
2490
+ // https://url.spec.whatwg.org/#dom-url-searchparams
2491
+ defineBuiltInAccessor$1(URLPrototype, 'searchParams', accessorDescriptor('getSearchParams'));
2492
+ // `URL.prototype.hash` accessors pair
2493
+ // https://url.spec.whatwg.org/#dom-url-hash
2494
+ defineBuiltInAccessor$1(URLPrototype, 'hash', accessorDescriptor('getHash', 'setHash'));
2495
+ }
2496
+
2497
+ // `URL.prototype.toJSON` method
2498
+ // https://url.spec.whatwg.org/#dom-url-tojson
2499
+ defineBuiltIn$2(URLPrototype, 'toJSON', function toJSON() {
2500
+ return getInternalURLState(this).serialize();
2501
+ }, { enumerable: true });
2502
+
2503
+ // `URL.prototype.toString` method
2504
+ // https://url.spec.whatwg.org/#URL-stringification-behavior
2505
+ defineBuiltIn$2(URLPrototype, 'toString', function toString() {
2506
+ return getInternalURLState(this).serialize();
2507
+ }, { enumerable: true });
2508
+
2509
+ if (NativeURL) {
2510
+ var nativeCreateObjectURL = NativeURL.createObjectURL;
2511
+ var nativeRevokeObjectURL = NativeURL.revokeObjectURL;
2512
+ // `URL.createObjectURL` method
2513
+ // https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL
2514
+ if (nativeCreateObjectURL) defineBuiltIn$2(URLConstructor, 'createObjectURL', bind(nativeCreateObjectURL, NativeURL));
2515
+ // `URL.revokeObjectURL` method
2516
+ // https://developer.mozilla.org/en-US/docs/Web/API/URL/revokeObjectURL
2517
+ if (nativeRevokeObjectURL) defineBuiltIn$2(URLConstructor, 'revokeObjectURL', bind(nativeRevokeObjectURL, NativeURL));
2518
+ }
2519
+
2520
+ setToStringTag(URLConstructor, 'URL');
2521
+
2522
+ $$1({ global: true, constructor: true, forced: !USE_NATIVE_URL, sham: !DESCRIPTORS$1 }, {
2523
+ URL: URLConstructor
2524
+ });
2525
+
2526
+ var $ = _export;
2527
+ var call = functionCall;
2528
+
2529
+ // `URL.prototype.toJSON` method
2530
+ // https://url.spec.whatwg.org/#dom-url-tojson
2531
+ $({ target: 'URL', proto: true, enumerable: true }, {
2532
+ toJSON: function toJSON() {
2533
+ return call(URL.prototype.toString, this);
2534
+ }
2535
+ });
2536
+
2537
+ var defineBuiltIn$1 = defineBuiltIn$5;
2538
+ var uncurryThis$2 = functionUncurryThis;
2539
+ var toString$1 = toString$4;
2540
+ var validateArgumentsLength$1 = validateArgumentsLength$4;
2541
+
2542
+ var $URLSearchParams$1 = URLSearchParams;
2543
+ var URLSearchParamsPrototype$2 = $URLSearchParams$1.prototype;
2544
+ var append = uncurryThis$2(URLSearchParamsPrototype$2.append);
2545
+ var $delete = uncurryThis$2(URLSearchParamsPrototype$2['delete']);
2546
+ var forEach$1 = uncurryThis$2(URLSearchParamsPrototype$2.forEach);
2547
+ var push = uncurryThis$2([].push);
2548
+ var params$1 = new $URLSearchParams$1('a=1&a=2&b=3');
2549
+
2550
+ params$1['delete']('a', 1);
2551
+ // `undefined` case is a Chromium 117 bug
2552
+ // https://bugs.chromium.org/p/v8/issues/detail?id=14222
2553
+ params$1['delete']('b', undefined);
2554
+
2555
+ if (params$1 + '' !== 'a=2') {
2556
+ defineBuiltIn$1(URLSearchParamsPrototype$2, 'delete', function (name /* , value */) {
2557
+ var length = arguments.length;
2558
+ var $value = length < 2 ? undefined : arguments[1];
2559
+ if (length && $value === undefined) return $delete(this, name);
2560
+ var entries = [];
2561
+ forEach$1(this, function (v, k) { // also validates `this`
2562
+ push(entries, { key: k, value: v });
2563
+ });
2564
+ validateArgumentsLength$1(length, 1);
2565
+ var key = toString$1(name);
2566
+ var value = toString$1($value);
2567
+ var index = 0;
2568
+ var dindex = 0;
2569
+ var found = false;
2570
+ var entriesLength = entries.length;
2571
+ var entry;
2572
+ while (index < entriesLength) {
2573
+ entry = entries[index++];
2574
+ if (found || entry.key === key) {
2575
+ found = true;
2576
+ $delete(this, entry.key);
2577
+ } else dindex++;
2578
+ }
2579
+ while (dindex < entriesLength) {
2580
+ entry = entries[dindex++];
2581
+ if (!(entry.key === key && entry.value === value)) append(this, entry.key, entry.value);
2582
+ }
2583
+ }, { enumerable: true, unsafe: true });
2584
+ }
2585
+
2586
+ var defineBuiltIn = defineBuiltIn$5;
2587
+ var uncurryThis$1 = functionUncurryThis;
2588
+ var toString = toString$4;
2589
+ var validateArgumentsLength = validateArgumentsLength$4;
2590
+
2591
+ var $URLSearchParams = URLSearchParams;
2592
+ var URLSearchParamsPrototype$1 = $URLSearchParams.prototype;
2593
+ var getAll = uncurryThis$1(URLSearchParamsPrototype$1.getAll);
2594
+ var $has = uncurryThis$1(URLSearchParamsPrototype$1.has);
2595
+ var params = new $URLSearchParams('a=1');
2596
+
2597
+ // `undefined` case is a Chromium 117 bug
2598
+ // https://bugs.chromium.org/p/v8/issues/detail?id=14222
2599
+ if (params.has('a', 2) || !params.has('a', undefined)) {
2600
+ defineBuiltIn(URLSearchParamsPrototype$1, 'has', function has(name /* , value */) {
2601
+ var length = arguments.length;
2602
+ var $value = length < 2 ? undefined : arguments[1];
2603
+ if (length && $value === undefined) return $has(this, name);
2604
+ var values = getAll(this, name); // also validates `this`
2605
+ validateArgumentsLength(length, 1);
2606
+ var value = toString($value);
2607
+ var index = 0;
2608
+ while (index < values.length) {
2609
+ if (values[index++] === value) return true;
2610
+ } return false;
2611
+ }, { enumerable: true, unsafe: true });
2612
+ }
2613
+
2614
+ var DESCRIPTORS = descriptors;
2615
+ var uncurryThis = functionUncurryThis;
2616
+ var defineBuiltInAccessor = defineBuiltInAccessor$3;
2617
+
2618
+ var URLSearchParamsPrototype = URLSearchParams.prototype;
2619
+ var forEach = uncurryThis(URLSearchParamsPrototype.forEach);
2620
+
2621
+ // `URLSearchParams.prototype.size` getter
2622
+ // https://github.com/whatwg/url/pull/734
2623
+ if (DESCRIPTORS && !('size' in URLSearchParamsPrototype)) {
2624
+ defineBuiltInAccessor(URLSearchParamsPrototype, 'size', {
2625
+ get: function size() {
2626
+ var count = 0;
2627
+ forEach(this, function () { count++; });
2628
+ return count;
2629
+ },
2630
+ configurable: true,
2631
+ enumerable: true
2632
+ });
2633
+ }
2634
+
2635
+ const DEFAULT_TINYMCE_CONFIG = {
2636
+ inline: true,
2637
+ menubar: false,
2638
+ powerpaste_html_import: 'clean',
2639
+ powerpaste_word_import: 'clean',
2640
+ suffix: '.min',
2641
+ valid_styles: {
2642
+ '*': 'font-size,font-family,color,text-decoration,text-align'
2643
+ }
2644
+ };
2645
+ const TINYMCE_CONFIG = {
2646
+ full: Object.assign({}, DEFAULT_TINYMCE_CONFIG, {
2647
+ plugins: 'link lists autolink charmap',
2648
+ toolbar: ['styleselect undo redo | bold italic underline | forecolor backcolor | alignleft aligncenter alignright alignfull | numlist bullist outdent indent | hr charmap removeformat | link'],
2649
+ style_formats: [{
2650
+ title: 'Paragraph',
2651
+ format: 'p'
2652
+ }, {
2653
+ title: 'Header 1',
2654
+ format: 'h1'
2655
+ }, {
2656
+ title: 'Header 2',
2657
+ format: 'h2'
2658
+ }, {
2659
+ title: 'Header 3',
2660
+ format: 'h3'
2661
+ }, {
2662
+ title: 'Header 4',
2663
+ format: 'h4'
2664
+ }, {
2665
+ title: 'Header 5',
2666
+ format: 'h5'
2667
+ }, {
2668
+ title: 'Header 6',
2669
+ format: 'h6'
2670
+ }, {
2671
+ title: 'Pre',
2672
+ format: 'pre'
2673
+ }, {
2674
+ title: 'Code',
2675
+ format: 'code'
2676
+ }]
2677
+ }),
2678
+ plain: Object.assign({}, DEFAULT_TINYMCE_CONFIG, {
2679
+ plugins: '',
2680
+ toolbar: ''
2681
+ }),
2682
+ minimal: Object.assign({}, DEFAULT_TINYMCE_CONFIG, {
2683
+ plugins: 'link autolink',
2684
+ toolbar: 'bold italic underline | link',
2685
+ valid_elements: 'strong,em,span[style],a[href]'
2686
+ })
2687
+ };
2688
+
2689
+ const MCE_URL = '/ext/tinymcev7/tinymce.min.js';
2690
+ /**
2691
+ * Allows inline edit content pulled from dotCMS API using TinyMCE editor
2692
+ *
2693
+ * @export
2694
+ * @component
2695
+ * @param {Readonly<DotEditableTextProps>} props {
2696
+ * mode = 'plain',
2697
+ * format = 'text',
2698
+ * contentlet,
2699
+ * fieldName = ''
2700
+ * }
2701
+ * @example
2702
+ * ```javascript
2703
+ * import { DotEditableText } from '@dotcms/react';
2704
+ *
2705
+ * const MyContentletWithTitle = ({ contentlet }) => (
2706
+ * <h2>
2707
+ * <DotEditableText
2708
+ * contentlet={contentlet}
2709
+ * fieldName="title"
2710
+ * mode='full'
2711
+ * format='text'/>
2712
+ * </h2>
2713
+ * );
2714
+ * ```
2715
+ * @returns {JSX.Element} A component to edit content inline
2716
+ */
2717
+ function DotEditableText({
2718
+ mode = 'plain',
2719
+ format = 'text',
2720
+ contentlet,
2721
+ fieldName = ''
2722
+ }) {
2723
+ const editorRef = useRef(null);
2724
+ const [scriptSrc, setScriptSrc] = useState('');
2725
+ const [isInsideEditor$1, setIsInsideEditor] = useState(false);
2726
+ const [content, setContent] = useState((contentlet == null ? void 0 : contentlet[fieldName]) || '');
2727
+ useEffect(() => {
2728
+ var _editorRef$current;
2729
+ setIsInsideEditor(isInsideEditor());
2730
+ if (!contentlet || !fieldName) {
2731
+ console.error('DotEditableText: contentlet or fieldName is missing');
2732
+ console.error('Ensure that all needed props are passed to view and edit the content');
2733
+ return;
2734
+ }
2735
+ if (!isInsideEditor()) {
2736
+ return;
2737
+ }
2738
+ const createURL = new URL(MCE_URL, DotCmsClient.dotcmsUrl);
2739
+ setScriptSrc(createURL.toString());
2740
+ const content = (contentlet == null ? void 0 : contentlet[fieldName]) || '';
2741
+ (_editorRef$current = editorRef.current) == null || _editorRef$current.setContent(content, {
2742
+ format
2743
+ });
2744
+ setContent(content);
2745
+ }, [format, fieldName, contentlet]);
2746
+ useEffect(() => {
2747
+ if (!isInsideEditor()) {
2748
+ return;
2749
+ }
2750
+ const onMessage = ({
2751
+ data
2752
+ }) => {
2753
+ const {
2754
+ name,
2755
+ payload
2756
+ } = data;
2757
+ if (name !== NOTIFY_CLIENT.UVE_COPY_CONTENTLET_INLINE_EDITING_SUCCESS) {
2758
+ return;
2759
+ }
2760
+ const {
2761
+ oldInode,
2762
+ inode
2763
+ } = payload;
2764
+ const currentInode = contentlet.inode;
2765
+ const shouldFocus = currentInode === oldInode || currentInode === inode;
2766
+ if (shouldFocus) {
2767
+ var _editorRef$current2;
2768
+ (_editorRef$current2 = editorRef.current) == null || _editorRef$current2.focus();
2769
+ }
2770
+ };
2771
+ window.addEventListener('message', onMessage);
2772
+ return () => {
2773
+ window.removeEventListener('message', onMessage);
2774
+ };
2775
+ }, [contentlet.inode]);
2776
+ const onMouseDown = event => {
2777
+ var _editorRef$current3;
2778
+ const {
2779
+ onNumberOfPages = 1
2780
+ } = contentlet;
2781
+ const {
2782
+ inode,
2783
+ languageId: language
2784
+ } = contentlet;
2785
+ if (onNumberOfPages <= 1 || (_editorRef$current3 = editorRef.current) != null && _editorRef$current3.hasFocus()) {
2786
+ return;
2787
+ }
2788
+ event.stopPropagation();
2789
+ event.preventDefault();
2790
+ postMessageToEditor({
2791
+ action: CLIENT_ACTIONS.COPY_CONTENTLET_INLINE_EDITING,
2792
+ payload: {
2793
+ dataset: {
2794
+ inode,
2795
+ language,
2796
+ fieldName
2797
+ }
2798
+ }
2799
+ });
2800
+ };
2801
+ const onFocusOut = () => {
2802
+ var _editorRef$current4, _editorRef$current5;
2803
+ const editedContent = ((_editorRef$current4 = editorRef.current) == null ? void 0 : _editorRef$current4.getContent({
2804
+ format: format
2805
+ })) || '';
2806
+ const {
2807
+ inode,
2808
+ languageId: langId
2809
+ } = contentlet;
2810
+ if (!((_editorRef$current5 = editorRef.current) != null && _editorRef$current5.isDirty()) || !didContentChange(editedContent)) {
2811
+ return;
2812
+ }
2813
+ postMessageToEditor({
2814
+ action: CLIENT_ACTIONS.UPDATE_CONTENTLET_INLINE_EDITING,
2815
+ payload: {
2816
+ content: editedContent,
2817
+ dataset: {
2818
+ inode,
2819
+ langId,
2820
+ fieldName
2821
+ }
2822
+ }
2823
+ });
2824
+ };
2825
+ const didContentChange = editedContent => {
2826
+ return content !== editedContent;
2827
+ };
2828
+ if (!isInsideEditor$1) {
2829
+ // We can let the user pass the Child Component and create a root to get the HTML for the editor
2830
+ return jsx("span", {
2831
+ dangerouslySetInnerHTML: {
2832
+ __html: content
2833
+ }
2834
+ });
2835
+ }
2836
+ return jsx(Editor, {
2837
+ tinymceScriptSrc: scriptSrc,
2838
+ inline: true,
2839
+ onInit: (_, editor) => editorRef.current = editor,
2840
+ init: TINYMCE_CONFIG[mode],
2841
+ initialValue: content,
2842
+ onMouseDown: onMouseDown,
2843
+ onFocusOut: onFocusOut
2844
+ });
2845
+ }
2846
+
2847
+ /**
2848
+ * `useDotcmsPageContext` is a custom React hook that provides access to the `PageProviderContext`.
2849
+ * It takes no parameters and returns the context value or `null` if it's not available.
2850
+ *
2851
+ * @category Hooks
2852
+ * @returns {DotCMSPageContext | null} - The context value or `null` if it's not available.
2853
+ */
2854
+ function useDotcmsPageContext() {
2855
+ return useContext(PageContext);
2856
+ }
2857
+
2858
+ /**
2859
+ * Represents the different types of Blocks that can be used in the Block Editor
2860
+ *
2861
+ * @export
2862
+ * @enum {number}
2863
+ */
2864
+ var Blocks;
2865
+ (function (Blocks) {
2866
+ Blocks["PARAGRAPH"] = "paragraph";
2867
+ Blocks["HEADING"] = "heading";
2868
+ Blocks["TEXT"] = "text";
2869
+ Blocks["BULLET_LIST"] = "bulletList";
2870
+ Blocks["ORDERED_LIST"] = "orderedList";
2871
+ Blocks["LIST_ITEM"] = "listItem";
2872
+ Blocks["BLOCK_QUOTE"] = "blockquote";
2873
+ Blocks["CODE_BLOCK"] = "codeBlock";
2874
+ Blocks["HARDBREAK"] = "hardBreak";
2875
+ Blocks["HORIZONTAL_RULE"] = "horizontalRule";
2876
+ Blocks["DOT_IMAGE"] = "dotImage";
2877
+ Blocks["DOT_VIDEO"] = "dotVideo";
2878
+ Blocks["TABLE"] = "table";
2879
+ Blocks["DOT_CONTENT"] = "dotContent";
2880
+ })(Blocks || (Blocks = {}));
2881
+
2882
+ /**
2883
+ * Renders a code block component.
2884
+ *
2885
+ * @param attrs - The attributes of the code block.
2886
+ * @param children - The content of the code block.
2887
+ * @returns The rendered code block component.
2888
+ */
2889
+ const CodeBlock = ({
2890
+ attrs,
2891
+ children
2892
+ }) => {
2893
+ const language = (attrs == null ? void 0 : attrs.language) || '';
2894
+ return jsx("pre", {
2895
+ "data-language": language,
2896
+ children: jsx("code", {
2897
+ children: children
2898
+ })
2899
+ });
2900
+ };
2901
+ /**
2902
+ * Renders a blockquote component.
2903
+ *
2904
+ * @param children - The content to be rendered inside the blockquote.
2905
+ * @returns The rendered blockquote component.
2906
+ */
2907
+ const BlockQuote = ({
2908
+ children
2909
+ }) => {
2910
+ return jsx("blockquote", {
2911
+ children: children
2912
+ });
2913
+ };
2914
+
2915
+ function _objectWithoutPropertiesLoose(r, e) {
2916
+ if (null == r) return {};
2917
+ var t = {};
2918
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
2919
+ if (e.includes(n)) continue;
2920
+ t[n] = r[n];
2921
+ }
2922
+ return t;
2923
+ }
2924
+
2925
+ const _excluded = ["customRenderers"];
2926
+ /**
2927
+ * Renders the default content for an unknown content type.
2928
+ */
2929
+ const DefaultContent = () => jsx("div", {
2930
+ children: "Unknown Content Type"
2931
+ });
2932
+ /**
2933
+ * Renders a DotContent component.
2934
+ *
2935
+ * @param {DotContentProps} props - The props for the DotContent component.
2936
+ * @returns {JSX.Element} The rendered DotContent component.
2937
+ */
2938
+ const DotContent = _ref => {
2939
+ var _customRenderers$data;
2940
+ let {
2941
+ customRenderers
2942
+ } = _ref,
2943
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
2944
+ const {
2945
+ attrs
2946
+ } = props;
2947
+ const data = attrs == null ? void 0 : attrs.data;
2948
+ const Component = (_customRenderers$data = customRenderers == null ? void 0 : customRenderers[data == null ? void 0 : data.contentType]) != null ? _customRenderers$data : DefaultContent;
2949
+ if (!data) {
2950
+ console.error('DotContent: No data provided');
2951
+ }
2952
+ return jsx(Component, Object.assign({}, props));
2953
+ };
2954
+
2955
+ /**
2956
+ * Renders an image component for dotCMS.
2957
+ *
2958
+ * @param props - The props for the DotCMSImage component.
2959
+ * @returns The rendered image component.
2960
+ */
2961
+ const DotCMSImage = props => {
2962
+ const {
2963
+ data,
2964
+ src,
2965
+ alt
2966
+ } = props.attrs;
2967
+ const client = DotCmsClient.instance;
2968
+ const srcUrl = data != null && data.identifier ? `${client.dotcmsUrl}${src}` : src;
2969
+ return jsx("img", {
2970
+ alt: alt,
2971
+ src: srcUrl
2972
+ });
2973
+ };
2974
+
2975
+ /**
2976
+ * ListItem component represents a list item in a block editor.
2977
+ *
2978
+ * @param children - The content of the list item.
2979
+ * @returns The rendered list item element.
2980
+ */
2981
+ const ListItem = ({
2982
+ children
2983
+ }) => {
2984
+ return jsx("li", {
2985
+ children: children
2986
+ });
2987
+ };
2988
+ /**
2989
+ * Renders an ordered list component.
2990
+ *
2991
+ * @param children - The content to be rendered inside the ordered list.
2992
+ * @returns The ordered list component.
2993
+ */
2994
+ const OrderedList = ({
2995
+ children
2996
+ }) => {
2997
+ return jsx("ol", {
2998
+ children: children
2999
+ });
3000
+ };
3001
+ /**
3002
+ * Renders a bullet list component.
3003
+ *
3004
+ * @param children - The content of the bullet list.
3005
+ * @returns The rendered bullet list component.
3006
+ */
3007
+ const BulletList = ({
3008
+ children
3009
+ }) => {
3010
+ return jsx("ul", {
3011
+ children: children
3012
+ });
3013
+ };
3014
+
3015
+ /**
3016
+ * Renders a table component for the Block Editor.
3017
+ *
3018
+ * @param content - The content of the table.
3019
+ * @param blockEditorItem - The Block Editor item component.
3020
+ */
3021
+ const TableRenderer = ({
3022
+ content,
3023
+ blockEditorItem
3024
+ }) => {
3025
+ const BlockEditorItemComponent = blockEditorItem;
3026
+ const renderTableContent = node => {
3027
+ return jsx(BlockEditorItemComponent, {
3028
+ content: node.content
3029
+ });
3030
+ };
3031
+ return jsxs("table", {
3032
+ children: [jsx("thead", {
3033
+ children: content.slice(0, 1).map((rowNode, rowIndex) => {
3034
+ var _rowNode$content;
3035
+ return jsx("tr", {
3036
+ children: (_rowNode$content = rowNode.content) == null ? void 0 : _rowNode$content.map((cellNode, cellIndex) => {
3037
+ var _cellNode$attrs, _cellNode$attrs2;
3038
+ return jsx("th", {
3039
+ colSpan: Number(((_cellNode$attrs = cellNode.attrs) == null ? void 0 : _cellNode$attrs.colspan) || 1),
3040
+ rowSpan: Number(((_cellNode$attrs2 = cellNode.attrs) == null ? void 0 : _cellNode$attrs2.rowspan) || 1),
3041
+ children: renderTableContent(cellNode)
3042
+ }, `${cellNode.type}-${cellIndex}`);
3043
+ })
3044
+ }, `${rowNode.type}-${rowIndex}`);
3045
+ })
3046
+ }), jsx("tbody", {
3047
+ children: content.slice(1).map((rowNode, rowIndex) => {
3048
+ var _rowNode$content2;
3049
+ return jsx("tr", {
3050
+ children: (_rowNode$content2 = rowNode.content) == null ? void 0 : _rowNode$content2.map((cellNode, cellIndex) => {
3051
+ var _cellNode$attrs3, _cellNode$attrs4;
3052
+ return jsx("td", {
3053
+ colSpan: Number(((_cellNode$attrs3 = cellNode.attrs) == null ? void 0 : _cellNode$attrs3.colspan) || 1),
3054
+ rowSpan: Number(((_cellNode$attrs4 = cellNode.attrs) == null ? void 0 : _cellNode$attrs4.rowspan) || 1),
3055
+ children: renderTableContent(cellNode)
3056
+ }, `${cellNode.type}-${cellIndex}`);
3057
+ })
3058
+ }, `${rowNode.type}-${rowIndex}`);
3059
+ })
3060
+ })]
3061
+ });
3062
+ };
3063
+
3064
+ /**
3065
+ * Renders the text in bold.
3066
+ *
3067
+ * @param children - The content to be rendered in bold.
3068
+ */
3069
+ const Bold = ({
3070
+ children
3071
+ }) => jsx("strong", {
3072
+ children: children
3073
+ });
3074
+ /**
3075
+ * Renders the text in italic format.
3076
+ *
3077
+ * @param children - The content to be rendered in italic.
3078
+ */
3079
+ const Italic = ({
3080
+ children
3081
+ }) => jsx("em", {
3082
+ children: children
3083
+ });
3084
+ /**
3085
+ * Renders a strike-through text.
3086
+ *
3087
+ * @param children - The content to be rendered within the strike-through element.
3088
+ */
3089
+ const Strike = ({
3090
+ children
3091
+ }) => jsx("s", {
3092
+ children: children
3093
+ });
3094
+ /**
3095
+ * Renders an underline element for the given children.
3096
+ *
3097
+ * @param children - The content to be underlined.
3098
+ */
3099
+ const Underline = ({
3100
+ children
3101
+ }) => jsx("u", {
3102
+ children: children
3103
+ });
3104
+ /**
3105
+ * Renders a paragraph element.
3106
+ *
3107
+ * @param children - The content of the paragraph.
3108
+ * @param attrs - The style attributes for the paragraph.
3109
+ * @returns The rendered paragraph element.
3110
+ */
3111
+ const Paragraph = ({
3112
+ children,
3113
+ attrs
3114
+ }) => {
3115
+ return jsx("p", {
3116
+ style: attrs,
3117
+ children: children
3118
+ });
3119
+ };
3120
+ /**
3121
+ * Renders a link component.
3122
+ *
3123
+ * @param children - The content of the link.
3124
+ * @param attrs - The attributes to be applied to the link.
3125
+ * @returns The rendered link component.
3126
+ */
3127
+ const Link = ({
3128
+ children,
3129
+ attrs
3130
+ }) => {
3131
+ return jsx("a", Object.assign({}, attrs, {
3132
+ children: children
3133
+ }));
3134
+ };
3135
+ /**
3136
+ * Renders a heading element with the specified level.
3137
+ *
3138
+ * @param children - The content of the heading.
3139
+ * @param attrs - The attributes for the heading.
3140
+ * @returns The rendered heading element.
3141
+ */
3142
+ const Heading = ({
3143
+ children,
3144
+ attrs
3145
+ }) => {
3146
+ const level = (attrs == null ? void 0 : attrs.level) || 1;
3147
+ const Tag = `h${level}`;
3148
+ return jsx(Tag, {
3149
+ children: children
3150
+ });
3151
+ };
3152
+ /**
3153
+ * Renders the superscript text.
3154
+ *
3155
+ * @param children - The content to be rendered as superscript.
3156
+ */
3157
+ const Superscript = ({
3158
+ children
3159
+ }) => jsx("sup", {
3160
+ children: children
3161
+ });
3162
+ /**
3163
+ * Renders a subscript element.
3164
+ *
3165
+ * @param children - The content to be rendered as subscript.
3166
+ */
3167
+ const Subscript = ({
3168
+ children
3169
+ }) => jsx("sub", {
3170
+ children: children
3171
+ });
3172
+ const nodeMarks = {
3173
+ link: Link,
3174
+ bold: Bold,
3175
+ underline: Underline,
3176
+ italic: Italic,
3177
+ strike: Strike,
3178
+ superscript: Superscript,
3179
+ subscript: Subscript
3180
+ };
3181
+ /**
3182
+ * Renders a text block with optional marks.
3183
+ *
3184
+ * @param props - The props for the TextBlock component.
3185
+ * @returns The rendered text block.
3186
+ */
3187
+ const TextBlock = props => {
3188
+ const {
3189
+ marks = [],
3190
+ text
3191
+ } = props;
3192
+ const mark = marks[0] || {
3193
+ type: '',
3194
+ attrs: {}
3195
+ };
3196
+ const newProps = Object.assign({}, props, {
3197
+ marks: marks.slice(1)
3198
+ });
3199
+ const Component = nodeMarks[mark == null ? void 0 : mark.type];
3200
+ // To avoid the warning: "Warning: Invalid DOM property `class`. Did you mean `className`?"
3201
+ if (mark.attrs) {
3202
+ mark.attrs.className = mark.attrs.class;
3203
+ delete mark.attrs.class;
3204
+ }
3205
+ if (!Component) {
3206
+ return text;
3207
+ }
3208
+ return jsx(Component, {
3209
+ attrs: mark.attrs,
3210
+ children: jsx(TextBlock, Object.assign({}, newProps))
3211
+ });
3212
+ };
3213
+
3214
+ /**
3215
+ * Renders a video component for displaying videos.
3216
+ *
3217
+ * @param props - The properties for the video component.
3218
+ * @returns The rendered video component.
3219
+ */
3220
+ const DotCMSVideo = props => {
3221
+ const {
3222
+ data,
3223
+ src,
3224
+ mimeType,
3225
+ width,
3226
+ height
3227
+ } = props.attrs;
3228
+ const client = DotCmsClient.instance;
3229
+ const srcUrl = data != null && data.identifier ? `${client.dotcmsUrl}${src}` : src;
3230
+ const poster = data != null && data.thumbnail ? `${client.dotcmsUrl}${data == null ? void 0 : data.thumbnail}` : 'poster-image.jpg';
3231
+ return jsxs("video", {
3232
+ controls: true,
3233
+ preload: "metadata",
3234
+ poster: poster,
3235
+ width: width,
3236
+ height: height,
3237
+ children: [jsx("track", {
3238
+ default: true,
3239
+ kind: "captions",
3240
+ srcLang: "en"
3241
+ }), jsx("source", {
3242
+ src: srcUrl,
3243
+ type: mimeType
3244
+ }), "Your browser does not support the ", jsx("code", {
3245
+ children: "video"
3246
+ }), " element."]
3247
+ });
3248
+ };
3249
+
3250
+ /**
3251
+ * Renders a block editor item based on the provided content and custom renderers.
3252
+ *
3253
+ * @param content - The content nodes to render.
3254
+ * @param customRenderers - Optional custom renderers for specific node types.
3255
+ * @returns The rendered block editor item.
3256
+ */
3257
+ const BlockEditorBlock = ({
3258
+ content,
3259
+ customRenderers
3260
+ }) => {
3261
+ return content == null ? void 0 : content.map((node, index) => {
3262
+ const CustomRendererComponent = customRenderers == null ? void 0 : customRenderers[node.type];
3263
+ if (CustomRendererComponent) {
3264
+ return jsx(CustomRendererComponent, Object.assign({}, node, {
3265
+ content: node.content,
3266
+ children: jsx(BlockEditorBlock, {
3267
+ content: node.content,
3268
+ customRenderers: customRenderers
3269
+ })
3270
+ }), `${node.type}-${index}`);
3271
+ }
3272
+ switch (node.type) {
3273
+ case Blocks.PARAGRAPH:
3274
+ return jsx(Paragraph, Object.assign({}, node, {
3275
+ children: jsx(BlockEditorBlock, {
3276
+ content: node.content,
3277
+ customRenderers: customRenderers
3278
+ })
3279
+ }), `${node.type}-${index}`);
3280
+ case Blocks.HEADING:
3281
+ return jsx(Heading, Object.assign({}, node, {
3282
+ children: jsx(BlockEditorBlock, {
3283
+ content: node.content,
3284
+ customRenderers: customRenderers
3285
+ })
3286
+ }), `${node.type}-${index}`);
3287
+ case Blocks.TEXT:
3288
+ return jsx(TextBlock, Object.assign({}, node), `${node.type}-${index}`);
3289
+ case Blocks.BULLET_LIST:
3290
+ return jsx(BulletList, {
3291
+ children: jsx(BlockEditorBlock, {
3292
+ content: node.content,
3293
+ customRenderers: customRenderers
3294
+ })
3295
+ }, `${node.type}-${index}`);
3296
+ case Blocks.ORDERED_LIST:
3297
+ return jsx(OrderedList, {
3298
+ children: jsx(BlockEditorBlock, {
3299
+ content: node.content,
3300
+ customRenderers: customRenderers
3301
+ })
3302
+ }, `${node.type}-${index}`);
3303
+ case Blocks.LIST_ITEM:
3304
+ return jsx(ListItem, {
3305
+ children: jsx(BlockEditorBlock, {
3306
+ content: node.content,
3307
+ customRenderers: customRenderers
3308
+ })
3309
+ }, `${node.type}-${index}`);
3310
+ case Blocks.BLOCK_QUOTE:
3311
+ return jsx(BlockQuote, {
3312
+ children: jsx(BlockEditorBlock, {
3313
+ content: node.content,
3314
+ customRenderers: customRenderers
3315
+ })
3316
+ }, `${node.type}-${index}`);
3317
+ case Blocks.CODE_BLOCK:
3318
+ return jsx(CodeBlock, Object.assign({}, node, {
3319
+ children: jsx(BlockEditorBlock, {
3320
+ content: node.content,
3321
+ customRenderers: customRenderers
3322
+ })
3323
+ }), `${node.type}-${index}`);
3324
+ case Blocks.HARDBREAK:
3325
+ return jsx("br", {}, `${node.type}-${index}`);
3326
+ case Blocks.HORIZONTAL_RULE:
3327
+ return jsx("hr", {}, `${node.type}-${index}`);
3328
+ case Blocks.DOT_IMAGE:
3329
+ return jsx(DotCMSImage, Object.assign({}, node), `${node.type}-${index}`);
3330
+ case Blocks.DOT_VIDEO:
3331
+ return jsx(DotCMSVideo, Object.assign({}, node), `${node.type}-${index}`);
3332
+ case Blocks.TABLE:
3333
+ return jsx(TableRenderer, {
3334
+ content: node.content,
3335
+ blockEditorItem: BlockEditorBlock
3336
+ }, `${node.type}-${index}`);
3337
+ case Blocks.DOT_CONTENT:
3338
+ return jsx(DotContent, Object.assign({}, node, {
3339
+ customRenderers: customRenderers
3340
+ }), `${node.type}-${index}`);
3341
+ default:
3342
+ return jsxs("div", {
3343
+ children: ["Unknown Block Type ", node.type]
3344
+ }, `${node.type}-${index}`);
3345
+ }
3346
+ });
3347
+ };
3348
+
3349
+ /**
3350
+ * BlockEditorRenderer component for rendering block editor field.
3351
+ *
3352
+ * @component
3353
+ * @param {Object} props - The component props.
3354
+ * @param {Block} props.blocks - The blocks of content to render.
3355
+ * @param {CustomRenderer} [props.customRenderers] - Optional custom renderers for specific block types.
3356
+ * @param {string} [props.className] - Optional CSS class name for the container div.
3357
+ * @param {React.CSSProperties} [props.style] - Optional inline styles for the container div.
3358
+ * @param {boolean} props.editable - Flag to enable inline editing. When true, `contentlet` and `fieldName` are required. Note: Enterprise only feature.
3359
+ * @param {DotCMSContentlet} [props.contentlet] - Contentlet object for inline editing. Required when `editable` is true.
3360
+ * @param {string} [props.fieldName] - Field name for inline editing. Required when `editable` is true.
3361
+ * @returns {JSX.Element} A div containing the rendered blocks of content.
3362
+ */
3363
+ const BlockEditorRenderer = ({
3364
+ style,
3365
+ blocks,
3366
+ editable,
3367
+ fieldName,
3368
+ className,
3369
+ contentlet,
3370
+ customRenderers
3371
+ }) => {
3372
+ const ref = useRef(null);
3373
+ const [blockEditorState, setBlockEditorState] = useState({
3374
+ error: null
3375
+ });
3376
+ /**
3377
+ * Sets up inline editing functionality when the component is editable and inside the editor.
3378
+ *
3379
+ * This effect:
3380
+ * 1. Checks if inline editing should be enabled based on props and editor context
3381
+ * 2. Validates required props for inline editing (contentlet and fieldName)
3382
+ * 3. Extracts necessary data from the contentlet
3383
+ * 4. Adds a click handler to initialize inline editing with the block editor
3384
+ * 5. Cleans up event listener on unmount
3385
+ *
3386
+ * @dependency {boolean} editable - Flag to enable/disable inline editing
3387
+ * @dependency {DotCMSContentlet} contentlet - Contentlet data required for editing
3388
+ * @dependency {Block} blocks - The content blocks to edit
3389
+ * @dependency {string} fieldName - Name of the field being edited
3390
+ */
3391
+ useEffect(() => {
3392
+ if (!editable || !ref.current || !isInsideEditor()) {
3393
+ return;
3394
+ }
3395
+ // TypeScript will throw an error if contentlet or fieldName are not provided when editable is true,
3396
+ // but we need to check them again to avoid runtime errors in Pure JavaScript
3397
+ if (!contentlet || !fieldName) {
3398
+ console.error('contentlet and fieldName are required to enable inline editing');
3399
+ return;
3400
+ }
3401
+ const {
3402
+ inode,
3403
+ languageId: language,
3404
+ contentType
3405
+ } = contentlet;
3406
+ // `ContentNode` lives on `@dotcms/react` that's why we can use it in `@dotcms/client`
3407
+ // We need to move interfaces to external lib
3408
+ const content = blocks;
3409
+ const element = ref.current;
3410
+ const handleClickEvent = () => {
3411
+ initInlineEditing('BLOCK_EDITOR', {
3412
+ inode,
3413
+ content,
3414
+ language,
3415
+ fieldName,
3416
+ contentType
3417
+ });
3418
+ };
3419
+ element.addEventListener('click', handleClickEvent);
3420
+ return () => element.removeEventListener('click', handleClickEvent);
3421
+ }, [editable, contentlet, blocks, fieldName]);
3422
+ /**
3423
+ * Validates the blocks structure and updates the block editor state.
3424
+ *
3425
+ * This effect:
3426
+ * 1. Validates that blocks have the correct structure (doc type, content array, etc)
3427
+ * 2. Updates the block editor state with validation result
3428
+ * 3. Logs any validation errors to console
3429
+ *
3430
+ * @dependency {Block} blocks - The content blocks to validate
3431
+ */
3432
+ useEffect(() => {
3433
+ const validationResult = isValidBlocks(blocks);
3434
+ setBlockEditorState(validationResult);
3435
+ if (validationResult.error) {
3436
+ console.error(validationResult.error);
3437
+ }
3438
+ }, [blocks]);
3439
+ if (blockEditorState.error) {
3440
+ console.error(blockEditorState.error);
3441
+ if (isInsideEditor()) {
3442
+ return jsx("div", {
3443
+ "data-testid": "invalid-blocks-message",
3444
+ children: blockEditorState.error
3445
+ });
3446
+ }
3447
+ return null;
3448
+ }
3449
+ return jsx("div", {
3450
+ className: className,
3451
+ style: style,
3452
+ ref: ref,
3453
+ "data-testid": "dot-block-editor-container",
3454
+ children: jsx(BlockEditorBlock, {
3455
+ content: blocks == null ? void 0 : blocks.content,
3456
+ customRenderers: customRenderers
3457
+ })
3458
+ });
3459
+ };
3460
+
3461
+ export { BlockEditorRenderer, DotEditableText, DotcmsLayout, PageProvider, Row, useDotcmsPageContext };