PluginProbe
Gutenberg / 19.6.4
Gutenberg v19.6.4
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
gutenberg / build / element / index.js

index.js in Gutenberg 19.6.4, at build/element/index.js

1,929 lines 66.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /******/ "use strict";
3 /******/ var __webpack_modules__ = ({
4
5 /***/ 4140:
6 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
7
8
9
10 var m = __webpack_require__(5795);
11 if (true) {
12 exports.H = m.createRoot;
13 exports.c = m.hydrateRoot;
14 } else { var i; }
15
16
17 /***/ }),
18
19 /***/ 5795:
20 /***/ ((module) => {
21
22 module.exports = window["ReactDOM"];
23
24 /***/ })
25
26 /******/ });
27 /************************************************************************/
28 /******/ // The module cache
29 /******/ var __webpack_module_cache__ = {};
30 /******/
31 /******/ // The require function
32 /******/ function __webpack_require__(moduleId) {
33 /******/ // Check if module is in cache
34 /******/ var cachedModule = __webpack_module_cache__[moduleId];
35 /******/ if (cachedModule !== undefined) {
36 /******/ return cachedModule.exports;
37 /******/ }
38 /******/ // Create a new module (and put it into the cache)
39 /******/ var module = __webpack_module_cache__[moduleId] = {
40 /******/ // no module.id needed
41 /******/ // no module.loaded needed
42 /******/ exports: {}
43 /******/ };
44 /******/
45 /******/ // Execute the module function
46 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
47 /******/
48 /******/ // Return the exports of the module
49 /******/ return module.exports;
50 /******/ }
51 /******/
52 /************************************************************************/
53 /******/ /* webpack/runtime/define property getters */
54 /******/ (() => {
55 /******/ // define getter functions for harmony exports
56 /******/ __webpack_require__.d = (exports, definition) => {
57 /******/ for(var key in definition) {
58 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
59 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
60 /******/ }
61 /******/ }
62 /******/ };
63 /******/ })();
64 /******/
65 /******/ /* webpack/runtime/hasOwnProperty shorthand */
66 /******/ (() => {
67 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
68 /******/ })();
69 /******/
70 /******/ /* webpack/runtime/make namespace object */
71 /******/ (() => {
72 /******/ // define __esModule on exports
73 /******/ __webpack_require__.r = (exports) => {
74 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
75 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
76 /******/ }
77 /******/ Object.defineProperty(exports, '__esModule', { value: true });
78 /******/ };
79 /******/ })();
80 /******/
81 /************************************************************************/
82 var __webpack_exports__ = {};
83 // ESM COMPAT FLAG
84 __webpack_require__.r(__webpack_exports__);
85
86 // EXPORTS
87 __webpack_require__.d(__webpack_exports__, {
88 Children: () => (/* reexport */ external_React_namespaceObject.Children),
89 Component: () => (/* reexport */ external_React_namespaceObject.Component),
90 Fragment: () => (/* reexport */ external_React_namespaceObject.Fragment),
91 Platform: () => (/* reexport */ platform),
92 PureComponent: () => (/* reexport */ external_React_namespaceObject.PureComponent),
93 RawHTML: () => (/* reexport */ RawHTML),
94 StrictMode: () => (/* reexport */ external_React_namespaceObject.StrictMode),
95 Suspense: () => (/* reexport */ external_React_namespaceObject.Suspense),
96 cloneElement: () => (/* reexport */ external_React_namespaceObject.cloneElement),
97 concatChildren: () => (/* reexport */ concatChildren),
98 createContext: () => (/* reexport */ external_React_namespaceObject.createContext),
99 createElement: () => (/* reexport */ external_React_namespaceObject.createElement),
100 createInterpolateElement: () => (/* reexport */ create_interpolate_element),
101 createPortal: () => (/* reexport */ external_ReactDOM_.createPortal),
102 createRef: () => (/* reexport */ external_React_namespaceObject.createRef),
103 createRoot: () => (/* reexport */ client/* createRoot */.H),
104 findDOMNode: () => (/* reexport */ external_ReactDOM_.findDOMNode),
105 flushSync: () => (/* reexport */ external_ReactDOM_.flushSync),
106 forwardRef: () => (/* reexport */ external_React_namespaceObject.forwardRef),
107 hydrate: () => (/* reexport */ external_ReactDOM_.hydrate),
108 hydrateRoot: () => (/* reexport */ client/* hydrateRoot */.c),
109 isEmptyElement: () => (/* reexport */ isEmptyElement),
110 isValidElement: () => (/* reexport */ external_React_namespaceObject.isValidElement),
111 lazy: () => (/* reexport */ external_React_namespaceObject.lazy),
112 memo: () => (/* reexport */ external_React_namespaceObject.memo),
113 render: () => (/* reexport */ external_ReactDOM_.render),
114 renderToString: () => (/* reexport */ serialize),
115 startTransition: () => (/* reexport */ external_React_namespaceObject.startTransition),
116 switchChildrenNodeName: () => (/* reexport */ switchChildrenNodeName),
117 unmountComponentAtNode: () => (/* reexport */ external_ReactDOM_.unmountComponentAtNode),
118 useCallback: () => (/* reexport */ external_React_namespaceObject.useCallback),
119 useContext: () => (/* reexport */ external_React_namespaceObject.useContext),
120 useDebugValue: () => (/* reexport */ external_React_namespaceObject.useDebugValue),
121 useDeferredValue: () => (/* reexport */ external_React_namespaceObject.useDeferredValue),
122 useEffect: () => (/* reexport */ external_React_namespaceObject.useEffect),
123 useId: () => (/* reexport */ external_React_namespaceObject.useId),
124 useImperativeHandle: () => (/* reexport */ external_React_namespaceObject.useImperativeHandle),
125 useInsertionEffect: () => (/* reexport */ external_React_namespaceObject.useInsertionEffect),
126 useLayoutEffect: () => (/* reexport */ external_React_namespaceObject.useLayoutEffect),
127 useMemo: () => (/* reexport */ external_React_namespaceObject.useMemo),
128 useReducer: () => (/* reexport */ external_React_namespaceObject.useReducer),
129 useRef: () => (/* reexport */ external_React_namespaceObject.useRef),
130 useState: () => (/* reexport */ external_React_namespaceObject.useState),
131 useSyncExternalStore: () => (/* reexport */ external_React_namespaceObject.useSyncExternalStore),
132 useTransition: () => (/* reexport */ external_React_namespaceObject.useTransition)
133 });
134
135 ;// external "React"
136 const external_React_namespaceObject = window["React"];
137 ;// ./packages/element/build-module/create-interpolate-element.js
138 /**
139 * Internal dependencies
140 */
141
142
143 /**
144 * Object containing a React element.
145 *
146 * @typedef {import('react').ReactElement} Element
147 */
148
149 let indoc, offset, output, stack;
150
151 /**
152 * Matches tags in the localized string
153 *
154 * This is used for extracting the tag pattern groups for parsing the localized
155 * string and along with the map converting it to a react element.
156 *
157 * There are four references extracted using this tokenizer:
158 *
159 * match: Full match of the tag (i.e. <strong>, </strong>, <br/>)
160 * isClosing: The closing slash, if it exists.
161 * name: The name portion of the tag (strong, br) (if )
162 * isSelfClosed: The slash on a self closing tag, if it exists.
163 *
164 * @type {RegExp}
165 */
166 const tokenizer = /<(\/)?(\w+)\s*(\/)?>/g;
167
168 /**
169 * The stack frame tracking parse progress.
170 *
171 * @typedef Frame
172 *
173 * @property {Element} element A parent element which may still have
174 * @property {number} tokenStart Offset at which parent element first
175 * appears.
176 * @property {number} tokenLength Length of string marking start of parent
177 * element.
178 * @property {number} [prevOffset] Running offset at which parsing should
179 * continue.
180 * @property {number} [leadingTextStart] Offset at which last closing element
181 * finished, used for finding text between
182 * elements.
183 * @property {Element[]} children Children.
184 */
185
186 /**
187 * Tracks recursive-descent parse state.
188 *
189 * This is a Stack frame holding parent elements until all children have been
190 * parsed.
191 *
192 * @private
193 * @param {Element} element A parent element which may still have
194 * nested children not yet parsed.
195 * @param {number} tokenStart Offset at which parent element first
196 * appears.
197 * @param {number} tokenLength Length of string marking start of parent
198 * element.
199 * @param {number} [prevOffset] Running offset at which parsing should
200 * continue.
201 * @param {number} [leadingTextStart] Offset at which last closing element
202 * finished, used for finding text between
203 * elements.
204 *
205 * @return {Frame} The stack frame tracking parse progress.
206 */
207 function createFrame(element, tokenStart, tokenLength, prevOffset, leadingTextStart) {
208 return {
209 element,
210 tokenStart,
211 tokenLength,
212 prevOffset,
213 leadingTextStart,
214 children: []
215 };
216 }
217
218 /**
219 * This function creates an interpolated element from a passed in string with
220 * specific tags matching how the string should be converted to an element via
221 * the conversion map value.
222 *
223 * @example
224 * For example, for the given string:
225 *
226 * "This is a <span>string</span> with <a>a link</a> and a self-closing
227 * <CustomComponentB/> tag"
228 *
229 * You would have something like this as the conversionMap value:
230 *
231 * ```js
232 * {
233 * span: <span />,
234 * a: <a href={ 'https://github.com' } />,
235 * CustomComponentB: <CustomComponent />,
236 * }
237 * ```
238 *
239 * @param {string} interpolatedString The interpolation string to be parsed.
240 * @param {Record<string, Element>} conversionMap The map used to convert the string to
241 * a react element.
242 * @throws {TypeError}
243 * @return {Element} A wp element.
244 */
245 const createInterpolateElement = (interpolatedString, conversionMap) => {
246 indoc = interpolatedString;
247 offset = 0;
248 output = [];
249 stack = [];
250 tokenizer.lastIndex = 0;
251 if (!isValidConversionMap(conversionMap)) {
252 throw new TypeError('The conversionMap provided is not valid. It must be an object with values that are React Elements');
253 }
254 do {
255 // twiddle our thumbs
256 } while (proceed(conversionMap));
257 return (0,external_React_namespaceObject.createElement)(external_React_namespaceObject.Fragment, null, ...output);
258 };
259
260 /**
261 * Validate conversion map.
262 *
263 * A map is considered valid if it's an object and every value in the object
264 * is a React Element
265 *
266 * @private
267 *
268 * @param {Object} conversionMap The map being validated.
269 *
270 * @return {boolean} True means the map is valid.
271 */
272 const isValidConversionMap = conversionMap => {
273 const isObject = typeof conversionMap === 'object';
274 const values = isObject && Object.values(conversionMap);
275 return isObject && values.length && values.every(element => (0,external_React_namespaceObject.isValidElement)(element));
276 };
277
278 /**
279 * This is the iterator over the matches in the string.
280 *
281 * @private
282 *
283 * @param {Object} conversionMap The conversion map for the string.
284 *
285 * @return {boolean} true for continuing to iterate, false for finished.
286 */
287 function proceed(conversionMap) {
288 const next = nextToken();
289 const [tokenType, name, startOffset, tokenLength] = next;
290 const stackDepth = stack.length;
291 const leadingTextStart = startOffset > offset ? offset : null;
292 if (!conversionMap[name]) {
293 addText();
294 return false;
295 }
296 switch (tokenType) {
297 case 'no-more-tokens':
298 if (stackDepth !== 0) {
299 const {
300 leadingTextStart: stackLeadingText,
301 tokenStart
302 } = stack.pop();
303 output.push(indoc.substr(stackLeadingText, tokenStart));
304 }
305 addText();
306 return false;
307 case 'self-closed':
308 if (0 === stackDepth) {
309 if (null !== leadingTextStart) {
310 output.push(indoc.substr(leadingTextStart, startOffset - leadingTextStart));
311 }
312 output.push(conversionMap[name]);
313 offset = startOffset + tokenLength;
314 return true;
315 }
316
317 // Otherwise we found an inner element.
318 addChild(createFrame(conversionMap[name], startOffset, tokenLength));
319 offset = startOffset + tokenLength;
320 return true;
321 case 'opener':
322 stack.push(createFrame(conversionMap[name], startOffset, tokenLength, startOffset + tokenLength, leadingTextStart));
323 offset = startOffset + tokenLength;
324 return true;
325 case 'closer':
326 // If we're not nesting then this is easy - close the block.
327 if (1 === stackDepth) {
328 closeOuterElement(startOffset);
329 offset = startOffset + tokenLength;
330 return true;
331 }
332
333 // Otherwise we're nested and we have to close out the current
334 // block and add it as a innerBlock to the parent.
335 const stackTop = stack.pop();
336 const text = indoc.substr(stackTop.prevOffset, startOffset - stackTop.prevOffset);
337 stackTop.children.push(text);
338 stackTop.prevOffset = startOffset + tokenLength;
339 const frame = createFrame(stackTop.element, stackTop.tokenStart, stackTop.tokenLength, startOffset + tokenLength);
340 frame.children = stackTop.children;
341 addChild(frame);
342 offset = startOffset + tokenLength;
343 return true;
344 default:
345 addText();
346 return false;
347 }
348 }
349
350 /**
351 * Grabs the next token match in the string and returns it's details.
352 *
353 * @private
354 *
355 * @return {Array} An array of details for the token matched.
356 */
357 function nextToken() {
358 const matches = tokenizer.exec(indoc);
359 // We have no more tokens.
360 if (null === matches) {
361 return ['no-more-tokens'];
362 }
363 const startedAt = matches.index;
364 const [match, isClosing, name, isSelfClosed] = matches;
365 const length = match.length;
366 if (isSelfClosed) {
367 return ['self-closed', name, startedAt, length];
368 }
369 if (isClosing) {
370 return ['closer', name, startedAt, length];
371 }
372 return ['opener', name, startedAt, length];
373 }
374
375 /**
376 * Pushes text extracted from the indoc string to the output stack given the
377 * current rawLength value and offset (if rawLength is provided ) or the
378 * indoc.length and offset.
379 *
380 * @private
381 */
382 function addText() {
383 const length = indoc.length - offset;
384 if (0 === length) {
385 return;
386 }
387 output.push(indoc.substr(offset, length));
388 }
389
390 /**
391 * Pushes a child element to the associated parent element's children for the
392 * parent currently active in the stack.
393 *
394 * @private
395 *
396 * @param {Frame} frame The Frame containing the child element and it's
397 * token information.
398 */
399 function addChild(frame) {
400 const {
401 element,
402 tokenStart,
403 tokenLength,
404 prevOffset,
405 children
406 } = frame;
407 const parent = stack[stack.length - 1];
408 const text = indoc.substr(parent.prevOffset, tokenStart - parent.prevOffset);
409 if (text) {
410 parent.children.push(text);
411 }
412 parent.children.push((0,external_React_namespaceObject.cloneElement)(element, null, ...children));
413 parent.prevOffset = prevOffset ? prevOffset : tokenStart + tokenLength;
414 }
415
416 /**
417 * This is called for closing tags. It creates the element currently active in
418 * the stack.
419 *
420 * @private
421 *
422 * @param {number} endOffset Offset at which the closing tag for the element
423 * begins in the string. If this is greater than the
424 * prevOffset attached to the element, then this
425 * helps capture any remaining nested text nodes in
426 * the element.
427 */
428 function closeOuterElement(endOffset) {
429 const {
430 element,
431 leadingTextStart,
432 prevOffset,
433 tokenStart,
434 children
435 } = stack.pop();
436 const text = endOffset ? indoc.substr(prevOffset, endOffset - prevOffset) : indoc.substr(prevOffset);
437 if (text) {
438 children.push(text);
439 }
440 if (null !== leadingTextStart) {
441 output.push(indoc.substr(leadingTextStart, tokenStart - leadingTextStart));
442 }
443 output.push((0,external_React_namespaceObject.cloneElement)(element, null, ...children));
444 }
445 /* harmony default export */ const create_interpolate_element = (createInterpolateElement);
446
447 ;// ./packages/element/build-module/react.js
448 /**
449 * External dependencies
450 */
451 // eslint-disable-next-line @typescript-eslint/no-restricted-imports
452
453
454 /**
455 * Object containing a React element.
456 *
457 * @typedef {import('react').ReactElement} Element
458 */
459
460 /**
461 * Object containing a React component.
462 *
463 * @typedef {import('react').ComponentType} ComponentType
464 */
465
466 /**
467 * Object containing a React synthetic event.
468 *
469 * @typedef {import('react').SyntheticEvent} SyntheticEvent
470 */
471
472 /**
473 * Object containing a React ref object.
474 *
475 * @template T
476 * @typedef {import('react').RefObject<T>} RefObject<T>
477 */
478
479 /**
480 * Object containing a React ref callback.
481 *
482 * @template T
483 * @typedef {import('react').RefCallback<T>} RefCallback<T>
484 */
485
486 /**
487 * Object containing a React ref.
488 *
489 * @template T
490 * @typedef {import('react').Ref<T>} Ref<T>
491 */
492
493 /**
494 * Object that provides utilities for dealing with React children.
495 */
496
497
498 /**
499 * Creates a copy of an element with extended props.
500 *
501 * @param {Element} element Element
502 * @param {?Object} props Props to apply to cloned element
503 *
504 * @return {Element} Cloned element.
505 */
506
507
508 /**
509 * A base class to create WordPress Components (Refs, state and lifecycle hooks)
510 */
511
512
513 /**
514 * Creates a context object containing two components: a provider and consumer.
515 *
516 * @param {Object} defaultValue A default data stored in the context.
517 *
518 * @return {Object} Context object.
519 */
520
521
522 /**
523 * Returns a new element of given type. Type can be either a string tag name or
524 * another function which itself returns an element.
525 *
526 * @param {?(string|Function)} type Tag name or element creator
527 * @param {Object} props Element properties, either attribute
528 * set to apply to DOM node or values to
529 * pass through to element creator
530 * @param {...Element} children Descendant elements
531 *
532 * @return {Element} Element.
533 */
534
535
536 /**
537 * Returns an object tracking a reference to a rendered element via its
538 * `current` property as either a DOMElement or Element, dependent upon the
539 * type of element rendered with the ref attribute.
540 *
541 * @return {Object} Ref object.
542 */
543
544
545 /**
546 * Component enhancer used to enable passing a ref to its wrapped component.
547 * Pass a function argument which receives `props` and `ref` as its arguments,
548 * returning an element using the forwarded ref. The return value is a new
549 * component which forwards its ref.
550 *
551 * @param {Function} forwarder Function passed `props` and `ref`, expected to
552 * return an element.
553 *
554 * @return {Component} Enhanced component.
555 */
556
557
558 /**
559 * A component which renders its children without any wrapping element.
560 */
561
562
563 /**
564 * Checks if an object is a valid React Element.
565 *
566 * @param {Object} objectToCheck The object to be checked.
567 *
568 * @return {boolean} true if objectToTest is a valid React Element and false otherwise.
569 */
570
571
572 /**
573 * @see https://react.dev/reference/react/memo
574 */
575
576
577 /**
578 * Component that activates additional checks and warnings for its descendants.
579 */
580
581
582 /**
583 * @see https://react.dev/reference/react/useCallback
584 */
585
586
587 /**
588 * @see https://react.dev/reference/react/useContext
589 */
590
591
592 /**
593 * @see https://react.dev/reference/react/useDebugValue
594 */
595
596
597 /**
598 * @see https://react.dev/reference/react/useDeferredValue
599 */
600
601
602 /**
603 * @see https://react.dev/reference/react/useEffect
604 */
605
606
607 /**
608 * @see https://react.dev/reference/react/useId
609 */
610
611
612 /**
613 * @see https://react.dev/reference/react/useImperativeHandle
614 */
615
616
617 /**
618 * @see https://react.dev/reference/react/useInsertionEffect
619 */
620
621
622 /**
623 * @see https://react.dev/reference/react/useLayoutEffect
624 */
625
626
627 /**
628 * @see https://react.dev/reference/react/useMemo
629 */
630
631
632 /**
633 * @see https://react.dev/reference/react/useReducer
634 */
635
636
637 /**
638 * @see https://react.dev/reference/react/useRef
639 */
640
641
642 /**
643 * @see https://react.dev/reference/react/useState
644 */
645
646
647 /**
648 * @see https://react.dev/reference/react/useSyncExternalStore
649 */
650
651
652 /**
653 * @see https://react.dev/reference/react/useTransition
654 */
655
656
657 /**
658 * @see https://react.dev/reference/react/startTransition
659 */
660
661
662 /**
663 * @see https://react.dev/reference/react/lazy
664 */
665
666
667 /**
668 * @see https://react.dev/reference/react/Suspense
669 */
670
671
672 /**
673 * @see https://react.dev/reference/react/PureComponent
674 */
675
676
677 /**
678 * Concatenate two or more React children objects.
679 *
680 * @param {...?Object} childrenArguments Array of children arguments (array of arrays/strings/objects) to concatenate.
681 *
682 * @return {Array} The concatenated value.
683 */
684 function concatChildren(...childrenArguments) {
685 return childrenArguments.reduce((accumulator, children, i) => {
686 external_React_namespaceObject.Children.forEach(children, (child, j) => {
687 if (child && 'string' !== typeof child) {
688 child = (0,external_React_namespaceObject.cloneElement)(child, {
689 key: [i, j].join()
690 });
691 }
692 accumulator.push(child);
693 });
694 return accumulator;
695 }, []);
696 }
697
698 /**
699 * Switches the nodeName of all the elements in the children object.
700 *
701 * @param {?Object} children Children object.
702 * @param {string} nodeName Node name.
703 *
704 * @return {?Object} The updated children object.
705 */
706 function switchChildrenNodeName(children, nodeName) {
707 return children && external_React_namespaceObject.Children.map(children, (elt, index) => {
708 if (typeof elt?.valueOf() === 'string') {
709 return (0,external_React_namespaceObject.createElement)(nodeName, {
710 key: index
711 }, elt);
712 }
713 const {
714 children: childrenProp,
715 ...props
716 } = elt.props;
717 return (0,external_React_namespaceObject.createElement)(nodeName, {
718 key: index,
719 ...props
720 }, childrenProp);
721 });
722 }
723
724 // EXTERNAL MODULE: external "ReactDOM"
725 var external_ReactDOM_ = __webpack_require__(5795);
726 // EXTERNAL MODULE: ./node_modules/react-dom/client.js
727 var client = __webpack_require__(4140);
728 ;// ./packages/element/build-module/react-platform.js
729 /**
730 * External dependencies
731 */
732
733
734
735 /**
736 * Creates a portal into which a component can be rendered.
737 *
738 * @see https://github.com/facebook/react/issues/10309#issuecomment-318433235
739 *
740 * @param {import('react').ReactElement} child Any renderable child, such as an element,
741 * string, or fragment.
742 * @param {HTMLElement} container DOM node into which element should be rendered.
743 */
744
745
746 /**
747 * Finds the dom node of a React component.
748 *
749 * @param {import('react').ComponentType} component Component's instance.
750 */
751
752
753 /**
754 * Forces React to flush any updates inside the provided callback synchronously.
755 *
756 * @param {Function} callback Callback to run synchronously.
757 */
758
759
760 /**
761 * Renders a given element into the target DOM node.
762 *
763 * @deprecated since WordPress 6.2.0. Use `createRoot` instead.
764 * @see https://react.dev/reference/react-dom/render
765 */
766
767
768 /**
769 * Hydrates a given element into the target DOM node.
770 *
771 * @deprecated since WordPress 6.2.0. Use `hydrateRoot` instead.
772 * @see https://react.dev/reference/react-dom/hydrate
773 */
774
775
776 /**
777 * Creates a new React root for the target DOM node.
778 *
779 * @since 6.2.0 Introduced in WordPress core.
780 * @see https://react.dev/reference/react-dom/client/createRoot
781 */
782
783
784 /**
785 * Creates a new React root for the target DOM node and hydrates it with a pre-generated markup.
786 *
787 * @since 6.2.0 Introduced in WordPress core.
788 * @see https://react.dev/reference/react-dom/client/hydrateRoot
789 */
790
791
792 /**
793 * Removes any mounted element from the target DOM node.
794 *
795 * @deprecated since WordPress 6.2.0. Use `root.unmount()` instead.
796 * @see https://react.dev/reference/react-dom/unmountComponentAtNode
797 */
798
799
800 ;// ./packages/element/build-module/utils.js
801 /**
802 * Checks if the provided WP element is empty.
803 *
804 * @param {*} element WP element to check.
805 * @return {boolean} True when an element is considered empty.
806 */
807 const isEmptyElement = element => {
808 if (typeof element === 'number') {
809 return false;
810 }
811 if (typeof element?.valueOf() === 'string' || Array.isArray(element)) {
812 return !element.length;
813 }
814 return !element;
815 };
816
817 ;// ./packages/element/build-module/platform.js
818 /**
819 * Parts of this source were derived and modified from react-native-web,
820 * released under the MIT license.
821 *
822 * Copyright (c) 2016-present, Nicolas Gallagher.
823 * Copyright (c) 2015-present, Facebook, Inc.
824 *
825 */
826 const Platform = {
827 OS: 'web',
828 select: spec => 'web' in spec ? spec.web : spec.default,
829 isWeb: true
830 };
831 /**
832 * Component used to detect the current Platform being used.
833 * Use Platform.OS === 'web' to detect if running on web enviroment.
834 *
835 * This is the same concept as the React Native implementation.
836 *
837 * @see https://reactnative.dev/docs/platform-specific-code#platform-module
838 *
839 * Here is an example of how to use the select method:
840 * @example
841 * ```js
842 * import { Platform } from '@wordpress/element';
843 *
844 * const placeholderLabel = Platform.select( {
845 * native: __( 'Add media' ),
846 * web: __( 'Drag images, upload new ones or select files from your library.' ),
847 * } );
848 * ```
849 */
850 /* harmony default export */ const platform = (Platform);
851
852 ;// ./node_modules/is-plain-object/dist/is-plain-object.mjs
853 /*!
854 * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
855 *
856 * Copyright (c) 2014-2017, Jon Schlinkert.
857 * Released under the MIT License.
858 */
859
860 function isObject(o) {
861 return Object.prototype.toString.call(o) === '[object Object]';
862 }
863
864 function isPlainObject(o) {
865 var ctor,prot;
866
867 if (isObject(o) === false) return false;
868
869 // If has modified constructor
870 ctor = o.constructor;
871 if (ctor === undefined) return true;
872
873 // If has modified prototype
874 prot = ctor.prototype;
875 if (isObject(prot) === false) return false;
876
877 // If constructor does not have an Object-specific method
878 if (prot.hasOwnProperty('isPrototypeOf') === false) {
879 return false;
880 }
881
882 // Most likely a plain Object
883 return true;
884 }
885
886
887
888 ;// ./node_modules/tslib/tslib.es6.mjs
889 /******************************************************************************
890 Copyright (c) Microsoft Corporation.
891
892 Permission to use, copy, modify, and/or distribute this software for any
893 purpose with or without fee is hereby granted.
894
895 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
896 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
897 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
898 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
899 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
900 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
901 PERFORMANCE OF THIS SOFTWARE.
902 ***************************************************************************** */
903 /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
904
905 var extendStatics = function(d, b) {
906 extendStatics = Object.setPrototypeOf ||
907 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
908 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
909 return extendStatics(d, b);
910 };
911
912 function __extends(d, b) {
913 if (typeof b !== "function" && b !== null)
914 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
915 extendStatics(d, b);
916 function __() { this.constructor = d; }
917 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
918 }
919
920 var __assign = function() {
921 __assign = Object.assign || function __assign(t) {
922 for (var s, i = 1, n = arguments.length; i < n; i++) {
923 s = arguments[i];
924 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
925 }
926 return t;
927 }
928 return __assign.apply(this, arguments);
929 }
930
931 function __rest(s, e) {
932 var t = {};
933 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
934 t[p] = s[p];
935 if (s != null && typeof Object.getOwnPropertySymbols === "function")
936 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
937 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
938 t[p[i]] = s[p[i]];
939 }
940 return t;
941 }
942
943 function __decorate(decorators, target, key, desc) {
944 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
945 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
946 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
947 return c > 3 && r && Object.defineProperty(target, key, r), r;
948 }
949
950 function __param(paramIndex, decorator) {
951 return function (target, key) { decorator(target, key, paramIndex); }
952 }
953
954 function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
955 function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
956 var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
957 var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
958 var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
959 var _, done = false;
960 for (var i = decorators.length - 1; i >= 0; i--) {
961 var context = {};
962 for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
963 for (var p in contextIn.access) context.access[p] = contextIn.access[p];
964 context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
965 var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
966 if (kind === "accessor") {
967 if (result === void 0) continue;
968 if (result === null || typeof result !== "object") throw new TypeError("Object expected");
969 if (_ = accept(result.get)) descriptor.get = _;
970 if (_ = accept(result.set)) descriptor.set = _;
971 if (_ = accept(result.init)) initializers.unshift(_);
972 }
973 else if (_ = accept(result)) {
974 if (kind === "field") initializers.unshift(_);
975 else descriptor[key] = _;
976 }
977 }
978 if (target) Object.defineProperty(target, contextIn.name, descriptor);
979 done = true;
980 };
981
982 function __runInitializers(thisArg, initializers, value) {
983 var useValue = arguments.length > 2;
984 for (var i = 0; i < initializers.length; i++) {
985 value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
986 }
987 return useValue ? value : void 0;
988 };
989
990 function __propKey(x) {
991 return typeof x === "symbol" ? x : "".concat(x);
992 };
993
994 function __setFunctionName(f, name, prefix) {
995 if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
996 return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
997 };
998
999 function __metadata(metadataKey, metadataValue) {
1000 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
1001 }
1002
1003 function __awaiter(thisArg, _arguments, P, generator) {
1004 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1005 return new (P || (P = Promise))(function (resolve, reject) {
1006 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1007 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1008 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1009 step((generator = generator.apply(thisArg, _arguments || [])).next());
1010 });
1011 }
1012
1013 function __generator(thisArg, body) {
1014 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
1015 return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
1016 function verb(n) { return function (v) { return step([n, v]); }; }
1017 function step(op) {
1018 if (f) throw new TypeError("Generator is already executing.");
1019 while (g && (g = 0, op[0] && (_ = 0)), _) try {
1020 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
1021 if (y = 0, t) op = [op[0] & 2, t.value];
1022 switch (op[0]) {
1023 case 0: case 1: t = op; break;
1024 case 4: _.label++; return { value: op[1], done: false };
1025 case 5: _.label++; y = op[1]; op = [0]; continue;
1026 case 7: op = _.ops.pop(); _.trys.pop(); continue;
1027 default:
1028 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
1029 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
1030 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
1031 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
1032 if (t[2]) _.ops.pop();
1033 _.trys.pop(); continue;
1034 }
1035 op = body.call(thisArg, _);
1036 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
1037 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
1038 }
1039 }
1040
1041 var __createBinding = Object.create ? (function(o, m, k, k2) {
1042 if (k2 === undefined) k2 = k;
1043 var desc = Object.getOwnPropertyDescriptor(m, k);
1044 if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1045 desc = { enumerable: true, get: function() { return m[k]; } };
1046 }
1047 Object.defineProperty(o, k2, desc);
1048 }) : (function(o, m, k, k2) {
1049 if (k2 === undefined) k2 = k;
1050 o[k2] = m[k];
1051 });
1052
1053 function __exportStar(m, o) {
1054 for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
1055 }
1056
1057 function __values(o) {
1058 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
1059 if (m) return m.call(o);
1060 if (o && typeof o.length === "number") return {
1061 next: function () {
1062 if (o && i >= o.length) o = void 0;
1063 return { value: o && o[i++], done: !o };
1064 }
1065 };
1066 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
1067 }
1068
1069 function __read(o, n) {
1070 var m = typeof Symbol === "function" && o[Symbol.iterator];
1071 if (!m) return o;
1072 var i = m.call(o), r, ar = [], e;
1073 try {
1074 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
1075 }
1076 catch (error) { e = { error: error }; }
1077 finally {
1078 try {
1079 if (r && !r.done && (m = i["return"])) m.call(i);
1080 }
1081 finally { if (e) throw e.error; }
1082 }
1083 return ar;
1084 }
1085
1086 /** @deprecated */
1087 function __spread() {
1088 for (var ar = [], i = 0; i < arguments.length; i++)
1089 ar = ar.concat(__read(arguments[i]));
1090 return ar;
1091 }
1092
1093 /** @deprecated */
1094 function __spreadArrays() {
1095 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
1096 for (var r = Array(s), k = 0, i = 0; i < il; i++)
1097 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
1098 r[k] = a[j];
1099 return r;
1100 }
1101
1102 function __spreadArray(to, from, pack) {
1103 if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
1104 if (ar || !(i in from)) {
1105 if (!ar) ar = Array.prototype.slice.call(from, 0, i);
1106 ar[i] = from[i];
1107 }
1108 }
1109 return to.concat(ar || Array.prototype.slice.call(from));
1110 }
1111
1112 function __await(v) {
1113 return this instanceof __await ? (this.v = v, this) : new __await(v);
1114 }
1115
1116 function __asyncGenerator(thisArg, _arguments, generator) {
1117 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
1118 var g = generator.apply(thisArg, _arguments || []), i, q = [];
1119 return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
1120 function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
1121 function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
1122 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
1123 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
1124 function fulfill(value) { resume("next", value); }
1125 function reject(value) { resume("throw", value); }
1126 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
1127 }
1128
1129 function __asyncDelegator(o) {
1130 var i, p;
1131 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
1132 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
1133 }
1134
1135 function __asyncValues(o) {
1136 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
1137 var m = o[Symbol.asyncIterator], i;
1138 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
1139 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
1140 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
1141 }
1142
1143 function __makeTemplateObject(cooked, raw) {
1144 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
1145 return cooked;
1146 };
1147
1148 var __setModuleDefault = Object.create ? (function(o, v) {
1149 Object.defineProperty(o, "default", { enumerable: true, value: v });
1150 }) : function(o, v) {
1151 o["default"] = v;
1152 };
1153
1154 function __importStar(mod) {
1155 if (mod && mod.__esModule) return mod;
1156 var result = {};
1157 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
1158 __setModuleDefault(result, mod);
1159 return result;
1160 }
1161
1162 function __importDefault(mod) {
1163 return (mod && mod.__esModule) ? mod : { default: mod };
1164 }
1165
1166 function __classPrivateFieldGet(receiver, state, kind, f) {
1167 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
1168 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
1169 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1170 }
1171
1172 function __classPrivateFieldSet(receiver, state, value, kind, f) {
1173 if (kind === "m") throw new TypeError("Private method is not writable");
1174 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
1175 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
1176 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
1177 }
1178
1179 function __classPrivateFieldIn(state, receiver) {
1180 if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
1181 return typeof state === "function" ? receiver === state : state.has(receiver);
1182 }
1183
1184 function __addDisposableResource(env, value, async) {
1185 if (value !== null && value !== void 0) {
1186 if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
1187 var dispose, inner;
1188 if (async) {
1189 if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
1190 dispose = value[Symbol.asyncDispose];
1191 }
1192 if (dispose === void 0) {
1193 if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
1194 dispose = value[Symbol.dispose];
1195 if (async) inner = dispose;
1196 }
1197 if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
1198 if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
1199 env.stack.push({ value: value, dispose: dispose, async: async });
1200 }
1201 else if (async) {
1202 env.stack.push({ async: true });
1203 }
1204 return value;
1205 }
1206
1207 var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
1208 var e = new Error(message);
1209 return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1210 };
1211
1212 function __disposeResources(env) {
1213 function fail(e) {
1214 env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
1215 env.hasError = true;
1216 }
1217 var r, s = 0;
1218 function next() {
1219 while (r = env.stack.pop()) {
1220 try {
1221 if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
1222 if (r.dispose) {
1223 var result = r.dispose.call(r.value);
1224 if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
1225 }
1226 else s |= 1;
1227 }
1228 catch (e) {
1229 fail(e);
1230 }
1231 }
1232 if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
1233 if (env.hasError) throw env.error;
1234 }
1235 return next();
1236 }
1237
1238 function __rewriteRelativeImportExtension(path, preserveJsx) {
1239 if (typeof path === "string" && /^\.\.?\//.test(path)) {
1240 return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
1241 return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
1242 });
1243 }
1244 return path;
1245 }
1246
1247 /* harmony default export */ const tslib_es6 = ({
1248 __extends,
1249 __assign,
1250 __rest,
1251 __decorate,
1252 __param,
1253 __esDecorate,
1254 __runInitializers,
1255 __propKey,
1256 __setFunctionName,
1257 __metadata,
1258 __awaiter,
1259 __generator,
1260 __createBinding,
1261 __exportStar,
1262 __values,
1263 __read,
1264 __spread,
1265 __spreadArrays,
1266 __spreadArray,
1267 __await,
1268 __asyncGenerator,
1269 __asyncDelegator,
1270 __asyncValues,
1271 __makeTemplateObject,
1272 __importStar,
1273 __importDefault,
1274 __classPrivateFieldGet,
1275 __classPrivateFieldSet,
1276 __classPrivateFieldIn,
1277 __addDisposableResource,
1278 __disposeResources,
1279 __rewriteRelativeImportExtension,
1280 });
1281
1282 ;// ./node_modules/lower-case/dist.es2015/index.js
1283 /**
1284 * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
1285 */
1286 var SUPPORTED_LOCALE = {
1287 tr: {
1288 regexp: /\u0130|\u0049|\u0049\u0307/g,
1289 map: {
1290 İ: "\u0069",
1291 I: "\u0131",
1292 : "\u0069",
1293 },
1294 },
1295 az: {
1296 regexp: /\u0130/g,
1297 map: {
1298 İ: "\u0069",
1299 I: "\u0131",
1300 : "\u0069",
1301 },
1302 },
1303 lt: {
1304 regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,
1305 map: {
1306 I: "\u0069\u0307",
1307 J: "\u006A\u0307",
1308 Į: "\u012F\u0307",
1309 Ì: "\u0069\u0307\u0300",
1310 Í: "\u0069\u0307\u0301",
1311 Ĩ: "\u0069\u0307\u0303",
1312 },
1313 },
1314 };
1315 /**
1316 * Localized lower case.
1317 */
1318 function localeLowerCase(str, locale) {
1319 var lang = SUPPORTED_LOCALE[locale.toLowerCase()];
1320 if (lang)
1321 return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; }));
1322 return lowerCase(str);
1323 }
1324 /**
1325 * Lower case as a function.
1326 */
1327 function lowerCase(str) {
1328 return str.toLowerCase();
1329 }
1330
1331 ;// ./node_modules/no-case/dist.es2015/index.js
1332
1333 // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
1334 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
1335 // Remove all non-word characters.
1336 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
1337 /**
1338 * Normalize the string into something other libraries can manipulate easier.
1339 */
1340 function noCase(input, options) {
1341 if (options === void 0) { options = {}; }
1342 var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
1343 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
1344 var start = 0;
1345 var end = result.length;
1346 // Trim the delimiter from around the output string.
1347 while (result.charAt(start) === "\0")
1348 start++;
1349 while (result.charAt(end - 1) === "\0")
1350 end--;
1351 // Transform each token independently.
1352 return result.slice(start, end).split("\0").map(transform).join(delimiter);
1353 }
1354 /**
1355 * Replace `re` in the input string with the replacement value.
1356 */
1357 function replace(input, re, value) {
1358 if (re instanceof RegExp)
1359 return input.replace(re, value);
1360 return re.reduce(function (input, re) { return input.replace(re, value); }, input);
1361 }
1362
1363 ;// ./node_modules/dot-case/dist.es2015/index.js
1364
1365
1366 function dotCase(input, options) {
1367 if (options === void 0) { options = {}; }
1368 return noCase(input, __assign({ delimiter: "." }, options));
1369 }
1370
1371 ;// ./node_modules/param-case/dist.es2015/index.js
1372
1373
1374 function paramCase(input, options) {
1375 if (options === void 0) { options = {}; }
1376 return dotCase(input, __assign({ delimiter: "-" }, options));
1377 }
1378
1379 ;// external ["wp","escapeHtml"]
1380 const external_wp_escapeHtml_namespaceObject = window["wp"]["escapeHtml"];
1381 ;// ./packages/element/build-module/raw-html.js
1382 /**
1383 * Internal dependencies
1384 */
1385
1386
1387 /** @typedef {{children: string} & import('react').ComponentPropsWithoutRef<'div'>} RawHTMLProps */
1388
1389 /**
1390 * Component used as equivalent of Fragment with unescaped HTML, in cases where
1391 * it is desirable to render dangerous HTML without needing a wrapper element.
1392 * To preserve additional props, a `div` wrapper _will_ be created if any props
1393 * aside from `children` are passed.
1394 *
1395 * @param {RawHTMLProps} props Children should be a string of HTML or an array
1396 * of strings. Other props will be passed through
1397 * to the div wrapper.
1398 *
1399 * @return {JSX.Element} Dangerously-rendering component.
1400 */
1401 function RawHTML({
1402 children,
1403 ...props
1404 }) {
1405 let rawHtml = '';
1406
1407 // Cast children as an array, and concatenate each element if it is a string.
1408 external_React_namespaceObject.Children.toArray(children).forEach(child => {
1409 if (typeof child === 'string' && child.trim() !== '') {
1410 rawHtml += child;
1411 }
1412 });
1413
1414 // The `div` wrapper will be stripped by the `renderElement` serializer in
1415 // `./serialize.js` unless there are non-children props present.
1416 return (0,external_React_namespaceObject.createElement)('div', {
1417 dangerouslySetInnerHTML: {
1418 __html: rawHtml
1419 },
1420 ...props
1421 });
1422 }
1423
1424 ;// ./packages/element/build-module/serialize.js
1425 /* wp:polyfill */
1426 /**
1427 * Parts of this source were derived and modified from fast-react-render,
1428 * released under the MIT license.
1429 *
1430 * https://github.com/alt-j/fast-react-render
1431 *
1432 * Copyright (c) 2016 Andrey Morozov
1433 *
1434 * Permission is hereby granted, free of charge, to any person obtaining a copy
1435 * of this software and associated documentation files (the "Software"), to deal
1436 * in the Software without restriction, including without limitation the rights
1437 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1438 * copies of the Software, and to permit persons to whom the Software is
1439 * furnished to do so, subject to the following conditions:
1440 *
1441 * The above copyright notice and this permission notice shall be included in
1442 * all copies or substantial portions of the Software.
1443 *
1444 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1445 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1446 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1447 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1448 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1449 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1450 * THE SOFTWARE.
1451 */
1452
1453 /**
1454 * External dependencies
1455 */
1456
1457
1458
1459 /**
1460 * WordPress dependencies
1461 */
1462
1463
1464 /**
1465 * Internal dependencies
1466 */
1467
1468
1469
1470 /** @typedef {import('react').ReactElement} ReactElement */
1471
1472 const {
1473 Provider,
1474 Consumer
1475 } = (0,external_React_namespaceObject.createContext)(undefined);
1476 const ForwardRef = (0,external_React_namespaceObject.forwardRef)(() => {
1477 return null;
1478 });
1479
1480 /**
1481 * Valid attribute types.
1482 *
1483 * @type {Set<string>}
1484 */
1485 const ATTRIBUTES_TYPES = new Set(['string', 'boolean', 'number']);
1486
1487 /**
1488 * Element tags which can be self-closing.
1489 *
1490 * @type {Set<string>}
1491 */
1492 const SELF_CLOSING_TAGS = new Set(['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']);
1493
1494 /**
1495 * Boolean attributes are attributes whose presence as being assigned is
1496 * meaningful, even if only empty.
1497 *
1498 * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes
1499 * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3
1500 *
1501 * Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ]
1502 * .filter( ( tr ) => tr.lastChild.textContent.indexOf( 'Boolean attribute' ) !== -1 )
1503 * .reduce( ( result, tr ) => Object.assign( result, {
1504 * [ tr.firstChild.textContent.trim() ]: true
1505 * } ), {} ) ).sort();
1506 *
1507 * @type {Set<string>}
1508 */
1509 const BOOLEAN_ATTRIBUTES = new Set(['allowfullscreen', 'allowpaymentrequest', 'allowusermedia', 'async', 'autofocus', 'autoplay', 'checked', 'controls', 'default', 'defer', 'disabled', 'download', 'formnovalidate', 'hidden', 'ismap', 'itemscope', 'loop', 'multiple', 'muted', 'nomodule', 'novalidate', 'open', 'playsinline', 'readonly', 'required', 'reversed', 'selected', 'typemustmatch']);
1510
1511 /**
1512 * Enumerated attributes are attributes which must be of a specific value form.
1513 * Like boolean attributes, these are meaningful if specified, even if not of a
1514 * valid enumerated value.
1515 *
1516 * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attribute
1517 * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3
1518 *
1519 * Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ]
1520 * .filter( ( tr ) => /^("(.+?)";?\s*)+/.test( tr.lastChild.textContent.trim() ) )
1521 * .reduce( ( result, tr ) => Object.assign( result, {
1522 * [ tr.firstChild.textContent.trim() ]: true
1523 * } ), {} ) ).sort();
1524 *
1525 * Some notable omissions:
1526 *
1527 * - `alt`: https://blog.whatwg.org/omit-alt
1528 *
1529 * @type {Set<string>}
1530 */
1531 const ENUMERATED_ATTRIBUTES = new Set(['autocapitalize', 'autocomplete', 'charset', 'contenteditable', 'crossorigin', 'decoding', 'dir', 'draggable', 'enctype', 'formenctype', 'formmethod', 'http-equiv', 'inputmode', 'kind', 'method', 'preload', 'scope', 'shape', 'spellcheck', 'translate', 'type', 'wrap']);
1532
1533 /**
1534 * Set of CSS style properties which support assignment of unitless numbers.
1535 * Used in rendering of style properties, where `px` unit is assumed unless
1536 * property is included in this set or value is zero.
1537 *
1538 * Generated via:
1539 *
1540 * Object.entries( document.createElement( 'div' ).style )
1541 * .filter( ( [ key ] ) => (
1542 * ! /^(webkit|ms|moz)/.test( key ) &&
1543 * ( e.style[ key ] = 10 ) &&
1544 * e.style[ key ] === '10'
1545 * ) )
1546 * .map( ( [ key ] ) => key )
1547 * .sort();
1548 *
1549 * @type {Set<string>}
1550 */
1551 const CSS_PROPERTIES_SUPPORTS_UNITLESS = new Set(['animation', 'animationIterationCount', 'baselineShift', 'borderImageOutset', 'borderImageSlice', 'borderImageWidth', 'columnCount', 'cx', 'cy', 'fillOpacity', 'flexGrow', 'flexShrink', 'floodOpacity', 'fontWeight', 'gridColumnEnd', 'gridColumnStart', 'gridRowEnd', 'gridRowStart', 'lineHeight', 'opacity', 'order', 'orphans', 'r', 'rx', 'ry', 'shapeImageThreshold', 'stopOpacity', 'strokeDasharray', 'strokeDashoffset', 'strokeMiterlimit', 'strokeOpacity', 'strokeWidth', 'tabSize', 'widows', 'x', 'y', 'zIndex', 'zoom']);
1552
1553 /**
1554 * Returns true if the specified string is prefixed by one of an array of
1555 * possible prefixes.
1556 *
1557 * @param {string} string String to check.
1558 * @param {string[]} prefixes Possible prefixes.
1559 *
1560 * @return {boolean} Whether string has prefix.
1561 */
1562 function hasPrefix(string, prefixes) {
1563 return prefixes.some(prefix => string.indexOf(prefix) === 0);
1564 }
1565
1566 /**
1567 * Returns true if the given prop name should be ignored in attributes
1568 * serialization, or false otherwise.
1569 *
1570 * @param {string} attribute Attribute to check.
1571 *
1572 * @return {boolean} Whether attribute should be ignored.
1573 */
1574 function isInternalAttribute(attribute) {
1575 return 'key' === attribute || 'children' === attribute;
1576 }
1577
1578 /**
1579 * Returns the normal form of the element's attribute value for HTML.
1580 *
1581 * @param {string} attribute Attribute name.
1582 * @param {*} value Non-normalized attribute value.
1583 *
1584 * @return {*} Normalized attribute value.
1585 */
1586 function getNormalAttributeValue(attribute, value) {
1587 switch (attribute) {
1588 case 'style':
1589 return renderStyle(value);
1590 }
1591 return value;
1592 }
1593 /**
1594 * This is a map of all SVG attributes that have dashes. Map(lower case prop => dashed lower case attribute).
1595 * We need this to render e.g strokeWidth as stroke-width.
1596 *
1597 * List from: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute.
1598 */
1599 const SVG_ATTRIBUTE_WITH_DASHES_LIST = ['accentHeight', 'alignmentBaseline', 'arabicForm', 'baselineShift', 'capHeight', 'clipPath', 'clipRule', 'colorInterpolation', 'colorInterpolationFilters', 'colorProfile', 'colorRendering', 'dominantBaseline', 'enableBackground', 'fillOpacity', 'fillRule', 'floodColor', 'floodOpacity', 'fontFamily', 'fontSize', 'fontSizeAdjust', 'fontStretch', 'fontStyle', 'fontVariant', 'fontWeight', 'glyphName', 'glyphOrientationHorizontal', 'glyphOrientationVertical', 'horizAdvX', 'horizOriginX', 'imageRendering', 'letterSpacing', 'lightingColor', 'markerEnd', 'markerMid', 'markerStart', 'overlinePosition', 'overlineThickness', 'paintOrder', 'panose1', 'pointerEvents', 'renderingIntent', 'shapeRendering', 'stopColor', 'stopOpacity', 'strikethroughPosition', 'strikethroughThickness', 'strokeDasharray', 'strokeDashoffset', 'strokeLinecap', 'strokeLinejoin', 'strokeMiterlimit', 'strokeOpacity', 'strokeWidth', 'textAnchor', 'textDecoration', 'textRendering', 'underlinePosition', 'underlineThickness', 'unicodeBidi', 'unicodeRange', 'unitsPerEm', 'vAlphabetic', 'vHanging', 'vIdeographic', 'vMathematical', 'vectorEffect', 'vertAdvY', 'vertOriginX', 'vertOriginY', 'wordSpacing', 'writingMode', 'xmlnsXlink', 'xHeight'].reduce((map, attribute) => {
1600 // The keys are lower-cased for more robust lookup.
1601 map[attribute.toLowerCase()] = attribute;
1602 return map;
1603 }, {});
1604
1605 /**
1606 * This is a map of all case-sensitive SVG attributes. Map(lowercase key => proper case attribute).
1607 * The keys are lower-cased for more robust lookup.
1608 * Note that this list only contains attributes that contain at least one capital letter.
1609 * Lowercase attributes don't need mapping, since we lowercase all attributes by default.
1610 */
1611 const CASE_SENSITIVE_SVG_ATTRIBUTES = ['allowReorder', 'attributeName', 'attributeType', 'autoReverse', 'baseFrequency', 'baseProfile', 'calcMode', 'clipPathUnits', 'contentScriptType', 'contentStyleType', 'diffuseConstant', 'edgeMode', 'externalResourcesRequired', 'filterRes', 'filterUnits', 'glyphRef', 'gradientTransform', 'gradientUnits', 'kernelMatrix', 'kernelUnitLength', 'keyPoints', 'keySplines', 'keyTimes', 'lengthAdjust', 'limitingConeAngle', 'markerHeight', 'markerUnits', 'markerWidth', 'maskContentUnits', 'maskUnits', 'numOctaves', 'pathLength', 'patternContentUnits', 'patternTransform', 'patternUnits', 'pointsAtX', 'pointsAtY', 'pointsAtZ', 'preserveAlpha', 'preserveAspectRatio', 'primitiveUnits', 'refX', 'refY', 'repeatCount', 'repeatDur', 'requiredExtensions', 'requiredFeatures', 'specularConstant', 'specularExponent', 'spreadMethod', 'startOffset', 'stdDeviation', 'stitchTiles', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'surfaceScale', 'systemLanguage', 'tableValues', 'targetX', 'targetY', 'textLength', 'viewBox', 'viewTarget', 'xChannelSelector', 'yChannelSelector'].reduce((map, attribute) => {
1612 // The keys are lower-cased for more robust lookup.
1613 map[attribute.toLowerCase()] = attribute;
1614 return map;
1615 }, {});
1616
1617 /**
1618 * This is a map of all SVG attributes that have colons.
1619 * Keys are lower-cased and stripped of their colons for more robust lookup.
1620 */
1621 const SVG_ATTRIBUTES_WITH_COLONS = ['xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space', 'xmlns:xlink'].reduce((map, attribute) => {
1622 map[attribute.replace(':', '').toLowerCase()] = attribute;
1623 return map;
1624 }, {});
1625
1626 /**
1627 * Returns the normal form of the element's attribute name for HTML.
1628 *
1629 * @param {string} attribute Non-normalized attribute name.
1630 *
1631 * @return {string} Normalized attribute name.
1632 */
1633 function getNormalAttributeName(attribute) {
1634 switch (attribute) {
1635 case 'htmlFor':
1636 return 'for';
1637 case 'className':
1638 return 'class';
1639 }
1640 const attributeLowerCase = attribute.toLowerCase();
1641 if (CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase]) {
1642 return CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase];
1643 } else if (SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]) {
1644 return paramCase(SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]);
1645 } else if (SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase]) {
1646 return SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase];
1647 }
1648 return attributeLowerCase;
1649 }
1650
1651 /**
1652 * Returns the normal form of the style property name for HTML.
1653 *
1654 * - Converts property names to kebab-case, e.g. 'backgroundColor' → 'background-color'
1655 * - Leaves custom attributes alone, e.g. '--myBackgroundColor' → '--myBackgroundColor'
1656 * - Converts vendor-prefixed property names to -kebab-case, e.g. 'MozTransform' → '-moz-transform'
1657 *
1658 * @param {string} property Property name.
1659 *
1660 * @return {string} Normalized property name.
1661 */
1662 function getNormalStylePropertyName(property) {
1663 if (property.startsWith('--')) {
1664 return property;
1665 }
1666 if (hasPrefix(property, ['ms', 'O', 'Moz', 'Webkit'])) {
1667 return '-' + paramCase(property);
1668 }
1669 return paramCase(property);
1670 }
1671
1672 /**
1673 * Returns the normal form of the style property value for HTML. Appends a
1674 * default pixel unit if numeric, not a unitless property, and not zero.
1675 *
1676 * @param {string} property Property name.
1677 * @param {*} value Non-normalized property value.
1678 *
1679 * @return {*} Normalized property value.
1680 */
1681 function getNormalStylePropertyValue(property, value) {
1682 if (typeof value === 'number' && 0 !== value && !CSS_PROPERTIES_SUPPORTS_UNITLESS.has(property)) {
1683 return value + 'px';
1684 }
1685 return value;
1686 }
1687
1688 /**
1689 * Serializes a React element to string.
1690 *
1691 * @param {import('react').ReactNode} element Element to serialize.
1692 * @param {Object} [context] Context object.
1693 * @param {Object} [legacyContext] Legacy context object.
1694 *
1695 * @return {string} Serialized element.
1696 */
1697 function renderElement(element, context, legacyContext = {}) {
1698 if (null === element || undefined === element || false === element) {
1699 return '';
1700 }
1701 if (Array.isArray(element)) {
1702 return renderChildren(element, context, legacyContext);
1703 }
1704 switch (typeof element) {
1705 case 'string':
1706 return (0,external_wp_escapeHtml_namespaceObject.escapeHTML)(element);
1707 case 'number':
1708 return element.toString();
1709 }
1710 const {
1711 type,
1712 props
1713 } = /** @type {{type?: any, props?: any}} */
1714 element;
1715 switch (type) {
1716 case external_React_namespaceObject.StrictMode:
1717 case external_React_namespaceObject.Fragment:
1718 return renderChildren(props.children, context, legacyContext);
1719 case RawHTML:
1720 const {
1721 children,
1722 ...wrapperProps
1723 } = props;
1724 return renderNativeComponent(!Object.keys(wrapperProps).length ? null : 'div', {
1725 ...wrapperProps,
1726 dangerouslySetInnerHTML: {
1727 __html: children
1728 }
1729 }, context, legacyContext);
1730 }
1731 switch (typeof type) {
1732 case 'string':
1733 return renderNativeComponent(type, props, context, legacyContext);
1734 case 'function':
1735 if (type.prototype && typeof type.prototype.render === 'function') {
1736 return renderComponent(type, props, context, legacyContext);
1737 }
1738 return renderElement(type(props, legacyContext), context, legacyContext);
1739 }
1740 switch (type && type.$$typeof) {
1741 case Provider.$$typeof:
1742 return renderChildren(props.children, props.value, legacyContext);
1743 case Consumer.$$typeof:
1744 return renderElement(props.children(context || type._currentValue), context, legacyContext);
1745 case ForwardRef.$$typeof:
1746 return renderElement(type.render(props), context, legacyContext);
1747 }
1748 return '';
1749 }
1750
1751 /**
1752 * Serializes a native component type to string.
1753 *
1754 * @param {?string} type Native component type to serialize, or null if
1755 * rendering as fragment of children content.
1756 * @param {Object} props Props object.
1757 * @param {Object} [context] Context object.
1758 * @param {Object} [legacyContext] Legacy context object.
1759 *
1760 * @return {string} Serialized element.
1761 */
1762 function renderNativeComponent(type, props, context, legacyContext = {}) {
1763 let content = '';
1764 if (type === 'textarea' && props.hasOwnProperty('value')) {
1765 // Textarea children can be assigned as value prop. If it is, render in
1766 // place of children. Ensure to omit so it is not assigned as attribute
1767 // as well.
1768 content = renderChildren(props.value, context, legacyContext);
1769 const {
1770 value,
1771 ...restProps
1772 } = props;
1773 props = restProps;
1774 } else if (props.dangerouslySetInnerHTML && typeof props.dangerouslySetInnerHTML.__html === 'string') {
1775 // Dangerous content is left unescaped.
1776 content = props.dangerouslySetInnerHTML.__html;
1777 } else if (typeof props.children !== 'undefined') {
1778 content = renderChildren(props.children, context, legacyContext);
1779 }
1780 if (!type) {
1781 return content;
1782 }
1783 const attributes = renderAttributes(props);
1784 if (SELF_CLOSING_TAGS.has(type)) {
1785 return '<' + type + attributes + '/>';
1786 }
1787 return '<' + type + attributes + '>' + content + '</' + type + '>';
1788 }
1789
1790 /** @typedef {import('react').ComponentType} ComponentType */
1791
1792 /**
1793 * Serializes a non-native component type to string.
1794 *
1795 * @param {ComponentType} Component Component type to serialize.
1796 * @param {Object} props Props object.
1797 * @param {Object} [context] Context object.
1798 * @param {Object} [legacyContext] Legacy context object.
1799 *
1800 * @return {string} Serialized element
1801 */
1802 function renderComponent(Component, props, context, legacyContext = {}) {
1803 const instance = new (/** @type {import('react').ComponentClass} */
1804 Component)(props, legacyContext);
1805 if (typeof
1806 // Ignore reason: Current prettier reformats parens and mangles type assertion
1807 // prettier-ignore
1808 /** @type {{getChildContext?: () => unknown}} */
1809 instance.getChildContext === 'function') {
1810 Object.assign(legacyContext, /** @type {{getChildContext?: () => unknown}} */instance.getChildContext());
1811 }
1812 const html = renderElement(instance.render(), context, legacyContext);
1813 return html;
1814 }
1815
1816 /**
1817 * Serializes an array of children to string.
1818 *
1819 * @param {import('react').ReactNodeArray} children Children to serialize.
1820 * @param {Object} [context] Context object.
1821 * @param {Object} [legacyContext] Legacy context object.
1822 *
1823 * @return {string} Serialized children.
1824 */
1825 function renderChildren(children, context, legacyContext = {}) {
1826 let result = '';
1827 children = Array.isArray(children) ? children : [children];
1828 for (let i = 0; i < children.length; i++) {
1829 const child = children[i];
1830 result += renderElement(child, context, legacyContext);
1831 }
1832 return result;
1833 }
1834
1835 /**
1836 * Renders a props object as a string of HTML attributes.
1837 *
1838 * @param {Object} props Props object.
1839 *
1840 * @return {string} Attributes string.
1841 */
1842 function renderAttributes(props) {
1843 let result = '';
1844 for (const key in props) {
1845 const attribute = getNormalAttributeName(key);
1846 if (!(0,external_wp_escapeHtml_namespaceObject.isValidAttributeName)(attribute)) {
1847 continue;
1848 }
1849 let value = getNormalAttributeValue(key, props[key]);
1850
1851 // If value is not of serializable type, skip.
1852 if (!ATTRIBUTES_TYPES.has(typeof value)) {
1853 continue;
1854 }
1855
1856 // Don't render internal attribute names.
1857 if (isInternalAttribute(key)) {
1858 continue;
1859 }
1860 const isBooleanAttribute = BOOLEAN_ATTRIBUTES.has(attribute);
1861
1862 // Boolean attribute should be omitted outright if its value is false.
1863 if (isBooleanAttribute && value === false) {
1864 continue;
1865 }
1866 const isMeaningfulAttribute = isBooleanAttribute || hasPrefix(key, ['data-', 'aria-']) || ENUMERATED_ATTRIBUTES.has(attribute);
1867
1868 // Only write boolean value as attribute if meaningful.
1869 if (typeof value === 'boolean' && !isMeaningfulAttribute) {
1870 continue;
1871 }
1872 result += ' ' + attribute;
1873
1874 // Boolean attributes should write attribute name, but without value.
1875 // Mere presence of attribute name is effective truthiness.
1876 if (isBooleanAttribute) {
1877 continue;
1878 }
1879 if (typeof value === 'string') {
1880 value = (0,external_wp_escapeHtml_namespaceObject.escapeAttribute)(value);
1881 }
1882 result += '="' + value + '"';
1883 }
1884 return result;
1885 }
1886
1887 /**
1888 * Renders a style object as a string attribute value.
1889 *
1890 * @param {Object} style Style object.
1891 *
1892 * @return {string} Style attribute value.
1893 */
1894 function renderStyle(style) {
1895 // Only generate from object, e.g. tolerate string value.
1896 if (!isPlainObject(style)) {
1897 return style;
1898 }
1899 let result;
1900 for (const property in style) {
1901 const value = style[property];
1902 if (null === value || undefined === value) {
1903 continue;
1904 }
1905 if (result) {
1906 result += ';';
1907 } else {
1908 result = '';
1909 }
1910 const normalName = getNormalStylePropertyName(property);
1911 const normalValue = getNormalStylePropertyValue(property, value);
1912 result += normalName + ':' + normalValue;
1913 }
1914 return result;
1915 }
1916 /* harmony default export */ const serialize = (renderElement);
1917
1918 ;// ./packages/element/build-module/index.js
1919
1920
1921
1922
1923
1924
1925
1926
1927 (window.wp = window.wp || {}).element = __webpack_exports__;
1928 /******/ })()
1929 ;