@uiw/react-md-editor 4.0.1 → 4.0.3

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.
package/dist/mdeditor.js CHANGED
@@ -266,7 +266,7 @@ var TYPE_DECLARATION = 'declaration';
266
266
  * @throws {TypeError}
267
267
  * @throws {Error}
268
268
  */
269
- module.exports = function(style, options) {
269
+ module.exports = function (style, options) {
270
270
  if (typeof style !== 'string') {
271
271
  throw new TypeError('First argument must be a string');
272
272
  }
@@ -300,7 +300,7 @@ module.exports = function(style, options) {
300
300
  */
301
301
  function position() {
302
302
  var start = { line: lineno, column: column };
303
- return function(node) {
303
+ return function (node) {
304
304
  node.position = new Position(start);
305
305
  whitespace();
306
306
  return node;
@@ -573,53 +573,54 @@ if (true) {
573
573
 
574
574
  /***/ }),
575
575
 
576
- /***/ 862:
577
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
576
+ /***/ 209:
577
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
578
578
 
579
- var parse = __webpack_require__(812);
579
+ "use strict";
580
580
 
581
+ var __importDefault = (this && this.__importDefault) || function (mod) {
582
+ return (mod && mod.__esModule) ? mod : { "default": mod };
583
+ };
584
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
585
+ var inline_style_parser_1 = __importDefault(__webpack_require__(812));
581
586
  /**
582
587
  * Parses inline style to object.
583
588
  *
584
- * @example
585
- * // returns { 'line-height': '42' }
586
- * StyleToObject('line-height: 42;');
589
+ * @param style - Inline style.
590
+ * @param iterator - Iterator.
591
+ * @returns - Style object or null.
592
+ *
593
+ * @example Parsing inline style to object:
587
594
  *
588
- * @param {String} style - The inline style.
589
- * @param {Function} [iterator] - The iterator function.
590
- * @return {null|Object}
595
+ * ```js
596
+ * import parse from 'style-to-object';
597
+ * parse('line-height: 42;'); // { 'line-height': '42' }
598
+ * ```
591
599
  */
592
600
  function StyleToObject(style, iterator) {
593
- var output = null;
594
- if (!style || typeof style !== 'string') {
595
- return output;
596
- }
597
-
598
- var declaration;
599
- var declarations = parse(style);
600
- var hasIterator = typeof iterator === 'function';
601
- var property;
602
- var value;
603
-
604
- for (var i = 0, len = declarations.length; i < len; i++) {
605
- declaration = declarations[i];
606
- property = declaration.property;
607
- value = declaration.value;
608
-
609
- if (hasIterator) {
610
- iterator(property, value, declaration);
611
- } else if (value) {
612
- output || (output = {});
613
- output[property] = value;
614
- }
615
- }
616
-
617
- return output;
601
+ var styleObject = null;
602
+ if (!style || typeof style !== 'string') {
603
+ return styleObject;
604
+ }
605
+ var declarations = (0, inline_style_parser_1.default)(style);
606
+ var hasIterator = typeof iterator === 'function';
607
+ declarations.forEach(function (declaration) {
608
+ if (declaration.type !== 'declaration') {
609
+ return;
610
+ }
611
+ var property = declaration.property, value = declaration.value;
612
+ if (hasIterator) {
613
+ iterator(property, value, declaration);
614
+ }
615
+ else if (value) {
616
+ styleObject = styleObject || {};
617
+ styleObject[property] = value;
618
+ }
619
+ });
620
+ return styleObject;
618
621
  }
619
-
620
- module.exports = StyleToObject;
621
- module.exports["default"] = StyleToObject; // ESM support
622
-
622
+ exports["default"] = StyleToObject;
623
+ //# sourceMappingURL=index.js.map
623
624
 
624
625
  /***/ }),
625
626
 
@@ -850,27 +851,27 @@ function _typeof(o) {
850
851
  }
851
852
  ;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
852
853
 
853
- function _toPrimitive(input, hint) {
854
- if (_typeof(input) !== "object" || input === null) return input;
855
- var prim = input[Symbol.toPrimitive];
856
- if (prim !== undefined) {
857
- var res = prim.call(input, hint || "default");
858
- if (_typeof(res) !== "object") return res;
854
+ function toPrimitive(t, r) {
855
+ if ("object" != _typeof(t) || !t) return t;
856
+ var e = t[Symbol.toPrimitive];
857
+ if (void 0 !== e) {
858
+ var i = e.call(t, r || "default");
859
+ if ("object" != _typeof(i)) return i;
859
860
  throw new TypeError("@@toPrimitive must return a primitive value.");
860
861
  }
861
- return (hint === "string" ? String : Number)(input);
862
+ return ("string" === r ? String : Number)(t);
862
863
  }
863
864
  ;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
864
865
 
865
866
 
866
- function _toPropertyKey(arg) {
867
- var key = _toPrimitive(arg, "string");
868
- return _typeof(key) === "symbol" ? key : String(key);
867
+ function toPropertyKey(t) {
868
+ var i = toPrimitive(t, "string");
869
+ return "symbol" == _typeof(i) ? i : String(i);
869
870
  }
870
871
  ;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/defineProperty.js
871
872
 
872
873
  function _defineProperty(obj, key, value) {
873
- key = _toPropertyKey(key);
874
+ key = toPropertyKey(key);
874
875
  if (key in obj) {
875
876
  Object.defineProperty(obj, key, {
876
877
  value: value,
@@ -1101,6 +1102,69 @@ function stringify(values, options) {
1101
1102
  .trim()
1102
1103
  }
1103
1104
 
1105
+ ;// CONCATENATED MODULE: ../node_modules/estree-util-is-identifier-name/lib/index.js
1106
+ /**
1107
+ * @typedef Options
1108
+ * Configuration.
1109
+ * @property {boolean | null | undefined} [jsx=false]
1110
+ * Support JSX identifiers (default: `false`).
1111
+ */
1112
+
1113
+ const startRe = /[$_\p{ID_Start}]/u
1114
+ const contRe = /[$_\u{200C}\u{200D}\p{ID_Continue}]/u
1115
+ const contReJsx = /[-$_\u{200C}\u{200D}\p{ID_Continue}]/u
1116
+ const nameRe = /^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u
1117
+ const nameReJsx = /^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u
1118
+
1119
+ /** @type {Options} */
1120
+ const emptyOptions = {}
1121
+
1122
+ /**
1123
+ * Checks if the given code point can start an identifier.
1124
+ *
1125
+ * @param {number | undefined} code
1126
+ * Code point to check.
1127
+ * @returns {boolean}
1128
+ * Whether `code` can start an identifier.
1129
+ */
1130
+ // Note: `undefined` is supported so you can pass the result from `''.codePointAt`.
1131
+ function start(code) {
1132
+ return code ? startRe.test(String.fromCodePoint(code)) : false
1133
+ }
1134
+
1135
+ /**
1136
+ * Checks if the given code point can continue an identifier.
1137
+ *
1138
+ * @param {number | undefined} code
1139
+ * Code point to check.
1140
+ * @param {Options | null | undefined} [options]
1141
+ * Configuration (optional).
1142
+ * @returns {boolean}
1143
+ * Whether `code` can continue an identifier.
1144
+ */
1145
+ // Note: `undefined` is supported so you can pass the result from `''.codePointAt`.
1146
+ function cont(code, options) {
1147
+ const settings = options || emptyOptions
1148
+ const re = settings.jsx ? contReJsx : contRe
1149
+ return code ? re.test(String.fromCodePoint(code)) : false
1150
+ }
1151
+
1152
+ /**
1153
+ * Checks if the given value is a valid identifier name.
1154
+ *
1155
+ * @param {string} name
1156
+ * Identifier to check.
1157
+ * @param {Options | null | undefined} [options]
1158
+ * Configuration (optional).
1159
+ * @returns {boolean}
1160
+ * Whether `name` can be an identifier.
1161
+ */
1162
+ function lib_name(name, options) {
1163
+ const settings = options || emptyOptions
1164
+ const re = settings.jsx ? nameReJsx : nameRe
1165
+ return re.test(name)
1166
+ }
1167
+
1104
1168
  ;// CONCATENATED MODULE: ../node_modules/hast-util-whitespace/lib/index.js
1105
1169
  /**
1106
1170
  * @typedef {import('hast').Nodes} Nodes
@@ -2500,12 +2564,13 @@ function space_separated_tokens_stringify(values) {
2500
2564
  return values.join(' ').trim()
2501
2565
  }
2502
2566
 
2503
- // EXTERNAL MODULE: ../node_modules/style-to-object/index.js
2504
- var style_to_object = __webpack_require__(862);
2505
- ;// CONCATENATED MODULE: ../node_modules/style-to-object/index.mjs
2567
+ // EXTERNAL MODULE: ../node_modules/style-to-object/cjs/index.js
2568
+ var cjs = __webpack_require__(209);
2569
+ ;// CONCATENATED MODULE: ../node_modules/style-to-object/esm/index.mjs
2506
2570
 
2507
2571
 
2508
- /* harmony default export */ const node_modules_style_to_object = (style_to_object);
2572
+ // ensure compatibility with rollup umd build
2573
+ /* harmony default export */ const esm = (cjs["default"] || cjs);
2509
2574
 
2510
2575
  ;// CONCATENATED MODULE: ../node_modules/unist-util-position/lib/index.js
2511
2576
  /**
@@ -3011,13 +3076,36 @@ VFileMessage.prototype.ruleId = undefined
3011
3076
  VFileMessage.prototype.source = undefined
3012
3077
 
3013
3078
  ;// CONCATENATED MODULE: ../node_modules/hast-util-to-jsx-runtime/lib/index.js
3079
+ // Register MDX nodes in mdast:
3080
+ /// <reference types="mdast-util-mdx-expression" />
3081
+ /// <reference types="mdast-util-mdx-jsx" />
3082
+ /// <reference types="mdast-util-mdxjs-esm" />
3083
+
3014
3084
  /**
3085
+ * @typedef {import('estree').Identifier} Identifier
3086
+ * @typedef {import('estree').Literal} Literal
3087
+ * @typedef {import('estree').MemberExpression} MemberExpression
3088
+ * @typedef {import('estree').Expression} Expression
3089
+ * @typedef {import('estree').Program} Program
3090
+ *
3015
3091
  * @typedef {import('hast').Element} Element
3016
3092
  * @typedef {import('hast').Nodes} Nodes
3017
3093
  * @typedef {import('hast').Parents} Parents
3094
+ * @typedef {import('hast').Root} Root
3095
+ * @typedef {import('hast').Text} Text
3096
+ *
3097
+ * @typedef {import('mdast-util-mdx-expression').MdxFlowExpressionHast} MdxFlowExpression
3098
+ * @typedef {import('mdast-util-mdx-expression').MdxTextExpressionHast} MdxTextExpression
3099
+ *
3100
+ * @typedef {import('mdast-util-mdx-jsx').MdxJsxFlowElementHast} MdxJsxFlowElement
3101
+ * @typedef {import('mdast-util-mdx-jsx').MdxJsxTextElementHast} MdxJsxTextElement
3102
+ *
3103
+ * @typedef {import('mdast-util-mdxjs-esm').MdxjsEsmHast} MdxjsEsm
3018
3104
  *
3019
3105
  * @typedef {import('property-information').Schema} Schema
3020
3106
  *
3107
+ * @typedef {import('unist').Position} Position
3108
+ *
3021
3109
  * @typedef {import('./components.js').Components} Components
3022
3110
  */
3023
3111
 
@@ -3038,12 +3126,40 @@ VFileMessage.prototype.source = undefined
3038
3126
  * @returns {JSX.Element}
3039
3127
  * Result.
3040
3128
  *
3129
+ * @callback CreateEvaluater
3130
+ * Create an evaluator that turns ESTree ASTs from embedded MDX into values.
3131
+ * @returns {Evaluater}
3132
+ * Evaluater.
3133
+ *
3041
3134
  * @typedef {'html' | 'react'} ElementAttributeNameCase
3042
3135
  * Casing to use for attribute names.
3043
3136
  *
3044
3137
  * HTML casing is for example `class`, `stroke-linecap`, `xml:lang`.
3045
3138
  * React casing is for example `className`, `strokeLinecap`, `xmlLang`.
3046
3139
  *
3140
+ * @callback EvaluateExpression
3141
+ * Turn an MDX expression into a value.
3142
+ * @param {Expression} expression
3143
+ * ESTree expression.
3144
+ * @returns {unknown}
3145
+ * Result of expression.
3146
+ *
3147
+ * @callback EvaluateProgram
3148
+ * Turn an MDX program (export/import statements) into a value.
3149
+ * @param {Program} expression
3150
+ * ESTree program.
3151
+ * @returns {unknown}
3152
+ * Result of program;
3153
+ * should likely be `undefined` as ESM changes the scope but doesn’t yield
3154
+ * something.
3155
+ *
3156
+ * @typedef Evaluater
3157
+ * Evaluator that turns ESTree ASTs from embedded MDX into values.
3158
+ * @property {EvaluateExpression} evaluateExpression
3159
+ * Evaluate an expression.
3160
+ * @property {EvaluateProgram} evaluateProgram
3161
+ * Evaluate a program.
3162
+ *
3047
3163
  * @typedef {[string, Value]} Field
3048
3164
  * Property field.
3049
3165
  *
@@ -3059,7 +3175,7 @@ VFileMessage.prototype.source = undefined
3059
3175
  * @param {string | undefined} [key]
3060
3176
  * Dynamicly generated key to use.
3061
3177
  * @returns {JSX.Element}
3062
- * An element from your framework.
3178
+ * Element from your framework.
3063
3179
  *
3064
3180
  * @callback JsxDev
3065
3181
  * Create a development element.
@@ -3077,15 +3193,17 @@ VFileMessage.prototype.source = undefined
3077
3193
  * @param {undefined} self
3078
3194
  * Nothing (this is used by frameworks that have components, we don’t).
3079
3195
  * @returns {JSX.Element}
3080
- * An element from your framework.
3196
+ * Element from your framework.
3081
3197
  *
3082
- * @typedef {{children?: Array<Child> | Child, node?: Element | undefined, [prop: string]: Array<Child> | Child | Element | Value | undefined}} Props
3198
+ * @typedef {{children?: Array<Child> | Child, node?: Element | MdxJsxFlowElement | MdxJsxTextElement | undefined, [prop: string]: Array<Child> | Child | Element | MdxJsxFlowElement | MdxJsxTextElement | Value | undefined}} Props
3083
3199
  * Properties and children.
3084
3200
  *
3085
3201
  * @typedef RegularFields
3086
3202
  * Configuration.
3087
3203
  * @property {Partial<Components> | null | undefined} [components]
3088
3204
  * Components to use (optional).
3205
+ * @property {CreateEvaluater | null | undefined} [createEvaluater]
3206
+ * Create an evaluator that turns ESTree ASTs into values (optional).
3089
3207
  * @property {ElementAttributeNameCase | null | undefined} [elementAttributeNameCase='react']
3090
3208
  * Specify casing to use for attribute names (default: `'react'`).
3091
3209
  * @property {string | null | undefined} [filePath]
@@ -3184,6 +3302,8 @@ VFileMessage.prototype.source = undefined
3184
3302
  * Create something in development or production.
3185
3303
  * @property {ElementAttributeNameCase} elementAttributeNameCase
3186
3304
  * Casing to use for attribute names.
3305
+ * @property {Evaluater | undefined} evaluater
3306
+ * Evaluator that turns ESTree ASTs into values.
3187
3307
  * @property {string | undefined} filePath
3188
3308
  * File path.
3189
3309
  * @property {boolean} ignoreInvalidStyle
@@ -3231,6 +3351,8 @@ VFileMessage.prototype.source = undefined
3231
3351
 
3232
3352
 
3233
3353
 
3354
+
3355
+
3234
3356
  const lib_own = {}.hasOwnProperty
3235
3357
 
3236
3358
  /** @type {Map<string, number>} */
@@ -3254,6 +3376,8 @@ const tableElements = new Set(['table', 'tbody', 'thead', 'tfoot', 'tr'])
3254
3376
 
3255
3377
  const tableCellElement = new Set(['td', 'th'])
3256
3378
 
3379
+ const docs = 'https://github.com/syntax-tree/hast-util-to-jsx-runtime'
3380
+
3257
3381
  /**
3258
3382
  * Transform a hast tree to preact, react, solid, svelte, vue, etc.,
3259
3383
  * with an automatic JSX runtime.
@@ -3302,6 +3426,7 @@ function toJsxRuntime(tree, options) {
3302
3426
  components: options.components || {},
3303
3427
  create,
3304
3428
  elementAttributeNameCase: options.elementAttributeNameCase || 'react',
3429
+ evaluater: options.createEvaluater ? options.createEvaluater() : undefined,
3305
3430
  filePath,
3306
3431
  ignoreInvalidStyle: options.ignoreInvalidStyle || false,
3307
3432
  passKeys: options.passKeys !== false,
@@ -3340,67 +3465,233 @@ function toJsxRuntime(tree, options) {
3340
3465
  * Child, optional.
3341
3466
  */
3342
3467
  function one(state, node, key) {
3343
- if (node.type === 'element' || node.type === 'root') {
3344
- const parentSchema = state.schema
3345
- let schema = parentSchema
3468
+ if (node.type === 'element') {
3469
+ return lib_element(state, node, key)
3470
+ }
3346
3471
 
3347
- if (
3348
- node.type === 'element' &&
3349
- node.tagName.toLowerCase() === 'svg' &&
3350
- parentSchema.space === 'html'
3351
- ) {
3352
- schema = property_information_svg
3353
- state.schema = schema
3354
- }
3472
+ if (node.type === 'mdxFlowExpression' || node.type === 'mdxTextExpression') {
3473
+ return mdxExpression(state, node)
3474
+ }
3355
3475
 
3356
- state.ancestors.push(node)
3476
+ if (node.type === 'mdxJsxFlowElement' || node.type === 'mdxJsxTextElement') {
3477
+ return mdxJsxElement(state, node, key)
3478
+ }
3357
3479
 
3358
- let children = createChildren(state, node)
3359
- const props = createProperties(state, state.ancestors)
3360
- let type = state.Fragment
3480
+ if (node.type === 'mdxjsEsm') {
3481
+ return mdxEsm(state, node)
3482
+ }
3361
3483
 
3362
- state.ancestors.pop()
3484
+ if (node.type === 'root') {
3485
+ return root(state, node, key)
3486
+ }
3363
3487
 
3364
- if (node.type === 'element') {
3365
- if (children && tableElements.has(node.tagName)) {
3366
- children = children.filter(function (child) {
3367
- return typeof child === 'string' ? !whitespace(child) : true
3368
- })
3369
- }
3488
+ if (node.type === 'text') {
3489
+ return lib_text(state, node)
3490
+ }
3491
+ }
3370
3492
 
3371
- if (lib_own.call(state.components, node.tagName)) {
3372
- const key = /** @type {keyof JSX.IntrinsicElements} */ (node.tagName)
3373
- type = state.components[key]
3493
+ /**
3494
+ * Handle element.
3495
+ *
3496
+ * @param {State} state
3497
+ * Info passed around.
3498
+ * @param {Element} node
3499
+ * Current node.
3500
+ * @param {string | undefined} key
3501
+ * Key.
3502
+ * @returns {Child | undefined}
3503
+ * Child, optional.
3504
+ */
3505
+ function lib_element(state, node, key) {
3506
+ const parentSchema = state.schema
3507
+ let schema = parentSchema
3374
3508
 
3375
- // If this is swapped out for a component:
3376
- if (
3377
- typeof type !== 'string' &&
3378
- type !== state.Fragment &&
3379
- state.passNode
3380
- ) {
3381
- props.node = node
3382
- }
3383
- } else {
3384
- type = node.tagName
3385
- }
3386
- }
3509
+ if (node.tagName.toLowerCase() === 'svg' && parentSchema.space === 'html') {
3510
+ schema = property_information_svg
3511
+ state.schema = schema
3512
+ }
3387
3513
 
3388
- if (children.length > 0) {
3389
- const value = children.length > 1 ? children : children[0]
3514
+ state.ancestors.push(node)
3390
3515
 
3391
- if (value) {
3392
- props.children = value
3393
- }
3394
- }
3516
+ const type = findComponentFromName(state, node.tagName, false)
3517
+ const props = createElementProps(state, node)
3518
+ let children = createChildren(state, node)
3519
+
3520
+ if (tableElements.has(node.tagName)) {
3521
+ children = children.filter(function (child) {
3522
+ return typeof child === 'string' ? !whitespace(child) : true
3523
+ })
3524
+ }
3525
+
3526
+ addNode(state, props, type, node)
3527
+ addChildren(props, children)
3395
3528
 
3396
- // Restore parent schema.
3397
- state.schema = parentSchema
3529
+ // Restore.
3530
+ state.ancestors.pop()
3531
+ state.schema = parentSchema
3398
3532
 
3399
- return state.create(node, type, props, key)
3533
+ return state.create(node, type, props, key)
3534
+ }
3535
+
3536
+ /**
3537
+ * Handle MDX expression.
3538
+ *
3539
+ * @param {State} state
3540
+ * Info passed around.
3541
+ * @param {MdxFlowExpression | MdxTextExpression} node
3542
+ * Current node.
3543
+ * @returns {Child | undefined}
3544
+ * Child, optional.
3545
+ */
3546
+ function mdxExpression(state, node) {
3547
+ if (node.data && node.data.estree && state.evaluater) {
3548
+ const program = node.data.estree
3549
+ const expression = program.body[0]
3550
+ ok(expression.type === 'ExpressionStatement')
3551
+
3552
+ // Assume result is a child.
3553
+ return /** @type {Child | undefined} */ (
3554
+ state.evaluater.evaluateExpression(expression.expression)
3555
+ )
3400
3556
  }
3401
3557
 
3402
- if (node.type === 'text') {
3403
- return node.value
3558
+ crashEstree(state, node.position)
3559
+ }
3560
+
3561
+ /**
3562
+ * Handle MDX ESM.
3563
+ *
3564
+ * @param {State} state
3565
+ * Info passed around.
3566
+ * @param {MdxjsEsm} node
3567
+ * Current node.
3568
+ * @returns {Child | undefined}
3569
+ * Child, optional.
3570
+ */
3571
+ function mdxEsm(state, node) {
3572
+ if (node.data && node.data.estree && state.evaluater) {
3573
+ // Assume result is a child.
3574
+ return /** @type {Child | undefined} */ (
3575
+ state.evaluater.evaluateProgram(node.data.estree)
3576
+ )
3577
+ }
3578
+
3579
+ crashEstree(state, node.position)
3580
+ }
3581
+
3582
+ /**
3583
+ * Handle MDX JSX.
3584
+ *
3585
+ * @param {State} state
3586
+ * Info passed around.
3587
+ * @param {MdxJsxFlowElement | MdxJsxTextElement} node
3588
+ * Current node.
3589
+ * @param {string | undefined} key
3590
+ * Key.
3591
+ * @returns {Child | undefined}
3592
+ * Child, optional.
3593
+ */
3594
+ function mdxJsxElement(state, node, key) {
3595
+ const parentSchema = state.schema
3596
+ let schema = parentSchema
3597
+
3598
+ if (node.name === 'svg' && parentSchema.space === 'html') {
3599
+ schema = property_information_svg
3600
+ state.schema = schema
3601
+ }
3602
+
3603
+ state.ancestors.push(node)
3604
+
3605
+ const type =
3606
+ node.name === null
3607
+ ? state.Fragment
3608
+ : findComponentFromName(state, node.name, true)
3609
+ const props = createJsxElementProps(state, node)
3610
+ const children = createChildren(state, node)
3611
+
3612
+ addNode(state, props, type, node)
3613
+ addChildren(props, children)
3614
+
3615
+ // Restore.
3616
+ state.ancestors.pop()
3617
+ state.schema = parentSchema
3618
+
3619
+ return state.create(node, type, props, key)
3620
+ }
3621
+
3622
+ /**
3623
+ * Handle root.
3624
+ *
3625
+ * @param {State} state
3626
+ * Info passed around.
3627
+ * @param {Root} node
3628
+ * Current node.
3629
+ * @param {string | undefined} key
3630
+ * Key.
3631
+ * @returns {Child | undefined}
3632
+ * Child, optional.
3633
+ */
3634
+ function root(state, node, key) {
3635
+ /** @type {Props} */
3636
+ const props = {}
3637
+
3638
+ addChildren(props, createChildren(state, node))
3639
+
3640
+ return state.create(node, state.Fragment, props, key)
3641
+ }
3642
+
3643
+ /**
3644
+ * Handle text.
3645
+ *
3646
+ * @param {State} _
3647
+ * Info passed around.
3648
+ * @param {Text} node
3649
+ * Current node.
3650
+ * @returns {Child | undefined}
3651
+ * Child, optional.
3652
+ */
3653
+ function lib_text(_, node) {
3654
+ return node.value
3655
+ }
3656
+
3657
+ /**
3658
+ * Add `node` to props.
3659
+ *
3660
+ * @param {State} state
3661
+ * Info passed around.
3662
+ * @param {Props} props
3663
+ * Props.
3664
+ * @param {unknown} type
3665
+ * Type.
3666
+ * @param {Element | MdxJsxFlowElement | MdxJsxTextElement} node
3667
+ * Node.
3668
+ * @returns {undefined}
3669
+ * Nothing.
3670
+ */
3671
+ function addNode(state, props, type, node) {
3672
+ // If this is swapped out for a component:
3673
+ if (typeof type !== 'string' && type !== state.Fragment && state.passNode) {
3674
+ props.node = node
3675
+ }
3676
+ }
3677
+
3678
+ /**
3679
+ * Add children to props.
3680
+ *
3681
+ * @param {Props} props
3682
+ * Props.
3683
+ * @param {Array<Child>} children
3684
+ * Children.
3685
+ * @returns {undefined}
3686
+ * Nothing.
3687
+ */
3688
+ function addChildren(props, children) {
3689
+ if (children.length > 0) {
3690
+ const value = children.length > 1 ? children : children[0]
3691
+
3692
+ if (value) {
3693
+ props.children = value
3694
+ }
3404
3695
  }
3405
3696
  }
3406
3697
 
@@ -3455,6 +3746,118 @@ function developmentCreate(filePath, jsxDEV) {
3455
3746
  }
3456
3747
  }
3457
3748
 
3749
+ /**
3750
+ * Create props from an element.
3751
+ *
3752
+ * @param {State} state
3753
+ * Info passed around.
3754
+ * @param {Element} node
3755
+ * Current element.
3756
+ * @returns {Props}
3757
+ * Props.
3758
+ */
3759
+ function createElementProps(state, node) {
3760
+ /** @type {Props} */
3761
+ const props = {}
3762
+ /** @type {string | undefined} */
3763
+ let alignValue
3764
+ /** @type {string} */
3765
+ let prop
3766
+
3767
+ for (prop in node.properties) {
3768
+ if (prop !== 'children' && lib_own.call(node.properties, prop)) {
3769
+ const result = createProperty(state, prop, node.properties[prop])
3770
+
3771
+ if (result) {
3772
+ const [key, value] = result
3773
+
3774
+ if (
3775
+ state.tableCellAlignToStyle &&
3776
+ key === 'align' &&
3777
+ typeof value === 'string' &&
3778
+ tableCellElement.has(node.tagName)
3779
+ ) {
3780
+ alignValue = value
3781
+ } else {
3782
+ props[key] = value
3783
+ }
3784
+ }
3785
+ }
3786
+ }
3787
+
3788
+ if (alignValue) {
3789
+ // Assume style is an object.
3790
+ const style = /** @type {Style} */ (props.style || (props.style = {}))
3791
+ style[state.stylePropertyNameCase === 'css' ? 'text-align' : 'textAlign'] =
3792
+ alignValue
3793
+ }
3794
+
3795
+ return props
3796
+ }
3797
+
3798
+ /**
3799
+ * Create props from a JSX element.
3800
+ *
3801
+ * @param {State} state
3802
+ * Info passed around.
3803
+ * @param {MdxJsxFlowElement | MdxJsxTextElement} node
3804
+ * Current JSX element.
3805
+ * @returns {Props}
3806
+ * Props.
3807
+ */
3808
+ function createJsxElementProps(state, node) {
3809
+ /** @type {Props} */
3810
+ const props = {}
3811
+
3812
+ for (const attribute of node.attributes) {
3813
+ if (attribute.type === 'mdxJsxExpressionAttribute') {
3814
+ if (attribute.data && attribute.data.estree && state.evaluater) {
3815
+ const program = attribute.data.estree
3816
+ const expression = program.body[0]
3817
+ ok(expression.type === 'ExpressionStatement')
3818
+ const objectExpression = expression.expression
3819
+ ok(objectExpression.type === 'ObjectExpression')
3820
+ const property = objectExpression.properties[0]
3821
+ ok(property.type === 'SpreadElement')
3822
+
3823
+ Object.assign(
3824
+ props,
3825
+ state.evaluater.evaluateExpression(property.argument)
3826
+ )
3827
+ } else {
3828
+ crashEstree(state, node.position)
3829
+ }
3830
+ } else {
3831
+ // For JSX, the author is responsible of passing in the correct values.
3832
+ const name = attribute.name
3833
+ /** @type {unknown} */
3834
+ let value
3835
+
3836
+ if (attribute.value && typeof attribute.value === 'object') {
3837
+ if (
3838
+ attribute.value.data &&
3839
+ attribute.value.data.estree &&
3840
+ state.evaluater
3841
+ ) {
3842
+ const program = attribute.value.data.estree
3843
+ const expression = program.body[0]
3844
+ ok(expression.type === 'ExpressionStatement')
3845
+ value = state.evaluater.evaluateExpression(expression.expression)
3846
+ } else {
3847
+ crashEstree(state, node.position)
3848
+ }
3849
+ } else {
3850
+ value = attribute.value === null ? true : attribute.value
3851
+ }
3852
+
3853
+ // Assume a prop.
3854
+ props[name] = /** @type {Props[keyof Props]} */ (value)
3855
+ }
3856
+ }
3857
+
3858
+ return props
3859
+ }
3860
+
3458
3861
  /**
3459
3862
  * Create children.
3460
3863
  *
@@ -3472,17 +3875,27 @@ function createChildren(state, node) {
3472
3875
  /** @type {Map<string, number>} */
3473
3876
  // Note: test this when Solid doesn’t want to merge my upcoming PR.
3474
3877
  /* c8 ignore next */
3475
- const countsByTagName = state.passKeys ? new Map() : emptyMap
3878
+ const countsByName = state.passKeys ? new Map() : emptyMap
3476
3879
 
3477
3880
  while (++index < node.children.length) {
3478
3881
  const child = node.children[index]
3479
3882
  /** @type {string | undefined} */
3480
3883
  let key
3481
3884
 
3482
- if (state.passKeys && child.type === 'element') {
3483
- const count = countsByTagName.get(child.tagName) || 0
3484
- key = child.tagName + '-' + count
3485
- countsByTagName.set(child.tagName, count + 1)
3885
+ if (state.passKeys) {
3886
+ const name =
3887
+ child.type === 'element'
3888
+ ? child.tagName
3889
+ : child.type === 'mdxJsxFlowElement' ||
3890
+ child.type === 'mdxJsxTextElement'
3891
+ ? child.name
3892
+ : undefined
3893
+
3894
+ if (name) {
3895
+ const count = countsByName.get(name) || 0
3896
+ key = name + '-' + count
3897
+ countsByName.set(name, count + 1)
3898
+ }
3486
3899
  }
3487
3900
 
3488
3901
  const result = one(state, child, key)
@@ -3492,72 +3905,11 @@ function createChildren(state, node) {
3492
3905
  return children
3493
3906
  }
3494
3907
 
3495
- /**
3496
- * Handle properties.
3497
- *
3498
- * @param {State} state
3499
- * Info passed around.
3500
- * @param {Array<Parents>} ancestors
3501
- * Stack of parents.
3502
- * @returns {Props}
3503
- * Props for runtime.
3504
- */
3505
- function createProperties(state, ancestors) {
3506
- const node = ancestors[ancestors.length - 1]
3507
- /** @type {Props} */
3508
- const props = {}
3509
- /** @type {string} */
3510
- let prop
3511
-
3512
- if ('properties' in node && node.properties) {
3513
- /** @type {string | undefined} */
3514
- let alignValue
3515
-
3516
- for (prop in node.properties) {
3517
- if (prop !== 'children' && lib_own.call(node.properties, prop)) {
3518
- const result = createProperty(
3519
- state,
3520
- ancestors,
3521
- prop,
3522
- node.properties[prop]
3523
- )
3524
-
3525
- if (result) {
3526
- const [key, value] = result
3527
-
3528
- if (
3529
- state.tableCellAlignToStyle &&
3530
- key === 'align' &&
3531
- typeof value === 'string' &&
3532
- tableCellElement.has(node.tagName)
3533
- ) {
3534
- alignValue = value
3535
- } else {
3536
- props[key] = value
3537
- }
3538
- }
3539
- }
3540
- }
3541
-
3542
- if (alignValue) {
3543
- // Assume style is an object.
3544
- const style = /** @type {Style} */ (props.style || (props.style = {}))
3545
- style[
3546
- state.stylePropertyNameCase === 'css' ? 'text-align' : 'textAlign'
3547
- ] = alignValue
3548
- }
3549
- }
3550
-
3551
- return props
3552
- }
3553
-
3554
3908
  /**
3555
3909
  * Handle a property.
3556
3910
  *
3557
3911
  * @param {State} state
3558
3912
  * Info passed around.
3559
- * @param {Array<Parents>} ancestors
3560
- * Stack of parents.
3561
3913
  * @param {string} prop
3562
3914
  * Key.
3563
3915
  * @param {Array<number | string> | boolean | number | string | null | undefined} value
@@ -3565,7 +3917,7 @@ function createProperties(state, ancestors) {
3565
3917
  * @returns {Field | undefined}
3566
3918
  * Field for runtime, optional.
3567
3919
  */
3568
- function createProperty(state, ancestors, prop, value) {
3920
+ function createProperty(state, prop, value) {
3569
3921
  const info = find(state.schema, prop)
3570
3922
 
3571
3923
  // Ignore nullish and `NaN` values.
@@ -3586,9 +3938,7 @@ function createProperty(state, ancestors, prop, value) {
3586
3938
  // React only accepts `style` as object.
3587
3939
  if (info.property === 'style') {
3588
3940
  let styleObject =
3589
- typeof value === 'object'
3590
- ? value
3591
- : parseStyle(state, ancestors, String(value))
3941
+ typeof value === 'object' ? value : parseStyle(state, String(value))
3592
3942
 
3593
3943
  if (state.stylePropertyNameCase === 'css') {
3594
3944
  styleObject = transformStylesToCssCasing(styleObject)
@@ -3610,8 +3960,6 @@ function createProperty(state, ancestors, prop, value) {
3610
3960
  *
3611
3961
  * @param {State} state
3612
3962
  * Info passed around.
3613
- * @param {Array<Nodes>} ancestors
3614
- * Stack of nodes.
3615
3963
  * @param {string} value
3616
3964
  * CSS declarations.
3617
3965
  * @returns {Style}
@@ -3619,24 +3967,24 @@ function createProperty(state, ancestors, prop, value) {
3619
3967
  * @throws
3620
3968
  * Throws `VFileMessage` when CSS cannot be parsed.
3621
3969
  */
3622
- function parseStyle(state, ancestors, value) {
3970
+ function parseStyle(state, value) {
3623
3971
  /** @type {Style} */
3624
3972
  const result = {}
3625
3973
 
3626
3974
  try {
3627
- node_modules_style_to_object(value, replacer)
3975
+ // @ts-expect-error: `style-to-object` types are broken.
3976
+ esm(value, replacer)
3628
3977
  } catch (error) {
3629
3978
  if (!state.ignoreInvalidStyle) {
3630
3979
  const cause = /** @type {Error} */ (error)
3631
3980
  const message = new VFileMessage('Cannot parse `style` attribute', {
3632
- ancestors,
3981
+ ancestors: state.ancestors,
3633
3982
  cause,
3634
- source: 'hast-util-to-jsx-runtime',
3635
- ruleId: 'style'
3983
+ ruleId: 'style',
3984
+ source: 'hast-util-to-jsx-runtime'
3636
3985
  })
3637
3986
  message.file = state.filePath || undefined
3638
- message.url =
3639
- 'https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-parse-style-attribute'
3987
+ message.url = docs + '#cannot-parse-style-attribute'
3640
3988
 
3641
3989
  throw message
3642
3990
  }
@@ -3667,6 +4015,92 @@ function parseStyle(state, ancestors, value) {
3667
4015
  }
3668
4016
  }
3669
4017
 
4018
+ /**
4019
+ * Create a JSX name from a string.
4020
+ *
4021
+ * @param {State} state
4022
+ * To do.
4023
+ * @param {string} name
4024
+ * Name.
4025
+ * @param {boolean} allowExpression
4026
+ * Allow member expressions and identifiers.
4027
+ * @returns {unknown}
4028
+ * To do.
4029
+ */
4030
+ function findComponentFromName(state, name, allowExpression) {
4031
+ /** @type {Identifier | Literal | MemberExpression} */
4032
+ let result
4033
+
4034
+ if (!allowExpression) {
4035
+ result = {type: 'Literal', value: name}
4036
+ } else if (name.includes('.')) {
4037
+ const identifiers = name.split('.')
4038
+ let index = -1
4039
+ /** @type {Identifier | Literal | MemberExpression | undefined} */
4040
+ let node
4041
+
4042
+ while (++index < identifiers.length) {
4043
+ /** @type {Identifier | Literal} */
4044
+ const prop = lib_name(identifiers[index])
4045
+ ? {type: 'Identifier', name: identifiers[index]}
4046
+ : {type: 'Literal', value: identifiers[index]}
4047
+ node = node
4048
+ ? {
4049
+ type: 'MemberExpression',
4050
+ object: node,
4051
+ property: prop,
4052
+ computed: Boolean(index && prop.type === 'Literal'),
4053
+ optional: false
4054
+ }
4055
+ : prop
4056
+ }
4057
+
4058
+ ok(node, 'always a result')
4059
+ result = node
4060
+ } else {
4061
+ result =
4062
+ lib_name(name) && !/^[a-z]/.test(name)
4063
+ ? {type: 'Identifier', name}
4064
+ : {type: 'Literal', value: name}
4065
+ }
4066
+
4067
+ // Only literals can be passed in `components` currently.
4068
+ // No identifiers / member expressions.
4069
+ if (result.type === 'Literal') {
4070
+ const name = /** @type {keyof JSX.IntrinsicElements} */ (result.value)
4071
+
4072
+ return lib_own.call(state.components, name) ? state.components[name] : name
4073
+ }
4074
+
4075
+ // Assume component.
4076
+ if (state.evaluater) {
4077
+ return state.evaluater.evaluateExpression(result)
4078
+ }
4079
+
4080
+ crashEstree(state)
4081
+ }
4082
+
4083
+ /**
4084
+ * @param {State} state
4085
+ * @param {Position | undefined} [place]
4086
+ * @returns {never}
4087
+ */
4088
+ function crashEstree(state, place) {
4089
+ const message = new VFileMessage(
4090
+ 'Cannot handle MDX estrees without `createEvaluater`',
4091
+ {
4092
+ ancestors: state.ancestors,
4093
+ place,
4094
+ ruleId: 'mdx-estree',
4095
+ source: 'hast-util-to-jsx-runtime'
4096
+ }
4097
+ )
4098
+ message.file = state.filePath || undefined
4099
+ message.url = docs + '#cannot-handle-mdx-estrees-without-createevaluater'
4100
+
4101
+ throw message
4102
+ }
4103
+
3670
4104
  /**
3671
4105
  * Transform a DOM casing style object to a CSS casing style object.
3672
4106
  *
@@ -3775,7 +4209,7 @@ var jsx_runtime = __webpack_require__(246);
3775
4209
  */
3776
4210
 
3777
4211
  /** @type {Options} */
3778
- const emptyOptions = {}
4212
+ const lib_emptyOptions = {}
3779
4213
 
3780
4214
  /**
3781
4215
  * Get the text content of a node or list of nodes.
@@ -3791,7 +4225,7 @@ const emptyOptions = {}
3791
4225
  * Serialized `value`.
3792
4226
  */
3793
4227
  function lib_toString(value, options) {
3794
- const settings = options || emptyOptions
4228
+ const settings = options || lib_emptyOptions
3795
4229
  const includeImageAlt =
3796
4230
  typeof settings.includeImageAlt === 'boolean'
3797
4231
  ? settings.includeImageAlt
@@ -14430,7 +14864,7 @@ const serializer = (strict, json, $, _) => {
14430
14864
  * fallback to the polyfill if present.
14431
14865
  * @returns {Record[]}
14432
14866
  */
14433
- /* harmony default export */ const esm = (typeof structuredClone === "function" ?
14867
+ /* harmony default export */ const structured_clone_esm = (typeof structuredClone === "function" ?
14434
14868
  /* c8 ignore start */
14435
14869
  (any, options) => (
14436
14870
  options && ('json' in options || 'lossy' in options) ?
@@ -15042,7 +15476,7 @@ function footer(state) {
15042
15476
  type: 'element',
15043
15477
  tagName: footnoteLabelTagName,
15044
15478
  properties: {
15045
- ...esm(footnoteLabelProperties),
15479
+ ...structured_clone_esm(footnoteLabelProperties),
15046
15480
  id: 'footnote-label'
15047
15481
  },
15048
15482
  children: [{type: 'text', value: footnoteLabel}]
@@ -16889,7 +17323,7 @@ function paragraph(state, node) {
16889
17323
  * @returns {HastParents}
16890
17324
  * hast node.
16891
17325
  */
16892
- function root(state, node) {
17326
+ function root_root(state, node) {
16893
17327
  /** @type {HastRoot} */
16894
17328
  const result = {type: 'root', children: state.wrap(state.all(node))}
16895
17329
  state.patch(node, result)
@@ -17274,7 +17708,7 @@ const handlers_handlers = {
17274
17708
  list: list_list,
17275
17709
  paragraph: paragraph,
17276
17710
  // @ts-expect-error: root is different, but hard to type.
17277
- root: root,
17711
+ root: root_root,
17278
17712
  strong: strong,
17279
17713
  table: table,
17280
17714
  tableCell: tableCell,
@@ -17548,7 +17982,7 @@ function createState(tree, options) {
17548
17982
  if (state.options.passThrough && state.options.passThrough.includes(type)) {
17549
17983
  if ('children' in node) {
17550
17984
  const {children, ...shallow} = node
17551
- const result = esm(shallow)
17985
+ const result = structured_clone_esm(shallow)
17552
17986
  // @ts-expect-error: TS doesn’t understand…
17553
17987
  result.children = state.all(node)
17554
17988
  // @ts-expect-error: TS doesn’t understand…
@@ -17556,7 +17990,7 @@ function createState(tree, options) {
17556
17990
  }
17557
17991
 
17558
17992
  // @ts-expect-error: it’s custom.
17559
- return esm(node)
17993
+ return structured_clone_esm(node)
17560
17994
  }
17561
17995
 
17562
17996
  const unknown = state.options.unknownHandler || defaultUnknownHandler
@@ -17666,7 +18100,7 @@ function applyData(from, to) {
17666
18100
  }
17667
18101
 
17668
18102
  if (result.type === 'element' && hProperties) {
17669
- Object.assign(result.properties, esm(hProperties))
18103
+ Object.assign(result.properties, structured_clone_esm(hProperties))
17670
18104
  }
17671
18105
 
17672
18106
  if (
@@ -23200,7 +23634,7 @@ function emphasisPeek(_, _1, state) {
23200
23634
  */
23201
23635
 
23202
23636
  /** @type {Options} */
23203
- const lib_emptyOptions = {}
23637
+ const mdast_util_to_string_lib_emptyOptions = {}
23204
23638
 
23205
23639
  /**
23206
23640
  * Get the text content of a node or list of nodes.
@@ -23216,7 +23650,7 @@ const lib_emptyOptions = {}
23216
23650
  * Serialized `value`.
23217
23651
  */
23218
23652
  function mdast_util_to_string_lib_toString(value, options) {
23219
- const settings = options || lib_emptyOptions
23653
+ const settings = options || mdast_util_to_string_lib_emptyOptions
23220
23654
  const includeImageAlt =
23221
23655
  typeof settings.includeImageAlt === 'boolean'
23222
23656
  ? settings.includeImageAlt
@@ -24276,7 +24710,7 @@ const phrasing =
24276
24710
  * @param {Info} info
24277
24711
  * @returns {string}
24278
24712
  */
24279
- function root_root(node, _, state, info) {
24713
+ function handle_root_root(node, _, state, info) {
24280
24714
  // Note: `html` nodes are ambiguous.
24281
24715
  const hasPhrasing = node.children.some(function (d) {
24282
24716
  return phrasing(d)
@@ -24467,7 +24901,7 @@ const handle = {
24467
24901
  list: handle_list_list,
24468
24902
  listItem: list_item_listItem,
24469
24903
  paragraph: paragraph_paragraph,
24470
- root: root_root,
24904
+ root: handle_root_root,
24471
24905
  strong: strong_strong,
24472
24906
  text: handle_text_text,
24473
24907
  thematicBreak: handle_thematic_break_thematicBreak
@@ -30810,7 +31244,7 @@ function hast_util_from_parse5_lib_one(state, node) {
30810
31244
  // Element.
30811
31245
  default: {
30812
31246
  const reference = /** @type {P5Element} */ (node)
30813
- result = lib_element(state, reference)
31247
+ result = hast_util_from_parse5_lib_element(state, reference)
30814
31248
  return result
30815
31249
  }
30816
31250
  }
@@ -30850,7 +31284,7 @@ function hast_util_from_parse5_lib_all(state, nodes) {
30850
31284
  * @returns {Element}
30851
31285
  * hast node.
30852
31286
  */
30853
- function lib_element(state, node) {
31287
+ function hast_util_from_parse5_lib_element(state, node) {
30854
31288
  const schema = state.schema
30855
31289
 
30856
31290
  state.schema = node.namespaceURI === webNamespaces.svg ? property_information_svg : property_information_html
@@ -31187,7 +31621,7 @@ const hast_util_to_parse5_lib_emptyOptions = {}
31187
31621
 
31188
31622
  const hast_util_to_parse5_lib_own = {}.hasOwnProperty
31189
31623
 
31190
- const hast_util_to_parse5_lib_one = zwitch('type', {handlers: {root: lib_root, element: hast_util_to_parse5_lib_element, text: lib_text, comment, doctype}})
31624
+ const hast_util_to_parse5_lib_one = zwitch('type', {handlers: {root: lib_root, element: hast_util_to_parse5_lib_element, text: hast_util_to_parse5_lib_text, comment, doctype}})
31191
31625
 
31192
31626
  /**
31193
31627
  * Transform a hast tree to a `parse5` AST.
@@ -31268,7 +31702,7 @@ function doctype(node) {
31268
31702
  * @returns {Parse5Text}
31269
31703
  * Parse5 node.
31270
31704
  */
31271
- function lib_text(node) {
31705
+ function hast_util_to_parse5_lib_text(node) {
31272
31706
  /** @type {Parse5Text} */
31273
31707
  const result = {
31274
31708
  nodeName: '#text',
@@ -41029,8 +41463,8 @@ function createParse5Location(node) {
41029
41463
  */
41030
41464
  function cloneWithoutChildren(node) {
41031
41465
  return 'children' in node
41032
- ? esm({...node, children: []})
41033
- : esm(node)
41466
+ ? structured_clone_esm({...node, children: []})
41467
+ : structured_clone_esm(node)
41034
41468
  }
41035
41469
 
41036
41470
  ;// CONCATENATED MODULE: ../node_modules/rehype-raw/lib/index.js
@@ -41116,7 +41550,7 @@ function useCopied(container) {
41116
41550
  ;// CONCATENATED MODULE: ../node_modules/@uiw/react-markdown-preview/esm/preview.js
41117
41551
 
41118
41552
 
41119
- var _excluded = ["prefixCls", "className", "source", "style", "disableCopy", "skipHtml", "onScroll", "onMouseOver", "pluginsFilter", "rehypeRewrite", "wrapperElement", "warpperElement"];
41553
+ var _excluded = ["prefixCls", "className", "source", "style", "disableCopy", "skipHtml", "onScroll", "onMouseOver", "pluginsFilter", "rehypeRewrite", "wrapperElement", "warpperElement", "urlTransform"];
41120
41554
 
41121
41555
 
41122
41556
 
@@ -41124,7 +41558,11 @@ var _excluded = ["prefixCls", "className", "source", "style", "disableCopy", "sk
41124
41558
 
41125
41559
 
41126
41560
 
41561
+ /**
41562
+ * https://github.com/uiwjs/react-md-editor/issues/607
41563
+ */
41127
41564
 
41565
+ var preview_defaultUrlTransform = url => url;
41128
41566
  /* harmony default export */ const preview = (/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().forwardRef((props, ref) => {
41129
41567
  var {
41130
41568
  prefixCls = 'wmde-markdown wmde-markdown-color',
@@ -41137,7 +41575,8 @@ var _excluded = ["prefixCls", "className", "source", "style", "disableCopy", "sk
41137
41575
  onMouseOver,
41138
41576
  pluginsFilter,
41139
41577
  wrapperElement = {},
41140
- warpperElement = {}
41578
+ warpperElement = {},
41579
+ urlTransform
41141
41580
  } = props,
41142
41581
  other = _objectWithoutPropertiesLoose(props, _excluded);
41143
41582
  var mdp = external_root_React_commonjs2_react_commonjs_react_amd_react_default().useRef(null);
@@ -41169,1244 +41608,200 @@ var _excluded = ["prefixCls", "className", "source", "style", "disableCopy", "sk
41169
41608
  style: style,
41170
41609
  children: /*#__PURE__*/(0,jsx_runtime.jsx)(Markdown, _extends({}, customProps, other, {
41171
41610
  skipHtml: skipHtml,
41611
+ urlTransform: urlTransform || preview_defaultUrlTransform,
41172
41612
  rehypePlugins: pluginsFilter ? pluginsFilter('rehype', rehypePlugins) : rehypePlugins,
41173
41613
  remarkPlugins: pluginsFilter ? pluginsFilter('remark', remarkPlugins) : remarkPlugins,
41174
41614
  children: source || ''
41175
41615
  }))
41176
41616
  }));
41177
41617
  }));
41178
- ;// CONCATENATED MODULE: ../node_modules/rehype-prism-plus/node_modules/unist-util-is/lib/index.js
41179
- /**
41180
- * @typedef {import('unist').Node} Node
41181
- * @typedef {import('unist').Parent} Parent
41182
- */
41183
-
41184
- /**
41185
- * @typedef {Record<string, unknown>} Props
41186
- * @typedef {null | undefined | string | Props | TestFunctionAnything | Array<string | Props | TestFunctionAnything>} Test
41187
- * Check for an arbitrary node, unaware of TypeScript inferral.
41188
- *
41189
- * @callback TestFunctionAnything
41190
- * Check if a node passes a test, unaware of TypeScript inferral.
41191
- * @param {unknown} this
41192
- * The given context.
41193
- * @param {Node} node
41194
- * A node.
41195
- * @param {number | null | undefined} [index]
41196
- * The node’s position in its parent.
41197
- * @param {Parent | null | undefined} [parent]
41198
- * The node’s parent.
41199
- * @returns {boolean | void}
41200
- * Whether this node passes the test.
41201
- */
41202
-
41203
- /**
41204
- * @template {Node} Kind
41205
- * Node type.
41206
- * @typedef {Kind['type'] | Partial<Kind> | TestFunctionPredicate<Kind> | Array<Kind['type'] | Partial<Kind> | TestFunctionPredicate<Kind>>} PredicateTest
41207
- * Check for a node that can be inferred by TypeScript.
41208
- */
41209
-
41210
- /**
41211
- * Check if a node passes a certain test.
41212
- *
41213
- * @template {Node} Kind
41214
- * Node type.
41215
- * @callback TestFunctionPredicate
41216
- * Complex test function for a node that can be inferred by TypeScript.
41217
- * @param {Node} node
41218
- * A node.
41219
- * @param {number | null | undefined} [index]
41220
- * The node’s position in its parent.
41221
- * @param {Parent | null | undefined} [parent]
41222
- * The node’s parent.
41223
- * @returns {node is Kind}
41224
- * Whether this node passes the test.
41225
- */
41226
-
41227
- /**
41228
- * @callback AssertAnything
41229
- * Check that an arbitrary value is a node, unaware of TypeScript inferral.
41230
- * @param {unknown} [node]
41231
- * Anything (typically a node).
41232
- * @param {number | null | undefined} [index]
41233
- * The node’s position in its parent.
41234
- * @param {Parent | null | undefined} [parent]
41235
- * The node’s parent.
41236
- * @returns {boolean}
41237
- * Whether this is a node and passes a test.
41238
- */
41239
-
41240
- /**
41241
- * Check if a node is a node and passes a certain node test.
41242
- *
41243
- * @template {Node} Kind
41244
- * Node type.
41245
- * @callback AssertPredicate
41246
- * Check that an arbitrary value is a specific node, aware of TypeScript.
41247
- * @param {unknown} [node]
41248
- * Anything (typically a node).
41249
- * @param {number | null | undefined} [index]
41250
- * The node’s position in its parent.
41251
- * @param {Parent | null | undefined} [parent]
41252
- * The node’s parent.
41253
- * @returns {node is Kind}
41254
- * Whether this is a node and passes a test.
41255
- */
41256
-
41618
+ ;// CONCATENATED MODULE: ../node_modules/hast-util-to-string/lib/index.js
41257
41619
  /**
41258
- * Check if `node` is a `Node` and whether it passes the given test.
41259
- *
41260
- * @param node
41261
- * Thing to check, typically `Node`.
41262
- * @param test
41263
- * A check for a specific node.
41264
- * @param index
41265
- * The node’s position in its parent.
41266
- * @param parent
41267
- * The node’s parent.
41268
- * @returns
41269
- * Whether `node` is a node and passes a test.
41620
+ * @typedef {import('hast').Nodes} Nodes
41621
+ * @typedef {import('hast').Parents} Parents
41270
41622
  */
41271
- const lib_is =
41272
- /**
41273
- * @type {(
41274
- * (() => false) &
41275
- * (<Kind extends Node = Node>(node: unknown, test: PredicateTest<Kind>, index: number, parent: Parent, context?: unknown) => node is Kind) &
41276
- * (<Kind extends Node = Node>(node: unknown, test: PredicateTest<Kind>, index?: null | undefined, parent?: null | undefined, context?: unknown) => node is Kind) &
41277
- * ((node: unknown, test: Test, index: number, parent: Parent, context?: unknown) => boolean) &
41278
- * ((node: unknown, test?: Test, index?: null | undefined, parent?: null | undefined, context?: unknown) => boolean)
41279
- * )}
41280
- */
41281
- (
41282
- /**
41283
- * @param {unknown} [node]
41284
- * @param {Test} [test]
41285
- * @param {number | null | undefined} [index]
41286
- * @param {Parent | null | undefined} [parent]
41287
- * @param {unknown} [context]
41288
- * @returns {boolean}
41289
- */
41290
- // eslint-disable-next-line max-params
41291
- function is(node, test, index, parent, context) {
41292
- const check = lib_convert(test)
41293
-
41294
- if (
41295
- index !== undefined &&
41296
- index !== null &&
41297
- (typeof index !== 'number' ||
41298
- index < 0 ||
41299
- index === Number.POSITIVE_INFINITY)
41300
- ) {
41301
- throw new Error('Expected positive finite index')
41302
- }
41303
-
41304
- if (
41305
- parent !== undefined &&
41306
- parent !== null &&
41307
- (!is(parent) || !parent.children)
41308
- ) {
41309
- throw new Error('Expected parent node')
41310
- }
41311
-
41312
- if (
41313
- (parent === undefined || parent === null) !==
41314
- (index === undefined || index === null)
41315
- ) {
41316
- throw new Error('Expected both parent and index')
41317
- }
41318
-
41319
- // @ts-expect-error Looks like a node.
41320
- return node && node.type && typeof node.type === 'string'
41321
- ? Boolean(check.call(context, node, index, parent))
41322
- : false
41323
- }
41324
- )
41325
41623
 
41326
41624
  /**
41327
- * Generate an assertion from a test.
41328
- *
41329
- * Useful if you’re going to test many nodes, for example when creating a
41330
- * utility where something else passes a compatible test.
41331
- *
41332
- * The created function is a bit faster because it expects valid input only:
41333
- * a `node`, `index`, and `parent`.
41625
+ * Get the plain-text value of a hast node.
41334
41626
  *
41335
- * @param test
41336
- * * when nullish, checks if `node` is a `Node`.
41337
- * * when `string`, works like passing `(node) => node.type === test`.
41338
- * * when `function` checks if function passed the node is true.
41339
- * * when `object`, checks that all keys in test are in node, and that they have (strictly) equal values.
41340
- * * when `array`, checks if any one of the subtests pass.
41341
- * @returns
41342
- * An assertion.
41343
- */
41344
- const lib_convert =
41345
- /**
41346
- * @type {(
41347
- * (<Kind extends Node>(test: PredicateTest<Kind>) => AssertPredicate<Kind>) &
41348
- * ((test?: Test) => AssertAnything)
41349
- * )}
41350
- */
41351
- (
41352
- /**
41353
- * @param {Test} [test]
41354
- * @returns {AssertAnything}
41355
- */
41356
- function (test) {
41357
- if (test === undefined || test === null) {
41358
- return unist_util_is_lib_ok
41359
- }
41360
-
41361
- if (typeof test === 'string') {
41362
- return lib_typeFactory(test)
41363
- }
41364
-
41365
- if (typeof test === 'object') {
41366
- return Array.isArray(test) ? lib_anyFactory(test) : lib_propsFactory(test)
41367
- }
41368
-
41369
- if (typeof test === 'function') {
41370
- return lib_castFactory(test)
41371
- }
41372
-
41373
- throw new Error('Expected function, string, or object as test')
41374
- }
41375
- )
41376
-
41377
- /**
41378
- * @param {Array<string | Props | TestFunctionAnything>} tests
41379
- * @returns {AssertAnything}
41627
+ * @param {Nodes} node
41628
+ * Node to serialize.
41629
+ * @returns {string}
41630
+ * Serialized node.
41380
41631
  */
41381
- function lib_anyFactory(tests) {
41382
- /** @type {Array<AssertAnything>} */
41383
- const checks = []
41384
- let index = -1
41385
-
41386
- while (++index < tests.length) {
41387
- checks[index] = lib_convert(tests[index])
41632
+ function hast_util_to_string_lib_toString(node) {
41633
+ // “The concatenation of data of all the Text node descendants of the context
41634
+ // object, in tree order.”
41635
+ if ('children' in node) {
41636
+ return hast_util_to_string_lib_all(node)
41388
41637
  }
41389
41638
 
41390
- return lib_castFactory(any)
41391
-
41392
- /**
41393
- * @this {unknown}
41394
- * @param {Array<unknown>} parameters
41395
- * @returns {boolean}
41396
- */
41397
- function any(...parameters) {
41398
- let index = -1
41399
-
41400
- while (++index < checks.length) {
41401
- if (checks[index].call(this, ...parameters)) return true
41402
- }
41403
-
41404
- return false
41405
- }
41639
+ // “Context object’s data.”
41640
+ return 'value' in node ? node.value : ''
41406
41641
  }
41407
41642
 
41408
41643
  /**
41409
- * Turn an object into a test for a node with a certain fields.
41410
- *
41411
- * @param {Props} check
41412
- * @returns {AssertAnything}
41644
+ * @param {Nodes} node
41645
+ * Node.
41646
+ * @returns {string}
41647
+ * Serialized node.
41413
41648
  */
41414
- function lib_propsFactory(check) {
41415
- return lib_castFactory(all)
41416
-
41417
- /**
41418
- * @param {Node} node
41419
- * @returns {boolean}
41420
- */
41421
- function all(node) {
41422
- /** @type {string} */
41423
- let key
41424
-
41425
- for (key in check) {
41426
- // @ts-expect-error: hush, it sure works as an index.
41427
- if (node[key] !== check[key]) return false
41428
- }
41429
-
41430
- return true
41649
+ function hast_util_to_string_lib_one(node) {
41650
+ if (node.type === 'text') {
41651
+ return node.value
41431
41652
  }
41432
- }
41433
-
41434
- /**
41435
- * Turn a string into a test for a node with a certain type.
41436
- *
41437
- * @param {string} check
41438
- * @returns {AssertAnything}
41439
- */
41440
- function lib_typeFactory(check) {
41441
- return lib_castFactory(type)
41442
41653
 
41443
- /**
41444
- * @param {Node} node
41445
- */
41446
- function type(node) {
41447
- return node && node.type === check
41448
- }
41654
+ return 'children' in node ? hast_util_to_string_lib_all(node) : ''
41449
41655
  }
41450
41656
 
41451
41657
  /**
41452
- * Turn a custom test into a test for a node that passes that test.
41453
- *
41454
- * @param {TestFunctionAnything} check
41455
- * @returns {AssertAnything}
41658
+ * @param {Parents} node
41659
+ * Node.
41660
+ * @returns {string}
41661
+ * Serialized node.
41456
41662
  */
41457
- function lib_castFactory(check) {
41458
- return assertion
41663
+ function hast_util_to_string_lib_all(node) {
41664
+ let index = -1
41665
+ /** @type {Array<string>} */
41666
+ const result = []
41459
41667
 
41460
- /**
41461
- * @this {unknown}
41462
- * @param {unknown} node
41463
- * @param {Array<unknown>} parameters
41464
- * @returns {boolean}
41465
- */
41466
- function assertion(node, ...parameters) {
41467
- return Boolean(
41468
- node &&
41469
- typeof node === 'object' &&
41470
- 'type' in node &&
41471
- // @ts-expect-error: fine.
41472
- Boolean(check.call(this, node, ...parameters))
41473
- )
41668
+ while (++index < node.children.length) {
41669
+ result[index] = hast_util_to_string_lib_one(node.children[index])
41474
41670
  }
41475
- }
41476
-
41477
- function unist_util_is_lib_ok() {
41478
- return true
41479
- }
41480
41671
 
41481
- ;// CONCATENATED MODULE: ../node_modules/rehype-prism-plus/node_modules/unist-util-visit-parents/lib/color.browser.js
41482
- /**
41483
- * @param {string} d
41484
- * @returns {string}
41485
- */
41486
- function color_browser_color(d) {
41487
- return d
41672
+ return result.join('')
41488
41673
  }
41489
41674
 
41490
- ;// CONCATENATED MODULE: ../node_modules/rehype-prism-plus/node_modules/unist-util-visit-parents/lib/index.js
41675
+ ;// CONCATENATED MODULE: ../node_modules/unist-util-filter/lib/index.js
41491
41676
  /**
41492
41677
  * @typedef {import('unist').Node} Node
41493
41678
  * @typedef {import('unist').Parent} Parent
41494
- * @typedef {import('unist-util-is').Test} Test
41495
- */
41496
-
41497
- /**
41498
- * @typedef {boolean | 'skip'} Action
41499
- * Union of the action types.
41500
- *
41501
- * @typedef {number} Index
41502
- * Move to the sibling at `index` next (after node itself is completely
41503
- * traversed).
41504
- *
41505
- * Useful if mutating the tree, such as removing the node the visitor is
41506
- * currently on, or any of its previous siblings.
41507
- * Results less than 0 or greater than or equal to `children.length` stop
41508
- * traversing the parent.
41509
- *
41510
- * @typedef {[(Action | null | undefined | void)?, (Index | null | undefined)?]} ActionTuple
41511
- * List with one or two values, the first an action, the second an index.
41512
- *
41513
- * @typedef {Action | ActionTuple | Index | null | undefined | void} VisitorResult
41514
- * Any value that can be returned from a visitor.
41515
- */
41516
-
41517
- /**
41518
- * @template {Node} [Visited=Node]
41519
- * Visited node type.
41520
- * @template {Parent} [Ancestor=Parent]
41521
- * Ancestor type.
41522
- * @callback Visitor
41523
- * Handle a node (matching `test`, if given).
41524
- *
41525
- * Visitors are free to transform `node`.
41526
- * They can also transform the parent of node (the last of `ancestors`).
41527
- *
41528
- * Replacing `node` itself, if `SKIP` is not returned, still causes its
41529
- * descendants to be walked (which is a bug).
41530
- *
41531
- * When adding or removing previous siblings of `node` (or next siblings, in
41532
- * case of reverse), the `Visitor` should return a new `Index` to specify the
41533
- * sibling to traverse after `node` is traversed.
41534
- * Adding or removing next siblings of `node` (or previous siblings, in case
41535
- * of reverse) is handled as expected without needing to return a new `Index`.
41536
- *
41537
- * Removing the children property of an ancestor still results in them being
41538
- * traversed.
41539
- * @param {Visited} node
41540
- * Found node.
41541
- * @param {Array<Ancestor>} ancestors
41542
- * Ancestors of `node`.
41543
- * @returns {VisitorResult}
41544
- * What to do next.
41545
41679
  *
41546
- * An `Index` is treated as a tuple of `[CONTINUE, Index]`.
41547
- * An `Action` is treated as a tuple of `[Action]`.
41680
+ * @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test
41681
+ * Test from `unist-util-is`.
41548
41682
  *
41549
- * Passing a tuple back only makes sense if the `Action` is `SKIP`.
41550
- * When the `Action` is `EXIT`, that action can be returned.
41551
- * When the `Action` is `CONTINUE`, `Index` can be returned.
41683
+ * Note: we have remove and add `undefined`, because otherwise when generating
41684
+ * automatic `.d.ts` files, TS tries to flatten paths from a local perspective,
41685
+ * which doesn’t work when publishing on npm.
41552
41686
  */
41553
41687
 
41554
41688
  /**
41555
- * @template {Node} [Tree=Node]
41556
- * Tree type.
41557
- * @template {Test} [Check=string]
41558
- * Test type.
41559
- * @typedef {Visitor<import('./complex-types.js').Matches<import('./complex-types.js').InclusiveDescendant<Tree>, Check>, Extract<import('./complex-types.js').InclusiveDescendant<Tree>, Parent>>} BuildVisitor
41560
- * Build a typed `Visitor` function from a tree and a test.
41561
- *
41562
- * It will infer which values are passed as `node` and which as `parents`.
41689
+ * @typedef Options
41690
+ * Configuration (optional).
41691
+ * @property {boolean | null | undefined} [cascade=true]
41692
+ * Whether to drop parent nodes if they had children, but all their children
41693
+ * were filtered out (default: `true`).
41563
41694
  */
41564
41695
 
41565
41696
 
41566
41697
 
41698
+ const unist_util_filter_lib_own = {}.hasOwnProperty
41567
41699
 
41568
41700
  /**
41569
- * Continue traversing as normal.
41570
- */
41571
- const lib_CONTINUE = true
41572
-
41573
- /**
41574
- * Stop traversing immediately.
41575
- */
41576
- const lib_EXIT = false
41577
-
41578
- /**
41579
- * Do not traverse this node’s children.
41580
- */
41581
- const lib_SKIP = 'skip'
41582
-
41583
- /**
41584
- * Visit nodes, with ancestral information.
41701
+ * Create a new `tree` of copies of all nodes that pass `test`.
41585
41702
  *
41586
- * This algorithm performs *depth-first* *tree traversal* in *preorder*
41587
- * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).
41703
+ * The tree is walked in *preorder* (NLR), visiting the node itself, then its
41704
+ * head, etc.
41588
41705
  *
41589
- * You can choose for which nodes `visitor` is called by passing a `test`.
41590
- * For complex tests, you should test yourself in `visitor`, as it will be
41591
- * faster and will have improved type information.
41706
+ * @template {Node} Tree
41707
+ * @template {Test} Check
41592
41708
  *
41593
- * Walking the tree is an intensive task.
41594
- * Make use of the return values of the visitor when possible.
41595
- * Instead of walking a tree multiple times, walk it once, use `unist-util-is`
41596
- * to check if a node matches, and then perform different operations.
41709
+ * @overload
41710
+ * @param {Tree} tree
41711
+ * @param {Options | null | undefined} options
41712
+ * @param {Check} test
41713
+ * @returns {import('./complex-types.js').Matches<Tree, Check>}
41597
41714
  *
41598
- * You can change the tree.
41599
- * See `Visitor` for more info.
41715
+ * @overload
41716
+ * @param {Tree} tree
41717
+ * @param {Check} test
41718
+ * @returns {import('./complex-types.js').Matches<Tree, Check>}
41600
41719
  *
41601
- * @param tree
41602
- * Tree to traverse.
41603
- * @param test
41604
- * `unist-util-is`-compatible test
41605
- * @param visitor
41606
- * Handle each node.
41607
- * @param reverse
41608
- * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).
41609
- * @returns
41610
- * Nothing.
41720
+ * @overload
41721
+ * @param {Tree} tree
41722
+ * @param {null | undefined} [options]
41723
+ * @returns {Tree}
41724
+ *
41725
+ * @param {Node} tree
41726
+ * Tree to filter.
41727
+ * @param {Options | Test} [options]
41728
+ * Configuration (optional).
41729
+ * @param {Test} [test]
41730
+ * `unist-util-is` compatible test.
41731
+ * @returns {Node | undefined}
41732
+ * New filtered tree.
41733
+ *
41734
+ * `undefined` is returned if `tree` itself didn’t pass the test, or is
41735
+ * cascaded away.
41611
41736
  */
41612
- const lib_visitParents =
41613
- /**
41614
- * @type {(
41615
- * (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: BuildVisitor<Tree, Check>, reverse?: boolean | null | undefined) => void) &
41616
- * (<Tree extends Node>(tree: Tree, visitor: BuildVisitor<Tree>, reverse?: boolean | null | undefined) => void)
41617
- * )}
41618
- */
41619
- (
41620
- /**
41621
- * @param {Node} tree
41622
- * @param {Test} test
41623
- * @param {Visitor<Node>} visitor
41624
- * @param {boolean | null | undefined} [reverse]
41625
- * @returns {void}
41626
- */
41627
- function (tree, test, visitor, reverse) {
41628
- if (typeof test === 'function' && typeof visitor !== 'function') {
41629
- reverse = visitor
41630
- // @ts-expect-error no visitor given, so `visitor` is test.
41631
- visitor = test
41632
- test = null
41633
- }
41634
-
41635
- const is = lib_convert(test)
41636
- const step = reverse ? -1 : 1
41637
-
41638
- factory(tree, undefined, [])()
41639
-
41640
- /**
41641
- * @param {Node} node
41642
- * @param {number | undefined} index
41643
- * @param {Array<Parent>} parents
41644
- */
41645
- function factory(node, index, parents) {
41646
- /** @type {Record<string, unknown>} */
41647
- // @ts-expect-error: hush
41648
- const value = node && typeof node === 'object' ? node : {}
41649
-
41650
- if (typeof value.type === 'string') {
41651
- const name =
41652
- // `hast`
41653
- typeof value.tagName === 'string'
41654
- ? value.tagName
41655
- : // `xast`
41656
- typeof value.name === 'string'
41657
- ? value.name
41658
- : undefined
41659
-
41660
- Object.defineProperty(visit, 'name', {
41661
- value:
41662
- 'node (' + color_browser_color(node.type + (name ? '<' + name + '>' : '')) + ')'
41663
- })
41664
- }
41737
+ function filter(tree, options, test) {
41738
+ const is = convert(test || options)
41739
+ const cascadeRaw =
41740
+ options && typeof options === 'object' && 'cascade' in options
41741
+ ? /** @type {boolean | null | undefined} */ (options.cascade)
41742
+ : undefined
41743
+ const cascade =
41744
+ cascadeRaw === undefined || cascadeRaw === null ? true : cascadeRaw
41665
41745
 
41666
- return visit
41746
+ return preorder(tree)
41667
41747
 
41668
- function visit() {
41669
- /** @type {ActionTuple} */
41670
- let result = []
41671
- /** @type {ActionTuple} */
41672
- let subresult
41673
- /** @type {number} */
41674
- let offset
41675
- /** @type {Array<Parent>} */
41676
- let grandparents
41748
+ /**
41749
+ * @param {Node} node
41750
+ * Current node.
41751
+ * @param {number | undefined} [index]
41752
+ * Index of `node` in `parent`.
41753
+ * @param {Parent | undefined} [parentNode]
41754
+ * Parent node.
41755
+ * @returns {Node | undefined}
41756
+ * Shallow copy of `node`.
41757
+ */
41758
+ function preorder(node, index, parentNode) {
41759
+ /** @type {Array<Node>} */
41760
+ const children = []
41677
41761
 
41678
- if (!test || is(node, index, parents[parents.length - 1] || null)) {
41679
- result = lib_toResult(visitor(node, parents))
41762
+ if (!is(node, index, parentNode)) return undefined
41680
41763
 
41681
- if (result[0] === lib_EXIT) {
41682
- return result
41683
- }
41684
- }
41764
+ if (lib_parent(node)) {
41765
+ let childIndex = -1
41685
41766
 
41686
- // @ts-expect-error looks like a parent.
41687
- if (node.children && result[0] !== lib_SKIP) {
41688
- // @ts-expect-error looks like a parent.
41689
- offset = (reverse ? node.children.length : -1) + step
41690
- // @ts-expect-error looks like a parent.
41691
- grandparents = parents.concat(node)
41767
+ while (++childIndex < node.children.length) {
41768
+ const result = preorder(node.children[childIndex], childIndex, node)
41692
41769
 
41693
- // @ts-expect-error looks like a parent.
41694
- while (offset > -1 && offset < node.children.length) {
41695
- // @ts-expect-error looks like a parent.
41696
- subresult = factory(node.children[offset], offset, grandparents)()
41770
+ if (result) {
41771
+ children.push(result)
41772
+ }
41773
+ }
41697
41774
 
41698
- if (subresult[0] === lib_EXIT) {
41699
- return subresult
41700
- }
41775
+ if (cascade && node.children.length > 0 && children.length === 0) {
41776
+ return undefined
41777
+ }
41778
+ }
41701
41779
 
41702
- offset =
41703
- typeof subresult[1] === 'number' ? subresult[1] : offset + step
41704
- }
41705
- }
41780
+ // Create a shallow clone, using the new children.
41781
+ /** @type {typeof node} */
41782
+ // @ts-expect-error all the fields will be copied over.
41783
+ const next = {}
41784
+ /** @type {string} */
41785
+ let key
41706
41786
 
41707
- return result
41708
- }
41787
+ for (key in node) {
41788
+ if (unist_util_filter_lib_own.call(node, key)) {
41789
+ // @ts-expect-error: Looks like a record.
41790
+ next[key] = key === 'children' ? children : node[key]
41709
41791
  }
41710
41792
  }
41711
- )
41712
-
41713
- /**
41714
- * Turn a return value into a clean result.
41715
- *
41716
- * @param {VisitorResult} value
41717
- * Valid return values from visitors.
41718
- * @returns {ActionTuple}
41719
- * Clean result.
41720
- */
41721
- function lib_toResult(value) {
41722
- if (Array.isArray(value)) {
41723
- return value
41724
- }
41725
41793
 
41726
- if (typeof value === 'number') {
41727
- return [lib_CONTINUE, value]
41794
+ return next
41728
41795
  }
41729
-
41730
- return [value]
41731
41796
  }
41732
41797
 
41733
- ;// CONCATENATED MODULE: ../node_modules/rehype-prism-plus/node_modules/unist-util-visit/lib/index.js
41734
41798
  /**
41735
- * @typedef {import('unist').Node} Node
41736
- * @typedef {import('unist').Parent} Parent
41737
- * @typedef {import('unist-util-is').Test} Test
41738
- * @typedef {import('unist-util-visit-parents').VisitorResult} VisitorResult
41799
+ * @param {Node} node
41800
+ * @returns {node is Parent}
41739
41801
  */
41740
-
41741
- /**
41742
- * Check if `Child` can be a child of `Ancestor`.
41743
- *
41744
- * Returns the ancestor when `Child` can be a child of `Ancestor`, or returns
41745
- * `never`.
41746
- *
41747
- * @template {Node} Ancestor
41748
- * Node type.
41749
- * @template {Node} Child
41750
- * Node type.
41751
- * @typedef {(
41752
- * Ancestor extends Parent
41753
- * ? Child extends Ancestor['children'][number]
41754
- * ? Ancestor
41755
- * : never
41756
- * : never
41757
- * )} ParentsOf
41758
- */
41759
-
41760
- /**
41761
- * @template {Node} [Visited=Node]
41762
- * Visited node type.
41763
- * @template {Parent} [Ancestor=Parent]
41764
- * Ancestor type.
41765
- * @callback Visitor
41766
- * Handle a node (matching `test`, if given).
41767
- *
41768
- * Visitors are free to transform `node`.
41769
- * They can also transform `parent`.
41770
- *
41771
- * Replacing `node` itself, if `SKIP` is not returned, still causes its
41772
- * descendants to be walked (which is a bug).
41773
- *
41774
- * When adding or removing previous siblings of `node` (or next siblings, in
41775
- * case of reverse), the `Visitor` should return a new `Index` to specify the
41776
- * sibling to traverse after `node` is traversed.
41777
- * Adding or removing next siblings of `node` (or previous siblings, in case
41778
- * of reverse) is handled as expected without needing to return a new `Index`.
41779
- *
41780
- * Removing the children property of `parent` still results in them being
41781
- * traversed.
41782
- * @param {Visited} node
41783
- * Found node.
41784
- * @param {Visited extends Node ? number | null : never} index
41785
- * Index of `node` in `parent`.
41786
- * @param {Ancestor extends Node ? Ancestor | null : never} parent
41787
- * Parent of `node`.
41788
- * @returns {VisitorResult}
41789
- * What to do next.
41790
- *
41791
- * An `Index` is treated as a tuple of `[CONTINUE, Index]`.
41792
- * An `Action` is treated as a tuple of `[Action]`.
41793
- *
41794
- * Passing a tuple back only makes sense if the `Action` is `SKIP`.
41795
- * When the `Action` is `EXIT`, that action can be returned.
41796
- * When the `Action` is `CONTINUE`, `Index` can be returned.
41797
- */
41798
-
41799
- /**
41800
- * Build a typed `Visitor` function from a node and all possible parents.
41801
- *
41802
- * It will infer which values are passed as `node` and which as `parent`.
41803
- *
41804
- * @template {Node} Visited
41805
- * Node type.
41806
- * @template {Parent} Ancestor
41807
- * Parent type.
41808
- * @typedef {Visitor<Visited, ParentsOf<Ancestor, Visited>>} BuildVisitorFromMatch
41809
- */
41810
-
41811
- /**
41812
- * Build a typed `Visitor` function from a list of descendants and a test.
41813
- *
41814
- * It will infer which values are passed as `node` and which as `parent`.
41815
- *
41816
- * @template {Node} Descendant
41817
- * Node type.
41818
- * @template {Test} Check
41819
- * Test type.
41820
- * @typedef {(
41821
- * BuildVisitorFromMatch<
41822
- * import('unist-util-visit-parents/complex-types.js').Matches<Descendant, Check>,
41823
- * Extract<Descendant, Parent>
41824
- * >
41825
- * )} BuildVisitorFromDescendants
41826
- */
41827
-
41828
- /**
41829
- * Build a typed `Visitor` function from a tree and a test.
41830
- *
41831
- * It will infer which values are passed as `node` and which as `parent`.
41832
- *
41833
- * @template {Node} [Tree=Node]
41834
- * Node type.
41835
- * @template {Test} [Check=string]
41836
- * Test type.
41837
- * @typedef {(
41838
- * BuildVisitorFromDescendants<
41839
- * import('unist-util-visit-parents/complex-types.js').InclusiveDescendant<Tree>,
41840
- * Check
41841
- * >
41842
- * )} BuildVisitor
41843
- */
41844
-
41845
-
41846
-
41847
- /**
41848
- * Visit nodes.
41849
- *
41850
- * This algorithm performs *depth-first* *tree traversal* in *preorder*
41851
- * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).
41852
- *
41853
- * You can choose for which nodes `visitor` is called by passing a `test`.
41854
- * For complex tests, you should test yourself in `visitor`, as it will be
41855
- * faster and will have improved type information.
41856
- *
41857
- * Walking the tree is an intensive task.
41858
- * Make use of the return values of the visitor when possible.
41859
- * Instead of walking a tree multiple times, walk it once, use `unist-util-is`
41860
- * to check if a node matches, and then perform different operations.
41861
- *
41862
- * You can change the tree.
41863
- * See `Visitor` for more info.
41864
- *
41865
- * @param tree
41866
- * Tree to traverse.
41867
- * @param test
41868
- * `unist-util-is`-compatible test
41869
- * @param visitor
41870
- * Handle each node.
41871
- * @param reverse
41872
- * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).
41873
- * @returns
41874
- * Nothing.
41875
- */
41876
- const lib_visit =
41877
- /**
41878
- * @type {(
41879
- * (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: BuildVisitor<Tree, Check>, reverse?: boolean | null | undefined) => void) &
41880
- * (<Tree extends Node>(tree: Tree, visitor: BuildVisitor<Tree>, reverse?: boolean | null | undefined) => void)
41881
- * )}
41882
- */
41883
- (
41884
- /**
41885
- * @param {Node} tree
41886
- * @param {Test} test
41887
- * @param {Visitor} visitor
41888
- * @param {boolean | null | undefined} [reverse]
41889
- * @returns {void}
41890
- */
41891
- function (tree, test, visitor, reverse) {
41892
- if (typeof test === 'function' && typeof visitor !== 'function') {
41893
- reverse = visitor
41894
- visitor = test
41895
- test = null
41896
- }
41897
-
41898
- lib_visitParents(tree, test, overload, reverse)
41899
-
41900
- /**
41901
- * @param {Node} node
41902
- * @param {Array<Parent>} parents
41903
- */
41904
- function overload(node, parents) {
41905
- const parent = parents[parents.length - 1]
41906
- return visitor(
41907
- node,
41908
- parent ? parent.children.indexOf(node) : null,
41909
- parent
41910
- )
41911
- }
41912
- }
41913
- )
41914
-
41915
-
41916
-
41917
- ;// CONCATENATED MODULE: ../node_modules/rehype-prism-plus/node_modules/hast-util-to-string/index.js
41918
- /**
41919
- * @fileoverview
41920
- * Get the plain-text value of a hast node.
41921
- * @longdescription
41922
- * ## Use
41923
- *
41924
- * ```js
41925
- * import {h} from 'hastscript'
41926
- * import {toString} from 'hast-util-to-string'
41927
- *
41928
- * toString(h('p', 'Alpha'))
41929
- * //=> 'Alpha'
41930
- * toString(h('div', [h('b', 'Bold'), ' and ', h('i', 'italic'), '.']))
41931
- * //=> 'Bold and italic.'
41932
- * ```
41933
- *
41934
- * ## API
41935
- *
41936
- * ### `toString(node)`
41937
- *
41938
- * Transform a node to a string.
41939
- */
41940
-
41941
- /**
41942
- * @typedef {import('hast').Root} Root
41943
- * @typedef {import('hast').Element} Element
41944
- * @typedef {Root|Root['children'][number]} Node
41945
- */
41946
-
41947
- /**
41948
- * Get the plain-text value of a hast node.
41949
- *
41950
- * @param {Node} node
41951
- * @returns {string}
41952
- */
41953
- function hast_util_to_string_toString(node) {
41954
- // “The concatenation of data of all the Text node descendants of the context
41955
- // object, in tree order.”
41956
- if ('children' in node) {
41957
- return hast_util_to_string_all(node)
41958
- }
41959
-
41960
- // “Context object’s data.”
41961
- return 'value' in node ? node.value : ''
41962
- }
41963
-
41964
- /**
41965
- * @param {Node} node
41966
- * @returns {string}
41967
- */
41968
- function hast_util_to_string_one(node) {
41969
- if (node.type === 'text') {
41970
- return node.value
41971
- }
41972
-
41973
- return 'children' in node ? hast_util_to_string_all(node) : ''
41974
- }
41975
-
41976
- /**
41977
- * @param {Root|Element} node
41978
- * @returns {string}
41979
- */
41980
- function hast_util_to_string_all(node) {
41981
- let index = -1
41982
- /** @type {string[]} */
41983
- const result = []
41984
-
41985
- while (++index < node.children.length) {
41986
- result[index] = hast_util_to_string_one(node.children[index])
41987
- }
41988
-
41989
- return result.join('')
41990
- }
41991
-
41992
- ;// CONCATENATED MODULE: ../node_modules/unist-util-filter/node_modules/unist-util-is/lib/index.js
41993
- /**
41994
- * @typedef {import('unist').Node} Node
41995
- * @typedef {import('unist').Parent} Parent
41996
- */
41997
-
41998
- /**
41999
- * @typedef {Record<string, unknown>} Props
42000
- * @typedef {null | undefined | string | Props | TestFunctionAnything | Array<string | Props | TestFunctionAnything>} Test
42001
- * Check for an arbitrary node, unaware of TypeScript inferral.
42002
- *
42003
- * @callback TestFunctionAnything
42004
- * Check if a node passes a test, unaware of TypeScript inferral.
42005
- * @param {unknown} this
42006
- * The given context.
42007
- * @param {Node} node
42008
- * A node.
42009
- * @param {number | null | undefined} [index]
42010
- * The node’s position in its parent.
42011
- * @param {Parent | null | undefined} [parent]
42012
- * The node’s parent.
42013
- * @returns {boolean | void}
42014
- * Whether this node passes the test.
42015
- */
42016
-
42017
- /**
42018
- * @template {Node} Kind
42019
- * Node type.
42020
- * @typedef {Kind['type'] | Partial<Kind> | TestFunctionPredicate<Kind> | Array<Kind['type'] | Partial<Kind> | TestFunctionPredicate<Kind>>} PredicateTest
42021
- * Check for a node that can be inferred by TypeScript.
42022
- */
42023
-
42024
- /**
42025
- * Check if a node passes a certain test.
42026
- *
42027
- * @template {Node} Kind
42028
- * Node type.
42029
- * @callback TestFunctionPredicate
42030
- * Complex test function for a node that can be inferred by TypeScript.
42031
- * @param {Node} node
42032
- * A node.
42033
- * @param {number | null | undefined} [index]
42034
- * The node’s position in its parent.
42035
- * @param {Parent | null | undefined} [parent]
42036
- * The node’s parent.
42037
- * @returns {node is Kind}
42038
- * Whether this node passes the test.
42039
- */
42040
-
42041
- /**
42042
- * @callback AssertAnything
42043
- * Check that an arbitrary value is a node, unaware of TypeScript inferral.
42044
- * @param {unknown} [node]
42045
- * Anything (typically a node).
42046
- * @param {number | null | undefined} [index]
42047
- * The node’s position in its parent.
42048
- * @param {Parent | null | undefined} [parent]
42049
- * The node’s parent.
42050
- * @returns {boolean}
42051
- * Whether this is a node and passes a test.
42052
- */
42053
-
42054
- /**
42055
- * Check if a node is a node and passes a certain node test.
42056
- *
42057
- * @template {Node} Kind
42058
- * Node type.
42059
- * @callback AssertPredicate
42060
- * Check that an arbitrary value is a specific node, aware of TypeScript.
42061
- * @param {unknown} [node]
42062
- * Anything (typically a node).
42063
- * @param {number | null | undefined} [index]
42064
- * The node’s position in its parent.
42065
- * @param {Parent | null | undefined} [parent]
42066
- * The node’s parent.
42067
- * @returns {node is Kind}
42068
- * Whether this is a node and passes a test.
42069
- */
42070
-
42071
- /**
42072
- * Check if `node` is a `Node` and whether it passes the given test.
42073
- *
42074
- * @param node
42075
- * Thing to check, typically `Node`.
42076
- * @param test
42077
- * A check for a specific node.
42078
- * @param index
42079
- * The node’s position in its parent.
42080
- * @param parent
42081
- * The node’s parent.
42082
- * @returns
42083
- * Whether `node` is a node and passes a test.
42084
- */
42085
- const unist_util_is_lib_is =
42086
- /**
42087
- * @type {(
42088
- * (() => false) &
42089
- * (<Kind extends Node = Node>(node: unknown, test: PredicateTest<Kind>, index: number, parent: Parent, context?: unknown) => node is Kind) &
42090
- * (<Kind extends Node = Node>(node: unknown, test: PredicateTest<Kind>, index?: null | undefined, parent?: null | undefined, context?: unknown) => node is Kind) &
42091
- * ((node: unknown, test: Test, index: number, parent: Parent, context?: unknown) => boolean) &
42092
- * ((node: unknown, test?: Test, index?: null | undefined, parent?: null | undefined, context?: unknown) => boolean)
42093
- * )}
42094
- */
42095
- (
42096
- /**
42097
- * @param {unknown} [node]
42098
- * @param {Test} [test]
42099
- * @param {number | null | undefined} [index]
42100
- * @param {Parent | null | undefined} [parent]
42101
- * @param {unknown} [context]
42102
- * @returns {boolean}
42103
- */
42104
- // eslint-disable-next-line max-params
42105
- function is(node, test, index, parent, context) {
42106
- const check = unist_util_is_lib_convert(test)
42107
-
42108
- if (
42109
- index !== undefined &&
42110
- index !== null &&
42111
- (typeof index !== 'number' ||
42112
- index < 0 ||
42113
- index === Number.POSITIVE_INFINITY)
42114
- ) {
42115
- throw new Error('Expected positive finite index')
42116
- }
42117
-
42118
- if (
42119
- parent !== undefined &&
42120
- parent !== null &&
42121
- (!is(parent) || !parent.children)
42122
- ) {
42123
- throw new Error('Expected parent node')
42124
- }
42125
-
42126
- if (
42127
- (parent === undefined || parent === null) !==
42128
- (index === undefined || index === null)
42129
- ) {
42130
- throw new Error('Expected both parent and index')
42131
- }
42132
-
42133
- // @ts-expect-error Looks like a node.
42134
- return node && node.type && typeof node.type === 'string'
42135
- ? Boolean(check.call(context, node, index, parent))
42136
- : false
42137
- }
42138
- )
42139
-
42140
- /**
42141
- * Generate an assertion from a test.
42142
- *
42143
- * Useful if you’re going to test many nodes, for example when creating a
42144
- * utility where something else passes a compatible test.
42145
- *
42146
- * The created function is a bit faster because it expects valid input only:
42147
- * a `node`, `index`, and `parent`.
42148
- *
42149
- * @param test
42150
- * * when nullish, checks if `node` is a `Node`.
42151
- * * when `string`, works like passing `(node) => node.type === test`.
42152
- * * when `function` checks if function passed the node is true.
42153
- * * when `object`, checks that all keys in test are in node, and that they have (strictly) equal values.
42154
- * * when `array`, checks if any one of the subtests pass.
42155
- * @returns
42156
- * An assertion.
42157
- */
42158
- const unist_util_is_lib_convert =
42159
- /**
42160
- * @type {(
42161
- * (<Kind extends Node>(test: PredicateTest<Kind>) => AssertPredicate<Kind>) &
42162
- * ((test?: Test) => AssertAnything)
42163
- * )}
42164
- */
42165
- (
42166
- /**
42167
- * @param {Test} [test]
42168
- * @returns {AssertAnything}
42169
- */
42170
- function (test) {
42171
- if (test === undefined || test === null) {
42172
- return node_modules_unist_util_is_lib_ok
42173
- }
42174
-
42175
- if (typeof test === 'string') {
42176
- return unist_util_is_lib_typeFactory(test)
42177
- }
42178
-
42179
- if (typeof test === 'object') {
42180
- return Array.isArray(test) ? unist_util_is_lib_anyFactory(test) : unist_util_is_lib_propsFactory(test)
42181
- }
42182
-
42183
- if (typeof test === 'function') {
42184
- return unist_util_is_lib_castFactory(test)
42185
- }
42186
-
42187
- throw new Error('Expected function, string, or object as test')
42188
- }
42189
- )
42190
-
42191
- /**
42192
- * @param {Array<string | Props | TestFunctionAnything>} tests
42193
- * @returns {AssertAnything}
42194
- */
42195
- function unist_util_is_lib_anyFactory(tests) {
42196
- /** @type {Array<AssertAnything>} */
42197
- const checks = []
42198
- let index = -1
42199
-
42200
- while (++index < tests.length) {
42201
- checks[index] = unist_util_is_lib_convert(tests[index])
42202
- }
42203
-
42204
- return unist_util_is_lib_castFactory(any)
42205
-
42206
- /**
42207
- * @this {unknown}
42208
- * @param {Array<unknown>} parameters
42209
- * @returns {boolean}
42210
- */
42211
- function any(...parameters) {
42212
- let index = -1
42213
-
42214
- while (++index < checks.length) {
42215
- if (checks[index].call(this, ...parameters)) return true
42216
- }
42217
-
42218
- return false
42219
- }
42220
- }
42221
-
42222
- /**
42223
- * Turn an object into a test for a node with a certain fields.
42224
- *
42225
- * @param {Props} check
42226
- * @returns {AssertAnything}
42227
- */
42228
- function unist_util_is_lib_propsFactory(check) {
42229
- return unist_util_is_lib_castFactory(all)
42230
-
42231
- /**
42232
- * @param {Node} node
42233
- * @returns {boolean}
42234
- */
42235
- function all(node) {
42236
- /** @type {string} */
42237
- let key
42238
-
42239
- for (key in check) {
42240
- // @ts-expect-error: hush, it sure works as an index.
42241
- if (node[key] !== check[key]) return false
42242
- }
42243
-
42244
- return true
42245
- }
42246
- }
42247
-
42248
- /**
42249
- * Turn a string into a test for a node with a certain type.
42250
- *
42251
- * @param {string} check
42252
- * @returns {AssertAnything}
42253
- */
42254
- function unist_util_is_lib_typeFactory(check) {
42255
- return unist_util_is_lib_castFactory(type)
42256
-
42257
- /**
42258
- * @param {Node} node
42259
- */
42260
- function type(node) {
42261
- return node && node.type === check
42262
- }
42263
- }
42264
-
42265
- /**
42266
- * Turn a custom test into a test for a node that passes that test.
42267
- *
42268
- * @param {TestFunctionAnything} check
42269
- * @returns {AssertAnything}
42270
- */
42271
- function unist_util_is_lib_castFactory(check) {
42272
- return assertion
42273
-
42274
- /**
42275
- * @this {unknown}
42276
- * @param {unknown} node
42277
- * @param {Array<unknown>} parameters
42278
- * @returns {boolean}
42279
- */
42280
- function assertion(node, ...parameters) {
42281
- return Boolean(
42282
- node &&
42283
- typeof node === 'object' &&
42284
- 'type' in node &&
42285
- // @ts-expect-error: fine.
42286
- Boolean(check.call(this, node, ...parameters))
42287
- )
42288
- }
42289
- }
42290
-
42291
- function node_modules_unist_util_is_lib_ok() {
42292
- return true
42293
- }
42294
-
42295
- ;// CONCATENATED MODULE: ../node_modules/unist-util-filter/lib/index.js
42296
- /**
42297
- * @typedef {import('unist').Node} Node
42298
- * @typedef {import('unist').Parent} Parent
42299
- * @typedef {import('unist-util-is').Test} Test
42300
- *
42301
- * @typedef Options
42302
- * Configuration (optional).
42303
- * @property {boolean | null | undefined} [cascade=true]
42304
- * Whether to drop parent nodes if they had children, but all their children
42305
- * were filtered out.
42306
- */
42307
-
42308
-
42309
-
42310
- const unist_util_filter_lib_own = {}.hasOwnProperty
42311
-
42312
- /**
42313
- * Create a new `tree` of copies of all nodes that pass `test`.
42314
- *
42315
- * The tree is walked in *preorder* (NLR), visiting the node itself, then its
42316
- * head, etc.
42317
- *
42318
- * @param tree
42319
- * Tree to filter.
42320
- * @param options
42321
- * Configuration (optional).
42322
- * @param test
42323
- * `unist-util-is` compatible test.
42324
- * @returns
42325
- * New filtered tree.
42326
- *
42327
- * `null` is returned if `tree` itself didn’t pass the test, or is cascaded
42328
- * away.
42329
- */
42330
- const filter =
42331
- /**
42332
- * @type {(
42333
- * (<Tree extends Node, Check extends Test>(node: Tree, options: Options | null | undefined, test: Check | null | undefined) => import('./complex-types.js').Matches<Tree, Check>) &
42334
- * (<Tree extends Node, Check extends Test>(node: Tree, test: Check) => import('./complex-types.js').Matches<Tree, Check>) &
42335
- * (<Tree extends Node>(node: Tree, options?: Options | null | undefined) => Tree)
42336
- * )}
42337
- */
42338
- (
42339
- /**
42340
- * @param {Node} tree
42341
- * @param {Options | Test | null | undefined} [options]
42342
- * @param {Test | null | undefined} [test]
42343
- * @returns {Node | null}
42344
- */
42345
- function (tree, options, test) {
42346
- const is = unist_util_is_lib_convert(test || options)
42347
- /** @type {boolean | null | undefined} */
42348
- const cascadeRaw =
42349
- options && typeof options === 'object' && 'cascade' in options
42350
- ? /** @type {boolean | null | undefined} */ (options.cascade)
42351
- : undefined
42352
- const cascade =
42353
- cascadeRaw === undefined || cascadeRaw === null ? true : cascadeRaw
42354
-
42355
- return preorder(tree)
42356
-
42357
- /**
42358
- * @param {Node} node
42359
- * Current node.
42360
- * @param {number | undefined} [index]
42361
- * Index of `node` in `parent`.
42362
- * @param {Parent | undefined} [parent]
42363
- * Parent node.
42364
- * @returns {Node | null}
42365
- * Shallow copy of `node`.
42366
- */
42367
- function preorder(node, index, parent) {
42368
- /** @type {Array<Node>} */
42369
- const children = []
42370
-
42371
- if (!is(node, index, parent)) return null
42372
-
42373
- // @ts-expect-error: Looks like a parent.
42374
- if (node.children) {
42375
- let childIndex = -1
42376
-
42377
- // @ts-expect-error Looks like a parent.
42378
- while (++childIndex < node.children.length) {
42379
- // @ts-expect-error Looks like a parent.
42380
- const result = preorder(node.children[childIndex], childIndex, node)
42381
-
42382
- if (result) {
42383
- children.push(result)
42384
- }
42385
- }
42386
-
42387
- // @ts-expect-error Looks like a parent.
42388
- if (cascade && node.children.length > 0 && children.length === 0)
42389
- return null
42390
- }
42391
-
42392
- // Create a shallow clone, using the new children.
42393
- /** @type {typeof node} */
42394
- // @ts-expect-error all the fields will be copied over.
42395
- const next = {}
42396
- /** @type {string} */
42397
- let key
42398
-
42399
- for (key in node) {
42400
- if (unist_util_filter_lib_own.call(node, key)) {
42401
- // @ts-expect-error: Looks like a record.
42402
- next[key] = key === 'children' ? children : node[key]
42403
- }
42404
- }
42405
-
42406
- return next
42407
- }
42408
- }
42409
- )
41802
+ function lib_parent(node) {
41803
+ return 'children' in node && node.children !== undefined
41804
+ }
42410
41805
 
42411
41806
  // EXTERNAL MODULE: ../node_modules/parse-numeric-range/index.js
42412
41807
  var parse_numeric_range = __webpack_require__(324);
@@ -69735,7 +69130,7 @@ refractor.register(zig)
69735
69130
 
69736
69131
 
69737
69132
  ;// CONCATENATED MODULE: ../node_modules/rehype-prism-plus/dist/index.es.js
69738
- function a(){a=function(e,r){return new t(e,void 0,r)};var e=RegExp.prototype,r=new WeakMap;function t(e,n,i){var o=new RegExp(e,n);return r.set(o,i||r.get(e)),l(o,t.prototype)}function n(e,t){var n=r.get(t);return Object.keys(n).reduce(function(r,t){var i=n[t];if("number"==typeof i)r[t]=e[i];else{for(var o=0;void 0===e[i[o]]&&o+1<i.length;)o++;r[t]=e[i[o]]}return r},Object.create(null))}return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),r&&l(e,r)}(t,RegExp),t.prototype.exec=function(r){var t=e.exec.call(this,r);if(t){t.groups=n(t,this);var i=t.indices;i&&(i.groups=n(i,this))}return t},t.prototype[Symbol.replace]=function(t,i){if("string"==typeof i){var o=r.get(this);return e[Symbol.replace].call(this,t,i.replace(/\$<([^>]+)>/g,function(e,r){var t=o[r];return"$"+(Array.isArray(t)?t.join("$"):t)}))}if("function"==typeof i){var a=this;return e[Symbol.replace].call(this,t,function(){var e=arguments;return"object"!=typeof e[e.length-1]&&(e=[].slice.call(e)).push(n(e,a)),i.apply(this,e)})}return e[Symbol.replace].call(this,t,i)},a.apply(this,arguments)}function l(e,r){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,r){return e.__proto__=r,e},l(e,r)}function index_es_s(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function u(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return index_es_s(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?index_es_s(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var index_es_c=function(i){return function(o){return void 0===o&&(o={}),function(e,r){if(r&&!e.registered(r))throw new Error('The default language "'+r+'" is not registered with refractor.')}(i,o.defaultLanguage),function(r){lib_visit(r,"element",l)};function l(e,l,s){var c,p;if(s&&"pre"===s.tagName&&"code"===e.tagName){var f=(null==e||null==(c=e.data)?void 0:c.meta)||(null==e||null==(p=e.properties)?void 0:p.metastring)||"";e.properties.className?"boolean"==typeof e.properties.className?e.properties.className=[]:Array.isArray(e.properties.className)||(e.properties.className=[e.properties.className]):e.properties.className=[];var m,h,d=function(e){for(var r,t=u(e.properties.className);!(r=t()).done;){var n=r.value;if("language-"===n.slice(0,9))return n.slice(9).toLowerCase()}return null}(e);if(!d&&o.defaultLanguage&&e.properties.className.push("language-"+(d=o.defaultLanguage)),e.properties.className.push("code-highlight"),d)try{var g,v;v=null!=(g=d)&&g.includes("diff-")?d.split("-")[1]:d,m=i.highlight(hast_util_to_string_toString(e),v),s.properties.className=(s.properties.className||[]).concat("language-"+v)}catch(r){if(!o.ignoreMissing||!/Unknown language/.test(r.message))throw r;m=e}else m=e;m.children=(h=1,function e(r){return r.reduce(function(r,t){if("text"===t.type){var n=t.value,i=(n.match(/\n/g)||"").length;if(0===i)t.position={start:{line:h,column:1},end:{line:h,column:1}},r.push(t);else for(var o,a=n.split("\n"),l=u(a.entries());!(o=l()).done;){var s=o.value,c=s[0],p=s[1];r.push({type:"text",value:c===a.length-1?p:p+"\n",position:{start:{line:h+c,column:1},end:{line:h+c,column:1}}})}return h+=i,r}if(Object.prototype.hasOwnProperty.call(t,"children")){var f=h;return t.children=e(t.children),r.push(t),t.position={start:{line:f,column:1},end:{line:h,column:1}},r}return r.push(t),r},[])})(m.children),m.position=m.children.length>0?{start:{line:m.children[0].position.start.line,column:0},end:{line:m.children[m.children.length-1].position.end.line,column:0}}:{start:{line:0,column:0},end:{line:0,column:0}};for(var y,b=function(e){var r=/{([\d,-]+)}/,t=e.split(",").map(function(e){return e.trim()}).join();if(r.test(t)){var i=r.exec(t)[1],o=parse_numeric_range(i);return function(e){return o.includes(e+1)}}return function(){return!1}}(f),w=function(e){var r=/*#__PURE__*/a(/showLineNumbers=(\d+)/i,{lines:1});if(r.test(e)){var t=r.exec(e);return Number(t.groups.lines)}return 1}(f),N=function(e){for(var r=new Array(e),t=0;t<e;t++)r[t]={type:"element",tagName:"span",properties:{className:[]},children:[]};return r}(m.position.end.line),j=["showlinenumbers=false",'showlinenumbers="false"',"showlinenumbers={false}"],x=function(){var e,n,i=y.value,a=i[0],l=i[1];l.properties.className=["code-line"];var s=filter(m,function(e){return e.position.start.line<=a+1&&e.position.end.line>=a+1});l.children=s.children,!f.toLowerCase().includes("showLineNumbers".toLowerCase())&&!o.showLineNumbers||j.some(function(e){return f.toLowerCase().includes(e)})||(l.properties.line=[(a+w).toString()],l.properties.className.push("line-number")),b(a)&&l.properties.className.push("highlight-line"),("diff"===d||null!=(e=d)&&e.includes("diff-"))&&"-"===hast_util_to_string_toString(l).substring(0,1)?l.properties.className.push("deleted"):("diff"===d||null!=(n=d)&&n.includes("diff-"))&&"+"===hast_util_to_string_toString(l).substring(0,1)&&l.properties.className.push("inserted")},O=u(N.entries());!(y=O()).done;)x();N.length>0&&""===hast_util_to_string_toString(N[N.length-1]).trim()&&N.pop(),e.children=N}}}},p=index_es_c(refractor),f=index_es_c(refractor);
69133
+ function a(){a=function(e,r){return new t(e,void 0,r)};var e=RegExp.prototype,r=new WeakMap;function t(e,n,i){var o=new RegExp(e,n);return r.set(o,i||r.get(e)),l(o,t.prototype)}function n(e,t){var n=r.get(t);return Object.keys(n).reduce(function(r,t){var i=n[t];if("number"==typeof i)r[t]=e[i];else{for(var o=0;void 0===e[i[o]]&&o+1<i.length;)o++;r[t]=e[i[o]]}return r},Object.create(null))}return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),r&&l(e,r)}(t,RegExp),t.prototype.exec=function(r){var t=e.exec.call(this,r);if(t){t.groups=n(t,this);var i=t.indices;i&&(i.groups=n(i,this))}return t},t.prototype[Symbol.replace]=function(t,i){if("string"==typeof i){var o=r.get(this);return e[Symbol.replace].call(this,t,i.replace(/\$<([^>]+)>/g,function(e,r){var t=o[r];return"$"+(Array.isArray(t)?t.join("$"):t)}))}if("function"==typeof i){var a=this;return e[Symbol.replace].call(this,t,function(){var e=arguments;return"object"!=typeof e[e.length-1]&&(e=[].slice.call(e)).push(n(e,a)),i.apply(this,e)})}return e[Symbol.replace].call(this,t,i)},a.apply(this,arguments)}function l(e,r){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,r){return e.__proto__=r,e},l(e,r)}function index_es_s(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function u(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return index_es_s(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?index_es_s(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var index_es_c=function(i){return function(o){return void 0===o&&(o={}),function(e,r){if(r&&!e.registered(r))throw new Error('The default language "'+r+'" is not registered with refractor.')}(i,o.defaultLanguage),function(r){visit(r,"element",l)};function l(e,l,s){var c,p;if(s&&"pre"===s.tagName&&"code"===e.tagName){var f=(null==e||null==(c=e.data)?void 0:c.meta)||(null==e||null==(p=e.properties)?void 0:p.metastring)||"";e.properties.className?"boolean"==typeof e.properties.className?e.properties.className=[]:Array.isArray(e.properties.className)||(e.properties.className=[e.properties.className]):e.properties.className=[];var m,h,d=function(e){for(var r,t=u(e.properties.className);!(r=t()).done;){var n=r.value;if("language-"===n.slice(0,9))return n.slice(9).toLowerCase()}return null}(e);if(!d&&o.defaultLanguage&&e.properties.className.push("language-"+(d=o.defaultLanguage)),e.properties.className.push("code-highlight"),d)try{var g,v;v=null!=(g=d)&&g.includes("diff-")?d.split("-")[1]:d,m=i.highlight(hast_util_to_string_lib_toString(e),v),s.properties.className=(s.properties.className||[]).concat("language-"+v)}catch(r){if(!o.ignoreMissing||!/Unknown language/.test(r.message))throw r;m=e}else m=e;m.children=(h=1,function e(r){return r.reduce(function(r,t){if("text"===t.type){var n=t.value,i=(n.match(/\n/g)||"").length;if(0===i)t.position={start:{line:h,column:1},end:{line:h,column:1}},r.push(t);else for(var o,a=n.split("\n"),l=u(a.entries());!(o=l()).done;){var s=o.value,c=s[0],p=s[1];r.push({type:"text",value:c===a.length-1?p:p+"\n",position:{start:{line:h+c,column:1},end:{line:h+c,column:1}}})}return h+=i,r}if(Object.prototype.hasOwnProperty.call(t,"children")){var f=h;return t.children=e(t.children),r.push(t),t.position={start:{line:f,column:1},end:{line:h,column:1}},r}return r.push(t),r},[])})(m.children),m.position=m.children.length>0?{start:{line:m.children[0].position.start.line,column:0},end:{line:m.children[m.children.length-1].position.end.line,column:0}}:{start:{line:0,column:0},end:{line:0,column:0}};for(var y,b=function(e){var r=/{([\d,-]+)}/,t=e.split(",").map(function(e){return e.trim()}).join();if(r.test(t)){var i=r.exec(t)[1],o=parse_numeric_range(i);return function(e){return o.includes(e+1)}}return function(){return!1}}(f),w=function(e){var r=/*#__PURE__*/a(/showLineNumbers=(\d+)/i,{lines:1});if(r.test(e)){var t=r.exec(e);return Number(t.groups.lines)}return 1}(f),N=function(e){for(var r=new Array(e),t=0;t<e;t++)r[t]={type:"element",tagName:"span",properties:{className:[]},children:[]};return r}(m.position.end.line),j=["showlinenumbers=false",'showlinenumbers="false"',"showlinenumbers={false}"],x=function(){var e,n,i=y.value,a=i[0],l=i[1];l.properties.className=["code-line"];var s=filter(m,function(e){return e.position.start.line<=a+1&&e.position.end.line>=a+1});l.children=s.children,!f.toLowerCase().includes("showLineNumbers".toLowerCase())&&!o.showLineNumbers||j.some(function(e){return f.toLowerCase().includes(e)})||(l.properties.line=[(a+w).toString()],l.properties.className.push("line-number")),b(a)&&l.properties.className.push("highlight-line"),("diff"===d||null!=(e=d)&&e.includes("diff-"))&&"-"===hast_util_to_string_lib_toString(l).substring(0,1)?l.properties.className.push("deleted"):("diff"===d||null!=(n=d)&&n.includes("diff-"))&&"+"===hast_util_to_string_lib_toString(l).substring(0,1)&&l.properties.className.push("inserted")},O=u(N.entries());!(y=O()).done;)x();N.length>0&&""===hast_util_to_string_lib_toString(N[N.length-1]).trim()&&N.pop(),e.children=N}}}},p=index_es_c(refractor),f=index_es_c(refractor);
69739
69134
  //# sourceMappingURL=index.es.js.map
69740
69135
 
69741
69136
  ;// CONCATENATED MODULE: ../node_modules/css-selector-parser/dist/mjs/indexes.js
@@ -70096,15 +69491,20 @@ var cssSyntaxDefinitions = {
70096
69491
 
70097
69492
  ;// CONCATENATED MODULE: ../node_modules/css-selector-parser/dist/mjs/utils.js
70098
69493
  function isIdentStart(c) {
70099
- return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c === '-' || c === '_' || c === '\\';
69494
+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c === '-' || c === '_' || c === '\\' || c >= '\u00a0';
70100
69495
  }
70101
69496
  function isIdent(c) {
70102
- return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c === '-' || c === '_';
69497
+ return ((c >= 'a' && c <= 'z') ||
69498
+ (c >= 'A' && c <= 'Z') ||
69499
+ (c >= '0' && c <= '9') ||
69500
+ c === '-' ||
69501
+ c === '_' ||
69502
+ c >= '\u00a0');
70103
69503
  }
70104
69504
  function isHex(c) {
70105
69505
  return (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') || (c >= '0' && c <= '9');
70106
69506
  }
70107
- var identSpecialChars = {
69507
+ var identEscapeChars = {
70108
69508
  '!': true,
70109
69509
  '"': true,
70110
69510
  '#': true,
@@ -70135,19 +69535,12 @@ var identSpecialChars = {
70135
69535
  '}': true,
70136
69536
  '~': true
70137
69537
  };
70138
- var strReplacementsRev = {
70139
- '\n': '\\n',
70140
- '\r': '\\r',
70141
- '\t': '\\t',
70142
- '\f': '\\f',
70143
- '\v': '\\v'
70144
- };
70145
- var stringEscapeChars = {
70146
- n: '\n',
70147
- r: '\r',
70148
- t: '\t',
70149
- f: '\f',
70150
- '\\': '\\'
69538
+ var stringRenderEscapeChars = {
69539
+ '\n': true,
69540
+ '\r': true,
69541
+ '\t': true,
69542
+ '\f': true,
69543
+ '\v': true
70151
69544
  };
70152
69545
  var whitespaceChars = {
70153
69546
  ' ': true,
@@ -70172,21 +69565,25 @@ var digitsChars = {
70172
69565
  8: true,
70173
69566
  9: true
70174
69567
  };
69568
+ var maxHexLength = 6;
70175
69569
  function utils_escapeIdentifier(s) {
70176
69570
  var len = s.length;
70177
69571
  var result = '';
70178
69572
  var i = 0;
70179
69573
  while (i < len) {
70180
69574
  var chr = s.charAt(i);
70181
- if (identSpecialChars[chr]) {
69575
+ if (identEscapeChars[chr] || (chr === '-' && i === 1 && s.charAt(0) === '-')) {
70182
69576
  result += '\\' + chr;
70183
69577
  }
70184
69578
  else {
70185
- if (!(chr === '_' ||
70186
- chr === '-' ||
69579
+ if (chr === '-' ||
69580
+ chr === '_' ||
70187
69581
  (chr >= 'A' && chr <= 'Z') ||
70188
69582
  (chr >= 'a' && chr <= 'z') ||
70189
- (i !== 0 && chr >= '0' && chr <= '9'))) {
69583
+ (chr >= '0' && chr <= '9' && i !== 0 && !(i === 1 && s.charAt(0) === '-'))) {
69584
+ result += chr;
69585
+ }
69586
+ else {
70190
69587
  var charCode = chr.charCodeAt(0);
70191
69588
  if ((charCode & 0xf800) === 0xd800) {
70192
69589
  var extraCharCode = s.charCodeAt(i++);
@@ -70197,19 +69594,15 @@ function utils_escapeIdentifier(s) {
70197
69594
  }
70198
69595
  result += '\\' + charCode.toString(16) + ' ';
70199
69596
  }
70200
- else {
70201
- result += chr;
70202
- }
70203
69597
  }
70204
69598
  i++;
70205
69599
  }
70206
69600
  return result.trim();
70207
69601
  }
70208
- function utils_escapeStr(s) {
69602
+ function utils_escapeString(s) {
70209
69603
  var len = s.length;
70210
69604
  var result = '';
70211
69605
  var i = 0;
70212
- var replacement;
70213
69606
  while (i < len) {
70214
69607
  var chr = s.charAt(i);
70215
69608
  if (chr === '"') {
@@ -70218,8 +69611,8 @@ function utils_escapeStr(s) {
70218
69611
  else if (chr === '\\') {
70219
69612
  chr = '\\\\';
70220
69613
  }
70221
- else if ((replacement = strReplacementsRev[chr]) !== undefined) {
70222
- chr = replacement;
69614
+ else if (stringRenderEscapeChars[chr]) {
69615
+ chr = '\\' + chr.charCodeAt(0).toString(16) + (i === len - 1 ? '' : ' ');
70223
69616
  }
70224
69617
  result += chr;
70225
69618
  i++;
@@ -70360,16 +69753,22 @@ function createParser(options) {
70360
69753
  }
70361
69754
  }
70362
69755
  }
69756
+ /**
69757
+ * @see https://www.w3.org/TR/css-syntax/#hex-digit-diagram
69758
+ */
70363
69759
  function parseHex() {
70364
69760
  var hex = readAndNext();
70365
- while (isHex(chr)) {
69761
+ var count = 1;
69762
+ while (isHex(chr) && count < maxHexLength) {
70366
69763
  hex += readAndNext();
69764
+ count++;
70367
69765
  }
70368
- if (is(' ')) {
70369
- next();
70370
- }
69766
+ skipSingleWhitespace();
70371
69767
  return String.fromCharCode(parseInt(hex, 16));
70372
69768
  }
69769
+ /**
69770
+ * @see https://www.w3.org/TR/css-syntax/#string-token-diagram
69771
+ */
70373
69772
  function parseString(quote) {
70374
69773
  var result = '';
70375
69774
  pass(quote);
@@ -70380,33 +69779,53 @@ function createParser(options) {
70380
69779
  }
70381
69780
  else if (is('\\')) {
70382
69781
  next();
70383
- var esc = void 0;
70384
69782
  if (is(quote)) {
70385
69783
  result += quote;
69784
+ next();
70386
69785
  }
70387
- else if ((esc = stringEscapeChars[chr]) !== undefined) {
70388
- result += esc;
69786
+ else if (chr === '\n' || chr === '\f') {
69787
+ next();
69788
+ }
69789
+ else if (chr === '\r') {
69790
+ next();
69791
+ if (is('\n')) {
69792
+ next();
69793
+ }
70389
69794
  }
70390
69795
  else if (isHex(chr)) {
70391
69796
  result += parseHex();
70392
- continue;
70393
69797
  }
70394
69798
  else {
70395
69799
  result += chr;
69800
+ next();
70396
69801
  }
70397
69802
  }
70398
69803
  else {
70399
69804
  result += chr;
69805
+ next();
70400
69806
  }
70401
- next();
70402
69807
  }
70403
69808
  return result;
70404
69809
  }
69810
+ /**
69811
+ * @see https://www.w3.org/TR/css-syntax/#ident-token-diagram
69812
+ */
70405
69813
  function parseIdentifier() {
70406
69814
  if (!isIdentStart(chr)) {
70407
69815
  return null;
70408
69816
  }
70409
69817
  var result = '';
69818
+ while (is('-')) {
69819
+ result += chr;
69820
+ next();
69821
+ }
69822
+ if (strict && result.length >= 2) {
69823
+ // Checking this only for strict mode since browsers work fine with these identifiers.
69824
+ fail('Identifiers cannot start with two hyphens with strict mode on.');
69825
+ }
69826
+ if (digitsChars[chr]) {
69827
+ fail('Identifiers cannot start with hyphens followed by digits.');
69828
+ }
70410
69829
  while (pos < l) {
70411
69830
  if (isIdent(chr)) {
70412
69831
  result += readAndNext();
@@ -70422,7 +69841,7 @@ function createParser(options) {
70422
69841
  }
70423
69842
  }
70424
69843
  else {
70425
- return result;
69844
+ break;
70426
69845
  }
70427
69846
  }
70428
69847
  return result;
@@ -70452,6 +69871,18 @@ function createParser(options) {
70452
69871
  }
70453
69872
  return result.trim();
70454
69873
  }
69874
+ function skipSingleWhitespace() {
69875
+ if (chr === ' ' || chr === '\t' || chr === '\f' || chr === '\n') {
69876
+ next();
69877
+ return;
69878
+ }
69879
+ if (chr === '\r') {
69880
+ next();
69881
+ }
69882
+ if (chr === '\n') {
69883
+ next();
69884
+ }
69885
+ }
70455
69886
  function skipWhitespace() {
70456
69887
  while (whitespaceChars[chr]) {
70457
69888
  next();
@@ -71012,7 +70443,7 @@ function render(entity) {
71012
70443
  if (operator && value) {
71013
70444
  result += operator;
71014
70445
  if (value.type === 'String') {
71015
- result += escapeStr(value.value);
70446
+ result += escapeString(value.value);
71016
70447
  }
71017
70448
  else if (value.type === 'Substitution') {
71018
70449
  result += renderSubstitution(value);
@@ -71168,63 +70599,6 @@ function direction(value) {
71168
70599
  return rtl.test(source) ? 'rtl' : ltr.test(source) ? 'ltr' : 'neutral'
71169
70600
  }
71170
70601
 
71171
- ;// CONCATENATED MODULE: ../node_modules/hast-util-to-string/lib/index.js
71172
- /**
71173
- * @typedef {import('hast').Nodes} Nodes
71174
- * @typedef {import('hast').Parents} Parents
71175
- */
71176
-
71177
- /**
71178
- * Get the plain-text value of a hast node.
71179
- *
71180
- * @param {Nodes} node
71181
- * Node to serialize.
71182
- * @returns {string}
71183
- * Serialized node.
71184
- */
71185
- function hast_util_to_string_lib_toString(node) {
71186
- // “The concatenation of data of all the Text node descendants of the context
71187
- // object, in tree order.”
71188
- if ('children' in node) {
71189
- return hast_util_to_string_lib_all(node)
71190
- }
71191
-
71192
- // “Context object’s data.”
71193
- return 'value' in node ? node.value : ''
71194
- }
71195
-
71196
- /**
71197
- * @param {Nodes} node
71198
- * Node.
71199
- * @returns {string}
71200
- * Serialized node.
71201
- */
71202
- function hast_util_to_string_lib_one(node) {
71203
- if (node.type === 'text') {
71204
- return node.value
71205
- }
71206
-
71207
- return 'children' in node ? hast_util_to_string_lib_all(node) : ''
71208
- }
71209
-
71210
- /**
71211
- * @param {Parents} node
71212
- * Node.
71213
- * @returns {string}
71214
- * Serialized node.
71215
- */
71216
- function hast_util_to_string_lib_all(node) {
71217
- let index = -1
71218
- /** @type {Array<string>} */
71219
- const result = []
71220
-
71221
- while (++index < node.children.length) {
71222
- result[index] = hast_util_to_string_lib_one(node.children[index])
71223
- }
71224
-
71225
- return result.join('')
71226
- }
71227
-
71228
70602
  ;// CONCATENATED MODULE: ../node_modules/hast-util-select/lib/enter-state.js
71229
70603
  /**
71230
70604
  * @typedef {import('hast').ElementContent} ElementContent
@@ -73918,11 +73292,11 @@ const convertElement =
73918
73292
 
73919
73293
  // Assume array.
73920
73294
  if (typeof test === 'object') {
73921
- return hast_util_is_element_lib_anyFactory(test)
73295
+ return lib_anyFactory(test)
73922
73296
  }
73923
73297
 
73924
73298
  if (typeof test === 'function') {
73925
- return hast_util_is_element_lib_castFactory(test)
73299
+ return lib_castFactory(test)
73926
73300
  }
73927
73301
 
73928
73302
  throw new Error('Expected function, string, or array as `test`')
@@ -73935,7 +73309,7 @@ const convertElement =
73935
73309
  * @param {Array<TestFunction | string>} tests
73936
73310
  * @returns {Check}
73937
73311
  */
73938
- function hast_util_is_element_lib_anyFactory(tests) {
73312
+ function lib_anyFactory(tests) {
73939
73313
  /** @type {Array<Check>} */
73940
73314
  const checks = []
73941
73315
  let index = -1
@@ -73944,7 +73318,7 @@ function hast_util_is_element_lib_anyFactory(tests) {
73944
73318
  checks[index] = convertElement(tests[index])
73945
73319
  }
73946
73320
 
73947
- return hast_util_is_element_lib_castFactory(any)
73321
+ return lib_castFactory(any)
73948
73322
 
73949
73323
  /**
73950
73324
  * @this {unknown}
@@ -73968,7 +73342,7 @@ function hast_util_is_element_lib_anyFactory(tests) {
73968
73342
  * @returns {Check}
73969
73343
  */
73970
73344
  function tagNameFactory(check) {
73971
- return hast_util_is_element_lib_castFactory(tagName)
73345
+ return lib_castFactory(tagName)
73972
73346
 
73973
73347
  /**
73974
73348
  * @param {Element} element
@@ -73985,7 +73359,7 @@ function tagNameFactory(check) {
73985
73359
  * @param {TestFunction} testFunction
73986
73360
  * @returns {Check}
73987
73361
  */
73988
- function hast_util_is_element_lib_castFactory(testFunction) {
73362
+ function lib_castFactory(testFunction) {
73989
73363
  return check
73990
73364
 
73991
73365
  /**
@@ -74247,7 +73621,7 @@ function rehypeAutolinkHeadings(options) {
74247
73621
  */
74248
73622
  function clone(thing) {
74249
73623
  // Cast because it’s mutable now.
74250
- return /** @type {Cloneable<T>} */ (esm(thing))
73624
+ return /** @type {Cloneable<T>} */ (structured_clone_esm(thing))
74251
73625
  }
74252
73626
 
74253
73627
  /**
@@ -76788,7 +76162,7 @@ function raw_raw(node, index, parent, state) {
76788
76162
  * @returns {string}
76789
76163
  * Serialized node.
76790
76164
  */
76791
- function handle_root_root(node, _1, _2, state) {
76165
+ function lib_handle_root_root(node, _1, _2, state) {
76792
76166
  return state.all(node)
76793
76167
  }
76794
76168
 
@@ -76814,7 +76188,7 @@ function handle_root_root(node, _1, _2, state) {
76814
76188
  const handle_handle = zwitch('type', {
76815
76189
  invalid,
76816
76190
  unknown: handle_unknown,
76817
- handlers: {comment: comment_comment, doctype: doctype_doctype, element: element_element, raw: raw_raw, root: handle_root_root, text: lib_handle_text_text}
76191
+ handlers: {comment: comment_comment, doctype: doctype_doctype, element: element_element, raw: raw_raw, root: lib_handle_root_root, text: lib_handle_text_text}
76818
76192
  })
76819
76193
 
76820
76194
  /**
@@ -77197,7 +76571,7 @@ function _defineProperties(target, props) {
77197
76571
  descriptor.enumerable = descriptor.enumerable || false;
77198
76572
  descriptor.configurable = true;
77199
76573
  if ("value" in descriptor) descriptor.writable = true;
77200
- Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
76574
+ Object.defineProperty(target, toPropertyKey(descriptor.key), descriptor);
77201
76575
  }
77202
76576
  }
77203
76577
  function _createClass(Constructor, protoProps, staticProps) {