PluginProbe
Gutenberg / 23.3.0
Gutenberg v23.3.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.3.0, at build/scripts/element/index.js

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