html-react-parser 1.2.6 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2024 +1,2379 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react')) :
3
- typeof define === 'function' && define.amd ? define(['react'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.HTMLReactParser = factory(global.React));
5
- }(this, (function (React) { 'use strict';
6
-
7
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
-
9
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
10
-
11
- var HTMLDOMPropertyConfig = {
12
- Properties: {
13
- autoFocus: 4,
14
- accept: 0,
15
- acceptCharset: 0,
16
- accessKey: 0,
17
- action: 0,
18
- allowFullScreen: 4,
19
- allowTransparency: 0,
20
- alt: 0,
21
- as: 0,
22
- async: 4,
23
- autoComplete: 0,
24
- autoPlay: 4,
25
- capture: 4,
26
- cellPadding: 0,
27
- cellSpacing: 0,
28
- charSet: 0,
29
- challenge: 0,
30
- checked: 5,
31
- cite: 0,
32
- classID: 0,
33
- className: 0,
34
- cols: 24,
35
- colSpan: 0,
36
- content: 0,
37
- contentEditable: 0,
38
- contextMenu: 0,
39
- controls: 4,
40
- controlsList: 0,
41
- coords: 0,
42
- crossOrigin: 0,
43
- data: 0,
44
- dateTime: 0,
45
- default: 4,
46
- defer: 4,
47
- dir: 0,
48
- disabled: 4,
49
- download: 32,
50
- draggable: 0,
51
- encType: 0,
52
- form: 0,
53
- formAction: 0,
54
- formEncType: 0,
55
- formMethod: 0,
56
- formNoValidate: 4,
57
- formTarget: 0,
58
- frameBorder: 0,
59
- headers: 0,
60
- height: 0,
61
- hidden: 4,
62
- high: 0,
63
- href: 0,
64
- hrefLang: 0,
65
- htmlFor: 0,
66
- httpEquiv: 0,
67
- icon: 0,
68
- id: 0,
69
- inputMode: 0,
70
- integrity: 0,
71
- is: 0,
72
- keyParams: 0,
73
- keyType: 0,
74
- kind: 0,
75
- label: 0,
76
- lang: 0,
77
- list: 0,
78
- loop: 4,
79
- low: 0,
80
- manifest: 0,
81
- marginHeight: 0,
82
- marginWidth: 0,
83
- max: 0,
84
- maxLength: 0,
85
- media: 0,
86
- mediaGroup: 0,
87
- method: 0,
88
- min: 0,
89
- minLength: 0,
90
- multiple: 5,
91
- muted: 5,
92
- name: 0,
93
- nonce: 0,
94
- noValidate: 4,
95
- open: 4,
96
- optimum: 0,
97
- pattern: 0,
98
- placeholder: 0,
99
- playsInline: 4,
100
- poster: 0,
101
- preload: 0,
102
- profile: 0,
103
- radioGroup: 0,
104
- readOnly: 4,
105
- referrerPolicy: 0,
106
- rel: 0,
107
- required: 4,
108
- reversed: 4,
109
- role: 0,
110
- rows: 24,
111
- rowSpan: 8,
112
- sandbox: 0,
113
- scope: 0,
114
- scoped: 4,
115
- scrolling: 0,
116
- seamless: 4,
117
- selected: 5,
118
- shape: 0,
119
- size: 24,
120
- sizes: 0,
121
- span: 24,
122
- spellCheck: 0,
123
- src: 0,
124
- srcDoc: 0,
125
- srcLang: 0,
126
- srcSet: 0,
127
- start: 8,
128
- step: 0,
129
- style: 0,
130
- summary: 0,
131
- tabIndex: 0,
132
- target: 0,
133
- title: 0,
134
- type: 0,
135
- useMap: 0,
136
- value: 0,
137
- width: 0,
138
- wmode: 0,
139
- wrap: 0,
140
- about: 0,
141
- datatype: 0,
142
- inlist: 0,
143
- prefix: 0,
144
- property: 0,
145
- resource: 0,
146
- typeof: 0,
147
- vocab: 0,
148
- autoCapitalize: 0,
149
- autoCorrect: 0,
150
- autoSave: 0,
151
- color: 0,
152
- itemProp: 0,
153
- itemScope: 4,
154
- itemType: 0,
155
- itemID: 0,
156
- itemRef: 0,
157
- results: 0,
158
- security: 0,
159
- unselectable: 0
160
- },
161
- DOMAttributeNames: {
162
- acceptCharset: 'accept-charset',
163
- className: 'class',
164
- htmlFor: 'for',
165
- httpEquiv: 'http-equiv'
166
- }
167
- };
168
-
169
- var SVGDOMPropertyConfig = {
170
- Properties: {
171
- accentHeight: 0,
172
- accumulate: 0,
173
- additive: 0,
174
- alignmentBaseline: 0,
175
- allowReorder: 0,
176
- alphabetic: 0,
177
- amplitude: 0,
178
- arabicForm: 0,
179
- ascent: 0,
180
- attributeName: 0,
181
- attributeType: 0,
182
- autoReverse: 0,
183
- azimuth: 0,
184
- baseFrequency: 0,
185
- baseProfile: 0,
186
- baselineShift: 0,
187
- bbox: 0,
188
- begin: 0,
189
- bias: 0,
190
- by: 0,
191
- calcMode: 0,
192
- capHeight: 0,
193
- clip: 0,
194
- clipPath: 0,
195
- clipRule: 0,
196
- clipPathUnits: 0,
197
- colorInterpolation: 0,
198
- colorInterpolationFilters: 0,
199
- colorProfile: 0,
200
- colorRendering: 0,
201
- contentScriptType: 0,
202
- contentStyleType: 0,
203
- cursor: 0,
204
- cx: 0,
205
- cy: 0,
206
- d: 0,
207
- decelerate: 0,
208
- descent: 0,
209
- diffuseConstant: 0,
210
- direction: 0,
211
- display: 0,
212
- divisor: 0,
213
- dominantBaseline: 0,
214
- dur: 0,
215
- dx: 0,
216
- dy: 0,
217
- edgeMode: 0,
218
- elevation: 0,
219
- enableBackground: 0,
220
- end: 0,
221
- exponent: 0,
222
- externalResourcesRequired: 0,
223
- fill: 0,
224
- fillOpacity: 0,
225
- fillRule: 0,
226
- filter: 0,
227
- filterRes: 0,
228
- filterUnits: 0,
229
- floodColor: 0,
230
- floodOpacity: 0,
231
- focusable: 0,
232
- fontFamily: 0,
233
- fontSize: 0,
234
- fontSizeAdjust: 0,
235
- fontStretch: 0,
236
- fontStyle: 0,
237
- fontVariant: 0,
238
- fontWeight: 0,
239
- format: 0,
240
- from: 0,
241
- fx: 0,
242
- fy: 0,
243
- g1: 0,
244
- g2: 0,
245
- glyphName: 0,
246
- glyphOrientationHorizontal: 0,
247
- glyphOrientationVertical: 0,
248
- glyphRef: 0,
249
- gradientTransform: 0,
250
- gradientUnits: 0,
251
- hanging: 0,
252
- horizAdvX: 0,
253
- horizOriginX: 0,
254
- ideographic: 0,
255
- imageRendering: 0,
256
- in: 0,
257
- in2: 0,
258
- intercept: 0,
259
- k: 0,
260
- k1: 0,
261
- k2: 0,
262
- k3: 0,
263
- k4: 0,
264
- kernelMatrix: 0,
265
- kernelUnitLength: 0,
266
- kerning: 0,
267
- keyPoints: 0,
268
- keySplines: 0,
269
- keyTimes: 0,
270
- lengthAdjust: 0,
271
- letterSpacing: 0,
272
- lightingColor: 0,
273
- limitingConeAngle: 0,
274
- local: 0,
275
- markerEnd: 0,
276
- markerMid: 0,
277
- markerStart: 0,
278
- markerHeight: 0,
279
- markerUnits: 0,
280
- markerWidth: 0,
281
- mask: 0,
282
- maskContentUnits: 0,
283
- maskUnits: 0,
284
- mathematical: 0,
285
- mode: 0,
286
- numOctaves: 0,
287
- offset: 0,
288
- opacity: 0,
289
- operator: 0,
290
- order: 0,
291
- orient: 0,
292
- orientation: 0,
293
- origin: 0,
294
- overflow: 0,
295
- overlinePosition: 0,
296
- overlineThickness: 0,
297
- paintOrder: 0,
298
- panose1: 0,
299
- pathLength: 0,
300
- patternContentUnits: 0,
301
- patternTransform: 0,
302
- patternUnits: 0,
303
- pointerEvents: 0,
304
- points: 0,
305
- pointsAtX: 0,
306
- pointsAtY: 0,
307
- pointsAtZ: 0,
308
- preserveAlpha: 0,
309
- preserveAspectRatio: 0,
310
- primitiveUnits: 0,
311
- r: 0,
312
- radius: 0,
313
- refX: 0,
314
- refY: 0,
315
- renderingIntent: 0,
316
- repeatCount: 0,
317
- repeatDur: 0,
318
- requiredExtensions: 0,
319
- requiredFeatures: 0,
320
- restart: 0,
321
- result: 0,
322
- rotate: 0,
323
- rx: 0,
324
- ry: 0,
325
- scale: 0,
326
- seed: 0,
327
- shapeRendering: 0,
328
- slope: 0,
329
- spacing: 0,
330
- specularConstant: 0,
331
- specularExponent: 0,
332
- speed: 0,
333
- spreadMethod: 0,
334
- startOffset: 0,
335
- stdDeviation: 0,
336
- stemh: 0,
337
- stemv: 0,
338
- stitchTiles: 0,
339
- stopColor: 0,
340
- stopOpacity: 0,
341
- strikethroughPosition: 0,
342
- strikethroughThickness: 0,
343
- string: 0,
344
- stroke: 0,
345
- strokeDasharray: 0,
346
- strokeDashoffset: 0,
347
- strokeLinecap: 0,
348
- strokeLinejoin: 0,
349
- strokeMiterlimit: 0,
350
- strokeOpacity: 0,
351
- strokeWidth: 0,
352
- surfaceScale: 0,
353
- systemLanguage: 0,
354
- tableValues: 0,
355
- targetX: 0,
356
- targetY: 0,
357
- textAnchor: 0,
358
- textDecoration: 0,
359
- textRendering: 0,
360
- textLength: 0,
361
- to: 0,
362
- transform: 0,
363
- u1: 0,
364
- u2: 0,
365
- underlinePosition: 0,
366
- underlineThickness: 0,
367
- unicode: 0,
368
- unicodeBidi: 0,
369
- unicodeRange: 0,
370
- unitsPerEm: 0,
371
- vAlphabetic: 0,
372
- vHanging: 0,
373
- vIdeographic: 0,
374
- vMathematical: 0,
375
- values: 0,
376
- vectorEffect: 0,
377
- version: 0,
378
- vertAdvY: 0,
379
- vertOriginX: 0,
380
- vertOriginY: 0,
381
- viewBox: 0,
382
- viewTarget: 0,
383
- visibility: 0,
384
- widths: 0,
385
- wordSpacing: 0,
386
- writingMode: 0,
387
- x: 0,
388
- xHeight: 0,
389
- x1: 0,
390
- x2: 0,
391
- xChannelSelector: 0,
392
- xlinkActuate: 0,
393
- xlinkArcrole: 0,
394
- xlinkHref: 0,
395
- xlinkRole: 0,
396
- xlinkShow: 0,
397
- xlinkTitle: 0,
398
- xlinkType: 0,
399
- xmlBase: 0,
400
- xmlns: 0,
401
- xmlnsXlink: 0,
402
- xmlLang: 0,
403
- xmlSpace: 0,
404
- y: 0,
405
- y1: 0,
406
- y2: 0,
407
- yChannelSelector: 0,
408
- z: 0,
409
- zoomAndPan: 0
410
- },
411
- DOMAttributeNames: {
412
- accentHeight: 'accent-height',
413
- alignmentBaseline: 'alignment-baseline',
414
- arabicForm: 'arabic-form',
415
- baselineShift: 'baseline-shift',
416
- capHeight: 'cap-height',
417
- clipPath: 'clip-path',
418
- clipRule: 'clip-rule',
419
- colorInterpolation: 'color-interpolation',
420
- colorInterpolationFilters: 'color-interpolation-filters',
421
- colorProfile: 'color-profile',
422
- colorRendering: 'color-rendering',
423
- dominantBaseline: 'dominant-baseline',
424
- enableBackground: 'enable-background',
425
- fillOpacity: 'fill-opacity',
426
- fillRule: 'fill-rule',
427
- floodColor: 'flood-color',
428
- floodOpacity: 'flood-opacity',
429
- fontFamily: 'font-family',
430
- fontSize: 'font-size',
431
- fontSizeAdjust: 'font-size-adjust',
432
- fontStretch: 'font-stretch',
433
- fontStyle: 'font-style',
434
- fontVariant: 'font-variant',
435
- fontWeight: 'font-weight',
436
- glyphName: 'glyph-name',
437
- glyphOrientationHorizontal: 'glyph-orientation-horizontal',
438
- glyphOrientationVertical: 'glyph-orientation-vertical',
439
- horizAdvX: 'horiz-adv-x',
440
- horizOriginX: 'horiz-origin-x',
441
- imageRendering: 'image-rendering',
442
- letterSpacing: 'letter-spacing',
443
- lightingColor: 'lighting-color',
444
- markerEnd: 'marker-end',
445
- markerMid: 'marker-mid',
446
- markerStart: 'marker-start',
447
- overlinePosition: 'overline-position',
448
- overlineThickness: 'overline-thickness',
449
- paintOrder: 'paint-order',
450
- panose1: 'panose-1',
451
- pointerEvents: 'pointer-events',
452
- renderingIntent: 'rendering-intent',
453
- shapeRendering: 'shape-rendering',
454
- stopColor: 'stop-color',
455
- stopOpacity: 'stop-opacity',
456
- strikethroughPosition: 'strikethrough-position',
457
- strikethroughThickness: 'strikethrough-thickness',
458
- strokeDasharray: 'stroke-dasharray',
459
- strokeDashoffset: 'stroke-dashoffset',
460
- strokeLinecap: 'stroke-linecap',
461
- strokeLinejoin: 'stroke-linejoin',
462
- strokeMiterlimit: 'stroke-miterlimit',
463
- strokeOpacity: 'stroke-opacity',
464
- strokeWidth: 'stroke-width',
465
- textAnchor: 'text-anchor',
466
- textDecoration: 'text-decoration',
467
- textRendering: 'text-rendering',
468
- underlinePosition: 'underline-position',
469
- underlineThickness: 'underline-thickness',
470
- unicodeBidi: 'unicode-bidi',
471
- unicodeRange: 'unicode-range',
472
- unitsPerEm: 'units-per-em',
473
- vAlphabetic: 'v-alphabetic',
474
- vHanging: 'v-hanging',
475
- vIdeographic: 'v-ideographic',
476
- vMathematical: 'v-mathematical',
477
- vectorEffect: 'vector-effect',
478
- vertAdvY: 'vert-adv-y',
479
- vertOriginX: 'vert-origin-x',
480
- vertOriginY: 'vert-origin-y',
481
- wordSpacing: 'word-spacing',
482
- writingMode: 'writing-mode',
483
- xHeight: 'x-height',
484
- xlinkActuate: 'xlink:actuate',
485
- xlinkArcrole: 'xlink:arcrole',
486
- xlinkHref: 'xlink:href',
487
- xlinkRole: 'xlink:role',
488
- xlinkShow: 'xlink:show',
489
- xlinkTitle: 'xlink:title',
490
- xlinkType: 'xlink:type',
491
- xmlBase: 'xml:base',
492
- xmlnsXlink: 'xmlns:xlink',
493
- xmlLang: 'xml:lang',
494
- xmlSpace: 'xml:space'
495
- }
496
- };
497
-
498
- var injection = {
499
- MUST_USE_PROPERTY: 1,
500
- HAS_BOOLEAN_VALUE: 4,
501
- HAS_NUMERIC_VALUE: 8,
502
- HAS_POSITIVE_NUMERIC_VALUE: 24,
503
- HAS_OVERLOADED_BOOLEAN_VALUE: 32
504
- };
505
-
506
- var MUST_USE_PROPERTY = injection.MUST_USE_PROPERTY;
507
- var HAS_BOOLEAN_VALUE = injection.HAS_BOOLEAN_VALUE;
508
- var HAS_NUMERIC_VALUE = injection.HAS_NUMERIC_VALUE;
509
- var HAS_POSITIVE_NUMERIC_VALUE = injection.HAS_POSITIVE_NUMERIC_VALUE;
510
- var HAS_OVERLOADED_BOOLEAN_VALUE = injection.HAS_OVERLOADED_BOOLEAN_VALUE;
511
-
512
- /**
513
- * @see https://github.com/facebook/react/blob/15-stable/src/renderers/dom/shared/DOMProperty.js#L14-L16
514
- *
515
- * @param {Number} value
516
- * @param {Number} bitmask
517
- * @return {Boolean}
518
- */
519
- function checkMask(value, bitmask) {
520
- return (value & bitmask) === bitmask;
521
- }
522
-
523
- /**
524
- * @see https://github.com/facebook/react/blob/15-stable/src/renderers/dom/shared/DOMProperty.js#L57
525
- *
526
- * @param {Object} domPropertyConfig - HTMLDOMPropertyConfig or SVGDOMPropertyConfig
527
- * @param {Object} config - The object to be mutated
528
- * @param {Boolean} isSVG - Whether the injected config is HTML or SVG (it assumes the default is HTML)
529
- */
530
- function injectDOMPropertyConfig(domPropertyConfig, config, isSVG) {
531
- var Properties = domPropertyConfig.Properties;
532
- var DOMAttributeNames = domPropertyConfig.DOMAttributeNames;
533
- var attributeName;
534
- var propertyName;
535
- var propConfig;
536
-
537
- for (propertyName in Properties) {
538
- attributeName =
539
- DOMAttributeNames[propertyName] ||
540
- (isSVG ? propertyName : propertyName.toLowerCase());
541
- propConfig = Properties[propertyName];
542
-
543
- config[attributeName] = {
544
- attributeName: attributeName,
545
- propertyName: propertyName,
546
- mustUseProperty: checkMask(propConfig, MUST_USE_PROPERTY),
547
- hasBooleanValue: checkMask(propConfig, HAS_BOOLEAN_VALUE),
548
- hasNumericValue: checkMask(propConfig, HAS_NUMERIC_VALUE),
549
- hasPositiveNumericValue: checkMask(
550
- propConfig,
551
- HAS_POSITIVE_NUMERIC_VALUE
552
- ),
553
- hasOverloadedBooleanValue: checkMask(
554
- propConfig,
555
- HAS_OVERLOADED_BOOLEAN_VALUE
556
- )
557
- };
558
- }
559
- }
560
-
561
- /**
562
- * HTML properties config.
563
- *
564
- * @type {Object}
565
- */
566
- var html = {};
567
- injectDOMPropertyConfig(HTMLDOMPropertyConfig, html);
568
-
569
- /**
570
- * SVG properties config.
571
- *
572
- * @type {Object}
573
- */
574
- var svg = {};
575
- injectDOMPropertyConfig(SVGDOMPropertyConfig, svg, true);
576
-
577
- /**
578
- * HTML and SVG properties config.
579
- *
580
- * @type {Object}
581
- */
582
- var properties = {};
583
- injectDOMPropertyConfig(HTMLDOMPropertyConfig, properties);
584
- injectDOMPropertyConfig(SVGDOMPropertyConfig, properties, true);
585
-
586
- var ATTRIBUTE_NAME_START_CHAR =
587
- ':A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD';
588
- var ATTRIBUTE_NAME_CHAR =
589
- ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040';
590
-
591
- var reactProperty = {
592
- html: html,
593
- svg: svg,
594
- properties: properties,
595
-
596
- /**
597
- * Checks whether a property name is a custom attribute.
598
- *
599
- * @see https://github.com/facebook/react/blob/15-stable/src/renderers/dom/shared/HTMLDOMPropertyConfig.js#L23-L25
600
- *
601
- * @param {String}
602
- * @return {Boolean}
603
- */
604
- isCustomAttribute: RegExp.prototype.test.bind(
605
- new RegExp('^(data|aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$')
606
- )
607
- };
608
-
609
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
610
-
611
- function createCommonjsModule(fn) {
612
- var module = { exports: {} };
613
- return fn(module, module.exports), module.exports;
614
- }
615
-
616
- // http://www.w3.org/TR/CSS21/grammar.html
617
- // https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
618
- var COMMENT_REGEX = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
619
-
620
- var NEWLINE_REGEX = /\n/g;
621
- var WHITESPACE_REGEX = /^\s*/;
622
-
623
- // declaration
624
- var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/;
625
- var COLON_REGEX = /^:\s*/;
626
- var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/;
627
- var SEMICOLON_REGEX = /^[;\s]*/;
628
-
629
- // https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
630
- var TRIM_REGEX = /^\s+|\s+$/g;
631
-
632
- // strings
633
- var NEWLINE = '\n';
634
- var FORWARD_SLASH = '/';
635
- var ASTERISK = '*';
636
- var EMPTY_STRING = '';
637
-
638
- // types
639
- var TYPE_COMMENT = 'comment';
640
- var TYPE_DECLARATION = 'declaration';
641
-
642
- /**
643
- * @param {String} style
644
- * @param {Object} [options]
645
- * @return {Object[]}
646
- * @throws {TypeError}
647
- * @throws {Error}
648
- */
649
- var inlineStyleParser = function(style, options) {
650
- if (typeof style !== 'string') {
651
- throw new TypeError('First argument must be a string');
652
- }
653
-
654
- if (!style) return [];
655
-
656
- options = options || {};
657
-
658
- /**
659
- * Positional.
660
- */
661
- var lineno = 1;
662
- var column = 1;
663
-
664
- /**
665
- * Update lineno and column based on `str`.
666
- *
667
- * @param {String} str
668
- */
669
- function updatePosition(str) {
670
- var lines = str.match(NEWLINE_REGEX);
671
- if (lines) lineno += lines.length;
672
- var i = str.lastIndexOf(NEWLINE);
673
- column = ~i ? str.length - i : column + str.length;
674
- }
675
-
676
- /**
677
- * Mark position and patch `node.position`.
678
- *
679
- * @return {Function}
680
- */
681
- function position() {
682
- var start = { line: lineno, column: column };
683
- return function(node) {
684
- node.position = new Position(start);
685
- whitespace();
686
- return node;
687
- };
688
- }
689
-
690
- /**
691
- * Store position information for a node.
692
- *
693
- * @constructor
694
- * @property {Object} start
695
- * @property {Object} end
696
- * @property {undefined|String} source
697
- */
698
- function Position(start) {
699
- this.start = start;
700
- this.end = { line: lineno, column: column };
701
- this.source = options.source;
702
- }
703
-
704
- /**
705
- * Non-enumerable source string.
706
- */
707
- Position.prototype.content = style;
708
-
709
- /**
710
- * Error `msg`.
711
- *
712
- * @param {String} msg
713
- * @throws {Error}
714
- */
715
- function error(msg) {
716
- var err = new Error(
717
- options.source + ':' + lineno + ':' + column + ': ' + msg
718
- );
719
- err.reason = msg;
720
- err.filename = options.source;
721
- err.line = lineno;
722
- err.column = column;
723
- err.source = style;
724
-
725
- if (options.silent) ; else {
726
- throw err;
727
- }
728
- }
729
-
730
- /**
731
- * Match `re` and return captures.
732
- *
733
- * @param {RegExp} re
734
- * @return {undefined|Array}
735
- */
736
- function match(re) {
737
- var m = re.exec(style);
738
- if (!m) return;
739
- var str = m[0];
740
- updatePosition(str);
741
- style = style.slice(str.length);
742
- return m;
743
- }
744
-
745
- /**
746
- * Parse whitespace.
747
- */
748
- function whitespace() {
749
- match(WHITESPACE_REGEX);
750
- }
751
-
752
- /**
753
- * Parse comments.
754
- *
755
- * @param {Object[]} [rules]
756
- * @return {Object[]}
757
- */
758
- function comments(rules) {
759
- var c;
760
- rules = rules || [];
761
- while ((c = comment())) {
762
- if (c !== false) {
763
- rules.push(c);
764
- }
765
- }
766
- return rules;
767
- }
768
-
769
- /**
770
- * Parse comment.
771
- *
772
- * @return {Object}
773
- * @throws {Error}
774
- */
775
- function comment() {
776
- var pos = position();
777
- if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;
778
-
779
- var i = 2;
780
- while (
781
- EMPTY_STRING != style.charAt(i) &&
782
- (ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))
783
- ) {
784
- ++i;
785
- }
786
- i += 2;
787
-
788
- if (EMPTY_STRING === style.charAt(i - 1)) {
789
- return error('End of comment missing');
790
- }
791
-
792
- var str = style.slice(2, i - 2);
793
- column += 2;
794
- updatePosition(str);
795
- style = style.slice(i);
796
- column += 2;
797
-
798
- return pos({
799
- type: TYPE_COMMENT,
800
- comment: str
801
- });
802
- }
803
-
804
- /**
805
- * Parse declaration.
806
- *
807
- * @return {Object}
808
- * @throws {Error}
809
- */
810
- function declaration() {
811
- var pos = position();
812
-
813
- // prop
814
- var prop = match(PROPERTY_REGEX);
815
- if (!prop) return;
816
- comment();
817
-
818
- // :
819
- if (!match(COLON_REGEX)) return error("property missing ':'");
820
-
821
- // val
822
- var val = match(VALUE_REGEX);
823
-
824
- var ret = pos({
825
- type: TYPE_DECLARATION,
826
- property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),
827
- value: val
828
- ? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING))
829
- : EMPTY_STRING
830
- });
831
-
832
- // ;
833
- match(SEMICOLON_REGEX);
834
-
835
- return ret;
836
- }
837
-
838
- /**
839
- * Parse declarations.
840
- *
841
- * @return {Object[]}
842
- */
843
- function declarations() {
844
- var decls = [];
845
-
846
- comments(decls);
847
-
848
- // declarations
849
- var decl;
850
- while ((decl = declaration())) {
851
- if (decl !== false) {
852
- decls.push(decl);
853
- comments(decls);
854
- }
855
- }
856
-
857
- return decls;
858
- }
859
-
860
- whitespace();
861
- return declarations();
862
- };
863
-
864
- /**
865
- * Trim `str`.
866
- *
867
- * @param {String} str
868
- * @return {String}
869
- */
870
- function trim(str) {
871
- return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;
872
- }
873
-
874
- /**
875
- * Parses inline style to object.
876
- *
877
- * @example
878
- * // returns { 'line-height': '42' }
879
- * StyleToObject('line-height: 42;');
880
- *
881
- * @param {String} style - The inline style.
882
- * @param {Function} [iterator] - The iterator function.
883
- * @return {null|Object}
884
- */
885
- function StyleToObject(style, iterator) {
886
- var output = null;
887
- if (!style || typeof style !== 'string') {
888
- return output;
889
- }
890
-
891
- var declaration;
892
- var declarations = inlineStyleParser(style);
893
- var hasIterator = typeof iterator === 'function';
894
- var property;
895
- var value;
896
-
897
- for (var i = 0, len = declarations.length; i < len; i++) {
898
- declaration = declarations[i];
899
- property = declaration.property;
900
- value = declaration.value;
901
-
902
- if (hasIterator) {
903
- iterator(property, value, declaration);
904
- } else if (value) {
905
- output || (output = {});
906
- output[property] = value;
907
- }
908
- }
909
-
910
- return output;
911
- }
912
-
913
- var styleToObject = StyleToObject;
914
-
915
- var utilities$2 = createCommonjsModule(function (module, exports) {
916
- exports.__esModule = true;
917
- exports.camelCase = void 0;
918
- var CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9-]+$/;
919
- var HYPHEN_REGEX = /-([a-z])/g;
920
- var NO_HYPHEN_REGEX = /^[^-]+$/;
921
- var VENDOR_PREFIX_REGEX = /^-(webkit|moz|ms|o|khtml)-/;
922
- var skipCamelCase = function (property) {
923
- return !property ||
924
- NO_HYPHEN_REGEX.test(property) ||
925
- CUSTOM_PROPERTY_REGEX.test(property);
926
- };
927
- var capitalize = function (match, character) {
928
- return character.toUpperCase();
929
- };
930
- var trimHyphen = function (match, prefix) { return prefix + "-"; };
931
- var camelCase = function (property, options) {
932
- if (options === void 0) { options = {}; }
933
- if (skipCamelCase(property)) {
934
- return property;
935
- }
936
- property = property.toLowerCase();
937
- if (!options.reactCompat) {
938
- property = property.replace(VENDOR_PREFIX_REGEX, trimHyphen);
939
- }
940
- return property.replace(HYPHEN_REGEX, capitalize);
941
- };
942
- exports.camelCase = camelCase;
943
- });
944
-
945
- var cjs = createCommonjsModule(function (module, exports) {
946
- var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
947
- return (mod && mod.__esModule) ? mod : { "default": mod };
948
- };
949
- exports.__esModule = true;
950
- var style_to_object_1 = __importDefault(styleToObject);
951
-
952
- function StyleToJS(style, options) {
953
- var output = {};
954
- if (!style || typeof style !== 'string') {
955
- return output;
956
- }
957
- style_to_object_1["default"](style, function (property, value) {
958
- if (property && value) {
959
- output[utilities$2.camelCase(property, options)] = value;
960
- }
961
- });
962
- return output;
963
- }
964
- exports["default"] = StyleToJS;
965
- });
966
-
967
- var styleToJS = cjs.default;
968
-
969
- /**
970
- * Swap key with value in an object.
971
- *
972
- * @param {Object} obj - The object.
973
- * @param {Function} [override] - The override method.
974
- * @return {Object} - The inverted object.
975
- */
976
- function invertObject(obj, override) {
977
- if (!obj || typeof obj !== 'object') {
978
- throw new TypeError('First argument must be an object');
979
- }
980
-
981
- var key;
982
- var value;
983
- var isOverridePresent = typeof override === 'function';
984
- var overrides = {};
985
- var result = {};
986
-
987
- for (key in obj) {
988
- value = obj[key];
989
-
990
- if (isOverridePresent) {
991
- overrides = override(key, value);
992
- if (overrides && overrides.length === 2) {
993
- result[overrides[0]] = overrides[1];
994
- continue;
995
- }
996
- }
997
-
998
- if (typeof value === 'string') {
999
- result[value] = key;
1000
- }
1001
- }
1002
-
1003
- return result;
1004
- }
1005
-
1006
- /**
1007
- * Check if a given tag is a custom component.
1008
- *
1009
- * @see {@link https://github.com/facebook/react/blob/v16.6.3/packages/react-dom/src/shared/isCustomComponent.js}
1010
- *
1011
- * @param {string} tagName - The name of the html tag.
1012
- * @param {Object} props - The props being passed to the element.
1013
- * @return {boolean}
1014
- */
1015
- function isCustomComponent(tagName, props) {
1016
- if (tagName.indexOf('-') === -1) {
1017
- return props && typeof props.is === 'string';
1018
- }
1019
-
1020
- switch (tagName) {
1021
- // These are reserved SVG and MathML elements.
1022
- // We don't mind this whitelist too much because we expect it to never grow.
1023
- // The alternative is to track the namespace in a few places which is convoluted.
1024
- // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
1025
- case 'annotation-xml':
1026
- case 'color-profile':
1027
- case 'font-face':
1028
- case 'font-face-src':
1029
- case 'font-face-uri':
1030
- case 'font-face-format':
1031
- case 'font-face-name':
1032
- case 'missing-glyph':
1033
- return false;
1034
- default:
1035
- return true;
1036
- }
1037
- }
1038
-
1039
- var styleToJSOptions = { reactCompat: true };
1040
-
1041
- /**
1042
- * Sets style prop.
1043
- *
1044
- * @param {null|undefined|string} style
1045
- * @param {object} props
1046
- */
1047
- function setStyleProp$2(style, props) {
1048
- if (style === null || style === undefined) {
1049
- return;
1050
- }
1051
- props.style = styleToJS(style, styleToJSOptions);
1052
- }
1053
-
1054
- /**
1055
- * @constant {boolean}
1056
- * @see {@link https://reactjs.org/blog/2017/09/08/dom-attributes-in-react-16.html}
1057
- */
1058
- var PRESERVE_CUSTOM_ATTRIBUTES = React__default['default'].version.split('.')[0] >= 16;
1059
-
1060
- var utilities$1 = {
1061
- PRESERVE_CUSTOM_ATTRIBUTES: PRESERVE_CUSTOM_ATTRIBUTES,
1062
- invertObject: invertObject,
1063
- isCustomComponent: isCustomComponent,
1064
- setStyleProp: setStyleProp$2
1065
- };
1066
-
1067
- var setStyleProp$1 = utilities$1.setStyleProp;
1068
-
1069
- var htmlProperties = reactProperty.html;
1070
- var svgProperties = reactProperty.svg;
1071
- var isCustomAttribute = reactProperty.isCustomAttribute;
1072
-
1073
- var hasOwnProperty = Object.prototype.hasOwnProperty;
1074
-
1075
- /**
1076
- * Converts HTML/SVG DOM attributes to React props.
1077
- *
1078
- * @param {object} [attributes={}] - HTML/SVG DOM attributes.
1079
- * @return {object} - React props.
1080
- */
1081
- function attributesToProps(attributes) {
1082
- attributes = attributes || {};
1083
-
1084
- var attributeName;
1085
- var attributeNameLowerCased;
1086
- var attributeValue;
1087
- var property;
1088
- var props = {};
1089
-
1090
- for (attributeName in attributes) {
1091
- attributeValue = attributes[attributeName];
1092
-
1093
- // ARIA (aria-*) or custom data (data-*) attribute
1094
- if (isCustomAttribute(attributeName)) {
1095
- props[attributeName] = attributeValue;
1096
- continue;
1097
- }
1098
-
1099
- // convert HTML attribute to React prop
1100
- attributeNameLowerCased = attributeName.toLowerCase();
1101
- if (hasOwnProperty.call(htmlProperties, attributeNameLowerCased)) {
1102
- property = htmlProperties[attributeNameLowerCased];
1103
- props[property.propertyName] =
1104
- property.hasBooleanValue ||
1105
- (property.hasOverloadedBooleanValue && !attributeValue)
1106
- ? true
1107
- : attributeValue;
1108
- continue;
1109
- }
1110
-
1111
- // convert SVG attribute to React prop
1112
- if (hasOwnProperty.call(svgProperties, attributeName)) {
1113
- property = svgProperties[attributeName];
1114
- props[property.propertyName] = attributeValue;
1115
- continue;
1116
- }
1117
-
1118
- // preserve custom attribute if React >=16
1119
- if (utilities$1.PRESERVE_CUSTOM_ATTRIBUTES) {
1120
- props[attributeName] = attributeValue;
1121
- }
1122
- }
1123
-
1124
- // transform inline style to object
1125
- setStyleProp$1(attributes.style, props);
1126
-
1127
- return props;
1128
- }
1129
-
1130
- var attributesToProps_1 = attributesToProps;
1131
-
1132
- var setStyleProp = utilities$1.setStyleProp;
1133
-
1134
- /**
1135
- * Converts DOM nodes to JSX element(s).
1136
- *
1137
- * @param {DomElement[]} nodes - DOM nodes.
1138
- * @param {object} [options={}] - Options.
1139
- * @param {Function} [options.replace] - Replacer.
1140
- * @param {object} [options.library] - Library (React/Preact/etc.).
1141
- * @return {string|JSX.Element|JSX.Element[]}
1142
- */
1143
- function domToReact(nodes, options) {
1144
- options = options || {};
1145
-
1146
- var library = options.library || React__default['default'];
1147
- var cloneElement = library.cloneElement;
1148
- var createElement = library.createElement;
1149
- var isValidElement = library.isValidElement;
1150
-
1151
- var result = [];
1152
- var node;
1153
- var hasReplace = typeof options.replace === 'function';
1154
- var replaceElement;
1155
- var props;
1156
- var children;
1157
- var data;
1158
- var trim = options.trim;
1159
-
1160
- for (var i = 0, len = nodes.length; i < len; i++) {
1161
- node = nodes[i];
1162
-
1163
- // replace with custom React element (if present)
1164
- if (hasReplace) {
1165
- replaceElement = options.replace(node);
1166
-
1167
- if (isValidElement(replaceElement)) {
1168
- // set "key" prop for sibling elements
1169
- // https://fb.me/react-warning-keys
1170
- if (len > 1) {
1171
- replaceElement = cloneElement(replaceElement, {
1172
- key: replaceElement.key || i
1173
- });
1174
- }
1175
- result.push(replaceElement);
1176
- continue;
1177
- }
1178
- }
1179
-
1180
- if (node.type === 'text') {
1181
- // if trim option is enabled, skip whitespace text nodes
1182
- if (trim) {
1183
- data = node.data.trim();
1184
- if (data) {
1185
- result.push(node.data);
1186
- }
1187
- } else {
1188
- result.push(node.data);
1189
- }
1190
- continue;
1191
- }
1192
-
1193
- props = node.attribs;
1194
- if (skipAttributesToProps(node)) {
1195
- setStyleProp(props.style, props);
1196
- } else if (props) {
1197
- props = attributesToProps_1(props);
1198
- }
1199
-
1200
- children = null;
1201
-
1202
- switch (node.type) {
1203
- case 'script':
1204
- case 'style':
1205
- // prevent text in <script> or <style> from being escaped
1206
- // https://reactjs.org/docs/dom-elements.html#dangerouslysetinnerhtml
1207
- if (node.children[0]) {
1208
- props.dangerouslySetInnerHTML = {
1209
- __html: node.children[0].data
1210
- };
1211
- }
1212
- break;
1213
-
1214
- case 'tag':
1215
- // setting textarea value in children is an antipattern in React
1216
- // https://reactjs.org/docs/forms.html#the-textarea-tag
1217
- if (node.name === 'textarea' && node.children[0]) {
1218
- props.defaultValue = node.children[0].data;
1219
- } else if (node.children && node.children.length) {
1220
- // continue recursion of creating React elements (if applicable)
1221
- children = domToReact(node.children, options);
1222
- }
1223
- break;
1224
-
1225
- // skip all other cases (e.g., comment)
1226
- default:
1227
- continue;
1228
- }
1229
-
1230
- // set "key" prop for sibling elements
1231
- // https://fb.me/react-warning-keys
1232
- if (len > 1) {
1233
- props.key = i;
1234
- }
1235
-
1236
- result.push(createElement(node.name, props, children));
1237
- }
1238
-
1239
- return result.length === 1 ? result[0] : result;
1240
- }
1241
-
1242
- /**
1243
- * Determines whether DOM element attributes should be transformed to props.
1244
- * Web Components should not have their attributes transformed except for `style`.
1245
- *
1246
- * @param {DomElement} node
1247
- * @return {boolean}
1248
- */
1249
- function skipAttributesToProps(node) {
1250
- return (
1251
- utilities$1.PRESERVE_CUSTOM_ATTRIBUTES &&
1252
- node.type === 'tag' &&
1253
- utilities$1.isCustomComponent(node.name, node.attribs)
1254
- );
1255
- }
1256
-
1257
- var domToReact_1 = domToReact;
1258
-
1259
- /**
1260
- * SVG elements are case-sensitive.
1261
- *
1262
- * @see {@link https://developer.mozilla.org/docs/Web/SVG/Element#SVG_elements_A_to_Z}
1263
- */
1264
- var CASE_SENSITIVE_TAG_NAMES$1 = [
1265
- 'animateMotion',
1266
- 'animateTransform',
1267
- 'clipPath',
1268
- 'feBlend',
1269
- 'feColorMatrix',
1270
- 'feComponentTransfer',
1271
- 'feComposite',
1272
- 'feConvolveMatrix',
1273
- 'feDiffuseLighting',
1274
- 'feDisplacementMap',
1275
- 'feDropShadow',
1276
- 'feFlood',
1277
- 'feFuncA',
1278
- 'feFuncB',
1279
- 'feFuncG',
1280
- 'feFuncR',
1281
- 'feGaussainBlur',
1282
- 'feImage',
1283
- 'feMerge',
1284
- 'feMergeNode',
1285
- 'feMorphology',
1286
- 'feOffset',
1287
- 'fePointLight',
1288
- 'feSpecularLighting',
1289
- 'feSpotLight',
1290
- 'feTile',
1291
- 'feTurbulence',
1292
- 'foreignObject',
1293
- 'linearGradient',
1294
- 'radialGradient',
1295
- 'textPath'
1296
- ];
1297
-
1298
- var constants = {
1299
- CASE_SENSITIVE_TAG_NAMES: CASE_SENSITIVE_TAG_NAMES$1
1300
- };
1301
-
1302
- var node = createCommonjsModule(function (module, exports) {
1303
- var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
1304
- var extendStatics = function (d, b) {
1305
- extendStatics = Object.setPrototypeOf ||
1306
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
1307
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
1308
- return extendStatics(d, b);
1309
- };
1310
- return function (d, b) {
1311
- extendStatics(d, b);
1312
- function __() { this.constructor = d; }
1313
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1314
- };
1315
- })();
1316
- var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
1317
- __assign = Object.assign || function(t) {
1318
- for (var s, i = 1, n = arguments.length; i < n; i++) {
1319
- s = arguments[i];
1320
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1321
- t[p] = s[p];
1322
- }
1323
- return t;
1324
- };
1325
- return __assign.apply(this, arguments);
1326
- };
1327
- Object.defineProperty(exports, "__esModule", { value: true });
1328
- exports.cloneNode = exports.Element = exports.Document = exports.NodeWithChildren = exports.ProcessingInstruction = exports.Comment = exports.Text = exports.DataNode = exports.Node = void 0;
1329
- var nodeTypes = new Map([
1330
- ["tag" /* Tag */, 1],
1331
- ["script" /* Script */, 1],
1332
- ["style" /* Style */, 1],
1333
- ["directive" /* Directive */, 1],
1334
- ["text" /* Text */, 3],
1335
- ["cdata" /* CDATA */, 4],
1336
- ["comment" /* Comment */, 8],
1337
- ["root" /* Root */, 9],
1338
- ]);
1339
- /**
1340
- * This object will be used as the prototype for Nodes when creating a
1341
- * DOM-Level-1-compliant structure.
1342
- */
1343
- var Node = /** @class */ (function () {
1344
- /**
1345
- *
1346
- * @param type The type of the node.
1347
- */
1348
- function Node(type) {
1349
- this.type = type;
1350
- /** Parent of the node */
1351
- this.parent = null;
1352
- /** Previous sibling */
1353
- this.prev = null;
1354
- /** Next sibling */
1355
- this.next = null;
1356
- /** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
1357
- this.startIndex = null;
1358
- /** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
1359
- this.endIndex = null;
1360
- }
1361
- Object.defineProperty(Node.prototype, "nodeType", {
1362
- // Read-only aliases
1363
- get: function () {
1364
- var _a;
1365
- return (_a = nodeTypes.get(this.type)) !== null && _a !== void 0 ? _a : 1;
1366
- },
1367
- enumerable: false,
1368
- configurable: true
1369
- });
1370
- Object.defineProperty(Node.prototype, "parentNode", {
1371
- // Read-write aliases for properties
1372
- get: function () {
1373
- return this.parent;
1374
- },
1375
- set: function (parent) {
1376
- this.parent = parent;
1377
- },
1378
- enumerable: false,
1379
- configurable: true
1380
- });
1381
- Object.defineProperty(Node.prototype, "previousSibling", {
1382
- get: function () {
1383
- return this.prev;
1384
- },
1385
- set: function (prev) {
1386
- this.prev = prev;
1387
- },
1388
- enumerable: false,
1389
- configurable: true
1390
- });
1391
- Object.defineProperty(Node.prototype, "nextSibling", {
1392
- get: function () {
1393
- return this.next;
1394
- },
1395
- set: function (next) {
1396
- this.next = next;
1397
- },
1398
- enumerable: false,
1399
- configurable: true
1400
- });
1401
- /**
1402
- * Clone this node, and optionally its children.
1403
- *
1404
- * @param recursive Clone child nodes as well.
1405
- * @returns A clone of the node.
1406
- */
1407
- Node.prototype.cloneNode = function (recursive) {
1408
- if (recursive === void 0) { recursive = false; }
1409
- return cloneNode(this, recursive);
1410
- };
1411
- return Node;
1412
- }());
1413
- exports.Node = Node;
1414
- var DataNode = /** @class */ (function (_super) {
1415
- __extends(DataNode, _super);
1416
- /**
1417
- * @param type The type of the node
1418
- * @param data The content of the data node
1419
- */
1420
- function DataNode(type, data) {
1421
- var _this = _super.call(this, type) || this;
1422
- _this.data = data;
1423
- return _this;
1424
- }
1425
- Object.defineProperty(DataNode.prototype, "nodeValue", {
1426
- get: function () {
1427
- return this.data;
1428
- },
1429
- set: function (data) {
1430
- this.data = data;
1431
- },
1432
- enumerable: false,
1433
- configurable: true
1434
- });
1435
- return DataNode;
1436
- }(Node));
1437
- exports.DataNode = DataNode;
1438
- var Text = /** @class */ (function (_super) {
1439
- __extends(Text, _super);
1440
- function Text(data) {
1441
- return _super.call(this, "text" /* Text */, data) || this;
1442
- }
1443
- return Text;
1444
- }(DataNode));
1445
- exports.Text = Text;
1446
- var Comment = /** @class */ (function (_super) {
1447
- __extends(Comment, _super);
1448
- function Comment(data) {
1449
- return _super.call(this, "comment" /* Comment */, data) || this;
1450
- }
1451
- return Comment;
1452
- }(DataNode));
1453
- exports.Comment = Comment;
1454
- var ProcessingInstruction = /** @class */ (function (_super) {
1455
- __extends(ProcessingInstruction, _super);
1456
- function ProcessingInstruction(name, data) {
1457
- var _this = _super.call(this, "directive" /* Directive */, data) || this;
1458
- _this.name = name;
1459
- return _this;
1460
- }
1461
- return ProcessingInstruction;
1462
- }(DataNode));
1463
- exports.ProcessingInstruction = ProcessingInstruction;
1464
- /**
1465
- * A `Node` that can have children.
1466
- */
1467
- var NodeWithChildren = /** @class */ (function (_super) {
1468
- __extends(NodeWithChildren, _super);
1469
- /**
1470
- * @param type Type of the node.
1471
- * @param children Children of the node. Only certain node types can have children.
1472
- */
1473
- function NodeWithChildren(type, children) {
1474
- var _this = _super.call(this, type) || this;
1475
- _this.children = children;
1476
- return _this;
1477
- }
1478
- Object.defineProperty(NodeWithChildren.prototype, "firstChild", {
1479
- // Aliases
1480
- get: function () {
1481
- var _a;
1482
- return (_a = this.children[0]) !== null && _a !== void 0 ? _a : null;
1483
- },
1484
- enumerable: false,
1485
- configurable: true
1486
- });
1487
- Object.defineProperty(NodeWithChildren.prototype, "lastChild", {
1488
- get: function () {
1489
- return this.children.length > 0
1490
- ? this.children[this.children.length - 1]
1491
- : null;
1492
- },
1493
- enumerable: false,
1494
- configurable: true
1495
- });
1496
- Object.defineProperty(NodeWithChildren.prototype, "childNodes", {
1497
- get: function () {
1498
- return this.children;
1499
- },
1500
- set: function (children) {
1501
- this.children = children;
1502
- },
1503
- enumerable: false,
1504
- configurable: true
1505
- });
1506
- return NodeWithChildren;
1507
- }(Node));
1508
- exports.NodeWithChildren = NodeWithChildren;
1509
- var Document = /** @class */ (function (_super) {
1510
- __extends(Document, _super);
1511
- function Document(children) {
1512
- return _super.call(this, "root" /* Root */, children) || this;
1513
- }
1514
- return Document;
1515
- }(NodeWithChildren));
1516
- exports.Document = Document;
1517
- var Element = /** @class */ (function (_super) {
1518
- __extends(Element, _super);
1519
- /**
1520
- * @param name Name of the tag, eg. `div`, `span`.
1521
- * @param attribs Object mapping attribute names to attribute values.
1522
- * @param children Children of the node.
1523
- */
1524
- function Element(name, attribs, children) {
1525
- if (children === void 0) { children = []; }
1526
- var _this = _super.call(this, name === "script"
1527
- ? "script" /* Script */
1528
- : name === "style"
1529
- ? "style" /* Style */
1530
- : "tag" /* Tag */, children) || this;
1531
- _this.name = name;
1532
- _this.attribs = attribs;
1533
- _this.attribs = attribs;
1534
- return _this;
1535
- }
1536
- Object.defineProperty(Element.prototype, "tagName", {
1537
- // DOM Level 1 aliases
1538
- get: function () {
1539
- return this.name;
1540
- },
1541
- set: function (name) {
1542
- this.name = name;
1543
- },
1544
- enumerable: false,
1545
- configurable: true
1546
- });
1547
- Object.defineProperty(Element.prototype, "attributes", {
1548
- get: function () {
1549
- var _this = this;
1550
- return Object.keys(this.attribs).map(function (name) {
1551
- var _a, _b;
1552
- return ({
1553
- name: name,
1554
- value: _this.attribs[name],
1555
- namespace: (_a = _this["x-attribsNamespace"]) === null || _a === void 0 ? void 0 : _a[name],
1556
- prefix: (_b = _this["x-attribsPrefix"]) === null || _b === void 0 ? void 0 : _b[name],
1557
- });
1558
- });
1559
- },
1560
- enumerable: false,
1561
- configurable: true
1562
- });
1563
- return Element;
1564
- }(NodeWithChildren));
1565
- exports.Element = Element;
1566
- /**
1567
- * Clone a node, and optionally its children.
1568
- *
1569
- * @param recursive Clone child nodes as well.
1570
- * @returns A clone of the node.
1571
- */
1572
- function cloneNode(node, recursive) {
1573
- if (recursive === void 0) { recursive = false; }
1574
- var result;
1575
- switch (node.type) {
1576
- case "text" /* Text */:
1577
- result = new Text(node.data);
1578
- break;
1579
- case "directive" /* Directive */: {
1580
- var instr = node;
1581
- result = new ProcessingInstruction(instr.name, instr.data);
1582
- if (instr["x-name"] != null) {
1583
- result["x-name"] = instr["x-name"];
1584
- result["x-publicId"] = instr["x-publicId"];
1585
- result["x-systemId"] = instr["x-systemId"];
1586
- }
1587
- break;
1588
- }
1589
- case "comment" /* Comment */:
1590
- result = new Comment(node.data);
1591
- break;
1592
- case "tag" /* Tag */:
1593
- case "script" /* Script */:
1594
- case "style" /* Style */: {
1595
- var elem = node;
1596
- var children = recursive ? cloneChildren(elem.children) : [];
1597
- var clone_1 = new Element(elem.name, __assign({}, elem.attribs), children);
1598
- children.forEach(function (child) { return (child.parent = clone_1); });
1599
- if (elem["x-attribsNamespace"]) {
1600
- clone_1["x-attribsNamespace"] = __assign({}, elem["x-attribsNamespace"]);
1601
- }
1602
- if (elem["x-attribsPrefix"]) {
1603
- clone_1["x-attribsPrefix"] = __assign({}, elem["x-attribsPrefix"]);
1604
- }
1605
- result = clone_1;
1606
- break;
1607
- }
1608
- case "cdata" /* CDATA */: {
1609
- var cdata = node;
1610
- var children = recursive ? cloneChildren(cdata.children) : [];
1611
- var clone_2 = new NodeWithChildren(node.type, children);
1612
- children.forEach(function (child) { return (child.parent = clone_2); });
1613
- result = clone_2;
1614
- break;
1615
- }
1616
- case "root" /* Root */: {
1617
- var doc = node;
1618
- var children = recursive ? cloneChildren(doc.children) : [];
1619
- var clone_3 = new Document(children);
1620
- children.forEach(function (child) { return (child.parent = clone_3); });
1621
- if (doc["x-mode"]) {
1622
- clone_3["x-mode"] = doc["x-mode"];
1623
- }
1624
- result = clone_3;
1625
- break;
1626
- }
1627
- case "doctype" /* Doctype */: {
1628
- // This type isn't used yet.
1629
- throw new Error("Not implemented yet: ElementType.Doctype case");
1630
- }
1631
- }
1632
- result.startIndex = node.startIndex;
1633
- result.endIndex = node.endIndex;
1634
- return result;
1635
- }
1636
- exports.cloneNode = cloneNode;
1637
- function cloneChildren(childs) {
1638
- var children = childs.map(function (child) { return cloneNode(child, true); });
1639
- for (var i = 1; i < children.length; i++) {
1640
- children[i].prev = children[i - 1];
1641
- children[i - 1].next = children[i];
1642
- }
1643
- return children;
1644
- }
1645
- });
1646
-
1647
- var CASE_SENSITIVE_TAG_NAMES = constants.CASE_SENSITIVE_TAG_NAMES;
1648
-
1649
- var Comment = node.Comment;
1650
- var Element = node.Element;
1651
- var ProcessingInstruction = node.ProcessingInstruction;
1652
- var Text = node.Text;
1653
-
1654
- var caseSensitiveTagNamesMap = {};
1655
- var tagName;
1656
-
1657
- for (var i = 0, len = CASE_SENSITIVE_TAG_NAMES.length; i < len; i++) {
1658
- tagName = CASE_SENSITIVE_TAG_NAMES[i];
1659
- caseSensitiveTagNamesMap[tagName.toLowerCase()] = tagName;
1660
- }
1661
-
1662
- /**
1663
- * Gets case-sensitive tag name.
1664
- *
1665
- * @param {string} tagName - Tag name in lowercase.
1666
- * @return {string|undefined} - Case-sensitive tag name.
1667
- */
1668
- function getCaseSensitiveTagName(tagName) {
1669
- return caseSensitiveTagNamesMap[tagName];
1670
- }
1671
-
1672
- /**
1673
- * Formats DOM attributes to a hash map.
1674
- *
1675
- * @param {NamedNodeMap} attributes - List of attributes.
1676
- * @return {object} - Map of attribute name to value.
1677
- */
1678
- function formatAttributes(attributes) {
1679
- var result = {};
1680
- var attribute;
1681
- // `NamedNodeMap` is array-like
1682
- for (var i = 0, len = attributes.length; i < len; i++) {
1683
- attribute = attributes[i];
1684
- result[attribute.name] = attribute.value;
1685
- }
1686
- return result;
1687
- }
1688
-
1689
- /**
1690
- * Corrects the tag name if it is case-sensitive (SVG).
1691
- * Otherwise, returns the lowercase tag name (HTML).
1692
- *
1693
- * @param {string} tagName - Lowercase tag name.
1694
- * @return {string} - Formatted tag name.
1695
- */
1696
- function formatTagName(tagName) {
1697
- tagName = tagName.toLowerCase();
1698
- var caseSensitiveTagName = getCaseSensitiveTagName(tagName);
1699
- if (caseSensitiveTagName) {
1700
- return caseSensitiveTagName;
1701
- }
1702
- return tagName;
1703
- }
1704
-
1705
- /**
1706
- * Transforms DOM nodes to `domhandler` nodes.
1707
- *
1708
- * @param {NodeList} nodes - DOM nodes.
1709
- * @param {Element|null} [parent=null] - Parent node.
1710
- * @param {string} [directive] - Directive.
1711
- * @return {Array<Comment|Element|ProcessingInstruction|Text>}
1712
- */
1713
- function formatDOM$1(nodes, parent, directive) {
1714
- parent = parent || null;
1715
- var result = [];
1716
-
1717
- for (var index = 0, len = nodes.length; index < len; index++) {
1718
- var node = nodes[index];
1719
- var current;
1720
-
1721
- // set the node data given the type
1722
- switch (node.nodeType) {
1723
- case 1:
1724
- // script, style, or tag
1725
- current = new Element(
1726
- formatTagName(node.nodeName),
1727
- formatAttributes(node.attributes)
1728
- );
1729
- current.children = formatDOM$1(node.childNodes, current);
1730
- break;
1731
-
1732
- case 3:
1733
- current = new Text(node.nodeValue);
1734
- break;
1735
-
1736
- case 8:
1737
- current = new Comment(node.nodeValue);
1738
- break;
1739
-
1740
- default:
1741
- continue;
1742
- }
1743
-
1744
- // set previous node next
1745
- var prev = result[index - 1] || null;
1746
- if (prev) {
1747
- prev.next = current;
1748
- }
1749
-
1750
- // set properties for current node
1751
- current.parent = parent;
1752
- current.prev = prev;
1753
- current.next = null;
1754
-
1755
- result.push(current);
1756
- }
1757
-
1758
- if (directive) {
1759
- current = new ProcessingInstruction(
1760
- directive.substring(0, directive.indexOf(' ')).toLowerCase(),
1761
- directive
1762
- );
1763
- current.next = result[0] || null;
1764
- current.parent = parent;
1765
- result.unshift(current);
1766
-
1767
- if (result[1]) {
1768
- result[1].prev = result[0];
1769
- }
1770
- }
1771
-
1772
- return result;
1773
- }
1774
-
1775
- /**
1776
- * Detects if browser is Internet Explorer.
1777
- *
1778
- * @return {boolean} - Whether IE is detected.
1779
- */
1780
- function isIE$1() {
1781
- return /(MSIE |Trident\/|Edge\/)/.test(navigator.userAgent);
1782
- }
1783
-
1784
- var utilities = {
1785
- formatAttributes: formatAttributes,
1786
- formatDOM: formatDOM$1,
1787
- isIE: isIE$1
1788
- };
1789
-
1790
- // constants
1791
- var HTML = 'html';
1792
- var HEAD = 'head';
1793
- var BODY = 'body';
1794
- var FIRST_TAG_REGEX = /<([a-zA-Z]+[0-9]?)/; // e.g., <h1>
1795
- var HEAD_TAG_REGEX = /<head.*>/i;
1796
- var BODY_TAG_REGEX = /<body.*>/i;
1797
-
1798
- // falls back to `parseFromString` if `createHTMLDocument` cannot be used
1799
- var parseFromDocument = function () {
1800
- throw new Error(
1801
- 'This browser does not support `document.implementation.createHTMLDocument`'
1802
- );
1803
- };
1804
-
1805
- var parseFromString = function () {
1806
- throw new Error(
1807
- 'This browser does not support `DOMParser.prototype.parseFromString`'
1808
- );
1809
- };
1810
-
1811
- /**
1812
- * DOMParser (performance: slow).
1813
- *
1814
- * @see https://developer.mozilla.org/docs/Web/API/DOMParser#Parsing_an_SVG_or_HTML_document
1815
- */
1816
- if (typeof window.DOMParser === 'function') {
1817
- var domParser = new window.DOMParser();
1818
- var mimeType = 'text/html';
1819
-
1820
- /**
1821
- * Creates an HTML document using `DOMParser.parseFromString`.
1822
- *
1823
- * @param {string} html - The HTML string.
1824
- * @param {string} [tagName] - The element to render the HTML (with 'body' as fallback).
1825
- * @return {HTMLDocument}
1826
- */
1827
- parseFromString = function (html, tagName) {
1828
- if (tagName) {
1829
- html = '<' + tagName + '>' + html + '</' + tagName + '>';
1830
- }
1831
-
1832
- return domParser.parseFromString(html, mimeType);
1833
- };
1834
-
1835
- parseFromDocument = parseFromString;
1836
- }
1837
-
1838
- /**
1839
- * DOMImplementation (performance: fair).
1840
- *
1841
- * @see https://developer.mozilla.org/docs/Web/API/DOMImplementation/createHTMLDocument
1842
- */
1843
- if (document.implementation) {
1844
- var isIE = utilities.isIE;
1845
-
1846
- // title parameter is required in IE
1847
- // https://msdn.microsoft.com/en-us/library/ff975457(v=vs.85).aspx
1848
- var doc = document.implementation.createHTMLDocument(
1849
- isIE() ? 'html-dom-parser' : undefined
1850
- );
1851
-
1852
- /**
1853
- * Use HTML document created by `document.implementation.createHTMLDocument`.
1854
- *
1855
- * @param {string} html - The HTML string.
1856
- * @param {string} [tagName] - The element to render the HTML (with 'body' as fallback).
1857
- * @return {HTMLDocument}
1858
- */
1859
- parseFromDocument = function (html, tagName) {
1860
- if (tagName) {
1861
- doc.documentElement.getElementsByTagName(tagName)[0].innerHTML = html;
1862
- return doc;
1863
- }
1864
-
1865
- doc.documentElement.innerHTML = html;
1866
- return doc;
1867
- };
1868
- }
1869
-
1870
- /**
1871
- * Template (performance: fast).
1872
- *
1873
- * @see https://developer.mozilla.org/docs/Web/HTML/Element/template
1874
- */
1875
- var template = document.createElement('template');
1876
- var parseFromTemplate;
1877
-
1878
- if (template.content) {
1879
- /**
1880
- * Uses a template element (content fragment) to parse HTML.
1881
- *
1882
- * @param {string} html - The HTML string.
1883
- * @return {NodeList}
1884
- */
1885
- parseFromTemplate = function (html) {
1886
- template.innerHTML = html;
1887
- return template.content.childNodes;
1888
- };
1889
- }
1890
-
1891
- /**
1892
- * Parses HTML string to DOM nodes.
1893
- *
1894
- * @param {string} html - HTML markup.
1895
- * @return {NodeList}
1896
- */
1897
- function domparser(html) {
1898
- var firstTagName;
1899
- var match = html.match(FIRST_TAG_REGEX);
1900
-
1901
- if (match && match[1]) {
1902
- firstTagName = match[1].toLowerCase();
1903
- }
1904
-
1905
- var doc;
1906
- var element;
1907
- var elements;
1908
-
1909
- switch (firstTagName) {
1910
- case HTML:
1911
- doc = parseFromString(html);
1912
-
1913
- // the created document may come with filler head/body elements,
1914
- // so make sure to remove them if they don't actually exist
1915
- if (!HEAD_TAG_REGEX.test(html)) {
1916
- element = doc.getElementsByTagName(HEAD)[0];
1917
- if (element) {
1918
- element.parentNode.removeChild(element);
1919
- }
1920
- }
1921
-
1922
- if (!BODY_TAG_REGEX.test(html)) {
1923
- element = doc.getElementsByTagName(BODY)[0];
1924
- if (element) {
1925
- element.parentNode.removeChild(element);
1926
- }
1927
- }
1928
-
1929
- return doc.getElementsByTagName(HTML);
1930
-
1931
- case HEAD:
1932
- case BODY:
1933
- elements = parseFromDocument(html).getElementsByTagName(firstTagName);
1934
-
1935
- // if there's a sibling element, then return both elements
1936
- if (BODY_TAG_REGEX.test(html) && HEAD_TAG_REGEX.test(html)) {
1937
- return elements[0].parentNode.childNodes;
1938
- }
1939
- return elements;
1940
-
1941
- // low-level tag or text
1942
- default:
1943
- if (parseFromTemplate) {
1944
- return parseFromTemplate(html);
1945
- }
1946
-
1947
- return parseFromDocument(html, BODY).getElementsByTagName(BODY)[0]
1948
- .childNodes;
1949
- }
1950
- }
1951
-
1952
- var domparser_1 = domparser;
1953
-
1954
- var formatDOM = utilities.formatDOM;
1955
-
1956
- var DIRECTIVE_REGEX = /<(![a-zA-Z\s]+)>/; // e.g., <!doctype html>
1957
-
1958
- /**
1959
- * Parses HTML string to DOM nodes in browser.
1960
- *
1961
- * @param {string} html - HTML markup.
1962
- * @return {DomElement[]} - DOM elements.
1963
- */
1964
- function HTMLDOMParser(html) {
1965
- if (typeof html !== 'string') {
1966
- throw new TypeError('First argument must be a string');
1967
- }
1968
-
1969
- if (html === '') {
1970
- return [];
1971
- }
1972
-
1973
- // match directive
1974
- var match = html.match(DIRECTIVE_REGEX);
1975
- var directive;
1976
-
1977
- if (match && match[1]) {
1978
- directive = match[1];
1979
- }
1980
-
1981
- return formatDOM(domparser_1(html), null, directive);
1982
- }
1983
-
1984
- var htmlToDom = HTMLDOMParser;
1985
-
1986
- var domParserOptions = { lowerCaseAttributeNames: false };
1987
-
1988
- /**
1989
- * Converts HTML string to React elements.
1990
- *
1991
- * @param {String} html - HTML string.
1992
- * @param {Object} [options] - Parser options.
1993
- * @param {Object} [options.htmlparser2] - htmlparser2 options.
1994
- * @param {Object} [options.library] - Library for React, Preact, etc.
1995
- * @param {Function} [options.replace] - Replace method.
1996
- * @return {JSX.Element|JSX.Element[]|String} - React element(s), empty array, or string.
1997
- */
1998
- function HTMLReactParser(html, options) {
1999
- if (typeof html !== 'string') {
2000
- throw new TypeError('First argument must be a string');
2001
- }
2002
- if (html === '') {
2003
- return [];
2004
- }
2005
- options = options || {};
2006
- return domToReact_1(
2007
- htmlToDom(html, options.htmlparser2 || domParserOptions),
2008
- options
2009
- );
2010
- }
2011
-
2012
- HTMLReactParser.domToReact = domToReact_1;
2013
- HTMLReactParser.htmlToDOM = htmlToDom;
2014
- HTMLReactParser.attributesToProps = attributesToProps_1;
2015
-
2016
- // support CommonJS and ES Modules
2017
- var htmlReactParser = HTMLReactParser;
2018
- var _default = HTMLReactParser;
2019
- htmlReactParser.default = _default;
2020
-
2021
- return htmlReactParser;
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react')) :
3
+ typeof define === 'function' && define.amd ? define(['react'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.HTMLReactParser = factory(global.React));
5
+ }(this, (function (require$$0) { 'use strict';
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
10
+
11
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
12
+
13
+ var htmlReactParser$1 = {exports: {}};
14
+
15
+ var lib$1 = {};
16
+
17
+ var possibleStandardNamesOptimized$1 = {};
18
+
19
+ // An attribute in which the DOM/SVG standard name is the same as the React prop name (e.g., 'accept').
20
+ var SAME$1 = 0;
21
+ possibleStandardNamesOptimized$1.SAME = SAME$1;
22
+
23
+ // An attribute in which the React prop name is the camelcased version of the DOM/SVG standard name (e.g., 'acceptCharset').
24
+ var CAMELCASE$1 = 1;
25
+ possibleStandardNamesOptimized$1.CAMELCASE = CAMELCASE$1;
26
+
27
+ possibleStandardNamesOptimized$1.possibleStandardNames = {
28
+ accept: 0,
29
+ acceptCharset: 1,
30
+ 'accept-charset': 'acceptCharset',
31
+ accessKey: 1,
32
+ action: 0,
33
+ allowFullScreen: 1,
34
+ alt: 0,
35
+ as: 0,
36
+ async: 0,
37
+ autoCapitalize: 1,
38
+ autoComplete: 1,
39
+ autoCorrect: 1,
40
+ autoFocus: 1,
41
+ autoPlay: 1,
42
+ autoSave: 1,
43
+ capture: 0,
44
+ cellPadding: 1,
45
+ cellSpacing: 1,
46
+ challenge: 0,
47
+ charSet: 1,
48
+ checked: 0,
49
+ children: 0,
50
+ cite: 0,
51
+ class: 'className',
52
+ classID: 1,
53
+ className: 1,
54
+ cols: 0,
55
+ colSpan: 1,
56
+ content: 0,
57
+ contentEditable: 1,
58
+ contextMenu: 1,
59
+ controls: 0,
60
+ controlsList: 1,
61
+ coords: 0,
62
+ crossOrigin: 1,
63
+ dangerouslySetInnerHTML: 1,
64
+ data: 0,
65
+ dateTime: 1,
66
+ default: 0,
67
+ defaultChecked: 1,
68
+ defaultValue: 1,
69
+ defer: 0,
70
+ dir: 0,
71
+ disabled: 0,
72
+ disablePictureInPicture: 1,
73
+ disableRemotePlayback: 1,
74
+ download: 0,
75
+ draggable: 0,
76
+ encType: 1,
77
+ enterKeyHint: 1,
78
+ for: 'htmlFor',
79
+ form: 0,
80
+ formMethod: 1,
81
+ formAction: 1,
82
+ formEncType: 1,
83
+ formNoValidate: 1,
84
+ formTarget: 1,
85
+ frameBorder: 1,
86
+ headers: 0,
87
+ height: 0,
88
+ hidden: 0,
89
+ high: 0,
90
+ href: 0,
91
+ hrefLang: 1,
92
+ htmlFor: 1,
93
+ httpEquiv: 1,
94
+ 'http-equiv': 'httpEquiv',
95
+ icon: 0,
96
+ id: 0,
97
+ innerHTML: 1,
98
+ inputMode: 1,
99
+ integrity: 0,
100
+ is: 0,
101
+ itemID: 1,
102
+ itemProp: 1,
103
+ itemRef: 1,
104
+ itemScope: 1,
105
+ itemType: 1,
106
+ keyParams: 1,
107
+ keyType: 1,
108
+ kind: 0,
109
+ label: 0,
110
+ lang: 0,
111
+ list: 0,
112
+ loop: 0,
113
+ low: 0,
114
+ manifest: 0,
115
+ marginWidth: 1,
116
+ marginHeight: 1,
117
+ max: 0,
118
+ maxLength: 1,
119
+ media: 0,
120
+ mediaGroup: 1,
121
+ method: 0,
122
+ min: 0,
123
+ minLength: 1,
124
+ multiple: 0,
125
+ muted: 0,
126
+ name: 0,
127
+ noModule: 1,
128
+ nonce: 0,
129
+ noValidate: 1,
130
+ open: 0,
131
+ optimum: 0,
132
+ pattern: 0,
133
+ placeholder: 0,
134
+ playsInline: 1,
135
+ poster: 0,
136
+ preload: 0,
137
+ profile: 0,
138
+ radioGroup: 1,
139
+ readOnly: 1,
140
+ referrerPolicy: 1,
141
+ rel: 0,
142
+ required: 0,
143
+ reversed: 0,
144
+ role: 0,
145
+ rows: 0,
146
+ rowSpan: 1,
147
+ sandbox: 0,
148
+ scope: 0,
149
+ scoped: 0,
150
+ scrolling: 0,
151
+ seamless: 0,
152
+ selected: 0,
153
+ shape: 0,
154
+ size: 0,
155
+ sizes: 0,
156
+ span: 0,
157
+ spellCheck: 1,
158
+ src: 0,
159
+ srcDoc: 1,
160
+ srcLang: 1,
161
+ srcSet: 1,
162
+ start: 0,
163
+ step: 0,
164
+ style: 0,
165
+ summary: 0,
166
+ tabIndex: 1,
167
+ target: 0,
168
+ title: 0,
169
+ type: 0,
170
+ useMap: 1,
171
+ value: 0,
172
+ width: 0,
173
+ wmode: 0,
174
+ wrap: 0,
175
+ about: 0,
176
+ accentHeight: 1,
177
+ 'accent-height': 'accentHeight',
178
+ accumulate: 0,
179
+ additive: 0,
180
+ alignmentBaseline: 1,
181
+ 'alignment-baseline': 'alignmentBaseline',
182
+ allowReorder: 1,
183
+ alphabetic: 0,
184
+ amplitude: 0,
185
+ arabicForm: 1,
186
+ 'arabic-form': 'arabicForm',
187
+ ascent: 0,
188
+ attributeName: 1,
189
+ attributeType: 1,
190
+ autoReverse: 1,
191
+ azimuth: 0,
192
+ baseFrequency: 1,
193
+ baselineShift: 1,
194
+ 'baseline-shift': 'baselineShift',
195
+ baseProfile: 1,
196
+ bbox: 0,
197
+ begin: 0,
198
+ bias: 0,
199
+ by: 0,
200
+ calcMode: 1,
201
+ capHeight: 1,
202
+ 'cap-height': 'capHeight',
203
+ clip: 0,
204
+ clipPath: 1,
205
+ 'clip-path': 'clipPath',
206
+ clipPathUnits: 1,
207
+ clipRule: 1,
208
+ 'clip-rule': 'clipRule',
209
+ color: 0,
210
+ colorInterpolation: 1,
211
+ 'color-interpolation': 'colorInterpolation',
212
+ colorInterpolationFilters: 1,
213
+ 'color-interpolation-filters': 'colorInterpolationFilters',
214
+ colorProfile: 1,
215
+ 'color-profile': 'colorProfile',
216
+ colorRendering: 1,
217
+ 'color-rendering': 'colorRendering',
218
+ contentScriptType: 1,
219
+ contentStyleType: 1,
220
+ cursor: 0,
221
+ cx: 0,
222
+ cy: 0,
223
+ d: 0,
224
+ datatype: 0,
225
+ decelerate: 0,
226
+ descent: 0,
227
+ diffuseConstant: 1,
228
+ direction: 0,
229
+ display: 0,
230
+ divisor: 0,
231
+ dominantBaseline: 1,
232
+ 'dominant-baseline': 'dominantBaseline',
233
+ dur: 0,
234
+ dx: 0,
235
+ dy: 0,
236
+ edgeMode: 1,
237
+ elevation: 0,
238
+ enableBackground: 1,
239
+ 'enable-background': 'enableBackground',
240
+ end: 0,
241
+ exponent: 0,
242
+ externalResourcesRequired: 1,
243
+ fill: 0,
244
+ fillOpacity: 1,
245
+ 'fill-opacity': 'fillOpacity',
246
+ fillRule: 1,
247
+ 'fill-rule': 'fillRule',
248
+ filter: 0,
249
+ filterRes: 1,
250
+ filterUnits: 1,
251
+ floodOpacity: 1,
252
+ 'flood-opacity': 'floodOpacity',
253
+ floodColor: 1,
254
+ 'flood-color': 'floodColor',
255
+ focusable: 0,
256
+ fontFamily: 1,
257
+ 'font-family': 'fontFamily',
258
+ fontSize: 1,
259
+ 'font-size': 'fontSize',
260
+ fontSizeAdjust: 1,
261
+ 'font-size-adjust': 'fontSizeAdjust',
262
+ fontStretch: 1,
263
+ 'font-stretch': 'fontStretch',
264
+ fontStyle: 1,
265
+ 'font-style': 'fontStyle',
266
+ fontVariant: 1,
267
+ 'font-variant': 'fontVariant',
268
+ fontWeight: 1,
269
+ 'font-weight': 'fontWeight',
270
+ format: 0,
271
+ from: 0,
272
+ fx: 0,
273
+ fy: 0,
274
+ g1: 0,
275
+ g2: 0,
276
+ glyphName: 1,
277
+ 'glyph-name': 'glyphName',
278
+ glyphOrientationHorizontal: 1,
279
+ 'glyph-orientation-horizontal': 'glyphOrientationHorizontal',
280
+ glyphOrientationVertical: 1,
281
+ 'glyph-orientation-vertical': 'glyphOrientationVertical',
282
+ glyphRef: 1,
283
+ gradientTransform: 1,
284
+ gradientUnits: 1,
285
+ hanging: 0,
286
+ horizAdvX: 1,
287
+ 'horiz-adv-x': 'horizAdvX',
288
+ horizOriginX: 1,
289
+ 'horiz-origin-x': 'horizOriginX',
290
+ ideographic: 0,
291
+ imageRendering: 1,
292
+ 'image-rendering': 'imageRendering',
293
+ in2: 0,
294
+ in: 0,
295
+ inlist: 0,
296
+ intercept: 0,
297
+ k1: 0,
298
+ k2: 0,
299
+ k3: 0,
300
+ k4: 0,
301
+ k: 0,
302
+ kernelMatrix: 1,
303
+ kernelUnitLength: 1,
304
+ kerning: 0,
305
+ keyPoints: 1,
306
+ keySplines: 1,
307
+ keyTimes: 1,
308
+ lengthAdjust: 1,
309
+ letterSpacing: 1,
310
+ 'letter-spacing': 'letterSpacing',
311
+ lightingColor: 1,
312
+ 'lighting-color': 'lightingColor',
313
+ limitingConeAngle: 1,
314
+ local: 0,
315
+ markerEnd: 1,
316
+ 'marker-end': 'markerEnd',
317
+ markerHeight: 1,
318
+ markerMid: 1,
319
+ 'marker-mid': 'markerMid',
320
+ markerStart: 1,
321
+ 'marker-start': 'markerStart',
322
+ markerUnits: 1,
323
+ markerWidth: 1,
324
+ mask: 0,
325
+ maskContentUnits: 1,
326
+ maskUnits: 1,
327
+ mathematical: 0,
328
+ mode: 0,
329
+ numOctaves: 1,
330
+ offset: 0,
331
+ opacity: 0,
332
+ operator: 0,
333
+ order: 0,
334
+ orient: 0,
335
+ orientation: 0,
336
+ origin: 0,
337
+ overflow: 0,
338
+ overlinePosition: 1,
339
+ 'overline-position': 'overlinePosition',
340
+ overlineThickness: 1,
341
+ 'overline-thickness': 'overlineThickness',
342
+ paintOrder: 1,
343
+ 'paint-order': 'paintOrder',
344
+ panose1: 0,
345
+ 'panose-1': 'panose1',
346
+ pathLength: 1,
347
+ patternContentUnits: 1,
348
+ patternTransform: 1,
349
+ patternUnits: 1,
350
+ pointerEvents: 1,
351
+ 'pointer-events': 'pointerEvents',
352
+ points: 0,
353
+ pointsAtX: 1,
354
+ pointsAtY: 1,
355
+ pointsAtZ: 1,
356
+ prefix: 0,
357
+ preserveAlpha: 1,
358
+ preserveAspectRatio: 1,
359
+ primitiveUnits: 1,
360
+ property: 0,
361
+ r: 0,
362
+ radius: 0,
363
+ refX: 1,
364
+ refY: 1,
365
+ renderingIntent: 1,
366
+ 'rendering-intent': 'renderingIntent',
367
+ repeatCount: 1,
368
+ repeatDur: 1,
369
+ requiredExtensions: 1,
370
+ requiredFeatures: 1,
371
+ resource: 0,
372
+ restart: 0,
373
+ result: 0,
374
+ results: 0,
375
+ rotate: 0,
376
+ rx: 0,
377
+ ry: 0,
378
+ scale: 0,
379
+ security: 0,
380
+ seed: 0,
381
+ shapeRendering: 1,
382
+ 'shape-rendering': 'shapeRendering',
383
+ slope: 0,
384
+ spacing: 0,
385
+ specularConstant: 1,
386
+ specularExponent: 1,
387
+ speed: 0,
388
+ spreadMethod: 1,
389
+ startOffset: 1,
390
+ stdDeviation: 1,
391
+ stemh: 0,
392
+ stemv: 0,
393
+ stitchTiles: 1,
394
+ stopColor: 1,
395
+ 'stop-color': 'stopColor',
396
+ stopOpacity: 1,
397
+ 'stop-opacity': 'stopOpacity',
398
+ strikethroughPosition: 1,
399
+ 'strikethrough-position': 'strikethroughPosition',
400
+ strikethroughThickness: 1,
401
+ 'strikethrough-thickness': 'strikethroughThickness',
402
+ string: 0,
403
+ stroke: 0,
404
+ strokeDasharray: 1,
405
+ 'stroke-dasharray': 'strokeDasharray',
406
+ strokeDashoffset: 1,
407
+ 'stroke-dashoffset': 'strokeDashoffset',
408
+ strokeLinecap: 1,
409
+ 'stroke-linecap': 'strokeLinecap',
410
+ strokeLinejoin: 1,
411
+ 'stroke-linejoin': 'strokeLinejoin',
412
+ strokeMiterlimit: 1,
413
+ 'stroke-miterlimit': 'strokeMiterlimit',
414
+ strokeWidth: 1,
415
+ 'stroke-width': 'strokeWidth',
416
+ strokeOpacity: 1,
417
+ 'stroke-opacity': 'strokeOpacity',
418
+ suppressContentEditableWarning: 1,
419
+ suppressHydrationWarning: 1,
420
+ surfaceScale: 1,
421
+ systemLanguage: 1,
422
+ tableValues: 1,
423
+ targetX: 1,
424
+ targetY: 1,
425
+ textAnchor: 1,
426
+ 'text-anchor': 'textAnchor',
427
+ textDecoration: 1,
428
+ 'text-decoration': 'textDecoration',
429
+ textLength: 1,
430
+ textRendering: 1,
431
+ 'text-rendering': 'textRendering',
432
+ to: 0,
433
+ transform: 0,
434
+ typeof: 0,
435
+ u1: 0,
436
+ u2: 0,
437
+ underlinePosition: 1,
438
+ 'underline-position': 'underlinePosition',
439
+ underlineThickness: 1,
440
+ 'underline-thickness': 'underlineThickness',
441
+ unicode: 0,
442
+ unicodeBidi: 1,
443
+ 'unicode-bidi': 'unicodeBidi',
444
+ unicodeRange: 1,
445
+ 'unicode-range': 'unicodeRange',
446
+ unitsPerEm: 1,
447
+ 'units-per-em': 'unitsPerEm',
448
+ unselectable: 0,
449
+ vAlphabetic: 1,
450
+ 'v-alphabetic': 'vAlphabetic',
451
+ values: 0,
452
+ vectorEffect: 1,
453
+ 'vector-effect': 'vectorEffect',
454
+ version: 0,
455
+ vertAdvY: 1,
456
+ 'vert-adv-y': 'vertAdvY',
457
+ vertOriginX: 1,
458
+ 'vert-origin-x': 'vertOriginX',
459
+ vertOriginY: 1,
460
+ 'vert-origin-y': 'vertOriginY',
461
+ vHanging: 1,
462
+ 'v-hanging': 'vHanging',
463
+ vIdeographic: 1,
464
+ 'v-ideographic': 'vIdeographic',
465
+ viewBox: 1,
466
+ viewTarget: 1,
467
+ visibility: 0,
468
+ vMathematical: 1,
469
+ 'v-mathematical': 'vMathematical',
470
+ vocab: 0,
471
+ widths: 0,
472
+ wordSpacing: 1,
473
+ 'word-spacing': 'wordSpacing',
474
+ writingMode: 1,
475
+ 'writing-mode': 'writingMode',
476
+ x1: 0,
477
+ x2: 0,
478
+ x: 0,
479
+ xChannelSelector: 1,
480
+ xHeight: 1,
481
+ 'x-height': 'xHeight',
482
+ xlinkActuate: 1,
483
+ 'xlink:actuate': 'xlinkActuate',
484
+ xlinkArcrole: 1,
485
+ 'xlink:arcrole': 'xlinkArcrole',
486
+ xlinkHref: 1,
487
+ 'xlink:href': 'xlinkHref',
488
+ xlinkRole: 1,
489
+ 'xlink:role': 'xlinkRole',
490
+ xlinkShow: 1,
491
+ 'xlink:show': 'xlinkShow',
492
+ xlinkTitle: 1,
493
+ 'xlink:title': 'xlinkTitle',
494
+ xlinkType: 1,
495
+ 'xlink:type': 'xlinkType',
496
+ xmlBase: 1,
497
+ 'xml:base': 'xmlBase',
498
+ xmlLang: 1,
499
+ 'xml:lang': 'xmlLang',
500
+ xmlns: 0,
501
+ 'xml:space': 'xmlSpace',
502
+ xmlnsXlink: 1,
503
+ 'xmlns:xlink': 'xmlnsXlink',
504
+ xmlSpace: 1,
505
+ y1: 0,
506
+ y2: 0,
507
+ y: 0,
508
+ yChannelSelector: 1,
509
+ z: 0,
510
+ zoomAndPan: 1
511
+ };
512
+
513
+ Object.defineProperty(lib$1, '__esModule', { value: true });
514
+
515
+ function _slicedToArray(arr, i) {
516
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
517
+ }
518
+
519
+ function _arrayWithHoles(arr) {
520
+ if (Array.isArray(arr)) return arr;
521
+ }
522
+
523
+ function _iterableToArrayLimit(arr, i) {
524
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
525
+
526
+ if (_i == null) return;
527
+ var _arr = [];
528
+ var _n = true;
529
+ var _d = false;
530
+
531
+ var _s, _e;
532
+
533
+ try {
534
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
535
+ _arr.push(_s.value);
536
+
537
+ if (i && _arr.length === i) break;
538
+ }
539
+ } catch (err) {
540
+ _d = true;
541
+ _e = err;
542
+ } finally {
543
+ try {
544
+ if (!_n && _i["return"] != null) _i["return"]();
545
+ } finally {
546
+ if (_d) throw _e;
547
+ }
548
+ }
549
+
550
+ return _arr;
551
+ }
552
+
553
+ function _unsupportedIterableToArray(o, minLen) {
554
+ if (!o) return;
555
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
556
+ var n = Object.prototype.toString.call(o).slice(8, -1);
557
+ if (n === "Object" && o.constructor) n = o.constructor.name;
558
+ if (n === "Map" || n === "Set") return Array.from(o);
559
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
560
+ }
561
+
562
+ function _arrayLikeToArray(arr, len) {
563
+ if (len == null || len > arr.length) len = arr.length;
564
+
565
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
566
+
567
+ return arr2;
568
+ }
569
+
570
+ function _nonIterableRest() {
571
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
572
+ }
573
+
574
+ // A reserved attribute.
575
+ // It is handled by React separately and shouldn't be written to the DOM.
576
+ var RESERVED = 0; // A simple string attribute.
577
+ // Attributes that aren't in the filter are presumed to have this type.
578
+
579
+ var STRING = 1; // A string attribute that accepts booleans in React. In HTML, these are called
580
+ // "enumerated" attributes with "true" and "false" as possible values.
581
+ // When true, it should be set to a "true" string.
582
+ // When false, it should be set to a "false" string.
583
+
584
+ var BOOLEANISH_STRING = 2; // A real boolean attribute.
585
+ // When true, it should be present (set either to an empty string or its name).
586
+ // When false, it should be omitted.
587
+
588
+ var BOOLEAN = 3; // An attribute that can be used as a flag as well as with a value.
589
+ // When true, it should be present (set either to an empty string or its name).
590
+ // When false, it should be omitted.
591
+ // For any other value, should be present with that value.
592
+
593
+ var OVERLOADED_BOOLEAN = 4; // An attribute that must be numeric or parse as a numeric.
594
+ // When falsy, it should be removed.
595
+
596
+ var NUMERIC = 5; // An attribute that must be positive numeric or parse as a positive numeric.
597
+ // When falsy, it should be removed.
598
+
599
+ var POSITIVE_NUMERIC = 6;
600
+ function getPropertyInfo(name) {
601
+ return properties.hasOwnProperty(name) ? properties[name] : null;
602
+ }
603
+
604
+ function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL, removeEmptyString) {
605
+ this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN;
606
+ this.attributeName = attributeName;
607
+ this.attributeNamespace = attributeNamespace;
608
+ this.mustUseProperty = mustUseProperty;
609
+ this.propertyName = name;
610
+ this.type = type;
611
+ this.sanitizeURL = sanitizeURL;
612
+ this.removeEmptyString = removeEmptyString;
613
+ } // When adding attributes to this list, be sure to also add them to
614
+ // the `possibleStandardNames` module to ensure casing and incorrect
615
+ // name warnings.
616
+
617
+
618
+ var properties = {}; // These props are reserved by React. They shouldn't be written to the DOM.
619
+
620
+ var reservedProps = ['children', 'dangerouslySetInnerHTML', // TODO: This prevents the assignment of defaultValue to regular
621
+ // elements (not just inputs). Now that ReactDOMInput assigns to the
622
+ // defaultValue property -- do we need this?
623
+ 'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style'];
624
+ reservedProps.forEach(function (name) {
625
+ properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty
626
+ name, // attributeName
627
+ null, // attributeNamespace
628
+ false, // sanitizeURL
629
+ false);
630
+ }); // A few React string attributes have a different name.
631
+ // This is a mapping from React prop names to the attribute names.
632
+
633
+ [['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) {
634
+ var _ref2 = _slicedToArray(_ref, 2),
635
+ name = _ref2[0],
636
+ attributeName = _ref2[1];
637
+
638
+ properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
639
+ attributeName, // attributeName
640
+ null, // attributeNamespace
641
+ false, // sanitizeURL
642
+ false);
643
+ }); // These are "enumerated" HTML attributes that accept "true" and "false".
644
+ // In React, we let users pass `true` and `false` even though technically
645
+ // these aren't boolean attributes (they are coerced to strings).
646
+
647
+ ['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) {
648
+ properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
649
+ name.toLowerCase(), // attributeName
650
+ null, // attributeNamespace
651
+ false, // sanitizeURL
652
+ false);
653
+ }); // These are "enumerated" SVG attributes that accept "true" and "false".
654
+ // In React, we let users pass `true` and `false` even though technically
655
+ // these aren't boolean attributes (they are coerced to strings).
656
+ // Since these are SVG attributes, their attribute names are case-sensitive.
657
+
658
+ ['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) {
659
+ properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
660
+ name, // attributeName
661
+ null, // attributeNamespace
662
+ false, // sanitizeURL
663
+ false);
664
+ }); // These are HTML boolean attributes.
665
+
666
+ ['allowFullScreen', 'async', // Note: there is a special case that prevents it from being written to the DOM
667
+ // on the client side because the browsers are inconsistent. Instead we call focus().
668
+ 'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'disablePictureInPicture', 'disableRemotePlayback', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless', // Microdata
669
+ 'itemScope'].forEach(function (name) {
670
+ properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty
671
+ name.toLowerCase(), // attributeName
672
+ null, // attributeNamespace
673
+ false, // sanitizeURL
674
+ false);
675
+ }); // These are the few React props that we set as DOM properties
676
+ // rather than attributes. These are all booleans.
677
+
678
+ ['checked', // Note: `option.selected` is not updated if `select.multiple` is
679
+ // disabled with `removeAttribute`. We have special logic for handling this.
680
+ 'multiple', 'muted', 'selected' // NOTE: if you add a camelCased prop to this list,
681
+ // you'll need to set attributeName to name.toLowerCase()
682
+ // instead in the assignment below.
683
+ ].forEach(function (name) {
684
+ properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty
685
+ name, // attributeName
686
+ null, // attributeNamespace
687
+ false, // sanitizeURL
688
+ false);
689
+ }); // These are HTML attributes that are "overloaded booleans": they behave like
690
+ // booleans, but can also accept a string value.
691
+
692
+ ['capture', 'download' // NOTE: if you add a camelCased prop to this list,
693
+ // you'll need to set attributeName to name.toLowerCase()
694
+ // instead in the assignment below.
695
+ ].forEach(function (name) {
696
+ properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty
697
+ name, // attributeName
698
+ null, // attributeNamespace
699
+ false, // sanitizeURL
700
+ false);
701
+ }); // These are HTML attributes that must be positive numbers.
702
+
703
+ ['cols', 'rows', 'size', 'span' // NOTE: if you add a camelCased prop to this list,
704
+ // you'll need to set attributeName to name.toLowerCase()
705
+ // instead in the assignment below.
706
+ ].forEach(function (name) {
707
+ properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty
708
+ name, // attributeName
709
+ null, // attributeNamespace
710
+ false, // sanitizeURL
711
+ false);
712
+ }); // These are HTML attributes that must be numbers.
713
+
714
+ ['rowSpan', 'start'].forEach(function (name) {
715
+ properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty
716
+ name.toLowerCase(), // attributeName
717
+ null, // attributeNamespace
718
+ false, // sanitizeURL
719
+ false);
720
+ });
721
+ var CAMELIZE = /[\-\:]([a-z])/g;
722
+
723
+ var capitalize$1 = function capitalize(token) {
724
+ return token[1].toUpperCase();
725
+ }; // This is a list of all SVG attributes that need special casing, namespacing,
726
+ // or boolean value assignment. Regular attributes that just accept strings
727
+ // and have the same names are omitted, just like in the HTML attribute filter.
728
+ // Some of these attributes can be hard to find. This list was created by
729
+ // scraping the MDN documentation.
730
+
731
+
732
+ ['accent-height', 'alignment-baseline', 'arabic-form', 'baseline-shift', 'cap-height', 'clip-path', 'clip-rule', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'dominant-baseline', 'enable-background', 'fill-opacity', 'fill-rule', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-name', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'horiz-adv-x', 'horiz-origin-x', 'image-rendering', 'letter-spacing', 'lighting-color', 'marker-end', 'marker-mid', 'marker-start', 'overline-position', 'overline-thickness', 'paint-order', 'panose-1', 'pointer-events', 'rendering-intent', 'shape-rendering', 'stop-color', 'stop-opacity', 'strikethrough-position', 'strikethrough-thickness', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-decoration', 'text-rendering', 'underline-position', 'underline-thickness', 'unicode-bidi', 'unicode-range', 'units-per-em', 'v-alphabetic', 'v-hanging', 'v-ideographic', 'v-mathematical', 'vector-effect', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'word-spacing', 'writing-mode', 'xmlns:xlink', 'x-height' // NOTE: if you add a camelCased prop to this list,
733
+ // you'll need to set attributeName to name.toLowerCase()
734
+ // instead in the assignment below.
735
+ ].forEach(function (attributeName) {
736
+ var name = attributeName.replace(CAMELIZE, capitalize$1);
737
+ properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
738
+ attributeName, null, // attributeNamespace
739
+ false, // sanitizeURL
740
+ false);
741
+ }); // String SVG attributes with the xlink namespace.
742
+
743
+ ['xlink:actuate', 'xlink:arcrole', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type' // NOTE: if you add a camelCased prop to this list,
744
+ // you'll need to set attributeName to name.toLowerCase()
745
+ // instead in the assignment below.
746
+ ].forEach(function (attributeName) {
747
+ var name = attributeName.replace(CAMELIZE, capitalize$1);
748
+ properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
749
+ attributeName, 'http://www.w3.org/1999/xlink', false, // sanitizeURL
750
+ false);
751
+ }); // String SVG attributes with the xml namespace.
752
+
753
+ ['xml:base', 'xml:lang', 'xml:space' // NOTE: if you add a camelCased prop to this list,
754
+ // you'll need to set attributeName to name.toLowerCase()
755
+ // instead in the assignment below.
756
+ ].forEach(function (attributeName) {
757
+ var name = attributeName.replace(CAMELIZE, capitalize$1);
758
+ properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
759
+ attributeName, 'http://www.w3.org/XML/1998/namespace', false, // sanitizeURL
760
+ false);
761
+ }); // These attribute exists both in HTML and SVG.
762
+ // The attribute name is case-sensitive in SVG so we can't just use
763
+ // the React name like we do for attributes that exist only in HTML.
764
+
765
+ ['tabIndex', 'crossOrigin'].forEach(function (attributeName) {
766
+ properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
767
+ attributeName.toLowerCase(), // attributeName
768
+ null, // attributeNamespace
769
+ false, // sanitizeURL
770
+ false);
771
+ }); // These attributes accept URLs. These must not allow javascript: URLS.
772
+ // These will also need to accept Trusted Types object in the future.
773
+
774
+ var xlinkHref = 'xlinkHref';
775
+ properties[xlinkHref] = new PropertyInfoRecord('xlinkHref', STRING, false, // mustUseProperty
776
+ 'xlink:href', 'http://www.w3.org/1999/xlink', true, // sanitizeURL
777
+ false);
778
+ ['src', 'href', 'action', 'formAction'].forEach(function (attributeName) {
779
+ properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
780
+ attributeName.toLowerCase(), // attributeName
781
+ null, // attributeNamespace
782
+ true, // sanitizeURL
783
+ true);
784
+ });
785
+
786
+ var _require = possibleStandardNamesOptimized$1,
787
+ CAMELCASE = _require.CAMELCASE,
788
+ SAME = _require.SAME,
789
+ possibleStandardNamesOptimized = _require.possibleStandardNames;
790
+
791
+ var ATTRIBUTE_NAME_START_CHAR = ":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
792
+ var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + "\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
793
+ /**
794
+ * Checks whether a property name is a custom attribute.
795
+ *
796
+ * @see {@link https://github.com/facebook/react/blob/15-stable/src/renderers/dom/shared/HTMLDOMPropertyConfig.js#L23-L25}
797
+ *
798
+ * @param {string}
799
+ * @return {boolean}
800
+ */
801
+
802
+ var isCustomAttribute = RegExp.prototype.test.bind( // eslint-disable-next-line no-misleading-character-class
803
+ new RegExp('^(data|aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$'));
804
+ var possibleStandardNames = Object.keys(possibleStandardNamesOptimized).reduce(function (accumulator, standardName) {
805
+ var propName = possibleStandardNamesOptimized[standardName];
806
+
807
+ if (propName === SAME) {
808
+ accumulator[standardName] = standardName;
809
+ } else if (propName === CAMELCASE) {
810
+ accumulator[standardName.toLowerCase()] = standardName;
811
+ } else {
812
+ accumulator[standardName] = propName;
813
+ }
814
+
815
+ return accumulator;
816
+ }, {});
817
+
818
+ lib$1.BOOLEAN = BOOLEAN;
819
+ lib$1.BOOLEANISH_STRING = BOOLEANISH_STRING;
820
+ lib$1.NUMERIC = NUMERIC;
821
+ lib$1.OVERLOADED_BOOLEAN = OVERLOADED_BOOLEAN;
822
+ lib$1.POSITIVE_NUMERIC = POSITIVE_NUMERIC;
823
+ lib$1.RESERVED = RESERVED;
824
+ lib$1.STRING = STRING;
825
+ lib$1.getPropertyInfo = getPropertyInfo;
826
+ lib$1.isCustomAttribute = isCustomAttribute;
827
+ lib$1.possibleStandardNames = possibleStandardNames;
828
+
829
+ var cjs = {};
830
+
831
+ // http://www.w3.org/TR/CSS21/grammar.html
832
+ // https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
833
+ var COMMENT_REGEX = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
834
+
835
+ var NEWLINE_REGEX = /\n/g;
836
+ var WHITESPACE_REGEX = /^\s*/;
837
+
838
+ // declaration
839
+ var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/;
840
+ var COLON_REGEX = /^:\s*/;
841
+ var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/;
842
+ var SEMICOLON_REGEX = /^[;\s]*/;
843
+
844
+ // https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
845
+ var TRIM_REGEX = /^\s+|\s+$/g;
846
+
847
+ // strings
848
+ var NEWLINE = '\n';
849
+ var FORWARD_SLASH = '/';
850
+ var ASTERISK = '*';
851
+ var EMPTY_STRING = '';
852
+
853
+ // types
854
+ var TYPE_COMMENT = 'comment';
855
+ var TYPE_DECLARATION = 'declaration';
856
+
857
+ /**
858
+ * @param {String} style
859
+ * @param {Object} [options]
860
+ * @return {Object[]}
861
+ * @throws {TypeError}
862
+ * @throws {Error}
863
+ */
864
+ var inlineStyleParser = function(style, options) {
865
+ if (typeof style !== 'string') {
866
+ throw new TypeError('First argument must be a string');
867
+ }
868
+
869
+ if (!style) return [];
870
+
871
+ options = options || {};
872
+
873
+ /**
874
+ * Positional.
875
+ */
876
+ var lineno = 1;
877
+ var column = 1;
878
+
879
+ /**
880
+ * Update lineno and column based on `str`.
881
+ *
882
+ * @param {String} str
883
+ */
884
+ function updatePosition(str) {
885
+ var lines = str.match(NEWLINE_REGEX);
886
+ if (lines) lineno += lines.length;
887
+ var i = str.lastIndexOf(NEWLINE);
888
+ column = ~i ? str.length - i : column + str.length;
889
+ }
890
+
891
+ /**
892
+ * Mark position and patch `node.position`.
893
+ *
894
+ * @return {Function}
895
+ */
896
+ function position() {
897
+ var start = { line: lineno, column: column };
898
+ return function(node) {
899
+ node.position = new Position(start);
900
+ whitespace();
901
+ return node;
902
+ };
903
+ }
904
+
905
+ /**
906
+ * Store position information for a node.
907
+ *
908
+ * @constructor
909
+ * @property {Object} start
910
+ * @property {Object} end
911
+ * @property {undefined|String} source
912
+ */
913
+ function Position(start) {
914
+ this.start = start;
915
+ this.end = { line: lineno, column: column };
916
+ this.source = options.source;
917
+ }
918
+
919
+ /**
920
+ * Non-enumerable source string.
921
+ */
922
+ Position.prototype.content = style;
923
+
924
+ /**
925
+ * Error `msg`.
926
+ *
927
+ * @param {String} msg
928
+ * @throws {Error}
929
+ */
930
+ function error(msg) {
931
+ var err = new Error(
932
+ options.source + ':' + lineno + ':' + column + ': ' + msg
933
+ );
934
+ err.reason = msg;
935
+ err.filename = options.source;
936
+ err.line = lineno;
937
+ err.column = column;
938
+ err.source = style;
939
+
940
+ if (options.silent) ; else {
941
+ throw err;
942
+ }
943
+ }
944
+
945
+ /**
946
+ * Match `re` and return captures.
947
+ *
948
+ * @param {RegExp} re
949
+ * @return {undefined|Array}
950
+ */
951
+ function match(re) {
952
+ var m = re.exec(style);
953
+ if (!m) return;
954
+ var str = m[0];
955
+ updatePosition(str);
956
+ style = style.slice(str.length);
957
+ return m;
958
+ }
959
+
960
+ /**
961
+ * Parse whitespace.
962
+ */
963
+ function whitespace() {
964
+ match(WHITESPACE_REGEX);
965
+ }
966
+
967
+ /**
968
+ * Parse comments.
969
+ *
970
+ * @param {Object[]} [rules]
971
+ * @return {Object[]}
972
+ */
973
+ function comments(rules) {
974
+ var c;
975
+ rules = rules || [];
976
+ while ((c = comment())) {
977
+ if (c !== false) {
978
+ rules.push(c);
979
+ }
980
+ }
981
+ return rules;
982
+ }
983
+
984
+ /**
985
+ * Parse comment.
986
+ *
987
+ * @return {Object}
988
+ * @throws {Error}
989
+ */
990
+ function comment() {
991
+ var pos = position();
992
+ if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;
993
+
994
+ var i = 2;
995
+ while (
996
+ EMPTY_STRING != style.charAt(i) &&
997
+ (ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))
998
+ ) {
999
+ ++i;
1000
+ }
1001
+ i += 2;
1002
+
1003
+ if (EMPTY_STRING === style.charAt(i - 1)) {
1004
+ return error('End of comment missing');
1005
+ }
1006
+
1007
+ var str = style.slice(2, i - 2);
1008
+ column += 2;
1009
+ updatePosition(str);
1010
+ style = style.slice(i);
1011
+ column += 2;
1012
+
1013
+ return pos({
1014
+ type: TYPE_COMMENT,
1015
+ comment: str
1016
+ });
1017
+ }
1018
+
1019
+ /**
1020
+ * Parse declaration.
1021
+ *
1022
+ * @return {Object}
1023
+ * @throws {Error}
1024
+ */
1025
+ function declaration() {
1026
+ var pos = position();
1027
+
1028
+ // prop
1029
+ var prop = match(PROPERTY_REGEX);
1030
+ if (!prop) return;
1031
+ comment();
1032
+
1033
+ // :
1034
+ if (!match(COLON_REGEX)) return error("property missing ':'");
1035
+
1036
+ // val
1037
+ var val = match(VALUE_REGEX);
1038
+
1039
+ var ret = pos({
1040
+ type: TYPE_DECLARATION,
1041
+ property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),
1042
+ value: val
1043
+ ? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING))
1044
+ : EMPTY_STRING
1045
+ });
1046
+
1047
+ // ;
1048
+ match(SEMICOLON_REGEX);
1049
+
1050
+ return ret;
1051
+ }
1052
+
1053
+ /**
1054
+ * Parse declarations.
1055
+ *
1056
+ * @return {Object[]}
1057
+ */
1058
+ function declarations() {
1059
+ var decls = [];
1060
+
1061
+ comments(decls);
1062
+
1063
+ // declarations
1064
+ var decl;
1065
+ while ((decl = declaration())) {
1066
+ if (decl !== false) {
1067
+ decls.push(decl);
1068
+ comments(decls);
1069
+ }
1070
+ }
1071
+
1072
+ return decls;
1073
+ }
1074
+
1075
+ whitespace();
1076
+ return declarations();
1077
+ };
1078
+
1079
+ /**
1080
+ * Trim `str`.
1081
+ *
1082
+ * @param {String} str
1083
+ * @return {String}
1084
+ */
1085
+ function trim(str) {
1086
+ return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;
1087
+ }
1088
+
1089
+ var parse = inlineStyleParser;
1090
+
1091
+ /**
1092
+ * Parses inline style to object.
1093
+ *
1094
+ * @example
1095
+ * // returns { 'line-height': '42' }
1096
+ * StyleToObject('line-height: 42;');
1097
+ *
1098
+ * @param {String} style - The inline style.
1099
+ * @param {Function} [iterator] - The iterator function.
1100
+ * @return {null|Object}
1101
+ */
1102
+ function StyleToObject(style, iterator) {
1103
+ var output = null;
1104
+ if (!style || typeof style !== 'string') {
1105
+ return output;
1106
+ }
1107
+
1108
+ var declaration;
1109
+ var declarations = parse(style);
1110
+ var hasIterator = typeof iterator === 'function';
1111
+ var property;
1112
+ var value;
1113
+
1114
+ for (var i = 0, len = declarations.length; i < len; i++) {
1115
+ declaration = declarations[i];
1116
+ property = declaration.property;
1117
+ value = declaration.value;
1118
+
1119
+ if (hasIterator) {
1120
+ iterator(property, value, declaration);
1121
+ } else if (value) {
1122
+ output || (output = {});
1123
+ output[property] = value;
1124
+ }
1125
+ }
1126
+
1127
+ return output;
1128
+ }
1129
+
1130
+ var styleToObject = StyleToObject;
1131
+
1132
+ var utilities$4 = {};
1133
+
1134
+ utilities$4.__esModule = true;
1135
+ utilities$4.camelCase = void 0;
1136
+ var CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9-]+$/;
1137
+ var HYPHEN_REGEX = /-([a-z])/g;
1138
+ var NO_HYPHEN_REGEX = /^[^-]+$/;
1139
+ var VENDOR_PREFIX_REGEX = /^-(webkit|moz|ms|o|khtml)-/;
1140
+ var skipCamelCase = function (property) {
1141
+ return !property ||
1142
+ NO_HYPHEN_REGEX.test(property) ||
1143
+ CUSTOM_PROPERTY_REGEX.test(property);
1144
+ };
1145
+ var capitalize = function (match, character) {
1146
+ return character.toUpperCase();
1147
+ };
1148
+ var trimHyphen = function (match, prefix) { return prefix + "-"; };
1149
+ var camelCase = function (property, options) {
1150
+ if (options === void 0) { options = {}; }
1151
+ if (skipCamelCase(property)) {
1152
+ return property;
1153
+ }
1154
+ property = property.toLowerCase();
1155
+ if (!options.reactCompat) {
1156
+ property = property.replace(VENDOR_PREFIX_REGEX, trimHyphen);
1157
+ }
1158
+ return property.replace(HYPHEN_REGEX, capitalize);
1159
+ };
1160
+ utilities$4.camelCase = camelCase;
1161
+
1162
+ (function (exports) {
1163
+ var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
1164
+ return (mod && mod.__esModule) ? mod : { "default": mod };
1165
+ };
1166
+ exports.__esModule = true;
1167
+ var style_to_object_1 = __importDefault(styleToObject);
1168
+ var utilities_1 = utilities$4;
1169
+ function StyleToJS(style, options) {
1170
+ var output = {};
1171
+ if (!style || typeof style !== 'string') {
1172
+ return output;
1173
+ }
1174
+ style_to_object_1["default"](style, function (property, value) {
1175
+ if (property && value) {
1176
+ output[utilities_1.camelCase(property, options)] = value;
1177
+ }
1178
+ });
1179
+ return output;
1180
+ }
1181
+ exports["default"] = StyleToJS;
1182
+ }(cjs));
1183
+
1184
+ var React$1 = require$$0__default['default'];
1185
+ var styleToJS = cjs.default;
1186
+
1187
+ /**
1188
+ * Swap key with value in an object.
1189
+ *
1190
+ * @param {Object} obj - The object.
1191
+ * @param {Function} [override] - The override method.
1192
+ * @return {Object} - The inverted object.
1193
+ */
1194
+ function invertObject(obj, override) {
1195
+ if (!obj || typeof obj !== 'object') {
1196
+ throw new TypeError('First argument must be an object');
1197
+ }
1198
+
1199
+ var key;
1200
+ var value;
1201
+ var isOverridePresent = typeof override === 'function';
1202
+ var overrides = {};
1203
+ var result = {};
1204
+
1205
+ for (key in obj) {
1206
+ value = obj[key];
1207
+
1208
+ if (isOverridePresent) {
1209
+ overrides = override(key, value);
1210
+ if (overrides && overrides.length === 2) {
1211
+ result[overrides[0]] = overrides[1];
1212
+ continue;
1213
+ }
1214
+ }
1215
+
1216
+ if (typeof value === 'string') {
1217
+ result[value] = key;
1218
+ }
1219
+ }
1220
+
1221
+ return result;
1222
+ }
1223
+
1224
+ /**
1225
+ * Check if a given tag is a custom component.
1226
+ *
1227
+ * @see {@link https://github.com/facebook/react/blob/v16.6.3/packages/react-dom/src/shared/isCustomComponent.js}
1228
+ *
1229
+ * @param {string} tagName - The name of the html tag.
1230
+ * @param {Object} props - The props being passed to the element.
1231
+ * @return {boolean}
1232
+ */
1233
+ function isCustomComponent(tagName, props) {
1234
+ if (tagName.indexOf('-') === -1) {
1235
+ return props && typeof props.is === 'string';
1236
+ }
1237
+
1238
+ switch (tagName) {
1239
+ // These are reserved SVG and MathML elements.
1240
+ // We don't mind this whitelist too much because we expect it to never grow.
1241
+ // The alternative is to track the namespace in a few places which is convoluted.
1242
+ // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
1243
+ case 'annotation-xml':
1244
+ case 'color-profile':
1245
+ case 'font-face':
1246
+ case 'font-face-src':
1247
+ case 'font-face-uri':
1248
+ case 'font-face-format':
1249
+ case 'font-face-name':
1250
+ case 'missing-glyph':
1251
+ return false;
1252
+ default:
1253
+ return true;
1254
+ }
1255
+ }
1256
+
1257
+ var styleToJSOptions = { reactCompat: true };
1258
+
1259
+ /**
1260
+ * Sets style prop.
1261
+ *
1262
+ * @param {null|undefined|string} style
1263
+ * @param {object} props
1264
+ */
1265
+ function setStyleProp$1(style, props) {
1266
+ if (style === null || style === undefined) {
1267
+ return;
1268
+ }
1269
+ try {
1270
+ props.style = styleToJS(style, styleToJSOptions);
1271
+ } catch (err) {
1272
+ props.style = {};
1273
+ }
1274
+ }
1275
+
1276
+ /**
1277
+ * @constant {boolean}
1278
+ * @see {@link https://reactjs.org/blog/2017/09/08/dom-attributes-in-react-16.html}
1279
+ */
1280
+ var PRESERVE_CUSTOM_ATTRIBUTES = React$1.version.split('.')[0] >= 16;
1281
+
1282
+ var utilities$3 = {
1283
+ PRESERVE_CUSTOM_ATTRIBUTES: PRESERVE_CUSTOM_ATTRIBUTES,
1284
+ invertObject: invertObject,
1285
+ isCustomComponent: isCustomComponent,
1286
+ setStyleProp: setStyleProp$1
1287
+ };
1288
+
1289
+ var reactProperty = lib$1;
1290
+ var utilities$2 = utilities$3;
1291
+
1292
+ /**
1293
+ * Converts HTML/SVG DOM attributes to React props.
1294
+ *
1295
+ * @param {object} [attributes={}] - HTML/SVG DOM attributes.
1296
+ * @return {object} - React props.
1297
+ */
1298
+ var attributesToProps$2 = function attributesToProps(attributes) {
1299
+ attributes = attributes || {};
1300
+
1301
+ var attributeName;
1302
+ var attributeNameLowerCased;
1303
+ var attributeValue;
1304
+ var propName;
1305
+ var propertyInfo;
1306
+ var props = {};
1307
+
1308
+ for (attributeName in attributes) {
1309
+ attributeValue = attributes[attributeName];
1310
+
1311
+ // ARIA (aria-*) or custom data (data-*) attribute
1312
+ if (reactProperty.isCustomAttribute(attributeName)) {
1313
+ props[attributeName] = attributeValue;
1314
+ continue;
1315
+ }
1316
+
1317
+ // convert HTML/SVG attribute to React prop
1318
+ attributeNameLowerCased = attributeName.toLowerCase();
1319
+ propName = reactProperty.possibleStandardNames[attributeNameLowerCased];
1320
+
1321
+ if (propName) {
1322
+ props[propName] = attributeValue;
1323
+ propertyInfo = reactProperty.getPropertyInfo(propName);
1324
+ switch (propertyInfo && propertyInfo.type) {
1325
+ case reactProperty.BOOLEAN:
1326
+ props[propName] = true;
1327
+ break;
1328
+ case reactProperty.OVERLOADED_BOOLEAN:
1329
+ if (attributeValue === '') {
1330
+ props[propName] = true;
1331
+ }
1332
+ break;
1333
+ }
1334
+ continue;
1335
+ }
1336
+
1337
+ // preserve custom attribute if React >=16
1338
+ if (utilities$2.PRESERVE_CUSTOM_ATTRIBUTES) {
1339
+ props[attributeName] = attributeValue;
1340
+ }
1341
+ }
1342
+
1343
+ // transform inline style to object
1344
+ utilities$2.setStyleProp(attributes.style, props);
1345
+
1346
+ return props;
1347
+ };
1348
+
1349
+ var React = require$$0__default['default'];
1350
+ var attributesToProps$1 = attributesToProps$2;
1351
+ var utilities$1 = utilities$3;
1352
+
1353
+ var setStyleProp = utilities$1.setStyleProp;
1354
+
1355
+ /**
1356
+ * Converts DOM nodes to JSX element(s).
1357
+ *
1358
+ * @param {DomElement[]} nodes - DOM nodes.
1359
+ * @param {object} [options={}] - Options.
1360
+ * @param {Function} [options.replace] - Replacer.
1361
+ * @param {object} [options.library] - Library (React/Preact/etc.).
1362
+ * @return {string|JSX.Element|JSX.Element[]}
1363
+ */
1364
+ function domToReact$1(nodes, options) {
1365
+ options = options || {};
1366
+
1367
+ var library = options.library || React;
1368
+ var cloneElement = library.cloneElement;
1369
+ var createElement = library.createElement;
1370
+ var isValidElement = library.isValidElement;
1371
+
1372
+ var result = [];
1373
+ var node;
1374
+ var hasReplace = typeof options.replace === 'function';
1375
+ var replaceElement;
1376
+ var props;
1377
+ var children;
1378
+ var data;
1379
+ var trim = options.trim;
1380
+
1381
+ for (var i = 0, len = nodes.length; i < len; i++) {
1382
+ node = nodes[i];
1383
+
1384
+ // replace with custom React element (if present)
1385
+ if (hasReplace) {
1386
+ replaceElement = options.replace(node);
1387
+
1388
+ if (isValidElement(replaceElement)) {
1389
+ // set "key" prop for sibling elements
1390
+ // https://fb.me/react-warning-keys
1391
+ if (len > 1) {
1392
+ replaceElement = cloneElement(replaceElement, {
1393
+ key: replaceElement.key || i
1394
+ });
1395
+ }
1396
+ result.push(replaceElement);
1397
+ continue;
1398
+ }
1399
+ }
1400
+
1401
+ if (node.type === 'text') {
1402
+ // if trim option is enabled, skip whitespace text nodes
1403
+ if (trim) {
1404
+ data = node.data.trim();
1405
+ if (data) {
1406
+ result.push(node.data);
1407
+ }
1408
+ } else {
1409
+ result.push(node.data);
1410
+ }
1411
+ continue;
1412
+ }
1413
+
1414
+ props = node.attribs;
1415
+ if (skipAttributesToProps(node)) {
1416
+ setStyleProp(props.style, props);
1417
+ } else if (props) {
1418
+ props = attributesToProps$1(props);
1419
+ }
1420
+
1421
+ children = null;
1422
+
1423
+ switch (node.type) {
1424
+ case 'script':
1425
+ case 'style':
1426
+ // prevent text in <script> or <style> from being escaped
1427
+ // https://reactjs.org/docs/dom-elements.html#dangerouslysetinnerhtml
1428
+ if (node.children[0]) {
1429
+ props.dangerouslySetInnerHTML = {
1430
+ __html: node.children[0].data
1431
+ };
1432
+ }
1433
+ break;
1434
+
1435
+ case 'tag':
1436
+ // setting textarea value in children is an antipattern in React
1437
+ // https://reactjs.org/docs/forms.html#the-textarea-tag
1438
+ if (node.name === 'textarea' && node.children[0]) {
1439
+ props.defaultValue = node.children[0].data;
1440
+ } else if (node.children && node.children.length) {
1441
+ // continue recursion of creating React elements (if applicable)
1442
+ children = domToReact$1(node.children, options);
1443
+ }
1444
+ break;
1445
+
1446
+ // skip all other cases (e.g., comment)
1447
+ default:
1448
+ continue;
1449
+ }
1450
+
1451
+ // set "key" prop for sibling elements
1452
+ // https://fb.me/react-warning-keys
1453
+ if (len > 1) {
1454
+ props.key = i;
1455
+ }
1456
+
1457
+ result.push(createElement(node.name, props, children));
1458
+ }
1459
+
1460
+ return result.length === 1 ? result[0] : result;
1461
+ }
1462
+
1463
+ /**
1464
+ * Determines whether DOM element attributes should be transformed to props.
1465
+ * Web Components should not have their attributes transformed except for `style`.
1466
+ *
1467
+ * @param {DomElement} node
1468
+ * @return {boolean}
1469
+ */
1470
+ function skipAttributesToProps(node) {
1471
+ return (
1472
+ utilities$1.PRESERVE_CUSTOM_ATTRIBUTES &&
1473
+ node.type === 'tag' &&
1474
+ utilities$1.isCustomComponent(node.name, node.attribs)
1475
+ );
1476
+ }
1477
+
1478
+ var domToReact_1 = domToReact$1;
1479
+
1480
+ /**
1481
+ * SVG elements are case-sensitive.
1482
+ *
1483
+ * @see {@link https://developer.mozilla.org/docs/Web/SVG/Element#SVG_elements_A_to_Z}
1484
+ */
1485
+
1486
+ var CASE_SENSITIVE_TAG_NAMES$1 = [
1487
+ 'animateMotion',
1488
+ 'animateTransform',
1489
+ 'clipPath',
1490
+ 'feBlend',
1491
+ 'feColorMatrix',
1492
+ 'feComponentTransfer',
1493
+ 'feComposite',
1494
+ 'feConvolveMatrix',
1495
+ 'feDiffuseLighting',
1496
+ 'feDisplacementMap',
1497
+ 'feDropShadow',
1498
+ 'feFlood',
1499
+ 'feFuncA',
1500
+ 'feFuncB',
1501
+ 'feFuncG',
1502
+ 'feFuncR',
1503
+ 'feGaussainBlur',
1504
+ 'feImage',
1505
+ 'feMerge',
1506
+ 'feMergeNode',
1507
+ 'feMorphology',
1508
+ 'feOffset',
1509
+ 'fePointLight',
1510
+ 'feSpecularLighting',
1511
+ 'feSpotLight',
1512
+ 'feTile',
1513
+ 'feTurbulence',
1514
+ 'foreignObject',
1515
+ 'linearGradient',
1516
+ 'radialGradient',
1517
+ 'textPath'
1518
+ ];
1519
+
1520
+ var constants$1 = {
1521
+ CASE_SENSITIVE_TAG_NAMES: CASE_SENSITIVE_TAG_NAMES$1
1522
+ };
1523
+
1524
+ var node = {};
1525
+
1526
+ var lib = {};
1527
+
1528
+ (function (exports) {
1529
+ Object.defineProperty(exports, "__esModule", { value: true });
1530
+ exports.Doctype = exports.CDATA = exports.Tag = exports.Style = exports.Script = exports.Comment = exports.Directive = exports.Text = exports.Root = exports.isTag = exports.ElementType = void 0;
1531
+ /** Types of elements found in htmlparser2's DOM */
1532
+ var ElementType;
1533
+ (function (ElementType) {
1534
+ /** Type for the root element of a document */
1535
+ ElementType["Root"] = "root";
1536
+ /** Type for Text */
1537
+ ElementType["Text"] = "text";
1538
+ /** Type for <? ... ?> */
1539
+ ElementType["Directive"] = "directive";
1540
+ /** Type for <!-- ... --> */
1541
+ ElementType["Comment"] = "comment";
1542
+ /** Type for <script> tags */
1543
+ ElementType["Script"] = "script";
1544
+ /** Type for <style> tags */
1545
+ ElementType["Style"] = "style";
1546
+ /** Type for Any tag */
1547
+ ElementType["Tag"] = "tag";
1548
+ /** Type for <![CDATA[ ... ]]> */
1549
+ ElementType["CDATA"] = "cdata";
1550
+ /** Type for <!doctype ...> */
1551
+ ElementType["Doctype"] = "doctype";
1552
+ })(ElementType = exports.ElementType || (exports.ElementType = {}));
1553
+ /**
1554
+ * Tests whether an element is a tag or not.
1555
+ *
1556
+ * @param elem Element to test
1557
+ */
1558
+ function isTag(elem) {
1559
+ return (elem.type === ElementType.Tag ||
1560
+ elem.type === ElementType.Script ||
1561
+ elem.type === ElementType.Style);
1562
+ }
1563
+ exports.isTag = isTag;
1564
+ // Exports for backwards compatibility
1565
+ /** Type for the root element of a document */
1566
+ exports.Root = ElementType.Root;
1567
+ /** Type for Text */
1568
+ exports.Text = ElementType.Text;
1569
+ /** Type for <? ... ?> */
1570
+ exports.Directive = ElementType.Directive;
1571
+ /** Type for <!-- ... --> */
1572
+ exports.Comment = ElementType.Comment;
1573
+ /** Type for <script> tags */
1574
+ exports.Script = ElementType.Script;
1575
+ /** Type for <style> tags */
1576
+ exports.Style = ElementType.Style;
1577
+ /** Type for Any tag */
1578
+ exports.Tag = ElementType.Tag;
1579
+ /** Type for <![CDATA[ ... ]]> */
1580
+ exports.CDATA = ElementType.CDATA;
1581
+ /** Type for <!doctype ...> */
1582
+ exports.Doctype = ElementType.Doctype;
1583
+ }(lib));
1584
+
1585
+ var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
1586
+ var extendStatics = function (d, b) {
1587
+ extendStatics = Object.setPrototypeOf ||
1588
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
1589
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
1590
+ return extendStatics(d, b);
1591
+ };
1592
+ return function (d, b) {
1593
+ if (typeof b !== "function" && b !== null)
1594
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1595
+ extendStatics(d, b);
1596
+ function __() { this.constructor = d; }
1597
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1598
+ };
1599
+ })();
1600
+ var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
1601
+ __assign = Object.assign || function(t) {
1602
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
1603
+ s = arguments[i];
1604
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1605
+ t[p] = s[p];
1606
+ }
1607
+ return t;
1608
+ };
1609
+ return __assign.apply(this, arguments);
1610
+ };
1611
+ Object.defineProperty(node, "__esModule", { value: true });
1612
+ node.cloneNode = node.hasChildren = node.isDocument = node.isDirective = node.isComment = node.isText = node.isCDATA = node.isTag = node.Element = node.Document = node.NodeWithChildren = node.ProcessingInstruction = node.Comment = node.Text = node.DataNode = node.Node = void 0;
1613
+ var domelementtype_1 = lib;
1614
+ var nodeTypes = new Map([
1615
+ [domelementtype_1.ElementType.Tag, 1],
1616
+ [domelementtype_1.ElementType.Script, 1],
1617
+ [domelementtype_1.ElementType.Style, 1],
1618
+ [domelementtype_1.ElementType.Directive, 1],
1619
+ [domelementtype_1.ElementType.Text, 3],
1620
+ [domelementtype_1.ElementType.CDATA, 4],
1621
+ [domelementtype_1.ElementType.Comment, 8],
1622
+ [domelementtype_1.ElementType.Root, 9],
1623
+ ]);
1624
+ /**
1625
+ * This object will be used as the prototype for Nodes when creating a
1626
+ * DOM-Level-1-compliant structure.
1627
+ */
1628
+ var Node = /** @class */ (function () {
1629
+ /**
1630
+ *
1631
+ * @param type The type of the node.
1632
+ */
1633
+ function Node(type) {
1634
+ this.type = type;
1635
+ /** Parent of the node */
1636
+ this.parent = null;
1637
+ /** Previous sibling */
1638
+ this.prev = null;
1639
+ /** Next sibling */
1640
+ this.next = null;
1641
+ /** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
1642
+ this.startIndex = null;
1643
+ /** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
1644
+ this.endIndex = null;
1645
+ }
1646
+ Object.defineProperty(Node.prototype, "nodeType", {
1647
+ // Read-only aliases
1648
+ get: function () {
1649
+ var _a;
1650
+ return (_a = nodeTypes.get(this.type)) !== null && _a !== void 0 ? _a : 1;
1651
+ },
1652
+ enumerable: false,
1653
+ configurable: true
1654
+ });
1655
+ Object.defineProperty(Node.prototype, "parentNode", {
1656
+ // Read-write aliases for properties
1657
+ get: function () {
1658
+ return this.parent;
1659
+ },
1660
+ set: function (parent) {
1661
+ this.parent = parent;
1662
+ },
1663
+ enumerable: false,
1664
+ configurable: true
1665
+ });
1666
+ Object.defineProperty(Node.prototype, "previousSibling", {
1667
+ get: function () {
1668
+ return this.prev;
1669
+ },
1670
+ set: function (prev) {
1671
+ this.prev = prev;
1672
+ },
1673
+ enumerable: false,
1674
+ configurable: true
1675
+ });
1676
+ Object.defineProperty(Node.prototype, "nextSibling", {
1677
+ get: function () {
1678
+ return this.next;
1679
+ },
1680
+ set: function (next) {
1681
+ this.next = next;
1682
+ },
1683
+ enumerable: false,
1684
+ configurable: true
1685
+ });
1686
+ /**
1687
+ * Clone this node, and optionally its children.
1688
+ *
1689
+ * @param recursive Clone child nodes as well.
1690
+ * @returns A clone of the node.
1691
+ */
1692
+ Node.prototype.cloneNode = function (recursive) {
1693
+ if (recursive === void 0) { recursive = false; }
1694
+ return cloneNode(this, recursive);
1695
+ };
1696
+ return Node;
1697
+ }());
1698
+ node.Node = Node;
1699
+ /**
1700
+ * A node that contains some data.
1701
+ */
1702
+ var DataNode = /** @class */ (function (_super) {
1703
+ __extends(DataNode, _super);
1704
+ /**
1705
+ * @param type The type of the node
1706
+ * @param data The content of the data node
1707
+ */
1708
+ function DataNode(type, data) {
1709
+ var _this = _super.call(this, type) || this;
1710
+ _this.data = data;
1711
+ return _this;
1712
+ }
1713
+ Object.defineProperty(DataNode.prototype, "nodeValue", {
1714
+ get: function () {
1715
+ return this.data;
1716
+ },
1717
+ set: function (data) {
1718
+ this.data = data;
1719
+ },
1720
+ enumerable: false,
1721
+ configurable: true
1722
+ });
1723
+ return DataNode;
1724
+ }(Node));
1725
+ node.DataNode = DataNode;
1726
+ /**
1727
+ * Text within the document.
1728
+ */
1729
+ var Text$1 = /** @class */ (function (_super) {
1730
+ __extends(Text, _super);
1731
+ function Text(data) {
1732
+ return _super.call(this, domelementtype_1.ElementType.Text, data) || this;
1733
+ }
1734
+ return Text;
1735
+ }(DataNode));
1736
+ node.Text = Text$1;
1737
+ /**
1738
+ * Comments within the document.
1739
+ */
1740
+ var Comment$1 = /** @class */ (function (_super) {
1741
+ __extends(Comment, _super);
1742
+ function Comment(data) {
1743
+ return _super.call(this, domelementtype_1.ElementType.Comment, data) || this;
1744
+ }
1745
+ return Comment;
1746
+ }(DataNode));
1747
+ node.Comment = Comment$1;
1748
+ /**
1749
+ * Processing instructions, including doc types.
1750
+ */
1751
+ var ProcessingInstruction$1 = /** @class */ (function (_super) {
1752
+ __extends(ProcessingInstruction, _super);
1753
+ function ProcessingInstruction(name, data) {
1754
+ var _this = _super.call(this, domelementtype_1.ElementType.Directive, data) || this;
1755
+ _this.name = name;
1756
+ return _this;
1757
+ }
1758
+ return ProcessingInstruction;
1759
+ }(DataNode));
1760
+ node.ProcessingInstruction = ProcessingInstruction$1;
1761
+ /**
1762
+ * A `Node` that can have children.
1763
+ */
1764
+ var NodeWithChildren = /** @class */ (function (_super) {
1765
+ __extends(NodeWithChildren, _super);
1766
+ /**
1767
+ * @param type Type of the node.
1768
+ * @param children Children of the node. Only certain node types can have children.
1769
+ */
1770
+ function NodeWithChildren(type, children) {
1771
+ var _this = _super.call(this, type) || this;
1772
+ _this.children = children;
1773
+ return _this;
1774
+ }
1775
+ Object.defineProperty(NodeWithChildren.prototype, "firstChild", {
1776
+ // Aliases
1777
+ get: function () {
1778
+ var _a;
1779
+ return (_a = this.children[0]) !== null && _a !== void 0 ? _a : null;
1780
+ },
1781
+ enumerable: false,
1782
+ configurable: true
1783
+ });
1784
+ Object.defineProperty(NodeWithChildren.prototype, "lastChild", {
1785
+ get: function () {
1786
+ return this.children.length > 0
1787
+ ? this.children[this.children.length - 1]
1788
+ : null;
1789
+ },
1790
+ enumerable: false,
1791
+ configurable: true
1792
+ });
1793
+ Object.defineProperty(NodeWithChildren.prototype, "childNodes", {
1794
+ get: function () {
1795
+ return this.children;
1796
+ },
1797
+ set: function (children) {
1798
+ this.children = children;
1799
+ },
1800
+ enumerable: false,
1801
+ configurable: true
1802
+ });
1803
+ return NodeWithChildren;
1804
+ }(Node));
1805
+ node.NodeWithChildren = NodeWithChildren;
1806
+ /**
1807
+ * The root node of the document.
1808
+ */
1809
+ var Document = /** @class */ (function (_super) {
1810
+ __extends(Document, _super);
1811
+ function Document(children) {
1812
+ return _super.call(this, domelementtype_1.ElementType.Root, children) || this;
1813
+ }
1814
+ return Document;
1815
+ }(NodeWithChildren));
1816
+ node.Document = Document;
1817
+ /**
1818
+ * An element within the DOM.
1819
+ */
1820
+ var Element$1 = /** @class */ (function (_super) {
1821
+ __extends(Element, _super);
1822
+ /**
1823
+ * @param name Name of the tag, eg. `div`, `span`.
1824
+ * @param attribs Object mapping attribute names to attribute values.
1825
+ * @param children Children of the node.
1826
+ */
1827
+ function Element(name, attribs, children, type) {
1828
+ if (children === void 0) { children = []; }
1829
+ if (type === void 0) { type = name === "script"
1830
+ ? domelementtype_1.ElementType.Script
1831
+ : name === "style"
1832
+ ? domelementtype_1.ElementType.Style
1833
+ : domelementtype_1.ElementType.Tag; }
1834
+ var _this = _super.call(this, type, children) || this;
1835
+ _this.name = name;
1836
+ _this.attribs = attribs;
1837
+ return _this;
1838
+ }
1839
+ Object.defineProperty(Element.prototype, "tagName", {
1840
+ // DOM Level 1 aliases
1841
+ get: function () {
1842
+ return this.name;
1843
+ },
1844
+ set: function (name) {
1845
+ this.name = name;
1846
+ },
1847
+ enumerable: false,
1848
+ configurable: true
1849
+ });
1850
+ Object.defineProperty(Element.prototype, "attributes", {
1851
+ get: function () {
1852
+ var _this = this;
1853
+ return Object.keys(this.attribs).map(function (name) {
1854
+ var _a, _b;
1855
+ return ({
1856
+ name: name,
1857
+ value: _this.attribs[name],
1858
+ namespace: (_a = _this["x-attribsNamespace"]) === null || _a === void 0 ? void 0 : _a[name],
1859
+ prefix: (_b = _this["x-attribsPrefix"]) === null || _b === void 0 ? void 0 : _b[name],
1860
+ });
1861
+ });
1862
+ },
1863
+ enumerable: false,
1864
+ configurable: true
1865
+ });
1866
+ return Element;
1867
+ }(NodeWithChildren));
1868
+ node.Element = Element$1;
1869
+ /**
1870
+ * @param node Node to check.
1871
+ * @returns `true` if the node is a `Element`, `false` otherwise.
1872
+ */
1873
+ function isTag(node) {
1874
+ return (0, domelementtype_1.isTag)(node);
1875
+ }
1876
+ node.isTag = isTag;
1877
+ /**
1878
+ * @param node Node to check.
1879
+ * @returns `true` if the node has the type `CDATA`, `false` otherwise.
1880
+ */
1881
+ function isCDATA(node) {
1882
+ return node.type === domelementtype_1.ElementType.CDATA;
1883
+ }
1884
+ node.isCDATA = isCDATA;
1885
+ /**
1886
+ * @param node Node to check.
1887
+ * @returns `true` if the node has the type `Text`, `false` otherwise.
1888
+ */
1889
+ function isText(node) {
1890
+ return node.type === domelementtype_1.ElementType.Text;
1891
+ }
1892
+ node.isText = isText;
1893
+ /**
1894
+ * @param node Node to check.
1895
+ * @returns `true` if the node has the type `Comment`, `false` otherwise.
1896
+ */
1897
+ function isComment(node) {
1898
+ return node.type === domelementtype_1.ElementType.Comment;
1899
+ }
1900
+ node.isComment = isComment;
1901
+ /**
1902
+ * @param node Node to check.
1903
+ * @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
1904
+ */
1905
+ function isDirective(node) {
1906
+ return node.type === domelementtype_1.ElementType.Directive;
1907
+ }
1908
+ node.isDirective = isDirective;
1909
+ /**
1910
+ * @param node Node to check.
1911
+ * @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
1912
+ */
1913
+ function isDocument(node) {
1914
+ return node.type === domelementtype_1.ElementType.Root;
1915
+ }
1916
+ node.isDocument = isDocument;
1917
+ /**
1918
+ * @param node Node to check.
1919
+ * @returns `true` if the node is a `NodeWithChildren` (has children), `false` otherwise.
1920
+ */
1921
+ function hasChildren(node) {
1922
+ return Object.prototype.hasOwnProperty.call(node, "children");
1923
+ }
1924
+ node.hasChildren = hasChildren;
1925
+ /**
1926
+ * Clone a node, and optionally its children.
1927
+ *
1928
+ * @param recursive Clone child nodes as well.
1929
+ * @returns A clone of the node.
1930
+ */
1931
+ function cloneNode(node, recursive) {
1932
+ if (recursive === void 0) { recursive = false; }
1933
+ var result;
1934
+ if (isText(node)) {
1935
+ result = new Text$1(node.data);
1936
+ }
1937
+ else if (isComment(node)) {
1938
+ result = new Comment$1(node.data);
1939
+ }
1940
+ else if (isTag(node)) {
1941
+ var children = recursive ? cloneChildren(node.children) : [];
1942
+ var clone_1 = new Element$1(node.name, __assign({}, node.attribs), children);
1943
+ children.forEach(function (child) { return (child.parent = clone_1); });
1944
+ if (node["x-attribsNamespace"]) {
1945
+ clone_1["x-attribsNamespace"] = __assign({}, node["x-attribsNamespace"]);
1946
+ }
1947
+ if (node["x-attribsPrefix"]) {
1948
+ clone_1["x-attribsPrefix"] = __assign({}, node["x-attribsPrefix"]);
1949
+ }
1950
+ result = clone_1;
1951
+ }
1952
+ else if (isCDATA(node)) {
1953
+ var children = recursive ? cloneChildren(node.children) : [];
1954
+ var clone_2 = new NodeWithChildren(domelementtype_1.ElementType.CDATA, children);
1955
+ children.forEach(function (child) { return (child.parent = clone_2); });
1956
+ result = clone_2;
1957
+ }
1958
+ else if (isDocument(node)) {
1959
+ var children = recursive ? cloneChildren(node.children) : [];
1960
+ var clone_3 = new Document(children);
1961
+ children.forEach(function (child) { return (child.parent = clone_3); });
1962
+ if (node["x-mode"]) {
1963
+ clone_3["x-mode"] = node["x-mode"];
1964
+ }
1965
+ result = clone_3;
1966
+ }
1967
+ else if (isDirective(node)) {
1968
+ var instruction = new ProcessingInstruction$1(node.name, node.data);
1969
+ if (node["x-name"] != null) {
1970
+ instruction["x-name"] = node["x-name"];
1971
+ instruction["x-publicId"] = node["x-publicId"];
1972
+ instruction["x-systemId"] = node["x-systemId"];
1973
+ }
1974
+ result = instruction;
1975
+ }
1976
+ else {
1977
+ throw new Error("Not implemented yet: " + node.type);
1978
+ }
1979
+ result.startIndex = node.startIndex;
1980
+ result.endIndex = node.endIndex;
1981
+ return result;
1982
+ }
1983
+ node.cloneNode = cloneNode;
1984
+ function cloneChildren(childs) {
1985
+ var children = childs.map(function (child) { return cloneNode(child, true); });
1986
+ for (var i = 1; i < children.length; i++) {
1987
+ children[i].prev = children[i - 1];
1988
+ children[i - 1].next = children[i];
1989
+ }
1990
+ return children;
1991
+ }
1992
+
1993
+ var constants = constants$1;
1994
+ var domhandler = node;
1995
+
1996
+ var CASE_SENSITIVE_TAG_NAMES = constants.CASE_SENSITIVE_TAG_NAMES;
1997
+
1998
+ var Comment = domhandler.Comment;
1999
+ var Element = domhandler.Element;
2000
+ var ProcessingInstruction = domhandler.ProcessingInstruction;
2001
+ var Text = domhandler.Text;
2002
+
2003
+ var caseSensitiveTagNamesMap = {};
2004
+ var tagName;
2005
+
2006
+ for (var i = 0, len = CASE_SENSITIVE_TAG_NAMES.length; i < len; i++) {
2007
+ tagName = CASE_SENSITIVE_TAG_NAMES[i];
2008
+ caseSensitiveTagNamesMap[tagName.toLowerCase()] = tagName;
2009
+ }
2010
+
2011
+ /**
2012
+ * Gets case-sensitive tag name.
2013
+ *
2014
+ * @param {string} tagName - Tag name in lowercase.
2015
+ * @return {string|undefined} - Case-sensitive tag name.
2016
+ */
2017
+ function getCaseSensitiveTagName(tagName) {
2018
+ return caseSensitiveTagNamesMap[tagName];
2019
+ }
2020
+
2021
+ /**
2022
+ * Formats DOM attributes to a hash map.
2023
+ *
2024
+ * @param {NamedNodeMap} attributes - List of attributes.
2025
+ * @return {object} - Map of attribute name to value.
2026
+ */
2027
+ function formatAttributes(attributes) {
2028
+ var result = {};
2029
+ var attribute;
2030
+ // `NamedNodeMap` is array-like
2031
+ for (var i = 0, len = attributes.length; i < len; i++) {
2032
+ attribute = attributes[i];
2033
+ result[attribute.name] = attribute.value;
2034
+ }
2035
+ return result;
2036
+ }
2037
+
2038
+ /**
2039
+ * Corrects the tag name if it is case-sensitive (SVG).
2040
+ * Otherwise, returns the lowercase tag name (HTML).
2041
+ *
2042
+ * @param {string} tagName - Lowercase tag name.
2043
+ * @return {string} - Formatted tag name.
2044
+ */
2045
+ function formatTagName(tagName) {
2046
+ tagName = tagName.toLowerCase();
2047
+ var caseSensitiveTagName = getCaseSensitiveTagName(tagName);
2048
+ if (caseSensitiveTagName) {
2049
+ return caseSensitiveTagName;
2050
+ }
2051
+ return tagName;
2052
+ }
2053
+
2054
+ /**
2055
+ * Transforms DOM nodes to `domhandler` nodes.
2056
+ *
2057
+ * @param {NodeList} nodes - DOM nodes.
2058
+ * @param {Element|null} [parent=null] - Parent node.
2059
+ * @param {string} [directive] - Directive.
2060
+ * @return {Array<Comment|Element|ProcessingInstruction|Text>}
2061
+ */
2062
+ function formatDOM$1(nodes, parent, directive) {
2063
+ parent = parent || null;
2064
+ var result = [];
2065
+
2066
+ for (var index = 0, len = nodes.length; index < len; index++) {
2067
+ var node = nodes[index];
2068
+ var current;
2069
+
2070
+ // set the node data given the type
2071
+ switch (node.nodeType) {
2072
+ case 1:
2073
+ // script, style, or tag
2074
+ current = new Element(
2075
+ formatTagName(node.nodeName),
2076
+ formatAttributes(node.attributes)
2077
+ );
2078
+ current.children = formatDOM$1(node.childNodes, current);
2079
+ break;
2080
+
2081
+ case 3:
2082
+ current = new Text(node.nodeValue);
2083
+ break;
2084
+
2085
+ case 8:
2086
+ current = new Comment(node.nodeValue);
2087
+ break;
2088
+
2089
+ default:
2090
+ continue;
2091
+ }
2092
+
2093
+ // set previous node next
2094
+ var prev = result[index - 1] || null;
2095
+ if (prev) {
2096
+ prev.next = current;
2097
+ }
2098
+
2099
+ // set properties for current node
2100
+ current.parent = parent;
2101
+ current.prev = prev;
2102
+ current.next = null;
2103
+
2104
+ result.push(current);
2105
+ }
2106
+
2107
+ if (directive) {
2108
+ current = new ProcessingInstruction(
2109
+ directive.substring(0, directive.indexOf(' ')).toLowerCase(),
2110
+ directive
2111
+ );
2112
+ current.next = result[0] || null;
2113
+ current.parent = parent;
2114
+ result.unshift(current);
2115
+
2116
+ if (result[1]) {
2117
+ result[1].prev = result[0];
2118
+ }
2119
+ }
2120
+
2121
+ return result;
2122
+ }
2123
+
2124
+ /**
2125
+ * Detects if browser is Internet Explorer.
2126
+ *
2127
+ * @return {boolean} - Whether IE is detected.
2128
+ */
2129
+ function isIE$1() {
2130
+ return /(MSIE |Trident\/|Edge\/)/.test(navigator.userAgent);
2131
+ }
2132
+
2133
+ var utilities = {
2134
+ formatAttributes: formatAttributes,
2135
+ formatDOM: formatDOM$1,
2136
+ isIE: isIE$1
2137
+ };
2138
+
2139
+ // constants
2140
+ var HTML = 'html';
2141
+ var HEAD = 'head';
2142
+ var BODY = 'body';
2143
+ var FIRST_TAG_REGEX = /<([a-zA-Z]+[0-9]?)/; // e.g., <h1>
2144
+ var HEAD_TAG_REGEX = /<head.*>/i;
2145
+ var BODY_TAG_REGEX = /<body.*>/i;
2146
+
2147
+ // falls back to `parseFromString` if `createHTMLDocument` cannot be used
2148
+ var parseFromDocument = function () {
2149
+ throw new Error(
2150
+ 'This browser does not support `document.implementation.createHTMLDocument`'
2151
+ );
2152
+ };
2153
+
2154
+ var parseFromString = function () {
2155
+ throw new Error(
2156
+ 'This browser does not support `DOMParser.prototype.parseFromString`'
2157
+ );
2158
+ };
2159
+
2160
+ /**
2161
+ * DOMParser (performance: slow).
2162
+ *
2163
+ * @see https://developer.mozilla.org/docs/Web/API/DOMParser#Parsing_an_SVG_or_HTML_document
2164
+ */
2165
+ if (typeof window.DOMParser === 'function') {
2166
+ var domParser = new window.DOMParser();
2167
+ var mimeType = 'text/html';
2168
+
2169
+ /**
2170
+ * Creates an HTML document using `DOMParser.parseFromString`.
2171
+ *
2172
+ * @param {string} html - The HTML string.
2173
+ * @param {string} [tagName] - The element to render the HTML (with 'body' as fallback).
2174
+ * @return {HTMLDocument}
2175
+ */
2176
+ parseFromString = function (html, tagName) {
2177
+ if (tagName) {
2178
+ html = '<' + tagName + '>' + html + '</' + tagName + '>';
2179
+ }
2180
+
2181
+ return domParser.parseFromString(html, mimeType);
2182
+ };
2183
+
2184
+ parseFromDocument = parseFromString;
2185
+ }
2186
+
2187
+ /**
2188
+ * DOMImplementation (performance: fair).
2189
+ *
2190
+ * @see https://developer.mozilla.org/docs/Web/API/DOMImplementation/createHTMLDocument
2191
+ */
2192
+ if (document.implementation) {
2193
+ var isIE = utilities.isIE;
2194
+
2195
+ // title parameter is required in IE
2196
+ // https://msdn.microsoft.com/en-us/library/ff975457(v=vs.85).aspx
2197
+ var doc = document.implementation.createHTMLDocument(
2198
+ isIE() ? 'html-dom-parser' : undefined
2199
+ );
2200
+
2201
+ /**
2202
+ * Use HTML document created by `document.implementation.createHTMLDocument`.
2203
+ *
2204
+ * @param {string} html - The HTML string.
2205
+ * @param {string} [tagName] - The element to render the HTML (with 'body' as fallback).
2206
+ * @return {HTMLDocument}
2207
+ */
2208
+ parseFromDocument = function (html, tagName) {
2209
+ if (tagName) {
2210
+ doc.documentElement.getElementsByTagName(tagName)[0].innerHTML = html;
2211
+ return doc;
2212
+ }
2213
+
2214
+ doc.documentElement.innerHTML = html;
2215
+ return doc;
2216
+ };
2217
+ }
2218
+
2219
+ /**
2220
+ * Template (performance: fast).
2221
+ *
2222
+ * @see https://developer.mozilla.org/docs/Web/HTML/Element/template
2223
+ */
2224
+ var template = document.createElement('template');
2225
+ var parseFromTemplate;
2226
+
2227
+ if (template.content) {
2228
+ /**
2229
+ * Uses a template element (content fragment) to parse HTML.
2230
+ *
2231
+ * @param {string} html - The HTML string.
2232
+ * @return {NodeList}
2233
+ */
2234
+ parseFromTemplate = function (html) {
2235
+ template.innerHTML = html;
2236
+ return template.content.childNodes;
2237
+ };
2238
+ }
2239
+
2240
+ /**
2241
+ * Parses HTML string to DOM nodes.
2242
+ *
2243
+ * @param {string} html - HTML markup.
2244
+ * @return {NodeList}
2245
+ */
2246
+ function domparser$1(html) {
2247
+ var firstTagName;
2248
+ var match = html.match(FIRST_TAG_REGEX);
2249
+
2250
+ if (match && match[1]) {
2251
+ firstTagName = match[1].toLowerCase();
2252
+ }
2253
+
2254
+ var doc;
2255
+ var element;
2256
+ var elements;
2257
+
2258
+ switch (firstTagName) {
2259
+ case HTML:
2260
+ doc = parseFromString(html);
2261
+
2262
+ // the created document may come with filler head/body elements,
2263
+ // so make sure to remove them if they don't actually exist
2264
+ if (!HEAD_TAG_REGEX.test(html)) {
2265
+ element = doc.getElementsByTagName(HEAD)[0];
2266
+ if (element) {
2267
+ element.parentNode.removeChild(element);
2268
+ }
2269
+ }
2270
+
2271
+ if (!BODY_TAG_REGEX.test(html)) {
2272
+ element = doc.getElementsByTagName(BODY)[0];
2273
+ if (element) {
2274
+ element.parentNode.removeChild(element);
2275
+ }
2276
+ }
2277
+
2278
+ return doc.getElementsByTagName(HTML);
2279
+
2280
+ case HEAD:
2281
+ case BODY:
2282
+ elements = parseFromDocument(html).getElementsByTagName(firstTagName);
2283
+
2284
+ // if there's a sibling element, then return both elements
2285
+ if (BODY_TAG_REGEX.test(html) && HEAD_TAG_REGEX.test(html)) {
2286
+ return elements[0].parentNode.childNodes;
2287
+ }
2288
+ return elements;
2289
+
2290
+ // low-level tag or text
2291
+ default:
2292
+ if (parseFromTemplate) {
2293
+ return parseFromTemplate(html);
2294
+ }
2295
+
2296
+ return parseFromDocument(html, BODY).getElementsByTagName(BODY)[0]
2297
+ .childNodes;
2298
+ }
2299
+ }
2300
+
2301
+ var domparser_1 = domparser$1;
2302
+
2303
+ var domparser = domparser_1;
2304
+ var formatDOM = utilities.formatDOM;
2305
+
2306
+ var DIRECTIVE_REGEX = /<(![a-zA-Z\s]+)>/; // e.g., <!doctype html>
2307
+
2308
+ /**
2309
+ * Parses HTML string to DOM nodes in browser.
2310
+ *
2311
+ * @param {string} html - HTML markup.
2312
+ * @return {DomElement[]} - DOM elements.
2313
+ */
2314
+ function HTMLDOMParser(html) {
2315
+ if (typeof html !== 'string') {
2316
+ throw new TypeError('First argument must be a string');
2317
+ }
2318
+
2319
+ if (html === '') {
2320
+ return [];
2321
+ }
2322
+
2323
+ // match directive
2324
+ var match = html.match(DIRECTIVE_REGEX);
2325
+ var directive;
2326
+
2327
+ if (match && match[1]) {
2328
+ directive = match[1];
2329
+ }
2330
+
2331
+ return formatDOM(domparser(html), null, directive);
2332
+ }
2333
+
2334
+ var htmlToDom = HTMLDOMParser;
2335
+
2336
+ var domToReact = domToReact_1;
2337
+ var attributesToProps = attributesToProps$2;
2338
+ var htmlToDOM = htmlToDom;
2339
+
2340
+ var domParserOptions = { lowerCaseAttributeNames: false };
2341
+
2342
+ /**
2343
+ * Converts HTML string to React elements.
2344
+ *
2345
+ * @param {String} html - HTML string.
2346
+ * @param {Object} [options] - Parser options.
2347
+ * @param {Object} [options.htmlparser2] - htmlparser2 options.
2348
+ * @param {Object} [options.library] - Library for React, Preact, etc.
2349
+ * @param {Function} [options.replace] - Replace method.
2350
+ * @return {JSX.Element|JSX.Element[]|String} - React element(s), empty array, or string.
2351
+ */
2352
+ function HTMLReactParser(html, options) {
2353
+ if (typeof html !== 'string') {
2354
+ throw new TypeError('First argument must be a string');
2355
+ }
2356
+ if (html === '') {
2357
+ return [];
2358
+ }
2359
+ options = options || {};
2360
+ return domToReact(
2361
+ htmlToDOM(html, options.htmlparser2 || domParserOptions),
2362
+ options
2363
+ );
2364
+ }
2365
+
2366
+ HTMLReactParser.domToReact = domToReact;
2367
+ HTMLReactParser.htmlToDOM = htmlToDOM;
2368
+ HTMLReactParser.attributesToProps = attributesToProps;
2369
+
2370
+ // support CommonJS and ES Modules
2371
+ htmlReactParser$1.exports = HTMLReactParser;
2372
+ htmlReactParser$1.exports.default = HTMLReactParser;
2373
+
2374
+ var htmlReactParser = htmlReactParser$1.exports;
2375
+
2376
+ return htmlReactParser;
2022
2377
 
2023
2378
  })));
2024
2379
  //# sourceMappingURL=html-react-parser.js.map