PluginProbe
Gutenberg / 23.8.0
Gutenberg v23.8.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 7.4.0 All 402 releases
gutenberg / build / scripts / element / index.js

index.js in Gutenberg 23.8.0, at build/scripts/element/index.js

966 lines 27.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function() {
2 "use strict";
3 var wp;
4 (wp ||= {}).element = (() => {
5 var __create = Object.create;
6 var __defProp = Object.defineProperty;
7 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8 var __getOwnPropNames = Object.getOwnPropertyNames;
9 var __getProtoOf = Object.getPrototypeOf;
10 var __hasOwnProp = Object.prototype.hasOwnProperty;
11 var __commonJS = (cb, mod) => function __require() {
12 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
13 };
14 var __export = (target, all) => {
15 for (var name in all)
16 __defProp(target, name, { get: all[name], enumerable: true });
17 };
18 var __copyProps = (to, from, except, desc) => {
19 if (from && typeof from === "object" || typeof from === "function") {
20 for (let key of __getOwnPropNames(from))
21 if (!__hasOwnProp.call(to, key) && key !== except)
22 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23 }
24 return to;
25 };
26 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27 // If the importer is in node compatibility mode or this is not an ESM
28 // file that has been converted to a CommonJS file using a Babel-
29 // compatible transform (i.e. "__esModule" has not been set), then set
30 // "default" to the CommonJS "module.exports" for node compatibility.
31 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32 mod
33 ));
34 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
36 // vendor-external:react
37 var require_react = __commonJS({
38 "vendor-external:react"(exports, module) {
39 module.exports = window.React;
40 }
41 });
42
43 // vendor-external:react-dom
44 var require_react_dom = __commonJS({
45 "vendor-external:react-dom"(exports, module) {
46 module.exports = window.ReactDOM;
47 }
48 });
49
50 // vendor-external:react-dom/client
51 var require_client = __commonJS({
52 "vendor-external:react-dom/client"(exports, module) {
53 module.exports = window.ReactDOM;
54 }
55 });
56
57 // package-external:@wordpress/escape-html
58 var require_escape_html = __commonJS({
59 "package-external:@wordpress/escape-html"(exports, module) {
60 module.exports = window.wp.escapeHtml;
61 }
62 });
63
64 // packages/element/build-module/index.mjs
65 var index_exports = {};
66 __export(index_exports, {
67 Children: () => import_react.Children,
68 Component: () => import_react.Component,
69 Fragment: () => import_react.Fragment,
70 Platform: () => platform_default,
71 PureComponent: () => import_react.PureComponent,
72 RawHTML: () => RawHTML,
73 StrictMode: () => import_react.StrictMode,
74 Suspense: () => import_react.Suspense,
75 cloneElement: () => import_react.cloneElement,
76 concatChildren: () => concatChildren,
77 createContext: () => import_react.createContext,
78 createElement: () => import_react.createElement,
79 createInterpolateElement: () => create_interpolate_element_default,
80 createPortal: () => createPortal,
81 createRef: () => import_react.createRef,
82 createRoot: () => import_client.createRoot,
83 findDOMNode: () => findDOMNode,
84 flushSync: () => flushSync,
85 forwardRef: () => import_react.forwardRef,
86 hydrate: () => hydrate,
87 hydrateRoot: () => import_client.hydrateRoot,
88 isEmptyElement: () => isEmptyElement,
89 isValidElement: () => import_react.isValidElement,
90 lazy: () => import_react.lazy,
91 memo: () => import_react.memo,
92 render: () => render,
93 renderToString: () => serialize_default,
94 startTransition: () => import_react.startTransition,
95 switchChildrenNodeName: () => switchChildrenNodeName,
96 unmountComponentAtNode: () => unmountComponentAtNode,
97 useCallback: () => import_react.useCallback,
98 useContext: () => import_react.useContext,
99 useDebugValue: () => import_react.useDebugValue,
100 useDeferredValue: () => import_react.useDeferredValue,
101 useEffect: () => import_react.useEffect,
102 useId: () => import_react.useId,
103 useImperativeHandle: () => import_react.useImperativeHandle,
104 useInsertionEffect: () => import_react.useInsertionEffect,
105 useLayoutEffect: () => import_react.useLayoutEffect,
106 useMemo: () => import_react.useMemo,
107 useReducer: () => import_react.useReducer,
108 useRef: () => import_react.useRef,
109 useState: () => import_react.useState,
110 useSyncExternalStore: () => import_react.useSyncExternalStore,
111 useTransition: () => import_react.useTransition
112 });
113
114 // packages/element/build-module/react.mjs
115 var import_react = __toESM(require_react(), 1);
116 function concatChildren(...childrenArguments) {
117 return childrenArguments.reduce(
118 (accumulator, children, i) => {
119 import_react.Children.forEach(children, (child, j) => {
120 if ((0, import_react.isValidElement)(child) && typeof child !== "string") {
121 child = (0, import_react.cloneElement)(child, {
122 key: [i, j].join()
123 });
124 }
125 accumulator.push(child);
126 });
127 return accumulator;
128 },
129 []
130 );
131 }
132 function switchChildrenNodeName(children, nodeName) {
133 return children && import_react.Children.map(children, (elt, index) => {
134 if (typeof elt?.valueOf() === "string") {
135 return (0, import_react.createElement)(nodeName, { key: index }, elt);
136 }
137 if (!(0, import_react.isValidElement)(elt)) {
138 return elt;
139 }
140 const { children: childrenProp, ...props } = elt.props;
141 return (0, import_react.createElement)(
142 nodeName,
143 { key: index, ...props },
144 childrenProp
145 );
146 });
147 }
148
149 // packages/element/build-module/create-interpolate-element.mjs
150 var indoc;
151 var offset;
152 var output;
153 var stack;
154 var tokenizer = /<(\/)?(\w+)\s*(\/)?>/g;
155 function createFrame(element, tokenStart, tokenLength, prevOffset, leadingTextStart) {
156 return {
157 element,
158 tokenStart,
159 tokenLength,
160 prevOffset,
161 leadingTextStart,
162 children: []
163 };
164 }
165 function createInterpolateElement(interpolatedString, conversionMap) {
166 indoc = interpolatedString;
167 offset = 0;
168 output = [];
169 stack = [];
170 tokenizer.lastIndex = 0;
171 if (!isValidConversionMap(conversionMap)) {
172 throw new TypeError(
173 "The conversionMap provided is not valid. It must be an object with values that are React Elements"
174 );
175 }
176 do {
177 } while (proceed(conversionMap));
178 return (0, import_react.createElement)(import_react.Fragment, null, ...output);
179 }
180 var isValidConversionMap = (conversionMap) => {
181 const isObject2 = typeof conversionMap === "object" && conversionMap !== null;
182 const values = isObject2 && Object.values(conversionMap);
183 return isObject2 && values.length > 0 && values.every((element) => (0, import_react.isValidElement)(element));
184 };
185 function proceed(conversionMap) {
186 const next = nextToken();
187 const [tokenType, name, startOffset, tokenLength] = next;
188 const stackDepth = stack.length;
189 const leadingTextStart = startOffset > offset ? offset : null;
190 if (name && !conversionMap[name]) {
191 addText();
192 return false;
193 }
194 switch (tokenType) {
195 case "no-more-tokens":
196 if (stackDepth !== 0) {
197 const { leadingTextStart: stackLeadingText, tokenStart } = stack.pop();
198 output.push(indoc.substr(stackLeadingText, tokenStart));
199 }
200 addText();
201 return false;
202 case "self-closed":
203 if (0 === stackDepth) {
204 if (null !== leadingTextStart) {
205 output.push(
206 indoc.substr(
207 leadingTextStart,
208 startOffset - leadingTextStart
209 )
210 );
211 }
212 output.push(conversionMap[name]);
213 offset = startOffset + tokenLength;
214 return true;
215 }
216 addChild(
217 createFrame(conversionMap[name], startOffset, tokenLength)
218 );
219 offset = startOffset + tokenLength;
220 return true;
221 case "opener":
222 stack.push(
223 createFrame(
224 conversionMap[name],
225 startOffset,
226 tokenLength,
227 startOffset + tokenLength,
228 leadingTextStart
229 )
230 );
231 offset = startOffset + tokenLength;
232 return true;
233 case "closer":
234 if (0 === stackDepth) {
235 if (true) {
236 console.warn(
237 `Unmatched closing tag '</${name}>' in createInterpolateElement. The rest of the string was not interpolated.`
238 );
239 }
240 addText();
241 return false;
242 }
243 if (1 === stackDepth) {
244 closeOuterElement(startOffset);
245 offset = startOffset + tokenLength;
246 return true;
247 }
248 const stackTop = stack.pop();
249 const text = indoc.substr(
250 stackTop.prevOffset,
251 startOffset - stackTop.prevOffset
252 );
253 stackTop.children.push(text);
254 stackTop.prevOffset = startOffset + tokenLength;
255 const frame = createFrame(
256 stackTop.element,
257 stackTop.tokenStart,
258 stackTop.tokenLength,
259 startOffset + tokenLength
260 );
261 frame.children = stackTop.children;
262 addChild(frame);
263 offset = startOffset + tokenLength;
264 return true;
265 default:
266 addText();
267 return false;
268 }
269 }
270 function nextToken() {
271 const matches = tokenizer.exec(indoc);
272 if (null === matches) {
273 return ["no-more-tokens"];
274 }
275 const startedAt = matches.index;
276 const [match, isClosing, name, isSelfClosed] = matches;
277 const length = match.length;
278 if (isSelfClosed) {
279 return ["self-closed", name, startedAt, length];
280 }
281 if (isClosing) {
282 return ["closer", name, startedAt, length];
283 }
284 return ["opener", name, startedAt, length];
285 }
286 function addText() {
287 const length = indoc.length - offset;
288 if (0 === length) {
289 return;
290 }
291 output.push(indoc.substr(offset, length));
292 }
293 function addChild(frame) {
294 const { element, tokenStart, tokenLength, prevOffset, children } = frame;
295 const parent = stack[stack.length - 1];
296 const text = indoc.substr(
297 parent.prevOffset,
298 tokenStart - parent.prevOffset
299 );
300 if (text) {
301 parent.children.push(text);
302 }
303 parent.children.push((0, import_react.cloneElement)(element, null, ...children));
304 parent.prevOffset = prevOffset ? prevOffset : tokenStart + tokenLength;
305 }
306 function closeOuterElement(endOffset) {
307 const { element, leadingTextStart, prevOffset, tokenStart, children } = stack.pop();
308 const text = endOffset ? indoc.substr(prevOffset, endOffset - prevOffset) : indoc.substr(prevOffset);
309 if (text) {
310 children.push(text);
311 }
312 if (null !== leadingTextStart) {
313 output.push(
314 indoc.substr(leadingTextStart, tokenStart - leadingTextStart)
315 );
316 }
317 output.push((0, import_react.cloneElement)(element, null, ...children));
318 }
319 var create_interpolate_element_default = createInterpolateElement;
320
321 // packages/element/build-module/react-platform.mjs
322 var ReactDOM = __toESM(require_react_dom(), 1);
323 var import_client = __toESM(require_client(), 1);
324 var {
325 createPortal,
326 flushSync,
327 /* eslint-disable react/no-deprecated */
328 findDOMNode,
329 render,
330 hydrate,
331 unmountComponentAtNode
332 /* eslint-enable react/no-deprecated */
333 } = ReactDOM;
334
335 // packages/element/build-module/utils.mjs
336 var isEmptyElement = (element) => {
337 if (typeof element === "number") {
338 return false;
339 }
340 if (typeof element?.valueOf() === "string" || Array.isArray(element)) {
341 return !element.length;
342 }
343 return !element;
344 };
345
346 // packages/element/build-module/platform.mjs
347 var Platform = {
348 /** Platform identifier. Will always be `'web'` in this module. */
349 OS: "web",
350 /**
351 * Select a value based on the platform.
352 *
353 * @template T
354 * @param spec - Object with optional platform-specific values.
355 * @return The selected value.
356 */
357 select(spec) {
358 return "web" in spec ? spec.web : spec.default;
359 },
360 /** Whether the platform is web */
361 isWeb: true
362 };
363 var platform_default = Platform;
364
365 // node_modules/is-plain-object/dist/is-plain-object.mjs
366 function isObject(o) {
367 return Object.prototype.toString.call(o) === "[object Object]";
368 }
369 function isPlainObject(o) {
370 var ctor, prot;
371 if (isObject(o) === false) return false;
372 ctor = o.constructor;
373 if (ctor === void 0) return true;
374 prot = ctor.prototype;
375 if (isObject(prot) === false) return false;
376 if (prot.hasOwnProperty("isPrototypeOf") === false) {
377 return false;
378 }
379 return true;
380 }
381
382 // node_modules/tslib/tslib.es6.mjs
383 var __assign = function() {
384 __assign = Object.assign || function __assign2(t) {
385 for (var s, i = 1, n = arguments.length; i < n; i++) {
386 s = arguments[i];
387 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
388 }
389 return t;
390 };
391 return __assign.apply(this, arguments);
392 };
393
394 // node_modules/lower-case/dist.es2015/index.js
395 function lowerCase(str) {
396 return str.toLowerCase();
397 }
398
399 // node_modules/no-case/dist.es2015/index.js
400 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
401 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
402 function noCase(input, options) {
403 if (options === void 0) {
404 options = {};
405 }
406 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;
407 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
408 var start = 0;
409 var end = result.length;
410 while (result.charAt(start) === "\0")
411 start++;
412 while (result.charAt(end - 1) === "\0")
413 end--;
414 return result.slice(start, end).split("\0").map(transform).join(delimiter);
415 }
416 function replace(input, re, value) {
417 if (re instanceof RegExp)
418 return input.replace(re, value);
419 return re.reduce(function(input2, re2) {
420 return input2.replace(re2, value);
421 }, input);
422 }
423
424 // node_modules/dot-case/dist.es2015/index.js
425 function dotCase(input, options) {
426 if (options === void 0) {
427 options = {};
428 }
429 return noCase(input, __assign({ delimiter: "." }, options));
430 }
431
432 // node_modules/param-case/dist.es2015/index.js
433 function paramCase(input, options) {
434 if (options === void 0) {
435 options = {};
436 }
437 return dotCase(input, __assign({ delimiter: "-" }, options));
438 }
439
440 // packages/element/build-module/serialize.mjs
441 var import_escape_html = __toESM(require_escape_html(), 1);
442
443 // packages/element/build-module/raw-html.mjs
444 function RawHTML({ children, ...props }) {
445 let rawHtml = "";
446 import_react.Children.toArray(children).forEach((child) => {
447 if (typeof child === "string" && child.trim() !== "") {
448 rawHtml += child;
449 }
450 });
451 return (0, import_react.createElement)("div", {
452 dangerouslySetInnerHTML: { __html: rawHtml },
453 ...props
454 });
455 }
456
457 // packages/element/build-module/serialize.mjs
458 var Context = (0, import_react.createContext)(void 0);
459 Context.displayName = "ElementContext";
460 var { Provider, Consumer } = Context;
461 var ForwardRef = (0, import_react.forwardRef)(() => {
462 return null;
463 });
464 var ATTRIBUTES_TYPES = /* @__PURE__ */ new Set(["string", "boolean", "number"]);
465 var SELF_CLOSING_TAGS = /* @__PURE__ */ new Set([
466 "area",
467 "base",
468 "br",
469 "col",
470 "command",
471 "embed",
472 "hr",
473 "img",
474 "input",
475 "keygen",
476 "link",
477 "meta",
478 "param",
479 "source",
480 "track",
481 "wbr"
482 ]);
483 var BOOLEAN_ATTRIBUTES = /* @__PURE__ */ new Set([
484 "allowfullscreen",
485 "allowpaymentrequest",
486 "allowusermedia",
487 "async",
488 "autofocus",
489 "autoplay",
490 "checked",
491 "controls",
492 "default",
493 "defer",
494 "disabled",
495 "download",
496 "formnovalidate",
497 "hidden",
498 "ismap",
499 "itemscope",
500 "loop",
501 "multiple",
502 "muted",
503 "nomodule",
504 "novalidate",
505 "open",
506 "playsinline",
507 "readonly",
508 "required",
509 "reversed",
510 "selected",
511 "typemustmatch"
512 ]);
513 var ENUMERATED_ATTRIBUTES = /* @__PURE__ */ new Set([
514 "autocapitalize",
515 "autocomplete",
516 "charset",
517 "contenteditable",
518 "crossorigin",
519 "decoding",
520 "dir",
521 "draggable",
522 "enctype",
523 "formenctype",
524 "formmethod",
525 "http-equiv",
526 "inputmode",
527 "kind",
528 "method",
529 "preload",
530 "scope",
531 "shape",
532 "spellcheck",
533 "translate",
534 "type",
535 "wrap"
536 ]);
537 var CSS_PROPERTIES_SUPPORTS_UNITLESS = /* @__PURE__ */ new Set([
538 "animation",
539 "animationIterationCount",
540 "baselineShift",
541 "borderImageOutset",
542 "borderImageSlice",
543 "borderImageWidth",
544 "columnCount",
545 "cx",
546 "cy",
547 "fillOpacity",
548 "flexGrow",
549 "flexShrink",
550 "floodOpacity",
551 "fontWeight",
552 "gridColumnEnd",
553 "gridColumnStart",
554 "gridRowEnd",
555 "gridRowStart",
556 "lineHeight",
557 "opacity",
558 "order",
559 "orphans",
560 "r",
561 "rx",
562 "ry",
563 "shapeImageThreshold",
564 "stopOpacity",
565 "strokeDasharray",
566 "strokeDashoffset",
567 "strokeMiterlimit",
568 "strokeOpacity",
569 "strokeWidth",
570 "tabSize",
571 "widows",
572 "x",
573 "y",
574 "zIndex",
575 "zoom"
576 ]);
577 function hasPrefix(string, prefixes) {
578 return prefixes.some((prefix) => string.indexOf(prefix) === 0);
579 }
580 function isInternalAttribute(attribute) {
581 return "key" === attribute || "children" === attribute;
582 }
583 function getNormalAttributeValue(attribute, value) {
584 switch (attribute) {
585 case "style":
586 return renderStyle(value);
587 }
588 return value;
589 }
590 var SVG_ATTRIBUTE_WITH_DASHES_LIST = [
591 "accentHeight",
592 "alignmentBaseline",
593 "arabicForm",
594 "baselineShift",
595 "capHeight",
596 "clipPath",
597 "clipRule",
598 "colorInterpolation",
599 "colorInterpolationFilters",
600 "colorProfile",
601 "colorRendering",
602 "dominantBaseline",
603 "enableBackground",
604 "fillOpacity",
605 "fillRule",
606 "floodColor",
607 "floodOpacity",
608 "fontFamily",
609 "fontSize",
610 "fontSizeAdjust",
611 "fontStretch",
612 "fontStyle",
613 "fontVariant",
614 "fontWeight",
615 "glyphName",
616 "glyphOrientationHorizontal",
617 "glyphOrientationVertical",
618 "horizAdvX",
619 "horizOriginX",
620 "imageRendering",
621 "letterSpacing",
622 "lightingColor",
623 "markerEnd",
624 "markerMid",
625 "markerStart",
626 "overlinePosition",
627 "overlineThickness",
628 "paintOrder",
629 "panose1",
630 "pointerEvents",
631 "renderingIntent",
632 "shapeRendering",
633 "stopColor",
634 "stopOpacity",
635 "strikethroughPosition",
636 "strikethroughThickness",
637 "strokeDasharray",
638 "strokeDashoffset",
639 "strokeLinecap",
640 "strokeLinejoin",
641 "strokeMiterlimit",
642 "strokeOpacity",
643 "strokeWidth",
644 "textAnchor",
645 "textDecoration",
646 "textRendering",
647 "underlinePosition",
648 "underlineThickness",
649 "unicodeBidi",
650 "unicodeRange",
651 "unitsPerEm",
652 "vAlphabetic",
653 "vHanging",
654 "vIdeographic",
655 "vMathematical",
656 "vectorEffect",
657 "vertAdvY",
658 "vertOriginX",
659 "vertOriginY",
660 "wordSpacing",
661 "writingMode",
662 "xmlnsXlink",
663 "xHeight"
664 ].reduce(
665 (map, attribute) => {
666 map[attribute.toLowerCase()] = attribute;
667 return map;
668 },
669 {}
670 );
671 var CASE_SENSITIVE_SVG_ATTRIBUTES = [
672 "allowReorder",
673 "attributeName",
674 "attributeType",
675 "autoReverse",
676 "baseFrequency",
677 "baseProfile",
678 "calcMode",
679 "clipPathUnits",
680 "contentScriptType",
681 "contentStyleType",
682 "diffuseConstant",
683 "edgeMode",
684 "externalResourcesRequired",
685 "filterRes",
686 "filterUnits",
687 "glyphRef",
688 "gradientTransform",
689 "gradientUnits",
690 "kernelMatrix",
691 "kernelUnitLength",
692 "keyPoints",
693 "keySplines",
694 "keyTimes",
695 "lengthAdjust",
696 "limitingConeAngle",
697 "markerHeight",
698 "markerUnits",
699 "markerWidth",
700 "maskContentUnits",
701 "maskUnits",
702 "numOctaves",
703 "pathLength",
704 "patternContentUnits",
705 "patternTransform",
706 "patternUnits",
707 "pointsAtX",
708 "pointsAtY",
709 "pointsAtZ",
710 "preserveAlpha",
711 "preserveAspectRatio",
712 "primitiveUnits",
713 "refX",
714 "refY",
715 "repeatCount",
716 "repeatDur",
717 "requiredExtensions",
718 "requiredFeatures",
719 "specularConstant",
720 "specularExponent",
721 "spreadMethod",
722 "startOffset",
723 "stdDeviation",
724 "stitchTiles",
725 "suppressContentEditableWarning",
726 "suppressHydrationWarning",
727 "surfaceScale",
728 "systemLanguage",
729 "tableValues",
730 "targetX",
731 "targetY",
732 "textLength",
733 "viewBox",
734 "viewTarget",
735 "xChannelSelector",
736 "yChannelSelector"
737 ].reduce(
738 (map, attribute) => {
739 map[attribute.toLowerCase()] = attribute;
740 return map;
741 },
742 {}
743 );
744 var SVG_ATTRIBUTES_WITH_COLONS = [
745 "xlink:actuate",
746 "xlink:arcrole",
747 "xlink:href",
748 "xlink:role",
749 "xlink:show",
750 "xlink:title",
751 "xlink:type",
752 "xml:base",
753 "xml:lang",
754 "xml:space",
755 "xmlns:xlink"
756 ].reduce(
757 (map, attribute) => {
758 map[attribute.replace(":", "").toLowerCase()] = attribute;
759 return map;
760 },
761 {}
762 );
763 function getNormalAttributeName(attribute) {
764 switch (attribute) {
765 case "htmlFor":
766 return "for";
767 case "className":
768 return "class";
769 }
770 const attributeLowerCase = attribute.toLowerCase();
771 if (CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase]) {
772 return CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase];
773 } else if (SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]) {
774 return paramCase(
775 SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]
776 );
777 } else if (SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase]) {
778 return SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase];
779 }
780 return attributeLowerCase;
781 }
782 function getNormalStylePropertyName(property) {
783 if (property.startsWith("--")) {
784 return property;
785 }
786 if (hasPrefix(property, ["ms", "O", "Moz", "Webkit"])) {
787 return "-" + paramCase(property);
788 }
789 return paramCase(property);
790 }
791 function getNormalStylePropertyValue(property, value) {
792 if (typeof value === "number" && 0 !== value && !hasPrefix(property, ["--"]) && !CSS_PROPERTIES_SUPPORTS_UNITLESS.has(property)) {
793 return value + "px";
794 }
795 return value;
796 }
797 function renderElement(element, context, legacyContext = {}) {
798 if (null === element || void 0 === element || false === element) {
799 return "";
800 }
801 if (Array.isArray(element)) {
802 return renderChildren(element, context, legacyContext);
803 }
804 switch (typeof element) {
805 case "string":
806 return (0, import_escape_html.escapeHTML)(element);
807 case "number":
808 return element.toString();
809 }
810 const { type, props } = element;
811 switch (type) {
812 case import_react.StrictMode:
813 case import_react.Fragment:
814 return renderChildren(props.children, context, legacyContext);
815 case RawHTML:
816 const { children, ...wrapperProps } = props;
817 return renderNativeComponent(
818 !Object.keys(wrapperProps).length ? null : "div",
819 {
820 ...wrapperProps,
821 dangerouslySetInnerHTML: { __html: children }
822 },
823 context,
824 legacyContext
825 );
826 }
827 switch (typeof type) {
828 case "string":
829 return renderNativeComponent(type, props, context, legacyContext);
830 case "function":
831 if (type.prototype && typeof type.prototype.render === "function") {
832 return renderComponent(type, props, context, legacyContext);
833 }
834 return renderElement(
835 type(props, legacyContext),
836 context,
837 legacyContext
838 );
839 }
840 switch (type && type.$$typeof) {
841 case Provider.$$typeof:
842 return renderChildren(props.children, props.value, legacyContext);
843 case Consumer.$$typeof:
844 return renderElement(
845 props.children(context || type._currentValue),
846 context,
847 legacyContext
848 );
849 case ForwardRef.$$typeof:
850 return renderElement(
851 type.render(props),
852 context,
853 legacyContext
854 );
855 }
856 return "";
857 }
858 function renderNativeComponent(type, props, context, legacyContext = {}) {
859 let content = "";
860 if (type === "textarea" && props.hasOwnProperty("value")) {
861 content = renderChildren(props.value, context, legacyContext);
862 const { value, ...restProps } = props;
863 props = restProps;
864 } else if (props.dangerouslySetInnerHTML && typeof props.dangerouslySetInnerHTML.__html === "string") {
865 content = props.dangerouslySetInnerHTML.__html;
866 } else if (typeof props.children !== "undefined") {
867 content = renderChildren(props.children, context, legacyContext);
868 }
869 if (!type) {
870 return content;
871 }
872 const attributes = renderAttributes(props);
873 if (SELF_CLOSING_TAGS.has(type)) {
874 return "<" + type + attributes + "/>";
875 }
876 return "<" + type + attributes + ">" + content + "</" + type + ">";
877 }
878 function renderComponent(Component2, props, context, legacyContext = {}) {
879 const instance = new Component2(props, legacyContext);
880 if (typeof instance.getChildContext === "function") {
881 Object.assign(legacyContext, instance.getChildContext());
882 }
883 const html = renderElement(instance.render(), context, legacyContext);
884 return html;
885 }
886 function renderChildren(children, context, legacyContext = {}) {
887 let result = "";
888 const childrenArray = Array.isArray(children) ? children : [children];
889 for (let i = 0; i < childrenArray.length; i++) {
890 const child = childrenArray[i];
891 result += renderElement(child, context, legacyContext);
892 }
893 return result;
894 }
895 function renderAttributes(props) {
896 let result = "";
897 for (const key in props) {
898 const attribute = getNormalAttributeName(key);
899 if (!(0, import_escape_html.isValidAttributeName)(attribute)) {
900 continue;
901 }
902 let value = getNormalAttributeValue(key, props[key]);
903 if (!ATTRIBUTES_TYPES.has(typeof value)) {
904 continue;
905 }
906 if (isInternalAttribute(key)) {
907 continue;
908 }
909 const isBooleanAttribute = BOOLEAN_ATTRIBUTES.has(attribute);
910 if (isBooleanAttribute && value === false) {
911 continue;
912 }
913 const isMeaningfulAttribute = isBooleanAttribute || hasPrefix(key, ["data-", "aria-"]) || ENUMERATED_ATTRIBUTES.has(attribute);
914 if (typeof value === "boolean" && !isMeaningfulAttribute) {
915 continue;
916 }
917 result += " " + attribute;
918 if (isBooleanAttribute) {
919 continue;
920 }
921 if (typeof value === "string") {
922 value = (0, import_escape_html.escapeAttribute)(value);
923 }
924 result += '="' + value + '"';
925 }
926 return result;
927 }
928 function renderStyle(style) {
929 if (!isPlainObject(style)) {
930 return style;
931 }
932 let result;
933 const styleObj = style;
934 for (const property in styleObj) {
935 const value = styleObj[property];
936 if (null === value || void 0 === value) {
937 continue;
938 }
939 if (result) {
940 result += ";";
941 } else {
942 result = "";
943 }
944 const normalName = getNormalStylePropertyName(property);
945 const normalValue = getNormalStylePropertyValue(property, value);
946 result += normalName + ":" + normalValue;
947 }
948 return result;
949 }
950 var serialize_default = renderElement;
951 return __toCommonJS(index_exports);
952 })();
953 /*! Bundled license information:
954
955 is-plain-object/dist/is-plain-object.mjs:
956 (*!
957 * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
958 *
959 * Copyright (c) 2014-2017, Jon Schlinkert.
960 * Released under the MIT License.
961 *)
962 */
963 (window.wp ||= {}).element = wp.element;
964 })();
965 //# sourceMappingURL=index.js.map
966