vendor: 16,384 bytes, lines 1-746
1"use strict"; 2(self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([[2561],{ 3 4/***/ 8613: 5/***/ (function(module) { 6 7 8 9var hasOwn = Object.prototype.hasOwnProperty; 10var toStr = Object.prototype.toString; 11var defineProperty = Object.defineProperty; 12var gOPD = Object.getOwnPropertyDescriptor; 13 14var isArray = function isArray(arr) { 15 if (typeof Array.isArray === 'function') { 16 return Array.isArray(arr); 17 } 18 19 return toStr.call(arr) === '[object Array]'; 20}; 21 22var isPlainObject = function isPlainObject(obj) { 23 if (!obj || toStr.call(obj) !== '[object Object]') { 24 return false; 25 } 26 27 var hasOwnConstructor = hasOwn.call(obj, 'constructor'); 28 var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf'); 29 // Not own constructor property must be Object 30 if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) { 31 return false; 32 } 33 34 // Own properties are enumerated firstly, so to speed up, 35 // if last one is own, then all properties are own. 36 var key; 37 for (key in obj) { /**/ } 38 39 return typeof key === 'undefined' || hasOwn.call(obj, key); 40}; 41 42// If name is '__proto__', and Object.defineProperty is available, define __proto__ as an own property on target 43var setProperty = function setProperty(target, options) { 44 if (defineProperty && options.name === '__proto__') { 45 defineProperty(target, options.name, { 46 enumerable: true, 47 configurable: true, 48 value: options.newValue, 49 writable: true 50 }); 51 } else { 52 target[options.name] = options.newValue; 53 } 54}; 55 56// Return undefined instead of __proto__ if '__proto__' is not an own property 57var getProperty = function getProperty(obj, name) { 58 if (name === '__proto__') { 59 if (!hasOwn.call(obj, name)) { 60 return void 0; 61 } else if (gOPD) { 62 // In early versions of node, obj['__proto__'] is buggy when obj has 63 // __proto__ as an own property. Object.getOwnPropertyDescriptor() works. 64 return gOPD(obj, name).value; 65 } 66 } 67 68 return obj[name]; 69}; 70 71module.exports = function extend() { 72 var options, name, src, copy, copyIsArray, clone; 73 var target = arguments[0]; 74 var i = 1; 75 var length = arguments.length; 76 var deep = false; 77 78 // Handle a deep copy situation 79 if (typeof target === 'boolean') { 80 deep = target; 81 target = arguments[1] || {}; 82 // skip the boolean and the target 83 i = 2; 84 } 85 if (target == null || (typeof target !== 'object' && typeof target !== 'function')) { 86 target = {}; 87 } 88 89 for (; i < length; ++i) { 90 options = arguments[i]; 91 // Only deal with non-null/undefined values 92 if (options != null) { 93 // Extend the base object 94 for (name in options) { 95 src = getProperty(target, name); 96 copy = getProperty(options, name); 97 98 // Prevent never-ending loop 99 if (target !== copy) { 100 // Recurse if we're merging plain objects or arrays 101 if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) { 102 if (copyIsArray) { 103 copyIsArray = false; 104 clone = src && isArray(src) ? src : []; 105 } else { 106 clone = src && isPlainObject(src) ? src : {}; 107 } 108 109 // Never move original objects, clone them 110 setProperty(target, { name: name, newValue: extend(deep, clone, copy) }); 111 112 // Don't bring in undefined values 113 } else if (typeof copy !== 'undefined') { 114 setProperty(target, { name: name, newValue: copy }); 115 } 116 } 117 } 118 } 119 } 120 121 // Return the modified object 122 return target; 123}; 124 125 126/***/ }), 127 128/***/ 95677: 129/***/ (function(module) { 130 131 132 133// http://www.w3.org/TR/CSS21/grammar.html 134// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027 135var COMMENT_REGEX = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g; 136 137var NEWLINE_REGEX = /\n/g; 138var WHITESPACE_REGEX = /^\s*/; 139 140// declaration 141var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/; 142var COLON_REGEX = /^:\s*/; 143var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/; 144var SEMICOLON_REGEX = /^[;\s]*/; 145 146// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill 147var TRIM_REGEX = /^\s+|\s+$/g; 148 149// strings 150var NEWLINE = '\n'; 151var FORWARD_SLASH = '/'; 152var ASTERISK = '*'; 153var EMPTY_STRING = ''; 154 155// types 156var TYPE_COMMENT = 'comment'; 157var TYPE_DECLARATION = 'declaration'; 158 159/** 160 * @param {String} style 161 * @param {Object} [options] 162 * @return {Object[]} 163 * @throws {TypeError} 164 * @throws {Error} 165 */ 166function index (style, options) { 167 if (typeof style !== 'string') { 168 throw new TypeError('First argument must be a string'); 169 } 170 171 if (!style) return []; 172 173 options = options || {}; 174 175 /** 176 * Positional. 177 */ 178 var lineno = 1; 179 var column = 1; 180 181 /** 182 * Update lineno and column based on `str`. 183 * 184 * @param {String} str 185 */ 186 function updatePosition(str) { 187 var lines = str.match(NEWLINE_REGEX); 188 if (lines) lineno += lines.length; 189 var i = str.lastIndexOf(NEWLINE); 190 column = ~i ? str.length - i : column + str.length; 191 } 192 193 /** 194 * Mark position and patch `node.position`. 195 * 196 * @return {Function} 197 */ 198 function position() { 199 var start = { line: lineno, column: column }; 200 return function (node) { 201 node.position = new Position(start); 202 whitespace(); 203 return node; 204 }; 205 } 206 207 /** 208 * Store position information for a node. 209 * 210 * @constructor 211 * @property {Object} start 212 * @property {Object} end 213 * @property {undefined|String} source 214 */ 215 function Position(start) { 216 this.start = start; 217 this.end = { line: lineno, column: column }; 218 this.source = options.source; 219 } 220 221 /** 222 * Non-enumerable source string. 223 */ 224 Position.prototype.content = style; 225 226 /** 227 * Error `msg`. 228 * 229 * @param {String} msg 230 * @throws {Error} 231 */ 232 function error(msg) { 233 var err = new Error( 234 options.source + ':' + lineno + ':' + column + ': ' + msg 235 ); 236 err.reason = msg; 237 err.filename = options.source; 238 err.line = lineno; 239 err.column = column; 240 err.source = style; 241 242 if (options.silent) ; else { 243 throw err; 244 } 245 } 246 247 /** 248 * Match `re` and return captures. 249 * 250 * @param {RegExp} re 251 * @return {undefined|Array} 252 */ 253 function match(re) { 254 var m = re.exec(style); 255 if (!m) return; 256 var str = m[0]; 257 updatePosition(str); 258 style = style.slice(str.length); 259 return m; 260 } 261 262 /** 263 * Parse whitespace. 264 */ 265 function whitespace() { 266 match(WHITESPACE_REGEX); 267 } 268 269 /** 270 * Parse comments. 271 * 272 * @param {Object[]} [rules] 273 * @return {Object[]} 274 */ 275 function comments(rules) { 276 var c; 277 rules = rules || []; 278 while ((c = comment())) { 279 if (c !== false) { 280 rules.push(c); 281 } 282 } 283 return rules; 284 } 285 286 /** 287 * Parse comment. 288 * 289 * @return {Object} 290 * @throws {Error} 291 */ 292 function comment() { 293 var pos = position(); 294 if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return; 295 296 var i = 2; 297 while ( 298 EMPTY_STRING != style.charAt(i) && 299 (ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1)) 300 ) { 301 ++i; 302 } 303 i += 2; 304 305 if (EMPTY_STRING === style.charAt(i - 1)) { 306 return error('End of comment missing'); 307 } 308 309 var str = style.slice(2, i - 2); 310 column += 2; 311 updatePosition(str); 312 style = style.slice(i); 313 column += 2; 314 315 return pos({ 316 type: TYPE_COMMENT, 317 comment: str 318 }); 319 } 320 321 /** 322 * Parse declaration. 323 * 324 * @return {Object} 325 * @throws {Error} 326 */ 327 function declaration() { 328 var pos = position(); 329 330 // prop 331 var prop = match(PROPERTY_REGEX); 332 if (!prop) return; 333 comment(); 334 335 // : 336 if (!match(COLON_REGEX)) return error("property missing ':'"); 337 338 // val 339 var val = match(VALUE_REGEX); 340 341 var ret = pos({ 342 type: TYPE_DECLARATION, 343 property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)), 344 value: val 345 ? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING)) 346 : EMPTY_STRING 347 }); 348 349 // ; 350 match(SEMICOLON_REGEX); 351 352 return ret; 353 } 354 355 /** 356 * Parse declarations. 357 * 358 * @return {Object[]} 359 */ 360 function declarations() { 361 var decls = []; 362 363 comments(decls); 364 365 // declarations 366 var decl; 367 while ((decl = declaration())) { 368 if (decl !== false) { 369 decls.push(decl); 370 comments(decls); 371 } 372 } 373 374 return decls; 375 } 376 377 whitespace(); 378 return declarations(); 379} 380 381/** 382 * Trim `str`. 383 * 384 * @param {String} str 385 * @return {String} 386 */ 387function trim(str) { 388 return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING; 389} 390 391module.exports = index; 392//# sourceMappingURL=index.js.map 393 394 395/***/ }), 396 397/***/ 94549: 398/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 399 400/* harmony export */ __webpack_require__.d(__webpack_exports__, { 401/* harmony export */ Z: function() { return /* binding */ BrainCircuit; } 402/* harmony export */ }); 403/* harmony import */ var _createLucideIcon_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(83992); 404/** 405 * @license lucide-react v0.414.0 - ISC 406 * 407 * This source code is licensed under the ISC license. 408 * See the LICENSE file in the root directory of this source tree. 409 */ 410const BrainCircuit = (0,_createLucideIcon_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z)("BrainCircuit", [ 411 [ 412 "path", 413 { 414 d: "M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z", 415 key: "l5xja" 416 } 417 ], 418 [ 419 "path", 420 { 421 d: "M9 13a4.5 4.5 0 0 0 3-4", 422 key: "10igwf" 423 } 424 ], 425 [ 426 "path", 427 { 428 d: "M6.003 5.125A3 3 0 0 0 6.401 6.5", 429 key: "105sqy" 430 } 431 ], 432 [ 433 "path", 434 { 435 d: "M3.477 10.896a4 4 0 0 1 .585-.396", 436 key: "ql3yin" 437 } 438 ], 439 [ 440 "path", 441 { 442 d: "M6 18a4 4 0 0 1-1.967-.516", 443 key: "2e4loj" 444 } 445 ], 446 [ 447 "path", 448 { 449 d: "M12 13h4", 450 key: "1ku699" 451 } 452 ], 453 [ 454 "path", 455 { 456 d: "M12 18h6a2 2 0 0 1 2 2v1", 457 key: "105ag5" 458 } 459 ], 460 [ 461 "path", 462 { 463 d: "M12 8h8", 464 key: "1lhi5i" 465 } 466 ], 467 [ 468 "path", 469 { 470 d: "M16 8V5a2 2 0 0 1 2-2", 471 key: "u6izg6" 472 } 473 ], 474 [ 475 "circle", 476 { 477 cx: "16", 478 cy: "13", 479 r: ".5", 480 key: "ry7gng" 481 } 482 ], 483 [ 484 "circle", 485 { 486 cx: "18", 487 cy: "3", 488 r: ".5", 489 key: "1aiba7" 490 } 491 ], 492 [ 493 "circle", 494 { 495 cx: "20", 496 cy: "21", 497 r: ".5", 498 key: "yhc1fs" 499 } 500 ], 501 [ 502 "circle", 503 { 504 cx: "20", 505 cy: "8", 506 r: ".5", 507 key: "1e43v0" 508 } 509 ] 510]); 511 //# sourceMappingURL=brain-circuit.js.map 512 513 514/***/ }), 515 516/***/ 40833: 517/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 518 519/* harmony export */ __webpack_require__.d(__webpack_exports__, { 520/* harmony export */ Z: function() { return /* binding */ Clock3; } 521/* harmony export */ }); 522/* harmony import */ var _createLucideIcon_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(83992); 523/** 524 * @license lucide-react v0.414.0 - ISC 525 * 526 * This source code is licensed under the ISC license. 527 * See the LICENSE file in the root directory of this source tree. 528 */ 529const Clock3 = (0,_createLucideIcon_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z)("Clock3", [ 530 [ 531 "circle", 532 { 533 cx: "12", 534 cy: "12", 535 r: "10", 536 key: "1mglay" 537 } 538 ], 539 [ 540 "polyline", 541 { 542 points: "12 6 12 12 16.5 12", 543 key: "1aq6pp" 544 } 545 ] 546]); 547 //# sourceMappingURL=clock-3.js.map 548 549 550/***/ }), 551 552/***/ 97205: 553/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 554 555/* harmony export */ __webpack_require__.d(__webpack_exports__, { 556/* harmony export */ Z: function() { return /* binding */ CloudCog; } 557/* harmony export */ }); 558/* harmony import */ var _createLucideIcon_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(83992); 559/** 560 * @license lucide-react v0.414.0 - ISC 561 * 562 * This source code is licensed under the ISC license. 563 * See the LICENSE file in the root directory of this source tree. 564 */ 565const CloudCog = (0,_createLucideIcon_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z)("CloudCog", [ 566 [ 567 "circle", 568 { 569 cx: "12", 570 cy: "17", 571 r: "3", 572 key: "1spfwm" 573 } 574 ], 575 [ 576 "path", 577 { 578 d: "M4.2 15.1A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.2", 579 key: "zaobp" 580 } 581 ], 582 [ 583 "path", 584 { 585 d: "m15.7 18.4-.9-.3", 586 key: "4qxpbn" 587 } 588 ], 589 [ 590 "path", 591 { 592 d: "m9.2 15.9-.9-.3", 593 key: "17q7o2" 594 } 595 ], 596 [ 597 "path", 598 { 599 d: "m10.6 20.7.3-.9", 600 key: "1pf4s2" 601 } 602 ], 603 [ 604 "path", 605 { 606 d: "m13.1 14.2.3-.9", 607 key: "1mnuqm" 608 } 609 ], 610 [ 611 "path", 612 { 613 d: "m13.6 20.7-.4-1", 614 key: "1jpd1m" 615 } 616 ], 617 [ 618 "path", 619 { 620 d: "m10.8 14.3-.4-1", 621 key: "17ugyy" 622 } 623 ], 624 [ 625 "path", 626 { 627 d: "m8.3 18.6 1-.4", 628 key: "s42vdx" 629 } 630 ], 631 [ 632 "path", 633 { 634 d: "m14.7 15.8 1-.4", 635 key: "2wizun" 636 } 637 ] 638]); 639 //# sourceMappingURL=cloud-cog.js.map 640 641 642/***/ }), 643 644/***/ 76260: 645/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 646 647/* harmony export */ __webpack_require__.d(__webpack_exports__, { 648/* harmony export */ Z: function() { return /* binding */ History; } 649/* harmony export */ }); 650/* harmony import */ var _createLucideIcon_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(83992); 651/** 652 * @license lucide-react v0.414.0 - ISC 653 * 654 * This source code is licensed under the ISC license. 655 * See the LICENSE file in the root directory of this source tree. 656 */ 657const History = (0,_createLucideIcon_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z)("History", [ 658 [ 659 "path", 660 { 661 d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", 662 key: "1357e3" 663 } 664 ], 665 [ 666 "path", 667 { 668 d: "M3 3v5h5", 669 key: "1xhq8a" 670 } 671 ], 672 [ 673 "path", 674 { 675 d: "M12 7v5l4 2", 676 key: "1fdv2h" 677 } 678 ] 679]); 680 //# sourceMappingURL=history.js.map 681 682 683/***/ }), 684 685/***/ 49468: 686/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 687 688/* harmony export */ __webpack_require__.d(__webpack_exports__, { 689/* harmony export */ Z: function() { return /* binding */ Radio; } 690/* harmony export */ }); 691/* harmony import */ var _createLucideIcon_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(83992); 692/** 693 * @license lucide-react v0.414.0 - ISC 694 * 695 * This source code is licensed under the ISC license. 696 * See the LICENSE file in the root directory of this source tree. 697 */ 698const Radio = (0,_createLucideIcon_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z)("Radio", [ 699 [ 700 "path", 701 { 702 d: "M4.9 19.1C1 15.2 1 8.8 4.9 4.9", 703 key: "1vaf9d" 704 } 705 ], 706 [ 707 "path", 708 { 709 d: "M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5", 710 key: "u1ii0m" 711 } 712 ], 713 [ 714 "circle", 715 { 716 cx: "12", 717 cy: "12", 718 r: "2", 719 key: "1c9p78" 720 } 721 ], 722 [ 723 "path", 724 { 725 d: "M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5", 726 key: "1j5fej" 727 } 728 ], 729 [ 730 "path", 731 { 732 d: "M19.1 4.9C23 8.8 23 15.1 19.1 19", 733 key: "10b0cb" 734 } 735 ] 736]); 737 //# sourceMappingURL=radio.js.map 738 739 740/***/ }), 741 742/***/ 2936: 743/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 744 745/* harmony export */ __webpack_require__.d(__webpack_exports__, { 746/* harmony export */ Z: function() { return /* bin
746ding */ Sun; } 747/* harmony export */ }); 748/* harmony import */ var _createLucideIcon_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(83992); 749/** 750 * @license lucide-react v0.414.0 - ISC 751 * 752 * This source code is licensed under the ISC license. 753 * See the LICENSE file in the root directory of this source tree. 754 */ 755const Sun = (0,_createLucideIcon_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z)("Sun", [ 756 [ 757 "circle", 758 { 759 cx: "12", 760 cy: "12", 761 r: "4", 762 key: "4exip2" 763 } 764 ], 765 [ 766 "path", 767 { 768 d: "M12 2v2", 769 key: "tus03m" 770 } 771 ], 772 [ 773 "path", 774 { 775 d: "M12 20v2", 776 key: "1lh1kg" 777 } 778 ], 779 [ 780 "path", 781 { 782 d: "m4.93 4.93 1.41 1.41", 783 key: "149t6j" 784 } 785 ], 786 [ 787 "path", 788 { 789 d: "m17.66 17.66 1.41 1.41", 790 key: "ptbguv" 791 } 792 ], 793 [ 794 "path", 795 { 796 d: "M2 12h2", 797 key: "1t8f8n" 798 } 799 ], 800 [ 801 "path", 802 { 803 d: "M20 12h2", 804 key: "1q8mjw" 805 } 806 ], 807 [ 808 "path", 809 { 810 d: "m6.34 17.66-1.41 1.41", 811 key: "1m8zz5" 812 } 813 ], 814 [ 815 "path", 816 { 817 d: "m19.07 4.93-1.41 1.41", 818 key: "1shlcs" 819 } 820 ] 821]); 822 //# sourceMappingURL=sun.js.map 823 824 825/***/ }), 826 827/***/ 14255: 828/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 829 830/* harmony export */ __webpack_require__.d(__webpack_exports__, { 831/* harmony export */ Z: function() { return /* binding */ VolumeX; } 832/* harmony export */ }); 833/* harmony import */ var _createLucideIcon_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(83992); 834/** 835 * @license lucide-react v0.414.0 - ISC 836 * 837 * This source code is licensed under the ISC license. 838 * See the LICENSE file in the root directory of this source tree. 839 */ 840const VolumeX = (0,_createLucideIcon_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z)("VolumeX", [ 841 [ 842 "polygon", 843 { 844 points: "11 5 6 9 2 9 2 15 6 15 11 19 11 5", 845 key: "16drj5" 846 } 847 ], 848 [ 849 "line", 850 { 851 x1: "22", 852 x2: "16", 853 y1: "9", 854 y2: "15", 855 key: "1ewh16" 856 } 857 ], 858 [ 859 "line", 860 { 861 x1: "16", 862 x2: "22", 863 y1: "9", 864 y2: "15", 865 key: "5ykzw1" 866 } 867 ] 868]); 869 //# sourceMappingURL=volume-x.js.map 870 871 872/***/ }), 873 874/***/ 69939: 875/***/ (function(module, __unused_webpack_exports, __webpack_require__) { 876 877 878var __importDefault = (this && this.__importDefault) || function (mod) { 879 return (mod && mod.__esModule) ? mod : { "default": mod }; 880}; 881var style_to_object_1 = __importDefault(__webpack_require__(11027)); 882var utilities_1 = __webpack_require__(29761); 883/** 884 * Parses CSS inline style to JavaScript object (camelCased). 885 */ 886function StyleToJS(style, options) { 887 var output = {}; 888 if (!style || typeof style !== 'string') { 889 return output; 890 } 891 (0, style_to_object_1.default)(style, function (property, value) { 892 // skip CSS comment 893 if (property && value) {
894 output[(0, utilities_1.camelCase)(property, options)] = value; 895 } 896 }); 897 return output; 898} 899StyleToJS.default = StyleToJS; 900module.exports = StyleToJS; 901//# sourceMappingURL=index.js.map 902 903/***/ }), 904 905/***/ 29761: 906/***/ (function(__unused_webpack_module, exports) { 907 908 909Object.defineProperty(exports, "__esModule", ({ value: true })); 910exports.camelCase = void 0; 911var CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9_-]+$/; 912var HYPHEN_REGEX = /-([a-z])/g; 913var NO_HYPHEN_REGEX = /^[^-]+$/; 914var VENDOR_PREFIX_REGEX = /^-(webkit|moz|ms|o|khtml)-/; 915var MS_VENDOR_PREFIX_REGEX = /^-(ms)-/; 916/** 917 * Checks whether to skip camelCase. 918 */ 919var skipCamelCase = function (property) { 920 return !property || 921 NO_HYPHEN_REGEX.test(property) || 922 CUSTOM_PROPERTY_REGEX.test(property); 923}; 924/** 925 * Replacer that capitalizes first character. 926 */ 927var capitalize = function (match, character) { 928 return character.toUpperCase(); 929}; 930/** 931 * Replacer that removes beginning hyphen of vendor prefix property. 932 */ 933var trimHyphen = function (match, prefix) { return "".concat(prefix, "-"); }; 934/** 935 * CamelCases a CSS property. 936 */
937var camelCase = function (property, options) { 938 if (options === void 0) { options = {}; } 939 if (skipCamelCase(property)) { 940 return property; 941 } 942 property = property.toLowerCase(); 943 if (options.reactCompat) { 944 // `-ms` vendor prefix should not be capitalized 945 property = property.replace(MS_VENDOR_PREFIX_REGEX, trimHyphen); 946 } 947 else { 948 // for non-React, remove first hyphen so vendor prefix is not capitalized 949 property = property.replace(VENDOR_PREFIX_REGEX, trimHyphen); 950 } 951 return property.replace(HYPHEN_REGEX, capitalize); 952}; 953exports.camelCase = camelCase; 954//# sourceMappingURL=utilities.js.map 955 956/***/ }), 957 958/***/ 11027: 959/***/ (function(__unused_webpack_module, exports, __webpack_require__) { 960 961 962var __importDefault = (this && this.__importDefault) || function (mod) { 963 return (mod && mod.__esModule) ? mod : { "default": mod }; 964}; 965Object.defineProperty(exports, "__esModule", ({ value: true })); 966exports["default"] = StyleToObject; 967const inline_style_parser_1 = __importDefault(__webpack_require__(95677)); 968/** 969 * Parses inline style to object. 970 * 971 * @param style - Inline style. 972 * @param iterator - Iterator. 973 * @returns - Style object or null. 974 * 975 * @example Parsing inline style to object: 976 * 977 * ```js 978 * import parse from 'style-to-object'; 979 * parse('line-height: 42;'); // { 'line-height': '42' } 980 * ``` 981 */ 982function StyleToObject(style, iterator) { 983 let styleObject = null; 984 if (!style || typeof style !== 'string') { 985 return styleObject; 986 } 987 const declarations = (0, inline_style_parser_1.default)(style); 988 const hasIterator = typeof iterator === 'function'; 989 declarations.forEach((declaration) => { 990 if (declaration.type !== 'declaration') { 991 return; 992 } 993 const { property, value } = declaration; 994 if (hasIterator) { 995 iterator(property, value, declaration); 996 } 997 else if (value) { 998 styleObject = styleObject || {}; 999 styleObject[property] = value; 1000 } 1001 }); 1002 return styleObject; 1003} 1004//# sourceMappingURL=index.js.map 1005 1006/***/ }), 1007 1008/***/ 99483: 1009/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { 1010 1011/* harmony export */ __webpack_require__.d(__webpack_exports__, { 1012/* harmony export */ ck: function() { return /* binding */ ToggleGroupItem; }, 1013/* harmony export */ fC: function() { return /* binding */ ToggleGroup; } 1014/* harmony export */ }); 1015/* unused harmony exports ToggleGroup, ToggleGroupItem, createToggleGroupScope */ 1016/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(25529); 1017/* harmony import */ var _radix_ui_react_context__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(94886); 1018/* harmony import */ var _radix_ui_react_primitive__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(83784); 1019/* harmony import */ var _radix_ui_react_roving_focus__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(68301); 1020/* harmony import */ var _radix_ui_react_toggle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(20079); 1021/* harmony import */ var _radix_ui_react_use_controllable_state__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(4021); 1022/* harmony import */ var _radix_ui_react_direction__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(37761); 1023/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(44951); 1024/* __next_internal_client_entry_do_not_use__ Item,Root,ToggleGroup,ToggleGroupItem,createToggleGroupScope auto */ // src/toggle-group.tsx 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034var TOGGLE_GROUP_NAME = "ToggleGroup"; 1035var [createToggleGroupContext, createToggleGroupScope] = (0,_radix_ui_react_context__WEBPACK_IMPORTED_MODULE_1__/* .createContextScope */ .b)(TOGGLE_GROUP_NAME, [ 1036 _radix_ui_react_roving_focus__WEBPACK_IMPORTED_MODULE_3__/* .createRovingFocusGroupScope */ .Pc 1037]); 1038var useRovingFocusGroupScope = (0,_radix_ui_react_roving_focus__WEBPACK_IMPORTED_MODULE_3__/* .createRovingFocusGroupScope */ .Pc)(); 1039var ToggleGroup = /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_0__.forwardRef((props, forwardedRef)=>{ 1040 const { type, ...toggleGroupProps } = props; 1041 if (type === "single") { 1042 const singleProps = toggleGroupProps; 1043 return /* @__PURE__ */ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(ToggleGroupImplSingle, { 1044 role: "radiogroup", 1045 ...singleProps, 1046 ref: forwardedRef 1047 }); 1048 } 1049 if (type === "multiple") { 1050 const multipleProps = toggleGroupProps; 1051 return /* @__PURE__ */ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(ToggleGroupImplMultiple, { 1052 role: "toolbar", 1053 ...multipleProps, 1054 ref: forwardedRef 1055 }); 1056 } 1057 throw new Error("Missing prop `type` expected on `".concat(TOGGLE_GROUP_NAME, "`")); 1058}); 1059ToggleGroup.displayName = TOGGLE_GROUP_NAME; 1060var [ToggleGroupValueProvider, useToggleGroupValueContext] = createToggleGroupContext(TOGGLE_GROUP_NAME); 1061var ToggleGroupImplSingle = /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_0__.forwardRef((props, forwardedRef)=>{ 1062 const { value: valueProp, defaultValue, onValueChange = ()=>{}, ...toggleGroupSingleProps } = props; 1063 const [value, setValue] = (0,_radix_ui_react_use_controllable_state__WEBPACK_IMPORTED_MODULE_5__/* .useControllableState */ .T)({ 1064 prop: valueProp, 1065 defaultProp: defaultValue !== null && defaultValue !== void 0 ? defaultValue : "", 1066 onChange: onValueChange, 1067 caller: TOGGLE_GROUP_NAME 1068 }); 1069 return /* @__PURE__ */ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(ToggleGroupValueProvider, { 1070 scope: props.__scopeToggleGroup, 1071 type: "single", 1072 value: react__WEBPACK_IMPORTED_MODULE_0__.useMemo(()=>value ? [ 1073 value 1074 ] : [], [ 1075 value 1076 ]), 1077 onItemActivate: setValue, 1078 onItemDeactivate: react__WEBPACK_IMPORTED_MODULE_0__.useCallback(()=>setValue(""), [ 1079 setValue 1080 ]), 1081 children: /* @__PURE__ */ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(ToggleGroupImpl, { 1082 ...toggleGroupSingleProps, 1083 ref: forwardedRef 1084 }) 1085 }); 1086}); 1087var ToggleGroupImplMultiple = /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_0__.forwardRef((props, forwardedRef)=>{ 1088 const { value: valueProp, defaultValue, onValueChange = ()=>{}, ...toggleGroupMultipleProps } = props; 1089 const [value, setValue] = (0,_radix_ui_react_use_controllable_state__WEBPACK_IMPORTED_MODULE_5__/* .useControllableState */ .T)({ 1090 prop: valueProp, 1091 defaultProp: defaultValue !== null && defaultValue !== void 0 ? defaultValue : [], 1092 onChange: onValueChange, 1093 caller: TOGGLE_GROUP_NAME 1094 }); 1095 const handleButtonActivate = react__WEBPACK_IMPORTED_MODULE_0__.useCallback((itemValue)=>setValue(function() { 1096 let prevValue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []; 1097 return [ 1098 ...prevValue, 1099 itemValue 1100 ]; 1101 }), [ 1102 setValue 1103 ]); 1104 const handleButtonDeactivate = react__WEBPACK_IMPORTED_MODULE_0__.useCallback((itemValue)=>setValue(function() { 1105 let prevValue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []; 1106 return prevValue.filter((value2)=>value2 !== itemValue); 1107 }), [ 1108 setValue 1109 ]); 1110 return /* @__PURE__ */ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(ToggleGroupValueProvider, { 1111 scope: props.__scopeToggleGroup, 1112 type: "multiple", 1113 value, 1114 onItemActivate: handleButtonActivate, 1115 onItemDeactivate: handleButtonDeactivate, 1116 children: /* @__PURE__ */ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(ToggleGroupImpl, { 1117 ...toggleGroupMultipleProps, 1118 ref: forwardedRef 1119 }) 1120 }); 1121}); 1122ToggleGroup.displayName = TOGGLE_GROUP_NAME; 1123var [ToggleGroupContext, useToggleGroupContext] = createToggleGroupContext(TOGGLE_GROUP_NAME); 1124var ToggleGroupImpl = /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_0__.forwardRef((props, forwardedRef)=>{ 1125 const { __scopeToggleGroup, disabled = false, rovingFocus = true, orientation, dir, loop = true, ...toggleGroupProps } = props; 1126 const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeToggleGroup); 1127 const direction = (0,_radix_ui_react_direction__WEBPACK_IMPORTED_MODULE_6__/* .useDirection */ .gm)(dir); 1128 const commonProps = { 1129 dir: direction, 1130 ...toggleGroupProps 1131 }; 1132 return /* @__PURE__ */ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(ToggleGroupContext, { 1133 scope: __scopeToggleGroup, 1134 rovingFocus, 1135 disabled,
1136 children: rovingFocus ? /* @__PURE__ */ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_radix_ui_react_roving_focus__WEBPACK_IMPORTED_MODULE_3__/* .Root */ .fC, { 1137 asChild: true, 1138 ...rovingFocusGroupScope, 1139 orientation, 1140 dir: direction, 1141 loop, 1142 children: /* @__PURE__ */ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_radix_ui_react_primitive__WEBPACK_IMPORTED_MODULE_2__/* .Primitive */ .WV.div, { 1143 ...commonProps, 1144 ref: forwardedRef 1145 }) 1146 }) : /* @__PURE__ */ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_radix_ui_react_primitive__WEBPACK_IMPORTED_MODULE_2__/* .Primitive */ .WV.div, { 1147 ...commonProps, 1148 ref: forwardedRef 1149 }) 1150 }); 1151}); 1152var ITEM_NAME = "ToggleGroupItem"; 1153var ToggleGroupItem = /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_0__.forwardRef((props, forwardedRef)=>{ 1154 const valueContext = useToggleGroupValueContext(ITEM_NAME, props.__scopeToggleGroup); 1155 const context = useToggleGroupContext(ITEM_NAME, props.__scopeToggleGroup); 1156 const rovingFocusGroupScope = useRovingFocusGroupScope(props.__scopeToggleGroup); 1157 const pressed = valueContext.value.includes(props.value); 1158 const disabled = context.disabled || props.disabled; 1159 const commonProps = { 1160 ...props, 1161 pressed, 1162 disabled 1163 }; 1164 const ref = react__WEBPACK_IMPORTED_MODULE_0__.useRef(null); 1165 return context.rovingFocus ? /* @__PURE__ */ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_radix_ui_react_roving_focus__WEBPACK_IMPORTED_MODULE_3__/* .Item */ .ck, { 1166 asChild: true, 1167 ...rovingFocusGroupScope, 1168 focusable: !disabled, 1169 active: pressed, 1170 ref, 1171 children: /* @__PURE__ */ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(ToggleGroupItemImpl, { 1172 ...commonProps, 1173 ref: forwardedRef 1174 }) 1175 }) : /* @__PURE__ */ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(ToggleGroupItemImpl, { 1176 ...commonProps, 1177 ref: forwardedRef 1178 }); 1179}); 1180ToggleGroupItem.displayName = ITEM_NAME; 1181var ToggleGroupItemImpl = /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_0__.forwardRef((props, forwardedRef)=>{ 1182 const { __scopeToggleGroup, value, ...itemProps } = props; 1183 const valueContext = useToggleGroupValueContext(ITEM_NAME, __scopeToggleGroup); 1184 const singleProps = { 1185 role: "radio", 1186 "aria-checked": props.pressed, 1187 "aria-pressed": void 0 1188 }; 1189 const typeProps = valueContext.type === "single" ? singleProps : void 0; 1190 return /* @__PURE__ */ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_radix_ui_react_toggle__WEBPACK_IMPORTED_MODULE_4__/* .Toggle */ .Z, { 1191 ...typeProps, 1192 ...itemProps, 1193 ref: forwardedRef,
1194 onPressedChange: (pressed)=>{ 1195 if (pressed) { 1196 valueContext.onItemActivate(value); 1197 } else { 1198 valueContext.onItemDeactivate(value); 1199 } 1200 } 1201 }); 1202}); 1203 //# sourceMappingURL=index.mjs.map 1204 1205 1206/***/ }), 1207 1208/***/ 20079: 1209/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { 1210 1211/* harmony export */ __webpack_require__.d(__webpack_exports__, { 1212/* harmony export */ Z: function() { return /* binding */ Toggle; }, 1213/* harmony export */ f: function() { return /* binding */ Root; } 1214/* harmony export */ }); 1215/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(25529); 1216/* harmony import */ var _radix_ui_primitive__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(39157); 1217/* harmony import */ var _radix_ui_react_use_controllable_state__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4021); 1218/* harmony import */ var _radix_ui_react_primitive__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(83784); 1219/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(44951); 1220/* __next_internal_client_entry_do_not_use__ Root,Toggle auto */ // src/toggle.tsx 1221 1222 1223 1224 1225 1226var NAME = "Toggle"; 1227var Toggle = /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_0__.forwardRef((props, forwardedRef)=>{
1228 const { pressed: pressedProp, defaultPressed, onPressedChange, ...buttonProps } = props; 1229 const [pressed, setPressed] = (0,_radix_ui_react_use_controllable_state__WEBPACK_IMPORTED_MODULE_2__/* .useControllableState */ .T)({ 1230 prop: pressedProp, 1231 onChange: onPressedChange, 1232 defaultProp: defaultPressed !== null && defaultPressed !== void 0 ? defaultPressed : false, 1233 caller: NAME 1234 }); 1235 return /* @__PURE__ */ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_radix_ui_react_primitive__WEBPACK_IMPORTED_MODULE_3__/* .Primitive */ .WV.button, { 1236 type: "button", 1237 "aria-pressed": pressed, 1238 "data-state": pressed ? "on" : "off", 1239 "data-disabled": props.disabled ? "" : void 0, 1240 ...buttonProps, 1241 ref: forwardedRef, 1242 onClick: (0,_radix_ui_primitive__WEBPACK_IMPORTED_MODULE_1__/* .composeEventHandlers */ .Mj)(props.onClick, ()=>{ 1243 if (!props.disabled) { 1244 setPressed(!pressed); 1245 } 1246 }) 1247 }); 1248}); 1249Toggle.displayName = NAME; 1250var Root = Toggle; 1251 //# sourceMappingURL=index.mjs.map 1252 1253 1254/***/ }), 1255 1256/***/ 7250: 1257/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { 1258 1259 1260// EXPORTS 1261__webpack_require__.d(__webpack_exports__, { 1262 Pu: function() { return /* reexport */ useHydrateAtoms; } 1263}); 1264 1265// UNUSED EXPORTS: RESET, atomFamily, atomWithDefault, atomWithLazy, atomWithObservable, atomWithReducer, atomWithRefresh, atomWithReset, atomWithStorage, createJSONStorage, freezeAtom, freezeAtomCreator, load
1265able, selectAtom, splitAtom, unstable_withStorageValidator, unwrap, useAtomCallback, useReducerAtom, useResetAtom 1266 1267// EXTERNAL MODULE: ./node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]/node_modules/jotai/esm/vanilla.mjs 1268var vanilla = __webpack_require__(57220); 1269;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]/node_modules/jotai/esm/vanilla/utils.mjs 1270 1271 1272const utils_RESET = /* @__PURE__ */ Symbol( 1273 ( false ? 0 : void 0) !== "production" ? "RESET" : "" 1274); 1275 1276function atomWithReset(initialValue) { 1277 const anAtom = atom( 1278 initialValue, 1279 (get, set, update) => { 1280 const nextValue = typeof update === "function" ? update(get(anAtom)) : update; 1281 set(anAtom, nextValue === utils_RESET ? initialValue : nextValue); 1282 } 1283 ); 1284 return anAtom; 1285} 1286 1287function atomWithReducer(initialValue, reducer) { 1288 return atom(initialValue, function(get, set, action) { 1289 set(this, reducer(get(this), action)); 1290 }); 1291} 1292 1293let didWarnDeprecation$1 = false; 1294function atomFamily(initializeAtom, areEqual) { 1295 if (( false ? 0 : void 0) !== "production" && !didWarnDeprecation$1) { 1296 console.warn( 1297 "[DEPRECATED] atomFamily is deprecated and will be removed in v3. Please use the `jotai-family` package instead: https://github.com/jotaijs/jotai-family" 1298 ); 1299 didWarnDeprecation$1 = true; 1300 } 1301 let shouldRemove = null; 1302 const atoms = /* @__PURE__ */ new Map(); 1303 const listeners = /* @__PURE__ */ new Set(); 1304 const createAtom = (param) => { 1305 let item; 1306 if (areEqual === void 0) { 1307 item = atoms.get(param); 1308 } else { 1309 for (const [key, value] of atoms) { 1310 if (areEqual(key, param)) { 1311 item = value; 1312 break; 1313 } 1314 } 1315 } 1316 if (item !== void 0) { 1317 if (shouldRemove == null ? void 0 : shouldRemove(item[1], param)) { 1318 createAtom.remove(param); 1319 } else { 1320 return item[0]; 1321 } 1322 } 1323 const newAtom = initializeAtom(param); 1324 atoms.set(param, [newAtom, Date.now()]); 1325 notifyListeners("CREATE", param, newAtom); 1326 return newAtom; 1327 }; 1328 const notifyListeners = (type, param, atom) => { 1329 for (const listener of listeners) { 1330 listener({ type, param, atom }); 1331 } 1332 }; 1333 createAtom.unstable_listen = (callback) => { 1334 listeners.add(callback); 1335 return () => { 1336 listeners.delete(callback); 1337 }; 1338 }; 1339 createAtom.getParams = () => atoms.keys(); 1340 createAtom.remove = (param) => { 1341 if (areEqual === void 0) { 1342 if (!atoms.has(param)) return; 1343 const [atom] = atoms.get(param); 1344 atoms.delete(param); 1345 notifyListeners("REMOVE", param, atom); 1346 } else { 1347 for (const [key, [atom]] of atoms) { 1348 if (areEqual(key, param)) { 1349 atoms.delete(key); 1350 notifyListeners("REMOVE", key, atom); 1351 break; 1352 } 1353 } 1354 } 1355 }; 1356 createAtom.setShouldRemove = (fn) => { 1357 shouldRemove = fn; 1358 if (!shouldRemove) return; 1359 for (const [key, [atom, createdAt]] of atoms) { 1360 if (shouldRemove(createdAt, key)) { 1361 atoms.delete(key); 1362 notifyListeners("REMOVE", key, atom); 1363 } 1364 } 1365 }; 1366 return createAtom; 1367} 1368 1369const getCached$2 = (c, m, k) => (m.has(k) ? m : m.set(k, c())).get(k); 1370const cache1$3 = /* @__PURE__ */ new WeakMap(); 1371const memo3 = (create, dep1, dep2, dep3) => { 1372 const cache2 = getCached$2(() => /* @__PURE__ */ new WeakMap(), cache1$3, dep1); 1373 const cache3 = getCached$2(() => /* @__PURE__ */ new WeakMap(), cache2, dep2); 1374 return getCached$2(create, cache3, dep3); 1375}; 1376function selectAtom(anAtom, selector, equalityFn = Object.is) { 1377 return memo3( 1378 () => { 1379 const EMPTY = /* @__PURE__ */ Symbol(); 1380 const selectValue = ([value, prevSlice]) => { 1381 if (prevSlice === EMPTY) { 1382 return selector(value); 1383 } 1384 const slice = selector(value, prevSlice); 1385 return equalityFn(prevSlice, slice) ? prevSlice : slice; 1386 }; 1387 const derivedAtom = atom((get) => { 1388 const prev = get(derivedAtom); 1389 const value = get(anAtom); 1390 return selectValue([value, prev]); 1391 }); 1392 derivedAtom.init = EMPTY; 1393 return derivedAtom; 1394 }, 1395 anAtom, 1396 selector, 1397 equalityFn 1398 ); 1399} 1400 1401const frozenAtoms = /* @__PURE__ */ new WeakSet(); 1402const deepFreeze = (value) => { 1403 if (typeof value !== "object" || value === null) { 1404 return value; 1405 } 1406 Object.freeze(value); 1407 const propNames = Object.getOwnPropertyNames(value); 1408 for (const name of propNames) { 1409 deepFreeze(value[name]); 1410 } 1411 return value; 1412}; 1413function freezeAtom(anAtom) { 1414 if (frozenAtoms.has(anAtom)) { 1415 return anAtom; 1416 } 1417 frozenAtoms.add(anAtom); 1418 const origRead = anAtom.read; 1419 anAtom.read = function(get, options) { 1420 return deepFreeze(origRead.call(this, get, options)); 1421 }; 1422 if ("write" in anAtom) { 1423 const origWrite = anAtom.write; 1424 anAtom.write = function(get, set, ...args) { 1425 return origWrite.call( 1426 this, 1427 get, 1428 (...setArgs) => { 1429 if (setArgs[0] === anAtom) { 1430 setArgs[1] = deepFreeze(setArgs[1]); 1431 } 1432 return set(...setArgs); 1433 }, 1434 ...args 1435 ); 1436 }; 1437 } 1438 return anAtom; 1439} 1440function freezeAtomCreator(createAtom) { 1441 if (( false ? 0 : void 0) !== "production") { 1442 console.warn( 1443 "[DEPRECATED] freezeAtomCreator is deprecated, define it on users end" 1444 ); 1445 } 1446 return ((...args) => freezeAtom(createAtom(...args))); 1447} 1448 1449const getCached$1 = (c, m, k) => (m.has(k) ? m : m.set(k, c())).get(k); 1450const cache1$2 = /* @__PURE__ */ new WeakMap(); 1451const memo2$1 = (create, dep1, dep2) => { 1452 const cache2 = getCached$1(() => /* @__PURE__ */ new WeakMap(), cache1$2, dep1); 1453 return getCached$1(create, cache2, dep2); 1454}; 1455const cacheKeyForEmptyKeyExtractor = {}; 1456const isWritable = (atom2) => !!atom2.write; 1457const isFunction = (x) => typeof x === "function"; 1458function splitAtom(arrAtom, keyExtractor) { 1459 return memo2$1( 1460 () => { 1461 const mappingCache = /* @__PURE__ */ new WeakMap(); 1462 const getMapping = (arr, prev) => { 1463 let mapping = mappingCache.get(arr); 1464 if (mapping) { 1465 return mapping; 1466 } 1467 const prevMapping = prev && mappingCache.get(prev); 1468 const atomList = [];
1469 const keyList = []; 1470 arr.forEach((item, index) => { 1471 const key = keyExtractor ? keyExtractor(item) : index; 1472 keyList[index] = key; 1473 const cachedAtom = prevMapping && prevMapping.atomList[prevMapping.keyList.indexOf(key)]; 1474 if (cachedAtom) { 1475 atomList[index] = cachedAtom; 1476 return; 1477 } 1478 const read = (get) => { 1479 const prev2 = get(mappingAtom); 1480 const currArr = get(arrAtom); 1481 const mapping2 = getMapping(currArr, prev2 == null ? void 0 : prev2.arr); 1482 const index2 = mapping2.keyList.indexOf(key); 1483 if (index2 < 0 || index2 >= currArr.length) { 1484 const prevItem = arr[getMapping(arr).keyList.indexOf(key)]; 1485 if (prevItem) { 1486 return prevItem; 1487 } 1488 throw new Error("splitAtom: index out of bounds for read"); 1489 } 1490 return currArr[index2]; 1491 }; 1492 const write = (get, set, update) => { 1493 const prev2 = get(mappingAtom); 1494 const arr2 = get(arrAtom); 1495 const mapping2 = getMapping(arr2, prev2 == null ? void 0 : prev2.arr); 1496 const index2 = mapping2.keyList.indexOf(key); 1497 if (index2 < 0 || index2 >= arr2.length) { 1498 throw new Error("splitAtom: index out of bounds for write"); 1499 } 1500 const nextItem = isFunction(update) ? update(arr2[index2]) : update; 1501 if (!Object.is(arr2[index2], nextItem)) { 1502 set(arrAtom, [ 1503 ...arr2.slice(0, index2), 1504 nextItem, 1505 ...arr2.slice(index2 + 1) 1506 ]); 1507 } 1508 }; 1509 atomList[index] = isWritable(arrAtom) ? atom(read, write) : atom(read); 1510 }); 1511 if (prevMapping && prevMapping.keyList.length === keyList.length && prevMapping.keyList.every((x, i) => x === keyList[i])) { 1512 mapping = prevMapping; 1513 } else { 1514 mapping = { arr, atomList, keyList }; 1515 } 1516 mappingCache.set(arr, mapping); 1517 return mapping; 1518 }; 1519 const mappingAtom = atom((get) => { 1520 const prev = get(mappingAtom); 1521 const arr = get(arrAtom); 1522 const mapping = getMapping(arr, prev == null ? void 0 : prev.arr); 1523 return mapping; 1524 }); 1525 if (( false ? 0 : void 0) !== "production") { 1526 mappingAtom.debugPrivate = true; 1527 } 1528 mappingAtom.init = void 0; 1529 const splittedAtom = isWritable(arrAtom) ? atom( 1530 (get) => get(mappingAtom).atomList, 1531 (get, set, action) => { 1532 switch (action.type) { 1533 case "remove": { 1534 const index = get(splittedAtom).indexOf(action.atom); 1535 if (index >= 0) { 1536 const arr = get(arrAtom); 1537 set(arrAtom, [ 1538 ...arr.slice(0, index), 1539 ...arr.slice(index + 1) 1540 ]); 1541 } 1542 break; 1543 } 1544 case "insert": { 1545 const index = action.before ? get(splittedAtom).indexOf(action.before) : get(splittedAtom).length; 1546 if (index >= 0) { 1547 const arr = get(arrAtom); 1548 set(arrAtom, [ 1549 ...arr.slice(0, index), 1550 action.value, 1551 ...arr.slice(index) 1552 ]); 1553 } 1554 break; 1555 } 1556 case "move": { 1557 const index1 = get(splittedAtom).indexOf(action.atom); 1558 const index2 = action.before ? get(splittedAtom).indexOf(action.before) : get(splittedAtom).length; 1559 if (index1 >= 0 && index2 >= 0) { 1560 const arr = get(arrAtom); 1561 if (index1 < index2) { 1562 set(arrAtom, [ 1563 ...arr.slice(0, index1), 1564 ...arr.slice(index1 + 1, index2), 1565 arr[index1], 1566 ...arr.slice(index2) 1567 ]); 1568 } else { 1569 set(arrAtom, [ 1570 ...arr.slice(0, index2), 1571 arr[index1], 1572 ...arr.slice(index2, index1), 1573 ...arr.slice(index1 + 1) 1574 ]); 1575 } 1576 } 1577 break; 1578 } 1579 } 1580 } 1581 ) : atom((get) => get(mappingAtom).atomList); 1582 return splittedAtom; 1583 }, 1584 arrAtom,
1585 keyExtractor || cacheKeyForEmptyKeyExtractor 1586 ); 1587} 1588 1589function atomWithDefault(getDefault) { 1590 const EMPTY = /* @__PURE__ */ Symbol(); 1591 const overwrittenAtom = atom(EMPTY); 1592 if (( false ? 0 : void 0) !== "production") { 1593 overwrittenAtom.debugPrivate = true; 1594 } 1595 const anAtom = atom( 1596 (get, options) => { 1597 const overwritten = get(overwrittenAtom); 1598 if (overwritten !== EMPTY) { 1599 return overwritten; 1600 } 1601 return getDefault(get, options); 1602 }, 1603 (get, set, update) => { 1604 const newValue = typeof update === "function" ? update(get(anAtom)) : update; 1605 set(overwrittenAtom, newValue === utils_RESET ? EMPTY : newValue); 1606 } 1607 ); 1608 return anAtom; 1609} 1610 1611const isPromiseLike$2 = (x) => typeof (x == null ? void 0 : x.then) === "function"; 1612function withStorageValidator(validator) { 1613 return (unknownStorage) => { 1614 const storage = { 1615 ...unknownStorage, 1616 getItem: (key, initialValue) => { 1617 const validate = (value2) => { 1618 if (!validator(value2)) { 1619 return initialValue; 1620 } 1621 return value2; 1622 }; 1623 const value = unknownStorage.getItem(key, initialValue); 1624 if (isPromiseLike$2(value)) { 1625 return value.then(validate); 1626 } 1627 return validate(value); 1628 } 1629 }; 1630 return storage; 1631 }; 1632} 1633function createJSONStorage(getStringStorage = () => { 1634 try { 1635 return window.localStorage; 1636 } catch (e) { 1637 if (( false ? 0 : void 0) !== "production") { 1638 if (typeof window !== "undefined") { 1639 console.warn(e); 1640 } 1641 } 1642 return void 0; 1643 } 1644}, options) { 1645 var _a; 1646 let lastStr; 1647 let lastValue; 1648 const storage = { 1649 getItem: (key, initialValue) => { 1650 var _a2, _b; 1651 const parse = (str2) => { 1652 str2 = str2 || ""; 1653 if (lastStr !== str2) { 1654 try { 1655 lastValue = JSON.parse(str2, options == null ? void 0 : options.reviver); 1656 } catch (e) { 1657 return initialValue; 1658 } 1659 lastStr = str2; 1660 } 1661 return lastValue; 1662 }; 1663 const str = (_b = (_a2 = getStringStorage()) == null ? void 0 : _a2.getItem(key)) != null ? _b : null; 1664 if (isPromiseLike$2(str)) { 1665 return str.then(parse); 1666 } 1667 return parse(str); 1668 }, 1669 setItem: (key, newValue) => { 1670 var _a2; 1671 return (_a2 = getStringStorage()) == null ? void 0 : _a2.setItem( 1672 key, 1673 JSON.stringify(newValue, options == null ? void 0 : options.replacer) 1674 ); 1675 }, 1676 removeItem: (key) => { 1677 var _a2; 1678 return (_a2 = getStringStorage()) == null ? void 0 : _a2.removeItem(key); 1679 } 1680 }; 1681 const createHandleSubscribe = (subscriber2) => (key, callback, initialValue) => subscriber2(key, (v) => { 1682 let newValue; 1683 try { 1684 newValue = JSON.parse(v || "", options == null ? void 0 : options.reviver); 1685 } catch (e) { 1686 newValue = initialValue; 1687 } 1688 callback(newValue); 1689 }); 1690 let subscriber; 1691 try { 1692 subscriber = (_a = getStringStorage()) == null ? void 0 : _a.subscribe; 1693 } catch (e) { 1694 } 1695 if (!subscriber && typeof window !== "undefined" && typeof window.addEventListener === "function" && window.Storage) { 1696 subscriber = (key, callback) => { 1697 if (!(getStringStorage() instanceof window.Storage)) { 1698 return () => { 1699 }; 1700 } 1701 const storageEventCallback = (e) => { 1702 if (e.storageArea === getStringStorage() && e.key === key) { 1703 callback(e.newValue); 1704 } 1705 }; 1706 window.addEventListener("storage", storageEventCallback); 1707 return () => { 1708 window.removeEventListener("storage", storageEventCallback); 1709 }; 1710 }; 1711 } 1712 if (subscriber) { 1713 storage.subscribe = createHandleSubscribe(subscriber); 1714 } 1715 return storage; 1716} 1717const defaultStorage = createJSONStorage(); 1718function atomWithStorage(key, initialValue, storage = defaultStorage, options) { 1719 const getOnInit = options == null ? void 0 : options.getOnInit; 1720 const baseAtom = atom( 1721 getOnInit ? storage.getItem(key, initialValue) : initialValue 1722 ); 1723 if (( false ? 0 : void 0) !== "production") { 1724 baseAtom.debugPrivate = true; 1725 } 1726 baseAtom.onMount = (setAtom) => { 1727 var _a; 1728 setAtom(storage.getItem(key, initialValue)); 1729 return (_a = storage.subscribe) == null ? void 0 : _a.call(storage, key, setAtom, initialValue); 1730 }; 1731 const anAtom = atom( 1732 (get) => get(baseAtom), 1733 (get, set, update) => { 1734 const nextValue = typeof update === "function" ? update(get(baseAtom)) : update;
1735 if (nextValue === utils_RESET) { 1736 set(baseAtom, initialValue); 1737 return storage.removeItem(key); 1738 } 1739 if (isPromiseLike$2(nextValue)) { 1740 return nextValue.then((resolvedValue) => { 1741 set(baseAtom, resolvedValue); 1742 return storage.setItem(key, resolvedValue); 1743 }); 1744 } 1745 set(baseAtom, nextValue); 1746 return storage.setItem(key, nextValue); 1747 } 1748 ); 1749 return anAtom; 1750} 1751 1752const isPromiseLike$1 = (x) => typeof (x == null ? void 0 : x.then) === "function"; 1753function atomWithObservable(getObservable, options) { 1754 const returnResultData = (result) => { 1755 if ("e" in result) { 1756 throw result.e; 1757 } 1758 return result.d; 1759 }; 1760 const observableResultAtom = atom((get) => { 1761 var _a; 1762 const observable = getObservable(get); 1763 const subscribable = ((_a = observable[Symbol.observable]) == null ? void 0 : _a.call(observable)) || observable; 1764 let resolve; 1765 const makePending = () => new Promise((r) => { 1766 resolve = r; 1767 }); 1768 const initialResult = options && "initialValue" in options ? { 1769 d: typeof options.initialValue === "function" ? options.initialValue() : options.initialValue 1770 } : makePending(); 1771 let setResult; 1772 let lastResult; 1773 const listener = (result) => { 1774 lastResult = result; 1775 resolve == null ? void 0 : resolve(result); 1776 setResult == null ? void 0 : setResult(result); 1777 }; 1778 let subscription; 1779 let timer; 1780 const isNotMounted = () => !setResult; 1781 const unsubscribe = () => { 1782 if (subscription) { 1783 subscription.unsubscribe(); 1784 subscription = void 0; 1785 } 1786 }; 1787 const start = () => { 1788 if (subscription) { 1789 clearTimeout(timer); 1790 subscription.unsubscribe(); 1791 } 1792 subscription = subscribable.subscribe({ 1793 next: (d) => listener({ d }), 1794 error: (e) => listener({ e }), 1795 complete: () => { 1796 } 1797 }); 1798 if (isNotMounted() && (options == null ? void 0 : options.unstable_timeout)) { 1799 timer = setTimeout(unsubscribe, options.unstable_timeout); 1800 } 1801 }; 1802 start(); 1803 const resultAtom = atom(lastResult || initialResult); 1804 if (( false ? 0 : void 0) !== "production") { 1805 resultAtom.debugPrivate = true; 1806 } 1807 resultAtom.onMount = (update) => { 1808 setResult = update; 1809 if (lastResult) { 1810 update(lastResult); 1811 } 1812 if (subscription) { 1813 clearTimeout(timer); 1814 } else { 1815 start(); 1816 } 1817 return () => { 1818 setResult = void 0; 1819 if (options == null ? void 0 : options.unstable_timeout) { 1820 timer = setTimeout(unsubscribe, options.unstable_timeout); 1821 } else { 1822 unsubscribe(); 1823 } 1824 }; 1825 }; 1826 return [resultAtom, observable, makePending, start, isNotMounted]; 1827 }); 1828 if (( false ? 0 : void 0) !== "production") { 1829 observableResultAtom.debugPrivate = true; 1830 } 1831 const observableAtom = atom( 1832 (get) => { 1833 const [resultAtom] = get(observableResultAtom); 1834 const result = get(resultAtom); 1835 if (isPromiseLike$1(result)) { 1836 return result.then(returnResultData); 1837 } 1838 return returnResultData(result); 1839 }, 1840 (get, set, data) => { 1841 const [resultAtom, observable, makePending, start, isNotMounted] = get(observableResultAtom); 1842 if ("next" in observable) { 1843 if (isNotMounted()) { 1844 set(resultAtom, makePending()); 1845 start(); 1846 } 1847 observable.next(data); 1848 } else { 1849 throw new Error("observable is not subject"); 1850 } 1851 } 1852 ); 1853 return observableAtom; 1854} 1855 1856const getCached = (c, m, k) => (m.has(k) ? m : m.set(k, c())).get(k); 1857const cache1$1 = /* @__PURE__ */ new WeakMap(); 1858const memo2 = (create, dep1, dep2) => { 1859 const cache2 = getCached(() => /* @__PURE__ */ new WeakMap(), cache1$1, dep1); 1860 return getCached(create, cache2, dep2); 1861}; 1862const isPromiseLike = (p) => typeof (p == null ? void 0 : p.then) === "function"; 1863const defaultFallback = () => void 0; 1864function unwrap(anAtom, fallback = defaultFallback) { 1865 return memo2( 1866 () => { 1867 const promiseErrorCache = /* @__PURE__ */ new WeakMap(); 1868 const promiseResultCache = /* @__PURE__ */ new WeakMap(); 1869 const refreshAtom = atom(0); 1870 const triggerRefreshAtom = atom([]); 1871 triggerRefreshAtom.INTERNAL_onInit = (store) => { 1872 store.set(triggerRefreshAtom, [ 1873 () => store.set(refreshAtom, (c) => c + 1) 1874 ]); 1875 }; 1876 if (( false ? 0 : void 0) !== "production") { 1877 refreshAtom.debugPrivate = true; 1878 triggerRefreshAtom.debugPrivate = true; 1879 } 1880 const promiseAndValueAtom = atom((get) => { 1881 get(refreshAtom); 1882 let prev; 1883 try { 1884 prev = get(promiseAndValueAtom); 1885 } catch (e) { 1886 } 1887 const promise = get(anAtom); 1888 if (!isPromiseLike(promise)) { 1889 return { v: promise }; 1890 } 1891 if (promise !== (prev == null ? void 0 : prev.p)) { 1892 promise.then( 1893 (v) => { 1894 promiseResultCache.set(promise, v); 1895 const [triggerRefresh] = get(triggerRefreshAtom); 1896 triggerRefresh(); 1897 }, 1898 (e) => { 1899 promiseErrorCache.set(promise, e); 1900 const [triggerRefresh] = get(triggerRefreshAtom); 1901 triggerRefresh(); 1902 } 1903 ); 1904 } 1905 if (promiseErrorCache.has(promise)) { 1906 throw promiseErrorCache.get(promise); 1907 } 1908 if (promiseResultCache.has(promise)) { 1909 return { 1910 p: promise, 1911 v: promiseResultCache.get(promise) 1912 }; 1913 } 1914 if (prev && "v" in prev) { 1915 return { p: promise, f: fallback(prev.v), v: prev.v }; 1916 } 1917 return { p: promise, f: fallback() }; 1918 }); 1919 promiseAndValueAtom.init = void 0; 1920 if (( false ? 0 : void 0) !== "production") { 1921 promiseAndValueAtom.debugPrivate = true; 1922 } 1923 return atom( 1924 (get) => { 1925 const state = get(promiseAndValueAtom); 1926 if ("f" in state) { 1927 return state.f; 1928 } 1929 return state.v; 1930 }, 1931 (_get, set, ...args) => set(anAtom, ...args) 1932 ); 1933 }, 1934 anAtom, 1935 fallback 1936 ); 1937} 1938 1939const cache1 = /* @__PURE__ */ new WeakMap(); 1940const memo1 = (create, dep1) => (cache1.has(dep1) ? cache1 : cache1.set(dep1, create())).get(dep1); 1941let didWarnDeprecation = false;
1942function loadable(anAtom) { 1943 if (( false ? 0 : void 0) !== "production" && !didWarnDeprecation) { 1944 console.warn( 1945 "[DEPRECATED] loadable is deprecated and will be removed in v3. Please use a userland util with the `unwrap` util: https://github.com/pmndrs/jotai/pull/3217" 1946 ); 1947 didWarnDeprecation = true; 1948 } 1949 return memo1(() => { 1950 const LOADING = { state: "loading" }; 1951 const unwrappedAtom = unwrap(anAtom, () => LOADING); 1952 return atom((get) => { 1953 try { 1954 const data = get(unwrappedAtom); 1955 if (data === LOADING) { 1956 return LOADING; 1957 } 1958 return { state: "hasData", data }; 1959 } catch (error) { 1960 return { state: "hasError", error }; 1961 } 1962 }); 1963 }, anAtom); 1964} 1965 1966function atomWithRefresh(read, write) { 1967 const refreshAtom = atom(0); 1968 if (( false ? 0 : void 0) !== "production") { 1969 refreshAtom.debugPrivate = true; 1970 } 1971 return atom( 1972 (get, options) => { 1973 get(refreshAtom); 1974 return read(get, options); 1975 }, 1976 (get, set, ...args) => { 1977 if (args.length === 0) { 1978 set(refreshAtom, (c) => c + 1); 1979 } else if (write) { 1980 return write(get, set, ...args); 1981 } else if (( false ? 0 : void 0) !== "production") { 1982 throw new Error("refresh must be called without arguments"); 1983 } 1984 } 1985 ); 1986} 1987 1988function atomWithLazy(makeInitial) { 1989 const a = atom(void 0); 1990 delete a.init; 1991 Object.defineProperty(a, "init", { 1992 get() { 1993 return makeInitial(); 1994 } 1995 }); 1996 return a; 1997} 1998 1999 2000 2001// EXTERNAL MODULE: ./node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/react/index.js 2002var react = __webpack_require__(25529); 2003// EXTERNAL MODULE: ./node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]/node_modules/jotai/esm/react.mjs 2004var esm_react = __webpack_require__(22077); 2005;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]/node_modules/jotai/esm/react/utils.mjs 2006/* __next_internal_client_entry_do_not_use__ useAtomCallback,useHydrateAtoms,useReducerAtom,useResetAtom auto */ 2007 2008 2009 2010function useResetAtom(anAtom, options) { 2011 const setAtom = useSetAtom(anAtom, options); 2012 const resetAtom = useCallback(()=>setAtom(RESET), [ 2013 setAtom 2014 ]); 2015 return resetAtom; 2016} 2017function useReducerAtom(anAtom, reducer, options) { 2018 if (( false ? 0 : void 0) !== "production") { 2019 console.warn("[DEPRECATED] useReducerAtom is deprecated and will be removed in the future. Please create your own version using the recipe. https://github.com/pmndrs/jotai/pull/2467"); 2020 } 2021 const [state, setState] = useAtom(anAtom, options); 2022 const dispatch = useCallback((action)=>{ 2023 setState((prev)=>reducer(prev, action)); 2024 }, [ 2025 setState, 2026 reducer 2027 ]); 2028 return [ 2029 state, 2030 dispatch 2031 ]; 2032} 2033function useAtomCallback(callback, options) { 2034 const anAtom = useMemo(()=>atom(null, function(get, set) { 2035 for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){ 2036 args[_key - 2] = arguments[_key]; 2037 } 2038 return callback(get, set, ...args); 2039 }), [ 2040 callback 2041 ]); 2042 return useSetAtom(anAtom, options); 2043} 2044const hydratedMap = /* @__PURE__ */ new WeakMap(); 2045function useHydrateAtoms(values, options) { 2046 const store = (0,esm_react.useStore)(options); 2047 const hydratedSet = getHydratedSet(store); 2048 for (const [atom, ...args] of values){ 2049 if (!hydratedSet.has(atom) || (options == null ? void 0 : options.dangerouslyForceHydrate)) { 2050 hydratedSet.add(atom); 2051 store.set(atom, ...args); 2052 } 2053 } 2054} 2055const getHydratedSet = (store)=>{ 2056 let hydratedSet = hydratedMap.get(store); 2057 if (!hydratedSet) { 2058 hydratedSet = /* @__PURE__ */ new WeakSet(); 2059 hydratedMap.set(store, hydratedSet); 2060 } 2061 return hydratedSet; 2062}; 2063 2064 2065;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]/node_modules/jotai/esm/utils.mjs 2066 2067 2068 2069 2070/***/ }), 2071 2072/***/ 31067: 2073/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { 2074 2075 2076// EXPORTS 2077__webpack_require__.d(__webpack_exports__, { 2078 ZP: function() { return /* reexport */ Markdown; } 2079}); 2080 2081// UNUSED EXPORTS: MarkdownAsync, MarkdownHooks, defaultUrlTransform 2082 2083// NAMESPACE OBJECT: ./node_modules/.pnpm/[email protected]/node_modules/property-information/lib/util/types.js
2084var types_namespaceObject = {}; 2085__webpack_require__.r(types_namespaceObject); 2086__webpack_require__.d(types_namespaceObject, { 2087 boolean: function() { return types_boolean; }, 2088 booleanish: function() { return booleanish; }, 2089 commaOrSpaceSeparated: function() { return commaOrSpaceSeparated; }, 2090 commaSeparated: function() { return commaSeparated; }, 2091 number: function() { return number; }, 2092 overloadedBoolean: function() { return overloadedBoolean; }, 2093 spaceSeparated: function() { return spaceSeparated; } 2094}); 2095 2096// NAMESPACE OBJECT: ./node_modules/.pnpm/[email protected]/node_modules/micromark/lib/constructs.js 2097var constructs_namespaceObject = {}; 2098__webpack_require__.r(constructs_namespaceObject); 2099__webpack_require__.d(constructs_namespaceObject, { 2100 attentionMarkers: function() { return attentionMarkers; }, 2101 contentInitial: function() { return contentInitial; }, 2102 disable: function() { return disable; }, 2103 document: function() { return constructs_document; }, 2104 flow: function() { return constructs_flow; }, 2105 flowInitial: function() { return flowInitial; }, 2106 insideSpan: function() { return insideSpan; }, 2107 string: function() { return constructs_string; }, 2108 text: function() { return constructs_text; } 2109}); 2110 2111;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/devlop/lib/default.js 2112function deprecate(fn) { 2113 return fn 2114} 2115 2116function equal() {} 2117 2118function ok() {} 2119 2120function unreachable() {} 2121 2122;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/comma-separated-tokens/index.js 2123/** 2124 * @typedef Options 2125 * Configuration for `stringify`. 2126 * @property {boolean} [padLeft=true] 2127 * Whether to pad a space before a token. 2128 * @property {boolean} [padRight=false] 2129 * Whether to pad a space after a token. 2130 */ 2131 2132/** 2133 * @typedef {Options} StringifyOptions 2134 * Please use `StringifyOptions` instead. 2135 */ 2136 2137/** 2138 * Parse comma-separated tokens to an array. 2139 * 2140 * @param {string} value 2141 * Comma-separated tokens. 2142 * @returns {Array<string>} 2143 * List of tokens. 2144 */ 2145function comma_separated_tokens_parse(value) { 2146 /** @type {Array<string>} */ 2147 const tokens = [] 2148 const input = String(value || '') 2149 let index = input.indexOf(',') 2150 let start = 0 2151 /** @type {boolean} */ 2152 let end = false 2153
2154 while (!end) { 2155 if (index === -1) { 2156 index = input.length 2157 end = true 2158 } 2159 2160 const token = input.slice(start, index).trim() 2161 2162 if (token || !end) { 2163 tokens.push(token) 2164 } 2165 2166 start = index + 1 2167 index = input.indexOf(',', start) 2168 } 2169 2170 return tokens 2171} 2172 2173/** 2174 * Serialize an array of strings or numbers to comma-separated tokens. 2175 * 2176 * @param {Array<string|number>} values 2177 * List of tokens. 2178 * @param {Options} [options] 2179 * Configuration for `stringify` (optional). 2180 * @returns {string} 2181 * Comma-separated tokens. 2182 */ 2183function stringify(values, options) { 2184 const settings = options || {} 2185 2186 // Ensure the last empty entry is seen. 2187 const input = values[values.length - 1] === '' ? [...values, ''] : values 2188 2189 return input 2190 .join( 2191 (settings.padRight ? ' ' : '') + 2192 ',' + 2193 (settings.padLeft === false ? '' : ' ') 2194 ) 2195 .trim() 2196} 2197 2198;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/estree-util-is-identifier-name/lib/index.js 2199/** 2200 * @typedef Options 2201 * Configuration. 2202 * @property {boolean | null | undefined} [jsx=false] 2203 * Support JSX identifiers (default: `false`). 2204 */ 2205 2206const startRe = /[$_\p{ID_Start}]/u 2207const contRe = /[$_\u{200C}\u{200D}\p{ID_Continue}]/u 2208const contReJsx = /[-$_\u{200C}\u{200D}\p{ID_Continue}]/u 2209const nameRe = /^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u 2210const nameReJsx = /^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u 2211 2212/** @type {Options} */ 2213const emptyOptions = {} 2214 2215/** 2216 * Checks if the given code point can start an identifier. 2217 * 2218 * @param {number | undefined} code 2219 * Code point to check. 2220 * @returns {boolean} 2221 * Whether `code` can start an identifier. 2222 */ 2223// Note: `undefined` is supported so you can pass the result from `''.codePointAt`. 2224function start(code) { 2225 return code ? startRe.test(String.fromCodePoint(code)) : false 2226} 2227 2228/** 2229 * Checks if the given code point can continue an identifier. 2230 * 2231 * @param {number | undefined} code 2232 * Code point to check. 2233 * @param {Options | null | undefined} [options] 2234 * Configuration (optional). 2235 * @returns {boolean} 2236 * Whether `code` can continue an identifier. 2237 */ 2238// Note: `undefined` is supported so you can pass the result from `''.codePointAt`. 2239function cont(code, options) { 2240 const settings = options || emptyOptions 2241 const re = settings.jsx ? contReJsx : contRe 2242 return code ? re.test(String.fromCodePoint(code)) : false 2243} 2244 2245/** 2246 * Checks if the given value is a valid identifier name. 2247 * 2248 * @param {string} name 2249 * Identifier to check. 2250 * @param {Options | null | undefined} [options] 2251 * Configuration (optional). 2252 * @returns {boolean} 2253 * Whether `name` can be an identifier. 2254 */ 2255function lib_name(name, options) { 2256 const settings = options || emptyOptions 2257 const re = settings.jsx ? nameReJsx : nameRe 2258 return re.test(name) 2259} 2260 2261;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/estree-util-is-identifier-name/index.js 2262/** 2263 * @typedef {import('./lib/index.js').Options} Options 2264 */ 2265 2266 2267 2268;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/hast-util-whitespace/lib/index.js 2269/** 2270 * @typedef {import('hast').Nodes} Nodes 2271 */ 2272 2273// HTML whitespace expression. 2274// See <https://infra.spec.whatwg.org/#ascii-whitespace>. 2275const re = /[ \t\n\f\r]/g 2276 2277/** 2278 * Check if the given value is *inter-element whitespace*. 2279 * 2280 * @param {Nodes | string} thing 2281 * Thing to check (`Node` or `string`). 2282 * @returns {boolean} 2283 * Whether the `value` is inter-element whitespace (`boolean`): consisting of 2284 * zero or more of space, tab (`\t`), line feed (`\n`), carriage return 2285 * (`\r`), or form feed (`\f`); if a node is passed it must be a `Text` node, 2286 * whose `value` field is checked. 2287 */ 2288function whitespace(thing) { 2289 return typeof thing === 'object' 2290 ? thing.type === 'text' 2291 ? empty(thing.value) 2292 : false 2293 : empty(thing) 2294} 2295 2296/** 2297 * @param {string} value 2298 * @returns {boolean} 2299 */ 2300function empty(value) { 2301 return value.replace(re, '') === '' 2302} 2303 2304;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/hast-util-whitespace/index.js 2305 2306 2307;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/property-information/lib/util/schema.js 2308/** 2309 * @import {Schema as SchemaType, Space} from 'property-information' 2310 */ 2311 2312/** @type {SchemaType} */ 2313class Schema { 2314 /** 2315 * @param {SchemaType['property']} property 2316 * Property. 2317 * @param {SchemaType['normal']} normal 2318 * Normal. 2319 * @param {Space | undefined} [space] 2320 * Space. 2321 * @returns 2322 * Schema. 2323 */ 2324 constructor(property, normal, space) { 2325 this.normal = normal 2326 this.property = property 2327 2328 if (space) { 2329 this.space = space 2330 } 2331 } 2332} 2333 2334Schema.prototype.normal = {} 2335Schema.prototype.property = {} 2336Schema.prototype.space = undefined 2337 2338;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/property-information/lib/util/merge.js 2339/** 2340 * @import {Info, Space} from 'property-information' 2341 */ 2342 2343 2344 2345/** 2346 * @param {ReadonlyArray<Schema>} definitions 2347 * Definitions. 2348 * @param {Space | undefined} [space] 2349 * Space. 2350 * @returns {Schema} 2351 * Schema. 2352 */ 2353function merge(definitions, space) { 2354 /** @type {Record<string, Info>} */ 2355 const property = {} 2356 /** @type {Record<string, string>} */ 2357 const normal = {} 2358 2359 for (const definition of definitions) { 2360 Object.assign(property, definition.property) 2361 Object.assign(normal, definition.normal) 2362 } 2363 2364 return new Schema(property, normal, space) 2365} 2366 2367;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/property-information/lib/normalize.js 2368/** 2369 * Get the cleaned case insensitive form of an attribute or property. 2370 * 2371 * @param {string} value 2372 * An attribute-like or property-like name. 2373 * @returns {string} 2374 * Value that can be used to look up the properly cased property on a 2375 * `Schema`. 2376 */ 2377function normalize(value) { 2378 return value.toLowerCase() 2379} 2380 2381;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/property-information/lib/util/info.js 2382/** 2383 * @import {Info as InfoType} from 'property-information' 2384 */ 2385 2386/** @type {InfoType} */ 2387class Info { 2388 /** 2389 * @param {string} property 2390 * Property. 2391 * @param {string} attribute 2392 * Attribute. 2393 * @returns 2394 * Info. 2395 */ 2396 constructor(property, attribute) { 2397 this.attribute = attribute 2398 this.property = property 2399 } 2400} 2401 2402Info.prototype.attribute = '' 2403Info.prototype.booleanish = false 2404Info.prototype.boolean = false 2405Info.prototype.commaOrSpaceSeparated = false 2406Info.prototype.commaSeparated = false 2407Info.prototype.defined = false 2408Info.prototype.mustUseProperty = false 2409Info.prototype.number = false 2410Info.prototype.overloadedBoolean = false 2411Info.prototype.property = '' 2412Info.prototype.spaceSeparated = false 2413Info.prototype.space = undefined 2414 2415;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/property-information/lib/util/types.js 2416let powers = 0 2417 2418const types_boolean = increment() 2419const booleanish = increment() 2420const overloadedBoolean = increment() 2421const number = increment() 2422const spaceSeparated = increment() 2423const commaSeparated = increment() 2424const commaOrSpaceSeparated = increment() 2425 2426function increment() { 2427 return 2 ** ++powers 2428} 2429 2430;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/property-information/lib/util/defined-info.js 2431/** 2432 * @import {Space} from 'property-information' 2433 */ 2434 2435 2436 2437 2438const checks = /** @type {ReadonlyArray<keyof typeof types>} */ ( 2439 Object.keys(types_namespaceObject) 2440) 2441 2442class DefinedInfo extends Info { 2443 /** 2444 * @constructor 2445 * @param {string} property 2446 * Property. 2447 * @param {string} attribute 2448 * Attribute. 2449 * @param {number | null | undefined} [mask] 2450 * Mask. 2451 * @param {Space | undefined} [space] 2452 * Space. 2453 * @returns 2454 * Info. 2455 */ 2456 constructor(property, attribute, mask, space) { 2457 let index = -1 2458 2459 super(property, attribute) 2460 2461 mark(this, 'space', space) 2462 2463 if (typeof mask === 'number') { 2464 while (++index < checks.length) { 2465 const check = checks[index]
2466 mark(this, checks[index], (mask & types_namespaceObject[check]) === types_namespaceObject[check]) 2467 } 2468 } 2469 } 2470} 2471 2472DefinedInfo.prototype.defined = true 2473 2474/** 2475 * @template {keyof DefinedInfo} Key 2476 * Key type. 2477 * @param {DefinedInfo} values 2478 * Info. 2479 * @param {Key} key 2480 * Key. 2481 * @param {DefinedInfo[Key]} value 2482 * Value. 2483 * @returns {undefined} 2484 * Nothing. 2485 */ 2486function mark(values, key, value) { 2487 if (value) { 2488 values[key] = value 2489 } 2490} 2491 2492;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/property-information/lib/util/create.js 2493/** 2494 * @import {Info, Space} from 'property-information' 2495 */ 2496 2497/** 2498 * @typedef Definition 2499 * Definition of a schema. 2500 * @property {Record<string, string> | undefined} [attributes] 2501 * Normalzed names to special attribute case. 2502 * @property {ReadonlyArray<string> | undefined} [mustUseProperty] 2503 * Normalized names that must be set as properties. 2504 * @property {Record<string, number | null>} properties 2505 * Property names to their types. 2506 * @property {Space | undefined} [space] 2507 * Space. 2508 * @property {Transform} transform 2509 * Transform a property name. 2510 */ 2511 2512/** 2513 * @callback Transform 2514 * Transform. 2515 * @param {Record<string, string>} attributes 2516 * Attributes. 2517 * @param {string} property 2518 * Property. 2519 * @returns {string} 2520 * Attribute. 2521 */ 2522 2523 2524 2525 2526 2527/** 2528 * @param {Definition} definition 2529 * Definition. 2530 * @returns {Schema} 2531 * Schema. 2532 */ 2533function create(definition) { 2534 /** @type {Record<string, Info>} */ 2535 const properties = {} 2536 /** @type {Record<string, string>} */ 2537 const normals = {} 2538 2539 for (const [property, value] of Object.entries(definition.properties)) { 2540 const info = new DefinedInfo( 2541 property, 2542 definition.transform(definition.attributes || {}, property), 2543 value, 2544 definition.space 2545 ) 2546 2547 if ( 2548 definition.mustUseProperty && 2549 definition.mustUseProperty.includes(property) 2550 ) { 2551 info.mustUseProperty = true 2552 } 2553 2554 properties[property] = info 2555 2556 normals[normalize(property)] = property 2557 normals[normalize(info.attribute)] = property 2558 } 2559 2560 return new Schema(properties, normals, definition.space) 2561} 2562 2563;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/property-information/lib/aria.js 2564 2565 2566 2567const aria = create({ 2568 properties: { 2569 ariaActiveDescendant: null, 2570 ariaAtomic: booleanish, 2571 ariaAutoComplete: null, 2572 ariaBusy: booleanish, 2573 ariaChecked: booleanish, 2574 ariaColCount: number, 2575 ariaColIndex: number, 2576 ariaColSpan: number, 2577 ariaControls: spaceSeparated, 2578 ariaCurrent: null, 2579 ariaDescribedBy: spaceSeparated, 2580 ariaDetails: null, 2581 ariaDisabled: booleanish, 2582 ariaDropEffect: spaceSeparated, 2583 ariaErrorMessage: null, 2584 ariaExpanded: booleanish, 2585 ariaFlowTo: spaceSeparated, 2586 ariaGrabbed: booleanish, 2587 ariaHasPopup: null, 2588 ariaHidden: booleanish, 2589 ariaInvalid: null, 2590 ariaKeyShortcuts: null, 2591 ariaLabel: null, 2592 ariaLabelledBy: spaceSeparated, 2593 ariaLevel: number, 2594 ariaLive: null, 2595 ariaModal: booleanish, 2596 ariaMultiLine: booleanish, 2597 ariaMultiSelectable: booleanish, 2598 ariaOrientation: null, 2599 ariaOwns: spaceSeparated, 2600 ariaPlaceholder: null, 2601 ariaPosInSet: number, 2602 ariaPressed: booleanish, 2603 ariaReadOnly: booleanish, 2604 ariaRelevant: null, 2605 ariaRequired: booleanish, 2606 ariaRoleDescription: spaceSeparated, 2607 ariaRowCount: number, 2608 ariaRowIndex: number, 2609 ariaRowSpan: number, 2610 ariaSelected: booleanish, 2611 ariaSetSize: number, 2612 ariaSort: null, 2613 ariaValueMax: number, 2614 ariaValueMin: number, 2615 ariaValueNow: number, 2616 ariaValueText: null, 2617 role: null 2618 }, 2619 transform(_, property) { 2620 return property === 'role' 2621 ? property 2622 : 'aria-' + property.slice(4).toLowerCase() 2623 } 2624}) 2625 2626;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/property-information/lib/util/case-sensitive-transform.js 2627/** 2628 * @param {Record<string, string>} attributes 2629 * Attributes. 2630 * @param {string} attribute 2631 * Attribute. 2632 * @returns {string} 2633 * Transformed attribute. 2634 */ 2635function caseSensitiveTransform(attributes, attribute) { 2636 return attribute in attributes ? attributes[attribute] : attribute 2637} 2638 2639;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/property-information/lib/util/case-insensitive-transform.js 2640 2641 2642/** 2643 * @param {Record<string, string>} attributes 2644 * Attributes. 2645 * @param {string} property 2646 * Property. 2647 * @returns {string} 2648 * Transformed property. 2649 */ 2650function caseInsensitiveTransform(attributes, property) { 2651 return caseSensitiveTransform(attributes, property.toLowerCase()) 2652} 2653 2654;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/property-information/lib/html.js
vendor: 5,719 bytes, lines 2655-2904
2655 2656 2657 2658 2659const html = create({ 2660 attributes: { 2661 acceptcharset: 'accept-charset', 2662 classname: 'class', 2663 htmlfor: 'for', 2664 httpequiv: 'http-equiv' 2665 }, 2666 mustUseProperty: ['checked', 'multiple', 'muted', 'selected'], 2667 properties: { 2668 // Standard Properties. 2669 abbr: null, 2670 accept: commaSeparated, 2671 acceptCharset: spaceSeparated, 2672 accessKey: spaceSeparated, 2673 action: null, 2674 allow: null, 2675 allowFullScreen: types_boolean, 2676 allowPaymentRequest: types_boolean, 2677 allowUserMedia: types_boolean, 2678 alpha: types_boolean, 2679 alt: null, 2680 as: null, 2681 async: types_boolean, 2682 autoCapitalize: null, 2683 autoComplete: spaceSeparated, 2684 autoFocus: types_boolean, 2685 autoPlay: types_boolean, 2686 blocking: spaceSeparated, 2687 capture: null, 2688 charSet: null, 2689 checked: types_boolean, 2690 cite: null, 2691 className: spaceSeparated, 2692 closedBy: null, 2693 colorSpace: null, 2694 cols: number, 2695 colSpan: number, 2696 command: null, 2697 commandFor: null, 2698 content: null, 2699 contentEditable: booleanish, 2700 controls: types_boolean, 2701 controlsList: spaceSeparated, 2702 coords: number | commaSeparated, 2703 crossOrigin: null, 2704 data: null, 2705 dateTime: null, 2706 decoding: null, 2707 default: types_boolean, 2708 defer: types_boolean, 2709 dir: null, 2710 dirName: null, 2711 disabled: types_boolean, 2712 download: overloadedBoolean, 2713 draggable: booleanish, 2714 encType: null, 2715 enterKeyHint: null, 2716 fetchPriority: null, 2717 form: null, 2718 formAction: null, 2719 formEncType: null, 2720 formMethod: null, 2721 formNoValidate: types_boolean, 2722 formTarget: null, 2723 headers: spaceSeparated, 2724 height: number, 2725 hidden: overloadedBoolean, 2726 high: number, 2727 href: null, 2728 hrefLang: null, 2729 htmlFor: spaceSeparated, 2730 httpEquiv: spaceSeparated, 2731 id: null, 2732 imageSizes: null, 2733 imageSrcSet: null, 2734 inert: types_boolean, 2735 inputMode: null, 2736 integrity: null, 2737 is: null, 2738 isMap: types_boolean, 2739 itemId: null, 2740 itemProp: spaceSeparated, 2741 itemRef: spaceSeparated, 2742 itemScope: types_boolean, 2743 itemType: spaceSeparated, 2744 kind: null, 2745 label: null, 2746 lang: null, 2747 language: null, 2748 list: null, 2749 loading: null, 2750 loop: types_boolean, 2751 low: number, 2752 manifest: null, 2753 max: null, 2754 maxLength: number, 2755 media: null, 2756 method: null, 2757 min: null, 2758 minLength: number, 2759 multiple: types_boolean, 2760 muted: types_boolean, 2761 name: null, 2762 nonce: null, 2763 noModule: types_boolean, 2764 noValidate: types_boolean, 2765 onAbort: null, 2766 onAfterPrint: null, 2767 onAuxClick: null, 2768 onBeforeMatch: null, 2769 onBeforePrint: null, 2770 onBeforeToggle: null, 2771 onBeforeUnload: null, 2772 onBlur: null, 2773 onCancel: null, 2774 onCanPlay: null, 2775 onCanPlayThrough: null, 2776 onChange: null, 2777 onClick: null, 2778 onClose: null, 2779 onContextLost: null, 2780 onContextMenu: null, 2781 onContextRestored: null, 2782 onCopy: null, 2783 onCueChange: null, 2784 onCut: null, 2785 onDblClick: null, 2786 onDrag: null, 2787 onDragEnd: null, 2788 onDragEnter: null, 2789 onDragExit: null, 2790 onDragLeave: null, 2791 onDragOver: null, 2792 onDragStart: null, 2793 onDrop: null, 2794 onDurationChange: null, 2795 onEmptied: null, 2796 onEnded: null, 2797 onError: null, 2798 onFocus: null, 2799 onFormData: null, 2800 onHashChange: null, 2801 onInput: null, 2802 onInvalid: null, 2803 onKeyDown: null, 2804 onKeyPress: null, 2805 onKeyUp: null, 2806 onLanguageChange: null, 2807 onLoad: null, 2808 onLoadedData: null, 2809 onLoadedMetadata: null, 2810 onLoadEnd: null, 2811 onLoadStart: null, 2812 onMessage: null, 2813 onMessageError: null, 2814 onMouseDown: null, 2815 onMouseEnter: null, 2816 onMouseLeave: null, 2817 onMouseMove: null, 2818 onMouseOut: null, 2819 onMouseOver: null, 2820 onMouseUp: null, 2821 onOffline: null, 2822 onOnline: null, 2823 onPageHide: null, 2824 onPageShow: null, 2825 onPaste: null, 2826 onPause: null, 2827 onPlay: null, 2828 onPlaying: null, 2829 onPopState: null, 2830 onProgress: null, 2831 onRateChange: null, 2832 onRejectionHandled: null, 2833 onReset: null, 2834 onResize: null, 2835 onScroll: null, 2836 onScrollEnd: null, 2837 onSecurityPolicyViolation: null, 2838 onSeeked: null, 2839 onSeeking: null, 2840 onSelect: null, 2841 onSlotChange: null, 2842 onStalled: null, 2843 onStorage: null, 2844 onSubmit: null, 2845 onSuspend: null, 2846 onTimeUpdate: null, 2847 onToggle: null, 2848 onUnhandledRejection: null, 2849 onUnload: null, 2850 onVolumeChange: null, 2851 onWaiting: null, 2852 onWheel: null, 2853 open: types_boolean, 2854 optimum: number, 2855 pattern: null, 2856 ping: spaceSeparated, 2857 placeholder: null, 2858 playsInline: types_boolean, 2859 popover: null, 2860 popoverTarget: null, 2861 popoverTargetAction: null, 2862 poster: null, 2863 preload: null, 2864 readOnly: types_boolean, 2865 referrerPolicy: null, 2866 rel: spaceSeparated, 2867 required: types_boolean, 2868 reversed: types_boolean, 2869 rows: number, 2870 rowSpan: number, 2871 sandbox: spaceSeparated, 2872 scope: null, 2873 scoped: types_boolean, 2874 seamless: types_boolean, 2875 selected: types_boolean, 2876 shadowRootClonable: types_boolean, 2877 shadowRootCustomElementRegistry: types_boolean, 2878 shadowRootDelegatesFocus: types_boolean, 2879 shadowRootMode: null, 2880 shadowRootSerializable: types_boolean, 2881 shape: null, 2882 size: number, 2883 sizes: null, 2884 slot: null, 2885 span: number, 2886 spellCheck: booleanish, 2887 src: null, 2888 srcDoc: null, 2889 srcLang: null, 2890 srcSet: null, 2891 start: number, 2892 step: null, 2893 style: null, 2894 tabIndex: number, 2895 target: null, 2896 title: null, 2897 translate: null, 2898 type: null, 2899 typeMustMatch: types_boolean, 2900 useMap: null, 2901 value: booleanish, 2902 width: number, 2903 wrap: null, 2904 writingSuggestions: null,
2905 2906 // Legacy. 2907 // See: https://html.spec.whatwg.org/#other-elements,-attributes-and-apis 2908 align: null, // Several. Use CSS `text-align` instead, 2909 aLink: null, // `<body>`. Use CSS `a:active {color}` instead 2910 archive: spaceSeparated, // `<object>`. List of URIs to archives 2911 axis: null, // `<td>` and `<th>`. Use `scope` on `<th>` 2912 background: null, // `<body>`. Use CSS `background-image` instead 2913 bgColor: null, // `<body>` and table elements. Use CSS `background-color` instead 2914 border: number, // `<table>`. Use CSS `border-width` instead, 2915 borderColor: null, // `<table>`. Use CSS `border-color` instead, 2916 bottomMargin: number, // `<body>` 2917 cellPadding: null, // `<table>` 2918 cellSpacing: null, // `<table>` 2919 char: null, // Several table elements. When `align=char`, sets the character to align on 2920 charOff: null, // Several table elements. When `char`, offsets the alignment 2921 classId: null, // `<object>` 2922 clear: null, // `<br>`. Use CSS `clear` instead 2923 code: null, // `<object>` 2924 codeBase: null, // `<object>` 2925 codeType: null, // `<object>` 2926 color: null, // `<font>` and `<hr>`. Use CSS instead 2927 compact: types_boolean, // Lists. Use CSS to reduce space between items instead 2928 declare: types_boolean, // `<object>` 2929 event: null, // `<script>` 2930 face: null, // `<font>`. Use CSS instead 2931 frame: null, // `<table>` 2932 frameBorder: null, // `<iframe>`. Use CSS `border` instead 2933 hSpace: number, // `<img>` and `<object>` 2934 leftMargin: number, // `<body>` 2935 link: null, // `<body>`. Use CSS `a:link {color: *}` instead 2936 longDesc: null, // `<frame>`, `<iframe>`, and `<img>`. Use an `<a>` 2937 lowSrc: null, // `<img>`. Use a `<picture>` 2938 marginHeight: number, // `<body>` 2939 marginWidth: number, // `<body>` 2940 noResize: types_boolean, // `<frame>` 2941 noHref: types_boolean, // `<area>`. Use no href instead of an explicit `nohref` 2942 noShade: types_boolean, // `<hr>`. Use background-color and height instead of borders 2943 noWrap: types_boolean, // `<td>` and `<th>` 2944 object: null, // `<applet>` 2945 profile: null, // `<head>` 2946 prompt: null, // `<isindex>` 2947 rev: null, // `<link>` 2948 rightMargin: number, // `<body>` 2949 rules: null, // `<table>` 2950 scheme: null, // `<meta>` 2951 scrolling: booleanish, // `<frame>`. Use overflow in the child context 2952 standby: null, // `<object>` 2953 summary: null, // `<table>` 2954 text: null, // `<body>`. Use CSS `color` instead 2955 topMargin: number, // `<body>` 2956 valueType: null, // `<param>` 2957 version: null, // `<html>`. Use a doctype. 2958 vAlign: null, // Several. Use CSS `vertical-align` instead 2959 vLink: null, // `<body>`. Use CSS `a:visited {color}` instead 2960 vSpace: number, // `<img>` and `<object>` 2961 2962 // Non-standard Properties. 2963 allowTransparency: null, 2964 autoCorrect: null, 2965 autoSave: null, 2966 credentialless: types_boolean, 2967 disablePictureInPicture: types_boolean, 2968 disableRemotePlayback: types_boolean, 2969 exportParts: commaSeparated, 2970 part: spaceSeparated, 2971 prefix: null, 2972 property: null, 2973 results: number, 2974 security: null, 2975 unselectable: null 2976 }, 2977 space: 'html', 2978 transform: caseInsensitiveTransform 2979}) 2980 2981;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/property-information/lib/svg.js 2982 2983 2984 2985 2986const svg = create({ 2987 attributes: { 2988 accentHeight: 'accent-height', 2989 alignmentBaseline: 'alignment-baseline', 2990 arabicForm: 'arabic-form', 2991 baselineShift: 'baseline-shift', 2992 capHeight: 'cap-height', 2993 className: 'class', 2994 clipPath: 'clip-path', 2995 clipRule: 'clip-rule', 2996 colorInterpolation: 'color-interpolation', 2997 colorInterpolationFilters: 'color-interpolation-filters', 2998 colorProfile: 'color-profile', 2999 colorRendering: 'color-rendering', 3000 crossOrigin: 'crossorigin', 3001 dataType: 'datatype', 3002 dominantBaseline: 'dominant-baseline', 3003 enableBackground: 'enable-background', 3004 fillOpacity: 'fill-opacity', 3005 fillRule: 'fill-rule', 3006 floodColor: 'flood-color', 3007 floodOpacity: 'flood-opacity', 3008 fontFamily: 'font-family', 3009 fontSize: 'font-size', 3010 fontSizeAdjust: 'font-size-adjust', 3011 fontStretch: 'font-stretch', 3012 fontStyle: 'font-style', 3013 fontVariant: 'font-variant', 3014 fontWeight: 'font-weight', 3015 glyphName: 'glyph-name', 3016 glyphOrientationHorizontal: 'glyph-orientation-horizontal', 3017 glyphOrientationVertical: 'glyph-orientation-vertical', 3018 hrefLang: 'hreflang', 3019 horizAdvX: 'horiz-adv-x', 3020 horizOriginX: 'horiz-origin-x', 3021 horizOriginY: 'horiz-origin-y', 3022 imageRendering: 'image-rendering', 3023 letterSpacing: 'letter-spacing', 3024 lightingColor: 'lighting-color', 3025 markerEnd: 'marker-end', 3026 markerMid: 'marker-mid', 3027 markerStart: 'marker-start', 3028 maskType: 'mask-type', 3029 navDown: 'nav-down',
3030 navDownLeft: 'nav-down-left', 3031 navDownRight: 'nav-down-right', 3032 navLeft: 'nav-left', 3033 navNext: 'nav-next', 3034 navPrev: 'nav-prev', 3035 navRight: 'nav-right', 3036 navUp: 'nav-up', 3037 navUpLeft: 'nav-up-left', 3038 navUpRight: 'nav-up-right', 3039 onAbort: 'onabort', 3040 onActivate: 'onactivate', 3041 onAfterPrint: 'onafterprint', 3042 onBeforePrint: 'onbeforeprint', 3043 onBegin: 'onbegin', 3044 onCancel: 'oncancel', 3045 onCanPlay: 'oncanplay', 3046 onCanPlayThrough: 'oncanplaythrough', 3047 onChange: 'onchange', 3048 onClick: 'onclick', 3049 onClose: 'onclose', 3050 onCopy: 'oncopy', 3051 onCueChange: 'oncuechange', 3052 onCut: 'oncut', 3053 onDblClick: 'ondblclick', 3054 onDrag: 'ondrag', 3055 onDragEnd: 'ondragend', 3056 onDragEnter: 'ondragenter', 3057 onDragExit: 'ondragexit', 3058 onDragLeave: 'ondragleave', 3059 onDragOver: 'ondragover', 3060 onDragStart: 'ondragstart', 3061 onDrop: 'ondrop', 3062 onDurationChange: 'ondurationchange', 3063 onEmptied: 'onemptied', 3064 onEnd: 'onend', 3065 onEnded: 'onended', 3066 onError: 'onerror', 3067 onFocus: 'onfocus', 3068 onFocusIn: 'onfocusin', 3069 onFocusOut: 'onfocusout', 3070 onHashChange: 'onhashchange', 3071 onInput: 'oninput', 3072 onInvalid: 'oninvalid', 3073 onKeyDown: 'onkeydown', 3074 onKeyPress: 'onkeypress', 3075 onKeyUp: 'onkeyup', 3076 onLoad: 'onload', 3077 onLoadedData: 'onloadeddata', 3078 onLoadedMetadata: 'onloadedmetadata', 3079 onLoadStart: 'onloadstart', 3080 onMessage: 'onmessage', 3081 onMouseDown: 'onmousedown', 3082 onMouseEnter: 'onmouseenter', 3083 onMouseLeave: 'onmouseleave', 3084 onMouseMove: 'onmousemove', 3085 onMouseOut: 'onmouseout', 3086 onMouseOver: 'onmouseover', 3087 onMouseUp: 'onmouseup', 3088 onMouseWheel: 'onmousewheel', 3089 onOffline: 'onoffline', 3090 onOnline: 'ononline', 3091 onPageHide: 'onpagehide', 3092 onPageShow: 'onpageshow', 3093 onPaste: 'onpaste', 3094 onPause: 'onpause', 3095 onPlay: 'onplay', 3096 onPlaying: 'onplaying', 3097 onPopState: 'onpopstate', 3098 onProgress: 'onprogress', 3099 onRateChange: 'onratechange', 3100 onRepeat: 'onrepeat', 3101 onReset: 'onreset', 3102 onResize: 'onresize', 3103 onScroll: 'onscroll', 3104 onSeeked: 'onseeked', 3105 onSeeking: 'onseeking', 3106 onSelect: 'onselect', 3107 onShow: 'onshow', 3108 onStalled: 'onstalled', 3109 onStorage: 'onstorage', 3110 onSubmit: 'onsubmit', 3111 onSuspend: 'onsuspend', 3112 onTimeUpdate: 'ontimeupdate', 3113 onToggle: 'ontoggle', 3114 onUnload: 'onunload', 3115 onVolumeChange: 'onvolumechange', 3116 onWaiting: 'onwaiting', 3117 onZoom: 'onzoom', 3118 overlinePosition: 'overline-position', 3119 overlineThickness: 'overline-thickness', 3120 paintOrder: 'paint-order', 3121 panose1: 'panose-1', 3122 pointerEvents: 'pointer-events', 3123 referrerPolicy: 'referrerpolicy', 3124 renderingIntent: 'rendering-intent', 3125 shapeRendering: 'shape-rendering', 3126 stopColor: 'stop-color', 3127 stopOpacity: 'stop-opacity', 3128 strikethroughPosition: 'strikethrough-position', 3129 strikethroughThickness: 'strikethrough-thickness', 3130 strokeDashArray: 'stroke-dasharray', 3131 strokeDashOffset: 'stroke-dashoffset', 3132 strokeLineCap: 'stroke-linecap', 3133 strokeLineJoin: 'stroke-linejoin', 3134 strokeMiterLimit: 'stroke-miterlimit', 3135 strokeOpacity: 'stroke-opacity', 3136 strokeWidth: 'stroke-width', 3137 tabIndex: 'tabindex', 3138 textAnchor: 'text-anchor', 3139 textDecoration: 'text-decoration', 3140 textRendering: 'text-rendering', 3141 transformOrigin: 'transform-origin', 3142 typeOf: 'typeof', 3143 underlinePosition: 'underline-position', 3144 underlineThickness: 'underline-thickness', 3145 unicodeBidi: 'unicode-bidi', 3146 unicodeRange: 'unicode-range', 3147 unitsPerEm: 'units-per-em', 3148 vAlphabetic: 'v-alphabetic', 3149 vHanging: 'v-hanging', 3150 vIdeographic: 'v-ideographic', 3151 vMathematical: 'v-mathematical', 3152 vectorEffect: 'vector-effect', 3153 vertAdvY: 'vert-adv-y', 3154 vertOriginX: 'vert-origin-x', 3155 vertOriginY: 'vert-origin-y', 3156 wordSpacing: 'word-spacing', 3157 writingMode: 'writing-mode', 3158 xHeight: 'x-height', 3159 // These were camelcased in Tiny. Now lowercased in SVG 2 3160 playbackOrder: 'playbackorder', 3161 timelineBegin: 'timelinebegin' 3162 }, 3163 properties: { 3164 about: commaOrSpaceSeparated,
3165 accentHeight: number, 3166 accumulate: null, 3167 additive: null, 3168 alignmentBaseline: null, 3169 alphabetic: number, 3170 amplitude: number, 3171 arabicForm: null, 3172 ascent: number, 3173 attributeName: null, 3174 attributeType: null, 3175 azimuth: number, 3176 bandwidth: null, 3177 baselineShift: null, 3178 baseFrequency: null, 3179 baseProfile: null, 3180 bbox: null, 3181 begin: null, 3182 bias: number, 3183 by: null, 3184 calcMode: null, 3185 capHeight: number, 3186 className: spaceSeparated, 3187 clip: null, 3188 clipPath: null, 3189 clipPathUnits: null, 3190 clipRule: null, 3191 color: null, 3192 colorInterpolation: null, 3193 colorInterpolationFilters: null, 3194 colorProfile: null, 3195 colorRendering: null, 3196 content: null, 3197 contentScriptType: null, 3198 contentStyleType: null, 3199 crossOrigin: null, 3200 cursor: null, 3201 cx: null, 3202 cy: null, 3203 d: null, 3204 dataType: null, 3205 defaultAction: null, 3206 descent: number, 3207 diffuseConstant: number, 3208 direction: null, 3209 display: null, 3210 dur: null, 3211 divisor: number, 3212 dominantBaseline: null, 3213 download: types_boolean, 3214 dx: null, 3215 dy: null, 3216 edgeMode: null, 3217 editable: null, 3218 elevation: number, 3219 enableBackground: null, 3220 end: null, 3221 event: null, 3222 exponent: number, 3223 externalResourcesRequired: null, 3224 fill: null, 3225 fillOpacity: number, 3226 fillRule: null, 3227 filter: null, 3228 filterRes: null, 3229 filterUnits: null, 3230 floodColor: null, 3231 floodOpacity: null, 3232 focusable: null, 3233 focusHighlight: null, 3234 fontFamily: null, 3235 fontSize: null, 3236 fontSizeAdjust: null, 3237 fontStretch: null, 3238 fontStyle: null, 3239 fontVariant: null, 3240 fontWeight: null, 3241 format: null, 3242 fr: null, 3243 from: null, 3244 fx: null, 3245 fy: null, 3246 g1: commaSeparated, 3247 g2: commaSeparated, 3248 glyphName: commaSeparated, 3249 glyphOrientationHorizontal: null, 3250 glyphOrientationVertical: null, 3251 glyphRef: null, 3252 gradientTransform: null, 3253 gradientUnits: null, 3254 handler: null, 3255 hanging: number, 3256 hatchContentUnits: null, 3257 hatchUnits: null, 3258 height: null, 3259 href: null, 3260 hrefLang: null, 3261 horizAdvX: number, 3262 horizOriginX: number, 3263 horizOriginY: number, 3264 id: null, 3265 ideographic: number, 3266 imageRendering: null, 3267 initialVisibility: null, 3268 in: null, 3269 in2: null, 3270 intercept: number, 3271 k: number, 3272 k1: number, 3273 k2: number, 3274 k3: number, 3275 k4: number, 3276 kernelMatrix: commaOrSpaceSeparated, 3277 kernelUnitLength: null, 3278 keyPoints: null, // SEMI_COLON_SEPARATED 3279 keySplines: null, // SEMI_COLON_SEPARATED 3280 keyTimes: null, // SEMI_COLON_SEPARATED 3281 kerning: null, 3282 lang: null, 3283 lengthAdjust: null, 3284 letterSpacing: null, 3285 lightingColor: null, 3286 limitingConeAngle: number, 3287 local: null, 3288 markerEnd: null, 3289 markerMid: null, 3290 markerStart: null, 3291 markerHeight: null, 3292 markerUnits: null, 3293 markerWidth: null, 3294 mask: null, 3295 maskContentUnits: null, 3296 maskType: null, 3297 maskUnits: null, 3298 mathematical: null, 3299 max: null, 3300 media: null, 3301 mediaCharacterEncoding: null, 3302 mediaContentEncodings: null, 3303 mediaSize: number, 3304 mediaTime: null, 3305 method: null, 3306 min: null, 3307 mode: null, 3308 name: null, 3309 navDown: null, 3310 navDownLeft: null, 3311 navDownRight: null, 3312 navLeft: null, 3313 navNext: null, 3314 navPrev: null, 3315 navRight: null, 3316 navUp: null, 3317 navUpLeft: null, 3318 navUpRight: null, 3319 numOctaves: null, 3320 observer: null, 3321 offset: null, 3322 onAbort: null, 3323 onActivate: null, 3324 onAfterPrint: null, 3325 onBeforePrint: null, 3326 onBegin: null, 3327 onCancel: null, 3328 onCanPlay: null, 3329 onCanPlayThrough: null, 3330 onChange: null, 3331 onClick: null, 3332 onClose: null, 3333 onCopy: null, 3334 onCueChange: null, 3335 onCut: null, 3336 onDblClick: null, 3337 onDrag: null, 3338 onDragEnd: null, 3339 onDragEnter: null, 3340 onDragExit: null, 3341 onDragLeave: null, 3342 onDragOver: null, 3343 onDragStart: null, 3344 onDrop: null, 3345 onDurationChange: null, 3346 onEmptied: null, 3347 onEnd: null, 3348 onEnded: null, 3349 onError: null, 3350 onFocus: null, 3351 onFocusIn: null, 3352 onFocusOut: null, 3353 onHashChange: null, 3354 onInput: null, 3355 onInvalid: null, 3356 onKeyDown: null, 3357 onKeyPress: null, 3358 onKeyUp: null, 3359 onLoad: null, 3360 onLoadedData: null, 3361 onLoadedMetadata: null, 3362 onLoadStart: null, 3363 onMessage: null, 3364 onMouseDown: null, 3365 onMouseEnter: null, 3366 onMouseLeave: null, 3367 onMouseMove: null, 3368 onMouseOut: null, 3369 onMouseOver: null, 3370 onMouseUp: null, 3371 onMouseWheel: null, 3372 onOffline: null, 3373 onOnline: null, 3374 onPageHide: null, 3375 onPageShow: null, 3376 onPaste: null, 3377 onPause: null, 3378 onPlay: null, 3379 onPlaying: null, 3380 onPopState: null, 3381 onProgress: null, 3382 onRateChange: null, 3383 onRepeat: null, 3384 onReset: null, 3385 onResize: null, 3386 onScroll: null, 3387 onSeeked: null, 3388 onSeeking: null, 3389 onSelect: null, 3390 onShow: null, 3391 onStalled: null, 3392 onStorage: null, 3393 onSubmit: null, 3394 onSuspend: null, 3395 onTimeUpdate: null, 3396 onToggle: null, 3397 onUnload: null, 3398 onVolumeChange: null, 3399 onWaiting: null, 3400 onZoom: null, 3401 opacity: null, 3402 operator: null, 3403 order: null, 3404 orient: null, 3405 orientation: null, 3406 origin: null, 3407 overflow: null, 3408 overlay: null, 3409 overlinePosition: number, 3410 overlineThickness: number, 3411 paintOrder: null, 3412 panose1: null, 3413 path: null, 3414 pathLength: number, 3415 patternContentUnits: null, 3416 patternTransform: null, 3417 patternUnits: null, 3418 phase: null, 3419 ping: spaceSeparated,
3420 pitch: null, 3421 playbackOrder: null, 3422 pointerEvents: null, 3423 points: null, 3424 pointsAtX: number, 3425 pointsAtY: number, 3426 pointsAtZ: number, 3427 preserveAlpha: null, 3428 preserveAspectRatio: null, 3429 primitiveUnits: null, 3430 propagate: null, 3431 property: commaOrSpaceSeparated, 3432 r: null, 3433 radius: null, 3434 referrerPolicy: null, 3435 refX: null, 3436 refY: null, 3437 rel: commaOrSpaceSeparated, 3438 rev: commaOrSpaceSeparated, 3439 renderingIntent: null, 3440 repeatCount: null, 3441 repeatDur: null, 3442 requiredExtensions: commaOrSpaceSeparated, 3443 requiredFeatures: commaOrSpaceSeparated, 3444 requiredFonts: commaOrSpaceSeparated, 3445 requiredFormats: commaOrSpaceSeparated, 3446 resource: null, 3447 restart: null, 3448 result: null, 3449 rotate: null, 3450 rx: null, 3451 ry: null, 3452 scale: null, 3453 seed: null, 3454 shapeRendering: null, 3455 side: null, 3456 slope: null, 3457 snapshotTime: null, 3458 specularConstant: number, 3459 specularExponent: number, 3460 spreadMethod: null, 3461 spacing: null, 3462 startOffset: null, 3463 stdDeviation: null, 3464 stemh: null, 3465 stemv: null, 3466 stitchTiles: null, 3467 stopColor: null, 3468 stopOpacity: null, 3469 strikethroughPosition: number, 3470 strikethroughThickness: number, 3471 string: null, 3472 stroke: null, 3473 strokeDashArray: commaOrSpaceSeparated, 3474 strokeDashOffset: null, 3475 strokeLineCap: null, 3476 strokeLineJoin: null, 3477 strokeMiterLimit: number, 3478 strokeOpacity: number, 3479 strokeWidth: null, 3480 style: null, 3481 surfaceScale: number, 3482 syncBehavior: null, 3483 syncBehaviorDefault: null, 3484 syncMaster: null, 3485 syncTolerance: null, 3486 syncToleranceDefault: null, 3487 systemLanguage: commaOrSpaceSeparated, 3488 tabIndex: number, 3489 tableValues: null, 3490 target: null, 3491 targetX: number, 3492 targetY: number, 3493 textAnchor: null, 3494 textDecoration: null, 3495 textRendering: null, 3496 textLength: null, 3497 timelineBegin: null, 3498 title: null, 3499 transformBehavior: null, 3500 type: null, 3501 typeOf: commaOrSpaceSeparated, 3502 to: null, 3503 transform: null, 3504 transformOrigin: null, 3505 u1: null, 3506 u2: null, 3507 underlinePosition: number, 3508 underlineThickness: number, 3509 unicode: null, 3510 unicodeBidi: null, 3511 unicodeRange: null, 3512 unitsPerEm: number, 3513 values: null, 3514 vAlphabetic: number, 3515 vMathematical: number, 3516 vectorEffect: null, 3517 vHanging: number, 3518 vIdeographic: number, 3519 version: null, 3520 vertAdvY: number, 3521 vertOriginX: number, 3522 vertOriginY: number, 3523 viewBox: null, 3524 viewTarget: null, 3525 visibility: null, 3526 width: null, 3527 widths: null, 3528 wordSpacing: null, 3529 writingMode: null, 3530 x: null, 3531 x1: null, 3532 x2: null, 3533 xChannelSelector: null, 3534 xHeight: number, 3535 y: null, 3536 y1: null, 3537 y2: null, 3538 yChannelSelector: null, 3539 z: null, 3540 zoomAndPan: null 3541 }, 3542 space: 'svg', 3543 transform: caseSensitiveTransform 3544}) 3545 3546;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/property-information/lib/xlink.js 3547 3548 3549const xlink = create({ 3550 properties: { 3551 xLinkActuate: null, 3552 xLinkArcRole: null, 3553 xLinkHref: null, 3554 xLinkRole: null, 3555 xLinkShow: null, 3556 xLinkTitle: null, 3557 xLinkType: null 3558 }, 3559 space: 'xlink', 3560 transform(_, property) { 3561 return 'xlink:' + property.slice(5).toLowerCase() 3562 } 3563}) 3564 3565;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/property-information/lib/xmlns.js 3566 3567 3568 3569const xmlns = create({ 3570 attributes: {xmlnsxlink: 'xmlns:xlink'}, 3571 properties: {xmlnsXLink: null, xmlns: null}, 3572 space: 'xmlns', 3573 transform: caseInsensitiveTransform 3574}) 3575 3576;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/property-information/lib/xml.js 3577 3578 3579const xml = create({ 3580 properties: {xmlBase: null, xmlLang: null, xmlSpace: null}, 3581 space: 'xml', 3582 transform(_, property) { 3583 return 'xml:' + property.slice(3).toLowerCase() 3584 } 3585}) 3586 3587;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/property-information/lib/hast-to-react.js 3588/** 3589 * Special cases for React (`Record<string, string>`). 3590 * 3591 * `hast` is close to `React` but differs in a couple of cases. 3592 * To get a React property from a hast property, 3593 * check if it is in `hastToReact`. 3594 * If it is, use the corresponding value; 3595 * otherwise, use the hast property. 3596 * 3597 * @type {Record<string, string>} 3598 */ 3599const hastToReact = { 3600 classId: 'classID', 3601 dataType: 'datatype', 3602 itemId: 'itemID', 3603 strokeDashArray: 'strokeDasharray', 3604 strokeDashOffset: 'strokeDashoffset', 3605 strokeLineCap: 'strokeLinecap', 3606 strokeLineJoin: 'strokeLinejoin', 3607 strokeMiterLimit: 'strokeMiterlimit', 3608 typeOf: 'typeof', 3609 xLinkActuate: 'xlinkActuate', 3610 xLinkArcRole: 'xlinkArcrole', 3611 xLinkHref: 'xlinkHref', 3612 xLinkRole: 'xlinkRole', 3613 xLinkShow: 'xlinkShow', 3614 xLinkTitle: 'xlinkTitle', 3615 xLinkType: 'xlinkType', 3616 xmlnsXLink: 'xmlnsXlink' 3617} 3618 3619;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/property-information/lib/find.js 3620/** 3621 * @import {Schema} from 'property-information' 3622 */ 3623 3624 3625 3626 3627 3628const cap = /[A-Z]/g 3629const dash = /-[a-z]/g 3630const valid = /^data[-\w.:]+$/i 3631 3632/** 3633 * Look up info on a property. 3634 * 3635 * In most cases the given `schema` contains info on the property. 3636 * All standard, 3637 * most legacy, 3638 * and some non-standard properties are supported. 3639 * For these cases, 3640 * the returned `Info` has hints about the value of the property. 3641 * 3642 * `name` can also be a valid data attribute or property, 3643 * in which case an `Info` object with the correctly cased `attribute` and 3644 * `property` is returned. 3645 * 3646 * `name` can be an unknown attribute, 3647 * in which case an `Info` object with `attribute` and `property` set to the 3648 * given name is returned. 3649 * It is not recommended to provide unsupported legacy or recently specced 3650 * properties. 3651 * 3652 * 3653 * @param {Schema} schema 3654 * Schema; 3655 * either the `html` or `svg` export. 3656 * @param {string} value 3657 * An attribute-like or property-like name;
3658 * it will be passed through `normalize` to hopefully find the correct info. 3659 * @returns {Info} 3660 * Info. 3661 */ 3662function find(schema, value) { 3663 const normal = normalize(value) 3664 let property = value 3665 let Type = Info 3666 3667 if (normal in schema.normal) { 3668 return schema.property[schema.normal[normal]] 3669 } 3670 3671 if (normal.length > 4 && normal.slice(0, 4) === 'data' && valid.test(value)) { 3672 // Attribute or property. 3673 if (value.charAt(4) === '-') { 3674 // Turn it into a property. 3675 const rest = value.slice(5).replace(dash, camelcase) 3676 property = 'data' + rest.charAt(0).toUpperCase() + rest.slice(1) 3677 } else { 3678 // Turn it into an attribute. 3679 const rest = value.slice(4) 3680 3681 if (!dash.test(rest)) { 3682 let dashes = rest.replace(cap, kebab) 3683 3684 if (dashes.charAt(0) !== '-') { 3685 dashes = '-' + dashes 3686 } 3687 3688 value = 'data' + dashes 3689 } 3690 } 3691 3692 Type = DefinedInfo 3693 } 3694 3695 return new Type(property, value) 3696} 3697 3698/** 3699 * @param {string} $0 3700 * Value. 3701 * @returns {string} 3702 * Kebab. 3703 */ 3704function kebab($0) { 3705 return '-' + $0.toLowerCase() 3706} 3707 3708/** 3709 * @param {string} $0 3710 * Value. 3711 * @returns {string} 3712 * Camel. 3713 */ 3714function camelcase($0) { 3715 return $0.charAt(1).toUpperCase() 3716} 3717 3718;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/property-information/index.js 3719// Note: types exposed from `index.d.ts`. 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730const property_information_html = merge([aria, html, xlink, xmlns, xml], 'html') 3731 3732 3733 3734 3735const property_information_svg = merge([aria, svg, xlink, xmlns, xml], 'svg') 3736 3737;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/space-separated-tokens/index.js 3738/** 3739 * Parse space-separated tokens to an array of strings. 3740 * 3741 * @param {string} value 3742 * Space-separated tokens. 3743 * @returns {Array<string>} 3744 * List of tokens. 3745 */ 3746function space_separated_tokens_parse(value) { 3747 const input = String(value || '').trim() 3748 return input ? input.split(/[ \t\n\r\f]+/g) : [] 3749} 3750 3751/** 3752 * Serialize an array of strings as space separated-tokens. 3753 * 3754 * @param {Array<string|number>} values 3755 * List of tokens. 3756 * @returns {string} 3757 * Space-separated tokens. 3758 */ 3759function space_separated_tokens_stringify(values) { 3760 return values.join(' ').trim() 3761} 3762 3763// EXTERNAL MODULE: ./node_modules/.pnpm/[email protected]/node_modules/style-to-js/cjs/index.js 3764var cjs = __webpack_require__(69939); 3765;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/unist-util-position/lib/index.js 3766/** 3767 * @typedef {import('unist').Node} Node 3768 * @typedef {import('unist').Point} Point 3769 * @typedef {import('unist').Position} Position 3770 */ 3771 3772/** 3773 * @typedef NodeLike 3774 * @property {string} type 3775 * @property {PositionLike | null | undefined} [position] 3776 * 3777 * @typedef PositionLike 3778 * @property {PointLike | null | undefined} [start] 3779 * @property {PointLike | null | undefined} [end] 3780 * 3781 * @typedef PointLike 3782 * @property {number | null | undefined} [line] 3783 * @property {number | null | undefined} [column] 3784 * @property {number | null | undefined} [offset] 3785 */ 3786 3787/** 3788 * Get the ending point of `node`. 3789 * 3790 * @param node 3791 * Node. 3792 * @returns 3793 * Point. 3794 */ 3795const pointEnd = point('end') 3796 3797/** 3798 * Get the starting point of `node`. 3799 * 3800 * @param node 3801 * Node. 3802 * @returns 3803 * Point. 3804 */ 3805const pointStart = point('start') 3806 3807/** 3808 * Get the positional info of `node`. 3809 * 3810 * @param {'end' | 'start'} type 3811 * Side. 3812 * @returns 3813 * Getter. 3814 */ 3815function point(type) { 3816 return point 3817 3818 /** 3819 * Get the point info of `node` at a bound side. 3820 * 3821 * @param {Node | NodeLike | null | undefined} [node] 3822 * @returns {Point | undefined} 3823 */ 3824 function point(node) { 3825 const point = (node && node.position && node.position[type]) || {} 3826 3827 if ( 3828 typeof point.line === 'number' && 3829 point.line > 0 && 3830 typeof point.column === 'number' && 3831 point.column > 0 3832 ) { 3833 return { 3834 line: point.line, 3835 column: point.column, 3836 offset: 3837 typeof point.offset === 'number' && point.offset > -1 3838 ? point.offset 3839 : undefined 3840 } 3841 } 3842 } 3843} 3844 3845/** 3846 * Get the positional info of `node`. 3847 * 3848 * @param {Node | NodeLike | null | undefined} [node] 3849 * Node. 3850 * @returns {Position | undefined} 3851 * Position. 3852 */ 3853function position(node) { 3854 const start = pointStart(node) 3855 const end = pointEnd(node) 3856 3857 if (start && end) { 3858 return {start, end} 3859 } 3860} 3861 3862;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/unist-util-position/index.js 3863 3864 3865;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/unist-util-stringify-position/lib/index.js 3866/** 3867 * @typedef {import('unist').Node} Node 3868 * @typedef {import('unist').Point} Point 3869 * @typedef {import('unist').Position} Position 3870 */ 3871 3872/** 3873 * @typedef NodeLike 3874 * @property {string} type 3875 * @property {PositionLike | null | undefined} [position] 3876 * 3877 * @typedef PointLike 3878 * @property {number | null | undefined} [line] 3879 * @property {number | null | undefined} [column] 3880 * @property {number | null | undefined} [offset] 3881 * 3882 * @typedef PositionLike 3883 * @property {PointLike | null | undefined} [start] 3884 * @property {PointLike | null | undefined} [end] 3885 */ 3886
3887/** 3888 * Serialize the positional info of a point, position (start and end points), 3889 * or node. 3890 * 3891 * @param {Node | NodeLike | Point | PointLike | Position | PositionLike | null | undefined} [value] 3892 * Node, position, or point. 3893 * @returns {string} 3894 * Pretty printed positional info of a node (`string`). 3895 * 3896 * In the format of a range `ls:cs-le:ce` (when given `node` or `position`) 3897 * or a point `l:c` (when given `point`), where `l` stands for line, `c` for 3898 * column, `s` for `start`, and `e` for end. 3899 * An empty string (`''`) is returned if the given value is neither `node`, 3900 * `position`, nor `point`. 3901 */ 3902function stringifyPosition(value) { 3903 // Nothing. 3904 if (!value || typeof value !== 'object') { 3905 return '' 3906 } 3907 3908 // Node. 3909 if ('position' in value || 'type' in value) { 3910 return lib_position(value.position) 3911 } 3912 3913 // Position. 3914 if ('start' in value || 'end' in value) { 3915 return lib_position(value) 3916 } 3917 3918 // Point. 3919 if ('line' in value || 'column' in value) { 3920 return lib_point(value) 3921 } 3922 3923 // ? 3924 return '' 3925} 3926 3927/** 3928 * @param {Point | PointLike | null | undefined} point 3929 * @returns {string} 3930 */ 3931function lib_point(point) { 3932 return index(point && point.line) + ':' + index(point && point.column) 3933} 3934 3935/** 3936 * @param {Position | PositionLike | null | undefined} pos 3937 * @returns {string} 3938 */ 3939function lib_position(pos) { 3940 return lib_point(pos && pos.start) + '-' + lib_point(pos && pos.end) 3941} 3942 3943/** 3944 * @param {number | null | undefined} value 3945 * @returns {number} 3946 */ 3947function index(value) { 3948 return value && typeof value === 'number' ? value : 1 3949} 3950 3951;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/unist-util-stringify-position/index.js 3952 3953 3954;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/vfile-message/lib/index.js 3955/** 3956 * @import {Node, Point, Position} from 'unist' 3957 */ 3958 3959/** 3960 * @typedef {object & {type: string, position?: Position | undefined}} NodeLike 3961 * 3962 * @typedef Options 3963 * Configuration. 3964 * @property {Array<Node> | null | undefined} [ancestors] 3965 * Stack of (inclusive) ancestor nodes surrounding the message (optional). 3966 * @property {Error | null | undefined} [cause] 3967 * Original error cause of the message (optional). 3968 * @property {Point | Position | null | undefined} [place] 3969 * Place of message (optional). 3970 * @property {string | null | undefined} [ruleId] 3971 * Category of message (optional, example: `'my-rule'`). 3972 * @property {string | null | undefined} [source] 3973 * Namespace of who sent the message (optional, example: `'my-package'`). 3974 */ 3975 3976 3977 3978/** 3979 * Message. 3980 */ 3981class VFileMessage extends Error { 3982 /** 3983 * Create a message for `reason`. 3984 * 3985 * > 𪦠**Note**: also has obsolete signatures. 3986 * 3987 * @overload 3988 * @param {string} reason 3989 * @param {Options | null | undefined} [options] 3990 * @returns 3991 * 3992 * @overload 3993 * @param {string} reason 3994 * @param {Node | NodeLike | null | undefined} parent 3995 * @param {string | null | undefined} [origin] 3996 * @returns 3997 * 3998 * @overload 3999 * @param {string} reason 4000 * @param {Point | Position | null | undefined} place 4001 * @param {string | null | undefined} [origin] 4002 * @returns 4003 * 4004 * @overload 4005 * @param {string} reason 4006 * @param {string | null | undefined} [origin] 4007 * @returns 4008 * 4009 * @overload 4010 * @param {Error | VFileMessage} cause 4011 * @param {Node | NodeLike | null | undefined} parent 4012 * @param {string | null | undefined} [origin] 4013 * @returns 4014 * 4015 * @overload 4016 * @param {Error | VFileMessage} cause 4017 * @param {Point | Position | null | undefined} place 4018 * @param {string | null | undefined} [origin] 4019 * @returns 4020 * 4021 * @overload 4022 * @param {Error | VFileMessage} cause 4023 * @param {string | null | undefined} [origin] 4024 * @returns 4025 * 4026 * @param {Error | VFileMessage | string} causeOrReason 4027 * Reason for message, should use markdown. 4028 * @param {Node | NodeLike | Options | Point | Position | string | null | undefined} [optionsOrParentOrPlace] 4029 * Configuration (optional). 4030 * @param {string | null | undefined} [origin] 4031 * Place in code where the message originates (example: 4032 * `'my-package:my-rule'` or `'my-rule'`). 4033 * @returns 4034 * Instance of `VFileMessage`. 4035 */ 4036 // eslint-disable-next-line complexity 4037 constructor(causeOrReason, optionsOrParentOrPlace, origin) { 4038 super() 4039 4040 if (typeof optionsOrParentOrPlace === 'string') { 4041 origin = optionsOrParentOrPlace 4042 optionsOrParentOrPlace = undefined 4043 } 4044 4045 /** @type {string} */ 4046 let reason = '' 4047 /** @type {Options} */ 4048 let options = {} 4049 let legacyCause = false 4050 4051 if (optionsOrParentOrPlace) { 4052 // Point. 4053 if ( 4054 'line' in optionsOrParentOrPlace &&
4055 'column' in optionsOrParentOrPlace 4056 ) { 4057 options = {place: optionsOrParentOrPlace} 4058 } 4059 // Position. 4060 else if ( 4061 'start' in optionsOrParentOrPlace && 4062 'end' in optionsOrParentOrPlace 4063 ) { 4064 options = {place: optionsOrParentOrPlace} 4065 } 4066 // Node. 4067 else if ('type' in optionsOrParentOrPlace) { 4068 options = { 4069 ancestors: [optionsOrParentOrPlace], 4070 place: optionsOrParentOrPlace.position 4071 } 4072 } 4073 // Options. 4074 else { 4075 options = {...optionsOrParentOrPlace} 4076 } 4077 } 4078 4079 if (typeof causeOrReason === 'string') { 4080 reason = causeOrReason 4081 } 4082 // Error. 4083 else if (!options.cause && causeOrReason) { 4084 legacyCause = true 4085 reason = causeOrReason.message 4086 options.cause = causeOrReason 4087 } 4088 4089 if (!options.ruleId && !options.source && typeof origin === 'string') { 4090 const index = origin.indexOf(':') 4091 4092 if (index === -1) { 4093 options.ruleId = origin 4094 } else { 4095 options.source = origin.slice(0, index) 4096 options.ruleId = origin.slice(index + 1) 4097 } 4098 } 4099 4100 if (!options.place && options.ancestors && options.ancestors) { 4101 const parent = options.ancestors[options.ancestors.length - 1] 4102 4103 if (parent) { 4104 options.place = parent.position 4105 } 4106 } 4107 4108 const start = 4109 options.place && 'start' in options.place 4110 ? options.place.start 4111 : options.place 4112 4113 /** 4114 * Stack of ancestor nodes surrounding the message. 4115 * 4116 * @type {Array<Node> | undefined} 4117 */ 4118 this.ancestors = options.ancestors || undefined 4119 4120 /** 4121 * Original error cause of the message. 4122 * 4123 * @type {Error | undefined} 4124 */ 4125 this.cause = options.cause || undefined 4126 4127 /** 4128 * Starting column of message. 4129 * 4130 * @type {number | undefined} 4131 */ 4132 this.column = start ? start.column : undefined 4133 4134 /** 4135 * State of problem. 4136 * 4137 * * `true` â error, file not usable 4138 * * `false` â warning, change may be needed 4139 * * `undefined` â change likely not needed 4140 * 4141 * @type {boolean | null | undefined} 4142 */ 4143 this.fatal = undefined 4144 4145 /** 4146 * Path of a file (used throughout the `VFile` ecosystem). 4147 * 4148 * @type {string | undefined} 4149 */ 4150 this.file = '' 4151 4152 // Field from `Error`. 4153 /** 4154 * Reason for message. 4155 * 4156 * @type {string} 4157 */ 4158 this.message = reason 4159 4160 /** 4161 * Starting line of error. 4162 * 4163 * @type {number | undefined} 4164 */ 4165 this.line = start ? start.line : undefined 4166 4167 // Field from `Error`. 4168 /** 4169 * Serialized positional info of message. 4170 * 4171 * On normal errors, this would be something like `ParseError`, buit in 4172 * `VFile` messages we use this space to show where an error happened. 4173 */ 4174 this.name = stringifyPosition(options.place) || '1:1' 4175 4176 /** 4177 * Place of message. 4178 * 4179 * @type {Point | Position | undefined} 4180 */ 4181 this.place = options.place || undefined 4182 4183 /** 4184 * Reason for message, should use markdown. 4185 * 4186 * @type {string} 4187 */ 4188 this.reason = this.message 4189 4190 /** 4191 * Category of message (example: `'my-rule'`). 4192 * 4193 * @type {string | undefined} 4194 */ 4195 this.ruleId = options.ruleId || undefined 4196 4197 /** 4198 * Namespace of message (example: `'my-package'`). 4199 * 4200 * @type {string | undefined} 4201 */ 4202 this.source = options.source || undefined 4203 4204 // Field from `Error`. 4205 /** 4206 * Stack of message. 4207 * 4208 * This is used by normal errors to show where something happened in 4209 * programming code, irrelevant for `VFile` messages, 4210 * 4211 * @type {string} 4212 */ 4213 this.stack = 4214 legacyCause && options.cause && typeof options.cause.stack === 'string' 4215 ? options.cause.stack 4216 : '' 4217 4218 // The following fields are âwell knownâ. 4219 // Not standard. 4220 // Feel free to add other non-standard fields to your messages. 4221 4222 /** 4223 * Specify the source value thatâs being reported, which is deemed 4224 * incorrect. 4225 * 4226 * @type {string | undefined} 4227 */ 4228 this.actual = undefined 4229 4230 /** 4231 * Suggest acceptable values that can be used instead of `actual`. 4232 * 4233 * @type {Array<string> | undefined} 4234 */ 4235 this.expected = undefined 4236 4237 /** 4238 * Long form description of the message (you should use markdown). 4239 * 4240 * @type {string | undefined} 4241 */ 4242 this.note = undefined 4243 4244 /** 4245 * Link to docs for the message. 4246 * 4247 * > ð **Note**: this must be an absolute URL that can be passed as `x` 4248 * > to `new URL(x)`. 4249 * 4250 * @type {string | undefined} 4251 */ 4252 this.url = undefined 4253 } 4254} 4255 4256VFileMessage.prototype.file = '' 4257VFileMessage.prototype.name = '' 4258VFileMessage.prototype.reason = '' 4259VFileMessage.prototype.message = '' 4260VFileMessage.prototype.stack = '' 4261VFileMessage.prototype.column = undefined 4262VFileMessage.prototype.line = undefined 4263VFileMessage.prototype.ancestors = undefined 4264VFileMessage.prototype.cause = undefined 4265VFileMessage.prototype.fatal = undefined 4266VFileMessage.prototype.place = undefined 4267VFileMessage.prototype.ruleId = undefined 4268VFileMessage.prototype.source = undefined 4269 4270;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/vfile-message/index.js 4271/** 4272 * @typedef {import('./lib/index.js').Options} Options 4273 */ 4274 4275 4276 4277;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/hast-util-to-jsx-runtime/lib/index.js 4278/** 4279 * @import {Identifier, Literal, MemberExpression} from 'estree' 4280 * @import {Jsx, JsxDev, Options, Props} from 'hast-util-to-jsx-runtime' 4281 * @import {Element, Nodes, Parents, Root, Text} from 'hast'
4282 * @import {MdxFlowExpressionHast, MdxTextExpressionHast} from 'mdast-util-mdx-expression' 4283 * @import {MdxJsxFlowElementHast, MdxJsxTextElementHast} from 'mdast-util-mdx-jsx' 4284 * @import {MdxjsEsmHast} from 'mdast-util-mdxjs-esm' 4285 * @import {Position} from 'unist' 4286 * @import {Child, Create, Field, JsxElement, State, Style} from './types.js' 4287 */ 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299// To do: next major: `Object.hasOwn`. 4300const own = {}.hasOwnProperty 4301 4302/** @type {Map<string, number>} */ 4303const emptyMap = new Map() 4304 4305const lib_cap = /[A-Z]/g 4306 4307// `react-dom` triggers a warning for *any* white space in tables. 4308// To follow GFM, `mdast-util-to-hast` injects line endings between elements. 4309// Other tools might do so too, but they donât do here, so we remove all of 4310// that. 4311 4312// See: <https://github.com/facebook/react/pull/7081>. 4313// See: <https://github.com/facebook/react/pull/7515>. 4314// See: <https://github.com/remarkjs/remark-react/issues/64>. 4315// See: <https://github.com/rehypejs/rehype-react/pull/29>. 4316// See: <https://github.com/rehypejs/rehype-react/pull/32>. 4317// See: <https://github.com/rehypejs/rehype-react/pull/45>. 4318const tableElements = new Set(['table', 'tbody', 'thead', 'tfoot', 'tr']) 4319 4320const tableCellElement = new Set(['td', 'th']) 4321 4322const docs = 'https://github.com/syntax-tree/hast-util-to-jsx-runtime' 4323 4324/** 4325 * Transform a hast tree to preact, react, solid, svelte, vue, etc., 4326 * with an automatic JSX runtime. 4327 * 4328 * @param {Nodes} tree 4329 * Tree to transform. 4330 * @param {Options} options 4331 * Configuration (required). 4332 * @returns {JsxElement} 4333 * JSX element. 4334 */ 4335 4336function toJsxRuntime(tree, options) { 4337 if (!options || options.Fragment === undefined) { 4338 throw new TypeError('Expected `Fragment` in options') 4339 } 4340 4341 const filePath = options.filePath || undefined 4342 /** @type {Create} */ 4343 let create 4344 4345 if (options.development) { 4346 if (typeof options.jsxDEV !== 'function') { 4347 throw new TypeError( 4348 'Expected `jsxDEV` in options when `development: true`' 4349 ) 4350 } 4351 4352 create = developmentCreate(filePath, options.jsxDEV) 4353 } else { 4354 if (typeof options.jsx !== 'function') { 4355 throw new TypeError('Expected `jsx` in production options') 4356 } 4357 4358 if (typeof options.jsxs !== 'function') { 4359 throw new TypeError('Expected `jsxs` in production options') 4360 } 4361 4362 create = productionCreate(filePath, options.jsx, options.jsxs) 4363 } 4364 4365 /** @type {State} */ 4366 const state = { 4367 Fragment: options.Fragment, 4368 ancestors: [], 4369 components: options.components || {}, 4370 create, 4371 elementAttributeNameCase: options.elementAttributeNameCase || 'react', 4372 evaluater: options.createEvaluater ? options.createEvaluater() : undefined, 4373 filePath, 4374 ignoreInvalidStyle: options.ignoreInvalidStyle || false, 4375 passKeys: options.passKeys !== false, 4376 passNode: options.passNode || false, 4377 schema: options.space === 'svg' ? property_information_svg : property_information_html, 4378 stylePropertyNameCase: options.stylePropertyNameCase || 'dom', 4379 tableCellAlignToStyle: options.tableCellAlignToStyle !== false 4380 } 4381 4382 const result = one(state, tree, undefined) 4383 4384 // JSX element. 4385 if (result && typeof result !== 'string') { 4386 return result 4387 } 4388 4389 // Text node or something that turned into nothing. 4390 return state.create( 4391 tree, 4392 state.Fragment, 4393 {children: result || undefined}, 4394 undefined 4395 ) 4396} 4397 4398/** 4399 * Transform a node. 4400 * 4401 * @param {State} state 4402 * Info passed around. 4403 * @param {Nodes} node 4404 * Current node. 4405 * @param {string | undefined} key 4406 * Key. 4407 * @returns {Child | undefined} 4408 * Child, optional. 4409 */ 4410function one(state, node, key) { 4411 if (node.type === 'element') { 4412 return lib_element(state, node, key) 4413 } 4414 4415 if (node.type === 'mdxFlowExpression' || node.type === 'mdxTextExpression') { 4416 return mdxExpression(state, node) 4417 } 4418 4419 if (node.type === 'mdxJsxFlowElement' || node.type === 'mdxJsxTextElement') { 4420 return mdxJsxElement(state, node, key) 4421 } 4422 4423 if (node.type === 'mdxjsEsm') { 4424 return mdxEsm(state, node) 4425 } 4426 4427 if (node.type === 'root') { 4428 return root(state, node, key) 4429 } 4430 4431 if (node.type === 'text') { 4432 return lib_text(state, node) 4433 } 4434} 4435 4436/** 4437 * Handle element. 4438 * 4439 * @param {State} state 4440 * Info passed around. 4441 * @param {Element} node 4442 * Current node. 4443 * @param {string | undefined} key 4444 * Key. 4445 * @returns {Child | undefined} 4446 * Child, optional. 4447 */
4448function lib_element(state, node, key) { 4449 const parentSchema = state.schema 4450 let schema = parentSchema 4451 4452 if (node.tagName.toLowerCase() === 'svg' && parentSchema.space === 'html') { 4453 schema = property_information_svg 4454 state.schema = schema 4455 } 4456 4457 state.ancestors.push(node) 4458 4459 const type = findComponentFromName(state, node.tagName, false) 4460 const props = createElementProps(state, node) 4461 let children = createChildren(state, node) 4462 4463 if (tableElements.has(node.tagName)) { 4464 children = children.filter(function (child) { 4465 return typeof child === 'string' ? !whitespace(child) : true 4466 }) 4467 } 4468 4469 addNode(state, props, type, node) 4470 addChildren(props, children) 4471 4472 // Restore. 4473 state.ancestors.pop() 4474 state.schema = parentSchema 4475 4476 return state.create(node, type, props, key) 4477} 4478 4479/** 4480 * Handle MDX expression. 4481 * 4482 * @param {State} state 4483 * Info passed around. 4484 * @param {MdxFlowExpressionHast | MdxTextExpressionHast} node 4485 * Current node. 4486 * @returns {Child | undefined} 4487 * Child, optional. 4488 */ 4489function mdxExpression(state, node) { 4490 if (node.data && node.data.estree && state.evaluater) { 4491 const program = node.data.estree 4492 const expression = program.body[0] 4493 ok(expression.type === 'ExpressionStatement') 4494 4495 // Assume result is a child. 4496 return /** @type {Child | undefined} */ ( 4497 state.evaluater.evaluateExpression(expression.expression) 4498 ) 4499 } 4500 4501 crashEstree(state, node.position) 4502} 4503 4504/** 4505 * Handle MDX ESM. 4506 * 4507 * @param {State} state 4508 * Info passed around. 4509 * @param {MdxjsEsmHast} node 4510 * Current node. 4511 * @returns {Child | undefined} 4512 * Child, optional. 4513 */ 4514function mdxEsm(state, node) { 4515 if (node.data && node.data.estree && state.evaluater) { 4516 // Assume result is a child. 4517 return /** @type {Child | undefined} */ ( 4518 state.evaluater.evaluateProgram(node.data.estree) 4519 ) 4520 } 4521 4522 crashEstree(state, node.position) 4523} 4524 4525/** 4526 * Handle MDX JSX. 4527 * 4528 * @param {State} state 4529 * Info passed around. 4530 * @param {MdxJsxFlowElementHast | MdxJsxTextElementHast} node 4531 * Current node. 4532 * @param {string | undefined} key 4533 * Key. 4534 * @returns {Child | undefined} 4535 * Child, optional. 4536 */ 4537function mdxJsxElement(state, node, key) { 4538 const parentSchema = state.schema 4539 let schema = parentSchema 4540 4541 if (node.name === 'svg' && parentSchema.space === 'html') { 4542 schema = property_information_svg 4543 state.schema = schema 4544 } 4545 4546 state.ancestors.push(node) 4547 4548 const type = 4549 node.name === null 4550 ? state.Fragment 4551 : findComponentFromName(state, node.name, true) 4552 const props = createJsxElementProps(state, node) 4553 const children = createChildren(state, node) 4554 4555 addNode(state, props, type, node) 4556 addChildren(props, children) 4557 4558 // Restore. 4559 state.ancestors.pop() 4560 state.schema = parentSchema 4561 4562 return state.create(node, type, props, key) 4563} 4564 4565/** 4566 * Handle root. 4567 * 4568 * @param {State} state 4569 * Info passed around. 4570 * @param {Root} node 4571 * Current node. 4572 * @param {string | undefined} key 4573 * Key. 4574 * @returns {Child | undefined} 4575 * Child, optional. 4576 */ 4577function root(state, node, key) { 4578 /** @type {Props} */ 4579 const props = {} 4580 4581 addChildren(props, createChildren(state, node)) 4582 4583 return state.create(node, state.Fragment, props, key) 4584} 4585 4586/** 4587 * Handle text. 4588 * 4589 * @param {State} _ 4590 * Info passed around. 4591 * @param {Text} node 4592 * Current node. 4593 * @returns {Child | undefined} 4594 * Child, optional. 4595 */ 4596function lib_text(_, node) { 4597 return node.value 4598} 4599 4600/** 4601 * Add `node` to props. 4602 * 4603 * @param {State} state 4604 * Info passed around. 4605 * @param {Props} props 4606 * Props. 4607 * @param {unknown} type 4608 * Type. 4609 * @param {Element | MdxJsxFlowElementHast | MdxJsxTextElementHast} node 4610 * Node. 4611 * @returns {undefined} 4612 * Nothing. 4613 */ 4614function addNode(state, props, type, node) { 4615 // If this is swapped out for a component: 4616 if (typeof type !== 'string' && type !== state.Fragment && state.passNode) { 4617 props.node = node 4618 } 4619} 4620 4621/** 4622 * Add children to props. 4623 * 4624 * @param {Props} props 4625 * Props. 4626 * @param {Array<Child>} children 4627 * Children. 4628 * @returns {undefined} 4629 * Nothing. 4630 */ 4631function addChildren(props, children) { 4632 if (children.length > 0) { 4633 const value = children.length > 1 ? children : children[0] 4634 4635 if (value) { 4636 props.children = value 4637 } 4638 } 4639} 4640 4641/** 4642 * @param {string | undefined} _ 4643 * Path to file. 4644 * @param {Jsx} jsx 4645 * Dynamic. 4646 * @param {Jsx} jsxs 4647 * Static. 4648 * @returns {Create} 4649 * Create a production element. 4650 */ 4651function productionCreate(_, jsx, jsxs) { 4652 return create 4653 /** @type {Create} */ 4654 function create(_, type, props, key) { 4655 // Only an array when there are 2 or more children. 4656 const isStaticChildren = Array.isArray(props.children) 4657 const fn = isStaticChildren ? jsxs : jsx 4658 return key ? fn(type, props, key) : fn(type, props) 4659 } 4660} 4661 4662/** 4663 * @param {string | undefined} filePath 4664 * Path to file. 4665 * @param {JsxDev} jsxDEV 4666 * Development. 4667 * @returns {Create} 4668 * Create a development element. 4669 */ 4670function developmentCreate(filePath, jsxDEV) { 4671 return create 4672 /** @type {Create} */ 4673 function create(node, type, props, key) { 4674 // Only an array when there are 2 or more children. 4675 const isStaticChildren = Array.isArray(props.children) 4676 const point = pointStart(node) 4677 return jsxDEV( 4678 type, 4679 props, 4680 key, 4681 isStaticChildren, 4682 { 4683 columnNumber: point ? point.column - 1 : undefined, 4684 fileName: filePath, 4685 lineNumber: point ? point.line : undefined 4686 }, 4687 undefined 4688 ) 4689 } 4690} 4691 4692/** 4693 * Create props from an element. 4694 * 4695 * @param {State} state 4696 * Info passed around. 4697 * @param {Element} node 4698 * Current element. 4699 * @returns {Props} 4700 * Props. 4701 */ 4702function createElementProps(state, node) { 4703 /** @type {Props}
4703 */ 4704 const props = {} 4705 /** @type {string | undefined} */ 4706 let alignValue 4707 /** @type {string} */ 4708 let prop 4709 4710 for (prop in node.properties) { 4711 if (prop !== 'children' && own.call(node.properties, prop)) { 4712 const result = createProperty(state, prop, node.properties[prop]) 4713 4714 if (result) { 4715 const [key, value] = result 4716 4717 if ( 4718 state.tableCellAlignToStyle && 4719 key === 'align' && 4720 typeof value === 'string' && 4721 tableCellElement.has(node.tagName) 4722 ) { 4723 alignValue = value 4724 } else { 4725 props[key] = value 4726 } 4727 } 4728 } 4729 } 4730 4731 if (alignValue) { 4732 // Assume style is an object. 4733 const style = /** @type {Style} */ (props.style || (props.style = {})) 4734 style[state.stylePropertyNameCase === 'css' ? 'text-align' : 'textAlign'] = 4735 alignValue 4736 } 4737 4738 return props 4739} 4740 4741/** 4742 * Create props from a JSX element. 4743 * 4744 * @param {State} state 4745 * Info passed around. 4746 * @param {MdxJsxFlowElementHast | MdxJsxTextElementHast} node 4747 * Current JSX element. 4748 * @returns {Props} 4749 * Props. 4750 */ 4751function createJsxElementProps(state, node) { 4752 /** @type {Props} */ 4753 const props = {} 4754 4755 for (const attribute of node.attributes) { 4756 if (attribute.type === 'mdxJsxExpressionAttribute') { 4757 if (attribute.data && attribute.data.estree && state.evaluater) { 4758 const program = attribute.data.estree 4759 const expression = program.body[0] 4760 ok(expression.type === 'ExpressionStatement') 4761 const objectExpression = expression.expression 4762 ok(objectExpression.type === 'ObjectExpression') 4763 const property = objectExpression.properties[0] 4764 ok(property.type === 'SpreadElement') 4765 4766 Object.assign( 4767 props, 4768 state.evaluater.evaluateExpression(property.argument) 4769 ) 4770 } else { 4771 crashEstree(state, node.position) 4772 } 4773 } else { 4774 // For JSX, the author is responsible of passing in the correct values. 4775 const name = attribute.name 4776 /** @type {unknown} */ 4777 let value 4778 4779 if (attribute.value && typeof attribute.value === 'object') { 4780 if ( 4781 attribute.value.data && 4782 attribute.value.data.estree && 4783 state.evaluater 4784 ) { 4785 const program = attribute.value.data.estree 4786 const expression = program.body[0] 4787 ok(expression.type === 'ExpressionStatement') 4788 value = state.evaluater.evaluateExpression(expression.expression) 4789 } else { 4790 crashEstree(state, node.position) 4791 } 4792 } else { 4793 value = attribute.value === null ? true : attribute.value 4794 } 4795 4796 // Assume a prop. 4797 props[name] = /** @type {Props[keyof Props]} */ (value) 4798 } 4799 } 4800 4801 return props 4802} 4803 4804/** 4805 * Create children. 4806 * 4807 * @param {State} state 4808 * Info passed around. 4809 * @param {Parents} node 4810 * Current element. 4811 * @returns {Array<Child>} 4812 * Children. 4813 */ 4814function createChildren(state, node) { 4815 /** @type {Array<Child>} */ 4816 const children = [] 4817 let index = -1 4818 /** @type {Map<string, number>} */ 4819 // Note: test this when Solid doesnât want to merge my upcoming PR. 4820 /* c8 ignore next */ 4821 const countsByName = state.passKeys ? new Map() : emptyMap 4822 4823 while (++index < node.children.length) { 4824 const child = node.children[index] 4825 /** @type {string | undefined} */ 4826 let key 4827 4828 if (state.passKeys) { 4829 const name = 4830 child.type === 'element' 4831 ? child.tagName 4832 : child.type === 'mdxJsxFlowElement' || 4833 child.type === 'mdxJsxTextElement' 4834 ? child.name 4835 : undefined 4836 4837 if (name) { 4838 const count = countsByName.get(name) || 0 4839 key = name + '-' + count 4840 countsByName.set(name, count + 1) 4841 } 4842 } 4843 4844 const result = one(state, child, key) 4845 if (result !== undefined) children.push(result) 4846 } 4847 4848 return children 4849} 4850 4851/** 4852 * Handle a property. 4853 * 4854 * @param {State} state 4855 * Info passed around. 4856 * @param {string} prop 4857 * Key. 4858 * @param {Array<number | string> | boolean | number | string | null | undefined} value 4859 * hast property value. 4860 * @returns {Field | undefined} 4861 * Field for runtime, optional. 4862 */ 4863function createProperty(state, prop, value) {
4864 const info = find(state.schema, prop) 4865 4866 // Ignore nullish and `NaN` values. 4867 if ( 4868 value === null || 4869 value === undefined || 4870 (typeof value === 'number' && Number.isNaN(value)) 4871 ) { 4872 return 4873 } 4874 4875 if (Array.isArray(value)) { 4876 // Accept `array`. 4877 // Most props are space-separated. 4878 value = info.commaSeparated ? stringify(value) : space_separated_tokens_stringify(value) 4879 } 4880 4881 // React only accepts `style` as object. 4882 if (info.property === 'style') { 4883 let styleObject = 4884 typeof value === 'object' ? value : parseStyle(state, String(value)) 4885 4886 if (state.stylePropertyNameCase === 'css') { 4887 styleObject = transformStylesToCssCasing(styleObject) 4888 } 4889 4890 return ['style', styleObject] 4891 } 4892 4893 return [ 4894 state.elementAttributeNameCase === 'react' && info.space 4895 ? hastToReact[info.property] || info.property 4896 : info.attribute, 4897 value 4898 ] 4899} 4900 4901/** 4902 * Parse a CSS declaration to an object. 4903 * 4904 * @param {State} state 4905 * Info passed around. 4906 * @param {string} value 4907 * CSS declarations. 4908 * @returns {Style} 4909 * Properties. 4910 * @throws 4911 * Throws `VFileMessage` when CSS cannot be parsed. 4912 */ 4913function parseStyle(state, value) { 4914 try { 4915 return cjs(value, {reactCompat: true}) 4916 } catch (error) { 4917 if (state.ignoreInvalidStyle) { 4918 return {} 4919 } 4920 4921 const cause = /** @type {Error} */ (error) 4922 const message = new VFileMessage('Cannot parse `style` attribute', { 4923 ancestors: state.ancestors, 4924 cause, 4925 ruleId: 'style', 4926 source: 'hast-util-to-jsx-runtime' 4927 }) 4928 message.file = state.filePath || undefined 4929 message.url = docs + '#cannot-parse-style-attribute' 4930 4931 throw message 4932 } 4933} 4934 4935/** 4936 * Create a JSX name from a string. 4937 * 4938 * @param {State} state 4939 * To do. 4940 * @param {string} name 4941 * Name. 4942 * @param {boolean} allowExpression 4943 * Allow member expressions and identifiers. 4944 * @returns {unknown} 4945 * To do. 4946 */ 4947function findComponentFromName(state, name, allowExpression) { 4948 /** @type {Identifier | Literal | MemberExpression} */ 4949 let result 4950 4951 if (!allowExpression) { 4952 result = {type: 'Literal', value: name} 4953 } else if (name.includes('.')) { 4954 const identifiers = name.split('.') 4955 let index = -1 4956 /** @type {Identifier | Literal | MemberExpression | undefined} */ 4957 let node 4958 4959 while (++index < identifiers.length) { 4960 /** @type {Identifier | Literal} */ 4961 const prop = lib_name(identifiers[index]) 4962 ? {type: 'Identifier', name: identifiers[index]} 4963 : {type: 'Literal', value: identifiers[index]} 4964 node = node 4965 ? { 4966 type: 'MemberExpression', 4967 object: node, 4968 property: prop, 4969 computed: Boolean(index && prop.type === 'Literal'), 4970 optional: false 4971 } 4972 : prop 4973 } 4974 4975 ok(node, 'always a result') 4976 result = node 4977 } else { 4978 result = 4979 lib_name(name) && !/^[a-z]/.test(name) 4980 ? {type: 'Identifier', name} 4981 : {type: 'Literal', value: name} 4982 } 4983 4984 // Only literals can be passed in `components` currently. 4985 // No identifiers / member expressions. 4986 if (result.type === 'Literal') { 4987 const name = /** @type {string | number} */ (result.value) 4988 return own.call(state.components, name) ? state.components[name] : name 4989 } 4990 4991 // Assume component. 4992 if (state.evaluater) { 4993 return state.evaluater.evaluateExpression(result) 4994 } 4995 4996 crashEstree(state) 4997} 4998 4999/** 5000 * @param {State} state 5001 * @param {Position | undefined} [place] 5002 * @returns {never} 5003 */ 5004function crashEstree(state, place) { 5005 const message = new VFileMessage( 5006 'Cannot handle MDX estrees without `createEvaluater`', 5007 { 5008 ancestors: state.ancestors, 5009 place, 5010 ruleId: 'mdx-estree', 5011 source: 'hast-util-to-jsx-runtime' 5012 } 5013 ) 5014 message.file = state.filePath || undefined 5015 message.url = docs + '#cannot-handle-mdx-estrees-without-createevaluater' 5016 5017 throw message 5018} 5019 5020/** 5021 * Transform a DOM casing style object to a CSS casing style object. 5022 * 5023 * @param {Style} domCasing 5024 * @returns {Style} 5025 */ 5026function transformStylesToCssCasing(domCasing) { 5027 /** @type {Style} */ 5028 const cssCasing = {} 5029 /** @type {string} */ 5030 let from 5031 5032 for (from in domCasing) { 5033 if (own.call(domCasing, from)) { 5034 cssCasing[transformStyleToCssCasing(from)] = domCasing[from] 5035 } 5036 } 5037 5038 return cssCasing 5039} 5040 5041/** 5042 * Transform a DOM casing style field to a CSS casing style field. 5043 * 5044 * @param {string} from 5045 * @returns {string} 5046 */ 5047function transformStyleToCssCasing(from) { 5048 let to = from.replace(lib_cap, toDash) 5049 // Handle `ms-xxx` -> `-ms-xxx`. 5050 if (to.slice(0, 3) === 'ms-') to = '-' + to 5051 return to 5052} 5053 5054/** 5055 * Make `$0` dash cased. 5056 * 5057 * @param {string} $0 5058 * Capitalized ASCII leter. 5059 * @returns {string} 5060 * Dash and lower letter. 5061 */ 5062function toDash($0) { 5063 return '-' + $0.toLowerCase() 5064} 5065 5066;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/hast-util-to-jsx-runtime/index.js
5067// Note: types exposed from `index.d.ts`. 5068 5069 5070;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/html-url-attributes/lib/index.js 5071/** 5072 * HTML URL properties. 5073 * 5074 * Each key is a property name and each value is a list of tag names it applies 5075 * to or `null` if it applies to all elements. 5076 * 5077 * @type {Record<string, Array<string> | null>} 5078 */ 5079const urlAttributes = { 5080 action: ['form'], 5081 cite: ['blockquote', 'del', 'ins', 'q'], 5082 data: ['object'], 5083 formAction: ['button', 'input'], 5084 href: ['a', 'area', 'base', 'link'], 5085 icon: ['menuitem'], 5086 itemId: null, 5087 manifest: ['html'], 5088 ping: ['a', 'area'], 5089 poster: ['video'], 5090 src: [ 5091 'audio', 5092 'embed', 5093 'iframe', 5094 'img', 5095 'input', 5096 'script', 5097 'source', 5098 'track', 5099 'video' 5100 ] 5101} 5102 5103;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/html-url-attributes/index.js 5104/** 5105 * Utility with info on URL attributes. 5106 * 5107 * ## What is this? 5108 * 5109 * This package contains info on attributes that have URLs as values. 5110 * 5111 * ## When should I use this? 5112 * 5113 * You can use this package any time youâre rewriting URLs. 5114 * 5115 * ## Use 5116 * 5117 * ```js 5118 * import {urlAttributes} from 'html-url-attributes' 5119 * 5120 * console.log(urlAttributes.formAction) 5121 * //=> ['button', 'input'] 5122 * console.log(urlAttributes.href) 5123 * //=> ['a', 'area', 'base', 'link'] 5124 * ``` 5125 * 5126 * ## API 5127 * 5128 * ### `urlAttributes` 5129 * 5130 * HTML URL properties (`Record<string, Array<string> | null>`). 5131 * 5132 * Each key is a property name and each value is a list of tag names it applies 5133 * to or `null` if it applies to all elements. 5134 */ 5135 5136 5137 5138// EXTERNAL MODULE: ./node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/react/jsx-runtime.js 5139var jsx_runtime = __webpack_require__(44951); 5140// EXTERNAL MODULE: ./node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/react/index.js 5141var react = __webpack_require__(25529); 5142;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-string/lib/index.js 5143/** 5144 * @typedef {import('mdast').Nodes} Nodes 5145 * 5146 * @typedef Options 5147 * Configuration (optional). 5148 * @property {boolean | null | undefined} [includeImageAlt=true] 5149 * Whether to use `alt` for `image`s (default: `true`). 5150 * @property {boolean | null | undefined} [includeHtml=true] 5151 * Whether to use `value` of HTML (default: `true`). 5152 */ 5153 5154/** @type {Options} */ 5155const lib_emptyOptions = {} 5156 5157/** 5158 * Get the text content of a node or list of nodes. 5159 * 5160 * Prefers the nodeâs plain-text fields, otherwise serializes its children, 5161 * and if the given value is an array, serialize the nodes in it. 5162 * 5163 * @param {unknown} [value] 5164 * Thing to serialize, typically `Node`. 5165 * @param {Options | null | undefined} [options] 5166 * Configuration (optional). 5167 * @returns {string} 5168 * Serialized `value`. 5169 */ 5170function lib_toString(value, options) { 5171 const settings = options || lib_emptyOptions 5172 const includeImageAlt = 5173 typeof settings.includeImageAlt === 'boolean' 5174 ? settings.includeImageAlt 5175 : true 5176 const includeHtml = 5177 typeof settings.includeHtml === 'boolean' ? settings.includeHtml : true 5178 5179 return lib_one(value, includeImageAlt, includeHtml) 5180} 5181 5182/** 5183 * One node or several nodes. 5184 * 5185 * @param {unknown} value 5186 * Thing to serialize. 5187 * @param {boolean} includeImageAlt 5188 * Include image `alt`s. 5189 * @param {boolean} includeHtml 5190 * Include HTML. 5191 * @returns {string} 5192 * Serialized node. 5193 */ 5194function lib_one(value, includeImageAlt, includeHtml) { 5195 if (node(value)) { 5196 if ('value' in value) { 5197 return value.type === 'html' && !includeHtml ? '' : value.value 5198 } 5199 5200 if (includeImageAlt && 'alt' in value && value.alt) { 5201 return value.alt 5202 } 5203 5204 if ('children' in value) { 5205 return lib_all(value.children, includeImageAlt, includeHtml) 5206 } 5207 } 5208 5209 if (Array.isArray(value)) { 5210 return lib_all(value, includeImageAlt, includeHtml) 5211 } 5212 5213 return '' 5214} 5215 5216/** 5217 * Serialize a list of nodes. 5218 * 5219 * @param {Array<unknown>} values 5220 * Thing to serialize. 5221 * @param {boolean} includeImageAlt 5222 * Include image `alt`s. 5223 * @param {boolean} includeHtml 5224 * Include HTML. 5225 * @returns {string} 5226 * Serialized nodes. 5227 */ 5228function lib_all(values, includeImageAlt, includeHtml) { 5229 /** @type {Array<string>} */ 5230 const result = [] 5231 let index = -1 5232 5233 while (++index < values.length) { 5234 result[index] = lib_one(values[index], includeImageAlt, includeHtml) 5235 } 5236 5237 return result.join('') 5238} 5239 5240/** 5241 * Check if `value` looks like a node. 5242 * 5243 * @param {unknown} value 5244 * Thing. 5245 * @returns {value is Nodes} 5246 * Whether `value` is a node. 5247 */ 5248function node(value) { 5249 return Boolean(value && typeof value === 'object') 5250} 5251 5252;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-string/index.js 5253/** 5254 * @typedef {import('./lib/index.js').Options} Options 5255 */ 5256 5257 5258 5259;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/decode-named-character-reference/index.dom.js 5260/// <reference lib="dom" /> 5261 5262/* global document */ 5263 5264const index_dom_element = document.createElement('i') 5265 5266/** 5267 * @param {string} value 5268 * @returns {string | false} 5269 */ 5270function index_dom_decodeNamedCharacterReference(value) { 5271 const characterReference = '&' + value + ';' 5272 index_dom_element.innerHTML = characterReference 5273 const character = index_dom_element.textContent 5274 5275 // Some named character references do not require the closing semicolon 5276 // (`¬`, for instance), which leads to situations where parsing the assumed 5277 // named reference of `¬it;` will result in the string `¬it;`. 5278 // When we encounter a trailing semicolon after parsing, and the character 5279 // reference to decode was not a semicolon (`;`), we can assume that the 5280 // matching was not complete. 5281 if ( 5282 character.charCodeAt(character.length - 1) === 59 /* `;` */ && 5283 value !== 'semi' 5284 ) { 5285 return false 5286 } 5287 5288 // If the decoded string is equal to the input, the character reference was
5289 // not valid. 5290 return character === characterReference ? false : character 5291} 5292 5293;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-util-chunked/index.js 5294/** 5295 * Like `Array#splice`, but smarter for giant arrays. 5296 * 5297 * `Array#splice` takes all items to be inserted as individual argument which 5298 * causes a stack overflow in V8 when trying to insert 100k items for instance. 5299 * 5300 * Otherwise, this does not return the removed items, and takes `items` as an 5301 * array instead of rest parameters. 5302 * 5303 * @template {unknown} T 5304 * Item type. 5305 * @param {Array<T>} list 5306 * List to operate on. 5307 * @param {number} start 5308 * Index to remove/insert at (can be negative). 5309 * @param {number} remove 5310 * Number of items to remove. 5311 * @param {Array<T>} items 5312 * Items to inject into `list`. 5313 * @returns {undefined} 5314 * Nothing. 5315 */ 5316function splice(list, start, remove, items) { 5317 const end = list.length; 5318 let chunkStart = 0; 5319 /** @type {Array<unknown>} */ 5320 let parameters; 5321 5322 // Make start between zero and `end` (included). 5323 if (start < 0) { 5324 start = -start > end ? 0 : end + start; 5325 } else { 5326 start = start > end ? end : start; 5327 } 5328 remove = remove > 0 ? remove : 0; 5329 5330 // No need to chunk the items if thereâs only a couple (10k) items. 5331 if (items.length < 10000) { 5332 parameters = Array.from(items); 5333 parameters.unshift(start, remove); 5334 // @ts-expect-error Hush, itâs fine. 5335 list.splice(...parameters); 5336 } else { 5337 // Delete `remove` items starting from `start` 5338 if (remove) list.splice(start, remove); 5339 5340 // Insert the items in chunks to not cause stack overflows. 5341 while (chunkStart < items.length) { 5342 parameters = items.slice(chunkStart, chunkStart + 10000); 5343 parameters.unshift(start, 0); 5344 // @ts-expect-error Hush, itâs fine. 5345 list.splice(...parameters); 5346 chunkStart += 10000; 5347 start += 10000; 5348 } 5349 } 5350} 5351 5352/** 5353 * Append `items` (an array) at the end of `list` (another array). 5354 * When `list` was empty, returns `items` instead. 5355 * 5356 * This prevents a potentially expensive operation when `list` is empty, 5357 * and adds items in batches to prevent V8 from hanging. 5358 * 5359 * @template {unknown} T 5360 * Item type. 5361 * @param {Array<T>} list 5362 * List to operate on. 5363 * @param {Array<T>} items 5364 * Items to add to `list`. 5365 * @returns {Array<T>} 5366 * Either `list` or `items`. 5367 */ 5368function micromark_util_chunked_push(list, items) { 5369 if (list.length > 0) { 5370 splice(list, list.length, 0, items); 5371 return list; 5372 } 5373 return items; 5374} 5375;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-util-combine-extensions/index.js 5376/** 5377 * @import { 5378 * Extension, 5379 * Handles, 5380 * HtmlExtension, 5381 * NormalizedExtension 5382 * } from 'micromark-util-types' 5383 */ 5384 5385 5386 5387const micromark_util_combine_extensions_hasOwnProperty = {}.hasOwnProperty 5388 5389/** 5390 * Combine multiple syntax extensions into one. 5391 * 5392 * @param {ReadonlyArray<Extension>} extensions 5393 * List of syntax extensions. 5394 * @returns {NormalizedExtension} 5395 * A single combined extension. 5396 */ 5397function combineExtensions(extensions) { 5398 /** @type {NormalizedExtension} */ 5399 const all = {} 5400 let index = -1 5401 5402 while (++index < extensions.length) { 5403 syntaxExtension(all, extensions[index]) 5404 } 5405 5406 return all 5407} 5408 5409/** 5410 * Merge `extension` into `all`. 5411 * 5412 * @param {NormalizedExtension} all 5413 * Extension to merge into. 5414 * @param {Extension} extension 5415 * Extension to merge. 5416 * @returns {undefined} 5417 * Nothing. 5418 */ 5419function syntaxExtension(all, extension) { 5420 /** @type {keyof Extension} */ 5421 let hook 5422 5423 for (hook in extension) { 5424 const maybe = micromark_util_combine_extensions_hasOwnProperty.call(all, hook) ? all[hook] : undefined 5425 /** @type {Record<string, unknown>} */ 5426 const left = maybe || (all[hook] = {}) 5427 /** @type {Record<string, unknown> | undefined} */ 5428 const right = extension[hook] 5429 /** @type {string} */ 5430 let code 5431 5432 if (right) { 5433 for (code in right) { 5434 if (!micromark_util_combine_extensions_hasOwnProperty.call(left, code)) left[code] = [] 5435 const value = right[code] 5436 constructs( 5437 // @ts-expect-error Looks like a list. 5438 left[code], 5439 Array.isArray(value) ? value : value ? [value] : [] 5440 ) 5441 } 5442 } 5443 } 5444} 5445 5446/** 5447 * Merge `list` into `existing` (both lists of constructs). 5448 * Mutates `existing`. 5449 * 5450 * @param {Array<unknown>} existing 5451 * List of constructs to merge into. 5452 * @param {Array<unknown>} list 5453 * List of constructs to merge. 5454 * @returns {undefined} 5455 * Nothing. 5456 */ 5457function constructs(existing, list) { 5458 let index = -1 5459 /** @type {Array<unknown>} */ 5460 const before = [] 5461 5462 while (++index < list.length) { 5463 // @ts-expect-error Looks like an object. 5464 ;(list[index].add === 'after' ? existing : before).push(list[index]) 5465 } 5466 5467 splice(existing, 0, 0, before) 5468} 5469 5470/** 5471 * Combine multiple HTML extensions into one. 5472 * 5473 * @param {ReadonlyArray<HtmlExtension>} htmlExtensions 5474 * List of HTML extensions. 5475 * @returns {HtmlExtension} 5476 * Single combined HTML extension. 5477 */
5478function micromark_util_combine_extensions_combineHtmlExtensions(htmlExtensions) { 5479 /** @type {HtmlExtension} */ 5480 const handlers = {} 5481 let index = -1 5482 5483 while (++index < htmlExtensions.length) { 5484 htmlExtension(handlers, htmlExtensions[index]) 5485 } 5486 5487 return handlers 5488} 5489 5490/** 5491 * Merge `extension` into `all`. 5492 * 5493 * @param {HtmlExtension} all 5494 * Extension to merge into. 5495 * @param {HtmlExtension} extension 5496 * Extension to merge. 5497 * @returns {undefined} 5498 * Nothing. 5499 */ 5500function htmlExtension(all, extension) { 5501 /** @type {keyof HtmlExtension} */ 5502 let hook 5503 5504 for (hook in extension) { 5505 const maybe = micromark_util_combine_extensions_hasOwnProperty.call(all, hook) ? all[hook] : undefined 5506 const left = maybe || (all[hook] = {}) 5507 const right = extension[hook] 5508 /** @type {keyof Handles} */ 5509 let type 5510 5511 if (right) { 5512 for (type in right) { 5513 // @ts-expect-error assume document vs regular handler are managed correctly. 5514 left[type] = right[type] 5515 } 5516 } 5517 } 5518} 5519 5520;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-util-decode-numeric-character-reference/index.js 5521/** 5522 * Turn the number (in string form as either hexa- or plain decimal) coming from 5523 * a numeric character reference into a character. 5524 * 5525 * Sort of like `String.fromCodePoint(Number.parseInt(value, base))`, but makes 5526 * non-characters and control characters safe. 5527 * 5528 * @param {string} value 5529 * Value to decode. 5530 * @param {number} base 5531 * Numeric base. 5532 * @returns {string} 5533 * Character. 5534 */ 5535function micromark_util_decode_numeric_character_reference_decodeNumericCharacterReference(value, base) { 5536 const code = Number.parseInt(value, base); 5537 if ( 5538 // C0 except for HT, LF, FF, CR, space. 5539 code < 9 || code === 11 || code > 13 && code < 32 || 5540 // Control character (DEL) of C0, and C1 controls. 5541 code > 126 && code < 160 || 5542 // Lone high surrogates and low surrogates. 5543 code > 55_295 && code < 57_344 || 5544 // Noncharacters. 5545 code > 64_975 && code < 65_008 || /* eslint-disable no-bitwise */ 5546 (code & 65_535) === 65_535 || (code & 65_535) === 65_534 || /* eslint-enable no-bitwise */ 5547 // Out of range 5548 code > 1_114_111) { 5549 return "\uFFFD"; 5550 } 5551 return String.fromCodePoint(code); 5552} 5553;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-util-encode/index.js 5554const characterReferences = {'"': 'quot', '&': 'amp', '<': 'lt', '>': 'gt'} 5555 5556/** 5557 * Encode only the dangerous HTML characters. 5558 * 5559 * This ensures that certain characters which have special meaning in HTML are 5560 * dealt with. 5561 * Technically, we can skip `>` and `"` in many cases, but CM includes them. 5562 * 5563 * @param {string} value 5564 * Value to encode. 5565 * @returns {string} 5566 * Encoded value. 5567 */ 5568function micromark_util_encode_encode(value) { 5569 return value.replace(/["&<>]/g, replace) 5570 5571 /** 5572 * @param {string} value 5573 * Value to replace. 5574 * @returns {string} 5575 * Encoded value. 5576 */ 5577 function replace(value) { 5578 return ( 5579 '&' + 5580 characterReferences[ 5581 /** @type {keyof typeof characterReferences} */ (value) 5582 ] + 5583 ';' 5584 ) 5585 } 5586} 5587 5588;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-util-normalize-identifier/index.js 5589/** 5590 * Normalize an identifier (as found in references, definitions). 5591 * 5592 * Collapses markdown whitespace, trim, and then lower- and uppercase. 5593 * 5594 * Some characters are considered âuppercaseâ, such as U+03F4 (`Ï´`), but if their 5595 * lowercase counterpart (U+03B8 (`θ`)) is uppercased will result in a different 5596 * uppercase character (U+0398 (`Î`)). 5597 * So, to get a canonical form, we perform both lower- and uppercase. 5598 * 5599 * Using uppercase last makes sure keys will never interact with default 5600 * prototypal values (such as `constructor`): nothing in the prototype of 5601 * `Object` is uppercase. 5602 * 5603 * @param {string} value 5604 * Identifier to normalize. 5605 * @returns {string} 5606 * Normalized identifier. 5607 */ 5608function micromark_util_normalize_identifier_normalizeIdentifier(value) { 5609 return value 5610 // Collapse markdown whitespace. 5611 .replace(/[\t\n\r ]+/g, " ") 5612 // Trim. 5613 .replace(/^ | $/g, '') 5614 // Some characters are considered âuppercaseâ, but if their lowercase 5615 // counterpart is uppercased will result in a different uppercase 5616 // character. 5617 // Hence, to get that form, we perform both lower- and uppercase. 5618 // Upper case makes sure keys will not interact with default prototypal 5619 // methods: no method is uppercase. 5620 .toLowerCase().toUpperCase(); 5621} 5622;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-util-character/index.js
vendor: 6,986 bytes, lines 5622-5868
5622 5623/** 5624 * @import {Code} from 'micromark-util-types' 5625 */ 5626 5627/** 5628 * Check whether the character code represents an ASCII alpha (`a` through `z`, 5629 * case insensitive). 5630 * 5631 * An **ASCII alpha** is an ASCII upper alpha or ASCII lower alpha. 5632 * 5633 * An **ASCII upper alpha** is a character in the inclusive range U+0041 (`A`) 5634 * to U+005A (`Z`). 5635 * 5636 * An **ASCII lower alpha** is a character in the inclusive range U+0061 (`a`) 5637 * to U+007A (`z`). 5638 * 5639 * @param code 5640 * Code. 5641 * @returns {boolean} 5642 * Whether it matches. 5643 */ 5644const asciiAlpha = regexCheck(/[A-Za-z]/); 5645 5646/** 5647 * Check whether the character code represents an ASCII alphanumeric (`a` 5648 * through `z`, case insensitive, or `0` through `9`). 5649 * 5650 * An **ASCII alphanumeric** is an ASCII digit (see `asciiDigit`) or ASCII alpha 5651 * (see `asciiAlpha`). 5652 * 5653 * @param code 5654 * Code. 5655 * @returns {boolean} 5656 * Whether it matches. 5657 */ 5658const asciiAlphanumeric = regexCheck(/[\dA-Za-z]/); 5659 5660/** 5661 * Check whether the character code represents an ASCII atext. 5662 * 5663 * atext is an ASCII alphanumeric (see `asciiAlphanumeric`), or a character in 5664 * the inclusive ranges U+0023 NUMBER SIGN (`#`) to U+0027 APOSTROPHE (`'`), 5665 * U+002A ASTERISK (`*`), U+002B PLUS SIGN (`+`), U+002D DASH (`-`), U+002F 5666 * SLASH (`/`), U+003D EQUALS TO (`=`), U+003F QUESTION MARK (`?`), U+005E 5667 * CARET (`^`) to U+0060 GRAVE ACCENT (`` ` ``), or U+007B LEFT CURLY BRACE 5668 * (`{`) to U+007E TILDE (`~`). 5669 * 5670 * See: 5671 * **\[RFC5322]**: 5672 * [Internet Message Format](https://tools.ietf.org/html/rfc5322). 5673 * P. Resnick. 5674 * IETF. 5675 * 5676 * @param code 5677 * Code. 5678 * @returns {boolean} 5679 * Whether it matches. 5680 */ 5681const asciiAtext = regexCheck(/[#-'*+\--9=?A-Z^-~]/); 5682 5683/** 5684 * Check whether a character code is an ASCII control character. 5685 * 5686 * An **ASCII control** is a character in the inclusive range U+0000 NULL (NUL) 5687 * to U+001F (US), or U+007F (DEL). 5688 * 5689 * @param {Code} code 5690 * Code. 5691 * @returns {boolean} 5692 * Whether it matches. 5693 */ 5694function asciiControl(code) { 5695 return ( 5696 // Special whitespace codes (which have negative values), C0 and Control 5697 // character DEL 5698 code !== null && (code < 32 || code === 127) 5699 ); 5700} 5701 5702/** 5703 * Check whether the character code represents an ASCII digit (`0` through `9`). 5704 * 5705 * An **ASCII digit** is a character in the inclusive range U+0030 (`0`) to 5706 * U+0039 (`9`). 5707 * 5708 * @param code 5709 * Code. 5710 * @returns {boolean} 5711 * Whether it matches. 5712 */ 5713const asciiDigit = regexCheck(/\d/); 5714 5715/** 5716 * Check whether the character code represents an ASCII hex digit (`a` through 5717 * `f`, case insensitive, or `0` through `9`). 5718 * 5719 * An **ASCII hex digit** is an ASCII digit (see `asciiDigit`), ASCII upper hex 5720 * digit, or an ASCII lower hex digit. 5721 * 5722 * An **ASCII upper hex digit** is a character in the inclusive range U+0041 5723 * (`A`) to U+0046 (`F`). 5724 * 5725 * An **ASCII lower hex digit** is a character in the inclusive range U+0061 5726 * (`a`) to U+0066 (`f`). 5727 * 5728 * @param code 5729 * Code. 5730 * @returns {boolean} 5731 * Whether it matches. 5732 */ 5733const asciiHexDigit = regexCheck(/[\dA-Fa-f]/); 5734 5735/** 5736 * Check whether the character code represents ASCII punctuation. 5737 * 5738 * An **ASCII punctuation** is a character in the inclusive ranges U+0021 5739 * EXCLAMATION MARK (`!`) to U+002F SLASH (`/`), U+003A COLON (`:`) to U+0040 AT 5740 * SIGN (`@`), U+005B LEFT SQUARE BRACKET (`[`) to U+0060 GRAVE ACCENT 5741 * (`` ` ``), or U+007B LEFT CURLY BRACE (`{`) to U+007E TILDE (`~`). 5742 * 5743 * @param code 5744 * Code. 5745 * @returns {boolean} 5746 * Whether it matches. 5747 */ 5748const asciiPunctuation = regexCheck(/[!-/:-@[-`{-~]/); 5749 5750/** 5751 * Check whether a character code is a markdown line ending. 5752 * 5753 * A **markdown line ending** is the virtual characters M-0003 CARRIAGE RETURN 5754 * LINE FEED (CRLF), M-0004 LINE FEED (LF) and M-0005 CARRIAGE RETURN (CR). 5755 * 5756 * In micromark, the actual character U+000A LINE FEED (LF) and U+000D CARRIAGE 5757 * RETURN (CR) are replaced by these virtual characters depending on whether 5758 * they occurred together. 5759 * 5760 * @param {Code} code 5761 * Code. 5762 * @returns {boolean} 5763 * Whether it matches. 5764 */ 5765function markdownLineEnding(code) { 5766 return code !== null && code < -2; 5767} 5768 5769/** 5770 * Check whether a character code is a markdown line ending (see 5771 * `markdownLineEnding`) or markdown space (see `markdownSpace`). 5772 * 5773 * @param {Code} code 5774 * Code. 5775 * @returns {boolean} 5776 * Whether it matches. 5777 */ 5778function markdownLineEndingOrSpace(code) { 5779 return code !== null && (code < 0 || code === 32); 5780} 5781 5782/** 5783 * Check whether a character code is a markdown space. 5784 * 5785 * A **markdown space** is the concrete character U+0020 SPACE (SP) and the 5786 * virtual characters M-0001 VIRTUAL SPACE (VS) and M-0002 HORIZONTAL TAB (HT). 5787 * 5788 * In micromark, the actual character U+0009 CHARACTER TABULATION (HT) is 5789 * replaced by one M-0002 HORIZONTAL TAB (HT) and between 0 and 3 M-0001 VIRTUAL 5790 * SPACE (VS) characters, depending on the column at which the tab occurred. 5791 * 5792 * @param {Code} code 5793 * Code. 5794 * @returns {boolean} 5795 * Whether it matches. 5796 */ 5797function markdownSpace(code) { 5798 return code === -2 || code === -1 || code === 32; 5799} 5800 5801// Size note: removing ASCII from the regex and using `asciiPunctuation` here 5802// In fact adds to the bundle size. 5803/** 5804 * Check whether the character code represents Unicode punctuation. 5805 * 5806 * A **Unicode punctuation** is a character in the Unicode `Pc` (Punctuation, 5807 * Connector), `Pd` (Punctuation, Dash), `Pe` (Punctuation, Close), `Pf` 5808 * (Punctuation, Final quote), `Pi` (Punctuation, Initial quote), `Po` 5809 * (Punctuation, Other), or `Ps` (Punctuation, Open) categories, or an ASCII 5810 * punctuation (see `asciiPunctuation`). 5811 * 5812 * See: 5813 * **\[UNICODE]**: 5814 * [The Unicode Standard](https://www.unicode.org/versions/). 5815 * Unicode Consortium. 5816 * 5817 * @param code 5818 * Code. 5819 * @returns 5820 * Whether it matches. 5821 */ 5822const unicodePunctuation = regexCheck(/\p{P}|\p{S}/u); 5823 5824/** 5825 * Check whether the character code represents Unicode whitespace. 5826 * 5827 * Note that this does handle micromark specific markdown whitespace characters. 5828 * See `markdownLineEndingOrSpace` to check that. 5829 * 5830 * A **Unicode whitespace** is a character in the Unicode `Zs` (Separator, 5831 * Space) category, or U+0009 CHARACTER TABULATION (HT), U+000A LINE FEED (LF), 5832 * U+000C (FF), or U+000D CARRIAGE RETURN (CR) (**\[UNICODE]**). 5833 * 5834 * See: 5835 * **\[UNICODE]**: 5836 * [The Unicode Standard](https://www.unicode.org/versions/). 5837 * Unicode Consortium. 5838 * 5839 * @param code 5840 * Code. 5841 * @returns 5842 * Whether it matches. 5843 */ 5844const unicodeWhitespace = regexCheck(/\s/); 5845 5846/** 5847 * Create a code check from a regex. 5848 * 5849 * @param {RegExp} regex 5850 * Expression. 5851 * @returns {(code: Code) => boolean} 5852 * Check. 5853 */ 5854function regexCheck(regex) { 5855 return check; 5856 5857 /** 5858 * Check whether a code matches the bound regex. 5859 * 5860 * @param {Code} code 5861 * Character code. 5862 * @returns {boolean} 5863 * Whether the character code matches the bound regex. 5864 */ 5865 function check(code) { 5866 return code !== null && code > -1 && regex.test(String.fromCharCode(code)); 5867 } 5868}
vendor: 3,026 bytes, lines 5869-5966
5869;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-util-sanitize-uri/index.js 5870 5871 5872/** 5873 * Make a value safe for injection as a URL. 5874 * 5875 * This encodes unsafe characters with percent-encoding and skips already 5876 * encoded sequences (see `normalizeUri`). 5877 * Further unsafe characters are encoded as character references (see 5878 * `micromark-util-encode`). 5879 * 5880 * A regex of allowed protocols can be given, in which case the URL is 5881 * sanitized. 5882 * For example, `/^(https?|ircs?|mailto|xmpp)$/i` can be used for `a[href]`, or 5883 * `/^https?$/i` for `img[src]` (this is what `github.com` allows). 5884 * If the URL includes an unknown protocol (one not matched by `protocol`, such 5885 * as a dangerous example, `javascript:`), the value is ignored. 5886 * 5887 * @param {string | null | undefined} url 5888 * URI to sanitize. 5889 * @param {RegExp | null | undefined} [protocol] 5890 * Allowed protocols. 5891 * @returns {string} 5892 * Sanitized URI. 5893 */ 5894function micromark_util_sanitize_uri_sanitizeUri(url, protocol) { 5895 const value = encode(normalizeUri(url || '')); 5896 if (!protocol) { 5897 return value; 5898 } 5899 const colon = value.indexOf(':'); 5900 const questionMark = value.indexOf('?'); 5901 const numberSign = value.indexOf('#'); 5902 const slash = value.indexOf('/'); 5903 if ( 5904 // If there is no protocol, itâs relative. 5905 colon < 0 || 5906 // If the first colon is after a `?`, `#`, or `/`, itâs not a protocol. 5907 slash > -1 && colon > slash || questionMark > -1 && colon > questionMark || numberSign > -1 && colon > numberSign || 5908 // It is a protocol, it should be allowed. 5909 protocol.test(value.slice(0, colon))) { 5910 return value; 5911 } 5912 return ''; 5913} 5914 5915/** 5916 * Normalize a URL. 5917 * 5918 * Encode unsafe characters with percent-encoding, skipping already encoded 5919 * sequences. 5920 * 5921 * @param {string} value 5922 * URI to normalize. 5923 * @returns {string} 5924 * Normalized URI. 5925 */ 5926function normalizeUri(value) { 5927 /** @type {Array<string>} */ 5928 const result = []; 5929 let index = -1; 5930 let start = 0; 5931 let skip = 0; 5932 while (++index < value.length) { 5933 const code = value.charCodeAt(index); 5934 /** @type {string} */ 5935 let replace = ''; 5936 5937 // A correct percent encoded value. 5938 if (code === 37 && asciiAlphanumeric(value.charCodeAt(index + 1)) && asciiAlphanumeric(value.charCodeAt(index + 2))) { 5939 skip = 2; 5940 } 5941 // ASCII. 5942 else if (code < 128) { 5943 if (!/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(code))) { 5944 replace = String.fromCharCode(code); 5945 } 5946 } 5947 // Astral. 5948 else if (code > 55_295 && code < 57_344) { 5949 const next = value.charCodeAt(index + 1); 5950 5951 // A correct surrogate pair. 5952 if (code < 56_320 && next > 56_319 && next < 57_344) { 5953 replace = String.fromCharCode(code, next); 5954 skip = 1; 5955 } 5956 // Lone surrogate. 5957 else { 5958 replace = "\uFFFD"; 5959 } 5960 } 5961 // Unicode. 5962 else { 5963 replace = String.fromCharCode(code); 5964 } 5965 if (replace) { 5966 result.push(value.slice(start, index), encodeURIComponent(replace));
5967 start = index + skip + 1; 5968 replace = ''; 5969 } 5970 if (skip) { 5971 index += skip; 5972 skip = 0; 5973 } 5974 } 5975 return result.join('') + value.slice(start); 5976} 5977;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark/lib/compile.js 5978/** 5979 * While micromark is a lexer/tokenizer, the common case of going from markdown 5980 * to html is currently built in as this module, even though the parts can be 5981 * used separately to build ASTs, CSTs, or many other output formats. 5982 * 5983 * Having an HTML compiler built in is useful because it allows us to check for 5984 * compliancy to CommonMark, the de facto norm of markdown, specified in roughly 5985 * 600 input/output cases. 5986 * 5987 * This module has an interface that accepts lists of events instead of the 5988 * whole at once, however, because markdown canât be truly streaming, we buffer 5989 * events before processing and outputting the final result. 5990 */ 5991 5992/** 5993 * @import { 5994 * CompileContext, 5995 * CompileData, 5996 * CompileOptions, 5997 * Compile, 5998 * Definition, 5999 * Event, 6000 * Handle, 6001 * HtmlExtension, 6002 * LineEnding, 6003 * NormalizedHtmlExtension, 6004 * Token 6005 * } from 'micromark-util-types' 6006 */ 6007 6008/** 6009 * @typedef Media 6010 * @property {boolean | undefined} [image] 6011 * @property {string | undefined} [labelId] 6012 * @property {string | undefined} [label] 6013 * @property {string | undefined} [referenceId] 6014 * @property {string | undefined} [destination] 6015 * @property {string | undefined} [title] 6016 */ 6017 6018 6019 6020 6021 6022 6023 6024 6025const compile_hasOwnProperty = {}.hasOwnProperty; 6026 6027/** 6028 * These two are allowlists of safe protocols for full URLs in respectively the 6029 * `href` (on `<a>`) and `src` (on `<img>`) attributes. 6030 * They are based on what is allowed on GitHub, 6031 * <https://github.com/syntax-tree/hast-util-sanitize/blob/9275b21/lib/github.json#L31> 6032 */ 6033const protocolHref = /^(https?|ircs?|mailto|xmpp)$/i; 6034const protocolSource = /^https?$/i; 6035 6036/** 6037 * @param {CompileOptions | null | undefined} [options] 6038 * @returns {Compile} 6039 */ 6040function compile_compile(options) { 6041 const settings = options || {}; 6042 6043 /** 6044 * Tags is needed because according to markdown, links and emphasis and 6045 * whatnot can exist in images, however, as HTML doesnât allow content in 6046 * images, the tags are ignored in the `alt` attribute, but the content 6047 * remains. 6048 * 6049 * @type {boolean | undefined} 6050 */ 6051 let tags = true; 6052 6053 /** 6054 * An object to track identifiers to media (URLs and titles) defined with 6055 * definitions. 6056 * 6057 * @type {Record<string, Definition>} 6058 */ 6059 const definitions = {}; 6060 6061 /** 6062 * A lot of the handlers need to capture some of the output data, modify it 6063 * somehow, and then deal with it. 6064 * We do that by tracking a stack of buffers, that can be opened (with 6065 * `buffer`) and closed (with `resume`) to access them. 6066 * 6067 * @type {Array<Array<string>>} 6068 */ 6069 const buffers = [[]]; 6070 6071 /** 6072 * As we can have links in images and the other way around, where the deepest 6073 * ones are closed first, we need to track which one weâre in. 6074 * 6075 * @type {Array<Media>} 6076 */ 6077 const mediaStack = []; 6078 6079 /** 6080 * Same as `mediaStack` for tightness, which is specific to lists. 6081 * We need to track if weâre currently in a tight or loose container. 6082 * 6083 * @type {Array<boolean>} 6084 */ 6085 const tightStack = []; 6086 6087 /** @type {HtmlExtension} */ 6088 const defaultHandlers = { 6089 enter: { 6090 blockQuote: onenterblockquote, 6091 codeFenced: onentercodefenced, 6092 codeFencedFenceInfo: buffer, 6093 codeFencedFenceMeta: buffer, 6094 codeIndented: onentercodeindented, 6095 codeText: onentercodetext, 6096 content: onentercontent, 6097 definition: onenterdefinition, 6098 definitionDestinationString: onenterdefinitiondestinationstring, 6099 definitionLabelString: buffer, 6100 definitionTitleString: buffer, 6101 emphasis: onenteremphasis, 6102 htmlFlow: onenterhtmlflow, 6103 htmlText: onenterhtml, 6104 image: onenterimage, 6105 label: buffer, 6106 link: onenterlink, 6107 listItemMarker: onenterlistitemmarker, 6108 listItemValue: onenterlistitemvalue, 6109 listOrdered: onenterlistordered, 6110 listUnordered: onenterlistunordered, 6111 paragraph: onenterparagraph, 6112 reference: buffer, 6113 resource: onenterresource, 6114 resourceDestinationString: onenterresourcedestinationstring, 6115 resourceTitleString: buffer, 6116 setextHeading: onentersetextheading, 6117 strong: onenterstrong 6118 }, 6119 exit: { 6120 atxHeading: onexitatxheading, 6121 atxHeadingSequence: onexitatxheadingsequence, 6122 autolinkEmail: onexitautolinkemail, 6123 autolinkProtocol: onexitautolinkprotocol, 6124 blockQuote: onexitblockquote, 6125 characterEscapeValue: onexitdata, 6126 characterReferenceMarkerHexadecimal: onexitcharacterreferencemarker, 6127 characterReferenceMarkerNumeric: onexitcharacterreferencemarker, 6128 characterReferenceValue: onexitcharacterreferencevalue, 6129 codeFenced: onexitflowcode,
6130 codeFencedFence: onexitcodefencedfence, 6131 codeFencedFenceInfo: onexitcodefencedfenceinfo, 6132 codeFencedFenceMeta: onresumedrop, 6133 codeFlowValue: onexitcodeflowvalue, 6134 codeIndented: onexitflowcode, 6135 codeText: onexitcodetext, 6136 codeTextData: onexitdata, 6137 data: onexitdata, 6138 definition: onexitdefinition, 6139 definitionDestinationString: onexitdefinitiondestinationstring, 6140 definitionLabelString: onexitdefinitionlabelstring, 6141 definitionTitleString: onexitdefinitiontitlestring, 6142 emphasis: onexitemphasis, 6143 hardBreakEscape: onexithardbreak, 6144 hardBreakTrailing: onexithardbreak, 6145 htmlFlow: onexithtml, 6146 htmlFlowData: onexitdata, 6147 htmlText: onexithtml, 6148 htmlTextData: onexitdata, 6149 image: onexitmedia, 6150 label: onexitlabel, 6151 labelText: onexitlabeltext, 6152 lineEnding: onexitlineending, 6153 link: onexitmedia, 6154 listOrdered: onexitlistordered, 6155 listUnordered: onexitlistunordered, 6156 paragraph: onexitparagraph, 6157 reference: onresumedrop, 6158 referenceString: onexitreferencestring, 6159 resource: onresumedrop, 6160 resourceDestinationString: onexitresourcedestinationstring, 6161 resourceTitleString: onexitresourcetitlestring, 6162 setextHeading: onexitsetextheading, 6163 setextHeadingLineSequence: onexitsetextheadinglinesequence, 6164 setextHeadingText: onexitsetextheadingtext, 6165 strong: onexitstrong, 6166 thematicBreak: onexitthematicbreak 6167 } 6168 }; 6169 6170 /** 6171 * Combine the HTML extensions with the default handlers. 6172 * An HTML extension is an object whose fields are either `enter` or `exit` 6173 * (reflecting whether a token is entered or exited). 6174 * The values at such objects are names of tokens mapping to handlers. 6175 * Handlers are called, respectively when a token is opener or closed, with 6176 * that token, and a context as `this`. 6177 */ 6178 const handlers = /** @type {NormalizedHtmlExtension} */ 6179 combineHtmlExtensions([defaultHandlers, ...(settings.htmlExtensions || [])]); 6180 6181 /** 6182 * Handlers do often need to keep track of some state. 6183 * That state is provided here as a key-value store (an object). 6184 * 6185 * @type {CompileData} 6186 */ 6187 const data = { 6188 definitions, 6189 tightStack 6190 }; 6191 6192 /** 6193 * The context for handlers references a couple of useful functions. 6194 * In handlers from extensions, those can be accessed at `this`. 6195 * For the handlers here, they can be accessed directly. 6196 * 6197 * @type {Omit<CompileContext, 'sliceSerialize'>} 6198 */ 6199 const context = { 6200 buffer, 6201 encode, 6202 getData, 6203 lineEndingIfNeeded, 6204 options: settings, 6205 raw, 6206 resume, 6207 setData, 6208 tag 6209 }; 6210 6211 /** 6212 * Generally, micromark copies line endings (`'\r'`, `'\n'`, `'\r\n'`) in the 6213 * markdown document over to the compiled HTML. 6214 * In some cases, such as `> a`, CommonMark requires that extra line endings 6215 * are added: `<blockquote>\n<p>a</p>\n</blockquote>`. 6216 * This variable hold the default line ending when given (or `undefined`), 6217 * and in the latter case will be updated to the first found line ending if 6218 * there is one. 6219 */ 6220 let lineEndingStyle = settings.defaultLineEnding; 6221 6222 // Return the function that handles a slice of events. 6223 return compile; 6224 6225 /** 6226 * Deal w/ a slice of events. 6227 * Return either the empty string if thereâs nothing of note to return, or the 6228 * result when done. 6229 * 6230 * @param {ReadonlyArray<Event>} events 6231 * @returns {string} 6232 */ 6233 function compile(events) { 6234 let index = -1; 6235 let start = 0; 6236 /** @type {Array<number>} */ 6237 const listStack = []; 6238 // As definitions can come after references, we need to figure out the media 6239 // (urls and titles) defined by them before handling the references. 6240 // So, we do sort of what HTML does: put metadata at the start (in head), and 6241 // then put content after (`body`). 6242 /** @type {Array<Event>} */ 6243 let head = []; 6244 /** @type {Array<Event>} */ 6245 let body = []; 6246 while (++index < events.length) { 6247 // Figure out the line ending style used in the document. 6248 if (!lineEndingStyle && (events[index][1].type === "lineEnding" || events[index][1].type === "lineEndingBlank")) { 6249 lineEndingStyle = /** @type {LineEnding} */ 6250 events[index][2].sliceSerialize(events[index][1]); 6251 } 6252 6253 // Preprocess lists to infer whether the list is loose or not. 6254 if (events[index][1].type === "listOrdered" || events[index][1].type === "listUnordered") { 6255 if (events[index][0] === 'enter') { 6256 listStack.push(index); 6257 } else { 6258 prepareList(events.slice(listStack.pop(), index)); 6259 } 6260 } 6261 6262 // Move definitions to the front. 6263 if (events[index][1].type === "definition") { 6264 if (events[index][0] === 'enter') { 6265 body = push(body, events.slice(start, index)); 6266 start = index; 6267 } else { 6268 head = push(head, events.slice(start, index + 1)); 6269 start = index + 1; 6270 } 6271 } 6272 } 6273 head = push(head, body); 6274 head = push(head, events.slice(start)); 6275 index = -1; 6276 const result = head; 6277 6278 // Handle the start of the document, if defined. 6279 if (handlers.enter.null) { 6280 handlers.enter.null.call(context); 6281 } 6282 6283 // Handle all events. 6284 while (++index < events.length) { 6285 const handles = handlers[result[index][0]];
6286 const kind = result[index][1].type; 6287 const handle = handles[kind]; 6288 if (compile_hasOwnProperty.call(handles, kind) && handle) { 6289 handle.call({ 6290 sliceSerialize: result[index][2].sliceSerialize, 6291 ...context 6292 }, result[index][1]); 6293 } 6294 } 6295 6296 // Handle the end of the document, if defined. 6297 if (handlers.exit.null) { 6298 handlers.exit.null.call(context); 6299 } 6300 return buffers[0].join(''); 6301 } 6302 6303 /** 6304 * Figure out whether lists are loose or not. 6305 * 6306 * @param {ReadonlyArray<Event>} slice 6307 * @returns {undefined} 6308 */ 6309 function prepareList(slice) { 6310 const length = slice.length; 6311 let index = 0; // Skip open. 6312 let containerBalance = 0; 6313 let loose = false; 6314 /** @type {boolean | undefined} */ 6315 let atMarker; 6316 while (++index < length) { 6317 const event = slice[index]; 6318 if (event[1]._container) { 6319 atMarker = undefined; 6320 if (event[0] === 'enter') { 6321 containerBalance++; 6322 } else { 6323 containerBalance--; 6324 } 6325 } else switch (event[1].type) { 6326 case "listItemPrefix": 6327 { 6328 if (event[0] === 'exit') { 6329 atMarker = true; 6330 } 6331 break; 6332 } 6333 case "linePrefix": 6334 { 6335 // Ignore 6336 6337 break; 6338 } 6339 case "lineEndingBlank": 6340 { 6341 if (event[0] === 'enter' && !containerBalance) { 6342 if (atMarker) { 6343 atMarker = undefined; 6344 } else { 6345 loose = true; 6346 } 6347 } 6348 break; 6349 } 6350 default: 6351 { 6352 atMarker = undefined; 6353 } 6354 } 6355 } 6356 slice[0][1]._loose = loose; 6357 } 6358 6359 /** 6360 * @type {CompileContext['setData']} 6361 */ 6362 function setData(key, value) { 6363 // @ts-expect-error: assume `value` is omitted (`undefined` is passed) only 6364 // if allowed. 6365 data[key] = value; 6366 } 6367 6368 /** 6369 * @type {CompileContext['getData']} 6370 */ 6371 function getData(key) { 6372 return data[key]; 6373 } 6374 6375 /** @type {CompileContext['buffer']} */ 6376 function buffer() { 6377 buffers.push([]); 6378 } 6379 6380 /** @type {CompileContext['resume']} */ 6381 function resume() { 6382 const buf = buffers.pop(); 6383 return buf.join(''); 6384 } 6385 6386 /** @type {CompileContext['tag']} */ 6387 function tag(value) { 6388 if (!tags) return; 6389 setData('lastWasTag', true); 6390 buffers[buffers.length - 1].push(value); 6391 } 6392 6393 /** @type {CompileContext['raw']} */ 6394 function raw(value) { 6395 setData('lastWasTag'); 6396 buffers[buffers.length - 1].push(value); 6397 } 6398 6399 /** 6400 * Output an extra line ending. 6401 * 6402 * @returns {undefined} 6403 */ 6404 function lineEnding() { 6405 raw(lineEndingStyle || '\n'); 6406 } 6407 6408 /** @type {CompileContext['lineEndingIfNeeded']} */ 6409 function lineEndingIfNeeded() { 6410 const buffer = buffers[buffers.length - 1]; 6411 const slice = buffer[buffer.length - 1]; 6412 const previous = slice ? slice.charCodeAt(slice.length - 1) : null; 6413 if (previous === 10 || previous === 13 || previous === null) { 6414 return; 6415 } 6416 lineEnding(); 6417 } 6418 6419 /** @type {CompileContext['encode']} */ 6420 function encode(value) { 6421 return getData('ignoreEncode') ? value : _encode(value); 6422 } 6423 6424 // 6425 // Handlers. 6426 // 6427 6428 /** 6429 * @returns {undefined} 6430 */ 6431 function onresumedrop() { 6432 resume(); 6433 } 6434 6435 /** 6436 * @this {CompileContext} 6437 * @type {Handle} 6438 */ 6439 function onenterlistordered(token) { 6440 tightStack.push(!token._loose); 6441 lineEndingIfNeeded(); 6442 tag('<ol'); 6443 setData('expectFirstItem', true); 6444 } 6445 6446 /** 6447 * @this {CompileContext} 6448 * @type {Handle} 6449 */ 6450 function onenterlistunordered(token) { 6451 tightStack.push(!token._loose); 6452 lineEndingIfNeeded(); 6453 tag('<ul'); 6454 setData('expectFirstItem', true); 6455 } 6456 6457 /** 6458 * @this {CompileContext} 6459 * @type {Handle} 6460 */ 6461 function onenterlistitemvalue(token) { 6462 if (getData('expectFirstItem')) { 6463 const value = Number.parseInt(this.sliceSerialize(token), 10); 6464 if (value !== 1) { 6465 tag(' start="' + encode(String(value)) + '"'); 6466 } 6467 } 6468 } 6469 6470 /** 6471 * @returns {undefined} 6472 */ 6473 function onenterlistitemmarker() { 6474 if (getData('expectFirstItem')) { 6475 tag('>'); 6476 } else { 6477 onexitlistitem(); 6478 } 6479 lineEndingIfNeeded(); 6480 tag('<li>'); 6481 setData('expectFirstItem'); 6482 // âHackâ to prevent a line ending from showing up if the item is empty. 6483 setData('lastWasTag'); 6484 } 6485 6486 /** 6487 * @returns {undefined} 6488 */ 6489 function onexitlistordered() { 6490 onexitlistitem(); 6491 tightStack.pop(); 6492 lineEnding(); 6493 tag('</ol>'); 6494 } 6495 6496 /** 6497 * @returns {undefined} 6498 */ 6499 function onexitlistunordered() { 6500 onexitlistitem(); 6501 tightStack.pop(); 6502 lineEnding(); 6503 tag('</ul>'); 6504 } 6505 6506 /** 6507 * @returns {undefined} 6508 */ 6509 function onexitlistitem() { 6510 if (getData('lastWasTag') && !getData('slurpAllLineEndings')) { 6511 lineEndingIfNeeded(); 6512 } 6513 tag('</li>'); 6514 setData('slurpAllLineEndings'); 6515 } 6516 6517 /** 6518 * @this {CompileContext} 6519 * @type {Handle} 6520 */ 6521 function onenterblockquote() { 6522 tightStack.push(false); 6523 lineEndingIfNeeded(); 6524 tag('<blockquote>'); 6525 } 6526 6527 /** 6528 * @this {CompileContext} 6529 * @type {Handle} 6530 */ 6531 function onexitblockquote() { 6532 tightStack.pop(); 6533 lineEndingIfNeeded(); 6534 tag('</blockquote>'); 6535 setData('slurpAllLineEndings'); 6536 } 6537 6538 /** 6539 * @this {CompileContext} 6540 * @type {Handle} 6541 */ 6542 function onenterparagraph() { 6543 if (!tightStack[tightStack.length - 1]) { 6544 lineEndingIfNeeded(); 6545 tag('<p>'); 6546 } 6547 setData('slurpAllLineEndings'); 6548 } 6549 6550 /** 6551 * @this {CompileContext} 6552 * @type {Handle} 6553 */ 6554 function onexitparagraph() { 6555 if (tightStack[tightStack.length - 1]) { 6556 setData('slurpAllLineEndings', true); 6557 } else { 6558 tag('</p>'); 6559 } 6560 } 6561 6562 /** 6563 * @this {CompileContext} 6564 * @type {Handle} 6565 */ 6566 function onentercodefenced() { 6567 lineEndingIfNeeded(); 6568 tag('<pre><code'); 6569 setData('fencesCount', 0); 6570 } 6571 6572 /** 6573 * @this {CompileContext} 6574 * @type {Handle} 6575 */
6576 function onexitcodefencedfenceinfo() { 6577 const value = resume(); 6578 tag(' class="language-' + value + '"'); 6579 } 6580 6581 /** 6582 * @this {CompileContext} 6583 * @type {Handle} 6584 */ 6585 function onexitcodefencedfence() { 6586 const count = getData('fencesCount') || 0; 6587 if (!count) { 6588 tag('>'); 6589 setData('slurpOneLineEnding', true); 6590 } 6591 setData('fencesCount', count + 1); 6592 } 6593 6594 /** 6595 * @this {CompileContext} 6596 * @type {Handle} 6597 */ 6598 function onentercodeindented() { 6599 lineEndingIfNeeded(); 6600 tag('<pre><code>'); 6601 } 6602 6603 /** 6604 * @this {CompileContext} 6605 * @type {Handle} 6606 */ 6607 function onexitflowcode() { 6608 const count = getData('fencesCount'); 6609 6610 // One special case is if we are inside a container, and the fenced code was 6611 // not closed (meaning it runs to the end). 6612 // In that case, the following line ending, is considered *outside* the 6613 // fenced code and block quote by micromark, but CM wants to treat that 6614 // ending as part of the code. 6615 if (count !== undefined && count < 2 && data.tightStack.length > 0 && !getData('lastWasTag')) { 6616 lineEnding(); 6617 } 6618 6619 // But in most cases, itâs simpler: when weâve seen some data, emit an extra 6620 // line ending when needed. 6621 if (getData('flowCodeSeenData')) { 6622 lineEndingIfNeeded(); 6623 } 6624 tag('</code></pre>'); 6625 if (count !== undefined && count < 2) lineEndingIfNeeded(); 6626 setData('flowCodeSeenData'); 6627 setData('fencesCount'); 6628 setData('slurpOneLineEnding'); 6629 } 6630 6631 /** 6632 * @this {CompileContext} 6633 * @type {Handle} 6634 */ 6635 function onenterimage() { 6636 mediaStack.push({ 6637 image: true 6638 }); 6639 tags = undefined; // Disallow tags. 6640 } 6641 6642 /** 6643 * @this {CompileContext} 6644 * @type {Handle} 6645 */ 6646 function onenterlink() { 6647 mediaStack.push({}); 6648 } 6649 6650 /** 6651 * @this {CompileContext} 6652 * @type {Handle} 6653 */ 6654 function onexitlabeltext(token) { 6655 mediaStack[mediaStack.length - 1].labelId = this.sliceSerialize(token); 6656 } 6657 6658 /** 6659 * @this {CompileContext} 6660 * @type {Handle} 6661 */ 6662 function onexitlabel() { 6663 mediaStack[mediaStack.length - 1].label = resume(); 6664 } 6665 6666 /** 6667 * @this {CompileContext} 6668 * @type {Handle} 6669 */ 6670 function onexitreferencestring(token) { 6671 mediaStack[mediaStack.length - 1].referenceId = this.sliceSerialize(token); 6672 } 6673 6674 /** 6675 * @this {CompileContext} 6676 * @type {Handle} 6677 */ 6678 function onenterresource() { 6679 buffer(); // We can have line endings in the resource, ignore them. 6680 mediaStack[mediaStack.length - 1].destination = ''; 6681 } 6682 6683 /** 6684 * @this {CompileContext} 6685 * @type {Handle} 6686 */ 6687 function onenterresourcedestinationstring() { 6688 buffer(); 6689 // Ignore encoding the result, as weâll first percent encode the url and 6690 // encode manually after. 6691 setData('ignoreEncode', true); 6692 } 6693 6694 /** 6695 * @this {CompileContext} 6696 * @type {Handle} 6697 */ 6698 function onexitresourcedestinationstring() { 6699 mediaStack[mediaStack.length - 1].destination = resume(); 6700 setData('ignoreEncode'); 6701 } 6702 6703 /** 6704 * @this {CompileContext} 6705 * @type {Handle} 6706 */ 6707 function onexitresourcetitlestring() { 6708 mediaStack[mediaStack.length - 1].title = resume(); 6709 } 6710 6711 /** 6712 * @this {CompileContext} 6713 * @type {Handle} 6714 */ 6715 function onexitmedia() { 6716 let index = mediaStack.length - 1; // Skip current. 6717 const media = mediaStack[index]; 6718 const id = media.referenceId || media.labelId; 6719 const context = media.destination === undefined ? definitions[normalizeIdentifier(id)] : media; 6720 tags = true; 6721 while (index--) { 6722 if (mediaStack[index].image) { 6723 tags = undefined; 6724 break; 6725 } 6726 } 6727 if (media.image) { 6728 tag('<img src="' + sanitizeUri(context.destination, settings.allowDangerousProtocol ? undefined : protocolSource) + '" alt="'); 6729 raw(media.label); 6730 tag('"'); 6731 } else { 6732 tag('<a href="' + sanitizeUri(context.destination, settings.allowDangerousProtocol ? undefined : protocolHref) + '"'); 6733 } 6734 tag(context.title ? ' title="' + context.title + '"' : ''); 6735 if (media.image) { 6736 tag(' />'); 6737 } else { 6738 tag('>'); 6739 raw(media.label); 6740 tag('</a>'); 6741 } 6742 mediaStack.pop(); 6743 } 6744 6745 /** 6746 * @this {CompileContext} 6747 * @type {Handle} 6748 */ 6749 function onenterdefinition() { 6750 buffer(); 6751 mediaStack.push({}); 6752 } 6753 6754 /** 6755 * @this {CompileContext} 6756 * @type {Handle} 6757 */
6758 function onexitdefinitionlabelstring(token) { 6759 // Discard label, use the source content instead. 6760 resume(); 6761 mediaStack[mediaStack.length - 1].labelId = this.sliceSerialize(token); 6762 } 6763 6764 /** 6765 * @this {CompileContext} 6766 * @type {Handle} 6767 */ 6768 function onenterdefinitiondestinationstring() { 6769 buffer(); 6770 setData('ignoreEncode', true); 6771 } 6772 6773 /** 6774 * @this {CompileContext} 6775 * @type {Handle} 6776 */ 6777 function onexitdefinitiondestinationstring() { 6778 mediaStack[mediaStack.length - 1].destination = resume(); 6779 setData('ignoreEncode'); 6780 } 6781 6782 /** 6783 * @this {CompileContext} 6784 * @type {Handle} 6785 */ 6786 function onexitdefinitiontitlestring() { 6787 mediaStack[mediaStack.length - 1].title = resume(); 6788 } 6789 6790 /** 6791 * @this {CompileContext} 6792 * @type {Handle} 6793 */ 6794 function onexitdefinition() { 6795 const media = mediaStack[mediaStack.length - 1]; 6796 const id = normalizeIdentifier(media.labelId); 6797 resume(); 6798 if (!compile_hasOwnProperty.call(definitions, id)) { 6799 definitions[id] = mediaStack[mediaStack.length - 1]; 6800 } 6801 mediaStack.pop(); 6802 } 6803 6804 /** 6805 * @this {CompileContext} 6806 * @type {Handle} 6807 */ 6808 function onentercontent() { 6809 setData('slurpAllLineEndings', true); 6810 } 6811 6812 /** 6813 * @this {CompileContext} 6814 * @type {Handle} 6815 */ 6816 function onexitatxheadingsequence(token) { 6817 // Exit for further sequences. 6818 if (getData('headingRank')) return; 6819 setData('headingRank', this.sliceSerialize(token).length); 6820 lineEndingIfNeeded(); 6821 tag('<h' + getData('headingRank') + '>'); 6822 } 6823 6824 /** 6825 * @this {CompileContext} 6826 * @type {Handle} 6827 */ 6828 function onentersetextheading() { 6829 buffer(); 6830 setData('slurpAllLineEndings'); 6831 } 6832 6833 /** 6834 * @this {CompileContext} 6835 * @type {Handle} 6836 */ 6837 function onexitsetextheadingtext() { 6838 setData('slurpAllLineEndings', true); 6839 } 6840 6841 /** 6842 * @this {CompileContext} 6843 * @type {Handle} 6844 */ 6845 function onexitatxheading() { 6846 tag('</h' + getData('headingRank') + '>'); 6847 setData('headingRank'); 6848 } 6849 6850 /** 6851 * @this {CompileContext} 6852 * @type {Handle} 6853 */ 6854 function onexitsetextheadinglinesequence(token) {
6855 setData('headingRank', this.sliceSerialize(token).charCodeAt(0) === 61 ? 1 : 2); 6856 } 6857 6858 /** 6859 * @this {CompileContext} 6860 * @type {Handle} 6861 */ 6862 function onexitsetextheading() { 6863 const value = resume(); 6864 lineEndingIfNeeded(); 6865 tag('<h' + getData('headingRank') + '>'); 6866 raw(value); 6867 tag('</h' + getData('headingRank') + '>'); 6868 setData('slurpAllLineEndings'); 6869 setData('headingRank'); 6870 } 6871 6872 /** 6873 * @this {CompileContext} 6874 * @type {Handle} 6875 */ 6876 function onexitdata(token) { 6877 raw(encode(this.sliceSerialize(token))); 6878 } 6879 6880 /** 6881 * @this {CompileContext} 6882 * @type {Handle} 6883 */ 6884 function onexitlineending(token) { 6885 if (getData('slurpAllLineEndings')) { 6886 return; 6887 } 6888 if (getData('slurpOneLineEnding')) { 6889 setData('slurpOneLineEnding'); 6890 return; 6891 } 6892 if (getData('inCodeText')) { 6893 raw(' '); 6894 return; 6895 } 6896 raw(encode(this.sliceSerialize(token))); 6897 } 6898 6899 /** 6900 * @this {CompileContext} 6901 * @type {Handle} 6902 */ 6903 function onexitcodeflowvalue(token) { 6904 raw(encode(this.sliceSerialize(token))); 6905 setData('flowCodeSeenData', true); 6906 } 6907 6908 /** 6909 * @this {CompileContext} 6910 * @type {Handle} 6911 */ 6912 function onexithardbreak() { 6913 tag('<br />'); 6914 } 6915 6916 /** 6917 * @returns {undefined} 6918 */ 6919 function onenterhtmlflow() { 6920 lineEndingIfNeeded(); 6921 onenterhtml(); 6922 } 6923 6924 /** 6925 * @returns {undefined} 6926 */ 6927 function onexithtml() { 6928 setData('ignoreEncode'); 6929 } 6930 6931 /** 6932 * @returns {undefined} 6933 */ 6934 function onenterhtml() { 6935 if (settings.allowDangerousHtml) { 6936 setData('ignoreEncode', true); 6937 } 6938 } 6939 6940 /** 6941 * @returns {undefined} 6942 */ 6943 function onenteremphasis() { 6944 tag('<em>'); 6945 } 6946 6947 /** 6948 * @returns {undefined} 6949 */ 6950 function onenterstrong() { 6951 tag('<strong>'); 6952 } 6953 6954 /** 6955 * @returns {undefined} 6956 */ 6957 function onentercodetext() { 6958 setData('inCodeText', true); 6959 tag('<code>'); 6960 } 6961 6962 /** 6963 * @returns {undefined} 6964 */ 6965 function onexitcodetext() { 6966 setData('inCodeText'); 6967 tag('</code>'); 6968 } 6969 6970 /** 6971 * @returns {undefined} 6972 */ 6973 function onexitemphasis() { 6974 tag('</em>'); 6975 } 6976 6977 /** 6978 * @returns {undefined} 6979 */ 6980 function onexitstrong() { 6981 tag('</strong>'); 6982 } 6983 6984 /** 6985 * @returns {undefined} 6986 */ 6987 function onexitthematicbreak() { 6988 lineEndingIfNeeded(); 6989 tag('<hr />'); 6990 } 6991 6992 /** 6993 * @this {CompileContext} 6994 * @param {Token} token 6995 * @returns {undefined} 6996 */ 6997 function onexitcharacterreferencemarker(token) { 6998 setData('characterReferenceType', token.type); 6999 } 7000 7001 /** 7002 * @this {CompileContext} 7003 * @type {Handle} 7004 */ 7005 function onexitcharacterreferencevalue(token) { 7006 const value = this.sliceSerialize(token); 7007 const decoded = getData('characterReferenceType') ? decodeNumericCharacterReference(value, getData('characterReferenceType') === "characterReferenceMarkerNumeric" ? 10 : 16) : decodeNamedCharacterReference(value); 7008 7009 // `decodeNamedCharacterReference` can return `false` for invalid named 7010 // character references, 7011 // but everything weâve tokenized is valid. 7012 raw(encode(/** @type {string} */decoded)); 7013 setData('characterReferenceType'); 7014 } 7015 7016 /** 7017 * @this {CompileContext} 7018 * @type {Handle} 7019 */ 7020 function onexitautolinkprotocol(token) { 7021 const uri = this.sliceSerialize(token); 7022 tag('<a href="' + sanitizeUri(uri, settings.allowDangerousProtocol ? undefined : protocolHref) + '">'); 7023 raw(encode(uri)); 7024 tag('</a>'); 7025 } 7026 7027 /** 7028 * @this {CompileContext} 7029 * @type {Handle} 7030 */ 7031 function onexitautolinkemail(token) { 7032 const uri = this.sliceSerialize(token); 7033 tag('<a href="' + sanitizeUri('mailto:' + uri) + '">'); 7034 raw(encode(uri)); 7035 tag('</a>'); 7036 } 7037} 7038;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-factory-space/index.js 7039/** 7040 * @import {Effects, State, TokenType} from 'micromark-util-types' 7041 */ 7042 7043 7044 7045// To do: implement `spaceOrTab`, `spaceOrTabMinMax`, `spaceOrTabWithOptions`. 7046 7047/** 7048 * Parse spaces and tabs. 7049 * 7050 * There is no `nok` parameter: 7051 * 7052 * * spaces in markdown are often optional, in which case this factory can be 7053 * used and `ok` will be switched to whether spaces were found or not 7054 * * one line ending or space can be detected with `markdownSpace(code)` right 7055 * before using `factorySpace` 7056 * 7057 * ###### Examples 7058 * 7059 * Where `â` represents a tab (plus how much it expands) and `â ` represents a 7060 * single space. 7061 * 7062 * ```markdown 7063 * â 7064 * â â â â 7065 * ââ 7066 * ``` 7067 * 7068 * @param {Effects} effects 7069 * Context. 7070 * @param {State} ok 7071 * State switched to when successful. 7072 * @param {TokenType} type 7073 * Type (`' \t'`). 7074 * @param {number | undefined} [max=Infinity] 7075 * Max (exclusive). 7076 * @returns {State} 7077 * Start state. 7078 */ 7079function factorySpace(effects, ok, type, max) { 7080 const limit = max ? max - 1 : Number.POSITIVE_INFINITY; 7081 let size = 0; 7082 return start; 7083 7084 /** @type {State} */ 7085 function start(code) { 7086 if (markdownSpace(code)) { 7087 effects.enter(type); 7088 return prefix(code); 7089 } 7090 return ok(code); 7091 } 7092 7093 /** @type {State} */ 7094 function prefix(code) { 7095 if (markdownSpace(code) && size++ < limit) {
vendor: 50,882 bytes, lines 7096-9251
7096 effects.consume(code); 7097 return prefix; 7098 } 7099 effects.exit(type); 7100 return ok(code); 7101 } 7102} 7103;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark/lib/initialize/content.js 7104/** 7105 * @import { 7106 * InitialConstruct, 7107 * Initializer, 7108 * State, 7109 * TokenizeContext, 7110 * Token 7111 * } from 'micromark-util-types' 7112 */ 7113 7114 7115 7116/** @type {InitialConstruct} */ 7117const content = { 7118 tokenize: initializeContent 7119}; 7120 7121/** 7122 * @this {TokenizeContext} 7123 * Context. 7124 * @type {Initializer} 7125 * Content. 7126 */ 7127function initializeContent(effects) { 7128 const contentStart = effects.attempt(this.parser.constructs.contentInitial, afterContentStartConstruct, paragraphInitial); 7129 /** @type {Token} */ 7130 let previous; 7131 return contentStart; 7132 7133 /** @type {State} */ 7134 function afterContentStartConstruct(code) { 7135 if (code === null) { 7136 effects.consume(code); 7137 return; 7138 } 7139 effects.enter("lineEnding"); 7140 effects.consume(code); 7141 effects.exit("lineEnding"); 7142 return factorySpace(effects, contentStart, "linePrefix"); 7143 } 7144 7145 /** @type {State} */ 7146 function paragraphInitial(code) { 7147 effects.enter("paragraph"); 7148 return lineStart(code); 7149 } 7150 7151 /** @type {State} */ 7152 function lineStart(code) { 7153 const token = effects.enter("chunkText", { 7154 contentType: "text", 7155 previous 7156 }); 7157 if (previous) { 7158 previous.next = token; 7159 } 7160 previous = token; 7161 return data(code); 7162 } 7163 7164 /** @type {State} */ 7165 function data(code) { 7166 if (code === null) { 7167 effects.exit("chunkText"); 7168 effects.exit("paragraph"); 7169 effects.consume(code); 7170 return; 7171 } 7172 if (markdownLineEnding(code)) { 7173 effects.consume(code); 7174 effects.exit("chunkText"); 7175 return lineStart; 7176 } 7177 7178 // Data. 7179 effects.consume(code); 7180 return data; 7181 } 7182} 7183;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark/lib/initialize/document.js 7184/** 7185 * @import { 7186 * Construct, 7187 * ContainerState, 7188 * InitialConstruct, 7189 * Initializer, 7190 * Point, 7191 * State, 7192 * TokenizeContext, 7193 * Tokenizer, 7194 * Token 7195 * } from 'micromark-util-types' 7196 */ 7197 7198/** 7199 * @typedef {[Construct, ContainerState]} StackItem 7200 * Construct and its state. 7201 */ 7202 7203 7204 7205 7206/** @type {InitialConstruct} */ 7207const document_document = { 7208 tokenize: initializeDocument 7209}; 7210 7211/** @type {Construct} */ 7212const containerConstruct = { 7213 tokenize: tokenizeContainer 7214}; 7215 7216/** 7217 * @this {TokenizeContext} 7218 * Self. 7219 * @type {Initializer} 7220 * Initializer. 7221 */ 7222function initializeDocument(effects) { 7223 const self = this; 7224 /** @type {Array<StackItem>} */ 7225 const stack = []; 7226 let continued = 0; 7227 /** @type {TokenizeContext | undefined} */ 7228 let childFlow; 7229 /** @type {Token | undefined} */ 7230 let childToken; 7231 /** @type {number} */ 7232 let lineStartOffset; 7233 return start; 7234 7235 /** @type {State} */ 7236 function start(code) { 7237 // First we iterate through the open blocks, starting with the root 7238 // document, and descending through last children down to the last open 7239 // block. 7240 // Each block imposes a condition that the line must satisfy if the block is 7241 // to remain open. 7242 // For example, a block quote requires a `>` character. 7243 // A paragraph requires a non-blank line. 7244 // In this phase we may match all or just some of the open blocks. 7245 // But we cannot close unmatched blocks yet, because we may have a lazy 7246 // continuation line. 7247 if (continued < stack.length) { 7248 const item = stack[continued]; 7249 self.containerState = item[1]; 7250 return effects.attempt(item[0].continuation, documentContinue, checkNewContainers)(code); 7251 } 7252 7253 // Done. 7254 return checkNewContainers(code); 7255 } 7256 7257 /** @type {State} */ 7258 function documentContinue(code) { 7259 continued++; 7260 7261 // Note: this field is called `_closeFlow` but it also closes containers. 7262 // Perhaps a good idea to rename it but itâs already used in the wild by 7263 // extensions. 7264 if (self.containerState._closeFlow) { 7265 self.containerState._closeFlow = undefined; 7266 if (childFlow) { 7267 closeFlow(); 7268 } 7269 7270 // Note: this algorithm for moving events around is similar to the 7271 // algorithm when dealing with lazy lines in `writeToChild`. 7272 const indexBeforeExits = self.events.length; 7273 let indexBeforeFlow = indexBeforeExits; 7274 /** @type {Point | undefined} */ 7275 let point; 7276 7277 // Find the flow chunk. 7278 while (indexBeforeFlow--) { 7279 if (self.events[indexBeforeFlow][0] === 'exit' && self.events[indexBeforeFlow][1].type === "chunkFlow") { 7280 point = self.events[indexBeforeFlow][1].end; 7281 break; 7282 } 7283 } 7284 exitContainers(continued); 7285 7286 // Fix positions. 7287 let index = indexBeforeExits; 7288 while (index < self.events.length) { 7289 self.events[index][1].end = { 7290 ...point 7291 }; 7292 index++; 7293 } 7294 7295 // Inject the exits earlier (theyâre still also at the end). 7296 splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits)); 7297 7298 // Discard the duplicate exits. 7299 self.events.length = index; 7300 return checkNewContainers(code); 7301 } 7302 return start(code); 7303 } 7304 7305 /** @type {State} */ 7306 function checkNewContainers(code) { 7307 // Next, after consuming the continuation markers for existing blocks, we 7308 // look for new block starts (e.g. `>` for a block quote). 7309 // If we encounter a new block start, we close any blocks unmatched in 7310 // step 1 before creating the new block as a child of the last matched 7311 // block. 7312 if (continued === stack.length) { 7313 // No need to `check` whether thereâs a container, of `exitContainers` 7314 // would be moot. 7315 // We can instead immediately `attempt` to parse one. 7316 if (!childFlow) { 7317 return documentContinued(code); 7318 } 7319 7320 // If we have concrete content, such as block HTML or fenced code, 7321 // we canât have containers âpierceâ into them, so we can immediately 7322 // start. 7323 if (childFlow.currentConstruct && childFlow.currentConstruct.concrete) { 7324 return flowStart(code); 7325 } 7326 7327 // If we do have flow, it could still be a blank line, 7328 // but weâd be interrupting it w/ a new container if thereâs a current 7329 // construct. 7330 // To do: next major: remove `_gfmTableDynamicInterruptHack` (no longer 7331 // needed in [email protected]). 7332 self.interrupt = Boolean(childFlow.currentConstruct && !childFlow._gfmTableDynamicInterruptHack); 7333 } 7334 7335 // Check if there is a new container. 7336 self.containerState = {}; 7337 return effects.check(containerConstruct, thereIsANewContainer, thereIsNoNewContainer)(code); 7338 } 7339 7340 /** @type {State} */ 7341 function thereIsANewContainer(code) { 7342 if (childFlow) closeFlow(); 7343 exitContainers(continued); 7344 return documentContinued(code); 7345 } 7346 7347 /** @type {State} */ 7348 function thereIsNoNewContainer(code) { 7349 self.parser.lazy[self.now().line] = continued !== stack.length; 7350 lineStartOffset = self.now().offset; 7351 return flowStart(code); 7352 } 7353 7354 /** @type {State} */ 7355 function documentContinued(code) { 7356 // Try new containers. 7357 self.containerState = {}; 7358 return effects.attempt(containerConstruct, containerContinue, flowStart)(code); 7359 } 7360 7361 /** @type {State} */ 7362 function containerContinue(code) { 7363 continued++; 7364 stack.push([self.currentConstruct, self.containerState]); 7365 // Try another. 7366 return documentContinued(code); 7367 } 7368 7369 /** @type {State} */ 7370 function flowStart(code) { 7371 if (code === null) { 7372 if (childFlow) closeFlow(); 7373 exitContainers(0); 7374 effects.consume(code); 7375 return; 7376 } 7377 childFlow = childFlow || self.parser.flow(self.now()); 7378 effects.enter("chunkFlow", { 7379 _tokenizer: childFlow, 7380 contentType: "flow", 7381 previous: childToken 7382 }); 7383 return flowContinue(code); 7384 } 7385 7386 /** @type {State} */ 7387 function flowContinue(code) { 7388 if (code === null) { 7389 writeToChild(effects.exit("chunkFlow"), true); 7390 exitContainers(0); 7391 effects.consume(code); 7392 return; 7393 } 7394 if (markdownLineEnding(code)) { 7395 effects.consume(code); 7396 writeToChild(effects.exit("chunkFlow")); 7397 // Get ready for the next line. 7398 continued = 0; 7399 self.interrupt = undefined; 7400 return start; 7401 } 7402 effects.consume(code); 7403 return flowContinue; 7404 } 7405 7406 /** 7407 * @param {Token} token 7408 * Token. 7409 * @param {boolean | undefined} [endOfFile] 7410 * Whether the token is at the end of the file (default: `false`). 7411 * @returns {undefined} 7412 * Nothing. 7413 */ 7414 function writeToChild(token, endOfFile) { 7415 const stream = self.sliceStream(token); 7416 if (endOfFile) stream.push(null); 7417 token.previous = childToken; 7418 if (childToken) childToken.next = token; 7419 childToken = token; 7420 childFlow.defineSkip(token.start); 7421 childFlow.write(stream); 7422 7423 // Alright, so we just added a lazy line: 7424 // 7425 // ```markdown 7426 // > a 7427 // b. 7428 // 7429 // Or: 7430 // 7431 // > ~~~c 7432 // d 7433 // 7434 // Or: 7435 // 7436 // > | e | 7437 // f 7438 // ``` 7439 // 7440 // The construct in the second example (fenced code) does not accept lazy 7441 // lines, so it marked itself as done at the end of its first line, and 7442 // then the content construct parses `d`. 7443 // Most constructs in markdown match on the first line: if the first line 7444 // forms a construct, a non-lazy line canât âunmakeâ it. 7445 // 7446 // The construct in the third example is potentially a GFM table, and 7447 // those are *weird*. 7448 // It *could* be a table, from the first line, if the following line 7449 // matches a condition. 7450 // In this case, that second line is lazy, which âunmakesâ the first line 7451 // and turns the whole into one content block. 7452 // 7453 // Weâve now parsed the non-lazy and the lazy line, and can figure out 7454 // whether the lazy line started a new flow block. 7455 // If it did, we exit the current containers between the two flow blocks. 7456 if (self.parser.lazy[token.start.line]) { 7457 let index = childFlow.events.length; 7458 while (index--) { 7459 if ( 7460 // The token starts before the line ending⦠7461 childFlow.events[index][1].start.offset < lineStartOffset && ( 7462 // â¦and either is not ended yet⦠7463 !childFlow.events[index][1].end || 7464 // â¦or ends after it. 7465 childFlow.events[index][1].end.offset > lineStartOffset)) { 7466 // Exit: thereâs still something open, which means itâs a lazy line 7467 // part of something. 7468 return; 7469 } 7470 } 7471 7472 // Note: this algorithm for moving events around is similar to the 7473 // algorithm when closing flow in `documentContinue`. 7474 const indexBeforeExits = self.events.length; 7475 let indexBeforeFlow = indexBeforeExits; 7476 /** @type {boolean | undefined} */ 7477 let seen; 7478 /** @type {Point | undefined} */ 7479 let point; 7480 7481 // Find the previous chunk (the one before the lazy line). 7482 while (indexBeforeFlow--) { 7483 if (self.events[indexBeforeFlow][0] === 'exit' && self.events[indexBeforeFlow][1].type === "chunkFlow") { 7484 if (seen) { 7485 point = self.events[indexBeforeFlow][1].end; 7486 break; 7487 } 7488 seen = true; 7489 } 7490 } 7491 exitContainers(continued); 7492 7493 // Fix positions. 7494 index = indexBeforeExits; 7495 while (index < self.events.length) { 7496 self.events[index][1].end = { 7497 ...point 7498 }; 7499 index++; 7500 } 7501 7502 // Inject the exits earlier (theyâre still also at the end). 7503 splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits)); 7504 7505 // Discard the duplicate exits. 7506 self.events.length = index; 7507 } 7508 } 7509 7510 /** 7511 * @param {number} size 7512 * Size. 7513 * @returns {undefined} 7514 * Nothing. 7515 */ 7516 function exitContainers(size) { 7517 let index = stack.length; 7518 7519 // Exit open containers. 7520 while (index-- > size) { 7521 const entry = stack[index]; 7522 self.containerState = entry[1]; 7523 entry[0].exit.call(self, effects); 7524 } 7525 stack.length = size; 7526 } 7527 function closeFlow() { 7528 childFlow.write([null]); 7529 childToken = undefined; 7530 childFlow = undefined; 7531 self.containerState._closeFlow = undefined; 7532 } 7533} 7534 7535/** 7536 * @this {TokenizeContext} 7537 * Context. 7538 * @type {Tokenizer} 7539 * Tokenizer. 7540 */ 7541function tokenizeContainer(effects, ok, nok) { 7542 // Always populated by defaults. 7543 7544 return factorySpace(effects, effects.attempt(this.parser.constructs.document, ok, nok), "linePrefix", this.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4); 7545} 7546;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-util-classify-character/index.js 7547/** 7548 * @import {Code} from 'micromark-util-types' 7549 */ 7550 7551 7552/** 7553 * Classify whether a code represents whitespace, punctuation, or something 7554 * else. 7555 * 7556 * Used for attention (emphasis, strong), whose sequences can open or close 7557 * based on the class of surrounding characters. 7558 * 7559 * > ð **Note**: eof (`null`) is seen as whitespace. 7560 * 7561 * @param {Code} code 7562 * Code. 7563 * @returns {typeof constants.characterGroupWhitespace | typeof constants.characterGroupPunctuation | undefined} 7564 * Group. 7565 */ 7566function classifyCharacter(code) { 7567 if (code === null || markdownLineEndingOrSpace(code) || unicodeWhitespace(code)) { 7568 return 1; 7569 } 7570 if (unicodePunctuation(code)) { 7571 return 2; 7572 } 7573} 7574;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-util-resolve-all/index.js 7575/** 7576 * @import {Event, Resolver, TokenizeContext} from 'micromark-util-types' 7577 */ 7578 7579/** 7580 * Call all `resolveAll`s. 7581 * 7582 * @param {ReadonlyArray<{resolveAll?: Resolver | undefined}>} constructs 7583 * List of constructs, optionally with `resolveAll`s. 7584 * @param {Array<Event>} events 7585 * List of events. 7586 * @param {TokenizeContext} context 7587 * Context used by `tokenize`. 7588 * @returns {Array<Event>} 7589 * Changed events. 7590 */ 7591function resolveAll(constructs, events, context) { 7592 /** @type {Array<Resolver>} */ 7593 const called = [] 7594 let index = -1 7595 7596 while (++index < constructs.length) { 7597 const resolve = constructs[index].resolveAll 7598 7599 if (resolve && !called.includes(resolve)) { 7600 events = resolve(events, context) 7601 called.push(resolve) 7602 } 7603 } 7604 7605 return events 7606} 7607 7608;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-core-commonmark/lib/attention.js 7609/** 7610 * @import { 7611 * Code, 7612 * Construct, 7613 * Event, 7614 * Point, 7615 * Resolver, 7616 * State, 7617 * TokenizeContext, 7618 * Tokenizer, 7619 * Token 7620 * } from 'micromark-util-types' 7621 */ 7622 7623 7624 7625 7626/** @type {Construct} */ 7627const attention = { 7628 name: 'attention', 7629 resolveAll: resolveAllAttention, 7630 tokenize: tokenizeAttention 7631}; 7632 7633/** 7634 * Take all events and resolve attention to emphasis or strong. 7635 * 7636 * @type {Resolver} 7637 */ 7638// eslint-disable-next-line complexity 7639function resolveAllAttention(events, context) { 7640 let index = -1; 7641 /** @type {number} */ 7642 let open; 7643 /** @type {Token} */ 7644 let group; 7645 /** @type {Token} */ 7646 let text; 7647 /** @type {Token} */ 7648 let openingSequence; 7649 /** @type {Token} */ 7650 let closingSequence; 7651 /** @type {number} */ 7652 let use; 7653 /** @type {Array<Event>} */ 7654 let nextEvents; 7655 /** @type {number} */ 7656 let offset; 7657 7658 // Walk through all events. 7659 // 7660 // Note: performance of this is fine on an mb of normal markdown, but itâs 7661 // a bottleneck for malicious stuff. 7662 while (++index < events.length) { 7663 // Find a token that can close. 7664 if (events[index][0] === 'enter' && events[index][1].type === 'attentionSequence' && events[index][1]._close) { 7665 open = index; 7666 7667 // Now walk back to find an opener. 7668 while (open--) { 7669 // Find a token that can open the closer. 7670 if (events[open][0] === 'exit' && events[open][1].type === 'attentionSequence' && events[open][1]._open && 7671 // If the markers are the same: 7672 context.sliceSerialize(events[open][1]).charCodeAt(0) === context.sliceSerialize(events[index][1]).charCodeAt(0)) { 7673 // If the opening can close or the closing can open, 7674 // and the close size *is not* a multiple of three, 7675 // but the sum of the opening and closing size *is* multiple of three, 7676 // then donât match. 7677 if ((events[open][1]._close || events[index][1]._open) && (events[index][1].end.offset - events[index][1].start.offset) % 3 && !((events[open][1].end.offset - events[open][1].start.offset + events[index][1].end.offset - events[index][1].start.offset) % 3)) { 7678 continue; 7679 } 7680 7681 // Number of markers to use from the sequence. 7682 use = events[open][1].end.offset - events[open][1].start.offset > 1 && events[index][1].end.offset - events[index][1].start.offset > 1 ? 2 : 1; 7683 const start = { 7684 ...events[open][1].end 7685 }; 7686 const end = { 7687 ...events[index][1].start 7688 }; 7689 movePoint(start, -use); 7690 movePoint(end, use); 7691 openingSequence = { 7692 type: use > 1 ? "strongSequence" : "emphasisSequence", 7693 start, 7694 end: { 7695 ...events[open][1].end 7696 } 7697 }; 7698 closingSequence = { 7699 type: use > 1 ? "strongSequence" : "emphasisSequence", 7700 start: { 7701 ...events[index][1].start 7702 }, 7703 end 7704 }; 7705 text = { 7706 type: use > 1 ? "strongText" : "emphasisText", 7707 start: { 7708 ...events[open][1].end 7709 }, 7710 end: { 7711 ...events[index][1].start 7712 } 7713 }; 7714 group = { 7715 type: use > 1 ? "strong" : "emphasis", 7716 start: { 7717 ...openingSequence.start 7718 }, 7719 end: { 7720 ...closingSequence.end 7721 } 7722 }; 7723 events[open][1].end = { 7724 ...openingSequence.start 7725 }; 7726 events[index][1].start = { 7727 ...closingSequence.end 7728 }; 7729 nextEvents = []; 7730 7731 // If there are more markers in the opening, add them before. 7732 if (events[open][1].end.offset - events[open][1].start.offset) { 7733 nextEvents = micromark_util_chunked_push(nextEvents, [['enter', events[open][1], context], ['exit', events[open][1], context]]); 7734 } 7735 7736 // Opening. 7737 nextEvents = micromark_util_chunked_push(nextEvents, [['enter', group, context], ['enter', openingSequence, context], ['exit', openingSequence, context], ['enter', text, context]]); 7738 7739 // Always populated by defaults. 7740 7741 // Between. 7742 nextEvents = micromark_util_chunked_push(nextEvents, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + 1, index), context)); 7743 7744 // Closing. 7745 nextEvents = micromark_util_chunked_push(nextEvents, [['exit', text, context], ['enter', closingSequence, context], ['exit', closingSequence, context], ['exit', group, context]]); 7746 7747 // If there are more markers in the closing, add them after. 7748 if (events[index][1].end.offset - events[index][1].start.offset) { 7749 offset = 2; 7750 nextEvents = micromark_util_chunked_push(nextEvents, [['enter', events[index][1], context], ['exit', events[index][1], context]]); 7751 } else { 7752 offset = 0; 7753 } 7754 splice(events, open - 1, index - open + 3, nextEvents); 7755 index = open + nextEvents.length - offset - 2; 7756 break; 7757 } 7758 } 7759 } 7760 } 7761 7762 // Remove remaining sequences. 7763 index = -1; 7764 while (++index < events.length) { 7765 if (events[index][1].type === 'attentionSequence') { 7766 events[index][1].type = 'data'; 7767 } 7768 } 7769 return events; 7770} 7771 7772/** 7773 * @this {TokenizeContext} 7774 * Context. 7775 * @type {Tokenizer} 7776 */ 7777function tokenizeAttention(effects, ok) { 7778 const attentionMarkers = this.parser.constructs.attentionMarkers.null; 7779 const previous = this.previous; 7780 const before = classifyCharacter(previous); 7781 7782 /** @type {NonNullable<Code>} */ 7783 let marker; 7784 return start; 7785 7786 /** 7787 * Before a sequence. 7788 * 7789 * ```markdown 7790 * > | ** 7791 * ^ 7792 * ``` 7793 * 7794 * @type {State} 7795 */ 7796 function start(code) { 7797 marker = code; 7798 effects.enter('attentionSequence'); 7799 return inside(code); 7800 } 7801 7802 /** 7803 * In a sequence. 7804 * 7805 * ```markdown 7806 * > | ** 7807 * ^^ 7808 * ``` 7809 * 7810 * @type {State} 7811 */ 7812 function inside(code) { 7813 if (code === marker) { 7814 effects.consume(code); 7815 return inside; 7816 } 7817 const token = effects.exit('attentionSequence'); 7818 7819 // To do: next major: move this to resolver, just like `markdown-rs`. 7820 const after = classifyCharacter(code); 7821 7822 // Always populated by defaults. 7823 7824 const open = !after || after === 2 && before || attentionMarkers.includes(code); 7825 const close = !before || before === 2 && after || attentionMarkers.includes(previous); 7826 token._open = Boolean(marker === 42 ? open : open && (before || !close)); 7827 token._close = Boolean(marker === 42 ? close : close && (after || !open)); 7828 return ok(code); 7829 } 7830} 7831 7832/** 7833 * Move a point a bit. 7834 * 7835 * Note: `move` only works inside lines! Itâs not possible to move past other 7836 * chunks (replacement characters, tabs, or line endings). 7837 * 7838 * @param {Point} point 7839 * Point. 7840 * @param {number} offset 7841 * Amount to move. 7842 * @returns {undefined} 7843 * Nothing. 7844 */ 7845function movePoint(point, offset) { 7846 point.column += offset; 7847 point.offset += offset; 7848 point._bufferIndex += offset; 7849} 7850;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-core-commonmark/lib/autolink.js 7851/** 7852 * @import { 7853 * Construct, 7854 * State, 7855 * TokenizeContext, 7856 * Tokenizer 7857 * } from 'micromark-util-types' 7858 */ 7859 7860 7861/** @type {Construct} */ 7862const autolink = { 7863 name: 'autolink', 7864 tokenize: tokenizeAutolink 7865}; 7866 7867/** 7868 * @this {TokenizeContext} 7869 * Context. 7870 * @type {Tokenizer} 7871 */ 7872function tokenizeAutolink(effects, ok, nok) { 7873 let size = 0; 7874 return start; 7875 7876 /** 7877 * Start of an autolink. 7878 * 7879 * ```markdown 7880 * > | a<https://example.com>b 7881 * ^ 7882 * > | a<[email protected]>b 7883 * ^ 7884 * ``` 7885 * 7886 * @type {State} 7887 */ 7888 function start(code) { 7889 effects.enter("autolink"); 7890 effects.enter("autolinkMarker"); 7891 effects.consume(code); 7892 effects.exit("autolinkMarker"); 7893 effects.enter("autolinkProtocol"); 7894 return open; 7895 } 7896 7897 /** 7898 * After `<`, at protocol or atext. 7899 * 7900 * ```markdown 7901 * > | a<https://example.com>b 7902 * ^ 7903 * > | a<[email protected]>b 7904 * ^ 7905 * ``` 7906 * 7907 * @type {State} 7908 */ 7909 function open(code) { 7910 if (asciiAlpha(code)) { 7911 effects.consume(code); 7912 return schemeOrEmailAtext; 7913 } 7914 if (code === 64) { 7915 return nok(code); 7916 } 7917 return emailAtext(code); 7918 } 7919 7920 /** 7921 * At second byte of protocol or atext. 7922 * 7923 * ```markdown 7924 * > | a<https://example.com>b 7925 * ^ 7926 * > | a<[email protected]>b 7927 * ^ 7928 * ``` 7929 * 7930 * @type {State} 7931 */ 7932 function schemeOrEmailAtext(code) { 7933 // ASCII alphanumeric and `+`, `-`, and `.`. 7934 if (code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) { 7935 // Count the previous alphabetical from `open` too. 7936 size = 1; 7937 return schemeInsideOrEmailAtext(code); 7938 } 7939 return emailAtext(code); 7940 } 7941 7942 /** 7943 * In ambiguous protocol or atext. 7944 * 7945 * ```markdown 7946 * > | a<https://example.com>b 7947 * ^ 7948 * > | a<[email protected]>b 7949 * ^ 7950 * ``` 7951 * 7952 * @type {State} 7953 */ 7954 function schemeInsideOrEmailAtext(code) { 7955 if (code === 58) { 7956 effects.consume(code); 7957 size = 0; 7958 return urlInside; 7959 } 7960 7961 // ASCII alphanumeric and `+`, `-`, and `.`. 7962 if ((code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) && size++ < 32) { 7963 effects.consume(code); 7964 return schemeInsideOrEmailAtext; 7965 } 7966 size = 0; 7967 return emailAtext(code); 7968 } 7969 7970 /** 7971 * After protocol, in URL. 7972 * 7973 * ```markdown 7974 * > | a<https://example.com>b 7975 * ^ 7976 * ``` 7977 * 7978 * @type {State} 7979 */ 7980 function urlInside(code) { 7981 if (code === 62) { 7982 effects.exit("autolinkProtocol"); 7983 effects.enter("autolinkMarker"); 7984 effects.consume(code); 7985 effects.exit("autolinkMarker"); 7986 effects.exit("autolink"); 7987 return ok; 7988 } 7989 7990 // ASCII control, space, or `<`. 7991 if (code === null || code === 32 || code === 60 || asciiControl(code)) { 7992 return nok(code); 7993 } 7994 effects.consume(code); 7995 return urlInside; 7996 } 7997 7998 /** 7999 * In email atext. 8000 * 8001 * ```markdown 8002 * > | a<[email protected]>b 8003 * ^ 8004 * ``` 8005 * 8006 * @type {State} 8007 */ 8008 function emailAtext(code) { 8009 if (code === 64) { 8010 effects.consume(code); 8011 return emailAtSignOrDot; 8012 } 8013 if (asciiAtext(code)) { 8014 effects.consume(code); 8015 return emailAtext; 8016 } 8017 return nok(code); 8018 } 8019 8020 /** 8021 * In label, after at-sign or dot. 8022 * 8023 * ```markdown 8024 * > | a<[email protected]>b 8025 * ^ ^ 8026 * ``` 8027 * 8028 * @type {State} 8029 */ 8030 function emailAtSignOrDot(code) { 8031 return asciiAlphanumeric(code) ? emailLabel(code) : nok(code); 8032 } 8033 8034 /** 8035 * In label, where `.` and `>` are allowed. 8036 * 8037 * ```markdown 8038 * > | a<[email protected]>b 8039 * ^ 8040 * ``` 8041 * 8042 * @type {State} 8043 */ 8044 function emailLabel(code) { 8045 if (code === 46) { 8046 effects.consume(code); 8047 size = 0; 8048 return emailAtSignOrDot; 8049 } 8050 if (code === 62) { 8051 // Exit, then change the token type. 8052 effects.exit("autolinkProtocol").type = "autolinkEmail"; 8053 effects.enter("autolinkMarker"); 8054 effects.consume(code); 8055 effects.exit("autolinkMarker"); 8056 effects.exit("autolink"); 8057 return ok; 8058 } 8059 return emailValue(code); 8060 } 8061 8062 /** 8063 * In label, where `.` and `>` are *not* allowed. 8064 * 8065 * Though, this is also used in `emailLabel` to parse other values. 8066 * 8067 * ```markdown 8068 * > | a<[email protected]>b 8069 * ^ 8070 * ``` 8071 * 8072 * @type {State} 8073 */ 8074 function emailValue(code) { 8075 // ASCII alphanumeric or `-`. 8076 if ((code === 45 || asciiAlphanumeric(code)) && size++ < 63) { 8077 const next = code === 45 ? emailValue : emailLabel; 8078 effects.consume(code); 8079 return next; 8080 } 8081 return nok(code); 8082 } 8083} 8084;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-core-commonmark/lib/blank-line.js 8085/** 8086 * @import { 8087 * Construct, 8088 * State, 8089 * TokenizeContext, 8090 * Tokenizer 8091 * } from 'micromark-util-types' 8092 */ 8093 8094 8095 8096/** @type {Construct} */ 8097const blankLine = { 8098 partial: true, 8099 tokenize: tokenizeBlankLine 8100}; 8101 8102/** 8103 * @this {TokenizeContext} 8104 * Context. 8105 * @type {Tokenizer} 8106 */ 8107function tokenizeBlankLine(effects, ok, nok) { 8108 return start; 8109 8110 /** 8111 * Start of blank line. 8112 * 8113 * > ð **Note**: `â ` represents a space character. 8114 * 8115 * ```markdown 8116 * > | â â â 8117 * ^ 8118 * > | â 8119 * ^ 8120 * ``` 8121 * 8122 * @type {State} 8123 */ 8124 function start(code) { 8125 return markdownSpace(code) ? factorySpace(effects, after, "linePrefix")(code) : after(code); 8126 } 8127 8128 /** 8129 * At eof/eol, after optional whitespace. 8130 * 8131 * > ð **Note**: `â ` represents a space character. 8132 * 8133 * ```markdown 8134 * > | â â â 8135 * ^ 8136 * > | â 8137 * ^ 8138 * ``` 8139 * 8140 * @type {State} 8141 */ 8142 function after(code) { 8143 return code === null || markdownLineEnding(code) ? ok(code) : nok(code); 8144 } 8145} 8146;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-core-commonmark/lib/block-quote.js 8147/** 8148 * @import { 8149 * Construct, 8150 * Exiter, 8151 * State, 8152 * TokenizeContext, 8153 * Tokenizer 8154 * } from 'micromark-util-types' 8155 */ 8156 8157 8158 8159/** @type {Construct} */ 8160const blockQuote = { 8161 continuation: { 8162 tokenize: tokenizeBlockQuoteContinuation 8163 }, 8164 exit, 8165 name: 'blockQuote', 8166 tokenize: tokenizeBlockQuoteStart 8167}; 8168 8169/** 8170 * @this {TokenizeContext} 8171 * Context. 8172 * @type {Tokenizer} 8173 */ 8174function tokenizeBlockQuoteStart(effects, ok, nok) { 8175 const self = this; 8176 return start; 8177 8178 /** 8179 * Start of block quote. 8180 * 8181 * ```markdown 8182 * > | > a 8183 * ^ 8184 * ``` 8185 * 8186 * @type {State} 8187 */ 8188 function start(code) { 8189 if (code === 62) { 8190 const state = self.containerState; 8191 if (!state.open) { 8192 effects.enter("blockQuote", { 8193 _container: true 8194 }); 8195 state.open = true; 8196 } 8197 effects.enter("blockQuotePrefix"); 8198 effects.enter("blockQuoteMarker"); 8199 effects.consume(code); 8200 effects.exit("blockQuoteMarker"); 8201 return after; 8202 } 8203 return nok(code); 8204 } 8205 8206 /** 8207 * After `>`, before optional whitespace. 8208 * 8209 * ```markdown 8210 * > | > a 8211 * ^ 8212 * ``` 8213 * 8214 * @type {State} 8215 */ 8216 function after(code) { 8217 if (markdownSpace(code)) { 8218 effects.enter("blockQuotePrefixWhitespace"); 8219 effects.consume(code); 8220 effects.exit("blockQuotePrefixWhitespace"); 8221 effects.exit("blockQuotePrefix"); 8222 return ok; 8223 } 8224 effects.exit("blockQuotePrefix"); 8225 return ok(code); 8226 } 8227} 8228 8229/** 8230 * Start of block quote continuation. 8231 * 8232 * ```markdown 8233 * | > a 8234 * > | > b 8235 * ^ 8236 * ``` 8237 * 8238 * @this {TokenizeContext} 8239 * Context. 8240 * @type {Tokenizer} 8241 */ 8242function tokenizeBlockQuoteContinuation(effects, ok, nok) { 8243 const self = this; 8244 return contStart; 8245 8246 /** 8247 * Start of block quote continuation. 8248 * 8249 * Also used to parse the first block quote opening. 8250 * 8251 * ```markdown 8252 * | > a 8253 * > | > b 8254 * ^ 8255 * ``` 8256 * 8257 * @type {State} 8258 */ 8259 function contStart(code) { 8260 if (markdownSpace(code)) { 8261 // Always populated by defaults. 8262 8263 return factorySpace(effects, contBefore, "linePrefix", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4)(code); 8264 } 8265 return contBefore(code); 8266 } 8267 8268 /** 8269 * At `>`, after optional whitespace. 8270 * 8271 * Also used to parse the first block quote opening. 8272 * 8273 * ```markdown 8274 * | > a 8275 * > | > b 8276 * ^ 8277 * ``` 8278 * 8279 * @type {State} 8280 */ 8281 function contBefore(code) { 8282 return effects.attempt(blockQuote, ok, nok)(code); 8283 } 8284} 8285 8286/** @type {Exiter} */ 8287function exit(effects) { 8288 effects.exit("blockQuote"); 8289} 8290;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-core-commonmark/lib/character-escape.js 8291/** 8292 * @import { 8293 * Construct, 8294 * State, 8295 * TokenizeContext, 8296 * Tokenizer 8297 * } from 'micromark-util-types' 8298 */ 8299 8300 8301/** @type {Construct} */ 8302const characterEscape = { 8303 name: 'characterEscape', 8304 tokenize: tokenizeCharacterEscape 8305}; 8306 8307/** 8308 * @this {TokenizeContext} 8309 * Context. 8310 * @type {Tokenizer} 8311 */ 8312function tokenizeCharacterEscape(effects, ok, nok) { 8313 return start; 8314 8315 /** 8316 * Start of character escape. 8317 * 8318 * ```markdown 8319 * > | a\*b 8320 * ^ 8321 * ``` 8322 * 8323 * @type {State} 8324 */ 8325 function start(code) { 8326 effects.enter("characterEscape"); 8327 effects.enter("escapeMarker"); 8328 effects.consume(code); 8329 effects.exit("escapeMarker"); 8330 return inside; 8331 } 8332 8333 /** 8334 * After `\`, at punctuation. 8335 * 8336 * ```markdown 8337 * > | a\*b 8338 * ^ 8339 * ``` 8340 * 8341 * @type {State} 8342 */ 8343 function inside(code) { 8344 // ASCII punctuation. 8345 if (asciiPunctuation(code)) { 8346 effects.enter("characterEscapeValue"); 8347 effects.consume(code); 8348 effects.exit("characterEscapeValue"); 8349 effects.exit("characterEscape"); 8350 return ok; 8351 } 8352 return nok(code); 8353 } 8354} 8355;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-core-commonmark/lib/character-reference.js 8356/** 8357 * @import { 8358 * Code, 8359 * Construct, 8360 * State, 8361 * TokenizeContext, 8362 * Tokenizer 8363 * } from 'micromark-util-types' 8364 */ 8365 8366 8367 8368/** @type {Construct} */ 8369const characterReference = { 8370 name: 'characterReference', 8371 tokenize: tokenizeCharacterReference 8372}; 8373 8374/** 8375 * @this {TokenizeContext} 8376 * Context. 8377 * @type {Tokenizer} 8378 */ 8379function tokenizeCharacterReference(effects, ok, nok) { 8380 const self = this; 8381 let size = 0; 8382 /** @type {number} */ 8383 let max; 8384 /** @type {(code: Code) => boolean} */ 8385 let test; 8386 return start; 8387 8388 /** 8389 * Start of character reference. 8390 * 8391 * ```markdown 8392 * > | a&b 8393 * ^ 8394 * > | a{b 8395 * ^ 8396 * > | a	b 8397 * ^ 8398 * ``` 8399 * 8400 * @type {State} 8401 */ 8402 function start(code) { 8403 effects.enter("characterReference"); 8404 effects.enter("characterReferenceMarker"); 8405 effects.consume(code); 8406 effects.exit("characterReferenceMarker"); 8407 return open; 8408 } 8409 8410 /** 8411 * After `&`, at `#` for numeric references or alphanumeric for named 8412 * references. 8413 * 8414 * ```markdown 8415 * > | a&b 8416 * ^ 8417 * > | a{b 8418 * ^ 8419 * > | a	b 8420 * ^ 8421 * ``` 8422 * 8423 * @type {State} 8424 */ 8425 function open(code) { 8426 if (code === 35) { 8427 effects.enter("characterReferenceMarkerNumeric"); 8428 effects.consume(code); 8429 effects.exit("characterReferenceMarkerNumeric"); 8430 return numeric; 8431 } 8432 effects.enter("characterReferenceValue"); 8433 max = 31; 8434 test = asciiAlphanumeric; 8435 return value(code); 8436 } 8437 8438 /** 8439 * After `#`, at `x` for hexadecimals or digit for decimals. 8440 * 8441 * ```markdown 8442 * > | a{b 8443 * ^ 8444 * > | a	b 8445 * ^ 8446 * ``` 8447 * 8448 * @type {State} 8449 */ 8450 function numeric(code) { 8451 if (code === 88 || code === 120) { 8452 effects.enter("characterReferenceMarkerHexadecimal"); 8453 effects.consume(code); 8454 effects.exit("characterReferenceMarkerHexadecimal"); 8455 effects.enter("characterReferenceValue"); 8456 max = 6; 8457 test = asciiHexDigit; 8458 return value; 8459 } 8460 effects.enter("characterReferenceValue"); 8461 max = 7; 8462 test = asciiDigit; 8463 return value(code); 8464 } 8465 8466 /** 8467 * After markers (`&#x`, `&#`, or `&`), in value, before `;`. 8468 * 8469 * The character reference kind defines what and how many characters are 8470 * allowed. 8471 * 8472 * ```markdown 8473 * > | a&b 8474 * ^^^ 8475 * > | a{b 8476 * ^^^ 8477 * > | a	b 8478 * ^ 8479 * ``` 8480 * 8481 * @type {State} 8482 */ 8483 function value(code) { 8484 if (code === 59 && size) { 8485 const token = effects.exit("characterReferenceValue"); 8486 if (test === asciiAlphanumeric && !index_dom_decodeNamedCharacterReference(self.sliceSerialize(token))) { 8487 return nok(code); 8488 } 8489 8490 // To do: `markdown-rs` uses a different name: 8491 // `CharacterReferenceMarkerSemi`. 8492 effects.enter("characterReferenceMarker"); 8493 effects.consume(code); 8494 effects.exit("characterReferenceMarker"); 8495 effects.exit("characterReference"); 8496 return ok; 8497 } 8498 if (test(code) && size++ < max) { 8499 effects.consume(code); 8500 return value; 8501 } 8502 return nok(code); 8503 } 8504} 8505;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-core-commonmark/lib/code-fenced.js 8506/** 8507 * @import { 8508 * Code, 8509 * Construct, 8510 * State, 8511 * TokenizeContext, 8512 * Tokenizer 8513 * } from 'micromark-util-types' 8514 */ 8515 8516 8517 8518/** @type {Construct} */ 8519const nonLazyContinuation = { 8520 partial: true, 8521 tokenize: tokenizeNonLazyContinuation 8522}; 8523 8524/** @type {Construct} */ 8525const codeFenced = { 8526 concrete: true, 8527 name: 'codeFenced', 8528 tokenize: tokenizeCodeFenced 8529}; 8530 8531/** 8532 * @this {TokenizeContext} 8533 * Context. 8534 * @type {Tokenizer} 8535 */ 8536function tokenizeCodeFenced(effects, ok, nok) { 8537 const self = this; 8538 /** @type {Construct} */ 8539 const closeStart = { 8540 partial: true, 8541 tokenize: tokenizeCloseStart 8542 }; 8543 let initialPrefix = 0; 8544 let sizeOpen = 0; 8545 /** @type {NonNullable<Code>} */ 8546 let marker; 8547 return start; 8548 8549 /** 8550 * Start of code. 8551 * 8552 * ```markdown 8553 * > | ~~~js 8554 * ^ 8555 * | alert(1) 8556 * | ~~~ 8557 * ``` 8558 * 8559 * @type {State} 8560 */ 8561 function start(code) { 8562 // To do: parse whitespace like `markdown-rs`. 8563 return beforeSequenceOpen(code); 8564 } 8565 8566 /** 8567 * In opening fence, after prefix, at sequence. 8568 * 8569 * ```markdown 8570 * > | ~~~js 8571 * ^ 8572 * | alert(1) 8573 * | ~~~ 8574 * ``` 8575 * 8576 * @type {State} 8577 */ 8578 function beforeSequenceOpen(code) { 8579 const tail = self.events[self.events.length - 1]; 8580 initialPrefix = tail && tail[1].type === "linePrefix" ? tail[2].sliceSerialize(tail[1], true).length : 0; 8581 marker = code; 8582 effects.enter("codeFenced"); 8583 effects.enter("codeFencedFence"); 8584 effects.enter("codeFencedFenceSequence"); 8585 return sequenceOpen(code); 8586 } 8587 8588 /** 8589 * In opening fence sequence. 8590 * 8591 * ```markdown 8592 * > | ~~~js 8593 * ^ 8594 * | alert(1) 8595 * | ~~~ 8596 * ``` 8597 * 8598 * @type {State} 8599 */ 8600 function sequenceOpen(code) { 8601 if (code === marker) { 8602 sizeOpen++; 8603 effects.consume(code); 8604 return sequenceOpen; 8605 } 8606 if (sizeOpen < 3) { 8607 return nok(code); 8608 } 8609 effects.exit("codeFencedFenceSequence"); 8610 return markdownSpace(code) ? factorySpace(effects, infoBefore, "whitespace")(code) : infoBefore(code); 8611 } 8612 8613 /** 8614 * In opening fence, after the sequence (and optional whitespace), before info. 8615 * 8616 * ```markdown 8617 * > | ~~~js 8618 * ^ 8619 * | alert(1) 8620 * | ~~~ 8621 * ``` 8622 * 8623 * @type {State} 8624 */ 8625 function infoBefore(code) { 8626 if (code === null || markdownLineEnding(code)) { 8627 effects.exit("codeFencedFence"); 8628 return self.interrupt ? ok(code) : effects.check(nonLazyContinuation, atNonLazyBreak, after)(code); 8629 } 8630 effects.enter("codeFencedFenceInfo"); 8631 effects.enter("chunkString", { 8632 contentType: "string" 8633 }); 8634 return info(code); 8635 } 8636 8637 /** 8638 * In info. 8639 * 8640 * ```markdown 8641 * > | ~~~js 8642 * ^ 8643 * | alert(1) 8644 * | ~~~ 8645 * ``` 8646 * 8647 * @type {State} 8648 */ 8649 function info(code) { 8650 if (code === null || markdownLineEnding(code)) { 8651 effects.exit("chunkString"); 8652 effects.exit("codeFencedFenceInfo"); 8653 return infoBefore(code); 8654 } 8655 if (markdownSpace(code)) { 8656 effects.exit("chunkString"); 8657 effects.exit("codeFencedFenceInfo"); 8658 return factorySpace(effects, metaBefore, "whitespace")(code); 8659 } 8660 if (code === 96 && code === marker) { 8661 return nok(code); 8662 } 8663 effects.consume(code); 8664 return info; 8665 } 8666 8667 /** 8668 * In opening fence, after info and whitespace, before meta. 8669 * 8670 * ```markdown 8671 * > | ~~~js eval 8672 * ^ 8673 * | alert(1) 8674 * | ~~~ 8675 * ``` 8676 * 8677 * @type {State} 8678 */ 8679 function metaBefore(code) { 8680 if (code === null || markdownLineEnding(code)) { 8681 return infoBefore(code); 8682 } 8683 effects.enter("codeFencedFenceMeta"); 8684 effects.enter("chunkString", { 8685 contentType: "string" 8686 }); 8687 return meta(code); 8688 } 8689 8690 /** 8691 * In meta. 8692 * 8693 * ```markdown 8694 * > | ~~~js eval 8695 * ^ 8696 * | alert(1) 8697 * | ~~~ 8698 * ``` 8699 * 8700 * @type {State} 8701 */ 8702 function meta(code) { 8703 if (code === null || markdownLineEnding(code)) { 8704 effects.exit("chunkString"); 8705 effects.exit("codeFencedFenceMeta"); 8706 return infoBefore(code); 8707 } 8708 if (code === 96 && code === marker) { 8709 return nok(code); 8710 } 8711 effects.consume(code); 8712 return meta; 8713 } 8714 8715 /** 8716 * At eol/eof in code, before a non-lazy closing fence or content. 8717 * 8718 * ```markdown 8719 * > | ~~~js 8720 * ^ 8721 * > | alert(1) 8722 * ^ 8723 * | ~~~ 8724 * ``` 8725 * 8726 * @type {State} 8727 */ 8728 function atNonLazyBreak(code) { 8729 return effects.attempt(closeStart, after, contentBefore)(code); 8730 } 8731 8732 /** 8733 * Before code content, not a closing fence, at eol. 8734 * 8735 * ```markdown 8736 * | ~~~js 8737 * > | alert(1) 8738 * ^ 8739 * | ~~~ 8740 * ``` 8741 * 8742 * @type {State} 8743 */ 8744 function contentBefore(code) { 8745 effects.enter("lineEnding"); 8746 effects.consume(code); 8747 effects.exit("lineEnding"); 8748 return contentStart; 8749 } 8750 8751 /** 8752 * Before code content, not a closing fence. 8753 * 8754 * ```markdown 8755 * | ~~~js 8756 * > | alert(1) 8757 * ^ 8758 * | ~~~ 8759 * ``` 8760 * 8761 * @type {State} 8762 */ 8763 function contentStart(code) { 8764 return initialPrefix > 0 && markdownSpace(code) ? factorySpace(effects, beforeContentChunk, "linePrefix", initialPrefix + 1)(code) : beforeContentChunk(code); 8765 } 8766 8767 /** 8768 * Before code content, after optional prefix. 8769 * 8770 * ```markdown 8771 * | ~~~js 8772 * > | alert(1) 8773 * ^ 8774 * | ~~~ 8775 * ``` 8776 * 8777 * @type {State} 8778 */ 8779 function beforeContentChunk(code) { 8780 if (code === null || markdownLineEnding(code)) { 8781 return effects.check(nonLazyContinuation, atNonLazyBreak, after)(code); 8782 } 8783 effects.enter("codeFlowValue"); 8784 return contentChunk(code); 8785 } 8786 8787 /** 8788 * In code content. 8789 * 8790 * ```markdown 8791 * | ~~~js 8792 * > | alert(1) 8793 * ^^^^^^^^ 8794 * | ~~~ 8795 * ``` 8796 * 8797 * @type {State} 8798 */ 8799 function contentChunk(code) { 8800 if (code === null || markdownLineEnding(code)) { 8801 effects.exit("codeFlowValue"); 8802 return beforeContentChunk(code); 8803 } 8804 effects.consume(code); 8805 return contentChunk; 8806 } 8807 8808 /** 8809 * After code. 8810 * 8811 * ```markdown 8812 * | ~~~js 8813 * | alert(1) 8814 * > | ~~~ 8815 * ^ 8816 * ``` 8817 * 8818 * @type {State} 8819 */ 8820 function after(code) { 8821 effects.exit("codeFenced"); 8822 return ok(code); 8823 } 8824 8825 /** 8826 * @this {TokenizeContext} 8827 * Context. 8828 * @type {Tokenizer} 8829 */ 8830 function tokenizeCloseStart(effects, ok, nok) { 8831 let size = 0; 8832 return startBefore; 8833 8834 /** 8835 * 8836 * 8837 * @type {State} 8838 */ 8839 function startBefore(code) { 8840 effects.enter("lineEnding"); 8841 effects.consume(code); 8842 effects.exit("lineEnding"); 8843 return start; 8844 } 8845 8846 /** 8847 * Before closing fence, at optional whitespace. 8848 * 8849 * ```markdown 8850 * | ~~~js 8851 * | alert(1) 8852 * > | ~~~ 8853 * ^ 8854 * ``` 8855 * 8856 * @type {State} 8857 */ 8858 function start(code) { 8859 // Always populated by defaults. 8860 8861 // To do: `enter` here or in next state? 8862 effects.enter("codeFencedFence"); 8863 return markdownSpace(code) ? factorySpace(effects, beforeSequenceClose, "linePrefix", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4)(code) : beforeSequenceClose(code); 8864 } 8865 8866 /** 8867 * In closing fence, after optional whitespace, at sequence. 8868 * 8869 * ```markdown 8870 * | ~~~js 8871 * | alert(1) 8872 * > | ~~~ 8873 * ^ 8874 * ``` 8875 * 8876 * @type {State} 8877 */ 8878 function beforeSequenceClose(code) { 8879 if (code === marker) { 8880 effects.enter("codeFencedFenceSequence"); 8881 return sequenceClose(code); 8882 } 8883 return nok(code); 8884 } 8885 8886 /** 8887 * In closing fence sequence. 8888 * 8889 * ```markdown 8890 * | ~~~js 8891 * | alert(1) 8892 * > | ~~~ 8893 * ^ 8894 * ``` 8895 * 8896 * @type {State} 8897 */ 8898 function sequenceClose(code) { 8899 if (code === marker) { 8900 size++; 8901 effects.consume(code); 8902 return sequenceClose; 8903 } 8904 if (size >= sizeOpen) { 8905 effects.exit("codeFencedFenceSequence"); 8906 return markdownSpace(code) ? factorySpace(effects, sequenceCloseAfter, "whitespace")(code) : sequenceCloseAfter(code); 8907 } 8908 return nok(code); 8909 } 8910 8911 /** 8912 * After closing fence sequence, after optional whitespace. 8913 * 8914 * ```markdown 8915 * | ~~~js 8916 * | alert(1) 8917 * > | ~~~ 8918 * ^ 8919 * ``` 8920 * 8921 * @type {State} 8922 */ 8923 function sequenceCloseAfter(code) { 8924 if (code === null || markdownLineEnding(code)) { 8925 effects.exit("codeFencedFence"); 8926 return ok(code); 8927 } 8928 return nok(code); 8929 } 8930 } 8931} 8932 8933/** 8934 * @this {TokenizeContext} 8935 * Context. 8936 * @type {Tokenizer} 8937 */ 8938function tokenizeNonLazyContinuation(effects, ok, nok) { 8939 const self = this; 8940 return start; 8941 8942 /** 8943 * 8944 * 8945 * @type {State} 8946 */ 8947 function start(code) { 8948 if (code === null) { 8949 return nok(code); 8950 } 8951 effects.enter("lineEnding"); 8952 effects.consume(code); 8953 effects.exit("lineEnding"); 8954 return lineStart; 8955 } 8956 8957 /** 8958 * 8959 * 8960 * @type {State} 8961 */ 8962 function lineStart(code) { 8963 return self.parser.lazy[self.now().line] ? nok(code) : ok(code); 8964 } 8965} 8966;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-core-commonmark/lib/code-indented.js 8967/** 8968 * @import { 8969 * Construct, 8970 * State, 8971 * TokenizeContext, 8972 * Tokenizer 8973 * } from 'micromark-util-types' 8974 */ 8975 8976 8977 8978/** @type {Construct} */ 8979const codeIndented = { 8980 name: 'codeIndented', 8981 tokenize: tokenizeCodeIndented 8982}; 8983 8984/** @type {Construct} */ 8985const furtherStart = { 8986 partial: true, 8987 tokenize: tokenizeFurtherStart 8988}; 8989 8990/** 8991 * @this {TokenizeContext} 8992 * Context. 8993 * @type {Tokenizer} 8994 */ 8995function tokenizeCodeIndented(effects, ok, nok) { 8996 const self = this; 8997 return start; 8998 8999 /** 9000 * Start of code (indented). 9001 * 9002 * > **Parsing note**: it is not needed to check if this first line is a 9003 * > filled line (that it has a non-whitespace character), because blank lines 9004 * > are parsed already, so we never run into that. 9005 * 9006 * ```markdown 9007 * > | aaa 9008 * ^ 9009 * ``` 9010 * 9011 * @type {State} 9012 */ 9013 function start(code) { 9014 // To do: manually check if interrupting like `markdown-rs`. 9015 9016 effects.enter("codeIndented"); 9017 // To do: use an improved `space_or_tab` function like `markdown-rs`, 9018 // so that we can drop the next state. 9019 return factorySpace(effects, afterPrefix, "linePrefix", 4 + 1)(code); 9020 } 9021 9022 /** 9023 * At start, after 1 or 4 spaces. 9024 * 9025 * ```markdown 9026 * > | aaa 9027 * ^ 9028 * ``` 9029 * 9030 * @type {State} 9031 */ 9032 function afterPrefix(code) { 9033 const tail = self.events[self.events.length - 1]; 9034 return tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], true).length >= 4 ? atBreak(code) : nok(code); 9035 } 9036 9037 /** 9038 * At a break. 9039 * 9040 * ```markdown 9041 * > | aaa 9042 * ^ ^ 9043 * ``` 9044 * 9045 * @type {State} 9046 */ 9047 function atBreak(code) { 9048 if (code === null) { 9049 return after(code); 9050 } 9051 if (markdownLineEnding(code)) { 9052 return effects.attempt(furtherStart, atBreak, after)(code); 9053 } 9054 effects.enter("codeFlowValue"); 9055 return inside(code); 9056 } 9057 9058 /** 9059 * In code content. 9060 * 9061 * ```markdown 9062 * > | aaa 9063 * ^^^^ 9064 * ``` 9065 * 9066 * @type {State} 9067 */ 9068 function inside(code) { 9069 if (code === null || markdownLineEnding(code)) { 9070 effects.exit("codeFlowValue"); 9071 return atBreak(code); 9072 } 9073 effects.consume(code); 9074 return inside; 9075 } 9076 9077 /** @type {State} */ 9078 function after(code) { 9079 effects.exit("codeIndented"); 9080 // To do: allow interrupting like `markdown-rs`. 9081 // Feel free to interrupt. 9082 // tokenizer.interrupt = false 9083 return ok(code); 9084 } 9085} 9086 9087/** 9088 * @this {TokenizeContext} 9089 * Context. 9090 * @type {Tokenizer} 9091 */ 9092function tokenizeFurtherStart(effects, ok, nok) { 9093 const self = this; 9094 return furtherStart; 9095 9096 /** 9097 * At eol, trying to parse another indent. 9098 * 9099 * ```markdown 9100 * > | aaa 9101 * ^ 9102 * | bbb 9103 * ``` 9104 * 9105 * @type {State} 9106 */ 9107 function furtherStart(code) { 9108 // To do: improve `lazy` / `pierce` handling. 9109 // If this is a lazy line, it canât be code. 9110 if (self.parser.lazy[self.now().line]) { 9111 return nok(code); 9112 } 9113 if (markdownLineEnding(code)) { 9114 effects.enter("lineEnding"); 9115 effects.consume(code); 9116 effects.exit("lineEnding"); 9117 return furtherStart; 9118 } 9119 9120 // To do: the code here in `micromark-js` is a bit different from 9121 // `markdown-rs` because there it can attempt spaces. 9122 // We canât yet. 9123 // 9124 // To do: use an improved `space_or_tab` function like `markdown-rs`, 9125 // so that we can drop the next state. 9126 return factorySpace(effects, afterPrefix, "linePrefix", 4 + 1)(code); 9127 } 9128 9129 /** 9130 * At start, after 1 or 4 spaces. 9131 * 9132 * ```markdown 9133 * > | aaa 9134 * ^ 9135 * ``` 9136 * 9137 * @type {State} 9138 */ 9139 function afterPrefix(code) { 9140 const tail = self.events[self.events.length - 1]; 9141 return tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], true).length >= 4 ? ok(code) : markdownLineEnding(code) ? furtherStart(code) : nok(code); 9142 } 9143} 9144;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-core-commonmark/lib/code-text.js 9145/** 9146 * @import { 9147 * Construct, 9148 * Previous, 9149 * Resolver, 9150 * State, 9151 * TokenizeContext, 9152 * Tokenizer, 9153 * Token 9154 * } from 'micromark-util-types' 9155 */ 9156 9157 9158/** @type {Construct} */ 9159const codeText = { 9160 name: 'codeText', 9161 previous, 9162 resolve: resolveCodeText, 9163 tokenize: tokenizeCodeText 9164}; 9165 9166// To do: next major: donât resolve, like `markdown-rs`. 9167/** @type {Resolver} */ 9168function resolveCodeText(events) { 9169 let tailExitIndex = events.length - 4; 9170 let headEnterIndex = 3; 9171 /** @type {number} */ 9172 let index; 9173 /** @type {number | undefined} */ 9174 let enter; 9175 9176 // If we start and end with an EOL or a space. 9177 if ((events[headEnterIndex][1].type === "lineEnding" || events[headEnterIndex][1].type === 'space') && (events[tailExitIndex][1].type === "lineEnding" || events[tailExitIndex][1].type === 'space')) { 9178 index = headEnterIndex; 9179 9180 // And we have data. 9181 while (++index < tailExitIndex) { 9182 if (events[index][1].type === "codeTextData") { 9183 // Then we have padding. 9184 events[headEnterIndex][1].type = "codeTextPadding"; 9185 events[tailExitIndex][1].type = "codeTextPadding"; 9186 headEnterIndex += 2; 9187 tailExitIndex -= 2; 9188 break; 9189 } 9190 } 9191 } 9192 9193 // Merge adjacent spaces and data. 9194 index = headEnterIndex - 1; 9195 tailExitIndex++; 9196 while (++index <= tailExitIndex) { 9197 if (enter === undefined) { 9198 if (index !== tailExitIndex && events[index][1].type !== "lineEnding") { 9199 enter = index; 9200 } 9201 } else if (index === tailExitIndex || events[index][1].type === "lineEnding") { 9202 events[enter][1].type = "codeTextData"; 9203 if (index !== enter + 2) { 9204 events[enter][1].end = events[index - 1][1].end; 9205 events.splice(enter + 2, index - enter - 2); 9206 tailExitIndex -= index - enter - 2; 9207 index = enter + 2; 9208 } 9209 enter = undefined; 9210 } 9211 } 9212 return events; 9213} 9214 9215/** 9216 * @this {TokenizeContext} 9217 * Context. 9218 * @type {Previous} 9219 */ 9220function previous(code) { 9221 // If there is a previous code, there will always be a tail. 9222 return code !== 96 || this.events[this.events.length - 1][1].type === "characterEscape"; 9223} 9224 9225/** 9226 * @this {TokenizeContext} 9227 * Context. 9228 * @type {Tokenizer} 9229 */ 9230function tokenizeCodeText(effects, ok, nok) { 9231 const self = this; 9232 let sizeOpen = 0; 9233 /** @type {number} */ 9234 let size; 9235 /** @type {Token} */ 9236 let token; 9237 return start; 9238 9239 /** 9240 * Start of code (text). 9241 * 9242 * ```markdown 9243 * > | `a` 9244 * ^ 9245 * > | \`a` 9246 * ^ 9247 * ``` 9248 * 9249 * @type {State} 9250 */ 9251 function start(code) {
vendor: 2,361 bytes, lines 9252-9370
9252 effects.enter("codeText"); 9253 effects.enter("codeTextSequence"); 9254 return sequenceOpen(code); 9255 } 9256 9257 /** 9258 * In opening sequence. 9259 * 9260 * ```markdown 9261 * > | `a` 9262 * ^ 9263 * ``` 9264 * 9265 * @type {State} 9266 */ 9267 function sequenceOpen(code) { 9268 if (code === 96) { 9269 effects.consume(code); 9270 sizeOpen++; 9271 return sequenceOpen; 9272 } 9273 effects.exit("codeTextSequence"); 9274 return between(code); 9275 } 9276 9277 /** 9278 * Between something and something else. 9279 * 9280 * ```markdown 9281 * > | `a` 9282 * ^^ 9283 * ``` 9284 * 9285 * @type {State} 9286 */ 9287 function between(code) { 9288 // EOF. 9289 if (code === null) { 9290 return nok(code); 9291 } 9292 9293 // To do: next major: donât do spaces in resolve, but when compiling, 9294 // like `markdown-rs`. 9295 // Tabs donât work, and virtual spaces donât make sense. 9296 if (code === 32) { 9297 effects.enter('space'); 9298 effects.consume(code); 9299 effects.exit('space'); 9300 return between; 9301 } 9302 9303 // Closing fence? Could also be data. 9304 if (code === 96) { 9305 token = effects.enter("codeTextSequence"); 9306 size = 0; 9307 return sequenceClose(code); 9308 } 9309 if (markdownLineEnding(code)) { 9310 effects.enter("lineEnding"); 9311 effects.consume(code); 9312 effects.exit("lineEnding"); 9313 return between; 9314 } 9315 9316 // Data. 9317 effects.enter("codeTextData"); 9318 return data(code); 9319 } 9320 9321 /** 9322 * In data. 9323 * 9324 * ```markdown 9325 * > | `a` 9326 * ^ 9327 * ``` 9328 * 9329 * @type {State} 9330 */ 9331 function data(code) { 9332 if (code === null || code === 32 || code === 96 || markdownLineEnding(code)) { 9333 effects.exit("codeTextData"); 9334 return between(code); 9335 } 9336 effects.consume(code); 9337 return data; 9338 } 9339 9340 /** 9341 * In closing sequence. 9342 * 9343 * ```markdown 9344 * > | `a` 9345 * ^ 9346 * ``` 9347 * 9348 * @type {State} 9349 */ 9350 function sequenceClose(code) { 9351 // More. 9352 if (code === 96) { 9353 effects.consume(code); 9354 size++; 9355 return sequenceClose; 9356 } 9357 9358 // Done! 9359 if (size === sizeOpen) { 9360 effects.exit("codeTextSequence"); 9361 effects.exit("codeText"); 9362 return ok(code); 9363 } 9364 9365 // More or less accents: mark as data. 9366 token.type = "codeTextData"; 9367 return data(code); 9368 } 9369} 9370;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-util-subtokenize/lib/splice-buffer.js
vendor: 7,612 bytes, lines 9370-9621
9370 9371/** 9372 * Some of the internal operations of micromark do lots of editing 9373 * operations on very large arrays. This runs into problems with two 9374 * properties of most circa-2020 JavaScript interpreters: 9375 * 9376 * - Array-length modifications at the high end of an array (push/pop) are 9377 * expected to be common and are implemented in (amortized) time 9378 * proportional to the number of elements added or removed, whereas 9379 * other operations (shift/unshift and splice) are much less efficient. 9380 * - Function arguments are passed on the stack, so adding tens of thousands 9381 * of elements to an array with `arr.push(...newElements)` will frequently 9382 * cause stack overflows. (see <https://stackoverflow.com/questions/22123769/rangeerror-maximum-call-stack-size-exceeded-why>) 9383 * 9384 * SpliceBuffers are an implementation of gap buffers, which are a 9385 * generalization of the "queue made of two stacks" idea. The splice buffer 9386 * maintains a cursor, and moving the cursor has cost proportional to the 9387 * distance the cursor moves, but inserting, deleting, or splicing in 9388 * new information at the cursor is as efficient as the push/pop operation. 9389 * This allows for an efficient sequence of splices (or pushes, pops, shifts, 9390 * or unshifts) as long such edits happen at the same part of the array or 9391 * generally sweep through the array from the beginning to the end. 9392 * 9393 * The interface for splice buffers also supports large numbers of inputs by 9394 * passing a single array argument rather passing multiple arguments on the 9395 * function call stack. 9396 * 9397 * @template T 9398 * Item type. 9399 */ 9400class SpliceBuffer { 9401 /** 9402 * @param {ReadonlyArray<T> | null | undefined} [initial] 9403 * Initial items (optional). 9404 * @returns 9405 * Splice buffer. 9406 */ 9407 constructor(initial) { 9408 /** @type {Array<T>} */ 9409 this.left = initial ? [...initial] : []; 9410 /** @type {Array<T>} */ 9411 this.right = []; 9412 } 9413 9414 /** 9415 * Array access; 9416 * does not move the cursor. 9417 * 9418 * @param {number} index 9419 * Index. 9420 * @return {T} 9421 * Item. 9422 */ 9423 get(index) { 9424 if (index < 0 || index >= this.left.length + this.right.length) { 9425 throw new RangeError('Cannot access index `' + index + '` in a splice buffer of size `' + (this.left.length + this.right.length) + '`'); 9426 } 9427 if (index < this.left.length) return this.left[index]; 9428 return this.right[this.right.length - index + this.left.length - 1]; 9429 } 9430 9431 /** 9432 * The length of the splice buffer, one greater than the largest index in the 9433 * array. 9434 */ 9435 get length() { 9436 return this.left.length + this.right.length; 9437 } 9438 9439 /** 9440 * Remove and return `list[0]`; 9441 * moves the cursor to `0`. 9442 * 9443 * @returns {T | undefined} 9444 * Item, optional. 9445 */ 9446 shift() { 9447 this.setCursor(0); 9448 return this.right.pop(); 9449 } 9450 9451 /** 9452 * Slice the buffer to get an array; 9453 * does not move the cursor. 9454 * 9455 * @param {number} start 9456 * Start. 9457 * @param {number | null | undefined} [end] 9458 * End (optional). 9459 * @returns {Array<T>} 9460 * Array of items. 9461 */ 9462 slice(start, end) { 9463 /** @type {number} */ 9464 const stop = end === null || end === undefined ? Number.POSITIVE_INFINITY : end; 9465 if (stop < this.left.length) { 9466 return this.left.slice(start, stop); 9467 } 9468 if (start > this.left.length) { 9469 return this.right.slice(this.right.length - stop + this.left.length, this.right.length - start + this.left.length).reverse(); 9470 } 9471 return this.left.slice(start).concat(this.right.slice(this.right.length - stop + this.left.length).reverse()); 9472 } 9473 9474 /** 9475 * Mimics the behavior of Array.prototype.splice() except for the change of 9476 * interface necessary to avoid segfaults when patching in very large arrays. 9477 * 9478 * This operation moves cursor is moved to `start` and results in the cursor 9479 * placed after any inserted items. 9480 * 9481 * @param {number} start 9482 * Start; 9483 * zero-based index at which to start changing the array; 9484 * negative numbers count backwards from the end of the array and values 9485 * that are out-of bounds are clamped to the appropriate end of the array. 9486 * @param {number | null | undefined} [deleteCount=0] 9487 * Delete count (default: `0`); 9488 * maximum number of elements to delete, starting from start. 9489 * @param {Array<T> | null | undefined} [items=[]] 9490 * Items to include in place of the deleted items (default: `[]`). 9491 * @return {Array<T>} 9492 * Any removed items. 9493 */ 9494 splice(start, deleteCount, items) { 9495 /** @type {number} */ 9496 const count = deleteCount || 0; 9497 this.setCursor(Math.trunc(start)); 9498 const removed = this.right.splice(this.right.length - count, Number.POSITIVE_INFINITY); 9499 if (items) chunkedPush(this.left, items); 9500 return removed.reverse(); 9501 } 9502 9503 /** 9504 * Remove and return the highest-numbered item in the array, so 9505 * `list[list.length - 1]`; 9506 * Moves the cursor to `length`. 9507 * 9508 * @returns {T | undefined} 9509 * Item, optional. 9510 */ 9511 pop() { 9512 this.setCursor(Number.POSITIVE_INFINITY); 9513 return this.left.pop(); 9514 } 9515 9516 /** 9517 * Inserts a single item to the high-numbered side of the array; 9518 * moves the cursor to `length`. 9519 * 9520 * @param {T} item 9521 * Item. 9522 * @returns {undefined} 9523 * Nothing. 9524 */ 9525 push(item) { 9526 this.setCursor(Number.POSITIVE_INFINITY); 9527 this.left.push(item); 9528 } 9529 9530 /** 9531 * Inserts many items to the high-numbered side of the array. 9532 * Moves the cursor to `length`. 9533 * 9534 * @param {Array<T>} items 9535 * Items. 9536 * @returns {undefined} 9537 * Nothing. 9538 */ 9539 pushMany(items) { 9540 this.setCursor(Number.POSITIVE_INFINITY); 9541 chunkedPush(this.left, items); 9542 } 9543 9544 /** 9545 * Inserts a single item to the low-numbered side of the array; 9546 * Moves the cursor to `0`. 9547 * 9548 * @param {T} item 9549 * Item. 9550 * @returns {undefined} 9551 * Nothing. 9552 */ 9553 unshift(item) { 9554 this.setCursor(0); 9555 this.right.push(item); 9556 } 9557 9558 /** 9559 * Inserts many items to the low-numbered side of the array; 9560 * moves the cursor to `0`. 9561 * 9562 * @param {Array<T>} items 9563 * Items. 9564 * @returns {undefined} 9565 * Nothing. 9566 */ 9567 unshiftMany(items) { 9568 this.setCursor(0); 9569 chunkedPush(this.right, items.reverse()); 9570 } 9571 9572 /** 9573 * Move the cursor to a specific position in the array. Requires 9574 * time proportional to the distance moved. 9575 * 9576 * If `n < 0`, the cursor will end up at the beginning. 9577 * If `n > length`, the cursor will end up at the end. 9578 * 9579 * @param {number} n 9580 * Position. 9581 * @return {undefined} 9582 * Nothing. 9583 */ 9584 setCursor(n) { 9585 if (n === this.left.length || n > this.left.length && this.right.length === 0 || n < 0 && this.left.length === 0) return; 9586 if (n < this.left.length) { 9587 // Move cursor to the this.left 9588 const removed = this.left.splice(n, Number.POSITIVE_INFINITY); 9589 chunkedPush(this.right, removed.reverse()); 9590 } else { 9591 // Move cursor to the this.right 9592 const removed = this.right.splice(this.left.length + this.right.length - n, Number.POSITIVE_INFINITY); 9593 chunkedPush(this.left, removed.reverse()); 9594 } 9595 } 9596} 9597 9598/** 9599 * Avoid stack overflow by pushing items onto the stack in segments 9600 * 9601 * @template T 9602 * Item type. 9603 * @param {Array<T>} list 9604 * List to inject into. 9605 * @param {ReadonlyArray<T>} right 9606 * Items to inject. 9607 * @return {undefined} 9608 * Nothing. 9609 */ 9610function chunkedPush(list, right) { 9611 /** @type {number} */ 9612 let chunkStart = 0; 9613 if (right.length < 10000) { 9614 list.push(...right); 9615 } else { 9616 while (chunkStart < right.length) { 9617 list.push(...right.slice(chunkStart, chunkStart + 10000)); 9618 chunkStart += 10000; 9619 } 9620 } 9621}
vendor: 4,786 bytes, lines 9622-9787
9622;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-util-subtokenize/index.js 9623/** 9624 * @import {Chunk, Event, Token} from 'micromark-util-types' 9625 */ 9626 9627 9628 9629 9630// Hidden API exposed for testing. 9631 9632 9633/** 9634 * Tokenize subcontent. 9635 * 9636 * @param {Array<Event>} eventsArray 9637 * List of events. 9638 * @returns {boolean} 9639 * Whether subtokens were found. 9640 */ 9641// eslint-disable-next-line complexity 9642function subtokenize(eventsArray) { 9643 /** @type {Record<string, number>} */ 9644 const jumps = {}; 9645 let index = -1; 9646 /** @type {Event} */ 9647 let event; 9648 /** @type {number | undefined} */ 9649 let lineIndex; 9650 /** @type {number} */ 9651 let otherIndex; 9652 /** @type {Event} */ 9653 let otherEvent; 9654 /** @type {Array<Event>} */ 9655 let parameters; 9656 /** @type {Array<Event>} */ 9657 let subevents; 9658 /** @type {boolean | undefined} */ 9659 let more; 9660 const events = new SpliceBuffer(eventsArray); 9661 while (++index < events.length) { 9662 while (index in jumps) { 9663 index = jumps[index]; 9664 } 9665 event = events.get(index); 9666 9667 // Add a hook for the GFM tasklist extension, which needs to know if text 9668 // is in the first content of a list item. 9669 if (index && event[1].type === "chunkFlow" && events.get(index - 1)[1].type === "listItemPrefix") { 9670 subevents = event[1]._tokenizer.events; 9671 otherIndex = 0; 9672 if (otherIndex < subevents.length && subevents[otherIndex][1].type === "lineEndingBlank") { 9673 otherIndex += 2; 9674 } 9675 if (otherIndex < subevents.length && subevents[otherIndex][1].type === "content") { 9676 while (++otherIndex < subevents.length) { 9677 if (subevents[otherIndex][1].type === "content") { 9678 break; 9679 } 9680 if (subevents[otherIndex][1].type === "chunkText") { 9681 subevents[otherIndex][1]._isInFirstContentOfListItem = true; 9682 otherIndex++; 9683 } 9684 } 9685 } 9686 } 9687 9688 // Enter. 9689 if (event[0] === 'enter') { 9690 if (event[1].contentType) { 9691 Object.assign(jumps, subcontent(events, index)); 9692 index = jumps[index]; 9693 more = true; 9694 } 9695 } 9696 // Exit. 9697 else if (event[1]._container) { 9698 otherIndex = index; 9699 lineIndex = undefined; 9700 while (otherIndex--) { 9701 otherEvent = events.get(otherIndex); 9702 if (otherEvent[1].type === "lineEnding" || otherEvent[1].type === "lineEndingBlank") { 9703 if (otherEvent[0] === 'enter') { 9704 if (lineIndex) { 9705 events.get(lineIndex)[1].type = "lineEndingBlank"; 9706 } 9707 otherEvent[1].type = "lineEnding"; 9708 lineIndex = otherIndex; 9709 } 9710 } else if (otherEvent[1].type === "linePrefix" || otherEvent[1].type === "listItemIndent") { 9711 // Move past. 9712 } else { 9713 break; 9714 } 9715 } 9716 if (lineIndex) { 9717 // Fix position. 9718 event[1].end = { 9719 ...events.get(lineIndex)[1].start 9720 }; 9721 9722 // Switch container exit w/ line endings. 9723 parameters = events.slice(lineIndex, index); 9724 parameters.unshift(event); 9725 events.splice(lineIndex, index - lineIndex + 1, parameters); 9726 } 9727 } 9728 } 9729 9730 // The changes to the `events` buffer must be copied back into the eventsArray 9731 splice(eventsArray, 0, Number.POSITIVE_INFINITY, events.slice(0)); 9732 return !more; 9733} 9734 9735/** 9736 * Tokenize embedded tokens. 9737 * 9738 * @param {SpliceBuffer<Event>} events 9739 * Events. 9740 * @param {number} eventIndex 9741 * Index. 9742 * @returns {Record<string, number>} 9743 * Gaps. 9744 */ 9745function subcontent(events, eventIndex) { 9746 const token = events.get(eventIndex)[1]; 9747 const context = events.get(eventIndex)[2]; 9748 let startPosition = eventIndex - 1; 9749 /** @type {Array<number>} */ 9750 const startPositions = []; 9751 let tokenizer = token._tokenizer; 9752 if (!tokenizer) { 9753 tokenizer = context.parser[token.contentType](token.start); 9754 if (token._contentTypeTextTrailing) { 9755 tokenizer._contentTypeTextTrailing = true; 9756 } 9757 } 9758 const childEvents = tokenizer.events; 9759 /** @type {Array<[number, number]>} */ 9760 const jumps = []; 9761 /** @type {Record<string, number>} */ 9762 const gaps = {}; 9763 /** @type {Array<Chunk>} */ 9764 let stream; 9765 /** @type {Token | undefined} */ 9766 let previous; 9767 let index = -1; 9768 /** @type {Token | undefined} */ 9769 let current = token; 9770 let adjust = 0; 9771 let start = 0; 9772 const breaks = [start]; 9773 9774 // Loop forward through the linked tokens to pass them in order to the 9775 // subtokenizer. 9776 while (current) { 9777 // Find the position of the event for this token. 9778 while (events.get(++startPosition)[1] !== current) { 9779 // Empty. 9780 } 9781 startPositions.push(startPosition); 9782 if (!current._tokenizer) { 9783 stream = context.sliceStream(current); 9784 if (!current.next) { 9785 stream.push(null); 9786 } 9787 if (previous) {
vendor: 53,499 bytes, lines 9788-12354
9788 tokenizer.defineSkip(current.start); 9789 } 9790 if (current._isInFirstContentOfListItem) { 9791 tokenizer._gfmTasklistFirstContentOfListItem = true; 9792 } 9793 tokenizer.write(stream); 9794 if (current._isInFirstContentOfListItem) { 9795 tokenizer._gfmTasklistFirstContentOfListItem = undefined; 9796 } 9797 } 9798 9799 // Unravel the next token. 9800 previous = current; 9801 current = current.next; 9802 } 9803 9804 // Now, loop back through all events (and linked tokens), to figure out which 9805 // parts belong where. 9806 current = token; 9807 while (++index < childEvents.length) { 9808 if ( 9809 // Find a void token that includes a break. 9810 childEvents[index][0] === 'exit' && childEvents[index - 1][0] === 'enter' && childEvents[index][1].type === childEvents[index - 1][1].type && childEvents[index][1].start.line !== childEvents[index][1].end.line) { 9811 start = index + 1; 9812 breaks.push(start); 9813 // Help GC. 9814 current._tokenizer = undefined; 9815 current.previous = undefined; 9816 current = current.next; 9817 } 9818 } 9819 9820 // Help GC. 9821 tokenizer.events = []; 9822 9823 // If thereâs one more token (which is the cases for lines that end in an 9824 // EOF), thatâs perfect: the last point we found starts it. 9825 // If there isnât then make sure any remaining content is added to it. 9826 if (current) { 9827 // Help GC. 9828 current._tokenizer = undefined; 9829 current.previous = undefined; 9830 } else { 9831 breaks.pop(); 9832 } 9833 9834 // Now splice the events from the subtokenizer into the current events, 9835 // moving back to front so that splice indices arenât affected. 9836 index = breaks.length; 9837 while (index--) { 9838 const slice = childEvents.slice(breaks[index], breaks[index + 1]); 9839 const start = startPositions.pop(); 9840 jumps.push([start, start + slice.length - 1]); 9841 events.splice(start, 2, slice); 9842 } 9843 jumps.reverse(); 9844 index = -1; 9845 while (++index < jumps.length) { 9846 gaps[adjust + jumps[index][0]] = adjust + jumps[index][1]; 9847 adjust += jumps[index][1] - jumps[index][0] - 1; 9848 } 9849 return gaps; 9850} 9851;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-core-commonmark/lib/content.js 9852/** 9853 * @import { 9854 * Construct, 9855 * Resolver, 9856 * State, 9857 * TokenizeContext, 9858 * Tokenizer, 9859 * Token 9860 * } from 'micromark-util-types' 9861 */ 9862 9863 9864 9865 9866/** 9867 * No name because it must not be turned off. 9868 * @type {Construct} 9869 */ 9870const content_content = { 9871 resolve: resolveContent, 9872 tokenize: tokenizeContent 9873}; 9874 9875/** @type {Construct} */ 9876const continuationConstruct = { 9877 partial: true, 9878 tokenize: tokenizeContinuation 9879}; 9880 9881/** 9882 * Content is transparent: itâs parsed right now. That way, definitions are also 9883 * parsed right now: before text in paragraphs (specifically, media) are parsed. 9884 * 9885 * @type {Resolver} 9886 */ 9887function resolveContent(events) { 9888 subtokenize(events); 9889 return events; 9890} 9891 9892/** 9893 * @this {TokenizeContext} 9894 * Context. 9895 * @type {Tokenizer} 9896 */ 9897function tokenizeContent(effects, ok) { 9898 /** @type {Token | undefined} */ 9899 let previous; 9900 return chunkStart; 9901 9902 /** 9903 * Before a content chunk. 9904 * 9905 * ```markdown 9906 * > | abc 9907 * ^ 9908 * ``` 9909 * 9910 * @type {State} 9911 */ 9912 function chunkStart(code) { 9913 effects.enter("content"); 9914 previous = effects.enter("chunkContent", { 9915 contentType: "content" 9916 }); 9917 return chunkInside(code); 9918 } 9919 9920 /** 9921 * In a content chunk. 9922 * 9923 * ```markdown 9924 * > | abc 9925 * ^^^ 9926 * ``` 9927 * 9928 * @type {State} 9929 */ 9930 function chunkInside(code) { 9931 if (code === null) { 9932 return contentEnd(code); 9933 } 9934 9935 // To do: in `markdown-rs`, each line is parsed on its own, and everything 9936 // is stitched together resolving. 9937 if (markdownLineEnding(code)) { 9938 return effects.check(continuationConstruct, contentContinue, contentEnd)(code); 9939 } 9940 9941 // Data. 9942 effects.consume(code); 9943 return chunkInside; 9944 } 9945 9946 /** 9947 * 9948 * 9949 * @type {State} 9950 */ 9951 function contentEnd(code) { 9952 effects.exit("chunkContent"); 9953 effects.exit("content"); 9954 return ok(code); 9955 } 9956 9957 /** 9958 * 9959 * 9960 * @type {State} 9961 */ 9962 function contentContinue(code) { 9963 effects.consume(code); 9964 effects.exit("chunkContent"); 9965 previous.next = effects.enter("chunkContent", { 9966 contentType: "content", 9967 previous 9968 }); 9969 previous = previous.next; 9970 return chunkInside; 9971 } 9972} 9973 9974/** 9975 * @this {TokenizeContext} 9976 * Context. 9977 * @type {Tokenizer} 9978 */ 9979function tokenizeContinuation(effects, ok, nok) { 9980 const self = this; 9981 return startLookahead; 9982 9983 /** 9984 * 9985 * 9986 * @type {State} 9987 */ 9988 function startLookahead(code) { 9989 effects.exit("chunkContent"); 9990 effects.enter("lineEnding"); 9991 effects.consume(code); 9992 effects.exit("lineEnding"); 9993 return factorySpace(effects, prefixed, "linePrefix"); 9994 } 9995 9996 /** 9997 * 9998 * 9999 * @type {State} 10000 */ 10001 function prefixed(code) { 10002 if (code === null || markdownLineEnding(code)) { 10003 return nok(code); 10004 } 10005 10006 // Always populated by defaults. 10007 10008 const tail = self.events[self.events.length - 1]; 10009 if (!self.parser.constructs.disable.null.includes('codeIndented') && tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], true).length >= 4) { 10010 return ok(code); 10011 } 10012 return effects.interrupt(self.parser.constructs.flow, nok, ok)(code); 10013 } 10014} 10015;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-factory-destination/index.js 10016/** 10017 * @import {Effects, State, TokenType} from 'micromark-util-types' 10018 */ 10019 10020 10021/** 10022 * Parse destinations. 10023 * 10024 * ###### Examples 10025 * 10026 * ```markdown 10027 * <a> 10028 * <a\>b> 10029 * <a b> 10030 * <a)> 10031 * a 10032 * a\)b 10033 * a(b)c 10034 * a(b) 10035 * ``` 10036 * 10037 * @param {Effects} effects 10038 * Context. 10039 * @param {State} ok 10040 * State switched to when successful. 10041 * @param {State} nok 10042 * State switched to when unsuccessful. 10043 * @param {TokenType} type 10044 * Type for whole (`<a>` or `b`). 10045 * @param {TokenType} literalType 10046 * Type when enclosed (`<a>`). 10047 * @param {TokenType} literalMarkerType 10048 * Type for enclosing (`<` and `>`). 10049 * @param {TokenType} rawType 10050 * Type when not enclosed (`b`). 10051 * @param {TokenType} stringType 10052 * Type for the value (`a` or `b`). 10053 * @param {number | undefined} [max=Infinity] 10054 * Depth of nested parens (inclusive). 10055 * @returns {State} 10056 * Start state. 10057 */ 10058function factoryDestination(effects, ok, nok, type, literalType, literalMarkerType, rawType, stringType, max) { 10059 const limit = max || Number.POSITIVE_INFINITY; 10060 let balance = 0; 10061 return start; 10062 10063 /** 10064 * Start of destination. 10065 * 10066 * ```markdown 10067 * > | <aa> 10068 * ^ 10069 * > | aa 10070 * ^ 10071 * ``` 10072 * 10073 * @type {State} 10074 */ 10075 function start(code) { 10076 if (code === 60) { 10077 effects.enter(type); 10078 effects.enter(literalType); 10079 effects.enter(literalMarkerType); 10080 effects.consume(code); 10081 effects.exit(literalMarkerType); 10082 return enclosedBefore; 10083 } 10084 10085 // ASCII control, space, closing paren. 10086 if (code === null || code === 32 || code === 41 || asciiControl(code)) { 10087 return nok(code); 10088 } 10089 effects.enter(type); 10090 effects.enter(rawType); 10091 effects.enter(stringType); 10092 effects.enter("chunkString", { 10093 contentType: "string" 10094 }); 10095 return raw(code); 10096 } 10097 10098 /** 10099 * After `<`, at an enclosed destination. 10100 * 10101 * ```markdown 10102 * > | <aa> 10103 * ^ 10104 * ``` 10105 * 10106 * @type {State} 10107 */ 10108 function enclosedBefore(code) { 10109 if (code === 62) { 10110 effects.enter(literalMarkerType); 10111 effects.consume(code); 10112 effects.exit(literalMarkerType); 10113 effects.exit(literalType); 10114 effects.exit(type); 10115 return ok; 10116 } 10117 effects.enter(stringType); 10118 effects.enter("chunkString", { 10119 contentType: "string" 10120 }); 10121 return enclosed(code); 10122 } 10123 10124 /** 10125 * In enclosed destination. 10126 * 10127 * ```markdown 10128 * > | <aa> 10129 * ^ 10130 * ``` 10131 * 10132 * @type {State} 10133 */ 10134 function enclosed(code) { 10135 if (code === 62) { 10136 effects.exit("chunkString"); 10137 effects.exit(stringType); 10138 return enclosedBefore(code); 10139 } 10140 if (code === null || code === 60 || markdownLineEnding(code)) { 10141 return nok(code); 10142 } 10143 effects.consume(code); 10144 return code === 92 ? enclosedEscape : enclosed; 10145 } 10146 10147 /** 10148 * After `\`, at a special character. 10149 * 10150 * ```markdown 10151 * > | <a\*a> 10152 * ^ 10153 * ``` 10154 * 10155 * @type {State} 10156 */ 10157 function enclosedEscape(code) { 10158 if (code === 60 || code === 62 || code === 92) { 10159 effects.consume(code); 10160 return enclosed; 10161 } 10162 return enclosed(code); 10163 } 10164 10165 /** 10166 * In raw destination. 10167 * 10168 * ```markdown 10169 * > | aa 10170 * ^ 10171 * ``` 10172 * 10173 * @type {State} 10174 */ 10175 function raw(code) { 10176 if (!balance && (code === null || code === 41 || markdownLineEndingOrSpace(code))) { 10177 effects.exit("chunkString"); 10178 effects.exit(stringType); 10179 effects.exit(rawType); 10180 effects.exit(type); 10181 return ok(code); 10182 } 10183 if (balance < limit && code === 40) { 10184 effects.consume(code); 10185 balance++; 10186 return raw; 10187 } 10188 if (code === 41) { 10189 effects.consume(code); 10190 balance--; 10191 return raw; 10192 } 10193 10194 // ASCII control (but *not* `\0`) and space and `(`. 10195 // Note: in `markdown-rs`, `\0` exists in codes, in `micromark-js` it 10196 // doesnât. 10197 if (code === null || code === 32 || code === 40 || asciiControl(code)) { 10198 return nok(code); 10199 } 10200 effects.consume(code); 10201 return code === 92 ? rawEscape : raw; 10202 } 10203 10204 /** 10205 * After `\`, at special character. 10206 * 10207 * ```markdown 10208 * > | a\*a 10209 * ^ 10210 * ``` 10211 * 10212 * @type {State} 10213 */ 10214 function rawEscape(code) { 10215 if (code === 40 || code === 41 || code === 92) { 10216 effects.consume(code); 10217 return raw; 10218 } 10219 return raw(code); 10220 } 10221} 10222;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-factory-label/index.js 10223/** 10224 * @import { 10225 * Effects, 10226 * State, 10227 * TokenizeContext, 10228 * TokenType 10229 * } from 'micromark-util-types' 10230 */ 10231 10232 10233/** 10234 * Parse labels. 10235 * 10236 * > ð **Note**: labels in markdown are capped at 999 characters in the string. 10237 * 10238 * ###### Examples 10239 * 10240 * ```markdown 10241 * [a] 10242 * [a 10243 * b] 10244 * [a\]b] 10245 * ``` 10246 * 10247 * @this {TokenizeContext} 10248 * Tokenize context. 10249 * @param {Effects} effects 10250 * Context. 10251 * @param {State} ok 10252 * State switched to when successful. 10253 * @param {State} nok 10254 * State switched to when unsuccessful. 10255 * @param {TokenType} type 10256 * Type of the whole label (`[a]`). 10257 * @param {TokenType} markerType 10258 * Type for the markers (`[` and `]`). 10259 * @param {TokenType} stringType 10260 * Type for the identifier (`a`). 10261 * @returns {State} 10262 * Start state. 10263 */ 10264function factoryLabel(effects, ok, nok, type, markerType, stringType) { 10265 const self = this; 10266 let size = 0; 10267 /** @type {boolean} */ 10268 let seen; 10269 return start; 10270 10271 /** 10272 * Start of label. 10273 * 10274 * ```markdown 10275 * > | [a] 10276 * ^ 10277 * ``` 10278 * 10279 * @type {State} 10280 */ 10281 function start(code) { 10282 effects.enter(type); 10283 effects.enter(markerType); 10284 effects.consume(code); 10285 effects.exit(markerType); 10286 effects.enter(stringType); 10287 return atBreak; 10288 } 10289 10290 /** 10291 * In label, at something, before something else. 10292 * 10293 * ```markdown 10294 * > | [a] 10295 * ^ 10296 * ``` 10297 * 10298 * @type {State} 10299 */ 10300 function atBreak(code) { 10301 if (size > 999 || code === null || code === 91 || code === 93 && !seen || 10302 // To do: remove in the future once weâve switched from 10303 // `micromark-extension-footnote` to `micromark-extension-gfm-footnote`, 10304 // which doesnât need this. 10305 // Hidden footnotes hook. 10306 /* c8 ignore next 3 */ 10307 code === 94 && !size && '_hiddenFootnoteSupport' in self.parser.constructs) { 10308 return nok(code); 10309 } 10310 if (code === 93) { 10311 effects.exit(stringType); 10312 effects.enter(markerType); 10313 effects.consume(code); 10314 effects.exit(markerType); 10315 effects.exit(type); 10316 return ok; 10317 } 10318 10319 // To do: indent? Link chunks and EOLs together? 10320 if (markdownLineEnding(code)) { 10321 effects.enter("lineEnding"); 10322 effects.consume(code); 10323 effects.exit("lineEnding"); 10324 return atBreak; 10325 } 10326 effects.enter("chunkString", { 10327 contentType: "string" 10328 }); 10329 return labelInside(code); 10330 } 10331 10332 /** 10333 * In label, in text. 10334 * 10335 * ```markdown 10336 * > | [a] 10337 * ^ 10338 * ``` 10339 * 10340 * @type {State} 10341 */ 10342 function labelInside(code) { 10343 if (code === null || code === 91 || code === 93 || markdownLineEnding(code) || size++ > 999) { 10344 effects.exit("chunkString"); 10345 return atBreak(code); 10346 } 10347 effects.consume(code); 10348 if (!seen) seen = !markdownSpace(code); 10349 return code === 92 ? labelEscape : labelInside; 10350 } 10351 10352 /** 10353 * After `\`, at a special character. 10354 * 10355 * ```markdown 10356 * > | [a\*a] 10357 * ^ 10358 * ``` 10359 * 10360 * @type {State} 10361 */ 10362 function labelEscape(code) { 10363 if (code === 91 || code === 92 || code === 93) { 10364 effects.consume(code); 10365 size++; 10366 return labelInside; 10367 } 10368 return labelInside(code); 10369 } 10370} 10371;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-factory-title/index.js 10372/** 10373 * @import { 10374 * Code, 10375 * Effects, 10376 * State, 10377 * TokenType 10378 * } from 'micromark-util-types' 10379 */ 10380 10381 10382 10383/** 10384 * Parse titles. 10385 * 10386 * ###### Examples 10387 * 10388 * ```markdown 10389 * "a" 10390 * 'b' 10391 * (c) 10392 * "a 10393 * b" 10394 * 'a 10395 * b' 10396 * (a\)b) 10397 * ``` 10398 * 10399 * @param {Effects} effects 10400 * Context. 10401 * @param {State} ok 10402 * State switched to when successful. 10403 * @param {State} nok 10404 * State switched to when unsuccessful. 10405 * @param {TokenType} type 10406 * Type of the whole title (`"a"`, `'b'`, `(c)`). 10407 * @param {TokenType} markerType 10408 * Type for the markers (`"`, `'`, `(`, and `)`). 10409 * @param {TokenType} stringType 10410 * Type for the value (`a`). 10411 * @returns {State} 10412 * Start state. 10413 */ 10414function factoryTitle(effects, ok, nok, type, markerType, stringType) { 10415 /** @type {NonNullable<Code>} */ 10416 let marker; 10417 return start; 10418 10419 /** 10420 * Start of title. 10421 * 10422 * ```markdown 10423 * > | "a" 10424 * ^ 10425 * ``` 10426 * 10427 * @type {State} 10428 */ 10429 function start(code) { 10430 if (code === 34 || code === 39 || code === 40) { 10431 effects.enter(type); 10432 effects.enter(markerType); 10433 effects.consume(code); 10434 effects.exit(markerType); 10435 marker = code === 40 ? 41 : code; 10436 return begin; 10437 } 10438 return nok(code); 10439 } 10440 10441 /** 10442 * After opening marker. 10443 * 10444 * This is also used at the closing marker. 10445 * 10446 * ```markdown 10447 * > | "a" 10448 * ^ 10449 * ``` 10450 * 10451 * @type {State} 10452 */ 10453 function begin(code) { 10454 if (code === marker) { 10455 effects.enter(markerType); 10456 effects.consume(code); 10457 effects.exit(markerType); 10458 effects.exit(type); 10459 return ok; 10460 } 10461 effects.enter(stringType); 10462 return atBreak(code); 10463 } 10464 10465 /** 10466 * At something, before something else. 10467 * 10468 * ```markdown 10469 * > | "a" 10470 * ^ 10471 * ``` 10472 * 10473 * @type {State} 10474 */ 10475 function atBreak(code) { 10476 if (code === marker) { 10477 effects.exit(stringType); 10478 return begin(marker); 10479 } 10480 if (code === null) { 10481 return nok(code); 10482 } 10483 10484 // Note: blank lines canât exist in content. 10485 if (markdownLineEnding(code)) { 10486 // To do: use `space_or_tab_eol_with_options`, connect. 10487 effects.enter("lineEnding"); 10488 effects.consume(code); 10489 effects.exit("lineEnding"); 10490 return factorySpace(effects, atBreak, "linePrefix"); 10491 } 10492 effects.enter("chunkString", { 10493 contentType: "string" 10494 }); 10495 return inside(code); 10496 } 10497 10498 /** 10499 * 10500 * 10501 * @type {State} 10502 */ 10503 function inside(code) { 10504 if (code === marker || code === null || markdownLineEnding(code)) { 10505 effects.exit("chunkString"); 10506 return atBreak(code); 10507 } 10508 effects.consume(code); 10509 return code === 92 ? escape : inside; 10510 } 10511 10512 /** 10513 * After `\`, at a special character. 10514 * 10515 * ```markdown 10516 * > | "a\*b" 10517 * ^ 10518 * ``` 10519 * 10520 * @type {State} 10521 */ 10522 function escape(code) { 10523 if (code === marker || code === 92) { 10524 effects.consume(code); 10525 return inside; 10526 } 10527 return inside(code); 10528 } 10529} 10530;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-factory-whitespace/index.js 10531/** 10532 * @import {Effects, State} from 'micromark-util-types' 10533 */ 10534 10535 10536 10537/** 10538 * Parse spaces and tabs. 10539 * 10540 * There is no `nok` parameter: 10541 * 10542 * * line endings or spaces in markdown are often optional, in which case this 10543 * factory can be used and `ok` will be switched to whether spaces were found 10544 * or not 10545 * * one line ending or space can be detected with 10546 * `markdownLineEndingOrSpace(code)` right before using `factoryWhitespace` 10547 * 10548 * @param {Effects} effects 10549 * Context. 10550 * @param {State} ok 10551 * State switched to when successful. 10552 * @returns {State} 10553 * Start state. 10554 */ 10555function factoryWhitespace(effects, ok) { 10556 /** @type {boolean} */ 10557 let seen; 10558 return start; 10559 10560 /** @type {State} */ 10561 function start(code) { 10562 if (markdownLineEnding(code)) { 10563 effects.enter("lineEnding"); 10564 effects.consume(code); 10565 effects.exit("lineEnding"); 10566 seen = true; 10567 return start; 10568 } 10569 if (markdownSpace(code)) { 10570 return factorySpace(effects, start, seen ? "linePrefix" : "lineSuffix")(code); 10571 } 10572 return ok(code); 10573 } 10574} 10575;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-core-commonmark/lib/definition.js 10576/** 10577 * @import { 10578 * Construct, 10579 * State, 10580 * TokenizeContext, 10581 * Tokenizer 10582 * } from 'micromark-util-types' 10583 */ 10584 10585 10586 10587 10588 10589 10590 10591 10592/** @type {Construct} */ 10593const definition = { 10594 name: 'definition', 10595 tokenize: tokenizeDefinition 10596}; 10597 10598/** @type {Construct} */ 10599const titleBefore = { 10600 partial: true, 10601 tokenize: tokenizeTitleBefore 10602}; 10603 10604/** 10605 * @this {TokenizeContext} 10606 * Context. 10607 * @type {Tokenizer} 10608 */ 10609function tokenizeDefinition(effects, ok, nok) { 10610 const self = this; 10611 /** @type {string} */ 10612 let identifier; 10613 return start; 10614 10615 /** 10616 * At start of a definition. 10617 * 10618 * ```markdown 10619 * > | [a]: b "c" 10620 * ^ 10621 * ``` 10622 * 10623 * @type {State} 10624 */ 10625 function start(code) { 10626 // Do not interrupt paragraphs (but do follow definitions). 10627 // To do: do `interrupt` the way `markdown-rs` does. 10628 // To do: parse whitespace the way `markdown-rs` does. 10629 effects.enter("definition"); 10630 return before(code); 10631 } 10632 10633 /** 10634 * After optional whitespace, at `[`. 10635 * 10636 * ```markdown 10637 * > | [a]: b "c" 10638 * ^ 10639 * ``` 10640 * 10641 * @type {State} 10642 */ 10643 function before(code) { 10644 // To do: parse whitespace the way `markdown-rs` does. 10645 10646 return factoryLabel.call(self, effects, labelAfter, 10647 // Note: we donât need to reset the way `markdown-rs` does. 10648 nok, "definitionLabel", "definitionLabelMarker", "definitionLabelString")(code); 10649 } 10650 10651 /** 10652 * After label. 10653 * 10654 * ```markdown 10655 * > | [a]: b "c" 10656 * ^ 10657 * ``` 10658 * 10659 * @type {State} 10660 */ 10661 function labelAfter(code) { 10662 identifier = micromark_util_normalize_identifier_normalizeIdentifier(self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1)); 10663 if (code === 58) { 10664 effects.enter("definitionMarker"); 10665 effects.consume(code); 10666 effects.exit("definitionMarker"); 10667 return markerAfter; 10668 } 10669 return nok(code); 10670 } 10671 10672 /** 10673 * After marker. 10674 * 10675 * ```markdown 10676 * > | [a]: b "c" 10677 * ^ 10678 * ``` 10679 * 10680 * @type {State} 10681 */ 10682 function markerAfter(code) { 10683 // Note: whitespace is optional. 10684 return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, destinationBefore)(code) : destinationBefore(code); 10685 } 10686 10687 /** 10688 * Before destination. 10689 * 10690 * ```markdown 10691 * > | [a]: b "c" 10692 * ^ 10693 * ``` 10694 * 10695 * @type {State} 10696 */ 10697 function destinationBefore(code) { 10698 return factoryDestination(effects, destinationAfter, 10699 // Note: we donât need to reset the way `markdown-rs` does. 10700 nok, "definitionDestination", "definitionDestinationLiteral", "definitionDestinationLiteralMarker", "definitionDestinationRaw", "definitionDestinationString")(code); 10701 } 10702 10703 /** 10704 * After destination. 10705 * 10706 * ```markdown 10707 * > | [a]: b "c" 10708 * ^ 10709 * ``` 10710 * 10711 * @type {State} 10712 */ 10713 function destinationAfter(code) { 10714 return effects.attempt(titleBefore, after, after)(code); 10715 } 10716 10717 /** 10718 * After definition. 10719 * 10720 * ```markdown 10721 * > | [a]: b 10722 * ^ 10723 * > | [a]: b "c" 10724 * ^ 10725 * ``` 10726 * 10727 * @type {State} 10728 */ 10729 function after(code) { 10730 return markdownSpace(code) ? factorySpace(effects, afterWhitespace, "whitespace")(code) : afterWhitespace(code); 10731 } 10732 10733 /** 10734 * After definition, after optional whitespace. 10735 * 10736 * ```markdown 10737 * > | [a]: b 10738 * ^ 10739 * > | [a]: b "c" 10740 * ^ 10741 * ``` 10742 * 10743 * @type {State} 10744 */ 10745 function afterWhitespace(code) { 10746 if (code === null || markdownLineEnding(code)) { 10747 effects.exit("definition"); 10748 10749 // Note: we donât care about uniqueness. 10750 // Itâs likely that that doesnât happen very frequently. 10751 // It is more likely that it wastes precious time. 10752 self.parser.defined.push(identifier); 10753 10754 // To do: `markdown-rs` interrupt. 10755 // // Youâd be interrupting. 10756 // tokenizer.interrupt = true 10757 return ok(code); 10758 } 10759 return nok(code); 10760 } 10761} 10762 10763/** 10764 * @this {TokenizeContext} 10765 * Context. 10766 * @type {Tokenizer} 10767 */ 10768function tokenizeTitleBefore(effects, ok, nok) { 10769 return titleBefore; 10770 10771 /** 10772 * After destination, at whitespace. 10773 * 10774 * ```markdown 10775 * > | [a]: b 10776 * ^ 10777 * > | [a]: b "c" 10778 * ^ 10779 * ``` 10780 * 10781 * @type {State} 10782 */ 10783 function titleBefore(code) { 10784 return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, beforeMarker)(code) : nok(code); 10785 } 10786 10787 /** 10788 * At title. 10789 * 10790 * ```markdown 10791 * | [a]: b 10792 * > | "c" 10793 * ^ 10794 * ``` 10795 * 10796 * @type {State} 10797 */ 10798 function beforeMarker(code) { 10799 return factoryTitle(effects, titleAfter, nok, "definitionTitle", "definitionTitleMarker", "definitionTitleString")(code); 10800 } 10801 10802 /** 10803 * After title. 10804 * 10805 * ```markdown 10806 * > | [a]: b "c" 10807 * ^ 10808 * ``` 10809 * 10810 * @type {State} 10811 */ 10812 function titleAfter(code) { 10813 return markdownSpace(code) ? factorySpace(effects, titleAfterOptionalWhitespace, "whitespace")(code) : titleAfterOptionalWhitespace(code); 10814 } 10815 10816 /** 10817 * After title, after optional whitespace. 10818 * 10819 * ```markdown 10820 * > | [a]: b "c" 10821 * ^ 10822 * ``` 10823 * 10824 * @type {State} 10825 */ 10826 function titleAfterOptionalWhitespace(code) { 10827 return code === null || markdownLineEnding(code) ? ok(code) : nok(code); 10828 } 10829} 10830;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-core-commonmark/lib/hard-break-escape.js 10831/** 10832 * @import { 10833 * Construct, 10834 * State, 10835 * TokenizeContext, 10836 * Tokenizer 10837 * } from 'micromark-util-types' 10838 */ 10839 10840 10841/** @type {Construct} */ 10842const hardBreakEscape = { 10843 name: 'hardBreakEscape', 10844 tokenize: tokenizeHardBreakEscape 10845}; 10846 10847/** 10848 * @this {TokenizeContext} 10849 * Context. 10850 * @type {Tokenizer} 10851 */ 10852function tokenizeHardBreakEscape(effects, ok, nok) { 10853 return start; 10854 10855 /** 10856 * Start of a hard break (escape). 10857 * 10858 * ```markdown 10859 * > | a\ 10860 * ^ 10861 * | b 10862 * ``` 10863 * 10864 * @type {State} 10865 */ 10866 function start(code) { 10867 effects.enter("hardBreakEscape"); 10868 effects.consume(code); 10869 return after; 10870 } 10871 10872 /** 10873 * After `\`, at eol. 10874 * 10875 * ```markdown 10876 * > | a\ 10877 * ^ 10878 * | b 10879 * ``` 10880 * 10881 * @type {State} 10882 */ 10883 function after(code) { 10884 if (markdownLineEnding(code)) { 10885 effects.exit("hardBreakEscape"); 10886 return ok(code); 10887 } 10888 return nok(code); 10889 } 10890} 10891;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-core-commonmark/lib/heading-atx.js 10892/** 10893 * @import { 10894 * Construct, 10895 * Resolver, 10896 * State, 10897 * TokenizeContext, 10898 * Tokenizer, 10899 * Token 10900 * } from 'micromark-util-types' 10901 */ 10902 10903 10904 10905 10906/** @type {Construct} */ 10907const headingAtx = { 10908 name: 'headingAtx', 10909 resolve: resolveHeadingAtx, 10910 tokenize: tokenizeHeadingAtx 10911}; 10912 10913/** @type {Resolver} */ 10914function resolveHeadingAtx(events, context) { 10915 let contentEnd = events.length - 2; 10916 let contentStart = 3; 10917 /** @type {Token} */ 10918 let content; 10919 /** @type {Token} */ 10920 let text; 10921 10922 // Prefix whitespace, part of the opening. 10923 if (events[contentStart][1].type === "whitespace") { 10924 contentStart += 2; 10925 } 10926 10927 // Suffix whitespace, part of the closing. 10928 if (contentEnd - 2 > contentStart && events[contentEnd][1].type === "whitespace") { 10929 contentEnd -= 2; 10930 } 10931 if (events[contentEnd][1].type === "atxHeadingSequence" && (contentStart === contentEnd - 1 || contentEnd - 4 > contentStart && events[contentEnd - 2][1].type === "whitespace")) { 10932 contentEnd -= contentStart + 1 === contentEnd ? 2 : 4; 10933 } 10934 if (contentEnd > contentStart) { 10935 content = { 10936 type: "atxHeadingText", 10937 start: events[contentStart][1].start, 10938 end: events[contentEnd][1].end 10939 }; 10940 text = { 10941 type: "chunkText", 10942 start: events[contentStart][1].start, 10943 end: events[contentEnd][1].end, 10944 contentType: "text" 10945 }; 10946 splice(events, contentStart, contentEnd - contentStart + 1, [['enter', content, context], ['enter', text, context], ['exit', text, context], ['exit', content, context]]); 10947 } 10948 return events; 10949} 10950 10951/** 10952 * @this {TokenizeContext} 10953 * Context. 10954 * @type {Tokenizer} 10955 */ 10956function tokenizeHeadingAtx(effects, ok, nok) { 10957 let size = 0; 10958 return start; 10959 10960 /** 10961 * Start of a heading (atx). 10962 * 10963 * ```markdown 10964 * > | ## aa 10965 * ^ 10966 * ``` 10967 * 10968 * @type {State} 10969 */ 10970 function start(code) { 10971 // To do: parse indent like `markdown-rs`. 10972 effects.enter("atxHeading"); 10973 return before(code); 10974 } 10975 10976 /** 10977 * After optional whitespace, at `#`. 10978 * 10979 * ```markdown 10980 * > | ## aa 10981 * ^ 10982 * ``` 10983 * 10984 * @type {State} 10985 */ 10986 function before(code) { 10987 effects.enter("atxHeadingSequence"); 10988 return sequenceOpen(code); 10989 } 10990 10991 /** 10992 * In opening sequence. 10993 * 10994 * ```markdown 10995 * > | ## aa 10996 * ^ 10997 * ``` 10998 * 10999 * @type {State} 11000 */ 11001 function sequenceOpen(code) { 11002 if (code === 35 && size++ < 6) { 11003 effects.consume(code); 11004 return sequenceOpen; 11005 } 11006 11007 // Always at least one `#`. 11008 if (code === null || markdownLineEndingOrSpace(code)) { 11009 effects.exit("atxHeadingSequence"); 11010 return atBreak(code); 11011 } 11012 return nok(code); 11013 } 11014 11015 /** 11016 * After something, before something else. 11017 * 11018 * ```markdown 11019 * > | ## aa 11020 * ^ 11021 * ``` 11022 * 11023 * @type {State} 11024 */ 11025 function atBreak(code) { 11026 if (code === 35) { 11027 effects.enter("atxHeadingSequence"); 11028 return sequenceFurther(code); 11029 } 11030 if (code === null || markdownLineEnding(code)) { 11031 effects.exit("atxHeading"); 11032 // To do: interrupt like `markdown-rs`. 11033 // // Feel free to interrupt. 11034 // tokenizer.interrupt = false 11035 return ok(code); 11036 } 11037 if (markdownSpace(code)) { 11038 return factorySpace(effects, atBreak, "whitespace")(code); 11039 } 11040 11041 // To do: generate `data` tokens, add the `text` token later. 11042 // Needs edit map, see: `markdown.rs`. 11043 effects.enter("atxHeadingText"); 11044 return data(code); 11045 } 11046 11047 /** 11048 * In further sequence (after whitespace). 11049 * 11050 * Could be normal âvisibleâ hashes in the heading or a final sequence. 11051 * 11052 * ```markdown 11053 * > | ## aa ## 11054 * ^ 11055 * ``` 11056 * 11057 * @type {State} 11058 */ 11059 function sequenceFurther(code) { 11060 if (code === 35) { 11061 effects.consume(code); 11062 return sequenceFurther; 11063 } 11064 effects.exit("atxHeadingSequence"); 11065 return atBreak(code); 11066 } 11067 11068 /** 11069 * In text. 11070 * 11071 * ```markdown 11072 * > | ## aa 11073 * ^ 11074 * ``` 11075 * 11076 * @type {State} 11077 */ 11078 function data(code) { 11079 if (code === null || code === 35 || markdownLineEndingOrSpace(code)) { 11080 effects.exit("atxHeadingText"); 11081 return atBreak(code); 11082 } 11083 effects.consume(code); 11084 return data; 11085 } 11086} 11087;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-util-html-tag-name/index.js 11088/** 11089 * List of lowercase HTML âblockâ tag names. 11090 * 11091 * The list, when parsing HTML (flow), results in more relaxed rules (condition 11092 * 6). 11093 * Because they are known blocks, the HTML-like syntax doesnât have to be 11094 * strictly parsed. 11095 * For tag names not in this list, a more strict algorithm (condition 7) is used 11096 * to detect whether the HTML-like syntax is seen as HTML (flow) or not. 11097 * 11098 * This is copied from: 11099 * <https://spec.commonmark.org/0.30/#html-blocks>. 11100 * 11101 * > ð **Note**: `search` was added in `[email protected]`. 11102 */ 11103const htmlBlockNames = [ 11104 'address', 11105 'article', 11106 'aside', 11107 'base', 11108 'basefont', 11109 'blockquote', 11110 'body', 11111 'caption', 11112 'center', 11113 'col', 11114 'colgroup', 11115 'dd', 11116 'details', 11117 'dialog', 11118 'dir', 11119 'div', 11120 'dl', 11121 'dt', 11122 'fieldset', 11123 'figcaption', 11124 'figure', 11125 'footer', 11126 'form', 11127 'frame', 11128 'frameset', 11129 'h1', 11130 'h2', 11131 'h3', 11132 'h4', 11133 'h5', 11134 'h6', 11135 'head', 11136 'header', 11137 'hr', 11138 'html', 11139 'iframe', 11140 'legend', 11141 'li', 11142 'link', 11143 'main', 11144 'menu', 11145 'menuitem', 11146 'nav', 11147 'noframes', 11148 'ol', 11149 'optgroup', 11150 'option', 11151 'p', 11152 'param', 11153 'search', 11154 'section', 11155 'summary', 11156 'table', 11157 'tbody', 11158 'td', 11159 'tfoot', 11160 'th', 11161 'thead', 11162 'title', 11163 'tr', 11164 'track', 11165 'ul' 11166] 11167 11168/** 11169 * List of lowercase HTML ârawâ tag names. 11170 * 11171 * The list, when parsing HTML (flow), results in HTML that can include lines 11172 * without exiting, until a closing tag also in this list is found (condition 11173 * 1). 11174 * 11175 * This module is copied from: 11176 * <https://spec.commonmark.org/0.30/#html-blocks>. 11177 * 11178 * > ð **Note**: `textarea` was added in `[email protected]`. 11179 */ 11180const htmlRawNames = ['pre', 'script', 'style', 'textarea'] 11181 11182;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-core-commonmark/lib/html-flow.js 11183/** 11184 * @import { 11185 * Code, 11186 * Construct, 11187 * Resolver, 11188 * State, 11189 * TokenizeContext, 11190 * Tokenizer 11191 * } from 'micromark-util-types' 11192 */ 11193 11194 11195 11196 11197 11198/** @type {Construct} */ 11199const htmlFlow = { 11200 concrete: true, 11201 name: 'htmlFlow', 11202 resolveTo: resolveToHtmlFlow, 11203 tokenize: tokenizeHtmlFlow 11204}; 11205 11206/** @type {Construct} */ 11207const blankLineBefore = { 11208 partial: true, 11209 tokenize: tokenizeBlankLineBefore 11210}; 11211const nonLazyContinuationStart = { 11212 partial: true, 11213 tokenize: tokenizeNonLazyContinuationStart 11214}; 11215 11216/** @type {Resolver} */ 11217function resolveToHtmlFlow(events) { 11218 let index = events.length; 11219 while (index--) { 11220 if (events[index][0] === 'enter' && events[index][1].type === "htmlFlow") { 11221 break; 11222 } 11223 } 11224 if (index > 1 && events[index - 2][1].type === "linePrefix") { 11225 // Add the prefix start to the HTML token. 11226 events[index][1].start = events[index - 2][1].start; 11227 // Add the prefix start to the HTML line token. 11228 events[index + 1][1].start = events[index - 2][1].start; 11229 // Remove the line prefix. 11230 events.splice(index - 2, 2); 11231 } 11232 return events; 11233} 11234 11235/** 11236 * @this {TokenizeContext} 11237 * Context. 11238 * @type {Tokenizer} 11239 */ 11240function tokenizeHtmlFlow(effects, ok, nok) { 11241 const self = this; 11242 /** @type {number} */ 11243 let marker; 11244 /** @type {boolean} */ 11245 let closingTag; 11246 /** @type {string} */ 11247 let buffer; 11248 /** @type {number} */ 11249 let index; 11250 /** @type {Code} */ 11251 let markerB; 11252 return start; 11253 11254 /** 11255 * Start of HTML (flow). 11256 * 11257 * ```markdown 11258 * > | <x /> 11259 * ^ 11260 * ``` 11261 * 11262 * @type {State} 11263 */ 11264 function start(code) { 11265 // To do: parse indent like `markdown-rs`. 11266 return before(code); 11267 } 11268 11269 /** 11270 * At `<`, after optional whitespace. 11271 * 11272 * ```markdown 11273 * > | <x /> 11274 * ^ 11275 * ``` 11276 * 11277 * @type {State} 11278 */ 11279 function before(code) { 11280 effects.enter("htmlFlow"); 11281 effects.enter("htmlFlowData"); 11282 effects.consume(code); 11283 return open; 11284 } 11285 11286 /** 11287 * After `<`, at tag name or other stuff. 11288 * 11289 * ```markdown 11290 * > | <x /> 11291 * ^ 11292 * > | <!doctype> 11293 * ^ 11294 * > | <!--xxx--> 11295 * ^ 11296 * ``` 11297 * 11298 * @type {State} 11299 */ 11300 function open(code) { 11301 if (code === 33) { 11302 effects.consume(code); 11303 return declarationOpen; 11304 } 11305 if (code === 47) { 11306 effects.consume(code); 11307 closingTag = true; 11308 return tagCloseStart; 11309 } 11310 if (code === 63) { 11311 effects.consume(code); 11312 marker = 3; 11313 // To do: 11314 // tokenizer.concrete = true 11315 // To do: use `markdown-rs` style interrupt. 11316 // While weâre in an instruction instead of a declaration, weâre on a `?` 11317 // right now, so we do need to search for `>`, similar to declarations. 11318 return self.interrupt ? ok : continuationDeclarationInside; 11319 } 11320 11321 // ASCII alphabetical. 11322 if (asciiAlpha(code)) { 11323 // Always the case. 11324 effects.consume(code); 11325 buffer = String.fromCharCode(code); 11326 return tagName; 11327 } 11328 return nok(code); 11329 } 11330 11331 /** 11332 * After `<!`, at declaration, comment, or CDATA. 11333 * 11334 * ```markdown 11335 * > | <!doctype> 11336 * ^ 11337 * > | <!--xxx--> 11338 * ^ 11339 * > | <![CDATA[>&<]]> 11340 * ^ 11341 * ``` 11342 * 11343 * @type {State} 11344 */ 11345 function declarationOpen(code) { 11346 if (code === 45) { 11347 effects.consume(code); 11348 marker = 2; 11349 return commentOpenInside; 11350 } 11351 if (code === 91) { 11352 effects.consume(code); 11353 marker = 5; 11354 index = 0; 11355 return cdataOpenInside; 11356 } 11357 11358 // ASCII alphabetical. 11359 if (asciiAlpha(code)) { 11360 effects.consume(code); 11361 marker = 4; 11362 // // Do not form containers. 11363 // tokenizer.concrete = true 11364 return self.interrupt ? ok : continuationDeclarationInside; 11365 } 11366 return nok(code); 11367 } 11368 11369 /** 11370 * After `<!-`, inside a comment, at another `-`. 11371 * 11372 * ```markdown 11373 * > | <!--xxx--> 11374 * ^ 11375 * ``` 11376 * 11377 * @type {State} 11378 */ 11379 function commentOpenInside(code) { 11380 if (code === 45) { 11381 effects.consume(code); 11382 // // Do not form containers. 11383 // tokenizer.concrete = true 11384 return self.interrupt ? ok : continuationDeclarationInside; 11385 } 11386 return nok(code); 11387 } 11388 11389 /** 11390 * After `<![`, inside CDATA, expecting `CDATA[`. 11391 * 11392 * ```markdown 11393 * > | <![CDATA[>&<]]> 11394 * ^^^^^^ 11395 * ``` 11396 * 11397 * @type {State} 11398 */ 11399 function cdataOpenInside(code) { 11400 const value = "CDATA["; 11401 if (code === value.charCodeAt(index++)) { 11402 effects.consume(code); 11403 if (index === value.length) { 11404 // // Do not form containers. 11405 // tokenizer.concrete = true 11406 return self.interrupt ? ok : continuation; 11407 } 11408 return cdataOpenInside; 11409 } 11410 return nok(code); 11411 } 11412 11413 /** 11414 * After `</`, in closing tag, at tag name. 11415 * 11416 * ```markdown 11417 * > | </x> 11418 * ^ 11419 * ``` 11420 * 11421 * @type {State} 11422 */ 11423 function tagCloseStart(code) { 11424 if (asciiAlpha(code)) { 11425 // Always the case. 11426 effects.consume(code); 11427 buffer = String.fromCharCode(code); 11428 return tagName; 11429 } 11430 return nok(code); 11431 } 11432 11433 /** 11434 * In tag name. 11435 * 11436 * ```markdown 11437 * > | <ab> 11438 * ^^ 11439 * > | </ab> 11440 * ^^ 11441 * ``` 11442 * 11443 * @type {State} 11444 */ 11445 function tagName(code) { 11446 if (code === null || code === 47 || code === 62 || markdownLineEndingOrSpace(code)) { 11447 const slash = code === 47; 11448 const name = buffer.toLowerCase(); 11449 if (!slash && !closingTag && htmlRawNames.includes(name)) { 11450 marker = 1; 11451 // // Do not form containers. 11452 // tokenizer.concrete = true 11453 return self.interrupt ? ok(code) : continuation(code); 11454 } 11455 if (htmlBlockNames.includes(buffer.toLowerCase())) { 11456 marker = 6; 11457 if (slash) { 11458 effects.consume(code); 11459 return basicSelfClosing; 11460 } 11461 11462 // // Do not form containers. 11463 // tokenizer.concrete = true 11464 return self.interrupt ? ok(code) : continuation(code); 11465 } 11466 marker = 7; 11467 // Do not support complete HTML when interrupting. 11468 return self.interrupt && !self.parser.lazy[self.now().line] ? nok(code) : closingTag ? completeClosingTagAfter(code) : completeAttributeNameBefore(code); 11469 } 11470 11471 // ASCII alphanumerical and `-`. 11472 if (code === 45 || asciiAlphanumeric(code)) { 11473 effects.consume(code); 11474 buffer += String.fromCharCode(code); 11475 return tagName; 11476 } 11477 return nok(code); 11478 } 11479 11480 /** 11481 * After closing slash of a basic tag name. 11482 * 11483 * ```markdown 11484 * > | <div/> 11485 * ^ 11486 * ``` 11487 * 11488 * @type {State} 11489 */ 11490 function basicSelfClosing(code) { 11491 if (code === 62) { 11492 effects.consume(code); 11493 // // Do not form containers. 11494 // tokenizer.concrete = true 11495 return self.interrupt ? ok : continuation; 11496 } 11497 return nok(code); 11498 } 11499 11500 /** 11501 * After closing slash of a complete tag name. 11502 * 11503 * ```markdown 11504 * > | <x/> 11505 * ^ 11506 * ``` 11507 * 11508 * @type {State} 11509 */ 11510 function completeClosingTagAfter(code) { 11511 if (markdownSpace(code)) { 11512 effects.consume(code); 11513 return completeClosingTagAfter; 11514 } 11515 return completeEnd(code); 11516 } 11517 11518 /** 11519 * At an attribute name. 11520 * 11521 * At first, this state is used after a complete tag name, after whitespace, 11522 * where it expects optional attributes or the end of the tag. 11523 * It is also reused after attributes, when expecting more optional 11524 * attributes. 11525 * 11526 * ```markdown 11527 * > | <a /> 11528 * ^ 11529 * > | <a :b> 11530 * ^ 11531 * > | <a _b> 11532 * ^ 11533 * > | <a b> 11534 * ^ 11535 * > | <a > 11536 * ^ 11537 * ``` 11538 * 11539 * @type {State} 11540 */ 11541 function completeAttributeNameBefore(code) { 11542 if (code === 47) { 11543 effects.consume(code); 11544 return completeEnd; 11545 } 11546 11547 // ASCII alphanumerical and `:` and `_`. 11548 if (code === 58 || code === 95 || asciiAlpha(code)) { 11549 effects.consume(code); 11550 return completeAttributeName; 11551 } 11552 if (markdownSpace(code)) { 11553 effects.consume(code); 11554 return completeAttributeNameBefore; 11555 } 11556 return completeEnd(code); 11557 } 11558 11559 /** 11560 * In attribute name. 11561 * 11562 * ```markdown 11563 * > | <a :b> 11564 * ^ 11565 * > | <a _b> 11566 * ^ 11567 * > | <a b> 11568 * ^ 11569 * ``` 11570 * 11571 * @type {State} 11572 */ 11573 function completeAttributeName(code) { 11574 // ASCII alphanumerical and `-`, `.`, `:`, and `_`. 11575 if (code === 45 || code === 46 || code === 58 || code === 95 || asciiAlphanumeric(code)) { 11576 effects.consume(code); 11577 return completeAttributeName; 11578 } 11579 return completeAttributeNameAfter(code); 11580 } 11581 11582 /** 11583 * After attribute name, at an optional initializer, the end of the tag, or 11584 * whitespace. 11585 * 11586 * ```markdown 11587 * > | <a b> 11588 * ^ 11589 * > | <a b=c> 11590 * ^ 11591 * ``` 11592 * 11593 * @type {State} 11594 */ 11595 function completeAttributeNameAfter(code) { 11596 if (code === 61) { 11597 effects.consume(code); 11598 return completeAttributeValueBefore; 11599 } 11600 if (markdownSpace(code)) { 11601 effects.consume(code); 11602 return completeAttributeNameAfter; 11603 } 11604 return completeAttributeNameBefore(code); 11605 } 11606 11607 /** 11608 * Before unquoted, double quoted, or single quoted attribute value, allowing 11609 * whitespace. 11610 * 11611 * ```markdown 11612 * > | <a b=c> 11613 * ^ 11614 * > | <a b="c"> 11615 * ^ 11616 * ``` 11617 * 11618 * @type {State} 11619 */ 11620 function completeAttributeValueBefore(code) { 11621 if (code === null || code === 60 || code === 61 || code === 62 || code === 96) { 11622 return nok(code); 11623 } 11624 if (code === 34 || code === 39) { 11625 effects.consume(code); 11626 markerB = code; 11627 return completeAttributeValueQuoted; 11628 } 11629 if (markdownSpace(code)) { 11630 effects.consume(code); 11631 return completeAttributeValueBefore; 11632 } 11633 return completeAttributeValueUnquoted(code); 11634 } 11635 11636 /** 11637 * In double or single quoted attribute value. 11638 * 11639 * ```markdown 11640 * > | <a b="c"> 11641 * ^ 11642 * > | <a b='c'> 11643 * ^ 11644 * ``` 11645 * 11646 * @type {State} 11647 */ 11648 function completeAttributeValueQuoted(code) { 11649 if (code === markerB) { 11650 effects.consume(code); 11651 markerB = null; 11652 return completeAttributeValueQuotedAfter; 11653 } 11654 if (code === null || markdownLineEnding(code)) { 11655 return nok(code); 11656 } 11657 effects.consume(code); 11658 return completeAttributeValueQuoted; 11659 } 11660 11661 /** 11662 * In unquoted attribute value. 11663 * 11664 * ```markdown 11665 * > | <a b=c> 11666 * ^ 11667 * ``` 11668 * 11669 * @type {State} 11670 */ 11671 function completeAttributeValueUnquoted(code) { 11672 if (code === null || code === 34 || code === 39 || code === 47 || code === 60 || code === 61 || code === 62 || code === 96 || markdownLineEndingOrSpace(code)) { 11673 return completeAttributeNameAfter(code); 11674 } 11675 effects.consume(code); 11676 return completeAttributeValueUnquoted; 11677 } 11678 11679 /** 11680 * After double or single quoted attribute value, before whitespace or the 11681 * end of the tag. 11682 * 11683 * ```markdown 11684 * > | <a b="c"> 11685 * ^ 11686 * ``` 11687 * 11688 * @type {State} 11689 */ 11690 function completeAttributeValueQuotedAfter(code) { 11691 if (code === 47 || code === 62 || markdownSpace(code)) { 11692 return completeAttributeNameBefore(code); 11693 } 11694 return nok(code); 11695 } 11696 11697 /** 11698 * In certain circumstances of a complete tag where only an `>` is allowed. 11699 * 11700 * ```markdown 11701 * > | <a b="c"> 11702 * ^ 11703 * ``` 11704 * 11705 * @type {State} 11706 */ 11707 function completeEnd(code) { 11708 if (code === 62) { 11709 effects.consume(code); 11710 return completeAfter; 11711 } 11712 return nok(code); 11713 } 11714 11715 /** 11716 * After `>` in a complete tag. 11717 * 11718 * ```markdown 11719 * > | <x> 11720 * ^ 11721 * ``` 11722 * 11723 * @type {State} 11724 */ 11725 function completeAfter(code) { 11726 if (code === null || markdownLineEnding(code)) { 11727 // // Do not form containers. 11728 // tokenizer.concrete = true 11729 return continuation(code); 11730 } 11731 if (markdownSpace(code)) { 11732 effects.consume(code); 11733 return completeAfter; 11734 } 11735 return nok(code); 11736 } 11737 11738 /** 11739 * In continuation of any HTML kind. 11740 * 11741 * ```markdown 11742 * > | <!--xxx--> 11743 * ^ 11744 * ``` 11745 * 11746 * @type {State} 11747 */ 11748 function continuation(code) { 11749 if (code === 45 && marker === 2) { 11750 effects.consume(code); 11751 return continuationCommentInside; 11752 } 11753 if (code === 60 && marker === 1) { 11754 effects.consume(code); 11755 return continuationRawTagOpen; 11756 } 11757 if (code === 62 && marker === 4) { 11758 effects.consume(code); 11759 return continuationClose; 11760 } 11761 if (code === 63 && marker === 3) { 11762 effects.consume(code); 11763 return continuationDeclarationInside; 11764 } 11765 if (code === 93 && marker === 5) { 11766 effects.consume(code); 11767 return continuationCdataInside; 11768 } 11769 if (markdownLineEnding(code) && (marker === 6 || marker === 7)) { 11770 effects.exit("htmlFlowData"); 11771 return effects.check(blankLineBefore, continuationAfter, continuationStart)(code); 11772 } 11773 if (code === null || markdownLineEnding(code)) { 11774 effects.exit("htmlFlowData"); 11775 return continuationStart(code); 11776 } 11777 effects.consume(code); 11778 return continuation; 11779 } 11780 11781 /** 11782 * In continuation, at eol. 11783 * 11784 * ```markdown 11785 * > | <x> 11786 * ^ 11787 * | asd 11788 * ``` 11789 * 11790 * @type {State} 11791 */ 11792 function continuationStart(code) { 11793 return effects.check(nonLazyContinuationStart, continuationStartNonLazy, continuationAfter)(code); 11794 } 11795 11796 /** 11797 * In continuation, at eol, before non-lazy content. 11798 * 11799 * ```markdown 11800 * > | <x> 11801 * ^ 11802 * | asd 11803 * ``` 11804 * 11805 * @type {State} 11806 */ 11807 function continuationStartNonLazy(code) { 11808 effects.enter("lineEnding"); 11809 effects.consume(code); 11810 effects.exit("lineEnding"); 11811 return continuationBefore; 11812 } 11813 11814 /** 11815 * In continuation, before non-lazy content. 11816 * 11817 * ```markdown 11818 * | <x> 11819 * > | asd 11820 * ^ 11821 * ``` 11822 * 11823 * @type {State} 11824 */ 11825 function continuationBefore(code) { 11826 if (code === null || markdownLineEnding(code)) { 11827 return continuationStart(code); 11828 } 11829 effects.enter("htmlFlowData"); 11830 return continuation(code); 11831 } 11832 11833 /** 11834 * In comment continuation, after one `-`, expecting another. 11835 * 11836 * ```markdown 11837 * > | <!--xxx--> 11838 * ^ 11839 * ``` 11840 * 11841 * @type {State} 11842 */ 11843 function continuationCommentInside(code) { 11844 if (code === 45) { 11845 effects.consume(code); 11846 return continuationDeclarationInside; 11847 } 11848 return continuation(code); 11849 } 11850 11851 /** 11852 * In raw continuation, after `<`, at `/`. 11853 * 11854 * ```markdown 11855 * > | <script>console.log(1)</script> 11856 * ^ 11857 * ``` 11858 * 11859 * @type {State} 11860 */ 11861 function continuationRawTagOpen(code) { 11862 if (code === 47) { 11863 effects.consume(code); 11864 buffer = ''; 11865 return continuationRawEndTag; 11866 } 11867 return continuation(code); 11868 } 11869 11870 /** 11871 * In raw continuation, after `</`, in a raw tag name. 11872 * 11873 * ```markdown 11874 * > | <script>console.log(1)</script> 11875 * ^^^^^^ 11876 * ``` 11877 * 11878 * @type {State} 11879 */ 11880 function continuationRawEndTag(code) { 11881 if (code === 62) { 11882 const name = buffer.toLowerCase(); 11883 if (htmlRawNames.includes(name)) { 11884 effects.consume(code); 11885 return continuationClose; 11886 } 11887 return continuation(code); 11888 } 11889 if (asciiAlpha(code) && buffer.length < 8) { 11890 // Always the case. 11891 effects.consume(code); 11892 buffer += String.fromCharCode(code); 11893 return continuationRawEndTag; 11894 } 11895 return continuation(code); 11896 } 11897 11898 /** 11899 * In cdata continuation, after `]`, expecting `]>`. 11900 * 11901 * ```markdown 11902 * > | <![CDATA[>&<]]> 11903 * ^ 11904 * ``` 11905 * 11906 * @type {State} 11907 */ 11908 function continuationCdataInside(code) { 11909 if (code === 93) { 11910 effects.consume(code); 11911 return continuationDeclarationInside; 11912 } 11913 return continuation(code); 11914 } 11915 11916 /** 11917 * In declaration or instruction continuation, at `>`. 11918 * 11919 * ```markdown 11920 * > | <!--> 11921 * ^ 11922 * > | <?> 11923 * ^ 11924 * > | <!q> 11925 * ^ 11926 * > | <!--ab--> 11927 * ^ 11928 * > | <![CDATA[>&<]]> 11929 * ^ 11930 * ``` 11931 * 11932 * @type {State} 11933 */ 11934 function continuationDeclarationInside(code) { 11935 if (code === 62) { 11936 effects.consume(code); 11937 return continuationClose; 11938 } 11939 11940 // More dashes. 11941 if (code === 45 && marker === 2) { 11942 effects.consume(code); 11943 return continuationDeclarationInside; 11944 } 11945 return continuation(code); 11946 } 11947 11948 /** 11949 * In closed continuation: everything we get until the eol/eof is part of it. 11950 * 11951 * ```markdown 11952 * > | <!doctype> 11953 * ^ 11954 * ``` 11955 * 11956 * @type {State} 11957 */ 11958 function continuationClose(code) { 11959 if (code === null || markdownLineEnding(code)) { 11960 effects.exit("htmlFlowData"); 11961 return continuationAfter(code); 11962 } 11963 effects.consume(code); 11964 return continuationClose; 11965 } 11966 11967 /** 11968 * Done. 11969 * 11970 * ```markdown 11971 * > | <!doctype> 11972 * ^ 11973 * ``` 11974 * 11975 * @type {State} 11976 */ 11977 function continuationAfter(code) { 11978 effects.exit("htmlFlow"); 11979 // // Feel free to interrupt. 11980 // tokenizer.interrupt = false 11981 // // No longer concrete. 11982 // tokenizer.concrete = false 11983 return ok(code); 11984 } 11985} 11986 11987/** 11988 * @this {TokenizeContext} 11989 * Context. 11990 * @type {Tokenizer} 11991 */ 11992function tokenizeNonLazyContinuationStart(effects, ok, nok) { 11993 const self = this; 11994 return start; 11995 11996 /** 11997 * At eol, before continuation. 11998 * 11999 * ```markdown 12000 * > | * ```js 12001 * ^ 12002 * | b 12003 * ``` 12004 * 12005 * @type {State} 12006 */ 12007 function start(code) { 12008 if (markdownLineEnding(code)) { 12009 effects.enter("lineEnding"); 12010 effects.consume(code); 12011 effects.exit("lineEnding"); 12012 return after; 12013 } 12014 return nok(code); 12015 } 12016 12017 /** 12018 * A continuation. 12019 * 12020 * ```markdown 12021 * | * ```js 12022 * > | b 12023 * ^ 12024 * ``` 12025 * 12026 * @type {State} 12027 */ 12028 function after(code) { 12029 return self.parser.lazy[self.now().line] ? nok(code) : ok(code); 12030 } 12031} 12032 12033/** 12034 * @this {TokenizeContext} 12035 * Context. 12036 * @type {Tokenizer} 12037 */ 12038function tokenizeBlankLineBefore(effects, ok, nok) { 12039 return start; 12040 12041 /** 12042 * Before eol, expecting blank line. 12043 * 12044 * ```markdown 12045 * > | <div> 12046 * ^ 12047 * | 12048 * ``` 12049 * 12050 * @type {State} 12051 */ 12052 function start(code) { 12053 effects.enter("lineEnding"); 12054 effects.consume(code); 12055 effects.exit("lineEnding"); 12056 return effects.attempt(blankLine, ok, nok); 12057 } 12058} 12059;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-core-commonmark/lib/html-text.js 12060/** 12061 * @import { 12062 * Code, 12063 * Construct, 12064 * State, 12065 * TokenizeContext, 12066 * Tokenizer 12067 * } from 'micromark-util-types' 12068 */ 12069 12070 12071 12072/** @type {Construct} */ 12073const htmlText = { 12074 name: 'htmlText', 12075 tokenize: tokenizeHtmlText 12076}; 12077 12078/** 12079 * @this {TokenizeContext} 12080 * Context. 12081 * @type {Tokenizer} 12082 */ 12083function tokenizeHtmlText(effects, ok, nok) { 12084 const self = this; 12085 /** @type {NonNullable<Code> | undefined} */ 12086 let marker; 12087 /** @type {number} */ 12088 let index; 12089 /** @type {State} */ 12090 let returnState; 12091 return start; 12092 12093 /** 12094 * Start of HTML (text). 12095 * 12096 * ```markdown 12097 * > | a <b> c 12098 * ^ 12099 * ``` 12100 * 12101 * @type {State} 12102 */ 12103 function start(code) { 12104 effects.enter("htmlText"); 12105 effects.enter("htmlTextData"); 12106 effects.consume(code); 12107 return open; 12108 } 12109 12110 /** 12111 * After `<`, at tag name or other stuff. 12112 * 12113 * ```markdown 12114 * > | a <b> c 12115 * ^ 12116 * > | a <!doctype> c 12117 * ^ 12118 * > | a <!--b--> c 12119 * ^ 12120 * ``` 12121 * 12122 * @type {State} 12123 */ 12124 function open(code) { 12125 if (code === 33) { 12126 effects.consume(code); 12127 return declarationOpen; 12128 } 12129 if (code === 47) { 12130 effects.consume(code); 12131 return tagCloseStart; 12132 } 12133 if (code === 63) { 12134 effects.consume(code); 12135 return instruction; 12136 } 12137 12138 // ASCII alphabetical. 12139 if (asciiAlpha(code)) { 12140 effects.consume(code); 12141 return tagOpen; 12142 } 12143 return nok(code); 12144 } 12145 12146 /** 12147 * After `<!`, at declaration, comment, or CDATA. 12148 * 12149 * ```markdown 12150 * > | a <!doctype> c 12151 * ^ 12152 * > | a <!--b--> c 12153 * ^ 12154 * > | a <![CDATA[>&<]]> c 12155 * ^ 12156 * ``` 12157 * 12158 * @type {State} 12159 */ 12160 function declarationOpen(code) { 12161 if (code === 45) { 12162 effects.consume(code); 12163 return commentOpenInside; 12164 } 12165 if (code === 91) { 12166 effects.consume(code); 12167 index = 0; 12168 return cdataOpenInside; 12169 } 12170 if (asciiAlpha(code)) { 12171 effects.consume(code); 12172 return declaration; 12173 } 12174 return nok(code); 12175 } 12176 12177 /** 12178 * In a comment, after `<!-`, at another `-`. 12179 * 12180 * ```markdown 12181 * > | a <!--b--> c 12182 * ^ 12183 * ``` 12184 * 12185 * @type {State} 12186 */ 12187 function commentOpenInside(code) { 12188 if (code === 45) { 12189 effects.consume(code); 12190 return commentEnd; 12191 } 12192 return nok(code); 12193 } 12194 12195 /** 12196 * In comment. 12197 * 12198 * ```markdown 12199 * > | a <!--b--> c 12200 * ^ 12201 * ``` 12202 * 12203 * @type {State} 12204 */ 12205 function comment(code) { 12206 if (code === null) { 12207 return nok(code); 12208 } 12209 if (code === 45) { 12210 effects.consume(code); 12211 return commentClose; 12212 } 12213 if (markdownLineEnding(code)) { 12214 returnState = comment; 12215 return lineEndingBefore(code); 12216 } 12217 effects.consume(code); 12218 return comment; 12219 } 12220 12221 /** 12222 * In comment, after `-`. 12223 * 12224 * ```markdown 12225 * > | a <!--b--> c 12226 * ^ 12227 * ``` 12228 * 12229 * @type {State} 12230 */ 12231 function commentClose(code) { 12232 if (code === 45) { 12233 effects.consume(code); 12234 return commentEnd; 12235 } 12236 return comment(code); 12237 } 12238 12239 /** 12240 * In comment, after `--`. 12241 * 12242 * ```markdown 12243 * > | a <!--b--> c 12244 * ^ 12245 * ``` 12246 * 12247 * @type {State} 12248 */ 12249 function commentEnd(code) { 12250 return code === 62 ? end(code) : code === 45 ? commentClose(code) : comment(code); 12251 } 12252 12253 /** 12254 * After `<![`, in CDATA, expecting `CDATA[`. 12255 * 12256 * ```markdown 12257 * > | a <![CDATA[>&<]]> b 12258 * ^^^^^^ 12259 * ``` 12260 * 12261 * @type {State} 12262 */ 12263 function cdataOpenInside(code) { 12264 const value = "CDATA["; 12265 if (code === value.charCodeAt(index++)) { 12266 effects.consume(code); 12267 return index === value.length ? cdata : cdataOpenInside; 12268 } 12269 return nok(code); 12270 } 12271 12272 /** 12273 * In CDATA. 12274 * 12275 * ```markdown 12276 * > | a <![CDATA[>&<]]> b 12277 * ^^^ 12278 * ``` 12279 * 12280 * @type {State} 12281 */ 12282 function cdata(code) { 12283 if (code === null) { 12284 return nok(code); 12285 } 12286 if (code === 93) { 12287 effects.consume(code); 12288 return cdataClose; 12289 } 12290 if (markdownLineEnding(code)) { 12291 returnState = cdata; 12292 return lineEndingBefore(code); 12293 } 12294 effects.consume(code); 12295 return cdata; 12296 } 12297 12298 /** 12299 * In CDATA, after `]`, at another `]`. 12300 * 12301 * ```markdown 12302 * > | a <![CDATA[>&<]]> b 12303 * ^ 12304 * ``` 12305 * 12306 * @type {State} 12307 */ 12308 function cdataClose(code) { 12309 if (code === 93) { 12310 effects.consume(code); 12311 return cdataEnd; 12312 } 12313 return cdata(code); 12314 } 12315 12316 /** 12317 * In CDATA, after `]]`, at `>`. 12318 * 12319 * ```markdown 12320 * > | a <![CDATA[>&<]]> b 12321 * ^ 12322 * ``` 12323 * 12324 * @type {State} 12325 */ 12326 function cdataEnd(code) { 12327 if (code === 62) { 12328 return end(code); 12329 } 12330 if (code === 93) { 12331 effects.consume(code); 12332 return cdataEnd; 12333 } 12334 return cdata(code); 12335 } 12336 12337 /** 12338 * In declaration. 12339 * 12340 * ```markdown 12341 * > | a <!b> c 12342 * ^ 12343 * ``` 12344 * 12345 * @type {State} 12346 */ 12347 function declaration(code) { 12348 if (code === null || code === 62) { 12349 return end(code); 12350 } 12351 if (markdownLineEnding(code)) { 12352 returnState = declaration; 12353 return lineEndingBefore(code); 12354 }
vendor: 4,384 bytes, lines 12355-12574
12355 effects.consume(code); 12356 return declaration; 12357 } 12358 12359 /** 12360 * In instruction. 12361 * 12362 * ```markdown 12363 * > | a <?b?> c 12364 * ^ 12365 * ``` 12366 * 12367 * @type {State} 12368 */ 12369 function instruction(code) { 12370 if (code === null) { 12371 return nok(code); 12372 } 12373 if (code === 63) { 12374 effects.consume(code); 12375 return instructionClose; 12376 } 12377 if (markdownLineEnding(code)) { 12378 returnState = instruction; 12379 return lineEndingBefore(code); 12380 } 12381 effects.consume(code); 12382 return instruction; 12383 } 12384 12385 /** 12386 * In instruction, after `?`, at `>`. 12387 * 12388 * ```markdown 12389 * > | a <?b?> c 12390 * ^ 12391 * ``` 12392 * 12393 * @type {State} 12394 */ 12395 function instructionClose(code) { 12396 return code === 62 ? end(code) : instruction(code); 12397 } 12398 12399 /** 12400 * After `</`, in closing tag, at tag name. 12401 * 12402 * ```markdown 12403 * > | a </b> c 12404 * ^ 12405 * ``` 12406 * 12407 * @type {State} 12408 */ 12409 function tagCloseStart(code) { 12410 // ASCII alphabetical. 12411 if (asciiAlpha(code)) { 12412 effects.consume(code); 12413 return tagClose; 12414 } 12415 return nok(code); 12416 } 12417 12418 /** 12419 * After `</x`, in a tag name. 12420 * 12421 * ```markdown 12422 * > | a </b> c 12423 * ^ 12424 * ``` 12425 * 12426 * @type {State} 12427 */ 12428 function tagClose(code) { 12429 // ASCII alphanumerical and `-`. 12430 if (code === 45 || asciiAlphanumeric(code)) { 12431 effects.consume(code); 12432 return tagClose; 12433 } 12434 return tagCloseBetween(code); 12435 } 12436 12437 /** 12438 * In closing tag, after tag name. 12439 * 12440 * ```markdown 12441 * > | a </b> c 12442 * ^ 12443 * ``` 12444 * 12445 * @type {State} 12446 */ 12447 function tagCloseBetween(code) { 12448 if (markdownLineEnding(code)) { 12449 returnState = tagCloseBetween; 12450 return lineEndingBefore(code); 12451 } 12452 if (markdownSpace(code)) { 12453 effects.consume(code); 12454 return tagCloseBetween; 12455 } 12456 return end(code); 12457 } 12458 12459 /** 12460 * After `<x`, in opening tag name. 12461 * 12462 * ```markdown 12463 * > | a <b> c 12464 * ^ 12465 * ``` 12466 * 12467 * @type {State} 12468 */ 12469 function tagOpen(code) { 12470 // ASCII alphanumerical and `-`. 12471 if (code === 45 || asciiAlphanumeric(code)) { 12472 effects.consume(code); 12473 return tagOpen; 12474 } 12475 if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) { 12476 return tagOpenBetween(code); 12477 } 12478 return nok(code); 12479 } 12480 12481 /** 12482 * In opening tag, after tag name. 12483 * 12484 * ```markdown 12485 * > | a <b> c 12486 * ^ 12487 * ``` 12488 * 12489 * @type {State} 12490 */ 12491 function tagOpenBetween(code) { 12492 if (code === 47) { 12493 effects.consume(code); 12494 return end; 12495 } 12496 12497 // ASCII alphabetical and `:` and `_`. 12498 if (code === 58 || code === 95 || asciiAlpha(code)) { 12499 effects.consume(code); 12500 return tagOpenAttributeName; 12501 } 12502 if (markdownLineEnding(code)) { 12503 returnState = tagOpenBetween; 12504 return lineEndingBefore(code); 12505 } 12506 if (markdownSpace(code)) { 12507 effects.consume(code); 12508 return tagOpenBetween; 12509 } 12510 return end(code); 12511 } 12512 12513 /** 12514 * In attribute name. 12515 * 12516 * ```markdown 12517 * > | a <b c> d 12518 * ^ 12519 * ``` 12520 * 12521 * @type {State} 12522 */ 12523 function tagOpenAttributeName(code) { 12524 // ASCII alphabetical and `-`, `.`, `:`, and `_`. 12525 if (code === 45 || code === 46 || code === 58 || code === 95 || asciiAlphanumeric(code)) { 12526 effects.consume(code); 12527 return tagOpenAttributeName; 12528 } 12529 return tagOpenAttributeNameAfter(code); 12530 } 12531 12532 /** 12533 * After attribute name, before initializer, the end of the tag, or 12534 * whitespace. 12535 * 12536 * ```markdown 12537 * > | a <b c> d 12538 * ^ 12539 * ``` 12540 * 12541 * @type {State} 12542 */ 12543 function tagOpenAttributeNameAfter(code) { 12544 if (code === 61) { 12545 effects.consume(code); 12546 return tagOpenAttributeValueBefore; 12547 } 12548 if (markdownLineEnding(code)) { 12549 returnState = tagOpenAttributeNameAfter; 12550 return lineEndingBefore(code); 12551 } 12552 if (markdownSpace(code)) { 12553 effects.consume(code); 12554 return tagOpenAttributeNameAfter; 12555 } 12556 return tagOpenBetween(code); 12557 } 12558 12559 /** 12560 * Before unquoted, double quoted, or single quoted attribute value, allowing 12561 * whitespace. 12562 * 12563 * ```markdown 12564 * > | a <b c=d> e 12565 * ^ 12566 * ``` 12567 * 12568 * @type {State} 12569 */ 12570 function tagOpenAttributeValueBefore(code) { 12571 if (code === null || code === 60 || code === 61 || code === 62 || code === 96) { 12572 return nok(code); 12573 } 12574 if (code === 34 || code === 39) {
vendor: 41,453 bytes, lines 12575-14379
12575 effects.consume(code); 12576 marker = code; 12577 return tagOpenAttributeValueQuoted; 12578 } 12579 if (markdownLineEnding(code)) { 12580 returnState = tagOpenAttributeValueBefore; 12581 return lineEndingBefore(code); 12582 } 12583 if (markdownSpace(code)) { 12584 effects.consume(code); 12585 return tagOpenAttributeValueBefore; 12586 } 12587 effects.consume(code); 12588 return tagOpenAttributeValueUnquoted; 12589 } 12590 12591 /** 12592 * In double or single quoted attribute value. 12593 * 12594 * ```markdown 12595 * > | a <b c="d"> e 12596 * ^ 12597 * ``` 12598 * 12599 * @type {State} 12600 */ 12601 function tagOpenAttributeValueQuoted(code) { 12602 if (code === marker) { 12603 effects.consume(code); 12604 marker = undefined; 12605 return tagOpenAttributeValueQuotedAfter; 12606 } 12607 if (code === null) { 12608 return nok(code); 12609 } 12610 if (markdownLineEnding(code)) { 12611 returnState = tagOpenAttributeValueQuoted; 12612 return lineEndingBefore(code); 12613 } 12614 effects.consume(code); 12615 return tagOpenAttributeValueQuoted; 12616 } 12617 12618 /** 12619 * In unquoted attribute value. 12620 * 12621 * ```markdown 12622 * > | a <b c=d> e 12623 * ^ 12624 * ``` 12625 * 12626 * @type {State} 12627 */ 12628 function tagOpenAttributeValueUnquoted(code) { 12629 if (code === null || code === 34 || code === 39 || code === 60 || code === 61 || code === 96) { 12630 return nok(code); 12631 } 12632 if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) { 12633 return tagOpenBetween(code); 12634 } 12635 effects.consume(code); 12636 return tagOpenAttributeValueUnquoted; 12637 } 12638 12639 /** 12640 * After double or single quoted attribute value, before whitespace or the end 12641 * of the tag. 12642 * 12643 * ```markdown 12644 * > | a <b c="d"> e 12645 * ^ 12646 * ``` 12647 * 12648 * @type {State} 12649 */ 12650 function tagOpenAttributeValueQuotedAfter(code) { 12651 if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) { 12652 return tagOpenBetween(code); 12653 } 12654 return nok(code); 12655 } 12656 12657 /** 12658 * In certain circumstances of a tag where only an `>` is allowed. 12659 * 12660 * ```markdown 12661 * > | a <b c="d"> e 12662 * ^ 12663 * ``` 12664 * 12665 * @type {State} 12666 */ 12667 function end(code) { 12668 if (code === 62) { 12669 effects.consume(code); 12670 effects.exit("htmlTextData"); 12671 effects.exit("htmlText"); 12672 return ok; 12673 } 12674 return nok(code); 12675 } 12676 12677 /** 12678 * At eol. 12679 * 12680 * > ð **Note**: we canât have blank lines in text, so no need to worry about 12681 * > empty tokens. 12682 * 12683 * ```markdown 12684 * > | a <!--a 12685 * ^ 12686 * | b--> 12687 * ``` 12688 * 12689 * @type {State} 12690 */ 12691 function lineEndingBefore(code) { 12692 effects.exit("htmlTextData"); 12693 effects.enter("lineEnding"); 12694 effects.consume(code); 12695 effects.exit("lineEnding"); 12696 return lineEndingAfter; 12697 } 12698 12699 /** 12700 * After eol, at optional whitespace. 12701 * 12702 * > ð **Note**: we canât have blank lines in text, so no need to worry about 12703 * > empty tokens. 12704 * 12705 * ```markdown 12706 * | a <!--a 12707 * > | b--> 12708 * ^ 12709 * ``` 12710 * 12711 * @type {State} 12712 */ 12713 function lineEndingAfter(code) { 12714 // Always populated by defaults. 12715 12716 return markdownSpace(code) ? factorySpace(effects, lineEndingAfterPrefix, "linePrefix", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4)(code) : lineEndingAfterPrefix(code); 12717 } 12718 12719 /** 12720 * After eol, after optional whitespace. 12721 * 12722 * > ð **Note**: we canât have blank lines in text, so no need to worry about 12723 * > empty tokens. 12724 * 12725 * ```markdown 12726 * | a <!--a 12727 * > | b--> 12728 * ^ 12729 * ``` 12730 * 12731 * @type {State} 12732 */ 12733 function lineEndingAfterPrefix(code) { 12734 effects.enter("htmlTextData"); 12735 return returnState(code); 12736 } 12737} 12738;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-core-commonmark/lib/label-end.js 12739/** 12740 * @import { 12741 * Construct, 12742 * Event, 12743 * Resolver, 12744 * State, 12745 * TokenizeContext, 12746 * Tokenizer, 12747 * Token 12748 * } from 'micromark-util-types' 12749 */ 12750 12751 12752 12753 12754 12755 12756 12757 12758 12759/** @type {Construct} */ 12760const labelEnd = { 12761 name: 'labelEnd', 12762 resolveAll: resolveAllLabelEnd, 12763 resolveTo: resolveToLabelEnd, 12764 tokenize: tokenizeLabelEnd 12765}; 12766 12767/** @type {Construct} */ 12768const resourceConstruct = { 12769 tokenize: tokenizeResource 12770}; 12771/** @type {Construct} */ 12772const referenceFullConstruct = { 12773 tokenize: tokenizeReferenceFull 12774}; 12775/** @type {Construct} */ 12776const referenceCollapsedConstruct = { 12777 tokenize: tokenizeReferenceCollapsed 12778}; 12779 12780/** @type {Resolver} */ 12781function resolveAllLabelEnd(events) { 12782 let index = -1; 12783 /** @type {Array<Event>} */ 12784 const newEvents = []; 12785 while (++index < events.length) { 12786 const token = events[index][1]; 12787 newEvents.push(events[index]); 12788 if (token.type === "labelImage" || token.type === "labelLink" || token.type === "labelEnd") { 12789 // Remove the marker. 12790 const offset = token.type === "labelImage" ? 4 : 2; 12791 token.type = "data"; 12792 index += offset; 12793 } 12794 } 12795 12796 // If the events are equal, we don't have to copy newEvents to events 12797 if (events.length !== newEvents.length) { 12798 splice(events, 0, events.length, newEvents); 12799 } 12800 return events; 12801} 12802 12803/** @type {Resolver} */ 12804function resolveToLabelEnd(events, context) { 12805 let index = events.length; 12806 let offset = 0; 12807 /** @type {Token} */ 12808 let token; 12809 /** @type {number | undefined} */ 12810 let open; 12811 /** @type {number | undefined} */ 12812 let close; 12813 /** @type {Array<Event>} */ 12814 let media; 12815 12816 // Find an opening. 12817 while (index--) { 12818 token = events[index][1]; 12819 if (open) { 12820 // If we see another link, or inactive link label, weâve been here before. 12821 if (token.type === "link" || token.type === "labelLink" && token._inactive) { 12822 break; 12823 } 12824 12825 // Mark other link openings as inactive, as we canât have links in 12826 // links. 12827 if (events[index][0] === 'enter' && token.type === "labelLink") { 12828 token._inactive = true; 12829 } 12830 } else if (close) { 12831 if (events[index][0] === 'enter' && (token.type === "labelImage" || token.type === "labelLink") && !token._balanced) { 12832 open = index; 12833 if (token.type !== "labelLink") { 12834 offset = 2; 12835 break; 12836 } 12837 } 12838 } else if (token.type === "labelEnd") { 12839 close = index; 12840 } 12841 } 12842 const group = { 12843 type: events[open][1].type === "labelLink" ? "link" : "image", 12844 start: { 12845 ...events[open][1].start 12846 }, 12847 end: { 12848 ...events[events.length - 1][1].end 12849 } 12850 }; 12851 const label = { 12852 type: "label", 12853 start: { 12854 ...events[open][1].start 12855 }, 12856 end: { 12857 ...events[close][1].end 12858 } 12859 }; 12860 const text = { 12861 type: "labelText", 12862 start: { 12863 ...events[open + offset + 2][1].end 12864 }, 12865 end: { 12866 ...events[close - 2][1].start 12867 } 12868 }; 12869 media = [['enter', group, context], ['enter', label, context]]; 12870 12871 // Opening marker. 12872 media = micromark_util_chunked_push(media, events.slice(open + 1, open + offset + 3)); 12873 12874 // Text open. 12875 media = micromark_util_chunked_push(media, [['enter', text, context]]); 12876 12877 // Always populated by defaults. 12878 12879 // Between. 12880 media = micromark_util_chunked_push(media, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + offset + 4, close - 3), context)); 12881 12882 // Text close, marker close, label close. 12883 media = micromark_util_chunked_push(media, [['exit', text, context], events[close - 2], events[close - 1], ['exit', label, context]]); 12884 12885 // Reference, resource, or so. 12886 media = micromark_util_chunked_push(media, events.slice(close + 1)); 12887 12888 // Media close. 12889 media = micromark_util_chunked_push(media, [['exit', group, context]]); 12890 splice(events, open, events.length, media); 12891 return events; 12892} 12893 12894/** 12895 * @this {TokenizeContext} 12896 * Context. 12897 * @type {Tokenizer} 12898 */ 12899function tokenizeLabelEnd(effects, ok, nok) { 12900 const self = this; 12901 let index = self.events.length; 12902 /** @type {Token} */ 12903 let labelStart; 12904 /** @type {boolean} */ 12905 let defined; 12906 12907 // Find an opening. 12908 while (index--) { 12909 if ((self.events[index][1].type === "labelImage" || self.events[index][1].type === "labelLink") && !self.events[index][1]._balanced) { 12910 labelStart = self.events[index][1]; 12911 break; 12912 } 12913 } 12914 return start; 12915 12916 /** 12917 * Start of label end. 12918 * 12919 * ```markdown 12920 * > | [a](b) c 12921 * ^ 12922 * > | [a][b] c 12923 * ^ 12924 * > | [a][] b 12925 * ^ 12926 * > | [a] b 12927 * ``` 12928 * 12929 * @type {State} 12930 */ 12931 function start(code) { 12932 // If there is not an okay opening. 12933 if (!labelStart) { 12934 return nok(code); 12935 } 12936 12937 // If the corresponding label (link) start is marked as inactive, 12938 // it means weâd be wrapping a link, like this: 12939 // 12940 // ```markdown 12941 // > | a [b [c](d) e](f) g. 12942 // ^ 12943 // ``` 12944 // 12945 // We canât have that, so itâs just balanced brackets. 12946 if (labelStart._inactive) { 12947 return labelEndNok(code); 12948 } 12949 defined = self.parser.defined.includes(micromark_util_normalize_identifier_normalizeIdentifier(self.sliceSerialize({ 12950 start: labelStart.end, 12951 end: self.now() 12952 }))); 12953 effects.enter("labelEnd"); 12954 effects.enter("labelMarker"); 12955 effects.consume(code); 12956 effects.exit("labelMarker"); 12957 effects.exit("labelEnd"); 12958 return after; 12959 } 12960 12961 /** 12962 * After `]`. 12963 * 12964 * ```markdown 12965 * > | [a](b) c 12966 * ^ 12967 * > | [a][b] c 12968 * ^ 12969 * > | [a][] b 12970 * ^ 12971 * > | [a] b 12972 * ^ 12973 * ``` 12974 * 12975 * @type {State} 12976 */ 12977 function after(code) { 12978 // Note: `markdown-rs` also parses GFM footnotes here, which for us is in 12979 // an extension. 12980 12981 // Resource (`[asd](fgh)`)? 12982 if (code === 40) { 12983 return effects.attempt(resourceConstruct, labelEndOk, defined ? labelEndOk : labelEndNok)(code); 12984 } 12985 12986 // Full (`[asd][fgh]`) or collapsed (`[asd][]`) reference? 12987 if (code === 91) { 12988 return effects.attempt(referenceFullConstruct, labelEndOk, defined ? referenceNotFull : labelEndNok)(code); 12989 } 12990 12991 // Shortcut (`[asd]`) reference? 12992 return defined ? labelEndOk(code) : labelEndNok(code); 12993 } 12994 12995 /** 12996 * After `]`, at `[`, but not at a full reference. 12997 * 12998 * > ð **Note**: we only get here if the label is defined. 12999 * 13000 * ```markdown 13001 * > | [a][] b 13002 * ^ 13003 * > | [a] b 13004 * ^ 13005 * ``` 13006 * 13007 * @type {State} 13008 */ 13009 function referenceNotFull(code) { 13010 return effects.attempt(referenceCollapsedConstruct, labelEndOk, labelEndNok)(code); 13011 } 13012 13013 /** 13014 * Done, we found something. 13015 * 13016 * ```markdown 13017 * > | [a](b) c 13018 * ^ 13019 * > | [a][b] c 13020 * ^ 13021 * > | [a][] b 13022 * ^ 13023 * > | [a] b 13024 * ^ 13025 * ``` 13026 * 13027 * @type {State} 13028 */ 13029 function labelEndOk(code) { 13030 // Note: `markdown-rs` does a bunch of stuff here. 13031 return ok(code); 13032 } 13033 13034 /** 13035 * Done, itâs nothing. 13036 * 13037 * There was an okay opening, but we didnât match anything. 13038 * 13039 * ```markdown 13040 * > | [a](b c 13041 * ^ 13042 * > | [a][b c 13043 * ^ 13044 * > | [a] b 13045 * ^ 13046 * ``` 13047 * 13048 * @type {State} 13049 */ 13050 function labelEndNok(code) { 13051 labelStart._balanced = true; 13052 return nok(code); 13053 } 13054} 13055 13056/** 13057 * @this {TokenizeContext} 13058 * Context. 13059 * @type {Tokenizer} 13060 */ 13061function tokenizeResource(effects, ok, nok) { 13062 return resourceStart; 13063 13064 /** 13065 * At a resource. 13066 * 13067 * ```markdown 13068 * > | [a](b) c 13069 * ^ 13070 * ``` 13071 * 13072 * @type {State} 13073 */ 13074 function resourceStart(code) { 13075 effects.enter("resource"); 13076 effects.enter("resourceMarker"); 13077 effects.consume(code); 13078 effects.exit("resourceMarker"); 13079 return resourceBefore; 13080 } 13081 13082 /** 13083 * In resource, after `(`, at optional whitespace. 13084 * 13085 * ```markdown 13086 * > | [a](b) c 13087 * ^ 13088 * ``` 13089 * 13090 * @type {State} 13091 */ 13092 function resourceBefore(code) { 13093 return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceOpen)(code) : resourceOpen(code); 13094 } 13095 13096 /** 13097 * In resource, after optional whitespace, at `)` or a destination. 13098 * 13099 * ```markdown 13100 * > | [a](b) c 13101 * ^ 13102 * ``` 13103 * 13104 * @type {State} 13105 */ 13106 function resourceOpen(code) { 13107 if (code === 41) { 13108 return resourceEnd(code); 13109 } 13110 return factoryDestination(effects, resourceDestinationAfter, resourceDestinationMissing, "resourceDestination", "resourceDestinationLiteral", "resourceDestinationLiteralMarker", "resourceDestinationRaw", "resourceDestinationString", 32)(code); 13111 } 13112 13113 /** 13114 * In resource, after destination, at optional whitespace. 13115 * 13116 * ```markdown 13117 * > | [a](b) c 13118 * ^ 13119 * ``` 13120 * 13121 * @type {State} 13122 */ 13123 function resourceDestinationAfter(code) { 13124 return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceBetween)(code) : resourceEnd(code); 13125 } 13126 13127 /** 13128 * At invalid destination. 13129 * 13130 * ```markdown 13131 * > | [a](<<) b 13132 * ^ 13133 * ``` 13134 * 13135 * @type {State} 13136 */ 13137 function resourceDestinationMissing(code) { 13138 return nok(code); 13139 } 13140 13141 /** 13142 * In resource, after destination and whitespace, at `(` or title. 13143 * 13144 * ```markdown 13145 * > | [a](b ) c 13146 * ^ 13147 * ``` 13148 * 13149 * @type {State} 13150 */ 13151 function resourceBetween(code) { 13152 if (code === 34 || code === 39 || code === 40) { 13153 return factoryTitle(effects, resourceTitleAfter, nok, "resourceTitle", "resourceTitleMarker", "resourceTitleString")(code); 13154 } 13155 return resourceEnd(code); 13156 } 13157 13158 /** 13159 * In resource, after title, at optional whitespace. 13160 * 13161 * ```markdown 13162 * > | [a](b "c") d 13163 * ^ 13164 * ``` 13165 * 13166 * @type {State} 13167 */ 13168 function resourceTitleAfter(code) { 13169 return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceEnd)(code) : resourceEnd(code); 13170 } 13171 13172 /** 13173 * In resource, at `)`. 13174 * 13175 * ```markdown 13176 * > | [a](b) d 13177 * ^ 13178 * ``` 13179 * 13180 * @type {State} 13181 */ 13182 function resourceEnd(code) { 13183 if (code === 41) { 13184 effects.enter("resourceMarker"); 13185 effects.consume(code); 13186 effects.exit("resourceMarker"); 13187 effects.exit("resource"); 13188 return ok; 13189 } 13190 return nok(code); 13191 } 13192} 13193 13194/** 13195 * @this {TokenizeContext} 13196 * Context. 13197 * @type {Tokenizer} 13198 */ 13199function tokenizeReferenceFull(effects, ok, nok) { 13200 const self = this; 13201 return referenceFull; 13202 13203 /** 13204 * In a reference (full), at the `[`. 13205 * 13206 * ```markdown 13207 * > | [a][b] d 13208 * ^ 13209 * ``` 13210 * 13211 * @type {State} 13212 */ 13213 function referenceFull(code) { 13214 return factoryLabel.call(self, effects, referenceFullAfter, referenceFullMissing, "reference", "referenceMarker", "referenceString")(code); 13215 } 13216 13217 /** 13218 * In a reference (full), after `]`. 13219 * 13220 * ```markdown 13221 * > | [a][b] d 13222 * ^ 13223 * ``` 13224 * 13225 * @type {State} 13226 */ 13227 function referenceFullAfter(code) { 13228 return self.parser.defined.includes(micromark_util_normalize_identifier_normalizeIdentifier(self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1))) ? ok(code) : nok(code); 13229 } 13230 13231 /** 13232 * In reference (full) that was missing. 13233 * 13234 * ```markdown 13235 * > | [a][b d 13236 * ^ 13237 * ``` 13238 * 13239 * @type {State} 13240 */ 13241 function referenceFullMissing(code) { 13242 return nok(code); 13243 } 13244} 13245 13246/** 13247 * @this {TokenizeContext} 13248 * Context. 13249 * @type {Tokenizer} 13250 */ 13251function tokenizeReferenceCollapsed(effects, ok, nok) { 13252 return referenceCollapsedStart; 13253 13254 /** 13255 * In reference (collapsed), at `[`. 13256 * 13257 * > ð **Note**: we only get here if the label is defined. 13258 * 13259 * ```markdown 13260 * > | [a][] d 13261 * ^ 13262 * ``` 13263 * 13264 * @type {State} 13265 */ 13266 function referenceCollapsedStart(code) { 13267 // We only attempt a collapsed label if thereâs a `[`. 13268 13269 effects.enter("reference"); 13270 effects.enter("referenceMarker"); 13271 effects.consume(code); 13272 effects.exit("referenceMarker"); 13273 return referenceCollapsedOpen; 13274 } 13275 13276 /** 13277 * In reference (collapsed), at `]`. 13278 * 13279 * > ð **Note**: we only get here if the label is defined. 13280 * 13281 * ```markdown 13282 * > | [a][] d 13283 * ^ 13284 * ``` 13285 * 13286 * @type {State} 13287 */ 13288 function referenceCollapsedOpen(code) { 13289 if (code === 93) { 13290 effects.enter("referenceMarker"); 13291 effects.consume(code); 13292 effects.exit("referenceMarker"); 13293 effects.exit("reference"); 13294 return ok; 13295 } 13296 return nok(code); 13297 } 13298} 13299;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-core-commonmark/lib/label-start-image.js 13300/** 13301 * @import { 13302 * Construct, 13303 * State, 13304 * TokenizeContext, 13305 * Tokenizer 13306 * } from 'micromark-util-types' 13307 */ 13308 13309 13310 13311/** @type {Construct} */ 13312const labelStartImage = { 13313 name: 'labelStartImage', 13314 resolveAll: labelEnd.resolveAll, 13315 tokenize: tokenizeLabelStartImage 13316}; 13317 13318/** 13319 * @this {TokenizeContext} 13320 * Context. 13321 * @type {Tokenizer} 13322 */ 13323function tokenizeLabelStartImage(effects, ok, nok) { 13324 const self = this; 13325 return start; 13326 13327 /** 13328 * Start of label (image) start. 13329 * 13330 * ```markdown 13331 * > | a ![b] c 13332 * ^ 13333 * ``` 13334 * 13335 * @type {State} 13336 */ 13337 function start(code) { 13338 effects.enter("labelImage"); 13339 effects.enter("labelImageMarker"); 13340 effects.consume(code); 13341 effects.exit("labelImageMarker"); 13342 return open; 13343 } 13344 13345 /** 13346 * After `!`, at `[`. 13347 * 13348 * ```markdown 13349 * > | a ![b] c 13350 * ^ 13351 * ``` 13352 * 13353 * @type {State} 13354 */ 13355 function open(code) { 13356 if (code === 91) { 13357 effects.enter("labelMarker"); 13358 effects.consume(code); 13359 effects.exit("labelMarker"); 13360 effects.exit("labelImage"); 13361 return after; 13362 } 13363 return nok(code); 13364 } 13365 13366 /** 13367 * After `![`. 13368 * 13369 * ```markdown 13370 * > | a ![b] c 13371 * ^ 13372 * ``` 13373 * 13374 * This is needed in because, when GFM footnotes are enabled, images never 13375 * form when started with a `^`. 13376 * Instead, links form: 13377 * 13378 * ```markdown 13379 *  13380 * 13381 * ![^a][b] 13382 * 13383 * [b]: c 13384 * ``` 13385 * 13386 * ```html 13387 * <p>!<a href=\"b\">^a</a></p> 13388 * <p>!<a href=\"c\">^a</a></p> 13389 * ``` 13390 * 13391 * @type {State} 13392 */ 13393 function after(code) { 13394 // To do: use a new field to do this, this is still needed for 13395 // `micromark-extension-gfm-footnote`, but the `label-start-link` 13396 // behavior isnât. 13397 // Hidden footnotes hook. 13398 /* c8 ignore next 3 */ 13399 return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs ? nok(code) : ok(code); 13400 } 13401} 13402;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-core-commonmark/lib/label-start-link.js 13403/** 13404 * @import { 13405 * Construct, 13406 * State, 13407 * TokenizeContext, 13408 * Tokenizer 13409 * } from 'micromark-util-types' 13410 */ 13411 13412 13413 13414/** @type {Construct} */ 13415const labelStartLink = { 13416 name: 'labelStartLink', 13417 resolveAll: labelEnd.resolveAll, 13418 tokenize: tokenizeLabelStartLink 13419}; 13420 13421/** 13422 * @this {TokenizeContext} 13423 * Context. 13424 * @type {Tokenizer} 13425 */ 13426function tokenizeLabelStartLink(effects, ok, nok) { 13427 const self = this; 13428 return start; 13429 13430 /** 13431 * Start of label (link) start. 13432 * 13433 * ```markdown 13434 * > | a [b] c 13435 * ^ 13436 * ``` 13437 * 13438 * @type {State} 13439 */ 13440 function start(code) { 13441 effects.enter("labelLink"); 13442 effects.enter("labelMarker"); 13443 effects.consume(code); 13444 effects.exit("labelMarker"); 13445 effects.exit("labelLink"); 13446 return after; 13447 } 13448 13449 /** @type {State} */ 13450 function after(code) { 13451 // To do: this isnât needed in `micromark-extension-gfm-footnote`, 13452 // remove. 13453 // Hidden footnotes hook. 13454 /* c8 ignore next 3 */ 13455 return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs ? nok(code) : ok(code); 13456 } 13457} 13458;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-core-commonmark/lib/line-ending.js 13459/** 13460 * @import { 13461 * Construct, 13462 * State, 13463 * TokenizeContext, 13464 * Tokenizer 13465 * } from 'micromark-util-types' 13466 */ 13467 13468 13469 13470/** @type {Construct} */ 13471const lineEnding = { 13472 name: 'lineEnding', 13473 tokenize: tokenizeLineEnding 13474}; 13475 13476/** 13477 * @this {TokenizeContext} 13478 * Context. 13479 * @type {Tokenizer} 13480 */ 13481function tokenizeLineEnding(effects, ok) { 13482 return start; 13483 13484 /** @type {State} */ 13485 function start(code) { 13486 effects.enter("lineEnding"); 13487 effects.consume(code); 13488 effects.exit("lineEnding"); 13489 return factorySpace(effects, ok, "linePrefix"); 13490 } 13491} 13492;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-core-commonmark/lib/thematic-break.js 13493/** 13494 * @import { 13495 * Code, 13496 * Construct, 13497 * State, 13498 * TokenizeContext, 13499 * Tokenizer 13500 * } from 'micromark-util-types' 13501 */ 13502 13503 13504 13505/** @type {Construct} */ 13506const thematicBreak = { 13507 name: 'thematicBreak', 13508 tokenize: tokenizeThematicBreak 13509}; 13510 13511/** 13512 * @this {TokenizeContext} 13513 * Context. 13514 * @type {Tokenizer} 13515 */ 13516function tokenizeThematicBreak(effects, ok, nok) { 13517 let size = 0; 13518 /** @type {NonNullable<Code>} */ 13519 let marker; 13520 return start; 13521 13522 /** 13523 * Start of thematic break. 13524 * 13525 * ```markdown 13526 * > | *** 13527 * ^ 13528 * ``` 13529 * 13530 * @type {State} 13531 */ 13532 function start(code) { 13533 effects.enter("thematicBreak"); 13534 // To do: parse indent like `markdown-rs`. 13535 return before(code); 13536 } 13537 13538 /** 13539 * After optional whitespace, at marker. 13540 * 13541 * ```markdown 13542 * > | *** 13543 * ^ 13544 * ``` 13545 * 13546 * @type {State} 13547 */ 13548 function before(code) { 13549 marker = code; 13550 return atBreak(code); 13551 } 13552 13553 /** 13554 * After something, before something else. 13555 * 13556 * ```markdown 13557 * > | *** 13558 * ^ 13559 * ``` 13560 * 13561 * @type {State} 13562 */ 13563 function atBreak(code) { 13564 if (code === marker) { 13565 effects.enter("thematicBreakSequence"); 13566 return sequence(code); 13567 } 13568 if (size >= 3 && (code === null || markdownLineEnding(code))) { 13569 effects.exit("thematicBreak"); 13570 return ok(code); 13571 } 13572 return nok(code); 13573 } 13574 13575 /** 13576 * In sequence. 13577 * 13578 * ```markdown 13579 * > | *** 13580 * ^ 13581 * ``` 13582 * 13583 * @type {State} 13584 */ 13585 function sequence(code) { 13586 if (code === marker) { 13587 effects.consume(code); 13588 size++; 13589 return sequence; 13590 } 13591 effects.exit("thematicBreakSequence"); 13592 return markdownSpace(code) ? factorySpace(effects, atBreak, "whitespace")(code) : atBreak(code); 13593 } 13594} 13595;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-core-commonmark/lib/list.js 13596/** 13597 * @import { 13598 * Code, 13599 * Construct, 13600 * Exiter, 13601 * State, 13602 * TokenizeContext, 13603 * Tokenizer 13604 * } from 'micromark-util-types' 13605 */ 13606 13607 13608 13609 13610 13611 13612/** @type {Construct} */ 13613const list = { 13614 continuation: { 13615 tokenize: tokenizeListContinuation 13616 }, 13617 exit: tokenizeListEnd, 13618 name: 'list', 13619 tokenize: tokenizeListStart 13620}; 13621 13622/** @type {Construct} */ 13623const listItemPrefixWhitespaceConstruct = { 13624 partial: true, 13625 tokenize: tokenizeListItemPrefixWhitespace 13626}; 13627 13628/** @type {Construct} */ 13629const indentConstruct = { 13630 partial: true, 13631 tokenize: tokenizeIndent 13632}; 13633 13634// To do: `markdown-rs` parses list items on their own and later stitches them 13635// together. 13636 13637/** 13638 * @this {TokenizeContext} 13639 * Context. 13640 * @type {Tokenizer} 13641 */ 13642function tokenizeListStart(effects, ok, nok) { 13643 const self = this; 13644 const tail = self.events[self.events.length - 1]; 13645 let initialSize = tail && tail[1].type === "linePrefix" ? tail[2].sliceSerialize(tail[1], true).length : 0; 13646 let size = 0; 13647 return start; 13648 13649 /** @type {State} */ 13650 function start(code) { 13651 const kind = self.containerState.type || (code === 42 || code === 43 || code === 45 ? "listUnordered" : "listOrdered"); 13652 if (kind === "listUnordered" ? !self.containerState.marker || code === self.containerState.marker : asciiDigit(code)) { 13653 if (!self.containerState.type) { 13654 self.containerState.type = kind; 13655 effects.enter(kind, { 13656 _container: true 13657 }); 13658 } 13659 if (kind === "listUnordered") { 13660 effects.enter("listItemPrefix"); 13661 return code === 42 || code === 45 ? effects.check(thematicBreak, nok, atMarker)(code) : atMarker(code); 13662 } 13663 if (!self.interrupt || code === 49) { 13664 effects.enter("listItemPrefix"); 13665 effects.enter("listItemValue"); 13666 return inside(code); 13667 } 13668 } 13669 return nok(code); 13670 } 13671 13672 /** @type {State} */ 13673 function inside(code) { 13674 if (asciiDigit(code) && ++size < 10) { 13675 effects.consume(code); 13676 return inside; 13677 } 13678 if ((!self.interrupt || size < 2) && (self.containerState.marker ? code === self.containerState.marker : code === 41 || code === 46)) { 13679 effects.exit("listItemValue"); 13680 return atMarker(code); 13681 } 13682 return nok(code); 13683 } 13684 13685 /** 13686 * @type {State} 13687 **/ 13688 function atMarker(code) { 13689 effects.enter("listItemMarker"); 13690 effects.consume(code); 13691 effects.exit("listItemMarker"); 13692 self.containerState.marker = self.containerState.marker || code; 13693 return effects.check(blankLine, 13694 // Canât be empty when interrupting. 13695 self.interrupt ? nok : onBlank, effects.attempt(listItemPrefixWhitespaceConstruct, endOfPrefix, otherPrefix)); 13696 } 13697 13698 /** @type {State} */ 13699 function onBlank(code) { 13700 self.containerState.initialBlankLine = true; 13701 initialSize++; 13702 return endOfPrefix(code); 13703 } 13704 13705 /** @type {State} */ 13706 function otherPrefix(code) { 13707 if (markdownSpace(code)) { 13708 effects.enter("listItemPrefixWhitespace"); 13709 effects.consume(code); 13710 effects.exit("listItemPrefixWhitespace"); 13711 return endOfPrefix; 13712 } 13713 return nok(code); 13714 } 13715 13716 /** @type {State} */ 13717 function endOfPrefix(code) { 13718 self.containerState.size = initialSize + self.sliceSerialize(effects.exit("listItemPrefix"), true).length; 13719 return ok(code); 13720 } 13721} 13722 13723/** 13724 * @this {TokenizeContext} 13725 * Context. 13726 * @type {Tokenizer} 13727 */ 13728function tokenizeListContinuation(effects, ok, nok) { 13729 const self = this; 13730 self.containerState._closeFlow = undefined; 13731 return effects.check(blankLine, onBlank, notBlank); 13732 13733 /** @type {State} */ 13734 function onBlank(code) { 13735 self.containerState.furtherBlankLines = self.containerState.furtherBlankLines || self.containerState.initialBlankLine; 13736 13737 // We have a blank line. 13738 // Still, try to consume at most the items size. 13739 return factorySpace(effects, ok, "listItemIndent", self.containerState.size + 1)(code); 13740 } 13741 13742 /** @type {State} */ 13743 function notBlank(code) { 13744 if (self.containerState.furtherBlankLines || !markdownSpace(code)) { 13745 self.containerState.furtherBlankLines = undefined; 13746 self.containerState.initialBlankLine = undefined; 13747 return notInCurrentItem(code); 13748 } 13749 self.containerState.furtherBlankLines = undefined; 13750 self.containerState.initialBlankLine = undefined; 13751 return effects.attempt(indentConstruct, ok, notInCurrentItem)(code); 13752 } 13753 13754 /** @type {State} */ 13755 function notInCurrentItem(code) { 13756 // While we do continue, we signal that the flow should be closed. 13757 self.containerState._closeFlow = true; 13758 // As weâre closing flow, weâre no longer interrupting. 13759 self.interrupt = undefined; 13760 // Always populated by defaults. 13761 13762 return factorySpace(effects, effects.attempt(list, ok, nok), "linePrefix", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4)(code); 13763 } 13764} 13765 13766/** 13767 * @this {TokenizeContext} 13768 * Context. 13769 * @type {Tokenizer} 13770 */ 13771function tokenizeIndent(effects, ok, nok) { 13772 const self = this; 13773 return factorySpace(effects, afterPrefix, "listItemIndent", self.containerState.size + 1); 13774 13775 /** @type {State} */ 13776 function afterPrefix(code) { 13777 const tail = self.events[self.events.length - 1]; 13778 return tail && tail[1].type === "listItemIndent" && tail[2].sliceSerialize(tail[1], true).length === self.containerState.size ? ok(code) : nok(code); 13779 } 13780} 13781 13782/** 13783 * @this {TokenizeContext} 13784 * Context. 13785 * @type {Exiter} 13786 */ 13787function tokenizeListEnd(effects) { 13788 effects.exit(this.containerState.type); 13789} 13790 13791/** 13792 * @this {TokenizeContext} 13793 * Context. 13794 * @type {Tokenizer} 13795 */ 13796function tokenizeListItemPrefixWhitespace(effects, ok, nok) { 13797 const self = this; 13798 13799 // Always populated by defaults. 13800 13801 return factorySpace(effects, afterPrefix, "listItemPrefixWhitespace", self.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4 + 1); 13802 13803 /** @type {State} */ 13804 function afterPrefix(code) { 13805 const tail = self.events[self.events.length - 1]; 13806 return !markdownSpace(code) && tail && tail[1].type === "listItemPrefixWhitespace" ? ok(code) : nok(code); 13807 } 13808} 13809;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-core-commonmark/lib/setext-underline.js 13810/** 13811 * @import { 13812 * Code, 13813 * Construct, 13814 * Resolver, 13815 * State, 13816 * TokenizeContext, 13817 * Tokenizer 13818 * } from 'micromark-util-types' 13819 */ 13820 13821 13822 13823/** @type {Construct} */ 13824const setextUnderline = { 13825 name: 'setextUnderline', 13826 resolveTo: resolveToSetextUnderline, 13827 tokenize: tokenizeSetextUnderline 13828}; 13829 13830/** @type {Resolver} */ 13831function resolveToSetextUnderline(events, context) { 13832 // To do: resolve like `markdown-rs`. 13833 let index = events.length; 13834 /** @type {number | undefined} */ 13835 let content; 13836 /** @type {number | undefined} */ 13837 let text; 13838 /** @type {number | undefined} */ 13839 let definition; 13840 13841 // Find the opening of the content. 13842 // Itâll always exist: we donât tokenize if it isnât there. 13843 while (index--) { 13844 if (events[index][0] === 'enter') { 13845 if (events[index][1].type === "content") { 13846 content = index; 13847 break; 13848 } 13849 if (events[index][1].type === "paragraph") { 13850 text = index; 13851 } 13852 } 13853 // Exit 13854 else { 13855 if (events[index][1].type === "content") { 13856 // Remove the content end (if needed weâll add it later) 13857 events.splice(index, 1); 13858 } 13859 if (!definition && events[index][1].type === "definition") { 13860 definition = index; 13861 } 13862 } 13863 } 13864 const heading = { 13865 type: "setextHeading", 13866 start: { 13867 ...events[content][1].start 13868 }, 13869 end: { 13870 ...events[events.length - 1][1].end 13871 } 13872 }; 13873 13874 // Change the paragraph to setext heading text. 13875 events[text][1].type = "setextHeadingText"; 13876 13877 // If we have definitions in the content, weâll keep on having content, 13878 // but we need move it. 13879 if (definition) { 13880 events.splice(text, 0, ['enter', heading, context]); 13881 events.splice(definition + 1, 0, ['exit', events[content][1], context]); 13882 events[content][1].end = { 13883 ...events[definition][1].end 13884 }; 13885 } else { 13886 events[content][1] = heading; 13887 } 13888 13889 // Add the heading exit at the end. 13890 events.push(['exit', heading, context]); 13891 return events; 13892} 13893 13894/** 13895 * @this {TokenizeContext} 13896 * Context. 13897 * @type {Tokenizer} 13898 */ 13899function tokenizeSetextUnderline(effects, ok, nok) { 13900 const self = this; 13901 /** @type {NonNullable<Code>} */ 13902 let marker; 13903 return start; 13904 13905 /** 13906 * At start of heading (setext) underline. 13907 * 13908 * ```markdown 13909 * | aa 13910 * > | == 13911 * ^ 13912 * ``` 13913 * 13914 * @type {State} 13915 */ 13916 function start(code) { 13917 let index = self.events.length; 13918 /** @type {boolean | undefined} */ 13919 let paragraph; 13920 // Find an opening. 13921 while (index--) { 13922 // Skip enter/exit of line ending, line prefix, and content. 13923 // We can now either have a definition or a paragraph. 13924 if (self.events[index][1].type !== "lineEnding" && self.events[index][1].type !== "linePrefix" && self.events[index][1].type !== "content") { 13925 paragraph = self.events[index][1].type === "paragraph"; 13926 break; 13927 } 13928 } 13929 13930 // To do: handle lazy/pierce like `markdown-rs`. 13931 // To do: parse indent like `markdown-rs`. 13932 if (!self.parser.lazy[self.now().line] && (self.interrupt || paragraph)) { 13933 effects.enter("setextHeadingLine"); 13934 marker = code; 13935 return before(code); 13936 } 13937 return nok(code); 13938 } 13939 13940 /** 13941 * After optional whitespace, at `-` or `=`. 13942 * 13943 * ```markdown 13944 * | aa 13945 * > | == 13946 * ^ 13947 * ``` 13948 * 13949 * @type {State} 13950 */ 13951 function before(code) { 13952 effects.enter("setextHeadingLineSequence"); 13953 return inside(code); 13954 } 13955 13956 /** 13957 * In sequence. 13958 * 13959 * ```markdown 13960 * | aa 13961 * > | == 13962 * ^ 13963 * ``` 13964 * 13965 * @type {State} 13966 */ 13967 function inside(code) { 13968 if (code === marker) { 13969 effects.consume(code); 13970 return inside; 13971 } 13972 effects.exit("setextHeadingLineSequence"); 13973 return markdownSpace(code) ? factorySpace(effects, after, "lineSuffix")(code) : after(code); 13974 } 13975 13976 /** 13977 * After sequence, after optional whitespace. 13978 * 13979 * ```markdown 13980 * | aa 13981 * > | == 13982 * ^ 13983 * ``` 13984 * 13985 * @type {State} 13986 */ 13987 function after(code) { 13988 if (code === null || markdownLineEnding(code)) { 13989 effects.exit("setextHeadingLine"); 13990 return ok(code); 13991 } 13992 return nok(code); 13993 } 13994} 13995;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-core-commonmark/index.js 13996 13997 13998 13999 14000 14001 14002 14003 14004 14005 14006 14007 14008 14009 14010 14011 14012 14013 14014 14015 14016 14017 14018;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark/lib/initialize/flow.js 14019/** 14020 * @import { 14021 * InitialConstruct, 14022 * Initializer, 14023 * State, 14024 * TokenizeContext 14025 * } from 'micromark-util-types' 14026 */ 14027 14028 14029 14030 14031/** @type {InitialConstruct} */ 14032const flow = { 14033 tokenize: initializeFlow 14034}; 14035 14036/** 14037 * @this {TokenizeContext} 14038 * Self. 14039 * @type {Initializer} 14040 * Initializer. 14041 */ 14042function initializeFlow(effects) { 14043 const self = this; 14044 const initial = effects.attempt( 14045 // Try to parse a blank line. 14046 blankLine, atBlankEnding, 14047 // Try to parse initial flow (essentially, only code). 14048 effects.attempt(this.parser.constructs.flowInitial, afterConstruct, factorySpace(effects, effects.attempt(this.parser.constructs.flow, afterConstruct, effects.attempt(content_content, afterConstruct)), "linePrefix"))); 14049 return initial; 14050 14051 /** @type {State} */ 14052 function atBlankEnding(code) { 14053 if (code === null) { 14054 effects.consume(code); 14055 return; 14056 } 14057 effects.enter("lineEndingBlank"); 14058 effects.consume(code); 14059 effects.exit("lineEndingBlank"); 14060 self.currentConstruct = undefined; 14061 return initial; 14062 } 14063 14064 /** @type {State} */ 14065 function afterConstruct(code) { 14066 if (code === null) { 14067 effects.consume(code); 14068 return; 14069 } 14070 effects.enter("lineEnding"); 14071 effects.consume(code); 14072 effects.exit("lineEnding"); 14073 self.currentConstruct = undefined; 14074 return initial; 14075 } 14076} 14077;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark/lib/initialize/text.js 14078/** 14079 * @import { 14080 * Code, 14081 * InitialConstruct, 14082 * Initializer, 14083 * Resolver, 14084 * State, 14085 * TokenizeContext 14086 * } from 'micromark-util-types' 14087 */ 14088 14089const resolver = { 14090 resolveAll: createResolver() 14091}; 14092const string = initializeFactory('string'); 14093const text_text = initializeFactory('text'); 14094 14095/** 14096 * @param {'string' | 'text'} field 14097 * Field. 14098 * @returns {InitialConstruct} 14099 * Construct. 14100 */ 14101function initializeFactory(field) { 14102 return { 14103 resolveAll: createResolver(field === 'text' ? resolveAllLineSuffixes : undefined), 14104 tokenize: initializeText 14105 }; 14106 14107 /** 14108 * @this {TokenizeContext} 14109 * Context. 14110 * @type {Initializer} 14111 */ 14112 function initializeText(effects) { 14113 const self = this; 14114 const constructs = this.parser.constructs[field]; 14115 const text = effects.attempt(constructs, start, notText); 14116 return start; 14117 14118 /** @type {State} */ 14119 function start(code) { 14120 return atBreak(code) ? text(code) : notText(code); 14121 } 14122 14123 /** @type {State} */ 14124 function notText(code) { 14125 if (code === null) { 14126 effects.consume(code); 14127 return; 14128 } 14129 effects.enter("data"); 14130 effects.consume(code); 14131 return data; 14132 } 14133 14134 /** @type {State} */ 14135 function data(code) { 14136 if (atBreak(code)) { 14137 effects.exit("data"); 14138 return text(code); 14139 } 14140 14141 // Data. 14142 effects.consume(code); 14143 return data; 14144 } 14145 14146 /** 14147 * @param {Code} code 14148 * Code. 14149 * @returns {boolean} 14150 * Whether the code is a break. 14151 */ 14152 function atBreak(code) { 14153 if (code === null) { 14154 return true; 14155 } 14156 const list = constructs[code]; 14157 let index = -1; 14158 if (list) { 14159 // Always populated by defaults. 14160 14161 while (++index < list.length) { 14162 const item = list[index]; 14163 if (!item.previous || item.previous.call(self, self.previous)) { 14164 return true; 14165 } 14166 } 14167 } 14168 return false; 14169 } 14170 } 14171} 14172 14173/** 14174 * @param {Resolver | undefined} [extraResolver] 14175 * Resolver. 14176 * @returns {Resolver} 14177 * Resolver. 14178 */ 14179function createResolver(extraResolver) { 14180 return resolveAllText; 14181 14182 /** @type {Resolver} */ 14183 function resolveAllText(events, context) { 14184 let index = -1; 14185 /** @type {number | undefined} */ 14186 let enter; 14187 14188 // A rather boring computation (to merge adjacent `data` events) which 14189 // improves mm performance by 29%. 14190 while (++index <= events.length) { 14191 if (enter === undefined) { 14192 if (events[index] && events[index][1].type === "data") { 14193 enter = index; 14194 index++; 14195 } 14196 } else if (!events[index] || events[index][1].type !== "data") { 14197 // Donât do anything if there is one data token. 14198 if (index !== enter + 2) { 14199 events[enter][1].end = events[index - 1][1].end; 14200 events.splice(enter + 2, index - enter - 2); 14201 index = enter + 2; 14202 } 14203 enter = undefined; 14204 } 14205 } 14206 return extraResolver ? extraResolver(events, context) : events; 14207 } 14208} 14209 14210/** 14211 * A rather ugly set of instructions which again looks at chunks in the input 14212 * stream. 14213 * The reason to do this here is that it is *much* faster to parse in reverse. 14214 * And that we canât hook into `null` to split the line suffix before an EOF. 14215 * To do: figure out if we can make this into a clean utility, or even in core. 14216 * As it will be useful for GFMs literal autolink extension (and maybe even 14217 * tables?) 14218 * 14219 * @type {Resolver} 14220 */ 14221function resolveAllLineSuffixes(events, context) { 14222 let eventIndex = 0; // Skip first. 14223 14224 while (++eventIndex <= events.length) { 14225 if ((eventIndex === events.length || events[eventIndex][1].type === "lineEnding") && events[eventIndex - 1][1].type === "data") { 14226 const data = events[eventIndex - 1][1]; 14227 const chunks = context.sliceStream(data); 14228 let index = chunks.length; 14229 let bufferIndex = -1; 14230 let size = 0; 14231 /** @type {boolean | undefined} */ 14232 let tabs; 14233 while (index--) { 14234 const chunk = chunks[index]; 14235 if (typeof chunk === 'string') { 14236 bufferIndex = chunk.length; 14237 while (chunk.charCodeAt(bufferIndex - 1) === 32) { 14238 size++; 14239 bufferIndex--; 14240 } 14241 if (bufferIndex) break; 14242 bufferIndex = -1; 14243 } 14244 // Number 14245 else if (chunk === -2) { 14246 tabs = true; 14247 size++; 14248 } else if (chunk === -1) { 14249 // Empty 14250 } else { 14251 // Replacement character, exit. 14252 index++; 14253 break; 14254 } 14255 } 14256 14257 // Allow final trailing whitespace. 14258 if (context._contentTypeTextTrailing && eventIndex === events.length) { 14259 size = 0; 14260 } 14261 if (size) { 14262 const token = { 14263 type: eventIndex === events.length || tabs || size < 2 ? "lineSuffix" : "hardBreakTrailing", 14264 start: { 14265 _bufferIndex: index ? bufferIndex : data.start._bufferIndex + bufferIndex, 14266 _index: data.start._index + index, 14267 line: data.end.line, 14268 column: data.end.column - size, 14269 offset: data.end.offset - size 14270 }, 14271 end: { 14272 ...data.end 14273 } 14274 }; 14275 data.end = { 14276 ...token.start 14277 }; 14278 if (data.start.offset === data.end.offset) { 14279 Object.assign(data, token); 14280 } else { 14281 events.splice(eventIndex, 0, ['enter', token, context], ['exit', token, context]); 14282 eventIndex += 2; 14283 } 14284 } 14285 eventIndex++; 14286 } 14287 } 14288 return events; 14289} 14290;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark/lib/constructs.js 14291/** 14292 * @import {Extension} from 'micromark-util-types' 14293 */ 14294 14295 14296 14297 14298/** @satisfies {Extension['document']} */ 14299const constructs_document = { 14300 [42]: list, 14301 [43]: list, 14302 [45]: list, 14303 [48]: list, 14304 [49]: list, 14305 [50]: list, 14306 [51]: list, 14307 [52]: list, 14308 [53]: list, 14309 [54]: list, 14310 [55]: list, 14311 [56]: list, 14312 [57]: list, 14313 [62]: blockQuote 14314}; 14315 14316/** @satisfies {Extension['contentInitial']} */ 14317const contentInitial = { 14318 [91]: definition 14319}; 14320 14321/** @satisfies {Extension['flowInitial']} */ 14322const flowInitial = { 14323 [-2]: codeIndented, 14324 [-1]: codeIndented, 14325 [32]: codeIndented 14326}; 14327 14328/** @satisfies {Extension['flow']} */ 14329const constructs_flow = { 14330 [35]: headingAtx, 14331 [42]: thematicBreak, 14332 [45]: [setextUnderline, thematicBreak], 14333 [60]: htmlFlow, 14334 [61]: setextUnderline, 14335 [95]: thematicBreak, 14336 [96]: codeFenced, 14337 [126]: codeFenced 14338}; 14339 14340/** @satisfies {Extension['string']} */ 14341const constructs_string = { 14342 [38]: characterReference, 14343 [92]: characterEscape 14344}; 14345 14346/** @satisfies {Extension['text']} */ 14347const constructs_text = { 14348 [-5]: lineEnding, 14349 [-4]: lineEnding, 14350 [-3]: lineEnding, 14351 [33]: labelStartImage, 14352 [38]: characterReference, 14353 [42]: attention, 14354 [60]: [autolink, htmlText], 14355 [91]: labelStartLink, 14356 [92]: [hardBreakEscape, characterEscape], 14357 [93]: labelEnd, 14358 [95]: attention, 14359 [96]: codeText 14360}; 14361 14362/** @satisfies {Extension['insideSpan']} */ 14363const insideSpan = { 14364 null: [attention, resolver] 14365}; 14366 14367/** @satisfies {Extension['attentionMarkers']} */ 14368const attentionMarkers = { 14369 null: [42, 95] 14370}; 14371 14372/** @satisfies {Extension['disable']} */ 14373const disable = { 14374 null: [] 14375}; 14376;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark/lib/create-tokenizer.js 14377/** 14378 * @import { 14379 * Chunk,
vendor: 4,484 bytes, lines 14380-14580
14380 * Code, 14381 * ConstructRecord, 14382 * Construct, 14383 * Effects, 14384 * InitialConstruct, 14385 * ParseContext, 14386 * Point, 14387 * State, 14388 * TokenizeContext, 14389 * Token 14390 * } from 'micromark-util-types' 14391 */ 14392 14393/** 14394 * @callback Restore 14395 * Restore the state. 14396 * @returns {undefined} 14397 * Nothing. 14398 * 14399 * @typedef Info 14400 * Info. 14401 * @property {Restore} restore 14402 * Restore. 14403 * @property {number} from 14404 * From. 14405 * 14406 * @callback ReturnHandle 14407 * Handle a successful run. 14408 * @param {Construct} construct 14409 * Construct. 14410 * @param {Info} info 14411 * Info. 14412 * @returns {undefined} 14413 * Nothing. 14414 */ 14415 14416 14417 14418 14419/** 14420 * Create a tokenizer. 14421 * Tokenizers deal with one type of data (e.g., containers, flow, text). 14422 * The parser is the object dealing with it all. 14423 * `initialize` works like other constructs, except that only its `tokenize` 14424 * function is used, in which case it doesnât receive an `ok` or `nok`. 14425 * `from` can be given to set the point before the first character, although 14426 * when further lines are indented, they must be set with `defineSkip`. 14427 * 14428 * @param {ParseContext} parser 14429 * Parser. 14430 * @param {InitialConstruct} initialize 14431 * Construct. 14432 * @param {Omit<Point, '_bufferIndex' | '_index'> | undefined} [from] 14433 * Point (optional). 14434 * @returns {TokenizeContext} 14435 * Context. 14436 */ 14437function createTokenizer(parser, initialize, from) { 14438 /** @type {Point} */ 14439 let point = { 14440 _bufferIndex: -1, 14441 _index: 0, 14442 line: from && from.line || 1, 14443 column: from && from.column || 1, 14444 offset: from && from.offset || 0 14445 }; 14446 /** @type {Record<string, number>} */ 14447 const columnStart = {}; 14448 /** @type {Array<Construct>} */ 14449 const resolveAllConstructs = []; 14450 /** @type {Array<Chunk>} */ 14451 let chunks = []; 14452 /** @type {Array<Token>} */ 14453 let stack = []; 14454 /** @type {boolean | undefined} */ 14455 let consumed = true; 14456 14457 /** 14458 * Tools used for tokenizing. 14459 * 14460 * @type {Effects} 14461 */ 14462 const effects = { 14463 attempt: constructFactory(onsuccessfulconstruct), 14464 check: constructFactory(onsuccessfulcheck), 14465 consume, 14466 enter, 14467 exit, 14468 interrupt: constructFactory(onsuccessfulcheck, { 14469 interrupt: true 14470 }) 14471 }; 14472 14473 /** 14474 * State and tools for resolving and serializing. 14475 * 14476 * @type {TokenizeContext} 14477 */ 14478 const context = { 14479 code: null, 14480 containerState: {}, 14481 defineSkip, 14482 events: [], 14483 now, 14484 parser, 14485 previous: null, 14486 sliceSerialize, 14487 sliceStream, 14488 write 14489 }; 14490 14491 /** 14492 * The state function. 14493 * 14494 * @type {State | undefined} 14495 */ 14496 let state = initialize.tokenize.call(context, effects); 14497 14498 /** 14499 * Track which character we expect to be consumed, to catch bugs. 14500 * 14501 * @type {Code} 14502 */ 14503 let expectedCode; 14504 if (initialize.resolveAll) { 14505 resolveAllConstructs.push(initialize); 14506 } 14507 return context; 14508 14509 /** @type {TokenizeContext['write']} */ 14510 function write(slice) { 14511 chunks = micromark_util_chunked_push(chunks, slice); 14512 main(); 14513 14514 // Exit if weâre not done, resolve might change stuff. 14515 if (chunks[chunks.length - 1] !== null) { 14516 return []; 14517 } 14518 addResult(initialize, 0); 14519 14520 // Otherwise, resolve, and exit. 14521 context.events = resolveAll(resolveAllConstructs, context.events, context); 14522 return context.events; 14523 } 14524 14525 // 14526 // Tools. 14527 // 14528 14529 /** @type {TokenizeContext['sliceSerialize']} */ 14530 function sliceSerialize(token, expandTabs) { 14531 return serializeChunks(sliceStream(token), expandTabs); 14532 } 14533 14534 /** @type {TokenizeContext['sliceStream']} */ 14535 function sliceStream(token) { 14536 return sliceChunks(chunks, token); 14537 } 14538 14539 /** @type {TokenizeContext['now']} */ 14540 function now() { 14541 // This is a hot path, so we clone manually instead of `Object.assign({}, point)` 14542 const { 14543 _bufferIndex, 14544 _index, 14545 line, 14546 column, 14547 offset 14548 } = point; 14549 return { 14550 _bufferIndex, 14551 _index, 14552 line, 14553 column, 14554 offset 14555 }; 14556 } 14557 14558 /** @type {TokenizeContext['defineSkip']} */ 14559 function defineSkip(value) { 14560 columnStart[value.line] = value.column; 14561 accountForPotentialSkip(); 14562 } 14563 14564 // 14565 // State management. 14566 // 14567 14568 /** 14569 * Main loop (note that `_index` and `_bufferIndex` in `point` are modified by 14570 * `consume`). 14571 * Here is where we walk through the chunks, which either include strings of 14572 * several characters, or numerical character codes. 14573 * The reason to do this in a loop instead of a call is so the stack can 14574 * drain. 14575 * 14576 * @returns {undefined} 14577 * Nothing. 14578 */ 14579 function main() { 14580 /** @type {number} */
vendor: 14,600 bytes, lines 14581-15151
14581 let chunkIndex; 14582 while (point._index < chunks.length) { 14583 const chunk = chunks[point._index]; 14584 14585 // If weâre in a buffer chunk, loop through it. 14586 if (typeof chunk === 'string') { 14587 chunkIndex = point._index; 14588 if (point._bufferIndex < 0) { 14589 point._bufferIndex = 0; 14590 } 14591 while (point._index === chunkIndex && point._bufferIndex < chunk.length) { 14592 go(chunk.charCodeAt(point._bufferIndex)); 14593 } 14594 } else { 14595 go(chunk); 14596 } 14597 } 14598 } 14599 14600 /** 14601 * Deal with one code. 14602 * 14603 * @param {Code} code 14604 * Code. 14605 * @returns {undefined} 14606 * Nothing. 14607 */ 14608 function go(code) { 14609 consumed = undefined; 14610 expectedCode = code; 14611 state = state(code); 14612 } 14613 14614 /** @type {Effects['consume']} */ 14615 function consume(code) { 14616 if (markdownLineEnding(code)) { 14617 point.line++; 14618 point.column = 1; 14619 point.offset += code === -3 ? 2 : 1; 14620 accountForPotentialSkip(); 14621 } else if (code !== -1) { 14622 point.column++; 14623 point.offset++; 14624 } 14625 14626 // Not in a string chunk. 14627 if (point._bufferIndex < 0) { 14628 point._index++; 14629 } else { 14630 point._bufferIndex++; 14631 14632 // At end of string chunk. 14633 if (point._bufferIndex === 14634 // Points w/ non-negative `_bufferIndex` reference 14635 // strings. 14636 /** @type {string} */ 14637 chunks[point._index].length) { 14638 point._bufferIndex = -1; 14639 point._index++; 14640 } 14641 } 14642 14643 // Expose the previous character. 14644 context.previous = code; 14645 14646 // Mark as consumed. 14647 consumed = true; 14648 } 14649 14650 /** @type {Effects['enter']} */ 14651 function enter(type, fields) { 14652 /** @type {Token} */ 14653 // @ts-expect-error Patch instead of assign required fields to help GC. 14654 const token = fields || {}; 14655 token.type = type; 14656 token.start = now(); 14657 context.events.push(['enter', token, context]); 14658 stack.push(token); 14659 return token; 14660 } 14661 14662 /** @type {Effects['exit']} */ 14663 function exit(type) { 14664 const token = stack.pop(); 14665 token.end = now(); 14666 context.events.push(['exit', token, context]); 14667 return token; 14668 } 14669 14670 /** 14671 * Use results. 14672 * 14673 * @type {ReturnHandle} 14674 */ 14675 function onsuccessfulconstruct(construct, info) { 14676 addResult(construct, info.from); 14677 } 14678 14679 /** 14680 * Discard results. 14681 * 14682 * @type {ReturnHandle} 14683 */ 14684 function onsuccessfulcheck(_, info) { 14685 info.restore(); 14686 } 14687 14688 /** 14689 * Factory to attempt/check/interrupt. 14690 * 14691 * @param {ReturnHandle} onreturn 14692 * Callback. 14693 * @param {{interrupt?: boolean | undefined} | undefined} [fields] 14694 * Fields. 14695 */ 14696 function constructFactory(onreturn, fields) { 14697 return hook; 14698 14699 /** 14700 * Handle either an object mapping codes to constructs, a list of 14701 * constructs, or a single construct. 14702 * 14703 * @param {Array<Construct> | ConstructRecord | Construct} constructs 14704 * Constructs. 14705 * @param {State} returnState 14706 * State. 14707 * @param {State | undefined} [bogusState] 14708 * State. 14709 * @returns {State} 14710 * State. 14711 */ 14712 function hook(constructs, returnState, bogusState) { 14713 /** @type {ReadonlyArray<Construct>} */ 14714 let listOfConstructs; 14715 /** @type {number} */ 14716 let constructIndex; 14717 /** @type {Construct} */ 14718 let currentConstruct; 14719 /** @type {Info} */ 14720 let info; 14721 return Array.isArray(constructs) ? /* c8 ignore next 1 */ 14722 handleListOfConstructs(constructs) : 'tokenize' in constructs ? 14723 // Looks like a construct. 14724 handleListOfConstructs([(/** @type {Construct} */constructs)]) : handleMapOfConstructs(constructs); 14725 14726 /** 14727 * Handle a list of construct. 14728 * 14729 * @param {ConstructRecord} map 14730 * Constructs. 14731 * @returns {State} 14732 * State. 14733 */ 14734 function handleMapOfConstructs(map) { 14735 return start; 14736 14737 /** @type {State} */ 14738 function start(code) { 14739 const left = code !== null && map[code]; 14740 const all = code !== null && map.null; 14741 const list = [ 14742 // To do: add more extension tests. 14743 /* c8 ignore next 2 */ 14744 ...(Array.isArray(left) ? left : left ? [left] : []), ...(Array.isArray(all) ? all : all ? [all] : [])]; 14745 return handleListOfConstructs(list)(code); 14746 } 14747 } 14748 14749 /** 14750 * Handle a list of construct. 14751 * 14752 * @param {ReadonlyArray<Construct>} list 14753 * Constructs. 14754 * @returns {State} 14755 * State. 14756 */ 14757 function handleListOfConstructs(list) { 14758 listOfConstructs = list; 14759 constructIndex = 0; 14760 if (list.length === 0) { 14761 return bogusState; 14762 } 14763 return handleConstruct(list[constructIndex]); 14764 } 14765 14766 /** 14767 * Handle a single construct. 14768 * 14769 * @param {Construct} construct 14770 * Construct. 14771 * @returns {State} 14772 * State. 14773 */ 14774 function handleConstruct(construct) { 14775 return start; 14776 14777 /** @type {State} */ 14778 function start(code) { 14779 // To do: not needed to store if there is no bogus state, probably? 14780 // Currently doesnât work because `inspect` in document does a check 14781 // w/o a bogus, which doesnât make sense. But it does seem to help perf 14782 // by not storing. 14783 info = store(); 14784 currentConstruct = construct; 14785 if (!construct.partial) { 14786 context.currentConstruct = construct; 14787 } 14788 14789 // Always populated by defaults. 14790 14791 if (construct.name && context.parser.constructs.disable.null.includes(construct.name)) { 14792 return nok(code); 14793 } 14794 return construct.tokenize.call( 14795 // If we do have fields, create an object w/ `context` as its 14796 // prototype. 14797 // This allows a âlive bindingâ, which is needed for `interrupt`. 14798 fields ? Object.assign(Object.create(context), fields) : context, effects, ok, nok)(code); 14799 } 14800 } 14801 14802 /** @type {State} */ 14803 function ok(code) { 14804 consumed = true; 14805 onreturn(currentConstruct, info); 14806 return returnState; 14807 } 14808 14809 /** @type {State} */ 14810 function nok(code) { 14811 consumed = true; 14812 info.restore(); 14813 if (++constructIndex < listOfConstructs.length) { 14814 return handleConstruct(listOfConstructs[constructIndex]); 14815 } 14816 return bogusState; 14817 } 14818 } 14819 } 14820 14821 /** 14822 * @param {Construct} construct 14823 * Construct. 14824 * @param {number} from 14825 * From. 14826 * @returns {undefined} 14827 * Nothing. 14828 */ 14829 function addResult(construct, from) { 14830 if (construct.resolveAll && !resolveAllConstructs.includes(construct)) { 14831 resolveAllConstructs.push(construct); 14832 } 14833 if (construct.resolve) { 14834 splice(context.events, from, context.events.length - from, construct.resolve(context.events.slice(from), context)); 14835 } 14836 if (construct.resolveTo) { 14837 context.events = construct.resolveTo(context.events, context); 14838 } 14839 } 14840 14841 /** 14842 * Store state. 14843 * 14844 * @returns {Info} 14845 * Info. 14846 */ 14847 function store() { 14848 const startPoint = now(); 14849 const startPrevious = context.previous; 14850 const startCurrentConstruct = context.currentConstruct; 14851 const startEventsIndex = context.events.length; 14852 const startStack = Array.from(stack); 14853 return { 14854 from: startEventsIndex, 14855 restore 14856 }; 14857 14858 /** 14859 * Restore state. 14860 * 14861 * @returns {undefined} 14862 * Nothing. 14863 */ 14864 function restore() { 14865 point = startPoint; 14866 context.previous = startPrevious; 14867 context.currentConstruct = startCurrentConstruct; 14868 context.events.length = startEventsIndex; 14869 stack = startStack; 14870 accountForPotentialSkip(); 14871 } 14872 } 14873 14874 /** 14875 * Move the current point a bit forward in the line when itâs on a column 14876 * skip. 14877 * 14878 * @returns {undefined} 14879 * Nothing. 14880 */ 14881 function accountForPotentialSkip() { 14882 if (point.line in columnStart && point.column < 2) { 14883 point.column = columnStart[point.line]; 14884 point.offset += columnStart[point.line] - 1; 14885 } 14886 } 14887} 14888 14889/** 14890 * Get the chunks from a slice of chunks in the range of a token. 14891 * 14892 * @param {ReadonlyArray<Chunk>} chunks 14893 * Chunks. 14894 * @param {Pick<Token, 'end' | 'start'>} token 14895 * Token. 14896 * @returns {Array<Chunk>} 14897 * Chunks. 14898 */ 14899function sliceChunks(chunks, token) { 14900 const startIndex = token.start._index; 14901 const startBufferIndex = token.start._bufferIndex; 14902 const endIndex = token.end._index; 14903 const endBufferIndex = token.end._bufferIndex; 14904 /** @type {Array<Chunk>} */ 14905 let view; 14906 if (startIndex === endIndex) { 14907 // @ts-expect-error `_bufferIndex` is used on string chunks. 14908 view = [chunks[startIndex].slice(startBufferIndex, endBufferIndex)]; 14909 } else { 14910 view = chunks.slice(startIndex, endIndex); 14911 if (startBufferIndex > -1) { 14912 const head = view[0]; 14913 if (typeof head === 'string') { 14914 view[0] = head.slice(startBufferIndex); 14915 /* c8 ignore next 4 -- used to be used, no longer */ 14916 } else { 14917 view.shift(); 14918 } 14919 } 14920 if (endBufferIndex > 0) { 14921 // @ts-expect-error `_bufferIndex` is used on string chunks. 14922 view.push(chunks[endIndex].slice(0, endBufferIndex)); 14923 } 14924 } 14925 return view; 14926} 14927 14928/** 14929 * Get the string value of a slice of chunks. 14930 * 14931 * @param {ReadonlyArray<Chunk>} chunks 14932 * Chunks. 14933 * @param {boolean | undefined} [expandTabs=false] 14934 * Whether to expand tabs (default: `false`). 14935 * @returns {string} 14936 * Result. 14937 */ 14938function serializeChunks(chunks, expandTabs) { 14939 let index = -1; 14940 /** @type {Array<string>} */ 14941 const result = []; 14942 /** @type {boolean | undefined} */ 14943 let atTab; 14944 while (++index < chunks.length) { 14945 const chunk = chunks[index]; 14946 /** @type {string} */ 14947 let value; 14948 if (typeof chunk === 'string') { 14949 value = chunk; 14950 } else switch (chunk) { 14951 case -5: 14952 { 14953 value = "\r"; 14954 break; 14955 } 14956 case -4: 14957 { 14958 value = "\n"; 14959 break; 14960 } 14961 case -3: 14962 { 14963 value = "\r" + "\n"; 14964 break; 14965 } 14966 case -2: 14967 { 14968 value = expandTabs ? " " : "\t"; 14969 break; 14970 } 14971 case -1: 14972 { 14973 if (!expandTabs && atTab) continue; 14974 value = " "; 14975 break; 14976 } 14977 default: 14978 { 14979 // Currently only replacement character. 14980 value = String.fromCharCode(chunk); 14981 } 14982 } 14983 atTab = chunk === -2; 14984 result.push(value); 14985 } 14986 return result.join(''); 14987} 14988;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark/lib/parse.js 14989/** 14990 * @import { 14991 * Create, 14992 * FullNormalizedExtension, 14993 * InitialConstruct, 14994 * ParseContext, 14995 * ParseOptions 14996 * } from 'micromark-util-types' 14997 */ 14998 14999 15000 15001 15002 15003 15004 15005 15006 15007/** 15008 * @param {ParseOptions | null | undefined} [options] 15009 * Configuration (optional). 15010 * @returns {ParseContext} 15011 * Parser. 15012 */ 15013function parse_parse(options) { 15014 const settings = options || {}; 15015 const constructs = /** @type {FullNormalizedExtension} */ 15016 combineExtensions([constructs_namespaceObject, ...(settings.extensions || [])]); 15017 15018 /** @type {ParseContext} */ 15019 const parser = { 15020 constructs, 15021 content: create(content), 15022 defined: [], 15023 document: create(document_document), 15024 flow: create(flow), 15025 lazy: {}, 15026 string: create(string), 15027 text: create(text_text) 15028 }; 15029 return parser; 15030 15031 /** 15032 * @param {InitialConstruct} initial 15033 * Construct to start with. 15034 * @returns {Create} 15035 * Create a tokenizer. 15036 */ 15037 function create(initial) { 15038 return creator; 15039 /** @type {Create} */ 15040 function creator(from) { 15041 return createTokenizer(parser, initial, from); 15042 } 15043 } 15044} 15045;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark/lib/postprocess.js 15046/** 15047 * @import {Event} from 'micromark-util-types' 15048 */ 15049 15050 15051 15052/** 15053 * @param {Array<Event>} events 15054 * Events. 15055 * @returns {Array<Event>} 15056 * Events. 15057 */ 15058function postprocess_postprocess(events) { 15059 while (!subtokenize(events)) { 15060 // Empty 15061 } 15062 return events; 15063} 15064;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark/lib/preprocess.js 15065/** 15066 * @import {Chunk, Code, Encoding, Value} from 'micromark-util-types' 15067 */ 15068 15069/** 15070 * @callback Preprocessor 15071 * Preprocess a value. 15072 * @param {Value} value 15073 * Value. 15074 * @param {Encoding | null | undefined} [encoding] 15075 * Encoding when `value` is a typed array (optional). 15076 * @param {boolean | null | undefined} [end=false] 15077 * Whether this is the last chunk (default: `false`). 15078 * @returns {Array<Chunk>} 15079 * Chunks. 15080 */ 15081 15082const search = /[\0\t\n\r]/g; 15083 15084/** 15085 * @returns {Preprocessor} 15086 * Preprocess a value. 15087 */ 15088function preprocess_preprocess() { 15089 let column = 1; 15090 let buffer = ''; 15091 /** @type {boolean | undefined} */ 15092 let start = true; 15093 /** @type {boolean | undefined} */ 15094 let atCarriageReturn; 15095 return preprocessor; 15096 15097 /** @type {Preprocessor} */ 15098 // eslint-disable-next-line complexity 15099 function preprocessor(value, encoding, end) { 15100 /** @type {Array<Chunk>} */ 15101 const chunks = []; 15102 /** @type {RegExpMatchArray | null} */ 15103 let match; 15104 /** @type {number} */ 15105 let next; 15106 /** @type {number} */ 15107 let startPosition; 15108 /** @type {number} */ 15109 let endPosition; 15110 /** @type {Code} */ 15111 let code; 15112 value = buffer + (typeof value === 'string' ? value.toString() : new TextDecoder(encoding || undefined).decode(value)); 15113 startPosition = 0; 15114 buffer = ''; 15115 if (start) { 15116 // To do: `markdown-rs` actually parses BOMs (byte order mark). 15117 if (value.charCodeAt(0) === 65279) { 15118 startPosition++; 15119 } 15120 start = undefined; 15121 } 15122 while (startPosition < value.length) { 15123 search.lastIndex = startPosition; 15124 match = search.exec(value); 15125 endPosition = match && match.index !== undefined ? match.index : value.length; 15126 code = value.charCodeAt(endPosition); 15127 if (!match) { 15128 buffer = value.slice(startPosition); 15129 break; 15130 } 15131 if (code === 10 && startPosition === endPosition && atCarriageReturn) { 15132 chunks.push(-3); 15133 atCarriageReturn = undefined; 15134 } else { 15135 if (atCarriageReturn) { 15136 chunks.push(-5); 15137 atCarriageReturn = undefined; 15138 } 15139 if (startPosition < endPosition) { 15140 chunks.push(value.slice(startPosition, endPosition)); 15141 column += endPosition - startPosition; 15142 } 15143 switch (code) { 15144 case 0: 15145 { 15146 chunks.push(65533); 15147 column++; 15148 break; 15149 } 15150 case 9: 15151 {
15152 next = Math.ceil(column / 4) * 4; 15153 chunks.push(-2); 15154 while (column++ < next) chunks.push(-1); 15155 break; 15156 } 15157 case 10: 15158 { 15159 chunks.push(-4); 15160 column = 1; 15161 break; 15162 } 15163 default: 15164 { 15165 atCarriageReturn = true; 15166 column = 1; 15167 } 15168 } 15169 } 15170 startPosition = endPosition + 1; 15171 } 15172 if (end) { 15173 if (atCarriageReturn) chunks.push(-5); 15174 if (buffer) chunks.push(buffer); 15175 chunks.push(null); 15176 } 15177 return chunks; 15178 } 15179} 15180;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark/index.js 15181/** 15182 * @import {Encoding, Value} from 'micromark-util-types' 15183 */ 15184 15185/** 15186 * @typedef {import('micromark-util-types').Options} Options 15187 */ 15188 15189 15190 15191 15192 15193 15194 15195 15196 15197 15198/** 15199 * Compile markdown to HTML. 15200 * 15201 * > Note: which encodings are supported depends on the engine. 15202 * > For info on Node.js, see: 15203 * > <https://nodejs.org/api/util.html#whatwg-supported-encodings>. 15204 * 15205 * @overload 15206 * @param {Value} value 15207 * Markdown to parse (`string` or `Uint8Array`). 15208 * @param {Encoding | null | undefined} encoding 15209 * Character encoding to understand `value` as when itâs a `Uint8Array` 15210 * (`string`, default: `'utf8'`). 15211 * @param {Options | null | undefined} [options] 15212 * Configuration. 15213 * @returns {string} 15214 * Compiled HTML. 15215 * 15216 * @overload 15217 * @param {Value} value 15218 * Markdown to parse (`string` or `Uint8Array`). 15219 * @param {Options | null | undefined} [options] 15220 * Configuration. 15221 * @returns {string} 15222 * Compiled HTML. 15223 * 15224 * @param {Value} value 15225 * Markdown to parse (`string` or `Uint8Array`). 15226 * @param {Encoding | Options | null | undefined} [encoding] 15227 * Character encoding to understand `value` as when itâs a `Uint8Array` 15228 * (`string`, default: `'utf8'`). 15229 * @param {Options | null | undefined} [options] 15230 * Configuration. 15231 * @returns {string} 15232 * Compiled HTML. 15233 */ 15234function micromark(value, encoding, options) { 15235 if (typeof encoding !== 'string') { 15236 options = encoding; 15237 encoding = undefined; 15238 } 15239 return compile(options)(postprocess(parse(options).document().write(preprocess()(value, encoding, true)))); 15240} 15241;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/micromark-util-decode-string/index.js 15242 15243 15244const characterEscapeOrReference = /\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi; 15245 15246/** 15247 * Decode markdown strings (which occur in places such as fenced code info 15248 * strings, destinations, labels, and titles). 15249 * 15250 * The âstringâ content type allows character escapes and -references. 15251 * This decodes those. 15252 * 15253 * @param {string} value 15254 * Value to decode. 15255 * @returns {string} 15256 * Decoded value. 15257 */ 15258function decodeString(value) { 15259 return value.replace(characterEscapeOrReference, decode); 15260} 15261 15262/** 15263 * @param {string} $0 15264 * Match. 15265 * @param {string} $1 15266 * Character escape. 15267 * @param {string} $2 15268 * Character reference. 15269 * @returns {string} 15270 * Decoded value 15271 */ 15272function decode($0, $1, $2) { 15273 if ($1) { 15274 // Escape. 15275 return $1; 15276 } 15277 15278 // Reference. 15279 const head = $2.charCodeAt(0); 15280 if (head === 35) { 15281 const head = $2.charCodeAt(1); 15282 const hex = head === 120 || head === 88; 15283 return micromark_util_decode_numeric_character_reference_decodeNumericCharacterReference($2.slice(hex ? 2 : 1), hex ? 16 : 10); 15284 } 15285 return index_dom_decodeNamedCharacterReference($2) || $0; 15286} 15287;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-from-markdown/lib/index.js 15288/** 15289 * @import { 15290 * Break, 15291 * Blockquote, 15292 * Code, 15293 * Definition, 15294 * Emphasis, 15295 * Heading, 15296 * Html, 15297 * Image, 15298 * InlineCode, 15299 * Link, 15300 * ListItem, 15301 * List, 15302 * Nodes, 15303 * Paragraph, 15304 * PhrasingContent, 15305 * ReferenceType, 15306 * Root, 15307 * Strong, 15308 * Text, 15309 * ThematicBreak 15310 * } from 'mdast' 15311 * @import { 15312 * Encoding, 15313 * Event, 15314 * Token, 15315 * Value 15316 * } from 'micromark-util-types' 15317 * @import {Point} from 'unist' 15318 * @import { 15319 * CompileContext, 15320 * CompileData, 15321 * Config, 15322 * Extension, 15323 * Handle, 15324 * OnEnterError, 15325 * Options 15326 * } from './types.js' 15327 */ 15328 15329 15330 15331 15332 15333 15334 15335 15336const lib_own = {}.hasOwnProperty; 15337 15338/** 15339 * Turn markdown into a syntax tree. 15340 * 15341 * @overload 15342 * @param {Value} value 15343 * @param {Encoding | null | undefined} [encoding] 15344 * @param {Options | null | undefined} [options] 15345 * @returns {Root} 15346 * 15347 * @overload 15348 * @param {Value} value 15349 * @param {Options | null | undefined} [options] 15350 * @returns {Root} 15351 * 15352 * @param {Value} value 15353 * Markdown to parse. 15354 * @param {Encoding | Options | null | undefined} [encoding] 15355 * Character encoding for when `value` is `Buffer`. 15356 * @param {Options | null | undefined} [options] 15357 * Configuration. 15358 * @returns {Root} 15359 * mdast tree. 15360 */ 15361function fromMarkdown(value, encoding, options) { 15362 if (encoding && typeof encoding === 'object') { 15363 options = encoding; 15364 encoding = undefined; 15365 } 15366 return compiler(options)(postprocess_postprocess(parse_parse(options).document().write(preprocess_
vendor: 5,211 bytes, lines 15366-15523
15366preprocess()(value, encoding, true)))); 15367} 15368 15369/** 15370 * Note this compiler only understand complete buffering, not streaming. 15371 * 15372 * @param {Options | null | undefined} [options] 15373 */ 15374function compiler(options) { 15375 /** @type {Config} */ 15376 const config = { 15377 transforms: [], 15378 canContainEols: ['emphasis', 'fragment', 'heading', 'paragraph', 'strong'], 15379 enter: { 15380 autolink: opener(link), 15381 autolinkProtocol: onenterdata, 15382 autolinkEmail: onenterdata, 15383 atxHeading: opener(heading), 15384 blockQuote: opener(blockQuote), 15385 characterEscape: onenterdata, 15386 characterReference: onenterdata, 15387 codeFenced: opener(codeFlow), 15388 codeFencedFenceInfo: buffer, 15389 codeFencedFenceMeta: buffer, 15390 codeIndented: opener(codeFlow, buffer), 15391 codeText: opener(codeText, buffer), 15392 codeTextData: onenterdata, 15393 data: onenterdata, 15394 codeFlowValue: onenterdata, 15395 definition: opener(definition), 15396 definitionDestinationString: buffer, 15397 definitionLabelString: buffer, 15398 definitionTitleString: buffer, 15399 emphasis: opener(emphasis), 15400 hardBreakEscape: opener(hardBreak), 15401 hardBreakTrailing: opener(hardBreak), 15402 htmlFlow: opener(html, buffer), 15403 htmlFlowData: onenterdata, 15404 htmlText: opener(html, buffer), 15405 htmlTextData: onenterdata, 15406 image: opener(image), 15407 label: buffer, 15408 link: opener(link), 15409 listItem: opener(listItem), 15410 listItemValue: onenterlistitemvalue, 15411 listOrdered: opener(list, onenterlistordered), 15412 listUnordered: opener(list), 15413 paragraph: opener(paragraph), 15414 reference: onenterreference, 15415 referenceString: buffer, 15416 resourceDestinationString: buffer, 15417 resourceTitleString: buffer, 15418 setextHeading: opener(heading), 15419 strong: opener(strong), 15420 thematicBreak: opener(thematicBreak) 15421 }, 15422 exit: { 15423 atxHeading: closer(), 15424 atxHeadingSequence: onexitatxheadingsequence, 15425 autolink: closer(), 15426 autolinkEmail: onexitautolinkemail, 15427 autolinkProtocol: onexitautolinkprotocol, 15428 blockQuote: closer(), 15429 characterEscapeValue: onexitdata, 15430 characterReferenceMarkerHexadecimal: onexitcharacterreferencemarker, 15431 characterReferenceMarkerNumeric: onexitcharacterreferencemarker, 15432 characterReferenceValue: onexitcharacterreferencevalue, 15433 characterReference: onexitcharacterreference, 15434 codeFenced: closer(onexitcodefenced), 15435 codeFencedFence: onexitcodefencedfence, 15436 codeFencedFenceInfo: onexitcodefencedfenceinfo, 15437 codeFencedFenceMeta: onexitcodefencedfencemeta, 15438 codeFlowValue: onexitdata, 15439 codeIndented: closer(onexitcodeindented), 15440 codeText: closer(onexitcodetext), 15441 codeTextData: onexitdata, 15442 data: onexitdata, 15443 definition: closer(), 15444 definitionDestinationString: onexitdefinitiondestinationstring, 15445 definitionLabelString: onexitdefinitionlabelstring, 15446 definitionTitleString: onexitdefinitiontitlestring, 15447 emphasis: closer(), 15448 hardBreakEscape: closer(onexithardbreak), 15449 hardBreakTrailing: closer(onexithardbreak), 15450 htmlFlow: closer(onexithtmlflow), 15451 htmlFlowData: onexitdata, 15452 htmlText: closer(onexithtmltext), 15453 htmlTextData: onexitdata, 15454 image: closer(onexitimage), 15455 label: onexitlabel, 15456 labelText: onexitlabeltext, 15457 lineEnding: onexitlineending, 15458 link: closer(onexitlink), 15459 listItem: closer(), 15460 listOrdered: closer(), 15461 listUnordered: closer(), 15462 paragraph: closer(), 15463 referenceString: onexitreferencestring, 15464 resourceDestinationString: onexitresourcedestinationstring, 15465 resourceTitleString: onexitresourcetitlestring, 15466 resource: onexitresource, 15467 setextHeading: closer(onexitsetextheading), 15468 setextHeadingLineSequence: onexitsetextheadinglinesequence, 15469 setextHeadingText: onexitsetextheadingtext, 15470 strong: closer(), 15471 thematicBreak: closer() 15472 } 15473 }; 15474 configure(config, (options || {}).mdastExtensions || []); 15475 15476 /** @type {CompileData} */ 15477 const data = {}; 15478 return compile; 15479 15480 /** 15481 * Turn micromark events into an mdast tree. 15482 * 15483 * @param {Array<Event>} events 15484 * Events. 15485 * @returns {Root} 15486 * mdast tree. 15487 */ 15488 function compile(events) { 15489 /** @type {Root} */ 15490 let tree = { 15491 type: 'root', 15492 children: [] 15493 }; 15494 /** @type {Omit<CompileContext, 'sliceSerialize'>} */ 15495 const context = { 15496 stack: [tree], 15497 tokenStack: [], 15498 config, 15499 enter, 15500 exit, 15501 buffer, 15502 resume, 15503 data 15504 }; 15505 /** @type {Array<number>} */ 15506 const listStack = []; 15507 let index = -1; 15508 while (++index < events.length) { 15509 // We preprocess lists to add `listItem` tokens, and to infer whether 15510 // items the list itself are spread out. 15511 if (events[index][1].type === "listOrdered" || events[index][1].type === "listUnordered") { 15512 if (events[index][0] === 'enter') { 15513 listStack.push(index); 15514 } else { 15515 const tail = listStack.pop(); 15516 index = prepareList(events, tail, index); 15517 } 15518 } 15519 } 15520 index = -1; 15521 while (++index < events.length) { 15522 const handler = config[events[index][0]]; 15523 if (
vendor: 22,431 bytes, lines 15523-16465
15523lib_own.call(handler, events[index][1].type)) { 15524 handler[events[index][1].type].call(Object.assign({ 15525 sliceSerialize: events[index][2].sliceSerialize 15526 }, context), events[index][1]); 15527 } 15528 } 15529 15530 // Handle tokens still being open. 15531 if (context.tokenStack.length > 0) { 15532 const tail = context.tokenStack[context.tokenStack.length - 1]; 15533 const handler = tail[1] || defaultOnError; 15534 handler.call(context, undefined, tail[0]); 15535 } 15536 15537 // Figure out `root` position. 15538 tree.position = { 15539 start: mdast_util_from_markdown_lib_point(events.length > 0 ? events[0][1].start : { 15540 line: 1, 15541 column: 1, 15542 offset: 0 15543 }), 15544 end: mdast_util_from_markdown_lib_point(events.length > 0 ? events[events.length - 2][1].end : { 15545 line: 1, 15546 column: 1, 15547 offset: 0 15548 }) 15549 }; 15550 15551 // Call transforms. 15552 index = -1; 15553 while (++index < config.transforms.length) { 15554 tree = config.transforms[index](tree) || tree; 15555 } 15556 return tree; 15557 } 15558 15559 /** 15560 * @param {Array<Event>} events 15561 * @param {number} start 15562 * @param {number} length 15563 * @returns {number} 15564 */ 15565 function prepareList(events, start, length) { 15566 let index = start - 1; 15567 let containerBalance = -1; 15568 let listSpread = false; 15569 /** @type {Token | undefined} */ 15570 let listItem; 15571 /** @type {number | undefined} */ 15572 let lineIndex; 15573 /** @type {number | undefined} */ 15574 let firstBlankLineIndex; 15575 /** @type {boolean | undefined} */ 15576 let atMarker; 15577 while (++index <= length) { 15578 const event = events[index]; 15579 switch (event[1].type) { 15580 case "listUnordered": 15581 case "listOrdered": 15582 case "blockQuote": 15583 { 15584 if (event[0] === 'enter') { 15585 containerBalance++; 15586 } else { 15587 containerBalance--; 15588 } 15589 atMarker = undefined; 15590 break; 15591 } 15592 case "lineEndingBlank": 15593 { 15594 if (event[0] === 'enter') { 15595 if (listItem && !atMarker && !containerBalance && !firstBlankLineIndex) { 15596 firstBlankLineIndex = index; 15597 } 15598 atMarker = undefined; 15599 } 15600 break; 15601 } 15602 case "linePrefix": 15603 case "listItemValue": 15604 case "listItemMarker": 15605 case "listItemPrefix": 15606 case "listItemPrefixWhitespace": 15607 { 15608 // Empty. 15609 15610 break; 15611 } 15612 default: 15613 { 15614 atMarker = undefined; 15615 } 15616 } 15617 if (!containerBalance && event[0] === 'enter' && event[1].type === "listItemPrefix" || containerBalance === -1 && event[0] === 'exit' && (event[1].type === "listUnordered" || event[1].type === "listOrdered")) { 15618 if (listItem) { 15619 let tailIndex = index; 15620 lineIndex = undefined; 15621 while (tailIndex--) { 15622 const tailEvent = events[tailIndex]; 15623 if (tailEvent[1].type === "lineEnding" || tailEvent[1].type === "lineEndingBlank") { 15624 if (tailEvent[0] === 'exit') continue; 15625 if (lineIndex) { 15626 events[lineIndex][1].type = "lineEndingBlank"; 15627 listSpread = true; 15628 } 15629 tailEvent[1].type = "lineEnding"; 15630 lineIndex = tailIndex; 15631 } else if (tailEvent[1].type === "linePrefix" || tailEvent[1].type === "blockQuotePrefix" || tailEvent[1].type === "blockQuotePrefixWhitespace" || tailEvent[1].type === "blockQuoteMarker" || tailEvent[1].type === "listItemIndent") { 15632 // Empty 15633 } else { 15634 break; 15635 } 15636 } 15637 if (firstBlankLineIndex && (!lineIndex || firstBlankLineIndex < lineIndex)) { 15638 listItem._spread = true; 15639 } 15640 15641 // Fix position. 15642 listItem.end = Object.assign({}, lineIndex ? events[lineIndex][1].start : event[1].end); 15643 events.splice(lineIndex || index, 0, ['exit', listItem, event[2]]); 15644 index++; 15645 length++; 15646 } 15647 15648 // Create a new list item. 15649 if (event[1].type === "listItemPrefix") { 15650 /** @type {Token} */ 15651 const item = { 15652 type: 'listItem', 15653 _spread: false, 15654 start: Object.assign({}, event[1].start), 15655 // @ts-expect-error: weâll add `end` in a second. 15656 end: undefined 15657 }; 15658 listItem = item; 15659 events.splice(index, 0, ['enter', item, event[2]]); 15660 index++; 15661 length++; 15662 firstBlankLineIndex = undefined; 15663 atMarker = true; 15664 } 15665 } 15666 } 15667 events[start][1]._spread = listSpread; 15668 return length; 15669 } 15670 15671 /** 15672 * Create an opener handle. 15673 * 15674 * @param {(token: Token) => Nodes} create 15675 * Create a node. 15676 * @param {Handle | undefined} [and] 15677 * Optional function to also run. 15678 * @returns {Handle} 15679 * Handle. 15680 */ 15681 function opener(create, and) { 15682 return open; 15683 15684 /** 15685 * @this {CompileContext} 15686 * @param {Token} token 15687 * @returns {undefined} 15688 */ 15689 function open(token) { 15690 enter.call(this, create(token), token); 15691 if (and) and.call(this, token); 15692 } 15693 } 15694 15695 /** 15696 * @type {CompileContext['buffer']} 15697 */ 15698 function buffer() { 15699 this.stack.push({ 15700 type: 'fragment', 15701 children: [] 15702 }); 15703 } 15704 15705 /** 15706 * @type {CompileContext['enter']} 15707 */ 15708 function enter(node, token, errorHandler) { 15709 const parent = this.stack[this.stack.length - 1]; 15710 /** @type {Array<Nodes>} */ 15711 const siblings = parent.children; 15712 siblings.push(node); 15713 this.stack.push(node); 15714 this.tokenStack.push([token, errorHandler || undefined]); 15715 node.position = { 15716 start: mdast_util_from_markdown_lib_point(token.start), 15717 // @ts-expect-error: `end` will be patched later. 15718 end: undefined 15719 }; 15720 } 15721 15722 /** 15723 * Create a closer handle. 15724 * 15725 * @param {Handle | undefined} [and] 15726 * Optional function to also run. 15727 * @returns {Handle} 15728 * Handle. 15729 */ 15730 function closer(and) { 15731 return close; 15732 15733 /** 15734 * @this {CompileContext} 15735 * @param {Token} token 15736 * @returns {undefined} 15737 */ 15738 function close(token) { 15739 if (and) and.call(this, token); 15740 exit.call(this, token); 15741 } 15742 } 15743 15744 /** 15745 * @type {CompileContext['exit']} 15746 */ 15747 function exit(token, onExitError) { 15748 const node = this.stack.pop(); 15749 const open = this.tokenStack.pop(); 15750 if (!open) { 15751 throw new Error('Cannot close `' + token.type + '` (' + stringifyPosition({ 15752 start: token.start, 15753 end: token.end 15754 }) + '): itâs not open'); 15755 } else if (open[0].type !== token.type) { 15756 if (onExitError) { 15757 onExitError.call(this, token, open[0]); 15758 } else { 15759 const handler = open[1] || defaultOnError; 15760 handler.call(this, token, open[0]); 15761 } 15762 } 15763 node.position.end = mdast_util_from_markdown_lib_point(token.end); 15764 } 15765 15766 /** 15767 * @type {CompileContext['resume']} 15768 */ 15769 function resume() { 15770 return lib_toString(this.stack.pop()); 15771 } 15772 15773 // 15774 // Handlers. 15775 // 15776 15777 /** 15778 * @this {CompileContext} 15779 * @type {Handle} 15780 */ 15781 function onenterlistordered() { 15782 this.data.expectingFirstListItemValue = true; 15783 } 15784 15785 /** 15786 * @this {CompileContext} 15787 * @type {Handle} 15788 */ 15789 function onenterlistitemvalue(token) { 15790 if (this.data.expectingFirstListItemValue) { 15791 const ancestor = this.stack[this.stack.length - 2]; 15792 ancestor.start = Number.parseInt(this.sliceSerialize(token), 10); 15793 this.data.expectingFirstListItemValue = undefined; 15794 } 15795 } 15796 15797 /** 15798 * @this {CompileContext} 15799 * @type {Handle} 15800 */ 15801 function onexitcodefencedfenceinfo() { 15802 const data = this.resume(); 15803 const node = this.stack[this.stack.length - 1]; 15804 node.lang = data; 15805 } 15806 15807 /** 15808 * @this {CompileContext} 15809 * @type {Handle} 15810 */ 15811 function onexitcodefencedfencemeta() { 15812 const data = this.resume(); 15813 const node = this.stack[this.stack.length - 1]; 15814 node.meta = data; 15815 } 15816 15817 /** 15818 * @this {CompileContext} 15819 * @type {Handle} 15820 */ 15821 function onexitcodefencedfence() { 15822 // Exit if this is the closing fence. 15823 if (this.data.flowCodeInside) return; 15824 this.buffer(); 15825 this.data.flowCodeInside = true; 15826 } 15827 15828 /** 15829 * @this {CompileContext} 15830 * @type {Handle} 15831 */ 15832 function onexitcodefenced() { 15833 const data = this.resume(); 15834 const node = this.stack[this.stack.length - 1]; 15835 node.value = data.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, ''); 15836 this.data.flowCodeInside = undefined; 15837 } 15838 15839 /** 15840 * @this {CompileContext} 15841 * @type {Handle} 15842 */ 15843 function onexitcodeindented() { 15844 const data = this.resume(); 15845 const node = this.stack[this.stack.length - 1]; 15846 node.value = data.replace(/(\r?\n|\r)$/g, ''); 15847 } 15848 15849 /** 15850 * @this {CompileContext} 15851 * @type {Handle} 15852 */ 15853 function onexitdefinitionlabelstring(token) { 15854 const label = this.resume(); 15855 const node = this.stack[this.stack.length - 1]; 15856 node.label = label; 15857 node.identifier = micromark_util_normalize_identifier_normalizeIdentifier(this.sliceSerialize(token)).toLowerCase(); 15858 } 15859 15860 /** 15861 * @this {CompileContext} 15862 * @type {Handle} 15863 */ 15864 function onexitdefinitiontitlestring() { 15865 const data = this.resume(); 15866 const node = this.stack[this.stack.length - 1]; 15867 node.title = data; 15868 } 15869 15870 /** 15871 * @this {CompileContext} 15872 * @type {Handle} 15873 */ 15874 function onexitdefinitiondestinationstring() { 15875 const data = this.resume(); 15876 const node = this.stack[this.stack.length - 1]; 15877 node.url = data; 15878 } 15879 15880 /** 15881 * @this {CompileContext} 15882 * @type {Handle} 15883 */ 15884 function onexitatxheadingsequence(token) { 15885 const node = this.stack[this.stack.length - 1]; 15886 if (!node.depth) { 15887 const depth = this.sliceSerialize(token).length; 15888 node.depth = depth; 15889 } 15890 } 15891 15892 /** 15893 * @this {CompileContext} 15894 * @type {Handle} 15895 */ 15896 function onexitsetextheadingtext() { 15897 this.data.setextHeadingSlurpLineEnding = true; 15898 } 15899 15900 /** 15901 * @this {CompileContext} 15902 * @type {Handle} 15903 */ 15904 function onexitsetextheadinglinesequence(token) { 15905 const node = this.stack[this.stack.length - 1]; 15906 node.depth = this.sliceSerialize(token).codePointAt(0) === 61 ? 1 : 2; 15907 } 15908 15909 /** 15910 * @this {CompileContext} 15911 * @type {Handle} 15912 */ 15913 function onexitsetextheading() { 15914 this.data.setextHeadingSlurpLineEnding = undefined; 15915 } 15916 15917 /** 15918 * @this {CompileContext} 15919 * @type {Handle} 15920 */ 15921 15922 function onenterdata(token) { 15923 const node = this.stack[this.stack.length - 1]; 15924 /** @type {Array<Nodes>} */ 15925 const siblings = node.children; 15926 let tail = siblings[siblings.length - 1]; 15927 if (!tail || tail.type !== 'text') { 15928 // Add a new text node. 15929 tail = text(); 15930 tail.position = { 15931 start: mdast_util_from_markdown_lib_point(token.start), 15932 // @ts-expect-error: weâll add `end` later. 15933 end: undefined 15934 }; 15935 siblings.push(tail); 15936 } 15937 this.stack.push(tail); 15938 } 15939 15940 /** 15941 * @this {CompileContext} 15942 * @type {Handle} 15943 */ 15944 15945 function onexitdata(token) { 15946 const tail = this.stack.pop(); 15947 tail.value += this.sliceSerialize(token); 15948 tail.position.end = mdast_util_from_markdown_lib_point(token.end); 15949 } 15950 15951 /** 15952 * @this {CompileContext} 15953 * @type {Handle} 15954 */ 15955 15956 function onexitlineending(token) { 15957 const context = this.stack[this.stack.length - 1]; 15958 // If weâre at a hard break, include the line ending in there. 15959 if (this.data.atHardBreak) { 15960 const tail = context.children[context.children.length - 1]; 15961 tail.position.end = mdast_util_from_markdown_lib_point(token.end); 15962 this.data.atHardBreak = undefined; 15963 return; 15964 } 15965 if (!this.data.setextHeadingSlurpLineEnding && config.canContainEols.includes(context.type)) { 15966 onenterdata.call(this, token); 15967 onexitdata.call(this, token); 15968 } 15969 } 15970 15971 /** 15972 * @this {CompileContext} 15973 * @type {Handle} 15974 */ 15975 15976 function onexithardbreak() { 15977 this.data.atHardBreak = true; 15978 } 15979 15980 /** 15981 * @this {CompileContext} 15982 * @type {Handle} 15983 */ 15984 15985 function onexithtmlflow() { 15986 const data = this.resume(); 15987 const node = this.stack[this.stack.length - 1]; 15988 node.value = data; 15989 } 15990 15991 /** 15992 * @this {CompileContext} 15993 * @type {Handle} 15994 */ 15995 15996 function onexithtmltext() { 15997 const data = this.resume(); 15998 const node = this.stack[this.stack.length - 1]; 15999 node.value = data; 16000 } 16001 16002 /** 16003 * @this {CompileContext} 16004 * @type {Handle} 16005 */ 16006 16007 function onexitcodetext() { 16008 const data = this.resume(); 16009 const node = this.stack[this.stack.length - 1]; 16010 node.value = data; 16011 } 16012 16013 /** 16014 * @this {CompileContext} 16015 * @type {Handle} 16016 */ 16017 16018 function onexitlink() { 16019 const node = this.stack[this.stack.length - 1]; 16020 // Note: there are also `identifier` and `label` fields on this link node! 16021 // These are used / cleaned here. 16022 16023 // To do: clean. 16024 if (this.data.inReference) { 16025 /** @type {ReferenceType} */ 16026 const referenceType = this.data.referenceType || 'shortcut'; 16027 node.type += 'Reference'; 16028 // @ts-expect-error: mutate. 16029 node.referenceType = referenceType; 16030 // @ts-expect-error: mutate. 16031 delete node.url; 16032 delete node.title; 16033 } else { 16034 // @ts-expect-error: mutate. 16035 delete node.identifier; 16036 // @ts-expect-error: mutate. 16037 delete node.label; 16038 } 16039 this.data.referenceType = undefined; 16040 } 16041 16042 /** 16043 * @this {CompileContext} 16044 * @type {Handle} 16045 */ 16046 16047 function onexitimage() { 16048 const node = this.stack[this.stack.length - 1]; 16049 // Note: there are also `identifier` and `label` fields on this link node! 16050 // These are used / cleaned here. 16051 16052 // To do: clean. 16053 if (this.data.inReference) { 16054 /** @type {ReferenceType} */ 16055 const referenceType = this.data.referenceType || 'shortcut'; 16056 node.type += 'Reference'; 16057 // @ts-expect-error: mutate. 16058 node.referenceType = referenceType; 16059 // @ts-expect-error: mutate. 16060 delete node.url; 16061 delete node.title; 16062 } else { 16063 // @ts-expect-error: mutate. 16064 delete node.identifier; 16065 // @ts-expect-error: mutate. 16066 delete node.label; 16067 } 16068 this.data.referenceType = undefined; 16069 } 16070 16071 /** 16072 * @this {CompileContext} 16073 * @type {Handle} 16074 */ 16075 16076 function onexitlabeltext(token) { 16077 const string = this.sliceSerialize(token); 16078 const ancestor = this.stack[this.stack.length - 2]; 16079 // @ts-expect-error: stash this on the node, as it might become a reference 16080 // later. 16081 ancestor.label = decodeString(string); 16082 // @ts-expect-error: same as above. 16083 ancestor.identifier = micromark_util_normalize_identifier_normalizeIdentifier(string).toLowerCase(); 16084 } 16085 16086 /** 16087 * @this {CompileContext} 16088 * @type {Handle} 16089 */ 16090 16091 function onexitlabel() { 16092 const fragment = this.stack[this.stack.length - 1]; 16093 const value = this.resume(); 16094 const node = this.stack[this.stack.length - 1]; 16095 // Assume a reference. 16096 this.data.inReference = true; 16097 if (node.type === 'link') { 16098 /** @type {Array<PhrasingContent>} */ 16099 const children = fragment.children; 16100 node.children = children; 16101 } else { 16102 node.alt = value; 16103 } 16104 } 16105 16106 /** 16107 * @this {CompileContext} 16108 * @type {Handle} 16109 */ 16110 16111 function onexitresourcedestinationstring() { 16112 const data = this.resume(); 16113 const node = this.stack[this.stack.length - 1]; 16114 node.url = data; 16115 } 16116 16117 /** 16118 * @this {CompileContext} 16119 * @type {Handle} 16120 */ 16121 16122 function onexitresourcetitlestring() { 16123 const data = this.resume(); 16124 const node = this.stack[this.stack.length - 1]; 16125 node.title = data; 16126 } 16127 16128 /** 16129 * @this {CompileContext} 16130 * @type {Handle} 16131 */ 16132 16133 function onexitresource() { 16134 this.data.inReference = undefined; 16135 } 16136 16137 /** 16138 * @this {CompileContext} 16139 * @type {Handle} 16140 */ 16141 16142 function onenterreference() { 16143 this.data.referenceType = 'collapsed'; 16144 } 16145 16146 /** 16147 * @this {CompileContext} 16148 * @type {Handle} 16149 */ 16150 16151 function onexitreferencestring(token) { 16152 const label = this.resume(); 16153 const node = this.stack[this.stack.length - 1]; 16154 // @ts-expect-error: stash this on the node, as it might become a reference 16155 // later. 16156 node.label = label; 16157 // @ts-expect-error: same as above. 16158 node.identifier = micromark_util_normalize_identifier_normalizeIdentifier(this.sliceSerialize(token)).toLowerCase(); 16159 this.data.referenceType = 'full'; 16160 } 16161 16162 /** 16163 * @this {CompileContext} 16164 * @type {Handle} 16165 */ 16166 16167 function onexitcharacterreferencemarker(token) { 16168 this.data.characterReferenceType = token.type; 16169 } 16170 16171 /** 16172 * @this {CompileContext} 16173 * @type {Handle} 16174 */ 16175 function onexitcharacterreferencevalue(token) { 16176 const data = this.sliceSerialize(token); 16177 const type = this.data.characterReferenceType; 16178 /** @type {string} */ 16179 let value; 16180 if (type) { 16181 value = micromark_util_decode_numeric_character_reference_decodeNumericCharacterReference(data, type === "characterReferenceMarkerNumeric" ? 10 : 16); 16182 this.data.characterReferenceType = undefined; 16183 } else { 16184 const result = index_dom_decodeNamedCharacterReference(data); 16185 value = result; 16186 } 16187 const tail = this.stack[this.stack.length - 1]; 16188 tail.value += value; 16189 } 16190 16191 /** 16192 * @this {CompileContext} 16193 * @type {Handle} 16194 */ 16195 function onexitcharacterreference(token) { 16196 const tail = this.stack.pop(); 16197 tail.position.end = mdast_util_from_markdown_lib_point(token.end); 16198 } 16199 16200 /** 16201 * @this {CompileContext} 16202 * @type {Handle} 16203 */ 16204 function onexitautolinkprotocol(token) { 16205 onexitdata.call(this, token); 16206 const node = this.stack[this.stack.length - 1]; 16207 node.url = this.sliceSerialize(token); 16208 } 16209 16210 /** 16211 * @this {CompileContext} 16212 * @type {Handle} 16213 */ 16214 function onexitautolinkemail(token) { 16215 onexitdata.call(this, token); 16216 const node = this.stack[this.stack.length - 1]; 16217 node.url = 'mailto:' + this.sliceSerialize(token); 16218 } 16219 16220 // 16221 // Creaters. 16222 // 16223 16224 /** @returns {Blockquote} */ 16225 function blockQuote() { 16226 return { 16227 type: 'blockquote', 16228 children: [] 16229 }; 16230 } 16231 16232 /** @returns {Code} */ 16233 function codeFlow() { 16234 return { 16235 type: 'code', 16236 lang: null, 16237 meta: null, 16238 value: '' 16239 }; 16240 } 16241 16242 /** @returns {InlineCode} */ 16243 function codeText() { 16244 return { 16245 type: 'inlineCode', 16246 value: '' 16247 }; 16248 } 16249 16250 /** @returns {Definition} */ 16251 function definition() { 16252 return { 16253 type: 'definition', 16254 identifier: '', 16255 label: null, 16256 title: null, 16257 url: '' 16258 }; 16259 } 16260 16261 /** @returns {Emphasis} */ 16262 function emphasis() { 16263 return { 16264 type: 'emphasis', 16265 children: [] 16266 }; 16267 } 16268 16269 /** @returns {Heading} */ 16270 function heading() { 16271 return { 16272 type: 'heading', 16273 // @ts-expect-error `depth` will be set later. 16274 depth: 0, 16275 children: [] 16276 }; 16277 } 16278 16279 /** @returns {Break} */ 16280 function hardBreak() { 16281 return { 16282 type: 'break' 16283 }; 16284 } 16285 16286 /** @returns {Html} */ 16287 function html() { 16288 return { 16289 type: 'html', 16290 value: '' 16291 }; 16292 } 16293 16294 /** @returns {Image} */ 16295 function image() { 16296 return { 16297 type: 'image', 16298 title: null, 16299 url: '', 16300 alt: null 16301 }; 16302 } 16303 16304 /** @returns {Link} */ 16305 function link() { 16306 return { 16307 type: 'link', 16308 title: null, 16309 url: '', 16310 children: [] 16311 }; 16312 } 16313 16314 /** 16315 * @param {Token} token 16316 * @returns {List} 16317 */ 16318 function list(token) { 16319 return { 16320 type: 'list', 16321 ordered: token.type === 'listOrdered', 16322 start: null, 16323 spread: token._spread, 16324 children: [] 16325 }; 16326 } 16327 16328 /** 16329 * @param {Token} token 16330 * @returns {ListItem} 16331 */ 16332 function listItem(token) { 16333 return { 16334 type: 'listItem', 16335 spread: token._spread, 16336 checked: null, 16337 children: [] 16338 }; 16339 } 16340 16341 /** @returns {Paragraph} */ 16342 function paragraph() { 16343 return { 16344 type: 'paragraph', 16345 children: [] 16346 }; 16347 } 16348 16349 /** @returns {Strong} */ 16350 function strong() { 16351 return { 16352 type: 'strong', 16353 children: [] 16354 }; 16355 } 16356 16357 /** @returns {Text} */ 16358 function text() { 16359 return { 16360 type: 'text', 16361 value: '' 16362 }; 16363 } 16364 16365 /** @returns {ThematicBreak} */ 16366 function thematicBreak() { 16367 return { 16368 type: 'thematicBreak' 16369 }; 16370 } 16371} 16372 16373/** 16374 * Copy a point-like value. 16375 * 16376 * @param {Point} d 16377 * Point-like value. 16378 * @returns {Point} 16379 * unist point. 16380 */ 16381function mdast_util_from_markdown_lib_point(d) { 16382 return { 16383 line: d.line, 16384 column: d.column, 16385 offset: d.offset 16386 }; 16387} 16388 16389/** 16390 * @param {Config} combined 16391 * @param {Array<Array<Extension> | Extension>} extensions 16392 * @returns {undefined} 16393 */ 16394function configure(combined, extensions) { 16395 let index = -1; 16396 while (++index < extensions.length) { 16397 const value = extensions[index]; 16398 if (Array.isArray(value)) { 16399 configure(combined, value); 16400 } else { 16401 extension(combined, value); 16402 } 16403 } 16404} 16405 16406/** 16407 * @param {Config} combined 16408 * @param {Extension} extension 16409 * @returns {undefined} 16410 */ 16411function extension(combined, extension) { 16412 /** @type {keyof Extension} */ 16413 let key; 16414 for (key in extension) { 16415 if (lib_own.call(extension, key)) { 16416 switch (key) { 16417 case 'canContainEols': 16418 { 16419 const right = extension[key]; 16420 if (right) { 16421 combined[key].push(...right); 16422 } 16423 break; 16424 } 16425 case 'transforms': 16426 { 16427 const right = extension[key]; 16428 if (right) { 16429 combined[key].push(...right); 16430 } 16431 break; 16432 } 16433 case 'enter': 16434 case 'exit': 16435 { 16436 const right = extension[key]; 16437 if (right) { 16438 Object.assign(combined[key], right); 16439 } 16440 break; 16441 } 16442 // No default 16443 } 16444 } 16445 } 16446} 16447 16448/** @type {OnEnterError} */ 16449function defaultOnError(left, right) { 16450 if (left) { 16451 throw new Error('Cannot close `' + left.type + '` (' + stringifyPosition({ 16452 start: left.start, 16453 end: left.end 16454 }) + '): a different token (`' + right.type + '`, ' + stringifyPosition({ 16455 start: right.start, 16456 end: right.end 16457 }) + ') is open'); 16458 } else { 16459 throw new Error('Cannot close document, a token (`' + right.type + '`, ' + stringifyPosition({ 16460 start: right.start, 16461 end: right.end 16462 }) + ') is still open'); 16463 } 16464} 16465;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-from-markdown/index.js
16466// Note: types exported from `index.d.ts`. 16467 16468;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/remark-parse/lib/index.js 16469/** 16470 * @typedef {import('mdast').Root} Root 16471 * @typedef {import('mdast-util-from-markdown').Options} FromMarkdownOptions 16472 * @typedef {import('unified').Parser<Root>} Parser 16473 * @typedef {import('unified').Processor<Root>} Processor 16474 */ 16475 16476/** 16477 * @typedef {Omit<FromMarkdownOptions, 'extensions' | 'mdastExtensions'>} Options 16478 */ 16479 16480 16481 16482/** 16483 * Aadd support for parsing from markdown. 16484 * 16485 * @param {Readonly<Options> | null | undefined} [options] 16486 * Configuration (optional). 16487 * @returns {undefined} 16488 * Nothing. 16489 */ 16490function remarkParse(options) { 16491 /** @type {Processor} */ 16492 // @ts-expect-error: TS in JSDoc generates wrong types if `this` is typed regularly. 16493 const self = this 16494 16495 self.parser = parser 16496 16497 /** 16498 * @type {Parser} 16499 */ 16500 function parser(doc) { 16501 return fromMarkdown(doc, { 16502 ...self.data('settings'), 16503 ...options, 16504 // Note: these options are not in the readme. 16505 // The goal is for them to be set by plugins on `data` instead of being 16506 // passed by users. 16507 extensions: self.data('micromarkExtensions') || [], 16508 mdastExtensions: self.data('fromMarkdownExtensions') || [] 16509 }) 16510 } 16511} 16512 16513;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/remark-parse/index.js 16514// Note: types exposed from `index.d.ts`. 16515 16516 16517;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/handlers/blockquote.js 16518/** 16519 * @import {Element} from 'hast' 16520 * @import {Blockquote} from 'mdast' 16521 * @import {State} from '../state.js' 16522 */ 16523 16524/** 16525 * Turn an mdast `blockquote` node into hast. 16526 * 16527 * @param {State} state 16528 * Info passed around. 16529 * @param {Blockquote} node 16530 * mdast node. 16531 * @returns {Element} 16532 * hast node. 16533 */ 16534function blockquote(state, node) { 16535 /** @type {Element} */ 16536 const result = { 16537 type: 'element', 16538 tagName: 'blockquote', 16539 properties: {}, 16540 children: state.wrap(state.all(node), true) 16541 } 16542 state.patch(node, result) 16543 return state.applyData(node, result) 16544} 16545 16546;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/handlers/break.js 16547/** 16548 * @import {Element, Text} from 'hast' 16549 * @import {Break} from 'mdast' 16550 * @import {State} from '../state.js' 16551 */ 16552 16553/** 16554 * Turn an mdast `break` node into hast. 16555 * 16556 * @param {State} state 16557 * Info passed around. 16558 * @param {Break} node 16559 * mdast node. 16560 * @returns {Array<Element | Text>} 16561 * hast element content. 16562 */ 16563function hardBreak(state, node) { 16564 /** @type {Element} */ 16565 const result = {type: 'element', tagName: 'br', properties: {}, children: []} 16566 state.patch(node, result) 16567 return [state.applyData(node, result), {type: 'text', value: '\n'}] 16568} 16569 16570;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/handlers/code.js 16571/** 16572 * @import {Element, Properties} from 'hast' 16573 * @import {Code} from 'mdast' 16574 * @import {State} from '../state.js' 16575 */ 16576 16577/** 16578 * Turn an mdast `code` node into hast. 16579 * 16580 * @param {State} state 16581 * Info passed around. 16582 * @param {Code} node 16583 * mdast node. 16584 * @returns {Element} 16585 * hast node. 16586 */ 16587function code(state, node) { 16588 const value = node.value ? node.value + '\n' : '' 16589 /** @type {Properties} */ 16590 const properties = {} 16591 // Someone can write `js python	ruby`. 16592 const language = node.lang ? node.lang.split(/\s+/) : [] 16593 16594 // GH/CM still drop the non-first languages. 16595 if (language.length > 0) { 16596 properties.className = ['language-' + language[0]] 16597 } 16598 16599 // Create `<code>`. 16600 /** @type {Element} */ 16601 let result = { 16602 type: 'element', 16603 tagName: 'code', 16604 properties, 16605 children: [{type: 'text', value}] 16606 } 16607 16608 if (node.meta) { 16609 result.data = {meta: node.meta} 16610 } 16611 16612 state.patch(node, result) 16613 result = state.applyData(node, result) 16614 16615 // Create `<pre>`. 16616 result = {type: 'element', tagName: 'pre', properties: {}, children: [result]} 16617 state.patch(node, result) 16618 return result 16619} 16620 16621;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/handlers/delete.js 16622/** 16623 * @import {Element} from 'hast' 16624 * @import {Delete} from 'mdast' 16625 * @import {State} from '../state.js' 16626 */ 16627 16628/** 16629 * Turn an mdast `delete` node into hast. 16630 * 16631 * @param {State} state 16632 * Info passed around. 16633 * @param {Delete} node 16634 * mdast node. 16635 * @returns {Element} 16636 * hast node. 16637 */ 16638function strikethrough(state, node) { 16639 /** @type {Element} */ 16640 const result = { 16641 type: 'element', 16642 tagName: 'del', 16643 properties: {}, 16644 children: state.all(node) 16645 } 16646 state.patch(node, result) 16647 return state.applyData(node, result) 16648} 16649 16650;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/handlers/emphasis.js 16651/** 16652 * @import {Element} from 'hast' 16653 * @import {Emphasis} from 'mdast' 16654 * @import {State} from '../state.js' 16655 */ 16656 16657/** 16658 * Turn an mdast `emphasis` node into hast. 16659 * 16660 * @param {State} state 16661 * Info passed around. 16662 * @param {Emphasis} node 16663 * mdast node. 16664 * @returns {Element} 16665 * hast node. 16666 */ 16667function emphasis(state, node) { 16668 /** @type {Element} */ 16669 const result = { 16670 type: 'element', 16671 tagName: 'em', 16672 properties: {}, 16673 children: state.all(node) 16674 } 16675 state.patch(node, result) 16676 return state.applyData(node, result) 16677} 16678 16679;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/handlers/footnote-reference.js 16680/** 16681 * @import {Element} from 'hast' 16682 * @import {FootnoteReference} from 'mdast' 16683 * @import {State} from '../state.js' 16684 */ 16685 16686 16687 16688/** 16689 * Turn an mdast `footnoteReference` node into hast. 16690 * 16691 * @param {State} state 16692 * Info passed around. 16693 * @param {FootnoteReference} node 16694 * mdast node. 16695 * @returns {Element} 16696 * hast node. 16697 */ 16698function footnoteReference(state, node) { 16699 const clobberPrefix = 16700 typeof state.options.clobberPrefix === 'string' 16701 ? state.options.clobberPrefix 16702 : 'user-content-' 16703 const id = String(node.identifier).toUpperCase() 16704 const safeId = normalizeUri(id.toLowerCase()) 16705 const index = state.footnoteOrder.indexOf(id) 16706 /** @type {number} */ 16707 let counter 16708 16709 let reuseCounter = state.footnoteCounts.get(id) 16710 16711 if (reuseCounter === undefined) { 16712 reuseCounter = 0 16713 state.footnoteOrder.push(id) 16714 counter = state.footnoteOrder.length 16715 } else { 16716 counter = index + 1 16717 } 16718 16719 reuseCounter += 1 16720 state.footnoteCounts.set(id, reuseCounter) 16721 16722 /** @type {Element} */ 16723 const link = { 16724 type: 'element', 16725 tagName: 'a', 16726 properties: { 16727 href: '#' + clobberPrefix + 'fn-' + safeId, 16728 id: 16729 clobberPrefix + 16730 'fnref-' + 16731 safeId + 16732 (reuseCounter > 1 ? '-' + reuseCounter : ''), 16733 dataFootnoteRef: true, 16734 ariaDescribedBy: ['footnote-label'] 16735 }, 16736 children: [{type: 'text', value: String(counter)}] 16737 } 16738 state.patch(node, link) 16739 16740 /** @type {Element} */ 16741 const sup = { 16742 type: 'element', 16743 tagName: 'sup', 16744 properties: {}, 16745 children: [link] 16746 } 16747 state.patch(node, sup) 16748 return state.applyData(node, sup) 16749} 16750 16751;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/handlers/heading.js 16752/** 16753 * @import {Element} from 'hast' 16754 * @import {Heading} from 'mdast' 16755 * @import {State} from '../state.js' 16756 */ 16757 16758/** 16759 * Turn an mdast `heading` node into hast. 16760 * 16761 * @param {State} state 16762 * Info passed around. 16763 * @param {Heading} node 16764 * mdast node. 16765 * @returns {Element} 16766 * hast node. 16767 */ 16768function heading(state, node) { 16769 /** @type {Element} */ 16770 const result = { 16771 type: 'element',
16772 tagName: 'h' + node.depth, 16773 properties: {}, 16774 children: state.all(node) 16775 } 16776 state.patch(node, result) 16777 return state.applyData(node, result) 16778} 16779 16780;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/handlers/html.js 16781/** 16782 * @import {Element} from 'hast' 16783 * @import {Html} from 'mdast' 16784 * @import {State} from '../state.js' 16785 * @import {Raw} from '../../index.js' 16786 */ 16787 16788/** 16789 * Turn an mdast `html` node into hast (`raw` node in dangerous mode, otherwise 16790 * nothing). 16791 * 16792 * @param {State} state 16793 * Info passed around. 16794 * @param {Html} node 16795 * mdast node. 16796 * @returns {Element | Raw | undefined} 16797 * hast node. 16798 */ 16799function html_html(state, node) { 16800 if (state.options.allowDangerousHtml) { 16801 /** @type {Raw} */ 16802 const result = {type: 'raw', value: node.value} 16803 state.patch(node, result) 16804 return state.applyData(node, result) 16805 } 16806 16807 return undefined 16808} 16809 16810;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/revert.js 16811/** 16812 * @import {ElementContent} from 'hast' 16813 * @import {Reference, Nodes} from 'mdast' 16814 * @import {State} from './state.js' 16815 */ 16816 16817/** 16818 * Return the content of a reference without definition as plain text. 16819 * 16820 * @param {State} state 16821 * Info passed around. 16822 * @param {Extract<Nodes, Reference>} node 16823 * Reference node (image, link). 16824 * @returns {Array<ElementContent>} 16825 * hast content. 16826 */ 16827function revert(state, node) { 16828 const subtype = node.referenceType 16829 let suffix = ']' 16830 16831 if (subtype === 'collapsed') { 16832 suffix += '[]' 16833 } else if (subtype === 'full') { 16834 suffix += '[' + (node.label || node.identifier) + ']' 16835 } 16836 16837 if (node.type === 'imageReference') { 16838 return [{type: 'text', value: '![' + node.alt + suffix}] 16839 } 16840 16841 const contents = state.all(node) 16842 const head = contents[0] 16843 16844 if (head && head.type === 'text') { 16845 head.value = '[' + head.value 16846 } else { 16847 contents.unshift({type: 'text', value: '['}) 16848 } 16849 16850 const tail = contents[contents.length - 1] 16851 16852 if (tail && tail.type === 'text') { 16853 tail.value += suffix 16854 } else { 16855 contents.push({type: 'text', value: suffix}) 16856 } 16857 16858 return contents 16859} 16860 16861;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/handlers/image-reference.js 16862/** 16863 * @import {ElementContent, Element, Properties} from 'hast' 16864 * @import {ImageReference} from 'mdast' 16865 * @import {State} from '../state.js' 16866 */ 16867 16868 16869 16870 16871/** 16872 * Turn an mdast `imageReference` node into hast. 16873 * 16874 * @param {State} state 16875 * Info passed around. 16876 * @param {ImageReference} node 16877 * mdast node. 16878 * @returns {Array<ElementContent> | ElementContent} 16879 * hast node. 16880 */ 16881function imageReference(state, node) { 16882 const id = String(node.identifier).toUpperCase() 16883 const definition = state.definitionById.get(id) 16884 16885 if (!definition) { 16886 return revert(state, node) 16887 } 16888 16889 /** @type {Properties} */ 16890 const properties = {src: normalizeUri(definition.url || ''), alt: node.alt} 16891 16892 if (definition.title !== null && definition.title !== undefined) { 16893 properties.title = definition.title 16894 } 16895 16896 /** @type {Element} */ 16897 const result = {type: 'element', tagName: 'img', properties, children: []} 16898 state.patch(node, result) 16899 return state.applyData(node, result) 16900} 16901 16902;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/handlers/image.js 16903/** 16904 * @import {Element, Properties} from 'hast' 16905 * @import {Image} from 'mdast' 16906 * @import {State} from '../state.js' 16907 */ 16908 16909 16910 16911/** 16912 * Turn an mdast `image` node into hast. 16913 * 16914 * @param {State} state 16915 * Info passed around. 16916 * @param {Image} node 16917 * mdast node. 16918 * @returns {Element} 16919 * hast node. 16920 */ 16921function image_image(state, node) { 16922 /** @type {Properties} */ 16923 const properties = {src: normalizeUri(node.url)} 16924 16925 if (node.alt !== null && node.alt !== undefined) { 16926 properties.alt = node.alt 16927 } 16928 16929 if (node.title !== null && node.title !== undefined) { 16930 properties.title = node.title 16931 } 16932 16933 /** @type {Element} */ 16934 const result = {type: 'element', tagName: 'img', properties, children: []} 16935 state.patch(node, result) 16936 return state.applyData(node, result) 16937} 16938 16939;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/handlers/inline-code.js 16940/** 16941 * @import {Element, Text} from 'hast' 16942 * @import {InlineCode} from 'mdast' 16943 * @import {State} from '../state.js' 16944 */ 16945 16946/** 16947 * Turn an mdast `inlineCode` node into hast. 16948 * 16949 * @param {State} state 16950 * Info passed around. 16951 * @param {InlineCode} node 16952 * mdast node. 16953 * @returns {Element} 16954 * hast node. 16955 */ 16956function inlineCode(state, node) { 16957 /** @type {Text} */
16958 const text = {type: 'text', value: node.value.replace(/\r?\n|\r/g, ' ')} 16959 state.patch(node, text) 16960 16961 /** @type {Element} */ 16962 const result = { 16963 type: 'element', 16964 tagName: 'code', 16965 properties: {}, 16966 children: [text] 16967 } 16968 state.patch(node, result) 16969 return state.applyData(node, result) 16970} 16971 16972;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/handlers/link-reference.js 16973/** 16974 * @import {ElementContent, Element, Properties} from 'hast' 16975 * @import {LinkReference} from 'mdast' 16976 * @import {State} from '../state.js' 16977 */ 16978 16979 16980 16981 16982/** 16983 * Turn an mdast `linkReference` node into hast. 16984 * 16985 * @param {State} state 16986 * Info passed around. 16987 * @param {LinkReference} node 16988 * mdast node. 16989 * @returns {Array<ElementContent> | ElementContent} 16990 * hast node. 16991 */ 16992function linkReference(state, node) { 16993 const id = String(node.identifier).toUpperCase() 16994 const definition = state.definitionById.get(id) 16995 16996 if (!definition) { 16997 return revert(state, node) 16998 } 16999 17000 /** @type {Properties} */ 17001 const properties = {href: normalizeUri(definition.url || '')} 17002 17003 if (definition.title !== null && definition.title !== undefined) { 17004 properties.title = definition.title 17005 } 17006 17007 /** @type {Element} */ 17008 const result = { 17009 type: 'element', 17010 tagName: 'a', 17011 properties, 17012 children: state.all(node) 17013 } 17014 state.patch(node, result) 17015 return state.applyData(node, result) 17016} 17017 17018;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/handlers/link.js 17019/** 17020 * @import {Element, Properties} from 'hast' 17021 * @import {Link} from 'mdast' 17022 * @import {State} from '../state.js' 17023 */ 17024 17025 17026 17027/** 17028 * Turn an mdast `link` node into hast. 17029 * 17030 * @param {State} state 17031 * Info passed around. 17032 * @param {Link} node 17033 * mdast node. 17034 * @returns {Element} 17035 * hast node. 17036 */ 17037function link_link(state, node) { 17038 /** @type {Properties} */ 17039 const properties = {href: normalizeUri(node.url)} 17040 17041 if (node.title !== null && node.title !== undefined) { 17042 properties.title = node.title 17043 } 17044 17045 /** @type {Element} */ 17046 const result = { 17047 type: 'element', 17048 tagName: 'a', 17049 properties, 17050 children: state.all(node) 17051 } 17052 state.patch(node, result) 17053 return state.applyData(node, result) 17054} 17055 17056;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/handlers/list-item.js 17057/** 17058 * @import {ElementContent, Element, Properties} from 'hast' 17059 * @import {ListItem, Parents} from 'mdast' 17060 * @import {State} from '../state.js' 17061 */ 17062 17063/** 17064 * Turn an mdast `listItem` node into hast. 17065 * 17066 * @param {State} state 17067 * Info passed around. 17068 * @param {ListItem} node 17069 * mdast node. 17070 * @param {Parents | undefined} parent 17071 * Parent of `node`. 17072 * @returns {Element} 17073 * hast node. 17074 */ 17075function listItem(state, node, parent) { 17076 const results = state.all(node) 17077 const loose = parent ? listLoose(parent) : listItemLoose(node) 17078 /** @type {Properties} */ 17079 const properties = {} 17080 /** @type {Array<ElementContent>} */ 17081 const children = [] 17082 17083 if (typeof node.checked === 'boolean') { 17084 const head = results[0] 17085 /** @type {Element} */ 17086 let paragraph 17087 17088 if (head && head.type === 'element' && head.tagName === 'p') { 17089 paragraph = head 17090 } else { 17091 paragraph = {type: 'element', tagName: 'p', properties: {}, children: []} 17092 results.unshift(paragraph) 17093 } 17094 17095 if (paragraph.children.length > 0) { 17096 paragraph.children.unshift({type: 'text', value: ' '}) 17097 } 17098 17099 paragraph.children.unshift({ 17100 type: 'element', 17101 tagName: 'input', 17102 properties: {type: 'checkbox', checked: node.checked, disabled: true}, 17103 children: [] 17104 }) 17105 17106 // According to github-markdown-css, this class hides bullet. 17107 // See: <https://github.com/sindresorhus/github-markdown-css>. 17108 properties.className = ['task-list-item'] 17109 } 17110 17111 let index = -1 17112 17113 while (++index < results.length) { 17114 const child = results[index] 17115 17116 // Add eols before nodes, except if this is a loose, first paragraph. 17117 if ( 17118 loose || 17119 index !== 0 || 17120 child.type !== 'element' || 17121 child.tagName !== 'p' 17122 ) { 17123 children.push({type: 'text', value: '\n'}) 17124 } 17125 17126 if (child.type === 'element' && child.tagName === 'p' && !loose) { 17127 children.push(...child.children) 17128 } else { 17129 children.push(child) 17130 } 17131 } 17132 17133 const tail = results[results.length - 1] 17134 17135 // Add a final eol. 17136 if (tail && (loose || tail.type !== 'element' || tail.tagName !== 'p')) { 17137 children.push({type: 'text', value: '\n'}) 17138 } 17139 17140 /** @type {Element} */ 17141 const result = {type: 'element', tagName: 'li', properties, children} 17142 state.patch(node, result) 17143 return state.applyData(node, result) 17144} 17145 17146/** 17147 * @param {Parents} node 17148 * @return {Boolean} 17149 */ 17150function listLoose(node) { 17151 let loose = false 17152 if (node.type === 'list') { 17153 loose = node.spread || false 17154 const children = node.children 17155 let index = -1 17156 17157 while (!loose && ++index < children.length) { 17158 loose = listItemLoose(children[index]) 17159 } 17160 } 17161 17162 return loose 17163} 17164 17165/** 17166 * @param {ListItem} node 17167 * @return {Boolean} 17168 */ 17169function listItemLoose(node) { 17170 const spread = node.spread 17171 17172 return spread === null || spread === undefined 17173 ? node.children.length > 1 17174 : spread 17175} 17176 17177;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/handlers/list.js 17178/** 17179 * @import {Element, Properties} from 'hast' 17180 * @import {List} from 'mdast' 17181 * @import {State} from '../state.js' 17182 */ 17183 17184/** 17185 * Turn an mdast `list` node into hast. 17186 * 17187 * @param {State} state 17188 * Info passed around. 17189 * @param {List} node 17190 * mdast node. 17191 * @returns {Element} 17192 * hast node. 17193 */ 17194function list_list(state, node) { 17195 /** @type {Properties} */ 17196 const properties = {} 17197 const results = state.all(node) 17198 let index = -1 17199 17200 if (typeof node.start === 'number' && node.start !== 1) { 17201 properties.start = node.start 17202 } 17203 17204 // Like GitHub, add a class for custom styling. 17205 while (++index < results.length) { 17206 const child = results[index] 17207 17208 if ( 17209 child.type === 'element' && 17210 child.tagName === 'li' && 17211 child.properties && 17212 Array.isArray(child.properties.className) && 17213 child.properties.className.includes('task-list-item') 17214 ) { 17215 properties.className = ['contains-task-list'] 17216 break 17217 } 17218 } 17219 17220 /** @type {Element} */ 17221 const result = { 17222 type: 'element', 17223 tagName: node.ordered ? 'ol' : 'ul', 17224 properties, 17225 children: state.wrap(results, true) 17226 } 17227 state.patch(node, result) 17228 return state.applyData(node, result) 17229} 17230 17231;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/handlers/paragraph.js 17232/** 17233 * @import {Element} from 'hast' 17234 * @import {Paragraph} from 'mdast' 17235 * @import {State} from '../state.js' 17236 */ 17237 17238/** 17239 * Turn an mdast `paragraph` node into hast. 17240 * 17241 * @param {State} state 17242 * Info passed around. 17243 * @param {Paragraph} node 17244 * mdast node. 17245 * @returns {Element} 17246 * hast node. 17247 */ 17248function paragraph(state, node) { 17249 /** @type {Element} */ 17250 const result = { 17251 type: 'element', 17252 tagName: 'p', 17253 properties: {}, 17254 children: state.all(node) 17255 } 17256 state.patch(node, result) 17257 return state.applyData(node, result) 17258} 17259 17260;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/handlers/root.js 17261/** 17262 * @import {Parents as HastParents, Root as HastRoot} from 'hast' 17263 * @import {Root as MdastRoot} from 'mdast' 17264 * @import {State} from '../state.js' 17265 */ 17266 17267/** 17268 * Turn an mdast `root` node into hast. 17269 * 17270 * @param {State} state 17271 * Info passed around. 17272 * @param {MdastRoot} node 17273 * mdast node. 17274 * @returns {HastParents} 17275 * hast node. 17276 */ 17277function root_root(state, node) { 17278 /** @type {HastRoot} */ 17279 const result = {type: 'root', children: state.wrap(state.all(node))} 17280 state.patch(node, result) 17281 return state.applyData(node, result) 17282} 17283 17284;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/handlers/strong.js 17285/** 17286 * @import {Element} from 'hast' 17287 * @import {Strong} from 'mdast' 17288 * @import {State} from '../state.js' 17289 */ 17290 17291/** 17292 * Turn an mdast `strong` node into hast. 17293 * 17294 * @param {State} state 17295 * Info passed around. 17296 * @param {Strong} node 17297 * mdast node. 17298 * @returns {Element} 17299 * hast node. 17300 */ 17301function strong(state, node) { 17302 /** @type {Element} */ 17303 const result = { 17304 type: 'element', 17305 tagName: 'strong', 17306 properties: {}, 17307 children: state.all(node) 17308 } 17309 state.patch(node, result) 17310 return state.applyData(node, result) 17311} 17312 17313;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/handlers/table.js 17314/** 17315 * @import {Table} from 'mdast' 17316 * @import {Element} from 'hast' 17317 * @import {State} from '../state.js' 17318 */ 17319 17320 17321 17322/** 17323 * Turn an mdast `table` node into hast. 17324 * 17325 * @param {State} state 17326 * Info passed around. 17327 * @param {Table} node 17328 * mdast node. 17329 * @returns {Element} 17330 * hast node. 17331 */ 17332function table(state, node) { 17333 const rows = state.all(node) 17334 const firstRow = rows.shift() 17335 /** @type {Array<Element>} */ 17336 const tableContent = [] 17337 17338 if (firstRow) { 17339 /** @type {Element} */ 17340 const head = { 17341 type: 'element', 17342 tagName: 'thead', 17343 properties: {}, 17344 children: state.wrap([firstRow], true) 17345 } 17346 state.patch(node.children[0], head) 17347 tableContent.push(head) 17348 } 17349 17350 if (rows.length > 0) { 17351 /** @type {Element} */ 17352 const body = { 17353 type: 'element', 17354 tagName: 'tbody', 17355 properties: {}, 17356 children: state.wrap(rows, true) 17357 } 17358 17359 const start = pointStart(node.children[1]) 17360 const end = pointEnd(node.children[node.children.length - 1]) 17361 if (start && end) body.position = {start, end} 17362 tableContent.push(body) 17363 } 17364 17365 /** @type {Element} */ 17366 const result = { 17367 type: 'element', 17368 tagName: 'table', 17369 properties: {}, 17370 children: state.wrap(tableContent, true) 17371 } 17372 state.patch(node, result) 17373 return state.applyData(node, result) 17374} 17375 17376;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/handlers/table-row.js 17377/** 17378 * @import {Element, ElementContent, Properties} from 'hast' 17379 * @import {Parents, TableRow} from 'mdast' 17380 * @import {State} from '../state.js' 17381 */ 17382 17383/** 17384 * Turn an mdast `tableRow` node into hast. 17385 * 17386 * @param {State} state 17387 * Info passed around. 17388 * @param {TableRow} node 17389 * mdast node. 17390 * @param {Parents | undefined} parent 17391 * Parent of `node`. 17392 * @returns {Element} 17393 * hast node. 17394 */ 17395function tableRow(state, node, parent) { 17396 const siblings = parent ? parent.children : undefined 17397 // Generate a body row when without parent. 17398 const rowIndex = siblings ? siblings.indexOf(node) : 1 17399 const tagName = rowIndex === 0 ? 'th' : 'td' 17400 // To do: option to use `style`? 17401 const align = parent && parent.type === 'table' ? parent.align : undefined 17402 const length = align ? align.length : node.children.length 17403 let cellIndex = -1 17404 /** @type {Array<ElementContent>} */ 17405 const cells = [] 17406 17407 while (++cellIndex < length) { 17408 // Note: can also be undefined. 17409 const cell = node.children[cellIndex] 17410 /** @type {Properties} */ 17411 const properties = {} 17412 const alignValue = align ? align[cellIndex] : undefined 17413 17414 if (alignValue) { 17415 properties.align = alignValue 17416 } 17417 17418 /** @type {Element} */ 17419 let result = {type: 'element', tagName, properties, children: []} 17420 17421 if (cell) { 17422 result.children = state.all(cell) 17423 state.patch(cell, result) 17424 result = state.applyData(cell, result) 17425 } 17426 17427 cells.push(result) 17428 } 17429 17430 /** @type {Element} */ 17431 const result = { 17432 type: 'element', 17433 tagName: 'tr', 17434 properties: {}, 17435 children: state.wrap(cells, true) 17436 } 17437 state.patch(node, result) 17438 return state.applyData(node, result) 17439} 17440 17441;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/handlers/table-cell.js 17442/** 17443 * @import {Element} from 'hast' 17444 * @import {TableCell} from 'mdast' 17445 * @import {State} from '../state.js' 17446 */ 17447 17448/** 17449 * Turn an mdast `tableCell` node into hast. 17450 * 17451 * @param {State} state 17452 * Info passed around. 17453 * @param {TableCell} node 17454 * mdast node. 17455 * @returns {Element} 17456 * hast node. 17457 */ 17458function tableCell(state, node) { 17459 // Note: this function is normally not called: see `table-row` for how rows 17460 // and their cells are compiled. 17461 /** @type {Element} */ 17462 const result = { 17463 type: 'element', 17464 tagName: 'td', // Assume body cell. 17465 properties: {}, 17466 children: state.all(node) 17467 } 17468 state.patch(node, result) 17469 return state.applyData(node, result) 17470} 17471 17472;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/trim-lines/index.js 17473const tab = 9 /* `\t` */ 17474const space = 32 /* ` ` */ 17475 17476/** 17477 * Remove initial and final spaces and tabs at the line breaks in `value`. 17478 * Does not trim initial and final spaces and tabs of the value itself. 17479 * 17480 * @param {string} value 17481 * Value to trim. 17482 * @returns {string} 17483 * Trimmed value. 17484 */ 17485function trimLines(value) { 17486 const source = String(value) 17487 const search = /\r?\n|\r/g 17488 let match = search.exec(source) 17489 let last = 0 17490 /** @type {Array<string>} */ 17491 const lines = [] 17492 17493 while (match) { 17494 lines.push( 17495 trimLine(source.slice(last, match.index), last > 0, true), 17496 match[0] 17497 ) 17498 17499 last = match.index + match[0].length 17500 match = search.exec(source) 17501 } 17502 17503 lines.push(trimLine(source.slice(last), last > 0, false)) 17504 17505 return lines.join('') 17506} 17507 17508/** 17509 * @param {string} value 17510 * Line to trim. 17511 * @param {boolean} start 17512 * Whether to trim the start of the line. 17513 * @param {boolean} end 17514 * Whether to trim the end of the line. 17515 * @returns {string} 17516 * Trimmed line. 17517 */ 17518function trimLine(value, start, end) { 17519 let startIndex = 0 17520 let endIndex = value.length 17521 17522 if (start) {
17523 let code = value.codePointAt(startIndex) 17524 17525 while (code === tab || code === space) { 17526 startIndex++ 17527 code = value.codePointAt(startIndex) 17528 } 17529 } 17530 17531 if (end) { 17532 let code = value.codePointAt(endIndex - 1) 17533 17534 while (code === tab || code === space) { 17535 endIndex-- 17536 code = value.codePointAt(endIndex - 1) 17537 } 17538 } 17539 17540 return endIndex > startIndex ? value.slice(startIndex, endIndex) : '' 17541} 17542 17543;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/handlers/text.js 17544/** 17545 * @import {Element as HastElement, Text as HastText} from 'hast' 17546 * @import {Text as MdastText} from 'mdast' 17547 * @import {State} from '../state.js' 17548 */ 17549 17550 17551 17552/** 17553 * Turn an mdast `text` node into hast. 17554 * 17555 * @param {State} state 17556 * Info passed around. 17557 * @param {MdastText} node 17558 * mdast node. 17559 * @returns {HastElement | HastText} 17560 * hast node. 17561 */ 17562function handlers_text_text(state, node) { 17563 /** @type {HastText} */ 17564 const result = {type: 'text', value: trimLines(String(node.value))} 17565 state.patch(node, result) 17566 return state.applyData(node, result) 17567} 17568 17569;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/handlers/thematic-break.js 17570/** 17571 * @import {Element} from 'hast' 17572 * @import {ThematicBreak} from 'mdast' 17573 * @import {State} from '../state.js' 17574 */ 17575 17576/** 17577 * Turn an mdast `thematicBreak` node into hast. 17578 * 17579 * @param {State} state 17580 * Info passed around. 17581 * @param {ThematicBreak} node 17582 * mdast node. 17583 * @returns {Element} 17584 * hast node. 17585 */ 17586function thematic_break_thematicBreak(state, node) { 17587 /** @type {Element} */ 17588 const result = { 17589 type: 'element', 17590 tagName: 'hr', 17591 properties: {}, 17592 children: [] 17593 } 17594 state.patch(node, result) 17595 return state.applyData(node, result) 17596} 17597 17598;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/handlers/index.js 17599/** 17600 * @import {Handlers} from '../state.js' 17601 */ 17602 17603 17604 17605 17606 17607 17608 17609 17610 17611 17612 17613 17614 17615 17616 17617 17618 17619 17620 17621 17622 17623 17624 17625 17626 17627/** 17628 * Default handlers for nodes. 17629 * 17630 * @satisfies {Handlers} 17631 */ 17632const handlers_handlers = { 17633 blockquote: blockquote, 17634 break: hardBreak, 17635 code: code, 17636 delete: strikethrough, 17637 emphasis: emphasis, 17638 footnoteReference: footnoteReference, 17639 heading: heading, 17640 html: html_html, 17641 imageReference: imageReference, 17642 image: image_image, 17643 inlineCode: inlineCode, 17644 linkReference: linkReference, 17645 link: link_link, 17646 listItem: listItem, 17647 list: list_list, 17648 paragraph: paragraph, 17649 // @ts-expect-error: root is different, but hard to type. 17650 root: root_root, 17651 strong: strong, 17652 table: table, 17653 tableCell: tableCell, 17654 tableRow: tableRow, 17655 text: handlers_text_text, 17656 thematicBreak: thematic_break_thematicBreak, 17657 toml: ignore, 17658 yaml: ignore, 17659 definition: ignore, 17660 footnoteDefinition: ignore 17661} 17662 17663// Return nothing for nodes that are ignored. 17664function ignore() { 17665 return undefined 17666} 17667 17668;// CONCATENATED MODULE: ./node_modules/.pnpm/@[email protected]/node_modules/@ungap/structured-clone/esm/types.js 17669const VOID = -1; 17670const PRIMITIVE = 0; 17671const ARRAY = 1; 17672const OBJECT = 2; 17673const DATE = 3; 17674const REGEXP = 4; 17675const MAP = 5; 17676const SET = 6; 17677const ERROR = 7; 17678const BIGINT = 8; 17679// export const SYMBOL = 9; 17680 17681;// CONCATENATED MODULE: ./node_modules/.pnpm/@[email protected]/node_modules/@ungap/structured-clone/esm/deserialize.js 17682 17683 17684const env = typeof self === 'object' ? self : globalThis; 17685 17686const guard = (name, init) => { 17687 switch (name) { 17688 case 'Function': 17689 case 'SharedWorker': 17690 case 'Worker': 17691 case 'eval': 17692 case 'setInterval': 17693 case 'setTimeout': 17694 throw new TypeError('unable to deserialize ' + name); 17695 } 17696 return new env[name](init); 17697}; 17698 17699const deserializer = ($, _) => { 17700 const as = (out, index) => { 17701 $.set(index, out); 17702 return out; 17703 }; 17704 17705 const unpair = index => { 17706 if ($.has(index)) 17707 return $.get(index); 17708 17709 const [type, value] = _[index]; 17710 switch (type) { 17711 case PRIMITIVE: 17712 case VOID: 17713 return as(value, index); 17714 case ARRAY: { 17715 const arr = as([], index); 17716 for (const index of value) 17717 arr.push(unpair(index)); 17718 return arr; 17719 } 17720 case OBJECT: { 17721 const object = as({}, index); 17722 for (const [key, index] of value) 17723 object[unpair(key)] = unpair(index); 17724 return object; 17725 } 17726 case DATE: 17727 return as(new Date(value), index); 17728 case REGEXP: { 17729 const {source, flags} = value; 17730 return as(new RegExp(source, flags), index); 17731 } 17732 case MAP: { 17733 const map = as(new Map, index); 17734 for (const [key, index] of value) 17735 map.set(unpair(key), unpair(index)); 17736 return map; 17737 }
vendor: 4,425 bytes, lines 17738-17904
17738 case SET: { 17739 const set = as(new Set, index); 17740 for (const index of value) 17741 set.add(unpair(index)); 17742 return set; 17743 } 17744 case ERROR: { 17745 const {name, message} = value; 17746 return as(guard(name, message), index); 17747 } 17748 case BIGINT: 17749 return as(BigInt(value), index); 17750 case 'BigInt': 17751 return as(Object(BigInt(value)), index); 17752 case 'ArrayBuffer': 17753 return as(new Uint8Array(value).buffer, value); 17754 case 'DataView': { 17755 const { buffer } = new Uint8Array(value); 17756 return as(new DataView(buffer), value); 17757 } 17758 } 17759 return as(guard(type, value), index); 17760 }; 17761 17762 return unpair; 17763}; 17764 17765/** 17766 * @typedef {Array<string,any>} Record a type representation 17767 */ 17768 17769/** 17770 * Returns a deserialized value from a serialized array of Records. 17771 * @param {Record[]} serialized a previously serialized value. 17772 * @returns {any} 17773 */ 17774const deserialize = serialized => deserializer(new Map, serialized)(0); 17775 17776;// CONCATENATED MODULE: ./node_modules/.pnpm/@[email protected]/node_modules/@ungap/structured-clone/esm/serialize.js 17777 17778 17779const EMPTY = ''; 17780 17781const {toString: serialize_toString} = {}; 17782const {keys} = Object; 17783 17784const typeOf = value => { 17785 const type = typeof value; 17786 if (type !== 'object' || !value) 17787 return [PRIMITIVE, type]; 17788 17789 const asString = serialize_toString.call(value).slice(8, -1); 17790 switch (asString) { 17791 case 'Array': 17792 return [ARRAY, EMPTY]; 17793 case 'Object': 17794 return [OBJECT, EMPTY]; 17795 case 'Date': 17796 return [DATE, EMPTY]; 17797 case 'RegExp': 17798 return [REGEXP, EMPTY]; 17799 case 'Map': 17800 return [MAP, EMPTY]; 17801 case 'Set': 17802 return [SET, EMPTY]; 17803 case 'DataView': 17804 return [ARRAY, asString]; 17805 } 17806 17807 if (asString.includes('Array')) 17808 return [ARRAY, asString]; 17809 17810 if (asString.includes('Error')) 17811 return [ERROR, asString]; 17812 17813 return [OBJECT, asString]; 17814}; 17815 17816const shouldSkip = ([TYPE, type]) => ( 17817 TYPE === PRIMITIVE && 17818 (type === 'function' || type === 'symbol') 17819); 17820 17821const serializer = (strict, json, $, _) => { 17822 17823 const as = (out, value) => { 17824 const index = _.push(out) - 1; 17825 $.set(value, index); 17826 return index; 17827 }; 17828 17829 const pair = value => { 17830 if ($.has(value)) 17831 return $.get(value); 17832 17833 let [TYPE, type] = typeOf(value); 17834 switch (TYPE) { 17835 case PRIMITIVE: { 17836 let entry = value; 17837 switch (type) { 17838 case 'bigint': 17839 TYPE = BIGINT; 17840 entry = value.toString(); 17841 break; 17842 case 'function': 17843 case 'symbol': 17844 if (strict) 17845 throw new TypeError('unable to serialize ' + type); 17846 entry = null; 17847 break; 17848 case 'undefined': 17849 return as([VOID], value); 17850 } 17851 return as([TYPE, entry], value); 17852 } 17853 case ARRAY: { 17854 if (type) { 17855 let spread = value; 17856 if (type === 'DataView') { 17857 spread = new Uint8Array(value.buffer); 17858 } 17859 else if (type === 'ArrayBuffer') { 17860 spread = new Uint8Array(value); 17861 } 17862 return as([type, [...spread]], value); 17863 } 17864 17865 const arr = []; 17866 const index = as([TYPE, arr], value); 17867 for (const entry of value) 17868 arr.push(pair(entry)); 17869 return index; 17870 } 17871 case OBJECT: { 17872 if (type) { 17873 switch (type) { 17874 case 'BigInt': 17875 return as([type, value.toString()], value); 17876 case 'Boolean': 17877 case 'Number': 17878 case 'String': 17879 return as([type, value.valueOf()], value); 17880 } 17881 } 17882 17883 if (json && ('toJSON' in value)) 17884 return pair(value.toJSON()); 17885 17886 const entries = []; 17887 const index = as([TYPE, entries], value); 17888 for (const key of keys(value)) { 17889 if (strict || !shouldSkip(typeOf(value[key]))) 17890 entries.push([pair(key), pair(value[key])]); 17891 } 17892 return index; 17893 } 17894 case DATE: 17895 return as([TYPE, isNaN(value.getTime()) ? EMPTY : value.toISOString()], value); 17896 case REGEXP: { 17897 const {source, flags} = value; 17898 return as([TYPE, {source, flags}], value); 17899 } 17900 case MAP: { 17901 const entries = []; 17902 const index = as([TYPE, entries], value); 17903 for (const [key, entry] of value) { 17904 if (strict || !(shouldSkip(typeOf(key)) || shouldSkip(typeOf(entry))))
17905 entries.push([pair(key), pair(entry)]); 17906 } 17907 return index; 17908 } 17909 case SET: { 17910 const entries = []; 17911 const index = as([TYPE, entries], value); 17912 for (const entry of value) { 17913 if (strict || !shouldSkip(typeOf(entry))) 17914 entries.push(pair(entry)); 17915 } 17916 return index; 17917 } 17918 } 17919 17920 const {message} = value; 17921 return as([TYPE, {name: type, message}], value); 17922 }; 17923 17924 return pair; 17925}; 17926 17927/** 17928 * @typedef {Array<string,any>} Record a type representation 17929 */ 17930 17931/** 17932 * Returns an array of serialized Records. 17933 * @param {any} value a serializable value. 17934 * @param {{json?: boolean, lossy?: boolean}?} options an object with a `lossy` or `json` property that, 17935 * if `true`, will not throw errors on incompatible types, and behave more 17936 * like JSON stringify would behave. Symbol and Function will be discarded. 17937 * @returns {Record[]} 17938 */ 17939 const serialize = (value, {json, lossy} = {}) => { 17940 const _ = []; 17941 return serializer(!(json || lossy), !!json, new Map, _)(value), _; 17942}; 17943 17944;// CONCATENATED MODULE: ./node_modules/.pnpm/@[email protected]/node_modules/@ungap/structured-clone/esm/index.js 17945 17946 17947 17948/** 17949 * @typedef {Array<string,any>} Record a type representation 17950 */ 17951 17952/** 17953 * Returns an array of serialized Records. 17954 * @param {any} any a serializable value. 17955 * @param {{transfer?: any[], json?: boolean, lossy?: boolean}?} options an object with 17956 * a transfer option (ignored when polyfilled) and/or non standard fields that 17957 * fallback to the polyfill if present. 17958 * @returns {Record[]} 17959 */ 17960/* harmony default export */ var esm = (typeof structuredClone === "function" ? 17961 /* c8 ignore start */ 17962 (any, options) => ( 17963 options && ('json' in options || 'lossy' in options) ? 17964 deserialize(serialize(any, options)) : structuredClone(any) 17965 ) : 17966 (any, options) => deserialize(serialize(any, options))); 17967 /* c8 ignore stop */ 17968 17969 17970 17971;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/footer.js 17972/** 17973 * @import {ElementContent, Element} from 'hast' 17974 * @import {State} from './state.js' 17975 */ 17976 17977/** 17978 * @callback FootnoteBackContentTemplate 17979 * Generate content for the backreference dynamically. 17980 * 17981 * For the following markdown: 17982 * 17983 * ```markdown 17984 * Alpha[^micromark], bravo[^micromark], and charlie[^remark]. 17985 * 17986 * [^remark]: things about remark 17987 * [^micromark]: things about micromark 17988 * ``` 17989 * 17990 * This function will be called with: 17991 * 17992 * * `0` and `0` for the backreference from `things about micromark` to 17993 * `alpha`, as it is the first used definition, and the first call to it 17994 * * `0` and `1` for the backreference from `things about micromark` to 17995 * `bravo`, as it is the first used definition, and the second call to it 17996 * * `1` and `0` for the backreference from `things about remark` to 17997 * `charlie`, as it is the second used definition 17998 * @param {number} referenceIndex 17999 * Index of the definition in the order that they are first referenced, 18000 * 0-indexed. 18001 * @param {number} rereferenceIndex 18002 * Index of calls to the same definition, 0-indexed. 18003 * @returns {Array<ElementContent> | ElementContent | string} 18004 * Content for the backreference when linking back from definitions to their 18005 * reference. 18006 * 18007 * @callback FootnoteBackLabelTemplate 18008 * Generate a back label dynamically. 18009 * 18010 * For the following markdown: 18011 * 18012 * ```markdown 18013 * Alpha[^micromark], bravo[^micromark], and charlie[^remark]. 18014 * 18015 * [^remark]: things about remark 18016 * [^micromark]: things about micromark 18017 * ``` 18018 * 18019 * This function will be called with: 18020 * 18021 * * `0` and `0` for the backreference from `things about micromark` to 18022 * `alpha`, as it is the first used definition, and the first call to it 18023 * * `0` and `1` for the backreference from `things about micromark` to 18024 * `bravo`, as it is the first used definition, and the second call to it 18025 * * `1` and `0` for the backreference from `things about remark` to 18026 * `charlie`, as it is the second used definition 18027 * @param {number} referenceIndex 18028 * Index of the definition in the order that they are first referenced, 18029 * 0-indexed. 18030 * @param {number} rereferenceIndex 18031 * Index of calls to the same definition, 0-indexed. 18032 * @returns {string} 18033 * Back label to use when linking back from definitions to their reference. 18034 */ 18035 18036 18037 18038 18039/** 18040 * Generate the default content that GitHub uses on backreferences. 18041 * 18042 * @param {number} _ 18043 * Index of the definition in the order that they are first referenced, 18044 * 0-indexed. 18045 * @param {number} rereferenceIndex 18046 * Index of calls to the same definition, 0-indexed. 18047 * @returns {Array<ElementContent>} 18048 * Content. 18049 */ 18050function defaultFootnoteBackContent(_, rereferenceIndex) { 18051 /** @type {Array<ElementContent>} */ 18052 const result = [{type: 'text', value: 'â©'}] 18053 18054 if (rereferenceIndex > 1) { 18055 result.push({ 18056 type: 'element', 18057 tagName: 'sup', 18058 properties: {}, 18059 children: [{type: 'text', value: String(rereferenceIndex)}] 18060 }) 18061 } 18062 18063 return result 18064} 18065 18066/** 18067 * Generate the default label that GitHub uses on backreferences. 18068 * 18069 * @param {number} referenceIndex 18070 * Index of the definition in the order that they are first referenced, 18071 * 0-indexed. 18072 * @param {number} rereferenceIndex 18073 * Index of calls to the same definition, 0-indexed. 18074 * @returns {string} 18075 * Label. 18076 */ 18077function defaultFootnoteBackLabel(referenceIndex, rereferenceIndex) { 18078 return ( 18079 'Back to reference ' + 18080 (referenceIndex + 1) + 18081 (rereferenceIndex > 1 ? '-' + rereferenceIndex : '') 18082 ) 18083} 18084 18085/** 18086 * Generate a hast footer for called footnote definitions. 18087 * 18088 * @param {State} state 18089 * Info passed around. 18090 * @returns {Element | undefined} 18091 * `section` element or `undefined`. 18092 */ 18093// eslint-disable-next-line complexity 18094function footer(state) { 18095 const clobberPrefix = 18096 typeof state.options.clobberPrefix === 'string' 18097 ? state.options.clobberPrefix 18098 : 'user-content-' 18099 const footnoteBackContent = 18100 state.options.footnoteBackContent || defaultFootnoteBackContent
18101 const footnoteBackLabel = 18102 state.options.footnoteBackLabel || defaultFootnoteBackLabel 18103 const footnoteLabel = state.options.footnoteLabel || 'Footnotes' 18104 const footnoteLabelTagName = state.options.footnoteLabelTagName || 'h2' 18105 const footnoteLabelProperties = state.options.footnoteLabelProperties || { 18106 className: ['sr-only'] 18107 } 18108 /** @type {Array<ElementContent>} */ 18109 const listItems = [] 18110 let referenceIndex = -1 18111 18112 while (++referenceIndex < state.footnoteOrder.length) { 18113 const definition = state.footnoteById.get( 18114 state.footnoteOrder[referenceIndex] 18115 ) 18116 18117 if (!definition) { 18118 continue 18119 } 18120 18121 const content = state.all(definition) 18122 const id = String(definition.identifier).toUpperCase() 18123 const safeId = normalizeUri(id.toLowerCase()) 18124 let rereferenceIndex = 0 18125 /** @type {Array<ElementContent>} */ 18126 const backReferences = [] 18127 const counts = state.footnoteCounts.get(id) 18128 18129 // eslint-disable-next-line no-unmodified-loop-condition 18130 while (counts !== undefined && ++rereferenceIndex <= counts) { 18131 if (backReferences.length > 0) { 18132 backReferences.push({type: 'text', value: ' '}) 18133 } 18134 18135 let children = 18136 typeof footnoteBackContent === 'string' 18137 ? footnoteBackContent 18138 : footnoteBackContent(referenceIndex, rereferenceIndex) 18139 18140 if (typeof children === 'string') { 18141 children = {type: 'text', value: children} 18142 } 18143 18144 backReferences.push({ 18145 type: 'element', 18146 tagName: 'a', 18147 properties: { 18148 href: 18149 '#' + 18150 clobberPrefix + 18151 'fnref-' + 18152 safeId + 18153 (rereferenceIndex > 1 ? '-' + rereferenceIndex : ''), 18154 dataFootnoteBackref: '', 18155 ariaLabel: 18156 typeof footnoteBackLabel === 'string' 18157 ? footnoteBackLabel 18158 : footnoteBackLabel(referenceIndex, rereferenceIndex), 18159 className: ['data-footnote-backref'] 18160 }, 18161 children: Array.isArray(children) ? children : [children] 18162 }) 18163 } 18164 18165 const tail = content[content.length - 1] 18166 18167 if (tail && tail.type === 'element' && tail.tagName === 'p') { 18168 const tailTail = tail.children[tail.children.length - 1] 18169 if (tailTail && tailTail.type === 'text') { 18170 tailTail.value += ' ' 18171 } else { 18172 tail.children.push({type: 'text', value: ' '}) 18173 } 18174 18175 tail.children.push(...backReferences) 18176 } else { 18177 content.push(...backReferences) 18178 } 18179 18180 /** @type {Element} */ 18181 const listItem = { 18182 type: 'element', 18183 tagName: 'li', 18184 properties: {id: clobberPrefix + 'fn-' + safeId}, 18185 children: state.wrap(content, true) 18186 } 18187 18188 state.patch(definition, listItem) 18189 18190 listItems.push(listItem) 18191 } 18192 18193 if (listItems.length === 0) { 18194 return 18195 } 18196 18197 return { 18198 type: 'element', 18199 tagName: 'section', 18200 properties: {dataFootnotes: true, className: ['footnotes']}, 18201 children: [ 18202 { 18203 type: 'element', 18204 tagName: footnoteLabelTagName, 18205 properties: { 18206 ...esm(footnoteLabelProperties), 18207 id: 'footnote-label' 18208 }, 18209 children: [{type: 'text', value: footnoteLabel}] 18210 }, 18211 {type: 'text', value: '\n'}, 18212 { 18213 type: 'element', 18214 tagName: 'ol', 18215 properties: {}, 18216 children: state.wrap(listItems, true) 18217 }, 18218 {type: 'text', value: '\n'} 18219 ] 18220 } 18221} 18222 18223;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/unist-util-is/lib/index.js 18224/** 18225 * @import {Node, Parent} from 'unist' 18226 */ 18227 18228/** 18229 * @template Fn 18230 * @template Fallback 18231 * @typedef {Fn extends (value: any) => value is infer Thing ? Thing : Fallback} Predicate 18232 */ 18233 18234/** 18235 * @callback Check 18236 * Check that an arbitrary value is a node. 18237 * @param {unknown} this 18238 * The given context. 18239 * @param {unknown} [node] 18240 * Anything (typically a node). 18241 * @param {number | null | undefined} [index] 18242 * The nodeâs position in its parent. 18243 * @param {Parent | null | undefined} [parent] 18244 * The nodeâs parent. 18245 * @returns {boolean} 18246 * Whether this is a node and passes a test. 18247 * 18248 * @typedef {Record<string, unknown> | Node} Props 18249 * Object to check for equivalence. 18250 * 18251 * Note: `Node` is included as it is common but is not indexable. 18252 * 18253 * @typedef {Array<Props | TestFunction | string> | ReadonlyArray<Props | TestFunction | string> | Props | TestFunction | string | null | undefined} Test
18254 * Check for an arbitrary node. 18255 * 18256 * @callback TestFunction 18257 * Check if a node passes a test. 18258 * @param {unknown} this 18259 * The given context. 18260 * @param {Node} node 18261 * A node. 18262 * @param {number | undefined} [index] 18263 * The nodeâs position in its parent. 18264 * @param {Parent | undefined} [parent] 18265 * The nodeâs parent. 18266 * @returns {boolean | undefined | void} 18267 * Whether this node passes the test. 18268 * 18269 * Note: `void` is included until TS sees no return as `undefined`. 18270 */ 18271 18272/** 18273 * Check if `node` is a `Node` and whether it passes the given test. 18274 * 18275 * @param {unknown} node 18276 * Thing to check, typically `Node`. 18277 * @param {Test} test 18278 * A check for a specific node. 18279 * @param {number | null | undefined} index 18280 * The nodeâs position in its parent. 18281 * @param {Parent | null | undefined} parent 18282 * The nodeâs parent. 18283 * @param {unknown} context 18284 * Context object (`this`) to pass to `test` functions. 18285 * @returns {boolean} 18286 * Whether `node` is a node and passes a test. 18287 */ 18288const is = 18289 // Note: overloads in JSDoc canât yet use different `@template`s. 18290 /** 18291 * @type {( 18292 * (<Condition extends ReadonlyArray<string>>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) =>
18292 node is Node & {type: Condition[number]}) & 18293 * (<Condition extends Array<string>>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition[number]}) & 18294 * (<Condition extends string>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) & 18295 * (<Condition extends Props>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) & 18296 * (<Condition extends TestFunction>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) & 18297 * ((node?: null | undefined) => false) & 18298 * ((node: unknown, test?: null | undefined, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) & 18299 * ((node: unknown, test?: Test, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => boolean) 18300 * )} 18301 */ 18302 ( 18303 /** 18304 * @param {unknown} [node] 18305 * @param {Test} [test] 18306 * @param {number | null | undefined} [index] 18307 * @param {Parent | null | undefined} [parent] 18308 * @param {unknown} [context] 18309 * @returns {boolean} 18310 */ 18311 // eslint-disable-next-line max-params 18312 function (node, test, index, parent, context) { 18313 const check = convert(test) 18314 18315 if ( 18316 index !== undefined && 18317 index !== null && 18318 (typeof index !== 'number' || 18319 index < 0 || 18320 index === Number.POSITIVE_INFINITY) 18321 ) { 18322 throw new Error('Expected positive finite index') 18323 } 18324 18325 if ( 18326 parent !== undefined && 18327 parent !== null && 18328 (!is(parent) || !parent.children) 18329 ) { 18330 throw new Error('Expected parent node') 18331 } 18332 18333 if ( 18334 (parent === undefined || parent === null) !== 18335 (index === undefined || index === null) 18336 ) { 18337 throw new Error('Expected both parent and index') 18338 } 18339 18340 return looksLikeANode(node) 18341 ? check.call(context, node, index, parent) 18342 : false 18343 } 18344 ) 18345 18346/** 18347 * Generate an assertion from a test. 18348 * 18349 * Useful if youâre going to test many nodes, for example when creating a 18350 * utility where something else passes a compatible test. 18351 * 18352 * The created function is a bit faster because it expects valid input only: 18353 * a `node`, `index`, and `parent`. 18354 * 18355 * @param {Test} test 18356 * * when nullish, checks if `node` is a `Node`. 18357 * * when `string`, works like passing `(node) => node.type === test`. 18358 * * when `function` checks if function passed the node is true. 18359 * * when `object`, checks that all keys in test are in node, and that they have (strictly) equal values. 18360 * * when `array`, checks if any one of the subtests pass. 18361 * @returns {Check} 18362 * An assertion. 18363 */ 18364const convert = 18365 // Note: overloads in JSDoc canât yet use different `@template`s. 18366 /** 18367 * @type {( 18368 * (<Condition extends string>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) =>
18368 node is Node & {type: Condition}) & 18369 * (<Condition extends Props>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) & 18370 * (<Condition extends TestFunction>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) & 18371 * ((test?: null | undefined) => (node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) & 18372 * ((test?: Test) => Check) 18373 * )} 18374 */ 18375 ( 18376 /** 18377 * @param {Test} [test] 18378 * @returns {Check} 18379 */ 18380 function (test) { 18381 if (test === null || test === undefined) { 18382 return lib_ok 18383 } 18384 18385 if (typeof test === 'function') { 18386 return castFactory(test) 18387 } 18388 18389 if (typeof test === 'object') { 18390 return Array.isArray(test) 18391 ? anyFactory(test) 18392 : // Cast because `ReadonlyArray` goes into the above but `isArray` 18393 // narrows to `Array`. 18394 propertiesFactory(/** @type {Props} */ (test)) 18395 } 18396 18397 if (typeof test === 'string') { 18398 return typeFactory(test) 18399 } 18400 18401 throw new Error('Expected function, string, or object as test') 18402 } 18403 ) 18404 18405/** 18406 * @param {Array<Props | TestFunction | string>} tests 18407 * @returns {Check} 18408 */ 18409function anyFactory(tests) { 18410 /** @type {Array<Check>} */ 18411 const checks = [] 18412 let index = -1 18413 18414 while (++index < tests.length) { 18415 checks[index] = convert(tests[index]) 18416 } 18417 18418 return castFactory(any) 18419 18420 /** 18421 * @this {unknown} 18422 * @type {TestFunction} 18423 */ 18424 function any(...parameters) { 18425 let index = -1 18426 18427 while (++index < checks.length) { 18428 if (checks[index].apply(this, parameters)) return true 18429 } 18430 18431 return false 18432 } 18433} 18434 18435/** 18436 * Turn an object into a test for a node with a certain fields. 18437 * 18438 * @param {Props} check 18439 * @returns {Check} 18440 */ 18441function propertiesFactory(check) { 18442 const checkAsRecord = /** @type {Record<string, unknown>} */ (check) 18443 18444 return castFactory(all) 18445 18446 /** 18447 * @param {Node} node 18448 * @returns {boolean} 18449 */ 18450 function all(node) { 18451 const nodeAsRecord = /** @type {Record<string, unknown>} */ ( 18452 /** @type {unknown} */ (node) 18453 ) 18454 18455 /** @type {string} */ 18456 let key 18457 18458 for (key in check) { 18459 if (nodeAsRecord[key] !== checkAsRecord[key]) return false 18460 } 18461 18462 return true 18463 } 18464} 18465 18466/** 18467 * Turn a string into a test for a node with a certain type. 18468 * 18469 * @param {string} check 18470 * @returns {Check} 18471 */ 18472function typeFactory(check) { 18473 return castFactory(type) 18474 18475 /** 18476 * @param {Node} node 18477 */ 18478 function type(node) { 18479 return node && node.type === check 18480 } 18481} 18482 18483/** 18484 * Turn a custom test into a test for a node that passes that test. 18485 * 18486 * @param {TestFunction} testFunction 18487 * @returns {Check} 18488 */ 18489function castFactory(testFunction) { 18490 return check 18491 18492 /** 18493 * @this {unknown} 18494 * @type {Check} 18495 */ 18496 function check(value, index, parent) { 18497 return Boolean( 18498 looksLikeANode(value) && 18499 testFunction.call( 18500 this, 18501 value, 18502 typeof index === 'number' ? index : undefined, 18503 parent || undefined 18504 ) 18505 ) 18506 } 18507} 18508 18509function lib_ok() { 18510 return true 18511} 18512 18513/** 18514 * @param {unknown} value 18515 * @returns {value is Node} 18516 */ 18517function looksLikeANode(value) { 18518 return value !== null && typeof value === 'object' && 'type' in value 18519} 18520 18521;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/unist-util-is/index.js 18522/** 18523 * @typedef {import('./lib/index.js').Check} Check 18524 * @typedef {import('./lib/index.js').Test} Test 18525 * @typedef {import('./lib/index.js').TestFunction} TestFunction 18526 */ 18527 18528 18529 18530;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/unist-util-visit-parents/lib/color.js 18531/** 18532 * @param {string} d 18533 * @returns {string} 18534 */ 18535function color(d) { 18536 return d 18537} 18538 18539;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/unist-util-visit-parents/lib/index.js 18540/** 18541 * @import {Node as UnistNode, Parent as UnistParent} from 'unist' 18542 */ 18543 18544/** 18545 * @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test 18546 * Test from `unist-util-is`. 18547 * 18548 * Note: we have remove and add `undefined`, because otherwise when generating 18549 * automatic `.d.ts` files, TS tries to flatten paths from a local perspective, 18550 * which doesnât work when publishing on npm. 18551 */ 18552 18553/** 18554 * @typedef {( 18555 * Fn extends (value: any) => value is infer Thing 18556 * ? Thing 18557 * : Fallback 18558 * )} Predicate 18559 * Get the value of a type guard `Fn`. 18560 * @template Fn 18561 * Value; typically function that is a type guard (such as `(x): x is Y`). 18562 * @template Fallback 18563 * Value to yield if `Fn` is not a type guard. 18564 */ 18565 18566/** 18567 * @typedef {( 18568 * Check extends null | undefined // No test. 18569 * ? Value 18570 * : Value extends {type: Check} // String (type) test. 18571 * ? Value 18572 * : Value extends Check // Partial test. 18573 * ? Value 18574 * : Check extends Function // Function test. 18575 * ? Predicate<Check, Value> extends Value 18576 * ? Predicate<Check, Value> 18577 * : never 18578 * : never // Some other test? 18579 * )} MatchesOne 18580 * Check whether a node matches a primitive check in the type system. 18581 * @template Value 18582 * Value; typically unist `Node`. 18583 * @template Check 18584 * Value; typically `unist-util-is`-compatible test, but not arrays. 18585 */ 18586 18587/** 18588 * @typedef {( 18589 * Check extends ReadonlyArray<infer T> 18590 * ? MatchesOne<Value, T> 18591 * : Check extends Array<infer T> 18592 * ? MatchesOne<Value, T> 18593 * : MatchesOne<Value, Check> 18594 * )} Matches 18595 * Check whether a node matches a check in the type system. 18596 * @template Value 18597 * Value; typically unist `Node`. 18598 * @template Check 18599 * Value; typically `unist-util-is`-compatible test. 18600 */ 18601 18602/** 18603 * @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint 18604 * Number; capped reasonably. 18605 */ 18606 18607/** 18608 * @typedef {I extends 0 ? 1 : I extends 1 ? 2 : I extends 2 ? 3 : I extends 3 ? 4 : I extends 4 ? 5 : I extends 5 ? 6 : I extends 6 ? 7 : I extends 7 ? 8 : I extends 8 ? 9 : 10} Increment 18609 * Increment a number in the type system. 18610 * @template {Uint} [I=0] 18611 * Index. 18612 */ 18613 18614/** 18615 * @typedef {( 18616 * Node extends UnistParent 18617 * ? Node extends {children: Array<infer Children>} 18618 * ? Child extends Children ? Node : never 18619 * : never 18620 * : never 18621 * )} InternalParent 18622 * Collect nodes that can be parents of `Child`. 18623 * @template {UnistNode} Node 18624 * All node types in a tree. 18625 * @template {UnistNode} Child 18626 * Node to search for. 18627 */ 18628 18629/** 18630 * @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent 18631 * Collect nodes in `Tree` that can be parents of `Child`. 18632 * @template {UnistNode} Tree 18633 * All node types in a tree. 18634 * @template {UnistNode} Child 18635 * Node to search for. 18636 */ 18637 18638/** 18639 * @typedef {( 18640 * Depth extends Max 18641 * ? never 18642 * : 18643 * | InternalParent<Node, Child> 18644 * | InternalAncestor<Node, InternalParent<Node, Child>, Max, Increment<Depth>> 18645 * )} InternalAncestor 18646 * Collect nodes in `Tree` that can be ancestors of `Child`. 18647 * @template {UnistNode} Node 18648 * All node types in a tree. 18649 * @template {UnistNode} Child 18650 * Node to search for. 18651 * @template {Uint} [Max=10] 18652 * Max; searches up to this depth. 18653 * @template {Uint} [Depth=0] 18654 * Current depth. 18655 */ 18656 18657/** 18658 * @typedef {InternalAncestor<InclusiveDescendant<Tree>, Child>} Ancestor 18659 * Collect nodes in `Tree` that can be ancestors of `Child`. 18660 * @template {UnistNode} Tree 18661 * All node types in a tree. 18662 * @template {UnistNode} Child 18663 * Node to search for. 18664 */ 18665 18666/** 18667 * @typedef {( 18668 * Tree extends UnistParent 18669 * ? Depth extends Max 18670 * ? Tree 18671 * : Tree | InclusiveDescendant<Tree['children'][number], Max, Increment<Depth>> 18672 * : Tree 18673 * )} InclusiveDescendant 18674 * Collect all (inclusive) descendants of `Tree`. 18675 * 18676 * > ð **Note**: for performance reasons, this seems to be the fastest way to 18677 * > recurse without actually running into an infinite loop, which the 18678 * > previous version did. 18679 * > 18680 * > Practically, a max of `2` is typically enough assuming a `Root` is 18681 * > passed, but it doesnât improve performance. 18682 * > It gets higher with `List > ListItem > Table > TableRow > TableCell`. 18683 * > Using up to `10` doesnât hurt or help either. 18684 * @template {UnistNode} Tree 18685 * Tree type. 18686 * @template {Uint} [Max=10] 18687 * Max; searches up to this depth. 18688 * @template {Uint} [Depth=0] 18689 * Current depth. 18690 */ 18691 18692/** 18693 * @typedef {'skip' | boolean} Action 18694 * Union of the action types. 18695 * 18696 * @typedef {number} Index 18697 * Move to the sibling at `index` next (after node itself is completely 18698 * traversed). 18699 * 18700 * Useful if mutating the tree, such as removing the node the visitor is 18701 * currently on, or any of its previous siblings. 18702 * Results less than 0 or greater than or equal to `children.length` stop 18703 * traversing the parent. 18704 * 18705 * @typedef {[(Action | null | undefined | void)?, (Index | null | undefined)?]} ActionTuple
18706 * List with one or two values, the first an action, the second an index. 18707 * 18708 * @typedef {Action | ActionTuple | Index | null | undefined | void} VisitorResult 18709 * Any value that can be returned from a visitor. 18710 */ 18711 18712/** 18713 * @callback Visitor 18714 * Handle a node (matching `test`, if given). 18715 * 18716 * Visitors are free to transform `node`. 18717 * They can also transform the parent of node (the last of `ancestors`). 18718 * 18719 * Replacing `node` itself, if `SKIP` is not returned, still causes its 18720 * descendants to be walked (which is a bug). 18721 * 18722 * When adding or removing previous siblings of `node` (or next siblings, in 18723 * case of reverse), the `Visitor` should return a new `Index` to specify the 18724 * sibling to traverse after `node` is traversed. 18725 * Adding or removing next siblings of `node` (or previous siblings, in case 18726 * of reverse) is handled as expected without needing to return a new `Index`. 18727 * 18728 * Removing the children property of an ancestor still results in them being 18729 * traversed. 18730 * @param {Visited} node 18731 * Found node. 18732 * @param {Array<VisitedParents>} ancestors 18733 * Ancestors of `node`. 18734 * @returns {VisitorResult} 18735 * What to do next. 18736 * 18737 * An `Index` is treated as a tuple of `[CONTINUE, Index]`. 18738 * An `Action` is treated as a tuple of `[Action]`. 18739 * 18740 * Passing a tuple back only makes sense if the `Action` is `SKIP`. 18741 * When the `Action` is `EXIT`, that action can be returned. 18742 * When the `Action` is `CONTINUE`, `Index` can be returned. 18743 * @template {UnistNode} [Visited=UnistNode] 18744 * Visited node type. 18745 * @template {UnistParent} [VisitedParents=UnistParent] 18746 * Ancestor type. 18747 */ 18748 18749/** 18750 * @typedef {Visitor<Matches<InclusiveDescendant<Tree>, Check>, Ancestor<Tree, Matches<InclusiveDescendant<Tree>, Check>>>} BuildVisitor 18751 * Build a typed `Visitor` function from a tree and a test. 18752 * 18753 * It will infer which values are passed as `node` and which as `parents`. 18754 * @template {UnistNode} [Tree=UnistNode] 18755 * Tree type. 18756 * @template {Test} [Check=Test] 18757 * Test type. 18758 */ 18759 18760 18761 18762 18763/** @type {Readonly<ActionTuple>} */ 18764const lib_empty = [] 18765 18766/** 18767 * Continue traversing as normal. 18768 */ 18769const CONTINUE = true 18770 18771/** 18772 * Stop traversing immediately. 18773 */ 18774const EXIT = false 18775 18776/** 18777 * Do not traverse this nodeâs children. 18778 */ 18779const SKIP = 'skip' 18780 18781/** 18782 * Visit nodes, with ancestral information. 18783 * 18784 * This algorithm performs *depth-first* *tree traversal* in *preorder* 18785 * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**). 18786 * 18787 * You can choose for which nodes `visitor` is called by passing a `test`. 18788 * For complex tests, you should test yourself in `visitor`, as it will be 18789 * faster and will have improved type information. 18790 * 18791 * Walking the tree is an intensive task. 18792 * Make use of the return values of the visitor when possible. 18793 * Instead of walking a tree multiple times, walk it once, use `unist-util-is` 18794 * to check if a node matches, and then perform different operations. 18795 * 18796 * You can change the tree. 18797 * See `Visitor` for more info. 18798 * 18799 * @overload 18800 * @param {Tree} tree 18801 * @param {Check} check 18802 * @param {BuildVisitor<Tree, Check>} visitor 18803 * @param {boolean | null | undefined} [reverse] 18804 * @returns {undefined} 18805 * 18806 * @overload 18807 * @param {Tree} tree 18808 * @param {BuildVisitor<Tree>} visitor 18809 * @param {boolean | null | undefined} [reverse] 18810 * @returns {undefined} 18811 * 18812 * @param {UnistNode} tree 18813 * Tree to traverse. 18814 * @param {Visitor | Test} test 18815 * `unist-util-is`-compatible test 18816 * @param {Visitor | boolean | null | undefined} [visitor] 18817 * Handle each node. 18818 * @param {boolean | null | undefined} [reverse] 18819 * Traverse in reverse preorder (NRL) instead of the default preorder (NLR). 18820 * @returns {undefined} 18821 * Nothing. 18822 * 18823 * @template {UnistNode} Tree 18824 * Node type. 18825 * @template {Test} Check 18826 * `unist-util-is`-compatible test. 18827 */ 18828function visitParents(tree, test, visitor, reverse) { 18829 /** @type {Test} */ 18830 let check 18831 18832 if (typeof test === 'function' && typeof visitor !== 'function') { 18833 reverse = visitor 18834 // @ts-expect-error no visitor given, so `visitor` is test. 18835 visitor = test 18836 } else { 18837 // @ts-expect-error visitor given, so `test` isnât a visitor. 18838 check = test 18839 } 18840 18841 const is = convert(check) 18842 const step = reverse ? -1 : 1 18843 18844 factory(tree, undefined, [])() 18845 18846 /** 18847 * @param {UnistNode} node 18848 * @param {number | undefined} index 18849 * @param {Array<UnistParent>} parents 18850 */ 18851 function factory(node, index, parents) { 18852 const value = /** @type {Record<string, unknown>} */ ( 18853 node && typeof node === 'object' ? node : {} 18854 ) 18855 18856 if (typeof value.type === 'string') { 18857 const name = 18858 // `hast` 18859 typeof value.tagName === 'string' 18860 ? value.tagName 18861 : // `xast` 18862 typeof value.name === 'string' 18863 ? value.name 18864 : undefined 18865 18866 Object.defineProperty(visit, 'name', { 18867 value: 18868 'node (' + color(node.type + (name ? '<' + name + '>' : '')) + ')' 18869 }) 18870 } 18871 18872 return visit 18873 18874 function visit() { 18875 /** @type {Readonly<ActionTuple>} */ 18876 let result = lib_empty 18877 /** @type {Readonly<ActionTuple>} */ 18878 let subresult 18879 /** @type {number} */ 18880 let offset 18881 /** @type {Array<UnistParent>} */ 18882 let grandparents 18883 18884 if (!test || is(node, index, parents[parents.length - 1] || undefined)) { 18885 // @ts-expect-error: `visitor` is now a visitor. 18886 result = toResult(visitor(node, parents)) 18887 18888 if (result[0] === EXIT) { 18889 return result 18890 } 18891 } 18892
18893 if ('children' in node && node.children) { 18894 const nodeAsParent = /** @type {UnistParent} */ (node) 18895 18896 if (nodeAsParent.children && result[0] !== SKIP) { 18897 offset = (reverse ? nodeAsParent.children.length : -1) + step 18898 grandparents = parents.concat(nodeAsParent) 18899 18900 while (offset > -1 && offset < nodeAsParent.children.length) { 18901 const child = nodeAsParent.children[offset] 18902 18903 subresult = factory(child, offset, grandparents)() 18904 18905 if (subresult[0] === EXIT) { 18906 return subresult 18907 } 18908 18909 offset = 18910 typeof subresult[1] === 'number' ? subresult[1] : offset + step 18911 } 18912 } 18913 } 18914 18915 return result 18916 } 18917 } 18918} 18919 18920/** 18921 * Turn a return value into a clean result. 18922 * 18923 * @param {VisitorResult} value 18924 * Valid return values from visitors. 18925 * @returns {Readonly<ActionTuple>} 18926 * Clean result. 18927 */ 18928function toResult(value) { 18929 if (Array.isArray(value)) { 18930 return value 18931 } 18932 18933 if (typeof value === 'number') { 18934 return [CONTINUE, value] 18935 } 18936 18937 return value === null || value === undefined ? lib_empty : [value] 18938} 18939 18940;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/unist-util-visit-parents/index.js 18941// Note: types exported from `index.d.ts` 18942 18943 18944;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/unist-util-visit/lib/index.js 18945/** 18946 * @import {Node as UnistNode, Parent as UnistParent} from 'unist' 18947 * @import {VisitorResult} from 'unist-util-visit-parents' 18948 */ 18949 18950/** 18951 * @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test 18952 * Test from `unist-util-is`. 18953 * 18954 * Note: we have remove and add `undefined`, because otherwise when generating 18955 * automatic `.d.ts` files, TS tries to flatten paths from a local perspective, 18956 * which doesnât work when publishing on npm. 18957 */ 18958 18959// To do: use types from `unist-util-visit-parents` when itâs released. 18960 18961/** 18962 * @typedef {( 18963 * Fn extends (value: any) => value is infer Thing 18964 * ? Thing 18965 * : Fallback 18966 * )} Predicate 18967 * Get the value of a type guard `Fn`. 18968 * @template Fn 18969 * Value; typically function that is a type guard (such as `(x): x is Y`). 18970 * @template Fallback 18971 * Value to yield if `Fn` is not a type guard. 18972 */ 18973 18974/** 18975 * @typedef {( 18976 * Check extends null | undefined // No test. 18977 * ? Value 18978 * : Value extends {type: Check} // String (type) test. 18979 * ? Value 18980 * : Value extends Check // Partial test. 18981 * ? Value 18982 * : Check extends Function // Function test. 18983 * ? Predicate<Check, Value> extends Value 18984 * ? Predicate<Check, Value> 18985 * : never 18986 * : never // Some other test? 18987 * )} MatchesOne 18988 * Check whether a node matches a primitive check in the type system. 18989 * @template Value 18990 * Value; typically unist `Node`. 18991 * @template Check 18992 * Value; typically `unist-util-is`-compatible test, but not arrays. 18993 */ 18994 18995/** 18996 * @typedef {( 18997 * Check extends ReadonlyArray<any> 18998 * ? MatchesOne<Value, Check[number]> 18999 * : MatchesOne<Value, Check> 19000 * )} Matches 19001 * Check whether a node matches a check in the type system. 19002 * @template Value 19003 * Value; typically unist `Node`. 19004 * @template Check 19005 * Value; typically `unist-util-is`-compatible test. 19006 */ 19007 19008/** 19009 * @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint 19010 * Number; capped reasonably. 19011 */ 19012 19013/** 19014 * @typedef {I extends 0 ? 1 : I extends 1 ? 2 : I extends 2 ? 3 : I extends 3 ? 4 : I extends 4 ? 5 : I extends 5 ? 6 : I extends 6 ? 7 : I extends 7 ? 8 : I extends 8 ? 9 : 10} Increment 19015 * Increment a number in the type system. 19016 * @template {Uint} [I=0] 19017 * Index. 19018 */ 19019 19020/** 19021 * @typedef {( 19022 * Node extends UnistParent 19023 * ? Node extends {children: Array<infer Children>} 19024 * ? Child extends Children ? Node : never 19025 * : never 19026 * : never 19027 * )} InternalParent 19028 * Collect nodes that can be parents of `Child`. 19029 * @template {UnistNode} Node 19030 * All node types in a tree. 19031 * @template {UnistNode} Child 19032 * Node to search for. 19033 */ 19034 19035/** 19036 * @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent 19037 * Collect nodes in `Tree` that can be parents of `Child`. 19038 * @template {UnistNode} Tree 19039 * All node types in a tree. 19040 * @template {UnistNode} Child 19041 * Node to search for. 19042 */ 19043 19044/** 19045 * @typedef {( 19046 * Depth extends Max 19047 * ? never 19048 * : 19049 * | InternalParent<Node, Child> 19050 * | InternalAncestor<Node, InternalParent<Node, Child>, Max, Increment<Depth>> 19051 * )} InternalAncestor 19052 * Collect nodes in `Tree` that can be ancestors of `Child`. 19053 * @template {UnistNode} Node 19054 * All node types in a tree. 19055 * @template {UnistNode} Child 19056 * Node to search for. 19057 * @template {Uint} [Max=10] 19058 * Max; searches up to this depth. 19059 * @template {Uint} [Depth=0] 19060 * Current depth. 19061 */ 19062 19063/** 19064 * @typedef {( 19065 * Tree extends UnistParent 19066 * ? Depth extends Max 19067 * ? Tree 19068 * : Tree | InclusiveDescendant<Tree['children'][number], Max, Increment<Depth>> 19069 * : Tree 19070 * )} InclusiveDescendant 19071 * Collect all (inclusive) descendants of `Tree`. 19072 * 19073 * > ð **Note**: for performance reasons, this seems to be the fastest way to 19074 * > recurse without actually running into an infinite loop, which the 19075 * > previous version did. 19076 * > 19077 * > Practically, a max of `2` is typically enough assuming a `Root` is 19078 * > passed, but it doesnât improve performance. 19079 * > It gets higher with `List > ListItem > Table > TableRow > TableCell`. 19080 * > Using up to `10` doesnât hurt or help either. 19081 * @template {UnistNode} Tree 19082 * Tree type. 19083 * @template {Uint} [Max=10] 19084 * Max; searches up to this depth. 19085 * @template {Uint} [Depth=0] 19086 * Current depth. 19087 */ 19088 19089/** 19090 * @callback Visitor 19091 * Handle a node (matching `test`, if given). 19092 * 19093 * Visitors are free to transform `node`. 19094 * They can also transform `parent`. 19095 * 19096 * Replacing `node` itself, if `SKIP` is not returned, still causes its 19097 * descendants to be walked (which is a bug). 19098 * 19099 * When adding or removing previous siblings of `node` (or next siblings, in 19100 * case of reverse), the `Visitor` should return a new `Index` to specify the 19101 * sibling to traverse after `node` is traversed. 19102 * Adding or removing next siblings of `node` (or previous siblings, in case 19103 * of reverse) is handled as expected without needing to return a new `Index`. 19104 * 19105 * Removing the children property of `parent` still results in them being 19106 * traversed. 19107 * @param {Visited} node 19108 * Found node. 19109 * @param {Visited extends UnistNode ? number | undefined : never} index 19110 * Index of `node` in `parent`. 19111 * @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent 19112 * Parent of `node`. 19113 * @returns {VisitorResult} 19114 * What to do next. 19115 * 19116 * An `Index` is treated as a tuple of `[CONTINUE, Index]`. 19117 * An `Action` is treated as a tuple of `[Action]`. 19118 * 19119 * Passing a tuple back only makes sense if the `Action` is `SKIP`. 19120 * When the `Action` is `EXIT`, that action can be returned. 19121 * When the `Action` is `CONTINUE`, `Index` can be returned. 19122 * @template {UnistNode} [Visited=UnistNode] 19123 * Visited node type. 19124 * @template {UnistParent} [Ancestor=UnistParent] 19125 * Ancestor type. 19126 */ 19127 19128/** 19129 * @typedef {Visitor<Visited, Parent<Ancestor, Visited>>} BuildVisitorFromMatch 19130 * Build a typed `Visitor` function from a node and all possible parents. 19131 * 19132 * It will infer which values are passed as `node` and which as `parent`. 19133 * @template {UnistNode} Visited 19134 * Node type. 19135 * @template {UnistParent} Ancestor 19136 * Parent type. 19137 */ 19138 19139/** 19140 * @typedef {( 19141 * BuildVisitorFromMatch< 19142 * Matches<Descendant, Check>, 19143 * Extract<Descendant, UnistParent> 19144 * > 19145 * )}
19145 BuildVisitorFromDescendants 19146 * Build a typed `Visitor` function from a list of descendants and a test. 19147 * 19148 * It will infer which values are passed as `node` and which as `parent`. 19149 * @template {UnistNode} Descendant 19150 * Node type. 19151 * @template {Test} Check 19152 * Test type. 19153 */ 19154 19155/** 19156 * @typedef {( 19157 * BuildVisitorFromDescendants< 19158 * InclusiveDescendant<Tree>, 19159 * Check 19160 * > 19161 * )} BuildVisitor 19162 * Build a typed `Visitor` function from a tree and a test. 19163 * 19164 * It will infer which values are passed as `node` and which as `parent`. 19165 * @template {UnistNode} [Tree=UnistNode] 19166 * Node type. 19167 * @template {Test} [Check=Test] 19168 * Test type. 19169 */ 19170 19171 19172 19173 19174 19175/** 19176 * Visit nodes. 19177 * 19178 * This algorithm performs *depth-first* *tree traversal* in *preorder* 19179 * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**). 19180 * 19181 * You can choose for which nodes `visitor` is called by passing a `test`. 19182 * For complex tests, you should test yourself in `visitor`, as it will be 19183 * faster and will have improved type information. 19184 * 19185 * Walking the tree is an intensive task. 19186 * Make use of the return values of the visitor when possible. 19187 * Instead of walking a tree multiple times, walk it once, use `unist-util-is` 19188 * to check if a node matches, and then perform different operations. 19189 * 19190 * You can change the tree. 19191 * See `Visitor` for more info. 19192 * 19193 * @overload 19194 * @param {Tree} tree 19195 * @param {Check} check 19196 * @param {BuildVisitor<Tree, Check>} visitor 19197 * @param {boolean | null | undefined} [reverse] 19198 * @returns {undefined} 19199 * 19200 * @overload 19201 * @param {Tree} tree 19202 * @param {BuildVisitor<Tree>} visitor 19203 * @param {boolean | null | undefined} [reverse] 19204 * @returns {undefined} 19205 * 19206 * @param {UnistNode} tree 19207 * Tree to traverse. 19208 * @param {Visitor | Test} testOrVisitor 19209 * `unist-util-is`-compatible test (optional, omit to pass a visitor). 19210 * @param {Visitor | boolean | null | undefined} [visitorOrReverse] 19211 * Handle each node (when test is omitted, pass `reverse`). 19212 * @param {boolean | null | undefined} [maybeReverse=false] 19213 * Traverse in reverse preorder (NRL) instead of the default preorder (NLR). 19214 * @returns {undefined} 19215 * Nothing. 19216 * 19217 * @template {UnistNode} Tree 19218 * Node type. 19219 * @template {Test} Check 19220 * `unist-util-is`-compatible test. 19221 */ 19222function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) { 19223 /** @type {boolean | null | undefined} */ 19224 let reverse 19225 /** @type {Test} */ 19226 let test 19227 /** @type {Visitor} */ 19228 let visitor 19229 19230 if ( 19231 typeof testOrVisitor === 'function' && 19232 typeof visitorOrReverse !== 'function' 19233 ) { 19234 test = undefined 19235 visitor = testOrVisitor 19236 reverse = visitorOrReverse 19237 } else { 19238 // @ts-expect-error: assume the overload with test was given. 19239 test = testOrVisitor 19240 // @ts-expect-error: assume the overload with test was given. 19241 visitor = visitorOrReverse 19242 reverse = maybeReverse 19243 } 19244 19245 visitParents(tree, test, overload, reverse) 19246 19247 /** 19248 * @param {UnistNode} node 19249 * @param {Array<UnistParent>} parents 19250 */ 19251 function overload(node, parents) { 19252 const parent = parents[parents.length - 1] 19253 const index = parent ? parent.children.indexOf(node) : undefined 19254 return visitor(node, index, parent) 19255 } 19256} 19257 19258;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/unist-util-visit/index.js 19259// Note: types exported from `index.d.ts` 19260 19261 19262;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/state.js 19263/** 19264 * @import { 19265 * ElementContent as HastElementContent, 19266 * Element as HastElement, 19267 * Nodes as HastNodes, 19268 * Properties as HastProperties, 19269 * RootContent as HastRootContent, 19270 * Text as HastText 19271 * } from 'hast' 19272 * @import { 19273 * Definition as MdastDefinition, 19274 * FootnoteDefinition as MdastFootnoteDefinition, 19275 * Nodes as MdastNodes, 19276 * Parents as MdastParents 19277 * } from 'mdast' 19278 * @import {VFile} from 'vfile' 19279 * @import { 19280 * FootnoteBackContentTemplate, 19281 * FootnoteBackLabelTemplate 19282 * } from './footer.js' 19283 */ 19284 19285/** 19286 * @callback Handler 19287 * Handle a node. 19288 * @param {State} state 19289 * Info passed around. 19290 * @param {any} node 19291 * mdast node to handle. 19292 * @param {MdastParents | undefined} parent 19293 * Parent of `node`. 19294 * @returns {Array<HastElementContent> | HastElementContent | undefined} 19295 * hast node. 19296 * 19297 * @typedef {Partial<Record<MdastNodes['type'], Handler>>} Handlers 19298 * Handle nodes. 19299 * 19300 * @typedef Options 19301 * Configuration (optional). 19302 * @property {boolean | null | undefined} [allowDangerousHtml=false] 19303 * Whether to persist raw HTML in markdown in the hast tree (default: 19304 * `false`). 19305 * @property {string | null | undefined} [clobberPrefix='user-content-'] 19306 * Prefix to use before the `id` property on footnotes to prevent them from 19307 * *clobbering* (default: `'user-content-'`). 19308 * 19309 * Pass `''` for trusted markdown and when you are careful with 19310 * polyfilling. 19311 * You could pass a different prefix. 19312 * 19313 * DOM clobbering is this: 19314 * 19315 * ```html 19316 * <p id="x"></p> 19317 * <script>alert(x) // `x` now refers to the `p#x` DOM element</script> 19318 * ``` 19319 * 19320 * The above example shows that elements are made available by browsers, by 19321 * their ID, on the `window` object. 19322 * This is a security risk because you might be expecting some other variable 19323 * at that place. 19324 * It can also break polyfills. 19325 * Using a prefix solves these problems. 19326 * @property {VFile | null | undefined} [file] 19327 * Corresponding virtual file representing the input document (optional). 19328 * @property {FootnoteBackContentTemplate | string | null | undefined} [footnoteBackContent] 19329 * Content of the backreference back to references (default: `defaultFootnoteBackContent`). 19330 * 19331 * The default value is: 19332 * 19333 * ```js 19334 * function defaultFootnoteBackContent(_, rereferenceIndex) { 19335 * const result = [{type: 'text', value: 'â©'}] 19336 * 19337 * if (rereferenceIndex > 1) { 19338 * result.push({ 19339 * type: 'element', 19340 * tagName: 'sup', 19341 * properties: {}, 19342 * children: [{type: 'text', value: String(rereferenceIndex)}] 19343 * }) 19344 * } 19345 * 19346 * return result 19347 * } 19348 * ``` 19349 * 19350 * This content is used in the `a` element of each backreference (the `â©` 19351 * links). 19352 * @property {FootnoteBackLabelTemplate | string | null | undefined} [footnoteBackLabel]
19353 * Label to describe the backreference back to references (default: 19354 * `defaultFootnoteBackLabel`). 19355 * 19356 * The default value is: 19357 * 19358 * ```js 19359 * function defaultFootnoteBackLabel(referenceIndex, rereferenceIndex) { 19360 * return ( 19361 * 'Back to reference ' + 19362 * (referenceIndex + 1) + 19363 * (rereferenceIndex > 1 ? '-' + rereferenceIndex : '') 19364 * ) 19365 * } 19366 * ``` 19367 * 19368 * Change it when the markdown is not in English. 19369 * 19370 * This label is used in the `ariaLabel` property on each backreference 19371 * (the `â©` links). 19372 * It affects users of assistive technology. 19373 * @property {string | null | undefined} [footnoteLabel='Footnotes'] 19374 * Textual label to use for the footnotes section (default: `'Footnotes'`). 19375 * 19376 * Change it when the markdown is not in English. 19377 * 19378 * This label is typically hidden visually (assuming a `sr-only` CSS class 19379 * is defined that does that) and so affects screen readers only. 19380 * If you do have such a class, but want to show this section to everyone, 19381 * pass different properties with the `footnoteLabelProperties` option. 19382 * @property {HastProperties | null | undefined} [footnoteLabelProperties={className: ['sr-only']}] 19383 * Properties to use on the footnote label (default: `{className: 19384 * ['sr-only']}`). 19385 * 19386 * Change it to show the label and add other properties. 19387 * 19388 * This label is typically hidden visually (assuming an `sr-only` CSS class 19389 * is defined that does that) and so affects screen readers only. 19390 * If you do have such a class, but want to show this section to everyone, 19391 * pass an empty string. 19392 * You can also add different properties. 19393 * 19394 * > **Note**: `id: 'footnote-label'` is always added, because footnote 19395 * > calls use it with `aria-describedby` to provide an accessible label. 19396 * @property {string | null | undefined} [footnoteLabelTagName='h2'] 19397 * HTML tag name to use for the footnote label element (default: `'h2'`). 19398 * 19399 * Change it to match your document structure. 19400 * 19401 * This label is typically hidden visually (assuming a `sr-only` CSS class 19402 * is defined that does that) and so affects screen readers only. 19403 * If you do have such a class, but want to show this section to everyone, 19404 * pass different properties with the `footnoteLabelProperties` option. 19405 * @property {Handlers | null | undefined} [handlers] 19406 * Extra handlers for nodes (optional). 19407 * @property {Array<MdastNodes['type']> | null | undefined} [passThrough] 19408 * List of custom mdast node types to pass through (keep) in hast (note that 19409 * the node itself is passed, but eventual children are transformed) 19410 * (optional). 19411 * @property {Handler | null | undefined} [unknownHandler] 19412 * Handler for all unknown nodes (optional). 19413 * 19414 * @typedef State 19415 * Info passed around. 19416 * @property {(node: MdastNodes) => Array<HastElementContent>} all 19417 * Transform the children of an mdast parent to hast. 19418 * @property {<Type extends HastNodes>(from: MdastNodes, to: Type) => HastElement | Type} applyData 19419 * Honor the `data` of `from`, and generate an element instead of `node`. 19420 * @property {Map<string, MdastDefinition>} definitionById 19421 * Definitions by their identifier. 19422 * @property {Map<string, MdastFootnoteDefinition>} footnoteById 19423 * Footnote definitions by their identifier. 19424 * @property {Map<string, number>} footnoteCounts 19425 * Counts for how often the same footnote was called. 19426 * @property {Array<string>} footnoteOrder 19427 * Identifiers of order when footnote calls first appear in tree order. 19428 * @property {Handlers} handlers 19429 * Applied handlers. 19430 * @property {(node: MdastNodes, parent: MdastParents | undefined) => Array<HastElementContent> | HastElementContent | undefined} one 19431 * Transform an mdast node to hast. 19432 * @property {Options} options 19433 * Configuration. 19434 * @property {(from: MdastNodes, node: HastNodes) => undefined} patch 19435 * Copy a nodeâs positional info. 19436 * @property {<Type extends HastRootContent>(nodes: Array<Type>, loose?: boolean | undefined) => Array<HastText | Type>} wrap 19437 * Wrap `nodes` with line endings between each node, adds initial/final line endings when `loose`. 19438 */ 19439 19440 19441 19442 19443 19444 19445const state_own = {}.hasOwnProperty 19446 19447/** @type {Options} */ 19448const state_emptyOptions = {} 19449 19450/** 19451 * Create `state` from an mdast tree. 19452 * 19453 * @param {MdastNodes} tree 19454 * mdast node to transform. 19455 * @param {Options | null | undefined} [options] 19456 * Configuration (optional). 19457 * @returns {State} 19458 * `state` function. 19459 */ 19460function createState(tree, options) { 19461 const settings = options || state_emptyOptions 19462 /** @type {Map<string, MdastDefinition>} */ 19463 const definitionById = new Map() 19464 /** @type {Map<string, MdastFootnoteDefinition>} */ 19465 const footnoteById = new Map() 19466 /** @type {Map<string, number>} */ 19467 const footnoteCounts = new Map() 19468 /** @type {Handlers} */ 19469 // @ts-expect-error: the root handler returns a root. 19470 // Hard to type. 19471 const handlers = {...handlers_handlers, ...settings.handlers} 19472 19473 /** @type {State} */ 19474 const state = { 19475 all, 19476 applyData, 19477 definitionById, 19478 footnoteById, 19479 footnoteCounts, 19480 footnoteOrder: [], 19481 handlers, 19482 one, 19483 options: settings, 19484 patch, 19485 wrap 19486 } 19487 19488 visit(tree, function (node) { 19489 if (node.type === 'definition' || node.type === 'footnoteDefinition') { 19490 const map = node.type === 'definition' ? definitionById : footnoteById 19491 const id = String(node.identifier).toUpperCase() 19492
19493 // Mimick CM behavior of link definitions. 19494 // See: <https://github.com/syntax-tree/mdast-util-definitions/blob/9032189/lib/index.js#L20-L21>. 19495 if (!map.has(id)) { 19496 // @ts-expect-error: node type matches map. 19497 map.set(id, node) 19498 } 19499 } 19500 }) 19501 19502 return state 19503 19504 /** 19505 * Transform an mdast node into a hast node. 19506 * 19507 * @param {MdastNodes} node 19508 * mdast node. 19509 * @param {MdastParents | undefined} [parent] 19510 * Parent of `node`. 19511 * @returns {Array<HastElementContent> | HastElementContent | undefined} 19512 * Resulting hast node. 19513 */ 19514 function one(node, parent) { 19515 const type = node.type 19516 const handle = state.handlers[type] 19517 19518 if (state_own.call(state.handlers, type) && handle) { 19519 return handle(state, node, parent) 19520 } 19521 19522 if (state.options.passThrough && state.options.passThrough.includes(type)) { 19523 if ('children' in node) { 19524 const {children, ...shallow} = node 19525 const result = esm(shallow) 19526 // @ts-expect-error: TS doesnât understand⦠19527 result.children = state.all(node) 19528 // @ts-expect-error: TS doesnât understand⦠19529 return result 19530 } 19531 19532 // @ts-expect-error: itâs custom. 19533 return esm(node) 19534 } 19535 19536 const unknown = state.options.unknownHandler || defaultUnknownHandler 19537 19538 return unknown(state, node, parent) 19539 } 19540 19541 /** 19542 * Transform the children of an mdast node into hast nodes. 19543 * 19544 * @param {MdastNodes} parent 19545 * mdast node to compile 19546 * @returns {Array<HastElementContent>} 19547 * Resulting hast nodes. 19548 */ 19549 function all(parent) { 19550 /** @type {Array<HastElementContent>} */ 19551 const values = [] 19552 19553 if ('children' in parent) { 19554 const nodes = parent.children 19555 let index = -1 19556 while (++index < nodes.length) { 19557 const result = state.one(nodes[index], parent) 19558 19559 // To do: see if we van clean this? Can we merge texts? 19560 if (result) { 19561 if (index && nodes[index - 1].type === 'break') { 19562 if (!Array.isArray(result) && result.type === 'text') { 19563 result.value = trimMarkdownSpaceStart(result.value) 19564 } 19565 19566 if (!Array.isArray(result) && result.type === 'element') { 19567 const head = result.children[0] 19568 19569 if (head && head.type === 'text') { 19570 head.value = trimMarkdownSpaceStart(head.value) 19571 } 19572 } 19573 } 19574 19575 if (Array.isArray(result)) { 19576 values.push(...result) 19577 } else { 19578 values.push(result) 19579 } 19580 } 19581 } 19582 } 19583 19584 return values 19585 } 19586} 19587 19588/** 19589 * Copy a nodeâs positional info. 19590 * 19591 * @param {MdastNodes} from 19592 * mdast node to copy from. 19593 * @param {HastNodes} to 19594 * hast node to copy into. 19595 * @returns {undefined} 19596 * Nothing. 19597 */ 19598function patch(from, to) { 19599 if (from.position) to.position = position(from) 19600} 19601 19602/** 19603 * Honor the `data` of `from` and maybe generate an element instead of `to`. 19604 * 19605 * @template {HastNodes} Type 19606 * Node type. 19607 * @param {MdastNodes} from 19608 * mdast node to use data from. 19609 * @param {Type} to 19610 * hast node to change. 19611 * @returns {HastElement | Type} 19612 * Nothing. 19613 */ 19614function applyData(from, to) { 19615 /** @type {HastElement | Type} */ 19616 let result = to 19617 19618 // Handle `data.hName`, `data.hProperties, `data.hChildren`. 19619 if (from && from.data) { 19620 const hName = from.data.hName 19621 const hChildren = from.data.hChildren 19622 const hProperties = from.data.hProperties 19623 19624 if (typeof hName === 'string') { 19625 // Transforming the node resulted in an element with a different name 19626 // than wanted: 19627 if (result.type === 'element') { 19628 result.tagName = hName 19629 } 19630 // Transforming the node resulted in a non-element, which happens for 19631 // raw, text, and root nodes (unless custom handlers are passed). 19632 // The intent of `hName` is to create an element, but likely also to keep 19633 // the content around (otherwise: pass `hChildren`). 19634 else { 19635 /** @type {Array<HastElementContent>} */ 19636 // @ts-expect-error: assume no doctypes in `root`. 19637 const children = 'children' in result ? result.children : [result] 19638 result = {type: 'element', tagName: hName, properties: {}, children} 19639 } 19640 } 19641 19642 if (result.type === 'element' && hProperties) { 19643 Object.assign(result.properties, esm(hProperties)) 19644 } 19645 19646 if ( 19647 'children' in result && 19648 result.children && 19649 hChildren !== null && 19650 hChildren !== undefined 19651 ) { 19652 result.children = hChildren 19653 } 19654 } 19655 19656 return result 19657} 19658 19659/** 19660 * Transform an unknown node. 19661 * 19662 * @param {State} state 19663 * Info passed around. 19664 * @param {MdastNodes} node 19665 * Unknown mdast node. 19666 * @returns {HastElement | HastText} 19667 * Resulting hast node. 19668 */ 19669function defaultUnknownHandler(state, node) { 19670 const data = node.data || {} 19671 /** @type {HastElement | HastText} */ 19672 const result = 19673 'value' in node && 19674 !(state_own.call(data, 'hProperties') || state_own.call(data, 'hChildren'))
19675 ? {type: 'text', value: node.value} 19676 : { 19677 type: 'element', 19678 tagName: 'div', 19679 properties: {}, 19680 children: state.all(node) 19681 } 19682 19683 state.patch(node, result) 19684 return state.applyData(node, result) 19685} 19686 19687/** 19688 * Wrap `nodes` with line endings between each node. 19689 * 19690 * @template {HastRootContent} Type 19691 * Node type. 19692 * @param {Array<Type>} nodes 19693 * List of nodes to wrap. 19694 * @param {boolean | undefined} [loose=false] 19695 * Whether to add line endings at start and end (default: `false`). 19696 * @returns {Array<HastText | Type>} 19697 * Wrapped nodes. 19698 */ 19699function wrap(nodes, loose) { 19700 /** @type {Array<HastText | Type>} */ 19701 const result = [] 19702 let index = -1 19703 19704 if (loose) { 19705 result.push({type: 'text', value: '\n'}) 19706 } 19707 19708 while (++index < nodes.length) { 19709 if (index) result.push({type: 'text', value: '\n'}) 19710 result.push(nodes[index]) 19711 } 19712 19713 if (loose && nodes.length > 0) { 19714 result.push({type: 'text', value: '\n'}) 19715 } 19716 19717 return result 19718} 19719 19720/** 19721 * Trim spaces and tabs at the start of `value`. 19722 * 19723 * @param {string} value 19724 * Value to trim. 19725 * @returns {string} 19726 * Result. 19727 */ 19728function trimMarkdownSpaceStart(value) { 19729 let index = 0 19730 let code = value.charCodeAt(index) 19731 19732 while (code === 9 || code === 32) { 19733 index++ 19734 code = value.charCodeAt(index) 19735 } 19736 19737 return value.slice(index) 19738} 19739 19740;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/lib/index.js 19741/** 19742 * @import {Nodes as HastNodes} from 'hast' 19743 * @import {Nodes as MdastNodes} from 'mdast' 19744 * @import {Options} from './state.js' 19745 */ 19746 19747 19748 19749 19750 19751/** 19752 * Transform mdast to hast. 19753 * 19754 * ##### Notes 19755 * 19756 * ###### HTML 19757 * 19758 * Raw HTML is available in mdast as `html` nodes and can be embedded in hast 19759 * as semistandard `raw` nodes. 19760 * Most utilities ignore `raw` nodes but two notable ones donât: 19761 * 19762 * * `hast-util-to-html` also has an option `allowDangerousHtml` which will 19763 * output the raw HTML. 19764 * This is typically discouraged as noted by the option name but is useful 19765 * if you completely trust authors 19766 * * `hast-util-raw` can handle the raw embedded HTML strings by parsing them 19767 * into standard hast nodes (`element`, `text`, etc). 19768 * This is a heavy task as it needs a full HTML parser, but it is the only 19769 * way to support untrusted content 19770 * 19771 * ###### Footnotes 19772 * 19773 * Many options supported here relate to footnotes. 19774 * Footnotes are not specified by CommonMark, which we follow by default. 19775 * They are supported by GitHub, so footnotes can be enabled in markdown with 19776 * `mdast-util-gfm`. 19777 * 19778 * The options `footnoteBackLabel` and `footnoteLabel` define natural language 19779 * that explains footnotes, which is hidden for sighted users but shown to 19780 * assistive technology. 19781 * When your page is not in English, you must define translated values. 19782 * 19783 * Back references use ARIA attributes, but the section label itself uses a 19784 * heading that is hidden with an `sr-only` class. 19785 * To show it to sighted users, define different attributes in 19786 * `footnoteLabelProperties`. 19787 * 19788 * ###### Clobbering 19789 * 19790 * Footnotes introduces a problem, as it links footnote calls to footnote 19791 * definitions on the page through `id` attributes generated from user content, 19792 * which results in DOM clobbering. 19793 * 19794 * DOM clobbering is this: 19795 * 19796 * ```html 19797 * <p id=x></p> 19798 * <script>alert(x) // `x` now refers to the DOM `p#x` element</script> 19799 * ``` 19800 * 19801 * Elements by their ID are made available by browsers on the `window` object, 19802 * which is a security risk. 19803 * Using a prefix solves this problem. 19804 * 19805 * More information on how to handle clobbering and the prefix is explained in 19806 * Example: headings (DOM clobbering) in `rehype-sanitize`. 19807 * 19808 * ###### Unknown nodes 19809 * 19810 * Unknown nodes are nodes with a type that isnât in `handlers` or `passThrough`. 19811 * The default behavior for unknown nodes is: 19812 * 19813 * * when the node has a `value` (and doesnât have `data.hName`, 19814 * `data.hProperties`, or `data.hChildren`, see later), create a hast `text` 19815 * node 19816 * * otherwise, create a `<div>` element (which could be changed with 19817 * `data.hName`), with its children mapped from mdast to hast as well 19818 * 19819 * This behavior can be changed by passing an `unknownHandler`. 19820 * 19821 * @param {MdastNodes} tree 19822 * mdast tree. 19823 * @param {Options | null | undefined} [options] 19824 * Configuration (optional). 19825 * @returns {HastNodes} 19826 * hast tree. 19827 */ 19828function toHast(tree, options) { 19829 const state = createState(tree, options) 19830 const node = state.one(tree, undefined) 19831 const foot = footer(state) 19832 /** @type {HastNodes} */ 19833 const result = Array.isArray(node) 19834 ? {type: 'root', children: node} 19835 : node || {type: 'root', children: []} 19836 19837 if (foot) { 19838 // If thereâs a footer, there were definitions, meaning block 19839 // content. 19840 // So `result` is a parent node. 19841 ok('children' in result) 19842 result.children.push({type: 'text', value: '\n'}, foot) 19843 } 19844 19845 return result 19846} 19847 19848;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-hast/index.js
19849// Note: types exposed from `index.d.ts`. 19850 19851 19852 19853 19854;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/remark-rehype/lib/index.js 19855/** 19856 * @import {Root as HastRoot} from 'hast' 19857 * @import {Root as MdastRoot} from 'mdast' 19858 * @import {Options as ToHastOptions} from 'mdast-util-to-hast' 19859 * @import {Processor} from 'unified' 19860 * @import {VFile} from 'vfile' 19861 */ 19862 19863/** 19864 * @typedef {Omit<ToHastOptions, 'file'>} Options 19865 * 19866 * @callback TransformBridge 19867 * Bridge-mode. 19868 * 19869 * Runs the destination with the new hast tree. 19870 * Discards result. 19871 * @param {MdastRoot} tree 19872 * Tree. 19873 * @param {VFile} file 19874 * File. 19875 * @returns {Promise<undefined>} 19876 * Nothing. 19877 * 19878 * @callback TransformMutate 19879 * Mutate-mode. 19880 * 19881 * Further transformers run on the hast tree. 19882 * @param {MdastRoot} tree 19883 * Tree. 19884 * @param {VFile} file 19885 * File. 19886 * @returns {HastRoot} 19887 * Tree (hast). 19888 */ 19889 19890 19891 19892/** 19893 * Turn markdown into HTML. 19894 * 19895 * ##### Notes 19896 * 19897 * ###### Signature 19898 * 19899 * * if a processor is given, 19900 * runs the (rehype) plugins used on it with a hast tree, 19901 * then discards the result (*bridge mode*) 19902 * * otherwise, 19903 * returns a hast tree, 19904 * the plugins used after `remarkRehype` are rehype plugins (*mutate mode*) 19905 * 19906 * > ð **Note**: 19907 * > Itâs highly unlikely that you want to pass a `processor`. 19908 * 19909 * ###### HTML 19910 * 19911 * Raw HTML is available in mdast as `html` nodes and can be embedded in hast 19912 * as semistandard `raw` nodes. 19913 * Most plugins ignore `raw` nodes but two notable ones donât: 19914 * 19915 * * `rehype-stringify` also has an option `allowDangerousHtml` which will 19916 * output the raw HTML. 19917 * This is typically discouraged as noted by the option name but is useful if 19918 * you completely trust authors 19919 * * `rehype-raw` can handle the raw embedded HTML strings by parsing them 19920 * into standard hast nodes (`element`, `text`, etc); 19921 * this is a heavy task as it needs a full HTML parser, 19922 * but it is the only way to support untrusted content 19923 * 19924 * ###### Footnotes 19925 * 19926 * Many options supported here relate to footnotes. 19927 * Footnotes are not specified by CommonMark, 19928 * which we follow by default. 19929 * They are supported by GitHub, 19930 * so footnotes can be enabled in markdown with `remark-gfm`. 19931 * 19932 * The options `footnoteBackLabel` and `footnoteLabel` define natural language 19933 * that explains footnotes, 19934 * which is hidden for sighted users but shown to assistive technology. 19935 * When your page is not in English, 19936 * you must define translated values. 19937 * 19938 * Back references use ARIA attributes, 19939 * but the section label itself uses a heading that is hidden with an 19940 * `sr-only` class. 19941 * To show it to sighted users, 19942 * define different attributes in `footnoteLabelProperties`. 19943 * 19944 * ###### Clobbering 19945 * 19946 * Footnotes introduces a problem, 19947 * as it links footnote calls to footnote definitions on the page through `id` 19948 * attributes generated from user content, 19949 * which results in DOM clobbering. 19950 * 19951 * DOM clobbering is this: 19952 * 19953 * ```html 19954 * <p id=x></p> 19955 * <script>alert(x) // `x` now refers to the DOM `p#x` element</script> 19956 * ``` 19957 * 19958 * Elements by their ID are made available by browsers on the `window` object, 19959 * which is a security risk. 19960 * Using a prefix solves this problem. 19961 * 19962 * More information on how to handle clobbering and the prefix is explained in 19963 * *Example: headings (DOM clobbering)* in `rehype-sanitize`. 19964 * 19965 * ###### Unknown nodes 19966 * 19967 * Unknown nodes are nodes with a type that isnât in `handlers` or `passThrough`. 19968 * The default behavior for unknown nodes is: 19969 * 19970 * * when the node has a `value` 19971 * (and doesnât have `data.hName`, `data.hProperties`, or `data.hChildren`, 19972 * see later), 19973 * create a hast `text` node 19974 * * otherwise, 19975 * create a `<div>` element (which could be changed with `data.hName`), 19976 * with its children mapped from mdast to hast as well 19977 * 19978 * This behavior can be changed by passing an `unknownHandler`. 19979 * 19980 * @overload 19981 * @param {Processor} processor 19982 * @param {Readonly<Options> | null | undefined} [options] 19983 * @returns {TransformBridge} 19984 * 19985 * @overload 19986 * @param {Readonly<Options> | null | undefined} [options] 19987 * @returns {TransformMutate} 19988 * 19989 * @overload 19990 * @param {Readonly<Options> | Processor | null | undefined} [destination] 19991 * @param {Readonly<Options> | null | undefined} [options] 19992 * @returns {TransformBridge | TransformMutate} 19993 * 19994 * @param {Readonly<Options> | Processor | null | undefined} [destination] 19995 * Processor or configuration (optional). 19996 * @param {Readonly<Options> | null | undefined} [options] 19997 * When a processor was given, 19998 * configuration (optional). 19999 * @returns {TransformBridge | TransformMutate} 20000 * Transform. 20001 */ 20002function remarkRehype(destination, options) { 20003 if (destination && 'run' in destination) { 20004 /** 20005 * @type {TransformBridge} 20006 */ 20007 return async function (tree, file) { 20008 // Cast because root in -> root out. 20009 const hastTree = /** @type {HastRoot} */ ( 20010 toHast(tree, {file, ...options}) 20011 ) 20012 await destination.run(hastTree, file) 20013 } 20014 } 20015 20016 /** 20017 * @type {TransformMutate} 20018 */ 20019 return function (tree, file) { 20020 // Cast because root in -> root out. 20021 // To do: in the future, disallow ` || options` fallback. 20022 // With `unified-engine`, `destination` can be `undefined` but 20023 // `options` will be the file set. 20024 // We should not pass that as `options`. 20025 return /** @type {HastRoot} */ ( 20026 toHast(tree, {file, ...(destination || options)}) 20027 ) 20028 } 20029} 20030 20031;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/remark-rehype/index.js 20032/** 20033 * @typedef {import('./lib/index.js').Options} Options 20034 */ 20035 20036 20037 20038 20039;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/bail/index.js 20040/** 20041 * Throw a given error. 20042 * 20043 * @param {Error|null|undefined} [error] 20044 * Maybe error. 20045 * @returns {asserts error is null|undefined} 20046 */ 20047function bail(error) { 20048 if (error) { 20049 throw error 20050 } 20051} 20052 20053// EXTERNAL MODULE: ./node_modules/.pnpm/[email protected]/node_modules/extend/index.js 20054var extend = __webpack_require__(8613); 20055;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/is-plain-obj/index.js 20056function isPlainObject(value) { 20057 if (typeof value !== 'object' || value === null) { 20058 return false;
20059 } 20060 20061 const prototype = Object.getPrototypeOf(value); 20062 return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value); 20063} 20064 20065;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/trough/lib/index.js 20066// To do: remove `void`s 20067// To do: remove `null` from output of our APIs, allow it as user APIs. 20068 20069/** 20070 * @typedef {(error?: Error | null | undefined, ...output: Array<any>) => void} Callback 20071 * Callback. 20072 * 20073 * @typedef {(...input: Array<any>) => any} Middleware 20074 * Ware. 20075 * 20076 * @typedef Pipeline 20077 * Pipeline. 20078 * @property {Run} run 20079 * Run the pipeline. 20080 * @property {Use} use 20081 * Add middleware. 20082 * 20083 * @typedef {(...input: Array<any>) => void} Run 20084 * Call all middleware. 20085 * 20086 * Calls `done` on completion with either an error or the output of the 20087 * last middleware. 20088 * 20089 * > ð **Note**: as the length of input defines whether async functions get a 20090 * > `next` function, 20091 * > itâs recommended to keep `input` at one value normally. 20092 20093 * 20094 * @typedef {(fn: Middleware) => Pipeline} Use 20095 * Add middleware. 20096 */ 20097 20098/** 20099 * Create new middleware. 20100 * 20101 * @returns {Pipeline} 20102 * Pipeline. 20103 */ 20104function trough() { 20105 /** @type {Array<Middleware>} */ 20106 const fns = [] 20107 /** @type {Pipeline} */ 20108 const pipeline = {run, use} 20109 20110 return pipeline 20111 20112 /** @type {Run} */ 20113 function run(...values) { 20114 let middlewareIndex = -1 20115 /** @type {Callback} */ 20116 const callback = values.pop() 20117 20118 if (typeof callback !== 'function') { 20119 throw new TypeError('Expected function as last argument, not ' + callback) 20120 } 20121 20122 next(null, ...values) 20123 20124 /** 20125 * Run the next `fn`, or weâre done. 20126 * 20127 * @param {Error | null | undefined} error 20128 * @param {Array<any>} output 20129 */ 20130 function next(error, ...output) { 20131 const fn = fns[++middlewareIndex] 20132 let index = -1 20133 20134 if (error) { 20135 callback(error) 20136 return 20137 } 20138 20139 // Copy non-nullish input into values. 20140 while (++index < values.length) { 20141 if (output[index] === null || output[index] === undefined) { 20142 output[index] = values[index] 20143 } 20144 } 20145 20146 // Save the newly created `output` for the next call. 20147 values = output 20148 20149 // Next or done. 20150 if (fn) { 20151 lib_wrap(fn, next)(...output) 20152 } else { 20153 callback(null, ...output) 20154 } 20155 } 20156 } 20157 20158 /** @type {Use} */ 20159 function use(middelware) { 20160 if (typeof middelware !== 'function') { 20161 throw new TypeError( 20162 'Expected `middelware` to be a function, not ' + middelware 20163 ) 20164 } 20165 20166 fns.push(middelware) 20167 return pipeline 20168 } 20169} 20170 20171/** 20172 * Wrap `middleware` into a uniform interface. 20173 * 20174 * You can pass all input to the resulting function. 20175 * `callback` is then called with the output of `middleware`. 20176 * 20177 * If `middleware` accepts more arguments than the later given in input, 20178 * an extra `done` function is passed to it after that input, 20179 * which must be called by `middleware`. 20180 * 20181 * The first value in `input` is the main input value. 20182 * All other input values are the rest input values. 20183 * The values given to `callback` are the input values, 20184 * merged with every non-nullish output value. 20185 * 20186 * * if `middleware` throws an error, 20187 * returns a promise that is rejected, 20188 * or calls the given `done` function with an error, 20189 * `callback` is called with that error 20190 * * if `middleware` returns a value or returns a promise that is resolved, 20191 * that value is the main output value 20192 * * if `middleware` calls `done`, 20193 * all non-nullish values except for the first one (the error) overwrite the 20194 * output values 20195 * 20196 * @param {Middleware} middleware 20197 * Function to wrap. 20198 * @param {Callback} callback 20199 * Callback called with the output of `middleware`. 20200 * @returns {Run} 20201 * Wrapped middleware. 20202 */ 20203function lib_wrap(middleware, callback) { 20204 /** @type {boolean} */ 20205 let called 20206 20207 return wrapped 20208 20209 /** 20210 * Call `middleware`. 20211 * @this {any} 20212 * @param {Array<any>} parameters 20213 * @returns {void} 20214 */ 20215 function wrapped(...parameters) { 20216 const fnExpectsCallback = middleware.length > parameters.length 20217 /** @type {any} */ 20218 let result 20219 20220 if (fnExpectsCallback) { 20221 parameters.push(done) 20222 } 20223 20224 try { 20225 result = middleware.apply(this, parameters) 20226 } catch (error) { 20227 const exception = /** @type {Error} */ (error) 20228 20229 // Well, this is quite the pickle.
20230 // `middleware` received a callback and called it synchronously, but that 20231 // threw an error. 20232 // The only thing left to do is to throw the thing instead. 20233 if (fnExpectsCallback && called) { 20234 throw exception 20235 } 20236 20237 return done(exception) 20238 } 20239 20240 if (!fnExpectsCallback) { 20241 if (result && result.then && typeof result.then === 'function') { 20242 result.then(then, done) 20243 } else if (result instanceof Error) { 20244 done(result) 20245 } else { 20246 then(result) 20247 } 20248 } 20249 } 20250 20251 /** 20252 * Call `callback`, only once. 20253 * 20254 * @type {Callback} 20255 */ 20256 function done(error, ...output) { 20257 if (!called) { 20258 called = true 20259 callback(error, ...output) 20260 } 20261 } 20262 20263 /** 20264 * Call `done` with one value. 20265 * 20266 * @param {any} [value] 20267 */ 20268 function then(value) { 20269 done(null, value) 20270 } 20271} 20272 20273;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/trough/index.js 20274/** 20275 * @typedef {import('./lib/index.js').Callback} Callback 20276 * @typedef {import('./lib/index.js').Middleware} Middleware 20277 * @typedef {import('./lib/index.js').Pipeline} Pipeline 20278 * @typedef {import('./lib/index.js').Run} Run 20279 * @typedef {import('./lib/index.js').Use} Use 20280 */ 20281 20282 20283 20284;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/vfile/lib/minpath.browser.js 20285// A derivative work based on: 20286// <https://github.com/browserify/path-browserify>. 20287// Which is licensed: 20288// 20289// MIT License 20290// 20291// Copyright (c) 2013 James Halliday 20292// 20293// Permission is hereby granted, free of charge, to any person obtaining a copy of 20294// this software and associated documentation files (the "Software"), to deal in 20295// the Software without restriction, including without limitation the rights to 20296// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 20297// the Software, and to permit persons to whom the Software is furnished to do so, 20298// subject to the following conditions: 20299// 20300// The above copyright notice and this permission notice shall be included in all 20301// copies or substantial portions of the Software. 20302// 20303// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20304// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 20305// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20306// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20307// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20308// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20309// A derivative work based on: 20310// 20311// Parts of that are extracted from Nodeâs internal `path` module: 20312// <https://github.com/nodejs/node/blob/master/lib/path.js>. 20313// Which is licensed: 20314// 20315// Copyright Joyent, Inc. and other Node contributors. 20316// 20317// Permission is hereby granted, free of charge, to any person obtaining a 20318// copy of this software and associated documentation files (the 20319// "Software"), to deal in the Software without restriction, including 20320// without limitation the rights to use, copy, modify, merge, publish, 20321// distribute, sublicense, and/or sell copies of the Software, and to permit 20322// persons to whom the Software is furnished to do so, subject to the 20323// following conditions: 20324// 20325// The above copyright notice and this permission notice shall be included 20326// in all copies or substantial portions of the Software. 20327// 20328// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20329// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20330// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 20331// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20332// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20333// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20334// USE OR OTHER DEALINGS IN THE SOFTWARE. 20335 20336const minpath = {basename, dirname, extname, join, sep: '/'} 20337 20338/* eslint-disable max-depth, complexity */ 20339 20340/**
20341 * Get the basename from a path. 20342 * 20343 * @param {string} path 20344 * File path. 20345 * @param {string | null | undefined} [extname] 20346 * Extension to strip. 20347 * @returns {string} 20348 * Stem or basename. 20349 */ 20350function basename(path, extname) { 20351 if (extname !== undefined && typeof extname !== 'string') { 20352 throw new TypeError('"ext" argument must be a string') 20353 } 20354 20355 assertPath(path) 20356 let start = 0 20357 let end = -1 20358 let index = path.length 20359 /** @type {boolean | undefined} */ 20360 let seenNonSlash 20361 20362 if ( 20363 extname === undefined || 20364 extname.length === 0 || 20365 extname.length > path.length 20366 ) { 20367 while (index--) { 20368 if (path.codePointAt(index) === 47 /* `/` */) { 20369 // If we reached a path separator that was not part of a set of path 20370 // separators at the end of the string, stop now. 20371 if (seenNonSlash) { 20372 start = index + 1 20373 break 20374 } 20375 } else if (end < 0) { 20376 // We saw the first non-path separator, mark this as the end of our 20377 // path component. 20378 seenNonSlash = true 20379 end = index + 1 20380 } 20381 } 20382 20383 return end < 0 ? '' : path.slice(start, end) 20384 } 20385 20386 if (extname === path) { 20387 return '' 20388 } 20389 20390 let firstNonSlashEnd = -1 20391 let extnameIndex = extname.length - 1 20392 20393 while (index--) { 20394 if (path.codePointAt(index) === 47 /* `/` */) { 20395 // If we reached a path separator that was not part of a set of path 20396 // separators at the end of the string, stop now. 20397 if (seenNonSlash) { 20398 start = index + 1 20399 break 20400 } 20401 } else { 20402 if (firstNonSlashEnd < 0) { 20403 // We saw the first non-path separator, remember this index in case 20404 // we need it if the extension ends up not matching. 20405 seenNonSlash = true 20406 firstNonSlashEnd = index + 1 20407 } 20408 20409 if (extnameIndex > -1) { 20410 // Try to match the explicit extension. 20411 if (path.codePointAt(index) === extname.codePointAt(extnameIndex--)) { 20412 if (extnameIndex < 0) { 20413 // We matched the extension, so mark this as the end of our path 20414 // component 20415 end = index 20416 } 20417 } else { 20418 // Extension does not match, so our result is the entire path 20419 // component 20420 extnameIndex = -1 20421 end = firstNonSlashEnd 20422 } 20423 } 20424 } 20425 } 20426 20427 if (start === end) { 20428 end = firstNonSlashEnd 20429 } else if (end < 0) { 20430 end = path.length 20431 } 20432 20433 return path.slice(start, end) 20434} 20435 20436/** 20437 * Get the dirname from a path. 20438 * 20439 * @param {string} path 20440 * File path. 20441 * @returns {string} 20442 * File path. 20443 */ 20444function dirname(path) { 20445 assertPath(path) 20446 20447 if (path.length === 0) { 20448 return '.' 20449 } 20450 20451 let end = -1 20452 let index = path.length 20453 /** @type {boolean | undefined} */ 20454 let unmatchedSlash 20455 20456 // Prefix `--` is important to not run on `0`. 20457 while (--index) { 20458 if (path.codePointAt(index) === 47 /* `/` */) { 20459 if (unmatchedSlash) { 20460 end = index 20461 break 20462 } 20463 } else if (!unmatchedSlash) { 20464 // We saw the first non-path separator 20465 unmatchedSlash = true 20466 } 20467 } 20468 20469 return end < 0 20470 ? path.codePointAt(0) === 47 /* `/` */ 20471 ? '/' 20472 : '.' 20473 : end === 1 && path.codePointAt(0) === 47 /* `/` */ 20474 ? '//' 20475 : path.slice(0, end) 20476} 20477 20478/** 20479 * Get an extname from a path. 20480 * 20481 * @param {string} path 20482 * File path. 20483 * @returns {string} 20484 * Extname. 20485 */ 20486function extname(path) { 20487 assertPath(path) 20488 20489 let index = path.length 20490 20491 let end = -1 20492 let startPart = 0 20493 let startDot = -1 20494 // Track the state of characters (if any) we see before our first dot and 20495 // after any path separator we find. 20496 let preDotState = 0 20497 /** @type {boolean | undefined} */ 20498 let unmatchedSlash 20499 20500 while (index--) { 20501 const code = path.codePointAt(index) 20502 20503 if (code === 47 /* `/` */) { 20504 // If we reached a path separator that was not part of a set of path 20505 // separators at the end of the string, stop now. 20506 if (unmatchedSlash) { 20507 startPart = index + 1 20508 break 20509 } 20510 20511 continue 20512 } 20513 20514 if (end < 0) { 20515 // We saw the first non-path separator, mark this as the end of our 20516 // extension. 20517 unmatchedSlash = true 20518 end = index + 1 20519 } 20520 20521 if (code === 46 /* `.` */) { 20522 // If this is our first dot, mark it as the start of our extension. 20523 if (startDot < 0) { 20524 startDot = index 20525 } else if (preDotState !== 1) { 20526 preDotState = 1 20527 } 20528 } else if (startDot > -1) { 20529 // We saw a non-dot and non-path separator before our dot, so we should 20530 // have a good chance at having a non-empty extension. 20531 preDotState = -1 20532 } 20533 } 20534 20535 if ( 20536 startDot < 0 || 20537 end < 0 || 20538 // We saw a non-dot character immediately before the dot. 20539 preDotState === 0 || 20540 // The (right-most) trimmed path component is exactly `..`. 20541 (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) 20542 ) { 20543 return '' 20544 } 20545 20546 return path.slice(startDot, end) 20547} 20548 20549/** 20550 * Join segments from a path. 20551 * 20552 * @param {Array<string>} segments 20553 * Path segments. 20554 * @returns {string} 20555 * File path. 20556 */ 20557function join(...segments) { 20558 let index = -1 20559 /** @type {string | undefined} */ 20560 let joined 20561 20562 while (++index < segments.length) { 20563 assertPath(segments[index]) 20564 20565 if (segments[index]) { 20566 joined = 20567 joined === undefined ? segments[index] : joined + '/' + segments[index] 20568 } 20569 } 20570 20571 return joined === undefined ? '.' : minpath_browser_normalize(joined) 20572} 20573 20574/** 20575 * Normalize a basic file path. 20576 * 20577 * @param {string} path 20578 * File path. 20579 * @returns {string} 20580 * File path. 20581 */ 20582// Note: `normalize` is not exposed as `path.normalize`, so some code is 20583// manually removed from it. 20584function minpath_browser_normalize(path) { 20585 assertPath(path) 20586 20587 const absolute = path.codePointAt(0) === 47 /* `/` */ 20588 20589 // Normalize the path according to POSIX rules.
20590 let value = normalizeString(path, !absolute) 20591 20592 if (value.length === 0 && !absolute) { 20593 value = '.' 20594 } 20595 20596 if (value.length > 0 && path.codePointAt(path.length - 1) === 47 /* / */) { 20597 value += '/' 20598 } 20599 20600 return absolute ? '/' + value : value 20601} 20602 20603/** 20604 * Resolve `.` and `..` elements in a path with directory names. 20605 * 20606 * @param {string} path 20607 * File path. 20608 * @param {boolean} allowAboveRoot 20609 * Whether `..` can move above root. 20610 * @returns {string} 20611 * File path. 20612 */ 20613function normalizeString(path, allowAboveRoot) { 20614 let result = '' 20615 let lastSegmentLength = 0 20616 let lastSlash = -1 20617 let dots = 0 20618 let index = -1 20619 /** @type {number | undefined} */ 20620 let code 20621 /** @type {number} */ 20622 let lastSlashIndex 20623 20624 while (++index <= path.length) { 20625 if (index < path.length) { 20626 code = path.codePointAt(index) 20627 } else if (code === 47 /* `/` */) { 20628 break 20629 } else { 20630 code = 47 /* `/` */ 20631 } 20632 20633 if (code === 47 /* `/` */) { 20634 if (lastSlash === index - 1 || dots === 1) { 20635 // Empty. 20636 } else if (lastSlash !== index - 1 && dots === 2) { 20637 if ( 20638 result.length < 2 || 20639 lastSegmentLength !== 2 || 20640 result.codePointAt(result.length - 1) !== 46 /* `.` */ || 20641 result.codePointAt(result.length - 2) !== 46 /* `.` */ 20642 ) { 20643 if (result.length > 2) { 20644 lastSlashIndex = result.lastIndexOf('/') 20645 20646 if (lastSlashIndex !== result.length - 1) { 20647 if (lastSlashIndex < 0) { 20648 result = '' 20649 lastSegmentLength = 0 20650 } else { 20651 result = result.slice(0, lastSlashIndex) 20652 lastSegmentLength = result.length - 1 - result.lastIndexOf('/') 20653 } 20654 20655 lastSlash = index 20656 dots = 0 20657 continue 20658 } 20659 } else if (result.length > 0) { 20660 result = '' 20661 lastSegmentLength = 0 20662 lastSlash = index 20663 dots = 0 20664 continue 20665 } 20666 } 20667 20668 if (allowAboveRoot) { 20669 result = result.length > 0 ? result + '/..' : '..' 20670 lastSegmentLength = 2 20671 } 20672 } else { 20673 if (result.length > 0) { 20674 result += '/' + path.slice(lastSlash + 1, index) 20675 } else { 20676 result = path.slice(lastSlash + 1, index) 20677 } 20678 20679 lastSegmentLength = index - lastSlash - 1 20680 } 20681 20682 lastSlash = index 20683 dots = 0 20684 } else if (code === 46 /* `.` */ && dots > -1) { 20685 dots++ 20686 } else { 20687 dots = -1 20688 } 20689 } 20690 20691 return result 20692} 20693 20694/** 20695 * Make sure `path` is a string. 20696 * 20697 * @param {string} path 20698 * File path. 20699 * @returns {asserts path is string} 20700 * Nothing. 20701 */ 20702function assertPath(path) { 20703 if (typeof path !== 'string') { 20704 throw new TypeError( 20705 'Path must be a string. Received ' + JSON.stringify(path) 20706 ) 20707 } 20708} 20709 20710/* eslint-enable max-depth, complexity */ 20711 20712;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/vfile/lib/minproc.browser.js 20713// Somewhat based on: 20714// <https://github.com/defunctzombie/node-process/blob/master/browser.js>. 20715// But I donât think one tiny line of code can be copyrighted. ð 20716const minproc = {cwd} 20717 20718function cwd() { 20719 return '/' 20720} 20721 20722;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/vfile/lib/minurl.shared.js 20723/** 20724 * Checks if a value has the shape of a WHATWG URL object. 20725 * 20726 * Using a symbol or instanceof would not be able to recognize URL objects 20727 * coming from other implementations (e.g. in Electron), so instead we are 20728 * checking some well known properties for a lack of a better test. 20729 * 20730 * We use `href` and `protocol` as they are the only properties that are 20731 * easy to retrieve and calculate due to the lazy nature of the getters. 20732 * 20733 * We check for auth attribute to distinguish legacy url instance with 20734 * WHATWG URL instance. 20735 * 20736 * @param {unknown} fileUrlOrPath 20737 * File path or URL. 20738 * @returns {fileUrlOrPath is URL} 20739 * Whether itâs a URL. 20740 */ 20741// From: <https://github.com/nodejs/node/blob/6a3403c/lib/internal/url.js#L720> 20742function isUrl(fileUrlOrPath) { 20743 return Boolean( 20744 fileUrlOrPath !== null && 20745 typeof fileUrlOrPath === 'object' && 20746 'href' in fileUrlOrPath && 20747 fileUrlOrPath.href && 20748 'protocol' in fileUrlOrPath && 20749 fileUrlOrPath.protocol && 20750 // @ts-expect-error: indexing is fine. 20751 fileUrlOrPath.auth === undefined 20752 ) 20753} 20754 20755;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/vfile/lib/minurl.browser.js 20756 20757 20758 20759 20760// See: <https://github.com/nodejs/node/blob/6a3403c/lib/internal/url.js> 20761 20762/** 20763 * @param {URL | string} path 20764 * File URL. 20765 * @returns {string} 20766 * File URL. 20767 */ 20768function urlToPath(path) { 20769 if (typeof path === 'string') { 20770 path = new URL(path) 20771 } else if (!isUrl(path)) { 20772 /** @type {NodeJS.ErrnoException} */ 20773 const error = new TypeError( 20774 'The "path" argument must be of type string or an instance of URL. Received `' + 20775 path + 20776 '`' 20777 ) 20778 error.code = 'ERR_INVALID_ARG_TYPE' 20779 throw error 20780 } 20781 20782 if (path.protocol !== 'file:') { 20783 /** @type {NodeJS.ErrnoException} */ 20784 const error = new TypeError('The URL must be of scheme file') 20785 error.code = 'ERR_INVALID_URL_SCHEME' 20786 throw error 20787 } 20788 20789 return getPathFromURLPosix(path) 20790} 20791 20792/** 20793 * Get a path from a POSIX URL. 20794 * 20795 * @param {URL} url 20796 * URL. 20797 * @returns {string} 20798 * File path. 20799 */ 20800function getPathFromURLPosix(url) { 20801 if (url.hostname !== '') { 20802 /** @type {NodeJS.ErrnoException} */ 20803 const error = new TypeError( 20804 'File URL host must be "localhost" or empty on darwin' 20805 ) 20806 error.code = 'ERR_INVALID_FILE_URL_HOST' 20807 throw error 20808 } 20809 20810 const pathname = url.pathname 20811 let index = -1 20812 20813 while (++index < pathname.length) { 20814 if ( 20815 pathname.codePointAt(index) === 37 /* `%` */ && 20816 pathname.codePointAt(index + 1) === 50 /* `2` */ 20817 ) { 20818 const third = pathname.codePointAt(index + 2) 20819 if (third === 70 /* `F` */ || third === 102 /* `f` */) { 20820 /** @type {NodeJS.ErrnoException} */ 20821 const error = new TypeError( 20822 'File URL path must not include encoded / characters' 20823 ) 20824 error.code = 'ERR_INVALID_FILE_URL_PATH' 20825 throw error 20826 } 20827 } 20828 } 20829 20830 return decodeURIComponent(pathname) 20831} 20832 20833;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/vfile/lib/index.js 20834/** 20835 * @import {Node, Point, Position} from 'unist' 20836 * @import {Options as MessageOptions} from 'vfile-message' 20837 * @import {Compatible, Data, Map, Options, Value} from 'vfile' 20838 */ 20839 20840/** 20841 * @typedef {object & {type: string, position?: Position | undefined}} NodeLike 20842 */ 20843 20844 20845 20846 20847 20848 20849/** 20850 * Order of setting (least specific to most), we need this because otherwise 20851 * `{stem: 'a', path: '~/b.js'}` would throw, as a path is needed before a 20852 * stem can be set. 20853 */ 20854const order = /** @type {const} */ ([ 20855 'history', 20856 'path', 20857 'basename', 20858 'stem', 20859 'extname', 20860 'dirname' 20861]) 20862 20863class VFile { 20864 /** 20865 * Create a new virtual file. 20866 * 20867 * `options` is treated as: 20868 * 20869 * * `string` or `Uint8Array` â `{value: options}` 20870 * * `URL` â `{path: options}` 20871 * * `VFile` â shallow copies its data over to the new file 20872 * * `object` â all fields are shallow copied over to the new file 20873 * 20874 * Path related fields are set in the following order (least specific to 20875 * most specific): `history`, `path`, `basename`, `stem`, `extname`, 20876 * `dirname`. 20877 * 20878 * You cannot set `dirname` or `extname` without setting either `history`, 20879 * `path`, `basename`, or `stem` too. 20880 * 20881 * @param {Compatible | null | undefined} [value] 20882 * File value. 20883 * @returns 20884 * New instance. 20885 */ 20886 constructor(value) { 20887 /** @type {Options | VFile} */ 20888 let options 20889 20890 if (!value) { 20891 options = {} 20892 } else if (isUrl(value)) { 20893 options = {path: value} 20894 } else if (typeof value === 'string' || isUint8Array(value)) { 20895 options = {value} 20896 } else { 20897 options = value 20898 } 20899 20900 /* eslint-disable no-unused-expressions */ 20901 20902 /** 20903 * Base of `path` (default: `process.cwd()` or `'/'` in browsers). 20904 * 20905 * @type {string} 20906 */ 20907 // Prevent calling `cwd` (which could be expensive) if itâs not needed; 20908 // the empty string will be overridden in the next block.
20909 this.cwd = 'cwd' in options ? '' : minproc.cwd() 20910 20911 /** 20912 * Place to store custom info (default: `{}`). 20913 * 20914 * Itâs OK to store custom data directly on the file but moving it to 20915 * `data` is recommended. 20916 * 20917 * @type {Data} 20918 */ 20919 this.data = {} 20920 20921 /** 20922 * List of file paths the file moved between. 20923 * 20924 * The first is the original path and the last is the current path. 20925 * 20926 * @type {Array<string>} 20927 */ 20928 this.history = [] 20929 20930 /** 20931 * List of messages associated with the file. 20932 * 20933 * @type {Array<VFileMessage>} 20934 */ 20935 this.messages = [] 20936 20937 /** 20938 * Raw value. 20939 * 20940 * @type {Value} 20941 */ 20942 this.value 20943 20944 // The below are non-standard, they are âwell-knownâ. 20945 // As in, used in several tools. 20946 /** 20947 * Source map. 20948 * 20949 * This type is equivalent to the `RawSourceMap` type from the `source-map` 20950 * module. 20951 * 20952 * @type {Map | null | undefined} 20953 */ 20954 this.map 20955 20956 /** 20957 * Custom, non-string, compiled, representation. 20958 * 20959 * This is used by unified to store non-string results. 20960 * One example is when turning markdown into React nodes. 20961 * 20962 * @type {unknown} 20963 */ 20964 this.result 20965 20966 /** 20967 * Whether a file was saved to disk. 20968 * 20969 * This is used by vfile reporters. 20970 * 20971 * @type {boolean} 20972 */ 20973 this.stored 20974 /* eslint-enable no-unused-expressions */ 20975 20976 // Set path related properties in the correct order. 20977 let index = -1 20978 20979 while (++index < order.length) { 20980 const field = order[index] 20981 20982 // Note: we specifically use `in` instead of `hasOwnProperty` to accept 20983 // `vfile`s too. 20984 if ( 20985 field in options && 20986 options[field] !== undefined && 20987 options[field] !== null 20988 ) { 20989 // @ts-expect-error: TS doesnât understand basic reality. 20990 this[field] = field === 'history' ? [...options[field]] : options[field] 20991 } 20992 } 20993 20994 /** @type {string} */ 20995 let field 20996 20997 // Set non-path related properties. 20998 for (field in options) { 20999 // @ts-expect-error: fine to set other things. 21000 if (!order.includes(field)) { 21001 // @ts-expect-error: fine to set other things. 21002 this[field] = options[field] 21003 } 21004 } 21005 } 21006 21007 /**
21008 * Get the basename (including extname) (example: `'index.min.js'`). 21009 * 21010 * @returns {string | undefined} 21011 * Basename. 21012 */ 21013 get basename() { 21014 return typeof this.path === 'string' 21015 ? minpath.basename(this.path) 21016 : undefined 21017 } 21018 21019 /** 21020 * Set basename (including extname) (`'index.min.js'`). 21021 * 21022 * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'` 21023 * on windows). 21024 * Cannot be nullified (use `file.path = file.dirname` instead). 21025 * 21026 * @param {string} basename 21027 * Basename. 21028 * @returns {undefined} 21029 * Nothing. 21030 */ 21031 set basename(basename) { 21032 assertNonEmpty(basename, 'basename') 21033 assertPart(basename, 'basename') 21034 this.path = minpath.join(this.dirname || '', basename) 21035 } 21036 21037 /** 21038 * Get the parent path (example: `'~'`). 21039 * 21040 * @returns {string | undefined} 21041 * Dirname. 21042 */ 21043 get dirname() { 21044 return typeof this.path === 'string' 21045 ? minpath.dirname(this.path) 21046 : undefined 21047 } 21048 21049 /** 21050 * Set the parent path (example: `'~'`). 21051 * 21052 * Cannot be set if thereâs no `path` yet. 21053 * 21054 * @param {string | undefined} dirname 21055 * Dirname. 21056 * @returns {undefined} 21057 * Nothing. 21058 */ 21059 set dirname(dirname) { 21060 lib_assertPath(this.basename, 'dirname') 21061 this.path = minpath.join(dirname || '', this.basename) 21062 } 21063 21064 /** 21065 * Get the extname (including dot) (example: `'.js'`). 21066 * 21067 * @returns {string | undefined} 21068 * Extname. 21069 */ 21070 get extname() { 21071 return typeof this.path === 'string' 21072 ? minpath.extname(this.path) 21073 : undefined 21074 } 21075 21076 /** 21077 * Set the extname (including dot) (example: `'.js'`). 21078 * 21079 * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'` 21080 * on windows). 21081 * Cannot be set if thereâs no `path` yet. 21082 * 21083 * @param {string | undefined} extname 21084 * Extname. 21085 * @returns {undefined} 21086 * Nothing. 21087 */ 21088 set extname(extname) { 21089 assertPart(extname, 'extname') 21090 lib_assertPath(this.dirname, 'extname') 21091 21092 if (extname) { 21093 if (extname.codePointAt(0) !== 46 /* `.` */) { 21094 throw new Error('`extname` must start with `.`') 21095 } 21096 21097 if (extname.includes('.', 1)) { 21098 throw new Error('`extname` cannot contain multiple dots') 21099 } 21100 } 21101 21102 this.path = minpath.join(this.dirname, this.stem + (extname || '')) 21103 } 21104 21105 /** 21106 * Get the full path (example: `'~/index.min.js'`). 21107 * 21108 * @returns {string} 21109 * Path. 21110 */ 21111 get path() { 21112 return this.history[this.history.length - 1] 21113 } 21114 21115 /** 21116 * Set the full path (example: `'~/index.min.js'`). 21117 * 21118 * Cannot be nullified. 21119 * You can set a file URL (a `URL` object with a `file:` protocol) which will 21120 * be turned into a path with `url.fileURLToPath`. 21121 * 21122 * @param {URL | string} path 21123 * Path. 21124 * @returns {undefined} 21125 * Nothing. 21126 */ 21127 set path(path) { 21128 if (isUrl(path)) { 21129 path = urlToPath(path) 21130 } 21131 21132 assertNonEmpty(path, 'path') 21133 21134 if (this.path !== path) { 21135 this.history.push(path) 21136 } 21137 } 21138 21139 /** 21140 * Get the stem (basename w/o extname) (example: `'index.min'`). 21141 * 21142 * @returns {string | undefined} 21143 * Stem. 21144 */ 21145 get stem() { 21146 return typeof this.path === 'string' 21147 ? minpath.basename(this.path, this.extname) 21148 : undefined 21149 } 21150 21151 /** 21152 * Set the stem (basename w/o extname) (example: `'index.min'`). 21153 * 21154 * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'` 21155 * on windows). 21156 * Cannot be nullified (use `file.path = file.dirname` instead). 21157 * 21158 * @param {string} stem 21159 * Stem. 21160 * @returns {undefined} 21161 * Nothing. 21162 */ 21163 set stem(stem) { 21164 assertNonEmpty(stem, 'stem') 21165 assertPart(stem, 'stem') 21166 this.path = minpath.join(this.dirname || '', stem + (this.extname || '')) 21167 } 21168 21169 // Normal prototypal methods. 21170 /** 21171 * Create a fatal message for `reason` associated with the file. 21172 * 21173 * The `fatal` field of the message is set to `true` (error; file not usable) 21174 * and the `file` field is set to the current file path. 21175 * The message is added to the `messages` field on `file`. 21176 * 21177 * > 𪦠**Note**: also has obsolete signatures. 21178 * 21179 * @overload 21180 * @param {string} reason 21181 * @param {MessageOptions | null | undefined} [options] 21182 * @returns {never} 21183 * 21184 * @overload 21185 * @param {string} reason 21186 * @param {Node | NodeLike | null | undefined} parent 21187 * @param {string | null | undefined} [origin] 21188 * @returns {never} 21189 * 21190 * @overload 21191 * @param {string} reason 21192 * @param {Point | Position | null | undefined} place 21193 * @param {string | null | undefined} [origin] 21194 * @returns {never} 21195 * 21196 * @overload 21197 * @param {string} reason 21198 * @param {string | null | undefined} [origin] 21199 * @returns {never} 21200 * 21201 * @overload 21202 * @param {Error | VFileMessage} cause 21203 * @param {Node | NodeLike | null | undefined} parent 21204 * @param {string | null | undefined} [origin] 21205 * @returns {never} 21206 * 21207 * @overload 21208 * @param {Error | VFileMessage} cause 21209 * @param {Point | Position | null | undefined} place 21210 * @param {string | null | undefined} [origin] 21211 * @returns {never} 21212 * 21213 * @overload 21214 * @param {Error | VFileMessage} cause 21215 * @param {string | null | undefined} [origin] 21216 * @returns {never} 21217 * 21218 * @param {Error | VFileMessage | string} causeOrReason 21219 * Reason for message, should use markdown. 21220 * @param {Node | NodeLike | MessageOptions | Point | Position | string | null | undefined} [optionsOrParentOrPlace] 21221 * Configuration (optional). 21222 * @param {string | null | undefined} [origin] 21223 * Place in code where the message originates (example: 21224 * `'my-package:my-rule'` or `'my-rule'`). 21225 * @returns {never} 21226 * Never. 21227 * @throws {VFileMessage} 21228 * Message. 21229 */ 21230 fail(causeOrReason, optionsOrParentOrPlace, origin) { 21231 // @ts-expect-error: the overloads are fine. 21232 const message = this.message(causeOrReason, optionsOrParentOrPlace, origin) 21233 21234 message.fatal = true 21235 21236 throw message 21237 } 21238 21239 /** 21240 * Create an info message for `reason` associated with the file. 21241 * 21242 * The `fatal` field of the message is set to `undefined` (info; change 21243 * likely not needed) and the `file` field is set to the current file path. 21244 * The message is added to the `messages` field on `file`. 21245 * 21246 * > 𪦠**Note**: also has obsolete signatures. 21247 * 21248 * @overload 21249 * @param {string} reason 21250 * @param {MessageOptions | null | undefined} [options] 21251 * @returns {VFileMessage} 21252 * 21253 * @overload 21254 * @param {string} reason 21255 * @param {Node | NodeLike | null | undefined} parent 21256 * @param {string | null | undefined} [origin] 21257 * @returns {VFileMessage} 21258 * 21259 * @overload 21260 * @param {string} reason 21261 * @param {Point | Position | null | undefined} place 21262 * @param {string | null | undefined} [origin] 21263 * @returns {VFileMessage} 21264 * 21265 * @overload 21266 * @param {string} reason 21267 * @param {string | null | undefined} [origin] 21268 * @returns {VFileMessage} 21269 * 21270 * @overload 21271 * @param {Error | VFileMessage} cause 21272 * @param {Node | NodeLike | null | undefined} parent 21273 * @param {string | null | undefined} [origin] 21274 * @returns {VFileMessage} 21275 * 21276 * @overload 21277 * @param {Error | VFileMessage} cause 21278 * @param {Point | Position | null | undefined} place 21279 * @param {string | null | undefined} [origin] 21280 * @returns {VFileMessage} 21281 * 21282 * @overload 21283 * @param {Error | VFileMessage} cause 21284 * @param {string | null | undefined} [origin] 21285 * @returns {VFileMessage} 21286 * 21287 * @param {Error | VFileMessage | string} causeOrReason 21288 * Reason for message, should use markdown. 21289 * @param {Node | NodeLike | MessageOptions | Point | Position | string | null | undefined} [optionsOrParentOrPlace] 21290 * Configuration (optional). 21291 * @param {string | null | undefined} [origin] 21292 * Place in code where the message originates (example: 21293 * `'my-package:my-rule'` or `'my-rule'`). 21294 * @returns {VFileMessage} 21295 * Message. 21296 */ 21297 info(causeOrReason, optionsOrParentOrPlace, origin) { 21298 // @ts-expect-error: the overloads are fine. 21299 const message = this.message(causeOrReason, optionsOrParentOrPlace, origin) 21300 21301 message.fatal = undefined 21302 21303 return message 21304 } 21305 21306 /** 21307 * Create a message for `reason` associated with the file. 21308 * 21309 * The `fatal` field of the message is set to `false` (warning; change may be 21310 * needed) and the `file` field is set to the current file path. 21311 * The message is added to the `messages` field on `file`. 21312 * 21313 * > 𪦠**Note**: also has obsolete signatures. 21314 * 21315 * @overload 21316 * @param {string} reason 21317 * @param {MessageOptions | null | undefined} [options] 21318 * @returns {VFileMessage} 21319 * 21320 * @overload 21321 * @param {string} reason 21322 * @param {Node | NodeLike | null | undefined} parent 21323 * @param {string | null | undefined} [origin] 21324 * @returns {VFileMessage} 21325 * 21326 * @overload 21327 * @param {string} reason 21328 * @param {Point | Position | null | undefined} place 21329 * @param {string | null | undefined} [origin] 21330 * @returns {VFileMessage} 21331 * 21332 * @overload 21333 * @param {string} reason 21334 * @param {string | null | undefined} [origin] 21335 * @returns {VFileMessage} 21336 * 21337 * @overload 21338 * @param {Error | VFileMessage} cause 21339 * @param {Node | NodeLike | null | undefined} parent 21340 * @param {string | null | undefined} [origin] 21341 * @returns {VFileMessage} 21342 * 21343 * @overload 21344 * @param {Error | VFileMessage} cause 21345 * @param {Point | Position | null | undefined} place 21346 * @param {string | null | undefined} [origin] 21347 * @returns {VFileMessage} 21348 * 21349 * @overload 21350 * @param {Error | VFileMessage} cause 21351 * @param {string | null | undefined} [origin] 21352 * @returns {VFileMessage} 21353 * 21354 * @param {Error | VFileMessage | string} causeOrReason 21355 * Reason for message, should use markdown. 21356 * @param {Node | NodeLike | MessageOptions | Point | Position | string | null | undefined} [optionsOrParentOrPlace] 21357 * Configuration (optional). 21358 * @param {string | null | undefined} [origin] 21359 * Place in code where the message originates (example: 21360 * `'my-package:my-rule'` or `'my-rule'`). 21361 * @returns {VFileMessage} 21362 * Message. 21363 */ 21364 message(causeOrReason, optionsOrParentOrPlace, origin) { 21365 const message = new VFileMessage( 21366 // @ts-expect-error: the overloads are fine. 21367 causeOrReason,
21368 optionsOrParentOrPlace, 21369 origin 21370 ) 21371 21372 if (this.path) { 21373 message.name = this.path + ':' + message.name 21374 message.file = this.path 21375 } 21376 21377 message.fatal = false 21378 21379 this.messages.push(message) 21380 21381 return message 21382 } 21383 21384 /** 21385 * Serialize the file. 21386 * 21387 * > **Note**: which encodings are supported depends on the engine. 21388 * > For info on Node.js, see: 21389 * > <https://nodejs.org/api/util.html#whatwg-supported-encodings>. 21390 * 21391 * @param {string | null | undefined} [encoding='utf8'] 21392 * Character encoding to understand `value` as when itâs a `Uint8Array` 21393 * (default: `'utf-8'`). 21394 * @returns {string} 21395 * Serialized file. 21396 */ 21397 toString(encoding) { 21398 if (this.value === undefined) { 21399 return '' 21400 } 21401 21402 if (typeof this.value === 'string') { 21403 return this.value 21404 } 21405 21406 const decoder = new TextDecoder(encoding || undefined) 21407 return decoder.decode(this.value) 21408 } 21409} 21410 21411/** 21412 * Assert that `part` is not a path (as in, does not contain `path.sep`). 21413 * 21414 * @param {string | null | undefined} part 21415 * File path part. 21416 * @param {string} name 21417 * Part name. 21418 * @returns {undefined} 21419 * Nothing. 21420 */ 21421function assertPart(part, name) { 21422 if (part && part.includes(minpath.sep)) { 21423 throw new Error( 21424 '`' + name + '` cannot be a path: did not expect `' + minpath.sep + '`' 21425 ) 21426 } 21427} 21428 21429/** 21430 * Assert that `part` is not empty. 21431 * 21432 * @param {string | undefined} part 21433 * Thing. 21434 * @param {string} name 21435 * Part name. 21436 * @returns {asserts part is string} 21437 * Nothing. 21438 */ 21439function assertNonEmpty(part, name) { 21440 if (!part) { 21441 throw new Error('`' + name + '` cannot be empty') 21442 } 21443} 21444 21445/** 21446 * Assert `path` exists. 21447 * 21448 * @param {string | undefined} path 21449 * Path. 21450 * @param {string} name 21451 * Dependency name. 21452 * @returns {asserts path is string} 21453 * Nothing. 21454 */ 21455function lib_assertPath(path, name) { 21456 if (!path) { 21457 throw new Error('Setting `' + name + '` requires `path` to be set too') 21458 } 21459} 21460 21461/** 21462 * Assert `value` is an `Uint8Array`. 21463 * 21464 * @param {unknown} value 21465 * thing. 21466 * @returns {value is Uint8Array} 21467 * Whether `value` is an `Uint8Array`. 21468 */ 21469function isUint8Array(value) { 21470 return Boolean( 21471 value && 21472 typeof value === 'object' && 21473 'byteLength' in value && 21474 'byteOffset' in value 21475 ) 21476} 21477 21478;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/vfile/index.js 21479// More types exposed from `index.d.ts`. 21480 21481 21482;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/unified/lib/callable-instance.js 21483const CallableInstance = 21484 /** 21485 * @type {new <Parameters extends Array<unknown>, Result>(property: string | symbol) => (...parameters: Parameters) => Result} 21486 */ 21487 ( 21488 /** @type {unknown} */ 21489 ( 21490 /** 21491 * @this {Function} 21492 * @param {string | symbol} property 21493 * @returns {(...parameters: Array<unknown>) => unknown} 21494 */ 21495 function (property) { 21496 const self = this 21497 const constr = self.constructor 21498 const proto = /** @type {Record<string | symbol, Function>} */ ( 21499 // Prototypes do exist. 21500 // type-coverage:ignore-next-line 21501 constr.prototype 21502 ) 21503 const value = proto[property] 21504 /** @type {(...parameters: Array<unknown>) => unknown} */ 21505 const apply = function () { 21506 return value.apply(apply, arguments) 21507 } 21508 21509 Object.setPrototypeOf(apply, proto) 21510 21511 // Not needed for us in `unified`: we only call this on the `copy` 21512 // function, 21513 // and we don't need to add its fields (`length`, `name`) 21514 // over. 21515 // See also: GH-246. 21516 // const names = Object.getOwnPropertyNames(value) 21517 // 21518 // for (const p of names) { 21519 // const descriptor = Object.getOwnPropertyDescriptor(value, p) 21520 // if (descriptor) Object.defineProperty(apply, p, descriptor) 21521 // } 21522 21523 return apply 21524 } 21525 ) 21526 ) 21527 21528;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/unified/lib/index.js 21529/** 21530 * @typedef {import('trough').Pipeline} Pipeline 21531 * 21532 * @typedef {import('unist').Node} Node 21533 * 21534 * @typedef {import('vfile').Compatible} Compatible 21535 * @typedef {import('vfile').Value} Value 21536 * 21537 * @typedef {import('../index.js').CompileResultMap} CompileResultMap 21538 * @typedef {import('../index.js').Data} Data 21539 * @typedef {import('../index.js').Settings} Settings 21540 */ 21541
21542/** 21543 * @typedef {CompileResultMap[keyof CompileResultMap]} CompileResults 21544 * Acceptable results from compilers. 21545 * 21546 * To register custom results, add them to 21547 * {@linkcode CompileResultMap}. 21548 */ 21549 21550/** 21551 * @template {Node} [Tree=Node] 21552 * The node that the compiler receives (default: `Node`). 21553 * @template {CompileResults} [Result=CompileResults] 21554 * The thing that the compiler yields (default: `CompileResults`). 21555 * @callback Compiler 21556 * A **compiler** handles the compiling of a syntax tree to something else 21557 * (in most cases, text) (TypeScript type). 21558 * 21559 * It is used in the stringify phase and called with a {@linkcode Node} 21560 * and {@linkcode VFile} representation of the document to compile. 21561 * It should return the textual representation of the given tree (typically 21562 * `string`). 21563 * 21564 * > **Note**: unified typically compiles by serializing: most compilers 21565 * > return `string` (or `Uint8Array`). 21566 * > Some compilers, such as the one configured with 21567 * > [`rehype-react`][rehype-react], return other values (in this case, a 21568 * > React tree). 21569 * > If youâre using a compiler that doesnât serialize, expect different 21570 * > result values. 21571 * > 21572 * > To register custom results in TypeScript, add them to 21573 * > {@linkcode CompileResultMap}. 21574 * 21575 * [rehype-react]: https://github.com/rehypejs/rehype-react 21576 * @param {Tree} tree 21577 * Tree to compile. 21578 * @param {VFile} file 21579 * File associated with `tree`. 21580 * @returns {Result} 21581 * New content: compiled text (`string` or `Uint8Array`, for `file.value`) or 21582 * something else (for `file.result`). 21583 */ 21584 21585/** 21586 * @template {Node} [Tree=Node] 21587 * The node that the parser yields (default: `Node`) 21588 * @callback Parser 21589 * A **parser** handles the parsing of text to a syntax tree. 21590 * 21591 * It is used in the parse phase and is called with a `string` and 21592 * {@linkcode VFile} of the document to parse. 21593 * It must return the syntax tree representation of the given file 21594 * ({@linkcode Node}). 21595 * @param {string} document 21596 * Document to parse. 21597 * @param {VFile} file 21598 * File associated with `document`. 21599 * @returns {Tree} 21600 * Node representing the given file. 21601 */ 21602 21603/** 21604 * @typedef {( 21605 * Plugin<Array<any>, any, any> | 21606 * PluginTuple<Array<any>, any, any> | 21607 * Preset 21608 * )} Pluggable 21609 * Union of the different ways to add plugins and settings. 21610 */ 21611 21612/** 21613 * @typedef {Array<Pluggable>} PluggableList 21614 * List of plugins and presets. 21615 */ 21616 21617// Note: we canât use `callback` yet as it messes up `this`: 21618// <https://github.com/microsoft/TypeScript/issues/55197>. 21619/** 21620 * @template {Array<unknown>} [PluginParameters=[]] 21621 * Arguments passed to the plugin (default: `[]`, the empty tuple). 21622 * @template {Node | string | undefined} [Input=Node] 21623 * Value that is expected as input (default: `Node`). 21624 * 21625 * * If the plugin returns a {@linkcode Transformer}, this 21626 * should be the node it expects. 21627 * * If the plugin sets a {@linkcode Parser}, this should be 21628 * `string`. 21629 * * If the plugin sets a {@linkcode Compiler}, this should be the 21630 * node it expects. 21631 * @template [Output=Input] 21632 * Value that is yielded as output (default: `Input`). 21633 * 21634 * * If the plugin returns a {@linkcode Transformer}, this 21635 * should be the node that that yields. 21636 * * If the plugin sets a {@linkcode Parser}, this should be the 21637 * node that it yields. 21638 * * If the plugin sets a {@linkcode Compiler}, this should be 21639 * result it yields. 21640 * @typedef {( 21641 * (this: Processor, ...parameters: PluginParameters) => 21642 * Input extends string ? // Parser. 21643 * Output extends Node | undefined ? undefined | void : never : 21644 * Output extends CompileResults ? // Compiler. 21645 * Input extends Node | undefined ? undefined | void : never : 21646 * Transformer< 21647 * Input extends Node ? Input : Node, 21648 * Output extends Node ? Output : Node 21649 * > | undefined | void 21650 * )} Plugin 21651 * Single plugin. 21652 * 21653 * Plugins configure the processors they are applied on in the following 21654 * ways: 21655 * 21656 * * they change the processor, such as the parser, the compiler, or by 21657 * configuring data 21658 * * they specify how to handle trees and files 21659 * 21660 * In practice, they are functions that can receive options and configure the 21661 * processor (`this`). 21662 * 21663 * > **Note**: plugins are called when the processor is *frozen*, not when 21664 * > they are applied. 21665 */ 21666 21667/** 21668 * Tuple of a plugin and its configuration. 21669 * 21670 * The first item is a plugin, the rest are its parameters. 21671 * 21672 * @template {Array<unknown>} [TupleParameters=[]] 21673 * Arguments passed to the plugin (default: `[]`, the empty tuple).
21674 * @template {Node | string | undefined} [Input=undefined] 21675 * Value that is expected as input (optional). 21676 * 21677 * * If the plugin returns a {@linkcode Transformer}, this 21678 * should be the node it expects. 21679 * * If the plugin sets a {@linkcode Parser}, this should be 21680 * `string`. 21681 * * If the plugin sets a {@linkcode Compiler}, this should be the 21682 * node it expects. 21683 * @template [Output=undefined] (optional). 21684 * Value that is yielded as output. 21685 * 21686 * * If the plugin returns a {@linkcode Transformer}, this 21687 * should be the node that that yields. 21688 * * If the plugin sets a {@linkcode Parser}, this should be the 21689 * node that it yields. 21690 * * If the plugin sets a {@linkcode Compiler}, this should be 21691 * result it yields. 21692 * @typedef {( 21693 * [ 21694 * plugin: Plugin<TupleParameters, Input, Output>, 21695 * ...parameters: TupleParameters 21696 * ] 21697 * )} PluginTuple 21698 */ 21699 21700/** 21701 * @typedef Preset 21702 * Sharable configuration. 21703 * 21704 * They can contain plugins and settings. 21705 * @property {PluggableList | undefined} [plugins] 21706 * List of plugins and presets (optional). 21707 * @property {Settings | undefined} [settings] 21708 * Shared settings for parsers and compilers (optional). 21709 */ 21710 21711/** 21712 * @template {VFile} [File=VFile] 21713 * The file that the callback receives (default: `VFile`). 21714 * @callback ProcessCallback 21715 * Callback called when the process is done. 21716 * 21717 * Called with either an error or a result. 21718 * @param {Error | undefined} [error] 21719 * Fatal error (optional). 21720 * @param {File | undefined} [file] 21721 * Processed file (optional). 21722 * @returns {undefined} 21723 * Nothing. 21724 */ 21725 21726/** 21727 * @template {Node} [Tree=Node] 21728 * The tree that the callback receives (default: `Node`). 21729 * @callback RunCallback 21730 * Callback called when transformers are done. 21731 * 21732 * Called with either an error or results. 21733 * @param {Error | undefined} [error] 21734 * Fatal error (optional). 21735 * @param {Tree | undefined} [tree] 21736 * Transformed tree (optional). 21737 * @param {VFile | undefined} [file] 21738 * File (optional). 21739 * @returns {undefined} 21740 * Nothing. 21741 */ 21742 21743/** 21744 * @template {Node} [Output=Node] 21745 * Node type that the transformer yields (default: `Node`). 21746 * @callback TransformCallback 21747 * Callback passed to transforms. 21748 * 21749 * If the signature of a `transformer` accepts a third argument, the 21750 * transformer may perform asynchronous operations, and must call it. 21751 * @param {Error | undefined} [error] 21752 * Fatal error to stop the process (optional). 21753 * @param {Output | undefined} [tree] 21754 * New, changed, tree (optional). 21755 * @param {VFile | undefined} [file] 21756 * New, changed, file (optional). 21757 * @returns {undefined} 21758 * Nothing. 21759 */ 21760 21761/** 21762 * @template {Node} [Input=Node] 21763 * Node type that the transformer expects (default: `Node`). 21764 * @template {Node} [Output=Input] 21765 * Node type that the transformer yields (default: `Input`). 21766 * @callback Transformer 21767 * Transformers handle syntax trees and files. 21768 * 21769 * They are functions that are called each time a syntax tree and file are 21770 * passed through the run phase. 21771 * When an error occurs in them (either because itâs thrown, returned, 21772 * rejected, or passed to `next`), the process stops. 21773 * 21774 * The run phase is handled by [`trough`][trough], see its documentation for 21775 * the exact semantics of these functions. 21776 * 21777 * > **Note**: you should likely ignore `next`: donât accept it. 21778 * > it supports callback-style async work. 21779 * > But promises are likely easier to reason about. 21780 * 21781 * [trough]: https://github.com/wooorm/trough#function-fninput-next 21782 * @param {Input} tree 21783 * Tree to handle. 21784 * @param {VFile} file 21785 * File to handle. 21786 * @param {TransformCallback<Output>} next 21787 * Callback. 21788 * @returns {( 21789 * Promise<Output | undefined | void> | 21790 * Promise<never> | // For some reason this is needed separately. 21791 * Output | 21792 * Error | 21793 * undefined | 21794 * void 21795 * )} 21796 * If you accept `next`, nothing. 21797 * Otherwise: 21798 * 21799 * * `Error` â fatal error to stop the process 21800 * * `Promise<undefined>` or `undefined` â the next transformer keeps using 21801 * same tree 21802 * * `Promise<Node>` or `Node` â new, changed, tree 21803 */ 21804 21805/** 21806 * @template {Node | undefined} ParseTree 21807 * Output of `parse`. 21808 * @template {Node | undefined} HeadTree 21809 * Input for `run`. 21810 * @template {Node | undefined} TailTree 21811 * Output for `run`. 21812 * @template {Node | undefined} CompileTree 21813 * Input of `stringify`. 21814 * @template {CompileResults | undefined} CompileResult 21815 * Output of `stringify`.
21816 * @template {Node | string | undefined} Input 21817 * Input of plugin. 21818 * @template Output 21819 * Output of plugin (optional). 21820 * @typedef {( 21821 * Input extends string 21822 * ? Output extends Node | undefined 21823 * ? // Parser. 21824 * Processor< 21825 * Output extends undefined ? ParseTree : Output, 21826 * HeadTree, 21827 * TailTree, 21828 * CompileTree, 21829 * CompileResult 21830 * > 21831 * : // Unknown. 21832 * Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult> 21833 * : Output extends CompileResults 21834 * ? Input extends Node | undefined 21835 * ? // Compiler. 21836 * Processor< 21837 * ParseTree, 21838 * HeadTree, 21839 * TailTree, 21840 * Input extends undefined ? CompileTree : Input, 21841 * Output extends undefined ? CompileResult : Output 21842 * > 21843 * : // Unknown. 21844 * Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult> 21845 * : Input extends Node | undefined 21846 * ? Output extends Node | undefined 21847 * ? // Transform. 21848 * Processor< 21849 * ParseTree, 21850 * HeadTree extends undefined ? Input : HeadTree, 21851 * Output extends undefined ? TailTree : Output, 21852 * CompileTree, 21853 * CompileResult 21854 * > 21855 * : // Unknown. 21856 * Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult> 21857 * : // Unknown. 21858 * Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult> 21859 * )} UsePlugin 21860 * Create a processor based on the input/output of a {@link Plugin plugin}. 21861 */ 21862 21863/** 21864 * @template {CompileResults | undefined} Result 21865 * Node type that the transformer yields. 21866 * @typedef {( 21867 * Result extends Value | undefined ? 21868 * VFile : 21869 * VFile & {result: Result} 21870 * )} VFileWithOutput 21871 * Type to generate a {@linkcode VFile} corresponding to a compiler result. 21872 * 21873 * If a result that is not acceptable on a `VFile` is used, that will 21874 * be stored on the `result` field of {@linkcode VFile}. 21875 */ 21876 21877 21878 21879 21880 21881 21882 21883 21884 21885// To do: next major: drop `Compiler`, `Parser`: prefer lowercase. 21886
21887// To do: we could start yielding `never` in TS when a parser is missing and 21888// `parse` is called. 21889// Currently, we allow directly setting `processor.parser`, which is untyped. 21890 21891const unified_lib_own = {}.hasOwnProperty 21892 21893/** 21894 * @template {Node | undefined} [ParseTree=undefined] 21895 * Output of `parse` (optional). 21896 * @template {Node | undefined} [HeadTree=undefined] 21897 * Input for `run` (optional). 21898 * @template {Node | undefined} [TailTree=undefined] 21899 * Output for `run` (optional). 21900 * @template {Node | undefined} [CompileTree=undefined] 21901 * Input of `stringify` (optional). 21902 * @template {CompileResults | undefined} [CompileResult=undefined] 21903 * Output of `stringify` (optional). 21904 * @extends {CallableInstance<[], Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>>} 21905 */ 21906class Processor extends CallableInstance { 21907 /** 21908 * Create a processor. 21909 */ 21910 constructor() { 21911 // If `Processor()` is called (w/o new), `copy` is called instead. 21912 super('copy') 21913 21914 /** 21915 * Compiler to use (deprecated). 21916 * 21917 * @deprecated 21918 * Use `compiler` instead. 21919 * @type {( 21920 * Compiler< 21921 * CompileTree extends undefined ? Node : CompileTree, 21922 * CompileResult extends undefined ? CompileResults : CompileResult 21923 * > | 21924 * undefined 21925 * )} 21926 */ 21927 this.Compiler = undefined 21928 21929 /** 21930 * Parser to use (deprecated). 21931 * 21932 * @deprecated 21933 * Use `parser` instead. 21934 * @type {( 21935 * Parser<ParseTree extends undefined ? Node : ParseTree> | 21936 * undefined 21937 * )} 21938 */ 21939 this.Parser = undefined 21940 21941 // Note: the following fields are considered private. 21942 // However, they are needed for tests, and TSC generates an untyped 21943 // `private freezeIndex` field for, which trips `type-coverage` up. 21944 // Instead, we use `@deprecated` to visualize that they shouldnât be used. 21945 /** 21946 * Internal list of configured plugins. 21947 * 21948 * @deprecated 21949 * This is a private internal property and should not be used. 21950 * @type {Array<PluginTuple<Array<unknown>>>} 21951 */ 21952 this.attachers = [] 21953 21954 /** 21955 * Compiler to use. 21956 * 21957 * @type {( 21958 * Compiler< 21959 * CompileTree extends undefined ? Node : CompileTree, 21960 * CompileResult extends undefined ? CompileResults : CompileResult 21961 * > | 21962 * undefined 21963 * )} 21964 */ 21965 this.compiler = undefined 21966 21967 /** 21968 * Internal state to track where we are while freezing. 21969 * 21970 * @deprecated 21971 * This is a private internal property and should not be used. 21972 * @type {number} 21973 */ 21974 this.freezeIndex = -1 21975 21976 /** 21977 * Internal state to track whether weâre frozen. 21978 * 21979 * @deprecated 21980 * This is a private internal property and should not be used. 21981 * @type {boolean | undefined} 21982 */ 21983 this.frozen = undefined 21984 21985 /** 21986 * Internal state. 21987 * 21988 * @deprecated 21989 * This is a private internal property and should not be used. 21990 * @type {Data} 21991 */ 21992 this.namespace = {} 21993 21994 /** 21995 * Parser to use. 21996 * 21997 * @type {( 21998 * Parser<ParseTree extends undefined ? Node : ParseTree> | 21999 * undefined 22000 * )} 22001 */ 22002 this.parser = undefined 22003 22004 /** 22005 * Internal list of configured transformers. 22006 * 22007 * @deprecated 22008 * This is a private internal property and should not be used. 22009 * @type {Pipeline} 22010 */ 22011 this.transformers = trough() 22012 } 22013 22014 /** 22015 * Copy a processor. 22016 * 22017 * @deprecated 22018 * This is a private internal method and should not be used. 22019 * @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} 22020 * New *unfrozen* processor ({@linkcode Processor}) that is 22021 * configured to work the same as its ancestor. 22022 * When the descendant processor is configured in the future it does not 22023 * affect the ancestral processor. 22024 */ 22025 copy() { 22026 // Cast as the type parameters will be the same after attaching. 22027 const destination = 22028 /** @type {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} */ ( 22029 new Processor() 22030 ) 22031 let index = -1 22032 22033 while (++index < this.attachers.length) { 22034 const attacher = this.attachers[index] 22035 destination.use(...attacher) 22036 } 22037 22038 destination.data(extend(true, {}, this.namespace)) 22039 22040 return destination 22041 } 22042 22043 /** 22044 * Configure the processor with info available to all plugins. 22045 * Information is stored in an object. 22046 * 22047 * Typically, options can be given to a specific plugin, but sometimes it 22048 * makes sense to have information shared with several plugins. 22049 * For example, a list of HTML elements that are self-closing, which is 22050 * needed during all phases. 22051 * 22052 * > **Note**: setting information cannot occur on *frozen* processors. 22053 * > Call the processor first to create a new unfrozen processor. 22054 * 22055 * > **Note**: to register custom data in TypeScript, augment the 22056 * > {@linkcode Data} interface. 22057 * 22058 * @example 22059 * This example show how to get and set info: 22060 * 22061 * ```js 22062 * import {unified} from 'unified' 22063 * 22064 * const processor = unified().data('alpha', 'bravo') 22065 * 22066 * processor.data('alpha') // => 'bravo' 22067 * 22068 * processor.data() // => {alpha: 'bravo'} 22069 * 22070 * processor.data({charlie: 'delta'}) 22071 * 22072 * processor.data() // => {charlie: 'delta'} 22073 * ``` 22074 * 22075 * @template {keyof Data} Key 22076 * 22077 * @overload 22078 * @returns {Data} 22079 * 22080 * @overload 22081 * @param {Data} dataset 22082 * @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} 22083 * 22084 * @overload 22085 * @param {Key}
22085 key 22086 * @returns {Data[Key]} 22087 * 22088 * @overload 22089 * @param {Key} key 22090 * @param {Data[Key]} value 22091 * @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} 22092 * 22093 * @param {Data | Key} [key] 22094 * Key to get or set, or entire dataset to set, or nothing to get the 22095 * entire dataset (optional). 22096 * @param {Data[Key]} [value] 22097 * Value to set (optional). 22098 * @returns {unknown} 22099 * The current processor when setting, the value at `key` when getting, or 22100 * the entire dataset when getting without key. 22101 */ 22102 data(key, value) { 22103 if (typeof key === 'string') { 22104 // Set `key`. 22105 if (arguments.length === 2) { 22106 assertUnfrozen('data', this.frozen) 22107 this.namespace[key] = value 22108 return this 22109 } 22110 22111 // Get `key`. 22112 return (unified_lib_own.call(this.namespace, key) && this.namespace[key]) || undefined 22113 } 22114 22115 // Set space. 22116 if (key) { 22117 assertUnfrozen('data', this.frozen) 22118 this.namespace = key 22119 return this 22120 } 22121 22122 // Get space. 22123 return this.namespace 22124 } 22125 22126 /** 22127 * Freeze a processor. 22128 * 22129 * Frozen processors are meant to be extended and not to be configured 22130 * directly. 22131 * 22132 * When a processor is frozen it cannot be unfrozen. 22133 * New processors working the same way can be created by calling the 22134 * processor. 22135 * 22136 * Itâs possible to freeze processors explicitly by calling `.freeze()`. 22137 * Processors freeze automatically when `.parse()`, `.run()`, `.runSync()`, 22138 * `.stringify()`, `.process()`, or `.processSync()` are called. 22139 * 22140 * @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} 22141 * The current processor. 22142 */ 22143 freeze() { 22144 if (this.frozen) { 22145 return this 22146 } 22147 22148 // Cast so that we can type plugins easier. 22149 // Plugins are supposed to be usable on different processors, not just on 22150 // this exact processor. 22151 const self = /** @type {Processor} */ (/** @type {unknown} */ (this)) 22152 22153 while (++this.freezeIndex < this.attachers.length) { 22154 const [attacher, ...options] = this.attachers[this.freezeIndex] 22155 22156 if (options[0] === false) { 22157 continue 22158 } 22159 22160 if (options[0] === true) { 22161 options[0] = undefined 22162 } 22163 22164 const transformer = attacher.call(self, ...options) 22165 22166 if (typeof transformer === 'function') { 22167 this.transformers.use(transformer) 22168 } 22169 } 22170 22171 this.frozen = true 22172 this.freezeIndex = Number.POSITIVE_INFINITY 22173 22174 return this 22175 } 22176 22177 /** 22178 * Parse text to a syntax tree. 22179 * 22180 * > **Note**: `parse` freezes the processor if not already *frozen*. 22181 * 22182 * > **Note**: `parse` performs the parse phase, not the run phase or other 22183 * > phases. 22184 * 22185 * @param {Compatible | undefined} [file] 22186 * file to parse (optional); typically `string` or `VFile`; any value 22187 * accepted as `x` in `new VFile(x)`. 22188 * @returns {ParseTree extends undefined ? Node : ParseTree} 22189 * Syntax tree representing `file`. 22190 */ 22191 parse(file) { 22192 this.freeze() 22193 const realFile = vfile(file) 22194 const parser = this.parser || this.Parser 22195 assertParser('parse', parser) 22196 return parser(String(realFile), realFile) 22197 } 22198 22199 /** 22200 * Process the given file as configured on the processor. 22201 * 22202 * > **Note**: `process` freezes the processor if not already *frozen*. 22203 * 22204 * > **Note**: `process` performs the parse, run, and stringify phases. 22205 * 22206 * @overload 22207 * @param {Compatible | undefined} file 22208 * @param {ProcessCallback<VFileWithOutput<CompileResult>>} done 22209 * @returns {undefined} 22210 * 22211 * @overload 22212 * @param {Compatible | undefined} [file] 22213 * @returns {Promise<VFileWithOutput<CompileResult>>} 22214 * 22215 * @param {Compatible | undefined} [file] 22216 * File (optional); typically `string` or `VFile`]; any value accepted as 22217 * `x` in `new VFile(x)`. 22218 * @param {ProcessCallback<VFileWithOutput<CompileResult>> | undefined} [done] 22219 * Callback (optional). 22220 * @returns {Promise<VFile> | undefined} 22221 * Nothing if `done` is given. 22222 * Otherwise a promise, rejected with a fatal error or resolved with the 22223 * processed file. 22224 * 22225 * The parsed, transformed, and compiled value is available at 22226 * `file.value` (see note). 22227 * 22228 * > **Note**: unified typically compiles by serializing: most 22229 * > compilers return `string` (or `Uint8Array`). 22230 * > Some compilers, such as the one configured with 22231 * > [`rehype-react`][rehype-react], return other values (in this case, a 22232 * > React tree). 22233 * > If youâre using a compiler that doesnât serialize, expect different 22234 * > result values. 22235 * > 22236 * > To register custom results in TypeScript, add them to 22237 * > {@linkcode CompileResultMap}. 22238 * 22239 * [rehype-react]: https://github.com/rehypejs/rehype-react 22240 */ 22241 process(file, done) { 22242 const self = this 22243 22244 this.freeze() 22245 assertParser('process', this.parser || this.Parser) 22246 assertCompiler('process', this.compiler || this.Compiler) 22247 22248 return done ? executor(undefined, done) : new Promise(executor) 22249 22250 // Note: `void`s needed for TS. 22251 /** 22252 * @param {((file: VFileWithOutput<CompileResult>) => undefined | void) | undefined} resolve 22253 * @param {(error: Error | undefined) => undefined | void} reject 22254 * @returns {undefined} 22255 */ 22256 function executor(resolve, reject) { 22257 const realFile = vfile(file) 22258 // Assume `ParseTree` (the result of the parser) matches `HeadTree` (the 22259 // input of the first transform). 22260 const parseTree = 22261 /** @type {HeadTree extends undefined ? Node : HeadTree} */ ( 22262 /** @type {unknown} */ (self.parse(realFile)) 22263 ) 22264 22265 self.run(parseTree, realFile, function (error, tree, file) { 22266 if (error || !tree || !file) { 22267 return realDone(error) 22268 } 22269 22270 // Assume `TailTree` (the output of the last transform) matches 22271 // `CompileTree` (the input of the compiler). 22272 const compileTree = 22273 /** @type {CompileTree extends undefined ? Node : CompileTree} */ ( 22274 /** @type {unknown} */ (tree) 22275 ) 22276 22277 const compileResult = self.stringify(compileTree, file) 22278 22279 if (looksLikeAValue(compileResult)) { 22280 file.value = compileResult 22281 } else { 22282 file.result = compileResult 22283 } 22284 22285 realDone(error, /** @type {VFileWithOutput<CompileResult>} */ (file)) 22286 }) 22287 22288 /** 22289 * @param {Error | undefined} error 22290 * @param {VFileWithOutput<CompileResult> | undefined} [file] 22291 * @returns {undefined} 22292 */ 22293 function realDone(error, file) { 22294 if (error || !file) { 22295 reject(error) 22296 } else if (resolve) { 22297 resolve(file) 22298 } else { 22299 ok(done, '`done` is defined if `resolve` is not') 22300 done(undefined, file) 22301 } 22302 } 22303 } 22304 } 22305 22306 /** 22307 * Process the given file as configured on the processor. 22308 * 22309 * An error is thrown if asynchronous transforms are configured. 22310 * 22311 * > **Note**: `processSync` freezes the processor if not already *frozen*. 22312 * 22313 * > **Note**: `processSync` performs the parse, run, and stringify phases. 22314 * 22315 * @param {Compatible | undefined} [file] 22316 * File (optional); typically `string` or `VFile`; any value accepted as 22317 * `x` in `new VFile(x)`. 22318 * @returns {VFileWithOutput<CompileResult>} 22319 * The processed file. 22320 * 22321 * The parsed, transformed, and compiled value is available at 22322 * `file.value` (see note). 22323 * 22324 * > **Note**: unified typically compiles by serializing: most 22325 * > compilers return `string` (or `Uint8Array`). 22326 * > Some compilers, such as the one configured with 22327 * > [`rehype-react`][rehype-react], return other values (in this case, a 22328 * > React tree). 22329 * > If youâre using a compiler that doesnât serialize, expect different 22330 * > result values. 22331 * > 22332 * > To register custom results in TypeScript, add them to 22333 * > {@linkcode CompileResultMap}. 22334 * 22335 * [rehype-react]: https://github.com/rehypejs/rehype-react 22336 */ 22337 processSync(file) { 22338 /** @type {boolean} */
22339 let complete = false 22340 /** @type {VFileWithOutput<CompileResult> | undefined} */ 22341 let result 22342 22343 this.freeze() 22344 assertParser('processSync', this.parser || this.Parser) 22345 assertCompiler('processSync', this.compiler || this.Compiler) 22346 22347 this.process(file, realDone) 22348 assertDone('processSync', 'process', complete) 22349 ok(result, 'we either bailed on an error or have a tree') 22350 22351 return result 22352 22353 /** 22354 * @type {ProcessCallback<VFileWithOutput<CompileResult>>} 22355 */ 22356 function realDone(error, file) { 22357 complete = true 22358 bail(error) 22359 result = file 22360 } 22361 } 22362 22363 /** 22364 * Run *transformers* on a syntax tree. 22365 * 22366 * > **Note**: `run` freezes the processor if not already *frozen*. 22367 * 22368 * > **Note**: `run` performs the run phase, not other phases. 22369 * 22370 * @overload 22371 * @param {HeadTree extends undefined ? Node : HeadTree} tree 22372 * @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done 22373 * @returns {undefined} 22374 * 22375 * @overload 22376 * @param {HeadTree extends undefined ? Node : HeadTree} tree 22377 * @param {Compatible | undefined} file 22378 * @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done 22379 * @returns {undefined} 22380 * 22381 * @overload 22382 * @param {HeadTree extends undefined ? Node : HeadTree} tree 22383 * @param {Compatible | undefined} [file] 22384 * @returns {Promise<TailTree extends undefined ? Node : TailTree>} 22385 * 22386 * @param {HeadTree extends undefined ? Node : HeadTree} tree 22387 * Tree to transform and inspect. 22388 * @param {( 22389 * RunCallback<TailTree extends undefined ? Node : TailTree> | 22390 * Compatible 22391 * )} [file] 22392 * File associated with `node` (optional); any value accepted as `x` in 22393 * `new VFile(x)`. 22394 * @param {RunCallback<TailTree extends undefined ? Node : TailTree>} [done] 22395 * Callback (optional). 22396 * @returns {Promise<TailTree extends undefined ? Node : TailTree> | undefined} 22397 * Nothing if `done` is given. 22398 * Otherwise, a promise rejected with a fatal error or resolved with the 22399 * transformed tree. 22400 */ 22401 run(tree, file, done) { 22402 assertNode(tree) 22403 this.freeze() 22404 22405 const transformers = this.transformers 22406 22407 if (!done && typeof file === 'function') { 22408 done = file 22409 file = undefined 22410 } 22411 22412 return done ? executor(undefined, done) : new Promise(executor) 22413 22414 // Note: `void`s needed for TS. 22415 /** 22416 * @param {( 22417 * ((tree: TailTree extends undefined ? Node : TailTree) => undefined | void) | 22418 * undefined 22419 * )} resolve 22420 * @param {(error: Error) => undefined | void} reject 22421 * @returns {undefined} 22422 */ 22423 function executor(resolve, reject) { 22424 ok( 22425 typeof file !== 'function', 22426 '`file` canât be a `done` anymore, we checked' 22427 ) 22428 const realFile = vfile(file) 22429 transformers.run(tree, realFile, realDone) 22430 22431 /** 22432 * @param {Error | undefined} error 22433 * @param {Node} outputTree 22434 * @param {VFile} file 22435 * @returns {undefined} 22436 */ 22437 function realDone(error, outputTree, file) { 22438 const resultingTree = 22439 /** @type {TailTree extends undefined ? Node : TailTree} */ ( 22440 outputTree || tree 22441 ) 22442 22443 if (error) { 22444 reject(error) 22445 } else if (resolve) { 22446 resolve(resultingTree) 22447 } else { 22448 ok(done, '`done` is defined if `resolve` is not') 22449 done(undefined, resultingTree, file) 22450 } 22451 } 22452 } 22453 } 22454 22455 /** 22456 * Run *transformers* on a syntax tree. 22457 * 22458 * An error is thrown if asynchronous transforms are configured. 22459 * 22460 * > **Note**: `runSync` freezes the processor if not already *frozen*. 22461 * 22462 * > **Note**: `runSync` performs the run phase, not other phases. 22463 * 22464 * @param {HeadTree extends undefined ? Node : HeadTree} tree 22465 * Tree to transform and inspect. 22466 * @param {Compatible | undefined} [file] 22467 * File associated with `node` (optional); any value accepted as `x` in 22468 * `new VFile(x)`. 22469 * @returns {TailTree extends undefined ? Node : TailTree} 22470 * Transformed tree. 22471 */ 22472 runSync(tree, file) { 22473 /** @type {boolean} */
22474 let complete = false 22475 /** @type {(TailTree extends undefined ? Node : TailTree) | undefined} */ 22476 let result 22477 22478 this.run(tree, file, realDone) 22479 22480 assertDone('runSync', 'run', complete) 22481 ok(result, 'we either bailed on an error or have a tree') 22482 return result 22483 22484 /** 22485 * @type {RunCallback<TailTree extends undefined ? Node : TailTree>} 22486 */ 22487 function realDone(error, tree) { 22488 bail(error) 22489 result = tree 22490 complete = true 22491 } 22492 } 22493 22494 /** 22495 * Compile a syntax tree. 22496 * 22497 * > **Note**: `stringify` freezes the processor if not already *frozen*. 22498 * 22499 * > **Note**: `stringify` performs the stringify phase, not the run phase 22500 * > or other phases. 22501 * 22502 * @param {CompileTree extends undefined ? Node : CompileTree} tree 22503 * Tree to compile. 22504 * @param {Compatible | undefined} [file] 22505 * File associated with `node` (optional); any value accepted as `x` in 22506 * `new VFile(x)`. 22507 * @returns {CompileResult extends undefined ? Value : CompileResult} 22508 * Textual representation of the tree (see note). 22509 * 22510 * > **Note**: unified typically compiles by serializing: most compilers 22511 * > return `string` (or `Uint8Array`). 22512 * > Some compilers, such as the one configured with 22513 * > [`rehype-react`][rehype-react], return other values (in this case, a 22514 * > React tree). 22515 * > If youâre using a compiler that doesnât serialize, expect different 22516 * > result values. 22517 * > 22518 * > To register custom results in TypeScript, add them to 22519 * > {@linkcode CompileResultMap}. 22520 * 22521 * [rehype-react]: https://github.com/rehypejs/rehype-react 22522 */ 22523 stringify(tree, file) { 22524 this.freeze() 22525 const realFile = vfile(file) 22526 const compiler = this.compiler || this.Compiler 22527 assertCompiler('stringify', compiler) 22528 assertNode(tree) 22529 22530 return compiler(tree, realFile) 22531 } 22532 22533 /** 22534 * Configure the processor to use a plugin, a list of usable values, or a 22535 * preset. 22536 * 22537 * If the processor is already using a plugin, the previous plugin 22538 * configuration is changed based on the options that are passed in. 22539 * In other words, the plugin is not added a second time. 22540 * 22541 * > **Note**: `use` cannot be called on *frozen* processors. 22542 * > Call the processor first to create a new unfrozen processor. 22543 * 22544 * @example 22545 * There are many ways to pass plugins to `.use()`. 22546 * This example gives an overview: 22547 * 22548 * ```js 22549 * import {unified} from 'unified' 22550 * 22551 * unified() 22552 * // Plugin with options: 22553 * .use(pluginA, {x: true, y: true}) 22554 * // Passing the same plugin again merges configuration (to `{x: true, y: false, z: true}`): 22555 * .use(pluginA, {y: false, z: true}) 22556 * // Plugins: 22557 * .use([pluginB, pluginC]) 22558 * // Two plugins, the second with options: 22559 * .use([pluginD, [pluginE, {}]]) 22560 * // Preset with plugins and settings: 22561 * .use({plugins: [pluginF, [pluginG, {}]], settings: {position: false}}) 22562 * // Settings only: 22563 * .use({settings: {position: false}}) 22564 * ``` 22565 * 22566 * @template {Array<unknown>} [Parameters=[]] 22567 * @template {Node | string | undefined} [Input=undefined] 22568 * @template [Output=Input] 22569 * 22570 * @overload 22571 * @param {Preset | null | undefined} [preset] 22572 * @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} 22573 * 22574 * @overload 22575 * @param {PluggableList} list 22576 * @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} 22577 * 22578 * @overload 22579 * @param {Plugin<Parameters, Input, Output>} plugin 22580 * @param {...(Parameters | [boolean])} parameters 22581 * @returns {UsePlugin<ParseTree, HeadTree, TailTree, CompileTree, CompileResult, Input, Output>} 22582 * 22583 * @param {PluggableList | Plugin | Preset | null | undefined} value 22584 * Usable value. 22585 * @param {...unknown} parameters 22586 * Parameters, when a plugin is given as a usable value. 22587 * @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} 22588 * Current processor. 22589 */ 22590 use(value, ...parameters) { 22591 const attachers = this.attachers 22592 const namespace = this.namespace 22593 22594 assertUnfrozen('use', this.frozen) 22595 22596 if (value === null || value === undefined) { 22597 // Empty. 22598 } else if (typeof value === 'function') { 22599 addPlugin(value, parameters) 22600 } else if (typeof value === 'object') { 22601 if (Array.isArray(value)) { 22602 addList(value) 22603 } else { 22604 addPreset(value) 22605 } 22606 } else { 22607 throw new TypeError('Expected usable value, not `' + value + '`') 22608 } 22609 22610 return this 22611 22612 /** 22613 * @param {Pluggable} value 22614 * @returns {undefined} 22615 */ 22616 function add(value) { 22617 if (typeof value === 'function') { 22618 addPlugin(value, []) 22619 } else if (typeof value === 'object') { 22620 if (Array.isArray(value)) { 22621 const [plugin, ...parameters] =
22622 /** @type {PluginTuple<Array<unknown>>} */ (value) 22623 addPlugin(plugin, parameters) 22624 } else { 22625 addPreset(value) 22626 } 22627 } else { 22628 throw new TypeError('Expected usable value, not `' + value + '`') 22629 } 22630 } 22631 22632 /** 22633 * @param {Preset} result 22634 * @returns {undefined} 22635 */ 22636 function addPreset(result) { 22637 if (!('plugins' in result) && !('settings' in result)) { 22638 throw new Error( 22639 'Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither' 22640 ) 22641 } 22642 22643 addList(result.plugins) 22644 22645 if (result.settings) { 22646 namespace.settings = extend(true, namespace.settings, result.settings) 22647 } 22648 } 22649 22650 /** 22651 * @param {PluggableList | null | undefined} plugins 22652 * @returns {undefined} 22653 */ 22654 function addList(plugins) { 22655 let index = -1 22656 22657 if (plugins === null || plugins === undefined) { 22658 // Empty. 22659 } else if (Array.isArray(plugins)) { 22660 while (++index < plugins.length) { 22661 const thing = plugins[index] 22662 add(thing) 22663 } 22664 } else { 22665 throw new TypeError('Expected a list of plugins, not `' + plugins + '`') 22666 } 22667 } 22668 22669 /** 22670 * @param {Plugin} plugin 22671 * @param {Array<unknown>} parameters 22672 * @returns {undefined} 22673 */ 22674 function addPlugin(plugin, parameters) { 22675 let index = -1 22676 let entryIndex = -1 22677 22678 while (++index < attachers.length) { 22679 if (attachers[index][0] === plugin) { 22680 entryIndex = index 22681 break 22682 } 22683 } 22684 22685 if (entryIndex === -1) { 22686 attachers.push([plugin, ...parameters]) 22687 } 22688 // Only set if there was at least a `primary` value, otherwise weâd change 22689 // `arguments.length`. 22690 else if (parameters.length > 0) { 22691 let [primary, ...rest] = parameters 22692 const currentPrimary = attachers[entryIndex][1] 22693 if (isPlainObject(currentPrimary) && isPlainObject(primary)) { 22694 primary = extend(true, currentPrimary, primary) 22695 } 22696 22697 attachers[entryIndex] = [plugin, primary, ...rest] 22698 } 22699 } 22700 } 22701} 22702 22703// Note: this returns a *callable* instance. 22704// Thatâs why itâs documented as a function. 22705/** 22706 * Create a new processor. 22707 * 22708 * @example 22709 * This example shows how a new processor can be created (from `remark`) and linked 22710 * to **stdin**(4) and **stdout**(4). 22711 * 22712 * ```js 22713 * import process from 'node:process'
22714 * import concatStream from 'concat-stream' 22715 * import {remark} from 'remark' 22716 * 22717 * process.stdin.pipe( 22718 * concatStream(function (buf) { 22719 * process.stdout.write(String(remark().processSync(buf))) 22720 * }) 22721 * ) 22722 * ``` 22723 * 22724 * @returns 22725 * New *unfrozen* processor (`processor`). 22726 * 22727 * This processor is configured to work the same as its ancestor. 22728 * When the descendant processor is configured in the future it does not 22729 * affect the ancestral processor. 22730 */ 22731const unified = new Processor().freeze() 22732 22733/** 22734 * Assert a parser is available. 22735 * 22736 * @param {string} name 22737 * @param {unknown} value 22738 * @returns {asserts value is Parser} 22739 */ 22740function assertParser(name, value) { 22741 if (typeof value !== 'function') { 22742 throw new TypeError('Cannot `' + name + '` without `parser`') 22743 } 22744} 22745 22746/** 22747 * Assert a compiler is available. 22748 * 22749 * @param {string} name 22750 * @param {unknown} value 22751 * @returns {asserts value is Compiler} 22752 */ 22753function assertCompiler(name, value) { 22754 if (typeof value !== 'function') { 22755 throw new TypeError('Cannot `' + name + '` without `compiler`') 22756 } 22757} 22758 22759/** 22760 * Assert the processor is not frozen. 22761 * 22762 * @param {string} name 22763 * @param {unknown} frozen 22764 * @returns {asserts frozen is false} 22765 */ 22766function assertUnfrozen(name, frozen) { 22767 if (frozen) { 22768 throw new Error( 22769 'Cannot call `' + 22770 name + 22771 '` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.' 22772 ) 22773 } 22774} 22775 22776/** 22777 * Assert `node` is a unist node. 22778 * 22779 * @param {unknown} node 22780 * @returns {asserts node is Node} 22781 */ 22782function assertNode(node) { 22783 // `isPlainObj` unfortunately uses `any` instead of `unknown`. 22784 // type-coverage:ignore-next-line 22785 if (!isPlainObject(node) || typeof node.type !== 'string') { 22786 throw new TypeError('Expected node, got `' + node + '`') 22787 // Fine. 22788 } 22789} 22790 22791/** 22792 * Assert that `complete` is `true`. 22793 * 22794 * @param {string} name 22795 * @param {string} asyncName 22796 * @param {unknown} complete 22797 * @returns {asserts complete is true} 22798 */ 22799function assertDone(name, asyncName, complete) { 22800 if (!complete) { 22801 throw new Error( 22802 '`' + name + '` finished async. Use `' + asyncName + '` instead' 22803 ) 22804 } 22805} 22806 22807/** 22808 * @param {Compatible | undefined} [value] 22809 * @returns {VFile} 22810 */ 22811function vfile(value) { 22812 return looksLikeAVFile(value) ? value : new VFile(value) 22813} 22814 22815/** 22816 * @param {Compatible | undefined} [value] 22817 * @returns {value is VFile} 22818 */ 22819function looksLikeAVFile(value) { 22820 return Boolean( 22821 value && 22822 typeof value === 'object' && 22823 'message' in value && 22824 'messages' in value 22825 ) 22826} 22827 22828/** 22829 * @param {unknown} [value] 22830 * @returns {value is Value} 22831 */ 22832function looksLikeAValue(value) { 22833 return typeof value === 'string' || lib_isUint8Array(value) 22834} 22835 22836/** 22837 * Assert `value` is an `Uint8Array`. 22838 * 22839 * @param {unknown} value 22840 * thing. 22841 * @returns {value is Uint8Array} 22842 * Whether `value` is an `Uint8Array`. 22843 */ 22844function lib_isUint8Array(value) { 22845 return Boolean( 22846 value && 22847 typeof value === 'object' && 22848 'byteLength' in value && 22849 'byteOffset' in value 22850 ) 22851} 22852 22853;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/unified/index.js 22854// Note: types exposed from `index.d.ts`. 22855 22856 22857;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/react-markdown/lib/index.js 22858/** 22859 * @import {Element, Nodes, Parents, Root} from 'hast' 22860 * @import {Root as MdastRoot} from 'mdast' 22861 * @import {ComponentType, JSX, ReactElement, ReactNode} from 'react' 22862 * @import {Options as RemarkRehypeOptions} from 'remark-rehype' 22863 * @import {BuildVisitor} from 'unist-util-visit' 22864 * @import {PluggableList, Processor} from 'unified' 22865 */ 22866 22867/** 22868 * @callback AllowElement 22869 * Filter elements. 22870 * @param {Readonly<Element>} element 22871 * Element to check. 22872 * @param {number} index 22873 * Index of `element` in `parent`. 22874 * @param {Readonly<Parents> | undefined} parent 22875 * Parent of `element`. 22876 * @returns {boolean | null | undefined} 22877 * Whether to allow `element` (default: `false`). 22878 */ 22879 22880/** 22881 * @typedef ExtraProps 22882 * Extra fields we pass. 22883 * @property {Element | undefined} [node] 22884 * passed when `passNode` is on. 22885 */ 22886 22887/** 22888 * @typedef {{ 22889 * [Key in keyof JSX.IntrinsicElements]?: ComponentType<JSX.IntrinsicElements[Ke
22889y] & ExtraProps> | keyof JSX.IntrinsicElements 22890 * }} Components 22891 * Map tag names to components. 22892 */ 22893 22894/** 22895 * @typedef Deprecation 22896 * Deprecation. 22897 * @property {string} from 22898 * Old field. 22899 * @property {string} id 22900 * ID in readme. 22901 * @property {keyof Options} [to] 22902 * New field. 22903 */ 22904 22905/** 22906 * @typedef Options 22907 * Configuration. 22908 * @property {AllowElement | null | undefined} [allowElement] 22909 * Filter elements (optional); 22910 * `allowedElements` / `disallowedElements` is used first. 22911 * @property {ReadonlyArray<string> | null | undefined} [allowedElements] 22912 * Tag names to allow (default: all tag names); 22913 * cannot combine w/ `disallowedElements`. 22914 * @property {string | null | undefined} [children] 22915 * Markdown. 22916 * @property {Components | null | undefined} [components] 22917 * Map tag names to components. 22918 * @property {ReadonlyArray<string> | null | undefined} [disallowedElements] 22919 * Tag names to disallow (default: `[]`); 22920 * cannot combine w/ `allowedElements`. 22921 * @property {PluggableList | null | undefined} [rehypePlugins] 22922 * List of rehype plugins to use. 22923 * @property {PluggableList | null | undefined} [remarkPlugins] 22924 * List of remark plugins to use. 22925 * @property {Readonly<RemarkRehypeOptions> | null | undefined} [remarkRehypeOptions] 22926 * Options to pass through to `remark-rehype`. 22927 * @property {boolean | null | undefined} [skipHtml=false] 22928 * Ignore HTML in markdown completely (default: `false`). 22929 * @property {boolean | null | undefined} [unwrapDisallowed=false] 22930 * Extract (unwrap) whatâs in disallowed elements (default: `false`); 22931 * normally when say `strong` is not allowed, it and itâs children are dropped, 22932 * with `unwrapDisallowed` the element itself is replaced by its children. 22933 * @property {UrlTransform | null | undefined} [urlTransform] 22934 * Change URLs (default: `defaultUrlTransform`) 22935 */ 22936 22937/** 22938 * @typedef HooksOptionsOnly 22939 * Configuration specifically for {@linkcode MarkdownHooks}. 22940 * @property {ReactNode | null | undefined} [fallback] 22941 * Content to render while the processor processing the markdown (optional). 22942 */ 22943 22944/** 22945 * @typedef {Options & HooksOptionsOnly} HooksOptions 22946 * Configuration for {@linkcode MarkdownHooks}; 22947 * extends the regular {@linkcode Options} with a `fallback` prop. 22948 */ 22949 22950/** 22951 * @callback UrlTransform 22952 * Transform all URLs. 22953 * @param {string} url 22954 * URL. 22955 * @param {string} key 22956 * Property name (example: `'href'`). 22957 * @param {Readonly<Element>} node 22958 * Node. 22959 * @returns {string | null | undefined} 22960 * Transformed URL (optional). 22961 */ 22962 22963 22964 22965 22966 22967 22968 22969 22970 22971 22972 22973 22974const changelog = 22975 'https://github.com/remarkjs/react-markdown/blob/main/changelog.md' 22976 22977/** @type {PluggableList} */ 22978const emptyPlugins = [] 22979/** @type {Readonly<RemarkRehypeOptions>} */ 22980const emptyRemarkRehypeOptions = {allowDangerousHtml: true} 22981const safeProtocol = /^(https?|ircs?|mailto|xmpp)$/i 22982 22983// Mutable because we `delete` any time itâs used and a message is sent. 22984/** @type {ReadonlyArray<Readonly<Deprecation>>} */ 22985const deprecations = [ 22986 {from: 'astPlugins', id: 'remove-buggy-html-in-markdown-parser'}, 22987 {from: 'allowDangerousHtml', id: 'remove-buggy-html-in-markdown-parser'}, 22988 { 22989 from: 'allowNode', 22990 id: 'replace-allownode-allowedtypes-and-disallowedtypes', 22991 to: 'allowElement' 22992 }, 22993 { 22994 from: 'allowedTypes', 22995 id: 'replace-allownode-allowedtypes-and-disallowedtypes', 22996 to: 'allowedElements' 22997 }, 22998 {from: 'className', id: 'remove-classname'}, 22999 { 23000 from: 'disallowedTypes', 23001 id: 'replace-allownode-allowedtypes-and-disallowedtypes', 23002 to: 'disallowedElements' 23003 }, 23004 {from: 'escapeHtml', id: 'remove-buggy-html-in-markdown-parser'}, 23005 {from: 'includeElementIndex', id: '#remove-includeelementindex'}, 23006 { 23007 from: 'includeNodeIndex', 23008 id: 'change-includenodeindex-to-includeelementindex' 23009 }, 23010 {from: 'linkTarget', id: 'remove-linktarget'}, 23011 {from: 'plugins', id: 'change-plugins-to-remarkplugins', to: 'remarkPlugins'}, 23012 {from: 'rawSourcePos', id: '#remove-rawsourcepos'}, 23013 {from: 'renderers', id: 'change-renderers-to-components', to: 'components'}, 23014 {from: 'source', id: 'change-source-to-children', to: 'children'}, 23015 {from: 'sourcePos', id: '#remove-sourcepos'}, 23016 {from: 'transformImageUri', id: '#add-urltransform', to: 'urlTransform'}, 23017 {from: 'transformLinkUri', id: '#add-urltransform', to: 'urlTransform'} 23018] 23019 23020/** 23021 * Component to render markdown. 23022 * 23023 * This is a synchronous component. 23024 * When using async plugins, 23025 * see {@linkcode MarkdownAsync} or {@linkcode MarkdownHooks}. 23026 * 23027 * @param {Readonly<Options>} options 23028 * Props. 23029 * @returns {ReactElement} 23030 * React element. 23031 */ 23032function Markdown(options) { 23033 const processor = createProcessor(options) 23034 const file = createFile(options) 23035 return post(processor.runSync(processor.parse(file), file), options) 23036} 23037 23038/** 23039 * Component to render markdown with support for async plugins 23040 * through async/await. 23041 * 23042 * Components returning promises are supported on the server. 23043 * For async support on the client, 23044 * see {@linkcode MarkdownHooks}. 23045 * 23046 * @param {Readonly<Options>} options 23047 * Props. 23048 * @returns {Promise<ReactElement>} 23049 * Promise to a React element. 23050 */ 23051async function MarkdownAsync(options) { 23052 const processor = createProcessor(options) 23053 const file = createFile(options) 23054 const tree = await processor.run(processor.parse(file), file) 23055 return post(tree, options) 23056} 23057 23058/** 23059 * Component to render markdown with support for async plugins through hooks. 23060 * 23061 * This uses `useEffect` and `useState` hooks. 23062 * Hooks run on the client and do not immediately render something. 23063 * For async support on the server,
23064 * see {@linkcode MarkdownAsync}. 23065 * 23066 * @param {Readonly<HooksOptions>} options 23067 * Props. 23068 * @returns {ReactNode} 23069 * React node. 23070 */ 23071function MarkdownHooks(options) { 23072 const processor = createProcessor(options) 23073 const [error, setError] = useState( 23074 /** @type {Error | undefined} */ (undefined) 23075 ) 23076 const [tree, setTree] = useState(/** @type {Root | undefined} */ (undefined)) 23077 23078 useEffect( 23079 function () { 23080 let cancelled = false 23081 const file = createFile(options) 23082 23083 processor.run(processor.parse(file), file, function (error, tree) { 23084 if (!cancelled) { 23085 setError(error) 23086 setTree(tree) 23087 } 23088 }) 23089 23090 /** 23091 * @returns {undefined} 23092 * Nothing. 23093 */ 23094 return function () { 23095 cancelled = true 23096 } 23097 }, 23098 [ 23099 options.children, 23100 options.rehypePlugins, 23101 options.remarkPlugins, 23102 options.remarkRehypeOptions 23103 ] 23104 ) 23105 23106 if (error) throw error 23107 23108 return tree ? post(tree, options) : options.fallback 23109} 23110 23111/** 23112 * Set up the `unified` processor. 23113 * 23114 * @param {Readonly<Options>} options 23115 * Props. 23116 * @returns {Processor<MdastRoot, MdastRoot, Root, undefined, undefined>} 23117 * Result. 23118 */ 23119function createProcessor(options) { 23120 const rehypePlugins = options.rehypePlugins || emptyPlugins 23121 const remarkPlugins = options.remarkPlugins || emptyPlugins 23122 const remarkRehypeOptions = options.remarkRehypeOptions 23123 ? {...options.remarkRehypeOptions, ...emptyRemarkRehypeOptions} 23124 : emptyRemarkRehypeOptions 23125 23126 const processor = unified() 23127 .use(remarkParse) 23128 .use(remarkPlugins) 23129 .use(remarkRehype, remarkRehypeOptions) 23130 .use(rehypePlugins) 23131 23132 return processor 23133} 23134 23135/** 23136 * Set up the virtual file. 23137 * 23138 * @param {Readonly<Options>} options 23139 * Props. 23140 * @returns {VFile} 23141 * Result. 23142 */ 23143function createFile(options) { 23144 const children = options.children || '' 23145 const file = new VFile() 23146 23147 if (typeof children === 'string') { 23148 file.value = children 23149 } else { 23150 unreachable( 23151 'Unexpected value `' + 23152 children + 23153 '` for `children` prop, expected `string`' 23154 ) 23155 } 23156 23157 return file 23158} 23159 23160/** 23161 * Process the result from unified some more. 23162 * 23163 * @param {Nodes} tree 23164 * Tree. 23165 * @param {Readonly<Options>} options 23166 * Props. 23167 * @returns {ReactElement} 23168 * React element. 23169 */ 23170function post(tree, options) { 23171 const allowedElements = options.allowedElements 23172 const allowElement = options.allowElement 23173 const components = options.components 23174 const disallowedElements = options.disallowedElements 23175 const skipHtml = options.skipHtml 23176 const unwrapDisallowed = options.unwrapDisallowed 23177 const urlTransform = options.urlTransform || defaultUrlTransform 23178 23179 for (const deprecation of deprecations) { 23180 if (Object.hasOwn(options, deprecation.from)) { 23181 unreachable( 23182 'Unexpected `' + 23183 deprecation.from + 23184 '` prop, ' + 23185 (deprecation.to 23186 ? 'use `' + deprecation.to + '` instead' 23187 : 'remove it') + 23188 ' (see <' + 23189 changelog + 23190 '#' + 23191 deprecation.id + 23192 '> for more info)' 23193 ) 23194 } 23195 } 23196 23197 if (allowedElements && disallowedElements) { 23198 unreachable( 23199 'Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other' 23200 ) 23201 } 23202 23203 visit(tree, transform) 23204 23205 return toJsxRuntime(tree, { 23206 Fragment: jsx_runtime.Fragment, 23207 components, 23208 ignoreInvalidStyle: true, 23209 jsx: jsx_runtime.jsx, 23210 jsxs: jsx_runtime.jsxs, 23211 passKeys: true, 23212 passNode: true 23213 }) 23214 23215 /** @type {BuildVisitor<Root>} */ 23216 function transform(node, index, parent) { 23217 if (node.type === 'raw' && parent && typeof index === 'number') { 23218 if (skipHtml) { 23219 parent.children.splice(index, 1) 23220 } else { 23221 parent.children[index] = {type: 'text', value: node.value} 23222 } 23223 23224 return index 23225 } 23226 23227 if (node.type === 'element') { 23228 /** @type {string} */ 23229 let key 23230 23231 for (key in urlAttributes) { 23232 if ( 23233 Object.hasOwn(urlAttributes, key) && 23234 Object.hasOwn(node.properties, key) 23235 ) { 23236 const value = node.properties[key] 23237 const test = urlAttributes[key] 23238 if (test === null || test.includes(node.tagName)) { 23239 node.properties[key] = urlTransform(String(value || ''), key, node) 23240 } 23241 } 23242 } 23243 } 23244 23245 if (node.type === 'element') { 23246 let remove = allowedElements 23247 ? !allowedElements.includes(node.tagName) 23248 : disallowedElements 23249 ? disallowedElements.includes(node.tagName) 23250 : false 23251 23252 if (!remove && allowElement && typeof index === 'number') { 23253 remove = !allowElement(node, index, parent) 23254 } 23255 23256 if (remove && parent && typeof index === 'number') { 23257 if (unwrapDisallowed && node.children) { 23258 parent.children.splice(index, 1, ...node.children) 23259 } else { 23260 parent.children.splice(index, 1) 23261 } 23262 23263 return index 23264 } 23265 } 23266 } 23267} 23268 23269/** 23270 * Make a URL safe. 23271 * 23272 * @satisfies {UrlTransform} 23273 * @param {string} value 23274 * URL. 23275 * @returns {string} 23276 * Safe URL. 23277 */ 23278function defaultUrlTransform(value) { 23279 // Same as: 23280 // <https://github.com/micromark/micromark/blob/929275e/packages/micromark-util-sanitize-uri/dev/index.js#L34> 23281 // But without the `encode` part. 23282 const colon = value.indexOf(':') 23283 const questionMark = value.indexOf('?') 23284 const numberSign = value.indexOf('#') 23285 const slash = value.indexOf('/') 23286 23287 if ( 23288 // If there is no protocol, itâs relative. 23289 colon === -1 || 23290 // If the first colon is after a `?`, `#`, or `/`, itâs not a protocol. 23291 (slash !== -1 && colon > slash) || 23292 (questionMark !== -1 && colon > questionMark) || 23293 (numberSign !== -1 && colon > numberSign) || 23294 // It is a protocol, it should be allowed. 23295 safeProtocol.test(value.slice(0, colon)) 23296 ) { 23297 return value 23298 } 23299 23300 return '' 23301} 23302 23303;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/react-markdown/index.js 23304/** 23305 * @typedef {import('./lib/index.js').AllowElement} AllowElement 23306 * @typedef {import('./lib/index.js').Components} Components 23307 * @typedef {import('./lib/index.js').ExtraProps} ExtraProps 23308 * @typedef {import('./lib/index.js').HooksOptions} HooksOptions 23309 * @typedef {import('./lib/index.js').Options} Options 23310 * @typedef {import('./lib/index.js').UrlTransform} UrlTransform 23311 */ 23312 23313 23314 23315 23316/***/ }), 23317 23318/***/ 14556: 23319/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { 23320 23321 23322// EXPORTS 23323__webpack_require__.d(__webpack_exports__, { 23324 ZP: function() { return /* binding */ useSWR; } 23325}); 23326 23327// UNUSED EXPORTS: SWRConfig, mutate, preload, unstable_serialize, useSWRConfig 23328 23329// EXTERNAL MODULE: ./node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/react/index.js 23330var react = __webpack_require__(25529); 23331// EXTERNAL MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/use-sync-external-store/shim/index.js 23332var shim = __webpack_require__(94524); 23333;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/swr/dist/_internal/events.mjs 23334const FOCUS_EVENT = 0; 23335const RECONNECT_EVENT = 1; 23336const MUTATE_EVENT = 2; 23337const ERROR_REVALIDATE_EVENT = 3; 23338 23339 23340 23341;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected]/node_modules/dequal/lite/index.mjs 23342var has = Object.prototype.hasOwnProperty; 23343 23344function dequal(foo, bar) { 23345 var ctor, len; 23346 if (foo === bar) return true; 23347
vendor: 1,788 bytes, lines 23348-23396
23348 if (foo && bar && (ctor=foo.constructor) === bar.constructor) { 23349 if (ctor === Date) return foo.getTime() === bar.getTime(); 23350 if (ctor === RegExp) return foo.toString() === bar.toString(); 23351 23352 if (ctor === Array) { 23353 if ((len=foo.length) === bar.length) { 23354 while (len-- && dequal(foo[len], bar[len])); 23355 } 23356 return len === -1; 23357 } 23358 23359 if (!ctor || typeof foo === 'object') { 23360 len = 0; 23361 for (ctor in foo) { 23362 if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false; 23363 if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false; 23364 } 23365 return Object.keys(bar).length === len; 23366 } 23367 } 23368 23369 return foo !== foo && bar !== bar; 23370} 23371 23372;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/swr/dist/_internal/config-context-12s-fLme8m6q.mjs 23373/* __next_internal_client_entry_do_not_use__ A,B,I,O,S,U,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z auto */ 23374 23375 23376// Global state used to deduplicate requests and store listeners 23377const config_context_12s_fLme8m6q_SWRGlobalState = new WeakMap(); 23378// Shared state between server components and client components 23379const noop = ()=>{}; 23380// Using noop() as the undefined value as undefined can be replaced 23381// by something else. Prettier ignore and extra parentheses are necessary here 23382// to ensure that tsc doesn't remove the __NOINLINE__ comment. 23383// prettier-ignore 23384const UNDEFINED = /*#__NOINLINE__*/ noop(); 23385const OBJECT = Object; 23386const isUndefined = (v)=>v === UNDEFINED; 23387const isFunction = (v)=>typeof v == "function"; 23388const mergeObjects = (a, b)=>({ 23389 ...a, 23390 ...b 23391 }); 23392const isPromiseLike = (x)=>isFunction(x.then); 23393const EMPTY_CACHE = {}; 23394const INITIAL_CACHE = {}; 23395const STR_UNDEFINED = "undefined"; 23396// NOTE: Use the function to guarantee it's re-evaluated between jsdom and n
vendor: 6,193 bytes, lines 23396-23550
23396ode runtime for tests. 23397const isWindowDefined = typeof window != STR_UNDEFINED; 23398const isDocumentDefined = typeof document != STR_UNDEFINED; 23399const isLegacyDeno = isWindowDefined && "Deno" in window; 23400const hasRequestAnimationFrame = ()=>isWindowDefined && typeof window["requestAnimationFrame"] != STR_UNDEFINED; 23401const createCacheHelper = (cache, key)=>{ 23402 const state = config_context_12s_fLme8m6q_SWRGlobalState.get(cache); 23403 return [ 23404 // Getter 23405 ()=>!isUndefined(key) && cache.get(key) || EMPTY_CACHE, 23406 // Setter 23407 (info)=>{ 23408 if (!isUndefined(key)) { 23409 const prev = cache.get(key); 23410 // Before writing to the store, we keep the value in the initial cache 23411 // if it's not there yet. 23412 if (!(key in INITIAL_CACHE)) { 23413 INITIAL_CACHE[key] = prev; 23414 } 23415 state[5](key, mergeObjects(prev, info), prev || EMPTY_CACHE); 23416 } 23417 }, 23418 // Subscriber 23419 state[6], 23420 // Get server cache snapshot 23421 ()=>{ 23422 if (!isUndefined(key)) { 23423 // If the cache was updated on the client, we return the stored initial value. 23424 if (key in INITIAL_CACHE) return INITIAL_CACHE[key]; 23425 } 23426 // If we haven't done any client-side updates, we return the current value. 23427 return !isUndefined(key) && cache.get(key) || EMPTY_CACHE; 23428 } 23429 ]; 23430} // export { UNDEFINED, OBJECT, isUndefined, isFunction, mergeObjects, isPromiseLike } 23431; 23432/** 23433 * Due to the bug https://bugs.chromium.org/p/chromium/issues/detail?id=678075, 23434 * it's not reliable to detect if the browser is currently online or offline 23435 * based on `navigator.onLine`. 23436 * As a workaround, we always assume it's online on the first load, and change 23437 * the status upon `online` or `offline` events. 23438 */ let online = true; 23439const isOnline = ()=>online; 23440// For node and React Native, `add/removeEventListener` doesn't exist on window. 23441const [onWindowEvent, offWindowEvent] = isWindowDefined && window.addEventListener ? [ 23442 window.addEventListener.bind(window), 23443 window.removeEventListener.bind(window) 23444] : [ 23445 noop, 23446 noop 23447]; 23448const isVisible = ()=>{ 23449 const visibilityState = isDocumentDefined && document.visibilityState; 23450 return isUndefined(visibilityState) || visibilityState !== "hidden"; 23451}; 23452const initFocus = (callback)=>{ 23453 // focus revalidate 23454 if (isDocumentDefined) { 23455 document.addEventListener("visibilitychange", callback); 23456 } 23457 onWindowEvent("focus", callback); 23458 return ()=>{ 23459 if (isDocumentDefined) { 23460 document.removeEventListener("visibilitychange", callback); 23461 } 23462 offWindowEvent("focus", callback); 23463 }; 23464}; 23465const initReconnect = (callback)=>{ 23466 // revalidate on reconnected 23467 const onOnline = ()=>{ 23468 online = true; 23469 callback(); 23470 }; 23471 // nothing to revalidate, just update the status 23472 const onOffline = ()=>{ 23473 online = false; 23474 }; 23475 onWindowEvent("online", onOnline); 23476 onWindowEvent("offline", onOffline); 23477 return ()=>{ 23478 offWindowEvent("online", onOnline); 23479 offWindowEvent("offline", onOffline); 23480 }; 23481}; 23482const preset = { 23483 isOnline, 23484 isVisible 23485}; 23486const defaultConfigOptions = { 23487 initFocus, 23488 initReconnect 23489}; 23490const IS_REACT_LEGACY = !react.useId; 23491const config_context_12s_fLme8m6q_IS_SERVER = !isWindowDefined || isLegacyDeno; 23492// Polyfill requestAnimationFrame 23493const rAF = (f)=>hasRequestAnimationFrame() ? window["requestAnimationFrame"](f) : setTimeout(f, 1); 23494// React currently throws a warning when using useLayoutEffect on the server. 23495// To get around it, we can conditionally useEffect on the server (no-op) and 23496// useLayoutEffect in the browser. 23497const useIsomorphicLayoutEffect = config_context_12s_fLme8m6q_IS_SERVER ? react.useEffect : react.useLayoutEffect; 23498// This assignment is to extend the Navigator type to use effectiveType. 23499const navigatorConnection = typeof navigator !== "undefined" && navigator.connection; 23500// Adjust the config based on slow connection status (<= 70Kbps). 23501const slowConnection = !config_context_12s_fLme8m6q_IS_SERVER && navigatorConnection && ([ 23502 "slow-2g", 23503 "2g" 23504].includes(navigatorConnection.effectiveType) || navigatorConnection.saveData); 23505// use WeakMap to store the object->key mapping 23506// so the objects can be garbage collected. 23507// WeakMap uses a hashtable under the hood, so the lookup 23508// complexity is almost O(1). 23509const table = new WeakMap(); 23510const getTypeName = (value)=>OBJECT.prototype.toString.call(value); 23511const isObjectTypeName = (typeName, type)=>typeName === "[object ".concat(type, "]"); 23512// counter of the key 23513let counter = 0; 23514// A stable hash implementation that supports: 23515// - Fast and ensures unique hash properties 23516// - Handles unserializable values 23517// - Handles object key ordering 23518// - Generates short results 23519// 23520// This is not a serialization function, and the result is not guaranteed to be 23521// parsable. 23522const stableHash = (arg)=>{ 23523 const type = typeof arg; 23524 const typeName = getTypeName(arg); 23525 const isDate = isObjectTypeName(typeName, "Date"); 23526 const isRegex = isObjectTypeName(typeName, "RegExp"); 23527 const isPlainObject = isObjectTypeName(typeName, "Object"); 23528 let result; 23529 let index; 23530 if (OBJECT(arg) === arg && !isDate && !isRegex) { 23531 // Object/function, not null/date/regexp. Use WeakMap to store the id first. 23532 // If it's already hashed, directly return the result. 23533 result = table.get(arg); 23534 if (result) return result; 23535 // Store the hash first for circular reference detection before entering the 23536 // recursive `stableHash` calls. 23537 // For other objects like set and map, we use this id directly as the hash. 23538 result = ++counter + "~"; 23539 table.set(arg, result); 23540 if (Array.isArray(arg)) { 23541 // Array. 23542 result = "@"; 23543 for(index = 0; index < arg.length; index++){ 23544 result += stableHash(arg[index]) + ","; 23545 } 23546 table.set(arg, result); 23547 } 23548 if (isPlainObject) { 23549 // Object, sort keys. 23550 result = "#";
vendor: 7,963 bytes, lines 23551-23749
23551 const keys = OBJECT.keys(arg).sort(); 23552 while(!isUndefined(index = keys.pop())){ 23553 if (!isUndefined(arg[index])) { 23554 result += index + ":" + stableHash(arg[index]) + ","; 23555 } 23556 } 23557 table.set(arg, result); 23558 } 23559 } else { 23560 result = isDate ? arg.toJSON() : type == "symbol" ? arg.toString() : type == "string" ? JSON.stringify(arg) : "" + arg; 23561 } 23562 return result; 23563}; 23564const config_context_12s_fLme8m6q_serialize = (key)=>{ 23565 if (isFunction(key)) { 23566 try { 23567 key = key(); 23568 } catch (err) { 23569 // dependencies not ready 23570 key = ""; 23571 } 23572 } 23573 // Use the original key as the argument of fetcher. This can be a string or an 23574 // array of values. 23575 const args = key; 23576 // If key is not falsy, or not an empty array, hash it. 23577 key = typeof key == "string" ? key : (Array.isArray(key) ? key.length : key) ? stableHash(key) : ""; 23578 return [ 23579 key, 23580 args 23581 ]; 23582}; 23583// Global timestamp. 23584let __timestamp = 0; 23585const getTimestamp = ()=>++__timestamp; 23586async function internalMutate() { 23587 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){ 23588 args[_key] = arguments[_key]; 23589 } 23590 const [cache, _key1, _data, _opts] = args; 23591 // When passing as a boolean, it's explicitly used to disable/enable 23592 // revalidation. 23593 const options = mergeObjects({ 23594 populateCache: true, 23595 throwOnError: true 23596 }, typeof _opts === "boolean" ? { 23597 revalidate: _opts 23598 } : _opts || {}); 23599 let populateCache = options.populateCache; 23600 const rollbackOnErrorOption = options.rollbackOnError; 23601 let optimisticData = options.optimisticData; 23602 const rollbackOnError = (error)=>{ 23603 return typeof rollbackOnErrorOption === "function" ? rollbackOnErrorOption(error) : rollbackOnErrorOption !== false; 23604 }; 23605 const throwOnError = options.throwOnError; 23606 // If the second argument is a key filter, return the mutation results for all 23607 // filtered keys. 23608 if (isFunction(_key1)) { 23609 const keyFilter = _key1; 23610 const matchedKeys = []; 23611 const it = cache.keys(); 23612 for (const key of it){ 23613 if (!/^\$(inf|sub)\$/.test(key) && keyFilter(cache.get(key)._k)) { 23614 matchedKeys.push(key); 23615 } 23616 } 23617 return Promise.all(matchedKeys.map(mutateByKey)); 23618 } 23619 return mutateByKey(_key1); 23620 async function mutateByKey(_k) { 23621 // Serialize key 23622 const [key] = config_context_12s_fLme8m6q_serialize(_k); 23623 if (!key) return; 23624 const [get, set] = createCacheHelper(cache, key); 23625 const [EVENT_REVALIDATORS, MUTATION, FETCH, PRELOAD] = config_context_12s_fLme8m6q_SWRGlobalState.get(cache); 23626 const startRevalidate = ()=>{ 23627 const revalidators = EVENT_REVALIDATORS[key]; 23628 const revalidate = isFunction(options.revalidate) ? options.revalidate(get().data, _k) : options.revalidate !== false; 23629 if (revalidate) { 23630 // Invalidate the key by deleting the concurrent request markers so new 23631 // requests will not be deduped. 23632 delete FETCH[key]; 23633 delete PRELOAD[key]; 23634 if (revalidators && revalidators[0]) { 23635 return revalidators[0](MUTATE_EVENT).then(()=>get().data); 23636 } 23637 } 23638 return get().data; 23639 }; 23640 // If there is no new data provided, revalidate the key with current state. 23641 if (args.length < 3) { 23642 // Revalidate and broadcast state. 23643 return startRevalidate(); 23644 } 23645 let data = _data; 23646 let error; 23647 let isError = false; 23648 // Update global timestamps. 23649 const beforeMutationTs = getTimestamp(); 23650 MUTATION[key] = [ 23651 beforeMutationTs, 23652 0 23653 ]; 23654 const hasOptimisticData = !isUndefined(optimisticData); 23655 const state = get(); 23656 // `displayedData` is the current value on screen. It could be the optimistic value 23657 // that is going to be overridden by a `committedData`, or get reverted back. 23658 // `committedData` is the validated value that comes from a fetch or mutation. 23659 const displayedData = state.data; 23660 const currentData = state._c; 23661 const committedData = isUndefined(currentData) ? displayedData : currentData; 23662 // Do optimistic data update. 23663 if (hasOptimisticData) { 23664 optimisticData = isFunction(optimisticData) ? optimisticData(committedData, displayedData) : optimisticData; 23665 // When we set optimistic data, backup the current committedData data in `_c`. 23666 set({ 23667 data: optimisticData, 23668 _c: committedData 23669 }); 23670 } 23671 if (isFunction(data)) { 23672 // `data` is a function, call it passing current cache value. 23673 try { 23674 data = data(committedData); 23675 } catch (err) { 23676 // If it throws an error synchronously, we shouldn't update the cache. 23677 error = err; 23678 isError = true; 23679 } 23680 } 23681 // `data` is a promise/thenable, resolve the final data first. 23682 if (data && isPromiseLike(data)) { 23683 // This means that the mutation is async, we need to check timestamps to 23684 // avoid race conditions. 23685 data = await data.catch((err)=>{ 23686 error = err; 23687 isError = true; 23688 }); 23689 // Check if other mutations have occurred since we've started this mutation. 23690 // If there's a race we don't update cache or broadcast the change, 23691 // just return the data. 23692 if (beforeMutationTs !== MUTATION[key][0]) { 23693 if (isError) throw error; 23694 return data; 23695 } else if (isError && hasOptimisticData && rollbackOnError(error)) { 23696 // Rollback. Always populate the cache in this case but without 23697 // transforming the data. 23698 populateCache = true; 23699 // Reset data to be the latest committed data, and clear the `_c` value. 23700 set({ 23701 data: committedData, 23702 _c: UNDEFINED 23703 }); 23704 } 23705 } 23706 // If we should write back the cache after request. 23707 if (populateCache) { 23708 if (!isError) { 23709 // Transform the result into data. 23710 if (isFunction(populateCache)) { 23711 const populateCachedData = populateCache(data, committedData); 23712 set({ 23713 data: populateCachedData, 23714 error: UNDEFINED, 23715 _c: UNDEFINED 23716 }); 23717 } else { 23718 // Only update cached data and reset the error if there's no error. Data can be `undefined` here. 23719 set({ 23720 data, 23721 error: UNDEFINED, 23722 _c: UNDEFINED 23723 }); 23724 } 23725 } 23726 } 23727 // Reset the timestamp to mark the mutation has ended. 23728 MUTATION[key][1] = getTimestamp(); 23729 // Update existing SWR Hooks' internal states: 23730 Promise.resolve(startRevalidate()).then(()=>{ 23731 // The mutation and revalidation are ended, we can clear it since the data is 23732 // not an optimistic value anymore. 23733 set({ 23734 _c: UNDEFINED 23735 }); 23736 }); 23737 // Throw error or return data 23738 if (isError) { 23739 if (throwOnError) throw error; 23740 return; 23741 } 23742 return data; 23743 } 23744} 23745const revalidateAllKeys = (revalidators, type)=>{ 23746 for(const key in revalidators){ 23747 if (revalidators[key][0]) revalidators[key][0](type); 23748 } 23749};
vendor: 5,044 bytes, lines 23750-23858
23750const initCache = (provider, options)=>{ 23751 // The global state for a specific provider will be used to deduplicate 23752 // requests and store listeners. As well as a mutate function that is bound to 23753 // the cache. 23754 // The provider's global state might be already initialized. Let's try to get the 23755 // global state associated with the provider first. 23756 if (!config_context_12s_fLme8m6q_SWRGlobalState.has(provider)) { 23757 const opts = mergeObjects(defaultConfigOptions, options); 23758 // If there's no global state bound to the provider, create a new one with the 23759 // new mutate function. 23760 const EVENT_REVALIDATORS = Object.create(null); 23761 const mutate = internalMutate.bind(UNDEFINED, provider); 23762 let unmount = noop; 23763 const subscriptions = Object.create(null); 23764 const subscribe = (key, callback)=>{ 23765 const subs = subscriptions[key] || []; 23766 subscriptions[key] = subs; 23767 subs.push(callback); 23768 return ()=>{ 23769 const index = subs.indexOf(callback); 23770 if (index >= 0) { 23771 // O(1): swap with the last element and pop 23772 subs[index] = subs[subs.length - 1]; 23773 subs.pop(); 23774 } 23775 }; 23776 }; 23777 const setter = (key, value, prev)=>{ 23778 provider.set(key, value); 23779 const subs = subscriptions[key]; 23780 if (subs) { 23781 for (const fn of subs){ 23782 fn(value, prev); 23783 } 23784 } 23785 }; 23786 const initProvider = ()=>{ 23787 if (!config_context_12s_fLme8m6q_SWRGlobalState.has(provider)) { 23788 // Update the state if it's new, or if the provider has been extended. 23789 config_context_12s_fLme8m6q_SWRGlobalState.set(provider, [ 23790 EVENT_REVALIDATORS, 23791 Object.create(null), 23792 Object.create(null), 23793 Object.create(null), 23794 mutate, 23795 setter, 23796 subscribe 23797 ]); 23798 if (!config_context_12s_fLme8m6q_IS_SERVER) { 23799 // When listening to the native events for auto revalidations, 23800 // we intentionally put a delay (setTimeout) here to make sure they are 23801 // fired after immediate JavaScript executions, which can be 23802 // React's state updates. 23803 // This avoids some unnecessary revalidations such as 23804 // https://github.com/vercel/swr/issues/1680. 23805 const releaseFocus = opts.initFocus(setTimeout.bind(UNDEFINED, revalidateAllKeys.bind(UNDEFINED, EVENT_REVALIDATORS, FOCUS_EVENT))); 23806 const releaseReconnect = opts.initReconnect(setTimeout.bind(UNDEFINED, revalidateAllKeys.bind(UNDEFINED, EVENT_REVALIDATORS, RECONNECT_EVENT))); 23807 unmount = ()=>{ 23808 // eslint-disable-next-line @typescript-eslint/no-unused-expressions 23809 releaseFocus && releaseFocus(); 23810 // eslint-disable-next-line @typescript-eslint/no-unused-expressions 23811 releaseReconnect && releaseReconnect(); 23812 // When un-mounting, we need to remove the cache provider from the state 23813 // storage too because it's a side-effect. Otherwise, when re-mounting we 23814 // will not re-register those event listeners. 23815 config_context_12s_fLme8m6q_SWRGlobalState.delete(provider); 23816 }; 23817 } 23818 } 23819 }; 23820 initProvider(); 23821 // This is a new provider, we need to initialize it and setup DOM events 23822 // listeners for `focus` and `reconnect` actions. 23823 // We might want to inject an extra layer on top of `provider` in the future, 23824 // such as key serialization, auto GC, etc. 23825 // For now, it's just a `Map` interface without any modifications. 23826 return [ 23827 provider, 23828 mutate, 23829 initProvider, 23830 unmount 23831 ]; 23832 } 23833 return [ 23834 provider, 23835 config_context_12s_fLme8m6q_SWRGlobalState.get(provider)[4] 23836 ]; 23837}; 23838// error retry 23839const onErrorRetry = (_, __, config, revalidate, opts)=>{ 23840 const maxRetryCount = config.errorRetryCount; 23841 const currentRetryCount = opts.retryCount; 23842 // Exponential backoff 23843 const timeout = ~~((Math.random() + 0.5) * (1 << (currentRetryCount < 8 ? currentRetryCount : 8))) * config.errorRetryInterval; 23844 if (!isUndefined(maxRetryCount) && currentRetryCount > maxRetryCount) { 23845 return; 23846 } 23847 setTimeout(revalidate, timeout, opts); 23848}; 23849const compare = dequal; 23850// Default cache provider 23851const [config_context_12s_fLme8m6q_cache, mutate] = initCache(new Map()); 23852// Default config 23853const defaultConfig = mergeObjects({ 23854 // events 23855 onLoadingSlow: noop, 23856 onSuccess: noop, 23857 onError: noop, 23858 onErrorRetry,
23859 onDiscarded: noop, 23860 // switches 23861 revalidateOnFocus: true, 23862 revalidateOnReconnect: true, 23863 revalidateIfStale: true, 23864 shouldRetryOnError: true, 23865 // timeouts 23866 errorRetryInterval: slowConnection ? 10000 : 5000, 23867 focusThrottleInterval: 5 * 1000, 23868 dedupingInterval: 2 * 1000, 23869 loadingTimeout: slowConnection ? 5000 : 3000, 23870 // providers 23871 compare, 23872 isPaused: ()=>false, 23873 cache: config_context_12s_fLme8m6q_cache, 23874 mutate, 23875 fallback: {} 23876}, preset); 23877const mergeConfigs = (a, b)=>{ 23878 // Need to create a new object to avoid mutating the original here. 23879 const v = mergeObjects(a, b); 23880 // If two configs are provided, merge their `use` and `fallback` options. 23881 if (b) { 23882 const { use: u1, fallback: f1 } = a; 23883 const { use: u2, fallback: f2 } = b; 23884 if (u1 && u2) { 23885 v.use = u1.concat(u2); 23886 } 23887 if (f1 && f2) { 23888 v.fallback = mergeObjects(f1, f2); 23889 } 23890 } 23891 return v; 23892}; 23893const SWRConfigContext = /*#__PURE__*/ (0,react.createContext)({}); 23894const SWRConfig = (props)=>{ 23895 const { value } = props; 23896 const parentConfig = (0,react.useContext)(SWRConfigContext); 23897 const isFunctionalConfig = isFunction(value); 23898 const config = (0,react.useMemo)(()=>isFunctionalConfig ? value(parentConfig) : value, [ 23899 isFunctionalConfig, 23900 parentConfig, 23901 value 23902 ]); 23903 // Extend parent context values and middleware. 23904 const extendedConfig = (0,react.useMemo)(()=>isFunctionalConfig ? config : mergeConfigs(parentConfig, config), [ 23905 isFunctionalConfig, 23906 parentConfig, 23907 config 23908 ]); 23909 // Should not use the inherited provider. 23910 const provider = config && config.provider; 23911 // initialize the cache only on first access. 23912 const cacheContextRef = (0,react.useRef)(UNDEFINED); 23913 if (provider && !cacheContextRef.current) { 23914 cacheContextRef.current = initCache(provider(extendedConfig.cache || config_context_12s_fLme8m6q_cache), config); 23915 } 23916 const cacheContext = cacheContextRef.current; 23917 // Override the cache if a new provider is given. 23918 if (cacheContext) { 23919 extendedConfig.cache = cacheContext[0]; 23920 extendedConfig.mutate = cacheContext[1]; 23921 } 23922 // Unsubscribe events. 23923 useIsomorphicLayoutEffect(()=>{ 23924 if (cacheContext) { 23925 // eslint-disable-next-line @typescript-eslint/no-unused-expressions 23926 cacheContext[2] && cacheContext[2](); 23927 return cacheContext[3]; 23928 } 23929 }, []); 23930 return /*#__PURE__*/ (0,react.createElement)(SWRConfigContext.Provider, mergeObjects(props, { 23931 value: extendedConfig 23932 })); 23933}; 23934 23935 23936;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/swr/dist/_internal/constants.mjs 23937const INFINITE_PREFIX = '$inf$'; 23938 23939 23940 23941;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/swr/dist/_internal/types.mjs 23942 23943 23944;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/swr/dist/_internal/index.mjs 23945 23946 23947 23948 23949 23950 23951 23952 23953 23954// @ts-expect-error 23955const enableDevtools = isWindowDefined && window.__SWR_DEVTOOLS_USE__; 23956const use = enableDevtools ? window.__SWR_DEVTOOLS_USE__ : []; 23957const setupDevTools = ()=>{ 23958 if (enableDevtools) { 23959 // @ts-expect-error 23960 window.__SWR_DEVTOOLS_REACT__ = react; 23961 } 23962}; 23963 23964const normalize = (args)=>{ 23965 return isFunction(args[1]) ? [ 23966 args[0], 23967 args[1], 23968 args[2] || {} 23969 ] : [ 23970 args[0], 23971 null, 23972 (args[1] === null ? args[2] : args[1]) || {} 23973 ]; 23974}; 23975 23976const useSWRConfig = ()=>{ 23977 const parentConfig = (0,react.useContext)(SWRConfigContext); 23978 const mergedConfig = (0,react.useMemo)(()=>mergeObjects(defaultConfig, parentConfig), [ 23979 parentConfig 23980 ]); 23981 return mergedConfig; 23982}; 23983 23984const preload = (key_, fetcher)=>{ 23985 // preload should be a no-op on the server 23986 if (IS_SERVER) { 23987 return undefined; 23988 } 23989 const [key, fnArg] = serialize(key_); 23990 const [, , , PRELOAD] = SWRGlobalState.get(cache); 23991 // Prevent preload to be called multiple times before used. 23992 if (PRELOAD[key]) return PRELOAD[key]; 23993 const req = fetcher(fnArg); 23994 PRELOAD[key] = req; 23995 return req; 23996}; 23997const middleware = (useSWRNext)=>(key_, fetcher_, config)=>{
23998 // fetcher might be a sync function, so this should not be an async function 23999 const fetcher = fetcher_ && ((...args)=>{ 24000 const [key] = config_context_12s_fLme8m6q_serialize(key_); 24001 const [, , , PRELOAD] = config_context_12s_fLme8m6q_SWRGlobalState.get(config_context_12s_fLme8m6q_cache); 24002 if (key.startsWith(INFINITE_PREFIX)) { 24003 // we want the infinite fetcher to be called. 24004 // handling of the PRELOAD cache happens there. 24005 return fetcher_(...args); 24006 } 24007 const req = PRELOAD[key]; 24008 if (isUndefined(req)) return fetcher_(...args); 24009 delete PRELOAD[key]; 24010 return req; 24011 }); 24012 return useSWRNext(key_, fetcher, config); 24013 }; 24014 24015const BUILT_IN_MIDDLEWARE = use.concat(middleware); 24016 24017// It's tricky to pass generic types as parameters, so we just directly override 24018// the types here. 24019const withArgs = (hook)=>{ 24020 return function useSWRArgs(...args) { 24021 // Get the default and inherited configuration. 24022 const fallbackConfig = useSWRConfig(); 24023 // Normalize arguments. 24024 const [key, fn, _config] = normalize(args); 24025 // Merge configurations. 24026 const config = mergeConfigs(fallbackConfig, _config); 24027 // Apply middleware 24028 let next = hook; 24029 const { use } = config; 24030 const middleware = (use || []).concat(BUILT_IN_MIDDLEWARE); 24031 for(let i = middleware.length; i--;){ 24032 next = middleware[i](next); 24033 } 24034 return next(key, fn || config.fetcher || null, config); 24035 }; 24036}; 24037 24038// Add a callback function to a list of keyed callback functions and return 24039// the unsubscribe function. 24040const subscribeCallback = (key, callbacks, callback)=>{ 24041 const keyedRevalidators = callbacks[key] || (callbacks[key] = []); 24042 keyedRevalidators.push(callback); 24043 return ()=>{ 24044 const index = keyedRevalidators.indexOf(callback); 24045 if (index >= 0) { 24046 // O(1): faster than splice 24047 keyedRevalidators[index] = keyedRevalidators[keyedRevalidators.length - 1]; 24048 keyedRevalidators.pop(); 24049 } 24050 }; 24051}; 24052 24053// Create a custom hook with a middleware 24054const withMiddleware = (useSWR, middleware)=>{ 24055 return (...args)=>{ 24056 const [key, fn, config] = normalize(args); 24057 const uses = (config.use || []).concat(middleware); 24058 return useSWR(key, fn, { 24059 ...config, 24060 use: uses 24061 }); 24062 }; 24063}; 24064 24065setupDevTools(); 24066 24067 24068 24069;// CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/swr/dist/index/index.mjs 24070 24071 24072 24073 24074 24075// Shared state between server components and client components 24076const index_noop = ()=>{}; 24077// Using noop() as the undefined value as undefined can be replaced 24078// by something else. Prettier ignore and extra parentheses are necessary here 24079// to ensure that tsc doesn't remove the __NOINLINE__ comment. 24080// prettier-ignore 24081const index_UNDEFINED = /*#__NOINLINE__*/ index_noop(); 24082const index_OBJECT = (/* unused pure expression or super */ null && (Object)); 24083const index_isUndefined = (v)=>v === index_UNDEFINED; 24084const index_isFunction = (v)=>typeof v == 'function'; 24085 24086// use WeakMap to store the object->key mapping 24087// so the objects can be garbage collected. 24088// WeakMap uses a hashtable under the hood, so the lookup 24089// complexity is almost O(1). 24090const index_table = new WeakMap(); 24091const index_getTypeName = (value)=>index_OBJECT.prototype.toString.call(value); 24092const index_isObjectTypeName = (typeName, type)=>typeName === `[object ${type}]`; 24093// counter of the key 24094let index_counter = 0; 24095// A stable hash implementation that supports: 24096// - Fast and ensures unique hash properties 24097// - Handles unserializable values 24098// - Handles object key ordering 24099// - Generates short results 24100// 24101// This is not a serialization function, and the result is not guaranteed to be 24102// parsable. 24103const index_stableHash = (arg)=>{ 24104 const type = typeof arg; 24105 const typeName = index_getTypeName(arg); 24106 const isDate = index_isObjectTypeName(typeName, 'Date'); 24107 const isRegex = index_isObjectTypeName(typeName, 'RegExp'); 24108 const isPlainObject = index_isObjectTypeName(typeName, 'Object'); 24109 let result; 24110 let index; 24111 if (index_OBJECT(arg) === arg && !isDate && !isRegex) { 24112 // Object/function, not null/date/regexp. Use WeakMap to store the id first. 24113 // If it's already hashed, directly return the result. 24114 result = index_table.get(arg); 24115 if (result) return result; 24116 // Store the hash first for circular reference detection before entering the 24117 // recursive `stableHash` calls. 24118 // For other objects like set and map, we use this id directly as the hash. 24119 result = ++index_counter + '~'; 24120 index_table.set(arg, result); 24121 if (Array.isArray(arg)) { 24122 // Array. 24123 result = '@'; 24124 for(index = 0; index < arg.length; index++){
vendor: 4,430 bytes, lines 24125-24237
24125 result += index_stableHash(arg[index]) + ','; 24126 } 24127 index_table.set(arg, result); 24128 } 24129 if (isPlainObject) { 24130 // Object, sort keys. 24131 result = '#'; 24132 const keys = index_OBJECT.keys(arg).sort(); 24133 while(!index_isUndefined(index = keys.pop())){ 24134 if (!index_isUndefined(arg[index])) { 24135 result += index + ':' + index_stableHash(arg[index]) + ','; 24136 } 24137 } 24138 index_table.set(arg, result); 24139 } 24140 } else { 24141 result = isDate ? arg.toJSON() : type == 'symbol' ? arg.toString() : type == 'string' ? JSON.stringify(arg) : '' + arg; 24142 } 24143 return result; 24144}; 24145 24146const index_serialize = (key)=>{ 24147 if (index_isFunction(key)) { 24148 try { 24149 key = key(); 24150 } catch (err) { 24151 // dependencies not ready 24152 key = ''; 24153 } 24154 } 24155 // Use the original key as the argument of fetcher. This can be a string or an 24156 // array of values. 24157 const args = key; 24158 // If key is not falsy, or not an empty array, hash it. 24159 key = typeof key == 'string' ? key : (Array.isArray(key) ? key.length : key) ? index_stableHash(key) : ''; 24160 return [ 24161 key, 24162 args 24163 ]; 24164}; 24165 24166const unstable_serialize = (key)=>index_serialize(key)[0]; 24167 24168/// <reference types="react/experimental" /> 24169const index_use = react.use || // This extra generic is to avoid TypeScript mixing up the generic and JSX sytax 24170// and emitting an error. 24171// We assume that this is only for the `use(thenable)` case, not `use(context)`. 24172// https://github.com/facebook/react/blob/aed00dacfb79d17c53218404c52b1c7aa59c4a89/packages/react-server/src/ReactFizzThenable.js#L45 24173((thenable)=>{ 24174 switch(thenable.status){ 24175 case 'pending': 24176 throw thenable; 24177 case 'fulfilled': 24178 return thenable.value; 24179 case 'rejected': 24180 throw thenable.reason; 24181 default: 24182 thenable.status = 'pending'; 24183 thenable.then((v)=>{ 24184 thenable.status = 'fulfilled'; 24185 thenable.value = v; 24186 }, (e)=>{ 24187 thenable.status = 'rejected'; 24188 thenable.reason = e; 24189 }); 24190 throw thenable; 24191 } 24192}); 24193const WITH_DEDUPE = { 24194 dedupe: true 24195}; 24196// React can only unwrap a thenable synchronously when it has React's thenable 24197// status fields, so this fulfilled no-op keeps Suspense paths from waiting. 24198const resolvedUndef = Promise.resolve(UNDEFINED); 24199// @ts-ignore modify react promise status 24200resolvedUndef.status = 'fulfilled'; 24201// @ts-ignore modify react promise value 24202resolvedUndef.value = UNDEFINED; 24203const sub = ()=>noop; 24204/** 24205 * The core implementation of the useSWR hook. 24206 * 24207 * This is the main handler function that implements all SWR functionality including 24208 * data fetching, caching, revalidation, error handling, and state management. 24209 * It manages the complete lifecycle of SWR requests from initialization through 24210 * cleanup. 24211 * 24212 * Key responsibilities: 24213 * - Key serialization and normalization 24214 * - Cache state management and synchronization 24215 * - Automatic and manual revalidation 24216 * - Error handling and retry logic 24217 * - Suspense integration 24218 * - Loading state management 24219 * - Effect cleanup and memory management 24220 * 24221 * @template Data - The type of data returned by the fetcher 24222 * @template Error - The type of error that can be thrown 24223 * 24224 * @param _key - The SWR key (string, array, object, function, or falsy) 24225 * @param fetcher - The fetcher function to retrieve data, or null to disable fetching 24226 * @param config - Complete SWR configuration object with both public and internal options 24227 * 24228 * @returns SWRResponse object containing data, error, mutate function, and loading states 24229 * 24230 * @internal This is the internal implementation. Use `useSWR` instead. 24231 */ const useSWRHandler = (_key, fetcher, config)=>{ 24232 const { cache, compare, suspense, fallbackData, revalidateOnMount, revalidateIfStale, refreshInterval, refreshWhenHidden, refreshWhenOffline, keepPreviousData, strictServerPrefetchWarning } = config; 24233 const [EVENT_REVALIDATORS, MUTATION, FETCH, PRELOAD] = config_context_12s_fLme8m6q_SWRGlobalState.get(cache); 24234 // `key` is the identifier of the SWR internal state, 24235 // `fnArg` is the argument/arguments parsed from the key, which will be passed 24236 // to the fetcher. 24237 // All of them are derived from `_key`.
vendor: 4,437 bytes, lines 24238-24323
24238 const [key, fnArg] = config_context_12s_fLme8m6q_serialize(_key); 24239 // If it's the initial render of this hook. 24240 const initialMountedRef = (0,react.useRef)(false); 24241 // If the hook is unmounted already. This will be used to prevent some effects 24242 // to be called after unmounting. 24243 const unmountedRef = (0,react.useRef)(false); 24244 // Refs to keep the key and config. 24245 const keyRef = (0,react.useRef)(key); 24246 const fetcherRef = (0,react.useRef)(fetcher); 24247 const configRef = (0,react.useRef)(config); 24248 const getConfig = ()=>configRef.current; 24249 const isActive = ()=>getConfig().isVisible() && getConfig().isOnline(); 24250 const [getCache, setCache, subscribeCache, getInitialCache] = createCacheHelper(cache, key); 24251 const stateDependencies = (0,react.useRef)({}).current; 24252 // Resolve the fallback data from either the inline option, or the global provider. 24253 // If it's a promise, we simply let React suspend and resolve it for us. 24254 const fallback = isUndefined(fallbackData) ? isUndefined(config.fallback) ? UNDEFINED : config.fallback[key] : fallbackData; 24255 const isEqual = (prev, current)=>{ 24256 for(const _ in stateDependencies){ 24257 const t = _; 24258 if (t === 'data') { 24259 if (!compare(prev[t], current[t])) { 24260 if (!isUndefined(prev[t])) { 24261 return false; 24262 } 24263 if (!compare(returnedData, current[t])) { 24264 return false; 24265 } 24266 } 24267 } else { 24268 if (current[t] !== prev[t]) { 24269 return false; 24270 } 24271 } 24272 } 24273 return true; 24274 }; 24275 const isInitialMount = !initialMountedRef.current; 24276 const getSnapshot = (0,react.useMemo)(()=>{ 24277 const cachedData = getCache(); 24278 const initialData = getInitialCache(); 24279 const getSelectedCache = (state)=>{ 24280 // We only select the needed fields from the state. 24281 const snapshot = mergeObjects(state); 24282 delete snapshot._k; 24283 const shouldStartRequest = (()=>{ 24284 if (!key) return false; 24285 if (!fetcher) return false; 24286 // If it's paused, we skip revalidation. 24287 if (getConfig().isPaused()) return false; 24288 // If `revalidateOnMount` is set, we take the value directly. 24289 if (isInitialMount && !isUndefined(revalidateOnMount)) return revalidateOnMount; 24290 const data = !isUndefined(fallback) ? fallback : snapshot.data; 24291 if (suspense) return isUndefined(data) || revalidateIfStale; 24292 return isUndefined(data) || revalidateIfStale; 24293 })(); 24294 if (!shouldStartRequest) { 24295 return snapshot; 24296 } 24297 return { 24298 isValidating: true, 24299 isLoading: true, 24300 ...snapshot 24301 }; 24302 }; 24303 const clientSnapshot = getSelectedCache(cachedData); 24304 const serverSnapshot = cachedData === initialData ? clientSnapshot : getSelectedCache(initialData); 24305 // To make sure that we are returning the same object reference to avoid 24306 // unnecessary re-renders, we keep the previous snapshot and use deep 24307 // comparison to check if we need to return a new one. 24308 let memorizedSnapshot = clientSnapshot; 24309 return [ 24310 ()=>{ 24311 const newSnapshot = getSelectedCache(getCache()); 24312 const compareResult = isEqual(newSnapshot, memorizedSnapshot); 24313 if (compareResult) { 24314 // Mentally, we should always return the `memorizedSnapshot` here 24315 // as there's no change between the new and old snapshots. 24316 // However, since the `isEqual` function only compares selected fields, 24317 // the values of the unselected fields might be changed. That's 24318 // simply because we didn't track them. 24319 // To support the case in https://github.com/vercel/swr/pull/2576, 24320 // we need to update these fields in the `memorizedSnapshot` too 24321 // with direct mutations to ensure the snapshot is always up-to-date 24322 // even for the unselected fields, but only trigger re-renders when 24323 // the selected fields are changed.
24324 memorizedSnapshot.data = newSnapshot.data; 24325 memorizedSnapshot.isLoading = newSnapshot.isLoading; 24326 memorizedSnapshot.isValidating = newSnapshot.isValidating; 24327 memorizedSnapshot.error = newSnapshot.error; 24328 return memorizedSnapshot; 24329 } else { 24330 memorizedSnapshot = newSnapshot; 24331 return newSnapshot; 24332 } 24333 }, 24334 ()=>serverSnapshot 24335 ]; 24336 // eslint-disable-next-line react-hooks/exhaustive-deps 24337 }, [ 24338 cache, 24339 key 24340 ]); 24341 // Get the current state that SWR should return. 24342 const cached = (0,shim.useSyncExternalStore)((0,react.useCallback)((callback)=>subscribeCache(key, (current, prev)=>{ 24343 if (!isEqual(prev, current)) callback(); 24344 }), // eslint-disable-next-line react-hooks/exhaustive-deps 24345 [ 24346 cache, 24347 key 24348 ]), getSnapshot[0], getSnapshot[1]); 24349 const hasRevalidator = EVENT_REVALIDATORS[key] && EVENT_REVALIDATORS[key].length > 0; 24350 const cachedData = cached.data; 24351 const data = isUndefined(cachedData) ? fallback && isPromiseLike(fallback) ? index_use(fallback) : fallback : cachedData; 24352 const error = cached.error; 24353 // Use a ref to store previously returned data. Use the initial data as its initial value. 24354 const laggyDataRef = (0,react.useRef)(data); 24355 const returnedData = keepPreviousData ? isUndefined(cachedData) ? isUndefined(laggyDataRef.current) ? data : laggyDataRef.current : cachedData : data; 24356 const hasKeyButNoData = key && isUndefined(data); 24357 const hydrationRef = (0,react.useRef)(null); 24358 // Note: the conditionally hook call is fine because the environment 24359 // `IS_SERVER` never changes. 24360 // @ts-expect-error -- use hydrationRef directly 24361 !config_context_12s_fLme8m6q_IS_SERVER && // getServerSnapshot is only called during hydration 24362 // eslint-disable-next-line react-hooks/rules-of-hooks 24363 (0,shim.useSyncExternalStore)(sub, ()=>{ 24364 hydrationRef.current = false; 24365 return hydrationRef; 24366 }, ()=>{ 24367 hydrationRef.current = true; 24368 return hydrationRef; 24369 }); 24370 const isHydration = hydrationRef.current; 24371 // During the initial SSR render, warn if the key has no data pre-fetched via: 24372 // - fallback data 24373 // - preload calls 24374 // - initial data from the cache provider 24375 // We only warn once for each key during Hydration. 24376 if (strictServerPrefetchWarning && isHydration && !suspense && hasKeyButNoData) { 24377 console.warn(`Missing pre-initiated data for serialized key "${key}" during server-side rendering. Data fetching should be initiated on the server and provided to SWR via fallback data. You can set "strictServerPrefetchWarning: false" to disable this warning.`); 24378 } 24379 // Resolve the default validating state: 24380 // If it's able to validate, and it should revalidate when mount, this will be true. 24381 // - Suspense mode and there's stale data for the initial render. 24382 // - Not suspense mode and there is no fallback data and `revalidateIfStale` is enabled. 24383 // - `revalidateIfStale` is enabled but `data` is not defined. 24384 const shouldDoInitialRevalidation = (()=>{ 24385 if (!key || !fetcher) return false; 24386 // If it's paused, we skip revalidation. 24387 if (getConfig().isPaused()) return false; 24388 // if a key already has revalidators and also has error, we should not trigger revalidation 24389 if (hasRevalidator && !isUndefined(error)) return false; 24390 // If `revalidateOnMount` is set, we take the value directly. 24391 if (isInitialMount && !isUndefined(revalidateOnMount)) return revalidateOnMount; 24392 // Under suspense mode, it will always fetch on render if there is no 24393 // stale data so no need to revalidate immediately mount it again. 24394 // If data exists, only revalidate if `revalidateIfStale` is true. 24395 if (suspense) return isUndefined(data) ? false : revalidateIfStale; 24396 // If there is no stale data, we need to revalidate when mount; 24397 // If `revalidateIfStale` is set to true, we will always revalidate. 24398 return isUndefined(data) || revalidateIfStale; 24399 })(); 24400 const defaultValidatingState = isInitialMount && shouldDoInitialRevalidation; 24401 const isValidating = isUndefined(cached.isValidating) ? defaultValidatingState : cached.isValidating; 24402 const isLoading = isUndefined(cached.isLoading) ? defaultValidatingState : cached.isLoading; 24403 // The revalidation function is a carefully crafted wrapper of the original
vendor: 10,694 bytes, lines 24404-24638
24404 // `fetcher`, to correctly handle the many edge cases. 24405 const revalidate = (0,react.useCallback)(async (revalidateOpts)=>{ 24406 const currentFetcher = fetcherRef.current; 24407 if (!key || !currentFetcher || unmountedRef.current || getConfig().isPaused()) { 24408 return false; 24409 } 24410 let newData; 24411 let startAt; 24412 let loading = true; 24413 const opts = revalidateOpts || {}; 24414 // If there is no ongoing concurrent request, or `dedupe` is not set, a 24415 // new request should be initiated. 24416 const shouldStartNewRequest = !FETCH[key] || !opts.dedupe; 24417 /* 24418 For React 17 24419 Do unmount check for calls: 24420 If key has changed during the revalidation, or the component has been 24421 unmounted, old dispatch and old event callbacks should not take any 24422 effect 24423 24424 For React 18 24425 only check if key has changed 24426 https://github.com/reactwg/react-18/discussions/82 24427 */ const callbackSafeguard = ()=>{ 24428 if (IS_REACT_LEGACY) { 24429 return !unmountedRef.current && key === keyRef.current && initialMountedRef.current; 24430 } 24431 return key === keyRef.current; 24432 }; 24433 // The final state object when the request finishes. 24434 const finalState = { 24435 isValidating: false, 24436 isLoading: false 24437 }; 24438 const finishRequestAndUpdateState = ()=>{ 24439 setCache(finalState); 24440 }; 24441 const cleanupState = ()=>{ 24442 // Check if it's still the same request before deleting it. 24443 const requestInfo = FETCH[key]; 24444 if (requestInfo && requestInfo[1] === startAt) { 24445 delete FETCH[key]; 24446 } 24447 }; 24448 // Start fetching. Change the `isValidating` state, update the cache. 24449 const initialState = { 24450 isValidating: true 24451 }; 24452 // It is in the `isLoading` state, if and only if there is no cached data. 24453 // This bypasses fallback data and laggy data. 24454 if (isUndefined(getCache().data)) { 24455 initialState.isLoading = true; 24456 } 24457 try { 24458 if (shouldStartNewRequest) { 24459 setCache(initialState); 24460 // If no cache is being rendered currently (it shows a blank page), 24461 // we trigger the loading slow event. 24462 if (config.loadingTimeout && isUndefined(getCache().data)) { 24463 setTimeout(()=>{ 24464 if (loading && callbackSafeguard()) { 24465 getConfig().onLoadingSlow(key, config); 24466 } 24467 }, config.loadingTimeout); 24468 } 24469 // Start the request and save the timestamp. 24470 // Key must be truthy if entering here. 24471 FETCH[key] = [ 24472 currentFetcher(fnArg), 24473 getTimestamp() 24474 ]; 24475 } 24476 // Wait until the ongoing request is done. Deduplication is also 24477 // considered here. 24478 ; 24479 [newData, startAt] = FETCH[key]; 24480 newData = await newData; 24481 if (shouldStartNewRequest) { 24482 // If the request isn't interrupted, clean it up after the 24483 // deduplication interval. 24484 setTimeout(cleanupState, config.dedupingInterval); 24485 } 24486 // If there're other ongoing request(s), started after the current one, 24487 // we need to ignore the current one to avoid possible race conditions: 24488 // req1------------------>res1 (current one) 24489 // req2---------------->res2 24490 // the request that fired later will always be kept. 24491 // The timestamp maybe be `undefined` or a number 24492 if (!FETCH[key] || FETCH[key][1] !== startAt) { 24493 if (shouldStartNewRequest) { 24494 if (callbackSafeguard()) { 24495 getConfig().onDiscarded(key); 24496 } 24497 } 24498 return false; 24499 } 24500 // Clear error. 24501 finalState.error = UNDEFINED; 24502 // If there're other mutations(s), that overlapped with the current revalidation: 24503 // case 1: 24504 // req------------------>res 24505 // mutate------>end 24506 // case 2: 24507 // req------------>res 24508 // mutate------>end 24509 // case 3: 24510 // req------------------>res 24511 // mutate-------...----------> 24512 // we have to ignore the revalidation result (res) because it's no longer fresh. 24513 // meanwhile, a new revalidation should be triggered when the mutation ends. 24514 const mutationInfo = MUTATION[key]; 24515 if (!isUndefined(mutationInfo) && // case 1 24516 (startAt <= mutationInfo[0] || // case 2 24517 startAt <= mutationInfo[1] || // case 3 24518 mutationInfo[1] === 0)) { 24519 finishRequestAndUpdateState(); 24520 if (shouldStartNewRequest) { 24521 if (callbackSafeguard()) { 24522 getConfig().onDiscarded(key); 24523 } 24524 } 24525 return false; 24526 } 24527 // Deep compare with the latest state to avoid extra re-renders. 24528 // For local state, compare and assign. 24529 const cacheData = getCache().data; 24530 // Since the compare fn could be custom fn 24531 // cacheData might be different from newData even when compare fn returns True 24532 finalState.data = compare(cacheData, newData) ? cacheData : newData; 24533 // Trigger the successful callback if it's the original request. 24534 if (shouldStartNewRequest) { 24535 if (callbackSafeguard()) { 24536 getConfig().onSuccess(newData, key, config); 24537 } 24538 } 24539 } catch (err) { 24540 cleanupState(); 24541 const currentConfig = getConfig(); 24542 const { shouldRetryOnError } = currentConfig; 24543 // Not paused, we continue handling the error. Otherwise, discard it. 24544 if (!currentConfig.isPaused()) { 24545 // Get a new error, don't use deep comparison for errors. 24546 finalState.error = err; 24547 // Error event and retry logic. Only for the actual request, not 24548 // deduped ones. 24549 if (shouldStartNewRequest && callbackSafeguard()) { 24550 currentConfig.onError(err, key, currentConfig); 24551 if (shouldRetryOnError === true || isFunction(shouldRetryOnError) && shouldRetryOnError(err)) { 24552 if (!getConfig().revalidateOnFocus || !getConfig().revalidateOnReconnect || isActive()) { 24553 // If it's inactive, stop. It will auto-revalidate when 24554 // refocusing or reconnecting. 24555 // When retrying, deduplication is always enabled. 24556 currentConfig.onErrorRetry(err, key, currentConfig, (_opts)=>{ 24557 const revalidators = EVENT_REVALIDATORS[key]; 24558 if (revalidators && revalidators[0]) { 24559 revalidators[0](ERROR_REVALIDATE_EVENT, _opts); 24560 } 24561 }, { 24562 retryCount: (opts.retryCount || 0) + 1, 24563 dedupe: true 24564 }); 24565 } 24566 } 24567 } 24568 } 24569 } 24570 // Mark loading as stopped. 24571 loading = false; 24572 // Update the current hook's state. 24573 finishRequestAndUpdateState(); 24574 return true; 24575 }, // `setState` is immutable, and `eventsCallback`, `fnArg`, and 24576 // `keyValidating` are depending on `key`, so we can exclude them from 24577 // the deps array. 24578 // 24579 // FIXME: 24580 // `fn` and `config` might be changed during the lifecycle, 24581 // but they might be changed every render like this. 24582 // `useSWR('key', () => fetch('/api/'), { suspense: true })` 24583 // So we omit the values from the deps array 24584 // even though it might cause unexpected behaviors. 24585 // eslint-disable-next-line react-hooks/exhaustive-deps 24586 [ 24587 key, 24588 cache 24589 ]); 24590 // Similar to the global mutate but bound to the current cache and key. 24591 // `cache` isn't allowed to change during the lifecycle. 24592 const boundMutate = (0,react.useCallback)(// Use callback to make sure `keyRef.current` returns latest result every time 24593 (...args)=>{ 24594 return internalMutate(cache, keyRef.current, ...args); 24595 }, // eslint-disable-next-line react-hooks/exhaustive-deps 24596 []); 24597 // The logic for updating refs. 24598 useIsomorphicLayoutEffect(()=>{ 24599 fetcherRef.current = fetcher; 24600 configRef.current = config; 24601 // Handle laggy data updates. If there's cached data of the current key, 24602 // it'll be the correct reference. 24603 if (!isUndefined(cachedData)) { 24604 laggyDataRef.current = cachedData; 24605 } 24606 }); 24607 // After mounted or key changed. 24608 useIsomorphicLayoutEffect(()=>{ 24609 if (!key) return; 24610 const softRevalidate = revalidate.bind(UNDEFINED, WITH_DEDUPE); 24611 let nextFocusRevalidatedAt = 0; 24612 if (getConfig().revalidateOnFocus) { 24613 const initNow = Date.now(); 24614 nextFocusRevalidatedAt = initNow + getConfig().focusThrottleInterval; 24615 } 24616 // Expose revalidators to global event listeners. So we can trigger 24617 // revalidation from the outside. 24618 const onRevalidate = (type, opts = {})=>{ 24619 if (type == FOCUS_EVENT) { 24620 const now = Date.now(); 24621 if (getConfig().revalidateOnFocus && now > nextFocusRevalidatedAt && isActive()) { 24622 nextFocusRevalidatedAt = now + getConfig().focusThrottleInterval; 24623 softRevalidate(); 24624 } 24625 } else if (type == RECONNECT_EVENT) { 24626 if (getConfig().revalidateOnReconnect && isActive()) { 24627 softRevalidate(); 24628 } 24629 } else if (type == MUTATE_EVENT) { 24630 return revalidate(); 24631 } else if (type == ERROR_REVALIDATE_EVENT) { 24632 return revalidate(opts); 24633 } 24634 return; 24635 }; 24636 const unsubEvents = subscribeCallback(key, EVENT_REVALIDATORS, onRevalidate); 24637 // Mark the component as mounted and update corresponding refs. 24638 unmountedRef.current = false;
vendor: 5,158 bytes, lines 24639-24787
24639 keyRef.current = key; 24640 initialMountedRef.current = true; 24641 // Keep the original key in the cache. 24642 setCache({ 24643 _k: fnArg 24644 }); 24645 // Trigger a revalidation 24646 if (shouldDoInitialRevalidation) { 24647 // Performance optimization: if a request is already in progress for this key, 24648 // skip the revalidation to avoid redundant work 24649 if (!FETCH[key]) { 24650 if (isUndefined(data) || config_context_12s_fLme8m6q_IS_SERVER) { 24651 // Revalidate immediately. 24652 softRevalidate(); 24653 } else { 24654 // Delay the revalidate if we have data to return so we won't block 24655 // rendering. 24656 rAF(softRevalidate); 24657 } 24658 } 24659 } 24660 return ()=>{ 24661 // Mark it as unmounted. 24662 unmountedRef.current = true; 24663 unsubEvents(); 24664 }; 24665 }, [ 24666 key 24667 ]); 24668 // Polling 24669 useIsomorphicLayoutEffect(()=>{ 24670 let timer; 24671 function next() { 24672 // Use the passed interval 24673 // ...or invoke the function with the updated data to get the interval 24674 const interval = isFunction(refreshInterval) ? refreshInterval(getCache().data) : refreshInterval; 24675 // We only start the next interval if `refreshInterval` is not 0, and: 24676 // - `force` is true, which is the start of polling 24677 // - or `timer` is not 0, which means the effect wasn't canceled 24678 if (interval && timer !== -1) { 24679 timer = setTimeout(execute, interval); 24680 } 24681 } 24682 function execute() { 24683 // Check if it's OK to execute: 24684 // Only revalidate when the page is visible, online, and not errored. 24685 if (!getCache().error && (refreshWhenHidden || getConfig().isVisible()) && (refreshWhenOffline || getConfig().isOnline())) { 24686 revalidate(WITH_DEDUPE).then(next); 24687 } else { 24688 // Schedule the next interval to check again. 24689 next(); 24690 } 24691 } 24692 next(); 24693 return ()=>{ 24694 if (timer) { 24695 clearTimeout(timer); 24696 timer = -1; 24697 } 24698 }; 24699 }, [ 24700 refreshInterval, 24701 refreshWhenHidden, 24702 refreshWhenOffline, 24703 key 24704 ]); 24705 // Display debug info in React DevTools. 24706 (0,react.useDebugValue)(returnedData); 24707 // In Suspense mode, we can't return the empty `data` state. 24708 // If there is an `error`, the `error` needs to be thrown to the error boundary. 24709 // If there is no `error`, the `revalidation` promise needs to be thrown to 24710 // the suspense boundary. 24711 if (suspense) { 24712 // SWR should throw when trying to use Suspense on the server with React 18, 24713 // without providing any fallback data. This causes hydration errors. See: 24714 // https://github.com/vercel/swr/issues/1832 24715 if (!IS_REACT_LEGACY && config_context_12s_fLme8m6q_IS_SERVER && hasKeyButNoData) { 24716 throw new Error('Fallback data is required when using Suspense in SSR.'); 24717 } 24718 // Always update fetcher and config refs even with the Suspense mode. 24719 if (hasKeyButNoData) { 24720 fetcherRef.current = fetcher; 24721 configRef.current = config; 24722 unmountedRef.current = false; 24723 } 24724 const req = PRELOAD[key]; 24725 const mutateReq = !isUndefined(req) && hasKeyButNoData ? boundMutate(req) : resolvedUndef; 24726 index_use(mutateReq); 24727 if (!isUndefined(error) && hasKeyButNoData) { 24728 throw error; 24729 } 24730 const revalidation = hasKeyButNoData ? revalidate(WITH_DEDUPE) : resolvedUndef; 24731 if (!isUndefined(returnedData) && hasKeyButNoData) { 24732 // @ts-ignore modify react promise status 24733 revalidation.status = 'fulfilled'; 24734 // @ts-ignore modify react promise value 24735 revalidation.value = true; 24736 } 24737 index_use(revalidation); 24738 } 24739 const swrResponse = { 24740 mutate: boundMutate, 24741 get data () { 24742 stateDependencies.data = true; 24743 return returnedData; 24744 }, 24745 get error () { 24746 stateDependencies.error = true; 24747 return error; 24748 }, 24749 get isValidating () { 24750 stateDependencies.isValidating = true; 24751 return isValidating; 24752 }, 24753 get isLoading () { 24754 stateDependencies.isLoading = true; 24755 return isLoading; 24756 } 24757 }; 24758 return swrResponse; 24759}; 24760const index_SWRConfig = OBJECT.defineProperty(SWRConfig, 'defaultValue', { 24761 value: defaultConfig 24762}); 24763/** 24764 * A hook to fetch data. 24765 * 24766 * @see {@link https://swr.vercel.app} 24767 * 24768 * @example 24769 * ```jsx 24770 * import useSWR from 'swr' 24771 * function Profile() { 24772 * const { data, error, isLoading } = useSWR('/api/user', fetcher) 24773 * if (error) return <div>failed to load</div> 24774 * if (isLoading) return <div>loading...</div> 24775 * return <div>hello {data.name}!</div> 24776 * } 24777 * ``` 24778 */ const useSWR = withArgs(useSWRHandler); 24779 24780// useSWR 24781 24782 24783 24784 24785/***/ }) 24786 24787}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.