@ai-react-markdown/core 1.2.9 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -25
- package/dist/index.cjs +2293 -848
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +336 -19
- package/dist/index.d.ts +336 -19
- package/dist/index.js +2301 -858
- package/dist/index.js.map +1 -1
- package/package.json +20 -4
package/dist/index.cjs
CHANGED
|
@@ -31,16 +31,18 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
// src/index.tsx
|
|
32
32
|
var index_exports = {};
|
|
33
33
|
__export(index_exports, {
|
|
34
|
+
AIMarkdownDocuments: () => AIMarkdownDocuments,
|
|
34
35
|
AIMarkdownRenderDisplayOptimizeAbility: () => AIMarkdownRenderDisplayOptimizeAbility,
|
|
35
36
|
AIMarkdownRenderExtraSyntax: () => AIMarkdownRenderExtraSyntax,
|
|
36
37
|
default: () => index_default,
|
|
37
38
|
defaultAIMarkdownRenderConfig: () => defaultAIMarkdownRenderConfig,
|
|
38
39
|
useAIMarkdownMetadata: () => useAIMarkdownMetadata,
|
|
39
40
|
useAIMarkdownRenderState: () => useAIMarkdownRenderState,
|
|
41
|
+
useDocumentRegistry: () => useDocumentRegistry,
|
|
40
42
|
useStableValue: () => useStableValue
|
|
41
43
|
});
|
|
42
44
|
module.exports = __toCommonJS(index_exports);
|
|
43
|
-
var
|
|
45
|
+
var import_react10 = require("react");
|
|
44
46
|
|
|
45
47
|
// src/context.tsx
|
|
46
48
|
var import_react = require("react");
|
|
@@ -301,8 +303,8 @@ function getNative(object, key) {
|
|
|
301
303
|
var getNative_default = getNative;
|
|
302
304
|
|
|
303
305
|
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_Map.js
|
|
304
|
-
var
|
|
305
|
-
var Map_default =
|
|
306
|
+
var Map2 = getNative_default(root_default, "Map");
|
|
307
|
+
var Map_default = Map2;
|
|
306
308
|
|
|
307
309
|
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_nativeCreate.js
|
|
308
310
|
var nativeCreate = getNative_default(Object, "create");
|
|
@@ -473,18 +475,6 @@ Stack.prototype.has = stackHas_default;
|
|
|
473
475
|
Stack.prototype.set = stackSet_default;
|
|
474
476
|
var Stack_default = Stack;
|
|
475
477
|
|
|
476
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayEach.js
|
|
477
|
-
function arrayEach(array, iteratee) {
|
|
478
|
-
var index = -1, length = array == null ? 0 : array.length;
|
|
479
|
-
while (++index < length) {
|
|
480
|
-
if (iteratee(array[index], index, array) === false) {
|
|
481
|
-
break;
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
return array;
|
|
485
|
-
}
|
|
486
|
-
var arrayEach_default = arrayEach;
|
|
487
|
-
|
|
488
478
|
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_defineProperty.js
|
|
489
479
|
var defineProperty = (function() {
|
|
490
480
|
try {
|
|
@@ -511,47 +501,124 @@ function baseAssignValue(object, key, value) {
|
|
|
511
501
|
}
|
|
512
502
|
var baseAssignValue_default = baseAssignValue;
|
|
513
503
|
|
|
514
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
function assignValue(object, key, value) {
|
|
518
|
-
var objValue = object[key];
|
|
519
|
-
if (!(hasOwnProperty5.call(object, key) && eq_default(objValue, value)) || value === void 0 && !(key in object)) {
|
|
504
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_assignMergeValue.js
|
|
505
|
+
function assignMergeValue(object, key, value) {
|
|
506
|
+
if (value !== void 0 && !eq_default(object[key], value) || value === void 0 && !(key in object)) {
|
|
520
507
|
baseAssignValue_default(object, key, value);
|
|
521
508
|
}
|
|
522
509
|
}
|
|
523
|
-
var
|
|
510
|
+
var assignMergeValue_default = assignMergeValue;
|
|
524
511
|
|
|
525
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/
|
|
526
|
-
function
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
newValue = source[key];
|
|
535
|
-
}
|
|
536
|
-
if (isNew) {
|
|
537
|
-
baseAssignValue_default(object, key, newValue);
|
|
538
|
-
} else {
|
|
539
|
-
assignValue_default(object, key, newValue);
|
|
512
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_createBaseFor.js
|
|
513
|
+
function createBaseFor(fromRight) {
|
|
514
|
+
return function(object, iteratee, keysFunc) {
|
|
515
|
+
var index = -1, iterable = Object(object), props = keysFunc(object), length = props.length;
|
|
516
|
+
while (length--) {
|
|
517
|
+
var key = props[fromRight ? length : ++index];
|
|
518
|
+
if (iteratee(iterable[key], key, iterable) === false) {
|
|
519
|
+
break;
|
|
520
|
+
}
|
|
540
521
|
}
|
|
541
|
-
|
|
542
|
-
|
|
522
|
+
return object;
|
|
523
|
+
};
|
|
543
524
|
}
|
|
544
|
-
var
|
|
525
|
+
var createBaseFor_default = createBaseFor;
|
|
545
526
|
|
|
546
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
527
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseFor.js
|
|
528
|
+
var baseFor = createBaseFor_default();
|
|
529
|
+
var baseFor_default = baseFor;
|
|
530
|
+
|
|
531
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneBuffer.js
|
|
532
|
+
var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
|
|
533
|
+
var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
|
|
534
|
+
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
535
|
+
var Buffer2 = moduleExports ? root_default.Buffer : void 0;
|
|
536
|
+
var allocUnsafe = Buffer2 ? Buffer2.allocUnsafe : void 0;
|
|
537
|
+
function cloneBuffer(buffer, isDeep) {
|
|
538
|
+
if (isDeep) {
|
|
539
|
+
return buffer.slice();
|
|
551
540
|
}
|
|
541
|
+
var length = buffer.length, result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
|
|
542
|
+
buffer.copy(result);
|
|
552
543
|
return result;
|
|
553
544
|
}
|
|
554
|
-
var
|
|
545
|
+
var cloneBuffer_default = cloneBuffer;
|
|
546
|
+
|
|
547
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_Uint8Array.js
|
|
548
|
+
var Uint8Array2 = root_default.Uint8Array;
|
|
549
|
+
var Uint8Array_default = Uint8Array2;
|
|
550
|
+
|
|
551
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneArrayBuffer.js
|
|
552
|
+
function cloneArrayBuffer(arrayBuffer) {
|
|
553
|
+
var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
|
|
554
|
+
new Uint8Array_default(result).set(new Uint8Array_default(arrayBuffer));
|
|
555
|
+
return result;
|
|
556
|
+
}
|
|
557
|
+
var cloneArrayBuffer_default = cloneArrayBuffer;
|
|
558
|
+
|
|
559
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneTypedArray.js
|
|
560
|
+
function cloneTypedArray(typedArray, isDeep) {
|
|
561
|
+
var buffer = isDeep ? cloneArrayBuffer_default(typedArray.buffer) : typedArray.buffer;
|
|
562
|
+
return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
|
|
563
|
+
}
|
|
564
|
+
var cloneTypedArray_default = cloneTypedArray;
|
|
565
|
+
|
|
566
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_copyArray.js
|
|
567
|
+
function copyArray(source, array) {
|
|
568
|
+
var index = -1, length = source.length;
|
|
569
|
+
array || (array = Array(length));
|
|
570
|
+
while (++index < length) {
|
|
571
|
+
array[index] = source[index];
|
|
572
|
+
}
|
|
573
|
+
return array;
|
|
574
|
+
}
|
|
575
|
+
var copyArray_default = copyArray;
|
|
576
|
+
|
|
577
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseCreate.js
|
|
578
|
+
var objectCreate = Object.create;
|
|
579
|
+
var baseCreate = /* @__PURE__ */ (function() {
|
|
580
|
+
function object() {
|
|
581
|
+
}
|
|
582
|
+
return function(proto) {
|
|
583
|
+
if (!isObject_default(proto)) {
|
|
584
|
+
return {};
|
|
585
|
+
}
|
|
586
|
+
if (objectCreate) {
|
|
587
|
+
return objectCreate(proto);
|
|
588
|
+
}
|
|
589
|
+
object.prototype = proto;
|
|
590
|
+
var result = new object();
|
|
591
|
+
object.prototype = void 0;
|
|
592
|
+
return result;
|
|
593
|
+
};
|
|
594
|
+
})();
|
|
595
|
+
var baseCreate_default = baseCreate;
|
|
596
|
+
|
|
597
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_overArg.js
|
|
598
|
+
function overArg(func, transform) {
|
|
599
|
+
return function(arg) {
|
|
600
|
+
return func(transform(arg));
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
var overArg_default = overArg;
|
|
604
|
+
|
|
605
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getPrototype.js
|
|
606
|
+
var getPrototype = overArg_default(Object.getPrototypeOf, Object);
|
|
607
|
+
var getPrototype_default = getPrototype;
|
|
608
|
+
|
|
609
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_isPrototype.js
|
|
610
|
+
var objectProto6 = Object.prototype;
|
|
611
|
+
function isPrototype(value) {
|
|
612
|
+
var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto6;
|
|
613
|
+
return value === proto;
|
|
614
|
+
}
|
|
615
|
+
var isPrototype_default = isPrototype;
|
|
616
|
+
|
|
617
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_initCloneObject.js
|
|
618
|
+
function initCloneObject(object) {
|
|
619
|
+
return typeof object.constructor == "function" && !isPrototype_default(object) ? baseCreate_default(getPrototype_default(object)) : {};
|
|
620
|
+
}
|
|
621
|
+
var initCloneObject_default = initCloneObject;
|
|
555
622
|
|
|
556
623
|
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isObjectLike.js
|
|
557
624
|
function isObjectLike(value) {
|
|
@@ -568,12 +635,12 @@ var baseIsArguments_default = baseIsArguments;
|
|
|
568
635
|
|
|
569
636
|
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isArguments.js
|
|
570
637
|
var objectProto7 = Object.prototype;
|
|
571
|
-
var
|
|
638
|
+
var hasOwnProperty5 = objectProto7.hasOwnProperty;
|
|
572
639
|
var propertyIsEnumerable = objectProto7.propertyIsEnumerable;
|
|
573
640
|
var isArguments = baseIsArguments_default(/* @__PURE__ */ (function() {
|
|
574
641
|
return arguments;
|
|
575
642
|
})()) ? baseIsArguments_default : function(value) {
|
|
576
|
-
return isObjectLike_default(value) &&
|
|
643
|
+
return isObjectLike_default(value) && hasOwnProperty5.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
|
|
577
644
|
};
|
|
578
645
|
var isArguments_default = isArguments;
|
|
579
646
|
|
|
@@ -581,6 +648,25 @@ var isArguments_default = isArguments;
|
|
|
581
648
|
var isArray = Array.isArray;
|
|
582
649
|
var isArray_default = isArray;
|
|
583
650
|
|
|
651
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isLength.js
|
|
652
|
+
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
653
|
+
function isLength(value) {
|
|
654
|
+
return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
655
|
+
}
|
|
656
|
+
var isLength_default = isLength;
|
|
657
|
+
|
|
658
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isArrayLike.js
|
|
659
|
+
function isArrayLike(value) {
|
|
660
|
+
return value != null && isLength_default(value.length) && !isFunction_default(value);
|
|
661
|
+
}
|
|
662
|
+
var isArrayLike_default = isArrayLike;
|
|
663
|
+
|
|
664
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isArrayLikeObject.js
|
|
665
|
+
function isArrayLikeObject(value) {
|
|
666
|
+
return isObjectLike_default(value) && isArrayLike_default(value);
|
|
667
|
+
}
|
|
668
|
+
var isArrayLikeObject_default = isArrayLikeObject;
|
|
669
|
+
|
|
584
670
|
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/stubFalse.js
|
|
585
671
|
function stubFalse() {
|
|
586
672
|
return false;
|
|
@@ -588,30 +674,33 @@ function stubFalse() {
|
|
|
588
674
|
var stubFalse_default = stubFalse;
|
|
589
675
|
|
|
590
676
|
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isBuffer.js
|
|
591
|
-
var
|
|
592
|
-
var
|
|
593
|
-
var
|
|
594
|
-
var
|
|
595
|
-
var nativeIsBuffer =
|
|
677
|
+
var freeExports2 = typeof exports == "object" && exports && !exports.nodeType && exports;
|
|
678
|
+
var freeModule2 = freeExports2 && typeof module == "object" && module && !module.nodeType && module;
|
|
679
|
+
var moduleExports2 = freeModule2 && freeModule2.exports === freeExports2;
|
|
680
|
+
var Buffer3 = moduleExports2 ? root_default.Buffer : void 0;
|
|
681
|
+
var nativeIsBuffer = Buffer3 ? Buffer3.isBuffer : void 0;
|
|
596
682
|
var isBuffer = nativeIsBuffer || stubFalse_default;
|
|
597
683
|
var isBuffer_default = isBuffer;
|
|
598
684
|
|
|
599
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/
|
|
600
|
-
var
|
|
601
|
-
var
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
var
|
|
611
|
-
|
|
612
|
-
|
|
685
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isPlainObject.js
|
|
686
|
+
var objectTag = "[object Object]";
|
|
687
|
+
var funcProto3 = Function.prototype;
|
|
688
|
+
var objectProto8 = Object.prototype;
|
|
689
|
+
var funcToString3 = funcProto3.toString;
|
|
690
|
+
var hasOwnProperty6 = objectProto8.hasOwnProperty;
|
|
691
|
+
var objectCtorString = funcToString3.call(Object);
|
|
692
|
+
function isPlainObject(value) {
|
|
693
|
+
if (!isObjectLike_default(value) || baseGetTag_default(value) != objectTag) {
|
|
694
|
+
return false;
|
|
695
|
+
}
|
|
696
|
+
var proto = getPrototype_default(value);
|
|
697
|
+
if (proto === null) {
|
|
698
|
+
return true;
|
|
699
|
+
}
|
|
700
|
+
var Ctor = hasOwnProperty6.call(proto, "constructor") && proto.constructor;
|
|
701
|
+
return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString3.call(Ctor) == objectCtorString;
|
|
613
702
|
}
|
|
614
|
-
var
|
|
703
|
+
var isPlainObject_default = isPlainObject;
|
|
615
704
|
|
|
616
705
|
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsTypedArray.js
|
|
617
706
|
var argsTag2 = "[object Arguments]";
|
|
@@ -622,7 +711,7 @@ var errorTag = "[object Error]";
|
|
|
622
711
|
var funcTag2 = "[object Function]";
|
|
623
712
|
var mapTag = "[object Map]";
|
|
624
713
|
var numberTag = "[object Number]";
|
|
625
|
-
var
|
|
714
|
+
var objectTag2 = "[object Object]";
|
|
626
715
|
var regexpTag = "[object RegExp]";
|
|
627
716
|
var setTag = "[object Set]";
|
|
628
717
|
var stringTag = "[object String]";
|
|
@@ -640,7 +729,7 @@ var uint16Tag = "[object Uint16Array]";
|
|
|
640
729
|
var uint32Tag = "[object Uint32Array]";
|
|
641
730
|
var typedArrayTags = {};
|
|
642
731
|
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
|
|
643
|
-
typedArrayTags[argsTag2] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag2] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[
|
|
732
|
+
typedArrayTags[argsTag2] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag2] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag2] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
|
|
644
733
|
function baseIsTypedArray(value) {
|
|
645
734
|
return isObjectLike_default(value) && isLength_default(value.length) && !!typedArrayTags[baseGetTag_default(value)];
|
|
646
735
|
}
|
|
@@ -655,13 +744,13 @@ function baseUnary(func) {
|
|
|
655
744
|
var baseUnary_default = baseUnary;
|
|
656
745
|
|
|
657
746
|
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_nodeUtil.js
|
|
658
|
-
var
|
|
659
|
-
var
|
|
660
|
-
var
|
|
661
|
-
var freeProcess =
|
|
747
|
+
var freeExports3 = typeof exports == "object" && exports && !exports.nodeType && exports;
|
|
748
|
+
var freeModule3 = freeExports3 && typeof module == "object" && module && !module.nodeType && module;
|
|
749
|
+
var moduleExports3 = freeModule3 && freeModule3.exports === freeExports3;
|
|
750
|
+
var freeProcess = moduleExports3 && freeGlobal_default.process;
|
|
662
751
|
var nodeUtil = (function() {
|
|
663
752
|
try {
|
|
664
|
-
var types =
|
|
753
|
+
var types = freeModule3 && freeModule3.require && freeModule3.require("util").types;
|
|
665
754
|
if (types) {
|
|
666
755
|
return types;
|
|
667
756
|
}
|
|
@@ -676,78 +765,87 @@ var nodeIsTypedArray = nodeUtil_default && nodeUtil_default.isTypedArray;
|
|
|
676
765
|
var isTypedArray = nodeIsTypedArray ? baseUnary_default(nodeIsTypedArray) : baseIsTypedArray_default;
|
|
677
766
|
var isTypedArray_default = isTypedArray;
|
|
678
767
|
|
|
679
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
var isArr = isArray_default(value), isArg = !isArr && isArguments_default(value), isBuff = !isArr && !isArg && isBuffer_default(value), isType = !isArr && !isArg && !isBuff && isTypedArray_default(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes_default(value.length, String) : [], length = result.length;
|
|
684
|
-
for (var key in value) {
|
|
685
|
-
if ((inherited || hasOwnProperty7.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
|
|
686
|
-
(key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
|
|
687
|
-
isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
|
|
688
|
-
isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
|
|
689
|
-
isIndex_default(key, length)))) {
|
|
690
|
-
result.push(key);
|
|
691
|
-
}
|
|
768
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_safeGet.js
|
|
769
|
+
function safeGet(object, key) {
|
|
770
|
+
if (key === "constructor" && typeof object[key] === "function") {
|
|
771
|
+
return;
|
|
692
772
|
}
|
|
693
|
-
|
|
773
|
+
if (key == "__proto__") {
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
776
|
+
return object[key];
|
|
694
777
|
}
|
|
695
|
-
var
|
|
778
|
+
var safeGet_default = safeGet;
|
|
696
779
|
|
|
697
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/
|
|
780
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_assignValue.js
|
|
698
781
|
var objectProto9 = Object.prototype;
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_overArg.js
|
|
706
|
-
function overArg(func, transform) {
|
|
707
|
-
return function(arg) {
|
|
708
|
-
return func(transform(arg));
|
|
709
|
-
};
|
|
782
|
+
var hasOwnProperty7 = objectProto9.hasOwnProperty;
|
|
783
|
+
function assignValue(object, key, value) {
|
|
784
|
+
var objValue = object[key];
|
|
785
|
+
if (!(hasOwnProperty7.call(object, key) && eq_default(objValue, value)) || value === void 0 && !(key in object)) {
|
|
786
|
+
baseAssignValue_default(object, key, value);
|
|
787
|
+
}
|
|
710
788
|
}
|
|
711
|
-
var
|
|
712
|
-
|
|
713
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeys.js
|
|
714
|
-
var nativeKeys = overArg_default(Object.keys, Object);
|
|
715
|
-
var nativeKeys_default = nativeKeys;
|
|
789
|
+
var assignValue_default = assignValue;
|
|
716
790
|
|
|
717
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/
|
|
718
|
-
|
|
719
|
-
var
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
791
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_copyObject.js
|
|
792
|
+
function copyObject(source, props, object, customizer) {
|
|
793
|
+
var isNew = !object;
|
|
794
|
+
object || (object = {});
|
|
795
|
+
var index = -1, length = props.length;
|
|
796
|
+
while (++index < length) {
|
|
797
|
+
var key = props[index];
|
|
798
|
+
var newValue = customizer ? customizer(object[key], source[key], key, object, source) : void 0;
|
|
799
|
+
if (newValue === void 0) {
|
|
800
|
+
newValue = source[key];
|
|
801
|
+
}
|
|
802
|
+
if (isNew) {
|
|
803
|
+
baseAssignValue_default(object, key, newValue);
|
|
804
|
+
} else {
|
|
805
|
+
assignValue_default(object, key, newValue);
|
|
728
806
|
}
|
|
729
807
|
}
|
|
730
|
-
return
|
|
808
|
+
return object;
|
|
731
809
|
}
|
|
732
|
-
var
|
|
810
|
+
var copyObject_default = copyObject;
|
|
733
811
|
|
|
734
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/
|
|
735
|
-
function
|
|
736
|
-
|
|
812
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseTimes.js
|
|
813
|
+
function baseTimes(n, iteratee) {
|
|
814
|
+
var index = -1, result = Array(n);
|
|
815
|
+
while (++index < n) {
|
|
816
|
+
result[index] = iteratee(index);
|
|
817
|
+
}
|
|
818
|
+
return result;
|
|
737
819
|
}
|
|
738
|
-
var
|
|
820
|
+
var baseTimes_default = baseTimes;
|
|
739
821
|
|
|
740
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/
|
|
741
|
-
|
|
742
|
-
|
|
822
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_isIndex.js
|
|
823
|
+
var MAX_SAFE_INTEGER2 = 9007199254740991;
|
|
824
|
+
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
|
825
|
+
function isIndex(value, length) {
|
|
826
|
+
var type = typeof value;
|
|
827
|
+
length = length == null ? MAX_SAFE_INTEGER2 : length;
|
|
828
|
+
return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
|
|
743
829
|
}
|
|
744
|
-
var
|
|
830
|
+
var isIndex_default = isIndex;
|
|
745
831
|
|
|
746
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/
|
|
747
|
-
|
|
748
|
-
|
|
832
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayLikeKeys.js
|
|
833
|
+
var objectProto10 = Object.prototype;
|
|
834
|
+
var hasOwnProperty8 = objectProto10.hasOwnProperty;
|
|
835
|
+
function arrayLikeKeys(value, inherited) {
|
|
836
|
+
var isArr = isArray_default(value), isArg = !isArr && isArguments_default(value), isBuff = !isArr && !isArg && isBuffer_default(value), isType = !isArr && !isArg && !isBuff && isTypedArray_default(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes_default(value.length, String) : [], length = result.length;
|
|
837
|
+
for (var key in value) {
|
|
838
|
+
if ((inherited || hasOwnProperty8.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
|
|
839
|
+
(key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
|
|
840
|
+
isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
|
|
841
|
+
isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
|
|
842
|
+
isIndex_default(key, length)))) {
|
|
843
|
+
result.push(key);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
return result;
|
|
749
847
|
}
|
|
750
|
-
var
|
|
848
|
+
var arrayLikeKeys_default = arrayLikeKeys;
|
|
751
849
|
|
|
752
850
|
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeysIn.js
|
|
753
851
|
function nativeKeysIn(object) {
|
|
@@ -768,525 +866,21 @@ function baseKeysIn(object) {
|
|
|
768
866
|
if (!isObject_default(object)) {
|
|
769
867
|
return nativeKeysIn_default(object);
|
|
770
868
|
}
|
|
771
|
-
var isProto = isPrototype_default(object), result = [];
|
|
772
|
-
for (var key in object) {
|
|
773
|
-
if (!(key == "constructor" && (isProto || !hasOwnProperty9.call(object, key)))) {
|
|
774
|
-
result.push(key);
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
return result;
|
|
778
|
-
}
|
|
779
|
-
var baseKeysIn_default = baseKeysIn;
|
|
780
|
-
|
|
781
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/keysIn.js
|
|
782
|
-
function keysIn(object) {
|
|
783
|
-
return isArrayLike_default(object) ? arrayLikeKeys_default(object, true) : baseKeysIn_default(object);
|
|
784
|
-
}
|
|
785
|
-
var keysIn_default = keysIn;
|
|
786
|
-
|
|
787
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignIn.js
|
|
788
|
-
function baseAssignIn(object, source) {
|
|
789
|
-
return object && copyObject_default(source, keysIn_default(source), object);
|
|
790
|
-
}
|
|
791
|
-
var baseAssignIn_default = baseAssignIn;
|
|
792
|
-
|
|
793
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneBuffer.js
|
|
794
|
-
var freeExports3 = typeof exports == "object" && exports && !exports.nodeType && exports;
|
|
795
|
-
var freeModule3 = freeExports3 && typeof module == "object" && module && !module.nodeType && module;
|
|
796
|
-
var moduleExports3 = freeModule3 && freeModule3.exports === freeExports3;
|
|
797
|
-
var Buffer3 = moduleExports3 ? root_default.Buffer : void 0;
|
|
798
|
-
var allocUnsafe = Buffer3 ? Buffer3.allocUnsafe : void 0;
|
|
799
|
-
function cloneBuffer(buffer, isDeep) {
|
|
800
|
-
if (isDeep) {
|
|
801
|
-
return buffer.slice();
|
|
802
|
-
}
|
|
803
|
-
var length = buffer.length, result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
|
|
804
|
-
buffer.copy(result);
|
|
805
|
-
return result;
|
|
806
|
-
}
|
|
807
|
-
var cloneBuffer_default = cloneBuffer;
|
|
808
|
-
|
|
809
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_copyArray.js
|
|
810
|
-
function copyArray(source, array) {
|
|
811
|
-
var index = -1, length = source.length;
|
|
812
|
-
array || (array = Array(length));
|
|
813
|
-
while (++index < length) {
|
|
814
|
-
array[index] = source[index];
|
|
815
|
-
}
|
|
816
|
-
return array;
|
|
817
|
-
}
|
|
818
|
-
var copyArray_default = copyArray;
|
|
819
|
-
|
|
820
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayFilter.js
|
|
821
|
-
function arrayFilter(array, predicate) {
|
|
822
|
-
var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
|
|
823
|
-
while (++index < length) {
|
|
824
|
-
var value = array[index];
|
|
825
|
-
if (predicate(value, index, array)) {
|
|
826
|
-
result[resIndex++] = value;
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
return result;
|
|
830
|
-
}
|
|
831
|
-
var arrayFilter_default = arrayFilter;
|
|
832
|
-
|
|
833
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/stubArray.js
|
|
834
|
-
function stubArray() {
|
|
835
|
-
return [];
|
|
836
|
-
}
|
|
837
|
-
var stubArray_default = stubArray;
|
|
838
|
-
|
|
839
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getSymbols.js
|
|
840
|
-
var objectProto12 = Object.prototype;
|
|
841
|
-
var propertyIsEnumerable2 = objectProto12.propertyIsEnumerable;
|
|
842
|
-
var nativeGetSymbols = Object.getOwnPropertySymbols;
|
|
843
|
-
var getSymbols = !nativeGetSymbols ? stubArray_default : function(object) {
|
|
844
|
-
if (object == null) {
|
|
845
|
-
return [];
|
|
846
|
-
}
|
|
847
|
-
object = Object(object);
|
|
848
|
-
return arrayFilter_default(nativeGetSymbols(object), function(symbol) {
|
|
849
|
-
return propertyIsEnumerable2.call(object, symbol);
|
|
850
|
-
});
|
|
851
|
-
};
|
|
852
|
-
var getSymbols_default = getSymbols;
|
|
853
|
-
|
|
854
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_copySymbols.js
|
|
855
|
-
function copySymbols(source, object) {
|
|
856
|
-
return copyObject_default(source, getSymbols_default(source), object);
|
|
857
|
-
}
|
|
858
|
-
var copySymbols_default = copySymbols;
|
|
859
|
-
|
|
860
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayPush.js
|
|
861
|
-
function arrayPush(array, values) {
|
|
862
|
-
var index = -1, length = values.length, offset = array.length;
|
|
863
|
-
while (++index < length) {
|
|
864
|
-
array[offset + index] = values[index];
|
|
865
|
-
}
|
|
866
|
-
return array;
|
|
867
|
-
}
|
|
868
|
-
var arrayPush_default = arrayPush;
|
|
869
|
-
|
|
870
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getPrototype.js
|
|
871
|
-
var getPrototype = overArg_default(Object.getPrototypeOf, Object);
|
|
872
|
-
var getPrototype_default = getPrototype;
|
|
873
|
-
|
|
874
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getSymbolsIn.js
|
|
875
|
-
var nativeGetSymbols2 = Object.getOwnPropertySymbols;
|
|
876
|
-
var getSymbolsIn = !nativeGetSymbols2 ? stubArray_default : function(object) {
|
|
877
|
-
var result = [];
|
|
878
|
-
while (object) {
|
|
879
|
-
arrayPush_default(result, getSymbols_default(object));
|
|
880
|
-
object = getPrototype_default(object);
|
|
881
|
-
}
|
|
882
|
-
return result;
|
|
883
|
-
};
|
|
884
|
-
var getSymbolsIn_default = getSymbolsIn;
|
|
885
|
-
|
|
886
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_copySymbolsIn.js
|
|
887
|
-
function copySymbolsIn(source, object) {
|
|
888
|
-
return copyObject_default(source, getSymbolsIn_default(source), object);
|
|
889
|
-
}
|
|
890
|
-
var copySymbolsIn_default = copySymbolsIn;
|
|
891
|
-
|
|
892
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseGetAllKeys.js
|
|
893
|
-
function baseGetAllKeys(object, keysFunc, symbolsFunc) {
|
|
894
|
-
var result = keysFunc(object);
|
|
895
|
-
return isArray_default(object) ? result : arrayPush_default(result, symbolsFunc(object));
|
|
896
|
-
}
|
|
897
|
-
var baseGetAllKeys_default = baseGetAllKeys;
|
|
898
|
-
|
|
899
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeys.js
|
|
900
|
-
function getAllKeys(object) {
|
|
901
|
-
return baseGetAllKeys_default(object, keys_default, getSymbols_default);
|
|
902
|
-
}
|
|
903
|
-
var getAllKeys_default = getAllKeys;
|
|
904
|
-
|
|
905
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeysIn.js
|
|
906
|
-
function getAllKeysIn(object) {
|
|
907
|
-
return baseGetAllKeys_default(object, keysIn_default, getSymbolsIn_default);
|
|
908
|
-
}
|
|
909
|
-
var getAllKeysIn_default = getAllKeysIn;
|
|
910
|
-
|
|
911
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_DataView.js
|
|
912
|
-
var DataView = getNative_default(root_default, "DataView");
|
|
913
|
-
var DataView_default = DataView;
|
|
914
|
-
|
|
915
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_Promise.js
|
|
916
|
-
var Promise2 = getNative_default(root_default, "Promise");
|
|
917
|
-
var Promise_default = Promise2;
|
|
918
|
-
|
|
919
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_Set.js
|
|
920
|
-
var Set = getNative_default(root_default, "Set");
|
|
921
|
-
var Set_default = Set;
|
|
922
|
-
|
|
923
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_WeakMap.js
|
|
924
|
-
var WeakMap = getNative_default(root_default, "WeakMap");
|
|
925
|
-
var WeakMap_default = WeakMap;
|
|
926
|
-
|
|
927
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getTag.js
|
|
928
|
-
var mapTag2 = "[object Map]";
|
|
929
|
-
var objectTag2 = "[object Object]";
|
|
930
|
-
var promiseTag = "[object Promise]";
|
|
931
|
-
var setTag2 = "[object Set]";
|
|
932
|
-
var weakMapTag2 = "[object WeakMap]";
|
|
933
|
-
var dataViewTag2 = "[object DataView]";
|
|
934
|
-
var dataViewCtorString = toSource_default(DataView_default);
|
|
935
|
-
var mapCtorString = toSource_default(Map_default);
|
|
936
|
-
var promiseCtorString = toSource_default(Promise_default);
|
|
937
|
-
var setCtorString = toSource_default(Set_default);
|
|
938
|
-
var weakMapCtorString = toSource_default(WeakMap_default);
|
|
939
|
-
var getTag = baseGetTag_default;
|
|
940
|
-
if (DataView_default && getTag(new DataView_default(new ArrayBuffer(1))) != dataViewTag2 || Map_default && getTag(new Map_default()) != mapTag2 || Promise_default && getTag(Promise_default.resolve()) != promiseTag || Set_default && getTag(new Set_default()) != setTag2 || WeakMap_default && getTag(new WeakMap_default()) != weakMapTag2) {
|
|
941
|
-
getTag = function(value) {
|
|
942
|
-
var result = baseGetTag_default(value), Ctor = result == objectTag2 ? value.constructor : void 0, ctorString = Ctor ? toSource_default(Ctor) : "";
|
|
943
|
-
if (ctorString) {
|
|
944
|
-
switch (ctorString) {
|
|
945
|
-
case dataViewCtorString:
|
|
946
|
-
return dataViewTag2;
|
|
947
|
-
case mapCtorString:
|
|
948
|
-
return mapTag2;
|
|
949
|
-
case promiseCtorString:
|
|
950
|
-
return promiseTag;
|
|
951
|
-
case setCtorString:
|
|
952
|
-
return setTag2;
|
|
953
|
-
case weakMapCtorString:
|
|
954
|
-
return weakMapTag2;
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
return result;
|
|
958
|
-
};
|
|
959
|
-
}
|
|
960
|
-
var getTag_default = getTag;
|
|
961
|
-
|
|
962
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_initCloneArray.js
|
|
963
|
-
var objectProto13 = Object.prototype;
|
|
964
|
-
var hasOwnProperty10 = objectProto13.hasOwnProperty;
|
|
965
|
-
function initCloneArray(array) {
|
|
966
|
-
var length = array.length, result = new array.constructor(length);
|
|
967
|
-
if (length && typeof array[0] == "string" && hasOwnProperty10.call(array, "index")) {
|
|
968
|
-
result.index = array.index;
|
|
969
|
-
result.input = array.input;
|
|
970
|
-
}
|
|
971
|
-
return result;
|
|
972
|
-
}
|
|
973
|
-
var initCloneArray_default = initCloneArray;
|
|
974
|
-
|
|
975
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_Uint8Array.js
|
|
976
|
-
var Uint8Array2 = root_default.Uint8Array;
|
|
977
|
-
var Uint8Array_default = Uint8Array2;
|
|
978
|
-
|
|
979
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneArrayBuffer.js
|
|
980
|
-
function cloneArrayBuffer(arrayBuffer) {
|
|
981
|
-
var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
|
|
982
|
-
new Uint8Array_default(result).set(new Uint8Array_default(arrayBuffer));
|
|
983
|
-
return result;
|
|
984
|
-
}
|
|
985
|
-
var cloneArrayBuffer_default = cloneArrayBuffer;
|
|
986
|
-
|
|
987
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneDataView.js
|
|
988
|
-
function cloneDataView(dataView, isDeep) {
|
|
989
|
-
var buffer = isDeep ? cloneArrayBuffer_default(dataView.buffer) : dataView.buffer;
|
|
990
|
-
return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
|
|
991
|
-
}
|
|
992
|
-
var cloneDataView_default = cloneDataView;
|
|
993
|
-
|
|
994
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneRegExp.js
|
|
995
|
-
var reFlags = /\w*$/;
|
|
996
|
-
function cloneRegExp(regexp) {
|
|
997
|
-
var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
|
|
998
|
-
result.lastIndex = regexp.lastIndex;
|
|
999
|
-
return result;
|
|
1000
|
-
}
|
|
1001
|
-
var cloneRegExp_default = cloneRegExp;
|
|
1002
|
-
|
|
1003
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneSymbol.js
|
|
1004
|
-
var symbolProto = Symbol_default ? Symbol_default.prototype : void 0;
|
|
1005
|
-
var symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
|
|
1006
|
-
function cloneSymbol(symbol) {
|
|
1007
|
-
return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
|
|
1008
|
-
}
|
|
1009
|
-
var cloneSymbol_default = cloneSymbol;
|
|
1010
|
-
|
|
1011
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneTypedArray.js
|
|
1012
|
-
function cloneTypedArray(typedArray, isDeep) {
|
|
1013
|
-
var buffer = isDeep ? cloneArrayBuffer_default(typedArray.buffer) : typedArray.buffer;
|
|
1014
|
-
return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
|
|
1015
|
-
}
|
|
1016
|
-
var cloneTypedArray_default = cloneTypedArray;
|
|
1017
|
-
|
|
1018
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_initCloneByTag.js
|
|
1019
|
-
var boolTag2 = "[object Boolean]";
|
|
1020
|
-
var dateTag2 = "[object Date]";
|
|
1021
|
-
var mapTag3 = "[object Map]";
|
|
1022
|
-
var numberTag2 = "[object Number]";
|
|
1023
|
-
var regexpTag2 = "[object RegExp]";
|
|
1024
|
-
var setTag3 = "[object Set]";
|
|
1025
|
-
var stringTag2 = "[object String]";
|
|
1026
|
-
var symbolTag = "[object Symbol]";
|
|
1027
|
-
var arrayBufferTag2 = "[object ArrayBuffer]";
|
|
1028
|
-
var dataViewTag3 = "[object DataView]";
|
|
1029
|
-
var float32Tag2 = "[object Float32Array]";
|
|
1030
|
-
var float64Tag2 = "[object Float64Array]";
|
|
1031
|
-
var int8Tag2 = "[object Int8Array]";
|
|
1032
|
-
var int16Tag2 = "[object Int16Array]";
|
|
1033
|
-
var int32Tag2 = "[object Int32Array]";
|
|
1034
|
-
var uint8Tag2 = "[object Uint8Array]";
|
|
1035
|
-
var uint8ClampedTag2 = "[object Uint8ClampedArray]";
|
|
1036
|
-
var uint16Tag2 = "[object Uint16Array]";
|
|
1037
|
-
var uint32Tag2 = "[object Uint32Array]";
|
|
1038
|
-
function initCloneByTag(object, tag, isDeep) {
|
|
1039
|
-
var Ctor = object.constructor;
|
|
1040
|
-
switch (tag) {
|
|
1041
|
-
case arrayBufferTag2:
|
|
1042
|
-
return cloneArrayBuffer_default(object);
|
|
1043
|
-
case boolTag2:
|
|
1044
|
-
case dateTag2:
|
|
1045
|
-
return new Ctor(+object);
|
|
1046
|
-
case dataViewTag3:
|
|
1047
|
-
return cloneDataView_default(object, isDeep);
|
|
1048
|
-
case float32Tag2:
|
|
1049
|
-
case float64Tag2:
|
|
1050
|
-
case int8Tag2:
|
|
1051
|
-
case int16Tag2:
|
|
1052
|
-
case int32Tag2:
|
|
1053
|
-
case uint8Tag2:
|
|
1054
|
-
case uint8ClampedTag2:
|
|
1055
|
-
case uint16Tag2:
|
|
1056
|
-
case uint32Tag2:
|
|
1057
|
-
return cloneTypedArray_default(object, isDeep);
|
|
1058
|
-
case mapTag3:
|
|
1059
|
-
return new Ctor();
|
|
1060
|
-
case numberTag2:
|
|
1061
|
-
case stringTag2:
|
|
1062
|
-
return new Ctor(object);
|
|
1063
|
-
case regexpTag2:
|
|
1064
|
-
return cloneRegExp_default(object);
|
|
1065
|
-
case setTag3:
|
|
1066
|
-
return new Ctor();
|
|
1067
|
-
case symbolTag:
|
|
1068
|
-
return cloneSymbol_default(object);
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1071
|
-
var initCloneByTag_default = initCloneByTag;
|
|
1072
|
-
|
|
1073
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseCreate.js
|
|
1074
|
-
var objectCreate = Object.create;
|
|
1075
|
-
var baseCreate = /* @__PURE__ */ (function() {
|
|
1076
|
-
function object() {
|
|
1077
|
-
}
|
|
1078
|
-
return function(proto) {
|
|
1079
|
-
if (!isObject_default(proto)) {
|
|
1080
|
-
return {};
|
|
1081
|
-
}
|
|
1082
|
-
if (objectCreate) {
|
|
1083
|
-
return objectCreate(proto);
|
|
1084
|
-
}
|
|
1085
|
-
object.prototype = proto;
|
|
1086
|
-
var result = new object();
|
|
1087
|
-
object.prototype = void 0;
|
|
1088
|
-
return result;
|
|
1089
|
-
};
|
|
1090
|
-
})();
|
|
1091
|
-
var baseCreate_default = baseCreate;
|
|
1092
|
-
|
|
1093
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_initCloneObject.js
|
|
1094
|
-
function initCloneObject(object) {
|
|
1095
|
-
return typeof object.constructor == "function" && !isPrototype_default(object) ? baseCreate_default(getPrototype_default(object)) : {};
|
|
1096
|
-
}
|
|
1097
|
-
var initCloneObject_default = initCloneObject;
|
|
1098
|
-
|
|
1099
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsMap.js
|
|
1100
|
-
var mapTag4 = "[object Map]";
|
|
1101
|
-
function baseIsMap(value) {
|
|
1102
|
-
return isObjectLike_default(value) && getTag_default(value) == mapTag4;
|
|
1103
|
-
}
|
|
1104
|
-
var baseIsMap_default = baseIsMap;
|
|
1105
|
-
|
|
1106
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isMap.js
|
|
1107
|
-
var nodeIsMap = nodeUtil_default && nodeUtil_default.isMap;
|
|
1108
|
-
var isMap = nodeIsMap ? baseUnary_default(nodeIsMap) : baseIsMap_default;
|
|
1109
|
-
var isMap_default = isMap;
|
|
1110
|
-
|
|
1111
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsSet.js
|
|
1112
|
-
var setTag4 = "[object Set]";
|
|
1113
|
-
function baseIsSet(value) {
|
|
1114
|
-
return isObjectLike_default(value) && getTag_default(value) == setTag4;
|
|
1115
|
-
}
|
|
1116
|
-
var baseIsSet_default = baseIsSet;
|
|
1117
|
-
|
|
1118
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isSet.js
|
|
1119
|
-
var nodeIsSet = nodeUtil_default && nodeUtil_default.isSet;
|
|
1120
|
-
var isSet = nodeIsSet ? baseUnary_default(nodeIsSet) : baseIsSet_default;
|
|
1121
|
-
var isSet_default = isSet;
|
|
1122
|
-
|
|
1123
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseClone.js
|
|
1124
|
-
var CLONE_DEEP_FLAG = 1;
|
|
1125
|
-
var CLONE_FLAT_FLAG = 2;
|
|
1126
|
-
var CLONE_SYMBOLS_FLAG = 4;
|
|
1127
|
-
var argsTag3 = "[object Arguments]";
|
|
1128
|
-
var arrayTag2 = "[object Array]";
|
|
1129
|
-
var boolTag3 = "[object Boolean]";
|
|
1130
|
-
var dateTag3 = "[object Date]";
|
|
1131
|
-
var errorTag2 = "[object Error]";
|
|
1132
|
-
var funcTag3 = "[object Function]";
|
|
1133
|
-
var genTag2 = "[object GeneratorFunction]";
|
|
1134
|
-
var mapTag5 = "[object Map]";
|
|
1135
|
-
var numberTag3 = "[object Number]";
|
|
1136
|
-
var objectTag3 = "[object Object]";
|
|
1137
|
-
var regexpTag3 = "[object RegExp]";
|
|
1138
|
-
var setTag5 = "[object Set]";
|
|
1139
|
-
var stringTag3 = "[object String]";
|
|
1140
|
-
var symbolTag2 = "[object Symbol]";
|
|
1141
|
-
var weakMapTag3 = "[object WeakMap]";
|
|
1142
|
-
var arrayBufferTag3 = "[object ArrayBuffer]";
|
|
1143
|
-
var dataViewTag4 = "[object DataView]";
|
|
1144
|
-
var float32Tag3 = "[object Float32Array]";
|
|
1145
|
-
var float64Tag3 = "[object Float64Array]";
|
|
1146
|
-
var int8Tag3 = "[object Int8Array]";
|
|
1147
|
-
var int16Tag3 = "[object Int16Array]";
|
|
1148
|
-
var int32Tag3 = "[object Int32Array]";
|
|
1149
|
-
var uint8Tag3 = "[object Uint8Array]";
|
|
1150
|
-
var uint8ClampedTag3 = "[object Uint8ClampedArray]";
|
|
1151
|
-
var uint16Tag3 = "[object Uint16Array]";
|
|
1152
|
-
var uint32Tag3 = "[object Uint32Array]";
|
|
1153
|
-
var cloneableTags = {};
|
|
1154
|
-
cloneableTags[argsTag3] = cloneableTags[arrayTag2] = cloneableTags[arrayBufferTag3] = cloneableTags[dataViewTag4] = cloneableTags[boolTag3] = cloneableTags[dateTag3] = cloneableTags[float32Tag3] = cloneableTags[float64Tag3] = cloneableTags[int8Tag3] = cloneableTags[int16Tag3] = cloneableTags[int32Tag3] = cloneableTags[mapTag5] = cloneableTags[numberTag3] = cloneableTags[objectTag3] = cloneableTags[regexpTag3] = cloneableTags[setTag5] = cloneableTags[stringTag3] = cloneableTags[symbolTag2] = cloneableTags[uint8Tag3] = cloneableTags[uint8ClampedTag3] = cloneableTags[uint16Tag3] = cloneableTags[uint32Tag3] = true;
|
|
1155
|
-
cloneableTags[errorTag2] = cloneableTags[funcTag3] = cloneableTags[weakMapTag3] = false;
|
|
1156
|
-
function baseClone(value, bitmask, customizer, key, object, stack) {
|
|
1157
|
-
var result, isDeep = bitmask & CLONE_DEEP_FLAG, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG;
|
|
1158
|
-
if (customizer) {
|
|
1159
|
-
result = object ? customizer(value, key, object, stack) : customizer(value);
|
|
1160
|
-
}
|
|
1161
|
-
if (result !== void 0) {
|
|
1162
|
-
return result;
|
|
1163
|
-
}
|
|
1164
|
-
if (!isObject_default(value)) {
|
|
1165
|
-
return value;
|
|
1166
|
-
}
|
|
1167
|
-
var isArr = isArray_default(value);
|
|
1168
|
-
if (isArr) {
|
|
1169
|
-
result = initCloneArray_default(value);
|
|
1170
|
-
if (!isDeep) {
|
|
1171
|
-
return copyArray_default(value, result);
|
|
1172
|
-
}
|
|
1173
|
-
} else {
|
|
1174
|
-
var tag = getTag_default(value), isFunc = tag == funcTag3 || tag == genTag2;
|
|
1175
|
-
if (isBuffer_default(value)) {
|
|
1176
|
-
return cloneBuffer_default(value, isDeep);
|
|
1177
|
-
}
|
|
1178
|
-
if (tag == objectTag3 || tag == argsTag3 || isFunc && !object) {
|
|
1179
|
-
result = isFlat || isFunc ? {} : initCloneObject_default(value);
|
|
1180
|
-
if (!isDeep) {
|
|
1181
|
-
return isFlat ? copySymbolsIn_default(value, baseAssignIn_default(result, value)) : copySymbols_default(value, baseAssign_default(result, value));
|
|
1182
|
-
}
|
|
1183
|
-
} else {
|
|
1184
|
-
if (!cloneableTags[tag]) {
|
|
1185
|
-
return object ? value : {};
|
|
1186
|
-
}
|
|
1187
|
-
result = initCloneByTag_default(value, tag, isDeep);
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
stack || (stack = new Stack_default());
|
|
1191
|
-
var stacked = stack.get(value);
|
|
1192
|
-
if (stacked) {
|
|
1193
|
-
return stacked;
|
|
1194
|
-
}
|
|
1195
|
-
stack.set(value, result);
|
|
1196
|
-
if (isSet_default(value)) {
|
|
1197
|
-
value.forEach(function(subValue) {
|
|
1198
|
-
result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
|
|
1199
|
-
});
|
|
1200
|
-
} else if (isMap_default(value)) {
|
|
1201
|
-
value.forEach(function(subValue, key2) {
|
|
1202
|
-
result.set(key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
|
|
1203
|
-
});
|
|
1204
|
-
}
|
|
1205
|
-
var keysFunc = isFull ? isFlat ? getAllKeysIn_default : getAllKeys_default : isFlat ? keysIn_default : keys_default;
|
|
1206
|
-
var props = isArr ? void 0 : keysFunc(value);
|
|
1207
|
-
arrayEach_default(props || value, function(subValue, key2) {
|
|
1208
|
-
if (props) {
|
|
1209
|
-
key2 = subValue;
|
|
1210
|
-
subValue = value[key2];
|
|
1211
|
-
}
|
|
1212
|
-
assignValue_default(result, key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
|
|
1213
|
-
});
|
|
1214
|
-
return result;
|
|
1215
|
-
}
|
|
1216
|
-
var baseClone_default = baseClone;
|
|
1217
|
-
|
|
1218
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/cloneDeep.js
|
|
1219
|
-
var CLONE_DEEP_FLAG2 = 1;
|
|
1220
|
-
var CLONE_SYMBOLS_FLAG2 = 4;
|
|
1221
|
-
function cloneDeep(value) {
|
|
1222
|
-
return baseClone_default(value, CLONE_DEEP_FLAG2 | CLONE_SYMBOLS_FLAG2);
|
|
1223
|
-
}
|
|
1224
|
-
var cloneDeep_default = cloneDeep;
|
|
1225
|
-
|
|
1226
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_assignMergeValue.js
|
|
1227
|
-
function assignMergeValue(object, key, value) {
|
|
1228
|
-
if (value !== void 0 && !eq_default(object[key], value) || value === void 0 && !(key in object)) {
|
|
1229
|
-
baseAssignValue_default(object, key, value);
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
var assignMergeValue_default = assignMergeValue;
|
|
1233
|
-
|
|
1234
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_createBaseFor.js
|
|
1235
|
-
function createBaseFor(fromRight) {
|
|
1236
|
-
return function(object, iteratee, keysFunc) {
|
|
1237
|
-
var index = -1, iterable = Object(object), props = keysFunc(object), length = props.length;
|
|
1238
|
-
while (length--) {
|
|
1239
|
-
var key = props[fromRight ? length : ++index];
|
|
1240
|
-
if (iteratee(iterable[key], key, iterable) === false) {
|
|
1241
|
-
break;
|
|
1242
|
-
}
|
|
1243
|
-
}
|
|
1244
|
-
return object;
|
|
1245
|
-
};
|
|
1246
|
-
}
|
|
1247
|
-
var createBaseFor_default = createBaseFor;
|
|
1248
|
-
|
|
1249
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseFor.js
|
|
1250
|
-
var baseFor = createBaseFor_default();
|
|
1251
|
-
var baseFor_default = baseFor;
|
|
1252
|
-
|
|
1253
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isArrayLikeObject.js
|
|
1254
|
-
function isArrayLikeObject(value) {
|
|
1255
|
-
return isObjectLike_default(value) && isArrayLike_default(value);
|
|
1256
|
-
}
|
|
1257
|
-
var isArrayLikeObject_default = isArrayLikeObject;
|
|
1258
|
-
|
|
1259
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isPlainObject.js
|
|
1260
|
-
var objectTag4 = "[object Object]";
|
|
1261
|
-
var funcProto3 = Function.prototype;
|
|
1262
|
-
var objectProto14 = Object.prototype;
|
|
1263
|
-
var funcToString3 = funcProto3.toString;
|
|
1264
|
-
var hasOwnProperty11 = objectProto14.hasOwnProperty;
|
|
1265
|
-
var objectCtorString = funcToString3.call(Object);
|
|
1266
|
-
function isPlainObject(value) {
|
|
1267
|
-
if (!isObjectLike_default(value) || baseGetTag_default(value) != objectTag4) {
|
|
1268
|
-
return false;
|
|
1269
|
-
}
|
|
1270
|
-
var proto = getPrototype_default(value);
|
|
1271
|
-
if (proto === null) {
|
|
1272
|
-
return true;
|
|
1273
|
-
}
|
|
1274
|
-
var Ctor = hasOwnProperty11.call(proto, "constructor") && proto.constructor;
|
|
1275
|
-
return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString3.call(Ctor) == objectCtorString;
|
|
1276
|
-
}
|
|
1277
|
-
var isPlainObject_default = isPlainObject;
|
|
1278
|
-
|
|
1279
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_safeGet.js
|
|
1280
|
-
function safeGet(object, key) {
|
|
1281
|
-
if (key === "constructor" && typeof object[key] === "function") {
|
|
1282
|
-
return;
|
|
1283
|
-
}
|
|
1284
|
-
if (key == "__proto__") {
|
|
1285
|
-
return;
|
|
869
|
+
var isProto = isPrototype_default(object), result = [];
|
|
870
|
+
for (var key in object) {
|
|
871
|
+
if (!(key == "constructor" && (isProto || !hasOwnProperty9.call(object, key)))) {
|
|
872
|
+
result.push(key);
|
|
873
|
+
}
|
|
1286
874
|
}
|
|
1287
|
-
return
|
|
875
|
+
return result;
|
|
1288
876
|
}
|
|
1289
|
-
var
|
|
877
|
+
var baseKeysIn_default = baseKeysIn;
|
|
878
|
+
|
|
879
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/keysIn.js
|
|
880
|
+
function keysIn(object) {
|
|
881
|
+
return isArrayLike_default(object) ? arrayLikeKeys_default(object, true) : baseKeysIn_default(object);
|
|
882
|
+
}
|
|
883
|
+
var keysIn_default = keysIn;
|
|
1290
884
|
|
|
1291
885
|
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/toPlainObject.js
|
|
1292
886
|
function toPlainObject(value) {
|
|
@@ -1496,7 +1090,6 @@ var mergeWith_default = mergeWith;
|
|
|
1496
1090
|
var AIMarkdownRenderExtraSyntax = /* @__PURE__ */ ((AIMarkdownRenderExtraSyntax2) => {
|
|
1497
1091
|
AIMarkdownRenderExtraSyntax2["HIGHLIGHT"] = "HIGHLIGHT";
|
|
1498
1092
|
AIMarkdownRenderExtraSyntax2["DEFINITION_LIST"] = "DEFINITION_LIST";
|
|
1499
|
-
AIMarkdownRenderExtraSyntax2["SUBSCRIPT"] = "SUBSCRIPT";
|
|
1500
1093
|
return AIMarkdownRenderExtraSyntax2;
|
|
1501
1094
|
})(AIMarkdownRenderExtraSyntax || {});
|
|
1502
1095
|
var AIMarkdownRenderDisplayOptimizeAbility = /* @__PURE__ */ ((AIMarkdownRenderDisplayOptimizeAbility2) => {
|
|
@@ -1508,14 +1101,15 @@ var AIMarkdownRenderDisplayOptimizeAbility = /* @__PURE__ */ ((AIMarkdownRenderD
|
|
|
1508
1101
|
var defaultAIMarkdownRenderConfig = Object.freeze({
|
|
1509
1102
|
extraSyntaxSupported: Object.freeze([
|
|
1510
1103
|
"HIGHLIGHT" /* HIGHLIGHT */,
|
|
1511
|
-
"DEFINITION_LIST" /* DEFINITION_LIST
|
|
1512
|
-
"SUBSCRIPT" /* SUBSCRIPT */
|
|
1104
|
+
"DEFINITION_LIST" /* DEFINITION_LIST */
|
|
1513
1105
|
]),
|
|
1514
1106
|
displayOptimizeAbilities: Object.freeze([
|
|
1515
1107
|
"REMOVE_COMMENTS" /* REMOVE_COMMENTS */,
|
|
1516
1108
|
"SMARTYPANTS" /* SMARTYPANTS */,
|
|
1517
1109
|
"PANGU" /* PANGU */
|
|
1518
|
-
])
|
|
1110
|
+
]),
|
|
1111
|
+
blockMemoEnabled: true,
|
|
1112
|
+
preserveOrphanReferences: true
|
|
1519
1113
|
});
|
|
1520
1114
|
|
|
1521
1115
|
// src/context.tsx
|
|
@@ -1548,24 +1142,35 @@ var AIMarkdownRenderStateProvider = ({
|
|
|
1548
1142
|
fontSize,
|
|
1549
1143
|
variant,
|
|
1550
1144
|
colorScheme,
|
|
1145
|
+
documentId,
|
|
1551
1146
|
defaultConfig,
|
|
1552
1147
|
config,
|
|
1553
1148
|
children
|
|
1554
1149
|
}) => {
|
|
1555
1150
|
const baseConfig = defaultConfig ?? defaultAIMarkdownRenderConfig;
|
|
1556
1151
|
const mergedConfig = (0, import_react.useMemo)(
|
|
1557
|
-
() => config ? mergeWith_default(
|
|
1152
|
+
() => config ? mergeWith_default({}, baseConfig, config, configMergeCustomizer) : baseConfig,
|
|
1558
1153
|
[baseConfig, config]
|
|
1559
1154
|
);
|
|
1155
|
+
const fallbackId = (0, import_react.useId)();
|
|
1156
|
+
const resolvedDocumentId = documentId && documentId.length > 0 ? documentId : fallbackId;
|
|
1560
1157
|
const state = (0, import_react.useMemo)(
|
|
1561
1158
|
() => Object.freeze({
|
|
1562
1159
|
streaming,
|
|
1563
1160
|
fontSize,
|
|
1564
1161
|
variant,
|
|
1565
1162
|
colorScheme,
|
|
1163
|
+
documentId: resolvedDocumentId,
|
|
1164
|
+
// URI-fragment safe per-document prefix derived once here so downstream
|
|
1165
|
+
// consumers (MarkdownContent, cross-chunk placeholder components) read
|
|
1166
|
+
// from one canonical source. `encodeURIComponent` runs at the prefix
|
|
1167
|
+
// construction site, not at the documentId storage site, so consumers
|
|
1168
|
+
// accessing `documentId` directly still see the raw React-native value
|
|
1169
|
+
// (e.g. `useId()`'s `_r_0_`) while id="..."/href="#..." bytes are safe.
|
|
1170
|
+
clobberPrefix: `${encodeURIComponent(resolvedDocumentId)}-user-content-`,
|
|
1566
1171
|
config: mergedConfig
|
|
1567
1172
|
}),
|
|
1568
|
-
[streaming, fontSize, variant, colorScheme, mergedConfig]
|
|
1173
|
+
[streaming, fontSize, variant, colorScheme, resolvedDocumentId, mergedConfig]
|
|
1569
1174
|
);
|
|
1570
1175
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AIMarkdownRenderStateContext.Provider, { value: state, children });
|
|
1571
1176
|
};
|
|
@@ -1579,10 +1184,42 @@ function getRepeatedMarkerLength(content, start, marker) {
|
|
|
1579
1184
|
}
|
|
1580
1185
|
return end - start;
|
|
1581
1186
|
}
|
|
1187
|
+
var HTML_TAG_REGEX = /<\/?(span|div|p|br|hr|img|a|em|strong|b|i|u|s|sub|sup|code|pre|table|tr|td|th|thead|tbody|tfoot|ul|ol|li|dl|dt|dd|h[1-6]|blockquote|details|summary|figure|figcaption|section|article|aside|nav|header|footer|main|mark|del|ins|small|abbr|cite|dfn|kbd|samp|var|ruby|rt|rp|bdo|wbr|input|button|select|textarea|label|fieldset|legend|output|iframe|video|audio|source|canvas|svg|math|time)(?:\s[^>]*)?\/?>/iy;
|
|
1188
|
+
var LITERAL_CONTENT_TAGS = /* @__PURE__ */ new Set(["code", "pre", "kbd", "samp", "math", "svg"]);
|
|
1189
|
+
var LITERAL_CONTENT_CLOSE_REGEX = {
|
|
1190
|
+
code: /<\/code\s*>/gi,
|
|
1191
|
+
pre: /<\/pre\s*>/gi,
|
|
1192
|
+
kbd: /<\/kbd\s*>/gi,
|
|
1193
|
+
samp: /<\/samp\s*>/gi,
|
|
1194
|
+
math: /<\/math\s*>/gi,
|
|
1195
|
+
svg: /<\/svg\s*>/gi
|
|
1196
|
+
};
|
|
1197
|
+
function isAtLineStart(content, pos) {
|
|
1198
|
+
let i = pos - 1;
|
|
1199
|
+
let spaces = 0;
|
|
1200
|
+
while (i >= 0 && content[i] === " ") {
|
|
1201
|
+
spaces++;
|
|
1202
|
+
if (spaces > 3) return false;
|
|
1203
|
+
i--;
|
|
1204
|
+
}
|
|
1205
|
+
return i < 0 || content[i] === "\n" || content[i] === "\r";
|
|
1206
|
+
}
|
|
1207
|
+
function findClosingBacktickRun(content, start, n) {
|
|
1208
|
+
let i = start;
|
|
1209
|
+
while (i < content.length) {
|
|
1210
|
+
if (content[i] === "`") {
|
|
1211
|
+
const runLen = getRepeatedMarkerLength(content, i, "`");
|
|
1212
|
+
if (runLen === n) return i;
|
|
1213
|
+
i += runLen;
|
|
1214
|
+
} else {
|
|
1215
|
+
i += 1;
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
return -1;
|
|
1219
|
+
}
|
|
1582
1220
|
function splitByProtectedRegions(content) {
|
|
1583
1221
|
const segments = [];
|
|
1584
1222
|
let lastIndex = 0;
|
|
1585
|
-
let inlineStart = -1;
|
|
1586
1223
|
let multilineStart = -1;
|
|
1587
1224
|
let multilineFenceMarker = null;
|
|
1588
1225
|
let multilineFenceLength = 0;
|
|
@@ -1593,42 +1230,69 @@ function splitByProtectedRegions(content) {
|
|
|
1593
1230
|
segments.push({ text: content.substring(start, end), isCode: true });
|
|
1594
1231
|
lastIndex = end;
|
|
1595
1232
|
}
|
|
1596
|
-
|
|
1233
|
+
let i = 0;
|
|
1234
|
+
while (i < content.length) {
|
|
1597
1235
|
const char = content[i];
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1236
|
+
if (multilineStart !== -1) {
|
|
1237
|
+
if (char === multilineFenceMarker) {
|
|
1238
|
+
const runLen = getRepeatedMarkerLength(content, i, multilineFenceMarker);
|
|
1239
|
+
if (runLen >= multilineFenceLength && isAtLineStart(content, i)) {
|
|
1240
|
+
pushProtected(multilineStart, i + runLen);
|
|
1241
|
+
multilineStart = -1;
|
|
1242
|
+
multilineFenceMarker = null;
|
|
1243
|
+
multilineFenceLength = 0;
|
|
1244
|
+
i += runLen;
|
|
1245
|
+
continue;
|
|
1246
|
+
}
|
|
1247
|
+
i += runLen;
|
|
1248
|
+
continue;
|
|
1249
|
+
}
|
|
1250
|
+
i += 1;
|
|
1251
|
+
continue;
|
|
1252
|
+
}
|
|
1253
|
+
if (char === "`" || char === "~") {
|
|
1254
|
+
const runLen = getRepeatedMarkerLength(content, i, char);
|
|
1255
|
+
if (runLen >= 3 && isAtLineStart(content, i)) {
|
|
1602
1256
|
multilineStart = i;
|
|
1603
1257
|
multilineFenceMarker = char;
|
|
1604
|
-
multilineFenceLength =
|
|
1605
|
-
i +=
|
|
1606
|
-
|
|
1607
|
-
pushProtected(multilineStart, i + fenceLength);
|
|
1608
|
-
multilineStart = -1;
|
|
1609
|
-
multilineFenceMarker = null;
|
|
1610
|
-
multilineFenceLength = 0;
|
|
1611
|
-
i += fenceLength - 1;
|
|
1612
|
-
} else {
|
|
1613
|
-
i += fenceLength - 1;
|
|
1258
|
+
multilineFenceLength = runLen;
|
|
1259
|
+
i += runLen;
|
|
1260
|
+
continue;
|
|
1614
1261
|
}
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1262
|
+
if (char === "`") {
|
|
1263
|
+
const closeIdx = findClosingBacktickRun(content, i + runLen, runLen);
|
|
1264
|
+
if (closeIdx !== -1) {
|
|
1265
|
+
pushProtected(i, closeIdx + runLen);
|
|
1266
|
+
i = closeIdx + runLen;
|
|
1267
|
+
continue;
|
|
1268
|
+
}
|
|
1621
1269
|
}
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1270
|
+
i += runLen;
|
|
1271
|
+
continue;
|
|
1272
|
+
}
|
|
1273
|
+
if (char === "<") {
|
|
1274
|
+
HTML_TAG_REGEX.lastIndex = i;
|
|
1275
|
+
const tagMatch = HTML_TAG_REGEX.exec(content);
|
|
1627
1276
|
if (tagMatch) {
|
|
1628
|
-
|
|
1629
|
-
|
|
1277
|
+
let endIndex = i + tagMatch[0].length;
|
|
1278
|
+
const tagName = tagMatch[1].toLowerCase();
|
|
1279
|
+
const isOpeningPairedTag = content[i + 1] !== "/" && !tagMatch[0].endsWith("/>") && LITERAL_CONTENT_TAGS.has(tagName);
|
|
1280
|
+
if (isOpeningPairedTag) {
|
|
1281
|
+
const closeRegex = LITERAL_CONTENT_CLOSE_REGEX[tagName];
|
|
1282
|
+
closeRegex.lastIndex = endIndex;
|
|
1283
|
+
const closeMatch = closeRegex.exec(content);
|
|
1284
|
+
if (closeMatch) {
|
|
1285
|
+
endIndex = closeMatch.index + closeMatch[0].length;
|
|
1286
|
+
} else {
|
|
1287
|
+
endIndex = content.length;
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
pushProtected(i, endIndex);
|
|
1291
|
+
i = endIndex;
|
|
1292
|
+
continue;
|
|
1630
1293
|
}
|
|
1631
1294
|
}
|
|
1295
|
+
i += 1;
|
|
1632
1296
|
}
|
|
1633
1297
|
if (multilineStart !== -1) {
|
|
1634
1298
|
pushProtected(multilineStart, content.length);
|
|
@@ -1646,15 +1310,23 @@ var NO_ESCAPED_DOLLAR_REGEX = /(?<![\\$])\$(?!\$)/g;
|
|
|
1646
1310
|
var DELIMITERS_REGEX = /(?<!!)\\\[([\S\s]*?[^\\])\\](?!\()|\\\((.*?)\\\)/g;
|
|
1647
1311
|
var ARRAY_COL_SPEC_OR_PIPE_REGEX = /(\\begin\{(?:array|tabular[x*]?)\}\{[^}]*\})|(?<!\\)\|/g;
|
|
1648
1312
|
var LATEX_BLOCK_REGEX = /\$\$([\S\s]*?)\$\$|(?<![\\$])\$(?!\$)((?:[^$\n]|\\\$)*?)(?<![\\`])\$(?!\$)/g;
|
|
1649
|
-
var
|
|
1313
|
+
var TEXT_COMMAND = "\\text{";
|
|
1650
1314
|
var SINGLE_DOLLAR_REGEX = /(?<![\\$])\$(?!\$)((?:[^$\n]|\\[$])+?)(?<!\\)(?<!`)\$(?!\$)/g;
|
|
1651
1315
|
function escapeCurrencyDollarSigns(text) {
|
|
1652
1316
|
const parts = [];
|
|
1653
1317
|
let lastIndex = 0;
|
|
1654
1318
|
const currencyMatches = Array.from(text.matchAll(CURRENCY_REGEX));
|
|
1319
|
+
let currentLineProcessed = "";
|
|
1655
1320
|
for (let i = 0; i < currencyMatches.length; i++) {
|
|
1656
1321
|
const match = currencyMatches[i];
|
|
1657
|
-
|
|
1322
|
+
const segment = text.substring(lastIndex, match.index);
|
|
1323
|
+
parts.push(segment);
|
|
1324
|
+
const newlineIdx = Math.max(segment.lastIndexOf("\n"), segment.lastIndexOf("\r"));
|
|
1325
|
+
if (newlineIdx !== -1) {
|
|
1326
|
+
currentLineProcessed = segment.substring(newlineIdx + 1);
|
|
1327
|
+
} else {
|
|
1328
|
+
currentLineProcessed += segment;
|
|
1329
|
+
}
|
|
1658
1330
|
let needEscape = true;
|
|
1659
1331
|
let restBeforeNextMatchOrEnd = "";
|
|
1660
1332
|
if (i < currencyMatches.length - 1) {
|
|
@@ -1667,14 +1339,14 @@ function escapeCurrencyDollarSigns(text) {
|
|
|
1667
1339
|
}
|
|
1668
1340
|
const firstLineBeforeNextMatch = restBeforeNextMatchOrEnd.split(/\r\n|\r|\n/g)[0];
|
|
1669
1341
|
if (Array.from(firstLineBeforeNextMatch.matchAll(NO_ESCAPED_DOLLAR_REGEX)).length % 2 !== 0) {
|
|
1670
|
-
const
|
|
1671
|
-
const previousLastLineContent = previousNewContent.split(/\r\n|\r|\n/g).pop();
|
|
1672
|
-
const wholeLineBeforeNextMatchWithoutCurrentDollar = previousLastLineContent + firstLineBeforeNextMatch;
|
|
1342
|
+
const wholeLineBeforeNextMatchWithoutCurrentDollar = currentLineProcessed + firstLineBeforeNextMatch;
|
|
1673
1343
|
if (Array.from(wholeLineBeforeNextMatchWithoutCurrentDollar.matchAll(NO_ESCAPED_DOLLAR_REGEX)).length % 2 !== 0) {
|
|
1674
1344
|
needEscape = false;
|
|
1675
1345
|
}
|
|
1676
1346
|
}
|
|
1677
|
-
|
|
1347
|
+
const replacement = needEscape ? "\\$" : "$";
|
|
1348
|
+
parts.push(replacement);
|
|
1349
|
+
currentLineProcessed += replacement;
|
|
1678
1350
|
lastIndex = match.index + 1;
|
|
1679
1351
|
}
|
|
1680
1352
|
parts.push(text.substring(lastIndex));
|
|
@@ -1708,14 +1380,23 @@ function escapeLatexPipes(text) {
|
|
|
1708
1380
|
return match;
|
|
1709
1381
|
});
|
|
1710
1382
|
}
|
|
1383
|
+
function isEscapedByBackslashRun(text, pos) {
|
|
1384
|
+
let count = 0;
|
|
1385
|
+
let j = pos - 1;
|
|
1386
|
+
while (j >= 0 && text[j] === "\\") {
|
|
1387
|
+
count++;
|
|
1388
|
+
j--;
|
|
1389
|
+
}
|
|
1390
|
+
return count % 2 === 1;
|
|
1391
|
+
}
|
|
1711
1392
|
function findUnclosedDelimiterStart(text, mode) {
|
|
1712
1393
|
let unclosedStart = -1;
|
|
1713
1394
|
let i = 0;
|
|
1714
1395
|
while (i < text.length) {
|
|
1715
|
-
if (text[i] === "$" && i + 1 < text.length && text[i + 1] === "$") {
|
|
1396
|
+
if (text[i] === "$" && i + 1 < text.length && text[i + 1] === "$" && !isEscapedByBackslashRun(text, i)) {
|
|
1716
1397
|
unclosedStart = unclosedStart === -1 ? i : -1;
|
|
1717
1398
|
i += 2;
|
|
1718
|
-
} else if (mode === "both" && text[i] === "$" && (
|
|
1399
|
+
} else if (mode === "both" && text[i] === "$" && !isEscapedByBackslashRun(text, i) && (i + 1 >= text.length || text[i + 1] !== "$")) {
|
|
1719
1400
|
unclosedStart = unclosedStart === -1 ? i : -1;
|
|
1720
1401
|
i += 1;
|
|
1721
1402
|
} else {
|
|
@@ -1739,10 +1420,41 @@ function truncateUnclosedLatexBlock(text) {
|
|
|
1739
1420
|
return text.substring(0, unclosedStart).trimEnd();
|
|
1740
1421
|
}
|
|
1741
1422
|
function escapeTextUnderscores(text) {
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1423
|
+
let out = "";
|
|
1424
|
+
let i = 0;
|
|
1425
|
+
while (i < text.length) {
|
|
1426
|
+
const start = text.indexOf(TEXT_COMMAND, i);
|
|
1427
|
+
if (start === -1) {
|
|
1428
|
+
out += text.substring(i);
|
|
1429
|
+
return out;
|
|
1430
|
+
}
|
|
1431
|
+
out += text.substring(i, start);
|
|
1432
|
+
const bodyStart = start + TEXT_COMMAND.length;
|
|
1433
|
+
let depth = 1;
|
|
1434
|
+
let j = bodyStart;
|
|
1435
|
+
while (j < text.length && depth > 0) {
|
|
1436
|
+
const c = text[j];
|
|
1437
|
+
if (c === "\\" && j + 1 < text.length) {
|
|
1438
|
+
j += 2;
|
|
1439
|
+
continue;
|
|
1440
|
+
}
|
|
1441
|
+
if (c === "{") depth++;
|
|
1442
|
+
else if (c === "}") {
|
|
1443
|
+
depth--;
|
|
1444
|
+
if (depth === 0) break;
|
|
1445
|
+
}
|
|
1446
|
+
j++;
|
|
1447
|
+
}
|
|
1448
|
+
if (depth !== 0) {
|
|
1449
|
+
out += text.substring(start);
|
|
1450
|
+
return out;
|
|
1451
|
+
}
|
|
1452
|
+
const body = text.substring(bodyStart, j);
|
|
1453
|
+
const escapedBody = body.replaceAll(/(?<!\\)_/g, "\\_");
|
|
1454
|
+
out += `\\text{${escapedBody}}`;
|
|
1455
|
+
i = j + 1;
|
|
1456
|
+
}
|
|
1457
|
+
return out;
|
|
1746
1458
|
}
|
|
1747
1459
|
function convertSingleToDoubleDollar(text) {
|
|
1748
1460
|
return text.replaceAll(SINGLE_DOLLAR_REGEX, (_match, content) => `$$${content}$$`);
|
|
@@ -1765,37 +1477,1351 @@ function preprocessLaTeX(str) {
|
|
|
1765
1477
|
});
|
|
1766
1478
|
return result.join("");
|
|
1767
1479
|
}
|
|
1768
|
-
|
|
1769
|
-
// src/preprocessors/index.ts
|
|
1770
|
-
function applyPreprocessors(value, ...fns) {
|
|
1771
|
-
return fns.reduce((result, fn) => fn(result), value);
|
|
1480
|
+
|
|
1481
|
+
// src/preprocessors/index.ts
|
|
1482
|
+
function applyPreprocessors(value, ...fns) {
|
|
1483
|
+
return fns.reduce((result, fn) => fn(result), value);
|
|
1484
|
+
}
|
|
1485
|
+
var defaultExtraPreprocessors = [];
|
|
1486
|
+
function preprocessAIMDContent(content, extraPreprocessors = defaultExtraPreprocessors) {
|
|
1487
|
+
return applyPreprocessors(content, preprocessLaTeX, ...extraPreprocessors);
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
// src/components/MarkdownContent.tsx
|
|
1491
|
+
var import_react7 = require("react");
|
|
1492
|
+
|
|
1493
|
+
// src/components/markdown/Markdown.tsx
|
|
1494
|
+
var import_devlop2 = require("devlop");
|
|
1495
|
+
var import_hast_util_to_jsx_runtime = require("hast-util-to-jsx-runtime");
|
|
1496
|
+
var import_react2 = require("react");
|
|
1497
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
1498
|
+
var import_unist_util_visit = require("unist-util-visit");
|
|
1499
|
+
|
|
1500
|
+
// src/components/markdown/processor.ts
|
|
1501
|
+
var import_devlop = require("devlop");
|
|
1502
|
+
var import_remark_parse = __toESM(require("remark-parse"), 1);
|
|
1503
|
+
var import_remark_rehype = __toESM(require("remark-rehype"), 1);
|
|
1504
|
+
var import_unified = require("unified");
|
|
1505
|
+
var import_vfile = require("vfile");
|
|
1506
|
+
var emptyPlugins = [];
|
|
1507
|
+
var emptyRemarkRehypeOptions = { allowDangerousHtml: true };
|
|
1508
|
+
function createProcessor(options) {
|
|
1509
|
+
const rehypePlugins = options.rehypePlugins || emptyPlugins;
|
|
1510
|
+
const remarkPlugins = options.remarkPlugins || emptyPlugins;
|
|
1511
|
+
const remarkRehypeOptions = options.remarkRehypeOptions ? { ...options.remarkRehypeOptions, ...emptyRemarkRehypeOptions } : emptyRemarkRehypeOptions;
|
|
1512
|
+
return (0, import_unified.unified)().use(import_remark_parse.default).use(remarkPlugins).use(import_remark_rehype.default, remarkRehypeOptions).use(rehypePlugins);
|
|
1513
|
+
}
|
|
1514
|
+
function createFile(options) {
|
|
1515
|
+
const children = options.children || "";
|
|
1516
|
+
const file = new import_vfile.VFile();
|
|
1517
|
+
if (typeof children === "string") {
|
|
1518
|
+
file.value = children;
|
|
1519
|
+
} else {
|
|
1520
|
+
(0, import_devlop.unreachable)("Unexpected value `" + String(children) + "` for `children` prop, expected `string`");
|
|
1521
|
+
}
|
|
1522
|
+
return file;
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
// src/components/markdown/transform.ts
|
|
1526
|
+
var import_html_url_attributes = require("html-url-attributes");
|
|
1527
|
+
function buildTransform(ctx) {
|
|
1528
|
+
return function transform(node, index, parent) {
|
|
1529
|
+
if (node.type === "raw" && parent && typeof index === "number") {
|
|
1530
|
+
if (ctx.skipHtml) {
|
|
1531
|
+
parent.children.splice(index, 1);
|
|
1532
|
+
} else {
|
|
1533
|
+
parent.children[index] = { type: "text", value: node.value };
|
|
1534
|
+
}
|
|
1535
|
+
return index;
|
|
1536
|
+
}
|
|
1537
|
+
if (node.type === "element") {
|
|
1538
|
+
const element = node;
|
|
1539
|
+
let key;
|
|
1540
|
+
for (key in import_html_url_attributes.urlAttributes) {
|
|
1541
|
+
if (Object.hasOwn(import_html_url_attributes.urlAttributes, key) && Object.hasOwn(element.properties, key)) {
|
|
1542
|
+
const value = element.properties[key];
|
|
1543
|
+
const test = import_html_url_attributes.urlAttributes[key];
|
|
1544
|
+
if (test === null || test.includes(element.tagName)) {
|
|
1545
|
+
element.properties[key] = ctx.urlTransform(String(value || ""), key, element);
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
if (node.type === "element") {
|
|
1551
|
+
const element = node;
|
|
1552
|
+
let remove = ctx.allowedElements ? !ctx.allowedElements.includes(element.tagName) : ctx.disallowedElements ? ctx.disallowedElements.includes(element.tagName) : false;
|
|
1553
|
+
if (!remove && ctx.allowElement && typeof index === "number") {
|
|
1554
|
+
remove = !ctx.allowElement(element, index, parent);
|
|
1555
|
+
}
|
|
1556
|
+
if (remove && parent && typeof index === "number") {
|
|
1557
|
+
if (ctx.unwrapDisallowed && element.children) {
|
|
1558
|
+
parent.children.splice(index, 1, ...element.children);
|
|
1559
|
+
} else {
|
|
1560
|
+
parent.children.splice(index, 1);
|
|
1561
|
+
}
|
|
1562
|
+
return index;
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
return void 0;
|
|
1566
|
+
};
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
// src/components/markdown/urlTransform.ts
|
|
1570
|
+
var safeProtocol = /^(https?|ircs?|mailto|xmpp)$/i;
|
|
1571
|
+
var defaultUrlTransform = (value) => {
|
|
1572
|
+
const colon = value.indexOf(":");
|
|
1573
|
+
const questionMark = value.indexOf("?");
|
|
1574
|
+
const numberSign = value.indexOf("#");
|
|
1575
|
+
const slash = value.indexOf("/");
|
|
1576
|
+
if (
|
|
1577
|
+
// No protocol → relative.
|
|
1578
|
+
colon === -1 || // First colon is after `/`, `?`, or `#` → not a protocol.
|
|
1579
|
+
slash !== -1 && colon > slash || questionMark !== -1 && colon > questionMark || numberSign !== -1 && colon > numberSign || // Allowed protocol.
|
|
1580
|
+
safeProtocol.test(value.slice(0, colon))
|
|
1581
|
+
) {
|
|
1582
|
+
return value;
|
|
1583
|
+
}
|
|
1584
|
+
return "";
|
|
1585
|
+
};
|
|
1586
|
+
|
|
1587
|
+
// src/components/markdown/Markdown.tsx
|
|
1588
|
+
var changelog = "https://github.com/remarkjs/react-markdown/blob/main/changelog.md";
|
|
1589
|
+
var deprecations = [
|
|
1590
|
+
{ from: "astPlugins", id: "remove-buggy-html-in-markdown-parser" },
|
|
1591
|
+
{ from: "allowDangerousHtml", id: "remove-buggy-html-in-markdown-parser" },
|
|
1592
|
+
{
|
|
1593
|
+
from: "allowNode",
|
|
1594
|
+
id: "replace-allownode-allowedtypes-and-disallowedtypes",
|
|
1595
|
+
to: "allowElement"
|
|
1596
|
+
},
|
|
1597
|
+
{
|
|
1598
|
+
from: "allowedTypes",
|
|
1599
|
+
id: "replace-allownode-allowedtypes-and-disallowedtypes",
|
|
1600
|
+
to: "allowedElements"
|
|
1601
|
+
},
|
|
1602
|
+
{ from: "className", id: "remove-classname" },
|
|
1603
|
+
{
|
|
1604
|
+
from: "disallowedTypes",
|
|
1605
|
+
id: "replace-allownode-allowedtypes-and-disallowedtypes",
|
|
1606
|
+
to: "disallowedElements"
|
|
1607
|
+
},
|
|
1608
|
+
{ from: "escapeHtml", id: "remove-buggy-html-in-markdown-parser" },
|
|
1609
|
+
{ from: "includeElementIndex", id: "#remove-includeelementindex" },
|
|
1610
|
+
{
|
|
1611
|
+
from: "includeNodeIndex",
|
|
1612
|
+
id: "change-includenodeindex-to-includeelementindex"
|
|
1613
|
+
},
|
|
1614
|
+
{ from: "linkTarget", id: "remove-linktarget" },
|
|
1615
|
+
{ from: "plugins", id: "change-plugins-to-remarkplugins", to: "remarkPlugins" },
|
|
1616
|
+
{ from: "rawSourcePos", id: "#remove-rawsourcepos" },
|
|
1617
|
+
{ from: "renderers", id: "change-renderers-to-components", to: "components" },
|
|
1618
|
+
{ from: "source", id: "change-source-to-children", to: "children" },
|
|
1619
|
+
{ from: "sourcePos", id: "#remove-sourcepos" },
|
|
1620
|
+
{ from: "transformImageUri", id: "#add-urltransform", to: "urlTransform" },
|
|
1621
|
+
{ from: "transformLinkUri", id: "#add-urltransform", to: "urlTransform" }
|
|
1622
|
+
];
|
|
1623
|
+
function validateOptions(options) {
|
|
1624
|
+
for (const deprecation of deprecations) {
|
|
1625
|
+
if (Object.hasOwn(options, deprecation.from)) {
|
|
1626
|
+
(0, import_devlop2.unreachable)(
|
|
1627
|
+
"Unexpected `" + deprecation.from + "` prop, " + (deprecation.to ? "use `" + deprecation.to + "` instead" : "remove it") + " (see <" + changelog + "#" + deprecation.id + "> for more info)"
|
|
1628
|
+
);
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
if (options.allowedElements && options.disallowedElements) {
|
|
1632
|
+
(0, import_devlop2.unreachable)("Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other");
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
function parseStage(options) {
|
|
1636
|
+
validateOptions(options);
|
|
1637
|
+
const processor2 = createProcessor(options);
|
|
1638
|
+
const file = createFile(options);
|
|
1639
|
+
const mdast = processor2.parse(file);
|
|
1640
|
+
return { processor: processor2, file, mdast };
|
|
1641
|
+
}
|
|
1642
|
+
function transformStage(parsed) {
|
|
1643
|
+
return parsed.processor.runSync(parsed.mdast, parsed.file);
|
|
1644
|
+
}
|
|
1645
|
+
function renderHastSubtree(tree, options) {
|
|
1646
|
+
const root2 = tree.type === "root" ? tree : { type: "root", children: [tree] };
|
|
1647
|
+
(0, import_unist_util_visit.visit)(
|
|
1648
|
+
root2,
|
|
1649
|
+
buildTransform({
|
|
1650
|
+
allowedElements: options.allowedElements,
|
|
1651
|
+
allowElement: options.allowElement,
|
|
1652
|
+
disallowedElements: options.disallowedElements,
|
|
1653
|
+
skipHtml: options.skipHtml,
|
|
1654
|
+
unwrapDisallowed: options.unwrapDisallowed,
|
|
1655
|
+
urlTransform: options.urlTransform || defaultUrlTransform
|
|
1656
|
+
})
|
|
1657
|
+
);
|
|
1658
|
+
return (0, import_hast_util_to_jsx_runtime.toJsxRuntime)(root2, {
|
|
1659
|
+
Fragment: import_react2.Fragment,
|
|
1660
|
+
components: options.components,
|
|
1661
|
+
ignoreInvalidStyle: true,
|
|
1662
|
+
jsx: import_jsx_runtime2.jsx,
|
|
1663
|
+
jsxs: import_jsx_runtime2.jsxs,
|
|
1664
|
+
passKeys: true,
|
|
1665
|
+
passNode: true
|
|
1666
|
+
});
|
|
1667
|
+
}
|
|
1668
|
+
function Markdown(options) {
|
|
1669
|
+
const parsed = parseStage(options);
|
|
1670
|
+
const tree = transformStage(parsed);
|
|
1671
|
+
return renderHastSubtree(tree, options);
|
|
1672
|
+
}
|
|
1673
|
+
var Markdown_default = Markdown;
|
|
1674
|
+
|
|
1675
|
+
// src/components/MarkdownContent.tsx
|
|
1676
|
+
var import_rehype_katex = __toESM(require("rehype-katex"), 1);
|
|
1677
|
+
var import_rehype_raw = __toESM(require("rehype-raw"), 1);
|
|
1678
|
+
var import_rehype_unwrap_images = __toESM(require("rehype-unwrap-images"), 1);
|
|
1679
|
+
var import_rehype_sanitize2 = __toESM(require("rehype-sanitize"), 1);
|
|
1680
|
+
|
|
1681
|
+
// src/components/sanitizeSchema.ts
|
|
1682
|
+
var import_rehype_sanitize = require("rehype-sanitize");
|
|
1683
|
+
function mergeClassNameAllowlist(existing, extraClassNames) {
|
|
1684
|
+
const entries = existing ? [...existing] : [];
|
|
1685
|
+
const idx = entries.findIndex(
|
|
1686
|
+
(entry) => typeof entry === "string" ? entry === "className" : entry[0] === "className"
|
|
1687
|
+
);
|
|
1688
|
+
if (idx === -1) {
|
|
1689
|
+
return [...entries, ["className", ...extraClassNames]];
|
|
1690
|
+
}
|
|
1691
|
+
const current = entries[idx];
|
|
1692
|
+
const merged = typeof current === "string" ? ["className", ...extraClassNames] : [...current, ...extraClassNames];
|
|
1693
|
+
entries[idx] = merged;
|
|
1694
|
+
return entries;
|
|
1695
|
+
}
|
|
1696
|
+
var crossChunkTags = ["cross-chunk-link", "cross-chunk-image", "footnote-sup"];
|
|
1697
|
+
var sanitizeSchema = {
|
|
1698
|
+
...import_rehype_sanitize.defaultSchema,
|
|
1699
|
+
tagNames: [...import_rehype_sanitize.defaultSchema.tagNames || [], "mark", ...crossChunkTags],
|
|
1700
|
+
attributes: {
|
|
1701
|
+
...import_rehype_sanitize.defaultSchema.attributes,
|
|
1702
|
+
code: mergeClassNameAllowlist(import_rehype_sanitize.defaultSchema.attributes?.code, ["math-inline", "math-display"]),
|
|
1703
|
+
"cross-chunk-link": ["label", "referenceType", "documentId"],
|
|
1704
|
+
"cross-chunk-image": ["label", "referenceType", "documentId", "alt"],
|
|
1705
|
+
"footnote-sup": ["label", "localOccurrence", "documentId"]
|
|
1706
|
+
}
|
|
1707
|
+
};
|
|
1708
|
+
|
|
1709
|
+
// src/components/rehypeRebaseHashLinks.ts
|
|
1710
|
+
var import_unist_util_visit2 = require("unist-util-visit");
|
|
1711
|
+
var DEFAULT_PREFIX = "user-content-";
|
|
1712
|
+
var rehypeRebaseHashLinks = (options) => {
|
|
1713
|
+
const prefix = options?.prefix ?? DEFAULT_PREFIX;
|
|
1714
|
+
const hashPrefix = "#" + prefix;
|
|
1715
|
+
return (tree) => {
|
|
1716
|
+
(0, import_unist_util_visit2.visit)(tree, "element", (node) => {
|
|
1717
|
+
if (node.tagName !== "a") return;
|
|
1718
|
+
const href = node.properties?.href;
|
|
1719
|
+
if (typeof href !== "string" || !href.startsWith("#")) return;
|
|
1720
|
+
if (href.startsWith(hashPrefix)) return;
|
|
1721
|
+
node.properties.href = hashPrefix + href.slice(1);
|
|
1722
|
+
});
|
|
1723
|
+
};
|
|
1724
|
+
};
|
|
1725
|
+
var rehypeRebaseHashLinks_default = rehypeRebaseHashLinks;
|
|
1726
|
+
|
|
1727
|
+
// src/components/rehypeFooterAdorn.ts
|
|
1728
|
+
var import_unist_util_visit3 = require("unist-util-visit");
|
|
1729
|
+
var FOOTNOTE_LABEL_ID_RE = /(?:^|-)footnote-label$/;
|
|
1730
|
+
function isFootnoteLabelH2(node) {
|
|
1731
|
+
if (node.type !== "element") return false;
|
|
1732
|
+
const el = node;
|
|
1733
|
+
if (el.tagName !== "h2") return false;
|
|
1734
|
+
const id = el.properties?.id;
|
|
1735
|
+
return typeof id === "string" && FOOTNOTE_LABEL_ID_RE.test(id);
|
|
1736
|
+
}
|
|
1737
|
+
function isHr(node) {
|
|
1738
|
+
if (node.type !== "element") return false;
|
|
1739
|
+
return node.tagName === "hr";
|
|
1740
|
+
}
|
|
1741
|
+
function rehypeFooterAdorn() {
|
|
1742
|
+
return (tree) => {
|
|
1743
|
+
(0, import_unist_util_visit3.visit)(tree, "element", (n) => {
|
|
1744
|
+
const el = n;
|
|
1745
|
+
if (el.tagName !== "section") return;
|
|
1746
|
+
if (!(el.properties && "dataFootnotes" in el.properties)) return;
|
|
1747
|
+
const filtered = el.children.filter((c) => !isFootnoteLabelH2(c));
|
|
1748
|
+
if (!filtered.some(isHr)) {
|
|
1749
|
+
const hr = {
|
|
1750
|
+
type: "element",
|
|
1751
|
+
tagName: "hr",
|
|
1752
|
+
properties: {},
|
|
1753
|
+
children: []
|
|
1754
|
+
};
|
|
1755
|
+
filtered.unshift(hr);
|
|
1756
|
+
}
|
|
1757
|
+
el.children = filtered;
|
|
1758
|
+
if (!el.properties) el.properties = {};
|
|
1759
|
+
if (!("ariaLabel" in el.properties)) {
|
|
1760
|
+
el.properties.ariaLabel = "Footnotes";
|
|
1761
|
+
}
|
|
1762
|
+
});
|
|
1763
|
+
};
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
// src/components/MarkdownContent.tsx
|
|
1767
|
+
var import_remark_breaks = __toESM(require("remark-breaks"), 1);
|
|
1768
|
+
var import_remark_cjk_friendly = __toESM(require("remark-cjk-friendly"), 1);
|
|
1769
|
+
var import_remark_cjk_friendly_gfm_strikethrough = __toESM(require("remark-cjk-friendly-gfm-strikethrough"), 1);
|
|
1770
|
+
var import_remark_emoji = __toESM(require("remark-emoji"), 1);
|
|
1771
|
+
var import_remark_gfm2 = __toESM(require("remark-gfm"), 1);
|
|
1772
|
+
var import_remark_math = __toESM(require("remark-math"), 1);
|
|
1773
|
+
var import_remark_definition_list = require("remark-definition-list");
|
|
1774
|
+
var import_remark_mark_highlight = require("remark-mark-highlight");
|
|
1775
|
+
var import_remark_squeeze_paragraphs = __toESM(require("remark-squeeze-paragraphs"), 1);
|
|
1776
|
+
var import_remark_smartypants = __toESM(require("remark-smartypants"), 1);
|
|
1777
|
+
var import_remark_pangu = __toESM(require("remark-pangu"), 1);
|
|
1778
|
+
var import_remark_remove_comments = __toESM(require("remark-remove-comments"), 1);
|
|
1779
|
+
|
|
1780
|
+
// src/components/blockMemo.ts
|
|
1781
|
+
var import_unist_util_visit4 = require("unist-util-visit");
|
|
1782
|
+
|
|
1783
|
+
// src/components/normalizeId.ts
|
|
1784
|
+
function normalizeId(s) {
|
|
1785
|
+
return s.replace(/\s+/g, " ").toUpperCase();
|
|
1786
|
+
}
|
|
1787
|
+
function normalizeForMatch(s) {
|
|
1788
|
+
return s.replace(/\\(.)/g, "$1").replace(/\s+/g, " ").toUpperCase();
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
// src/components/blockMemo.ts
|
|
1792
|
+
var TAINT_TYPES = /* @__PURE__ */ new Set([
|
|
1793
|
+
"footnoteReference",
|
|
1794
|
+
"footnoteDefinition",
|
|
1795
|
+
"linkReference",
|
|
1796
|
+
"imageReference",
|
|
1797
|
+
"definition"
|
|
1798
|
+
]);
|
|
1799
|
+
var CTX_TYPES = TAINT_TYPES;
|
|
1800
|
+
function createCache() {
|
|
1801
|
+
return { blocks: /* @__PURE__ */ new Map() };
|
|
1802
|
+
}
|
|
1803
|
+
function extractRaw(node, source) {
|
|
1804
|
+
if (!node.position) return "";
|
|
1805
|
+
return source.slice(node.position.start.offset, node.position.end.offset);
|
|
1806
|
+
}
|
|
1807
|
+
function isFootnoteSection(node) {
|
|
1808
|
+
if (node.tagName !== "section") return false;
|
|
1809
|
+
const props = node.properties;
|
|
1810
|
+
return props?.dataFootnotes !== void 0;
|
|
1811
|
+
}
|
|
1812
|
+
function hasMdastSource(node) {
|
|
1813
|
+
return node.position !== void 0;
|
|
1814
|
+
}
|
|
1815
|
+
var FOOTNOTE_SECTION_KEY = "__footnote_section__";
|
|
1816
|
+
function buildBlocks(mdast, hast, source) {
|
|
1817
|
+
const mdastByOffset = /* @__PURE__ */ new Map();
|
|
1818
|
+
const mdastRanges = [];
|
|
1819
|
+
for (const child of mdast.children) {
|
|
1820
|
+
const off = child.position?.start.offset;
|
|
1821
|
+
const endOff = child.position?.end.offset;
|
|
1822
|
+
if (off !== void 0) {
|
|
1823
|
+
mdastByOffset.set(off, child);
|
|
1824
|
+
}
|
|
1825
|
+
if (off !== void 0 && endOff !== void 0) {
|
|
1826
|
+
mdastRanges.push({ start: off, end: endOff, node: child });
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1830
|
+
for (let i = 1; i < mdastRanges.length; i++) {
|
|
1831
|
+
if (mdastRanges[i].start < mdastRanges[i - 1].start) {
|
|
1832
|
+
throw new Error(
|
|
1833
|
+
"block-memo: mdast.children not sorted by source offset \u2014 a remark plugin is reordering top-level children."
|
|
1834
|
+
);
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
function findContainingMdast(offset) {
|
|
1839
|
+
let lo = 0;
|
|
1840
|
+
let hi = mdastRanges.length;
|
|
1841
|
+
while (lo < hi) {
|
|
1842
|
+
const mid = lo + hi >>> 1;
|
|
1843
|
+
if (mdastRanges[mid].start <= offset) lo = mid + 1;
|
|
1844
|
+
else hi = mid;
|
|
1845
|
+
}
|
|
1846
|
+
const idx = lo - 1;
|
|
1847
|
+
if (idx < 0) return void 0;
|
|
1848
|
+
const r = mdastRanges[idx];
|
|
1849
|
+
return offset < r.end ? r.node : void 0;
|
|
1850
|
+
}
|
|
1851
|
+
const ctxParts = [];
|
|
1852
|
+
(0, import_unist_util_visit4.visit)(mdast, (n) => {
|
|
1853
|
+
if (!CTX_TYPES.has(n.type)) return;
|
|
1854
|
+
if (n.type === "footnoteReference") ctxParts.push(["fr", n.identifier]);
|
|
1855
|
+
else if (n.type === "footnoteDefinition") ctxParts.push(["fd", n.identifier, extractRaw(n, source)]);
|
|
1856
|
+
else if (n.type === "linkReference") ctxParts.push(["lr", n.identifier]);
|
|
1857
|
+
else if (n.type === "imageReference") ctxParts.push(["ir", n.identifier]);
|
|
1858
|
+
else if (n.type === "definition") ctxParts.push(["d", n.identifier, n.url, n.title ?? null]);
|
|
1859
|
+
});
|
|
1860
|
+
const globalCtx = JSON.stringify(ctxParts);
|
|
1861
|
+
const plan = [];
|
|
1862
|
+
const blocks = [];
|
|
1863
|
+
const blockHasts = [];
|
|
1864
|
+
let synthetic;
|
|
1865
|
+
for (let i = 0; i < hast.children.length; i++) {
|
|
1866
|
+
const hastChild = hast.children[i];
|
|
1867
|
+
if (hastChild.type !== "element") {
|
|
1868
|
+
const off = hastChild.position?.start.offset;
|
|
1869
|
+
const reactKey = off !== void 0 ? `inline-${off}` : `inline-i${i}`;
|
|
1870
|
+
plan.push({ kind: "inline", el: hastChild, reactKey });
|
|
1871
|
+
continue;
|
|
1872
|
+
}
|
|
1873
|
+
const el = hastChild;
|
|
1874
|
+
if (isFootnoteSection(el)) {
|
|
1875
|
+
synthetic = el;
|
|
1876
|
+
plan.push({ kind: "synthetic", el, reactKey: FOOTNOTE_SECTION_KEY });
|
|
1877
|
+
continue;
|
|
1878
|
+
}
|
|
1879
|
+
const hastOffset = el.position?.start.offset;
|
|
1880
|
+
if (hastOffset === void 0) {
|
|
1881
|
+
plan.push({ kind: "inline", el, reactKey: `inline-i${i}` });
|
|
1882
|
+
continue;
|
|
1883
|
+
}
|
|
1884
|
+
let mdastNode = mdastByOffset.get(hastOffset);
|
|
1885
|
+
if (!mdastNode) {
|
|
1886
|
+
mdastNode = findContainingMdast(hastOffset);
|
|
1887
|
+
}
|
|
1888
|
+
if (!mdastNode) {
|
|
1889
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1890
|
+
throw new Error(
|
|
1891
|
+
`block-memo: hast block at offset ${hastOffset} has no mdast counterpart. A rehype plugin may have synthesized positions outside source. tagName=${el.tagName}`
|
|
1892
|
+
);
|
|
1893
|
+
}
|
|
1894
|
+
plan.push({ kind: "inline", el, reactKey: `inline-${hastOffset}` });
|
|
1895
|
+
continue;
|
|
1896
|
+
}
|
|
1897
|
+
if (mdastNode.type === "footnoteDefinition") {
|
|
1898
|
+
plan.push({ kind: "inline", el, reactKey: `inline-${hastOffset}` });
|
|
1899
|
+
continue;
|
|
1900
|
+
}
|
|
1901
|
+
let hasReference = false;
|
|
1902
|
+
const footnoteRefLabels = [];
|
|
1903
|
+
const linkRefLabels = [];
|
|
1904
|
+
const imageRefLabels = [];
|
|
1905
|
+
const footnoteDefLabels = [];
|
|
1906
|
+
(0, import_unist_util_visit4.visit)(mdastNode, (n) => {
|
|
1907
|
+
if (!TAINT_TYPES.has(n.type)) return;
|
|
1908
|
+
hasReference = true;
|
|
1909
|
+
const id = "identifier" in n ? normalizeId(String(n.identifier)) : null;
|
|
1910
|
+
if (id === null) return;
|
|
1911
|
+
if (n.type === "footnoteReference") footnoteRefLabels.push(id);
|
|
1912
|
+
else if (n.type === "linkReference") linkRefLabels.push(id);
|
|
1913
|
+
else if (n.type === "imageReference") imageRefLabels.push(id);
|
|
1914
|
+
else if (n.type === "footnoteDefinition") footnoteDefLabels.push(id);
|
|
1915
|
+
});
|
|
1916
|
+
const mdastPos = mdastNode.position;
|
|
1917
|
+
if (!mdastPos || mdastPos.start.offset === void 0 || mdastPos.end.offset === void 0) {
|
|
1918
|
+
continue;
|
|
1919
|
+
}
|
|
1920
|
+
const info = {
|
|
1921
|
+
raw: extractRaw(mdastNode, source),
|
|
1922
|
+
startOffset: mdastPos.start.offset,
|
|
1923
|
+
endOffset: mdastPos.end.offset,
|
|
1924
|
+
startLine: mdastPos.start.line,
|
|
1925
|
+
startColumn: mdastPos.start.column,
|
|
1926
|
+
hasReference,
|
|
1927
|
+
...hasReference ? {
|
|
1928
|
+
taintLabels: { footnoteRefLabels, linkRefLabels, imageRefLabels, footnoteDefLabels }
|
|
1929
|
+
} : {}
|
|
1930
|
+
};
|
|
1931
|
+
blocks.push(info);
|
|
1932
|
+
blockHasts.push(el);
|
|
1933
|
+
plan.push({ kind: "block", el, info, reactKey: `block-${hastOffset}` });
|
|
1934
|
+
}
|
|
1935
|
+
return { plan, globalCtx, blocks, blockHasts, synthetic };
|
|
1936
|
+
}
|
|
1937
|
+
function computeBlockFingerprint(taintLabels, registry, thisChunkSym, clobberPrefix) {
|
|
1938
|
+
const parts = [clobberPrefix];
|
|
1939
|
+
for (const label of taintLabels.footnoteRefLabels) {
|
|
1940
|
+
parts.push(`fn:${label}=${registry.globalNumber(label) ?? "null"}`);
|
|
1941
|
+
}
|
|
1942
|
+
for (const label of taintLabels.linkRefLabels) {
|
|
1943
|
+
const def = registry.resolveLinkDef(label);
|
|
1944
|
+
parts.push(`lr:${label}=${def?.url ?? "null"}|${def?.title ?? ""}`);
|
|
1945
|
+
}
|
|
1946
|
+
for (const label of taintLabels.imageRefLabels) {
|
|
1947
|
+
const def = registry.resolveLinkDef(label);
|
|
1948
|
+
parts.push(`ir:${label}=${def?.url ?? "null"}|${def?.title ?? ""}`);
|
|
1949
|
+
}
|
|
1950
|
+
for (const label of taintLabels.footnoteDefLabels) {
|
|
1951
|
+
const isCanonical = registry.canonicalFootnoteFor(label) === thisChunkSym ? 1 : 0;
|
|
1952
|
+
parts.push(`fd:${label}=${isCanonical}/${registry.getRefsForLabel(label)}`);
|
|
1953
|
+
}
|
|
1954
|
+
return parts.join("|");
|
|
1955
|
+
}
|
|
1956
|
+
function renderBlocksWithCache(cacheRef, plan, globalCtx, postOptions) {
|
|
1957
|
+
const prev = cacheRef.current;
|
|
1958
|
+
const next = { blocks: /* @__PURE__ */ new Map() };
|
|
1959
|
+
const rendered = [];
|
|
1960
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1961
|
+
for (const item of plan) {
|
|
1962
|
+
if (item.kind === "block" && !hasMdastSource(item.el)) {
|
|
1963
|
+
throw new Error(
|
|
1964
|
+
"block-memo: block hast child has no position. Did a rehype plugin strip it? (Run positionPropagation.test.ts to verify.)"
|
|
1965
|
+
);
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
for (const item of plan) {
|
|
1970
|
+
if (item.kind === "inline") {
|
|
1971
|
+
rendered.push({
|
|
1972
|
+
node: renderHastSubtree(item.el, postOptions),
|
|
1973
|
+
reactKey: item.reactKey
|
|
1974
|
+
});
|
|
1975
|
+
continue;
|
|
1976
|
+
}
|
|
1977
|
+
if (item.kind === "synthetic") {
|
|
1978
|
+
if (postOptions.registry && postOptions.thisChunkSymbol) {
|
|
1979
|
+
continue;
|
|
1980
|
+
}
|
|
1981
|
+
const cached = prev.footnoteSection;
|
|
1982
|
+
let node;
|
|
1983
|
+
if (cached && cached.ctx === globalCtx) {
|
|
1984
|
+
node = cached.node;
|
|
1985
|
+
} else {
|
|
1986
|
+
node = renderHastSubtree(item.el, postOptions);
|
|
1987
|
+
}
|
|
1988
|
+
next.footnoteSection = { ctx: globalCtx, node };
|
|
1989
|
+
rendered.push({ node, reactKey: item.reactKey });
|
|
1990
|
+
continue;
|
|
1991
|
+
}
|
|
1992
|
+
const block = item.info;
|
|
1993
|
+
let bucket = next.blocks.get(block.raw);
|
|
1994
|
+
if (!bucket) {
|
|
1995
|
+
bucket = [];
|
|
1996
|
+
next.blocks.set(block.raw, bucket);
|
|
1997
|
+
}
|
|
1998
|
+
const occ = bucket.length;
|
|
1999
|
+
if (block.hasReference) {
|
|
2000
|
+
const useFingerprint = postOptions.registry && block.taintLabels && postOptions.thisChunkSymbol && postOptions.clobberPrefix !== void 0;
|
|
2001
|
+
const blockCtx = useFingerprint ? computeBlockFingerprint(
|
|
2002
|
+
block.taintLabels,
|
|
2003
|
+
postOptions.registry,
|
|
2004
|
+
postOptions.thisChunkSymbol,
|
|
2005
|
+
postOptions.clobberPrefix
|
|
2006
|
+
) : globalCtx;
|
|
2007
|
+
const entry = prev.blocks.get(block.raw)?.[occ];
|
|
2008
|
+
const valid = entry !== void 0 && entry.ctx === blockCtx && entry.startOffset === block.startOffset && entry.startLine === block.startLine && entry.startColumn === block.startColumn;
|
|
2009
|
+
let node;
|
|
2010
|
+
if (valid) {
|
|
2011
|
+
node = entry.node;
|
|
2012
|
+
} else {
|
|
2013
|
+
node = renderHastSubtree(item.el, postOptions);
|
|
2014
|
+
}
|
|
2015
|
+
bucket.push({
|
|
2016
|
+
node,
|
|
2017
|
+
ctx: blockCtx,
|
|
2018
|
+
startOffset: block.startOffset,
|
|
2019
|
+
startLine: block.startLine,
|
|
2020
|
+
startColumn: block.startColumn
|
|
2021
|
+
});
|
|
2022
|
+
rendered.push({ node, reactKey: item.reactKey });
|
|
2023
|
+
continue;
|
|
2024
|
+
}
|
|
2025
|
+
{
|
|
2026
|
+
const entry = prev.blocks.get(block.raw)?.[occ];
|
|
2027
|
+
const valid = entry !== void 0 && entry.ctx === "" && entry.startOffset === block.startOffset && entry.startLine === block.startLine && entry.startColumn === block.startColumn;
|
|
2028
|
+
const node = valid ? entry.node : renderHastSubtree(item.el, postOptions);
|
|
2029
|
+
bucket.push({
|
|
2030
|
+
node,
|
|
2031
|
+
ctx: "",
|
|
2032
|
+
startOffset: block.startOffset,
|
|
2033
|
+
startLine: block.startLine,
|
|
2034
|
+
startColumn: block.startColumn
|
|
2035
|
+
});
|
|
2036
|
+
rendered.push({ node, reactKey: item.reactKey });
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
cacheRef.current = next;
|
|
2040
|
+
return rendered;
|
|
2041
|
+
}
|
|
2042
|
+
|
|
2043
|
+
// src/components/collectDefLabels.ts
|
|
2044
|
+
var import_unified2 = require("unified");
|
|
2045
|
+
var import_remark_parse2 = __toESM(require("remark-parse"), 1);
|
|
2046
|
+
var import_remark_gfm = __toESM(require("remark-gfm"), 1);
|
|
2047
|
+
var import_unist_util_visit5 = require("unist-util-visit");
|
|
2048
|
+
function buildProcessor() {
|
|
2049
|
+
return (0, import_unified2.unified)().use(import_remark_parse2.default).use(import_remark_gfm.default);
|
|
2050
|
+
}
|
|
2051
|
+
var _processor = null;
|
|
2052
|
+
function processor() {
|
|
2053
|
+
if (!_processor) _processor = buildProcessor();
|
|
2054
|
+
return _processor;
|
|
2055
|
+
}
|
|
2056
|
+
function collectDefLabels(source) {
|
|
2057
|
+
if (!source) {
|
|
2058
|
+
return { footnoteLabels: /* @__PURE__ */ new Set(), linkLabels: /* @__PURE__ */ new Set() };
|
|
2059
|
+
}
|
|
2060
|
+
const mdast = processor().parse(source);
|
|
2061
|
+
const footnoteLabels = /* @__PURE__ */ new Set();
|
|
2062
|
+
const linkLabels = /* @__PURE__ */ new Set();
|
|
2063
|
+
(0, import_unist_util_visit5.visit)(mdast, (node) => {
|
|
2064
|
+
if (node.type === "footnoteDefinition" && "identifier" in node) {
|
|
2065
|
+
footnoteLabels.add(normalizeId(node.identifier));
|
|
2066
|
+
} else if (node.type === "definition" && "identifier" in node) {
|
|
2067
|
+
linkLabels.add(normalizeId(node.identifier));
|
|
2068
|
+
}
|
|
2069
|
+
});
|
|
2070
|
+
return { footnoteLabels, linkLabels };
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
// src/components/AIMarkdownDocuments.tsx
|
|
2074
|
+
var import_react3 = require("react");
|
|
2075
|
+
|
|
2076
|
+
// src/components/documentRegistry.ts
|
|
2077
|
+
function createRegistry(onEmpty) {
|
|
2078
|
+
const reg = {
|
|
2079
|
+
chunkOrder: [],
|
|
2080
|
+
chunkData: /* @__PURE__ */ new Map(),
|
|
2081
|
+
labelSet: { footnoteLabels: /* @__PURE__ */ new Set(), linkLabels: /* @__PURE__ */ new Set() },
|
|
2082
|
+
version: 0,
|
|
2083
|
+
_reactIdMap: /* @__PURE__ */ new Map(),
|
|
2084
|
+
_subscribers: /* @__PURE__ */ new Set(),
|
|
2085
|
+
_notifyScheduled: false,
|
|
2086
|
+
allocateSymbol(reactId) {
|
|
2087
|
+
const existing = this._reactIdMap.get(reactId);
|
|
2088
|
+
if (existing) {
|
|
2089
|
+
existing.refcount++;
|
|
2090
|
+
return existing.symbol;
|
|
2091
|
+
}
|
|
2092
|
+
const sym = Symbol(reactId);
|
|
2093
|
+
this._reactIdMap.set(reactId, { symbol: sym, refcount: 1 });
|
|
2094
|
+
this.chunkOrder.push(sym);
|
|
2095
|
+
this._notify();
|
|
2096
|
+
return sym;
|
|
2097
|
+
},
|
|
2098
|
+
registerChunk(reactId, footnotes, links) {
|
|
2099
|
+
const sym = this.allocateSymbol(reactId);
|
|
2100
|
+
this.contributeLabels(sym, footnotes, links);
|
|
2101
|
+
return sym;
|
|
2102
|
+
},
|
|
2103
|
+
releaseSymbol(reactId) {
|
|
2104
|
+
const entry = this._reactIdMap.get(reactId);
|
|
2105
|
+
if (!entry) return;
|
|
2106
|
+
entry.refcount--;
|
|
2107
|
+
if (entry.refcount === 0) {
|
|
2108
|
+
queueMicrotask(() => {
|
|
2109
|
+
const latest = this._reactIdMap.get(reactId);
|
|
2110
|
+
if (latest && latest.refcount === 0) {
|
|
2111
|
+
this._reactIdMap.delete(reactId);
|
|
2112
|
+
const idx = this.chunkOrder.indexOf(entry.symbol);
|
|
2113
|
+
if (idx !== -1) this.chunkOrder.splice(idx, 1);
|
|
2114
|
+
this.chunkData.delete(entry.symbol);
|
|
2115
|
+
const nextFn = /* @__PURE__ */ new Set();
|
|
2116
|
+
const nextLink = /* @__PURE__ */ new Set();
|
|
2117
|
+
for (const cd of this.chunkData.values()) {
|
|
2118
|
+
for (const l of cd.ownFootnoteLabels) nextFn.add(l);
|
|
2119
|
+
for (const l of cd.ownLinkLabels) nextLink.add(l);
|
|
2120
|
+
}
|
|
2121
|
+
this.labelSet.footnoteLabels = nextFn;
|
|
2122
|
+
this.labelSet.linkLabels = nextLink;
|
|
2123
|
+
this._notify();
|
|
2124
|
+
if (this.chunkOrder.length === 0 && this.chunkData.size === 0 && onEmpty) {
|
|
2125
|
+
onEmpty();
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
});
|
|
2129
|
+
}
|
|
2130
|
+
},
|
|
2131
|
+
contributeLabels(symbol, footnotes, links) {
|
|
2132
|
+
const data = this.chunkData.get(symbol);
|
|
2133
|
+
if (data) {
|
|
2134
|
+
data.ownFootnoteLabels = footnotes;
|
|
2135
|
+
data.ownLinkLabels = links;
|
|
2136
|
+
} else {
|
|
2137
|
+
this.chunkData.set(symbol, {
|
|
2138
|
+
refs: [],
|
|
2139
|
+
defs: /* @__PURE__ */ new Map(),
|
|
2140
|
+
linkDefs: /* @__PURE__ */ new Map(),
|
|
2141
|
+
ownFootnoteLabels: footnotes,
|
|
2142
|
+
ownLinkLabels: links
|
|
2143
|
+
});
|
|
2144
|
+
}
|
|
2145
|
+
const newFn = /* @__PURE__ */ new Set();
|
|
2146
|
+
const newLink = /* @__PURE__ */ new Set();
|
|
2147
|
+
for (const cd of this.chunkData.values()) {
|
|
2148
|
+
for (const l of cd.ownFootnoteLabels) newFn.add(l);
|
|
2149
|
+
for (const l of cd.ownLinkLabels) newLink.add(l);
|
|
2150
|
+
}
|
|
2151
|
+
this.labelSet.footnoteLabels = newFn;
|
|
2152
|
+
this.labelSet.linkLabels = newLink;
|
|
2153
|
+
this._notify();
|
|
2154
|
+
},
|
|
2155
|
+
contributeChunkData(symbol, data) {
|
|
2156
|
+
this.chunkData.set(symbol, data);
|
|
2157
|
+
this.labelSet.footnoteLabels = /* @__PURE__ */ new Set();
|
|
2158
|
+
this.labelSet.linkLabels = /* @__PURE__ */ new Set();
|
|
2159
|
+
for (const cd of this.chunkData.values()) {
|
|
2160
|
+
for (const l of cd.ownFootnoteLabels) this.labelSet.footnoteLabels.add(l);
|
|
2161
|
+
for (const l of cd.ownLinkLabels) this.labelSet.linkLabels.add(l);
|
|
2162
|
+
}
|
|
2163
|
+
this._notify();
|
|
2164
|
+
},
|
|
2165
|
+
subscribe(cb) {
|
|
2166
|
+
this._subscribers.add(cb);
|
|
2167
|
+
return () => {
|
|
2168
|
+
this._subscribers.delete(cb);
|
|
2169
|
+
};
|
|
2170
|
+
},
|
|
2171
|
+
canonicalFootnoteFor(label) {
|
|
2172
|
+
const id = normalizeId(label);
|
|
2173
|
+
for (const sym of this.chunkOrder) {
|
|
2174
|
+
const data = this.chunkData.get(sym);
|
|
2175
|
+
if (data?.defs.has(id)) return sym;
|
|
2176
|
+
}
|
|
2177
|
+
return null;
|
|
2178
|
+
},
|
|
2179
|
+
canonicalLinkFor(label) {
|
|
2180
|
+
const id = normalizeId(label);
|
|
2181
|
+
for (const sym of this.chunkOrder) {
|
|
2182
|
+
const data = this.chunkData.get(sym);
|
|
2183
|
+
if (data?.linkDefs.has(id)) return sym;
|
|
2184
|
+
}
|
|
2185
|
+
return null;
|
|
2186
|
+
},
|
|
2187
|
+
globalNumber(label) {
|
|
2188
|
+
const id = normalizeId(label);
|
|
2189
|
+
let n = 0;
|
|
2190
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2191
|
+
for (const sym of this.chunkOrder) {
|
|
2192
|
+
const data = this.chunkData.get(sym);
|
|
2193
|
+
if (!data) continue;
|
|
2194
|
+
for (const ref of data.refs) {
|
|
2195
|
+
if (ref.kind !== "footnote") continue;
|
|
2196
|
+
if (!seen.has(ref.label)) {
|
|
2197
|
+
seen.add(ref.label);
|
|
2198
|
+
n++;
|
|
2199
|
+
if (ref.label === id) return n;
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
return null;
|
|
2204
|
+
},
|
|
2205
|
+
resolveLinkDef(label) {
|
|
2206
|
+
const sym = this.canonicalLinkFor(label);
|
|
2207
|
+
if (!sym) return null;
|
|
2208
|
+
return this.chunkData.get(sym)?.linkDefs.get(normalizeId(label)) ?? null;
|
|
2209
|
+
},
|
|
2210
|
+
getRefsForLabel(label) {
|
|
2211
|
+
const id = normalizeId(label);
|
|
2212
|
+
let n = 0;
|
|
2213
|
+
for (const sym of this.chunkOrder) {
|
|
2214
|
+
const data = this.chunkData.get(sym);
|
|
2215
|
+
if (!data) continue;
|
|
2216
|
+
for (const ref of data.refs) {
|
|
2217
|
+
if (ref.kind === "footnote" && ref.label === id) n++;
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
return n;
|
|
2221
|
+
},
|
|
2222
|
+
globalOccurrenceForRef(chunkSym, label, localOccurrence) {
|
|
2223
|
+
const id = normalizeId(label);
|
|
2224
|
+
let global2 = 0;
|
|
2225
|
+
for (const sym of this.chunkOrder) {
|
|
2226
|
+
const data = this.chunkData.get(sym);
|
|
2227
|
+
if (!data) continue;
|
|
2228
|
+
let localCount = 0;
|
|
2229
|
+
for (const ref of data.refs) {
|
|
2230
|
+
if (ref.kind !== "footnote") continue;
|
|
2231
|
+
if (ref.label !== id) continue;
|
|
2232
|
+
localCount++;
|
|
2233
|
+
global2++;
|
|
2234
|
+
if (sym === chunkSym && localCount === localOccurrence) return global2;
|
|
2235
|
+
}
|
|
2236
|
+
}
|
|
2237
|
+
return null;
|
|
2238
|
+
},
|
|
2239
|
+
_notify() {
|
|
2240
|
+
this.version++;
|
|
2241
|
+
if (this._notifyScheduled) return;
|
|
2242
|
+
this._notifyScheduled = true;
|
|
2243
|
+
queueMicrotask(() => {
|
|
2244
|
+
this._notifyScheduled = false;
|
|
2245
|
+
for (const cb of [...this._subscribers]) cb();
|
|
2246
|
+
});
|
|
2247
|
+
}
|
|
2248
|
+
};
|
|
2249
|
+
return reg;
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2252
|
+
// src/components/AIMarkdownDocuments.tsx
|
|
2253
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
2254
|
+
var AIMarkdownDocumentsContext = (0, import_react3.createContext)(null);
|
|
2255
|
+
var AIMarkdownDocuments = ({ preserveOrphanReferences = true, children }) => {
|
|
2256
|
+
const parent = (0, import_react3.useContext)(AIMarkdownDocumentsContext);
|
|
2257
|
+
if (parent !== null) {
|
|
2258
|
+
throw new Error(
|
|
2259
|
+
"<AIMarkdownDocuments> must not be nested inside another <AIMarkdownDocuments>. Use a single top-level wrapper per coordinated scope."
|
|
2260
|
+
);
|
|
2261
|
+
}
|
|
2262
|
+
const registriesRef = (0, import_react3.useRef)(/* @__PURE__ */ new Map());
|
|
2263
|
+
const value = (0, import_react3.useMemo)(
|
|
2264
|
+
() => ({
|
|
2265
|
+
preserveOrphanReferences,
|
|
2266
|
+
getRegistry(documentId) {
|
|
2267
|
+
let r = registriesRef.current.get(documentId);
|
|
2268
|
+
if (!r) {
|
|
2269
|
+
const created = createRegistry(() => {
|
|
2270
|
+
if (registriesRef.current.get(documentId) === created) {
|
|
2271
|
+
registriesRef.current.delete(documentId);
|
|
2272
|
+
}
|
|
2273
|
+
});
|
|
2274
|
+
r = created;
|
|
2275
|
+
registriesRef.current.set(documentId, r);
|
|
2276
|
+
}
|
|
2277
|
+
return r;
|
|
2278
|
+
}
|
|
2279
|
+
}),
|
|
2280
|
+
[preserveOrphanReferences]
|
|
2281
|
+
);
|
|
2282
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AIMarkdownDocumentsContext.Provider, { value, children });
|
|
2283
|
+
};
|
|
2284
|
+
function useDocumentRegistry(documentId) {
|
|
2285
|
+
const ctx = (0, import_react3.useContext)(AIMarkdownDocumentsContext);
|
|
2286
|
+
if (!ctx || !documentId) return null;
|
|
2287
|
+
return ctx.getRegistry(documentId);
|
|
2288
|
+
}
|
|
2289
|
+
function usePreserveOrphanReferences(fallback) {
|
|
2290
|
+
const ctx = (0, import_react3.useContext)(AIMarkdownDocumentsContext);
|
|
2291
|
+
return ctx?.preserveOrphanReferences ?? fallback;
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2294
|
+
// src/components/remarkInjectPhantomDefs.ts
|
|
2295
|
+
var SENTINEL_LINK_URL = "__aimd_sentinel_link__";
|
|
2296
|
+
var SENTINEL_FN_CONTENT = "__aimd_sentinel_fn__";
|
|
2297
|
+
function augmentSourceWithPhantoms(source, phantoms) {
|
|
2298
|
+
if (phantoms.missingFootnotes.size === 0 && phantoms.missingLinks.size === 0) {
|
|
2299
|
+
return source;
|
|
2300
|
+
}
|
|
2301
|
+
let suffix = "\n\n";
|
|
2302
|
+
for (const label of phantoms.missingLinks) {
|
|
2303
|
+
suffix += `[${label}]: ${SENTINEL_LINK_URL}
|
|
2304
|
+
`;
|
|
2305
|
+
}
|
|
2306
|
+
for (const label of phantoms.missingFootnotes) {
|
|
2307
|
+
suffix += `[^${label}]: ${SENTINEL_FN_CONTENT}
|
|
2308
|
+
`;
|
|
2309
|
+
}
|
|
2310
|
+
return source + suffix;
|
|
2311
|
+
}
|
|
2312
|
+
|
|
2313
|
+
// src/components/customMdastHandlers.ts
|
|
2314
|
+
function buildCrossChunkHandlers() {
|
|
2315
|
+
return {
|
|
2316
|
+
footnoteDefinition: (state, node) => {
|
|
2317
|
+
const s = state;
|
|
2318
|
+
const id = normalizeId(node.identifier);
|
|
2319
|
+
if (s.options.phantomFootnoteLabels.has(id)) {
|
|
2320
|
+
return void 0;
|
|
2321
|
+
}
|
|
2322
|
+
if (s.options.preserveOrphan && !s.footnoteOrder.includes(id)) {
|
|
2323
|
+
s.footnoteOrder.push(id);
|
|
2324
|
+
}
|
|
2325
|
+
return void 0;
|
|
2326
|
+
},
|
|
2327
|
+
linkReference: ((state, node) => {
|
|
2328
|
+
const s = state;
|
|
2329
|
+
const id = normalizeId(node.identifier);
|
|
2330
|
+
const resolved = s.definitionById.has(id);
|
|
2331
|
+
if (!resolved) {
|
|
2332
|
+
return void 0;
|
|
2333
|
+
}
|
|
2334
|
+
return {
|
|
2335
|
+
type: "element",
|
|
2336
|
+
tagName: "cross-chunk-link",
|
|
2337
|
+
properties: {
|
|
2338
|
+
// `label` is the ORIGINAL source text (mdast's `label` field), NOT
|
|
2339
|
+
// the normalized `identifier`. The placeholder uses it to construct
|
|
2340
|
+
// hrefs that line up with mdast-util-to-hast's default `<li id>`
|
|
2341
|
+
// which also preserves source case. Registry lookups normalize
|
|
2342
|
+
// internally, so cross-chunk case-insensitive matching still works.
|
|
2343
|
+
label: node.label ?? node.identifier,
|
|
2344
|
+
referenceType: node.referenceType,
|
|
2345
|
+
documentId: s.options.documentId
|
|
2346
|
+
},
|
|
2347
|
+
children: s.all(node)
|
|
2348
|
+
};
|
|
2349
|
+
}),
|
|
2350
|
+
imageReference: ((state, node) => {
|
|
2351
|
+
const s = state;
|
|
2352
|
+
const id = normalizeId(node.identifier);
|
|
2353
|
+
const resolved = s.definitionById.has(id);
|
|
2354
|
+
if (!resolved) return void 0;
|
|
2355
|
+
return {
|
|
2356
|
+
type: "element",
|
|
2357
|
+
tagName: "cross-chunk-image",
|
|
2358
|
+
properties: {
|
|
2359
|
+
label: node.label ?? node.identifier,
|
|
2360
|
+
referenceType: node.referenceType,
|
|
2361
|
+
alt: node.alt ?? "",
|
|
2362
|
+
documentId: s.options.documentId
|
|
2363
|
+
},
|
|
2364
|
+
children: []
|
|
2365
|
+
};
|
|
2366
|
+
}),
|
|
2367
|
+
footnoteReference: ((state, node) => {
|
|
2368
|
+
const s = state;
|
|
2369
|
+
const id = normalizeId(node.identifier);
|
|
2370
|
+
const localOccurrence = (s.footnoteCounts.get(id) ?? 0) + 1;
|
|
2371
|
+
s.footnoteCounts.set(id, localOccurrence);
|
|
2372
|
+
if (s.options.phantomFootnoteLabels.has(id)) {
|
|
2373
|
+
return {
|
|
2374
|
+
type: "element",
|
|
2375
|
+
tagName: "footnote-sup",
|
|
2376
|
+
properties: {
|
|
2377
|
+
label: node.identifier,
|
|
2378
|
+
localOccurrence,
|
|
2379
|
+
documentId: s.options.documentId
|
|
2380
|
+
},
|
|
2381
|
+
children: []
|
|
2382
|
+
};
|
|
2383
|
+
}
|
|
2384
|
+
if (!s.footnoteOrder.includes(id)) s.footnoteOrder.push(id);
|
|
2385
|
+
return {
|
|
2386
|
+
type: "element",
|
|
2387
|
+
tagName: "footnote-sup",
|
|
2388
|
+
properties: {
|
|
2389
|
+
label: node.identifier,
|
|
2390
|
+
localOccurrence,
|
|
2391
|
+
documentId: s.options.documentId
|
|
2392
|
+
},
|
|
2393
|
+
children: []
|
|
2394
|
+
};
|
|
2395
|
+
})
|
|
2396
|
+
};
|
|
2397
|
+
}
|
|
2398
|
+
|
|
2399
|
+
// src/components/crossChunkPlaceholders.tsx
|
|
2400
|
+
var import_react5 = require("react");
|
|
2401
|
+
|
|
2402
|
+
// src/components/chunkSymbolContext.ts
|
|
2403
|
+
var import_react4 = require("react");
|
|
2404
|
+
var ChunkSymbolContext = (0, import_react4.createContext)(null);
|
|
2405
|
+
|
|
2406
|
+
// src/components/crossChunkPlaceholders.tsx
|
|
2407
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2408
|
+
var SSR_NUM_SNAPSHOT = () => 0;
|
|
2409
|
+
var SSR_DEF_SNAPSHOT = () => null;
|
|
2410
|
+
function coerceLocalOccurrence(v) {
|
|
2411
|
+
if (v === void 0) return null;
|
|
2412
|
+
if (typeof v === "number") return Number.isFinite(v) && v >= 1 ? Math.trunc(v) : null;
|
|
2413
|
+
const n = Number(v);
|
|
2414
|
+
return Number.isFinite(n) && n >= 1 ? Math.trunc(n) : null;
|
|
2415
|
+
}
|
|
2416
|
+
function FootnoteSupNumber({ label, localOccurrence: localOccurrenceRaw }) {
|
|
2417
|
+
const localOccurrence = coerceLocalOccurrence(localOccurrenceRaw);
|
|
2418
|
+
const { documentId, clobberPrefix } = useAIMarkdownRenderState();
|
|
2419
|
+
const registry = useDocumentRegistry(documentId);
|
|
2420
|
+
const chunkSym = (0, import_react5.useContext)(ChunkSymbolContext);
|
|
2421
|
+
const subscribe = (0, import_react5.useCallback)((cb) => registry ? registry.subscribe(cb) : () => {
|
|
2422
|
+
}, [registry]);
|
|
2423
|
+
const getSnapshot = (0, import_react5.useCallback)(() => registry?.version ?? 0, [registry]);
|
|
2424
|
+
(0, import_react5.useSyncExternalStore)(subscribe, getSnapshot, SSR_NUM_SNAPSHOT);
|
|
2425
|
+
const num = registry?.globalNumber(label) ?? null;
|
|
2426
|
+
if (num === null) return null;
|
|
2427
|
+
if (localOccurrence !== null && !chunkSym) return null;
|
|
2428
|
+
const globalOcc = registry && chunkSym && localOccurrence !== null ? registry.globalOccurrenceForRef(chunkSym, label, localOccurrence) : null;
|
|
2429
|
+
if (localOccurrence !== null && globalOcc === null) return null;
|
|
2430
|
+
const occSuffix = globalOcc !== null && globalOcc > 1 ? `-${globalOcc}` : "";
|
|
2431
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("sup", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("a", { href: `#${clobberPrefix}fn-${label}`, id: `${clobberPrefix}fnref-${label}${occSuffix}`, "data-footnote-ref": true, children: num }) });
|
|
2432
|
+
}
|
|
2433
|
+
function reactNodeToText(node) {
|
|
2434
|
+
if (node === null || node === void 0 || typeof node === "boolean") return "";
|
|
2435
|
+
if (typeof node === "string") return node;
|
|
2436
|
+
if (typeof node === "number" || typeof node === "bigint") return String(node);
|
|
2437
|
+
if (Array.isArray(node)) return node.map(reactNodeToText).join("");
|
|
2438
|
+
if ((0, import_react5.isValidElement)(node)) {
|
|
2439
|
+
return reactNodeToText(node.props.children);
|
|
2440
|
+
}
|
|
2441
|
+
return "";
|
|
2442
|
+
}
|
|
2443
|
+
function literalLink(rt, label, children) {
|
|
2444
|
+
const text = reactNodeToText(children);
|
|
2445
|
+
switch (rt) {
|
|
2446
|
+
case "full":
|
|
2447
|
+
return `[${text}][${label}]`;
|
|
2448
|
+
case "collapsed":
|
|
2449
|
+
return `[${label}][]`;
|
|
2450
|
+
case "shortcut":
|
|
2451
|
+
default:
|
|
2452
|
+
return `[${label}]`;
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2455
|
+
function CrossChunkLink({ label, referenceType, children }) {
|
|
2456
|
+
const { documentId } = useAIMarkdownRenderState();
|
|
2457
|
+
const registry = useDocumentRegistry(documentId);
|
|
2458
|
+
const subscribe = (0, import_react5.useCallback)((cb) => registry ? registry.subscribe(cb) : () => {
|
|
2459
|
+
}, [registry]);
|
|
2460
|
+
const getSnapshot = (0, import_react5.useCallback)(() => registry?.resolveLinkDef(label) ?? null, [registry, label]);
|
|
2461
|
+
const def = (0, import_react5.useSyncExternalStore)(subscribe, getSnapshot, SSR_DEF_SNAPSHOT);
|
|
2462
|
+
if (!def) {
|
|
2463
|
+
return literalLink(referenceType, label, children);
|
|
2464
|
+
}
|
|
2465
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("a", { href: def.url, title: def.title, children });
|
|
2466
|
+
}
|
|
2467
|
+
function literalImage(rt, label, alt) {
|
|
2468
|
+
switch (rt) {
|
|
2469
|
+
case "full":
|
|
2470
|
+
return `![${alt}][${label}]`;
|
|
2471
|
+
case "collapsed":
|
|
2472
|
+
return `![${alt}][]`;
|
|
2473
|
+
case "shortcut":
|
|
2474
|
+
default:
|
|
2475
|
+
return `![${label}]`;
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2478
|
+
function CrossChunkImage({ label, referenceType, alt = "" }) {
|
|
2479
|
+
const { documentId } = useAIMarkdownRenderState();
|
|
2480
|
+
const registry = useDocumentRegistry(documentId);
|
|
2481
|
+
const subscribe = (0, import_react5.useCallback)((cb) => registry ? registry.subscribe(cb) : () => {
|
|
2482
|
+
}, [registry]);
|
|
2483
|
+
const getSnapshot = (0, import_react5.useCallback)(() => registry?.resolveLinkDef(label) ?? null, [registry, label]);
|
|
2484
|
+
const def = (0, import_react5.useSyncExternalStore)(subscribe, getSnapshot, SSR_DEF_SNAPSHOT);
|
|
2485
|
+
if (!def) {
|
|
2486
|
+
return literalImage(referenceType, label, alt);
|
|
2487
|
+
}
|
|
2488
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("img", { src: def.url, alt, title: def.title });
|
|
2489
|
+
}
|
|
2490
|
+
var crossChunkComponents = {
|
|
2491
|
+
"footnote-sup": FootnoteSupNumber,
|
|
2492
|
+
"cross-chunk-link": CrossChunkLink,
|
|
2493
|
+
"cross-chunk-image": CrossChunkImage
|
|
2494
|
+
};
|
|
2495
|
+
|
|
2496
|
+
// src/components/extractContributions.ts
|
|
2497
|
+
var import_unist_util_visit6 = require("unist-util-visit");
|
|
2498
|
+
function* extractContributions(mdast, options = {}) {
|
|
2499
|
+
const phantomFn = options.phantomFootnoteLabels;
|
|
2500
|
+
const out = [];
|
|
2501
|
+
(0, import_unist_util_visit6.visit)(mdast, (n) => {
|
|
2502
|
+
if (n.type === "footnoteReference") {
|
|
2503
|
+
out.push({
|
|
2504
|
+
kind: "ref",
|
|
2505
|
+
refKind: "footnote",
|
|
2506
|
+
label: normalizeId(n.identifier)
|
|
2507
|
+
});
|
|
2508
|
+
} else if (n.type === "linkReference") {
|
|
2509
|
+
const r = n;
|
|
2510
|
+
out.push({ kind: "ref", refKind: "link", label: normalizeId(r.identifier), referenceType: r.referenceType });
|
|
2511
|
+
} else if (n.type === "imageReference") {
|
|
2512
|
+
const r = n;
|
|
2513
|
+
out.push({ kind: "ref", refKind: "image", label: normalizeId(r.identifier), referenceType: r.referenceType });
|
|
2514
|
+
} else if (n.type === "footnoteDefinition") {
|
|
2515
|
+
const d = n;
|
|
2516
|
+
const label = normalizeId(d.identifier);
|
|
2517
|
+
if (phantomFn?.has(label)) return import_unist_util_visit6.SKIP;
|
|
2518
|
+
const content = JSON.stringify(d.children ?? []);
|
|
2519
|
+
out.push({ kind: "fnDef", label, sourceIdentifier: d.identifier, content });
|
|
2520
|
+
return import_unist_util_visit6.SKIP;
|
|
2521
|
+
} else if (n.type === "definition") {
|
|
2522
|
+
const d = n;
|
|
2523
|
+
if (d.url === SENTINEL_LINK_URL) return;
|
|
2524
|
+
out.push({ kind: "linkDef", label: normalizeId(d.identifier), url: d.url, title: d.title });
|
|
2525
|
+
}
|
|
2526
|
+
});
|
|
2527
|
+
for (const c of out) yield c;
|
|
2528
|
+
}
|
|
2529
|
+
|
|
2530
|
+
// src/components/extractDefBodiesFromHast.ts
|
|
2531
|
+
var import_unist_util_visit7 = require("unist-util-visit");
|
|
2532
|
+
var FN_LI_ID_RE = /(?:^|-)user-content-fn-(.+)$/;
|
|
2533
|
+
function sourceIdFromFootnoteLiId(idProp, clobberPrefix) {
|
|
2534
|
+
let raw = null;
|
|
2535
|
+
if (clobberPrefix !== void 0) {
|
|
2536
|
+
const exactPrefix = `${clobberPrefix}fn-`;
|
|
2537
|
+
if (idProp.startsWith(exactPrefix)) raw = idProp.slice(exactPrefix.length);
|
|
2538
|
+
}
|
|
2539
|
+
if (raw === null) {
|
|
2540
|
+
const m = idProp.match(FN_LI_ID_RE);
|
|
2541
|
+
raw = m ? m[1] : null;
|
|
2542
|
+
}
|
|
2543
|
+
if (raw === null) return null;
|
|
2544
|
+
try {
|
|
2545
|
+
return decodeURIComponent(raw);
|
|
2546
|
+
} catch {
|
|
2547
|
+
return raw;
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
function isBackrefAnchor(c) {
|
|
2551
|
+
if (c.type !== "element") return false;
|
|
2552
|
+
const el = c;
|
|
2553
|
+
if (el.tagName !== "a") return false;
|
|
2554
|
+
return Boolean(el.properties && "dataFootnoteBackref" in el.properties);
|
|
2555
|
+
}
|
|
2556
|
+
function isWhitespaceText(c) {
|
|
2557
|
+
if (c.type !== "text") return false;
|
|
2558
|
+
return /^\s*$/.test(c.value);
|
|
2559
|
+
}
|
|
2560
|
+
function lastMeaningfulIdx(children) {
|
|
2561
|
+
for (let i = children.length - 1; i >= 0; i--) {
|
|
2562
|
+
if (!isWhitespaceText(children[i])) return i;
|
|
2563
|
+
}
|
|
2564
|
+
return -1;
|
|
2565
|
+
}
|
|
2566
|
+
function dropTrailingBackrefs(children) {
|
|
2567
|
+
let trailingWsStart = children.length;
|
|
2568
|
+
while (trailingWsStart > 0 && isWhitespaceText(children[trailingWsStart - 1])) {
|
|
2569
|
+
trailingWsStart--;
|
|
2570
|
+
}
|
|
2571
|
+
let scan = trailingWsStart;
|
|
2572
|
+
let peeledAny = false;
|
|
2573
|
+
while (scan > 0) {
|
|
2574
|
+
const t = children[scan - 1];
|
|
2575
|
+
if (!isBackrefAnchor(t)) break;
|
|
2576
|
+
peeledAny = true;
|
|
2577
|
+
scan -= 1;
|
|
2578
|
+
if (scan > 0 && children[scan - 1].type === "text" && children[scan - 1].value === " ") {
|
|
2579
|
+
scan -= 1;
|
|
2580
|
+
}
|
|
2581
|
+
}
|
|
2582
|
+
if (!peeledAny) return children;
|
|
2583
|
+
const trailing = children.slice(trailingWsStart);
|
|
2584
|
+
if (scan > 0) {
|
|
2585
|
+
const last = children[scan - 1];
|
|
2586
|
+
if (last.type === "text") {
|
|
2587
|
+
const v = last.value;
|
|
2588
|
+
if (v.endsWith(" ") && !/^\s*$/.test(v)) {
|
|
2589
|
+
return [...children.slice(0, scan - 1), { ...last, value: v.slice(0, -1) }, ...trailing];
|
|
2590
|
+
}
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
return [...children.slice(0, scan), ...trailing];
|
|
2594
|
+
}
|
|
2595
|
+
function stripBackrefs(liChildren) {
|
|
2596
|
+
if (liChildren.length === 0) return liChildren;
|
|
2597
|
+
const lastIdx = lastMeaningfulIdx(liChildren);
|
|
2598
|
+
if (lastIdx < 0) return liChildren;
|
|
2599
|
+
const last = liChildren[lastIdx];
|
|
2600
|
+
if (isBackrefAnchor(last)) {
|
|
2601
|
+
return dropTrailingBackrefs(liChildren);
|
|
2602
|
+
}
|
|
2603
|
+
if (last.type === "element" && last.tagName === "p") {
|
|
2604
|
+
const p = last;
|
|
2605
|
+
const newPChildren = dropTrailingBackrefs(p.children);
|
|
2606
|
+
if (newPChildren === p.children) return liChildren;
|
|
2607
|
+
return liChildren.map((c, i) => i === lastIdx ? { ...p, children: newPChildren } : c);
|
|
2608
|
+
}
|
|
2609
|
+
return liChildren;
|
|
2610
|
+
}
|
|
2611
|
+
function stripLocalOccurrenceFromFootnoteSups(children) {
|
|
2612
|
+
let changed = false;
|
|
2613
|
+
const out = [];
|
|
2614
|
+
for (const c of children) {
|
|
2615
|
+
if (c.type === "element") {
|
|
2616
|
+
const el = c;
|
|
2617
|
+
let nextEl = el;
|
|
2618
|
+
if (el.tagName === "footnote-sup" && el.properties && "localOccurrence" in el.properties) {
|
|
2619
|
+
const { localOccurrence: _drop, ...rest } = el.properties;
|
|
2620
|
+
nextEl = { ...el, properties: rest };
|
|
2621
|
+
changed = true;
|
|
2622
|
+
}
|
|
2623
|
+
const newChildren = stripLocalOccurrenceFromFootnoteSups(nextEl.children);
|
|
2624
|
+
if (newChildren !== nextEl.children) {
|
|
2625
|
+
nextEl = { ...nextEl, children: newChildren };
|
|
2626
|
+
changed = true;
|
|
2627
|
+
}
|
|
2628
|
+
out.push(nextEl);
|
|
2629
|
+
} else {
|
|
2630
|
+
out.push(c);
|
|
2631
|
+
}
|
|
2632
|
+
}
|
|
2633
|
+
return changed ? out : children;
|
|
2634
|
+
}
|
|
2635
|
+
function extractDefBodiesFromHast(hast, clobberPrefix) {
|
|
2636
|
+
const out = /* @__PURE__ */ new Map();
|
|
2637
|
+
(0, import_unist_util_visit7.visit)(hast, "element", (sectionNode) => {
|
|
2638
|
+
const sec = sectionNode;
|
|
2639
|
+
if (sec.tagName !== "section") return;
|
|
2640
|
+
if (!(sec.properties && "dataFootnotes" in sec.properties)) return;
|
|
2641
|
+
(0, import_unist_util_visit7.visit)(sec, "element", (liNode) => {
|
|
2642
|
+
const li = liNode;
|
|
2643
|
+
if (li.tagName !== "li") return;
|
|
2644
|
+
const idProp = li.properties?.id;
|
|
2645
|
+
if (typeof idProp !== "string") return;
|
|
2646
|
+
const sourceId = sourceIdFromFootnoteLiId(idProp, clobberPrefix);
|
|
2647
|
+
if (sourceId === null) return;
|
|
2648
|
+
const normalized = normalizeId(sourceId);
|
|
2649
|
+
const stripped = stripBackrefs(li.children);
|
|
2650
|
+
out.set(normalized, stripLocalOccurrenceFromFootnoteSups(stripped));
|
|
2651
|
+
});
|
|
2652
|
+
return import_unist_util_visit7.SKIP;
|
|
2653
|
+
});
|
|
2654
|
+
return out;
|
|
2655
|
+
}
|
|
2656
|
+
|
|
2657
|
+
// src/components/aggregateFootnotesIfLast.tsx
|
|
2658
|
+
var import_react6 = require("react");
|
|
2659
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
2660
|
+
function cloneHast(node) {
|
|
2661
|
+
return JSON.parse(JSON.stringify(node));
|
|
2662
|
+
}
|
|
2663
|
+
function isWhitespaceText2(c) {
|
|
2664
|
+
return c.type === "text" && /^\s*$/.test(c.value);
|
|
2665
|
+
}
|
|
2666
|
+
function lastMeaningfulIdx2(children) {
|
|
2667
|
+
for (let i = children.length - 1; i >= 0; i--) {
|
|
2668
|
+
if (!isWhitespaceText2(children[i])) return i;
|
|
2669
|
+
}
|
|
2670
|
+
return -1;
|
|
2671
|
+
}
|
|
2672
|
+
function buildBackref(href, occurrence, globalNumber) {
|
|
2673
|
+
const children = [{ type: "text", value: "\u21A9" }];
|
|
2674
|
+
if (occurrence > 1) {
|
|
2675
|
+
children.push({
|
|
2676
|
+
type: "element",
|
|
2677
|
+
tagName: "sup",
|
|
2678
|
+
properties: {},
|
|
2679
|
+
children: [{ type: "text", value: String(occurrence) }]
|
|
2680
|
+
});
|
|
2681
|
+
}
|
|
2682
|
+
const ariaLabel = occurrence === 1 ? `Back to reference ${globalNumber}` : `Back to reference ${globalNumber}-${occurrence}`;
|
|
2683
|
+
return {
|
|
2684
|
+
type: "element",
|
|
2685
|
+
tagName: "a",
|
|
2686
|
+
properties: {
|
|
2687
|
+
href,
|
|
2688
|
+
dataFootnoteBackref: "",
|
|
2689
|
+
className: ["data-footnote-backref"],
|
|
2690
|
+
ariaLabel
|
|
2691
|
+
},
|
|
2692
|
+
children
|
|
2693
|
+
};
|
|
1772
2694
|
}
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
2695
|
+
function buildAggregateTree(registry, clobberPrefix, preserveOrphanReferences = false) {
|
|
2696
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2697
|
+
const ordered = [];
|
|
2698
|
+
for (const sym of registry.chunkOrder) {
|
|
2699
|
+
const data = registry.chunkData.get(sym);
|
|
2700
|
+
if (!data) continue;
|
|
2701
|
+
for (const ref of data.refs) {
|
|
2702
|
+
if (ref.kind !== "footnote") continue;
|
|
2703
|
+
if (seen.has(ref.label)) continue;
|
|
2704
|
+
seen.add(ref.label);
|
|
2705
|
+
const canonicalSym = registry.canonicalFootnoteFor(ref.label);
|
|
2706
|
+
if (!canonicalSym) continue;
|
|
2707
|
+
const def = registry.chunkData.get(canonicalSym)?.defs.get(ref.label);
|
|
2708
|
+
if (!def) continue;
|
|
2709
|
+
const n = registry.globalNumber(ref.label);
|
|
2710
|
+
if (n === null) continue;
|
|
2711
|
+
const sourceIdentifier = def.sourceIdentifier ?? ref.label;
|
|
2712
|
+
ordered.push({
|
|
2713
|
+
normalizedLabel: ref.label,
|
|
2714
|
+
sourceIdentifier,
|
|
2715
|
+
bodyHast: def.bodyHast ?? [],
|
|
2716
|
+
n,
|
|
2717
|
+
withBackref: true
|
|
2718
|
+
});
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2721
|
+
if (preserveOrphanReferences) {
|
|
2722
|
+
for (const sym of registry.chunkOrder) {
|
|
2723
|
+
const data = registry.chunkData.get(sym);
|
|
2724
|
+
if (!data) continue;
|
|
2725
|
+
for (const [label, def] of data.defs) {
|
|
2726
|
+
if (seen.has(label)) continue;
|
|
2727
|
+
if (registry.canonicalFootnoteFor(label) !== sym) continue;
|
|
2728
|
+
seen.add(label);
|
|
2729
|
+
ordered.push({
|
|
2730
|
+
normalizedLabel: label,
|
|
2731
|
+
sourceIdentifier: def.sourceIdentifier ?? label,
|
|
2732
|
+
bodyHast: def.bodyHast ?? [],
|
|
2733
|
+
n: null,
|
|
2734
|
+
withBackref: false
|
|
2735
|
+
});
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
}
|
|
2739
|
+
if (ordered.length === 0) return null;
|
|
2740
|
+
const liElements = ordered.map(({ normalizedLabel, sourceIdentifier, bodyHast, n, withBackref }) => {
|
|
2741
|
+
const liChildren = bodyHast.map((c) => cloneHast(c));
|
|
2742
|
+
if (withBackref) {
|
|
2743
|
+
const totalRefs = registry.getRefsForLabel(normalizedLabel);
|
|
2744
|
+
const tailIdx = lastMeaningfulIdx2(liChildren);
|
|
2745
|
+
const tail = tailIdx !== -1 ? liChildren[tailIdx] : null;
|
|
2746
|
+
const dest = tail && tail.type === "element" && tail.tagName === "p" ? tail : null;
|
|
2747
|
+
const appended = [];
|
|
2748
|
+
for (let i = 1; i <= Math.max(totalRefs, 1); i++) {
|
|
2749
|
+
appended.push({ type: "text", value: " " });
|
|
2750
|
+
const href = i === 1 ? `#${clobberPrefix}fnref-${sourceIdentifier}` : `#${clobberPrefix}fnref-${sourceIdentifier}-${i}`;
|
|
2751
|
+
appended.push(buildBackref(href, i, n ?? 0));
|
|
2752
|
+
}
|
|
2753
|
+
if (dest) {
|
|
2754
|
+
dest.children = [...dest.children, ...appended];
|
|
2755
|
+
} else if (tailIdx !== -1) {
|
|
2756
|
+
liChildren.splice(tailIdx + 1, 0, ...appended);
|
|
2757
|
+
} else {
|
|
2758
|
+
liChildren.push(...appended);
|
|
2759
|
+
}
|
|
2760
|
+
}
|
|
2761
|
+
return {
|
|
2762
|
+
type: "element",
|
|
2763
|
+
tagName: "li",
|
|
2764
|
+
properties: {
|
|
2765
|
+
id: `${clobberPrefix}fn-${sourceIdentifier}`,
|
|
2766
|
+
...n !== null ? { value: n } : {}
|
|
2767
|
+
},
|
|
2768
|
+
children: liChildren
|
|
2769
|
+
};
|
|
2770
|
+
});
|
|
2771
|
+
return {
|
|
2772
|
+
type: "element",
|
|
2773
|
+
tagName: "section",
|
|
2774
|
+
properties: {
|
|
2775
|
+
className: ["footnotes"],
|
|
2776
|
+
dataFootnotes: true,
|
|
2777
|
+
// a11y: name the section landmark so screen readers still announce it
|
|
2778
|
+
// even though the visible "Footnotes" h2 is omitted in coordinated mode.
|
|
2779
|
+
ariaLabel: "Footnotes"
|
|
2780
|
+
},
|
|
2781
|
+
children: [
|
|
2782
|
+
// Conventional separator above the footnote list. The default
|
|
2783
|
+
// mdast-util-to-hast footer doesn't emit one (GitHub renders the
|
|
2784
|
+
// separation via CSS `border-top` on `.footnotes`); we render a literal
|
|
2785
|
+
// `<hr>` so the visual break is preserved without sanitize-friendly CSS.
|
|
2786
|
+
{
|
|
2787
|
+
type: "element",
|
|
2788
|
+
tagName: "hr",
|
|
2789
|
+
properties: {},
|
|
2790
|
+
children: []
|
|
2791
|
+
},
|
|
2792
|
+
{
|
|
2793
|
+
type: "element",
|
|
2794
|
+
tagName: "ol",
|
|
2795
|
+
properties: {},
|
|
2796
|
+
children: liElements
|
|
2797
|
+
}
|
|
2798
|
+
]
|
|
2799
|
+
};
|
|
1776
2800
|
}
|
|
2801
|
+
var AggregateFootnotesIfLastImpl = ({
|
|
2802
|
+
registry,
|
|
2803
|
+
thisChunkSym,
|
|
2804
|
+
clobberPrefix,
|
|
2805
|
+
postOptions,
|
|
2806
|
+
preserveOrphanReferences = false
|
|
2807
|
+
}) => {
|
|
2808
|
+
const tree = (0, import_react6.useMemo)(
|
|
2809
|
+
() => buildAggregateTree(registry, clobberPrefix, preserveOrphanReferences),
|
|
2810
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2811
|
+
[registry, registry.version, clobberPrefix, preserveOrphanReferences]
|
|
2812
|
+
);
|
|
2813
|
+
const order = registry.chunkOrder;
|
|
2814
|
+
if (order.length === 0) return null;
|
|
2815
|
+
if (order[order.length - 1] !== thisChunkSym) return null;
|
|
2816
|
+
if (!tree) return null;
|
|
2817
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: renderHastSubtree(cloneHast(tree), postOptions) });
|
|
2818
|
+
};
|
|
2819
|
+
var AggregateFootnotesIfLast = (0, import_react6.memo)(AggregateFootnotesIfLastImpl);
|
|
2820
|
+
AggregateFootnotesIfLast.displayName = "AggregateFootnotesIfLast";
|
|
1777
2821
|
|
|
1778
2822
|
// src/components/MarkdownContent.tsx
|
|
1779
|
-
var
|
|
1780
|
-
var
|
|
1781
|
-
var import_rehype_katex = __toESM(require("rehype-katex"), 1);
|
|
1782
|
-
var import_rehype_raw = __toESM(require("rehype-raw"), 1);
|
|
1783
|
-
var import_rehype_unwrap_images = __toESM(require("rehype-unwrap-images"), 1);
|
|
1784
|
-
var import_rehype_sanitize = __toESM(require("rehype-sanitize"), 1);
|
|
1785
|
-
var import_remark_breaks = __toESM(require("remark-breaks"), 1);
|
|
1786
|
-
var import_remark_cjk_friendly = __toESM(require("remark-cjk-friendly"), 1);
|
|
1787
|
-
var import_remark_cjk_friendly_gfm_strikethrough = __toESM(require("remark-cjk-friendly-gfm-strikethrough"), 1);
|
|
1788
|
-
var import_remark_emoji = __toESM(require("remark-emoji"), 1);
|
|
1789
|
-
var import_remark_gfm = __toESM(require("remark-gfm"), 1);
|
|
1790
|
-
var import_remark_math = __toESM(require("remark-math"), 1);
|
|
1791
|
-
var import_remark_definition_list = require("remark-definition-list");
|
|
1792
|
-
var import_remark_supersub = __toESM(require("remark-supersub"), 1);
|
|
1793
|
-
var import_remark_mark_highlight = require("remark-mark-highlight");
|
|
1794
|
-
var import_remark_squeeze_paragraphs = __toESM(require("remark-squeeze-paragraphs"), 1);
|
|
1795
|
-
var import_remark_smartypants = __toESM(require("remark-smartypants"), 1);
|
|
1796
|
-
var import_remark_pangu = __toESM(require("remark-pangu"), 1);
|
|
1797
|
-
var import_remark_remove_comments = __toESM(require("remark-remove-comments"), 1);
|
|
1798
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2823
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
2824
|
+
var REGISTRY_SSR_SNAPSHOT = () => 0;
|
|
1799
2825
|
var DisplayOptimizeRemarkPluginMap = {
|
|
1800
2826
|
["REMOVE_COMMENTS" /* REMOVE_COMMENTS */]: import_remark_remove_comments.default,
|
|
1801
2827
|
["SMARTYPANTS" /* SMARTYPANTS */]: import_remark_smartypants.default,
|
|
@@ -1803,83 +2829,359 @@ var DisplayOptimizeRemarkPluginMap = {
|
|
|
1803
2829
|
};
|
|
1804
2830
|
var ExtraSyntaxRemarkPluginMap = {
|
|
1805
2831
|
["HIGHLIGHT" /* HIGHLIGHT */]: import_remark_mark_highlight.remarkMark,
|
|
1806
|
-
["DEFINITION_LIST" /* DEFINITION_LIST */]: import_remark_definition_list.remarkDefinitionList
|
|
1807
|
-
["SUBSCRIPT" /* SUBSCRIPT */]: import_remark_supersub.default
|
|
2832
|
+
["DEFINITION_LIST" /* DEFINITION_LIST */]: import_remark_definition_list.remarkDefinitionList
|
|
1808
2833
|
};
|
|
1809
2834
|
var DefaultCustomComponents = {};
|
|
1810
|
-
var
|
|
1811
|
-
|
|
1812
|
-
|
|
2835
|
+
var BlockMemoizedRenderer = (0, import_react7.memo)(
|
|
2836
|
+
({ content, usedComponents, remarkPlugins, rehypePlugins, remarkRehypeOptions }) => {
|
|
2837
|
+
const urlTransform = void 0;
|
|
2838
|
+
const allowedElements = void 0;
|
|
2839
|
+
const disallowedElements = void 0;
|
|
2840
|
+
const allowElement = void 0;
|
|
2841
|
+
const skipHtml = void 0;
|
|
2842
|
+
const unwrapDisallowed = void 0;
|
|
2843
|
+
const { documentId, clobberPrefix, config } = useAIMarkdownRenderState();
|
|
2844
|
+
const reactId = (0, import_react7.useId)();
|
|
2845
|
+
const registry = useDocumentRegistry(documentId);
|
|
2846
|
+
const [allocation, setAllocation] = (0, import_react7.useState)(null);
|
|
2847
|
+
const sym = allocation && allocation.registry === registry ? allocation.sym : null;
|
|
2848
|
+
const subscribeRegistry = (0, import_react7.useCallback)(
|
|
2849
|
+
(cb) => registry ? registry.subscribe(cb) : () => {
|
|
2850
|
+
},
|
|
2851
|
+
[registry]
|
|
2852
|
+
);
|
|
2853
|
+
const getRegistryVersion = (0, import_react7.useCallback)(() => registry?.version ?? 0, [registry]);
|
|
2854
|
+
(0, import_react7.useSyncExternalStore)(subscribeRegistry, getRegistryVersion, REGISTRY_SSR_SNAPSHOT);
|
|
2855
|
+
const ownLabels = (0, import_react7.useMemo)(() => collectDefLabels(content ?? ""), [content]);
|
|
2856
|
+
(0, import_react7.useEffect)(() => {
|
|
2857
|
+
if (!registry) return;
|
|
2858
|
+
const s = registry.registerChunk(reactId, ownLabels.footnoteLabels, ownLabels.linkLabels);
|
|
2859
|
+
setAllocation({ registry, sym: s });
|
|
2860
|
+
return () => {
|
|
2861
|
+
registry.releaseSymbol(reactId);
|
|
2862
|
+
setAllocation(null);
|
|
2863
|
+
};
|
|
2864
|
+
}, [reactId, registry, ownLabels]);
|
|
2865
|
+
const cacheRef = (0, import_react7.useRef)(createCache());
|
|
2866
|
+
const depsRef = (0, import_react7.useRef)({
|
|
2867
|
+
usedComponents,
|
|
2868
|
+
remarkPlugins,
|
|
2869
|
+
rehypePlugins,
|
|
2870
|
+
remarkRehypeOptions,
|
|
2871
|
+
urlTransform,
|
|
2872
|
+
allowedElements,
|
|
2873
|
+
disallowedElements,
|
|
2874
|
+
allowElement,
|
|
2875
|
+
skipHtml,
|
|
2876
|
+
unwrapDisallowed,
|
|
2877
|
+
registry,
|
|
2878
|
+
symbol: sym
|
|
2879
|
+
});
|
|
2880
|
+
if (depsRef.current.usedComponents !== usedComponents || depsRef.current.remarkPlugins !== remarkPlugins || depsRef.current.rehypePlugins !== rehypePlugins || depsRef.current.remarkRehypeOptions !== remarkRehypeOptions || depsRef.current.urlTransform !== urlTransform || depsRef.current.allowedElements !== allowedElements || depsRef.current.disallowedElements !== disallowedElements || depsRef.current.allowElement !== allowElement || depsRef.current.skipHtml !== skipHtml || depsRef.current.unwrapDisallowed !== unwrapDisallowed || depsRef.current.registry !== registry || depsRef.current.symbol !== sym) {
|
|
2881
|
+
cacheRef.current = createCache();
|
|
2882
|
+
depsRef.current = {
|
|
2883
|
+
usedComponents,
|
|
2884
|
+
remarkPlugins,
|
|
2885
|
+
rehypePlugins,
|
|
2886
|
+
remarkRehypeOptions,
|
|
2887
|
+
urlTransform,
|
|
2888
|
+
allowedElements,
|
|
2889
|
+
disallowedElements,
|
|
2890
|
+
allowElement,
|
|
2891
|
+
skipHtml,
|
|
2892
|
+
unwrapDisallowed,
|
|
2893
|
+
registry,
|
|
2894
|
+
symbol: sym
|
|
2895
|
+
};
|
|
2896
|
+
}
|
|
2897
|
+
const targetPhantomsRef = (0, import_react7.useRef)({
|
|
2898
|
+
missingFootnotes: /* @__PURE__ */ new Set(),
|
|
2899
|
+
missingLinks: /* @__PURE__ */ new Set()
|
|
2900
|
+
});
|
|
2901
|
+
const targetPhantoms = (0, import_react7.useMemo)(() => {
|
|
2902
|
+
let nextFootnotes;
|
|
2903
|
+
let nextLinks;
|
|
2904
|
+
if (!registry) {
|
|
2905
|
+
nextFootnotes = /* @__PURE__ */ new Set();
|
|
2906
|
+
nextLinks = /* @__PURE__ */ new Set();
|
|
2907
|
+
} else {
|
|
2908
|
+
const normalized = normalizeForMatch(content ?? "");
|
|
2909
|
+
nextFootnotes = /* @__PURE__ */ new Set();
|
|
2910
|
+
nextLinks = /* @__PURE__ */ new Set();
|
|
2911
|
+
for (const label of registry.labelSet.footnoteLabels) {
|
|
2912
|
+
if (ownLabels.footnoteLabels.has(label)) continue;
|
|
2913
|
+
if (normalized.includes(label)) nextFootnotes.add(label);
|
|
2914
|
+
}
|
|
2915
|
+
for (const label of registry.labelSet.linkLabels) {
|
|
2916
|
+
if (ownLabels.linkLabels.has(label)) continue;
|
|
2917
|
+
if (normalized.includes(label)) nextLinks.add(label);
|
|
2918
|
+
}
|
|
2919
|
+
}
|
|
2920
|
+
const prev = targetPhantomsRef.current;
|
|
2921
|
+
if (nextFootnotes.size === prev.missingFootnotes.size && nextLinks.size === prev.missingLinks.size && [...nextFootnotes].every((l) => prev.missingFootnotes.has(l)) && [...nextLinks].every((l) => prev.missingLinks.has(l))) {
|
|
2922
|
+
return prev;
|
|
2923
|
+
}
|
|
2924
|
+
const next = { missingFootnotes: nextFootnotes, missingLinks: nextLinks };
|
|
2925
|
+
targetPhantomsRef.current = next;
|
|
2926
|
+
return next;
|
|
2927
|
+
}, [registry, registry?.version, content, ownLabels]);
|
|
2928
|
+
const effectivePreserveOrphan = usePreserveOrphanReferences(config.preserveOrphanReferences);
|
|
2929
|
+
const preserveForBodyHarvest = effectivePreserveOrphan || Boolean(registry && sym);
|
|
2930
|
+
const handlers = (0, import_react7.useMemo)(() => {
|
|
2931
|
+
if (registry) return buildCrossChunkHandlers();
|
|
2932
|
+
if (effectivePreserveOrphan) {
|
|
2933
|
+
const { footnoteDefinition } = buildCrossChunkHandlers();
|
|
2934
|
+
return { footnoteDefinition };
|
|
2935
|
+
}
|
|
2936
|
+
return void 0;
|
|
2937
|
+
}, [registry, effectivePreserveOrphan]);
|
|
2938
|
+
const parsed = (0, import_react7.useMemo)(() => {
|
|
2939
|
+
const augmented = augmentSourceWithPhantoms(content ?? "", targetPhantoms);
|
|
2940
|
+
const baseHandlers = remarkRehypeOptions?.handlers ?? {};
|
|
2941
|
+
const mergedRemarkRehypeOptions = handlers ? {
|
|
2942
|
+
...remarkRehypeOptions,
|
|
2943
|
+
handlers: { ...baseHandlers, ...handlers },
|
|
2944
|
+
// Phantom label sets are empty in standalone mode (no PASS 0.5
|
|
2945
|
+
// injection happened); the footnoteDefinition handler still reads
|
|
2946
|
+
// them via `state.options.phantomFootnoteLabels.has(id)`, which
|
|
2947
|
+
// returns false for every id → orphan-protect path proceeds.
|
|
2948
|
+
phantomFootnoteLabels: targetPhantoms.missingFootnotes,
|
|
2949
|
+
phantomLinkLabels: targetPhantoms.missingLinks,
|
|
2950
|
+
preserveOrphan: preserveForBodyHarvest,
|
|
2951
|
+
documentId
|
|
2952
|
+
} : {
|
|
2953
|
+
...remarkRehypeOptions
|
|
2954
|
+
};
|
|
2955
|
+
return parseStage({
|
|
2956
|
+
children: augmented,
|
|
2957
|
+
remarkPlugins,
|
|
2958
|
+
rehypePlugins,
|
|
2959
|
+
remarkRehypeOptions: mergedRemarkRehypeOptions
|
|
2960
|
+
});
|
|
2961
|
+
}, [
|
|
2962
|
+
content,
|
|
2963
|
+
targetPhantoms,
|
|
2964
|
+
remarkPlugins,
|
|
2965
|
+
rehypePlugins,
|
|
2966
|
+
remarkRehypeOptions,
|
|
2967
|
+
handlers,
|
|
2968
|
+
preserveForBodyHarvest,
|
|
2969
|
+
documentId
|
|
2970
|
+
]);
|
|
2971
|
+
const hast = (0, import_react7.useMemo)(() => transformStage(parsed), [parsed]);
|
|
2972
|
+
const built = (0, import_react7.useMemo)(() => buildBlocks(parsed.mdast, hast, content ?? ""), [parsed.mdast, hast, content]);
|
|
2973
|
+
const postOptions = (0, import_react7.useMemo)(
|
|
2974
|
+
() => ({
|
|
2975
|
+
components: { ...crossChunkComponents, ...usedComponents },
|
|
2976
|
+
urlTransform,
|
|
2977
|
+
allowedElements,
|
|
2978
|
+
disallowedElements,
|
|
2979
|
+
allowElement,
|
|
2980
|
+
skipHtml,
|
|
2981
|
+
unwrapDisallowed,
|
|
2982
|
+
// v6 fingerprint cache fields:
|
|
2983
|
+
registry: registry ?? void 0,
|
|
2984
|
+
thisChunkSymbol: sym ?? void 0,
|
|
2985
|
+
clobberPrefix
|
|
2986
|
+
}),
|
|
2987
|
+
// `sym` is now real state (setSym after allocateSymbol), so it's a
|
|
2988
|
+
// proper dep and postOptions refreshes when allocation completes.
|
|
2989
|
+
// `registry?.version` stays in deps so the per-block fingerprint cache
|
|
2990
|
+
// path sees the latest registry version on every coordinated update.
|
|
2991
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2992
|
+
[
|
|
2993
|
+
usedComponents,
|
|
2994
|
+
urlTransform,
|
|
2995
|
+
allowedElements,
|
|
2996
|
+
disallowedElements,
|
|
2997
|
+
allowElement,
|
|
2998
|
+
skipHtml,
|
|
2999
|
+
unwrapDisallowed,
|
|
3000
|
+
registry,
|
|
3001
|
+
registry?.version,
|
|
3002
|
+
sym,
|
|
3003
|
+
clobberPrefix
|
|
3004
|
+
]
|
|
3005
|
+
);
|
|
3006
|
+
const lastContributionRef = (0, import_react7.useRef)(null);
|
|
3007
|
+
(0, import_react7.useEffect)(() => {
|
|
3008
|
+
if (!registry || !sym) return;
|
|
3009
|
+
const refs = [];
|
|
3010
|
+
const defMeta = /* @__PURE__ */ new Map();
|
|
3011
|
+
const linkDefs = /* @__PURE__ */ new Map();
|
|
3012
|
+
for (const node of extractContributions(parsed.mdast, {
|
|
3013
|
+
phantomFootnoteLabels: targetPhantoms.missingFootnotes
|
|
3014
|
+
})) {
|
|
3015
|
+
if (node.kind === "ref") {
|
|
3016
|
+
refs.push({ label: node.label, kind: node.refKind, referenceType: node.referenceType });
|
|
3017
|
+
} else if (node.kind === "fnDef") {
|
|
3018
|
+
defMeta.set(node.label, {
|
|
3019
|
+
identifier: node.label,
|
|
3020
|
+
sourceIdentifier: node.sourceIdentifier,
|
|
3021
|
+
contentSource: node.content
|
|
3022
|
+
});
|
|
3023
|
+
} else if (node.kind === "linkDef") {
|
|
3024
|
+
linkDefs.set(node.label, { identifier: node.label, url: node.url, title: node.title });
|
|
3025
|
+
}
|
|
3026
|
+
}
|
|
3027
|
+
const fp = JSON.stringify({
|
|
3028
|
+
r: refs,
|
|
3029
|
+
d: Array.from(defMeta.entries()).map(([k, v]) => [k, v.sourceIdentifier, v.contentSource]),
|
|
3030
|
+
l: Array.from(linkDefs.entries()).map(([k, v]) => [k, v.url, v.title ?? ""]),
|
|
3031
|
+
ofn: Array.from(ownLabels.footnoteLabels).sort(),
|
|
3032
|
+
ol: Array.from(ownLabels.linkLabels).sort(),
|
|
3033
|
+
// Include targetPhantoms in the fingerprint: a phantom→resolved
|
|
3034
|
+
// transition (another chunk publishes a def for a label this chunk
|
|
3035
|
+
// references inside one of its OWN def bodies) changes the rendered
|
|
3036
|
+
// hast — the `<cross-chunk-link>` / `<cross-chunk-image>` placeholder
|
|
3037
|
+
// disappears and a real `<a>` / `<img>` takes its place — without
|
|
3038
|
+
// touching this chunk's refs / defMeta / linkDefs / ownLabels. Without
|
|
3039
|
+
// including the phantom snapshot in the fingerprint, the fp check
|
|
3040
|
+
// would short-circuit and the registry would keep stale bodyHast
|
|
3041
|
+
// forever, leaving the aggregate footer rendering the placeholder
|
|
3042
|
+
// long after the label was resolved.
|
|
3043
|
+
tpfn: Array.from(targetPhantoms.missingFootnotes).sort(),
|
|
3044
|
+
tpl: Array.from(targetPhantoms.missingLinks).sort()
|
|
3045
|
+
});
|
|
3046
|
+
if (lastContributionRef.current?.registry === registry && lastContributionRef.current.symbol === sym && lastContributionRef.current.fp === fp) {
|
|
3047
|
+
return;
|
|
3048
|
+
}
|
|
3049
|
+
const bodiesByLabel = extractDefBodiesFromHast(hast, clobberPrefix);
|
|
3050
|
+
const defs = /* @__PURE__ */ new Map();
|
|
3051
|
+
for (const [label, meta] of defMeta) {
|
|
3052
|
+
defs.set(label, {
|
|
3053
|
+
identifier: meta.identifier,
|
|
3054
|
+
sourceIdentifier: meta.sourceIdentifier,
|
|
3055
|
+
contentSource: meta.contentSource,
|
|
3056
|
+
bodyHast: bodiesByLabel.get(label) ?? []
|
|
3057
|
+
});
|
|
3058
|
+
}
|
|
3059
|
+
lastContributionRef.current = { registry, symbol: sym, fp };
|
|
3060
|
+
registry.contributeChunkData(sym, {
|
|
3061
|
+
refs,
|
|
3062
|
+
defs,
|
|
3063
|
+
linkDefs,
|
|
3064
|
+
ownFootnoteLabels: ownLabels.footnoteLabels,
|
|
3065
|
+
ownLinkLabels: ownLabels.linkLabels
|
|
3066
|
+
});
|
|
3067
|
+
}, [parsed, ownLabels, registry, targetPhantoms, sym, hast, clobberPrefix]);
|
|
3068
|
+
const rendered = renderBlocksWithCache(cacheRef, built.plan, built.globalCtx, postOptions);
|
|
3069
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(ChunkSymbolContext.Provider, { value: sym, children: [
|
|
3070
|
+
rendered.map(({ node, reactKey }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react7.Fragment, { children: node }, reactKey)),
|
|
3071
|
+
registry && sym ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3072
|
+
AggregateFootnotesIfLast,
|
|
3073
|
+
{
|
|
3074
|
+
registry,
|
|
3075
|
+
thisChunkSym: sym,
|
|
3076
|
+
clobberPrefix,
|
|
3077
|
+
postOptions,
|
|
3078
|
+
preserveOrphanReferences: effectivePreserveOrphan
|
|
3079
|
+
}
|
|
3080
|
+
) : null
|
|
3081
|
+
] });
|
|
3082
|
+
}
|
|
3083
|
+
);
|
|
3084
|
+
BlockMemoizedRenderer.displayName = "BlockMemoizedRenderer";
|
|
3085
|
+
var LegacyRenderer = (0, import_react7.memo)(
|
|
3086
|
+
({ content, usedComponents, remarkPlugins, rehypePlugins, remarkRehypeOptions }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3087
|
+
Markdown_default,
|
|
3088
|
+
{
|
|
3089
|
+
remarkPlugins,
|
|
3090
|
+
rehypePlugins,
|
|
3091
|
+
remarkRehypeOptions,
|
|
3092
|
+
components: usedComponents,
|
|
3093
|
+
children: content
|
|
3094
|
+
}
|
|
3095
|
+
)
|
|
3096
|
+
);
|
|
3097
|
+
LegacyRenderer.displayName = "LegacyRenderer";
|
|
3098
|
+
var AIMarkdownContent = (0, import_react7.memo)(({ content, customComponents }) => {
|
|
3099
|
+
const { config, clobberPrefix } = useAIMarkdownRenderState();
|
|
3100
|
+
const { extraSyntaxRemarkPlugins, enableDefinitionList } = (0, import_react7.useMemo)(
|
|
1813
3101
|
() => ({
|
|
1814
3102
|
extraSyntaxRemarkPlugins: config.extraSyntaxSupported.map((syntax) => ExtraSyntaxRemarkPluginMap[syntax]),
|
|
1815
3103
|
enableDefinitionList: config.extraSyntaxSupported.includes("DEFINITION_LIST" /* DEFINITION_LIST */)
|
|
1816
3104
|
}),
|
|
1817
3105
|
[config.extraSyntaxSupported]
|
|
1818
3106
|
);
|
|
1819
|
-
const displayOptimizeRemarkPlugins = (0,
|
|
3107
|
+
const displayOptimizeRemarkPlugins = (0, import_react7.useMemo)(() => {
|
|
1820
3108
|
return config.displayOptimizeAbilities.map((ability) => DisplayOptimizeRemarkPluginMap[ability]);
|
|
1821
3109
|
}, [config.displayOptimizeAbilities]);
|
|
1822
|
-
const usedComponents = (0,
|
|
3110
|
+
const usedComponents = (0, import_react7.useMemo)(() => {
|
|
1823
3111
|
return customComponents ? { ...DefaultCustomComponents, ...customComponents } : DefaultCustomComponents;
|
|
1824
3112
|
}, [customComponents]);
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
// signs and other dollar usages; the preprocessor converts $...$ to $$...$$.
|
|
1836
|
-
singleDollarTextMath: false
|
|
1837
|
-
}
|
|
1838
|
-
],
|
|
1839
|
-
// --- Configurable extra syntax plugins ---
|
|
1840
|
-
...extraSyntaxRemarkPlugins,
|
|
1841
|
-
// --- Formatting & normalization ---
|
|
1842
|
-
import_remark_breaks.default,
|
|
1843
|
-
import_remark_emoji.default,
|
|
1844
|
-
import_remark_squeeze_paragraphs.default,
|
|
1845
|
-
import_remark_cjk_friendly.default,
|
|
1846
|
-
import_remark_cjk_friendly_gfm_strikethrough.default,
|
|
1847
|
-
// --- Configurable display optimizations ---
|
|
1848
|
-
...displayOptimizeRemarkPlugins
|
|
1849
|
-
],
|
|
1850
|
-
rehypePlugins: [
|
|
1851
|
-
// Allow raw HTML through so rehype-sanitize can handle it.
|
|
1852
|
-
[
|
|
1853
|
-
import_rehype_raw.default,
|
|
1854
|
-
{
|
|
1855
|
-
passThrough: []
|
|
1856
|
-
}
|
|
1857
|
-
],
|
|
1858
|
-
// Sanitize HTML while allowing <mark> (highlight) and KaTeX class names.
|
|
1859
|
-
[
|
|
1860
|
-
import_rehype_sanitize.default,
|
|
1861
|
-
{
|
|
1862
|
-
...import_rehype_sanitize.defaultSchema,
|
|
1863
|
-
tagNames: [...import_rehype_sanitize.defaultSchema.tagNames || [], "mark"],
|
|
1864
|
-
attributes: {
|
|
1865
|
-
...import_rehype_sanitize.defaultSchema.attributes,
|
|
1866
|
-
// The `language-*` regex is allowed by default.
|
|
1867
|
-
code: [["className", /^language-./, "math-inline", "math-display"]]
|
|
1868
|
-
}
|
|
1869
|
-
}
|
|
1870
|
-
],
|
|
1871
|
-
import_rehype_katex.default,
|
|
1872
|
-
import_rehype_unwrap_images.default
|
|
1873
|
-
],
|
|
1874
|
-
remarkRehypeOptions: {
|
|
1875
|
-
allowDangerousHtml: true,
|
|
1876
|
-
handlers: {
|
|
1877
|
-
// Inject definition-list HAST handlers when the extension is active.
|
|
1878
|
-
...enableDefinitionList ? import_remark_definition_list.defListHastHandlers : {}
|
|
3113
|
+
const remarkPlugins = (0, import_react7.useMemo)(
|
|
3114
|
+
() => [
|
|
3115
|
+
// --- Core plugins (always active) ---
|
|
3116
|
+
import_remark_gfm2.default,
|
|
3117
|
+
[
|
|
3118
|
+
import_remark_math.default,
|
|
3119
|
+
{
|
|
3120
|
+
// Disable single-dollar inline math to avoid conflicts with currency
|
|
3121
|
+
// signs and other dollar usages; the preprocessor converts $...$ to $$...$$.
|
|
3122
|
+
singleDollarTextMath: false
|
|
1879
3123
|
}
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
3124
|
+
],
|
|
3125
|
+
// --- Configurable extra syntax plugins ---
|
|
3126
|
+
...extraSyntaxRemarkPlugins,
|
|
3127
|
+
// --- Formatting & normalization ---
|
|
3128
|
+
import_remark_breaks.default,
|
|
3129
|
+
import_remark_emoji.default,
|
|
3130
|
+
import_remark_squeeze_paragraphs.default,
|
|
3131
|
+
import_remark_cjk_friendly.default,
|
|
3132
|
+
import_remark_cjk_friendly_gfm_strikethrough.default,
|
|
3133
|
+
// --- Configurable display optimizations ---
|
|
3134
|
+
...displayOptimizeRemarkPlugins
|
|
3135
|
+
],
|
|
3136
|
+
[extraSyntaxRemarkPlugins, displayOptimizeRemarkPlugins]
|
|
3137
|
+
);
|
|
3138
|
+
const rehypePlugins = (0, import_react7.useMemo)(
|
|
3139
|
+
() => [
|
|
3140
|
+
// Allow raw HTML through so rehype-sanitize can handle it.
|
|
3141
|
+
[import_rehype_raw.default, { passThrough: [] }],
|
|
3142
|
+
// Sanitize HTML while allowing <mark> (highlight) and KaTeX class names.
|
|
3143
|
+
// Override `clobberPrefix` with the instance-scoped value so every id
|
|
3144
|
+
// and clobberable attribute is namespaced to this `<AIMarkdown>` instance.
|
|
3145
|
+
[import_rehype_sanitize2.default, { ...sanitizeSchema, clobberPrefix }],
|
|
3146
|
+
// Normalize the auto-generated `<section data-footnotes>`: strip the
|
|
3147
|
+
// sr-only `<h2>Footnotes</h2>` label and prepend `<hr>`. Keeps standalone
|
|
3148
|
+
// single-doc rendering visually consistent with the cross-chunk aggregate
|
|
3149
|
+
// footer (which builds the same shape from scratch).
|
|
3150
|
+
rehypeFooterAdorn,
|
|
3151
|
+
// Re-prefix intra-document hash hrefs so they match the ids that
|
|
3152
|
+
// rehype-sanitize just clobbered. Must use the SAME prefix as the schema
|
|
3153
|
+
// above — that's why both read from `clobberPrefix`.
|
|
3154
|
+
[rehypeRebaseHashLinks_default, { prefix: clobberPrefix }],
|
|
3155
|
+
import_rehype_katex.default,
|
|
3156
|
+
import_rehype_unwrap_images.default
|
|
3157
|
+
],
|
|
3158
|
+
[clobberPrefix]
|
|
3159
|
+
);
|
|
3160
|
+
const remarkRehypeOptions = (0, import_react7.useMemo)(
|
|
3161
|
+
() => ({
|
|
3162
|
+
allowDangerousHtml: true,
|
|
3163
|
+
// Suppress mdast-util-to-hast's `user-content-` prefix on footnote
|
|
3164
|
+
// ids/hrefs; rehype-sanitize will apply the same prefix downstream
|
|
3165
|
+
// and `rehypeRebaseHashLinks` mirrors it onto matching hash hrefs.
|
|
3166
|
+
// Without this, ids would end up double-prefixed
|
|
3167
|
+
// (`user-content-user-content-fn-x`).
|
|
3168
|
+
clobberPrefix: "",
|
|
3169
|
+
handlers: {
|
|
3170
|
+
// Inject definition-list HAST handlers when the extension is active.
|
|
3171
|
+
...enableDefinitionList ? import_remark_definition_list.defListHastHandlers : {}
|
|
3172
|
+
}
|
|
3173
|
+
}),
|
|
3174
|
+
[enableDefinitionList]
|
|
3175
|
+
);
|
|
3176
|
+
const Renderer = config.blockMemoEnabled ? BlockMemoizedRenderer : LegacyRenderer;
|
|
3177
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3178
|
+
Renderer,
|
|
3179
|
+
{
|
|
3180
|
+
content,
|
|
3181
|
+
usedComponents,
|
|
3182
|
+
remarkPlugins,
|
|
3183
|
+
rehypePlugins,
|
|
3184
|
+
remarkRehypeOptions
|
|
1883
3185
|
}
|
|
1884
3186
|
);
|
|
1885
3187
|
});
|
|
@@ -1887,7 +3189,7 @@ AIMarkdownContent.displayName = "AIMarkdownContent";
|
|
|
1887
3189
|
var MarkdownContent_default = AIMarkdownContent;
|
|
1888
3190
|
|
|
1889
3191
|
// src/hooks/useStableValue.ts
|
|
1890
|
-
var
|
|
3192
|
+
var import_react8 = require("react");
|
|
1891
3193
|
|
|
1892
3194
|
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_setCacheAdd.js
|
|
1893
3195
|
var HASH_UNDEFINED3 = "__lodash_hash_undefined__";
|
|
@@ -2004,44 +3306,44 @@ var setToArray_default = setToArray;
|
|
|
2004
3306
|
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_equalByTag.js
|
|
2005
3307
|
var COMPARE_PARTIAL_FLAG2 = 1;
|
|
2006
3308
|
var COMPARE_UNORDERED_FLAG2 = 2;
|
|
2007
|
-
var
|
|
2008
|
-
var
|
|
2009
|
-
var
|
|
2010
|
-
var
|
|
2011
|
-
var
|
|
2012
|
-
var
|
|
2013
|
-
var
|
|
2014
|
-
var
|
|
2015
|
-
var
|
|
2016
|
-
var
|
|
2017
|
-
var
|
|
2018
|
-
var
|
|
2019
|
-
var
|
|
3309
|
+
var boolTag2 = "[object Boolean]";
|
|
3310
|
+
var dateTag2 = "[object Date]";
|
|
3311
|
+
var errorTag2 = "[object Error]";
|
|
3312
|
+
var mapTag2 = "[object Map]";
|
|
3313
|
+
var numberTag2 = "[object Number]";
|
|
3314
|
+
var regexpTag2 = "[object RegExp]";
|
|
3315
|
+
var setTag2 = "[object Set]";
|
|
3316
|
+
var stringTag2 = "[object String]";
|
|
3317
|
+
var symbolTag = "[object Symbol]";
|
|
3318
|
+
var arrayBufferTag2 = "[object ArrayBuffer]";
|
|
3319
|
+
var dataViewTag2 = "[object DataView]";
|
|
3320
|
+
var symbolProto = Symbol_default ? Symbol_default.prototype : void 0;
|
|
3321
|
+
var symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
|
|
2020
3322
|
function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
|
|
2021
3323
|
switch (tag) {
|
|
2022
|
-
case
|
|
3324
|
+
case dataViewTag2:
|
|
2023
3325
|
if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
|
|
2024
3326
|
return false;
|
|
2025
3327
|
}
|
|
2026
3328
|
object = object.buffer;
|
|
2027
3329
|
other = other.buffer;
|
|
2028
|
-
case
|
|
3330
|
+
case arrayBufferTag2:
|
|
2029
3331
|
if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array_default(object), new Uint8Array_default(other))) {
|
|
2030
3332
|
return false;
|
|
2031
3333
|
}
|
|
2032
3334
|
return true;
|
|
2033
|
-
case
|
|
2034
|
-
case
|
|
2035
|
-
case
|
|
3335
|
+
case boolTag2:
|
|
3336
|
+
case dateTag2:
|
|
3337
|
+
case numberTag2:
|
|
2036
3338
|
return eq_default(+object, +other);
|
|
2037
|
-
case
|
|
3339
|
+
case errorTag2:
|
|
2038
3340
|
return object.name == other.name && object.message == other.message;
|
|
2039
|
-
case
|
|
2040
|
-
case
|
|
3341
|
+
case regexpTag2:
|
|
3342
|
+
case stringTag2:
|
|
2041
3343
|
return object == other + "";
|
|
2042
|
-
case
|
|
3344
|
+
case mapTag2:
|
|
2043
3345
|
var convert = mapToArray_default;
|
|
2044
|
-
case
|
|
3346
|
+
case setTag2:
|
|
2045
3347
|
var isPartial = bitmask & COMPARE_PARTIAL_FLAG2;
|
|
2046
3348
|
convert || (convert = setToArray_default);
|
|
2047
3349
|
if (object.size != other.size && !isPartial) {
|
|
@@ -2056,19 +3358,103 @@ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
|
|
|
2056
3358
|
var result = equalArrays_default(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
|
|
2057
3359
|
stack["delete"](object);
|
|
2058
3360
|
return result;
|
|
2059
|
-
case
|
|
2060
|
-
if (
|
|
2061
|
-
return
|
|
3361
|
+
case symbolTag:
|
|
3362
|
+
if (symbolValueOf) {
|
|
3363
|
+
return symbolValueOf.call(object) == symbolValueOf.call(other);
|
|
2062
3364
|
}
|
|
2063
3365
|
}
|
|
2064
3366
|
return false;
|
|
2065
3367
|
}
|
|
2066
3368
|
var equalByTag_default = equalByTag;
|
|
2067
3369
|
|
|
3370
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayPush.js
|
|
3371
|
+
function arrayPush(array, values) {
|
|
3372
|
+
var index = -1, length = values.length, offset = array.length;
|
|
3373
|
+
while (++index < length) {
|
|
3374
|
+
array[offset + index] = values[index];
|
|
3375
|
+
}
|
|
3376
|
+
return array;
|
|
3377
|
+
}
|
|
3378
|
+
var arrayPush_default = arrayPush;
|
|
3379
|
+
|
|
3380
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseGetAllKeys.js
|
|
3381
|
+
function baseGetAllKeys(object, keysFunc, symbolsFunc) {
|
|
3382
|
+
var result = keysFunc(object);
|
|
3383
|
+
return isArray_default(object) ? result : arrayPush_default(result, symbolsFunc(object));
|
|
3384
|
+
}
|
|
3385
|
+
var baseGetAllKeys_default = baseGetAllKeys;
|
|
3386
|
+
|
|
3387
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayFilter.js
|
|
3388
|
+
function arrayFilter(array, predicate) {
|
|
3389
|
+
var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
|
|
3390
|
+
while (++index < length) {
|
|
3391
|
+
var value = array[index];
|
|
3392
|
+
if (predicate(value, index, array)) {
|
|
3393
|
+
result[resIndex++] = value;
|
|
3394
|
+
}
|
|
3395
|
+
}
|
|
3396
|
+
return result;
|
|
3397
|
+
}
|
|
3398
|
+
var arrayFilter_default = arrayFilter;
|
|
3399
|
+
|
|
3400
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/stubArray.js
|
|
3401
|
+
function stubArray() {
|
|
3402
|
+
return [];
|
|
3403
|
+
}
|
|
3404
|
+
var stubArray_default = stubArray;
|
|
3405
|
+
|
|
3406
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getSymbols.js
|
|
3407
|
+
var objectProto12 = Object.prototype;
|
|
3408
|
+
var propertyIsEnumerable2 = objectProto12.propertyIsEnumerable;
|
|
3409
|
+
var nativeGetSymbols = Object.getOwnPropertySymbols;
|
|
3410
|
+
var getSymbols = !nativeGetSymbols ? stubArray_default : function(object) {
|
|
3411
|
+
if (object == null) {
|
|
3412
|
+
return [];
|
|
3413
|
+
}
|
|
3414
|
+
object = Object(object);
|
|
3415
|
+
return arrayFilter_default(nativeGetSymbols(object), function(symbol) {
|
|
3416
|
+
return propertyIsEnumerable2.call(object, symbol);
|
|
3417
|
+
});
|
|
3418
|
+
};
|
|
3419
|
+
var getSymbols_default = getSymbols;
|
|
3420
|
+
|
|
3421
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeys.js
|
|
3422
|
+
var nativeKeys = overArg_default(Object.keys, Object);
|
|
3423
|
+
var nativeKeys_default = nativeKeys;
|
|
3424
|
+
|
|
3425
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseKeys.js
|
|
3426
|
+
var objectProto13 = Object.prototype;
|
|
3427
|
+
var hasOwnProperty10 = objectProto13.hasOwnProperty;
|
|
3428
|
+
function baseKeys(object) {
|
|
3429
|
+
if (!isPrototype_default(object)) {
|
|
3430
|
+
return nativeKeys_default(object);
|
|
3431
|
+
}
|
|
3432
|
+
var result = [];
|
|
3433
|
+
for (var key in Object(object)) {
|
|
3434
|
+
if (hasOwnProperty10.call(object, key) && key != "constructor") {
|
|
3435
|
+
result.push(key);
|
|
3436
|
+
}
|
|
3437
|
+
}
|
|
3438
|
+
return result;
|
|
3439
|
+
}
|
|
3440
|
+
var baseKeys_default = baseKeys;
|
|
3441
|
+
|
|
3442
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/keys.js
|
|
3443
|
+
function keys(object) {
|
|
3444
|
+
return isArrayLike_default(object) ? arrayLikeKeys_default(object) : baseKeys_default(object);
|
|
3445
|
+
}
|
|
3446
|
+
var keys_default = keys;
|
|
3447
|
+
|
|
3448
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeys.js
|
|
3449
|
+
function getAllKeys(object) {
|
|
3450
|
+
return baseGetAllKeys_default(object, keys_default, getSymbols_default);
|
|
3451
|
+
}
|
|
3452
|
+
var getAllKeys_default = getAllKeys;
|
|
3453
|
+
|
|
2068
3454
|
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_equalObjects.js
|
|
2069
3455
|
var COMPARE_PARTIAL_FLAG3 = 1;
|
|
2070
|
-
var
|
|
2071
|
-
var
|
|
3456
|
+
var objectProto14 = Object.prototype;
|
|
3457
|
+
var hasOwnProperty11 = objectProto14.hasOwnProperty;
|
|
2072
3458
|
function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
|
|
2073
3459
|
var isPartial = bitmask & COMPARE_PARTIAL_FLAG3, objProps = getAllKeys_default(object), objLength = objProps.length, othProps = getAllKeys_default(other), othLength = othProps.length;
|
|
2074
3460
|
if (objLength != othLength && !isPartial) {
|
|
@@ -2077,7 +3463,7 @@ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
|
|
|
2077
3463
|
var index = objLength;
|
|
2078
3464
|
while (index--) {
|
|
2079
3465
|
var key = objProps[index];
|
|
2080
|
-
if (!(isPartial ? key in other :
|
|
3466
|
+
if (!(isPartial ? key in other : hasOwnProperty11.call(other, key))) {
|
|
2081
3467
|
return false;
|
|
2082
3468
|
}
|
|
2083
3469
|
}
|
|
@@ -2114,18 +3500,69 @@ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
|
|
|
2114
3500
|
}
|
|
2115
3501
|
var equalObjects_default = equalObjects;
|
|
2116
3502
|
|
|
3503
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_DataView.js
|
|
3504
|
+
var DataView = getNative_default(root_default, "DataView");
|
|
3505
|
+
var DataView_default = DataView;
|
|
3506
|
+
|
|
3507
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_Promise.js
|
|
3508
|
+
var Promise2 = getNative_default(root_default, "Promise");
|
|
3509
|
+
var Promise_default = Promise2;
|
|
3510
|
+
|
|
3511
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_Set.js
|
|
3512
|
+
var Set2 = getNative_default(root_default, "Set");
|
|
3513
|
+
var Set_default = Set2;
|
|
3514
|
+
|
|
3515
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_WeakMap.js
|
|
3516
|
+
var WeakMap = getNative_default(root_default, "WeakMap");
|
|
3517
|
+
var WeakMap_default = WeakMap;
|
|
3518
|
+
|
|
3519
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getTag.js
|
|
3520
|
+
var mapTag3 = "[object Map]";
|
|
3521
|
+
var objectTag3 = "[object Object]";
|
|
3522
|
+
var promiseTag = "[object Promise]";
|
|
3523
|
+
var setTag3 = "[object Set]";
|
|
3524
|
+
var weakMapTag2 = "[object WeakMap]";
|
|
3525
|
+
var dataViewTag3 = "[object DataView]";
|
|
3526
|
+
var dataViewCtorString = toSource_default(DataView_default);
|
|
3527
|
+
var mapCtorString = toSource_default(Map_default);
|
|
3528
|
+
var promiseCtorString = toSource_default(Promise_default);
|
|
3529
|
+
var setCtorString = toSource_default(Set_default);
|
|
3530
|
+
var weakMapCtorString = toSource_default(WeakMap_default);
|
|
3531
|
+
var getTag = baseGetTag_default;
|
|
3532
|
+
if (DataView_default && getTag(new DataView_default(new ArrayBuffer(1))) != dataViewTag3 || Map_default && getTag(new Map_default()) != mapTag3 || Promise_default && getTag(Promise_default.resolve()) != promiseTag || Set_default && getTag(new Set_default()) != setTag3 || WeakMap_default && getTag(new WeakMap_default()) != weakMapTag2) {
|
|
3533
|
+
getTag = function(value) {
|
|
3534
|
+
var result = baseGetTag_default(value), Ctor = result == objectTag3 ? value.constructor : void 0, ctorString = Ctor ? toSource_default(Ctor) : "";
|
|
3535
|
+
if (ctorString) {
|
|
3536
|
+
switch (ctorString) {
|
|
3537
|
+
case dataViewCtorString:
|
|
3538
|
+
return dataViewTag3;
|
|
3539
|
+
case mapCtorString:
|
|
3540
|
+
return mapTag3;
|
|
3541
|
+
case promiseCtorString:
|
|
3542
|
+
return promiseTag;
|
|
3543
|
+
case setCtorString:
|
|
3544
|
+
return setTag3;
|
|
3545
|
+
case weakMapCtorString:
|
|
3546
|
+
return weakMapTag2;
|
|
3547
|
+
}
|
|
3548
|
+
}
|
|
3549
|
+
return result;
|
|
3550
|
+
};
|
|
3551
|
+
}
|
|
3552
|
+
var getTag_default = getTag;
|
|
3553
|
+
|
|
2117
3554
|
// ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsEqualDeep.js
|
|
2118
3555
|
var COMPARE_PARTIAL_FLAG4 = 1;
|
|
2119
|
-
var
|
|
2120
|
-
var
|
|
2121
|
-
var
|
|
2122
|
-
var
|
|
2123
|
-
var
|
|
3556
|
+
var argsTag3 = "[object Arguments]";
|
|
3557
|
+
var arrayTag2 = "[object Array]";
|
|
3558
|
+
var objectTag4 = "[object Object]";
|
|
3559
|
+
var objectProto15 = Object.prototype;
|
|
3560
|
+
var hasOwnProperty12 = objectProto15.hasOwnProperty;
|
|
2124
3561
|
function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
|
|
2125
|
-
var objIsArr = isArray_default(object), othIsArr = isArray_default(other), objTag = objIsArr ?
|
|
2126
|
-
objTag = objTag ==
|
|
2127
|
-
othTag = othTag ==
|
|
2128
|
-
var objIsObj = objTag ==
|
|
3562
|
+
var objIsArr = isArray_default(object), othIsArr = isArray_default(other), objTag = objIsArr ? arrayTag2 : getTag_default(object), othTag = othIsArr ? arrayTag2 : getTag_default(other);
|
|
3563
|
+
objTag = objTag == argsTag3 ? objectTag4 : objTag;
|
|
3564
|
+
othTag = othTag == argsTag3 ? objectTag4 : othTag;
|
|
3565
|
+
var objIsObj = objTag == objectTag4, othIsObj = othTag == objectTag4, isSameTag = objTag == othTag;
|
|
2129
3566
|
if (isSameTag && isBuffer_default(object)) {
|
|
2130
3567
|
if (!isBuffer_default(other)) {
|
|
2131
3568
|
return false;
|
|
@@ -2138,7 +3575,7 @@ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
|
|
|
2138
3575
|
return objIsArr || isTypedArray_default(object) ? equalArrays_default(object, other, bitmask, customizer, equalFunc, stack) : equalByTag_default(object, other, objTag, bitmask, customizer, equalFunc, stack);
|
|
2139
3576
|
}
|
|
2140
3577
|
if (!(bitmask & COMPARE_PARTIAL_FLAG4)) {
|
|
2141
|
-
var objIsWrapped = objIsObj &&
|
|
3578
|
+
var objIsWrapped = objIsObj && hasOwnProperty12.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty12.call(other, "__wrapped__");
|
|
2142
3579
|
if (objIsWrapped || othIsWrapped) {
|
|
2143
3580
|
var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
|
|
2144
3581
|
stack || (stack = new Stack_default());
|
|
@@ -2172,32 +3609,33 @@ function isEqual(value, other) {
|
|
|
2172
3609
|
var isEqual_default = isEqual;
|
|
2173
3610
|
|
|
2174
3611
|
// src/hooks/useStableValue.ts
|
|
3612
|
+
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_react8.useLayoutEffect : import_react8.useEffect;
|
|
2175
3613
|
function useStableValue(value) {
|
|
2176
|
-
const ref = (0,
|
|
3614
|
+
const ref = (0, import_react8.useRef)(value);
|
|
2177
3615
|
const prev = ref.current;
|
|
2178
3616
|
const stableValue = isEqual_default(prev, value) ? prev : value;
|
|
2179
|
-
(
|
|
3617
|
+
useIsomorphicLayoutEffect(() => {
|
|
2180
3618
|
ref.current = stableValue;
|
|
2181
3619
|
}, [stableValue]);
|
|
2182
3620
|
return stableValue;
|
|
2183
3621
|
}
|
|
2184
3622
|
|
|
2185
3623
|
// src/components/typography/Default.tsx
|
|
2186
|
-
var
|
|
2187
|
-
var
|
|
2188
|
-
var DefaultTypography = (0,
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
}
|
|
2195
|
-
)
|
|
3624
|
+
var import_react9 = require("react");
|
|
3625
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3626
|
+
var DefaultTypography = (0, import_react9.memo)(({ children, fontSize, variant, colorScheme, style }) => {
|
|
3627
|
+
const className = (0, import_react9.useMemo)(
|
|
3628
|
+
() => ["aim-typography-root", variant, colorScheme].filter(Boolean).join(" "),
|
|
3629
|
+
[variant, colorScheme]
|
|
3630
|
+
);
|
|
3631
|
+
const mergedStyle = (0, import_react9.useMemo)(() => ({ width: "100%", fontSize, ...style }), [fontSize, style]);
|
|
3632
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className, style: mergedStyle, children });
|
|
3633
|
+
});
|
|
2196
3634
|
DefaultTypography.displayName = "DefaultTypography";
|
|
2197
3635
|
var Default_default = DefaultTypography;
|
|
2198
3636
|
|
|
2199
3637
|
// src/index.tsx
|
|
2200
|
-
var
|
|
3638
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
2201
3639
|
var AIMarkdownComponent = ({
|
|
2202
3640
|
streaming = false,
|
|
2203
3641
|
content,
|
|
@@ -2210,49 +3648,56 @@ var AIMarkdownComponent = ({
|
|
|
2210
3648
|
Typography = Default_default,
|
|
2211
3649
|
ExtraStyles,
|
|
2212
3650
|
variant = "default",
|
|
2213
|
-
colorScheme = "light"
|
|
3651
|
+
colorScheme = "light",
|
|
3652
|
+
documentId
|
|
2214
3653
|
}) => {
|
|
2215
|
-
const usedFontSize = fontSize ? typeof fontSize === "number" ? `${fontSize}px` : fontSize
|
|
3654
|
+
const usedFontSize = fontSize === void 0 ? "0.9375rem" : typeof fontSize === "number" ? `${fontSize}px` : fontSize;
|
|
3655
|
+
const generatedId = (0, import_react10.useId)();
|
|
3656
|
+
const usedDocumentId = documentId && documentId.length > 0 ? documentId : generatedId;
|
|
2216
3657
|
const stableDefaultConfig = useStableValue(defaultConfig);
|
|
2217
3658
|
const stableConfig = useStableValue(config);
|
|
2218
3659
|
const stablePreprocessors = useStableValue(contentPreprocessors);
|
|
2219
3660
|
const stableCustomComponents = useStableValue(customComponents);
|
|
2220
|
-
const usedContent = (0,
|
|
3661
|
+
const usedContent = (0, import_react10.useMemo)(
|
|
2221
3662
|
() => content ? preprocessAIMDContent(content, stablePreprocessors) : content,
|
|
2222
3663
|
[content, stablePreprocessors]
|
|
2223
3664
|
);
|
|
2224
|
-
|
|
3665
|
+
const typographyStyle = (0, import_react10.useMemo)(() => ({ "--aim-font-size-root": usedFontSize }), [usedFontSize]);
|
|
3666
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AIMarkdownMetadataProvider, { metadata, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2225
3667
|
context_default,
|
|
2226
3668
|
{
|
|
2227
3669
|
streaming,
|
|
2228
3670
|
fontSize: usedFontSize,
|
|
2229
3671
|
variant,
|
|
2230
3672
|
colorScheme,
|
|
3673
|
+
documentId: usedDocumentId,
|
|
2231
3674
|
defaultConfig: stableDefaultConfig,
|
|
2232
3675
|
config: stableConfig,
|
|
2233
|
-
children: /* @__PURE__ */ (0,
|
|
3676
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2234
3677
|
Typography,
|
|
2235
3678
|
{
|
|
2236
3679
|
fontSize: usedFontSize,
|
|
2237
3680
|
variant,
|
|
2238
3681
|
colorScheme,
|
|
2239
|
-
style:
|
|
2240
|
-
children: ExtraStyles ? /* @__PURE__ */ (0,
|
|
3682
|
+
style: typographyStyle,
|
|
3683
|
+
children: ExtraStyles ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ExtraStyles, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(MarkdownContent_default, { content: usedContent, customComponents: stableCustomComponents }) }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(MarkdownContent_default, { content: usedContent, customComponents: stableCustomComponents })
|
|
2241
3684
|
}
|
|
2242
3685
|
)
|
|
2243
3686
|
}
|
|
2244
3687
|
) });
|
|
2245
3688
|
};
|
|
2246
|
-
var AIMarkdown = (0,
|
|
3689
|
+
var AIMarkdown = (0, import_react10.memo)(AIMarkdownComponent);
|
|
2247
3690
|
AIMarkdown.displayName = "AIMarkdown";
|
|
2248
3691
|
var index_default = AIMarkdown;
|
|
2249
3692
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2250
3693
|
0 && (module.exports = {
|
|
3694
|
+
AIMarkdownDocuments,
|
|
2251
3695
|
AIMarkdownRenderDisplayOptimizeAbility,
|
|
2252
3696
|
AIMarkdownRenderExtraSyntax,
|
|
2253
3697
|
defaultAIMarkdownRenderConfig,
|
|
2254
3698
|
useAIMarkdownMetadata,
|
|
2255
3699
|
useAIMarkdownRenderState,
|
|
3700
|
+
useDocumentRegistry,
|
|
2256
3701
|
useStableValue
|
|
2257
3702
|
});
|
|
2258
3703
|
//# sourceMappingURL=index.cjs.map
|